Merge origin/master
This commit is contained in:
@@ -164,6 +164,7 @@ public class AnuraCore extends JavaPlugin implements PluginMessageListener {
|
||||
|
||||
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.registerAction("FEATURES", 2, Inventories.Action.COMMAND, "toggledbljump");
|
||||
|
||||
Inventories.registerInventory("LANGUAGE", "Select language", ChatColor.DARK_BLUE);
|
||||
int i = 0;
|
||||
@@ -177,7 +178,8 @@ public class AnuraCore extends JavaPlugin implements PluginMessageListener {
|
||||
Inventories.buildInvItem("COMPASS", Material.COMPASS, "select_game", ChatColor.DARK_AQUA);
|
||||
Inventories.buildInvItem("SIGN", Material.SIGN, "Change language", ChatColor.DARK_GREEN);
|
||||
Inventories.buildInvItem("PAPER", Material.PAPER, "features_item", ChatColor.BLUE);
|
||||
Inventories.buildInvItem("DOOR", Material.WOOD_DOOR, "to_spawn", ChatColor.YELLOW);
|
||||
Inventories.buildInvItem("DOOR", Material.WOOD_DOOR, "to_to_spawn", ChatColor.YELLOW);
|
||||
Inventories.buildInvItem("EYE", Material.EYE_OF_ENDER, "inv_to_lobby", ChatColor.YELLOW);
|
||||
if (getConfig().getString("server-name").equals("lobby")) {
|
||||
Inventories.setItemInPlayerInv("COMPASS", 0);
|
||||
Inventories.setItemInPlayerInv("SIGN", 1);
|
||||
@@ -188,6 +190,7 @@ public class AnuraCore extends JavaPlugin implements PluginMessageListener {
|
||||
Inventories.registerItemAction("SIGN", Inventories.Action.OPEN_INV, "LANGUAGE");
|
||||
Inventories.registerItemAction("PAPER", Inventories.Action.OPEN_INV, "FEATURES");
|
||||
Inventories.registerItemAction("DOOR", Inventories.Action.COMMAND, "spawn");
|
||||
Inventories.registerItemAction("EYE", Inventories.Action.SERVER, "lobby");
|
||||
|
||||
this.pots = new FlowerPots();
|
||||
ResultSet rs = sql.querySelect("SELECT id, X, Y, Z, world, type, waitTime FROM corePots");
|
||||
@@ -324,6 +327,18 @@ public class AnuraCore extends JavaPlugin implements PluginMessageListener {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if(cmd.getName().equalsIgnoreCase("toggledbljump")) {
|
||||
if(!(sender instanceof Player)) {
|
||||
API.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
if (P.getAllowFlight()) {
|
||||
features.disableFeature(P, Features.Feature.DOUBLE_JUMP);
|
||||
} else {
|
||||
features.enableFeature(P, Features.Feature.DOUBLE_JUMP);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if(cmd.getName().equalsIgnoreCase("updatecommandblocks"))
|
||||
{
|
||||
if(!(sender instanceof BlockCommandSender))
|
||||
|
||||
@@ -42,6 +42,7 @@ public class Features implements Listener {
|
||||
|
||||
private final HashMap<Player, ArrayList<Feature>> playerFeatures = new HashMap<>();
|
||||
private final HashMap<Player, Boolean> canDoubleJump = new HashMap<>();
|
||||
private final HashMap<Player, HashMap<Feature, Boolean>> featureEnabled = new HashMap<>();
|
||||
|
||||
public void updateFeatures(Player P)
|
||||
{
|
||||
@@ -50,11 +51,13 @@ public class Features implements Listener {
|
||||
ResultSet rs = API.getMySql().querySelect("SELECT featureId FROM coreFeatures WHERE playerId = (SELECT id FROM players WHERE uuid = '"+P.getUniqueId().toString()+"')");
|
||||
resetPlayerFeatures(P);
|
||||
playerFeatures.put(P, new ArrayList<Feature>());
|
||||
featureEnabled.put(P, new HashMap<Feature, Boolean>());
|
||||
while(rs.next())
|
||||
{
|
||||
if(Feature.getById(rs.getInt("featureId")) != null)
|
||||
{
|
||||
this.addFeature(P, Feature.getById(rs.getInt("featureId")));
|
||||
featureEnabled.get(P).put(Feature.DOUBLE_JUMP, true);
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
@@ -78,6 +81,36 @@ public class Features implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public void disableFeature(Player P, Feature f) {
|
||||
if(!mainLobby()) return;
|
||||
if (f == Feature.DOUBLE_JUMP) {
|
||||
if (!hasFeature(P, f)) {
|
||||
API.statusMsg(P, "dont_have_dbl_jump", false);
|
||||
return;
|
||||
}
|
||||
featureEnabled.get(P).put(f, false);
|
||||
canDoubleJump.put(P, false);
|
||||
API.statusMsg(P, "dbl_jump_off", true);
|
||||
if (P.getGameMode() != GameMode.CREATIVE) {
|
||||
P.setAllowFlight(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void enableFeature(Player P, Feature f) {
|
||||
if(!mainLobby()) return;
|
||||
if (f == Feature.DOUBLE_JUMP) {
|
||||
if (!hasFeature(P, f)) {
|
||||
API.statusMsg(P, "dont_have_dbl_jump", false);
|
||||
return;
|
||||
}
|
||||
featureEnabled.get(P).put(f, true);
|
||||
P.setAllowFlight(true);
|
||||
canDoubleJump.put(P, true);
|
||||
API.statusMsg(P, "dbl_jump_on", true);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasFeature(Player P, Feature f)
|
||||
{
|
||||
if(!mainLobby()) return false;
|
||||
|
||||
@@ -43,6 +43,7 @@ public class Inventories implements Listener {
|
||||
private static final HashMap<String, HashMap<String, ItemStack>> items = new HashMap<>();
|
||||
private static final HashMap<String, Entry<Action, Object>> itemActions = new HashMap<>();
|
||||
private static final HashMap<String, Integer> itemPositions = new HashMap<>();
|
||||
public static final HashMap<Player, Boolean> checkInteracts = new HashMap<>();
|
||||
|
||||
public static void registerInventory(String type, String name, ChatColor nameColor) {
|
||||
HashMap<String, Inventory> langInvs = new HashMap<>();
|
||||
@@ -174,6 +175,7 @@ public class Inventories implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInvClick(InventoryClickEvent event) {
|
||||
if (checkInteracts.containsKey((Player)event.getWhoClicked()) && !checkInteracts.get((Player)event.getWhoClicked())) return;
|
||||
final Player player = (Player) event.getWhoClicked();
|
||||
Inventory inventory = event.getClickedInventory();
|
||||
String invName = inventory.getName();
|
||||
@@ -204,6 +206,7 @@ public class Inventories implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (checkInteracts.containsKey((Player)event.getPlayer()) && !checkInteracts.get((Player)event.getPlayer())) return;
|
||||
if (event.hasItem()) {
|
||||
if (event.getAction().equals(org.bukkit.event.block.Action.RIGHT_CLICK_AIR) || event.getAction().equals(org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK)) {
|
||||
final Player P = event.getPlayer();
|
||||
|
||||
@@ -69,4 +69,7 @@ commands:
|
||||
usage: /<command> <player> <enable|disable>
|
||||
updatecommandblocks:
|
||||
description: Updates command blocks at the given positions
|
||||
usage: /<command> {<x1>, <y1>, <z1>}...
|
||||
usage: /<command> {<x1>, <y1>, <z1>}...
|
||||
toggledbljump:
|
||||
description: Toggles the double jump
|
||||
usage: /<command>
|
||||
Reference in New Issue
Block a user