Minor code changes

This commit is contained in:
Daniel Saukel 2015-12-28 22:54:11 +01:00
parent f9e616b3cf
commit f4bd3d579a
46 changed files with 663 additions and 528 deletions

View File

@ -166,16 +166,16 @@ public class DungeonsXL extends JavaPlugin {
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
for (GameWorld gworld : gameWorlds) { for (GameWorld gameWorld : gameWorlds) {
if (gworld.getWorld().getPlayers().isEmpty()) { if (gameWorld.getWorld().getPlayers().isEmpty()) {
if (DPlayer.get(gworld.getWorld()).isEmpty()) { if (DPlayer.getByWorld(gameWorld.getWorld()).isEmpty()) {
gworld.delete(); gameWorld.delete();
} }
} }
} }
for (EditWorld eworld : editWorlds) { for (EditWorld editWorld : editWorlds) {
if (eworld.getWorld().getPlayers().isEmpty()) { if (editWorld.getWorld().getPlayers().isEmpty()) {
eworld.delete(); editWorld.delete();
} }
} }
} }
@ -239,7 +239,7 @@ public class DungeonsXL extends JavaPlugin {
if (dungeonFile.getName().contains(".id_")) { if (dungeonFile.getName().contains(".id_")) {
String dungeonName = dungeonFile.getName().substring(4); String dungeonName = dungeonFile.getName().substring(4);
FileUtil.copyDirectory(file, new File(plugin.getDataFolder(), "/maps/" + dungeonName)); 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));
} }
} }

View File

@ -20,7 +20,7 @@ public class ChatCommand extends DCommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) 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_NOT_IN_GROUP)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_IN_GROUP));

View File

@ -48,7 +48,7 @@ public class CreateCommand extends DCommand {
} else if (sender instanceof Player) { } else if (sender instanceof Player) {
Player player = (Player) sender; Player player = (Player) sender;
if (DPlayer.get(player) != null) { if (DPlayer.getByPlayer(player) != null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
return; return;
} }

View File

@ -11,24 +11,24 @@ public class DCommands {
public DCommands() { public DCommands() {
// Add Commands // Add Commands
dCommands.add(new HelpCommand()); dCommands.add(new HelpCommand());
dCommands.add(new CreateCommand());
dCommands.add(new SaveCommand());
dCommands.add(new LeaveCommand()); 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 ChatCommand());
dCommands.add(new ChatSpyCommand()); dCommands.add(new ChatSpyCommand());
dCommands.add(new LivesCommand()); dCommands.add(new CreateCommand());
dCommands.add(new ListCommand()); dCommands.add(new EditCommand());
dCommands.add(new UninviteCommand()); dCommands.add(new EscapeCommand());
dCommands.add(new InviteCommand()); 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 MsgCommand());
dCommands.add(new PlayCommand()); dCommands.add(new PlayCommand());
dCommands.add(new TestCommand()); dCommands.add(new PortalCommand());
dCommands.add(new DeletePortalCommand());
dCommands.add(new ReloadCommand()); dCommands.add(new ReloadCommand());
dCommands.add(new SaveCommand());
dCommands.add(new TestCommand());
} }
/** /**

View File

@ -10,28 +10,29 @@ import org.bukkit.Material;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@Deprecated
public class DeletePortalCommand extends DCommand { public class DeletePortalCommand extends DCommand {
public DeletePortalCommand() { public DeletePortalCommand() {
setCommand("deleteportal"); setCommand("deleteportal");
setMinArgs(0); setMinArgs(0);
setMaxArgs(0); setMaxArgs(0);
setHelp(dMessages.getMessage(Messages.HELP_CMD_DELETE_PORTAL)); setHelp("/dxl deleteportal - Deletes the portal you are looking at");
setPermission("dxl.deleteportal"); setPermission("dxl.portal");
setPlayerCommand(true); setPlayerCommand(true);
} }
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender; Player player = (Player) sender;
DPortal dPortal = DPortal.get(player.getTargetBlock((Set<Material>) null, 20).getLocation()); DPortal dPortal = DPortal.getByLocation(player.getTargetBlock((Set<Material>) null, 20).getLocation());
if (dPortal != null) { if (dPortal != null) {
dPortal.delete(); dPortal.delete();
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PORTAL_DELETED)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PROTECTED_BLOCK_DELETED));
} else { } else {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_PORTAL)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_PROTECTED_BLOCK));
} }
} }

View File

@ -23,36 +23,36 @@ public class EditCommand extends DCommand {
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender; Player player = (Player) sender;
String dungeonName = args[1]; String mapName = args[1];
EditWorld eworld = EditWorld.load(dungeonName); EditWorld editWorld = EditWorld.load(mapName);
DGroup dgroup = DGroup.get(player); DGroup dGroup = DGroup.getByPlayer(player);
DPlayer dplayer = DPlayer.get(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)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_PERMISSIONS));
return; return;
} }
if (dplayer != null) { if (dPlayer != null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
return; return;
} }
if (dgroup != null) { if (dGroup != null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_GROUP)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_GROUP));
return; return;
} }
if (eworld == null) { if (editWorld == null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, dungeonName)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, mapName));
return; return;
} }
if (eworld.getLobby() == null) { if (editWorld.getLobby() == null) {
new DPlayer(player, eworld.getWorld(), eworld.getWorld().getSpawnLocation(), true); new DPlayer(player, editWorld.getWorld(), editWorld.getWorld().getSpawnLocation(), true);
} else { } else {
new DPlayer(player, eworld.getWorld(), eworld.getLobby(), true); new DPlayer(player, editWorld.getWorld(), editWorld.getLobby(), true);
} }
} }

View File

@ -22,29 +22,29 @@ public class EscapeCommand extends DCommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender; Player player = (Player) sender;
DPlayer dplayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dplayer != null) { if (dPlayer != null) {
if ( !dplayer.isEditing()) { if ( !dPlayer.isEditing()) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
return; return;
} }
dplayer.escape(); dPlayer.escape();
EditWorld eworld = EditWorld.get(dplayer.getWorld()); EditWorld editWorld = EditWorld.get(dPlayer.getWorld());
if (eworld == null) { if (editWorld == null) {
return; return;
} }
if (eworld.getWorld().getPlayers().isEmpty()) { if (editWorld.getWorld().getPlayers().isEmpty()) {
eworld.deleteNoSave(); editWorld.deleteNoSave();
} }
} else { } else {
DGroup dgroup = DGroup.get(player); DGroup dGroup = DGroup.getByPlayer(player);
if (dgroup != null) { if (dGroup != null) {
dgroup.removePlayer(player); dGroup.removePlayer(player);
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LEAVE_SUCCESS)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LEAVE_SUCCESS));
return; return;
} }

View File

@ -22,23 +22,23 @@ public class LeaveCommand extends DCommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender; Player player = (Player) sender;
DPlayer dplayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
if (GameWorld.get(player.getWorld()) != null) { if (GameWorld.getByWorld(player.getWorld()) != null) {
if (GameWorld.get(player.getWorld()).isTutorial()) { if (GameWorld.getByWorld(player.getWorld()).isTutorial()) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_LEAVE_IN_TUTORIAL)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_LEAVE_IN_TUTORIAL));
return; return;
} }
} }
if (dplayer != null) { if (dPlayer != null) {
dplayer.leave(); dPlayer.leave();
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LEAVE_SUCCESS)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LEAVE_SUCCESS));
} else { } else {
DGroup dgroup = DGroup.get(player); DGroup dGroup = DGroup.getByPlayer(player);
if (dgroup != null) { if (dGroup != null) {
dgroup.removePlayer(player); dGroup.removePlayer(player);
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LEAVE_SUCCESS)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LEAVE_SUCCESS));
return; return;
} }

View File

@ -60,7 +60,7 @@ public class ListCommand extends DCommand {
MessageUtil.sendMessage(sender, "&estartFloor: &o[" + dungeon.getConfig().getStartFloor() + "]"); MessageUtil.sendMessage(sender, "&estartFloor: &o[" + dungeon.getConfig().getStartFloor() + "]");
MessageUtil.sendMessage(sender, "&eendFloor: &o[" + dungeon.getConfig().getEndFloor() + "]"); MessageUtil.sendMessage(sender, "&eendFloor: &o[" + dungeon.getConfig().getEndFloor() + "]");
MessageUtil.sendMessage(sender, "&efloorCount: &o[" + dungeon.getConfig().getFloorCount() + "]"); 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; return;
} }
} }

View File

@ -36,9 +36,9 @@ public class LivesCommand extends DCommand {
return; return;
} }
DPlayer dPlayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dPlayer != null) { 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 { } else {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_IN_DUNGEON)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_IN_DUNGEON));

View File

@ -28,7 +28,7 @@ public class PlayCommand extends DCommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) 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)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
@ -85,7 +85,7 @@ public class PlayCommand extends DCommand {
return; return;
} }
if (DGroup.get(player) != null) { if (DGroup.getByPlayer(player) != null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_GROUP)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_GROUP));
return; return;
} }
@ -93,7 +93,7 @@ public class PlayCommand extends DCommand {
DGroup dGroup = new DGroup(player, identifier, multiFloor); DGroup dGroup = new DGroup(player, identifier, multiFloor);
if (dGroup.getGameWorld() == null) { 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) { if (dGroup.getGameWorld().getLocLobby() == null) {

View File

@ -24,23 +24,23 @@ public class PortalCommand extends DCommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) 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)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
} }
DPortal dportal = DPortal.get(player); DPortal dPortal = DPortal.getByPlayer(player);
if (dportal == null) { if (dPortal == null) {
dportal = new DPortal(false); dPortal = new DPortal(false);
dportal.setPlayer(player); dPortal.setPlayer(player);
dportal.setWorld(player.getWorld()); dPortal.setWorld(player.getWorld());
player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD)); player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PORTAL_INTRODUCTION)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PORTAL_INTRODUCTION));
} else { } else {
plugin.getDPortals().remove(dportal); plugin.getDPortals().remove(dPortal);
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PORTAL_ABORT)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PORTAL_ABORT));
} }
} }

View File

@ -21,9 +21,9 @@ public class SaveCommand extends DCommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender; Player player = (Player) sender;
EditWorld eworld = EditWorld.get(player.getWorld()); EditWorld editWorld = EditWorld.get(player.getWorld());
if (eworld != null) { if (editWorld != null) {
eworld.save(); editWorld.save();
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_SAVE_SUCCESS)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_SAVE_SUCCESS));
} else { } else {

View File

@ -25,7 +25,7 @@ public class TestCommand extends DCommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) 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)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
@ -61,7 +61,7 @@ public class TestCommand extends DCommand {
return; return;
} }
if (DGroup.get(player) != null) { if (DGroup.getByPlayer(player) != null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_GROUP)); MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_GROUP));
return; return;
} }
@ -69,7 +69,7 @@ public class TestCommand extends DCommand {
DGroup dGroup = new DGroup(player, identifier, multiFloor); DGroup dGroup = new DGroup(player, identifier, multiFloor);
if (dGroup.getGameWorld() == null) { if (dGroup.getGameWorld() == null) {
dGroup.setGameWorld(GameWorld.load(DGroup.get(player).getMapName())); dGroup.setGameWorld(GameWorld.load(DGroup.getByPlayer(player).getMapName()));
} }
DPlayer newDPlayer; DPlayer newDPlayer;
@ -81,7 +81,7 @@ public class TestCommand extends DCommand {
newDPlayer = new DPlayer(player, dGroup.getGameWorld().getWorld(), dGroup.getGameWorld().getLocLobby(), false); newDPlayer = new DPlayer(player, dGroup.getGameWorld().getWorld(), dGroup.getGameWorld().getLocLobby(), false);
} }
newDPlayer.setIsInTestMode(true); newDPlayer.setInTestMode(true);
} }
} }

View File

@ -32,7 +32,11 @@ public class DLootInventory {
this.player = player; 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()) { for (DLootInventory inventory : plugin.getDLootInventories()) {
if (inventory.player == player) { if (inventory.player == player) {
return inventory; return inventory;

View File

@ -122,7 +122,7 @@ public class DungeonConfig extends WorldConfig {
/** /**
* @return the removeWhenPlayed * @return the removeWhenPlayed
*/ */
public boolean isRemoveWhenPlayed() { public boolean getRemoveWhenPlayed() {
return removeWhenPlayed; return removeWhenPlayed;
} }

View File

@ -80,6 +80,7 @@ public class EditWorld {
out.writeInt(sign.getZ()); out.writeInt(sign.getZ());
} }
out.close(); out.close();
} catch (IOException exception) { } catch (IOException exception) {
} }
} }
@ -98,27 +99,27 @@ public class EditWorld {
public void delete() { public void delete() {
plugin.getEditWorlds().remove(this); plugin.getEditWorlds().remove(this);
for (Player player : world.getPlayers()) { for (Player player : world.getPlayers()) {
DPlayer dplayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
dplayer.leave(); dPlayer.leave();
} }
plugin.getServer().unloadWorld(world, true); plugin.getServer().unloadWorld(world, true);
File dir = new File("DXL_Edit_" + id); File dir = new File("DXL_Edit_" + id);
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName)); 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); FileUtil.removeDirectory(dir);
} }
public void deleteNoSave() { public void deleteNoSave() {
plugin.getEditWorlds().remove(this); plugin.getEditWorlds().remove(this);
for (Player player : world.getPlayers()) { for (Player player : world.getPlayers()) {
DPlayer dplayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
dplayer.leave(); dPlayer.leave();
} }
File dir = new File("DXL_Edit_" + id); File dir = new File("DXL_Edit_" + id);
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName)); 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); plugin.getServer().unloadWorld(world, true);
FileUtil.removeDirectory(dir); FileUtil.removeDirectory(dir);
} }
@ -220,15 +221,15 @@ public class EditWorld {
} }
public void msg(String msg) { public void msg(String msg) {
for (DPlayer dplayer : DPlayer.get(world)) { for (DPlayer dPlayer : DPlayer.getByWorld(world)) {
MessageUtil.sendMessage(dplayer.getPlayer(), msg); MessageUtil.sendMessage(dPlayer.getPlayer(), msg);
} }
} }
// Invite // Invite
public static boolean addInvitedPlayer(String editWorldname, UUID uuid) { public static boolean addInvitedPlayer(String editWorldName, UUID uuid) {
if (exist(editWorldname)) { if (exist(editWorldName)) {
WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + editWorldname, "config.yml")); WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml"));
config.addInvitedPlayer(uuid.toString()); config.addInvitedPlayer(uuid.toString());
config.save(); config.save();
return true; return true;
@ -246,7 +247,7 @@ public class EditWorld {
// Kick Player // Kick Player
EditWorld editWorld = EditWorld.get(editWorldName); EditWorld editWorld = EditWorld.get(editWorldName);
if (editWorld != null) { if (editWorld != null) {
DPlayer player = DPlayer.get(name); DPlayer player = DPlayer.getByName(name);
if (player != null) { if (player != null) {
if (editWorld.world.getPlayers().contains(player.getPlayer())) { if (editWorld.world.getPlayers().contains(player.getPlayer())) {
@ -261,12 +262,12 @@ public class EditWorld {
return false; return false;
} }
public static boolean isInvitedPlayer(String editWorldname, UUID uuid, String name) { public static boolean isInvitedPlayer(String editWorldName, UUID uuid, String name) {
if ( !exist(editWorldname)) { if ( !exist(editWorldName)) {
return false; 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 // 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())) { if (config.getInvitedPlayers().contains(name.toLowerCase()) || config.getInvitedPlayers().contains(uuid.toString())) {
return true; return true;

View File

@ -87,15 +87,15 @@ public class WorldConfig {
boolean hasDog = configSectionClasses.getBoolean(className + ".dog"); boolean hasDog = configSectionClasses.getBoolean(className + ".dog");
/* Items */ /* Items */
List<String> items = configSectionClasses.getStringList(className + ".items"); List<String> items = configSectionClasses.getStringList(className + ".items");
CopyOnWriteArrayList<ItemStack> istacks = new CopyOnWriteArrayList<ItemStack>(); CopyOnWriteArrayList<ItemStack> itemStacks = new CopyOnWriteArrayList<ItemStack>();
for (String item : items) { for (String item : items) {
String[] itemsplit = item.split(","); String[] itemSplit = item.split(",");
if (itemsplit.length > 0) { if (itemSplit.length > 0) {
int itemId = 0, itemData = 0, itemSize = 1, itemLvlEnchantment = 1; int itemId = 0, itemData = 0, itemSize = 1, itemLvlEnchantment = 1;
Enchantment itemEnchantment = null; Enchantment itemEnchantment = null;
// Check Id & Data // Check Id & Data
String[] idAndData = itemsplit[0].split("/"); String[] idAndData = itemSplit[0].split("/");
itemId = IntegerUtil.parseInt(idAndData[0]); itemId = IntegerUtil.parseInt(idAndData[0]);
if (idAndData.length > 1) { if (idAndData.length > 1) {
@ -103,12 +103,12 @@ public class WorldConfig {
} }
// Size // Size
if (itemsplit.length > 1) { if (itemSplit.length > 1) {
itemSize = IntegerUtil.parseInt(itemsplit[1]); itemSize = IntegerUtil.parseInt(itemSplit[1]);
} }
// Enchantment // Enchantment
if (itemsplit.length > 2) { if (itemSplit.length > 2) {
String[] enchantmentSplit = itemsplit[2].split("/"); String[] enchantmentSplit = itemSplit[2].split("/");
itemEnchantment = Enchantment.getByName(enchantmentSplit[0]); itemEnchantment = Enchantment.getByName(enchantmentSplit[0]);
@ -118,16 +118,16 @@ public class WorldConfig {
} }
// Add Item to Stacks // Add Item to Stacks
ItemStack istack = new ItemStack(itemId, itemSize, (short) itemData); ItemStack itemStack = new ItemStack(itemId, itemSize, (short) itemData);
if (itemEnchantment != null) { if (itemEnchantment != null) {
istack.addEnchantment(itemEnchantment, itemLvlEnchantment); itemStack.addEnchantment(itemEnchantment, itemLvlEnchantment);
} }
istacks.add(istack); itemStacks.add(itemStack);
} }
} }
/* Create Class */ /* 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 */ /* Secure Objects */
if (configFile.contains("secureObjects")) { if (configFile.contains("secureObjects")) {
List<Integer> secureobjectlist = configFile.getIntegerList("secureObjects"); List<Integer> secureObjectList = configFile.getIntegerList("secureObjects");
for (int i : secureobjectlist) { for (int i : secureObjectList) {
secureObjects.add(Material.getMaterial(i)); secureObjects.add(Material.getMaterial(i));
} }
} }
/* Invited Players */ /* Invited Players */
if (configFile.contains("invitedPlayers")) { if (configFile.contains("invitedPlayers")) {
List<String> invitedplayers = configFile.getStringList("invitedPlayers"); List<String> invitedPlayers = configFile.getStringList("invitedPlayers");
for (String i : invitedplayers) { for (String i : invitedPlayers) {
invitedPlayers.add(i); invitedPlayers.add(i);
} }
} }
@ -269,7 +269,7 @@ public class WorldConfig {
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file); FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
// Messages // Messages
for (Integer msgs : this.msgs.keySet()) { for (int msgs : this.msgs.keySet()) {
configFile.set("message." + msgs, this.msgs.get(msgs)); configFile.set("message." + msgs, this.msgs.get(msgs));
} }
@ -288,8 +288,8 @@ public class WorldConfig {
try { try {
configFile.save(file); configFile.save(file);
} catch (IOException e) { } catch (IOException exception) {
e.printStackTrace(); exception.printStackTrace();
} }
} }

View File

@ -19,7 +19,7 @@ import org.bukkit.inventory.ItemStack;
public class GameChest { public class GameChest {
// Variables // Variables
private boolean isUsed = false; private boolean used = false;
private Chest chest; private Chest chest;
private GameWorld gameWorld; private GameWorld gameWorld;
private double moneyReward; private double moneyReward;
@ -44,12 +44,12 @@ public class GameChest {
} }
for (Player player : dGroup.getPlayers()) { for (Player player : dGroup.getPlayers()) {
DPlayer dplayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dplayer == null) { if (dPlayer == null) {
continue; continue;
} }
dplayer.setTreasureMoney(dplayer.getTreasureMoney() + moneyReward); dPlayer.setTreasureMoney(dPlayer.getTreasureMoney() + moneyReward);
String msg = ""; String msg = "";
for (ItemStack itemStack : chest.getInventory().getContents()) { for (ItemStack itemStack : chest.getInventory().getContents()) {
@ -57,7 +57,7 @@ public class GameChest {
continue; continue;
} }
dplayer.getTreasureInv().addItem(itemStack); dPlayer.getTreasureInv().addItem(itemStack);
String name; String name;
if ( !itemStack.hasItemMeta()) { if ( !itemStack.hasItemMeta()) {
@ -92,7 +92,7 @@ public class GameChest {
public static void onOpenInventory(InventoryOpenEvent event) { public static void onOpenInventory(InventoryOpenEvent event) {
InventoryView inventory = event.getView(); InventoryView inventory = event.getView();
GameWorld gameWorld = GameWorld.get(event.getPlayer().getWorld()); GameWorld gameWorld = GameWorld.getByWorld(event.getPlayer().getWorld());
if (gameWorld == null) { if (gameWorld == null) {
return; return;
@ -109,7 +109,7 @@ public class GameChest {
continue; continue;
} }
if ( !gameChest.isUsed) { if ( !gameChest.used) {
MessageUtil MessageUtil
.sendMessage(DungeonsXL.getPlugin().getServer().getPlayer(event.getPlayer().getUniqueId()), DungeonsXL.getPlugin().getDMessages().getMessage(Messages.ERROR_CHEST_IS_OPENED)); .sendMessage(DungeonsXL.getPlugin().getServer().getPlayer(event.getPlayer().getUniqueId()), DungeonsXL.getPlugin().getDMessages().getMessage(Messages.ERROR_CHEST_IS_OPENED));
event.setCancelled(true); event.setCancelled(true);
@ -117,26 +117,26 @@ public class GameChest {
} }
if (gameChest.chest.getLocation().distance(chest.getLocation()) < 1) { if (gameChest.chest.getLocation().distance(chest.getLocation()) < 1) {
gameChest.addTreasure(DGroup.get(gameWorld)); gameChest.addTreasure(DGroup.getByGameWorld(gameWorld));
gameChest.isUsed = true; gameChest.used = true;
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }
/** /**
* @return the isUsed * @return if the GameChest is used
*/ */
public boolean isUsed() { public boolean isUsed() {
return isUsed; return used;
} }
/** /**
* @param isUsed * @param used
* the isUsed to set * set if the chest is used
*/ */
public void setUsed(boolean isUsed) { public void setUsed(boolean used) {
this.isUsed = isUsed; this.used = used;
} }
/** /**

View File

@ -13,7 +13,7 @@ public class GamePlaceableBlock {
// Variables // Variables
private Block block; private Block block;
private Set<Material> mats = new HashSet<Material>(); private Set<Material> materials = new HashSet<Material>();
private boolean onTop = false; private boolean onTop = false;
private boolean onBottom = false; private boolean onBottom = false;
@ -30,9 +30,9 @@ public class GamePlaceableBlock {
String[] splittedIds = ids.split(","); String[] splittedIds = ids.split(",");
for (String id : splittedIds) { for (String id : splittedIds) {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
Material mat = Material.getMaterial(IntegerUtil.parseInt(id)); Material material = Material.getMaterial(IntegerUtil.parseInt(id));
if (mat != null) { if (material != null) {
mats.add(mat); materials.add(material);
} }
} }
} }
@ -240,36 +240,36 @@ public class GamePlaceableBlock {
// Canbuild // Canbuild
public static boolean canBuildHere(Block block, BlockFace blockFace, Material mat, GameWorld gameWorld) { public static boolean canBuildHere(Block block, BlockFace blockFace, Material mat, GameWorld gameWorld) {
for (GamePlaceableBlock gPBlock : gameWorld.getPlaceableBlocks()) { for (GamePlaceableBlock gamePlacableBlock : gameWorld.getPlaceableBlocks()) {
if (gPBlock.block.getFace(block) != BlockFace.SELF) { if (gamePlacableBlock.block.getFace(block) != BlockFace.SELF) {
continue; continue;
} }
if ( !(gPBlock.mats.contains(mat) || gPBlock.mats.isEmpty())) { if ( !(gamePlacableBlock.materials.contains(mat) || gamePlacableBlock.materials.isEmpty())) {
continue; continue;
} }
if (blockFace == BlockFace.NORTH && gPBlock.onNorth) { if (blockFace == BlockFace.NORTH && gamePlacableBlock.onNorth) {
return true; return true;
} }
if (blockFace == BlockFace.SOUTH && gPBlock.onSouth) { if (blockFace == BlockFace.SOUTH && gamePlacableBlock.onSouth) {
return true; return true;
} }
if (blockFace == BlockFace.EAST && gPBlock.onEast) { if (blockFace == BlockFace.EAST && gamePlacableBlock.onEast) {
return true; return true;
} }
if (blockFace == BlockFace.WEST && gPBlock.onWest) { if (blockFace == BlockFace.WEST && gamePlacableBlock.onWest) {
return true; return true;
} }
if (blockFace == BlockFace.UP && gPBlock.onTop) { if (blockFace == BlockFace.UP && gamePlacableBlock.onTop) {
return true; return true;
} }
if (blockFace == BlockFace.DOWN && gPBlock.onBottom) { if (blockFace == BlockFace.DOWN && gamePlacableBlock.onBottom) {
return true; return true;
} }
} }

View File

@ -39,7 +39,7 @@ public class GameWorld {
static DungeonsXL plugin = DungeonsXL.getPlugin(); static DungeonsXL plugin = DungeonsXL.getPlugin();
// Variables placeable // Variables placeable
private boolean isTutorial; private boolean tutorial;
private CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks = new CopyOnWriteArrayList<GamePlaceableBlock>(); private CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks = new CopyOnWriteArrayList<GamePlaceableBlock>();
private World world; private World world;
@ -110,24 +110,24 @@ public class GameWorld {
} }
public void msg(String msg) { public void msg(String msg) {
for (DPlayer dplayer : DPlayer.get(world)) { for (DPlayer dPlayer : DPlayer.getByWorld(world)) {
MessageUtil.sendMessage(dplayer.getPlayer(), msg); MessageUtil.sendMessage(dPlayer.getPlayer(), msg);
} }
} }
/** /**
* @return the isTutorial * @return the tutorial
*/ */
public boolean isTutorial() { public boolean isTutorial() {
return isTutorial; return tutorial;
} }
/** /**
* @param isTutorial * @param tutorial
* the isTutorial to set * if the GameWorld is the tutorial
*/ */
public void setTutorial(boolean isTutorial) { public void setTutorial(boolean tutorial) {
this.isTutorial = isTutorial; this.tutorial = tutorial;
} }
/** /**
@ -283,7 +283,7 @@ public class GameWorld {
/** /**
* @return the dMobs * @return the dMobs
*/ */
public CopyOnWriteArrayList<DMob> getdMobs() { public CopyOnWriteArrayList<DMob> getDMobs() {
return dMobs; return dMobs;
} }
@ -291,7 +291,7 @@ public class GameWorld {
* @param dMobs * @param dMobs
* the dMobs to set * the dMobs to set
*/ */
public void setdMobs(CopyOnWriteArrayList<DMob> dMobs) { public void setDMobs(CopyOnWriteArrayList<DMob> dMobs) {
this.dMobs = dMobs; this.dMobs = dMobs;
} }
@ -313,7 +313,7 @@ public class GameWorld {
/** /**
* @return the dSigns * @return the dSigns
*/ */
public CopyOnWriteArrayList<DSign> getdSigns() { public CopyOnWriteArrayList<DSign> getDSigns() {
return dSigns; return dSigns;
} }
@ -321,7 +321,7 @@ public class GameWorld {
* @param dSigns * @param dSigns
* the dSigns to set * the dSigns to set
*/ */
public void setdSigns(CopyOnWriteArrayList<DSign> dSigns) { public void setDSigns(CopyOnWriteArrayList<DSign> dSigns) {
this.dSigns = dSigns; this.dSigns = dSigns;
} }
@ -356,7 +356,7 @@ public class GameWorld {
// Statics // Statics
public static GameWorld get(World world) { public static GameWorld getByWorld(World world) {
for (GameWorld gameWorld : plugin.getGameWorlds()) { for (GameWorld gameWorld : plugin.getGameWorlds()) {
if (gameWorld.world.equals(world)) { if (gameWorld.world.equals(world)) {
return gameWorld; return gameWorld;
@ -374,7 +374,7 @@ public class GameWorld {
public static boolean canPlayDungeon(String dungeon, Player player) { public static boolean canPlayDungeon(String dungeon, Player player) {
if (player.hasPermission("dungeonsxl.ignoretimelimit")) { if (player.hasPermission("dxl.ignoretimelimit")) {
return true; return true;
} }

View File

@ -11,34 +11,34 @@ public class DMessages {
public enum Messages { 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_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_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_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_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("Player_Death", "&6You died, lives left: &2v1"),
PLAYER_DEATH_KICK("Player_DeathKick", "&2v1&6 died and lost his last life."), 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_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_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"), 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_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_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_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_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_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]"), 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_RELOAD_DONE("Cmd_Reload_Done", "&7Successfully reloaded DungeonsXL."),
CMD_SAVE_SUCCESS("Cmd_Save_Success", "&6Dungeon saved!"), 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_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_BED("Error_Bed", "&4You cannot use a bed while in a Dungeon!"),
ERROR_DISPENSER("Error_Dispenser", "&4You cannot access this dispenser!"), ERROR_CHEST_IS_OPENED("Error_ChestIsOpened", "&4This chest has already been opened."),
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_CMD("Error_Cmd", "&4Commands are not allowed while in a dungeon!"), 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_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_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_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_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_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_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_FORMAT("Error_MsgFormat", "&4The Messages has to be between \"!"),
ERROR_MSG_NO_INT("Error_MsgNoInt", "&4Argument <id> has to include a number!"), ERROR_MSG_NO_INT("Error_MsgNoInt", "&4Argument <id> has to include a number!"),
ERROR_TUTORIAL_NOT_EXIST("Error_TutorialNotExist", "&4Tutorial dungeon does not exist!"), ERROR_NAME_TO_LONG("Error_NameToLong", "&4The name may not be longer than 15 characters!"),
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_NO_CONSOLE_COMMAND("Error_NoConsoleCommand", "&6/dxl &v1&4 cannot be executed as console!"), 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!"), 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_CHATSPY("Help_Cmd_Chatspy", "/dxl chatspy - Dis/enables the spymode"),
HELP_CMD_CREATE("Help_Cmd_Create", "/dxl create <name> - Creates a new dungeon"), HELP_CMD_CREATE("Help_Cmd_Create", "/dxl create <name> - Creates a new dungeon"),
HELP_CMD_EDIT("Help_Cmd_Edit", "/dxl edit <name> - Edit an existing dungeon"), HELP_CMD_EDIT("Help_Cmd_Edit", "/dxl edit <name> - 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 <page> - Shows the help page"), HELP_CMD_HELP("Help_Cmd_Help", "/dxl help <page> - Shows the help page"),
HELP_CMD_INVITE("Help_Cmd_Invite", "/dxl invite <player> <dungeon> - Invite a player to edit a dungeon"), HELP_CMD_INVITE("Help_Cmd_Invite", "/dxl invite <player> <dungeon> - Invite a player to edit a dungeon"),
HELP_CMD_LEAVE("Help_Cmd_Leave", "/dxl leave - Leaves the current 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_LIST("Help_Cmd_List", "/dxl list ([dungeon|map|loaded]) ([dungeon]) - Lists all dungeons"),
HELP_CMD_LIVES("Help_Cmd_Lives", "/dxl lives <player> - Shows the lives a player has left"),
HELP_CMD_MAIN("Help_Cmd_Main", "/dxl - General status information"), HELP_CMD_MAIN("Help_Cmd_Main", "/dxl - General status information"),
HELP_CMD_MSG("Help_Cmd_Msg", "/dxl msg <id> '[msg]' - Show or edit a message"), HELP_CMD_MSG("Help_Cmd_Msg", "/dxl msg <id> '[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_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_RELOAD("Help_Cmd_Reload", "/dxl reload - Reloads the plugin"),
HELP_CMD_SAVE("Help_Cmd_Save", "/dxl save - Saves the current dungeon"), 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_TEST("Help_Cmd_Test", "/dxl test ([dungeon|map]) [name] - Tests a dungeon"),
HELP_CMD_LIVES("Help_Cmd_Lives", "/dxl lives <player> - Shows the lives a player has left"),
HELP_CMD_UNINVITE("Help_Cmd_Uninvite", "/dxl uninvite <player> <dungeon> - Uninvite a player to edit a dungeon"); HELP_CMD_UNINVITE("Help_Cmd_Uninvite", "/dxl uninvite <player> <dungeon> - Uninvite a player to edit a dungeon");
private String identifier; private String identifier;
@ -142,7 +142,7 @@ public class DMessages {
* @param identifer * @param identifer
* the identifer to set * the identifer to set
*/ */
public static Messages fromIdentifier(String identifier) { public static Messages getByIdentifier(String identifier) {
for (Messages message : Messages.values()) { for (Messages message : Messages.values()) {
if (message.getIdentifier().equals(identifier)) { if (message.getIdentifier().equals(identifier)) {
return message; return message;
@ -192,7 +192,7 @@ public class DMessages {
if (config != null) { if (config != null) {
Set<String> keySet = config.getKeys(false); Set<String> keySet = config.getKeys(false);
for (String key : keySet) { for (String key : keySet) {
Messages.fromIdentifier(key).setMessage(config.getString(key)); Messages.getByIdentifier(key).setMessage(config.getString(key));
} }
} }
} }

View File

@ -21,12 +21,12 @@ public class DPortal {
private World world; private World world;
private Block block1; private Block block1;
private Block block2; private Block block2;
private boolean isActive; private boolean active;
private Player player; private Player player;
public DPortal(boolean active) { public DPortal(boolean active) {
plugin.getDPortals().add(this); plugin.getDPortals().add(this);
isActive = active; this.active = active;
} }
public void create() { public void create() {
@ -84,7 +84,7 @@ public class DPortal {
} }
public void teleport(Player player) { public void teleport(Player player) {
DGroup dgroup = DGroup.get(player); DGroup dgroup = DGroup.getByPlayer(player);
if (dgroup == null) { if (dgroup == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_NOT_IN_GROUP)); MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_NOT_IN_GROUP));
@ -92,11 +92,11 @@ public class DPortal {
} }
if (dgroup.getGameWorld() == null) { if (dgroup.getGameWorld() == null) {
dgroup.setGameWorld(GameWorld.load(DGroup.get(player).getMapName())); dgroup.setGameWorld(GameWorld.load(DGroup.getByPlayer(player).getMapName()));
} }
if (dgroup.getGameWorld() == null) { 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; return;
} }
@ -156,11 +156,11 @@ public class DPortal {
} }
// Statics // Statics
public static DPortal get(Location location) { public static DPortal getByLocation(Location location) {
return get(location.getBlock()); return getByBlock(location.getBlock());
} }
public static DPortal get(Block block) { public static DPortal getByBlock(Block block) {
for (DPortal portal : plugin.getDPortals()) { for (DPortal portal : plugin.getDPortals()) {
int x1 = portal.block1.getX(), y1 = portal.block1.getY(), z1 = portal.block1.getZ(); 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(); int x2 = portal.block2.getX(), y2 = portal.block2.getY(), z2 = portal.block2.getZ();
@ -204,7 +204,7 @@ public class DPortal {
return null; return null;
} }
public static DPortal get(Player player) { public static DPortal getByPlayer(Player player) {
for (DPortal portal : plugin.getDPortals()) { for (DPortal portal : plugin.getDPortals()) {
if (portal.player == player) { if (portal.player == player) {
return portal; return portal;
@ -217,22 +217,22 @@ public class DPortal {
// Save and Load // Save and Load
public static void save(FileConfiguration configFile) { public static void save(FileConfiguration configFile) {
int id = 0; int id = 0;
for (DPortal dportal : plugin.getDPortals()) { for (DPortal dPortal : plugin.getDPortals()) {
id++; id++;
if ( !dportal.isActive) { if ( !dPortal.active) {
continue; continue;
} }
String preString = "portal." + dportal.world.getName() + "." + id; String preString = "portal." + dPortal.world.getName() + "." + id;
// Location1 // Location1
configFile.set(preString + ".loc1.x", dportal.block1.getX()); configFile.set(preString + ".loc1.x", dPortal.block1.getX());
configFile.set(preString + ".loc1.y", dportal.block1.getY()); configFile.set(preString + ".loc1.y", dPortal.block1.getY());
configFile.set(preString + ".loc1.z", dportal.block1.getZ()); configFile.set(preString + ".loc1.z", dPortal.block1.getZ());
// Location1 // Location1
configFile.set(preString + ".loc2.x", dportal.block2.getX()); configFile.set(preString + ".loc2.x", dPortal.block2.getX());
configFile.set(preString + ".loc2.y", dportal.block2.getY()); configFile.set(preString + ".loc2.y", dPortal.block2.getY());
configFile.set(preString + ".loc2.z", dportal.block2.getZ()); configFile.set(preString + ".loc2.z", dPortal.block2.getZ());
} }
} }
@ -249,11 +249,11 @@ public class DPortal {
preString = "portal." + world.getName() + "." + id + "."; preString = "portal." + world.getName() + "." + id + ".";
if (configFile.contains(preString)) { if (configFile.contains(preString)) {
DPortal dportal = new DPortal(true); DPortal dPortal = new DPortal(true);
dportal.world = world; dPortal.world = world;
dportal.block1 = world.getBlockAt(configFile.getInt(preString + "loc1.x"), configFile.getInt(preString + "loc1.y"), configFile.getInt(preString + "loc1.z")); 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.block2 = world.getBlockAt(configFile.getInt(preString + "loc2.x"), configFile.getInt(preString + "loc2.y"), configFile.getInt(preString + "loc2.z"));
dportal.create(); dPortal.create();
} }
} while (configFile.contains(preString)); } while (configFile.contains(preString));
@ -306,18 +306,18 @@ public class DPortal {
} }
/** /**
* @return the isActive * @return if the portal is active
*/ */
public boolean isActive() { public boolean isActive() {
return isActive; return active;
} }
/** /**
* @param isActive * @param active
* the isActive to set * set the DPortal active
*/ */
public void setActive(boolean isActive) { public void setActive(boolean active) {
this.isActive = isActive; this.active = active;
} }
/** /**

View File

@ -24,10 +24,10 @@ public class GroupSign {
static DungeonsXL plugin = DungeonsXL.getPlugin(); static DungeonsXL plugin = DungeonsXL.getPlugin();
// Sign Labels // Sign Labels
public static final String strIsPlaying = ChatColor.DARK_RED + "Is Playing"; public static final String IS_PLAYING = ChatColor.DARK_RED + "Is Playing";
public static final String strFull = ChatColor.DARK_RED + "Full"; public static final String FULL = ChatColor.DARK_RED + "Full";
public static final String strJoinGrp = ChatColor.DARK_GREEN + "Join Group"; public static final String JOIN_GROUP = ChatColor.DARK_GREEN + "Join Group";
public static final String strNewGrp = ChatColor.DARK_GREEN + "New Group"; public static final String NEW_GROUP = ChatColor.DARK_GREEN + "New Group";
// Variables // Variables
private DGroup[] dGroups; private DGroup[] dGroups;
@ -142,13 +142,13 @@ public class GroupSign {
// Set Signs // Set Signs
if (dGroup != null) { if (dGroup != null) {
if (dGroup.isPlaying()) { if (dGroup.isPlaying()) {
sign.setLine(0, strIsPlaying); sign.setLine(0, IS_PLAYING);
} else if (dGroup.getPlayers().size() >= maxPlayersPerGroup) { } else if (dGroup.getPlayers().size() >= maxPlayersPerGroup) {
sign.setLine(0, strFull); sign.setLine(0, FULL);
} else { } else {
sign.setLine(0, strJoinGrp); sign.setLine(0, JOIN_GROUP);
} }
int j = 1; int j = 1;
@ -169,7 +169,7 @@ public class GroupSign {
} }
} else { } else {
sign.setLine(0, strNewGrp); sign.setLine(0, NEW_GROUP);
} }
sign.update(); sign.update();
@ -377,7 +377,7 @@ public class GroupSign {
return false; return false;
} }
if (DGroup.get(player) != null) { if (DGroup.getByPlayer(player) != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_LEAVE_GROUP)); MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_LEAVE_GROUP));
return true; return true;
} }
@ -417,7 +417,7 @@ public class GroupSign {
Sign topSign = (Sign) topBlock.getState(); Sign topSign = (Sign) topBlock.getState();
if (topSign.getLine(0).equals(strNewGrp)) { if (topSign.getLine(0).equals(NEW_GROUP)) {
if (groupSign.isMultiFloor()) { if (groupSign.isMultiFloor()) {
groupSign.dGroups[column] = new DGroup(player, groupSign.dungeonName, groupSign.isMultiFloor()); groupSign.dGroups[column] = new DGroup(player, groupSign.dungeonName, groupSign.isMultiFloor());
@ -426,7 +426,7 @@ public class GroupSign {
} }
groupSign.update(); groupSign.update();
} else if (topSign.getLine(0).equals(strJoinGrp)) { } else if (topSign.getLine(0).equals(JOIN_GROUP)) {
groupSign.dGroups[column].addPlayer(player); groupSign.dGroups[column].addPlayer(player);
groupSign.update(); groupSign.update();
} }
@ -434,7 +434,7 @@ public class GroupSign {
return true; return true;
} }
public static void updatePerGroup(DGroup dGroupsearch) { public static void updatePerGroup(DGroup dGroupSearch) {
for (GroupSign groupSign : plugin.getGroupSigns()) { for (GroupSign groupSign : plugin.getGroupSigns()) {
int i = 0; int i = 0;
@ -443,8 +443,8 @@ public class GroupSign {
continue; continue;
} }
if (dGroup == dGroupsearch) { if (dGroup == dGroupSearch) {
if (dGroupsearch.isEmpty()) { if (dGroupSearch.isEmpty()) {
groupSign.dGroups[i] = null; groupSign.dGroups[i] = null;
} }
groupSign.update(); groupSign.update();

View File

@ -37,20 +37,20 @@ public class LeaveSign {
public static boolean playerInteract(Block block, Player player) { public static boolean playerInteract(Block block, Player player) {
LeaveSign lsign = getSign(block); LeaveSign leaveSign = getSign(block);
if (lsign == null) { if (leaveSign == null) {
return false; return false;
} }
DPlayer dplayer = DPlayer.get(player); DPlayer dplayer = DPlayer.getByPlayer(player);
if (dplayer != null) { if (dplayer != null) {
dplayer.leave(); dplayer.leave();
return true; return true;
} else { } else {
DGroup dgroup = DGroup.get(player); DGroup dgroup = DGroup.getByPlayer(player);
if (dgroup != null) { if (dgroup != null) {
dgroup.removePlayer(player); dgroup.removePlayer(player);
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().getMessage(Messages.PLAYER_LEAVE_GROUP));// ChatColor.YELLOW+"Du hast deine Gruppe erfolgreich verlassen!"); 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") @SuppressWarnings("deprecation")
public static boolean isRelativeSign(Block block, int x, int z) { public static boolean isRelativeSign(Block block, int x, int z) {
LeaveSign lsign = getSign(block.getRelative(x, 0, z)); LeaveSign leaveSign = getSign(block.getRelative(x, 0, z));
if (lsign == null) { if (leaveSign == null) {
return false; return false;
} }
if (x == -1 && lsign.sign.getData().getData() == 4) { if (x == -1 && leaveSign.sign.getData().getData() == 4) {
return true; return true;
} }
if (x == 1 && lsign.sign.getData().getData() == 5) { if (x == 1 && leaveSign.sign.getData().getData() == 5) {
return true; return true;
} }
if (z == -1 && lsign.sign.getData().getData() == 2) { if (z == -1 && leaveSign.sign.getData().getData() == 2) {
return true; return true;
} }
if (z == 1 && lsign.sign.getData().getData() == 3) { if (z == 1 && leaveSign.sign.getData().getData() == 3) {
return true; return true;
} }
@ -108,17 +108,17 @@ public class LeaveSign {
// Save and Load // Save and Load
public static void save(FileConfiguration configFile) { public static void save(FileConfiguration configFile) {
int id = 0; int id = 0;
for (LeaveSign lsign : plugin.getLeaveSigns()) { for (LeaveSign leaveSign : plugin.getLeaveSigns()) {
id++; id++;
String preString = "leavesign." + lsign.sign.getWorld().getName() + "." + id; String preString = "leavesign." + leaveSign.sign.getWorld().getName() + "." + id;
configFile.set(preString + ".x", lsign.sign.getX()); configFile.set(preString + ".x", leaveSign.sign.getX());
configFile.set(preString + ".y", lsign.sign.getY()); configFile.set(preString + ".y", leaveSign.sign.getY());
configFile.set(preString + ".z", lsign.sign.getZ()); configFile.set(preString + ".z", leaveSign.sign.getZ());
} }
} }
public static void load(FileConfiguration configFile) { 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())) { if ( !configFile.contains("leavesign." + world.getName())) {
continue; continue;
} }

View File

@ -39,7 +39,7 @@ public class BlockListener implements Listener {
return; return;
} }
if (DPortal.get(event.getBlock()) != null) { if (DPortal.getByBlock(event.getBlock()) != null) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -50,7 +50,7 @@ public class BlockListener implements Listener {
// Deny DPortal destroying // Deny DPortal destroying
if (block.getType() == Material.PORTAL) { if (block.getType() == Material.PORTAL) {
if (DPortal.get(event.getBlock()) != null) { if (DPortal.getByBlock(event.getBlock()) != null) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -83,7 +83,7 @@ public class BlockListener implements Listener {
} }
// Deny GameWorld Blocks // Deny GameWorld Blocks
GameWorld gameWorld = GameWorld.get(block.getWorld()); GameWorld gameWorld = GameWorld.getByWorld(block.getWorld());
if (gameWorld != null) { if (gameWorld != null) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -95,7 +95,7 @@ public class BlockListener implements Listener {
Block block = event.getBlock(); Block block = event.getBlock();
// Deny GameWorld Blocks // Deny GameWorld Blocks
GameWorld gameWorld = GameWorld.get(block.getWorld()); GameWorld gameWorld = GameWorld.getByWorld(block.getWorld());
if (gameWorld == null) { if (gameWorld == null) {
return; return;
} }
@ -205,7 +205,7 @@ public class BlockListener implements Listener {
} }
// Check GameWorlds // Check GameWorlds
GameWorld gameWorld = GameWorld.get(event.getBlock().getWorld()); GameWorld gameWorld = GameWorld.getByWorld(event.getBlock().getWorld());
if (gameWorld != null) { if (gameWorld != null) {
event.setCancelled(true); event.setCancelled(true);
} }

View File

@ -36,7 +36,7 @@ public class EntityListener implements Listener {
// Remove drops from breaking Signs // Remove drops from breaking Signs
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onItemSpawn(ItemSpawnEvent event) { 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) { if (event.getEntity().getItemStack().getType() == Material.SIGN) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -47,10 +47,10 @@ public class EntityListener implements Listener {
public void onCreatureSpawn(CreatureSpawnEvent event) { public void onCreatureSpawn(CreatureSpawnEvent event) {
World world = event.getLocation().getWorld(); World world = event.getLocation().getWorld();
EditWorld eworld = EditWorld.get(world); EditWorld editWorld = EditWorld.get(world);
GameWorld gworld = GameWorld.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 if (event.getSpawnReason() == SpawnReason.CHUNK_GEN || event.getSpawnReason() == SpawnReason.BREEDING || event.getSpawnReason() == SpawnReason.NATURAL
|| event.getSpawnReason() == SpawnReason.DEFAULT) { || event.getSpawnReason() == SpawnReason.DEFAULT) {
event.setCancelled(true); event.setCancelled(true);
@ -64,9 +64,9 @@ public class EntityListener implements Listener {
if (event.getEntity() instanceof LivingEntity) { if (event.getEntity() instanceof LivingEntity) {
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
GameWorld gworld = GameWorld.get(world); GameWorld gameWorld = GameWorld.getByWorld(world);
if (gworld != null) { if (gameWorld != null) {
if (gworld.isPlaying()) { if (gameWorld.isPlaying()) {
if (entity.getType() != EntityType.PLAYER) { if (entity.getType() != EntityType.PLAYER) {
event.getDrops().clear(); event.getDrops().clear();
DMob.onDeath(event); DMob.onDeath(event);
@ -79,10 +79,10 @@ public class EntityListener implements Listener {
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
World world = event.getEntity().getWorld(); World world = event.getEntity().getWorld();
GameWorld gworld = GameWorld.get(world); GameWorld gameWorld = GameWorld.getByWorld(world);
if (gworld != null) { if (gameWorld != null) {
// Deny all Damage in Lobby // Deny all Damage in Lobby
if ( !gworld.isPlaying()) { if ( !gameWorld.isPlaying()) {
event.setCancelled(true); event.setCancelled(true);
} }
// Deny all Damage from Players to Players // Deny all Damage from Players to Players
@ -106,9 +106,9 @@ public class EntityListener implements Listener {
// Check Dogs // Check Dogs
if (entity instanceof Player || entity2 instanceof Player) { if (entity instanceof Player || entity2 instanceof Player) {
for (DPlayer dplayer : DPlayer.get(gworld.getWorld())) { for (DPlayer dPlayer : DPlayer.getByWorld(gameWorld.getWorld())) {
if (dplayer.getWolf() != null) { if (dPlayer.getWolf() != null) {
if (entity == dplayer.getWolf() || entity2 == dplayer.getWolf()) { if (entity == dPlayer.getWolf() || entity2 == dPlayer.getWolf()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -116,16 +116,16 @@ public class EntityListener implements Listener {
} }
} }
for (DPlayer dplayer : DPlayer.get(gworld.getWorld())) { for (DPlayer dPlayer : DPlayer.getByWorld(gameWorld.getWorld())) {
if (dplayer.getWolf() != null) { if (dPlayer.getWolf() != null) {
if (entity instanceof Player || entity2 instanceof Player) { if (entity instanceof Player || entity2 instanceof Player) {
if (entity == dplayer.getWolf() || entity2 == dplayer.getWolf()) { if (entity == dPlayer.getWolf() || entity2 == dPlayer.getWolf()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} else { } else {
if (entity == dplayer.getWolf() || entity2 == dplayer.getWolf()) { if (entity == dPlayer.getWolf() || entity2 == dPlayer.getWolf()) {
event.setCancelled(false); event.setCancelled(false);
return; return;
} }
@ -142,9 +142,9 @@ public class EntityListener implements Listener {
public void onFoodLevelChange(FoodLevelChangeEvent event) { public void onFoodLevelChange(FoodLevelChangeEvent event) {
World world = event.getEntity().getWorld(); World world = event.getEntity().getWorld();
GameWorld gworld = GameWorld.get(world); GameWorld gameWorld = GameWorld.getByWorld(world);
if (gworld != null) { if (gameWorld != null) {
if ( !gworld.isPlaying()) { if ( !gameWorld.isPlaying()) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -153,8 +153,8 @@ public class EntityListener implements Listener {
// Zombie/skeleton combustion from the sun. // Zombie/skeleton combustion from the sun.
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onEntityCombust(EntityCombustEvent event) { public void onEntityCombust(EntityCombustEvent event) {
GameWorld gworld = GameWorld.get(event.getEntity().getWorld()); GameWorld gameWorld = GameWorld.getByWorld(event.getEntity().getWorld());
if (gworld != null) { if (gameWorld != null) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -162,8 +162,8 @@ public class EntityListener implements Listener {
// Allow Other combustion // Allow Other combustion
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) { public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
GameWorld gworld = GameWorld.get(event.getEntity().getWorld()); GameWorld gameWorld = GameWorld.getByWorld(event.getEntity().getWorld());
if (gworld != null) { if (gameWorld != null) {
if (event.isCancelled()) { if (event.isCancelled()) {
event.setCancelled(false); event.setCancelled(false);
} }
@ -173,11 +173,11 @@ public class EntityListener implements Listener {
// Explosions // Explosions
@EventHandler @EventHandler
public void onEntityExplode(EntityExplodeEvent event) { 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) { if (event.getEntity() instanceof LivingEntity) {
// Disable Creeper explosions in gameworlds // Disable Creeper explosions in gameditWorlds
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -193,7 +193,7 @@ public class EntityListener implements Listener {
for (Block block : blocklist) { for (Block block : blocklist) {
// Portals // Portals
if (block.getType() == Material.PORTAL) { if (block.getType() == Material.PORTAL) {
if (DPortal.get(block) != null) { if (DPortal.getByBlock(block) != null) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }

View File

@ -10,8 +10,8 @@ public class HangingListener implements Listener {
@EventHandler @EventHandler
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) { public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {
GameWorld gworld = GameWorld.get(event.getEntity().getWorld()); GameWorld gameWorld = GameWorld.getByWorld(event.getEntity().getWorld());
if (gworld != null) { if (gameWorld != null) {
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -53,9 +53,9 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onDeath(PlayerDeathEvent event) { public void onDeath(PlayerDeathEvent event) {
Player player = event.getEntity(); 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) { if (gameWorld == null) {
return; return;
} }
@ -100,7 +100,7 @@ public class PlayerListener implements Listener {
if (clickedBlock != null) { if (clickedBlock != null) {
// Block Enderchests // 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 (event.getAction() != Action.LEFT_CLICK_BLOCK) {
if (clickedBlock.getType() == Material.ENDER_CHEST) { if (clickedBlock.getType() == Material.ENDER_CHEST) {
if ( !player.hasPermission("dxl.bypass")) { if ( !player.hasPermission("dxl.bypass")) {
@ -118,7 +118,7 @@ public class PlayerListener implements Listener {
} }
// Block Dispensers // Block Dispensers
if (GameWorld.get(player.getWorld()) != null) { if (GameWorld.getByWorld(player.getWorld()) != null) {
if (event.getAction() != Action.LEFT_CLICK_BLOCK) { if (event.getAction() != Action.LEFT_CLICK_BLOCK) {
if (clickedBlock.getType() == Material.DISPENSER) { if (clickedBlock.getType() == Material.DISPENSER) {
if ( !player.hasPermission("dxl.bypass")) { if ( !player.hasPermission("dxl.bypass")) {
@ -159,7 +159,7 @@ public class PlayerListener implements Listener {
if (EditWorld.get(player.getWorld()) != null) { if (EditWorld.get(player.getWorld()) != null) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (item.getType() == Material.STICK) { if (item.getType() == Material.STICK) {
DPlayer dPlayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dPlayer != null) { if (dPlayer != null) {
dPlayer.poke(clickedBlock); dPlayer.poke(clickedBlock);
event.setCancelled(true); event.setCancelled(true);
@ -169,7 +169,7 @@ public class PlayerListener implements Listener {
} }
// Trigger UseItem Signs // Trigger UseItem Signs
GameWorld gameWorld = GameWorld.get(player.getWorld()); GameWorld gameWorld = GameWorld.getByWorld(player.getWorld());
if (gameWorld != null) { if (gameWorld != null) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
if (UseItemTrigger.hasTriggers(gameWorld)) { if (UseItemTrigger.hasTriggers(gameWorld)) {
@ -213,11 +213,11 @@ public class PlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
DPlayer dPlayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dPlayer != null) { if (dPlayer != null) {
// Check GameWorld Signs // Check GameWorld Signs
GameWorld gameWorld = GameWorld.get(player.getWorld()); GameWorld gameWorld = GameWorld.getByWorld(player.getWorld());
if (gameWorld != null) { if (gameWorld != null) {
// Trigger InteractTrigger // Trigger InteractTrigger
@ -255,7 +255,7 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
// Deny dropping things at the lobby // Deny dropping things at the lobby
DGroup dGroup = DGroup.get(player); DGroup dGroup = DGroup.getByPlayer(player);
if (dGroup == null) { if (dGroup == null) {
return; return;
} }
@ -265,13 +265,13 @@ public class PlayerListener implements Listener {
return; return;
} }
if ( !DPlayer.get(player).isReady()) { if ( !DPlayer.getByPlayer(player).isReady()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
DPlayer dPlayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
GameWorld gameWorld = GameWorld.get(dPlayer.getWorld()); GameWorld gameWorld = GameWorld.getByWorld(dPlayer.getWorld());
if (dPlayer != null) { if (dPlayer != null) {
for (Material material : gameWorld.getConfig().getSecureObjects()) { for (Material material : gameWorld.getConfig().getSecureObjects()) {
@ -287,7 +287,7 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onRespawn(PlayerRespawnEvent event) { public void onRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
DPlayer dPlayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dPlayer == null) { if (dPlayer == null) {
return; return;
@ -307,13 +307,13 @@ public class PlayerListener implements Listener {
} }
} else { } else {
GameWorld gameWorld = GameWorld.get(dPlayer.getWorld()); GameWorld gameWorld = GameWorld.getByWorld(dPlayer.getWorld());
if (gameWorld == null) { if (gameWorld == null) {
return; return;
} }
DGroup dGroup = DGroup.get(dPlayer.getPlayer()); DGroup dGroup = DGroup.getByPlayer(dPlayer.getPlayer());
if (dPlayer.getCheckpoint() == null) { if (dPlayer.getCheckpoint() == null) {
event.setRespawnLocation(dGroup.getGameWorld().getLocStart()); event.setRespawnLocation(dGroup.getGameWorld().getLocStart());
@ -346,7 +346,7 @@ public class PlayerListener implements Listener {
public void onPortal(PlayerPortalEvent event) { public void onPortal(PlayerPortalEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
Location location = event.getFrom(); Location location = event.getFrom();
DPortal dportal = DPortal.get(location); DPortal dportal = DPortal.getByLocation(location);
if (dportal != null) { if (dportal != null) {
event.setCancelled(true); event.setCancelled(true);
@ -357,7 +357,7 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onTeleport(PlayerTeleportEvent event) { public void onTeleport(PlayerTeleportEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
DPlayer dPlayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dPlayer == null) { if (dPlayer == null) {
return; return;
@ -375,7 +375,7 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onChat(AsyncPlayerChatEvent event) { public void onChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
DPlayer dPlayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dPlayer == null) { if (dPlayer == null) {
return; return;
} }
@ -389,16 +389,16 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onQuit(PlayerQuitEvent event) { public void onQuit(PlayerQuitEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
DPlayer dPlayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dPlayer == null) { if (dPlayer == null) {
return; return;
} }
DGroup dGroup = DGroup.get(player); DGroup dGroup = DGroup.getByPlayer(player);
// Check GameWorld // Check GameWorld
GameWorld gameWorld = GameWorld.get(player.getWorld()); GameWorld gameWorld = GameWorld.getByWorld(player.getWorld());
if (gameWorld != null) { if (gameWorld != null) {
int timeUntilKickOfflinePlayer = gameWorld.getConfig().getTimeUntilKickOfflinePlayer(); int timeUntilKickOfflinePlayer = gameWorld.getConfig().getTimeUntilKickOfflinePlayer();
@ -423,9 +423,9 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
// Check dPlayers // Check dPlayers
DPlayer dPlayer = DPlayer.get(player.getName()); DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dPlayer != null) { if (dPlayer != null) {
DGroup dGroup = DGroup.get(dPlayer.getPlayer()); DGroup dGroup = DGroup.getByPlayer(dPlayer.getPlayer());
if (dGroup != null) { if (dGroup != null) {
dGroup.getPlayers().remove(dPlayer.getPlayer()); dGroup.getPlayers().remove(dPlayer.getPlayer());
dGroup.getPlayers().add(player); dGroup.getPlayers().add(player);
@ -441,7 +441,7 @@ public class PlayerListener implements Listener {
return; return;
} }
if (DPlayer.get(player) != null) { if (DPlayer.getByPlayer(player) != null) {
return; return;
} }
@ -461,7 +461,7 @@ public class PlayerListener implements Listener {
DGroup dGroup = new DGroup(player, plugin.getMainConfig().getTutorialDungeon(), false); DGroup dGroup = new DGroup(player, plugin.getMainConfig().getTutorialDungeon(), false);
if (dGroup.getGameWorld() == null) { if (dGroup.getGameWorld() == null) {
dGroup.setGameWorld(GameWorld.load(DGroup.get(player).getMapName())); dGroup.setGameWorld(GameWorld.load(DGroup.getByPlayer(player).getMapName()));
dGroup.getGameWorld().setTutorial(true); dGroup.getGameWorld().setTutorial(true);
} }
@ -483,7 +483,7 @@ public class PlayerListener implements Listener {
return; return;
} }
DPlayer dPlayer = DPlayer.get(event.getPlayer()); DPlayer dPlayer = DPlayer.getByPlayer(event.getPlayer());
if (dPlayer == null) { if (dPlayer == null) {
return; return;
} }
@ -532,7 +532,7 @@ public class PlayerListener implements Listener {
@EventHandler @EventHandler
public void onMove(PlayerMoveEvent event) { public void onMove(PlayerMoveEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
DLootInventory inventory = DLootInventory.get(player); DLootInventory inventory = DLootInventory.getByPlayer(player);
if (inventory == null) { if (inventory == null) {
return; return;
@ -567,7 +567,7 @@ public class PlayerListener implements Listener {
MiscUtil.secureTeleport(player, location); MiscUtil.secureTeleport(player, location);
} }
DPlayer dPlayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dPlayer == null) { if (dPlayer == null) {
return; return;

View File

@ -11,9 +11,9 @@ public class WorldListener implements Listener {
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onChunkUnload(ChunkUnloadEvent event) { public void onChunkUnload(ChunkUnloadEvent event) {
GameWorld gWorld = GameWorld.get(event.getWorld()); GameWorld gameWorld = GameWorld.getByWorld(event.getWorld());
if (gWorld != null) { if (gameWorld != null) {
if (gWorld.getLoadedChunks().contains(event.getChunk())) { if (gameWorld.getLoadedChunks().contains(event.getChunk())) {
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -18,7 +18,7 @@ public class DMob {
private String trigger; private String trigger;
public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type) { public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type) {
gameWorld.getdMobs().add(this); gameWorld.getDMobs().add(this);
this.entity = entity; this.entity = entity;
this.type = type; this.type = type;
@ -32,7 +32,7 @@ public class DMob {
} }
public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type, String trigger) { public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type, String trigger) {
gameWorld.getdMobs().add(this); gameWorld.getDMobs().add(this);
this.entity = entity; this.entity = entity;
this.type = type; this.type = type;
@ -54,23 +54,23 @@ public class DMob {
} }
LivingEntity victim = event.getEntity(); LivingEntity victim = event.getEntity();
GameWorld gameWorld = GameWorld.get(victim.getWorld()); GameWorld gameWorld = GameWorld.getByWorld(victim.getWorld());
String name = null; String name = null;
if (gameWorld == null) { if (gameWorld == null) {
return; return;
} }
for (DMob dMob : gameWorld.getdMobs()) { for (DMob dMob : gameWorld.getDMobs()) {
if (dMob.entity == victim) { if (dMob.entity == victim) {
if (dMob.type != null) { if (dMob.type != null) {
for (ItemStack item : dMob.type.getDrops().keySet()) { for (ItemStack itemStack : dMob.type.getDrops().keySet()) {
Random randomGenerator = new Random(); Random randomGenerator = new Random();
int random = randomGenerator.nextInt(100); int random = randomGenerator.nextInt(100);
if (dMob.type.getDrops().get(item) > random) { if (dMob.type.getDrops().get(itemStack) > random) {
event.getDrops().add(item); event.getDrops().add(itemStack);
} }
} }
name = dMob.type.getName(); name = dMob.type.getName();
@ -87,7 +87,7 @@ public class DMob {
trigger.onTrigger(); trigger.onTrigger();
} }
gameWorld.getdMobs().remove(dMob); gameWorld.getDMobs().remove(dMob);
return; return;
} }
} }

View File

@ -41,7 +41,7 @@ public class DMobType {
private Map<ItemStack, Integer> drops = new HashMap<ItemStack, Integer>(); private Map<ItemStack, Integer> drops = new HashMap<ItemStack, Integer>();
/* Extra Values for different Mob Types */ /* Extra Values for different Mob Types */
private boolean isWitherSkeleton = false; private boolean witherSkeleton = false;
private String ocelotType = null; private String ocelotType = null;
/* Methods */ /* Methods */
@ -70,7 +70,7 @@ public class DMobType {
/* Check mob specified stuff */ /* Check mob specified stuff */
if (type == EntityType.SKELETON) { if (type == EntityType.SKELETON) {
if (isWitherSkeleton) { if (witherSkeleton) {
((Skeleton) entity).setSkeletonType(SkeletonType.WITHER); ((Skeleton) entity).setSkeletonType(SkeletonType.WITHER);
} else { } else {
((Skeleton) entity).setSkeletonType(SkeletonType.NORMAL); ((Skeleton) entity).setSkeletonType(SkeletonType.NORMAL);
@ -79,16 +79,8 @@ public class DMobType {
if (type == EntityType.OCELOT) { if (type == EntityType.OCELOT) {
Ocelot ocelot = (Ocelot) entity; Ocelot ocelot = (Ocelot) entity;
if (ocelotType != null) { if (Ocelot.Type.valueOf(ocelotType.toUpperCase()) != null) {
if (ocelotType.equalsIgnoreCase("BLACK_CAT")) { ocelot.setCatType(Ocelot.Type.valueOf(ocelotType.toUpperCase()));
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);
}
} }
} }
@ -159,7 +151,7 @@ public class DMobType {
// Load different Mob options // Load different Mob options
if (configFile.contains(mobName + ".isWitherSkeleton")) { if (configFile.contains(mobName + ".isWitherSkeleton")) {
mobType.isWitherSkeleton = configFile.getBoolean(mobName + ".isWitherSkeleton"); mobType.witherSkeleton = configFile.getBoolean(mobName + ".isWitherSkeleton");
} }
if (configFile.contains(mobName + ".ocelotType")) { if (configFile.contains(mobName + ".ocelotType")) {
@ -233,7 +225,7 @@ public class DMobType {
} }
// Get // Get
public static DMobType get(String name, Set<DMobType> mobTypes) { public static DMobType getByName(String name, Set<DMobType> mobTypes) {
for (DMobType mobType : mobTypes) { for (DMobType mobType : mobTypes) {
if (mobType.name.equalsIgnoreCase(name)) { if (mobType.name.equalsIgnoreCase(name)) {
return mobType; return mobType;
@ -266,6 +258,111 @@ public class DMobType {
this.name = name; 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 * @return the drops
*/ */
@ -281,4 +378,34 @@ public class DMobType {
this.drops = drops; 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;
}
} }

View File

@ -8,12 +8,12 @@ public class DClass {
private CopyOnWriteArrayList<ItemStack> items = new CopyOnWriteArrayList<ItemStack>(); private CopyOnWriteArrayList<ItemStack> items = new CopyOnWriteArrayList<ItemStack>();
private String name; private String name;
private boolean hasDog; private boolean dog;
public DClass(String name, CopyOnWriteArrayList<ItemStack> items, boolean hasDog) { public DClass(String name, CopyOnWriteArrayList<ItemStack> items, boolean dog) {
this.items = items; this.items = items;
this.name = name; this.name = name;
this.hasDog = hasDog; this.dog = dog;
} }
/** /**
@ -50,15 +50,15 @@ public class DClass {
* @return if the class has a dog * @return if the class has a dog
*/ */
public boolean hasDog() { public boolean hasDog() {
return hasDog; return dog;
} }
/** /**
* @param hasDog * @param dog
* set if the class has a dog * set if the class has a dog
*/ */
public void setDog(boolean hasDog) { public void setDog(boolean dog) {
this.hasDog = hasDog; this.dog = dog;
} }
} }

View File

@ -61,7 +61,7 @@ public class DGroup {
public void addPlayer(Player player) { public void addPlayer(Player player) {
// Send message // Send message
for (Player groupPlayer : getPlayers()) { 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 // Add player
@ -78,7 +78,7 @@ public class DGroup {
// Send message // Send message
for (Player groupPlayer : getPlayers()) { 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 // Check group
@ -167,7 +167,7 @@ public class DGroup {
* the unplayedFloor to add * the unplayedFloor to add
*/ */
public void removeUnplayedFloor(String unplayedFloor) { public void removeUnplayedFloor(String unplayedFloor) {
if (getDungeon().getConfig().isRemoveWhenPlayed()) { if (getDungeon().getConfig().getRemoveWhenPlayed()) {
unplayedFloors.remove(unplayedFloor); unplayedFloors.remove(unplayedFloor);
} }
} }
@ -224,8 +224,8 @@ public class DGroup {
fee = new WorldConfig(file).getFee(); fee = new WorldConfig(file).getFee();
for (Player player : getPlayers()) { for (Player player : getPlayers()) {
DPlayer dplayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
dplayer.respawn(); dPlayer.respawn();
if (dungeonName != null) { if (dungeonName != null) {
MessageUtil.sendScreenMessage(player, "&b&l" + dungeonName.replaceAll("_", " "), "&4&l" + mapName.replaceAll("_", "")); MessageUtil.sendScreenMessage(player, "&b&l" + dungeonName.replaceAll("_", " "), "&4&l" + mapName.replaceAll("_", ""));
@ -272,7 +272,7 @@ public class DGroup {
// Statics // Statics
public static DGroup get(Player player) { public static DGroup getByPlayer(Player player) {
for (DGroup dGroup : plugin.getDGroups()) { for (DGroup dGroup : plugin.getDGroups()) {
if (dGroup.getPlayers().contains(player)) { if (dGroup.getPlayers().contains(player)) {
return dGroup; return dGroup;
@ -282,7 +282,7 @@ public class DGroup {
return null; return null;
} }
public static DGroup get(GameWorld gameWorld) { public static DGroup getByGameWorld(GameWorld gameWorld) {
for (DGroup dGroup : plugin.getDGroups()) { for (DGroup dGroup : plugin.getDGroups()) {
if (dGroup.getGameWorld() == gameWorld) { if (dGroup.getGameWorld() == gameWorld) {
return dGroup; return dGroup;

View File

@ -44,14 +44,13 @@ public class DPlayer {
private Player player; private Player player;
private World world; private World world;
private boolean isInTestMode = false;
private DSavePlayer savePlayer; private DSavePlayer savePlayer;
private boolean isEditing; private boolean inTestMode = false;
private boolean isInDungeonChat = false; private boolean editing;
private boolean isReady = false; private boolean inDungeonChat = false;
private boolean isFinished = false; private boolean ready = false;
private boolean finished = false;
private DClass dClass; private DClass dClass;
private Location checkpoint; private Location checkpoint;
@ -68,7 +67,7 @@ public class DPlayer {
private int initialLives = -1; private int initialLives = -1;
private int lives; 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); plugin.getDPlayers().add(this);
this.setPlayer(player); 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(), 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()); 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); this.getPlayer().setGameMode(GameMode.CREATIVE);
clearPlayerData(); clearPlayerData();
} else { } else {
this.getPlayer().setGameMode(GameMode.SURVIVAL); this.getPlayer().setGameMode(GameMode.SURVIVAL);
WorldConfig dConfig = GameWorld.get(world).getConfig(); WorldConfig dConfig = GameWorld.getByWorld(world).getConfig();
if ( !dConfig.getKeepInventoryOnEnter()) { if ( !dConfig.getKeepInventoryOnEnter()) {
clearPlayerData(); clearPlayerData();
} }
if (dConfig.isLobbyDisabled()) { if (dConfig.isLobbyDisabled()) {
ready(); ready();
} }
initialLives = GameWorld.get(world).getConfig().getInitialLives(); initialLives = GameWorld.getByWorld(world).getConfig().getInitialLives();
lives = initialLives; lives = initialLives;
} }
@ -120,9 +119,9 @@ public class DPlayer {
public void leave() { public void leave() {
remove(this); remove(this);
if ( !isEditing) { if ( !editing) {
WorldConfig dConfig = GameWorld.get(world).getConfig(); WorldConfig dConfig = GameWorld.getByWorld(world).getConfig();
if (isFinished) { if (finished) {
savePlayer.reset(dConfig.getKeepInventoryOnFinish()); savePlayer.reset(dConfig.getKeepInventoryOnFinish());
} else { } else {
savePlayer.reset(dConfig.getKeepInventoryOnEscape()); savePlayer.reset(dConfig.getKeepInventoryOnEscape());
@ -131,22 +130,22 @@ public class DPlayer {
savePlayer.reset(false); savePlayer.reset(false);
} }
if (isEditing) { if (editing) {
EditWorld eworld = EditWorld.get(world); EditWorld editWorld = EditWorld.get(world);
if (eworld != null) { if (editWorld != null) {
eworld.save(); editWorld.save();
} }
} else { } else {
GameWorld gameWorld = GameWorld.get(world); GameWorld gameWorld = GameWorld.getByWorld(world);
DGroup dGroup = DGroup.get(getPlayer()); DGroup dGroup = DGroup.getByPlayer(getPlayer());
if (dGroup != null) { if (dGroup != null) {
dGroup.removePlayer(getPlayer()); dGroup.removePlayer(getPlayer());
} }
// Belohnung // Belohnung
if ( !isInTestMode) {// Nur wenn man nicht am Testen ist if ( !inTestMode) {// Nur wenn man nicht am Testen ist
if (isFinished) { if (finished) {
addTreasure(); addTreasure();
if (plugin.getEconomyProvider() != null) { if (plugin.getEconomyProvider() != null) {
plugin.getEconomyProvider().depositPlayer(getPlayer(), treasureMoney); plugin.getEconomyProvider().depositPlayer(getPlayer(), treasureMoney);
@ -169,8 +168,9 @@ public class DPlayer {
try { try {
playerConfig.save(file); playerConfig.save(file);
} catch (IOException e) {
e.printStackTrace(); } catch (IOException exception) {
exception.printStackTrace();
} }
// Tutorial Permissions // Tutorial Permissions
@ -192,35 +192,34 @@ public class DPlayer {
if (dGroup != null) { if (dGroup != null) {
if ( !dGroup.isEmpty()) { if ( !dGroup.isEmpty()) {
int i = 0; int i = 0;
Player groupplayer; Player groupPlayer;
do { do {
groupplayer = dGroup.getPlayers().get(i); groupPlayer = dGroup.getPlayers().get(i);
if (groupplayer != null) { if (groupPlayer != null) {
org.bukkit.Bukkit.broadcastMessage("14");
for (ItemStack istack : getPlayer().getInventory()) { for (ItemStack istack : getPlayer().getInventory()) {
if (istack != null) { if (istack != null) {
if (gameWorld.getSecureObjects().contains(istack.getType())) { if (gameWorld.getSecureObjects().contains(istack.getType())) {
groupplayer.getInventory().addItem(istack); groupPlayer.getInventory().addItem(istack);
} }
} }
} }
} }
i++; i++;
} while (groupplayer == null); } while (groupPlayer == null);
} }
} }
} }
} }
public void ready() { public void ready() {
isReady = true; ready = true;
DGroup dGroup = DGroup.get(getPlayer()); DGroup dGroup = DGroup.getByPlayer(getPlayer());
if ( !dGroup.isPlaying()) { if ( !dGroup.isPlaying()) {
if (dGroup != null) { if (dGroup != null) {
for (Player player : dGroup.getPlayers()) { for (Player player : dGroup.getPlayers()) {
DPlayer dplayer = get(player); DPlayer dPlayer = getByPlayer(player);
if ( !dplayer.isReady) { if ( !dPlayer.ready) {
return; return;
} }
} }
@ -233,7 +232,7 @@ public class DPlayer {
} }
public void respawn() { public void respawn() {
DGroup dGroup = DGroup.get(getPlayer()); DGroup dGroup = DGroup.getByPlayer(getPlayer());
if (checkpoint == null) { if (checkpoint == null) {
MiscUtil.secureTeleport(getPlayer(), dGroup.getGameWorld().getLocStart()); MiscUtil.secureTeleport(getPlayer(), dGroup.getGameWorld().getLocStart());
} else { } else {
@ -244,7 +243,7 @@ public class DPlayer {
} }
// Respawn Items // Respawn Items
if (GameWorld.get(world).getConfig().getKeepInventoryOnDeath()) { if (GameWorld.getByWorld(world).getConfig().getKeepInventoryOnDeath()) {
if (respawnInventory != null || respawnArmor != null) { if (respawnInventory != null || respawnArmor != null) {
getPlayer().getInventory().setContents(respawnInventory); getPlayer().getInventory().setContents(respawnInventory);
getPlayer().getInventory().setArmorContents(respawnArmor); getPlayer().getInventory().setArmorContents(respawnArmor);
@ -257,9 +256,9 @@ public class DPlayer {
public void finishFloor(String specifiedFloor) { public void finishFloor(String specifiedFloor) {
MessageUtil.sendMessage(getPlayer(), dMessages.getMessage(Messages.PLAYER_FINISHED_DUNGEON)); 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) { if (dGroup == null) {
return; return;
} }
@ -269,8 +268,8 @@ public class DPlayer {
} }
for (Player player : dGroup.getPlayers()) { for (Player player : dGroup.getPlayers()) {
DPlayer dplayer = get(player); DPlayer dPlayer = getByPlayer(player);
if ( !dplayer.isFinished) { if ( !dPlayer.finished) {
MessageUtil.sendMessage(this.getPlayer(), dMessages.getMessage(Messages.PLAYER_WAIT_FOR_OTHER_PLAYERS)); MessageUtil.sendMessage(this.getPlayer(), dMessages.getMessage(Messages.PLAYER_WAIT_FOR_OTHER_PLAYERS));
return; return;
} }
@ -283,13 +282,13 @@ public class DPlayer {
} }
for (Player player : dGroup.getPlayers()) { for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = get(player); DPlayer dPlayer = getByPlayer(player);
if (invalid) { if (invalid) {
dPlayer.leave(); dPlayer.leave();
} else { } else {
dPlayer.isFinished = false; dPlayer.finished = false;
} }
} }
@ -311,7 +310,7 @@ public class DPlayer {
GameWorld gameWorld = GameWorld.load(newFloor); GameWorld gameWorld = GameWorld.load(newFloor);
dGroup.setGameWorld(gameWorld); dGroup.setGameWorld(gameWorld);
for (Player player : dGroup.getPlayers()) { for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = get(player); DPlayer dPlayer = getByPlayer(player);
dPlayer.setWorld(gameWorld.getWorld()); dPlayer.setWorld(gameWorld.getWorld());
dPlayer.setCheckpoint(dGroup.getGameWorld().getLocStart()); dPlayer.setCheckpoint(dGroup.getGameWorld().getLocStart());
if (dPlayer.getWolf() != null) { if (dPlayer.getWolf() != null) {
@ -323,9 +322,9 @@ public class DPlayer {
public void finish() { public void finish() {
MessageUtil.sendMessage(getPlayer(), dMessages.getMessage(Messages.PLAYER_FINISHED_DUNGEON)); 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) { if (dGroup == null) {
return; return;
} }
@ -335,21 +334,21 @@ public class DPlayer {
} }
for (Player player : dGroup.getPlayers()) { for (Player player : dGroup.getPlayers()) {
DPlayer dplayer = get(player); DPlayer dPlayer = getByPlayer(player);
if ( !dplayer.isFinished) { if ( !dPlayer.finished) {
MessageUtil.sendMessage(this.getPlayer(), dMessages.getMessage(Messages.PLAYER_WAIT_FOR_OTHER_PLAYERS)); MessageUtil.sendMessage(this.getPlayer(), dMessages.getMessage(Messages.PLAYER_WAIT_FOR_OTHER_PLAYERS));
return; return;
} }
} }
for (Player player : dGroup.getPlayers()) { for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = get(player); DPlayer dPlayer = getByPlayer(player);
dPlayer.leave(); dPlayer.leave();
} }
} }
public void sendMessage(String message) { public void sendMessage(String message) {
if (isEditing) { if (editing) {
EditWorld editWorld = EditWorld.get(world); EditWorld editWorld = EditWorld.get(world);
editWorld.msg(message); editWorld.msg(message);
for (Player player : plugin.getChatSpyers()) { for (Player player : plugin.getChatSpyers()) {
@ -359,7 +358,7 @@ public class DPlayer {
} }
} else { } else {
GameWorld gameWorld = GameWorld.get(world); GameWorld gameWorld = GameWorld.getByWorld(world);
gameWorld.msg(message); gameWorld.msg(message);
for (Player player : plugin.getChatSpyers()) { for (Player player : plugin.getChatSpyers()) {
if ( !gameWorld.getWorld().getPlayers().contains(player)) { if ( !gameWorld.getWorld().getPlayers().contains(player)) {
@ -433,21 +432,6 @@ public class DPlayer {
this.world = world; 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 * @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() { public boolean isEditing() {
return isEditing; return editing;
} }
/** /**
* @param isEditing * @param editing
* the isEditing to set * the editing to set
*/ */
public void setEditing(boolean isEditing) { public void setEditing(boolean editing) {
this.isEditing = isEditing; this.editing = editing;
} }
/** /**
* @return the isInDungeonChat * @return the inDungeonChat
*/ */
public boolean isInDungeonChat() { public boolean isInDungeonChat() {
return isInDungeonChat; return inDungeonChat;
} }
/** /**
* @param isInDungeonChat * @param inDungeonChat
* the isInDungeonChat to set * the inDungeonChat to set
*/ */
public void setInDungeonChat(boolean isInDungeonChat) { public void setInDungeonChat(boolean inDungeonChat) {
this.isInDungeonChat = isInDungeonChat; this.inDungeonChat = inDungeonChat;
} }
/** /**
* @return the isReady * @return the isReady
*/ */
public boolean isReady() { public boolean isReady() {
return isReady; return ready;
} }
/** /**
* @param isReady * @param ready
* the isReady to set * If the player is ready to play the dungeon
*/ */
public void setReady(boolean isReady) { public void setReady(boolean ready) {
this.isReady = isReady; this.ready = ready;
} }
/** /**
* @return the isFinished * @return the finished
*/ */
public boolean isFinished() { public boolean isFinished() {
return isFinished; return finished;
} }
/** /**
* @param isFinished * @param finished
* the isFinished to set * the finished to set
*/ */
public void setFinished(boolean isFinished) { public void setFinished(boolean finished) {
this.isFinished = isFinished; this.finished = finished;
} }
/** /**
@ -535,7 +534,7 @@ public class DPlayer {
* the dClass to set * the dClass to set
*/ */
public void setDClass(String className) { public void setDClass(String className) {
GameWorld gameWorld = GameWorld.get(getPlayer().getWorld()); GameWorld gameWorld = GameWorld.getByWorld(getPlayer().getWorld());
if (gameWorld == null) { if (gameWorld == null) {
return; return;
} }
@ -777,30 +776,30 @@ public class DPlayer {
plugin.getDPlayers().remove(player); plugin.getDPlayers().remove(player);
} }
public static DPlayer get(Player player) { public static DPlayer getByPlayer(Player player) {
for (DPlayer dplayer : plugin.getDPlayers()) { for (DPlayer dPlayer : plugin.getDPlayers()) {
if (dplayer.getPlayer().equals(player)) { if (dPlayer.getPlayer().equals(player)) {
return dplayer; return dPlayer;
} }
} }
return null; return null;
} }
public static DPlayer get(String name) { public static DPlayer getByName(String name) {
for (DPlayer dplayer : plugin.getDPlayers()) { for (DPlayer dPlayer : plugin.getDPlayers()) {
if (dplayer.getPlayer().getName().equalsIgnoreCase(name)) { if (dPlayer.getPlayer().getName().equalsIgnoreCase(name)) {
return dplayer; return dPlayer;
} }
} }
return null; return null;
} }
public static CopyOnWriteArrayList<DPlayer> get(World world) { public static CopyOnWriteArrayList<DPlayer> getByWorld(World world) {
CopyOnWriteArrayList<DPlayer> dPlayers = new CopyOnWriteArrayList<DPlayer>(); CopyOnWriteArrayList<DPlayer> dPlayers = new CopyOnWriteArrayList<DPlayer>();
for (DPlayer dplayer : plugin.getDPlayers()) { for (DPlayer dPlayer : plugin.getDPlayers()) {
if (dplayer.world == world) { if (dPlayer.world == world) {
dPlayers.add(dplayer); dPlayers.add(dPlayer);
} }
} }
@ -808,70 +807,70 @@ public class DPlayer {
} }
public static void update(boolean updateSecond) { public static void update(boolean updateSecond) {
for (DPlayer dplayer : plugin.getDPlayers()) { for (DPlayer dPlayer : plugin.getDPlayers()) {
if ( !updateSecond) { if ( !updateSecond) {
if ( !dplayer.getPlayer().getWorld().equals(dplayer.world)) { if ( !dPlayer.getPlayer().getWorld().equals(dPlayer.world)) {
if (dplayer.isEditing) { if (dPlayer.editing) {
EditWorld eworld = EditWorld.get(dplayer.world); EditWorld editWorld = EditWorld.get(dPlayer.world);
if (eworld != null) { if (editWorld != null) {
if (eworld.getLobby() == null) { if (editWorld.getLobby() == null) {
MiscUtil.secureTeleport(dplayer.getPlayer(), eworld.getWorld().getSpawnLocation()); MiscUtil.secureTeleport(dPlayer.getPlayer(), editWorld.getWorld().getSpawnLocation());
} else { } else {
MiscUtil.secureTeleport(dplayer.getPlayer(), eworld.getLobby()); MiscUtil.secureTeleport(dPlayer.getPlayer(), editWorld.getLobby());
} }
} }
} else { } else {
GameWorld gameWorld = GameWorld.get(dplayer.world); GameWorld gameWorld = GameWorld.getByWorld(dPlayer.world);
if (gameWorld != null) { if (gameWorld != null) {
DGroup dGroup = DGroup.get(dplayer.getPlayer()); DGroup dGroup = DGroup.getByPlayer(dPlayer.getPlayer());
if (dplayer.checkpoint == null) { if (dPlayer.checkpoint == null) {
MiscUtil.secureTeleport(dplayer.getPlayer(), dGroup.getGameWorld().getLocStart()); MiscUtil.secureTeleport(dPlayer.getPlayer(), dGroup.getGameWorld().getLocStart());
if (dplayer.wolf != null) { if (dPlayer.wolf != null) {
dplayer.wolf.teleport(dGroup.getGameWorld().getLocStart()); dPlayer.wolf.teleport(dGroup.getGameWorld().getLocStart());
} }
} else { } else {
MiscUtil.secureTeleport(dplayer.getPlayer(), dplayer.checkpoint); MiscUtil.secureTeleport(dPlayer.getPlayer(), dPlayer.checkpoint);
if (dplayer.wolf != null) { if (dPlayer.wolf != null) {
dplayer.wolf.teleport(dplayer.checkpoint); dPlayer.wolf.teleport(dPlayer.checkpoint);
} }
} }
// Respawn Items // Respawn Items
if (dplayer.respawnInventory != null || dplayer.respawnArmor != null) { if (dPlayer.respawnInventory != null || dPlayer.respawnArmor != null) {
dplayer.getPlayer().getInventory().setContents(dplayer.respawnInventory); dPlayer.getPlayer().getInventory().setContents(dPlayer.respawnInventory);
dplayer.getPlayer().getInventory().setArmorContents(dplayer.respawnArmor); dPlayer.getPlayer().getInventory().setArmorContents(dPlayer.respawnArmor);
dplayer.respawnInventory = null; dPlayer.respawnInventory = null;
dplayer.respawnArmor = null; dPlayer.respawnArmor = null;
} }
} }
} }
} }
} else { } else {
GameWorld gameWorld = GameWorld.get(dplayer.world); GameWorld gameWorld = GameWorld.getByWorld(dPlayer.world);
if (gameWorld != null) { if (gameWorld != null) {
// Update Wolf // Update Wolf
if (dplayer.wolf != null) { if (dPlayer.wolf != null) {
if (dplayer.wolf.isDead()) { if (dPlayer.wolf.isDead()) {
if (dplayer.wolfRespawnTime <= 0) { if (dPlayer.wolfRespawnTime <= 0) {
dplayer.wolf = (Wolf) dplayer.world.spawnEntity(dplayer.getPlayer().getLocation(), EntityType.WOLF); dPlayer.wolf = (Wolf) dPlayer.world.spawnEntity(dPlayer.getPlayer().getLocation(), EntityType.WOLF);
dplayer.wolf.setTamed(true); dPlayer.wolf.setTamed(true);
dplayer.wolf.setOwner(dplayer.getPlayer()); dPlayer.wolf.setOwner(dPlayer.getPlayer());
dplayer.wolfRespawnTime = 30; dPlayer.wolfRespawnTime = 30;
} }
dplayer.wolfRespawnTime--; dPlayer.wolfRespawnTime--;
} }
} }
// Kick offline plugin.getDPlayers() // Kick offline plugin.getDPlayers()
if (dplayer.offlineTime > 0) { if (dPlayer.offlineTime > 0) {
if (dplayer.offlineTime < System.currentTimeMillis()) { if (dPlayer.offlineTime < System.currentTimeMillis()) {
dplayer.leave(); dPlayer.leave();
} }
} }
// Check Distance Trigger Signs // Check Distance Trigger Signs
DistanceTrigger.triggerAllInDistance(dplayer.getPlayer(), gameWorld); DistanceTrigger.triggerAllInDistance(dPlayer.getPlayer(), gameWorld);
} }
} }
} }

View File

@ -41,7 +41,7 @@ public class CheckpointSign extends DSign {
return; return;
} }
for (DPlayer dplayer : DPlayer.get(getGameWorld().getWorld())) { for (DPlayer dplayer : DPlayer.getByWorld(getGameWorld().getWorld())) {
dplayer.setCheckpoint(getSign().getLocation()); dplayer.setCheckpoint(getSign().getLocation());
MessageUtil.sendMessage(dplayer.getPlayer(), plugin.getDMessages().getMessage(Messages.PLAYER_CHECKPOINT_REACHED)); MessageUtil.sendMessage(dplayer.getPlayer(), plugin.getDMessages().getMessage(Messages.PLAYER_CHECKPOINT_REACHED));
} }
@ -55,7 +55,7 @@ public class CheckpointSign extends DSign {
return true; return true;
} }
DPlayer dplayer = DPlayer.get(player); DPlayer dplayer = DPlayer.getByPlayer(player);
if (dplayer != null) { if (dplayer != null) {
if ( !done.contains(dplayer)) { if ( !done.contains(dplayer)) {
done.add(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(); remove();
} }

View File

@ -138,7 +138,7 @@ public abstract class DSign {
for (Trigger trigger : triggers) { for (Trigger trigger : triggers) {
trigger.removeListener(this); trigger.removeListener(this);
} }
gameWorld.getdSigns().remove(this); gameWorld.getDSigns().remove(this);
} }
public boolean hasTriggers() { public boolean hasTriggers() {

View File

@ -44,10 +44,10 @@ public class EndSign extends DSign {
@Override @Override
public boolean onPlayerTrigger(Player player) { public boolean onPlayerTrigger(Player player) {
DPlayer dplayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dplayer != null) { if (dPlayer != null) {
if ( !dplayer.isFinished()) { if ( !dPlayer.isFinished()) {
dplayer.finish(); dPlayer.finish();
} }
} }
return true; return true;
@ -55,8 +55,8 @@ public class EndSign extends DSign {
@Override @Override
public void onTrigger() { public void onTrigger() {
for (DPlayer dplayer : plugin.getDPlayers()) { for (DPlayer dPlayer : plugin.getDPlayers()) {
dplayer.finish(); dPlayer.finish();
} }
} }

View File

@ -55,10 +55,10 @@ public class FloorSign extends DSign {
@Override @Override
public boolean onPlayerTrigger(Player player) { public boolean onPlayerTrigger(Player player) {
DPlayer dplayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dplayer != null) { if (dPlayer != null) {
if ( !dplayer.isFinished()) { if ( !dPlayer.isFinished()) {
dplayer.finishFloor(floor); dPlayer.finishFloor(floor);
} }
} }
@ -67,8 +67,8 @@ public class FloorSign extends DSign {
@Override @Override
public void onTrigger() { public void onTrigger() {
for (DPlayer dplayer : plugin.getDPlayers()) { for (DPlayer dPlayer : plugin.getDPlayers()) {
dplayer.finish(); dPlayer.finish();
} }
} }

View File

@ -44,9 +44,9 @@ public class LeaveSign extends DSign {
@Override @Override
public boolean onPlayerTrigger(Player player) { public boolean onPlayerTrigger(Player player) {
DPlayer dplayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dplayer != null) { if (dPlayer != null) {
dplayer.leave(); dPlayer.leave();
} }
return true; return true;
@ -54,8 +54,8 @@ public class LeaveSign extends DSign {
@Override @Override
public void onTrigger() { public void onTrigger() {
for (DPlayer dplayer : DungeonsXL.getPlugin().getDPlayers()) { for (DPlayer dPlayer : DungeonsXL.getPlugin().getDPlayers()) {
dplayer.leave(); dPlayer.leave();
} }
} }

View File

@ -118,7 +118,7 @@ public class MobSign extends DSign {
public void run() { public void run() {
if (sign.interval <= 0) { if (sign.interval <= 0) {
World world = sign.getSign().getWorld(); World world = sign.getSign().getWorld();
GameWorld gameWorld = GameWorld.get(world); GameWorld gameWorld = GameWorld.getByWorld(world);
if (gameWorld != null) { if (gameWorld != null) {
Location spawnLoc = sign.getSign().getLocation().add(0.5, 0, 0.5); Location spawnLoc = sign.getSign().getLocation().add(0.5, 0, 0.5);
@ -144,10 +144,10 @@ public class MobSign extends DSign {
} }
// Check custom mobs // Check custom mobs
DMobType mobType = DMobType.get(sign.mob, gameWorld.getConfig().getMobTypes()); DMobType mobType = DMobType.getByName(sign.mob, gameWorld.getConfig().getMobTypes());
if (mobType != null) { if (mobType != null) {
mobType.spawn(GameWorld.get(world), spawnLoc); mobType.spawn(GameWorld.getByWorld(world), spawnLoc);
} }
// Set the amount // Set the amount

View File

@ -120,7 +120,7 @@ public class MythicMobsSign extends DSign {
public void run() { public void run() {
if (sign.interval <= 0) { if (sign.interval <= 0) {
World world = sign.getSign().getWorld(); World world = sign.getSign().getWorld();
GameWorld gameWorld = GameWorld.get(world); GameWorld gameWorld = GameWorld.getByWorld(world);
if (gameWorld != null) { if (gameWorld != null) {
spawnLoc = sign.getSign().getLocation().add(0.5, 0, 0.5); spawnLoc = sign.getSign().getLocation().add(0.5, 0, 0.5);

View File

@ -47,7 +47,7 @@ public class ReadySign extends DSign {
@Override @Override
public boolean onPlayerTrigger(Player player) { public boolean onPlayerTrigger(Player player) {
ready(DPlayer.get(player)); ready(DPlayer.getByPlayer(player));
return true; return true;
} }

View File

@ -136,7 +136,7 @@ public class RedstoneSign extends DSign {
@Override @Override
public void run() { public void run() {
if (GameWorld.get(block.getWorld()) == null) { if (GameWorld.getByWorld(block.getWorld()) == null) {
disableTask(enableTaskId); disableTask(enableTaskId);
disableTask(disableTaskId); disableTask(disableTaskId);
return; return;

View File

@ -27,7 +27,7 @@ public class FileUtil {
return files; 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) { public static void copyDirectory(File sourceLocation, File targetLocation) {
if (sourceLocation.isDirectory()) { if (sourceLocation.isDirectory()) {
@ -39,7 +39,7 @@ public class FileUtil {
for (String element : children) { for (String element : children) {
boolean isOk = true; boolean isOk = true;
for (String excluded : excludedFiles) { for (String excluded : EXCLUDED_FILES) {
if (element.contains(excluded)) { if (element.contains(excluded)) {
isOk = false; isOk = false;
break; break;
@ -85,7 +85,7 @@ public class FileUtil {
} }
} }
public static void deletenotusingfiles(File directory) { public static void deleteUnusedFiles(File directory) {
File[] files = directory.listFiles(); File[] files = directory.listFiles();
for (File file : files) { for (File file : files) {
if (file.getName().equalsIgnoreCase("uid.dat") || file.getName().contains(".id_")) { if (file.getName().equalsIgnoreCase("uid.dat") || file.getName().contains(".id_")) {
@ -112,8 +112,10 @@ public class FileUtil {
inChannel = new FileInputStream(in).getChannel(); inChannel = new FileInputStream(in).getChannel();
outChannel = new FileOutputStream(out).getChannel(); outChannel = new FileOutputStream(out).getChannel();
inChannel.transferTo(0, inChannel.size(), outChannel); inChannel.transferTo(0, inChannel.size(), outChannel);
} catch (IOException e) { } catch (IOException e) {
throw e; throw e;
} finally { } finally {
if (inChannel != null) { if (inChannel != null) {
inChannel.close(); inChannel.close();

View File

@ -21,6 +21,7 @@ public class UUIDUtil {
public static boolean isValidUUID(String string) { 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}")) { 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; return true;
} else { } else {
return false; return false;
} }