|
1 |
| -package io.github.a5h73y.controllers; |
| 1 | +package io.github.a5h73y.carz.controllers; |
2 | 2 |
|
3 | 3 | import java.util.HashMap;
|
4 | 4 | import java.util.Map;
|
5 | 5 | import java.util.Set;
|
6 | 6 |
|
7 |
| -import io.github.a5h73y.Carz; |
8 |
| -import io.github.a5h73y.enums.Permissions; |
9 |
| -import io.github.a5h73y.model.Car; |
10 |
| -import io.github.a5h73y.model.CarDetails; |
11 |
| -import io.github.a5h73y.other.AbstractPluginReceiver; |
12 |
| -import io.github.a5h73y.utility.CarUtils; |
13 |
| -import io.github.a5h73y.utility.EffectUtils; |
14 |
| -import io.github.a5h73y.utility.PermissionUtils; |
15 |
| -import io.github.a5h73y.utility.TranslationUtils; |
| 7 | +import io.github.a5h73y.carz.Carz; |
| 8 | +import io.github.a5h73y.carz.enums.Permissions; |
| 9 | +import io.github.a5h73y.carz.enums.VehicleDetailKey; |
| 10 | +import io.github.a5h73y.carz.model.Car; |
| 11 | +import io.github.a5h73y.carz.model.CarDetails; |
| 12 | +import io.github.a5h73y.carz.other.AbstractPluginReceiver; |
| 13 | +import io.github.a5h73y.carz.utility.CarUtils; |
| 14 | +import io.github.a5h73y.carz.utility.EffectUtils; |
| 15 | +import io.github.a5h73y.carz.utility.PermissionUtils; |
| 16 | +import io.github.a5h73y.carz.utility.TranslationUtils; |
16 | 17 | import org.bukkit.Effect;
|
17 | 18 | import org.bukkit.entity.Minecart;
|
18 | 19 | import org.bukkit.entity.Player;
|
19 | 20 | import org.bukkit.entity.Vehicle;
|
20 | 21 |
|
21 |
| -import static io.github.a5h73y.enums.VehicleDetailKey.VEHICLE_FUEL; |
22 |
| -import static io.github.a5h73y.enums.VehicleDetailKey.VEHICLE_OWNER; |
23 |
| -import static io.github.a5h73y.enums.VehicleDetailKey.VEHICLE_SPEED; |
24 |
| -import static io.github.a5h73y.enums.VehicleDetailKey.VEHICLE_TYPE; |
25 |
| - |
26 | 22 | /**
|
27 | 23 | * All Car related functionality.
|
28 | 24 | */
|
@@ -65,14 +61,14 @@ public void populateCarTypes() {
|
65 | 61 | * @param vehicle vehicle the player is driving
|
66 | 62 | */
|
67 | 63 | public void startDriving(String playerName, Vehicle vehicle) {
|
68 |
| - String carType = carz.getItemMetaUtils().getValue(VEHICLE_TYPE, vehicle); |
| 64 | + String carType = carz.getItemMetaUtils().getValue(VehicleDetailKey.VEHICLE_TYPE, vehicle); |
69 | 65 | Car car = getOrCreateCar(vehicle.getEntityId(), carType);
|
70 | 66 |
|
71 |
| - if (carz.getItemMetaUtils().has(VEHICLE_SPEED, vehicle)) { |
72 |
| - car.setMaxSpeed(Double.parseDouble(carz.getItemMetaUtils().getValue(VEHICLE_SPEED, vehicle))); |
| 67 | + if (carz.getItemMetaUtils().has(VehicleDetailKey.VEHICLE_SPEED, vehicle)) { |
| 68 | + car.setMaxSpeed(Double.parseDouble(carz.getItemMetaUtils().getValue(VehicleDetailKey.VEHICLE_SPEED, vehicle))); |
73 | 69 | }
|
74 |
| - if (carz.getItemMetaUtils().has(VEHICLE_FUEL, vehicle)) { |
75 |
| - car.setCurrentFuel(Double.parseDouble(carz.getItemMetaUtils().getValue(VEHICLE_FUEL, vehicle))); |
| 70 | + if (carz.getItemMetaUtils().has(VehicleDetailKey.VEHICLE_FUEL, vehicle)) { |
| 71 | + car.setCurrentFuel(Double.parseDouble(carz.getItemMetaUtils().getValue(VehicleDetailKey.VEHICLE_FUEL, vehicle))); |
76 | 72 | }
|
77 | 73 |
|
78 | 74 | playersDriving.put(playerName, car.getEntityId());
|
@@ -173,7 +169,7 @@ public void stashCar(Player player, Vehicle vehicle) {
|
173 | 169 | return;
|
174 | 170 | }
|
175 | 171 |
|
176 |
| - String owner = carz.getItemMetaUtils().getValue(VEHICLE_OWNER, vehicle); |
| 172 | + String owner = carz.getItemMetaUtils().getValue(VehicleDetailKey.VEHICLE_OWNER, vehicle); |
177 | 173 |
|
178 | 174 | if (!player.getName().equals(owner) && !PermissionUtils.hasStrictPermission(player, Permissions.ADMIN)) {
|
179 | 175 | return;
|
@@ -219,7 +215,7 @@ private void upgradeCarSpeed(Vehicle vehicle) {
|
219 | 215 | }
|
220 | 216 |
|
221 | 217 | car.setMaxSpeed(currentMax + upgradeAmount);
|
222 |
| - carz.getItemMetaUtils().setValue(VEHICLE_SPEED, vehicle, String.valueOf(car.getMaxSpeed())); |
| 218 | + carz.getItemMetaUtils().setValue(VehicleDetailKey.VEHICLE_SPEED, vehicle, String.valueOf(car.getMaxSpeed())); |
223 | 219 | }
|
224 | 220 |
|
225 | 221 | public Map<String, CarDetails> getCarTypes() {
|
|
0 commit comments