Complete the boats feature
This commit is contained in:
@@ -52,7 +52,7 @@ public class Features implements Listener {
|
|||||||
|
|
||||||
private final HashMap<Player, ArrayList<Feature>> playerFeatures = new HashMap<>();
|
private final HashMap<Player, ArrayList<Feature>> playerFeatures = new HashMap<>();
|
||||||
private final HashMap<Player, Boolean> canDoubleJump = new HashMap<>();
|
private final HashMap<Player, Boolean> canDoubleJump = new HashMap<>();
|
||||||
private final HashMap<Player, HashMap<Feature, Boolean>> featureEnabled = new HashMap<>();
|
public final HashMap<Player, HashMap<Feature, Boolean>> featureEnabled = new HashMap<>();
|
||||||
public static ArrayList<UUID> wantFlight = new ArrayList<>();
|
public static ArrayList<UUID> wantFlight = new ArrayList<>();
|
||||||
|
|
||||||
public void updateFeatures(Player P) {
|
public void updateFeatures(Player P) {
|
||||||
@@ -72,7 +72,7 @@ public class Features implements Listener {
|
|||||||
}
|
}
|
||||||
if (Feature.getById(rs.getInt("featureId")) != null) {
|
if (Feature.getById(rs.getInt("featureId")) != null) {
|
||||||
this.addFeature(P, Feature.getById(rs.getInt("featureId")));
|
this.addFeature(P, Feature.getById(rs.getInt("featureId")));
|
||||||
featureEnabled.get(P).put(Feature.DOUBLE_JUMP, true);
|
featureEnabled.get(P).put(Feature.getById(rs.getInt("featureId")), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
@@ -111,6 +111,12 @@ public class Features implements Listener {
|
|||||||
if (P.getGameMode() != GameMode.CREATIVE) {
|
if (P.getGameMode() != GameMode.CREATIVE) {
|
||||||
P.setAllowFlight(false);
|
P.setAllowFlight(false);
|
||||||
}
|
}
|
||||||
|
} else if (f == Feature.BOAT) {
|
||||||
|
if (!hasFeature(P, f)) {
|
||||||
|
Core.statusMsg(P, "dont_have_boats", false);
|
||||||
|
}
|
||||||
|
featureEnabled.get(P).put(f, false);
|
||||||
|
Core.statusMsg(P, "boat_off", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,6 +134,12 @@ public class Features implements Listener {
|
|||||||
P.setExp(1);
|
P.setExp(1);
|
||||||
canDoubleJump.put(P, true);
|
canDoubleJump.put(P, true);
|
||||||
Core.statusMsg(P, "dbl_jump_on", true);
|
Core.statusMsg(P, "dbl_jump_on", true);
|
||||||
|
} else if (f == Feature.BOAT) {
|
||||||
|
if (!hasFeature(P, f)) {
|
||||||
|
Core.statusMsg(P, "dont_have_boats", false);
|
||||||
|
}
|
||||||
|
featureEnabled.get(P).put(f, true);
|
||||||
|
Core.statusMsg(P, "boat_on", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,9 +209,11 @@ public class Features implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (P.getLocation().getBlock().getType().equals(Material.STATIONARY_WATER) && P.getVehicle() == null && P.getVehicle().getType().equals(EntityType.BOAT)) {
|
if (this.hasFeature(P, Feature.BOAT) && featureEnabled.get(P).get(Feature.BOAT)) {
|
||||||
Boat b = (Boat) P.getWorld().spawnEntity(event.getTo(), EntityType.BOAT);
|
if (P.getLocation().getBlock().getType().equals(Material.STATIONARY_WATER) && P.getVehicle() == null) {
|
||||||
b.setPassenger(P);
|
Boat b = (Boat) P.getWorld().spawnEntity(event.getTo(), EntityType.BOAT);
|
||||||
|
b.setPassenger(P);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -213,6 +213,8 @@ public class Setup {
|
|||||||
Core.getMainClass().getCommand("leaveminigame").setExecutor(pc);
|
Core.getMainClass().getCommand("leaveminigame").setExecutor(pc);
|
||||||
Core.getMainClass().getCommand("toggleminigame").setExecutor(pc);
|
Core.getMainClass().getCommand("toggleminigame").setExecutor(pc);
|
||||||
Core.getMainClass().getCommand("addAimTWWin").setExecutor(oc);
|
Core.getMainClass().getCommand("addAimTWWin").setExecutor(oc);
|
||||||
|
Core.getMainClass().getCommand("toggleboat").setExecutor(pc);
|
||||||
|
Core.getMainClass().getCommand("toggleboatflight").setExecutor(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setupInventories() {
|
private static void setupInventories() {
|
||||||
@@ -253,7 +255,9 @@ public class Setup {
|
|||||||
|
|
||||||
Inventories.registerInventory("FEATURES", "features_inv", ChatColor.DARK_BLUE);
|
Inventories.registerInventory("FEATURES", "features_inv", ChatColor.DARK_BLUE);
|
||||||
Inventories.putIntoInventory("FEATURES", 2, Inventories.buildItems(Material.LEATHER_BOOTS, "inv_lobby_double_jump", ChatColor.DARK_AQUA));
|
Inventories.putIntoInventory("FEATURES", 2, Inventories.buildItems(Material.LEATHER_BOOTS, "inv_lobby_double_jump", ChatColor.DARK_AQUA));
|
||||||
|
Inventories.putIntoInventory("FEATURES", 4, Inventories.buildItems(Material.BOAT, "inv_lobby_boat", ChatColor.DARK_AQUA));
|
||||||
Inventories.registerAction("FEATURES", 2, Inventories.Action.COMMAND, "toggledbljump");
|
Inventories.registerAction("FEATURES", 2, Inventories.Action.COMMAND, "toggledbljump");
|
||||||
|
Inventories.registerAction("FEATURES", 4, Inventories.Action.COMMAND, "toggleboat");
|
||||||
|
|
||||||
Inventories.registerInventory("LANGUAGE", "Select language", ChatColor.DARK_BLUE);
|
Inventories.registerInventory("LANGUAGE", "Select language", ChatColor.DARK_BLUE);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|||||||
@@ -37,6 +37,17 @@ public class PlayerCommands implements CommandExecutor {
|
|||||||
Core.getMainClass().getFeatures().enableFeature(P, Features.Feature.DOUBLE_JUMP);
|
Core.getMainClass().getFeatures().enableFeature(P, Features.Feature.DOUBLE_JUMP);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
} else if (cmd.getName().equalsIgnoreCase("toggleboat")) {
|
||||||
|
if (P == null) {
|
||||||
|
Core.statusMsg(sender, "only_player_cmd", false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (Core.getMainClass().getFeatures().featureEnabled.get(P).get(Features.Feature.BOAT)) {
|
||||||
|
Core.getMainClass().getFeatures().disableFeature(P, Features.Feature.BOAT);
|
||||||
|
} else {
|
||||||
|
Core.getMainClass().getFeatures().enableFeature(P, Features.Feature.BOAT);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
} else if (cmd.getName().equalsIgnoreCase("joinminigame")) {
|
} else if (cmd.getName().equalsIgnoreCase("joinminigame")) {
|
||||||
if (P == null) {
|
if (P == null) {
|
||||||
Core.statusMsg(sender, "only_player_cmd", false);
|
Core.statusMsg(sender, "only_player_cmd", false);
|
||||||
|
|||||||
@@ -327,6 +327,7 @@ public class TeamCommands implements CommandExecutor {
|
|||||||
Features.wantFlight.add(P.getUniqueId());
|
Features.wantFlight.add(P.getUniqueId());
|
||||||
P.sendMessage("Du wurdest zu der Liste hinzugefügt!");
|
P.sendMessage("Du wurdest zu der Liste hinzugefügt!");
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Core.statusMsg(P, "no_perms", false);
|
Core.statusMsg(P, "no_perms", false);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -84,4 +84,7 @@ commands:
|
|||||||
usage: /<command> <username>
|
usage: /<command> <username>
|
||||||
toggleBoatFlight:
|
toggleBoatFlight:
|
||||||
description: Toggles if you automatic flight when you escape a boat (only in gamemode 1)
|
description: Toggles if you automatic flight when you escape a boat (only in gamemode 1)
|
||||||
|
usage: /<command>
|
||||||
|
toggleboat:
|
||||||
|
description: Enables/Disables the boat feature
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
Reference in New Issue
Block a user