From f4bd3d579a14ebada6b7bf6dade8de37edffb2c3 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Mon, 28 Dec 2015 22:54:11 +0100 Subject: [PATCH] Minor code changes --- .../github/dre2n/dungeonsxl/DungeonsXL.java | 16 +- .../dre2n/dungeonsxl/command/ChatCommand.java | 2 +- .../dungeonsxl/command/CreateCommand.java | 2 +- .../dre2n/dungeonsxl/command/DCommands.java | 22 +- .../command/DeletePortalCommand.java | 11 +- .../dre2n/dungeonsxl/command/EditCommand.java | 24 +- .../dungeonsxl/command/EscapeCommand.java | 22 +- .../dungeonsxl/command/LeaveCommand.java | 16 +- .../dre2n/dungeonsxl/command/ListCommand.java | 2 +- .../dungeonsxl/command/LivesCommand.java | 4 +- .../dre2n/dungeonsxl/command/PlayCommand.java | 6 +- .../dungeonsxl/command/PortalCommand.java | 16 +- .../dre2n/dungeonsxl/command/SaveCommand.java | 6 +- .../dre2n/dungeonsxl/command/TestCommand.java | 8 +- .../dungeonsxl/dungeon/DLootInventory.java | 6 +- .../dungeonsxl/dungeon/DungeonConfig.java | 2 +- .../dre2n/dungeonsxl/dungeon/EditWorld.java | 31 +- .../dre2n/dungeonsxl/dungeon/WorldConfig.java | 38 +-- .../dungeonsxl/dungeon/game/GameChest.java | 30 +- .../dungeon/game/GamePlaceableBlock.java | 26 +- .../dungeonsxl/dungeon/game/GameWorld.java | 30 +- .../dre2n/dungeonsxl/file/DMessages.java | 88 +++--- .../dre2n/dungeonsxl/global/DPortal.java | 58 ++-- .../dre2n/dungeonsxl/global/GroupSign.java | 28 +- .../dre2n/dungeonsxl/global/LeaveSign.java | 32 +-- .../dungeonsxl/listener/BlockListener.java | 10 +- .../dungeonsxl/listener/EntityListener.java | 56 ++-- .../dungeonsxl/listener/HangingListener.java | 4 +- .../dungeonsxl/listener/PlayerListener.java | 56 ++-- .../dungeonsxl/listener/WorldListener.java | 6 +- src/io/github/dre2n/dungeonsxl/mob/DMob.java | 16 +- .../github/dre2n/dungeonsxl/mob/DMobType.java | 155 +++++++++- .../dre2n/dungeonsxl/player/DClass.java | 14 +- .../dre2n/dungeonsxl/player/DGroup.java | 14 +- .../dre2n/dungeonsxl/player/DPlayer.java | 271 +++++++++--------- .../dre2n/dungeonsxl/sign/CheckpointSign.java | 6 +- .../github/dre2n/dungeonsxl/sign/DSign.java | 2 +- .../github/dre2n/dungeonsxl/sign/EndSign.java | 12 +- .../dre2n/dungeonsxl/sign/FloorSign.java | 12 +- .../dre2n/dungeonsxl/sign/LeaveSign.java | 10 +- .../github/dre2n/dungeonsxl/sign/MobSign.java | 6 +- .../dre2n/dungeonsxl/sign/MythicMobsSign.java | 2 +- .../dre2n/dungeonsxl/sign/ReadySign.java | 2 +- .../dre2n/dungeonsxl/sign/RedstoneSign.java | 2 +- .../dre2n/dungeonsxl/util/FileUtil.java | 8 +- .../dre2n/dungeonsxl/util/UUIDUtil.java | 1 + 46 files changed, 663 insertions(+), 528 deletions(-) diff --git a/src/io/github/dre2n/dungeonsxl/DungeonsXL.java b/src/io/github/dre2n/dungeonsxl/DungeonsXL.java index 97a17e9c..f23bdf2b 100644 --- a/src/io/github/dre2n/dungeonsxl/DungeonsXL.java +++ b/src/io/github/dre2n/dungeonsxl/DungeonsXL.java @@ -166,16 +166,16 @@ public class DungeonsXL extends JavaPlugin { plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override public void run() { - for (GameWorld gworld : gameWorlds) { - if (gworld.getWorld().getPlayers().isEmpty()) { - if (DPlayer.get(gworld.getWorld()).isEmpty()) { - gworld.delete(); + for (GameWorld gameWorld : gameWorlds) { + if (gameWorld.getWorld().getPlayers().isEmpty()) { + if (DPlayer.getByWorld(gameWorld.getWorld()).isEmpty()) { + gameWorld.delete(); } } } - for (EditWorld eworld : editWorlds) { - if (eworld.getWorld().getPlayers().isEmpty()) { - eworld.delete(); + for (EditWorld editWorld : editWorlds) { + if (editWorld.getWorld().getPlayers().isEmpty()) { + editWorld.delete(); } } } @@ -239,7 +239,7 @@ public class DungeonsXL extends JavaPlugin { if (dungeonFile.getName().contains(".id_")) { String dungeonName = dungeonFile.getName().substring(4); FileUtil.copyDirectory(file, new File(plugin.getDataFolder(), "/maps/" + dungeonName)); - FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + dungeonName)); + FileUtil.deleteUnusedFiles(new File(plugin.getDataFolder(), "/maps/" + dungeonName)); } } diff --git a/src/io/github/dre2n/dungeonsxl/command/ChatCommand.java b/src/io/github/dre2n/dungeonsxl/command/ChatCommand.java index 4d335419..dc86e038 100644 --- a/src/io/github/dre2n/dungeonsxl/command/ChatCommand.java +++ b/src/io/github/dre2n/dungeonsxl/command/ChatCommand.java @@ -20,7 +20,7 @@ public class ChatCommand extends DCommand { @Override public void onExecute(String[] args, CommandSender sender) { Player player = (Player) sender; - DPlayer dplayer = DPlayer.get(player); + DPlayer dplayer = DPlayer.getByPlayer(player); if (dplayer == null) { MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_IN_GROUP)); diff --git a/src/io/github/dre2n/dungeonsxl/command/CreateCommand.java b/src/io/github/dre2n/dungeonsxl/command/CreateCommand.java index 15b5e956..efded8b1 100644 --- a/src/io/github/dre2n/dungeonsxl/command/CreateCommand.java +++ b/src/io/github/dre2n/dungeonsxl/command/CreateCommand.java @@ -48,7 +48,7 @@ public class CreateCommand extends DCommand { } else if (sender instanceof Player) { Player player = (Player) sender; - if (DPlayer.get(player) != null) { + if (DPlayer.getByPlayer(player) != null) { MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON)); return; } diff --git a/src/io/github/dre2n/dungeonsxl/command/DCommands.java b/src/io/github/dre2n/dungeonsxl/command/DCommands.java index 0ccbe9d4..ff1d6d83 100644 --- a/src/io/github/dre2n/dungeonsxl/command/DCommands.java +++ b/src/io/github/dre2n/dungeonsxl/command/DCommands.java @@ -11,24 +11,24 @@ public class DCommands { public DCommands() { // Add Commands dCommands.add(new HelpCommand()); - dCommands.add(new CreateCommand()); - dCommands.add(new SaveCommand()); dCommands.add(new LeaveCommand()); - dCommands.add(new EscapeCommand()); - dCommands.add(new EditCommand()); - dCommands.add(new PortalCommand()); - dCommands.add(new DeletePortalCommand()); - dCommands.add(new MainCommand()); dCommands.add(new ChatCommand()); dCommands.add(new ChatSpyCommand()); - dCommands.add(new LivesCommand()); - dCommands.add(new ListCommand()); - dCommands.add(new UninviteCommand()); + dCommands.add(new CreateCommand()); + dCommands.add(new EditCommand()); + dCommands.add(new EscapeCommand()); dCommands.add(new InviteCommand()); + dCommands.add(new ListCommand()); + dCommands.add(new LivesCommand()); + dCommands.add(new MainCommand()); + dCommands.add(new UninviteCommand()); dCommands.add(new MsgCommand()); dCommands.add(new PlayCommand()); - dCommands.add(new TestCommand()); + dCommands.add(new PortalCommand()); + dCommands.add(new DeletePortalCommand()); dCommands.add(new ReloadCommand()); + dCommands.add(new SaveCommand()); + dCommands.add(new TestCommand()); } /** diff --git a/src/io/github/dre2n/dungeonsxl/command/DeletePortalCommand.java b/src/io/github/dre2n/dungeonsxl/command/DeletePortalCommand.java index eebcd77e..19c08771 100644 --- a/src/io/github/dre2n/dungeonsxl/command/DeletePortalCommand.java +++ b/src/io/github/dre2n/dungeonsxl/command/DeletePortalCommand.java @@ -10,28 +10,29 @@ import org.bukkit.Material; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +@Deprecated public class DeletePortalCommand extends DCommand { public DeletePortalCommand() { setCommand("deleteportal"); setMinArgs(0); setMaxArgs(0); - setHelp(dMessages.getMessage(Messages.HELP_CMD_DELETE_PORTAL)); - setPermission("dxl.deleteportal"); + setHelp("/dxl deleteportal - Deletes the portal you are looking at"); + setPermission("dxl.portal"); setPlayerCommand(true); } @Override public void onExecute(String[] args, CommandSender sender) { Player player = (Player) sender; - DPortal dPortal = DPortal.get(player.getTargetBlock((Set) null, 20).getLocation()); + DPortal dPortal = DPortal.getByLocation(player.getTargetBlock((Set) null, 20).getLocation()); if (dPortal != null) { dPortal.delete(); - MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PORTAL_DELETED)); + MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PROTECTED_BLOCK_DELETED)); } else { - MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_PORTAL)); + MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_PROTECTED_BLOCK)); } } diff --git a/src/io/github/dre2n/dungeonsxl/command/EditCommand.java b/src/io/github/dre2n/dungeonsxl/command/EditCommand.java index bc32bc48..8f8722f1 100644 --- a/src/io/github/dre2n/dungeonsxl/command/EditCommand.java +++ b/src/io/github/dre2n/dungeonsxl/command/EditCommand.java @@ -23,36 +23,36 @@ public class EditCommand extends DCommand { public void onExecute(String[] args, CommandSender sender) { Player player = (Player) sender; - String dungeonName = args[1]; - EditWorld eworld = EditWorld.load(dungeonName); - DGroup dgroup = DGroup.get(player); - DPlayer dplayer = DPlayer.get(player); + String mapName = args[1]; + EditWorld editWorld = EditWorld.load(mapName); + DGroup dGroup = DGroup.getByPlayer(player); + DPlayer dPlayer = DPlayer.getByPlayer(player); - if ( !(EditWorld.isInvitedPlayer(dungeonName, player.getUniqueId(), player.getName()) || player.hasPermission("dxl.edit"))) { + if ( !(EditWorld.isInvitedPlayer(mapName, player.getUniqueId(), player.getName()) || player.hasPermission("dxl.edit"))) { MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_PERMISSIONS)); return; } - if (dplayer != null) { + if (dPlayer != null) { MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON)); return; } - if (dgroup != null) { + if (dGroup != null) { MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_GROUP)); return; } - if (eworld == null) { - MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, dungeonName)); + if (editWorld == null) { + MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, mapName)); return; } - if (eworld.getLobby() == null) { - new DPlayer(player, eworld.getWorld(), eworld.getWorld().getSpawnLocation(), true); + if (editWorld.getLobby() == null) { + new DPlayer(player, editWorld.getWorld(), editWorld.getWorld().getSpawnLocation(), true); } else { - new DPlayer(player, eworld.getWorld(), eworld.getLobby(), true); + new DPlayer(player, editWorld.getWorld(), editWorld.getLobby(), true); } } diff --git a/src/io/github/dre2n/dungeonsxl/command/EscapeCommand.java b/src/io/github/dre2n/dungeonsxl/command/EscapeCommand.java index bb24cb5d..87312cda 100644 --- a/src/io/github/dre2n/dungeonsxl/command/EscapeCommand.java +++ b/src/io/github/dre2n/dungeonsxl/command/EscapeCommand.java @@ -22,29 +22,29 @@ public class EscapeCommand extends DCommand { @Override public void onExecute(String[] args, CommandSender sender) { Player player = (Player) sender; - DPlayer dplayer = DPlayer.get(player); - if (dplayer != null) { + DPlayer dPlayer = DPlayer.getByPlayer(player); + if (dPlayer != null) { - if ( !dplayer.isEditing()) { + if ( !dPlayer.isEditing()) { MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON)); return; } - dplayer.escape(); + dPlayer.escape(); - EditWorld eworld = EditWorld.get(dplayer.getWorld()); - if (eworld == null) { + EditWorld editWorld = EditWorld.get(dPlayer.getWorld()); + if (editWorld == null) { return; } - if (eworld.getWorld().getPlayers().isEmpty()) { - eworld.deleteNoSave(); + if (editWorld.getWorld().getPlayers().isEmpty()) { + editWorld.deleteNoSave(); } } else { - DGroup dgroup = DGroup.get(player); - if (dgroup != null) { - dgroup.removePlayer(player); + DGroup dGroup = DGroup.getByPlayer(player); + if (dGroup != null) { + dGroup.removePlayer(player); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LEAVE_SUCCESS)); return; } diff --git a/src/io/github/dre2n/dungeonsxl/command/LeaveCommand.java b/src/io/github/dre2n/dungeonsxl/command/LeaveCommand.java index af0a000e..f931c1bb 100644 --- a/src/io/github/dre2n/dungeonsxl/command/LeaveCommand.java +++ b/src/io/github/dre2n/dungeonsxl/command/LeaveCommand.java @@ -22,23 +22,23 @@ public class LeaveCommand extends DCommand { @Override public void onExecute(String[] args, CommandSender sender) { Player player = (Player) sender; - DPlayer dplayer = DPlayer.get(player); + DPlayer dPlayer = DPlayer.getByPlayer(player); - if (GameWorld.get(player.getWorld()) != null) { - if (GameWorld.get(player.getWorld()).isTutorial()) { + if (GameWorld.getByWorld(player.getWorld()) != null) { + if (GameWorld.getByWorld(player.getWorld()).isTutorial()) { MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_LEAVE_IN_TUTORIAL)); return; } } - if (dplayer != null) { - dplayer.leave(); + if (dPlayer != null) { + dPlayer.leave(); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LEAVE_SUCCESS)); } else { - DGroup dgroup = DGroup.get(player); - if (dgroup != null) { - dgroup.removePlayer(player); + DGroup dGroup = DGroup.getByPlayer(player); + if (dGroup != null) { + dGroup.removePlayer(player); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LEAVE_SUCCESS)); return; } diff --git a/src/io/github/dre2n/dungeonsxl/command/ListCommand.java b/src/io/github/dre2n/dungeonsxl/command/ListCommand.java index 27b49d3d..eb90a66a 100644 --- a/src/io/github/dre2n/dungeonsxl/command/ListCommand.java +++ b/src/io/github/dre2n/dungeonsxl/command/ListCommand.java @@ -60,7 +60,7 @@ public class ListCommand extends DCommand { MessageUtil.sendMessage(sender, "&estartFloor: &o[" + dungeon.getConfig().getStartFloor() + "]"); MessageUtil.sendMessage(sender, "&eendFloor: &o[" + dungeon.getConfig().getEndFloor() + "]"); MessageUtil.sendMessage(sender, "&efloorCount: &o[" + dungeon.getConfig().getFloorCount() + "]"); - MessageUtil.sendMessage(sender, "&eremoveWhenPlayed: &o[" + dungeon.getConfig().isRemoveWhenPlayed() + "]"); + MessageUtil.sendMessage(sender, "&eremoveWhenPlayed: &o[" + dungeon.getConfig().getRemoveWhenPlayed() + "]"); return; } } diff --git a/src/io/github/dre2n/dungeonsxl/command/LivesCommand.java b/src/io/github/dre2n/dungeonsxl/command/LivesCommand.java index 34255832..7b09e047 100644 --- a/src/io/github/dre2n/dungeonsxl/command/LivesCommand.java +++ b/src/io/github/dre2n/dungeonsxl/command/LivesCommand.java @@ -36,9 +36,9 @@ public class LivesCommand extends DCommand { return; } - DPlayer dPlayer = DPlayer.get(player); + DPlayer dPlayer = DPlayer.getByPlayer(player); if (dPlayer != null) { - MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LIVES).replaceAll("v1", player.getName()).replaceAll("v2", String.valueOf(dPlayer.getLives()))); + MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LIVES, player.getName(), String.valueOf(dPlayer.getLives()))); } else { MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_IN_DUNGEON)); diff --git a/src/io/github/dre2n/dungeonsxl/command/PlayCommand.java b/src/io/github/dre2n/dungeonsxl/command/PlayCommand.java index e98aadba..eb432080 100644 --- a/src/io/github/dre2n/dungeonsxl/command/PlayCommand.java +++ b/src/io/github/dre2n/dungeonsxl/command/PlayCommand.java @@ -28,7 +28,7 @@ public class PlayCommand extends DCommand { @Override public void onExecute(String[] args, CommandSender sender) { Player player = (Player) sender; - DPlayer dplayer = DPlayer.get(player); + DPlayer dplayer = DPlayer.getByPlayer(player); if (dplayer != null) { MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON)); @@ -85,7 +85,7 @@ public class PlayCommand extends DCommand { return; } - if (DGroup.get(player) != null) { + if (DGroup.getByPlayer(player) != null) { MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_GROUP)); return; } @@ -93,7 +93,7 @@ public class PlayCommand extends DCommand { DGroup dGroup = new DGroup(player, identifier, multiFloor); if (dGroup.getGameWorld() == null) { - dGroup.setGameWorld(GameWorld.load(DGroup.get(player).getMapName())); + dGroup.setGameWorld(GameWorld.load(DGroup.getByPlayer(player).getMapName())); } if (dGroup.getGameWorld().getLocLobby() == null) { diff --git a/src/io/github/dre2n/dungeonsxl/command/PortalCommand.java b/src/io/github/dre2n/dungeonsxl/command/PortalCommand.java index 1d7c35dc..6a7a94aa 100644 --- a/src/io/github/dre2n/dungeonsxl/command/PortalCommand.java +++ b/src/io/github/dre2n/dungeonsxl/command/PortalCommand.java @@ -24,23 +24,23 @@ public class PortalCommand extends DCommand { @Override public void onExecute(String[] args, CommandSender sender) { Player player = (Player) sender; - DPlayer dplayer = DPlayer.get(player); + DPlayer dPlayer = DPlayer.getByPlayer(player); - if (dplayer != null) { + if (dPlayer != null) { MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON)); } - DPortal dportal = DPortal.get(player); + DPortal dPortal = DPortal.getByPlayer(player); - if (dportal == null) { - dportal = new DPortal(false); - dportal.setPlayer(player); - dportal.setWorld(player.getWorld()); + if (dPortal == null) { + dPortal = new DPortal(false); + dPortal.setPlayer(player); + dPortal.setWorld(player.getWorld()); player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PORTAL_INTRODUCTION)); } else { - plugin.getDPortals().remove(dportal); + plugin.getDPortals().remove(dPortal); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PORTAL_ABORT)); } } diff --git a/src/io/github/dre2n/dungeonsxl/command/SaveCommand.java b/src/io/github/dre2n/dungeonsxl/command/SaveCommand.java index 70bc3729..428c3936 100644 --- a/src/io/github/dre2n/dungeonsxl/command/SaveCommand.java +++ b/src/io/github/dre2n/dungeonsxl/command/SaveCommand.java @@ -21,9 +21,9 @@ public class SaveCommand extends DCommand { @Override public void onExecute(String[] args, CommandSender sender) { Player player = (Player) sender; - EditWorld eworld = EditWorld.get(player.getWorld()); - if (eworld != null) { - eworld.save(); + EditWorld editWorld = EditWorld.get(player.getWorld()); + if (editWorld != null) { + editWorld.save(); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_SAVE_SUCCESS)); } else { diff --git a/src/io/github/dre2n/dungeonsxl/command/TestCommand.java b/src/io/github/dre2n/dungeonsxl/command/TestCommand.java index bee7220b..d116a5ff 100644 --- a/src/io/github/dre2n/dungeonsxl/command/TestCommand.java +++ b/src/io/github/dre2n/dungeonsxl/command/TestCommand.java @@ -25,7 +25,7 @@ public class TestCommand extends DCommand { @Override public void onExecute(String[] args, CommandSender sender) { Player player = (Player) sender; - DPlayer dplayer = DPlayer.get(player); + DPlayer dplayer = DPlayer.getByPlayer(player); if (dplayer != null) { MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON)); @@ -61,7 +61,7 @@ public class TestCommand extends DCommand { return; } - if (DGroup.get(player) != null) { + if (DGroup.getByPlayer(player) != null) { MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_GROUP)); return; } @@ -69,7 +69,7 @@ public class TestCommand extends DCommand { DGroup dGroup = new DGroup(player, identifier, multiFloor); if (dGroup.getGameWorld() == null) { - dGroup.setGameWorld(GameWorld.load(DGroup.get(player).getMapName())); + dGroup.setGameWorld(GameWorld.load(DGroup.getByPlayer(player).getMapName())); } DPlayer newDPlayer; @@ -81,7 +81,7 @@ public class TestCommand extends DCommand { newDPlayer = new DPlayer(player, dGroup.getGameWorld().getWorld(), dGroup.getGameWorld().getLocLobby(), false); } - newDPlayer.setIsInTestMode(true); + newDPlayer.setInTestMode(true); } } diff --git a/src/io/github/dre2n/dungeonsxl/dungeon/DLootInventory.java b/src/io/github/dre2n/dungeonsxl/dungeon/DLootInventory.java index 334c2557..96cc68c2 100644 --- a/src/io/github/dre2n/dungeonsxl/dungeon/DLootInventory.java +++ b/src/io/github/dre2n/dungeonsxl/dungeon/DLootInventory.java @@ -32,7 +32,11 @@ public class DLootInventory { this.player = player; } - public static DLootInventory get(Player player) { + /** + * @param player + * the player whose DLootIntentory will be returned + */ + public static DLootInventory getByPlayer(Player player) { for (DLootInventory inventory : plugin.getDLootInventories()) { if (inventory.player == player) { return inventory; diff --git a/src/io/github/dre2n/dungeonsxl/dungeon/DungeonConfig.java b/src/io/github/dre2n/dungeonsxl/dungeon/DungeonConfig.java index c6eb97c6..5cc271bc 100644 --- a/src/io/github/dre2n/dungeonsxl/dungeon/DungeonConfig.java +++ b/src/io/github/dre2n/dungeonsxl/dungeon/DungeonConfig.java @@ -122,7 +122,7 @@ public class DungeonConfig extends WorldConfig { /** * @return the removeWhenPlayed */ - public boolean isRemoveWhenPlayed() { + public boolean getRemoveWhenPlayed() { return removeWhenPlayed; } diff --git a/src/io/github/dre2n/dungeonsxl/dungeon/EditWorld.java b/src/io/github/dre2n/dungeonsxl/dungeon/EditWorld.java index 49ee4439..aa051e39 100644 --- a/src/io/github/dre2n/dungeonsxl/dungeon/EditWorld.java +++ b/src/io/github/dre2n/dungeonsxl/dungeon/EditWorld.java @@ -80,6 +80,7 @@ public class EditWorld { out.writeInt(sign.getZ()); } out.close(); + } catch (IOException exception) { } } @@ -98,27 +99,27 @@ public class EditWorld { public void delete() { plugin.getEditWorlds().remove(this); for (Player player : world.getPlayers()) { - DPlayer dplayer = DPlayer.get(player); - dplayer.leave(); + DPlayer dPlayer = DPlayer.getByPlayer(player); + dPlayer.leave(); } plugin.getServer().unloadWorld(world, true); File dir = new File("DXL_Edit_" + id); FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName)); - FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + mapName)); + FileUtil.deleteUnusedFiles(new File(plugin.getDataFolder(), "/maps/" + mapName)); FileUtil.removeDirectory(dir); } public void deleteNoSave() { plugin.getEditWorlds().remove(this); for (Player player : world.getPlayers()) { - DPlayer dplayer = DPlayer.get(player); - dplayer.leave(); + DPlayer dPlayer = DPlayer.getByPlayer(player); + dPlayer.leave(); } File dir = new File("DXL_Edit_" + id); FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName)); - FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + mapName)); + FileUtil.deleteUnusedFiles(new File(plugin.getDataFolder(), "/maps/" + mapName)); plugin.getServer().unloadWorld(world, true); FileUtil.removeDirectory(dir); } @@ -220,15 +221,15 @@ public class EditWorld { } public void msg(String msg) { - for (DPlayer dplayer : DPlayer.get(world)) { - MessageUtil.sendMessage(dplayer.getPlayer(), msg); + for (DPlayer dPlayer : DPlayer.getByWorld(world)) { + MessageUtil.sendMessage(dPlayer.getPlayer(), msg); } } // Invite - public static boolean addInvitedPlayer(String editWorldname, UUID uuid) { - if (exist(editWorldname)) { - WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + editWorldname, "config.yml")); + public static boolean addInvitedPlayer(String editWorldName, UUID uuid) { + if (exist(editWorldName)) { + WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml")); config.addInvitedPlayer(uuid.toString()); config.save(); return true; @@ -246,7 +247,7 @@ public class EditWorld { // Kick Player EditWorld editWorld = EditWorld.get(editWorldName); if (editWorld != null) { - DPlayer player = DPlayer.get(name); + DPlayer player = DPlayer.getByName(name); if (player != null) { if (editWorld.world.getPlayers().contains(player.getPlayer())) { @@ -261,12 +262,12 @@ public class EditWorld { return false; } - public static boolean isInvitedPlayer(String editWorldname, UUID uuid, String name) { - if ( !exist(editWorldname)) { + public static boolean isInvitedPlayer(String editWorldName, UUID uuid, String name) { + if ( !exist(editWorldName)) { return false; } - WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + editWorldname, "config.yml")); + WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml")); // get player from both a 0.9.1 and lower and 0.9.2 and higher file if (config.getInvitedPlayers().contains(name.toLowerCase()) || config.getInvitedPlayers().contains(uuid.toString())) { return true; diff --git a/src/io/github/dre2n/dungeonsxl/dungeon/WorldConfig.java b/src/io/github/dre2n/dungeonsxl/dungeon/WorldConfig.java index 7ddeb28c..6b256528 100644 --- a/src/io/github/dre2n/dungeonsxl/dungeon/WorldConfig.java +++ b/src/io/github/dre2n/dungeonsxl/dungeon/WorldConfig.java @@ -87,15 +87,15 @@ public class WorldConfig { boolean hasDog = configSectionClasses.getBoolean(className + ".dog"); /* Items */ List items = configSectionClasses.getStringList(className + ".items"); - CopyOnWriteArrayList istacks = new CopyOnWriteArrayList(); + CopyOnWriteArrayList itemStacks = new CopyOnWriteArrayList(); for (String item : items) { - String[] itemsplit = item.split(","); - if (itemsplit.length > 0) { + String[] itemSplit = item.split(","); + if (itemSplit.length > 0) { int itemId = 0, itemData = 0, itemSize = 1, itemLvlEnchantment = 1; Enchantment itemEnchantment = null; // Check Id & Data - String[] idAndData = itemsplit[0].split("/"); + String[] idAndData = itemSplit[0].split("/"); itemId = IntegerUtil.parseInt(idAndData[0]); if (idAndData.length > 1) { @@ -103,12 +103,12 @@ public class WorldConfig { } // Size - if (itemsplit.length > 1) { - itemSize = IntegerUtil.parseInt(itemsplit[1]); + if (itemSplit.length > 1) { + itemSize = IntegerUtil.parseInt(itemSplit[1]); } // Enchantment - if (itemsplit.length > 2) { - String[] enchantmentSplit = itemsplit[2].split("/"); + if (itemSplit.length > 2) { + String[] enchantmentSplit = itemSplit[2].split("/"); itemEnchantment = Enchantment.getByName(enchantmentSplit[0]); @@ -118,16 +118,16 @@ public class WorldConfig { } // Add Item to Stacks - ItemStack istack = new ItemStack(itemId, itemSize, (short) itemData); + ItemStack itemStack = new ItemStack(itemId, itemSize, (short) itemData); if (itemEnchantment != null) { - istack.addEnchantment(itemEnchantment, itemLvlEnchantment); + itemStack.addEnchantment(itemEnchantment, itemLvlEnchantment); } - istacks.add(istack); + itemStacks.add(itemStack); } } /* Create Class */ - dClasses.add(new DClass(name, istacks, hasDog)); + dClasses.add(new DClass(name, itemStacks, hasDog)); } } @@ -143,16 +143,16 @@ public class WorldConfig { /* Secure Objects */ if (configFile.contains("secureObjects")) { - List secureobjectlist = configFile.getIntegerList("secureObjects"); - for (int i : secureobjectlist) { + List secureObjectList = configFile.getIntegerList("secureObjects"); + for (int i : secureObjectList) { secureObjects.add(Material.getMaterial(i)); } } /* Invited Players */ if (configFile.contains("invitedPlayers")) { - List invitedplayers = configFile.getStringList("invitedPlayers"); - for (String i : invitedplayers) { + List invitedPlayers = configFile.getStringList("invitedPlayers"); + for (String i : invitedPlayers) { invitedPlayers.add(i); } } @@ -269,7 +269,7 @@ public class WorldConfig { FileConfiguration configFile = YamlConfiguration.loadConfiguration(file); // Messages - for (Integer msgs : this.msgs.keySet()) { + for (int msgs : this.msgs.keySet()) { configFile.set("message." + msgs, this.msgs.get(msgs)); } @@ -288,8 +288,8 @@ public class WorldConfig { try { configFile.save(file); - } catch (IOException e) { - e.printStackTrace(); + } catch (IOException exception) { + exception.printStackTrace(); } } diff --git a/src/io/github/dre2n/dungeonsxl/dungeon/game/GameChest.java b/src/io/github/dre2n/dungeonsxl/dungeon/game/GameChest.java index 17b9ed57..5ae64cd4 100644 --- a/src/io/github/dre2n/dungeonsxl/dungeon/game/GameChest.java +++ b/src/io/github/dre2n/dungeonsxl/dungeon/game/GameChest.java @@ -19,7 +19,7 @@ import org.bukkit.inventory.ItemStack; public class GameChest { // Variables - private boolean isUsed = false; + private boolean used = false; private Chest chest; private GameWorld gameWorld; private double moneyReward; @@ -44,12 +44,12 @@ public class GameChest { } for (Player player : dGroup.getPlayers()) { - DPlayer dplayer = DPlayer.get(player); - if (dplayer == null) { + DPlayer dPlayer = DPlayer.getByPlayer(player); + if (dPlayer == null) { continue; } - dplayer.setTreasureMoney(dplayer.getTreasureMoney() + moneyReward); + dPlayer.setTreasureMoney(dPlayer.getTreasureMoney() + moneyReward); String msg = ""; for (ItemStack itemStack : chest.getInventory().getContents()) { @@ -57,7 +57,7 @@ public class GameChest { continue; } - dplayer.getTreasureInv().addItem(itemStack); + dPlayer.getTreasureInv().addItem(itemStack); String name; if ( !itemStack.hasItemMeta()) { @@ -92,7 +92,7 @@ public class GameChest { public static void onOpenInventory(InventoryOpenEvent event) { InventoryView inventory = event.getView(); - GameWorld gameWorld = GameWorld.get(event.getPlayer().getWorld()); + GameWorld gameWorld = GameWorld.getByWorld(event.getPlayer().getWorld()); if (gameWorld == null) { return; @@ -109,7 +109,7 @@ public class GameChest { continue; } - if ( !gameChest.isUsed) { + if ( !gameChest.used) { MessageUtil .sendMessage(DungeonsXL.getPlugin().getServer().getPlayer(event.getPlayer().getUniqueId()), DungeonsXL.getPlugin().getDMessages().getMessage(Messages.ERROR_CHEST_IS_OPENED)); event.setCancelled(true); @@ -117,26 +117,26 @@ public class GameChest { } if (gameChest.chest.getLocation().distance(chest.getLocation()) < 1) { - gameChest.addTreasure(DGroup.get(gameWorld)); - gameChest.isUsed = true; + gameChest.addTreasure(DGroup.getByGameWorld(gameWorld)); + gameChest.used = true; event.setCancelled(true); } } } /** - * @return the isUsed + * @return if the GameChest is used */ public boolean isUsed() { - return isUsed; + return used; } /** - * @param isUsed - * the isUsed to set + * @param used + * set if the chest is used */ - public void setUsed(boolean isUsed) { - this.isUsed = isUsed; + public void setUsed(boolean used) { + this.used = used; } /** diff --git a/src/io/github/dre2n/dungeonsxl/dungeon/game/GamePlaceableBlock.java b/src/io/github/dre2n/dungeonsxl/dungeon/game/GamePlaceableBlock.java index f794ea94..0f0e81bd 100644 --- a/src/io/github/dre2n/dungeonsxl/dungeon/game/GamePlaceableBlock.java +++ b/src/io/github/dre2n/dungeonsxl/dungeon/game/GamePlaceableBlock.java @@ -13,7 +13,7 @@ public class GamePlaceableBlock { // Variables private Block block; - private Set mats = new HashSet(); + private Set materials = new HashSet(); private boolean onTop = false; private boolean onBottom = false; @@ -30,9 +30,9 @@ public class GamePlaceableBlock { String[] splittedIds = ids.split(","); for (String id : splittedIds) { @SuppressWarnings("deprecation") - Material mat = Material.getMaterial(IntegerUtil.parseInt(id)); - if (mat != null) { - mats.add(mat); + Material material = Material.getMaterial(IntegerUtil.parseInt(id)); + if (material != null) { + materials.add(material); } } } @@ -240,36 +240,36 @@ public class GamePlaceableBlock { // Canbuild public static boolean canBuildHere(Block block, BlockFace blockFace, Material mat, GameWorld gameWorld) { - for (GamePlaceableBlock gPBlock : gameWorld.getPlaceableBlocks()) { - if (gPBlock.block.getFace(block) != BlockFace.SELF) { + for (GamePlaceableBlock gamePlacableBlock : gameWorld.getPlaceableBlocks()) { + if (gamePlacableBlock.block.getFace(block) != BlockFace.SELF) { continue; } - if ( !(gPBlock.mats.contains(mat) || gPBlock.mats.isEmpty())) { + if ( !(gamePlacableBlock.materials.contains(mat) || gamePlacableBlock.materials.isEmpty())) { continue; } - if (blockFace == BlockFace.NORTH && gPBlock.onNorth) { + if (blockFace == BlockFace.NORTH && gamePlacableBlock.onNorth) { return true; } - if (blockFace == BlockFace.SOUTH && gPBlock.onSouth) { + if (blockFace == BlockFace.SOUTH && gamePlacableBlock.onSouth) { return true; } - if (blockFace == BlockFace.EAST && gPBlock.onEast) { + if (blockFace == BlockFace.EAST && gamePlacableBlock.onEast) { return true; } - if (blockFace == BlockFace.WEST && gPBlock.onWest) { + if (blockFace == BlockFace.WEST && gamePlacableBlock.onWest) { return true; } - if (blockFace == BlockFace.UP && gPBlock.onTop) { + if (blockFace == BlockFace.UP && gamePlacableBlock.onTop) { return true; } - if (blockFace == BlockFace.DOWN && gPBlock.onBottom) { + if (blockFace == BlockFace.DOWN && gamePlacableBlock.onBottom) { return true; } } diff --git a/src/io/github/dre2n/dungeonsxl/dungeon/game/GameWorld.java b/src/io/github/dre2n/dungeonsxl/dungeon/game/GameWorld.java index 3b14dcec..fcf2b31d 100644 --- a/src/io/github/dre2n/dungeonsxl/dungeon/game/GameWorld.java +++ b/src/io/github/dre2n/dungeonsxl/dungeon/game/GameWorld.java @@ -39,7 +39,7 @@ public class GameWorld { static DungeonsXL plugin = DungeonsXL.getPlugin(); // Variables placeable - private boolean isTutorial; + private boolean tutorial; private CopyOnWriteArrayList placeableBlocks = new CopyOnWriteArrayList(); private World world; @@ -110,24 +110,24 @@ public class GameWorld { } public void msg(String msg) { - for (DPlayer dplayer : DPlayer.get(world)) { - MessageUtil.sendMessage(dplayer.getPlayer(), msg); + for (DPlayer dPlayer : DPlayer.getByWorld(world)) { + MessageUtil.sendMessage(dPlayer.getPlayer(), msg); } } /** - * @return the isTutorial + * @return the tutorial */ public boolean isTutorial() { - return isTutorial; + return tutorial; } /** - * @param isTutorial - * the isTutorial to set + * @param tutorial + * if the GameWorld is the tutorial */ - public void setTutorial(boolean isTutorial) { - this.isTutorial = isTutorial; + public void setTutorial(boolean tutorial) { + this.tutorial = tutorial; } /** @@ -283,7 +283,7 @@ public class GameWorld { /** * @return the dMobs */ - public CopyOnWriteArrayList getdMobs() { + public CopyOnWriteArrayList getDMobs() { return dMobs; } @@ -291,7 +291,7 @@ public class GameWorld { * @param dMobs * the dMobs to set */ - public void setdMobs(CopyOnWriteArrayList dMobs) { + public void setDMobs(CopyOnWriteArrayList dMobs) { this.dMobs = dMobs; } @@ -313,7 +313,7 @@ public class GameWorld { /** * @return the dSigns */ - public CopyOnWriteArrayList getdSigns() { + public CopyOnWriteArrayList getDSigns() { return dSigns; } @@ -321,7 +321,7 @@ public class GameWorld { * @param dSigns * the dSigns to set */ - public void setdSigns(CopyOnWriteArrayList dSigns) { + public void setDSigns(CopyOnWriteArrayList dSigns) { this.dSigns = dSigns; } @@ -356,7 +356,7 @@ public class GameWorld { // Statics - public static GameWorld get(World world) { + public static GameWorld getByWorld(World world) { for (GameWorld gameWorld : plugin.getGameWorlds()) { if (gameWorld.world.equals(world)) { return gameWorld; @@ -374,7 +374,7 @@ public class GameWorld { public static boolean canPlayDungeon(String dungeon, Player player) { - if (player.hasPermission("dungeonsxl.ignoretimelimit")) { + if (player.hasPermission("dxl.ignoretimelimit")) { return true; } diff --git a/src/io/github/dre2n/dungeonsxl/file/DMessages.java b/src/io/github/dre2n/dungeonsxl/file/DMessages.java index 150a5eee..d5e124a2 100644 --- a/src/io/github/dre2n/dungeonsxl/file/DMessages.java +++ b/src/io/github/dre2n/dungeonsxl/file/DMessages.java @@ -11,34 +11,34 @@ public class DMessages { public enum Messages { - LOG_NEW_DUNGEON("Log_NewDungeon", "&6New Dungeon"), - LOG_GENERATE_NEW_WORLD("Log_GenerateNewWorld", "&6Generate new world..."), - LOG_WORLD_GENERATION_FINISHED("Log_WorldGenerationFinished", "&6World generation finished!"), LOG_ERROR_MOB_ENCHANTMENT("Log_Error_MobEnchantment", "&4Error at loading mob.yml: Enchantment &6&v1&4 doesn't exist!"), LOG_ERROR_MOBTYPE("Log_Error_MobType", "&4Error at loading mob.yml: Mob &6&v1&4 doesn't exist!"), LOG_ERROR_NO_CONSOLE_COMMAND("Log_Error_NoConsoleCommand", "&6/dxl &v1&4 can not be executed as Console!"), + LOG_GENERATE_NEW_WORLD("Log_GenerateNewWorld", "&6Generate new world..."), + LOG_NEW_DUNGEON("Log_NewDungeon", "&6New Dungeon"), + LOG_WORLD_GENERATION_FINISHED("Log_WorldGenerationFinished", "&6World generation finished!"), - PLAYER_CHECKPOINT_REACHED("Player_CheckpointReached", "&6Checkpoint reached!"), - PLAYER_LOOT_ADDED("Player_LootAdded", "&4&v1&6 have been added to your reward inventory!"), - PLAYER_READY("Player_Ready", "&6You are now ready for the Dungeon!"), - PLAYER_FINISHED_DUNGEON("Player_FinishedDungeon", "&6You successfully finished the Dungeon!"), - PLAYER_WAIT_FOR_OTHER_PLAYERS("Player_WaitForOtherPlayers", "&6Waiting for teammates..."), - PLAYER_LEAVE_GROUP("Player_LeaveGroup", "&6You have successfully left your group!"), - PLAYER_OFFLINE("Player_Offline", "&Player &4&v1&6 went offline. In &4&v2&6 seconds he will autmatically be kicked from the Dungeon!"), - PLAYER_OFFLINE_NEVER("Player_OfflineNever", "&Player &4&v1&6 went offline. He will &4not&6 be kicked from the Dungeon automatically!"), - PLAYER_LEFT_GROUP("Player_LeftGroup", "&Player &4&v1&6 has left the Group!"), - PLAYER_JOIN_GROUP("Player_JoinGroup", "&Player &4&v1&6 has joined the Group!"), - PLAYER_PORTAL_ABORT("Player_PortalAbort", "&6Portal creation cancelled!"), - PLAYER_PORTAL_INTRODUCTION("Player_PortalIntroduction", "&6Click the two edges of the Portal with the wooden sword!"), - PLAYER_PORTAL_DELETED("Player_PortalDeleted", "&6Portal deleted!"), - PLAYER_PORTAL_PROGRESS("Player_PortalProgress", "&6First Block, now the second one!"), - PLAYER_PORTAL_CREATED("Player_PortalCreated", "&6Portal created!"), - PLAYER_SIGN_CREATED("Player_SignCreated", "&6Sign created!"), - PLAYER_SIGN_COPIED("Player_SignCopied", "&6Copied!"), PLAYER_BLOCK_INFO("Player_BlockInfo", "&6Block-ID: &2&v1"), + PLAYER_CHECKPOINT_REACHED("Player_CheckpointReached", "&6Checkpoint reached!"), PLAYER_DEATH("Player_Death", "&6You died, lives left: &2v1"), PLAYER_DEATH_KICK("Player_DeathKick", "&2v1&6 died and lost his last life."), + PLAYER_FINISHED_DUNGEON("Player_FinishedDungeon", "&6You successfully finished the Dungeon!"), + PLAYER_JOIN_GROUP("Player_JoinGroup", "&Player &4&v1&6 has joined the Group!"), + PLAYER_LEAVE_GROUP("Player_LeaveGroup", "&6You have successfully left your group!"), + PLAYER_LEFT_GROUP("Player_LeftGroup", "&Player &4&v1&6 has left the Group!"), + PLAYER_LOOT_ADDED("Player_LootAdded", "&4&v1&6 have been added to your reward inventory!"), + PLAYER_OFFLINE("Player_Offline", "&Player &4&v1&6 went offline. In &4&v2&6 seconds he will autmatically be kicked from the Dungeon!"), + PLAYER_OFFLINE_NEVER("Player_OfflineNever", "&Player &4&v1&6 went offline. He will &4not&6 be kicked from the Dungeon automatically!"), + PLAYER_PORTAL_ABORT("Player_PortalAbort", "&6Portal creation cancelled!"), + PLAYER_PORTAL_INTRODUCTION("Player_PortalIntroduction", "&6Click the two edges of the Portal with the wooden sword!"), + PLAYER_PORTAL_CREATED("Player_PortalCreated", "&6Portal created!"), + PLAYER_PORTAL_PROGRESS("Player_PortalProgress", "&6First Block, now the second one!"), + PLAYER_PROTECTED_BLOCK_DELETED("Player_ProtectedBlockDeleted", "&6Protected block deleted!"), + PLAYER_READY("Player_Ready", "&6You are now ready for the Dungeon!"), + PLAYER_SIGN_CREATED("Player_SignCreated", "&6Sign created!"), + PLAYER_SIGN_COPIED("Player_SignCopied", "&6Copied!"), PLAYER_TREASURES("Player_Treasures", "&1Treasures"), + PLAYER_WAIT_FOR_OTHER_PLAYERS("Player_WaitForOtherPlayers", "&6Waiting for teammates..."), CMD_CHAT_DUNGEON_CHAT("Cmd_Chat_DungeonChat", "&6You have entered the Dungeon-chat"), CMD_CHAT_NORMAL_CHAT("Cmd_Chat_NormalChat", "&6You are now in the public chat"), @@ -46,6 +46,7 @@ public class DMessages { CMD_CHATSPY_START("Cmd_Chatspy_Start", "&You started spying the DXL-chat!"), CMD_INVITE_SUCCESS("Cmd_Invite_Success", "&6Player &4&v1&6 was successfully invited to edit the Dungeon &4&v2&6!"), CMD_LEAVE_SUCCESS("Cmd_Leave_Success", "&6You have successfully left your group!"), + CMD_LIVES("Cmd_Lives", "&4v1&6 has &4v2 &6lives left."), CMD_MAIN_WELCOME("Cmd_Main_Welcome", "&7Welcome to &4Dungeons&fXL"), CMD_MAIN_LOADED("Cmd_Main_Loaded", "&eMaps: &o[&v1] &eDungeons: &o[&v2] &eLoaded: &o[&v3] &ePlayers: &o[&v4]"), CMD_MAIN_COMPATIBILITY("Cmd_Main_Compatibility", "&eInternals: &o[&v1] &eVault: &o[&v2] &eMythicMobs: &o[&v3]"), @@ -55,55 +56,54 @@ public class DMessages { CMD_RELOAD_DONE("Cmd_Reload_Done", "&7Successfully reloaded DungeonsXL."), CMD_SAVE_SUCCESS("Cmd_Save_Success", "&6Dungeon saved!"), CMD_UNINVITE_SUCCESS("Cmd_Uninvite_Success", "&4&v1&6 was successfully uninvited to edit the Dungeon &4&v1&6!"), - CMD_LIVES("Cmd_Lives", "&4v1&6 has &4v2 &6lives left."), - ERROR_CHEST_IS_OPENED("Error_ChestIsOpened", "&4This chest has already been opened."), - ERROR_ENDERCHEST("Error_Enderchest", "&4You cannot use an enderchest while in a Dungeon!"), ERROR_BED("Error_Bed", "&4You cannot use a bed while in a Dungeon!"), - ERROR_DISPENSER("Error_Dispenser", "&4You cannot access this dispenser!"), - ERROR_READY("Error_Ready", "&4Choose your class first!"), - ERROR_COOLDOWN("Error_Cooldown", "&4You can only enter this Dungeon every &6&v1&4 hours!"), - ERROR_REQUIREMENTS("Error_Requirements", "&4You don't fulfill the requirements for this Dungeon!"), - ERROR_LEFT_CLICK("Error_Leftklick", "&4You have to use Left-Click on this sign!"), - ERROR_DROP("Error_Drop", "&4You cannot drop safe items"), + ERROR_CHEST_IS_OPENED("Error_ChestIsOpened", "&4This chest has already been opened."), ERROR_CMD("Error_Cmd", "&4Commands are not allowed while in a dungeon!"), - ERROR_NOT_IN_GROUP("Error_NotInGroup", "&4You have to join a group first!"), - ERROR_NO_PERMISSIONS("Error_NoPermissions", "&4You have no permission to do this!"), ERROR_CMD_NOT_EXIST_1("Error_CmdNotExist1", "&4Command &6&v1&4 does not exist!"), ERROR_CMD_NOT_EXIST_2("Error_CmdNotExist2", "&4Pleaser enter &6/dxl help&4 for help!"), - ERROR_NOT_IN_DUNGEON("Error_NotInDungeon", "&4You are not in a dungeon!"), + ERROR_COOLDOWN("Error_Cooldown", "&4You can only enter this Dungeon every &6&v1&4 hours!"), + ERROR_DISPENSER("Error_Dispenser", "&4You cannot access this dispenser!"), + ERROR_DROP("Error_Drop", "&4You cannot drop safe items"), ERROR_DUNGEON_NOT_EXIST("Error_DungeonNotExist", "&4Dungeon &6&v1&4 does not exist!"), + ERROR_ENDERCHEST("Error_Enderchest", "&4You cannot use an enderchest while in a Dungeon!"), ERROR_LEAVE_DUNGEON("Error_LeaveDungeon", "&4You have to leave your current dungeon first!"), - ERROR_NAME_TO_LONG("Error_NameToLong", "&4The name may not be longer than 15 characters!"), ERROR_LEAVE_GROUP("Error_LeaveGroup", "&4You have to leave your group first!"), - ERROR_NO_LEAVE_IN_TUTORIAL("Error_NoLeaveInTutorial", "&4You cannot use this command in the tutorial!"), + ERROR_LEFT_CLICK("Error_Leftklick", "&4You have to use Left-Click on this sign!"), ERROR_MSG_ID_NOT_EXIST("Error_MsgIdNotExist", "&4Messages with Id &6&v1&4 does not exist!"), ERROR_MSG_FORMAT("Error_MsgFormat", "&4The Messages has to be between \"!"), ERROR_MSG_NO_INT("Error_MsgNoInt", "&4Argument has to include a number!"), - ERROR_TUTORIAL_NOT_EXIST("Error_TutorialNotExist", "&4Tutorial dungeon does not exist!"), - ERROR_NO_PORTAL("Error_NoPortal", "&4You have to look at a portal!"), - ERROR_NO_PLAYER_COMMAND("Error_NoPlayerCommand", "&6/dxl &v1&4 cannot be executed as player!"), + ERROR_NAME_TO_LONG("Error_NameToLong", "&4The name may not be longer than 15 characters!"), ERROR_NO_CONSOLE_COMMAND("Error_NoConsoleCommand", "&6/dxl &v1&4 cannot be executed as console!"), + ERROR_NO_LEAVE_IN_TUTORIAL("Error_NoLeaveInTutorial", "&4You cannot use this command in the tutorial!"), + ERROR_NO_PERMISSIONS("Error_NoPermissions", "&4You have no permission to do this!"), + ERROR_NO_PLAYER_COMMAND("Error_NoPlayerCommand", "&6/dxl &v1&4 cannot be executed as player!"), + ERROR_NO_PROTECTED_BLOCK("Error_NoDXLBlock", "&4This is not a block protected by DungeonsXL!"), + ERROR_NOT_IN_DUNGEON("Error_NotInDungeon", "&4You are not in a dungeon!"), + ERROR_NOT_IN_GROUP("Error_NotInGroup", "&4You have to join a group first!"), + ERROR_TUTORIAL_NOT_EXIST("Error_TutorialNotExist", "&4Tutorial dungeon does not exist!"), + ERROR_READY("Error_Ready", "&4Choose your class first!"), + ERROR_REQUIREMENTS("Error_Requirements", "&4You don't fulfill the requirements for this Dungeon!"), ERROR_SIGN_WRONG_FORMAT("Error_SignWrongFormat", "&4The sign is not written correctly!"), - HELP_CMD_CHAT("Help_Cmd_Chat", "/dxl chat - Change the Chat-Mode"), + HELP_CMD_BREAK("Help_Cmd_Break", "/dxl break - Break a block protected by DungeonsXL"), + HELP_CMD_CHAT("Help_Cmd_Chat", "/dxl chat - Change the chat mode"), HELP_CMD_CHATSPY("Help_Cmd_Chatspy", "/dxl chatspy - Dis/enables the spymode"), HELP_CMD_CREATE("Help_Cmd_Create", "/dxl create - Creates a new dungeon"), HELP_CMD_EDIT("Help_Cmd_Edit", "/dxl edit - Edit an existing dungeon"), + HELP_CMD_ESCAPE("Help_Cmd_Escape", "/dxl escape - Leaves the current dungeon, without saving!"), HELP_CMD_HELP("Help_Cmd_Help", "/dxl help - Shows the help page"), HELP_CMD_INVITE("Help_Cmd_Invite", "/dxl invite - Invite a player to edit a dungeon"), HELP_CMD_LEAVE("Help_Cmd_Leave", "/dxl leave - Leaves the current dungeon"), - HELP_CMD_ESCAPE("Help_Cmd_Escape", "/dxl escape - Leaves the current dungeon, without saving!"), HELP_CMD_LIST("Help_Cmd_List", "/dxl list ([dungeon|map|loaded]) ([dungeon]) - Lists all dungeons"), + HELP_CMD_LIVES("Help_Cmd_Lives", "/dxl lives - Shows the lives a player has left"), HELP_CMD_MAIN("Help_Cmd_Main", "/dxl - General status information"), HELP_CMD_MSG("Help_Cmd_Msg", "/dxl msg '[msg]' - Show or edit a message"), + HELP_CMD_PLAY("Help_Cmd_Play", "/dxl play ([dungeon|map]) [name] - Allows the player to join a game without a portal"), HELP_CMD_PORTAL("Help_Cmd_Portal", "/dxl portal - Creates a portal that leads into a dungeon"), - HELP_CMD_DELETE_PORTAL("Help_Cmd_DeletePortal", "/dxl deleteportal - Deletes the portal you are looking at"), HELP_CMD_RELOAD("Help_Cmd_Reload", "/dxl reload - Reloads the plugin"), HELP_CMD_SAVE("Help_Cmd_Save", "/dxl save - Saves the current dungeon"), - HELP_CMD_PLAY("Help_Cmd_Play", "/dxl play ([dungeon|map]) [name] - Allows the player to join a game without a portal"), HELP_CMD_TEST("Help_Cmd_Test", "/dxl test ([dungeon|map]) [name] - Tests a dungeon"), - HELP_CMD_LIVES("Help_Cmd_Lives", "/dxl lives - Shows the lives a player has left"), HELP_CMD_UNINVITE("Help_Cmd_Uninvite", "/dxl uninvite - Uninvite a player to edit a dungeon"); private String identifier; @@ -142,7 +142,7 @@ public class DMessages { * @param identifer * the identifer to set */ - public static Messages fromIdentifier(String identifier) { + public static Messages getByIdentifier(String identifier) { for (Messages message : Messages.values()) { if (message.getIdentifier().equals(identifier)) { return message; @@ -192,7 +192,7 @@ public class DMessages { if (config != null) { Set keySet = config.getKeys(false); for (String key : keySet) { - Messages.fromIdentifier(key).setMessage(config.getString(key)); + Messages.getByIdentifier(key).setMessage(config.getString(key)); } } } diff --git a/src/io/github/dre2n/dungeonsxl/global/DPortal.java b/src/io/github/dre2n/dungeonsxl/global/DPortal.java index 11adaa62..456b0c1e 100644 --- a/src/io/github/dre2n/dungeonsxl/global/DPortal.java +++ b/src/io/github/dre2n/dungeonsxl/global/DPortal.java @@ -21,12 +21,12 @@ public class DPortal { private World world; private Block block1; private Block block2; - private boolean isActive; + private boolean active; private Player player; public DPortal(boolean active) { plugin.getDPortals().add(this); - isActive = active; + this.active = active; } public void create() { @@ -84,7 +84,7 @@ public class DPortal { } public void teleport(Player player) { - DGroup dgroup = DGroup.get(player); + DGroup dgroup = DGroup.getByPlayer(player); if (dgroup == null) { MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_NOT_IN_GROUP)); @@ -92,11 +92,11 @@ public class DPortal { } if (dgroup.getGameWorld() == null) { - dgroup.setGameWorld(GameWorld.load(DGroup.get(player).getMapName())); + dgroup.setGameWorld(GameWorld.load(DGroup.getByPlayer(player).getMapName())); } if (dgroup.getGameWorld() == null) { - MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, DGroup.get(player).getMapName())); + MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, DGroup.getByPlayer(player).getMapName())); return; } @@ -156,11 +156,11 @@ public class DPortal { } // Statics - public static DPortal get(Location location) { - return get(location.getBlock()); + public static DPortal getByLocation(Location location) { + return getByBlock(location.getBlock()); } - public static DPortal get(Block block) { + public static DPortal getByBlock(Block block) { for (DPortal portal : plugin.getDPortals()) { int x1 = portal.block1.getX(), y1 = portal.block1.getY(), z1 = portal.block1.getZ(); int x2 = portal.block2.getX(), y2 = portal.block2.getY(), z2 = portal.block2.getZ(); @@ -204,7 +204,7 @@ public class DPortal { return null; } - public static DPortal get(Player player) { + public static DPortal getByPlayer(Player player) { for (DPortal portal : plugin.getDPortals()) { if (portal.player == player) { return portal; @@ -217,22 +217,22 @@ public class DPortal { // Save and Load public static void save(FileConfiguration configFile) { int id = 0; - for (DPortal dportal : plugin.getDPortals()) { + for (DPortal dPortal : plugin.getDPortals()) { id++; - if ( !dportal.isActive) { + if ( !dPortal.active) { continue; } - String preString = "portal." + dportal.world.getName() + "." + id; + String preString = "portal." + dPortal.world.getName() + "." + id; // Location1 - configFile.set(preString + ".loc1.x", dportal.block1.getX()); - configFile.set(preString + ".loc1.y", dportal.block1.getY()); - configFile.set(preString + ".loc1.z", dportal.block1.getZ()); + configFile.set(preString + ".loc1.x", dPortal.block1.getX()); + configFile.set(preString + ".loc1.y", dPortal.block1.getY()); + configFile.set(preString + ".loc1.z", dPortal.block1.getZ()); // Location1 - configFile.set(preString + ".loc2.x", dportal.block2.getX()); - configFile.set(preString + ".loc2.y", dportal.block2.getY()); - configFile.set(preString + ".loc2.z", dportal.block2.getZ()); + configFile.set(preString + ".loc2.x", dPortal.block2.getX()); + configFile.set(preString + ".loc2.y", dPortal.block2.getY()); + configFile.set(preString + ".loc2.z", dPortal.block2.getZ()); } } @@ -249,11 +249,11 @@ public class DPortal { preString = "portal." + world.getName() + "." + id + "."; if (configFile.contains(preString)) { - DPortal dportal = new DPortal(true); - dportal.world = world; - dportal.block1 = world.getBlockAt(configFile.getInt(preString + "loc1.x"), configFile.getInt(preString + "loc1.y"), configFile.getInt(preString + "loc1.z")); - dportal.block2 = world.getBlockAt(configFile.getInt(preString + "loc2.x"), configFile.getInt(preString + "loc2.y"), configFile.getInt(preString + "loc2.z")); - dportal.create(); + DPortal dPortal = new DPortal(true); + dPortal.world = world; + dPortal.block1 = world.getBlockAt(configFile.getInt(preString + "loc1.x"), configFile.getInt(preString + "loc1.y"), configFile.getInt(preString + "loc1.z")); + dPortal.block2 = world.getBlockAt(configFile.getInt(preString + "loc2.x"), configFile.getInt(preString + "loc2.y"), configFile.getInt(preString + "loc2.z")); + dPortal.create(); } } while (configFile.contains(preString)); @@ -306,18 +306,18 @@ public class DPortal { } /** - * @return the isActive + * @return if the portal is active */ public boolean isActive() { - return isActive; + return active; } /** - * @param isActive - * the isActive to set + * @param active + * set the DPortal active */ - public void setActive(boolean isActive) { - this.isActive = isActive; + public void setActive(boolean active) { + this.active = active; } /** diff --git a/src/io/github/dre2n/dungeonsxl/global/GroupSign.java b/src/io/github/dre2n/dungeonsxl/global/GroupSign.java index aecf2a22..17193722 100644 --- a/src/io/github/dre2n/dungeonsxl/global/GroupSign.java +++ b/src/io/github/dre2n/dungeonsxl/global/GroupSign.java @@ -24,10 +24,10 @@ public class GroupSign { static DungeonsXL plugin = DungeonsXL.getPlugin(); // Sign Labels - public static final String strIsPlaying = ChatColor.DARK_RED + "Is Playing"; - public static final String strFull = ChatColor.DARK_RED + "Full"; - public static final String strJoinGrp = ChatColor.DARK_GREEN + "Join Group"; - public static final String strNewGrp = ChatColor.DARK_GREEN + "New Group"; + public static final String IS_PLAYING = ChatColor.DARK_RED + "Is Playing"; + public static final String FULL = ChatColor.DARK_RED + "Full"; + public static final String JOIN_GROUP = ChatColor.DARK_GREEN + "Join Group"; + public static final String NEW_GROUP = ChatColor.DARK_GREEN + "New Group"; // Variables private DGroup[] dGroups; @@ -142,13 +142,13 @@ public class GroupSign { // Set Signs if (dGroup != null) { if (dGroup.isPlaying()) { - sign.setLine(0, strIsPlaying); + sign.setLine(0, IS_PLAYING); } else if (dGroup.getPlayers().size() >= maxPlayersPerGroup) { - sign.setLine(0, strFull); + sign.setLine(0, FULL); } else { - sign.setLine(0, strJoinGrp); + sign.setLine(0, JOIN_GROUP); } int j = 1; @@ -169,7 +169,7 @@ public class GroupSign { } } else { - sign.setLine(0, strNewGrp); + sign.setLine(0, NEW_GROUP); } sign.update(); @@ -377,7 +377,7 @@ public class GroupSign { return false; } - if (DGroup.get(player) != null) { + if (DGroup.getByPlayer(player) != null) { MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_LEAVE_GROUP)); return true; } @@ -417,7 +417,7 @@ public class GroupSign { Sign topSign = (Sign) topBlock.getState(); - if (topSign.getLine(0).equals(strNewGrp)) { + if (topSign.getLine(0).equals(NEW_GROUP)) { if (groupSign.isMultiFloor()) { groupSign.dGroups[column] = new DGroup(player, groupSign.dungeonName, groupSign.isMultiFloor()); @@ -426,7 +426,7 @@ public class GroupSign { } groupSign.update(); - } else if (topSign.getLine(0).equals(strJoinGrp)) { + } else if (topSign.getLine(0).equals(JOIN_GROUP)) { groupSign.dGroups[column].addPlayer(player); groupSign.update(); } @@ -434,7 +434,7 @@ public class GroupSign { return true; } - public static void updatePerGroup(DGroup dGroupsearch) { + public static void updatePerGroup(DGroup dGroupSearch) { for (GroupSign groupSign : plugin.getGroupSigns()) { int i = 0; @@ -443,8 +443,8 @@ public class GroupSign { continue; } - if (dGroup == dGroupsearch) { - if (dGroupsearch.isEmpty()) { + if (dGroup == dGroupSearch) { + if (dGroupSearch.isEmpty()) { groupSign.dGroups[i] = null; } groupSign.update(); diff --git a/src/io/github/dre2n/dungeonsxl/global/LeaveSign.java b/src/io/github/dre2n/dungeonsxl/global/LeaveSign.java index 64b19f02..f735701f 100644 --- a/src/io/github/dre2n/dungeonsxl/global/LeaveSign.java +++ b/src/io/github/dre2n/dungeonsxl/global/LeaveSign.java @@ -37,20 +37,20 @@ public class LeaveSign { public static boolean playerInteract(Block block, Player player) { - LeaveSign lsign = getSign(block); + LeaveSign leaveSign = getSign(block); - if (lsign == null) { + if (leaveSign == null) { return false; } - DPlayer dplayer = DPlayer.get(player); + DPlayer dplayer = DPlayer.getByPlayer(player); if (dplayer != null) { dplayer.leave(); return true; } else { - DGroup dgroup = DGroup.get(player); + DGroup dgroup = DGroup.getByPlayer(player); if (dgroup != null) { dgroup.removePlayer(player); MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().getMessage(Messages.PLAYER_LEAVE_GROUP));// ChatColor.YELLOW+"Du hast deine Gruppe erfolgreich verlassen!"); @@ -63,24 +63,24 @@ public class LeaveSign { @SuppressWarnings("deprecation") public static boolean isRelativeSign(Block block, int x, int z) { - LeaveSign lsign = getSign(block.getRelative(x, 0, z)); - if (lsign == null) { + LeaveSign leaveSign = getSign(block.getRelative(x, 0, z)); + if (leaveSign == null) { return false; } - if (x == -1 && lsign.sign.getData().getData() == 4) { + if (x == -1 && leaveSign.sign.getData().getData() == 4) { return true; } - if (x == 1 && lsign.sign.getData().getData() == 5) { + if (x == 1 && leaveSign.sign.getData().getData() == 5) { return true; } - if (z == -1 && lsign.sign.getData().getData() == 2) { + if (z == -1 && leaveSign.sign.getData().getData() == 2) { return true; } - if (z == 1 && lsign.sign.getData().getData() == 3) { + if (z == 1 && leaveSign.sign.getData().getData() == 3) { return true; } @@ -108,17 +108,17 @@ public class LeaveSign { // Save and Load public static void save(FileConfiguration configFile) { int id = 0; - for (LeaveSign lsign : plugin.getLeaveSigns()) { + for (LeaveSign leaveSign : plugin.getLeaveSigns()) { id++; - String preString = "leavesign." + lsign.sign.getWorld().getName() + "." + id; - configFile.set(preString + ".x", lsign.sign.getX()); - configFile.set(preString + ".y", lsign.sign.getY()); - configFile.set(preString + ".z", lsign.sign.getZ()); + String preString = "leavesign." + leaveSign.sign.getWorld().getName() + "." + id; + configFile.set(preString + ".x", leaveSign.sign.getX()); + configFile.set(preString + ".y", leaveSign.sign.getY()); + configFile.set(preString + ".z", leaveSign.sign.getZ()); } } public static void load(FileConfiguration configFile) { - for (World world : DungeonsXL.getPlugin().getServer().getWorlds()) { + for (World world : plugin.getServer().getWorlds()) { if ( !configFile.contains("leavesign." + world.getName())) { continue; } diff --git a/src/io/github/dre2n/dungeonsxl/listener/BlockListener.java b/src/io/github/dre2n/dungeonsxl/listener/BlockListener.java index e0c759ed..48973123 100644 --- a/src/io/github/dre2n/dungeonsxl/listener/BlockListener.java +++ b/src/io/github/dre2n/dungeonsxl/listener/BlockListener.java @@ -39,7 +39,7 @@ public class BlockListener implements Listener { return; } - if (DPortal.get(event.getBlock()) != null) { + if (DPortal.getByBlock(event.getBlock()) != null) { event.setCancelled(true); } } @@ -50,7 +50,7 @@ public class BlockListener implements Listener { // Deny DPortal destroying if (block.getType() == Material.PORTAL) { - if (DPortal.get(event.getBlock()) != null) { + if (DPortal.getByBlock(event.getBlock()) != null) { event.setCancelled(true); } } @@ -83,7 +83,7 @@ public class BlockListener implements Listener { } // Deny GameWorld Blocks - GameWorld gameWorld = GameWorld.get(block.getWorld()); + GameWorld gameWorld = GameWorld.getByWorld(block.getWorld()); if (gameWorld != null) { event.setCancelled(true); } @@ -95,7 +95,7 @@ public class BlockListener implements Listener { Block block = event.getBlock(); // Deny GameWorld Blocks - GameWorld gameWorld = GameWorld.get(block.getWorld()); + GameWorld gameWorld = GameWorld.getByWorld(block.getWorld()); if (gameWorld == null) { return; } @@ -205,7 +205,7 @@ public class BlockListener implements Listener { } // Check GameWorlds - GameWorld gameWorld = GameWorld.get(event.getBlock().getWorld()); + GameWorld gameWorld = GameWorld.getByWorld(event.getBlock().getWorld()); if (gameWorld != null) { event.setCancelled(true); } diff --git a/src/io/github/dre2n/dungeonsxl/listener/EntityListener.java b/src/io/github/dre2n/dungeonsxl/listener/EntityListener.java index 5009f80c..8b0c456d 100644 --- a/src/io/github/dre2n/dungeonsxl/listener/EntityListener.java +++ b/src/io/github/dre2n/dungeonsxl/listener/EntityListener.java @@ -36,7 +36,7 @@ public class EntityListener implements Listener { // Remove drops from breaking Signs @EventHandler(priority = EventPriority.HIGH) public void onItemSpawn(ItemSpawnEvent event) { - if (GameWorld.get(event.getLocation().getWorld()) != null) { + if (GameWorld.getByWorld(event.getLocation().getWorld()) != null) { if (event.getEntity().getItemStack().getType() == Material.SIGN) { event.setCancelled(true); } @@ -47,10 +47,10 @@ public class EntityListener implements Listener { public void onCreatureSpawn(CreatureSpawnEvent event) { World world = event.getLocation().getWorld(); - EditWorld eworld = EditWorld.get(world); - GameWorld gworld = GameWorld.get(world); + EditWorld editWorld = EditWorld.get(world); + GameWorld gameWorld = GameWorld.getByWorld(world); - if (eworld != null || gworld != null) { + if (editWorld != null || gameWorld != null) { if (event.getSpawnReason() == SpawnReason.CHUNK_GEN || event.getSpawnReason() == SpawnReason.BREEDING || event.getSpawnReason() == SpawnReason.NATURAL || event.getSpawnReason() == SpawnReason.DEFAULT) { event.setCancelled(true); @@ -64,9 +64,9 @@ public class EntityListener implements Listener { if (event.getEntity() instanceof LivingEntity) { LivingEntity entity = event.getEntity(); - GameWorld gworld = GameWorld.get(world); - if (gworld != null) { - if (gworld.isPlaying()) { + GameWorld gameWorld = GameWorld.getByWorld(world); + if (gameWorld != null) { + if (gameWorld.isPlaying()) { if (entity.getType() != EntityType.PLAYER) { event.getDrops().clear(); DMob.onDeath(event); @@ -79,10 +79,10 @@ public class EntityListener implements Listener { @EventHandler(priority = EventPriority.HIGH) public void onEntityDamage(EntityDamageEvent event) { World world = event.getEntity().getWorld(); - GameWorld gworld = GameWorld.get(world); - if (gworld != null) { + GameWorld gameWorld = GameWorld.getByWorld(world); + if (gameWorld != null) { // Deny all Damage in Lobby - if ( !gworld.isPlaying()) { + if ( !gameWorld.isPlaying()) { event.setCancelled(true); } // Deny all Damage from Players to Players @@ -106,9 +106,9 @@ public class EntityListener implements Listener { // Check Dogs if (entity instanceof Player || entity2 instanceof Player) { - for (DPlayer dplayer : DPlayer.get(gworld.getWorld())) { - if (dplayer.getWolf() != null) { - if (entity == dplayer.getWolf() || entity2 == dplayer.getWolf()) { + for (DPlayer dPlayer : DPlayer.getByWorld(gameWorld.getWorld())) { + if (dPlayer.getWolf() != null) { + if (entity == dPlayer.getWolf() || entity2 == dPlayer.getWolf()) { event.setCancelled(true); return; } @@ -116,16 +116,16 @@ public class EntityListener implements Listener { } } - for (DPlayer dplayer : DPlayer.get(gworld.getWorld())) { - if (dplayer.getWolf() != null) { + for (DPlayer dPlayer : DPlayer.getByWorld(gameWorld.getWorld())) { + if (dPlayer.getWolf() != null) { if (entity instanceof Player || entity2 instanceof Player) { - if (entity == dplayer.getWolf() || entity2 == dplayer.getWolf()) { + if (entity == dPlayer.getWolf() || entity2 == dPlayer.getWolf()) { event.setCancelled(true); return; } } else { - if (entity == dplayer.getWolf() || entity2 == dplayer.getWolf()) { + if (entity == dPlayer.getWolf() || entity2 == dPlayer.getWolf()) { event.setCancelled(false); return; } @@ -142,9 +142,9 @@ public class EntityListener implements Listener { public void onFoodLevelChange(FoodLevelChangeEvent event) { World world = event.getEntity().getWorld(); - GameWorld gworld = GameWorld.get(world); - if (gworld != null) { - if ( !gworld.isPlaying()) { + GameWorld gameWorld = GameWorld.getByWorld(world); + if (gameWorld != null) { + if ( !gameWorld.isPlaying()) { event.setCancelled(true); } } @@ -153,8 +153,8 @@ public class EntityListener implements Listener { // Zombie/skeleton combustion from the sun. @EventHandler(priority = EventPriority.NORMAL) public void onEntityCombust(EntityCombustEvent event) { - GameWorld gworld = GameWorld.get(event.getEntity().getWorld()); - if (gworld != null) { + GameWorld gameWorld = GameWorld.getByWorld(event.getEntity().getWorld()); + if (gameWorld != null) { event.setCancelled(true); } } @@ -162,8 +162,8 @@ public class EntityListener implements Listener { // Allow Other combustion @EventHandler(priority = EventPriority.HIGH) public void onEntityCombustByEntity(EntityCombustByEntityEvent event) { - GameWorld gworld = GameWorld.get(event.getEntity().getWorld()); - if (gworld != null) { + GameWorld gameWorld = GameWorld.getByWorld(event.getEntity().getWorld()); + if (gameWorld != null) { if (event.isCancelled()) { event.setCancelled(false); } @@ -173,11 +173,11 @@ public class EntityListener implements Listener { // Explosions @EventHandler public void onEntityExplode(EntityExplodeEvent event) { - GameWorld gworld = GameWorld.get(event.getEntity().getWorld()); + GameWorld gameWorld = GameWorld.getByWorld(event.getEntity().getWorld()); - if (gworld != null) { + if (gameWorld != null) { if (event.getEntity() instanceof LivingEntity) { - // Disable Creeper explosions in gameworlds + // Disable Creeper explosions in gameditWorlds event.setCancelled(true); return; @@ -193,7 +193,7 @@ public class EntityListener implements Listener { for (Block block : blocklist) { // Portals if (block.getType() == Material.PORTAL) { - if (DPortal.get(block) != null) { + if (DPortal.getByBlock(block) != null) { event.setCancelled(true); return; } diff --git a/src/io/github/dre2n/dungeonsxl/listener/HangingListener.java b/src/io/github/dre2n/dungeonsxl/listener/HangingListener.java index 45c01de3..a3400aff 100644 --- a/src/io/github/dre2n/dungeonsxl/listener/HangingListener.java +++ b/src/io/github/dre2n/dungeonsxl/listener/HangingListener.java @@ -10,8 +10,8 @@ public class HangingListener implements Listener { @EventHandler public void onHangingBreakByEntity(HangingBreakByEntityEvent event) { - GameWorld gworld = GameWorld.get(event.getEntity().getWorld()); - if (gworld != null) { + GameWorld gameWorld = GameWorld.getByWorld(event.getEntity().getWorld()); + if (gameWorld != null) { event.setCancelled(true); } } diff --git a/src/io/github/dre2n/dungeonsxl/listener/PlayerListener.java b/src/io/github/dre2n/dungeonsxl/listener/PlayerListener.java index 59a58772..261f1d00 100644 --- a/src/io/github/dre2n/dungeonsxl/listener/PlayerListener.java +++ b/src/io/github/dre2n/dungeonsxl/listener/PlayerListener.java @@ -53,9 +53,9 @@ public class PlayerListener implements Listener { @EventHandler(priority = EventPriority.HIGH) public void onDeath(PlayerDeathEvent event) { Player player = event.getEntity(); - final DPlayer dPlayer = DPlayer.get(player); + final DPlayer dPlayer = DPlayer.getByPlayer(player); - GameWorld gameWorld = GameWorld.get(player.getLocation().getWorld()); + GameWorld gameWorld = GameWorld.getByWorld(player.getLocation().getWorld()); if (gameWorld == null) { return; } @@ -100,7 +100,7 @@ public class PlayerListener implements Listener { if (clickedBlock != null) { // Block Enderchests - if (GameWorld.get(player.getWorld()) != null || EditWorld.get(player.getWorld()) != null) { + if (GameWorld.getByWorld(player.getWorld()) != null || EditWorld.get(player.getWorld()) != null) { if (event.getAction() != Action.LEFT_CLICK_BLOCK) { if (clickedBlock.getType() == Material.ENDER_CHEST) { if ( !player.hasPermission("dxl.bypass")) { @@ -118,7 +118,7 @@ public class PlayerListener implements Listener { } // Block Dispensers - if (GameWorld.get(player.getWorld()) != null) { + if (GameWorld.getByWorld(player.getWorld()) != null) { if (event.getAction() != Action.LEFT_CLICK_BLOCK) { if (clickedBlock.getType() == Material.DISPENSER) { if ( !player.hasPermission("dxl.bypass")) { @@ -159,7 +159,7 @@ public class PlayerListener implements Listener { if (EditWorld.get(player.getWorld()) != null) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { if (item.getType() == Material.STICK) { - DPlayer dPlayer = DPlayer.get(player); + DPlayer dPlayer = DPlayer.getByPlayer(player); if (dPlayer != null) { dPlayer.poke(clickedBlock); event.setCancelled(true); @@ -169,7 +169,7 @@ public class PlayerListener implements Listener { } // Trigger UseItem Signs - GameWorld gameWorld = GameWorld.get(player.getWorld()); + GameWorld gameWorld = GameWorld.getByWorld(player.getWorld()); if (gameWorld != null) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) { if (UseItemTrigger.hasTriggers(gameWorld)) { @@ -213,11 +213,11 @@ public class PlayerListener implements Listener { event.setCancelled(true); } - DPlayer dPlayer = DPlayer.get(player); + DPlayer dPlayer = DPlayer.getByPlayer(player); if (dPlayer != null) { // Check GameWorld Signs - GameWorld gameWorld = GameWorld.get(player.getWorld()); + GameWorld gameWorld = GameWorld.getByWorld(player.getWorld()); if (gameWorld != null) { // Trigger InteractTrigger @@ -255,7 +255,7 @@ public class PlayerListener implements Listener { Player player = event.getPlayer(); // Deny dropping things at the lobby - DGroup dGroup = DGroup.get(player); + DGroup dGroup = DGroup.getByPlayer(player); if (dGroup == null) { return; } @@ -265,13 +265,13 @@ public class PlayerListener implements Listener { return; } - if ( !DPlayer.get(player).isReady()) { + if ( !DPlayer.getByPlayer(player).isReady()) { event.setCancelled(true); return; } - DPlayer dPlayer = DPlayer.get(player); - GameWorld gameWorld = GameWorld.get(dPlayer.getWorld()); + DPlayer dPlayer = DPlayer.getByPlayer(player); + GameWorld gameWorld = GameWorld.getByWorld(dPlayer.getWorld()); if (dPlayer != null) { for (Material material : gameWorld.getConfig().getSecureObjects()) { @@ -287,7 +287,7 @@ public class PlayerListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onRespawn(PlayerRespawnEvent event) { Player player = event.getPlayer(); - DPlayer dPlayer = DPlayer.get(player); + DPlayer dPlayer = DPlayer.getByPlayer(player); if (dPlayer == null) { return; @@ -307,13 +307,13 @@ public class PlayerListener implements Listener { } } else { - GameWorld gameWorld = GameWorld.get(dPlayer.getWorld()); + GameWorld gameWorld = GameWorld.getByWorld(dPlayer.getWorld()); if (gameWorld == null) { return; } - DGroup dGroup = DGroup.get(dPlayer.getPlayer()); + DGroup dGroup = DGroup.getByPlayer(dPlayer.getPlayer()); if (dPlayer.getCheckpoint() == null) { event.setRespawnLocation(dGroup.getGameWorld().getLocStart()); @@ -346,7 +346,7 @@ public class PlayerListener implements Listener { public void onPortal(PlayerPortalEvent event) { Player player = event.getPlayer(); Location location = event.getFrom(); - DPortal dportal = DPortal.get(location); + DPortal dportal = DPortal.getByLocation(location); if (dportal != null) { event.setCancelled(true); @@ -357,7 +357,7 @@ public class PlayerListener implements Listener { @EventHandler(priority = EventPriority.HIGH) public void onTeleport(PlayerTeleportEvent event) { Player player = event.getPlayer(); - DPlayer dPlayer = DPlayer.get(player); + DPlayer dPlayer = DPlayer.getByPlayer(player); if (dPlayer == null) { return; @@ -375,7 +375,7 @@ public class PlayerListener implements Listener { @EventHandler(priority = EventPriority.HIGH) public void onChat(AsyncPlayerChatEvent event) { Player player = event.getPlayer(); - DPlayer dPlayer = DPlayer.get(player); + DPlayer dPlayer = DPlayer.getByPlayer(player); if (dPlayer == null) { return; } @@ -389,16 +389,16 @@ public class PlayerListener implements Listener { @EventHandler(priority = EventPriority.HIGH) public void onQuit(PlayerQuitEvent event) { Player player = event.getPlayer(); - DPlayer dPlayer = DPlayer.get(player); + DPlayer dPlayer = DPlayer.getByPlayer(player); if (dPlayer == null) { return; } - DGroup dGroup = DGroup.get(player); + DGroup dGroup = DGroup.getByPlayer(player); // Check GameWorld - GameWorld gameWorld = GameWorld.get(player.getWorld()); + GameWorld gameWorld = GameWorld.getByWorld(player.getWorld()); if (gameWorld != null) { int timeUntilKickOfflinePlayer = gameWorld.getConfig().getTimeUntilKickOfflinePlayer(); @@ -423,9 +423,9 @@ public class PlayerListener implements Listener { Player player = event.getPlayer(); // Check dPlayers - DPlayer dPlayer = DPlayer.get(player.getName()); + DPlayer dPlayer = DPlayer.getByPlayer(player); if (dPlayer != null) { - DGroup dGroup = DGroup.get(dPlayer.getPlayer()); + DGroup dGroup = DGroup.getByPlayer(dPlayer.getPlayer()); if (dGroup != null) { dGroup.getPlayers().remove(dPlayer.getPlayer()); dGroup.getPlayers().add(player); @@ -441,7 +441,7 @@ public class PlayerListener implements Listener { return; } - if (DPlayer.get(player) != null) { + if (DPlayer.getByPlayer(player) != null) { return; } @@ -461,7 +461,7 @@ public class PlayerListener implements Listener { DGroup dGroup = new DGroup(player, plugin.getMainConfig().getTutorialDungeon(), false); if (dGroup.getGameWorld() == null) { - dGroup.setGameWorld(GameWorld.load(DGroup.get(player).getMapName())); + dGroup.setGameWorld(GameWorld.load(DGroup.getByPlayer(player).getMapName())); dGroup.getGameWorld().setTutorial(true); } @@ -483,7 +483,7 @@ public class PlayerListener implements Listener { return; } - DPlayer dPlayer = DPlayer.get(event.getPlayer()); + DPlayer dPlayer = DPlayer.getByPlayer(event.getPlayer()); if (dPlayer == null) { return; } @@ -532,7 +532,7 @@ public class PlayerListener implements Listener { @EventHandler public void onMove(PlayerMoveEvent event) { Player player = event.getPlayer(); - DLootInventory inventory = DLootInventory.get(player); + DLootInventory inventory = DLootInventory.getByPlayer(player); if (inventory == null) { return; @@ -567,7 +567,7 @@ public class PlayerListener implements Listener { MiscUtil.secureTeleport(player, location); } - DPlayer dPlayer = DPlayer.get(player); + DPlayer dPlayer = DPlayer.getByPlayer(player); if (dPlayer == null) { return; diff --git a/src/io/github/dre2n/dungeonsxl/listener/WorldListener.java b/src/io/github/dre2n/dungeonsxl/listener/WorldListener.java index d2c89336..b3cb13bc 100644 --- a/src/io/github/dre2n/dungeonsxl/listener/WorldListener.java +++ b/src/io/github/dre2n/dungeonsxl/listener/WorldListener.java @@ -11,9 +11,9 @@ public class WorldListener implements Listener { @EventHandler(priority = EventPriority.HIGH) public void onChunkUnload(ChunkUnloadEvent event) { - GameWorld gWorld = GameWorld.get(event.getWorld()); - if (gWorld != null) { - if (gWorld.getLoadedChunks().contains(event.getChunk())) { + GameWorld gameWorld = GameWorld.getByWorld(event.getWorld()); + if (gameWorld != null) { + if (gameWorld.getLoadedChunks().contains(event.getChunk())) { event.setCancelled(true); } } diff --git a/src/io/github/dre2n/dungeonsxl/mob/DMob.java b/src/io/github/dre2n/dungeonsxl/mob/DMob.java index 5754c9f2..e57e1922 100644 --- a/src/io/github/dre2n/dungeonsxl/mob/DMob.java +++ b/src/io/github/dre2n/dungeonsxl/mob/DMob.java @@ -18,7 +18,7 @@ public class DMob { private String trigger; public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type) { - gameWorld.getdMobs().add(this); + gameWorld.getDMobs().add(this); this.entity = entity; this.type = type; @@ -32,7 +32,7 @@ public class DMob { } public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type, String trigger) { - gameWorld.getdMobs().add(this); + gameWorld.getDMobs().add(this); this.entity = entity; this.type = type; @@ -54,23 +54,23 @@ public class DMob { } LivingEntity victim = event.getEntity(); - GameWorld gameWorld = GameWorld.get(victim.getWorld()); + GameWorld gameWorld = GameWorld.getByWorld(victim.getWorld()); String name = null; if (gameWorld == null) { return; } - for (DMob dMob : gameWorld.getdMobs()) { + for (DMob dMob : gameWorld.getDMobs()) { if (dMob.entity == victim) { if (dMob.type != null) { - for (ItemStack item : dMob.type.getDrops().keySet()) { + for (ItemStack itemStack : dMob.type.getDrops().keySet()) { Random randomGenerator = new Random(); int random = randomGenerator.nextInt(100); - if (dMob.type.getDrops().get(item) > random) { - event.getDrops().add(item); + if (dMob.type.getDrops().get(itemStack) > random) { + event.getDrops().add(itemStack); } } name = dMob.type.getName(); @@ -87,7 +87,7 @@ public class DMob { trigger.onTrigger(); } - gameWorld.getdMobs().remove(dMob); + gameWorld.getDMobs().remove(dMob); return; } } diff --git a/src/io/github/dre2n/dungeonsxl/mob/DMobType.java b/src/io/github/dre2n/dungeonsxl/mob/DMobType.java index 694ba0a6..fec07a23 100644 --- a/src/io/github/dre2n/dungeonsxl/mob/DMobType.java +++ b/src/io/github/dre2n/dungeonsxl/mob/DMobType.java @@ -41,7 +41,7 @@ public class DMobType { private Map drops = new HashMap(); /* Extra Values for different Mob Types */ - private boolean isWitherSkeleton = false; + private boolean witherSkeleton = false; private String ocelotType = null; /* Methods */ @@ -70,7 +70,7 @@ public class DMobType { /* Check mob specified stuff */ if (type == EntityType.SKELETON) { - if (isWitherSkeleton) { + if (witherSkeleton) { ((Skeleton) entity).setSkeletonType(SkeletonType.WITHER); } else { ((Skeleton) entity).setSkeletonType(SkeletonType.NORMAL); @@ -79,16 +79,8 @@ public class DMobType { if (type == EntityType.OCELOT) { Ocelot ocelot = (Ocelot) entity; - if (ocelotType != null) { - if (ocelotType.equalsIgnoreCase("BLACK_CAT")) { - ocelot.setCatType(Ocelot.Type.BLACK_CAT); - } else if (ocelotType.equalsIgnoreCase("RED_CAT")) { - ocelot.setCatType(Ocelot.Type.RED_CAT); - } else if (ocelotType.equalsIgnoreCase("SIAMESE_CAT")) { - ocelot.setCatType(Ocelot.Type.SIAMESE_CAT); - } else if (ocelotType.equalsIgnoreCase("WILD_OCELOT")) { - ocelot.setCatType(Ocelot.Type.WILD_OCELOT); - } + if (Ocelot.Type.valueOf(ocelotType.toUpperCase()) != null) { + ocelot.setCatType(Ocelot.Type.valueOf(ocelotType.toUpperCase())); } } @@ -159,7 +151,7 @@ public class DMobType { // Load different Mob options if (configFile.contains(mobName + ".isWitherSkeleton")) { - mobType.isWitherSkeleton = configFile.getBoolean(mobName + ".isWitherSkeleton"); + mobType.witherSkeleton = configFile.getBoolean(mobName + ".isWitherSkeleton"); } if (configFile.contains(mobName + ".ocelotType")) { @@ -233,7 +225,7 @@ public class DMobType { } // Get - public static DMobType get(String name, Set mobTypes) { + public static DMobType getByName(String name, Set mobTypes) { for (DMobType mobType : mobTypes) { if (mobType.name.equalsIgnoreCase(name)) { return mobType; @@ -266,6 +258,111 @@ public class DMobType { this.name = name; } + /** + * @return the type + */ + public EntityType getType() { + return type; + } + + /** + * @param type + * the type to set + */ + public void setType(EntityType type) { + this.type = type; + } + + /** + * @return the maxHealth + */ + public int getMaxHealth() { + return maxHealth; + } + + /** + * @param maxHealth + * the maxHealth to set + */ + public void setMaxHealth(int maxHealth) { + this.maxHealth = maxHealth; + } + + /** + * @return the itemHand + */ + public ItemStack getItemHand() { + return ItemHand; + } + + /** + * @param itemHand + * the itemHand to set + */ + public void setItemHand(ItemStack itemHand) { + ItemHand = itemHand; + } + + /** + * @return the itemHelmet + */ + public ItemStack getItemHelmet() { + return ItemHelmet; + } + + /** + * @param itemHelmet + * the itemHelmet to set + */ + public void setItemHelmet(ItemStack itemHelmet) { + ItemHelmet = itemHelmet; + } + + /** + * @return the itemChestplate + */ + public ItemStack getItemChestplate() { + return ItemChestplate; + } + + /** + * @param itemChestplate + * the itemChestplate to set + */ + public void setItemChestplate(ItemStack itemChestplate) { + ItemChestplate = itemChestplate; + } + + /** + * @return the itemLeggings + */ + public ItemStack getItemLeggings() { + return ItemLeggings; + } + + /** + * @param itemLeggings + * the itemLeggings to set + */ + public void setItemLeggings(ItemStack itemLeggings) { + ItemLeggings = itemLeggings; + } + + /** + * @return the itemBoots + */ + public ItemStack getItemBoots() { + return ItemBoots; + } + + /** + * @param itemBoots + * the itemBoots to set + */ + public void setItemBoots(ItemStack itemBoots) { + ItemBoots = itemBoots; + } + /** * @return the drops */ @@ -281,4 +378,34 @@ public class DMobType { this.drops = drops; } + /** + * @return if the skeleton is a wither skeleton + */ + public boolean isWitherSkeleton() { + return witherSkeleton; + } + + /** + * @param witherSkeleton + * set if the skeleton is a wither skeleton + */ + public void setWitherSkeleton(boolean witherSkeleton) { + this.witherSkeleton = witherSkeleton; + } + + /** + * @return the ocelotType + */ + public String getOcelotType() { + return ocelotType; + } + + /** + * @param ocelotType + * the ocelotType to set + */ + public void setOcelotType(String ocelotType) { + this.ocelotType = ocelotType; + } + } diff --git a/src/io/github/dre2n/dungeonsxl/player/DClass.java b/src/io/github/dre2n/dungeonsxl/player/DClass.java index 7dba51a5..3150746e 100644 --- a/src/io/github/dre2n/dungeonsxl/player/DClass.java +++ b/src/io/github/dre2n/dungeonsxl/player/DClass.java @@ -8,12 +8,12 @@ public class DClass { private CopyOnWriteArrayList items = new CopyOnWriteArrayList(); private String name; - private boolean hasDog; + private boolean dog; - public DClass(String name, CopyOnWriteArrayList items, boolean hasDog) { + public DClass(String name, CopyOnWriteArrayList items, boolean dog) { this.items = items; this.name = name; - this.hasDog = hasDog; + this.dog = dog; } /** @@ -50,15 +50,15 @@ public class DClass { * @return if the class has a dog */ public boolean hasDog() { - return hasDog; + return dog; } /** - * @param hasDog + * @param dog * set if the class has a dog */ - public void setDog(boolean hasDog) { - this.hasDog = hasDog; + public void setDog(boolean dog) { + this.dog = dog; } } diff --git a/src/io/github/dre2n/dungeonsxl/player/DGroup.java b/src/io/github/dre2n/dungeonsxl/player/DGroup.java index 2c9ba7fc..a4675b6c 100644 --- a/src/io/github/dre2n/dungeonsxl/player/DGroup.java +++ b/src/io/github/dre2n/dungeonsxl/player/DGroup.java @@ -61,7 +61,7 @@ public class DGroup { public void addPlayer(Player player) { // Send message for (Player groupPlayer : getPlayers()) { - MessageUtil.sendMessage(groupPlayer, DungeonsXL.getPlugin().getDMessages().getMessage(Messages.PLAYER_JOIN_GROUP, player.getName())); + MessageUtil.sendMessage(groupPlayer, plugin.getDMessages().getMessage(Messages.PLAYER_JOIN_GROUP, player.getName())); } // Add player @@ -78,7 +78,7 @@ public class DGroup { // Send message for (Player groupPlayer : getPlayers()) { - MessageUtil.sendMessage(groupPlayer, DungeonsXL.getPlugin().getDMessages().getMessage(Messages.PLAYER_LEFT_GROUP, player.getName())); + MessageUtil.sendMessage(groupPlayer, plugin.getDMessages().getMessage(Messages.PLAYER_LEFT_GROUP, player.getName())); } // Check group @@ -167,7 +167,7 @@ public class DGroup { * the unplayedFloor to add */ public void removeUnplayedFloor(String unplayedFloor) { - if (getDungeon().getConfig().isRemoveWhenPlayed()) { + if (getDungeon().getConfig().getRemoveWhenPlayed()) { unplayedFloors.remove(unplayedFloor); } } @@ -224,8 +224,8 @@ public class DGroup { fee = new WorldConfig(file).getFee(); for (Player player : getPlayers()) { - DPlayer dplayer = DPlayer.get(player); - dplayer.respawn(); + DPlayer dPlayer = DPlayer.getByPlayer(player); + dPlayer.respawn(); if (dungeonName != null) { MessageUtil.sendScreenMessage(player, "&b&l" + dungeonName.replaceAll("_", " "), "&4&l" + mapName.replaceAll("_", "")); @@ -272,7 +272,7 @@ public class DGroup { // Statics - public static DGroup get(Player player) { + public static DGroup getByPlayer(Player player) { for (DGroup dGroup : plugin.getDGroups()) { if (dGroup.getPlayers().contains(player)) { return dGroup; @@ -282,7 +282,7 @@ public class DGroup { return null; } - public static DGroup get(GameWorld gameWorld) { + public static DGroup getByGameWorld(GameWorld gameWorld) { for (DGroup dGroup : plugin.getDGroups()) { if (dGroup.getGameWorld() == gameWorld) { return dGroup; diff --git a/src/io/github/dre2n/dungeonsxl/player/DPlayer.java b/src/io/github/dre2n/dungeonsxl/player/DPlayer.java index 50adefde..908e794b 100644 --- a/src/io/github/dre2n/dungeonsxl/player/DPlayer.java +++ b/src/io/github/dre2n/dungeonsxl/player/DPlayer.java @@ -44,14 +44,13 @@ public class DPlayer { private Player player; private World world; - private boolean isInTestMode = false; - private DSavePlayer savePlayer; - private boolean isEditing; - private boolean isInDungeonChat = false; - private boolean isReady = false; - private boolean isFinished = false; + private boolean inTestMode = false; + private boolean editing; + private boolean inDungeonChat = false; + private boolean ready = false; + private boolean finished = false; private DClass dClass; private Location checkpoint; @@ -68,7 +67,7 @@ public class DPlayer { private int initialLives = -1; private int lives; - public DPlayer(Player player, World world, Location teleport, boolean isEditing) { + public DPlayer(Player player, World world, Location teleport, boolean editing) { plugin.getDPlayers().add(this); this.setPlayer(player); @@ -79,22 +78,22 @@ public class DPlayer { savePlayer = new DSavePlayer(player.getName(), player.getUniqueId(), player.getLocation(), player.getInventory().getContents(), player.getInventory().getArmorContents(), player.getLevel(), player.getTotalExperience(), (int) health, player.getFoodLevel(), player.getFireTicks(), player.getGameMode(), player.getActivePotionEffects()); - this.isEditing = isEditing; + this.editing = editing; - if (this.isEditing) { + if (this.editing) { this.getPlayer().setGameMode(GameMode.CREATIVE); clearPlayerData(); } else { this.getPlayer().setGameMode(GameMode.SURVIVAL); - WorldConfig dConfig = GameWorld.get(world).getConfig(); + WorldConfig dConfig = GameWorld.getByWorld(world).getConfig(); if ( !dConfig.getKeepInventoryOnEnter()) { clearPlayerData(); } if (dConfig.isLobbyDisabled()) { ready(); } - initialLives = GameWorld.get(world).getConfig().getInitialLives(); + initialLives = GameWorld.getByWorld(world).getConfig().getInitialLives(); lives = initialLives; } @@ -120,9 +119,9 @@ public class DPlayer { public void leave() { remove(this); - if ( !isEditing) { - WorldConfig dConfig = GameWorld.get(world).getConfig(); - if (isFinished) { + if ( !editing) { + WorldConfig dConfig = GameWorld.getByWorld(world).getConfig(); + if (finished) { savePlayer.reset(dConfig.getKeepInventoryOnFinish()); } else { savePlayer.reset(dConfig.getKeepInventoryOnEscape()); @@ -131,22 +130,22 @@ public class DPlayer { savePlayer.reset(false); } - if (isEditing) { - EditWorld eworld = EditWorld.get(world); - if (eworld != null) { - eworld.save(); + if (editing) { + EditWorld editWorld = EditWorld.get(world); + if (editWorld != null) { + editWorld.save(); } } else { - GameWorld gameWorld = GameWorld.get(world); - DGroup dGroup = DGroup.get(getPlayer()); + GameWorld gameWorld = GameWorld.getByWorld(world); + DGroup dGroup = DGroup.getByPlayer(getPlayer()); if (dGroup != null) { dGroup.removePlayer(getPlayer()); } // Belohnung - if ( !isInTestMode) {// Nur wenn man nicht am Testen ist - if (isFinished) { + if ( !inTestMode) {// Nur wenn man nicht am Testen ist + if (finished) { addTreasure(); if (plugin.getEconomyProvider() != null) { plugin.getEconomyProvider().depositPlayer(getPlayer(), treasureMoney); @@ -169,8 +168,9 @@ public class DPlayer { try { playerConfig.save(file); - } catch (IOException e) { - e.printStackTrace(); + + } catch (IOException exception) { + exception.printStackTrace(); } // Tutorial Permissions @@ -192,35 +192,34 @@ public class DPlayer { if (dGroup != null) { if ( !dGroup.isEmpty()) { int i = 0; - Player groupplayer; + Player groupPlayer; do { - groupplayer = dGroup.getPlayers().get(i); - if (groupplayer != null) { - org.bukkit.Bukkit.broadcastMessage("14"); + groupPlayer = dGroup.getPlayers().get(i); + if (groupPlayer != null) { for (ItemStack istack : getPlayer().getInventory()) { if (istack != null) { if (gameWorld.getSecureObjects().contains(istack.getType())) { - groupplayer.getInventory().addItem(istack); + groupPlayer.getInventory().addItem(istack); } } } } i++; - } while (groupplayer == null); + } while (groupPlayer == null); } } } } public void ready() { - isReady = true; + ready = true; - DGroup dGroup = DGroup.get(getPlayer()); + DGroup dGroup = DGroup.getByPlayer(getPlayer()); if ( !dGroup.isPlaying()) { if (dGroup != null) { for (Player player : dGroup.getPlayers()) { - DPlayer dplayer = get(player); - if ( !dplayer.isReady) { + DPlayer dPlayer = getByPlayer(player); + if ( !dPlayer.ready) { return; } } @@ -233,7 +232,7 @@ public class DPlayer { } public void respawn() { - DGroup dGroup = DGroup.get(getPlayer()); + DGroup dGroup = DGroup.getByPlayer(getPlayer()); if (checkpoint == null) { MiscUtil.secureTeleport(getPlayer(), dGroup.getGameWorld().getLocStart()); } else { @@ -244,7 +243,7 @@ public class DPlayer { } // Respawn Items - if (GameWorld.get(world).getConfig().getKeepInventoryOnDeath()) { + if (GameWorld.getByWorld(world).getConfig().getKeepInventoryOnDeath()) { if (respawnInventory != null || respawnArmor != null) { getPlayer().getInventory().setContents(respawnInventory); getPlayer().getInventory().setArmorContents(respawnArmor); @@ -257,9 +256,9 @@ public class DPlayer { public void finishFloor(String specifiedFloor) { MessageUtil.sendMessage(getPlayer(), dMessages.getMessage(Messages.PLAYER_FINISHED_DUNGEON)); - isFinished = true; + finished = true; - DGroup dGroup = DGroup.get(getPlayer()); + DGroup dGroup = DGroup.getByPlayer(getPlayer()); if (dGroup == null) { return; } @@ -269,8 +268,8 @@ public class DPlayer { } for (Player player : dGroup.getPlayers()) { - DPlayer dplayer = get(player); - if ( !dplayer.isFinished) { + DPlayer dPlayer = getByPlayer(player); + if ( !dPlayer.finished) { MessageUtil.sendMessage(this.getPlayer(), dMessages.getMessage(Messages.PLAYER_WAIT_FOR_OTHER_PLAYERS)); return; } @@ -283,13 +282,13 @@ public class DPlayer { } for (Player player : dGroup.getPlayers()) { - DPlayer dPlayer = get(player); + DPlayer dPlayer = getByPlayer(player); if (invalid) { dPlayer.leave(); } else { - dPlayer.isFinished = false; + dPlayer.finished = false; } } @@ -311,7 +310,7 @@ public class DPlayer { GameWorld gameWorld = GameWorld.load(newFloor); dGroup.setGameWorld(gameWorld); for (Player player : dGroup.getPlayers()) { - DPlayer dPlayer = get(player); + DPlayer dPlayer = getByPlayer(player); dPlayer.setWorld(gameWorld.getWorld()); dPlayer.setCheckpoint(dGroup.getGameWorld().getLocStart()); if (dPlayer.getWolf() != null) { @@ -323,9 +322,9 @@ public class DPlayer { public void finish() { MessageUtil.sendMessage(getPlayer(), dMessages.getMessage(Messages.PLAYER_FINISHED_DUNGEON)); - isFinished = true; + finished = true; - DGroup dGroup = DGroup.get(getPlayer()); + DGroup dGroup = DGroup.getByPlayer(getPlayer()); if (dGroup == null) { return; } @@ -335,21 +334,21 @@ public class DPlayer { } for (Player player : dGroup.getPlayers()) { - DPlayer dplayer = get(player); - if ( !dplayer.isFinished) { + DPlayer dPlayer = getByPlayer(player); + if ( !dPlayer.finished) { MessageUtil.sendMessage(this.getPlayer(), dMessages.getMessage(Messages.PLAYER_WAIT_FOR_OTHER_PLAYERS)); return; } } for (Player player : dGroup.getPlayers()) { - DPlayer dPlayer = get(player); + DPlayer dPlayer = getByPlayer(player); dPlayer.leave(); } } public void sendMessage(String message) { - if (isEditing) { + if (editing) { EditWorld editWorld = EditWorld.get(world); editWorld.msg(message); for (Player player : plugin.getChatSpyers()) { @@ -359,7 +358,7 @@ public class DPlayer { } } else { - GameWorld gameWorld = GameWorld.get(world); + GameWorld gameWorld = GameWorld.getByWorld(world); gameWorld.msg(message); for (Player player : plugin.getChatSpyers()) { if ( !gameWorld.getWorld().getPlayers().contains(player)) { @@ -433,21 +432,6 @@ public class DPlayer { this.world = world; } - /** - * @return the isinTestMode - */ - public boolean isIsinTestMode() { - return isInTestMode; - } - - /** - * @param isInTestMode - * the isInTestMode to set - */ - public void setIsInTestMode(boolean isInTestMode) { - this.isInTestMode = isInTestMode; - } - /** * @return the savePlayer */ @@ -464,63 +448,78 @@ public class DPlayer { } /** - * @return the isEditing + * @return if the player is in test mode + */ + public boolean isInTestMode() { + return inTestMode; + } + + /** + * @param inTestMode + * if the player is in test mode + */ + public void setInTestMode(boolean inTestMode) { + this.inTestMode = inTestMode; + } + + /** + * @return the editing */ public boolean isEditing() { - return isEditing; + return editing; } /** - * @param isEditing - * the isEditing to set + * @param editing + * the editing to set */ - public void setEditing(boolean isEditing) { - this.isEditing = isEditing; + public void setEditing(boolean editing) { + this.editing = editing; } /** - * @return the isInDungeonChat + * @return the inDungeonChat */ public boolean isInDungeonChat() { - return isInDungeonChat; + return inDungeonChat; } /** - * @param isInDungeonChat - * the isInDungeonChat to set + * @param inDungeonChat + * the inDungeonChat to set */ - public void setInDungeonChat(boolean isInDungeonChat) { - this.isInDungeonChat = isInDungeonChat; + public void setInDungeonChat(boolean inDungeonChat) { + this.inDungeonChat = inDungeonChat; } /** * @return the isReady */ public boolean isReady() { - return isReady; + return ready; } /** - * @param isReady - * the isReady to set + * @param ready + * If the player is ready to play the dungeon */ - public void setReady(boolean isReady) { - this.isReady = isReady; + public void setReady(boolean ready) { + this.ready = ready; } /** - * @return the isFinished + * @return the finished */ public boolean isFinished() { - return isFinished; + return finished; } /** - * @param isFinished - * the isFinished to set + * @param finished + * the finished to set */ - public void setFinished(boolean isFinished) { - this.isFinished = isFinished; + public void setFinished(boolean finished) { + this.finished = finished; } /** @@ -535,7 +534,7 @@ public class DPlayer { * the dClass to set */ public void setDClass(String className) { - GameWorld gameWorld = GameWorld.get(getPlayer().getWorld()); + GameWorld gameWorld = GameWorld.getByWorld(getPlayer().getWorld()); if (gameWorld == null) { return; } @@ -777,30 +776,30 @@ public class DPlayer { plugin.getDPlayers().remove(player); } - public static DPlayer get(Player player) { - for (DPlayer dplayer : plugin.getDPlayers()) { - if (dplayer.getPlayer().equals(player)) { - return dplayer; + public static DPlayer getByPlayer(Player player) { + for (DPlayer dPlayer : plugin.getDPlayers()) { + if (dPlayer.getPlayer().equals(player)) { + return dPlayer; } } return null; } - public static DPlayer get(String name) { - for (DPlayer dplayer : plugin.getDPlayers()) { - if (dplayer.getPlayer().getName().equalsIgnoreCase(name)) { - return dplayer; + public static DPlayer getByName(String name) { + for (DPlayer dPlayer : plugin.getDPlayers()) { + if (dPlayer.getPlayer().getName().equalsIgnoreCase(name)) { + return dPlayer; } } return null; } - public static CopyOnWriteArrayList get(World world) { + public static CopyOnWriteArrayList getByWorld(World world) { CopyOnWriteArrayList dPlayers = new CopyOnWriteArrayList(); - for (DPlayer dplayer : plugin.getDPlayers()) { - if (dplayer.world == world) { - dPlayers.add(dplayer); + for (DPlayer dPlayer : plugin.getDPlayers()) { + if (dPlayer.world == world) { + dPlayers.add(dPlayer); } } @@ -808,70 +807,70 @@ public class DPlayer { } public static void update(boolean updateSecond) { - for (DPlayer dplayer : plugin.getDPlayers()) { + for (DPlayer dPlayer : plugin.getDPlayers()) { if ( !updateSecond) { - if ( !dplayer.getPlayer().getWorld().equals(dplayer.world)) { - if (dplayer.isEditing) { - EditWorld eworld = EditWorld.get(dplayer.world); - if (eworld != null) { - if (eworld.getLobby() == null) { - MiscUtil.secureTeleport(dplayer.getPlayer(), eworld.getWorld().getSpawnLocation()); + if ( !dPlayer.getPlayer().getWorld().equals(dPlayer.world)) { + if (dPlayer.editing) { + EditWorld editWorld = EditWorld.get(dPlayer.world); + if (editWorld != null) { + if (editWorld.getLobby() == null) { + MiscUtil.secureTeleport(dPlayer.getPlayer(), editWorld.getWorld().getSpawnLocation()); } else { - MiscUtil.secureTeleport(dplayer.getPlayer(), eworld.getLobby()); + MiscUtil.secureTeleport(dPlayer.getPlayer(), editWorld.getLobby()); } } } else { - GameWorld gameWorld = GameWorld.get(dplayer.world); + GameWorld gameWorld = GameWorld.getByWorld(dPlayer.world); if (gameWorld != null) { - DGroup dGroup = DGroup.get(dplayer.getPlayer()); - if (dplayer.checkpoint == null) { - MiscUtil.secureTeleport(dplayer.getPlayer(), dGroup.getGameWorld().getLocStart()); - if (dplayer.wolf != null) { - dplayer.wolf.teleport(dGroup.getGameWorld().getLocStart()); + DGroup dGroup = DGroup.getByPlayer(dPlayer.getPlayer()); + if (dPlayer.checkpoint == null) { + MiscUtil.secureTeleport(dPlayer.getPlayer(), dGroup.getGameWorld().getLocStart()); + if (dPlayer.wolf != null) { + dPlayer.wolf.teleport(dGroup.getGameWorld().getLocStart()); } } else { - MiscUtil.secureTeleport(dplayer.getPlayer(), dplayer.checkpoint); - if (dplayer.wolf != null) { - dplayer.wolf.teleport(dplayer.checkpoint); + MiscUtil.secureTeleport(dPlayer.getPlayer(), dPlayer.checkpoint); + if (dPlayer.wolf != null) { + dPlayer.wolf.teleport(dPlayer.checkpoint); } } // Respawn Items - if (dplayer.respawnInventory != null || dplayer.respawnArmor != null) { - dplayer.getPlayer().getInventory().setContents(dplayer.respawnInventory); - dplayer.getPlayer().getInventory().setArmorContents(dplayer.respawnArmor); - dplayer.respawnInventory = null; - dplayer.respawnArmor = null; + if (dPlayer.respawnInventory != null || dPlayer.respawnArmor != null) { + dPlayer.getPlayer().getInventory().setContents(dPlayer.respawnInventory); + dPlayer.getPlayer().getInventory().setArmorContents(dPlayer.respawnArmor); + dPlayer.respawnInventory = null; + dPlayer.respawnArmor = null; } } } } } else { - GameWorld gameWorld = GameWorld.get(dplayer.world); + GameWorld gameWorld = GameWorld.getByWorld(dPlayer.world); if (gameWorld != null) { // Update Wolf - if (dplayer.wolf != null) { - if (dplayer.wolf.isDead()) { - if (dplayer.wolfRespawnTime <= 0) { - dplayer.wolf = (Wolf) dplayer.world.spawnEntity(dplayer.getPlayer().getLocation(), EntityType.WOLF); - dplayer.wolf.setTamed(true); - dplayer.wolf.setOwner(dplayer.getPlayer()); - dplayer.wolfRespawnTime = 30; + if (dPlayer.wolf != null) { + if (dPlayer.wolf.isDead()) { + if (dPlayer.wolfRespawnTime <= 0) { + dPlayer.wolf = (Wolf) dPlayer.world.spawnEntity(dPlayer.getPlayer().getLocation(), EntityType.WOLF); + dPlayer.wolf.setTamed(true); + dPlayer.wolf.setOwner(dPlayer.getPlayer()); + dPlayer.wolfRespawnTime = 30; } - dplayer.wolfRespawnTime--; + dPlayer.wolfRespawnTime--; } } // Kick offline plugin.getDPlayers() - if (dplayer.offlineTime > 0) { - if (dplayer.offlineTime < System.currentTimeMillis()) { - dplayer.leave(); + if (dPlayer.offlineTime > 0) { + if (dPlayer.offlineTime < System.currentTimeMillis()) { + dPlayer.leave(); } } // Check Distance Trigger Signs - DistanceTrigger.triggerAllInDistance(dplayer.getPlayer(), gameWorld); + DistanceTrigger.triggerAllInDistance(dPlayer.getPlayer(), gameWorld); } } } diff --git a/src/io/github/dre2n/dungeonsxl/sign/CheckpointSign.java b/src/io/github/dre2n/dungeonsxl/sign/CheckpointSign.java index c7d3c623..a2309433 100644 --- a/src/io/github/dre2n/dungeonsxl/sign/CheckpointSign.java +++ b/src/io/github/dre2n/dungeonsxl/sign/CheckpointSign.java @@ -41,7 +41,7 @@ public class CheckpointSign extends DSign { return; } - for (DPlayer dplayer : DPlayer.get(getGameWorld().getWorld())) { + for (DPlayer dplayer : DPlayer.getByWorld(getGameWorld().getWorld())) { dplayer.setCheckpoint(getSign().getLocation()); MessageUtil.sendMessage(dplayer.getPlayer(), plugin.getDMessages().getMessage(Messages.PLAYER_CHECKPOINT_REACHED)); } @@ -55,7 +55,7 @@ public class CheckpointSign extends DSign { return true; } - DPlayer dplayer = DPlayer.get(player); + DPlayer dplayer = DPlayer.getByPlayer(player); if (dplayer != null) { if ( !done.contains(dplayer)) { done.add(dplayer); @@ -64,7 +64,7 @@ public class CheckpointSign extends DSign { } } - if (done.size() >= DPlayer.get(getGameWorld().getWorld()).size()) { + if (done.size() >= DPlayer.getByWorld(getGameWorld().getWorld()).size()) { remove(); } diff --git a/src/io/github/dre2n/dungeonsxl/sign/DSign.java b/src/io/github/dre2n/dungeonsxl/sign/DSign.java index b99da916..afd03766 100644 --- a/src/io/github/dre2n/dungeonsxl/sign/DSign.java +++ b/src/io/github/dre2n/dungeonsxl/sign/DSign.java @@ -138,7 +138,7 @@ public abstract class DSign { for (Trigger trigger : triggers) { trigger.removeListener(this); } - gameWorld.getdSigns().remove(this); + gameWorld.getDSigns().remove(this); } public boolean hasTriggers() { diff --git a/src/io/github/dre2n/dungeonsxl/sign/EndSign.java b/src/io/github/dre2n/dungeonsxl/sign/EndSign.java index 6d7c012e..f5997166 100644 --- a/src/io/github/dre2n/dungeonsxl/sign/EndSign.java +++ b/src/io/github/dre2n/dungeonsxl/sign/EndSign.java @@ -44,10 +44,10 @@ public class EndSign extends DSign { @Override public boolean onPlayerTrigger(Player player) { - DPlayer dplayer = DPlayer.get(player); - if (dplayer != null) { - if ( !dplayer.isFinished()) { - dplayer.finish(); + DPlayer dPlayer = DPlayer.getByPlayer(player); + if (dPlayer != null) { + if ( !dPlayer.isFinished()) { + dPlayer.finish(); } } return true; @@ -55,8 +55,8 @@ public class EndSign extends DSign { @Override public void onTrigger() { - for (DPlayer dplayer : plugin.getDPlayers()) { - dplayer.finish(); + for (DPlayer dPlayer : plugin.getDPlayers()) { + dPlayer.finish(); } } diff --git a/src/io/github/dre2n/dungeonsxl/sign/FloorSign.java b/src/io/github/dre2n/dungeonsxl/sign/FloorSign.java index 55defb13..f957ea57 100644 --- a/src/io/github/dre2n/dungeonsxl/sign/FloorSign.java +++ b/src/io/github/dre2n/dungeonsxl/sign/FloorSign.java @@ -55,10 +55,10 @@ public class FloorSign extends DSign { @Override public boolean onPlayerTrigger(Player player) { - DPlayer dplayer = DPlayer.get(player); - if (dplayer != null) { - if ( !dplayer.isFinished()) { - dplayer.finishFloor(floor); + DPlayer dPlayer = DPlayer.getByPlayer(player); + if (dPlayer != null) { + if ( !dPlayer.isFinished()) { + dPlayer.finishFloor(floor); } } @@ -67,8 +67,8 @@ public class FloorSign extends DSign { @Override public void onTrigger() { - for (DPlayer dplayer : plugin.getDPlayers()) { - dplayer.finish(); + for (DPlayer dPlayer : plugin.getDPlayers()) { + dPlayer.finish(); } } diff --git a/src/io/github/dre2n/dungeonsxl/sign/LeaveSign.java b/src/io/github/dre2n/dungeonsxl/sign/LeaveSign.java index 4f57b8a3..3948aeac 100644 --- a/src/io/github/dre2n/dungeonsxl/sign/LeaveSign.java +++ b/src/io/github/dre2n/dungeonsxl/sign/LeaveSign.java @@ -44,9 +44,9 @@ public class LeaveSign extends DSign { @Override public boolean onPlayerTrigger(Player player) { - DPlayer dplayer = DPlayer.get(player); - if (dplayer != null) { - dplayer.leave(); + DPlayer dPlayer = DPlayer.getByPlayer(player); + if (dPlayer != null) { + dPlayer.leave(); } return true; @@ -54,8 +54,8 @@ public class LeaveSign extends DSign { @Override public void onTrigger() { - for (DPlayer dplayer : DungeonsXL.getPlugin().getDPlayers()) { - dplayer.leave(); + for (DPlayer dPlayer : DungeonsXL.getPlugin().getDPlayers()) { + dPlayer.leave(); } } diff --git a/src/io/github/dre2n/dungeonsxl/sign/MobSign.java b/src/io/github/dre2n/dungeonsxl/sign/MobSign.java index 6ee791dd..e9eec10b 100644 --- a/src/io/github/dre2n/dungeonsxl/sign/MobSign.java +++ b/src/io/github/dre2n/dungeonsxl/sign/MobSign.java @@ -118,7 +118,7 @@ public class MobSign extends DSign { public void run() { if (sign.interval <= 0) { World world = sign.getSign().getWorld(); - GameWorld gameWorld = GameWorld.get(world); + GameWorld gameWorld = GameWorld.getByWorld(world); if (gameWorld != null) { Location spawnLoc = sign.getSign().getLocation().add(0.5, 0, 0.5); @@ -144,10 +144,10 @@ public class MobSign extends DSign { } // Check custom mobs - DMobType mobType = DMobType.get(sign.mob, gameWorld.getConfig().getMobTypes()); + DMobType mobType = DMobType.getByName(sign.mob, gameWorld.getConfig().getMobTypes()); if (mobType != null) { - mobType.spawn(GameWorld.get(world), spawnLoc); + mobType.spawn(GameWorld.getByWorld(world), spawnLoc); } // Set the amount diff --git a/src/io/github/dre2n/dungeonsxl/sign/MythicMobsSign.java b/src/io/github/dre2n/dungeonsxl/sign/MythicMobsSign.java index 5397e86f..0b648fff 100644 --- a/src/io/github/dre2n/dungeonsxl/sign/MythicMobsSign.java +++ b/src/io/github/dre2n/dungeonsxl/sign/MythicMobsSign.java @@ -120,7 +120,7 @@ public class MythicMobsSign extends DSign { public void run() { if (sign.interval <= 0) { World world = sign.getSign().getWorld(); - GameWorld gameWorld = GameWorld.get(world); + GameWorld gameWorld = GameWorld.getByWorld(world); if (gameWorld != null) { spawnLoc = sign.getSign().getLocation().add(0.5, 0, 0.5); diff --git a/src/io/github/dre2n/dungeonsxl/sign/ReadySign.java b/src/io/github/dre2n/dungeonsxl/sign/ReadySign.java index 01087fc2..ef8758c0 100644 --- a/src/io/github/dre2n/dungeonsxl/sign/ReadySign.java +++ b/src/io/github/dre2n/dungeonsxl/sign/ReadySign.java @@ -47,7 +47,7 @@ public class ReadySign extends DSign { @Override public boolean onPlayerTrigger(Player player) { - ready(DPlayer.get(player)); + ready(DPlayer.getByPlayer(player)); return true; } diff --git a/src/io/github/dre2n/dungeonsxl/sign/RedstoneSign.java b/src/io/github/dre2n/dungeonsxl/sign/RedstoneSign.java index f0c07e10..445e415a 100644 --- a/src/io/github/dre2n/dungeonsxl/sign/RedstoneSign.java +++ b/src/io/github/dre2n/dungeonsxl/sign/RedstoneSign.java @@ -136,7 +136,7 @@ public class RedstoneSign extends DSign { @Override public void run() { - if (GameWorld.get(block.getWorld()) == null) { + if (GameWorld.getByWorld(block.getWorld()) == null) { disableTask(enableTaskId); disableTask(disableTaskId); return; diff --git a/src/io/github/dre2n/dungeonsxl/util/FileUtil.java b/src/io/github/dre2n/dungeonsxl/util/FileUtil.java index dfb783fa..2ce2b790 100644 --- a/src/io/github/dre2n/dungeonsxl/util/FileUtil.java +++ b/src/io/github/dre2n/dungeonsxl/util/FileUtil.java @@ -27,7 +27,7 @@ public class FileUtil { return files; } - private static final String[] excludedFiles = {"config.yml", "uid.dat", "DXLData.data"}; + private static final String[] EXCLUDED_FILES = {"config.yml", "uid.dat", "DXLData.data"}; public static void copyDirectory(File sourceLocation, File targetLocation) { if (sourceLocation.isDirectory()) { @@ -39,7 +39,7 @@ public class FileUtil { for (String element : children) { boolean isOk = true; - for (String excluded : excludedFiles) { + for (String excluded : EXCLUDED_FILES) { if (element.contains(excluded)) { isOk = false; break; @@ -85,7 +85,7 @@ public class FileUtil { } } - public static void deletenotusingfiles(File directory) { + public static void deleteUnusedFiles(File directory) { File[] files = directory.listFiles(); for (File file : files) { if (file.getName().equalsIgnoreCase("uid.dat") || file.getName().contains(".id_")) { @@ -112,8 +112,10 @@ public class FileUtil { inChannel = new FileInputStream(in).getChannel(); outChannel = new FileOutputStream(out).getChannel(); inChannel.transferTo(0, inChannel.size(), outChannel); + } catch (IOException e) { throw e; + } finally { if (inChannel != null) { inChannel.close(); diff --git a/src/io/github/dre2n/dungeonsxl/util/UUIDUtil.java b/src/io/github/dre2n/dungeonsxl/util/UUIDUtil.java index ac6de3f3..78fa92ed 100644 --- a/src/io/github/dre2n/dungeonsxl/util/UUIDUtil.java +++ b/src/io/github/dre2n/dungeonsxl/util/UUIDUtil.java @@ -21,6 +21,7 @@ public class UUIDUtil { public static boolean isValidUUID(String string) { if (string.matches("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")) { return true; + } else { return false; }