Continue rewrite (including sign system rewrite)

This commit is contained in:
Daniel Saukel 2015-12-25 01:30:23 +01:00
parent e0a87dd2ac
commit 56f98e6826
58 changed files with 2836 additions and 1904 deletions

View File

@ -1,3 +1,6 @@
/* TODO: Cleanup - Overhaul DPlayer, GameWorld, GameChest & Listeners - MiscUtil - FileUtil -
* Variable names - Triggers */
package io.github.dre2n.dungeonsxl; package io.github.dre2n.dungeonsxl;
import io.github.dre2n.dungeonsxl.command.DCommands; import io.github.dre2n.dungeonsxl.command.DCommands;
@ -20,6 +23,7 @@ import io.github.dre2n.dungeonsxl.listener.WorldListener;
import io.github.dre2n.dungeonsxl.player.DGroup; import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer; import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.player.DSavePlayer; import io.github.dre2n.dungeonsxl.player.DSavePlayer;
import io.github.dre2n.dungeonsxl.sign.DSigns;
import io.github.dre2n.dungeonsxl.util.FileUtil; import io.github.dre2n.dungeonsxl.util.FileUtil;
import io.github.dre2n.dungeonsxl.util.VersionUtil; import io.github.dre2n.dungeonsxl.util.VersionUtil;
import io.github.dre2n.dungeonsxl.util.VersionUtil.Internals; import io.github.dre2n.dungeonsxl.util.VersionUtil.Internals;
@ -31,7 +35,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -49,6 +52,7 @@ public class DungeonsXL extends JavaPlugin {
private DMessages dMessages; private DMessages dMessages;
private VersionUtil versionUtil; private VersionUtil versionUtil;
private DCommands dCommands; private DCommands dCommands;
private DSigns dSigns;
private Dungeons dungeons; private Dungeons dungeons;
private CopyOnWriteArrayList<Player> chatSpyers = new CopyOnWriteArrayList<Player>(); private CopyOnWriteArrayList<Player> chatSpyers = new CopyOnWriteArrayList<Player>();
@ -67,15 +71,14 @@ public class DungeonsXL extends JavaPlugin {
getDataFolder().mkdir(); getDataFolder().mkdir();
// Load Language // Load Language
dMessages = new DMessages(new File(plugin.getDataFolder(), "languages/en.yml")); loadDMessages(new File(plugin.getDataFolder(), "languages/en.yml"));
// Load Config // Load Config
mainConfig = new MainConfig(new File(plugin.getDataFolder(), "config.yml")); loadMainConfig(new File(plugin.getDataFolder(), "config.yml"));
// Load Language 2 // Load Language 2
loadDMessages(new File(plugin.getDataFolder(), "languages/" + mainConfig.getLanguage() + ".yml")); loadDMessages(new File(plugin.getDataFolder(), "languages/" + mainConfig.getLanguage() + ".yml"));
loadVersionUtil(); loadVersionUtil();
loadDCommands(); loadDCommands();
loadDSigns();
loadDungeons(); loadDungeons();
// InitFolders // InitFolders
@ -88,11 +91,11 @@ public class DungeonsXL extends JavaPlugin {
loadEconomyProvider(); loadEconomyProvider();
getCommand("dungeonsxl").setExecutor(new CommandListener()); getCommand("dungeonsxl").setExecutor(new CommandListener());
Bukkit.getServer().getPluginManager().registerEvents(new EntityListener(), this); getServer().getPluginManager().registerEvents(new EntityListener(), this);
Bukkit.getServer().getPluginManager().registerEvents(new PlayerListener(), this); getServer().getPluginManager().registerEvents(new PlayerListener(), this);
Bukkit.getServer().getPluginManager().registerEvents(new BlockListener(), this); getServer().getPluginManager().registerEvents(new BlockListener(), this);
Bukkit.getServer().getPluginManager().registerEvents(new WorldListener(), this); getServer().getPluginManager().registerEvents(new WorldListener(), this);
Bukkit.getServer().getPluginManager().registerEvents(new HangingListener(), this); getServer().getPluginManager().registerEvents(new HangingListener(), this);
// Load All // Load All
loadAll(); loadAll();
@ -167,14 +170,14 @@ public class DungeonsXL extends JavaPlugin {
@Override @Override
public void run() { public void run() {
for (GameWorld gworld : gameWorlds) { for (GameWorld gworld : gameWorlds) {
if (gworld.world.getPlayers().isEmpty()) { if (gworld.getWorld().getPlayers().isEmpty()) {
if (DPlayer.get(gworld.world).isEmpty()) { if (DPlayer.get(gworld.getWorld()).isEmpty()) {
gworld.delete(); gworld.delete();
} }
} }
} }
for (EditWorld eworld : editWorlds) { for (EditWorld eworld : editWorlds) {
if (eworld.world.getPlayers().isEmpty()) { if (eworld.getWorld().getPlayers().isEmpty()) {
eworld.delete(); eworld.delete();
} }
} }
@ -208,6 +211,7 @@ public class DungeonsXL extends JavaPlugin {
try { try {
configFile.save(file); configFile.save(file);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -243,6 +247,7 @@ public class DungeonsXL extends JavaPlugin {
} }
FileUtil.removeDirectory(file); FileUtil.removeDirectory(file);
} else if (file.getName().contains("DXL_Game_") && file.isDirectory()) { } else if (file.getName().contains("DXL_Game_") && file.isDirectory()) {
FileUtil.removeDirectory(file); FileUtil.removeDirectory(file);
} }
@ -276,6 +281,7 @@ public class DungeonsXL extends JavaPlugin {
this.economyProvider = economyProvider.getProvider(); this.economyProvider = economyProvider.getProvider();
} }
} }
} catch (NoClassDefFoundError error) { } catch (NoClassDefFoundError error) {
getLogger().info("Could not hook into Vault to register an economy provider!"); getLogger().info("Could not hook into Vault to register an economy provider!");
} }
@ -297,6 +303,7 @@ public class DungeonsXL extends JavaPlugin {
if (permissionProvider != null) { if (permissionProvider != null) {
this.permissionProvider = permissionProvider.getProvider(); this.permissionProvider = permissionProvider.getProvider();
} }
} catch (NoClassDefFoundError error) { } catch (NoClassDefFoundError error) {
getLogger().info("Could not hook into Vault to register a permission provider!"); getLogger().info("Could not hook into Vault to register a permission provider!");
} }
@ -372,6 +379,20 @@ public class DungeonsXL extends JavaPlugin {
dCommands = new DCommands(); dCommands = new DCommands();
} }
/**
* @return the dSigns
*/
public DSigns getDSigns() {
return dSigns;
}
/**
* load / reload a new instance of Dungeons
*/
public void loadDSigns() {
dSigns = new DSigns();
}
/** /**
* @return the loaded instance of Dungeons * @return the loaded instance of Dungeons
*/ */

View File

@ -21,19 +21,19 @@ public class ChatCommand extends DCommand {
Player player = (Player) sender; Player player = (Player) sender;
DPlayer dplayer = DPlayer.get(player); DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) { if (dplayer == null) {
if (dplayer.isInDungeonChat) { MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
dplayer.isInDungeonChat = false; return;
}
if (dplayer.isInDungeonChat()) {
dplayer.setInDungeonChat(false);
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Chat_NormalChat")); MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Chat_NormalChat"));
} else { } else {
dplayer.isInDungeonChat = true; dplayer.setInDungeonChat(true);
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Chat_DungeonChat")); MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Chat_DungeonChat"));
} }
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
}
} }
} }

View File

@ -31,11 +31,11 @@ public class CreateCommand extends DCommand {
plugin.getLogger().info(plugin.getDMessages().get("Log_GenerateNewWorld")); plugin.getLogger().info(plugin.getDMessages().get("Log_GenerateNewWorld"));
// Create World // Create World
EditWorld eworld = new EditWorld(); EditWorld editWorld = new EditWorld();
eworld.generate(); editWorld.generate();
eworld.dungeonname = name; editWorld.setMapName(name);
eworld.save(); editWorld.save();
eworld.delete(); editWorld.delete();
// MSG Done // MSG Done
plugin.getLogger().info(plugin.getDMessages().get("Log_WorldGenerationFinished")); plugin.getLogger().info(plugin.getDMessages().get("Log_WorldGenerationFinished"));
@ -47,35 +47,35 @@ 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.get(player) != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
return;
}
if (name.length() <= 15) { if (name.length() <= 15) {
// Msg create // Msg create
plugin.getLogger().info(plugin.getDMessages().get("Log_NewDungeon")); plugin.getLogger().info(plugin.getDMessages().get("Log_NewDungeon"));
plugin.getLogger().info(plugin.getDMessages().get("Log_GenerateNewWorld")); plugin.getLogger().info(plugin.getDMessages().get("Log_GenerateNewWorld"));
// Create World // Create World
EditWorld eworld = new EditWorld(); EditWorld editWorld = new EditWorld();
eworld.generate(); editWorld.generate();
eworld.dungeonname = name; editWorld.setMapName(name);
// MSG Done // MSG Done
plugin.getLogger().info(plugin.getDMessages().get("Log_WorldGenerationFinished")); plugin.getLogger().info(plugin.getDMessages().get("Log_WorldGenerationFinished"));
// Tp Player // Tp Player
if (eworld.lobby == null) { if (editWorld.getLobby() == null) {
new DPlayer(player, eworld.world, eworld.world.getSpawnLocation(), true); new DPlayer(player, editWorld.getWorld(), editWorld.getWorld().getSpawnLocation(), true);
} else { } else {
new DPlayer(player, eworld.world, eworld.lobby, true); new DPlayer(player, editWorld.getWorld(), editWorld.getLobby(), true);
} }
} else { } else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NameToLong")); MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NameToLong"));
} }
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
}
} }
} }

View File

@ -28,6 +28,7 @@ public class DeletePortalCommand extends DCommand {
if (dPortal != null) { if (dPortal != null) {
dPortal.delete(); dPortal.delete();
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalDeleted")); MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalDeleted"));
} else { } else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoPortal")); MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoPortal"));
} }

View File

@ -27,26 +27,31 @@ public class EditCommand extends DCommand {
DGroup dgroup = DGroup.get(player); DGroup dgroup = DGroup.get(player);
DPlayer dplayer = DPlayer.get(player); DPlayer dplayer = DPlayer.get(player);
if (EditWorld.isInvitedPlayer(dungeonName, player.getUniqueId(), player.getName()) || player.hasPermission("dxl.edit")) { if ( !(EditWorld.isInvitedPlayer(dungeonName, player.getUniqueId(), player.getName()) || player.hasPermission("dxl.edit"))) {
if (dplayer == null) {
if (dgroup == null) {
if (eworld != null) {
if (eworld.lobby == null) {
new DPlayer(player, eworld.world, eworld.world.getSpawnLocation(), true);
} else {
new DPlayer(player, eworld.world, eworld.lobby, true);
}
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_DungeonNotExist", dungeonName));
}
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveGroup"));
}
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
}
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoPermission")); MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoPermission"));
return;
}
if (dplayer != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
return;
}
if (dgroup != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveGroup"));
return;
}
if (eworld == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_DungeonNotExist", dungeonName));
return;
}
if (eworld.getLobby() == null) {
new DPlayer(player, eworld.getWorld(), eworld.getWorld().getSpawnLocation(), true);
} else {
new DPlayer(player, eworld.getWorld(), eworld.getLobby(), true);
} }
} }

View File

@ -24,21 +24,21 @@ public class EscapeCommand extends DCommand {
DPlayer dplayer = DPlayer.get(player); DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) { if (dplayer != null) {
if (dplayer.isEditing) { if ( !dplayer.isEditing()) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
return;
}
dplayer.escape(); dplayer.escape();
EditWorld eworld = EditWorld.get(dplayer.world); EditWorld eworld = EditWorld.get(dplayer.getWorld());
if (eworld != null) { if (eworld == null) {
if (eworld.world.getPlayers().isEmpty()) { return;
}
if (eworld.getWorld().getPlayers().isEmpty()) {
eworld.deleteNoSave(); eworld.deleteNoSave();
} }
}
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
}
return;
} else { } else {
DGroup dgroup = DGroup.get(player); DGroup dgroup = DGroup.get(player);

View File

@ -22,6 +22,7 @@ public class InviteCommand extends DCommand {
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
if (EditWorld.addInvitedPlayer(args[2], UUIDUtil.getUniqueIdFromName(args[1]))) { if (EditWorld.addInvitedPlayer(args[2], UUIDUtil.getUniqueIdFromName(args[1]))) {
MessageUtil.sendMessage(sender, plugin.getDMessages().get("Cmd_Invite_Success", args[1], args[2])); MessageUtil.sendMessage(sender, plugin.getDMessages().get("Cmd_Invite_Success", args[1], args[2]));
} else { } else {
MessageUtil.sendMessage(sender, plugin.getDMessages().get("Error_DungeonNotExist", args[2])); MessageUtil.sendMessage(sender, plugin.getDMessages().get("Error_DungeonNotExist", args[2]));
} }

View File

@ -24,7 +24,7 @@ public class LeaveCommand extends DCommand {
DPlayer dplayer = DPlayer.get(player); DPlayer dplayer = DPlayer.get(player);
if (GameWorld.get(player.getWorld()) != null) { if (GameWorld.get(player.getWorld()) != null) {
if (GameWorld.get(player.getWorld()).isTutorial) { if (GameWorld.get(player.getWorld()).isTutorial()) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoLeaveInTutorial")); MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoLeaveInTutorial"));
return; return;
} }

View File

@ -38,10 +38,10 @@ public class ListCommand extends DCommand {
} }
ArrayList<String> loadedList = new ArrayList<String>(); ArrayList<String> loadedList = new ArrayList<String>();
for (EditWorld editWorld : plugin.getEditWorlds()) { for (EditWorld editWorld : plugin.getEditWorlds()) {
loadedList.add(editWorld.world.getWorldFolder().getName()); loadedList.add(editWorld.getWorld().getWorldFolder().getName());
} }
for (GameWorld gameWorld : plugin.getGameWorlds()) { for (GameWorld gameWorld : plugin.getGameWorlds()) {
loadedList.add(gameWorld.world.getWorldFolder().getName()); loadedList.add(gameWorld.getWorld().getWorldFolder().getName());
} }
ArrayList<String> toSend = new ArrayList<String>(); ArrayList<String> toSend = new ArrayList<String>();

View File

@ -39,7 +39,7 @@ public class LivesCommand extends DCommand {
DPlayer dPlayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.get(player);
if (dPlayer != null) { if (dPlayer != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Lives").replaceAll("v1", player.getName()).replaceAll("v2", String.valueOf(dPlayer.lives))); MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Lives").replaceAll("v1", player.getName()).replaceAll("v2", String.valueOf(dPlayer.getLives())));
} else { } else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon")); MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));

View File

@ -25,14 +25,22 @@ public class MsgCommand 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 (editWorld == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
return;
}
if (args.length <= 1) {
displayHelp(player);
return;
}
if (eworld != null) {
if (args.length > 1) {
try { try {
int id = IntegerUtil.parseInt(args[1]); int id = IntegerUtil.parseInt(args[1]);
WorldConfig confreader = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + eworld.dungeonname, "config.yml")); WorldConfig confreader = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + editWorld.getMapName(), "config.yml"));
if (args.length == 2) { if (args.length == 2) {
String msg = confreader.getMsg(id, true); String msg = confreader.getMsg(id, true);
@ -78,14 +86,6 @@ public class MsgCommand extends DCommand {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_MsgNoInt")); MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_MsgNoInt"));
} }
} else {
displayHelp(player);
}
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
}
} }
} }

View File

@ -90,17 +90,17 @@ public class PlayCommand extends DCommand {
return; return;
} }
DGroup dgroup = new DGroup(player, identifier, multiFloor); DGroup dGroup = new DGroup(player, identifier, multiFloor);
if (dgroup.getGWorld() == null) { if (dGroup.getGWorld() == null) {
dgroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName())); dGroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName()));
} }
if (dgroup.getGWorld().locLobby == null) { if (dGroup.getGWorld().getLocLobby() == null) {
new DPlayer(player, dgroup.getGWorld().world, dgroup.getGWorld().world.getSpawnLocation(), false); new DPlayer(player, dGroup.getGWorld().getWorld(), dGroup.getGWorld().getWorld().getSpawnLocation(), false);
} else { } else {
new DPlayer(player, dgroup.getGWorld().world, dgroup.getGWorld().locLobby, false); new DPlayer(player, dGroup.getGWorld().getWorld(), dGroup.getGWorld().getLocLobby(), false);
} }
} }

View File

@ -25,7 +25,10 @@ public class PortalCommand extends DCommand {
Player player = (Player) sender; Player player = (Player) sender;
DPlayer dplayer = DPlayer.get(player); DPlayer dplayer = DPlayer.get(player);
if (dplayer == null) { if (dplayer != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
}
DPortal dportal = DPortal.get(player); DPortal dportal = DPortal.get(player);
if (dportal == null) { if (dportal == null) {
@ -39,10 +42,6 @@ public class PortalCommand extends DCommand {
plugin.getDPortals().remove(dportal); plugin.getDPortals().remove(dportal);
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalAbort")); MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalAbort"));
} }
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
}
} }
} }

View File

@ -65,22 +65,22 @@ public class TestCommand extends DCommand {
return; return;
} }
DGroup dgroup = new DGroup(player, identifier, multiFloor); DGroup dGroup = new DGroup(player, identifier, multiFloor);
if (dgroup.getGWorld() == null) { if (dGroup.getGWorld() == null) {
dgroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName())); dGroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName()));
} }
DPlayer newDPlayer; DPlayer newDPlayer;
if (dgroup.getGWorld().locLobby == null) { if (dGroup.getGWorld().getLocLobby() == null) {
newDPlayer = new DPlayer(player, dgroup.getGWorld().world, dgroup.getGWorld().world.getSpawnLocation(), false); newDPlayer = new DPlayer(player, dGroup.getGWorld().getWorld(), dGroup.getGWorld().getWorld().getSpawnLocation(), false);
} else { } else {
newDPlayer = new DPlayer(player, dgroup.getGWorld().world, dgroup.getGWorld().locLobby, false); newDPlayer = new DPlayer(player, dGroup.getGWorld().getWorld(), dGroup.getGWorld().getLocLobby(), false);
} }
newDPlayer.isinTestMode = true; newDPlayer.setIsInTestMode(true);
} }
} }

View File

@ -19,13 +19,13 @@ public class DLootInventory {
private long time; private long time;
public DLootInventory(Player player, ItemStack[] istacks) { public DLootInventory(Player player, ItemStack[] itemStacks) {
plugin.getDLootInventories().add(this); plugin.getDLootInventories().add(this);
inventory = Bukkit.createInventory(player, 54, ChatColor.translateAlternateColorCodes('&', DungeonsXL.getPlugin().getDMessages().get("Player_Treasures"))); inventory = Bukkit.createInventory(player, 54, ChatColor.translateAlternateColorCodes('&', DungeonsXL.getPlugin().getDMessages().get("Player_Treasures")));
for (ItemStack istack : istacks) { for (ItemStack itemStack : itemStacks) {
if (istack != null) { if (itemStack != null) {
inventory.addItem(istack); inventory.addItem(itemStack);
} }
} }
this.player = player; this.player = player;

View File

@ -28,14 +28,14 @@ public class EditWorld {
static DungeonsXL plugin = DungeonsXL.getPlugin(); static DungeonsXL plugin = DungeonsXL.getPlugin();
// Variables // Variables
public World world; private World world;
public String owner; private String owner;
public String name; private String name;
public String dungeonname; private String mapName;
public int id; private int id;
public Location lobby; private Location lobby;
public CopyOnWriteArrayList<String> invitedPlayers = new CopyOnWriteArrayList<String>(); private CopyOnWriteArrayList<String> invitedPlayers = new CopyOnWriteArrayList<String>();
public CopyOnWriteArrayList<Block> sign = new CopyOnWriteArrayList<Block>(); private CopyOnWriteArrayList<Block> sign = new CopyOnWriteArrayList<Block>();
public EditWorld() { public EditWorld() {
plugin.getEditWorlds().add(this); plugin.getEditWorlds().add(this);
@ -46,8 +46,8 @@ public class EditWorld {
while (id == -1) { while (id == -1) {
i++; i++;
boolean exist = false; boolean exist = false;
for (EditWorld eworld : plugin.getEditWorlds()) { for (EditWorld editWorld : plugin.getEditWorlds()) {
if (eworld.id == i) { if (editWorld.id == i) {
exist = true; exist = true;
break; break;
} }
@ -72,7 +72,7 @@ public class EditWorld {
world.save(); world.save();
try { try {
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(new File(plugin.getDataFolder(), "/maps/" + dungeonname + "/DXLData.data"))); ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(new File(plugin.getDataFolder(), "/maps/" + mapName + "/DXLData.data")));
out.writeInt(sign.size()); out.writeInt(sign.size());
for (Block sign : this.sign) { for (Block sign : this.sign) {
out.writeInt(sign.getX()); out.writeInt(sign.getX());
@ -104,8 +104,8 @@ public class EditWorld {
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/" + dungeonname)); FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName));
FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + dungeonname)); FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
FileUtil.removeDirectory(dir); FileUtil.removeDirectory(dir);
} }
@ -117,17 +117,17 @@ public class EditWorld {
} }
File dir = new File("DXL_Edit_" + id); File dir = new File("DXL_Edit_" + id);
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + dungeonname)); FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName));
FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + dungeonname)); FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
plugin.getServer().unloadWorld(world, true); plugin.getServer().unloadWorld(world, true);
FileUtil.removeDirectory(dir); FileUtil.removeDirectory(dir);
} }
// Static // Static
public static EditWorld get(World world) { public static EditWorld get(World world) {
for (EditWorld eworld : plugin.getEditWorlds()) { for (EditWorld editWorld : plugin.getEditWorlds()) {
if (eworld.world.equals(world)) { if (editWorld.world.equals(world)) {
return eworld; return editWorld;
} }
} }
@ -135,9 +135,9 @@ public class EditWorld {
} }
public static EditWorld get(String name) { public static EditWorld get(String name) {
for (EditWorld eworld : plugin.getEditWorlds()) { for (EditWorld editWorld : plugin.getEditWorlds()) {
if (eworld.dungeonname.equalsIgnoreCase(name)) { if (editWorld.mapName.equalsIgnoreCase(name)) {
return eworld; return editWorld;
} }
} }
@ -145,47 +145,47 @@ public class EditWorld {
} }
public static void deleteAll() { public static void deleteAll() {
for (EditWorld eworld : plugin.getEditWorlds()) { for (EditWorld editWorld : plugin.getEditWorlds()) {
eworld.delete(); editWorld.delete();
} }
} }
public static EditWorld load(String name) { public static EditWorld load(String name) {
for (EditWorld eworld : plugin.getEditWorlds()) { for (EditWorld editWorld : plugin.getEditWorlds()) {
if (eworld.dungeonname.equalsIgnoreCase(name)) { if (editWorld.mapName.equalsIgnoreCase(name)) {
return eworld; return editWorld;
} }
} }
File file = new File(plugin.getDataFolder(), "/maps/" + name); File file = new File(plugin.getDataFolder(), "/maps/" + name);
if (file.exists()) { if (file.exists()) {
EditWorld eworld = new EditWorld(); EditWorld editWorld = new EditWorld();
eworld.dungeonname = name; editWorld.mapName = name;
// World // World
FileUtil.copyDirectory(file, new File("DXL_Edit_" + eworld.id)); FileUtil.copyDirectory(file, new File("DXL_Edit_" + editWorld.id));
// Id File // Id File
File idFile = new File("DXL_Edit_" + eworld.id + "/.id_" + name); File idFile = new File("DXL_Edit_" + editWorld.id + "/.id_" + name);
try { try {
idFile.createNewFile(); idFile.createNewFile();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
eworld.world = plugin.getServer().createWorld(WorldCreator.name("DXL_Edit_" + eworld.id)); editWorld.world = plugin.getServer().createWorld(WorldCreator.name("DXL_Edit_" + editWorld.id));
try { try {
ObjectInputStream os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder(), "/maps/" + eworld.dungeonname + "/DXLData.data"))); ObjectInputStream os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder(), "/maps/" + editWorld.mapName + "/DXLData.data")));
int length = os.readInt(); int length = os.readInt();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
int x = os.readInt(); int x = os.readInt();
int y = os.readInt(); int y = os.readInt();
int z = os.readInt(); int z = os.readInt();
Block block = eworld.world.getBlockAt(x, y, z); Block block = editWorld.world.getBlockAt(x, y, z);
eworld.checkSign(block); editWorld.checkSign(block);
eworld.sign.add(block); editWorld.sign.add(block);
} }
os.close(); os.close();
@ -195,7 +195,7 @@ public class EditWorld {
e.printStackTrace(); e.printStackTrace();
} }
return eworld; return editWorld;
} }
return null; return null;
@ -203,8 +203,8 @@ public class EditWorld {
public static boolean exist(String name) { public static boolean exist(String name) {
// Cheack Loaded EditWorlds // Cheack Loaded EditWorlds
for (EditWorld eworld : plugin.getEditWorlds()) { for (EditWorld editWorld : plugin.getEditWorlds()) {
if (eworld.dungeonname.equalsIgnoreCase(name)) { if (editWorld.mapName.equalsIgnoreCase(name)) {
return true; return true;
} }
} }
@ -221,14 +221,14 @@ public class EditWorld {
public void msg(String msg) { public void msg(String msg) {
for (DPlayer dplayer : DPlayer.get(world)) { for (DPlayer dplayer : DPlayer.get(world)) {
MessageUtil.sendMessage(dplayer.player, msg); MessageUtil.sendMessage(dplayer.getPlayer(), msg);
} }
} }
// Invite // Invite
public static boolean addInvitedPlayer(String eworldname, UUID uuid) { public static boolean addInvitedPlayer(String editWorldname, UUID uuid) {
if (exist(eworldname)) { if (exist(editWorldname)) {
WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + eworldname, "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;
@ -237,20 +237,19 @@ public class EditWorld {
return false; return false;
} }
public static boolean removeInvitedPlayer(String eworldname, UUID uuid, String name) { public static boolean removeInvitedPlayer(String editWorldName, UUID uuid, String name) {
if (exist(editWorldName)) {
if (exist(eworldname)) { WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml"));
WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + eworldname, "config.yml"));
config.removeInvitedPlayers(uuid.toString(), name.toLowerCase()); config.removeInvitedPlayers(uuid.toString(), name.toLowerCase());
config.save(); config.save();
// Kick Player // Kick Player
EditWorld eworld = EditWorld.get(eworldname); EditWorld editWorld = EditWorld.get(editWorldName);
if (eworld != null) { if (editWorld != null) {
DPlayer player = DPlayer.get(name); DPlayer player = DPlayer.get(name);
if (player != null) { if (player != null) {
if (eworld.world.getPlayers().contains(player.player)) { if (editWorld.world.getPlayers().contains(player.getPlayer())) {
player.leave(); player.leave();
} }
} }
@ -262,16 +261,139 @@ public class EditWorld {
return false; return false;
} }
public static boolean isInvitedPlayer(String eworldname, UUID uuid, String name) { public static boolean isInvitedPlayer(String editWorldname, UUID uuid, String name) {
if (exist(eworldname)) { if ( !exist(editWorldname)) {
WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + eworldname, "config.yml"));
// get player from both a 0.9.1 and lower and 0.9.2 and higher file
if (config.getInvitedPlayers().contains(name.toLowerCase()) || config.getInvitedPlayers().contains(uuid.toString())) {
return true;
}
}
return false; return false;
} }
WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + editWorldname, "config.yml"));
// get player from both a 0.9.1 and lower and 0.9.2 and higher file
if (config.getInvitedPlayers().contains(name.toLowerCase()) || config.getInvitedPlayers().contains(uuid.toString())) {
return true;
} else {
return false;
}
}
/**
* @return the world
*/
public World getWorld() {
return world;
}
/**
* @param world
* the world to set
*/
public void setWorld(World world) {
this.world = world;
}
/**
* @return the owner
*/
public String getOwner() {
return owner;
}
/**
* @param owner
* the owner to set
*/
public void setOwner(String owner) {
this.owner = owner;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the mapName
*/
public String getMapName() {
return mapName;
}
/**
* @param mapName
* the mapName to set
*/
public void setMapName(String mapName) {
this.mapName = mapName;
}
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id
* the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the lobby
*/
public Location getLobby() {
return lobby;
}
/**
* @param lobby
* the lobby to set
*/
public void setLobby(Location lobby) {
this.lobby = lobby;
}
/**
* @return the invitedPlayers
*/
public CopyOnWriteArrayList<String> getInvitedPlayers() {
return invitedPlayers;
}
/**
* @param invitedPlayers
* the invitedPlayers to set
*/
public void setInvitedPlayers(CopyOnWriteArrayList<String> invitedPlayers) {
this.invitedPlayers = invitedPlayers;
}
/**
* @return the sign
*/
public CopyOnWriteArrayList<Block> getSign() {
return sign;
}
/**
* @param sign
* the sign to set
*/
public void setSign(CopyOnWriteArrayList<Block> sign) {
this.sign = sign;
}
} }

View File

@ -263,7 +263,9 @@ public class WorldConfig {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void save() { public void save() {
if (file != null) { if (file == null) {
return;
}
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file); FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
// Messages // Messages
@ -285,11 +287,11 @@ public class WorldConfig {
try { try {
configFile.save(file); configFile.save(file);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
}
// Getters and Setters // Getters and Setters
public CopyOnWriteArrayList<DClass> getClasses() { public CopyOnWriteArrayList<DClass> getClasses() {

View File

@ -18,49 +18,64 @@ import org.bukkit.inventory.ItemStack;
public class GameChest { public class GameChest {
// Variables // Variables
public boolean isUsed = false; private boolean isUsed = false;
public Chest chest; private Chest chest;
public GameWorld gWorld; private GameWorld gameWorld;
public double moneyReward; private double moneyReward;
public GameChest(Block chest, GameWorld gameWorld, double moneyReward) {
if ( !(chest.getState() instanceof Chest)) {
return;
}
public GameChest(Block chest, GameWorld gWorld, double moneyReward) {
if (chest.getState() instanceof Chest) {
this.chest = (Chest) chest.getState(); this.chest = (Chest) chest.getState();
this.gWorld = gWorld; this.gameWorld = gameWorld;
this.moneyReward = moneyReward; this.moneyReward = moneyReward;
gWorld.gameChests.add(this); gameWorld.getGameChests().add(this);
}
} }
public void addTreasure(DGroup dgroup) { public void addTreasure(DGroup dGroup) {
if (dgroup != null) { if (dGroup == null) {
for (Player player : dgroup.getPlayers()) { return;
}
for (Player player : dGroup.getPlayers()) {
DPlayer dplayer = DPlayer.get(player); DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) { if (dplayer == null) {
dplayer.treasureMoney = dplayer.treasureMoney + moneyReward; continue;
String msg = ""; }
for (ItemStack istack : chest.getInventory().getContents()) {
if (istack != null) { dplayer.setTreasureMoney(dplayer.getTreasureMoney() + moneyReward);
dplayer.treasureInv.addItem(istack); String msg = "";
for (ItemStack itemStack : chest.getInventory().getContents()) {
if (itemStack == null) {
continue;
}
dplayer.getTreasureInv().addItem(itemStack);
String name; String name;
if (istack.hasItemMeta() && istack.getItemMeta().hasDisplayName()) { if ( !itemStack.hasItemMeta()) {
name = istack.getItemMeta().getDisplayName(); continue;
}
if (itemStack.getItemMeta().hasDisplayName()) {
name = itemStack.getItemMeta().getDisplayName();
} else { } else {
ItemInfo itemInfo = Items.itemByStack(istack); ItemInfo itemInfo = Items.itemByStack(itemStack);
if (itemInfo != null) { if (itemInfo != null) {
name = itemInfo.getName(); name = itemInfo.getName();
} else { } else {
name = istack.getType().name(); name = itemStack.getType().name();
} }
} }
msg = msg + ChatColor.RED + " " + istack.getAmount() + " " + name + ChatColor.GOLD + ",";
} msg = msg + ChatColor.RED + " " + itemStack.getAmount() + " " + name + ChatColor.GOLD + ",";
} }
msg = msg.substring(0, msg.length() - 1); msg = msg.substring(0, msg.length() - 1);
@ -71,37 +86,100 @@ public class GameChest {
} }
} }
} }
}
}
// Statics // Statics
public static void onOpenInventory(InventoryOpenEvent event) { public static void onOpenInventory(InventoryOpenEvent event) {
InventoryView inventory = event.getView(); InventoryView inventory = event.getView();
GameWorld gWorld = GameWorld.get(event.getPlayer().getWorld()); GameWorld gameWorld = GameWorld.get(event.getPlayer().getWorld());
if (gameWorld == null) {
return;
}
if (gWorld != null) {
if (inventory.getTopInventory().getHolder() instanceof Chest) { if (inventory.getTopInventory().getHolder() instanceof Chest) {
return;
}
Chest chest = (Chest) inventory.getTopInventory().getHolder(); Chest chest = (Chest) inventory.getTopInventory().getHolder();
for (GameChest gchest : gWorld.gameChests) { for (GameChest gameChest : gameWorld.getGameChests()) {
if (gchest.chest.equals(chest)) { if ( !gameChest.chest.equals(chest)) {
continue;
if ( !gchest.isUsed) {
if (gchest.chest.getLocation().distance(chest.getLocation()) < 1) {
gchest.addTreasure(DGroup.get(gWorld));
gchest.isUsed = true;
event.setCancelled(true);
} }
} else { if ( !gameChest.isUsed) {
MessageUtil.sendMessage(DungeonsXL.getPlugin().getServer().getPlayer(event.getPlayer().getUniqueId()), DungeonsXL.getPlugin().getDMessages().get("Error_ChestIsOpened")); MessageUtil.sendMessage(DungeonsXL.getPlugin().getServer().getPlayer(event.getPlayer().getUniqueId()), DungeonsXL.getPlugin().getDMessages().get("Error_ChestIsOpened"));
event.setCancelled(true); event.setCancelled(true);
continue;
} }
}
} if (gameChest.chest.getLocation().distance(chest.getLocation()) < 1) {
gameChest.addTreasure(DGroup.get(gameWorld));
gameChest.isUsed = true;
event.setCancelled(true);
} }
} }
} }
/**
* @return the isUsed
*/
public boolean isUsed() {
return isUsed;
}
/**
* @param isUsed
* the isUsed to set
*/
public void setUsed(boolean isUsed) {
this.isUsed = isUsed;
}
/**
* @return the chest
*/
public Chest getChest() {
return chest;
}
/**
* @param chest
* the chest to set
*/
public void setChest(Chest chest) {
this.chest = chest;
}
/**
* @return the gameWorld
*/
public GameWorld getGameWorld() {
return gameWorld;
}
/**
* @param gameWorld
* the gameWorld to set
*/
public void setGameWorld(GameWorld gameWorld) {
this.gameWorld = gameWorld;
}
/**
* @return the moneyReward
*/
public double getMoneyReward() {
return moneyReward;
}
/**
* @param moneyReward
* the moneyReward to set
*/
public void setMoneyReward(double moneyReward) {
this.moneyReward = moneyReward;
}
} }

View File

@ -42,10 +42,14 @@ public class GamePlaceableBlock {
for (int direction = 0; direction < 6; direction++) { for (int direction = 0; direction < 6; direction++) {
boolean positive = String.valueOf(directions.charAt(direction)).equals("x"); boolean positive = String.valueOf(directions.charAt(direction)).equals("x");
if (positive) { if ( !positive) {
continue;
}
if (direction == 0) { if (direction == 0) {
onTop = true; onTop = true;
} }
if (direction == 1) { if (direction == 1) {
onBottom = true; onBottom = true;
} }
@ -58,59 +62,79 @@ public class GamePlaceableBlock {
if (direction == 2) { if (direction == 2) {
onNorth = true; onNorth = true;
} }
if (direction == 3) { if (direction == 3) {
onEast = true; onEast = true;
} }
if (direction == 4) { if (direction == 4) {
onSouth = true; onSouth = true;
} }
if (direction == 5) { if (direction == 5) {
onWest = true; onWest = true;
} }
break; break;
case 4: case 4:
if (direction == 5) { if (direction == 5) {
onNorth = true; onNorth = true;
} }
if (direction == 2) { if (direction == 2) {
onEast = true; onEast = true;
} }
if (direction == 3) { if (direction == 3) {
onSouth = true; onSouth = true;
} }
if (direction == 4) { if (direction == 4) {
onWest = true; onWest = true;
} }
break; break;
case 2: case 2:
if (direction == 4) { if (direction == 4) {
onNorth = true; onNorth = true;
} }
if (direction == 5) { if (direction == 5) {
onEast = true; onEast = true;
} }
if (direction == 2) { if (direction == 2) {
onSouth = true; onSouth = true;
} }
if (direction == 3) { if (direction == 3) {
onWest = true; onWest = true;
} }
break; break;
case 5: case 5:
if (direction == 3) { if (direction == 3) {
onNorth = true; onNorth = true;
} }
if (direction == 4) { if (direction == 4) {
onEast = true; onEast = true;
} }
if (direction == 5) { if (direction == 5) {
onSouth = true; onSouth = true;
} }
if (direction == 2) { if (direction == 2) {
onWest = true; onWest = true;
} }
break; break;
} }
} else { } else {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
int data = block.getData(); int data = block.getData();
@ -122,15 +146,19 @@ public class GamePlaceableBlock {
if (direction == 2) { if (direction == 2) {
onNorth = true; onNorth = true;
} }
if (direction == 3) { if (direction == 3) {
onEast = true; onEast = true;
} }
if (direction == 4) { if (direction == 4) {
onSouth = true; onSouth = true;
} }
if (direction == 5) { if (direction == 5) {
onWest = true; onWest = true;
} }
break; break;
case 4: case 4:
case 3: case 3:
@ -139,16 +167,21 @@ public class GamePlaceableBlock {
if (direction == 5) { if (direction == 5) {
onNorth = true; onNorth = true;
} }
if (direction == 2) { if (direction == 2) {
onEast = true; onEast = true;
} }
if (direction == 3) { if (direction == 3) {
onSouth = true; onSouth = true;
} }
if (direction == 4) { if (direction == 4) {
onWest = true; onWest = true;
} }
break; break;
case 8: case 8:
case 7: case 7:
case 9: case 9:
@ -156,15 +189,19 @@ public class GamePlaceableBlock {
if (direction == 4) { if (direction == 4) {
onNorth = true; onNorth = true;
} }
if (direction == 5) { if (direction == 5) {
onEast = true; onEast = true;
} }
if (direction == 2) { if (direction == 2) {
onSouth = true; onSouth = true;
} }
if (direction == 3) { if (direction == 3) {
onWest = true; onWest = true;
} }
break; break;
case 12: case 12:
case 11: case 11:
@ -173,20 +210,24 @@ public class GamePlaceableBlock {
if (direction == 3) { if (direction == 3) {
onNorth = true; onNorth = true;
} }
if (direction == 4) { if (direction == 4) {
onEast = true; onEast = true;
} }
if (direction == 5) { if (direction == 5) {
onSouth = true; onSouth = true;
} }
if (direction == 2) { if (direction == 2) {
onWest = true; onWest = true;
} }
break; break;
} }
} }
} }
}
} else { } else {
onTop = true; onTop = true;
onBottom = true; onBottom = true;
@ -198,31 +239,42 @@ public class GamePlaceableBlock {
} }
// Canbuild // Canbuild
public static boolean canBuildHere(Block block, BlockFace blockFace, Material mat, GameWorld gWorld) { public static boolean canBuildHere(Block block, BlockFace blockFace, Material mat, GameWorld gameWorld) {
for (GamePlaceableBlock gPBlock : gWorld.placeableBlocks) { for (GamePlaceableBlock gPBlock : gameWorld.getPlaceableBlocks()) {
if (gPBlock.block.getFace(block) == BlockFace.SELF) { if (gPBlock.block.getFace(block) != BlockFace.SELF) {
if (gPBlock.mats.contains(mat) || gPBlock.mats.isEmpty()) { continue;
}
if ( !(gPBlock.mats.contains(mat) || gPBlock.mats.isEmpty())) {
continue;
}
if (blockFace == BlockFace.NORTH && gPBlock.onNorth) { if (blockFace == BlockFace.NORTH && gPBlock.onNorth) {
return true; return true;
} }
if (blockFace == BlockFace.SOUTH && gPBlock.onSouth) { if (blockFace == BlockFace.SOUTH && gPBlock.onSouth) {
return true; return true;
} }
if (blockFace == BlockFace.EAST && gPBlock.onEast) { if (blockFace == BlockFace.EAST && gPBlock.onEast) {
return true; return true;
} }
if (blockFace == BlockFace.WEST && gPBlock.onWest) { if (blockFace == BlockFace.WEST && gPBlock.onWest) {
return true; return true;
} }
if (blockFace == BlockFace.UP && gPBlock.onTop) { if (blockFace == BlockFace.UP && gPBlock.onTop) {
return true; return true;
} }
if (blockFace == BlockFace.DOWN && gPBlock.onBottom) { if (blockFace == BlockFace.DOWN && gPBlock.onBottom) {
return true; return true;
} }
} }
}
}
return false; return false;
} }
} }

View File

@ -39,22 +39,22 @@ public class GameWorld {
static DungeonsXL plugin = DungeonsXL.getPlugin(); static DungeonsXL plugin = DungeonsXL.getPlugin();
// Variables placeable // Variables placeable
public boolean isTutorial; private boolean isTutorial;
public CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks = new CopyOnWriteArrayList<GamePlaceableBlock>(); private CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks = new CopyOnWriteArrayList<GamePlaceableBlock>();
public World world; private World world;
public String dungeonname; private String mapName;
public Location locLobby; private Location locLobby;
public Location locStart; private Location locStart;
public boolean isPlaying = false; private boolean isPlaying = false;
public int id; private int id;
public CopyOnWriteArrayList<Material> secureObjects = new CopyOnWriteArrayList<Material>(); private CopyOnWriteArrayList<Material> secureObjects = new CopyOnWriteArrayList<Material>();
public CopyOnWriteArrayList<Chunk> loadedChunks = new CopyOnWriteArrayList<Chunk>(); private CopyOnWriteArrayList<Chunk> loadedChunks = new CopyOnWriteArrayList<Chunk>();
public CopyOnWriteArrayList<Sign> signClass = new CopyOnWriteArrayList<Sign>(); private CopyOnWriteArrayList<Sign> signClass = new CopyOnWriteArrayList<Sign>();
public CopyOnWriteArrayList<DMob> dMobs = new CopyOnWriteArrayList<DMob>(); private CopyOnWriteArrayList<DMob> dMobs = new CopyOnWriteArrayList<DMob>();
public CopyOnWriteArrayList<GameChest> gameChests = new CopyOnWriteArrayList<GameChest>(); private CopyOnWriteArrayList<GameChest> gameChests = new CopyOnWriteArrayList<GameChest>();
public CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<DSign>(); private CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<DSign>();
private WorldConfig worldConfig; private WorldConfig worldConfig;
public GameWorld() { public GameWorld() {
@ -66,8 +66,8 @@ public class GameWorld {
while (id == -1) { while (id == -1) {
i++; i++;
boolean exist = false; boolean exist = false;
for (GameWorld gWorld : plugin.getGameWorlds()) { for (GameWorld gameWorld : plugin.getGameWorlds()) {
if (gWorld.id == i) { if (gameWorld.id == i) {
exist = true; exist = true;
break; break;
} }
@ -90,7 +90,7 @@ public class GameWorld {
for (DSign dSign : dSigns) { for (DSign dSign : dSigns) {
if (dSign != null) { if (dSign != null) {
if ( !dSign.isOnDungeonInit()) { if ( !dSign.getType().isOnDungeonInit()) {
dSign.onInit(); dSign.onInit();
} }
} }
@ -111,10 +111,220 @@ public class GameWorld {
public void msg(String msg) { public void msg(String msg) {
for (DPlayer dplayer : DPlayer.get(world)) { for (DPlayer dplayer : DPlayer.get(world)) {
MessageUtil.sendMessage(dplayer.player, msg); MessageUtil.sendMessage(dplayer.getPlayer(), msg);
} }
} }
/**
* @return the isTutorial
*/
public boolean isTutorial() {
return isTutorial;
}
/**
* @param isTutorial
* the isTutorial to set
*/
public void setTutorial(boolean isTutorial) {
this.isTutorial = isTutorial;
}
/**
* @return the placeableBlocks
*/
public CopyOnWriteArrayList<GamePlaceableBlock> getPlaceableBlocks() {
return placeableBlocks;
}
/**
* @param placeableBlocks
* the placeableBlocks to set
*/
public void setPlaceableBlocks(CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks) {
this.placeableBlocks = placeableBlocks;
}
/**
* @return the world
*/
public World getWorld() {
return world;
}
/**
* @param world
* the world to set
*/
public void setWorld(World world) {
this.world = world;
}
/**
* @return the mapName
*/
public String getMapName() {
return mapName;
}
/**
* @param mapName
* the mapName to set
*/
public void setMapName(String mapName) {
this.mapName = mapName;
}
/**
* @return the locLobby
*/
public Location getLocLobby() {
return locLobby;
}
/**
* @param locLobby
* the locLobby to set
*/
public void setLocLobby(Location locLobby) {
this.locLobby = locLobby;
}
/**
* @return the locStart
*/
public Location getLocStart() {
return locStart;
}
/**
* @param locStart
* the locStart to set
*/
public void setLocStart(Location locStart) {
this.locStart = locStart;
}
/**
* @return the isPlaying
*/
public boolean isPlaying() {
return isPlaying;
}
/**
* @param isPlaying
* the isPlaying to set
*/
public void setPlaying(boolean isPlaying) {
this.isPlaying = isPlaying;
}
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id
* the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the secureObjects
*/
public CopyOnWriteArrayList<Material> getSecureObjects() {
return secureObjects;
}
/**
* @param secureObjects
* the secureObjects to set
*/
public void setSecureObjects(CopyOnWriteArrayList<Material> secureObjects) {
this.secureObjects = secureObjects;
}
/**
* @return the loadedChunks
*/
public CopyOnWriteArrayList<Chunk> getLoadedChunks() {
return loadedChunks;
}
/**
* @param loadedChunks
* the loadedChunks to set
*/
public void setLoadedChunks(CopyOnWriteArrayList<Chunk> loadedChunks) {
this.loadedChunks = loadedChunks;
}
/**
* @return the signClass
*/
public CopyOnWriteArrayList<Sign> getSignClass() {
return signClass;
}
/**
* @param signClass
* the signClass to set
*/
public void setSignClass(CopyOnWriteArrayList<Sign> signClass) {
this.signClass = signClass;
}
/**
* @return the dMobs
*/
public CopyOnWriteArrayList<DMob> getdMobs() {
return dMobs;
}
/**
* @param dMobs
* the dMobs to set
*/
public void setdMobs(CopyOnWriteArrayList<DMob> dMobs) {
this.dMobs = dMobs;
}
/**
* @return the gameChests
*/
public CopyOnWriteArrayList<GameChest> getGameChests() {
return gameChests;
}
/**
* @param gameChests
* the gameChests to set
*/
public void setGameChests(CopyOnWriteArrayList<GameChest> gameChests) {
this.gameChests = gameChests;
}
/**
* @return the dSigns
*/
public CopyOnWriteArrayList<DSign> getdSigns() {
return dSigns;
}
/**
* @param dSigns
* the dSigns to set
*/
public void setdSigns(CopyOnWriteArrayList<DSign> dSigns) {
this.dSigns = dSigns;
}
/** /**
* @return the worldConfig * @return the worldConfig
*/ */
@ -147,9 +357,9 @@ public class GameWorld {
// Statics // Statics
public static GameWorld get(World world) { public static GameWorld get(World world) {
for (GameWorld gWorld : plugin.getGameWorlds()) { for (GameWorld gameWorld : plugin.getGameWorlds()) {
if (gWorld.world.equals(world)) { if (gameWorld.world.equals(world)) {
return gWorld; return gameWorld;
} }
} }
@ -157,8 +367,8 @@ public class GameWorld {
} }
public static void deleteAll() { public static void deleteAll() {
for (GameWorld gWorld : plugin.getGameWorlds()) { for (GameWorld gameWorld : plugin.getGameWorlds()) {
gWorld.delete(); gameWorld.delete();
} }
} }
@ -197,7 +407,7 @@ public class GameWorld {
WorldConfig worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + dungeon, "config.yml")); WorldConfig worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + dungeon, "config.yml"));
if (plugin.getMainConfig().enableEconomy()) { if (plugin.getEconomyProvider() != null) {
if ( !(DungeonsXL.getPlugin().getEconomyProvider().getBalance(player) >= worldConfig.getFee())) { if ( !(DungeonsXL.getPlugin().getEconomyProvider().getBalance(player) >= worldConfig.getFee())) {
return false; return false;
} }
@ -289,46 +499,46 @@ public class GameWorld {
File file = new File(plugin.getDataFolder(), "/maps/" + name); File file = new File(plugin.getDataFolder(), "/maps/" + name);
if (file.exists()) { if (file.exists()) {
GameWorld gWorld = new GameWorld(); GameWorld gameWorld = new GameWorld();
gWorld.dungeonname = name; gameWorld.mapName = name;
// Unload empty eworlds // Unload empty eworlds
for (EditWorld eworld : plugin.getEditWorlds()) { for (EditWorld eworld : plugin.getEditWorlds()) {
if (eworld.world.getPlayers().isEmpty()) { if (eworld.getWorld().getPlayers().isEmpty()) {
eworld.delete(); eworld.delete();
} }
} }
// Config einlesen // Config einlesen
gWorld.worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + gWorld.dungeonname, "config.yml")); gameWorld.worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + gameWorld.mapName, "config.yml"));
// Secure Objects // Secure Objects
gWorld.secureObjects = gWorld.worldConfig.getSecureObjects(); gameWorld.secureObjects = gameWorld.worldConfig.getSecureObjects();
// World // World
FileUtil.copyDirectory(file, new File("DXL_Game_" + gWorld.id)); FileUtil.copyDirectory(file, new File("DXL_Game_" + gameWorld.id));
// Id File // Id File
File idFile = new File("DXL_Game_" + gWorld.id + "/.id_" + name); File idFile = new File("DXL_Game_" + gameWorld.id + "/.id_" + name);
try { try {
idFile.createNewFile(); idFile.createNewFile();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
gWorld.world = plugin.getServer().createWorld(WorldCreator.name("DXL_Game_" + gWorld.id)); gameWorld.world = plugin.getServer().createWorld(WorldCreator.name("DXL_Game_" + gameWorld.id));
ObjectInputStream os; ObjectInputStream os;
try { try {
os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder() + "/maps/" + gWorld.dungeonname + "/DXLData.data"))); os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder() + "/maps/" + gameWorld.mapName + "/DXLData.data")));
int length = os.readInt(); int length = os.readInt();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
int x = os.readInt(); int x = os.readInt();
int y = os.readInt(); int y = os.readInt();
int z = os.readInt(); int z = os.readInt();
Block block = gWorld.world.getBlockAt(x, y, z); Block block = gameWorld.world.getBlockAt(x, y, z);
gWorld.checkSign(block); gameWorld.checkSign(block);
} }
os.close(); os.close();
@ -338,16 +548,16 @@ public class GameWorld {
e.printStackTrace(); e.printStackTrace();
} }
return gWorld; return gameWorld;
} }
return null; return null;
} }
public static void update() { public static void update() {
for (GameWorld gWorld : plugin.getGameWorlds()) { for (GameWorld gameWorld : plugin.getGameWorlds()) {
// Update Spiders // Update Spiders
for (LivingEntity mob : gWorld.world.getLivingEntities()) { for (LivingEntity mob : gameWorld.world.getLivingEntities()) {
if (mob.getType() == EntityType.SPIDER || mob.getType() == EntityType.CAVE_SPIDER) { if (mob.getType() == EntityType.SPIDER || mob.getType() == EntityType.CAVE_SPIDER) {
Spider spider = (Spider) mob; Spider spider = (Spider) mob;
if (spider.getTarget() != null) { if (spider.getTarget() != null) {

View File

@ -35,7 +35,6 @@ public class DMessages {
} }
private void setDefaults() { private void setDefaults() {
/* Log */ /* Log */
defaults.put("Log_NewDungeon", "&6New Dungeon"); defaults.put("Log_NewDungeon", "&6New Dungeon");
defaults.put("Log_GenerateNewWorld", "&6Generate new world..."); defaults.put("Log_GenerateNewWorld", "&6Generate new world...");
@ -147,7 +146,10 @@ public class DMessages {
} }
public void save() { public void save() {
if (changed) { if ( !changed) {
return;
}
/* Copy old File */ /* Copy old File */
File source = new File(file.getPath()); File source = new File(file.getPath());
String filePath = file.getPath(); String filePath = file.getPath();
@ -168,26 +170,30 @@ public class DMessages {
try { try {
configFile.save(file); configFile.save(file);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
}
public String get(String key, String... args) { public String get(String key, String... args) {
String entry = entries.get(key); String entry = entries.get(key);
if (entry != null) { if (entry == null) {
return entry;
}
int i = 0; int i = 0;
for (String arg : args) { for (String arg : args) {
i++; i++;
if (arg != null) { if (arg != null) {
entry = entry.replace("&v" + i, arg); entry = entry.replace("&v" + i, arg);
} else { } else {
entry = entry.replace("&v" + i, "null"); entry = entry.replace("&v" + i, "null");
} }
} }
}
return entry; return entry;
} }

View File

@ -31,7 +31,11 @@ public class DPortal {
public void create() { public void create() {
player = null; player = null;
if (block1 != null && block2 != null) { if (block1 == null || block2 == null) {
plugin.getDPortals().remove(this);
return;
}
int x1 = block1.getX(), y1 = block1.getY(), z1 = block1.getZ(); int x1 = block1.getX(), y1 = block1.getY(), z1 = block1.getZ();
int x2 = block2.getX(), y2 = block2.getY(), z2 = block2.getZ(); int x2 = block2.getX(), y2 = block2.getY(), z2 = block2.getZ();
int xcount = 0, ycount = 0, zcount = 0; int xcount = 0, ycount = 0, zcount = 0;
@ -55,15 +59,16 @@ public class DPortal {
int xx = x1; int xx = x1;
do { do {
int yy = y1; int yy = y1;
do { do {
int zz = z1; int zz = z1;
do { do {
Material type = world.getBlockAt(xx, yy, zz).getType(); Material type = world.getBlockAt(xx, yy, zz).getType();
if (type == Material.AIR || type == Material.WATER || type == Material.STATIONARY_WATER || type == Material.LAVA || type == Material.STATIONARY_LAVA if (type == Material.AIR || type == Material.WATER || type == Material.STATIONARY_WATER || type == Material.LAVA || type == Material.STATIONARY_LAVA || type == Material.SAPLING
|| type == Material.SAPLING || type == Material.WEB || type == Material.LONG_GRASS || type == Material.DEAD_BUSH || type == Material.PISTON_EXTENSION || type == Material.WEB || type == Material.LONG_GRASS || type == Material.DEAD_BUSH || type == Material.PISTON_EXTENSION || type == Material.YELLOW_FLOWER
|| type == Material.YELLOW_FLOWER || type == Material.RED_ROSE || type == Material.BROWN_MUSHROOM || type == Material.RED_MUSHROOM || type == Material.TORCH || type == Material.RED_ROSE || type == Material.BROWN_MUSHROOM || type == Material.RED_MUSHROOM || type == Material.TORCH || type == Material.FIRE
|| type == Material.FIRE || type == Material.CROPS || type == Material.REDSTONE_WIRE || type == Material.REDSTONE_TORCH_OFF || type == Material.SNOW || type == Material.CROPS || type == Material.REDSTONE_WIRE || type == Material.REDSTONE_TORCH_OFF || type == Material.SNOW || type == Material.REDSTONE_TORCH_ON) {
|| type == Material.REDSTONE_TORCH_ON) {
world.getBlockAt(xx, yy, zz).setType(Material.PORTAL); world.getBlockAt(xx, yy, zz).setType(Material.PORTAL);
} }
@ -75,36 +80,29 @@ public class DPortal {
xx = xx + xcount; xx = xx + xcount;
} while (xx != x2 + xcount); } while (xx != x2 + xcount);
} else {
plugin.getDPortals().remove(this);
}
} }
public void teleport(Player player) { public void teleport(Player player) {
DGroup dgroup = DGroup.get(player); DGroup dgroup = DGroup.get(player);
if (dgroup != null) {
if (dgroup == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInGroup"));
}
if (dgroup.getGWorld() == null) { if (dgroup.getGWorld() == null) {
dgroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName())); dgroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName()));
} }
if (dgroup.getGWorld() != null) { if (dgroup.getGWorld() == null) {
if (dgroup.getGWorld().locLobby == null) {
new DPlayer(player, dgroup.getGWorld().world, dgroup.getGWorld().world.getSpawnLocation(), false);
} else {
new DPlayer(player, dgroup.getGWorld().world, dgroup.getGWorld().locLobby, false);
}
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_DungeonNotExist", DGroup.get(player).getMapName())); MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_DungeonNotExist", DGroup.get(player).getMapName()));
} }
} else { if (dgroup.getGWorld().getLocLobby() == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInGroup")); new DPlayer(player, dgroup.getGWorld().getWorld(), dgroup.getGWorld().getWorld().getSpawnLocation(), false);
}
} else {
new DPlayer(player, dgroup.getGWorld().getWorld(), dgroup.getGWorld().getLocLobby(), false);
}
} }
public void delete() { public void delete() {
@ -119,11 +117,13 @@ public class DPortal {
} else if (x1 < x2) { } else if (x1 < x2) {
xcount = 1; xcount = 1;
} }
if (y1 > y2) { if (y1 > y2) {
ycount = -1; ycount = -1;
} else if (y1 < y2) { } else if (y1 < y2) {
ycount = 1; ycount = 1;
} }
if (z1 > z2) { if (z1 > z2) {
zcount = -1; zcount = -1;
} else if (z1 < z2) { } else if (z1 < z2) {
@ -167,6 +167,7 @@ public class DPortal {
if (x3 < x2 || x3 > x1) { if (x3 < x2 || x3 > x1) {
continue; continue;
} }
} else { } else {
if (x3 > x2 || x3 < x1) { if (x3 > x2 || x3 < x1) {
continue; continue;
@ -177,6 +178,7 @@ public class DPortal {
if (y3 < y2 || y3 > y1) { if (y3 < y2 || y3 > y1) {
continue; continue;
} }
} else { } else {
if (y3 > y2 || y3 < y1) { if (y3 > y2 || y3 < y1) {
continue; continue;
@ -205,6 +207,7 @@ public class DPortal {
return portal; return portal;
} }
} }
return null; return null;
} }
@ -213,7 +216,11 @@ public class DPortal {
int id = 0; int id = 0;
for (DPortal dportal : plugin.getDPortals()) { for (DPortal dportal : plugin.getDPortals()) {
id++; id++;
if (dportal.isActive) {
if ( !dportal.isActive) {
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());
@ -225,16 +232,19 @@ public class DPortal {
configFile.set(preString + ".loc2.z", dportal.block2.getZ()); configFile.set(preString + ".loc2.z", dportal.block2.getZ());
} }
} }
}
public static void load(FileConfiguration configFile) { public static void load(FileConfiguration configFile) {
for (World world : plugin.getServer().getWorlds()) { for (World world : plugin.getServer().getWorlds()) {
if (configFile.contains("portal." + world.getName())) { if ( !configFile.contains("portal." + world.getName())) {
return;
}
int id = 0; int id = 0;
String preString; String preString;
do { do {
id++; id++;
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;
@ -242,10 +252,10 @@ public class DPortal {
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));
} }
} }
}
/** /**
* @return the world * @return the world

View File

@ -29,7 +29,7 @@ public class GroupSign {
public static final String strNewGrp = ChatColor.DARK_GREEN + "New Group"; public static final String strNewGrp = ChatColor.DARK_GREEN + "New Group";
// Variables // Variables
private DGroup[] dgroups; private DGroup[] dGroups;
private boolean multiFloor; private boolean multiFloor;
private String dungeonName; private String dungeonName;
private String mapName; private String mapName;
@ -42,7 +42,7 @@ public class GroupSign {
plugin.getGroupSigns().add(this); plugin.getGroupSigns().add(this);
this.startSign = startSign; this.startSign = startSign;
dgroups = new DGroup[maxGroups]; dGroups = new DGroup[maxGroups];
this.multiFloor = multiFloor; this.multiFloor = multiFloor;
if (multiFloor) { if (multiFloor) {
dungeonName = identifier; dungeonName = identifier;
@ -83,8 +83,12 @@ public class GroupSign {
public void update() { public void update() {
int i = 0; int i = 0;
for (DGroup dgroup : dgroups) { for (DGroup dGroup : dGroups) {
if (startSign.getRelative(i * directionX, 0, i * directionZ).getState() instanceof Sign) { if ( !(startSign.getRelative(i * directionX, 0, i * directionZ).getState() instanceof Sign)) {
i++;
continue;
}
Sign sign = (Sign) startSign.getRelative(i * directionX, 0, i * directionZ).getState(); Sign sign = (Sign) startSign.getRelative(i * directionX, 0, i * directionZ).getState();
// Reset Signs // Reset Signs
@ -105,32 +109,40 @@ 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, strIsPlaying);
} else if (dgroup.getPlayers().size() >= maxPlayersPerGroup) {
} else if (dGroup.getPlayers().size() >= maxPlayersPerGroup) {
sign.setLine(0, strFull); sign.setLine(0, strFull);
} else { } else {
sign.setLine(0, strJoinGrp); sign.setLine(0, strJoinGrp);
} }
int j = 1; int j = 1;
Sign rowSign = sign; Sign rowSign = sign;
for (Player player : dgroup.getPlayers()) {
for (Player player : dGroup.getPlayers()) {
if (j > 3) { if (j > 3) {
j = 0; j = 0;
rowSign = (Sign) sign.getBlock().getRelative(0, -1, 0).getState(); rowSign = (Sign) sign.getBlock().getRelative(0, -1, 0).getState();
} }
if (rowSign != null) { if (rowSign != null) {
rowSign.setLine(j, player.getName()); rowSign.setLine(j, player.getName());
} }
j++; j++;
rowSign.update(); rowSign.update();
} }
} else { } else {
sign.setLine(0, strNewGrp); sign.setLine(0, strNewGrp);
} }
sign.update(); sign.update();
}
i++; i++;
} }
} }
@ -151,19 +163,25 @@ public class GroupSign {
switch (direction) { switch (direction) {
case 2: case 2:
zz = z; zz = z;
for (yy = y; yy > y - verticalSigns; yy--) { for (yy = y; yy > y - verticalSigns; yy--) {
for (xx = x; xx > x - maxGroups; xx--) { for (xx = x; xx > x - maxGroups; xx--) {
Block block = world.getBlockAt(xx, yy, zz); Block block = world.getBlockAt(xx, yy, zz);
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) { if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
return null; return null;
} }
if (block.getRelative(0, 0, 1).getType() == Material.AIR) { if (block.getRelative(0, 0, 1).getType() == Material.AIR) {
return null; return null;
} }
changeBlocks.add(block); changeBlocks.add(block);
} }
} }
break; break;
case 3: case 3:
zz = z; zz = z;
for (yy = y; yy > y - verticalSigns; yy--) { for (yy = y; yy > y - verticalSigns; yy--) {
@ -173,48 +191,61 @@ public class GroupSign {
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) { if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
return null; return null;
} }
if (block.getRelative(0, 0, -1).getType() == Material.AIR) { if (block.getRelative(0, 0, -1).getType() == Material.AIR) {
return null; return null;
} }
changeBlocks.add(block); changeBlocks.add(block);
} }
} }
break; break;
case 4: case 4:
xx = x; xx = x;
for (yy = y; yy > y - verticalSigns; yy--) { for (yy = y; yy > y - verticalSigns; yy--) {
for (zz = z; zz < z + maxGroups; zz++) { for (zz = z; zz < z + maxGroups; zz++) {
Block block = world.getBlockAt(xx, yy, zz); Block block = world.getBlockAt(xx, yy, zz);
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) { if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
return null; return null;
} }
if (block.getRelative(1, 0, 0).getType() == Material.AIR) { if (block.getRelative(1, 0, 0).getType() == Material.AIR) {
return null; return null;
} }
changeBlocks.add(block); changeBlocks.add(block);
} }
} }
break; break;
case 5: case 5:
xx = x; xx = x;
for (yy = y; yy > y - verticalSigns; yy--) { for (yy = y; yy > y - verticalSigns; yy--) {
for (zz = z; zz > z - maxGroups; zz--) { for (zz = z; zz > z - maxGroups; zz--) {
Block block = world.getBlockAt(xx, yy, zz); Block block = world.getBlockAt(xx, yy, zz);
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) { if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
return null; return null;
} }
if (block.getRelative( -1, 0, 0).getType() == Material.AIR) { if (block.getRelative( -1, 0, 0).getType() == Material.AIR) {
return null; return null;
} }
changeBlocks.add(block); changeBlocks.add(block);
} }
} }
break; break;
} }
for (Block block : changeBlocks) { for (Block block : changeBlocks) {
block.setTypeIdAndData(68, startSign.getData(), true); block.setTypeIdAndData(68, startSign.getData(), true);
} }
GroupSign sign = new GroupSign(startSign, mapName, maxGroups, maxPlayersPerGroup, multiFloor); GroupSign sign = new GroupSign(startSign, mapName, maxGroups, maxPlayersPerGroup, multiFloor);
return sign; return sign;
@ -222,116 +253,101 @@ public class GroupSign {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static boolean isRelativeSign(Block block, int x, int z) { public static boolean isRelativeSign(Block block, int x, int z) {
GroupSign dgsign = getSign(block.getRelative(x, 0, z)); GroupSign groupSign = getSign(block.getRelative(x, 0, z));
if (dgsign != null) { if (groupSign == null) {
if (x == -1 && dgsign.startSign.getData() == 4) { return false;
}
if (x == -1 && groupSign.startSign.getData() == 4) {
return true; return true;
} }
if (x == 1 && dgsign.startSign.getData() == 5) {
if (x == 1 && groupSign.startSign.getData() == 5) {
return true; return true;
} }
if (z == -1 && dgsign.startSign.getData() == 2) {
if (z == -1 && groupSign.startSign.getData() == 2) {
return true; return true;
} }
if (z == 1 && dgsign.startSign.getData() == 3) {
if (z == 1 && groupSign.startSign.getData() == 3) {
return true; return true;
} }
}
return false; return false;
} }
public static GroupSign getSign(Block block) { public static GroupSign getSign(Block block) {
if (block.getType() == Material.WALL_SIGN) { if (block.getType() != Material.WALL_SIGN) {
return null;
}
int x = block.getX(), y = block.getY(), z = block.getZ(); int x = block.getX(), y = block.getY(), z = block.getZ();
for (GroupSign dgsign : plugin.getGroupSigns()) { for (GroupSign groupSign : plugin.getGroupSigns()) {
int sx1 = dgsign.startSign.getX(), sy1 = dgsign.startSign.getY(), sz1 = dgsign.startSign.getZ(); int sx1 = groupSign.startSign.getX(), sy1 = groupSign.startSign.getY(), sz1 = groupSign.startSign.getZ();
int sx2 = sx1 + (dgsign.dgroups.length - 1) * dgsign.directionX; int sx2 = sx1 + (groupSign.dGroups.length - 1) * groupSign.directionX;
int sy2 = sy1 - dgsign.verticalSigns + 1; int sy2 = sy1 - groupSign.verticalSigns + 1;
int sz2 = sz1 + (dgsign.dgroups.length - 1) * dgsign.directionZ; int sz2 = sz1 + (groupSign.dGroups.length - 1) * groupSign.directionZ;
if (sx1 > sx2) { if (sx1 > sx2) {
if (x < sx2 || x > sx1) { if (x < sx2 || x > sx1) {
continue; continue;
} }
} else if (sx1 < sx2) { } else if (sx1 < sx2) {
if (x > sx2 || x < sx1) { if (x > sx2 || x < sx1) {
continue; continue;
} }
} else { } else {
if (x != sx1) { if (x != sx1) {
continue; continue;
} }
} }
if (sy1 > sy2) { if (sy1 > sy2) {
if (y < sy2 || y > sy1) { if (y < sy2 || y > sy1) {
continue; continue;
} }
} else { } else {
if (y != sy1) { if (y != sy1) {
continue; continue;
} }
} }
if (sz1 > sz2) { if (sz1 > sz2) {
if (z < sz2 || z > sz1) { if (z < sz2 || z > sz1) {
continue; continue;
} }
} else if (sz1 < sz2) { } else if (sz1 < sz2) {
if (z > sz2 || z < sz1) { if (z > sz2 || z < sz1) {
continue; continue;
} }
} else { } else {
if (z != sz1) { if (z != sz1) {
continue; continue;
} }
} }
return dgsign; return groupSign;
}
} }
return null; return null;
} }
public static boolean playerInteract(Block block, Player player) { public static boolean playerInteract(Block block, Player player) {
int x = block.getX(), y = block.getY(), z = block.getZ(); int x = block.getX(), y = block.getY(), z = block.getZ();
GroupSign dgsign = getSign(block); GroupSign groupSign = getSign(block);
if (dgsign != null) {
if (GameWorld.canPlayDungeon(dgsign.mapName, player)) {
if (GameWorld.checkRequirements(dgsign.mapName, player)) {
int sx1 = dgsign.startSign.getX(), sy1 = dgsign.startSign.getY(), sz1 = dgsign.startSign.getZ();
Block topBlock = block.getRelative(0, sy1 - y, 0); if (groupSign == null) {
return false;
int column;
if (dgsign.directionX != 0) {
column = Math.abs(x - sx1);
} else {
column = Math.abs(z - sz1);
} }
if (topBlock.getState() instanceof Sign) { if ( !GameWorld.canPlayDungeon(groupSign.mapName, player)) {
Sign topSign = (Sign) topBlock.getState(); File file = new File(DungeonsXL.getPlugin().getDataFolder() + "/maps/" + groupSign.mapName, "config.yml");
if (topSign.getLine(0).equals(strNewGrp)) {
if (DGroup.get(player) == null) {
dgsign.dgroups[column] = new DGroup(player, dgsign.mapName, dgsign.multiFloor);
dgsign.update();
}
} else if (topSign.getLine(0).equals(strJoinGrp)) {
if (DGroup.get(player) == null) {
dgsign.dgroups[column].addPlayer(player);
dgsign.update();
}
}
}
} else {
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_Requirements"));
}
} else {
File file = new File(DungeonsXL.getPlugin().getDataFolder() + "/maps/" + dgsign.mapName, "config.yml");
if (file != null) { if (file != null) {
WorldConfig confReader = new WorldConfig(file); WorldConfig confReader = new WorldConfig(file);
if (confReader != null) { if (confReader != null) {
@ -339,25 +355,60 @@ public class GroupSign {
} }
} }
} }
if ( !GameWorld.checkRequirements(groupSign.mapName, player)) {
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_Requirements"));
}
int sx1 = groupSign.startSign.getX(), sy1 = groupSign.startSign.getY(), sz1 = groupSign.startSign.getZ();
Block topBlock = block.getRelative(0, sy1 - y, 0);
int column;
if (groupSign.directionX != 0) {
column = Math.abs(x - sx1);
} else {
column = Math.abs(z - sz1);
}
if ( !(topBlock.getState() instanceof Sign)) {
return true; return true;
} }
return false; Sign topSign = (Sign) topBlock.getState();
if (topSign.getLine(0).equals(strNewGrp)) {
if (DGroup.get(player) == null) {
groupSign.dGroups[column] = new DGroup(player, groupSign.mapName, groupSign.multiFloor);
groupSign.update();
} }
public static void updatePerGroup(DGroup dgroupsearch) { } else if (topSign.getLine(0).equals(strJoinGrp)) {
if (DGroup.get(player) == null) {
groupSign.dGroups[column].addPlayer(player);
groupSign.update();
}
}
for (GroupSign dgsign : plugin.getGroupSigns()) { return true;
}
public static void updatePerGroup(DGroup dGroupsearch) {
for (GroupSign groupSign : plugin.getGroupSigns()) {
int i = 0; int i = 0;
for (DGroup dgroup : dgsign.dgroups) { for (DGroup dGroup : groupSign.dGroups) {
if (dgroup != null) { if (dGroup == null) {
if (dgroup == dgroupsearch) { continue;
if (dgroupsearch.isEmpty()) {
dgsign.dgroups[i] = null;
} }
dgsign.update();
if (dGroup == dGroupsearch) {
if (dGroupsearch.isEmpty()) {
groupSign.dGroups[i] = null;
} }
groupSign.update();
} }
i++; i++;
} }
} }
@ -365,16 +416,20 @@ public class GroupSign {
public static int[] getDirection(byte data) { public static int[] getDirection(byte data) {
int[] direction = new int[2]; int[] direction = new int[2];
switch (data) { switch (data) {
case 2: case 2:
direction[0] = -1; direction[0] = -1;
break; break;
case 3: case 3:
direction[0] = 1; direction[0] = 1;
break; break;
case 4: case 4:
direction[1] = 1; direction[1] = 1;
break; break;
case 5: case 5:
direction[1] = -1; direction[1] = -1;
break; break;
@ -386,30 +441,35 @@ public class GroupSign {
public static void save(FileConfiguration configFile) { public static void save(FileConfiguration configFile) {
int id = 0; int id = 0;
for (GroupSign dgsign : plugin.getGroupSigns()) { for (GroupSign groupSign : plugin.getGroupSigns()) {
id++; id++;
String preString = "groupsign." + dgsign.startSign.getWorld().getName() + "." + id; String preString = "groupsign." + groupSign.startSign.getWorld().getName() + "." + id;
// Location // Location
configFile.set(preString + ".x", dgsign.startSign.getX()); configFile.set(preString + ".x", groupSign.startSign.getX());
configFile.set(preString + ".y", dgsign.startSign.getY()); configFile.set(preString + ".y", groupSign.startSign.getY());
configFile.set(preString + ".z", dgsign.startSign.getZ()); configFile.set(preString + ".z", groupSign.startSign.getZ());
// Etc. // Etc.
if (dgsign.multiFloor) { if (groupSign.multiFloor) {
configFile.set(preString + ".dungeon", dgsign.dungeonName); configFile.set(preString + ".dungeon", groupSign.dungeonName);
} else { } else {
configFile.set(preString + ".dungeon", dgsign.mapName); configFile.set(preString + ".dungeon", groupSign.mapName);
} }
configFile.set(preString + ".maxGroups", dgsign.dgroups.length);
configFile.set(preString + ".maxPlayersPerGroup", dgsign.maxPlayersPerGroup); configFile.set(preString + ".maxGroups", groupSign.dGroups.length);
configFile.set(preString + ".multiFloor", dgsign.multiFloor); configFile.set(preString + ".maxPlayersPerGroup", groupSign.maxPlayersPerGroup);
configFile.set(preString + ".multiFloor", groupSign.multiFloor);
} }
} }
public static void load(FileConfiguration configFile) { public static void load(FileConfiguration configFile) {
for (World world : DungeonsXL.getPlugin().getServer().getWorlds()) { for (World world : DungeonsXL.getPlugin().getServer().getWorlds()) {
if (configFile.contains("groupsign." + world.getName())) { if ( !configFile.contains("groupsign." + world.getName())) {
continue;
}
int id = 0; int id = 0;
String preString; String preString;
do { do {
@ -432,5 +492,3 @@ public class GroupSign {
} }
} }
}

View File

@ -38,11 +38,16 @@ public class LeaveSign {
LeaveSign lsign = getSign(block); LeaveSign lsign = getSign(block);
if (lsign != null) { if (lsign == null) {
return false;
}
DPlayer dplayer = DPlayer.get(player); DPlayer dplayer = DPlayer.get(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.get(player);
if (dgroup != null) { if (dgroup != null) {
@ -51,41 +56,51 @@ public class LeaveSign {
return true; return true;
} }
} }
}
return false; return false;
} }
@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 lsign = getSign(block.getRelative(x, 0, z));
if (lsign != null) { if (lsign == null) {
return false;
}
if (x == -1 && lsign.sign.getData().getData() == 4) { if (x == -1 && lsign.sign.getData().getData() == 4) {
return true; return true;
} }
if (x == 1 && lsign.sign.getData().getData() == 5) { if (x == 1 && lsign.sign.getData().getData() == 5) {
return true; return true;
} }
if (z == -1 && lsign.sign.getData().getData() == 2) { if (z == -1 && lsign.sign.getData().getData() == 2) {
return true; return true;
} }
if (z == 1 && lsign.sign.getData().getData() == 3) { if (z == 1 && lsign.sign.getData().getData() == 3) {
return true; return true;
} }
}
return false; return false;
} }
public static LeaveSign getSign(Block block) { public static LeaveSign getSign(Block block) {
if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) { if ( !(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST)) {
return null;
}
for (LeaveSign leavesign : plugin.getLeaveSigns()) { for (LeaveSign leavesign : plugin.getLeaveSigns()) {
if (block.getWorld() == leavesign.sign.getWorld()) { if (block.getWorld() != leavesign.sign.getWorld()) {
continue;
}
if (block.getLocation().distance(leavesign.sign.getBlock().getLocation()) < 1) { if (block.getLocation().distance(leavesign.sign.getBlock().getLocation()) < 1) {
return leavesign; return leavesign;
} }
} }
}
}
return null; return null;
} }
@ -103,9 +118,13 @@ public class LeaveSign {
public static void load(FileConfiguration configFile) { public static void load(FileConfiguration configFile) {
for (World world : DungeonsXL.getPlugin().getServer().getWorlds()) { for (World world : DungeonsXL.getPlugin().getServer().getWorlds()) {
if (configFile.contains("leavesign." + world.getName())) { if ( !configFile.contains("leavesign." + world.getName())) {
continue;
}
int id = 0; int id = 0;
String preString; String preString;
do { do {
id++; id++;
preString = "leavesign." + world.getName() + "." + id + "."; preString = "leavesign." + world.getName() + "." + id + ".";
@ -116,9 +135,9 @@ public class LeaveSign {
new LeaveSign(sign); new LeaveSign(sign);
} }
} }
} while (configFile.contains(preString)); } while (configFile.contains(preString));
} }
} }
}
} }

View File

@ -74,7 +74,7 @@ public class BlockListener implements Listener {
// Editworld Signs // Editworld Signs
EditWorld eworld = EditWorld.get(block.getWorld()); EditWorld eworld = EditWorld.get(block.getWorld());
if (eworld != null) { if (eworld != null) {
eworld.sign.remove(event.getBlock()); eworld.getSign().remove(event.getBlock());
} }
// Deny GameWorld Blocks // Deny GameWorld Blocks
@ -161,10 +161,10 @@ public class BlockListener implements Listener {
DSign dsign = DSign.create(sign, null); DSign dsign = DSign.create(sign, null);
if (dsign != null) { if (dsign != null) {
if (player.isOp() || player.hasPermission(dsign.getPermissions())) { if (player.isOp() || player.hasPermission(dsign.getType().getBuildPermission())) {
if (dsign.check()) { if (dsign.check()) {
eworld.checkSign(block); eworld.checkSign(block);
eworld.sign.add(block); eworld.getSign().add(block);
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_SignCreated")); MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_SignCreated"));
} else { } else {
@ -214,7 +214,7 @@ public class BlockListener implements Listener {
@Override @Override
public void run() { public void run() {
for (GameWorld gworld : DungeonsXL.getPlugin().getGameWorlds()) { for (GameWorld gworld : DungeonsXL.getPlugin().getGameWorlds()) {
if (block.getWorld() == gworld.world) { if (block.getWorld() == gworld.getWorld()) {
RedstoneTrigger.updateAll(gworld); RedstoneTrigger.updateAll(gworld);
} }
} }

View File

@ -66,7 +66,7 @@ public class EntityListener implements Listener {
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
GameWorld gworld = GameWorld.get(world); GameWorld gworld = GameWorld.get(world);
if (gworld != null) { if (gworld != null) {
if (gworld.isPlaying) { if (gworld.isPlaying()) {
if (entity.getType() != EntityType.PLAYER) { if (entity.getType() != EntityType.PLAYER) {
event.getDrops().clear(); event.getDrops().clear();
DMob.onDeath(event); DMob.onDeath(event);
@ -82,7 +82,7 @@ public class EntityListener implements Listener {
GameWorld gworld = GameWorld.get(world); GameWorld gworld = GameWorld.get(world);
if (gworld != null) { if (gworld != null) {
// Deny all Damage in Lobby // Deny all Damage in Lobby
if ( !gworld.isPlaying) { if ( !gworld.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.world)) { for (DPlayer dplayer : DPlayer.get(gworld.getWorld())) {
if (dplayer.wolf != null) { if (dplayer.getWolf() != null) {
if (entity == dplayer.wolf || entity2 == dplayer.wolf) { 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.world)) { for (DPlayer dplayer : DPlayer.get(gworld.getWorld())) {
if (dplayer.wolf != null) { if (dplayer.getWolf() != null) {
if (entity instanceof Player || entity2 instanceof Player) { if (entity instanceof Player || entity2 instanceof Player) {
if (entity == dplayer.wolf || entity2 == dplayer.wolf) { if (entity == dplayer.getWolf() || entity2 == dplayer.getWolf()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} else { } else {
if (entity == dplayer.wolf || entity2 == dplayer.wolf) { if (entity == dplayer.getWolf() || entity2 == dplayer.getWolf()) {
event.setCancelled(false); event.setCancelled(false);
return; return;
} }
@ -144,7 +144,7 @@ public class EntityListener implements Listener {
GameWorld gworld = GameWorld.get(world); GameWorld gworld = GameWorld.get(world);
if (gworld != null) { if (gworld != null) {
if ( !gworld.isPlaying) { if ( !gworld.isPlaying()) {
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -58,9 +58,9 @@ public class PlayerListener implements Listener {
WorldConfig dConfig = gameWorld.getConfig(); WorldConfig dConfig = gameWorld.getConfig();
if (dPlayer != null) { if (dPlayer != null) {
dPlayer.lives = dPlayer.lives - 1; dPlayer.setLives(dPlayer.getLives() - 1);
if (dPlayer.lives == 0 && dPlayer.isReady) { if (dPlayer.getLives() == 0 && dPlayer.isReady()) {
Bukkit.broadcastMessage(plugin.getDMessages().get("Player_DeathKick").replaceAll("v1", player.getName()).replaceAll("&", "\u00a7")); Bukkit.broadcastMessage(plugin.getDMessages().get("Player_DeathKick").replaceAll("v1", player.getName()).replaceAll("&", "\u00a7"));
// TODO: This Runnable is a workaround for a bug I couldn't find, yet... // TODO: This Runnable is a workaround for a bug I couldn't find, yet...
new BukkitRunnable() { new BukkitRunnable() {
@ -69,13 +69,13 @@ public class PlayerListener implements Listener {
} }
}.runTaskLater(plugin, 1L); }.runTaskLater(plugin, 1L);
} else if ( !(dPlayer.lives == -1)) { } else if ( !(dPlayer.getLives() == -1)) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_Death").replaceAll("v1", String.valueOf(dPlayer.lives))); MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_Death").replaceAll("v1", String.valueOf(dPlayer.getLives())));
} else if (dConfig != null) { } else if (dConfig != null) {
if (dConfig.getKeepInventoryOnDeath()) { if (dConfig.getKeepInventoryOnDeath()) {
dPlayer.respawnInventory = event.getEntity().getInventory().getContents(); dPlayer.setRespawnInventory(event.getEntity().getInventory().getContents());
dPlayer.respawnArmor = event.getEntity().getInventory().getArmorContents(); dPlayer.setRespawnArmor(event.getEntity().getInventory().getArmorContents());
// Delete all drops // Delete all drops
for (ItemStack istack : event.getDrops()) { for (ItemStack istack : event.getDrops()) {
istack.setType(Material.AIR); istack.setType(Material.AIR);
@ -224,11 +224,11 @@ public class PlayerListener implements Listener {
} }
// Class Signs // Class Signs
for (Sign classSign : gworld.signClass) { for (Sign classSign : gworld.getSignClass()) {
if (classSign != null) { if (classSign != null) {
if (classSign.getLocation().distance(clickedBlock.getLocation()) < 1) { if (classSign.getLocation().distance(clickedBlock.getLocation()) < 1) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK) { if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
dplayer.setClass(ChatColor.stripColor(classSign.getLine(1))); dplayer.setDClass(ChatColor.stripColor(classSign.getLine(1)));
} else { } else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_Leftklick")); MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_Leftklick"));
} }
@ -254,13 +254,13 @@ public class PlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if ( !DPlayer.get(player).isReady) { if ( !DPlayer.get(player).isReady()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
DPlayer dplayer = DPlayer.get(player); DPlayer dplayer = DPlayer.get(player);
GameWorld gworld = GameWorld.get(dplayer.world); GameWorld gworld = GameWorld.get(dplayer.getWorld());
if (dplayer != null) { if (dplayer != null) {
for (Material material : gworld.getConfig().getSecureObjects()) { for (Material material : gworld.getConfig().getSecureObjects()) {
if (material == event.getItemDrop().getItemStack().getType()) { if (material == event.getItemDrop().getItemStack().getType()) {
@ -279,45 +279,45 @@ public class PlayerListener implements Listener {
DPlayer dplayer = DPlayer.get(player); DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) { if (dplayer != null) {
if (dplayer.isEditing) { if (dplayer.isEditing()) {
EditWorld eworld = EditWorld.get(dplayer.world); EditWorld eworld = EditWorld.get(dplayer.getWorld());
if (eworld != null) { if (eworld != null) {
if (eworld.lobby == null) { if (eworld.getLobby() == null) {
event.setRespawnLocation(eworld.world.getSpawnLocation()); event.setRespawnLocation(eworld.getWorld().getSpawnLocation());
} else { } else {
event.setRespawnLocation(eworld.lobby); event.setRespawnLocation(eworld.getLobby());
} }
} }
} else { } else {
GameWorld gworld = GameWorld.get(dplayer.world); GameWorld gworld = GameWorld.get(dplayer.getWorld());
if (gworld != null) { if (gworld != null) {
DGroup dgroup = DGroup.get(dplayer.player); DGroup dgroup = DGroup.get(dplayer.getPlayer());
if (dplayer.checkpoint == null) { if (dplayer.getCheckpoint() == null) {
event.setRespawnLocation(dgroup.getGWorld().locStart); event.setRespawnLocation(dgroup.getGWorld().getLocStart());
// Da einige Plugins einen anderen Respawn setzen wird // Da einige Plugins einen anderen Respawn setzen wird
// ein Scheduler gestartet der den Player nach einer // ein Scheduler gestartet der den Player nach einer
// Sekunde teleportiert. // Sekunde teleportiert.
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RespawnRunnable(player, dgroup.getGWorld().locStart), 10); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RespawnRunnable(player, dgroup.getGWorld().getLocStart()), 10);
if (dplayer.wolf != null) { if (dplayer.getWolf() != null) {
dplayer.wolf.teleport(dgroup.getGWorld().locStart); dplayer.getWolf().teleport(dgroup.getGWorld().getLocStart());
} }
} else { } else {
event.setRespawnLocation(dplayer.checkpoint); event.setRespawnLocation(dplayer.getCheckpoint());
// Da einige Plugins einen anderen Respawn setzen wird // Da einige Plugins einen anderen Respawn setzen wird
// ein Scheduler gestartet der den Player nach einer // ein Scheduler gestartet der den Player nach einer
// Sekunde teleportiert. // Sekunde teleportiert.
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RespawnRunnable(player, dplayer.checkpoint), 10); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RespawnRunnable(player, dplayer.getCheckpoint()), 10);
if (dplayer.wolf != null) { if (dplayer.getWolf() != null) {
dplayer.wolf.teleport(dplayer.checkpoint); dplayer.getWolf().teleport(dplayer.getCheckpoint());
} }
} }
} }
@ -343,7 +343,7 @@ public class PlayerListener implements Listener {
DPlayer dplayer = DPlayer.get(player); DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) { if (dplayer != null) {
if (dplayer.world != event.getTo().getWorld()) { if (dplayer.getWorld() != event.getTo().getWorld()) {
if ( !player.isOp()) { if ( !player.isOp()) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -356,7 +356,7 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
DPlayer dplayer = DPlayer.get(player); DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) { if (dplayer != null) {
if (dplayer.isInDungeonChat) { if (dplayer.isInDungeonChat()) {
dplayer.msg(player.getDisplayName() + ": " + event.getMessage()); dplayer.msg(player.getDisplayName() + ": " + event.getMessage());
event.setCancelled(true); event.setCancelled(true);
} }
@ -378,14 +378,14 @@ public class PlayerListener implements Listener {
dPlayer.leave(); dPlayer.leave();
} else if (timeUntilKickOfflinePlayer > 0) { } else if (timeUntilKickOfflinePlayer > 0) {
dPlayer.msg(plugin.getDMessages().get("Player_Offline", dPlayer.player.getName(), "" + timeUntilKickOfflinePlayer)); dPlayer.msg(plugin.getDMessages().get("Player_Offline", dPlayer.getPlayer().getName(), "" + timeUntilKickOfflinePlayer));
dPlayer.offlineTime = System.currentTimeMillis() + timeUntilKickOfflinePlayer * 1000; dPlayer.setOfflineTime(System.currentTimeMillis() + timeUntilKickOfflinePlayer * 1000);
} else { } else {
dPlayer.msg(plugin.getDMessages().get("Player_OfflineNeverKick", dPlayer.player.getName())); dPlayer.msg(plugin.getDMessages().get("Player_OfflineNeverKick", dPlayer.getPlayer().getName()));
} }
} else if (dPlayer.isEditing) { } else if (dPlayer.isEditing()) {
dPlayer.leave(); dPlayer.leave();
} }
} }
@ -398,15 +398,15 @@ public class PlayerListener implements Listener {
// Check dplayers // Check dplayers
DPlayer dplayer = DPlayer.get(player.getName()); DPlayer dplayer = DPlayer.get(player.getName());
if (dplayer != null) { if (dplayer != null) {
DGroup dgroup = DGroup.get(dplayer.player); DGroup dgroup = DGroup.get(dplayer.getPlayer());
if (dgroup != null) { if (dgroup != null) {
dgroup.getPlayers().remove(dplayer.player); dgroup.getPlayers().remove(dplayer.getPlayer());
dgroup.getPlayers().add(player); dgroup.getPlayers().add(player);
} }
dplayer.player = player; dplayer.setPlayer(player);
// Check offlineTime // Check offlineTime
dplayer.offlineTime = 0; dplayer.setOfflineTime(0);
} }
// Tutorial Mode // Tutorial Mode
@ -419,14 +419,14 @@ public class PlayerListener implements Listener {
if (dgroup.getGWorld() == null) { if (dgroup.getGWorld() == null) {
dgroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName())); dgroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName()));
dgroup.getGWorld().isTutorial = true; dgroup.getGWorld().setTutorial(true);
} }
if (dgroup.getGWorld() != null) { if (dgroup.getGWorld() != null) {
if (dgroup.getGWorld().locLobby == null) { if (dgroup.getGWorld().getLocLobby() == null) {
} else { } else {
new DPlayer(player, dgroup.getGWorld().world, dgroup.getGWorld().locLobby, false); new DPlayer(player, dgroup.getGWorld().getWorld(), dgroup.getGWorld().getLocLobby(), false);
} }
} else { } else {
@ -448,7 +448,7 @@ public class PlayerListener implements Listener {
DPlayer dplayer = DPlayer.get(event.getPlayer()); DPlayer dplayer = DPlayer.get(event.getPlayer());
if (dplayer != null) { if (dplayer != null) {
if (dplayer.isEditing && event.getPlayer().hasPermission("dungeonsxl.cmdedit") || event.getPlayer().isOp()) { if (dplayer.isEditing() && event.getPlayer().hasPermission("dungeonsxl.cmdedit") || event.getPlayer().isOp()) {
return; return;
} }
@ -523,11 +523,11 @@ public class PlayerListener implements Listener {
if (dplayer != null) { if (dplayer != null) {
// Respawn Items // Respawn Items
if (dplayer.respawnInventory != null || dplayer.respawnArmor != null) { if (dplayer.getRespawnInventory() != null || dplayer.getRespawnArmor() != null) {
player.getInventory().setContents(dplayer.respawnInventory); player.getInventory().setContents(dplayer.getRespawnInventory());
player.getInventory().setArmorContents(dplayer.respawnArmor); player.getInventory().setArmorContents(dplayer.getRespawnArmor());
dplayer.respawnInventory = null; dplayer.setRespawnInventory(null);
dplayer.respawnArmor = null; dplayer.setRespawnArmor(null);
} }
} }
} }

View File

@ -13,7 +13,7 @@ public class WorldListener implements Listener {
public void onChunkUnload(ChunkUnloadEvent event) { public void onChunkUnload(ChunkUnloadEvent event) {
GameWorld gWorld = GameWorld.get(event.getWorld()); GameWorld gWorld = GameWorld.get(event.getWorld());
if (gWorld != null) { if (gWorld != null) {
if (gWorld.loadedChunks.contains(event.getChunk())) { if (gWorld.getLoadedChunks().contains(event.getChunk())) {
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -17,8 +17,8 @@ public class DMob {
private String trigger; private String trigger;
public DMob(LivingEntity entity, GameWorld gworld, DMobType type) { public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type) {
gworld.dMobs.add(this); gameWorld.getdMobs().add(this);
this.entity = entity; this.entity = entity;
this.type = type; this.type = type;
@ -31,8 +31,8 @@ public class DMob {
this.entity.getEquipment().setItemInHandDropChance(0); this.entity.getEquipment().setItemInHandDropChance(0);
} }
public DMob(LivingEntity entity, GameWorld gworld, DMobType type, String trigger) { public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type, String trigger) {
gworld.dMobs.add(this); gameWorld.getdMobs().add(this);
this.entity = entity; this.entity = entity;
this.type = type; this.type = type;
@ -49,44 +49,48 @@ public class DMob {
// Statics // Statics
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void onDeath(EntityDeathEvent event) { public static void onDeath(EntityDeathEvent event) {
if (event.getEntity() instanceof LivingEntity) { if ( !(event.getEntity() instanceof LivingEntity)) {
return;
}
LivingEntity victim = event.getEntity(); LivingEntity victim = event.getEntity();
GameWorld gworld = GameWorld.get(victim.getWorld()); GameWorld gameWorld = GameWorld.get(victim.getWorld());
String name = null; String name = null;
if (gworld != null) { if (gameWorld == null) {
for (DMob dmob : gworld.dMobs) { return;
if (dmob.entity == victim) { }
if (dmob.type != null) { for (DMob dMob : gameWorld.getdMobs()) {
for (ItemStack item : dmob.type.getDrops().keySet()) { if (dMob.entity == victim) {
if (dMob.type != null) {
for (ItemStack item : 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(item) > random) {
event.getDrops().add(item); event.getDrops().add(item);
} }
} }
name = dmob.type.getName(); name = dMob.type.getName();
} else if (dmob.type == null && dmob.trigger != null) {// <=MythicMobs mob } else if (dMob.type == null && dMob.trigger != null) {// <=MythicMobs mob
name = dmob.trigger; name = dMob.trigger;
} else { } else {
name = victim.getType().getName(); name = victim.getType().getName();
} }
MobTrigger trigger = MobTrigger.get(name, gworld); MobTrigger trigger = MobTrigger.get(name, gameWorld);
if (trigger != null) { if (trigger != null) {
trigger.onTrigger(); trigger.onTrigger();
} }
gworld.dMobs.remove(dmob); gameWorld.getdMobs().remove(dMob);
return; return;
} }
} }
} }
}
}
} }

View File

@ -48,9 +48,15 @@ public class DMobType {
} }
public void spawn(GameWorld gWorld, Location loc) { public void spawn(GameWorld gWorld, Location loc) {
if (type != null) { if (type == null) {
if (type.isAlive()) { return;
LivingEntity entity = (LivingEntity) gWorld.world.spawnEntity(loc, type); }
if ( !type.isAlive()) {
return;
}
LivingEntity entity = (LivingEntity) gWorld.getWorld().spawnEntity(loc, type);
/* Set the Items */ /* Set the Items */
entity.getEquipment().setItemInHand(ItemHand); entity.getEquipment().setItemInHand(ItemHand);
@ -94,21 +100,26 @@ public class DMobType {
/* Spawn Mob */ /* Spawn Mob */
new DMob(entity, gWorld, this); new DMob(entity, gWorld, this);
}
}
} }
// Load Config // Load Config
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static Set<DMobType> load(ConfigurationSection configFile) { public static Set<DMobType> load(ConfigurationSection configFile) {
Set<DMobType> set = new HashSet<DMobType>(); Set<DMobType> set = new HashSet<DMobType>();
if (configFile != null) {
if (configFile == null) {
return null;
}
// Read Mobs // Read Mobs
for (String mobName : configFile.getKeys(false)) { for (String mobName : configFile.getKeys(false)) {
EntityType type = EntityType.fromName(configFile.getString(mobName + ".Type")); EntityType type = EntityType.fromName(configFile.getString(mobName + ".Type"));
if (type != null) { if (type == null) {
DungeonsXL.getPlugin().getLogger().info(DungeonsXL.getPlugin().getDMessages().get("Log_Error_MobType", configFile.getString(mobName + ".Type")));
continue;
}
DMobType mobType = new DMobType(mobName, type); DMobType mobType = new DMobType(mobName, type);
set.add(mobType); set.add(mobType);
@ -213,12 +224,8 @@ public class DMobType {
mobType.getDrops().put(item, chance); mobType.getDrops().put(item, chance);
} }
} }
}
} else {
DungeonsXL.getPlugin().getLogger().info(DungeonsXL.getPlugin().getDMessages().get("Log_Error_MobType", configFile.getString(mobName + ".Type")));
}
}
}
return set; return set;
} }

View File

@ -22,7 +22,7 @@ public class DGroup {
private String dungeonName; private String dungeonName;
private String mapName; private String mapName;
private List<String> unplayedFloors = new ArrayList<String>(); private List<String> unplayedFloors = new ArrayList<String>();
private GameWorld gWorld; private GameWorld gameWorld;
private boolean playing; private boolean playing;
private int floorCount; private int floorCount;
@ -34,6 +34,7 @@ public class DGroup {
this.dungeonName = identifier; this.dungeonName = identifier;
this.mapName = plugin.getDungeons().getDungeon(dungeonName).getConfig().getStartFloor(); this.mapName = plugin.getDungeons().getDungeon(dungeonName).getConfig().getStartFloor();
this.unplayedFloors = plugin.getDungeons().getDungeon(dungeonName).getConfig().getFloors(); this.unplayedFloors = plugin.getDungeons().getDungeon(dungeonName).getConfig().getFloors();
} else { } else {
this.mapName = identifier; this.mapName = identifier;
} }
@ -84,18 +85,18 @@ public class DGroup {
} }
/** /**
* @return the gWorld * @return the gameWorld
*/ */
public GameWorld getGWorld() { public GameWorld getGWorld() {
return gWorld; return gameWorld;
} }
/** /**
* @param gWorld * @param gameWorld
* the gWorld to set * the gameWorld to set
*/ */
public void setGWorld(GameWorld gWorld) { public void setGWorld(GameWorld gameWorld) {
this.gWorld = gWorld; this.gameWorld = gameWorld;
} }
/** /**
@ -212,7 +213,7 @@ public class DGroup {
public void startGame() { public void startGame() {
playing = true; playing = true;
gWorld.startGame(); gameWorld.startGame();
floorCount++; floorCount++;
double fee; double fee;
@ -244,19 +245,19 @@ public class DGroup {
// Statics // Statics
public static DGroup get(Player player) { public static DGroup get(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;
} }
} }
return null; return null;
} }
public static DGroup get(GameWorld gWorld) { public static DGroup get(GameWorld gameWorld) {
for (DGroup dgroup : plugin.getDGroups()) { for (DGroup dGroup : plugin.getDGroups()) {
if (dgroup.getGWorld() == gWorld) { if (dGroup.getGWorld() == gameWorld) {
return dgroup; return dGroup;
} }
} }
@ -264,9 +265,9 @@ public class DGroup {
} }
public static void leaveGroup(Player player) { public static void leaveGroup(Player player) {
for (DGroup dgroup : plugin.getDGroups()) { for (DGroup dGroup : plugin.getDGroups()) {
if (dgroup.getPlayers().contains(player)) { if (dGroup.getPlayers().contains(player)) {
dgroup.getPlayers().remove(player); dGroup.getPlayers().remove(player);
} }
} }
} }

View File

@ -38,37 +38,37 @@ public class DPlayer {
static DungeonsXL plugin = DungeonsXL.getPlugin(); static DungeonsXL plugin = DungeonsXL.getPlugin();
// Variables // Variables
public Player player; private Player player;
public World world; private World world;
public boolean isinTestMode = false; private boolean isInTestMode = false;
public DSavePlayer savePlayer; private DSavePlayer savePlayer;
public boolean isEditing; private boolean isEditing;
public boolean isInDungeonChat = false; private boolean isInDungeonChat = false;
public boolean isReady = false; private boolean isReady = false;
public boolean isFinished = false; private boolean isFinished = false;
public DClass dclass; private DClass dClass;
public Location checkpoint; private Location checkpoint;
public Wolf wolf; private Wolf wolf;
public int wolfRespawnTime = 30; private int wolfRespawnTime = 30;
public long offlineTime; private long offlineTime;
public ItemStack[] respawnInventory; private ItemStack[] respawnInventory;
public ItemStack[] respawnArmor; private ItemStack[] respawnArmor;
public String[] linesCopy; private String[] linesCopy;
public Inventory treasureInv = DungeonsXL.getPlugin().getServer().createInventory(player, 45, plugin.getDMessages().get("Player_Treasures")); private Inventory treasureInv = DungeonsXL.getPlugin().getServer().createInventory(getPlayer(), 45, plugin.getDMessages().get("Player_Treasures"));
public double treasureMoney = 0; private double treasureMoney = 0;
public int initialLives = -1; private int initialLives = -1;
public int lives; private int lives;
public DPlayer(Player player, World world, Location teleport, boolean isEditing) { public DPlayer(Player player, World world, Location teleport, boolean isEditing) {
plugin.getDPlayers().add(this); plugin.getDPlayers().add(this);
this.player = player; this.setPlayer(player);
this.world = world; this.world = world;
double health = ((Damageable) player).getHealth(); double health = ((Damageable) player).getHealth();
@ -79,11 +79,11 @@ public class DPlayer {
this.isEditing = isEditing; this.isEditing = isEditing;
if (this.isEditing) { if (this.isEditing) {
this.player.setGameMode(GameMode.CREATIVE); this.getPlayer().setGameMode(GameMode.CREATIVE);
clearPlayerData(); clearPlayerData();
} else { } else {
this.player.setGameMode(GameMode.SURVIVAL); this.getPlayer().setGameMode(GameMode.SURVIVAL);
WorldConfig dConfig = GameWorld.get(world).getConfig(); WorldConfig dConfig = GameWorld.get(world).getConfig();
if ( !dConfig.getKeepInventoryOnEnter()) { if ( !dConfig.getKeepInventoryOnEnter()) {
clearPlayerData(); clearPlayerData();
@ -95,18 +95,18 @@ public class DPlayer {
lives = initialLives; lives = initialLives;
} }
MiscUtil.secureTeleport(this.player, teleport); MiscUtil.secureTeleport(this.getPlayer(), teleport);
} }
public void clearPlayerData() { public void clearPlayerData() {
player.getInventory().clear(); getPlayer().getInventory().clear();
player.getInventory().setArmorContents(null); getPlayer().getInventory().setArmorContents(null);
player.setTotalExperience(0); getPlayer().setTotalExperience(0);
player.setLevel(0); getPlayer().setLevel(0);
player.setHealth(20); getPlayer().setHealth(20);
player.setFoodLevel(20); getPlayer().setFoodLevel(20);
for (PotionEffect effect : player.getActivePotionEffects()) { for (PotionEffect effect : getPlayer().getActivePotionEffects()) {
player.removePotionEffect(effect.getType()); getPlayer().removePotionEffect(effect.getType());
} }
} }
@ -135,22 +135,22 @@ public class DPlayer {
} }
} else { } else {
GameWorld gWorld = GameWorld.get(world); GameWorld gameWorld = GameWorld.get(world);
DGroup dGroup = DGroup.get(player); DGroup dGroup = DGroup.get(getPlayer());
if (dGroup != null) { if (dGroup != null) {
dGroup.removePlayer(player); dGroup.removePlayer(getPlayer());
} }
// Belohnung // Belohnung
if ( !isinTestMode) {// Nur wenn man nicht am Testen ist if ( !isInTestMode) {// Nur wenn man nicht am Testen ist
if (isFinished) { if (isFinished) {
addTreasure(); addTreasure();
if (plugin.getEconomyProvider() != null) { if (plugin.getEconomyProvider() != null) {
plugin.getEconomyProvider().depositPlayer(player, treasureMoney); plugin.getEconomyProvider().depositPlayer(getPlayer(), treasureMoney);
} }
// Set Time // Set Time
File file = new File(plugin.getDataFolder() + "/maps/" + gWorld.dungeonname, "players.yml"); File file = new File(plugin.getDataFolder() + "/maps/" + gameWorld.getMapName(), "players.yml");
if ( !file.exists()) { if ( !file.exists()) {
try { try {
@ -162,7 +162,7 @@ public class DPlayer {
FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file); FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file);
playerConfig.set(player.getUniqueId().toString(), System.currentTimeMillis()); playerConfig.set(getPlayer().getUniqueId().toString(), System.currentTimeMillis());
try { try {
playerConfig.save(file); playerConfig.save(file);
@ -171,15 +171,15 @@ public class DPlayer {
} }
// Tutorial Permissions // Tutorial Permissions
if (gWorld.isTutorial) { if (gameWorld.isTutorial()) {
String endGroup = plugin.getMainConfig().getTutorialEndGroup(); String endGroup = plugin.getMainConfig().getTutorialEndGroup();
if (plugin.isGroupEnabled(endGroup)) { if (plugin.isGroupEnabled(endGroup)) {
plugin.getPermissionProvider().playerAddGroup(player, endGroup); plugin.getPermissionProvider().playerAddGroup(getPlayer(), endGroup);
} }
String startGroup = plugin.getMainConfig().getTutorialStartGroup(); String startGroup = plugin.getMainConfig().getTutorialStartGroup();
if (plugin.isGroupEnabled(startGroup)) { if (plugin.isGroupEnabled(startGroup)) {
plugin.getPermissionProvider().playerRemoveGroup(player, startGroup); plugin.getPermissionProvider().playerRemoveGroup(getPlayer(), startGroup);
} }
} }
} }
@ -194,9 +194,9 @@ public class DPlayer {
groupplayer = dGroup.getPlayers().get(i); groupplayer = dGroup.getPlayers().get(i);
if (groupplayer != null) { if (groupplayer != null) {
org.bukkit.Bukkit.broadcastMessage("14"); org.bukkit.Bukkit.broadcastMessage("14");
for (ItemStack istack : player.getInventory()) { for (ItemStack istack : getPlayer().getInventory()) {
if (istack != null) { if (istack != null) {
if (gWorld.secureObjects.contains(istack.getType())) { if (gameWorld.getSecureObjects().contains(istack.getType())) {
groupplayer.getInventory().addItem(istack); groupplayer.getInventory().addItem(istack);
} }
} }
@ -212,7 +212,7 @@ public class DPlayer {
public void ready() { public void ready() {
isReady = true; isReady = true;
DGroup dGroup = DGroup.get(player); DGroup dGroup = DGroup.get(getPlayer());
if ( !dGroup.isPlaying()) { if ( !dGroup.isPlaying()) {
if (dGroup != null) { if (dGroup != null) {
for (Player player : dGroup.getPlayers()) { for (Player player : dGroup.getPlayers()) {
@ -230,21 +230,21 @@ public class DPlayer {
} }
public void respawn() { public void respawn() {
DGroup dGroup = DGroup.get(player); DGroup dGroup = DGroup.get(getPlayer());
if (checkpoint == null) { if (checkpoint == null) {
MiscUtil.secureTeleport(player, dGroup.getGWorld().locStart); MiscUtil.secureTeleport(getPlayer(), dGroup.getGWorld().getLocStart());
} else { } else {
MiscUtil.secureTeleport(player, checkpoint); MiscUtil.secureTeleport(getPlayer(), checkpoint);
} }
if (wolf != null) { if (wolf != null) {
wolf.teleport(player); wolf.teleport(getPlayer());
} }
// Respawn Items // Respawn Items
if (GameWorld.get(world).getConfig().getKeepInventoryOnDeath()) { if (GameWorld.get(world).getConfig().getKeepInventoryOnDeath()) {
if (respawnInventory != null || respawnArmor != null) { if (respawnInventory != null || respawnArmor != null) {
player.getInventory().setContents(respawnInventory); getPlayer().getInventory().setContents(respawnInventory);
player.getInventory().setArmorContents(respawnArmor); getPlayer().getInventory().setArmorContents(respawnArmor);
respawnInventory = null; respawnInventory = null;
respawnArmor = null; respawnArmor = null;
} }
@ -253,10 +253,10 @@ public class DPlayer {
} }
public void finishFloor(String specifiedFloor) { public void finishFloor(String specifiedFloor) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_FinishedDungeon")); MessageUtil.sendMessage(getPlayer(), plugin.getDMessages().get("Player_FinishedDungeon"));
isFinished = true; isFinished = true;
DGroup dGroup = DGroup.get(player); DGroup dGroup = DGroup.get(getPlayer());
if (dGroup == null) { if (dGroup == null) {
return; return;
} }
@ -268,7 +268,7 @@ public class DPlayer {
for (Player player : dGroup.getPlayers()) { for (Player player : dGroup.getPlayers()) {
DPlayer dplayer = get(player); DPlayer dplayer = get(player);
if ( !dplayer.isFinished) { if ( !dplayer.isFinished) {
MessageUtil.sendMessage(this.player, plugin.getDMessages().get("Player_WaitForOtherPlayers")); MessageUtil.sendMessage(this.getPlayer(), plugin.getDMessages().get("Player_WaitForOtherPlayers"));
return; return;
} }
} }
@ -308,16 +308,16 @@ public class DPlayer {
dGroup.setGWorld(GameWorld.load(newFloor)); dGroup.setGWorld(GameWorld.load(newFloor));
for (Player player : dGroup.getPlayers()) { for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = get(player); DPlayer dPlayer = get(player);
dPlayer.checkpoint = dGroup.getGWorld().locStart; dPlayer.checkpoint = dGroup.getGWorld().getLocStart();
} }
dGroup.startGame(); dGroup.startGame();
} }
public void finish() { public void finish() {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_FinishedDungeon")); MessageUtil.sendMessage(getPlayer(), plugin.getDMessages().get("Player_FinishedDungeon"));
isFinished = true; isFinished = true;
DGroup dGroup = DGroup.get(player); DGroup dGroup = DGroup.get(getPlayer());
if (dGroup == null) { if (dGroup == null) {
return; return;
} }
@ -329,7 +329,7 @@ public class DPlayer {
for (Player player : dGroup.getPlayers()) { for (Player player : dGroup.getPlayers()) {
DPlayer dplayer = get(player); DPlayer dplayer = get(player);
if ( !dplayer.isFinished) { if ( !dplayer.isFinished) {
MessageUtil.sendMessage(this.player, plugin.getDMessages().get("Player_WaitForOtherPlayers")); MessageUtil.sendMessage(this.getPlayer(), plugin.getDMessages().get("Player_WaitForOtherPlayers"));
return; return;
} }
} }
@ -345,15 +345,15 @@ public class DPlayer {
EditWorld eworld = EditWorld.get(world); EditWorld eworld = EditWorld.get(world);
eworld.msg(msg); eworld.msg(msg);
for (Player player : plugin.getChatSpyers()) { for (Player player : plugin.getChatSpyers()) {
if ( !eworld.world.getPlayers().contains(player)) { if ( !eworld.getWorld().getPlayers().contains(player)) {
MessageUtil.sendMessage(player, ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + msg); MessageUtil.sendMessage(player, ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + msg);
} }
} }
} else { } else {
GameWorld gWorld = GameWorld.get(world); GameWorld gameWorld = GameWorld.get(world);
gWorld.msg(msg); gameWorld.msg(msg);
for (Player player : plugin.getChatSpyers()) { for (Player player : plugin.getChatSpyers()) {
if ( !gWorld.world.getPlayers().contains(player)) { if ( !gameWorld.getWorld().getPlayers().contains(player)) {
MessageUtil.sendMessage(player, ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + msg); MessageUtil.sendMessage(player, ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + msg);
} }
} }
@ -367,7 +367,7 @@ public class DPlayer {
String[] lines = sign.getLines(); String[] lines = sign.getLines();
if (lines[0].equals("") && lines[1].equals("") && lines[2].equals("") && lines[3].equals("")) { if (lines[0].equals("") && lines[1].equals("") && lines[2].equals("") && lines[3].equals("")) {
if (linesCopy != null) { if (linesCopy != null) {
SignChangeEvent event = new SignChangeEvent(block, player, linesCopy); SignChangeEvent event = new SignChangeEvent(block, getPlayer(), linesCopy);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
if ( !event.isCancelled()) { if ( !event.isCancelled()) {
sign.setLine(0, event.getLine(0)); sign.setLine(0, event.getLine(0));
@ -379,27 +379,162 @@ public class DPlayer {
} }
} else { } else {
linesCopy = lines; linesCopy = lines;
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_SignCopied")); MessageUtil.sendMessage(getPlayer(), plugin.getDMessages().get("Player_SignCopied"));
} }
} else { } else {
String info = "" + block.getType(); String info = "" + block.getType();
if (block.getData() != 0) { if (block.getData() != 0) {
info = info + "," + block.getData(); info = info + "," + block.getData();
} }
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_BlockInfo", info)); MessageUtil.sendMessage(getPlayer(), plugin.getDMessages().get("Player_BlockInfo", info));
} }
} }
public void setClass(String classname) { public void addTreasure() {
GameWorld gWorld = GameWorld.get(player.getWorld()); new DLootInventory(getPlayer(), treasureInv.getContents());
if (gWorld == null) { }
/**
* @return the player
*/
public Player getPlayer() {
return player;
}
/**
* @param player
* the player to set
*/
public void setPlayer(Player player) {
this.player = player;
}
/**
* @return the world
*/
public World getWorld() {
return world;
}
/**
* @param world
* the world to set
*/
public void setWorld(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
*/
public DSavePlayer getSavePlayer() {
return savePlayer;
}
/**
* @param savePlayer
* the savePlayer to set
*/
public void setSavePlayer(DSavePlayer savePlayer) {
this.savePlayer = savePlayer;
}
/**
* @return the isEditing
*/
public boolean isEditing() {
return isEditing;
}
/**
* @param isEditing
* the isEditing to set
*/
public void setEditing(boolean isEditing) {
this.isEditing = isEditing;
}
/**
* @return the isInDungeonChat
*/
public boolean isInDungeonChat() {
return isInDungeonChat;
}
/**
* @param isInDungeonChat
* the isInDungeonChat to set
*/
public void setInDungeonChat(boolean isInDungeonChat) {
this.isInDungeonChat = isInDungeonChat;
}
/**
* @return the isReady
*/
public boolean isReady() {
return isReady;
}
/**
* @param isReady
* the isReady to set
*/
public void setReady(boolean isReady) {
this.isReady = isReady;
}
/**
* @return the isFinished
*/
public boolean isFinished() {
return isFinished;
}
/**
* @param isFinished
* the isFinished to set
*/
public void setFinished(boolean isFinished) {
this.isFinished = isFinished;
}
/**
* @return the dClass
*/
public DClass getDClass() {
return dClass;
}
/**
* @param dClass
* the dClass to set
*/
public void setDClass(String className) {
GameWorld gameWorld = GameWorld.get(getPlayer().getWorld());
if (gameWorld == null) {
return; return;
} }
DClass dclass = gWorld.getConfig().getClass(classname); DClass dClass = gameWorld.getConfig().getClass(className);
if (dclass != null) { if (dClass != null) {
if (this.dclass != dclass) { if (this.dClass != dClass) {
this.dclass = dclass; this.dClass = dClass;
/* Set Dog */ /* Set Dog */
if (wolf != null) { if (wolf != null) {
@ -407,77 +542,235 @@ public class DPlayer {
wolf = null; wolf = null;
} }
if (dclass.hasDog()) { if (dClass.hasDog()) {
wolf = (Wolf) world.spawnEntity(player.getLocation(), EntityType.WOLF); wolf = (Wolf) world.spawnEntity(getPlayer().getLocation(), EntityType.WOLF);
wolf.setTamed(true); wolf.setTamed(true);
wolf.setOwner(player); wolf.setOwner(getPlayer());
double maxHealth = ((Damageable) wolf).getMaxHealth(); double maxHealth = ((Damageable) wolf).getMaxHealth();
wolf.setHealth(maxHealth); wolf.setHealth(maxHealth);
} }
/* Delete Inventory */ /* Delete Inventory */
player.getInventory().clear(); getPlayer().getInventory().clear();
player.getInventory().setArmorContents(null); getPlayer().getInventory().setArmorContents(null);
player.getInventory().setItemInHand(new ItemStack(Material.AIR)); getPlayer().getInventory().setItemInHand(new ItemStack(Material.AIR));
// Remove Potion Effects // Remove Potion Effects
for (PotionEffect effect : player.getActivePotionEffects()) { for (PotionEffect effect : getPlayer().getActivePotionEffects()) {
player.removePotionEffect(effect.getType()); getPlayer().removePotionEffect(effect.getType());
} }
// Reset lvl // Reset lvl
player.setTotalExperience(0); getPlayer().setTotalExperience(0);
player.setLevel(0); getPlayer().setLevel(0);
/* Set Inventory */ /* Set Inventory */
for (ItemStack istack : dclass.getItems()) { for (ItemStack istack : dClass.getItems()) {
// Leggings // Leggings
if (istack.getType() == Material.LEATHER_LEGGINGS || istack.getType() == Material.CHAINMAIL_LEGGINGS || istack.getType() == Material.IRON_LEGGINGS if (istack.getType() == Material.LEATHER_LEGGINGS || istack.getType() == Material.CHAINMAIL_LEGGINGS || istack.getType() == Material.IRON_LEGGINGS
|| istack.getType() == Material.DIAMOND_LEGGINGS || istack.getType() == Material.GOLD_LEGGINGS) { || istack.getType() == Material.DIAMOND_LEGGINGS || istack.getType() == Material.GOLD_LEGGINGS) {
player.getInventory().setLeggings(istack); getPlayer().getInventory().setLeggings(istack);
} }
// Helmet // Helmet
else if (istack.getType() == Material.LEATHER_HELMET || istack.getType() == Material.CHAINMAIL_HELMET || istack.getType() == Material.IRON_HELMET else if (istack.getType() == Material.LEATHER_HELMET || istack.getType() == Material.CHAINMAIL_HELMET || istack.getType() == Material.IRON_HELMET
|| istack.getType() == Material.DIAMOND_HELMET || istack.getType() == Material.GOLD_HELMET) { || istack.getType() == Material.DIAMOND_HELMET || istack.getType() == Material.GOLD_HELMET) {
player.getInventory().setHelmet(istack); getPlayer().getInventory().setHelmet(istack);
} }
// Chestplate // Chestplate
else if (istack.getType() == Material.LEATHER_CHESTPLATE || istack.getType() == Material.CHAINMAIL_CHESTPLATE || istack.getType() == Material.IRON_CHESTPLATE else if (istack.getType() == Material.LEATHER_CHESTPLATE || istack.getType() == Material.CHAINMAIL_CHESTPLATE || istack.getType() == Material.IRON_CHESTPLATE
|| istack.getType() == Material.DIAMOND_CHESTPLATE || istack.getType() == Material.GOLD_CHESTPLATE) { || istack.getType() == Material.DIAMOND_CHESTPLATE || istack.getType() == Material.GOLD_CHESTPLATE) {
player.getInventory().setChestplate(istack); getPlayer().getInventory().setChestplate(istack);
} }
// Boots // Boots
else if (istack.getType() == Material.LEATHER_BOOTS || istack.getType() == Material.CHAINMAIL_BOOTS || istack.getType() == Material.IRON_BOOTS else if (istack.getType() == Material.LEATHER_BOOTS || istack.getType() == Material.CHAINMAIL_BOOTS || istack.getType() == Material.IRON_BOOTS
|| istack.getType() == Material.DIAMOND_BOOTS || istack.getType() == Material.GOLD_BOOTS) { || istack.getType() == Material.DIAMOND_BOOTS || istack.getType() == Material.GOLD_BOOTS) {
player.getInventory().setBoots(istack); getPlayer().getInventory().setBoots(istack);
} }
else { else {
player.getInventory().addItem(istack); getPlayer().getInventory().addItem(istack);
} }
} }
} }
} }
} }
/**
* @return the checkpoint
*/
public Location getCheckpoint() {
return checkpoint;
}
/**
* @param checkpoint
* the checkpoint to set
*/
public void setCheckpoint(Location checkpoint) { public void setCheckpoint(Location checkpoint) {
this.checkpoint = checkpoint; this.checkpoint = checkpoint;
} }
public void addTreasure() { /**
new DLootInventory(player, treasureInv.getContents()); * @return the wolf
*/
public Wolf getWolf() {
return wolf;
}
/**
* @param wolf
* the wolf to set
*/
public void setWolf(Wolf wolf) {
this.wolf = wolf;
}
/**
* @return the wolfRespawnTime
*/
public int getWolfRespawnTime() {
return wolfRespawnTime;
}
/**
* @param wolfRespawnTime
* the wolfRespawnTime to set
*/
public void setWolfRespawnTime(int wolfRespawnTime) {
this.wolfRespawnTime = wolfRespawnTime;
}
/**
* @return the offlineTime
*/
public long getOfflineTime() {
return offlineTime;
}
/**
* @param offlineTime
* the offlineTime to set
*/
public void setOfflineTime(long offlineTime) {
this.offlineTime = offlineTime;
}
/**
* @return the respawnInventory
*/
public ItemStack[] getRespawnInventory() {
return respawnInventory;
}
/**
* @param respawnInventory
* the respawnInventory to set
*/
public void setRespawnInventory(ItemStack[] respawnInventory) {
this.respawnInventory = respawnInventory;
}
/**
* @return the respawnArmor
*/
public ItemStack[] getRespawnArmor() {
return respawnArmor;
}
/**
* @param respawnArmor
* the respawnArmor to set
*/
public void setRespawnArmor(ItemStack[] respawnArmor) {
this.respawnArmor = respawnArmor;
}
/**
* @return the linesCopy
*/
public String[] getLinesCopy() {
return linesCopy;
}
/**
* @param linesCopy
* the linesCopy to set
*/
public void setLinesCopy(String[] linesCopy) {
this.linesCopy = linesCopy;
}
/**
* @return the treasureInv
*/
public Inventory getTreasureInv() {
return treasureInv;
}
/**
* @param treasureInv
* the treasureInv to set
*/
public void setTreasureInv(Inventory treasureInv) {
this.treasureInv = treasureInv;
}
/**
* @return the treasureMoney
*/
public double getTreasureMoney() {
return treasureMoney;
}
/**
* @param treasureMoney
* the treasureMoney to set
*/
public void setTreasureMoney(double treasureMoney) {
this.treasureMoney = treasureMoney;
}
/**
* @return the initialLives
*/
public int getInitialLives() {
return initialLives;
}
/**
* @param initialLives
* the initialLives to set
*/
public void setInitialLives(int initialLives) {
this.initialLives = initialLives;
}
/**
* @return the lives
*/
public int getLives() {
return lives;
}
/**
* @param lives
* the lives to set
*/
public void setLives(int lives) {
this.lives = lives;
} }
// Static // Static
public static void remove(DPlayer player) { public static void remove(DPlayer player) {
plugin.getDPlayers().remove(player); plugin.getDPlayers().remove(player);
} }
public static DPlayer get(Player player) { public static DPlayer get(Player player) {
for (DPlayer dplayer : plugin.getDPlayers()) { for (DPlayer dplayer : plugin.getDPlayers()) {
if (dplayer.player.equals(player)) { if (dplayer.getPlayer().equals(player)) {
return dplayer; return dplayer;
} }
} }
@ -486,7 +779,7 @@ public class DPlayer {
public static DPlayer get(String name) { public static DPlayer get(String name) {
for (DPlayer dplayer : plugin.getDPlayers()) { for (DPlayer dplayer : plugin.getDPlayers()) {
if (dplayer.player.getName().equalsIgnoreCase(name)) { if (dplayer.getPlayer().getName().equalsIgnoreCase(name)) {
return dplayer; return dplayer;
} }
} }
@ -508,27 +801,27 @@ 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.player.getWorld().equals(dplayer.world)) { if ( !dplayer.getPlayer().getWorld().equals(dplayer.world)) {
if (dplayer.isEditing) { if (dplayer.isEditing) {
EditWorld eworld = EditWorld.get(dplayer.world); EditWorld eworld = EditWorld.get(dplayer.world);
if (eworld != null) { if (eworld != null) {
if (eworld.lobby == null) { if (eworld.getLobby() == null) {
MiscUtil.secureTeleport(dplayer.player, eworld.world.getSpawnLocation()); MiscUtil.secureTeleport(dplayer.getPlayer(), eworld.getWorld().getSpawnLocation());
} else { } else {
MiscUtil.secureTeleport(dplayer.player, eworld.lobby); MiscUtil.secureTeleport(dplayer.getPlayer(), eworld.getLobby());
} }
} }
} else { } else {
GameWorld gWorld = GameWorld.get(dplayer.world); GameWorld gameWorld = GameWorld.get(dplayer.world);
if (gWorld != null) { if (gameWorld != null) {
DGroup dGroup = DGroup.get(dplayer.player); DGroup dGroup = DGroup.get(dplayer.getPlayer());
if (dplayer.checkpoint == null) { if (dplayer.checkpoint == null) {
MiscUtil.secureTeleport(dplayer.player, dGroup.getGWorld().locStart); MiscUtil.secureTeleport(dplayer.getPlayer(), dGroup.getGWorld().getLocStart());
if (dplayer.wolf != null) { if (dplayer.wolf != null) {
dplayer.wolf.teleport(dGroup.getGWorld().locStart); dplayer.wolf.teleport(dGroup.getGWorld().getLocStart());
} }
} else { } else {
MiscUtil.secureTeleport(dplayer.player, 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);
} }
@ -536,8 +829,8 @@ public class DPlayer {
// Respawn Items // Respawn Items
if (dplayer.respawnInventory != null || dplayer.respawnArmor != null) { if (dplayer.respawnInventory != null || dplayer.respawnArmor != null) {
dplayer.player.getInventory().setContents(dplayer.respawnInventory); dplayer.getPlayer().getInventory().setContents(dplayer.respawnInventory);
dplayer.player.getInventory().setArmorContents(dplayer.respawnArmor); dplayer.getPlayer().getInventory().setArmorContents(dplayer.respawnArmor);
dplayer.respawnInventory = null; dplayer.respawnInventory = null;
dplayer.respawnArmor = null; dplayer.respawnArmor = null;
} }
@ -545,16 +838,16 @@ public class DPlayer {
} }
} }
} else { } else {
GameWorld gWorld = GameWorld.get(dplayer.world); GameWorld gameWorld = GameWorld.get(dplayer.world);
if (gWorld != 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.player.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.player); dplayer.wolf.setOwner(dplayer.getPlayer());
dplayer.wolfRespawnTime = 30; dplayer.wolfRespawnTime = 30;
} }
dplayer.wolfRespawnTime--; dplayer.wolfRespawnTime--;
@ -569,7 +862,7 @@ public class DPlayer {
} }
// Check Distance Trigger Signs // Check Distance Trigger Signs
DistanceTrigger.triggerAllInDistance(dplayer.player, gWorld); DistanceTrigger.triggerAllInDistance(dplayer.getPlayer(), gameWorld);
} }
} }
} }

View File

@ -8,9 +8,7 @@ import org.bukkit.block.Sign;
public class BlockSign extends DSign { public class BlockSign extends DSign {
public static String name = "Block"; private DSignType type = DSignTypeDefault.BLOCK;
public String buildPermissions = "dxl.sign.block";
public boolean onDungeonInit = false;
// Variables // Variables
private boolean initialized; private boolean initialized;
@ -49,11 +47,14 @@ public class BlockSign extends DSign {
if ( !lines[2].equals("")) { if ( !lines[2].equals("")) {
String line2[] = lines[2].split(","); String line2[] = lines[2].split(",");
Material onBlock = Material.matchMaterial(line2[0]); Material onBlock = Material.matchMaterial(line2[0]);
if (onBlock != null) { if (onBlock != null) {
onBlockId = onBlock.getId(); onBlockId = onBlock.getId();
} else { } else {
onBlockId = IntegerUtil.parseInt(line2[0]); onBlockId = IntegerUtil.parseInt(line2[0]);
} }
if (line2.length > 1) { if (line2.length > 1) {
onBlockData = (byte) IntegerUtil.parseInt(line2[1]); onBlockData = (byte) IntegerUtil.parseInt(line2[1]);
} }
@ -82,13 +83,8 @@ public class BlockSign extends DSign {
} }
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
} }
} }

View File

@ -13,16 +13,14 @@ import org.bukkit.entity.Player;
public class CheckpointSign extends DSign { public class CheckpointSign extends DSign {
public static String name = "Checkpoint"; private DSignType type = DSignTypeDefault.CHECKPOINT;
private String buildPermissions = "dxl.sign.checkpoint";
private boolean onDungeonInit = false;
// Variables // Variables
private boolean initialized; private boolean initialized;
private CopyOnWriteArrayList<DPlayer> done = new CopyOnWriteArrayList<DPlayer>(); private CopyOnWriteArrayList<DPlayer> done = new CopyOnWriteArrayList<DPlayer>();
public CheckpointSign(Sign sign, GameWorld gWorld) { public CheckpointSign(Sign sign, GameWorld gameWorld) {
super(sign, gWorld); super(sign, gameWorld);
} }
@Override @Override
@ -39,19 +37,24 @@ public class CheckpointSign extends DSign {
@Override @Override
public void onTrigger() { public void onTrigger() {
if (initialized) { if ( !initialized) {
for (DPlayer dplayer : DPlayer.get(getGWorld().world)) { return;
}
for (DPlayer dplayer : DPlayer.get(getGameWorld().getWorld())) {
dplayer.setCheckpoint(getSign().getLocation()); dplayer.setCheckpoint(getSign().getLocation());
MessageUtil.sendMessage(dplayer.player, DungeonsXL.getPlugin().getDMessages().get("Player_CheckpointReached")); MessageUtil.sendMessage(dplayer.getPlayer(), DungeonsXL.getPlugin().getDMessages().get("Player_CheckpointReached"));
} }
remove(); remove();
} }
}
@Override @Override
public boolean onPlayerTrigger(Player player) { public boolean onPlayerTrigger(Player player) {
if (initialized) { if ( !initialized) {
return true;
}
DPlayer dplayer = DPlayer.get(player); DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) { if (dplayer != null) {
if ( !done.contains(dplayer)) { if ( !done.contains(dplayer)) {
@ -60,20 +63,17 @@ public class CheckpointSign extends DSign {
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_CheckpointReached")); MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_CheckpointReached"));
} }
} }
if (done.size() >= DPlayer.get(getGWorld().world).size()) {
if (done.size() >= DPlayer.get(getGameWorld().getWorld()).size()) {
remove(); remove();
} }
}
return true; return true;
} }
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
} }
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -8,9 +8,7 @@ import org.bukkit.block.Sign;
public class ChestSign extends DSign { public class ChestSign extends DSign {
public static String name = "Chest"; private DSignType type = DSignTypeDefault.CHEST;
public String buildPermissions = "dxl.sign.chest";
public boolean onDungeonInit = false;
// Variables // Variables
private double moneyReward; private double moneyReward;
@ -25,6 +23,7 @@ public class ChestSign extends DSign {
if (lines[1].equals("")) { if (lines[1].equals("")) {
return false; return false;
} }
return true; return true;
} }
@ -34,15 +33,18 @@ public class ChestSign extends DSign {
if ( !lines[1].equals("")) { if ( !lines[1].equals("")) {
moneyReward = Double.parseDouble(lines[1]); moneyReward = Double.parseDouble(lines[1]);
} }
for (int i = -1; i <= 1; i++) { for (int i = -1; i <= 1; i++) {
if (getSign().getBlock().getRelative(i, 0, 0).getType() == Material.CHEST) { if (getSign().getBlock().getRelative(i, 0, 0).getType() == Material.CHEST) {
new GameChest(getSign().getBlock().getRelative(i, 0, 0), getGWorld(), moneyReward); new GameChest(getSign().getBlock().getRelative(i, 0, 0), getGameWorld(), moneyReward);
} }
if (getSign().getBlock().getRelative(0, 0, i).getType() == Material.CHEST) { if (getSign().getBlock().getRelative(0, 0, i).getType() == Material.CHEST) {
new GameChest(getSign().getBlock().getRelative(0, 0, i), getGWorld(), moneyReward); new GameChest(getSign().getBlock().getRelative(0, 0, i), getGameWorld(), moneyReward);
} }
if (getSign().getBlock().getRelative(0, i, 0).getType() == Material.CHEST) { if (getSign().getBlock().getRelative(0, i, 0).getType() == Material.CHEST) {
new GameChest(getSign().getBlock().getRelative(0, i, 0), getGWorld(), moneyReward); new GameChest(getSign().getBlock().getRelative(0, i, 0), getGameWorld(), moneyReward);
} }
} }
@ -50,12 +52,8 @@ public class ChestSign extends DSign {
} }
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
} }
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -9,48 +9,43 @@ import org.bukkit.block.Sign;
public class ChunkUpdaterSign extends DSign { public class ChunkUpdaterSign extends DSign {
public static String name = "ChunkUpdater"; private DSignType type = DSignTypeDefault.CHUNK_UPDATER;
public String buildPermissions = "dxl.sign.chunkupdater";
public boolean onDungeonInit = true;
public ChunkUpdaterSign(Sign sign, GameWorld gWorld) { public ChunkUpdaterSign(Sign sign, GameWorld gameWorld) {
super(sign, gWorld); super(sign, gameWorld);
} }
@Override @Override
public boolean check() { public boolean check() {
// TODO Auto-generated method stub
return true; return true;
} }
@Override @Override
public void onInit() { public void onInit() {
String lines[] = getSign().getLines(); String lines[] = getSign().getLines();
Chunk chunk = getGWorld().world.getChunkAt(getSign().getBlock()); Chunk chunk = getGameWorld().getWorld().getChunkAt(getSign().getBlock());
if ( !lines[1].equals("")) { if ( !lines[1].equals("")) {
Integer radius = IntegerUtil.parseInt(lines[1]); Integer radius = IntegerUtil.parseInt(lines[1]);
for (int x = -radius; x < radius; x++) { for (int x = -radius; x < radius; x++) {
for (int z = -radius; z < radius; z++) { for (int z = -radius; z < radius; z++) {
Chunk chunk1 = getGWorld().world.getChunkAt(chunk.getX() - x, chunk.getZ() - z); Chunk chunk1 = getGameWorld().getWorld().getChunkAt(chunk.getX() - x, chunk.getZ() - z);
chunk1.load(); chunk1.load();
getGWorld().loadedChunks.add(chunk1); getGameWorld().getLoadedChunks().add(chunk1);
} }
} }
} else { } else {
chunk.load(); chunk.load();
getGWorld().loadedChunks.add(chunk); getGameWorld().getLoadedChunks().add(chunk);
} }
getSign().getBlock().setType(Material.AIR); getSign().getBlock().setType(Material.AIR);
} }
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
} }
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -11,12 +11,10 @@ import org.bukkit.block.Sign;
public class ClassesSign extends DSign { public class ClassesSign extends DSign {
public static String name = "Classes"; private DSignType type = DSignTypeDefault.CLASSES;
public String buildPermissions = "dxl.sign.classes";
public boolean onDungeonInit = true;
public ClassesSign(Sign sign, GameWorld gWorld) { public ClassesSign(Sign sign, GameWorld gameWorld) {
super(sign, gWorld); super(sign, gameWorld);
} }
@Override @Override
@ -27,24 +25,30 @@ public class ClassesSign extends DSign {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public void onInit() { public void onInit() {
if ( !getGWorld().getConfig().isLobbyDisabled()) { if (getGameWorld().getConfig().isLobbyDisabled()) {
getSign().getBlock().setType(Material.AIR);
return;
}
int[] direction = GroupSign.getDirection(getSign().getBlock().getData()); int[] direction = GroupSign.getDirection(getSign().getBlock().getData());
int directionX = direction[0]; int directionX = direction[0];
int directionZ = direction[1]; int directionZ = direction[1];
int xx = 0, zz = 0; int xx = 0, zz = 0;
for (DClass dclass : getGWorld().getConfig().getClasses()) { for (DClass dclass : getGameWorld().getConfig().getClasses()) {
// Check existing signs // Check existing signs
boolean isContinued = true; boolean isContinued = true;
for (Sign isusedsign : getGWorld().signClass) { for (Sign isusedsign : getGameWorld().getSignClass()) {
if (dclass.getName().equalsIgnoreCase(ChatColor.stripColor(isusedsign.getLine(1)))) { if (dclass.getName().equalsIgnoreCase(ChatColor.stripColor(isusedsign.getLine(1)))) {
isContinued = false; isContinued = false;
} }
} }
if (isContinued) { if ( !isContinued) {
continue;
}
Block classBlock = getSign().getBlock().getRelative(xx, 0, zz); Block classBlock = getSign().getBlock().getRelative(xx, 0, zz);
if (classBlock.getData() == getSign().getData().getData() && classBlock.getType() == Material.WALL_SIGN && classBlock.getState() instanceof Sign) { if (classBlock.getData() == getSign().getData().getData() && classBlock.getType() == Material.WALL_SIGN && classBlock.getState() instanceof Sign) {
@ -56,7 +60,8 @@ public class ClassesSign extends DSign {
classSign.setLine(3, ChatColor.DARK_BLUE + "############"); classSign.setLine(3, ChatColor.DARK_BLUE + "############");
classSign.update(); classSign.update();
getGWorld().signClass.add(classSign); getGameWorld().getSignClass().add(classSign);
} else { } else {
break; break;
} }
@ -65,18 +70,10 @@ public class ClassesSign extends DSign {
zz = zz + directionZ; zz = zz + directionZ;
} }
} }
} else {
getSign().getBlock().setType(Material.AIR);
}
}
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
} }
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -13,9 +13,7 @@ import org.bukkit.entity.Player;
public class CommandSign extends DSign { public class CommandSign extends DSign {
public static String name = "Cmd"; private DSignType type = DSignTypeDefault.COMMAND;
public String buildPermissions = "dxl.sign.cmd";
public boolean onDungeonInit = false;
// Variables // Variables
private CCommand cCommand; private CCommand cCommand;
@ -23,14 +21,12 @@ public class CommandSign extends DSign {
private String executor; private String executor;
private boolean initialized; private boolean initialized;
public CommandSign(Sign sign, GameWorld gWorld) { public CommandSign(Sign sign, GameWorld gameWorld) {
super(sign, gWorld); super(sign, gameWorld);
} }
@Override @Override
public boolean check() { public boolean check() {
// TODO Auto-generated method stub
return true; return true;
} }
@ -41,19 +37,22 @@ public class CommandSign extends DSign {
cCommand = CommandsXL.getCCommands().getCCommand(command); cCommand = CommandsXL.getCCommands().getCCommand(command);
if (getTriggers().isEmpty()) { if (getTriggers().isEmpty()) {
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGWorld()); getSign().getBlock().setType(Material.AIR);
return;
}
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGameWorld());
if (trigger != null) { if (trigger != null) {
trigger.addListener(this); trigger.addListener(this);
getTriggers().add(trigger); getTriggers().add(trigger);
} }
getSign().setLine(0, ChatColor.DARK_BLUE + "############"); getSign().setLine(0, ChatColor.DARK_BLUE + "############");
getSign().setLine(1, ChatColor.DARK_GREEN + command); getSign().setLine(1, ChatColor.DARK_GREEN + command);
getSign().setLine(2, ""); getSign().setLine(2, "");
getSign().setLine(3, ChatColor.DARK_BLUE + "############"); getSign().setLine(3, ChatColor.DARK_BLUE + "############");
getSign().update(); getSign().update();
} else {
getSign().getBlock().setType(Material.AIR);
}
initialized = true; initialized = true;
} }
@ -69,6 +68,7 @@ public class CommandSign extends DSign {
} else { } else {
cCommand.execute(player, player, false); cCommand.execute(player, player, false);
} }
return true; return true;
} }
@ -80,12 +80,8 @@ public class CommandSign extends DSign {
} }
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
} }
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -4,6 +4,8 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld; import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.trigger.Trigger; import io.github.dre2n.dungeonsxl.trigger.Trigger;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -15,22 +17,27 @@ public abstract class DSign {
static DungeonsXL plugin = DungeonsXL.getPlugin(); static DungeonsXL plugin = DungeonsXL.getPlugin();
private Sign sign; private Sign sign;
private GameWorld gWorld; private GameWorld gameWorld;
// List of Triggers // List of Triggers
private Set<Trigger> triggers = new HashSet<Trigger>(); private Set<Trigger> triggers = new HashSet<Trigger>();
public DSign(Sign sign, GameWorld gWorld) { public DSign(Sign sign, GameWorld gameWorld) {
this.setSign(sign); this.setSign(sign);
this.gWorld = gWorld; this.gameWorld = gameWorld;
// Check Trigger // Check Trigger
if (gWorld != null) { if (gameWorld == null) {
return;
}
String line3 = sign.getLine(3).replaceAll("\\s", ""); String line3 = sign.getLine(3).replaceAll("\\s", "");
String[] triggerTypes = line3.split(","); String[] triggerTypes = line3.split(",");
for (String triggerString : triggerTypes) { for (String triggerString : triggerTypes) {
if ( !triggerString.equals("")) { if (triggerString.equals("")) {
continue;
}
String type = triggerString.substring(0, 1); String type = triggerString.substring(0, 1);
String value = null; String value = null;
@ -45,8 +52,6 @@ public abstract class DSign {
} }
} }
} }
}
}
/** /**
* @return the sign * @return the sign
@ -64,10 +69,10 @@ public abstract class DSign {
} }
/** /**
* @return the gWorld * @return the gameWorld
*/ */
public GameWorld getGWorld() { public GameWorld getGameWorld() {
return gWorld; return gameWorld;
} }
/** /**
@ -94,11 +99,9 @@ public abstract class DSign {
} }
public void onInit() { public void onInit() {
} }
public void onTrigger() { public void onTrigger() {
} }
public boolean onPlayerTrigger(Player player) { public boolean onPlayerTrigger(Player player) {
@ -106,7 +109,6 @@ public abstract class DSign {
} }
public void onDisable() { public void onDisable() {
} }
public void onUpdate() { public void onUpdate() {
@ -115,14 +117,19 @@ public abstract class DSign {
onDisable(); onDisable();
return; return;
} }
if (triggers.size() == 1) {
if (trigger.player != null) { if (triggers.size() != 1) {
continue;
}
if (trigger.player == null) {
continue;
}
if (onPlayerTrigger(trigger.player)) { if (onPlayerTrigger(trigger.player)) {
return; return;
} }
} }
}
}
onTrigger(); onTrigger();
} }
@ -131,84 +138,41 @@ public abstract class DSign {
for (Trigger trigger : triggers) { for (Trigger trigger : triggers) {
trigger.removeListener(this); trigger.removeListener(this);
} }
gWorld.dSigns.remove(this); gameWorld.getdSigns().remove(this);
} }
public boolean hasTriggers() { public boolean hasTriggers() {
return !triggers.isEmpty(); return !triggers.isEmpty();
} }
// TODO: API to add custom signs public static DSign create(Sign sign, GameWorld gameWorld) {
public static DSign create(Sign sign, GameWorld gWorld) {
String[] lines = sign.getLines(); String[] lines = sign.getLines();
DSign dSign = null; DSign dSign = null;
if (lines[0].equalsIgnoreCase("[" + BlockSign.name + "]")) { for (DSignType type : plugin.getDSigns().getDSigns()) {
dSign = new BlockSign(sign, gWorld); if ( !lines[0].equalsIgnoreCase("[" + type.getName() + "]")) {
continue;
} else if (lines[0].equalsIgnoreCase("[" + CheckpointSign.name + "]")) {
dSign = new CheckpointSign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + ChestSign.name + "]")) {
dSign = new ChestSign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + ChunkUpdaterSign.name + "]")) {
dSign = new ChunkUpdaterSign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + ClassesSign.name + "]")) {
dSign = new ClassesSign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + CommandSign.name + "]")) {
dSign = new CommandSign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + EndSign.name + "]")) {
dSign = new EndSign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + FloorSign.name + "]")) {
dSign = new FloorSign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + InteractSign.name + "]")) {
dSign = new InteractSign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + LeaveSign.name + "]")) {
dSign = new LeaveSign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + LobbySign.name + "]")) {
dSign = new LobbySign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + MobSign.name + "]")) {
dSign = new MobSign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + MsgSign.name + "]")) {
dSign = new MsgSign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + MythicMobsSign.name + "]")) {
dSign = new MythicMobsSign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + PlaceSign.name + "]")) {
dSign = new PlaceSign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + ReadySign.name + "]")) {
dSign = new ReadySign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + RedstoneSign.name + "]")) {
dSign = new RedstoneSign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + SoundMsgSign.name + "]")) {
dSign = new SoundMsgSign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + StartSign.name + "]")) {
dSign = new StartSign(sign, gWorld);
} else if (lines[0].equalsIgnoreCase("[" + TriggerSign.name + "]")) {
dSign = new TriggerSign(sign, gWorld);
} }
if (dSign != null && gWorld != null) { try {
if (dSign.isOnDungeonInit()) { Constructor<? extends DSign> constructor = type.getHandler().getConstructor(Sign.class, GameWorld.class);
dSign = constructor.newInstance(sign, gameWorld);
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException exception) {
plugin.getLogger().info("DungeonsXL could not find the handler class of the sign " + type.getName() + ".");
if ( !(type instanceof DSignTypeDefault)) {
plugin.getLogger().info("Please note that this sign is an unsupported feature added by an addon!");
}
}
}
if ( !(dSign != null && gameWorld != null)) {
return dSign;
}
if (dSign.getType().isOnDungeonInit()) {
dSign.onInit(); dSign.onInit();
} }
}
return dSign; return dSign;
} }
@ -217,8 +181,6 @@ public abstract class DSign {
public abstract boolean check(); public abstract boolean check();
public abstract String getPermissions(); public abstract DSignType getType();
public abstract boolean isOnDungeonInit();
} }

View File

@ -0,0 +1,25 @@
package io.github.dre2n.dungeonsxl.sign;
public interface DSignType {
/**
* @return the name
*/
public String getName();
/**
* @return the buildPermission
*/
public String getBuildPermission();
/**
* @return the onDungeonInit
*/
public boolean isOnDungeonInit();
/**
* @return the handler
*/
public Class<? extends DSign> getHandler();
}

View File

@ -0,0 +1,58 @@
package io.github.dre2n.dungeonsxl.sign;
public enum DSignTypeDefault implements DSignType {
BLOCK("Block", "dxl.sign.block", false, BlockSign.class),
CHECKPOINT("Checkpoint", "dxl.sign.checkpoint", false, CheckpointSign.class),
CHEST("Chest", "dxl.sign.chest", false, ChestSign.class),
CHUNK_UPDATER("ChunkUpdater", "dxl.sign.chunkupdater", true, ChunkUpdaterSign.class),
CLASSES("Classes", "dxl.sign.classes", true, ClassesSign.class),
COMMAND("CMD", "dxl.sign.cmd", false, CommandSign.class),
END("End", "dxl.sign.end", false, EndSign.class),
FLOOR("Floor", "dxl.sign.floor", false, FloorSign.class),
INTERACT("Interact", "dxl.sign.interact", true, InteractSign.class),
LEAVE("Leave", "dxl.sign.leave", true, LeaveSign.class),
LOBBY("Lobby", "dxl.sign.lobby", true, LobbySign.class),
MOB("Mob", "dxl.sign.mob", false, MobSign.class),
MESSAGE("MSG", "dxl.sign.msg", false, MessageSign.class),
MYTHIC_MOBS("MythicMobs", "dxl.sign.mob", false, MythicMobsSign.class),
PLACE("Place", "dxl.sign.place", false, PlaceSign.class),
READY("Ready", "dxl.sign.ready", true, ReadySign.class),
REDSTONE("Redstone", "dxl.sign.redstone", false, RedstoneSign.class),
SOUND_MESSAGE("SoundMSG", "dxl.sign.soundmsg", false, SoundMessageSign.class),
START("Start", "dxl.sign.start", true, StartSign.class),
TRIGGER("Trigger", "dxl.sign.trigger", true, TriggerSign.class);
private String name;
private String buildPermission;
private boolean onDungeonInit;
private Class<? extends DSign> handler;
DSignTypeDefault(String name, String buildPermission, boolean onDungeonInit, Class<? extends DSign> handler) {
this.name = name;
this.buildPermission = buildPermission;
this.onDungeonInit = onDungeonInit;
this.handler = handler;
}
@Override
public String getName() {
return name;
}
@Override
public String getBuildPermission() {
return buildPermission;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
@Override
public Class<? extends DSign> getHandler() {
return handler;
}
}

View File

@ -0,0 +1,39 @@
package io.github.dre2n.dungeonsxl.sign;
import java.util.ArrayList;
import java.util.List;
public class DSigns {
private List<DSignType> dSigns = new ArrayList<DSignType>();
public DSigns() {
for (DSignType type : DSignTypeDefault.values()) {
dSigns.add(type);
}
}
/**
* @return the dSigns
*/
public List<DSignType> getDSigns() {
return dSigns;
}
/**
* @param dSign
* the dSigns to add
*/
public void addDSign(DSignType dSign) {
dSigns.add(dSign);
}
/**
* @param dSign
* the dSigns to remove
*/
public void removeDSign(DSignType dSign) {
dSigns.remove(dSign);
}
}

View File

@ -1,6 +1,5 @@
package io.github.dre2n.dungeonsxl.sign; package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld; import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DPlayer; import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger; import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
@ -12,12 +11,10 @@ import org.bukkit.entity.Player;
public class EndSign extends DSign { public class EndSign extends DSign {
public static String name = "End"; private DSignType type = DSignTypeDefault.END;
public String buildPermissions = "dxl.sign.end";
public boolean onDungeonInit = false;
public EndSign(Sign sign, GameWorld gWorld) { public EndSign(Sign sign, GameWorld gameWorld) {
super(sign, gWorld); super(sign, gameWorld);
} }
@Override @Override
@ -27,27 +24,29 @@ public class EndSign extends DSign {
@Override @Override
public void onInit() { public void onInit() {
if (getTriggers().isEmpty()) { if ( !getTriggers().isEmpty()) {
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGWorld()); getSign().getBlock().setType(Material.AIR);
return;
}
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGameWorld());
if (trigger != null) { if (trigger != null) {
trigger.addListener(this); trigger.addListener(this);
addTrigger(trigger); addTrigger(trigger);
} }
getSign().setLine(0, ChatColor.DARK_BLUE + "############"); getSign().setLine(0, ChatColor.DARK_BLUE + "############");
getSign().setLine(1, ChatColor.DARK_GREEN + "End"); getSign().setLine(1, ChatColor.DARK_GREEN + "End");
getSign().setLine(2, ""); getSign().setLine(2, "");
getSign().setLine(3, ChatColor.DARK_BLUE + "############"); getSign().setLine(3, ChatColor.DARK_BLUE + "############");
getSign().update(); getSign().update();
} else {
getSign().getBlock().setType(Material.AIR);
}
} }
@Override @Override
public boolean onPlayerTrigger(Player player) { public boolean onPlayerTrigger(Player player) {
DPlayer dplayer = DPlayer.get(player); DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) { if (dplayer != null) {
if ( !dplayer.isFinished) { if ( !dplayer.isFinished()) {
dplayer.finish(); dplayer.finish();
} }
} }
@ -56,18 +55,14 @@ public class EndSign extends DSign {
@Override @Override
public void onTrigger() { public void onTrigger() {
for (DPlayer dplayer : DungeonsXL.getPlugin().getDPlayers()) { for (DPlayer dplayer : plugin.getDPlayers()) {
dplayer.finish(); dplayer.finish();
} }
} }
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
} }
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -1,6 +1,5 @@
package io.github.dre2n.dungeonsxl.sign; package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld; import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DPlayer; import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger; import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
@ -12,14 +11,12 @@ import org.bukkit.entity.Player;
public class FloorSign extends DSign { public class FloorSign extends DSign {
public static String name = "Floor"; private DSignType type = DSignTypeDefault.FLOOR;
public String buildPermissions = "dxl.sign.floor";
public boolean onDungeonInit = false;
private String floor; private String floor;
public FloorSign(Sign sign, GameWorld gWorld) { public FloorSign(Sign sign, GameWorld gameWorld) {
super(sign, gWorld); super(sign, gameWorld);
} }
@Override @Override
@ -34,12 +31,17 @@ public class FloorSign extends DSign {
floor = lines[1]; floor = lines[1];
} }
if (getTriggers().isEmpty()) { if ( !getTriggers().isEmpty()) {
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGWorld()); getSign().getBlock().setType(Material.AIR);
return;
}
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGameWorld());
if (trigger != null) { if (trigger != null) {
trigger.addListener(this); trigger.addListener(this);
addTrigger(trigger); addTrigger(trigger);
} }
getSign().setLine(0, ChatColor.DARK_BLUE + "############"); getSign().setLine(0, ChatColor.DARK_BLUE + "############");
getSign().setLine(1, ChatColor.DARK_GREEN + "ENTER"); getSign().setLine(1, ChatColor.DARK_GREEN + "ENTER");
if (floor == null) { if (floor == null) {
@ -49,37 +51,30 @@ public class FloorSign extends DSign {
} }
getSign().setLine(3, ChatColor.DARK_BLUE + "############"); getSign().setLine(3, ChatColor.DARK_BLUE + "############");
getSign().update(); getSign().update();
} else {
getSign().getBlock().setType(Material.AIR);
}
} }
@Override @Override
public boolean onPlayerTrigger(Player player) { public boolean onPlayerTrigger(Player player) {
DPlayer dplayer = DPlayer.get(player); DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) { if (dplayer != null) {
if ( !dplayer.isFinished) { if ( !dplayer.isFinished()) {
dplayer.finishFloor(floor); dplayer.finishFloor(floor);
} }
} }
return true; return true;
} }
@Override @Override
public void onTrigger() { public void onTrigger() {
for (DPlayer dplayer : DungeonsXL.getPlugin().getDPlayers()) { for (DPlayer dplayer : plugin.getDPlayers()) {
dplayer.finish(); dplayer.finish();
} }
} }
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
} }
} }

View File

@ -14,30 +14,32 @@ import org.bukkit.block.Sign;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class InteractSign extends DSign { public class InteractSign extends DSign {
public static String name = "Interact";
public String buildPermissions = "dxl.sign.trigger";
public boolean onDungeonInit = true;
public InteractSign(Sign sign, GameWorld gWorld) { private DSignType type = DSignTypeDefault.INTERACT;
super(sign, gWorld);
public InteractSign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
} }
@Override @Override
public boolean check() { public boolean check() {
Set<Integer> used = new HashSet<Integer>(); Set<Integer> used = new HashSet<Integer>();
for (Block block : EditWorld.get(getSign().getLocation().getWorld()).sign) { for (Block block : EditWorld.get(getSign().getLocation().getWorld()).getSign()) {
if (block != null) { if (block == null) {
continue;
}
if ( !block.getChunk().isLoaded()) { if ( !block.getChunk().isLoaded()) {
block.getChunk().load(); block.getChunk().load();
} }
if (block.getState() instanceof Sign) { if (block.getState() instanceof Sign) {
Sign rsign = (Sign) block.getState(); Sign rsign = (Sign) block.getState();
if (rsign.getLine(0).equalsIgnoreCase("[" + name + "]")) { if (rsign.getLine(0).equalsIgnoreCase("[" + type.getName() + "]")) {
used.add(IntegerUtil.parseInt(rsign.getLine(1))); used.add(IntegerUtil.parseInt(rsign.getLine(1)));
} }
} }
} }
}
int id = 1; int id = 1;
if (getSign().getLine(1).equalsIgnoreCase("")) { if (getSign().getLine(1).equalsIgnoreCase("")) {
@ -46,10 +48,12 @@ public class InteractSign extends DSign {
id++; id++;
} }
} }
} else { } else {
id = IntegerUtil.parseInt(getSign().getLine(1)); id = IntegerUtil.parseInt(getSign().getLine(1));
if (id == 0 || used.contains(id)) { if (id == 0 || used.contains(id)) {
return false; return false;
} else { } else {
return true; return true;
} }
@ -62,7 +66,7 @@ public class InteractSign extends DSign {
@Override @Override
public void onInit() { public void onInit() {
InteractTrigger trigger = InteractTrigger.getOrCreate(IntegerUtil.parseInt(getSign().getLine(1)), getSign().getBlock(), getGWorld()); InteractTrigger trigger = InteractTrigger.getOrCreate(IntegerUtil.parseInt(getSign().getLine(1)), getSign().getBlock(), getGameWorld());
if (trigger != null) { if (trigger != null) {
trigger.addListener(this); trigger.addListener(this);
addTrigger(trigger); addTrigger(trigger);
@ -81,13 +85,8 @@ public class InteractSign extends DSign {
} }
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
} }
public class UpdateTask implements Runnable { public class UpdateTask implements Runnable {
@ -100,4 +99,5 @@ public class InteractSign extends DSign {
getSign().update(); getSign().update();
} }
} }
} }

View File

@ -12,25 +12,25 @@ import org.bukkit.entity.Player;
public class LeaveSign extends DSign { public class LeaveSign extends DSign {
public static String name = "Leave"; private DSignType type = DSignTypeDefault.LEAVE;
public String buildPermissions = "dxl.sign.leave";
public boolean onDungeonInit = true;
public LeaveSign(Sign sign, GameWorld gWorld) { public LeaveSign(Sign sign, GameWorld gameWorld) {
super(sign, gWorld); super(sign, gameWorld);
} }
@Override @Override
public boolean check() { public boolean check() {
// TODO Auto-generated method stub
return true; return true;
} }
@Override @Override
public void onInit() { public void onInit() {
if (getTriggers().isEmpty()) { if ( !getTriggers().isEmpty()) {
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGWorld()); getSign().getBlock().setType(Material.AIR);
return;
}
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGameWorld());
if (trigger != null) { if (trigger != null) {
trigger.addListener(this); trigger.addListener(this);
addTrigger(trigger); addTrigger(trigger);
@ -40,9 +40,6 @@ public class LeaveSign extends DSign {
getSign().setLine(2, ""); getSign().setLine(2, "");
getSign().setLine(3, ChatColor.DARK_BLUE + "############"); getSign().setLine(3, ChatColor.DARK_BLUE + "############");
getSign().update(); getSign().update();
} else {
getSign().getBlock().setType(Material.AIR);
}
} }
@Override @Override
@ -51,6 +48,7 @@ public class LeaveSign extends DSign {
if (dplayer != null) { if (dplayer != null) {
dplayer.leave(); dplayer.leave();
} }
return true; return true;
} }
@ -62,12 +60,8 @@ public class LeaveSign extends DSign {
} }
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
} }
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -7,34 +7,26 @@ import org.bukkit.block.Sign;
public class LobbySign extends DSign { public class LobbySign extends DSign {
public static String name = "Lobby"; private DSignType type = DSignTypeDefault.LOBBY;
public String buildPermissions = "dxl.sign.lobby";
public boolean onDungeonInit = true;
public LobbySign(Sign sign, GameWorld gWorld) { public LobbySign(Sign sign, GameWorld gameWorld) {
super(sign, gWorld); super(sign, gameWorld);
} }
@Override @Override
public boolean check() { public boolean check() {
// TODO Auto-generated method stub
return true; return true;
} }
@Override @Override
public void onInit() { public void onInit() {
getGWorld().locLobby = getSign().getLocation(); getGameWorld().setLocLobby(getSign().getLocation());
getSign().getBlock().setType(Material.AIR); getSign().getBlock().setType(Material.AIR);
} }
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
} }
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -10,19 +10,17 @@ import org.bukkit.Material;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class MsgSign extends DSign { public class MessageSign extends DSign {
public static String name = "Msg"; private DSignType type = DSignTypeDefault.MESSAGE;
public String buildPermissions = "dxl.sign.msg";
public boolean onDungeonInit = false;
// Variables // Variables
private String msg; private String msg;
private boolean initialized; private boolean initialized;
private CopyOnWriteArrayList<Player> done = new CopyOnWriteArrayList<Player>(); private CopyOnWriteArrayList<Player> done = new CopyOnWriteArrayList<Player>();
public MsgSign(Sign sign, GameWorld gWorld) { public MessageSign(Sign sign, GameWorld gameWorld) {
super(sign, gWorld); super(sign, gameWorld);
} }
@Override @Override
@ -39,7 +37,7 @@ public class MsgSign extends DSign {
String lines[] = getSign().getLines(); String lines[] = getSign().getLines();
if ( !lines[1].equals("")) { if ( !lines[1].equals("")) {
String msg = getGWorld().getConfig().getMsg(IntegerUtil.parseInt(lines[1]), true); String msg = getGameWorld().getConfig().getMsg(IntegerUtil.parseInt(lines[1]), true);
if (msg != null) { if (msg != null) {
this.msg = msg; this.msg = msg;
getSign().getBlock().setType(Material.AIR); getSign().getBlock().setType(Material.AIR);
@ -51,22 +49,26 @@ public class MsgSign extends DSign {
@Override @Override
public boolean onPlayerTrigger(Player player) { public boolean onPlayerTrigger(Player player) {
if (initialized) { if ( !initialized) {
return true;
}
if ( !done.contains(player)) { if ( !done.contains(player)) {
MessageUtil.sendMessage(player, msg); MessageUtil.sendMessage(player, msg);
done.add(player); done.add(player);
} }
if (done.size() >= getGWorld().world.getPlayers().size()) {
if (done.size() >= getGameWorld().getWorld().getPlayers().size()) {
remove(); remove();
} }
}
return true; return true;
} }
@Override @Override
public void onTrigger() { public void onTrigger() {
if (initialized) { if (initialized) {
for (Player player : getGWorld().world.getPlayers()) { for (Player player : getGameWorld().getWorld().getPlayers()) {
MessageUtil.sendMessage(player, msg); MessageUtil.sendMessage(player, msg);
} }
remove(); remove();
@ -74,12 +76,8 @@ public class MsgSign extends DSign {
} }
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
} }
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -17,9 +17,7 @@ import org.bukkit.inventory.ItemStack;
public class MobSign extends DSign { public class MobSign extends DSign {
public static String name = "Mob"; private DSignType type = DSignTypeDefault.MOB;
public String buildPermissions = "dxl.sign.mob";
public boolean onDungeonInit = false;
// Variables // Variables
private String mob; private String mob;
@ -30,24 +28,29 @@ public class MobSign extends DSign {
private boolean active; private boolean active;
private int taskId = -1; private int taskId = -1;
public MobSign(Sign sign, GameWorld gWorld) { public MobSign(Sign sign, GameWorld gameWorld) {
super(sign, gWorld); super(sign, gameWorld);
} }
@Override @Override
public boolean check() { public boolean check() {
String lines[] = getSign().getLines(); String lines[] = getSign().getLines();
if ( !lines[1].equals("") && !lines[2].equals("")) { if (lines[1].equals("") || lines[2].equals("")) {
if (lines[1] != null) { return false;
}
if (lines[1] == null) {
return false;
}
String[] atributes = lines[2].split(","); String[] atributes = lines[2].split(",");
if (atributes.length == 2) { if (atributes.length == 2) {
return true; return true;
}
}
}
} else {
return false; return false;
} }
}
@Override @Override
public void onInit() { public void onInit() {
@ -55,11 +58,11 @@ public class MobSign extends DSign {
if ( !lines[1].equals("") && !lines[2].equals("")) { if ( !lines[1].equals("") && !lines[2].equals("")) {
String mob = lines[1]; String mob = lines[1];
if (mob != null) { if (mob != null) {
String[] atributes = lines[2].split(","); String[] attributes = lines[2].split(",");
if (atributes.length == 2) { if (attributes.length == 2) {
this.mob = mob; this.mob = mob;
maxinterval = IntegerUtil.parseInt(atributes[0]); maxinterval = IntegerUtil.parseInt(attributes[0]);
amount = IntegerUtil.parseInt(atributes[1]); amount = IntegerUtil.parseInt(attributes[1]);
} }
} }
} }
@ -70,32 +73,38 @@ public class MobSign extends DSign {
@Override @Override
public void onTrigger() { public void onTrigger() {
if (initialized && !active) { if ( !initialized || active) {
return;
}
MobSpawnScheduler scheduler = new MobSpawnScheduler(this); MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
taskId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, scheduler, 0L, 20L); taskId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, scheduler, 0L, 20L);
active = true; active = true;
} }
}
@Override @Override
public void onDisable() { public void onDisable() {
if (initialized && active) { if ( !initialized || !active) {
return;
}
killTask(); killTask();
interval = 0; interval = 0;
active = false; active = false;
} }
}
public void killTask() { public void killTask() {
if (initialized && active) { if ( !initialized || !active) {
return;
}
if (taskId != -1) { if (taskId != -1) {
plugin.getServer().getScheduler().cancelTask(taskId); plugin.getServer().getScheduler().cancelTask(taskId);
taskId = -1; taskId = -1;
} }
} }
}
public class MobSpawnScheduler implements Runnable { public class MobSpawnScheduler implements Runnable {
private MobSign sign; private MobSign sign;
@ -109,9 +118,9 @@ 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 gWorld = GameWorld.get(world); GameWorld gameWorld = GameWorld.get(world);
if (gWorld != 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);
// Check normal mobs // Check normal mobs
@ -130,12 +139,12 @@ public class MobSign extends DSign {
// Disable Despawning // Disable Despawning
entity.setRemoveWhenFarAway(false); entity.setRemoveWhenFarAway(false);
new DMob(entity, sign.getGWorld(), null); new DMob(entity, sign.getGameWorld(), null);
} }
} }
// Check custom mobs // Check custom mobs
DMobType mobType = DMobType.get(sign.mob, gWorld.getConfig().getMobTypes()); DMobType mobType = DMobType.get(sign.mob, gameWorld.getConfig().getMobTypes());
if (mobType != null) { if (mobType != null) {
mobType.spawn(GameWorld.get(world), spawnLoc); mobType.spawn(GameWorld.get(world), spawnLoc);
@ -161,12 +170,8 @@ public class MobSign extends DSign {
} }
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
} }
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -17,9 +17,7 @@ import org.bukkit.entity.Player;
public class MythicMobsSign extends DSign { public class MythicMobsSign extends DSign {
public static String name = "MythicMobs"; private DSignType type = DSignTypeDefault.MYTHIC_MOBS;
public String buildPermissions = "dxl.sign.mob";
public boolean onDungeonInit = false;
// Variables // Variables
private String mob; private String mob;
@ -33,24 +31,29 @@ public class MythicMobsSign extends DSign {
private LivingEntity mythicMob; private LivingEntity mythicMob;
private ArrayList<Entity> mythicMobs = new ArrayList<Entity>(); private ArrayList<Entity> mythicMobs = new ArrayList<Entity>();
public MythicMobsSign(Sign sign, GameWorld gWorld) { public MythicMobsSign(Sign sign, GameWorld gameWorld) {
super(sign, gWorld); super(sign, gameWorld);
} }
@Override @Override
public boolean check() { public boolean check() {
String lines[] = getSign().getLines(); String lines[] = getSign().getLines();
if ( !lines[1].equals("") && !lines[2].equals("")) { if (lines[1].equals("") || lines[2].equals("")) {
if (lines[1] != null) { return false;
}
if (lines[1] == null) {
return false;
}
String[] atributes = lines[2].split(","); String[] atributes = lines[2].split(",");
if (atributes.length == 2) { if (atributes.length == 2) {
return true; return true;
}
}
}
} else {
return false; return false;
} }
}
@Override @Override
public void onInit() { public void onInit() {
@ -58,11 +61,11 @@ public class MythicMobsSign extends DSign {
if ( !lines[1].equals("") && !lines[2].equals("")) { if ( !lines[1].equals("") && !lines[2].equals("")) {
String mob = lines[1]; String mob = lines[1];
if (mob != null) { if (mob != null) {
String[] atributes = lines[2].split(","); String[] attributes = lines[2].split(",");
if (atributes.length == 2) { if (attributes.length == 2) {
this.mob = mob; this.mob = mob;
maxinterval = IntegerUtil.parseInt(atributes[0]); maxinterval = IntegerUtil.parseInt(attributes[0]);
amount = IntegerUtil.parseInt(atributes[1]); amount = IntegerUtil.parseInt(attributes[1]);
} }
} }
} }
@ -73,32 +76,38 @@ public class MythicMobsSign extends DSign {
@Override @Override
public void onTrigger() { public void onTrigger() {
if (initialized && !active) { if ( !initialized || active) {
return;
}
MobSpawnScheduler scheduler = new MobSpawnScheduler(this); MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
taskId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, scheduler, 0L, 20L); taskId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, scheduler, 0L, 20L);
active = true; active = true;
} }
}
@Override @Override
public void onDisable() { public void onDisable() {
if (initialized && active) { if ( !initialized || !active) {
return;
}
killTask(); killTask();
interval = 0; interval = 0;
active = false; active = false;
} }
}
public void killTask() { public void killTask() {
if (initialized && active) { if ( !initialized || !active) {
return;
}
if (taskId != -1) { if (taskId != -1) {
plugin.getServer().getScheduler().cancelTask(taskId); plugin.getServer().getScheduler().cancelTask(taskId);
taskId = -1; taskId = -1;
} }
} }
}
public class MobSpawnScheduler implements Runnable { public class MobSpawnScheduler implements Runnable {
private MythicMobsSign sign; private MythicMobsSign sign;
@ -111,20 +120,20 @@ 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 gWorld = GameWorld.get(world); GameWorld gameWorld = GameWorld.get(world);
if (gWorld != null) { if (gameWorld != null) {
spawnLoc = sign.getSign().getLocation().add(0.5, 0, 0.5); spawnLoc = sign.getSign().getLocation().add(0.5, 0, 0.5);
double x = spawnLoc.getX(); double x = spawnLoc.getX();
double y = spawnLoc.getY(); double y = spawnLoc.getY();
double z = spawnLoc.getZ(); double z = spawnLoc.getZ();
String command = "mm mobs spawn " + mob + " " + amount + " DXL_Game_" + gWorld.id + "," + x + "," + y + "," + z; String command = "mm mobs spawn " + mob + " " + amount + " DXL_Game_" + gameWorld.getId() + "," + x + "," + y + "," + z;
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command); Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command);
setMythicMobs(); setMythicMobs();
if (mythicMob != null) { if (mythicMob != null) {
new DMob(mythicMob, sign.getGWorld(), null, mob); new DMob(mythicMob, sign.getGameWorld(), null, mob);
} }
// Set the amount // Set the amount
@ -146,16 +155,6 @@ public class MythicMobsSign extends DSign {
} }
} }
@Override
public String getPermissions() {
return buildPermissions;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
private void setMythicMobs() { private void setMythicMobs() {
for (Entity entity : spawnLoc.getChunk().getEntities()) { for (Entity entity : spawnLoc.getChunk().getEntities()) {
if (entity.getLocation().getX() >= spawnLoc.getX() - 1 && entity.getLocation().getX() <= spawnLoc.getX() + 1 && entity.getLocation().getY() >= spawnLoc.getY() - 1 if (entity.getLocation().getX() >= spawnLoc.getX() - 1 && entity.getLocation().getX() <= spawnLoc.getX() + 1 && entity.getLocation().getY() >= spawnLoc.getY() - 1
@ -163,9 +162,14 @@ public class MythicMobsSign extends DSign {
&& !mythicMobs.contains(entity) && entity.isCustomNameVisible() && !(entity instanceof Player)) { && !mythicMobs.contains(entity) && entity.isCustomNameVisible() && !(entity instanceof Player)) {
mythicMob = (LivingEntity) entity; mythicMob = (LivingEntity) entity;
mythicMobs.add(entity); mythicMobs.add(entity);
org.bukkit.Bukkit.broadcastMessage("[DXL Debug] MythicMob counter: " + mythicMobs.size());
return; return;
} }
} }
} }
@Override
public DSignType getType() {
return type;
}
} }

View File

@ -8,12 +8,10 @@ import org.bukkit.block.Sign;
public class PlaceSign extends DSign { public class PlaceSign extends DSign {
public static String name = "Place"; private DSignType type = DSignTypeDefault.PLACE;
public String buildPermissions = "dxl.sign.place";
public boolean onDungeonInit = false;
public PlaceSign(Sign sign, GameWorld gWorld) { public PlaceSign(Sign sign, GameWorld gameWorld) {
super(sign, gWorld); super(sign, gameWorld);
} }
@Override @Override
@ -24,17 +22,13 @@ public class PlaceSign extends DSign {
@Override @Override
public void onInit() { public void onInit() {
String lines[] = getSign().getLines(); String lines[] = getSign().getLines();
getGWorld().placeableBlocks.add(new GamePlaceableBlock(getSign().getBlock(), lines[1], lines[2])); getGameWorld().getPlaceableBlocks().add(new GamePlaceableBlock(getSign().getBlock(), lines[1], lines[2]));
getSign().getBlock().setType(Material.AIR); getSign().getBlock().setType(Material.AIR);
} }
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
} }
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -13,12 +13,10 @@ import org.bukkit.entity.Player;
public class ReadySign extends DSign { public class ReadySign extends DSign {
public static String name = "Ready"; private DSignType type = DSignTypeDefault.READY;
public String buildPermissions = "dxl.sign.ready";
public boolean onDungeonInit = true;
public ReadySign(Sign sign, GameWorld gWorld) { public ReadySign(Sign sign, GameWorld gameWorld) {
super(sign, gWorld); super(sign, gameWorld);
} }
@Override @Override
@ -28,20 +26,22 @@ public class ReadySign extends DSign {
@Override @Override
public void onInit() { public void onInit() {
if (getTriggers().isEmpty()) { if ( !getTriggers().isEmpty()) {
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGWorld()); getSign().getBlock().setType(Material.AIR);
return;
}
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGameWorld());
if (trigger != null) { if (trigger != null) {
trigger.addListener(this); trigger.addListener(this);
addTrigger(trigger); addTrigger(trigger);
} }
getSign().setLine(0, ChatColor.DARK_BLUE + "############"); getSign().setLine(0, ChatColor.DARK_BLUE + "############");
getSign().setLine(1, ChatColor.DARK_GREEN + "Ready"); getSign().setLine(1, ChatColor.DARK_GREEN + "Ready");
getSign().setLine(2, ""); getSign().setLine(2, "");
getSign().setLine(3, ChatColor.DARK_BLUE + "############"); getSign().setLine(3, ChatColor.DARK_BLUE + "############");
getSign().update(); getSign().update();
} else {
getSign().getBlock().setType(Material.AIR);
}
} }
@Override @Override
@ -58,26 +58,27 @@ public class ReadySign extends DSign {
} }
private void ready(DPlayer dplayer) { private void ready(DPlayer dplayer) {
if (dplayer != null) { if (dplayer == null) {
if ( !dplayer.isReady) {
if (getGWorld().signClass.isEmpty() || dplayer.dclass != null) {
dplayer.ready();
MessageUtil.sendMessage(dplayer.player, plugin.getDMessages().get("Player_Ready"));
return; return;
}
if (dplayer.isReady()) {
return;
}
if (getGameWorld().getSignClass().isEmpty() || dplayer.getDClass() != null) {
dplayer.ready();
MessageUtil.sendMessage(dplayer.getPlayer(), plugin.getDMessages().get("Player_Ready"));
return;
} else { } else {
MessageUtil.sendMessage(dplayer.player, plugin.getDMessages().get("Error_Ready")); MessageUtil.sendMessage(dplayer.getPlayer(), plugin.getDMessages().get("Error_Ready"));
}
}
} }
} }
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
} }
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -10,9 +10,7 @@ import org.bukkit.block.Sign;
public class RedstoneSign extends DSign { public class RedstoneSign extends DSign {
public static String name = "Redstone"; private DSignType type = DSignTypeDefault.REDSTONE;
public String buildPermissions = "dxl.sign.redstone";
public boolean onDungeonInit = false;
// Variables // Variables
private boolean initialized; private boolean initialized;
@ -71,23 +69,31 @@ public class RedstoneSign extends DSign {
@Override @Override
public void onTrigger() { public void onTrigger() {
if (initialized && !active) { if ( !initialized || active) {
return;
}
if (delay > 0) { if (delay > 0) {
enableTaskId = DungeonsXL.getPlugin().getServer().getScheduler().scheduleSyncRepeatingTask(DungeonsXL.getPlugin(), new DelayedPower(true), delay, delay + offDelay); enableTaskId = DungeonsXL.getPlugin().getServer().getScheduler().scheduleSyncRepeatingTask(DungeonsXL.getPlugin(), new DelayedPower(true), delay, delay + offDelay);
if (repeat != 1) { if (repeat != 1) {
repeatsToDo = repeat; repeatsToDo = repeat;
disableTaskId = DungeonsXL.getPlugin().getServer().getScheduler().scheduleSyncRepeatingTask(DungeonsXL.getPlugin(), new DelayedPower(false), delay + offDelay, delay + offDelay); disableTaskId = DungeonsXL.getPlugin().getServer().getScheduler().scheduleSyncRepeatingTask(DungeonsXL.getPlugin(), new DelayedPower(false), delay + offDelay, delay + offDelay);
} }
} else { } else {
power(); power();
} }
active = true; active = true;
} }
}
@Override @Override
public void onDisable() { public void onDisable() {
if (initialized && active) { if ( !initialized || !active) {
return;
}
unpower(); unpower();
disableTask(enableTaskId); disableTask(enableTaskId);
@ -97,7 +103,6 @@ public class RedstoneSign extends DSign {
active = false; active = false;
} }
}
public void power() { public void power() {
block.setType(Material.REDSTONE_BLOCK); block.setType(Material.REDSTONE_BLOCK);
@ -108,21 +113,18 @@ public class RedstoneSign extends DSign {
} }
public void disableTask(int taskId) { public void disableTask(int taskId) {
if (taskId != -1) { if (taskId == -1) {
return;
}
if (DungeonsXL.getPlugin().getServer().getScheduler().isCurrentlyRunning(taskId) || DungeonsXL.getPlugin().getServer().getScheduler().isQueued(taskId)) { if (DungeonsXL.getPlugin().getServer().getScheduler().isCurrentlyRunning(taskId) || DungeonsXL.getPlugin().getServer().getScheduler().isQueued(taskId)) {
DungeonsXL.getPlugin().getServer().getScheduler().cancelTask(taskId); DungeonsXL.getPlugin().getServer().getScheduler().cancelTask(taskId);
} }
} }
}
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
} }
public class DelayedPower implements Runnable { public class DelayedPower implements Runnable {
@ -155,4 +157,5 @@ public class RedstoneSign extends DSign {
} }
} }
} }
} }

View File

@ -9,11 +9,9 @@ import org.bukkit.Material;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class SoundMsgSign extends DSign { public class SoundMessageSign extends DSign {
public static String name = "SoundMsg"; private DSignType type = DSignTypeDefault.SOUND_MESSAGE;
public String buildPermissions = "dxl.sign.soundmsg";
public boolean onDungeonInit = false;
// Variables // Variables
private boolean initialized; private boolean initialized;
@ -21,8 +19,8 @@ public class SoundMsgSign extends DSign {
private String msg; private String msg;
private CopyOnWriteArrayList<Player> done = new CopyOnWriteArrayList<Player>(); private CopyOnWriteArrayList<Player> done = new CopyOnWriteArrayList<Player>();
public SoundMsgSign(Sign sign, GameWorld gWorld) { public SoundMessageSign(Sign sign, GameWorld gameWorld) {
super(sign, gWorld); super(sign, gameWorld);
} }
@Override @Override
@ -39,7 +37,7 @@ public class SoundMsgSign extends DSign {
String lines[] = getSign().getLines(); String lines[] = getSign().getLines();
if ( !lines[1].equals("")) { if ( !lines[1].equals("")) {
String msg = getGWorld().getConfig().getMsg(IntegerUtil.parseInt(lines[1]), true); String msg = getGameWorld().getConfig().getMsg(IntegerUtil.parseInt(lines[1]), true);
if (msg != null) { if (msg != null) {
this.msg = msg; this.msg = msg;
getSign().getBlock().setType(Material.AIR); getSign().getBlock().setType(Material.AIR);
@ -60,20 +58,17 @@ public class SoundMsgSign extends DSign {
public boolean onPlayerTrigger(Player player) { public boolean onPlayerTrigger(Player player) {
if (initialized) { if (initialized) {
remove(); remove();
if (done.size() >= getGWorld().world.getPlayers().size()) { if (done.size() >= getGameWorld().getWorld().getPlayers().size()) {
remove(); remove();
} }
} }
return true; return true;
} }
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
} }
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -7,12 +7,10 @@ import org.bukkit.block.Sign;
public class StartSign extends DSign { public class StartSign extends DSign {
public static String name = "Start"; private DSignType type = DSignTypeDefault.START;
public String buildPermissions = "dxl.sign.start";
public boolean onDungeonInit = true;
public StartSign(Sign sign, GameWorld gWorld) { public StartSign(Sign sign, GameWorld gameWorld) {
super(sign, gWorld); super(sign, gameWorld);
} }
@Override @Override
@ -22,17 +20,13 @@ public class StartSign extends DSign {
@Override @Override
public void onInit() { public void onInit() {
getGWorld().locStart = getSign().getLocation(); getGameWorld().setLocStart(getSign().getLocation());
getSign().getBlock().setType(Material.AIR); getSign().getBlock().setType(Material.AIR);
} }
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
} }
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -13,34 +13,36 @@ import org.bukkit.block.Block;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
public class TriggerSign extends DSign { public class TriggerSign extends DSign {
public static String name = "Trigger";
public String buildPermissions = "dxl.sign.trigger"; private DSignType type = DSignTypeDefault.TRIGGER;
public boolean onDungeonInit = true;
// Variables // Variables
private int triggerId; private int triggerId;
private boolean initialized; private boolean initialized;
public TriggerSign(Sign sign, GameWorld gWorld) { public TriggerSign(Sign sign, GameWorld gameWorld) {
super(sign, gWorld); super(sign, gameWorld);
} }
@Override @Override
public boolean check() { public boolean check() {
Set<Integer> used = new HashSet<Integer>(); Set<Integer> used = new HashSet<Integer>();
for (Block block : EditWorld.get(getSign().getLocation().getWorld()).sign) { for (Block block : EditWorld.get(getSign().getLocation().getWorld()).getSign()) {
if (block != null) { if (block == null) {
continue;
}
if ( !block.getChunk().isLoaded()) { if ( !block.getChunk().isLoaded()) {
block.getChunk().load(); block.getChunk().load();
} }
if (block.getState() instanceof Sign) { if (block.getState() instanceof Sign) {
Sign rsign = (Sign) block.getState(); Sign rsign = (Sign) block.getState();
if (rsign.getLine(0).equalsIgnoreCase("[" + name + "]")) { if (rsign.getLine(0).equalsIgnoreCase("[" + type.getName() + "]")) {
used.add(IntegerUtil.parseInt(rsign.getLine(1))); used.add(IntegerUtil.parseInt(rsign.getLine(1)));
} }
} }
} }
}
int id = 1; int id = 1;
if (getSign().getLine(1).equalsIgnoreCase("")) { if (getSign().getLine(1).equalsIgnoreCase("")) {
@ -49,6 +51,7 @@ public class TriggerSign extends DSign {
id++; id++;
} }
} }
} else { } else {
id = IntegerUtil.parseInt(getSign().getLine(1)); id = IntegerUtil.parseInt(getSign().getLine(1));
if (used.contains(id)) { if (used.contains(id)) {
@ -73,32 +76,31 @@ public class TriggerSign extends DSign {
@Override @Override
public void onTrigger() { public void onTrigger() {
if (initialized) { if ( !initialized) {
SignTrigger trigger = SignTrigger.get(triggerId, getGWorld()); return;
}
SignTrigger trigger = SignTrigger.get(triggerId, getGameWorld());
if (trigger != null) { if (trigger != null) {
trigger.onTrigger(true); trigger.onTrigger(true);
} }
} }
}
@Override @Override
public void onDisable() { public void onDisable() {
if (initialized) { if ( !initialized) {
SignTrigger trigger = SignTrigger.get(triggerId, getGWorld()); return;
}
SignTrigger trigger = SignTrigger.get(triggerId, getGameWorld());
if (trigger != null) { if (trigger != null) {
trigger.onTrigger(false); trigger.onTrigger(false);
} }
} }
}
@Override @Override
public String getPermissions() { public DSignType getType() {
return buildPermissions; return type;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
} }
public class UpdateTask implements Runnable { public class UpdateTask implements Runnable {

View File

@ -31,7 +31,6 @@ public class DistanceTrigger extends Trigger {
triggered = true; triggered = true;
this.player = player; this.player = player;
updateDSigns(); updateDSigns();
} }
@Override @Override
@ -53,15 +52,21 @@ public class DistanceTrigger extends Trigger {
} }
} }
public static void triggerAllInDistance(Player player, GameWorld gworld) { public static void triggerAllInDistance(Player player, GameWorld gWorld) {
if (hasTriggers(gworld)) { if ( !hasTriggers(gWorld)) {
for (DistanceTrigger trigger : getTriggersArray(gworld)) { return;
}
if ( !player.getLocation().getWorld().equals(gWorld.getWorld())) {
return;
}
for (DistanceTrigger trigger : getTriggersArray(gWorld)) {
if (player.getLocation().distance(trigger.loc) < trigger.distance) { if (player.getLocation().distance(trigger.loc) < trigger.distance) {
trigger.onTrigger(player); trigger.onTrigger(player);
} }
} }
} }
}
public static boolean hasTriggers(GameWorld gworld) { public static boolean hasTriggers(GameWorld gworld) {
return !triggers.isEmpty() && triggers.containsKey(gworld); return !triggers.isEmpty() && triggers.containsKey(gworld);

View File

@ -28,7 +28,7 @@ public abstract class Trigger {
if (type.equalsIgnoreCase("R")) { if (type.equalsIgnoreCase("R")) {
trigger = RedstoneTrigger.getOrCreate(dsign.getSign(), dsign.getGWorld()); trigger = RedstoneTrigger.getOrCreate(dsign.getSign(), dsign.getGameWorld());
} else if (type.equalsIgnoreCase("D")) { } else if (type.equalsIgnoreCase("D")) {
@ -41,25 +41,25 @@ public abstract class Trigger {
} else if (type.equalsIgnoreCase("T")) { } else if (type.equalsIgnoreCase("T")) {
if (value != null) { if (value != null) {
trigger = SignTrigger.getOrCreate(IntegerUtil.parseInt(value), dsign.getGWorld()); trigger = SignTrigger.getOrCreate(IntegerUtil.parseInt(value), dsign.getGameWorld());
} }
} else if (type.equalsIgnoreCase("I")) { } else if (type.equalsIgnoreCase("I")) {
if (value != null) { if (value != null) {
trigger = InteractTrigger.getOrCreate(IntegerUtil.parseInt(value), dsign.getGWorld()); trigger = InteractTrigger.getOrCreate(IntegerUtil.parseInt(value), dsign.getGameWorld());
} }
} else if (type.equalsIgnoreCase("M")) { } else if (type.equalsIgnoreCase("M")) {
if (value != null) { if (value != null) {
trigger = MobTrigger.getOrCreate(value, dsign.getGWorld()); trigger = MobTrigger.getOrCreate(value, dsign.getGameWorld());
} }
} else if (type.equalsIgnoreCase("U")) { } else if (type.equalsIgnoreCase("U")) {
if (value != null) { if (value != null) {
trigger = UseItemTrigger.getOrCreate(value, dsign.getGWorld()); trigger = UseItemTrigger.getOrCreate(value, dsign.getGameWorld());
} }
} }
@ -68,7 +68,7 @@ public abstract class Trigger {
public void addListener(DSign dsign) { public void addListener(DSign dsign) {
if (dsigns.isEmpty()) { if (dsigns.isEmpty()) {
register(dsign.getGWorld()); register(dsign.getGameWorld());
} }
dsigns.add(dsign); dsigns.add(dsign);
} }
@ -76,7 +76,7 @@ public abstract class Trigger {
public void removeListener(DSign dsign) { public void removeListener(DSign dsign) {
dsigns.remove(dsign); dsigns.remove(dsign);
if (dsigns.isEmpty()) { if (dsigns.isEmpty()) {
unregister(dsign.getGWorld()); unregister(dsign.getGameWorld());
} }
} }