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;
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.DPlayer;
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.VersionUtil;
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.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
@ -49,6 +52,7 @@ public class DungeonsXL extends JavaPlugin {
private DMessages dMessages;
private VersionUtil versionUtil;
private DCommands dCommands;
private DSigns dSigns;
private Dungeons dungeons;
private CopyOnWriteArrayList<Player> chatSpyers = new CopyOnWriteArrayList<Player>();
@ -67,15 +71,14 @@ public class DungeonsXL extends JavaPlugin {
getDataFolder().mkdir();
// Load Language
dMessages = new DMessages(new File(plugin.getDataFolder(), "languages/en.yml"));
loadDMessages(new File(plugin.getDataFolder(), "languages/en.yml"));
// Load Config
mainConfig = new MainConfig(new File(plugin.getDataFolder(), "config.yml"));
loadMainConfig(new File(plugin.getDataFolder(), "config.yml"));
// Load Language 2
loadDMessages(new File(plugin.getDataFolder(), "languages/" + mainConfig.getLanguage() + ".yml"));
loadVersionUtil();
loadDCommands();
loadDSigns();
loadDungeons();
// InitFolders
@ -88,11 +91,11 @@ public class DungeonsXL extends JavaPlugin {
loadEconomyProvider();
getCommand("dungeonsxl").setExecutor(new CommandListener());
Bukkit.getServer().getPluginManager().registerEvents(new EntityListener(), this);
Bukkit.getServer().getPluginManager().registerEvents(new PlayerListener(), this);
Bukkit.getServer().getPluginManager().registerEvents(new BlockListener(), this);
Bukkit.getServer().getPluginManager().registerEvents(new WorldListener(), this);
Bukkit.getServer().getPluginManager().registerEvents(new HangingListener(), this);
getServer().getPluginManager().registerEvents(new EntityListener(), this);
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
getServer().getPluginManager().registerEvents(new BlockListener(), this);
getServer().getPluginManager().registerEvents(new WorldListener(), this);
getServer().getPluginManager().registerEvents(new HangingListener(), this);
// Load All
loadAll();
@ -167,14 +170,14 @@ public class DungeonsXL extends JavaPlugin {
@Override
public void run() {
for (GameWorld gworld : gameWorlds) {
if (gworld.world.getPlayers().isEmpty()) {
if (DPlayer.get(gworld.world).isEmpty()) {
if (gworld.getWorld().getPlayers().isEmpty()) {
if (DPlayer.get(gworld.getWorld()).isEmpty()) {
gworld.delete();
}
}
}
for (EditWorld eworld : editWorlds) {
if (eworld.world.getPlayers().isEmpty()) {
if (eworld.getWorld().getPlayers().isEmpty()) {
eworld.delete();
}
}
@ -208,6 +211,7 @@ public class DungeonsXL extends JavaPlugin {
try {
configFile.save(file);
} catch (IOException e) {
e.printStackTrace();
}
@ -243,6 +247,7 @@ public class DungeonsXL extends JavaPlugin {
}
FileUtil.removeDirectory(file);
} else if (file.getName().contains("DXL_Game_") && file.isDirectory()) {
FileUtil.removeDirectory(file);
}
@ -276,6 +281,7 @@ public class DungeonsXL extends JavaPlugin {
this.economyProvider = economyProvider.getProvider();
}
}
} catch (NoClassDefFoundError error) {
getLogger().info("Could not hook into Vault to register an economy provider!");
}
@ -297,6 +303,7 @@ public class DungeonsXL extends JavaPlugin {
if (permissionProvider != null) {
this.permissionProvider = permissionProvider.getProvider();
}
} catch (NoClassDefFoundError error) {
getLogger().info("Could not hook into Vault to register a permission provider!");
}
@ -372,6 +379,20 @@ public class DungeonsXL extends JavaPlugin {
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
*/

View File

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

View File

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

View File

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

View File

@ -27,26 +27,31 @@ public class EditCommand extends DCommand {
DGroup dgroup = DGroup.get(player);
DPlayer dplayer = DPlayer.get(player);
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 {
if ( !(EditWorld.isInvitedPlayer(dungeonName, player.getUniqueId(), player.getName()) || player.hasPermission("dxl.edit"))) {
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);
if (dplayer != null) {
if (dplayer.isEditing) {
dplayer.escape();
EditWorld eworld = EditWorld.get(dplayer.world);
if (eworld != null) {
if (eworld.world.getPlayers().isEmpty()) {
eworld.deleteNoSave();
}
}
} else {
if ( !dplayer.isEditing()) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
return;
}
return;
dplayer.escape();
EditWorld eworld = EditWorld.get(dplayer.getWorld());
if (eworld == null) {
return;
}
if (eworld.getWorld().getPlayers().isEmpty()) {
eworld.deleteNoSave();
}
} else {
DGroup dgroup = DGroup.get(player);

View File

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

View File

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

View File

@ -39,7 +39,7 @@ public class LivesCommand extends DCommand {
DPlayer dPlayer = DPlayer.get(player);
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 {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));

View File

@ -25,65 +25,65 @@ public class MsgCommand extends DCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender;
EditWorld eworld = EditWorld.get(player.getWorld());
EditWorld editWorld = EditWorld.get(player.getWorld());
if (eworld != null) {
if (args.length > 1) {
try {
int id = IntegerUtil.parseInt(args[1]);
if (editWorld == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
return;
}
if (args.length <= 1) {
displayHelp(player);
return;
}
try {
int id = IntegerUtil.parseInt(args[1]);
WorldConfig confreader = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + editWorld.getMapName(), "config.yml"));
if (args.length == 2) {
String msg = confreader.getMsg(id, true);
if (msg != null) {
MessageUtil.sendMessage(player, ChatColor.WHITE + msg);
WorldConfig confreader = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + eworld.dungeonname, "config.yml"));
if (args.length == 2) {
String msg = confreader.getMsg(id, true);
if (msg != null) {
MessageUtil.sendMessage(player, ChatColor.WHITE + msg);
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_MsgIdNotExist", "" + id));
}
} else {
String msg = "";
int i = 0;
for (String arg : args) {
i++;
if (i > 2) {
msg = msg + " " + arg;
}
}
String[] splitMsg = msg.split("\"");
if (splitMsg.length > 1) {
msg = splitMsg[1];
String old = confreader.getMsg(id, false);
if (old == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Msg_Added", "" + id));
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Msg_Updated", "" + id));
}
confreader.setMsg(msg, id);
confreader.save();
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_MsgFormat"));
}
}
} catch (NumberFormatException e) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_MsgNoInt"));
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_MsgIdNotExist", "" + id));
}
} else {
displayHelp(player);
String msg = "";
int i = 0;
for (String arg : args) {
i++;
if (i > 2) {
msg = msg + " " + arg;
}
}
String[] splitMsg = msg.split("\"");
if (splitMsg.length > 1) {
msg = splitMsg[1];
String old = confreader.getMsg(id, false);
if (old == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Msg_Added", "" + id));
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Msg_Updated", "" + id));
}
confreader.setMsg(msg, id);
confreader.save();
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_MsgFormat"));
}
}
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
} catch (NumberFormatException e) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_MsgNoInt"));
}
}

View File

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

View File

@ -25,23 +25,22 @@ public class PortalCommand extends DCommand {
Player player = (Player) sender;
DPlayer dplayer = DPlayer.get(player);
if (dplayer == null) {
DPortal dportal = DPortal.get(player);
if (dportal == null) {
dportal = new DPortal(false);
dportal.setPlayer(player);
dportal.setWorld(player.getWorld());
player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD));
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalIntroduction"));
} else {
plugin.getDPortals().remove(dportal);
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalAbort"));
}
if (dplayer != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
}
DPortal dportal = DPortal.get(player);
if (dportal == null) {
dportal = new DPortal(false);
dportal.setPlayer(player);
dportal.setWorld(player.getWorld());
player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD));
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalIntroduction"));
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
plugin.getDPortals().remove(dportal);
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalAbort"));
}
}

View File

@ -65,22 +65,22 @@ public class TestCommand extends DCommand {
return;
}
DGroup dgroup = new DGroup(player, identifier, multiFloor);
DGroup dGroup = new DGroup(player, identifier, multiFloor);
if (dgroup.getGWorld() == null) {
dgroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName()));
if (dGroup.getGWorld() == null) {
dGroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName()));
}
DPlayer newDPlayer;
if (dgroup.getGWorld().locLobby == null) {
newDPlayer = new DPlayer(player, dgroup.getGWorld().world, dgroup.getGWorld().world.getSpawnLocation(), false);
if (dGroup.getGWorld().getLocLobby() == null) {
newDPlayer = new DPlayer(player, dGroup.getGWorld().getWorld(), dGroup.getGWorld().getWorld().getSpawnLocation(), false);
} 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;
public DLootInventory(Player player, ItemStack[] istacks) {
public DLootInventory(Player player, ItemStack[] itemStacks) {
plugin.getDLootInventories().add(this);
inventory = Bukkit.createInventory(player, 54, ChatColor.translateAlternateColorCodes('&', DungeonsXL.getPlugin().getDMessages().get("Player_Treasures")));
for (ItemStack istack : istacks) {
if (istack != null) {
inventory.addItem(istack);
for (ItemStack itemStack : itemStacks) {
if (itemStack != null) {
inventory.addItem(itemStack);
}
}
this.player = player;

View File

@ -28,14 +28,14 @@ public class EditWorld {
static DungeonsXL plugin = DungeonsXL.getPlugin();
// Variables
public World world;
public String owner;
public String name;
public String dungeonname;
public int id;
public Location lobby;
public CopyOnWriteArrayList<String> invitedPlayers = new CopyOnWriteArrayList<String>();
public CopyOnWriteArrayList<Block> sign = new CopyOnWriteArrayList<Block>();
private World world;
private String owner;
private String name;
private String mapName;
private int id;
private Location lobby;
private CopyOnWriteArrayList<String> invitedPlayers = new CopyOnWriteArrayList<String>();
private CopyOnWriteArrayList<Block> sign = new CopyOnWriteArrayList<Block>();
public EditWorld() {
plugin.getEditWorlds().add(this);
@ -46,8 +46,8 @@ public class EditWorld {
while (id == -1) {
i++;
boolean exist = false;
for (EditWorld eworld : plugin.getEditWorlds()) {
if (eworld.id == i) {
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.id == i) {
exist = true;
break;
}
@ -72,7 +72,7 @@ public class EditWorld {
world.save();
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());
for (Block sign : this.sign) {
out.writeInt(sign.getX());
@ -104,8 +104,8 @@ public class EditWorld {
plugin.getServer().unloadWorld(world, true);
File dir = new File("DXL_Edit_" + id);
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + dungeonname));
FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + dungeonname));
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName));
FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
FileUtil.removeDirectory(dir);
}
@ -117,17 +117,17 @@ public class EditWorld {
}
File dir = new File("DXL_Edit_" + id);
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + dungeonname));
FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + dungeonname));
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName));
FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
plugin.getServer().unloadWorld(world, true);
FileUtil.removeDirectory(dir);
}
// Static
public static EditWorld get(World world) {
for (EditWorld eworld : plugin.getEditWorlds()) {
if (eworld.world.equals(world)) {
return eworld;
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.world.equals(world)) {
return editWorld;
}
}
@ -135,9 +135,9 @@ public class EditWorld {
}
public static EditWorld get(String name) {
for (EditWorld eworld : plugin.getEditWorlds()) {
if (eworld.dungeonname.equalsIgnoreCase(name)) {
return eworld;
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.mapName.equalsIgnoreCase(name)) {
return editWorld;
}
}
@ -145,47 +145,47 @@ public class EditWorld {
}
public static void deleteAll() {
for (EditWorld eworld : plugin.getEditWorlds()) {
eworld.delete();
for (EditWorld editWorld : plugin.getEditWorlds()) {
editWorld.delete();
}
}
public static EditWorld load(String name) {
for (EditWorld eworld : plugin.getEditWorlds()) {
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (eworld.dungeonname.equalsIgnoreCase(name)) {
return eworld;
if (editWorld.mapName.equalsIgnoreCase(name)) {
return editWorld;
}
}
File file = new File(plugin.getDataFolder(), "/maps/" + name);
if (file.exists()) {
EditWorld eworld = new EditWorld();
eworld.dungeonname = name;
EditWorld editWorld = new EditWorld();
editWorld.mapName = name;
// World
FileUtil.copyDirectory(file, new File("DXL_Edit_" + eworld.id));
FileUtil.copyDirectory(file, new File("DXL_Edit_" + editWorld.id));
// Id File
File idFile = new File("DXL_Edit_" + eworld.id + "/.id_" + name);
File idFile = new File("DXL_Edit_" + editWorld.id + "/.id_" + name);
try {
idFile.createNewFile();
} catch (IOException e) {
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 {
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();
for (int i = 0; i < length; i++) {
int x = os.readInt();
int y = os.readInt();
int z = os.readInt();
Block block = eworld.world.getBlockAt(x, y, z);
eworld.checkSign(block);
eworld.sign.add(block);
Block block = editWorld.world.getBlockAt(x, y, z);
editWorld.checkSign(block);
editWorld.sign.add(block);
}
os.close();
@ -195,7 +195,7 @@ public class EditWorld {
e.printStackTrace();
}
return eworld;
return editWorld;
}
return null;
@ -203,8 +203,8 @@ public class EditWorld {
public static boolean exist(String name) {
// Cheack Loaded EditWorlds
for (EditWorld eworld : plugin.getEditWorlds()) {
if (eworld.dungeonname.equalsIgnoreCase(name)) {
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.mapName.equalsIgnoreCase(name)) {
return true;
}
}
@ -221,14 +221,14 @@ public class EditWorld {
public void msg(String msg) {
for (DPlayer dplayer : DPlayer.get(world)) {
MessageUtil.sendMessage(dplayer.player, msg);
MessageUtil.sendMessage(dplayer.getPlayer(), msg);
}
}
// Invite
public static boolean addInvitedPlayer(String eworldname, UUID uuid) {
if (exist(eworldname)) {
WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + eworldname, "config.yml"));
public static boolean addInvitedPlayer(String editWorldname, UUID uuid) {
if (exist(editWorldname)) {
WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + editWorldname, "config.yml"));
config.addInvitedPlayer(uuid.toString());
config.save();
return true;
@ -237,20 +237,19 @@ public class EditWorld {
return false;
}
public static boolean removeInvitedPlayer(String eworldname, UUID uuid, String name) {
if (exist(eworldname)) {
WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + eworldname, "config.yml"));
public static boolean removeInvitedPlayer(String editWorldName, UUID uuid, String name) {
if (exist(editWorldName)) {
WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml"));
config.removeInvitedPlayers(uuid.toString(), name.toLowerCase());
config.save();
// Kick Player
EditWorld eworld = EditWorld.get(eworldname);
if (eworld != null) {
EditWorld editWorld = EditWorld.get(editWorldName);
if (editWorld != null) {
DPlayer player = DPlayer.get(name);
if (player != null) {
if (eworld.world.getPlayers().contains(player.player)) {
if (editWorld.world.getPlayers().contains(player.getPlayer())) {
player.leave();
}
}
@ -262,16 +261,139 @@ public class EditWorld {
return false;
}
public static boolean isInvitedPlayer(String eworldname, UUID uuid, String name) {
if (exist(eworldname)) {
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;
}
public static boolean isInvitedPlayer(String editWorldname, UUID uuid, String name) {
if ( !exist(editWorldname)) {
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,31 +263,33 @@ public class WorldConfig {
@SuppressWarnings("deprecation")
public void save() {
if (file != null) {
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
if (file == null) {
return;
}
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
// Messages
for (Integer msgs : this.msgs.keySet()) {
configFile.set("message." + msgs, this.msgs.get(msgs));
}
// Secure Objects
CopyOnWriteArrayList<Integer> secureObjectsids = new CopyOnWriteArrayList<Integer>();
for (Material mat : secureObjects) {
secureObjectsids.add(mat.getId());
}
configFile.set("secureObjects", secureObjectsids);
// Invited Players
configFile.set("invitedPlayers", invitedPlayers);
try {
configFile.save(file);
// Messages
for (Integer msgs : this.msgs.keySet()) {
configFile.set("message." + msgs, this.msgs.get(msgs));
}
// Secure Objects
CopyOnWriteArrayList<Integer> secureObjectsids = new CopyOnWriteArrayList<Integer>();
for (Material mat : secureObjects) {
secureObjectsids.add(mat.getId());
}
configFile.set("secureObjects", secureObjectsids);
// Invited Players
configFile.set("invitedPlayers", invitedPlayers);
try {
configFile.save(file);
} catch (IOException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}

View File

@ -18,58 +18,71 @@ import org.bukkit.inventory.ItemStack;
public class GameChest {
// Variables
public boolean isUsed = false;
public Chest chest;
public GameWorld gWorld;
public double moneyReward;
private boolean isUsed = false;
private Chest chest;
private GameWorld gameWorld;
private double moneyReward;
public GameChest(Block chest, GameWorld gWorld, double moneyReward) {
if (chest.getState() instanceof Chest) {
this.chest = (Chest) chest.getState();
this.gWorld = gWorld;
this.moneyReward = moneyReward;
gWorld.gameChests.add(this);
public GameChest(Block chest, GameWorld gameWorld, double moneyReward) {
if ( !(chest.getState() instanceof Chest)) {
return;
}
this.chest = (Chest) chest.getState();
this.gameWorld = gameWorld;
this.moneyReward = moneyReward;
gameWorld.getGameChests().add(this);
}
public void addTreasure(DGroup dgroup) {
if (dgroup != null) {
for (Player player : dgroup.getPlayers()) {
DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) {
dplayer.treasureMoney = dplayer.treasureMoney + moneyReward;
String msg = "";
for (ItemStack istack : chest.getInventory().getContents()) {
if (istack != null) {
dplayer.treasureInv.addItem(istack);
String name;
if (istack.hasItemMeta() && istack.getItemMeta().hasDisplayName()) {
name = istack.getItemMeta().getDisplayName();
} else {
ItemInfo itemInfo = Items.itemByStack(istack);
if (itemInfo != null) {
name = itemInfo.getName();
} else {
name = istack.getType().name();
}
}
msg = msg + ChatColor.RED + " " + istack.getAmount() + " " + name + ChatColor.GOLD + ",";
}
}
public void addTreasure(DGroup dGroup) {
if (dGroup == null) {
return;
}
for (Player player : dGroup.getPlayers()) {
DPlayer dplayer = DPlayer.get(player);
if (dplayer == null) {
continue;
}
dplayer.setTreasureMoney(dplayer.getTreasureMoney() + moneyReward);
String msg = "";
for (ItemStack itemStack : chest.getInventory().getContents()) {
if (itemStack == null) {
continue;
}
dplayer.getTreasureInv().addItem(itemStack);
String name;
if ( !itemStack.hasItemMeta()) {
continue;
}
if (itemStack.getItemMeta().hasDisplayName()) {
name = itemStack.getItemMeta().getDisplayName();
msg = msg.substring(0, msg.length() - 1);
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_LootAdded", msg));
if (moneyReward != 0) {
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_LootAdded", String.valueOf(moneyReward)));
} else {
ItemInfo itemInfo = Items.itemByStack(itemStack);
if (itemInfo != null) {
name = itemInfo.getName();
} else {
name = itemStack.getType().name();
}
}
msg = msg + ChatColor.RED + " " + itemStack.getAmount() + " " + name + ChatColor.GOLD + ",";
}
msg = msg.substring(0, msg.length() - 1);
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_LootAdded", msg));
if (moneyReward != 0) {
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_LootAdded", String.valueOf(moneyReward)));
}
}
}
@ -78,30 +91,95 @@ public class GameChest {
public static void onOpenInventory(InventoryOpenEvent event) {
InventoryView inventory = event.getView();
GameWorld gWorld = GameWorld.get(event.getPlayer().getWorld());
GameWorld gameWorld = GameWorld.get(event.getPlayer().getWorld());
if (gWorld != null) {
if (inventory.getTopInventory().getHolder() instanceof Chest) {
Chest chest = (Chest) inventory.getTopInventory().getHolder();
for (GameChest gchest : gWorld.gameChests) {
if (gchest.chest.equals(chest)) {
if ( !gchest.isUsed) {
if (gchest.chest.getLocation().distance(chest.getLocation()) < 1) {
gchest.addTreasure(DGroup.get(gWorld));
gchest.isUsed = true;
event.setCancelled(true);
}
} else {
MessageUtil.sendMessage(DungeonsXL.getPlugin().getServer().getPlayer(event.getPlayer().getUniqueId()), DungeonsXL.getPlugin().getDMessages().get("Error_ChestIsOpened"));
event.setCancelled(true);
}
}
}
if (gameWorld == null) {
return;
}
if (inventory.getTopInventory().getHolder() instanceof Chest) {
return;
}
Chest chest = (Chest) inventory.getTopInventory().getHolder();
for (GameChest gameChest : gameWorld.getGameChests()) {
if ( !gameChest.chest.equals(chest)) {
continue;
}
if ( !gameChest.isUsed) {
MessageUtil.sendMessage(DungeonsXL.getPlugin().getServer().getPlayer(event.getPlayer().getUniqueId()), DungeonsXL.getPlugin().getDMessages().get("Error_ChestIsOpened"));
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

@ -30,7 +30,7 @@ public class GamePlaceableBlock {
String[] splittedIds = ids.split(",");
for (String id : splittedIds) {
@SuppressWarnings("deprecation")
Material mat = Material.getMaterial(IntegerUtil.parseInt(id));
Material mat = Material.getMaterial(IntegerUtil.parseInt(id));
if (mat != null) {
mats.add(mat);
}
@ -42,151 +42,192 @@ public class GamePlaceableBlock {
for (int direction = 0; direction < 6; direction++) {
boolean positive = String.valueOf(directions.charAt(direction)).equals("x");
if (positive) {
if (direction == 0) {
onTop = true;
}
if (direction == 1) {
onBottom = true;
if ( !positive) {
continue;
}
if (direction == 0) {
onTop = true;
}
if (direction == 1) {
onBottom = true;
}
if (block.getType() == Material.WALL_SIGN) {
@SuppressWarnings("deprecation")
int data = block.getData();
switch (data) {
case 3:
if (direction == 2) {
onNorth = true;
}
if (direction == 3) {
onEast = true;
}
if (direction == 4) {
onSouth = true;
}
if (direction == 5) {
onWest = true;
}
break;
case 4:
if (direction == 5) {
onNorth = true;
}
if (direction == 2) {
onEast = true;
}
if (direction == 3) {
onSouth = true;
}
if (direction == 4) {
onWest = true;
}
break;
case 2:
if (direction == 4) {
onNorth = true;
}
if (direction == 5) {
onEast = true;
}
if (direction == 2) {
onSouth = true;
}
if (direction == 3) {
onWest = true;
}
break;
case 5:
if (direction == 3) {
onNorth = true;
}
if (direction == 4) {
onEast = true;
}
if (direction == 5) {
onSouth = true;
}
if (direction == 2) {
onWest = true;
}
break;
}
if (block.getType() == Material.WALL_SIGN) {
@SuppressWarnings("deprecation")
int data = block.getData();
switch (data) {
case 3:
if (direction == 2) {
onNorth = true;
}
if (direction == 3) {
onEast = true;
}
if (direction == 4) {
onSouth = true;
}
if (direction == 5) {
onWest = true;
}
break;
case 4:
if (direction == 5) {
onNorth = true;
}
if (direction == 2) {
onEast = true;
}
if (direction == 3) {
onSouth = true;
}
if (direction == 4) {
onWest = true;
}
break;
case 2:
if (direction == 4) {
onNorth = true;
}
if (direction == 5) {
onEast = true;
}
if (direction == 2) {
onSouth = true;
}
if (direction == 3) {
onWest = true;
}
break;
case 5:
if (direction == 3) {
onNorth = true;
}
if (direction == 4) {
onEast = true;
}
if (direction == 5) {
onSouth = true;
}
if (direction == 2) {
onWest = true;
}
break;
}
} else {
@SuppressWarnings("deprecation")
int data = block.getData();
switch (data) {
case 0:
case 1:
case 2:
case 15:
if (direction == 2) {
onNorth = true;
}
if (direction == 3) {
onEast = true;
}
if (direction == 4) {
onSouth = true;
}
if (direction == 5) {
onWest = true;
}
break;
case 4:
case 3:
case 5:
case 6:
if (direction == 5) {
onNorth = true;
}
if (direction == 2) {
onEast = true;
}
if (direction == 3) {
onSouth = true;
}
if (direction == 4) {
onWest = true;
}
break;
case 8:
case 7:
case 9:
case 10:
if (direction == 4) {
onNorth = true;
}
if (direction == 5) {
onEast = true;
}
if (direction == 2) {
onSouth = true;
}
if (direction == 3) {
onWest = true;
}
break;
case 12:
case 11:
case 13:
case 14:
if (direction == 3) {
onNorth = true;
}
if (direction == 4) {
onEast = true;
}
if (direction == 5) {
onSouth = true;
}
if (direction == 2) {
onWest = true;
}
break;
}
} else {
@SuppressWarnings("deprecation")
int data = block.getData();
switch (data) {
case 0:
case 1:
case 2:
case 15:
if (direction == 2) {
onNorth = true;
}
if (direction == 3) {
onEast = true;
}
if (direction == 4) {
onSouth = true;
}
if (direction == 5) {
onWest = true;
}
break;
case 4:
case 3:
case 5:
case 6:
if (direction == 5) {
onNorth = true;
}
if (direction == 2) {
onEast = true;
}
if (direction == 3) {
onSouth = true;
}
if (direction == 4) {
onWest = true;
}
break;
case 8:
case 7:
case 9:
case 10:
if (direction == 4) {
onNorth = true;
}
if (direction == 5) {
onEast = true;
}
if (direction == 2) {
onSouth = true;
}
if (direction == 3) {
onWest = true;
}
break;
case 12:
case 11:
case 13:
case 14:
if (direction == 3) {
onNorth = true;
}
if (direction == 4) {
onEast = true;
}
if (direction == 5) {
onSouth = true;
}
if (direction == 2) {
onWest = true;
}
break;
}
}
}
} else {
onTop = true;
onBottom = true;
@ -198,31 +239,42 @@ public class GamePlaceableBlock {
}
// Canbuild
public static boolean canBuildHere(Block block, BlockFace blockFace, Material mat, GameWorld gWorld) {
for (GamePlaceableBlock gPBlock : gWorld.placeableBlocks) {
if (gPBlock.block.getFace(block) == BlockFace.SELF) {
if (gPBlock.mats.contains(mat) || gPBlock.mats.isEmpty()) {
if (blockFace == BlockFace.NORTH && gPBlock.onNorth) {
return true;
}
if (blockFace == BlockFace.SOUTH && gPBlock.onSouth) {
return true;
}
if (blockFace == BlockFace.EAST && gPBlock.onEast) {
return true;
}
if (blockFace == BlockFace.WEST && gPBlock.onWest) {
return true;
}
if (blockFace == BlockFace.UP && gPBlock.onTop) {
return true;
}
if (blockFace == BlockFace.DOWN && gPBlock.onBottom) {
return true;
}
}
public static boolean canBuildHere(Block block, BlockFace blockFace, Material mat, GameWorld gameWorld) {
for (GamePlaceableBlock gPBlock : gameWorld.getPlaceableBlocks()) {
if (gPBlock.block.getFace(block) != BlockFace.SELF) {
continue;
}
if ( !(gPBlock.mats.contains(mat) || gPBlock.mats.isEmpty())) {
continue;
}
if (blockFace == BlockFace.NORTH && gPBlock.onNorth) {
return true;
}
if (blockFace == BlockFace.SOUTH && gPBlock.onSouth) {
return true;
}
if (blockFace == BlockFace.EAST && gPBlock.onEast) {
return true;
}
if (blockFace == BlockFace.WEST && gPBlock.onWest) {
return true;
}
if (blockFace == BlockFace.UP && gPBlock.onTop) {
return true;
}
if (blockFace == BlockFace.DOWN && gPBlock.onBottom) {
return true;
}
}
return false;
}
}

View File

@ -39,22 +39,22 @@ public class GameWorld {
static DungeonsXL plugin = DungeonsXL.getPlugin();
// Variables placeable
public boolean isTutorial;
private boolean isTutorial;
public CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks = new CopyOnWriteArrayList<GamePlaceableBlock>();
public World world;
public String dungeonname;
public Location locLobby;
public Location locStart;
public boolean isPlaying = false;
public int id;
public CopyOnWriteArrayList<Material> secureObjects = new CopyOnWriteArrayList<Material>();
public CopyOnWriteArrayList<Chunk> loadedChunks = new CopyOnWriteArrayList<Chunk>();
private CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks = new CopyOnWriteArrayList<GamePlaceableBlock>();
private World world;
private String mapName;
private Location locLobby;
private Location locStart;
private boolean isPlaying = false;
private int id;
private CopyOnWriteArrayList<Material> secureObjects = new CopyOnWriteArrayList<Material>();
private CopyOnWriteArrayList<Chunk> loadedChunks = new CopyOnWriteArrayList<Chunk>();
public CopyOnWriteArrayList<Sign> signClass = new CopyOnWriteArrayList<Sign>();
public CopyOnWriteArrayList<DMob> dMobs = new CopyOnWriteArrayList<DMob>();
public CopyOnWriteArrayList<GameChest> gameChests = new CopyOnWriteArrayList<GameChest>();
public CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<DSign>();
private CopyOnWriteArrayList<Sign> signClass = new CopyOnWriteArrayList<Sign>();
private CopyOnWriteArrayList<DMob> dMobs = new CopyOnWriteArrayList<DMob>();
private CopyOnWriteArrayList<GameChest> gameChests = new CopyOnWriteArrayList<GameChest>();
private CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<DSign>();
private WorldConfig worldConfig;
public GameWorld() {
@ -66,8 +66,8 @@ public class GameWorld {
while (id == -1) {
i++;
boolean exist = false;
for (GameWorld gWorld : plugin.getGameWorlds()) {
if (gWorld.id == i) {
for (GameWorld gameWorld : plugin.getGameWorlds()) {
if (gameWorld.id == i) {
exist = true;
break;
}
@ -90,7 +90,7 @@ public class GameWorld {
for (DSign dSign : dSigns) {
if (dSign != null) {
if ( !dSign.isOnDungeonInit()) {
if ( !dSign.getType().isOnDungeonInit()) {
dSign.onInit();
}
}
@ -111,10 +111,220 @@ public class GameWorld {
public void msg(String msg) {
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
*/
@ -147,9 +357,9 @@ public class GameWorld {
// Statics
public static GameWorld get(World world) {
for (GameWorld gWorld : plugin.getGameWorlds()) {
if (gWorld.world.equals(world)) {
return gWorld;
for (GameWorld gameWorld : plugin.getGameWorlds()) {
if (gameWorld.world.equals(world)) {
return gameWorld;
}
}
@ -157,8 +367,8 @@ public class GameWorld {
}
public static void deleteAll() {
for (GameWorld gWorld : plugin.getGameWorlds()) {
gWorld.delete();
for (GameWorld gameWorld : plugin.getGameWorlds()) {
gameWorld.delete();
}
}
@ -197,7 +407,7 @@ public class GameWorld {
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())) {
return false;
}
@ -289,46 +499,46 @@ public class GameWorld {
File file = new File(plugin.getDataFolder(), "/maps/" + name);
if (file.exists()) {
GameWorld gWorld = new GameWorld();
gWorld.dungeonname = name;
GameWorld gameWorld = new GameWorld();
gameWorld.mapName = name;
// Unload empty eworlds
for (EditWorld eworld : plugin.getEditWorlds()) {
if (eworld.world.getPlayers().isEmpty()) {
if (eworld.getWorld().getPlayers().isEmpty()) {
eworld.delete();
}
}
// 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
gWorld.secureObjects = gWorld.worldConfig.getSecureObjects();
gameWorld.secureObjects = gameWorld.worldConfig.getSecureObjects();
// World
FileUtil.copyDirectory(file, new File("DXL_Game_" + gWorld.id));
FileUtil.copyDirectory(file, new File("DXL_Game_" + gameWorld.id));
// Id File
File idFile = new File("DXL_Game_" + gWorld.id + "/.id_" + name);
File idFile = new File("DXL_Game_" + gameWorld.id + "/.id_" + name);
try {
idFile.createNewFile();
} catch (IOException e) {
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;
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();
for (int i = 0; i < length; i++) {
int x = os.readInt();
int y = os.readInt();
int z = os.readInt();
Block block = gWorld.world.getBlockAt(x, y, z);
gWorld.checkSign(block);
Block block = gameWorld.world.getBlockAt(x, y, z);
gameWorld.checkSign(block);
}
os.close();
@ -338,16 +548,16 @@ public class GameWorld {
e.printStackTrace();
}
return gWorld;
return gameWorld;
}
return null;
}
public static void update() {
for (GameWorld gWorld : plugin.getGameWorlds()) {
for (GameWorld gameWorld : plugin.getGameWorlds()) {
// Update Spiders
for (LivingEntity mob : gWorld.world.getLivingEntities()) {
for (LivingEntity mob : gameWorld.world.getLivingEntities()) {
if (mob.getType() == EntityType.SPIDER || mob.getType() == EntityType.CAVE_SPIDER) {
Spider spider = (Spider) mob;
if (spider.getTarget() != null) {

View File

@ -35,7 +35,6 @@ public class DMessages {
}
private void setDefaults() {
/* Log */
defaults.put("Log_NewDungeon", "&6New Dungeon");
defaults.put("Log_GenerateNewWorld", "&6Generate new world...");
@ -147,45 +146,52 @@ public class DMessages {
}
public void save() {
if (changed) {
/* Copy old File */
File source = new File(file.getPath());
String filePath = file.getPath();
File temp = new File(filePath.substring(0, filePath.length() - 4) + "_old.yml");
if ( !changed) {
return;
}
/* Copy old File */
File source = new File(file.getPath());
String filePath = file.getPath();
File temp = new File(filePath.substring(0, filePath.length() - 4) + "_old.yml");
if (temp.exists()) {
temp.delete();
}
source.renameTo(temp);
/* Save */
FileConfiguration configFile = new YamlConfiguration();
for (String key : entries.keySet()) {
configFile.set(key, entries.get(key));
}
try {
configFile.save(file);
if (temp.exists()) {
temp.delete();
}
source.renameTo(temp);
/* Save */
FileConfiguration configFile = new YamlConfiguration();
for (String key : entries.keySet()) {
configFile.set(key, entries.get(key));
}
try {
configFile.save(file);
} catch (IOException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}
public String get(String key, String... args) {
String entry = entries.get(key);
if (entry != null) {
int i = 0;
for (String arg : args) {
i++;
if (arg != null) {
entry = entry.replace("&v" + i, arg);
} else {
entry = entry.replace("&v" + i, "null");
}
if (entry == null) {
return entry;
}
int i = 0;
for (String arg : args) {
i++;
if (arg != null) {
entry = entry.replace("&v" + i, arg);
} else {
entry = entry.replace("&v" + i, "null");
}
}

View File

@ -31,84 +31,10 @@ public class DPortal {
public void create() {
player = null;
if (block1 != null && block2 != null) {
int x1 = block1.getX(), y1 = block1.getY(), z1 = block1.getZ();
int x2 = block2.getX(), y2 = block2.getY(), z2 = block2.getZ();
int xcount = 0, ycount = 0, zcount = 0;
if (x1 > x2) {
xcount = -1;
} else if (x1 < x2) {
xcount = 1;
}
if (y1 > y2) {
ycount = -1;
} else if (y1 < y2) {
ycount = 1;
}
if (z1 > z2) {
zcount = -1;
} else if (z1 < z2) {
zcount = 1;
}
int xx = x1;
do {
int yy = y1;
do {
int zz = z1;
do {
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
|| type == Material.SAPLING || type == Material.WEB || type == Material.LONG_GRASS || type == Material.DEAD_BUSH || type == Material.PISTON_EXTENSION
|| type == Material.YELLOW_FLOWER || type == Material.RED_ROSE || type == Material.BROWN_MUSHROOM || type == Material.RED_MUSHROOM || type == Material.TORCH
|| type == Material.FIRE || type == Material.CROPS || type == Material.REDSTONE_WIRE || type == Material.REDSTONE_TORCH_OFF || type == Material.SNOW
|| type == Material.REDSTONE_TORCH_ON) {
world.getBlockAt(xx, yy, zz).setType(Material.PORTAL);
}
zz = zz + zcount;
} while (zz != z2 + zcount);
yy = yy + ycount;
} while (yy != y2 + ycount);
xx = xx + xcount;
} while (xx != x2 + xcount);
} else {
if (block1 == null || block2 == null) {
plugin.getDPortals().remove(this);
return;
}
}
public void teleport(Player player) {
DGroup dgroup = DGroup.get(player);
if (dgroup != null) {
if (dgroup.getGWorld() == null) {
dgroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName()));
}
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()));
}
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInGroup"));
}
}
public void delete() {
plugin.getDPortals().remove(this);
int x1 = block1.getX(), y1 = block1.getY(), z1 = block1.getZ();
int x2 = block2.getX(), y2 = block2.getY(), z2 = block2.getZ();
@ -130,6 +56,80 @@ public class DPortal {
zcount = 1;
}
int xx = x1;
do {
int yy = y1;
do {
int zz = z1;
do {
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 || type == Material.SAPLING
|| type == Material.WEB || type == Material.LONG_GRASS || type == Material.DEAD_BUSH || type == Material.PISTON_EXTENSION || type == Material.YELLOW_FLOWER
|| type == Material.RED_ROSE || type == Material.BROWN_MUSHROOM || type == Material.RED_MUSHROOM || type == Material.TORCH || type == Material.FIRE
|| type == Material.CROPS || type == Material.REDSTONE_WIRE || type == Material.REDSTONE_TORCH_OFF || type == Material.SNOW || type == Material.REDSTONE_TORCH_ON) {
world.getBlockAt(xx, yy, zz).setType(Material.PORTAL);
}
zz = zz + zcount;
} while (zz != z2 + zcount);
yy = yy + ycount;
} while (yy != y2 + ycount);
xx = xx + xcount;
} while (xx != x2 + xcount);
}
public void teleport(Player player) {
DGroup dgroup = DGroup.get(player);
if (dgroup == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInGroup"));
}
if (dgroup.getGWorld() == null) {
dgroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName()));
}
if (dgroup.getGWorld() == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_DungeonNotExist", DGroup.get(player).getMapName()));
}
if (dgroup.getGWorld().getLocLobby() == null) {
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() {
plugin.getDPortals().remove(this);
int x1 = block1.getX(), y1 = block1.getY(), z1 = block1.getZ();
int x2 = block2.getX(), y2 = block2.getY(), z2 = block2.getZ();
int xcount = 0, ycount = 0, zcount = 0;
if (x1 > x2) {
xcount = -1;
} else if (x1 < x2) {
xcount = 1;
}
if (y1 > y2) {
ycount = -1;
} else if (y1 < y2) {
ycount = 1;
}
if (z1 > z2) {
zcount = -1;
} else if (z1 < z2) {
zcount = 1;
}
int xx = x1;
do {
int yy = y1;
@ -167,6 +167,7 @@ public class DPortal {
if (x3 < x2 || x3 > x1) {
continue;
}
} else {
if (x3 > x2 || x3 < x1) {
continue;
@ -177,6 +178,7 @@ public class DPortal {
if (y3 < y2 || y3 > y1) {
continue;
}
} else {
if (y3 > y2 || y3 < y1) {
continue;
@ -205,6 +207,7 @@ public class DPortal {
return portal;
}
}
return null;
}
@ -213,37 +216,44 @@ public class DPortal {
int id = 0;
for (DPortal dportal : plugin.getDPortals()) {
id++;
if (dportal.isActive) {
String preString = "portal." + dportal.world.getName() + "." + id;
// Location1
configFile.set(preString + ".loc1.x", dportal.block1.getX());
configFile.set(preString + ".loc1.y", dportal.block1.getY());
configFile.set(preString + ".loc1.z", dportal.block1.getZ());
// Location1
configFile.set(preString + ".loc2.x", dportal.block2.getX());
configFile.set(preString + ".loc2.y", dportal.block2.getY());
configFile.set(preString + ".loc2.z", dportal.block2.getZ());
if ( !dportal.isActive) {
continue;
}
String preString = "portal." + dportal.world.getName() + "." + id;
// Location1
configFile.set(preString + ".loc1.x", dportal.block1.getX());
configFile.set(preString + ".loc1.y", dportal.block1.getY());
configFile.set(preString + ".loc1.z", dportal.block1.getZ());
// Location1
configFile.set(preString + ".loc2.x", dportal.block2.getX());
configFile.set(preString + ".loc2.y", dportal.block2.getY());
configFile.set(preString + ".loc2.z", dportal.block2.getZ());
}
}
public static void load(FileConfiguration configFile) {
for (World world : plugin.getServer().getWorlds()) {
if (configFile.contains("portal." + world.getName())) {
int id = 0;
String preString;
do {
id++;
preString = "portal." + world.getName() + "." + id + ".";
if (configFile.contains(preString)) {
DPortal dportal = new DPortal(true);
dportal.world = world;
dportal.block1 = world.getBlockAt(configFile.getInt(preString + "loc1.x"), configFile.getInt(preString + "loc1.y"), configFile.getInt(preString + "loc1.z"));
dportal.block2 = world.getBlockAt(configFile.getInt(preString + "loc2.x"), configFile.getInt(preString + "loc2.y"), configFile.getInt(preString + "loc2.z"));
dportal.create();
}
} while (configFile.contains(preString));
if ( !configFile.contains("portal." + world.getName())) {
return;
}
int id = 0;
String preString;
do {
id++;
preString = "portal." + world.getName() + "." + id + ".";
if (configFile.contains(preString)) {
DPortal dportal = new DPortal(true);
dportal.world = world;
dportal.block1 = world.getBlockAt(configFile.getInt(preString + "loc1.x"), configFile.getInt(preString + "loc1.y"), configFile.getInt(preString + "loc1.z"));
dportal.block2 = world.getBlockAt(configFile.getInt(preString + "loc2.x"), configFile.getInt(preString + "loc2.y"), configFile.getInt(preString + "loc2.z"));
dportal.create();
}
} while (configFile.contains(preString));
}
}

View File

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

View File

@ -38,37 +38,21 @@ public class LeaveSign {
LeaveSign lsign = getSign(block);
if (lsign != null) {
DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) {
dplayer.leave();
return true;
} else {
DGroup dgroup = DGroup.get(player);
if (dgroup != null) {
dgroup.removePlayer(player);
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_LeaveGroup"));// ChatColor.YELLOW+"Du hast deine Gruppe erfolgreich verlassen!");
return true;
}
}
if (lsign == null) {
return false;
}
return false;
}
@SuppressWarnings("deprecation")
public static boolean isRelativeSign(Block block, int x, int z) {
LeaveSign lsign = getSign(block.getRelative(x, 0, z));
if (lsign != null) {
if (x == -1 && lsign.sign.getData().getData() == 4) {
return true;
}
if (x == 1 && lsign.sign.getData().getData() == 5) {
return true;
}
if (z == -1 && lsign.sign.getData().getData() == 2) {
return true;
}
if (z == 1 && lsign.sign.getData().getData() == 3) {
DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) {
dplayer.leave();
return true;
} else {
DGroup dgroup = DGroup.get(player);
if (dgroup != null) {
dgroup.removePlayer(player);
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_LeaveGroup"));// ChatColor.YELLOW+"Du hast deine Gruppe erfolgreich verlassen!");
return true;
}
}
@ -76,16 +60,47 @@ public class LeaveSign {
return false;
}
@SuppressWarnings("deprecation")
public static boolean isRelativeSign(Block block, int x, int z) {
LeaveSign lsign = getSign(block.getRelative(x, 0, z));
if (lsign == null) {
return false;
}
if (x == -1 && lsign.sign.getData().getData() == 4) {
return true;
}
if (x == 1 && lsign.sign.getData().getData() == 5) {
return true;
}
if (z == -1 && lsign.sign.getData().getData() == 2) {
return true;
}
if (z == 1 && lsign.sign.getData().getData() == 3) {
return true;
}
return false;
}
public static LeaveSign getSign(Block block) {
if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) {
for (LeaveSign leavesign : plugin.getLeaveSigns()) {
if (block.getWorld() == leavesign.sign.getWorld()) {
if (block.getLocation().distance(leavesign.sign.getBlock().getLocation()) < 1) {
return leavesign;
}
}
if ( !(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST)) {
return null;
}
for (LeaveSign leavesign : plugin.getLeaveSigns()) {
if (block.getWorld() != leavesign.sign.getWorld()) {
continue;
}
if (block.getLocation().distance(leavesign.sign.getBlock().getLocation()) < 1) {
return leavesign;
}
}
return null;
}
@ -103,21 +118,25 @@ public class LeaveSign {
public static void load(FileConfiguration configFile) {
for (World world : DungeonsXL.getPlugin().getServer().getWorlds()) {
if (configFile.contains("leavesign." + world.getName())) {
int id = 0;
String preString;
do {
id++;
preString = "leavesign." + world.getName() + "." + id + ".";
if (configFile.contains(preString)) {
Block block = world.getBlockAt(configFile.getInt(preString + ".x"), configFile.getInt(preString + ".y"), configFile.getInt(preString + ".z"));
if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState();
new LeaveSign(sign);
}
}
} while (configFile.contains(preString));
if ( !configFile.contains("leavesign." + world.getName())) {
continue;
}
int id = 0;
String preString;
do {
id++;
preString = "leavesign." + world.getName() + "." + id + ".";
if (configFile.contains(preString)) {
Block block = world.getBlockAt(configFile.getInt(preString + ".x"), configFile.getInt(preString + ".y"), configFile.getInt(preString + ".z"));
if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState();
new LeaveSign(sign);
}
}
} while (configFile.contains(preString));
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -48,177 +48,184 @@ public class DMobType {
}
public void spawn(GameWorld gWorld, Location loc) {
if (type != null) {
if (type.isAlive()) {
LivingEntity entity = (LivingEntity) gWorld.world.spawnEntity(loc, type);
/* Set the Items */
entity.getEquipment().setItemInHand(ItemHand);
entity.getEquipment().setHelmet(ItemHelmet);
entity.getEquipment().setChestplate(ItemChestplate);
entity.getEquipment().setLeggings(ItemLeggings);
entity.getEquipment().setBoots(ItemBoots);
/* Check mob specified stuff */
if (type == EntityType.SKELETON) {
if (isWitherSkeleton) {
((Skeleton) entity).setSkeletonType(SkeletonType.WITHER);
} else {
((Skeleton) entity).setSkeletonType(SkeletonType.NORMAL);
}
}
if (type == EntityType.OCELOT) {
Ocelot ocelot = (Ocelot) entity;
if (ocelotType != null) {
if (ocelotType.equalsIgnoreCase("BLACK_CAT")) {
ocelot.setCatType(Ocelot.Type.BLACK_CAT);
} else if (ocelotType.equalsIgnoreCase("RED_CAT")) {
ocelot.setCatType(Ocelot.Type.RED_CAT);
} else if (ocelotType.equalsIgnoreCase("SIAMESE_CAT")) {
ocelot.setCatType(Ocelot.Type.SIAMESE_CAT);
} else if (ocelotType.equalsIgnoreCase("WILD_OCELOT")) {
ocelot.setCatType(Ocelot.Type.WILD_OCELOT);
}
}
}
/* Set Health */
if (maxHealth > 0) {
entity.setMaxHealth(maxHealth);
entity.setHealth(maxHealth);
}
/* Disable Despawning */
entity.setRemoveWhenFarAway(false);
/* Spawn Mob */
new DMob(entity, gWorld, this);
if (type == null) {
return;
}
if ( !type.isAlive()) {
return;
}
LivingEntity entity = (LivingEntity) gWorld.getWorld().spawnEntity(loc, type);
/* Set the Items */
entity.getEquipment().setItemInHand(ItemHand);
entity.getEquipment().setHelmet(ItemHelmet);
entity.getEquipment().setChestplate(ItemChestplate);
entity.getEquipment().setLeggings(ItemLeggings);
entity.getEquipment().setBoots(ItemBoots);
/* Check mob specified stuff */
if (type == EntityType.SKELETON) {
if (isWitherSkeleton) {
((Skeleton) entity).setSkeletonType(SkeletonType.WITHER);
} else {
((Skeleton) entity).setSkeletonType(SkeletonType.NORMAL);
}
}
if (type == EntityType.OCELOT) {
Ocelot ocelot = (Ocelot) entity;
if (ocelotType != null) {
if (ocelotType.equalsIgnoreCase("BLACK_CAT")) {
ocelot.setCatType(Ocelot.Type.BLACK_CAT);
} else if (ocelotType.equalsIgnoreCase("RED_CAT")) {
ocelot.setCatType(Ocelot.Type.RED_CAT);
} else if (ocelotType.equalsIgnoreCase("SIAMESE_CAT")) {
ocelot.setCatType(Ocelot.Type.SIAMESE_CAT);
} else if (ocelotType.equalsIgnoreCase("WILD_OCELOT")) {
ocelot.setCatType(Ocelot.Type.WILD_OCELOT);
}
}
}
/* Set Health */
if (maxHealth > 0) {
entity.setMaxHealth(maxHealth);
entity.setHealth(maxHealth);
}
/* Disable Despawning */
entity.setRemoveWhenFarAway(false);
/* Spawn Mob */
new DMob(entity, gWorld, this);
}
// Load Config
@SuppressWarnings("deprecation")
public static Set<DMobType> load(ConfigurationSection configFile) {
Set<DMobType> set = new HashSet<DMobType>();
if (configFile != null) {
// Read Mobs
for (String mobName : configFile.getKeys(false)) {
EntityType type = EntityType.fromName(configFile.getString(mobName + ".Type"));
if (type != null) {
DMobType mobType = new DMobType(mobName, type);
set.add(mobType);
if (configFile == null) {
return null;
}
// Read Mobs
for (String mobName : configFile.getKeys(false)) {
EntityType type = EntityType.fromName(configFile.getString(mobName + ".Type"));
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);
set.add(mobType);
// Load MaxHealth
if (configFile.contains(mobName + ".MaxHealth")) {
mobType.maxHealth = configFile.getInt(mobName + ".MaxHealth");
}
// Load Items
if (configFile.contains(mobName + ".ItemHelmet")) {
mobType.ItemHelmet = new ItemStack(configFile.getInt(mobName + ".ItemHelmet"));// CraftItemStack.asNMSCopy(new
// ItemStack(configFile.getInt(mobName+".ItemHelmet"))).getItem();
}
if (configFile.contains(mobName + ".ItemChestplate")) {
mobType.ItemChestplate = new ItemStack(configFile.getInt(mobName + ".ItemChestplate"));// CraftItemStack.asNMSCopy(new
// ItemStack(configFile.getInt(mobName+".ItemChestplate"))).getItem();
}
if (configFile.contains(mobName + ".ItemBoots")) {
mobType.ItemBoots = new ItemStack(configFile.getInt(mobName + ".ItemBoots"));// CraftItemStack.asNMSCopy(new
// ItemStack(configFile.getInt(mobName+".ItemBoots"))).getItem();
}
if (configFile.contains(mobName + ".ItemLeggings")) {
mobType.ItemLeggings = new ItemStack(configFile.getInt(mobName + ".ItemLeggings"));// CraftItemStack.asNMSCopy(new
// ItemStack(configFile.getInt(mobName+".ItemLeggings"))).getItem();
}
if (configFile.contains(mobName + ".ItemHand")) {
mobType.ItemHand = new ItemStack(configFile.getInt(mobName + ".ItemHand"));// CraftItemStack.asNMSCopy(new
// ItemStack(configFile.getInt(mobName+".ItemHand"))).getItem();
}
// Load different Mob options
if (configFile.contains(mobName + ".isWitherSkeleton")) {
mobType.isWitherSkeleton = configFile.getBoolean(mobName + ".isWitherSkeleton");
}
if (configFile.contains(mobName + ".ocelotType")) {
mobType.ocelotType = configFile.getString(mobName + ".ocelotType");
}
// Drops
ConfigurationSection configSetion = configFile.getConfigurationSection(mobName + ".drops");
if (configSetion != null) {
Set<String> list = configSetion.getKeys(false);
for (String dropPath : list) {
ItemStack item = null;
ItemMeta itemMeta = null;
int chance = 100;
// Load MaxHealth
if (configFile.contains(mobName + ".MaxHealth")) {
mobType.maxHealth = configFile.getInt(mobName + ".MaxHealth");
/* Item Stack */
Material mat = Material.getMaterial(configSetion.getInt(dropPath + ".id"));
int amount = 1;
short data = 0;
if (configSetion.contains(dropPath + ".amount")) {
amount = configSetion.getInt(dropPath + ".amount");
}
if (configSetion.contains(dropPath + ".data")) {
data = Short.parseShort(configSetion.getString(dropPath + ".data"));
}
// Load Items
if (configFile.contains(mobName + ".ItemHelmet")) {
mobType.ItemHelmet = new ItemStack(configFile.getInt(mobName + ".ItemHelmet"));// CraftItemStack.asNMSCopy(new
// ItemStack(configFile.getInt(mobName+".ItemHelmet"))).getItem();
}
item = new ItemStack(mat, amount, data);
itemMeta = item.getItemMeta();
if (configFile.contains(mobName + ".ItemChestplate")) {
mobType.ItemChestplate = new ItemStack(configFile.getInt(mobName + ".ItemChestplate"));// CraftItemStack.asNMSCopy(new
// ItemStack(configFile.getInt(mobName+".ItemChestplate"))).getItem();
}
if (configFile.contains(mobName + ".ItemBoots")) {
mobType.ItemBoots = new ItemStack(configFile.getInt(mobName + ".ItemBoots"));// CraftItemStack.asNMSCopy(new
// ItemStack(configFile.getInt(mobName+".ItemBoots"))).getItem();
}
if (configFile.contains(mobName + ".ItemLeggings")) {
mobType.ItemLeggings = new ItemStack(configFile.getInt(mobName + ".ItemLeggings"));// CraftItemStack.asNMSCopy(new
// ItemStack(configFile.getInt(mobName+".ItemLeggings"))).getItem();
}
if (configFile.contains(mobName + ".ItemHand")) {
mobType.ItemHand = new ItemStack(configFile.getInt(mobName + ".ItemHand"));// CraftItemStack.asNMSCopy(new
// ItemStack(configFile.getInt(mobName+".ItemHand"))).getItem();
}
// Load different Mob options
if (configFile.contains(mobName + ".isWitherSkeleton")) {
mobType.isWitherSkeleton = configFile.getBoolean(mobName + ".isWitherSkeleton");
}
if (configFile.contains(mobName + ".ocelotType")) {
mobType.ocelotType = configFile.getString(mobName + ".ocelotType");
}
// Drops
ConfigurationSection configSetion = configFile.getConfigurationSection(mobName + ".drops");
if (configSetion != null) {
Set<String> list = configSetion.getKeys(false);
for (String dropPath : list) {
ItemStack item = null;
ItemMeta itemMeta = null;
int chance = 100;
/* Item Stack */
Material mat = Material.getMaterial(configSetion.getInt(dropPath + ".id"));
int amount = 1;
short data = 0;
if (configSetion.contains(dropPath + ".amount")) {
amount = configSetion.getInt(dropPath + ".amount");
}
if (configSetion.contains(dropPath + ".data")) {
data = Short.parseShort(configSetion.getString(dropPath + ".data"));
}
item = new ItemStack(mat, amount, data);
itemMeta = item.getItemMeta();
/* Enchantments */
if (configSetion.contains(dropPath + ".enchantments")) {
for (String enchantment : configSetion.getStringList(dropPath + ".enchantments")) {
String[] splittedEnchantment = enchantment.split(" ");
if (Enchantment.getByName(splittedEnchantment[0].toUpperCase()) != null) {
if (splittedEnchantment.length > 1) {
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), IntegerUtil.parseInt(splittedEnchantment[1]), true);
} else {
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), 1, true);
}
} else {
DungeonsXL.getPlugin().getLogger().info(DungeonsXL.getPlugin().getDMessages().get("Log_Error_MobEnchantment", splittedEnchantment[0]));
}
/* Enchantments */
if (configSetion.contains(dropPath + ".enchantments")) {
for (String enchantment : configSetion.getStringList(dropPath + ".enchantments")) {
String[] splittedEnchantment = enchantment.split(" ");
if (Enchantment.getByName(splittedEnchantment[0].toUpperCase()) != null) {
if (splittedEnchantment.length > 1) {
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), IntegerUtil.parseInt(splittedEnchantment[1]), true);
} else {
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), 1, true);
}
} else {
DungeonsXL.getPlugin().getLogger().info(DungeonsXL.getPlugin().getDMessages().get("Log_Error_MobEnchantment", splittedEnchantment[0]));
}
/* Item Name */
if (configSetion.contains(dropPath + ".name")) {
itemMeta.setDisplayName(configSetion.getString(dropPath + ".name"));
}
/* Item Lore */
if (configSetion.contains(dropPath + ".lore")) {
String[] lore = configSetion.getString(dropPath + ".lore").split("//");
itemMeta.setLore(Arrays.asList(lore));
}
/* Drop chance */
if (configSetion.contains(dropPath + ".chance")) {
chance = configSetion.getInt(dropPath + ".chance");
}
/* Add Item to the drops map */
item.setItemMeta(itemMeta);
mobType.getDrops().put(item, chance);
}
}
} else {
DungeonsXL.getPlugin().getLogger().info(DungeonsXL.getPlugin().getDMessages().get("Log_Error_MobType", configFile.getString(mobName + ".Type")));
/* Item Name */
if (configSetion.contains(dropPath + ".name")) {
itemMeta.setDisplayName(configSetion.getString(dropPath + ".name"));
}
/* Item Lore */
if (configSetion.contains(dropPath + ".lore")) {
String[] lore = configSetion.getString(dropPath + ".lore").split("//");
itemMeta.setLore(Arrays.asList(lore));
}
/* Drop chance */
if (configSetion.contains(dropPath + ".chance")) {
chance = configSetion.getInt(dropPath + ".chance");
}
/* Add Item to the drops map */
item.setItemMeta(itemMeta);
mobType.getDrops().put(item, chance);
}
}
}
return set;
}

View File

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

View File

@ -38,37 +38,37 @@ public class DPlayer {
static DungeonsXL plugin = DungeonsXL.getPlugin();
// Variables
public Player player;
public World world;
private Player player;
private World world;
public boolean isinTestMode = false;
private boolean isInTestMode = false;
public DSavePlayer savePlayer;
private DSavePlayer savePlayer;
public boolean isEditing;
public boolean isInDungeonChat = false;
public boolean isReady = false;
public boolean isFinished = false;
private boolean isEditing;
private boolean isInDungeonChat = false;
private boolean isReady = false;
private boolean isFinished = false;
public DClass dclass;
public Location checkpoint;
public Wolf wolf;
public int wolfRespawnTime = 30;
public long offlineTime;
public ItemStack[] respawnInventory;
public ItemStack[] respawnArmor;
public String[] linesCopy;
private DClass dClass;
private Location checkpoint;
private Wolf wolf;
private int wolfRespawnTime = 30;
private long offlineTime;
private ItemStack[] respawnInventory;
private ItemStack[] respawnArmor;
private String[] linesCopy;
public Inventory treasureInv = DungeonsXL.getPlugin().getServer().createInventory(player, 45, plugin.getDMessages().get("Player_Treasures"));
public double treasureMoney = 0;
private Inventory treasureInv = DungeonsXL.getPlugin().getServer().createInventory(getPlayer(), 45, plugin.getDMessages().get("Player_Treasures"));
private double treasureMoney = 0;
public int initialLives = -1;
public int lives;
private int initialLives = -1;
private int lives;
public DPlayer(Player player, World world, Location teleport, boolean isEditing) {
plugin.getDPlayers().add(this);
this.player = player;
this.setPlayer(player);
this.world = world;
double health = ((Damageable) player).getHealth();
@ -79,11 +79,11 @@ public class DPlayer {
this.isEditing = isEditing;
if (this.isEditing) {
this.player.setGameMode(GameMode.CREATIVE);
this.getPlayer().setGameMode(GameMode.CREATIVE);
clearPlayerData();
} else {
this.player.setGameMode(GameMode.SURVIVAL);
this.getPlayer().setGameMode(GameMode.SURVIVAL);
WorldConfig dConfig = GameWorld.get(world).getConfig();
if ( !dConfig.getKeepInventoryOnEnter()) {
clearPlayerData();
@ -95,18 +95,18 @@ public class DPlayer {
lives = initialLives;
}
MiscUtil.secureTeleport(this.player, teleport);
MiscUtil.secureTeleport(this.getPlayer(), teleport);
}
public void clearPlayerData() {
player.getInventory().clear();
player.getInventory().setArmorContents(null);
player.setTotalExperience(0);
player.setLevel(0);
player.setHealth(20);
player.setFoodLevel(20);
for (PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType());
getPlayer().getInventory().clear();
getPlayer().getInventory().setArmorContents(null);
getPlayer().setTotalExperience(0);
getPlayer().setLevel(0);
getPlayer().setHealth(20);
getPlayer().setFoodLevel(20);
for (PotionEffect effect : getPlayer().getActivePotionEffects()) {
getPlayer().removePotionEffect(effect.getType());
}
}
@ -135,22 +135,22 @@ public class DPlayer {
}
} else {
GameWorld gWorld = GameWorld.get(world);
DGroup dGroup = DGroup.get(player);
GameWorld gameWorld = GameWorld.get(world);
DGroup dGroup = DGroup.get(getPlayer());
if (dGroup != null) {
dGroup.removePlayer(player);
dGroup.removePlayer(getPlayer());
}
// Belohnung
if ( !isinTestMode) {// Nur wenn man nicht am Testen ist
if ( !isInTestMode) {// Nur wenn man nicht am Testen ist
if (isFinished) {
addTreasure();
if (plugin.getEconomyProvider() != null) {
plugin.getEconomyProvider().depositPlayer(player, treasureMoney);
plugin.getEconomyProvider().depositPlayer(getPlayer(), treasureMoney);
}
// 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()) {
try {
@ -162,7 +162,7 @@ public class DPlayer {
FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file);
playerConfig.set(player.getUniqueId().toString(), System.currentTimeMillis());
playerConfig.set(getPlayer().getUniqueId().toString(), System.currentTimeMillis());
try {
playerConfig.save(file);
@ -171,15 +171,15 @@ public class DPlayer {
}
// Tutorial Permissions
if (gWorld.isTutorial) {
if (gameWorld.isTutorial()) {
String endGroup = plugin.getMainConfig().getTutorialEndGroup();
if (plugin.isGroupEnabled(endGroup)) {
plugin.getPermissionProvider().playerAddGroup(player, endGroup);
plugin.getPermissionProvider().playerAddGroup(getPlayer(), endGroup);
}
String startGroup = plugin.getMainConfig().getTutorialStartGroup();
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);
if (groupplayer != null) {
org.bukkit.Bukkit.broadcastMessage("14");
for (ItemStack istack : player.getInventory()) {
for (ItemStack istack : getPlayer().getInventory()) {
if (istack != null) {
if (gWorld.secureObjects.contains(istack.getType())) {
if (gameWorld.getSecureObjects().contains(istack.getType())) {
groupplayer.getInventory().addItem(istack);
}
}
@ -212,7 +212,7 @@ public class DPlayer {
public void ready() {
isReady = true;
DGroup dGroup = DGroup.get(player);
DGroup dGroup = DGroup.get(getPlayer());
if ( !dGroup.isPlaying()) {
if (dGroup != null) {
for (Player player : dGroup.getPlayers()) {
@ -230,21 +230,21 @@ public class DPlayer {
}
public void respawn() {
DGroup dGroup = DGroup.get(player);
DGroup dGroup = DGroup.get(getPlayer());
if (checkpoint == null) {
MiscUtil.secureTeleport(player, dGroup.getGWorld().locStart);
MiscUtil.secureTeleport(getPlayer(), dGroup.getGWorld().getLocStart());
} else {
MiscUtil.secureTeleport(player, checkpoint);
MiscUtil.secureTeleport(getPlayer(), checkpoint);
}
if (wolf != null) {
wolf.teleport(player);
wolf.teleport(getPlayer());
}
// Respawn Items
if (GameWorld.get(world).getConfig().getKeepInventoryOnDeath()) {
if (respawnInventory != null || respawnArmor != null) {
player.getInventory().setContents(respawnInventory);
player.getInventory().setArmorContents(respawnArmor);
getPlayer().getInventory().setContents(respawnInventory);
getPlayer().getInventory().setArmorContents(respawnArmor);
respawnInventory = null;
respawnArmor = null;
}
@ -253,10 +253,10 @@ public class DPlayer {
}
public void finishFloor(String specifiedFloor) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_FinishedDungeon"));
MessageUtil.sendMessage(getPlayer(), plugin.getDMessages().get("Player_FinishedDungeon"));
isFinished = true;
DGroup dGroup = DGroup.get(player);
DGroup dGroup = DGroup.get(getPlayer());
if (dGroup == null) {
return;
}
@ -268,7 +268,7 @@ public class DPlayer {
for (Player player : dGroup.getPlayers()) {
DPlayer dplayer = get(player);
if ( !dplayer.isFinished) {
MessageUtil.sendMessage(this.player, plugin.getDMessages().get("Player_WaitForOtherPlayers"));
MessageUtil.sendMessage(this.getPlayer(), plugin.getDMessages().get("Player_WaitForOtherPlayers"));
return;
}
}
@ -308,16 +308,16 @@ public class DPlayer {
dGroup.setGWorld(GameWorld.load(newFloor));
for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = get(player);
dPlayer.checkpoint = dGroup.getGWorld().locStart;
dPlayer.checkpoint = dGroup.getGWorld().getLocStart();
}
dGroup.startGame();
}
public void finish() {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_FinishedDungeon"));
MessageUtil.sendMessage(getPlayer(), plugin.getDMessages().get("Player_FinishedDungeon"));
isFinished = true;
DGroup dGroup = DGroup.get(player);
DGroup dGroup = DGroup.get(getPlayer());
if (dGroup == null) {
return;
}
@ -329,7 +329,7 @@ public class DPlayer {
for (Player player : dGroup.getPlayers()) {
DPlayer dplayer = get(player);
if ( !dplayer.isFinished) {
MessageUtil.sendMessage(this.player, plugin.getDMessages().get("Player_WaitForOtherPlayers"));
MessageUtil.sendMessage(this.getPlayer(), plugin.getDMessages().get("Player_WaitForOtherPlayers"));
return;
}
}
@ -345,15 +345,15 @@ public class DPlayer {
EditWorld eworld = EditWorld.get(world);
eworld.msg(msg);
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);
}
}
} else {
GameWorld gWorld = GameWorld.get(world);
gWorld.msg(msg);
GameWorld gameWorld = GameWorld.get(world);
gameWorld.msg(msg);
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);
}
}
@ -367,7 +367,7 @@ public class DPlayer {
String[] lines = sign.getLines();
if (lines[0].equals("") && lines[1].equals("") && lines[2].equals("") && lines[3].equals("")) {
if (linesCopy != null) {
SignChangeEvent event = new SignChangeEvent(block, player, linesCopy);
SignChangeEvent event = new SignChangeEvent(block, getPlayer(), linesCopy);
plugin.getServer().getPluginManager().callEvent(event);
if ( !event.isCancelled()) {
sign.setLine(0, event.getLine(0));
@ -379,27 +379,162 @@ public class DPlayer {
}
} else {
linesCopy = lines;
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_SignCopied"));
MessageUtil.sendMessage(getPlayer(), plugin.getDMessages().get("Player_SignCopied"));
}
} else {
String info = "" + block.getType();
if (block.getData() != 0) {
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) {
GameWorld gWorld = GameWorld.get(player.getWorld());
if (gWorld == null) {
public void addTreasure() {
new DLootInventory(getPlayer(), treasureInv.getContents());
}
/**
* @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;
}
DClass dclass = gWorld.getConfig().getClass(classname);
if (dclass != null) {
if (this.dclass != dclass) {
this.dclass = dclass;
DClass dClass = gameWorld.getConfig().getClass(className);
if (dClass != null) {
if (this.dClass != dClass) {
this.dClass = dClass;
/* Set Dog */
if (wolf != null) {
@ -407,77 +542,235 @@ public class DPlayer {
wolf = null;
}
if (dclass.hasDog()) {
wolf = (Wolf) world.spawnEntity(player.getLocation(), EntityType.WOLF);
if (dClass.hasDog()) {
wolf = (Wolf) world.spawnEntity(getPlayer().getLocation(), EntityType.WOLF);
wolf.setTamed(true);
wolf.setOwner(player);
wolf.setOwner(getPlayer());
double maxHealth = ((Damageable) wolf).getMaxHealth();
wolf.setHealth(maxHealth);
}
/* Delete Inventory */
player.getInventory().clear();
player.getInventory().setArmorContents(null);
player.getInventory().setItemInHand(new ItemStack(Material.AIR));
getPlayer().getInventory().clear();
getPlayer().getInventory().setArmorContents(null);
getPlayer().getInventory().setItemInHand(new ItemStack(Material.AIR));
// Remove Potion Effects
for (PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType());
for (PotionEffect effect : getPlayer().getActivePotionEffects()) {
getPlayer().removePotionEffect(effect.getType());
}
// Reset lvl
player.setTotalExperience(0);
player.setLevel(0);
getPlayer().setTotalExperience(0);
getPlayer().setLevel(0);
/* Set Inventory */
for (ItemStack istack : dclass.getItems()) {
for (ItemStack istack : dClass.getItems()) {
// 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) {
player.getInventory().setLeggings(istack);
getPlayer().getInventory().setLeggings(istack);
}
// 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) {
player.getInventory().setHelmet(istack);
getPlayer().getInventory().setHelmet(istack);
}
// 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) {
player.getInventory().setChestplate(istack);
getPlayer().getInventory().setChestplate(istack);
}
// 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) {
player.getInventory().setBoots(istack);
getPlayer().getInventory().setBoots(istack);
}
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) {
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
public static void remove(DPlayer player) {
plugin.getDPlayers().remove(player);
}
public static DPlayer get(Player player) {
for (DPlayer dplayer : plugin.getDPlayers()) {
if (dplayer.player.equals(player)) {
if (dplayer.getPlayer().equals(player)) {
return dplayer;
}
}
@ -486,7 +779,7 @@ public class DPlayer {
public static DPlayer get(String name) {
for (DPlayer dplayer : plugin.getDPlayers()) {
if (dplayer.player.getName().equalsIgnoreCase(name)) {
if (dplayer.getPlayer().getName().equalsIgnoreCase(name)) {
return dplayer;
}
}
@ -508,27 +801,27 @@ public class DPlayer {
public static void update(boolean updateSecond) {
for (DPlayer dplayer : plugin.getDPlayers()) {
if ( !updateSecond) {
if ( !dplayer.player.getWorld().equals(dplayer.world)) {
if ( !dplayer.getPlayer().getWorld().equals(dplayer.world)) {
if (dplayer.isEditing) {
EditWorld eworld = EditWorld.get(dplayer.world);
if (eworld != null) {
if (eworld.lobby == null) {
MiscUtil.secureTeleport(dplayer.player, eworld.world.getSpawnLocation());
if (eworld.getLobby() == null) {
MiscUtil.secureTeleport(dplayer.getPlayer(), eworld.getWorld().getSpawnLocation());
} else {
MiscUtil.secureTeleport(dplayer.player, eworld.lobby);
MiscUtil.secureTeleport(dplayer.getPlayer(), eworld.getLobby());
}
}
} else {
GameWorld gWorld = GameWorld.get(dplayer.world);
if (gWorld != null) {
DGroup dGroup = DGroup.get(dplayer.player);
GameWorld gameWorld = GameWorld.get(dplayer.world);
if (gameWorld != null) {
DGroup dGroup = DGroup.get(dplayer.getPlayer());
if (dplayer.checkpoint == null) {
MiscUtil.secureTeleport(dplayer.player, dGroup.getGWorld().locStart);
MiscUtil.secureTeleport(dplayer.getPlayer(), dGroup.getGWorld().getLocStart());
if (dplayer.wolf != null) {
dplayer.wolf.teleport(dGroup.getGWorld().locStart);
dplayer.wolf.teleport(dGroup.getGWorld().getLocStart());
}
} else {
MiscUtil.secureTeleport(dplayer.player, dplayer.checkpoint);
MiscUtil.secureTeleport(dplayer.getPlayer(), dplayer.checkpoint);
if (dplayer.wolf != null) {
dplayer.wolf.teleport(dplayer.checkpoint);
}
@ -536,8 +829,8 @@ public class DPlayer {
// Respawn Items
if (dplayer.respawnInventory != null || dplayer.respawnArmor != null) {
dplayer.player.getInventory().setContents(dplayer.respawnInventory);
dplayer.player.getInventory().setArmorContents(dplayer.respawnArmor);
dplayer.getPlayer().getInventory().setContents(dplayer.respawnInventory);
dplayer.getPlayer().getInventory().setArmorContents(dplayer.respawnArmor);
dplayer.respawnInventory = null;
dplayer.respawnArmor = null;
}
@ -545,16 +838,16 @@ public class DPlayer {
}
}
} else {
GameWorld gWorld = GameWorld.get(dplayer.world);
GameWorld gameWorld = GameWorld.get(dplayer.world);
if (gWorld != null) {
if (gameWorld != null) {
// Update Wolf
if (dplayer.wolf != null) {
if (dplayer.wolf.isDead()) {
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.setOwner(dplayer.player);
dplayer.wolf.setOwner(dplayer.getPlayer());
dplayer.wolfRespawnTime = 30;
}
dplayer.wolfRespawnTime--;
@ -569,7 +862,7 @@ public class DPlayer {
}
// 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 static String name = "Block";
public String buildPermissions = "dxl.sign.block";
public boolean onDungeonInit = false;
private DSignType type = DSignTypeDefault.BLOCK;
// Variables
private boolean initialized;
@ -49,11 +47,14 @@ public class BlockSign extends DSign {
if ( !lines[2].equals("")) {
String line2[] = lines[2].split(",");
Material onBlock = Material.matchMaterial(line2[0]);
if (onBlock != null) {
onBlockId = onBlock.getId();
} else {
onBlockId = IntegerUtil.parseInt(line2[0]);
}
if (line2.length > 1) {
onBlockData = (byte) IntegerUtil.parseInt(line2[1]);
}
@ -82,13 +83,8 @@ public class BlockSign extends DSign {
}
@Override
public String getPermissions() {
return buildPermissions;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
public DSignType getType() {
return type;
}
}

View File

@ -13,16 +13,14 @@ import org.bukkit.entity.Player;
public class CheckpointSign extends DSign {
public static String name = "Checkpoint";
private String buildPermissions = "dxl.sign.checkpoint";
private boolean onDungeonInit = false;
private DSignType type = DSignTypeDefault.CHECKPOINT;
// Variables
private boolean initialized;
private CopyOnWriteArrayList<DPlayer> done = new CopyOnWriteArrayList<DPlayer>();
public CheckpointSign(Sign sign, GameWorld gWorld) {
super(sign, gWorld);
public CheckpointSign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
}
@Override
@ -39,41 +37,43 @@ public class CheckpointSign extends DSign {
@Override
public void onTrigger() {
if (initialized) {
for (DPlayer dplayer : DPlayer.get(getGWorld().world)) {
dplayer.setCheckpoint(getSign().getLocation());
MessageUtil.sendMessage(dplayer.player, DungeonsXL.getPlugin().getDMessages().get("Player_CheckpointReached"));
}
remove();
if ( !initialized) {
return;
}
for (DPlayer dplayer : DPlayer.get(getGameWorld().getWorld())) {
dplayer.setCheckpoint(getSign().getLocation());
MessageUtil.sendMessage(dplayer.getPlayer(), DungeonsXL.getPlugin().getDMessages().get("Player_CheckpointReached"));
}
remove();
}
@Override
public boolean onPlayerTrigger(Player player) {
if (initialized) {
DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) {
if ( !done.contains(dplayer)) {
done.add(dplayer);
dplayer.setCheckpoint(getSign().getLocation());
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_CheckpointReached"));
}
}
if (done.size() >= DPlayer.get(getGWorld().world).size()) {
remove();
if ( !initialized) {
return true;
}
DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) {
if ( !done.contains(dplayer)) {
done.add(dplayer);
dplayer.setCheckpoint(getSign().getLocation());
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_CheckpointReached"));
}
}
if (done.size() >= DPlayer.get(getGameWorld().getWorld()).size()) {
remove();
}
return true;
}
@Override
public String getPermissions() {
return buildPermissions;
public DSignType getType() {
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 static String name = "Chest";
public String buildPermissions = "dxl.sign.chest";
public boolean onDungeonInit = false;
private DSignType type = DSignTypeDefault.CHEST;
// Variables
private double moneyReward;
@ -25,6 +23,7 @@ public class ChestSign extends DSign {
if (lines[1].equals("")) {
return false;
}
return true;
}
@ -34,15 +33,18 @@ public class ChestSign extends DSign {
if ( !lines[1].equals("")) {
moneyReward = Double.parseDouble(lines[1]);
}
for (int i = -1; i <= 1; i++) {
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) {
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) {
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
public String getPermissions() {
return buildPermissions;
public DSignType getType() {
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 static String name = "ChunkUpdater";
public String buildPermissions = "dxl.sign.chunkupdater";
public boolean onDungeonInit = true;
private DSignType type = DSignTypeDefault.CHUNK_UPDATER;
public ChunkUpdaterSign(Sign sign, GameWorld gWorld) {
super(sign, gWorld);
public ChunkUpdaterSign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
}
@Override
public boolean check() {
// TODO Auto-generated method stub
return true;
}
@Override
public void onInit() {
String lines[] = getSign().getLines();
Chunk chunk = getGWorld().world.getChunkAt(getSign().getBlock());
Chunk chunk = getGameWorld().getWorld().getChunkAt(getSign().getBlock());
if ( !lines[1].equals("")) {
Integer radius = IntegerUtil.parseInt(lines[1]);
for (int x = -radius; x < radius; x++) {
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();
getGWorld().loadedChunks.add(chunk1);
getGameWorld().getLoadedChunks().add(chunk1);
}
}
} else {
chunk.load();
getGWorld().loadedChunks.add(chunk);
getGameWorld().getLoadedChunks().add(chunk);
}
getSign().getBlock().setType(Material.AIR);
}
@Override
public String getPermissions() {
return buildPermissions;
public DSignType getType() {
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 static String name = "Classes";
public String buildPermissions = "dxl.sign.classes";
public boolean onDungeonInit = true;
private DSignType type = DSignTypeDefault.CLASSES;
public ClassesSign(Sign sign, GameWorld gWorld) {
super(sign, gWorld);
public ClassesSign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
}
@Override
@ -27,56 +25,55 @@ public class ClassesSign extends DSign {
@SuppressWarnings("deprecation")
@Override
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 directionX = direction[0];
int directionZ = direction[1];
int xx = 0, zz = 0;
for (DClass dclass : getGameWorld().getConfig().getClasses()) {
int[] direction = GroupSign.getDirection(getSign().getBlock().getData());
int directionX = direction[0];
int directionZ = direction[1];
int xx = 0, zz = 0;
for (DClass dclass : getGWorld().getConfig().getClasses()) {
// Check existing signs
boolean isContinued = true;
for (Sign isusedsign : getGWorld().signClass) {
if (dclass.getName().equalsIgnoreCase(ChatColor.stripColor(isusedsign.getLine(1)))) {
isContinued = false;
}
}
if (isContinued) {
Block classBlock = getSign().getBlock().getRelative(xx, 0, zz);
if (classBlock.getData() == getSign().getData().getData() && classBlock.getType() == Material.WALL_SIGN && classBlock.getState() instanceof Sign) {
Sign classSign = (Sign) classBlock.getState();
classSign.setLine(0, ChatColor.DARK_BLUE + "############");
classSign.setLine(1, ChatColor.DARK_GREEN + dclass.getName());
classSign.setLine(2, "");
classSign.setLine(3, ChatColor.DARK_BLUE + "############");
classSign.update();
getGWorld().signClass.add(classSign);
} else {
break;
}
xx = xx + directionX;
zz = zz + directionZ;
// Check existing signs
boolean isContinued = true;
for (Sign isusedsign : getGameWorld().getSignClass()) {
if (dclass.getName().equalsIgnoreCase(ChatColor.stripColor(isusedsign.getLine(1)))) {
isContinued = false;
}
}
} else {
getSign().getBlock().setType(Material.AIR);
if ( !isContinued) {
continue;
}
Block classBlock = getSign().getBlock().getRelative(xx, 0, zz);
if (classBlock.getData() == getSign().getData().getData() && classBlock.getType() == Material.WALL_SIGN && classBlock.getState() instanceof Sign) {
Sign classSign = (Sign) classBlock.getState();
classSign.setLine(0, ChatColor.DARK_BLUE + "############");
classSign.setLine(1, ChatColor.DARK_GREEN + dclass.getName());
classSign.setLine(2, "");
classSign.setLine(3, ChatColor.DARK_BLUE + "############");
classSign.update();
getGameWorld().getSignClass().add(classSign);
} else {
break;
}
xx = xx + directionX;
zz = zz + directionZ;
}
}
@Override
public String getPermissions() {
return buildPermissions;
public DSignType getType() {
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 static String name = "Cmd";
public String buildPermissions = "dxl.sign.cmd";
public boolean onDungeonInit = false;
private DSignType type = DSignTypeDefault.COMMAND;
// Variables
private CCommand cCommand;
@ -23,14 +21,12 @@ public class CommandSign extends DSign {
private String executor;
private boolean initialized;
public CommandSign(Sign sign, GameWorld gWorld) {
super(sign, gWorld);
public CommandSign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
}
@Override
public boolean check() {
// TODO Auto-generated method stub
return true;
}
@ -41,20 +37,23 @@ public class CommandSign extends DSign {
cCommand = CommandsXL.getCCommands().getCCommand(command);
if (getTriggers().isEmpty()) {
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGWorld());
if (trigger != null) {
trigger.addListener(this);
getTriggers().add(trigger);
}
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
getSign().setLine(1, ChatColor.DARK_GREEN + command);
getSign().setLine(2, "");
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
getSign().update();
} else {
getSign().getBlock().setType(Material.AIR);
return;
}
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGameWorld());
if (trigger != null) {
trigger.addListener(this);
getTriggers().add(trigger);
}
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
getSign().setLine(1, ChatColor.DARK_GREEN + command);
getSign().setLine(2, "");
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
getSign().update();
initialized = true;
}
@ -69,6 +68,7 @@ public class CommandSign extends DSign {
} else {
cCommand.execute(player, player, false);
}
return true;
}
@ -80,12 +80,8 @@ public class CommandSign extends DSign {
}
@Override
public String getPermissions() {
return buildPermissions;
public DSignType getType() {
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.trigger.Trigger;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashSet;
import java.util.Set;
@ -15,35 +17,38 @@ public abstract class DSign {
static DungeonsXL plugin = DungeonsXL.getPlugin();
private Sign sign;
private GameWorld gWorld;
private GameWorld gameWorld;
// List of Triggers
private Set<Trigger> triggers = new HashSet<Trigger>();
public DSign(Sign sign, GameWorld gWorld) {
public DSign(Sign sign, GameWorld gameWorld) {
this.setSign(sign);
this.gWorld = gWorld;
this.gameWorld = gameWorld;
// Check Trigger
if (gWorld != null) {
String line3 = sign.getLine(3).replaceAll("\\s", "");
String[] triggerTypes = line3.split(",");
if (gameWorld == null) {
return;
}
String line3 = sign.getLine(3).replaceAll("\\s", "");
String[] triggerTypes = line3.split(",");
for (String triggerString : triggerTypes) {
if (triggerString.equals("")) {
continue;
}
for (String triggerString : triggerTypes) {
if ( !triggerString.equals("")) {
String type = triggerString.substring(0, 1);
String value = null;
if (triggerString.length() > 1) {
value = triggerString.substring(1);
}
Trigger trigger = Trigger.getOrCreate(type, value, this);
if (trigger != null) {
trigger.addListener(this);
addTrigger(trigger);
}
}
String type = triggerString.substring(0, 1);
String value = null;
if (triggerString.length() > 1) {
value = triggerString.substring(1);
}
Trigger trigger = Trigger.getOrCreate(type, value, this);
if (trigger != null) {
trigger.addListener(this);
addTrigger(trigger);
}
}
}
@ -64,10 +69,10 @@ public abstract class DSign {
}
/**
* @return the gWorld
* @return the gameWorld
*/
public GameWorld getGWorld() {
return gWorld;
public GameWorld getGameWorld() {
return gameWorld;
}
/**
@ -94,11 +99,9 @@ public abstract class DSign {
}
public void onInit() {
}
public void onTrigger() {
}
public boolean onPlayerTrigger(Player player) {
@ -106,7 +109,6 @@ public abstract class DSign {
}
public void onDisable() {
}
public void onUpdate() {
@ -115,12 +117,17 @@ public abstract class DSign {
onDisable();
return;
}
if (triggers.size() == 1) {
if (trigger.player != null) {
if (onPlayerTrigger(trigger.player)) {
return;
}
}
if (triggers.size() != 1) {
continue;
}
if (trigger.player == null) {
continue;
}
if (onPlayerTrigger(trigger.player)) {
return;
}
}
@ -131,83 +138,40 @@ public abstract class DSign {
for (Trigger trigger : triggers) {
trigger.removeListener(this);
}
gWorld.dSigns.remove(this);
gameWorld.getdSigns().remove(this);
}
public boolean hasTriggers() {
return !triggers.isEmpty();
}
// TODO: API to add custom signs
public static DSign create(Sign sign, GameWorld gWorld) {
public static DSign create(Sign sign, GameWorld gameWorld) {
String[] lines = sign.getLines();
DSign dSign = null;
if (lines[0].equalsIgnoreCase("[" + BlockSign.name + "]")) {
dSign = new BlockSign(sign, gWorld);
for (DSignType type : plugin.getDSigns().getDSigns()) {
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);
try {
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 && gWorld != null) {
if (dSign.isOnDungeonInit()) {
dSign.onInit();
}
if ( !(dSign != null && gameWorld != null)) {
return dSign;
}
if (dSign.getType().isOnDungeonInit()) {
dSign.onInit();
}
return dSign;
@ -217,8 +181,6 @@ public abstract class DSign {
public abstract boolean check();
public abstract String getPermissions();
public abstract boolean isOnDungeonInit();
public abstract DSignType getType();
}

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

View File

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

View File

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

View File

@ -12,37 +12,34 @@ import org.bukkit.entity.Player;
public class LeaveSign extends DSign {
public static String name = "Leave";
public String buildPermissions = "dxl.sign.leave";
public boolean onDungeonInit = true;
private DSignType type = DSignTypeDefault.LEAVE;
public LeaveSign(Sign sign, GameWorld gWorld) {
super(sign, gWorld);
public LeaveSign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
}
@Override
public boolean check() {
// TODO Auto-generated method stub
return true;
}
@Override
public void onInit() {
if (getTriggers().isEmpty()) {
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGWorld());
if (trigger != null) {
trigger.addListener(this);
addTrigger(trigger);
}
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
getSign().setLine(1, ChatColor.DARK_GREEN + "Leave");
getSign().setLine(2, "");
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
getSign().update();
} else {
if ( !getTriggers().isEmpty()) {
getSign().getBlock().setType(Material.AIR);
return;
}
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGameWorld());
if (trigger != null) {
trigger.addListener(this);
addTrigger(trigger);
}
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
getSign().setLine(1, ChatColor.DARK_GREEN + "Leave");
getSign().setLine(2, "");
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
getSign().update();
}
@Override
@ -51,6 +48,7 @@ public class LeaveSign extends DSign {
if (dplayer != null) {
dplayer.leave();
}
return true;
}
@ -62,12 +60,8 @@ public class LeaveSign extends DSign {
}
@Override
public String getPermissions() {
return buildPermissions;
public DSignType getType() {
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 static String name = "Lobby";
public String buildPermissions = "dxl.sign.lobby";
public boolean onDungeonInit = true;
private DSignType type = DSignTypeDefault.LOBBY;
public LobbySign(Sign sign, GameWorld gWorld) {
super(sign, gWorld);
public LobbySign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
}
@Override
public boolean check() {
// TODO Auto-generated method stub
return true;
}
@Override
public void onInit() {
getGWorld().locLobby = getSign().getLocation();
getGameWorld().setLocLobby(getSign().getLocation());
getSign().getBlock().setType(Material.AIR);
}
@Override
public String getPermissions() {
return buildPermissions;
public DSignType getType() {
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.entity.Player;
public class MsgSign extends DSign {
public class MessageSign extends DSign {
public static String name = "Msg";
public String buildPermissions = "dxl.sign.msg";
public boolean onDungeonInit = false;
private DSignType type = DSignTypeDefault.MESSAGE;
// Variables
private String msg;
private boolean initialized;
private CopyOnWriteArrayList<Player> done = new CopyOnWriteArrayList<Player>();
public MsgSign(Sign sign, GameWorld gWorld) {
super(sign, gWorld);
public MessageSign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
}
@Override
@ -39,7 +37,7 @@ public class MsgSign extends DSign {
String lines[] = getSign().getLines();
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) {
this.msg = msg;
getSign().getBlock().setType(Material.AIR);
@ -51,22 +49,26 @@ public class MsgSign extends DSign {
@Override
public boolean onPlayerTrigger(Player player) {
if (initialized) {
if ( !done.contains(player)) {
MessageUtil.sendMessage(player, msg);
done.add(player);
}
if (done.size() >= getGWorld().world.getPlayers().size()) {
remove();
}
if ( !initialized) {
return true;
}
if ( !done.contains(player)) {
MessageUtil.sendMessage(player, msg);
done.add(player);
}
if (done.size() >= getGameWorld().getWorld().getPlayers().size()) {
remove();
}
return true;
}
@Override
public void onTrigger() {
if (initialized) {
for (Player player : getGWorld().world.getPlayers()) {
for (Player player : getGameWorld().getWorld().getPlayers()) {
MessageUtil.sendMessage(player, msg);
}
remove();
@ -74,12 +76,8 @@ public class MsgSign extends DSign {
}
@Override
public String getPermissions() {
return buildPermissions;
public DSignType getType() {
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 static String name = "Mob";
public String buildPermissions = "dxl.sign.mob";
public boolean onDungeonInit = false;
private DSignType type = DSignTypeDefault.MOB;
// Variables
private String mob;
@ -30,23 +28,28 @@ public class MobSign extends DSign {
private boolean active;
private int taskId = -1;
public MobSign(Sign sign, GameWorld gWorld) {
super(sign, gWorld);
public MobSign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
}
@Override
public boolean check() {
String lines[] = getSign().getLines();
if ( !lines[1].equals("") && !lines[2].equals("")) {
if (lines[1] != null) {
String[] atributes = lines[2].split(",");
if (atributes.length == 2) {
return true;
}
}
if (lines[1].equals("") || lines[2].equals("")) {
return false;
}
return false;
if (lines[1] == null) {
return false;
}
String[] atributes = lines[2].split(",");
if (atributes.length == 2) {
return true;
} else {
return false;
}
}
@Override
@ -55,11 +58,11 @@ public class MobSign extends DSign {
if ( !lines[1].equals("") && !lines[2].equals("")) {
String mob = lines[1];
if (mob != null) {
String[] atributes = lines[2].split(",");
if (atributes.length == 2) {
String[] attributes = lines[2].split(",");
if (attributes.length == 2) {
this.mob = mob;
maxinterval = IntegerUtil.parseInt(atributes[0]);
amount = IntegerUtil.parseInt(atributes[1]);
maxinterval = IntegerUtil.parseInt(attributes[0]);
amount = IntegerUtil.parseInt(attributes[1]);
}
}
}
@ -70,30 +73,36 @@ public class MobSign extends DSign {
@Override
public void onTrigger() {
if (initialized && !active) {
MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
taskId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, scheduler, 0L, 20L);
active = true;
if ( !initialized || active) {
return;
}
MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
taskId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, scheduler, 0L, 20L);
active = true;
}
@Override
public void onDisable() {
if (initialized && active) {
killTask();
interval = 0;
active = false;
if ( !initialized || !active) {
return;
}
killTask();
interval = 0;
active = false;
}
public void killTask() {
if (initialized && active) {
if (taskId != -1) {
plugin.getServer().getScheduler().cancelTask(taskId);
taskId = -1;
}
if ( !initialized || !active) {
return;
}
if (taskId != -1) {
plugin.getServer().getScheduler().cancelTask(taskId);
taskId = -1;
}
}
@ -109,9 +118,9 @@ public class MobSign extends DSign {
public void run() {
if (sign.interval <= 0) {
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);
// Check normal mobs
@ -130,12 +139,12 @@ public class MobSign extends DSign {
// Disable Despawning
entity.setRemoveWhenFarAway(false);
new DMob(entity, sign.getGWorld(), null);
new DMob(entity, sign.getGameWorld(), null);
}
}
// Check custom mobs
DMobType mobType = DMobType.get(sign.mob, gWorld.getConfig().getMobTypes());
DMobType mobType = DMobType.get(sign.mob, gameWorld.getConfig().getMobTypes());
if (mobType != null) {
mobType.spawn(GameWorld.get(world), spawnLoc);
@ -161,12 +170,8 @@ public class MobSign extends DSign {
}
@Override
public String getPermissions() {
return buildPermissions;
public DSignType getType() {
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 static String name = "MythicMobs";
public String buildPermissions = "dxl.sign.mob";
public boolean onDungeonInit = false;
private DSignType type = DSignTypeDefault.MYTHIC_MOBS;
// Variables
private String mob;
@ -33,23 +31,28 @@ public class MythicMobsSign extends DSign {
private LivingEntity mythicMob;
private ArrayList<Entity> mythicMobs = new ArrayList<Entity>();
public MythicMobsSign(Sign sign, GameWorld gWorld) {
super(sign, gWorld);
public MythicMobsSign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
}
@Override
public boolean check() {
String lines[] = getSign().getLines();
if ( !lines[1].equals("") && !lines[2].equals("")) {
if (lines[1] != null) {
String[] atributes = lines[2].split(",");
if (atributes.length == 2) {
return true;
}
}
if (lines[1].equals("") || lines[2].equals("")) {
return false;
}
return false;
if (lines[1] == null) {
return false;
}
String[] atributes = lines[2].split(",");
if (atributes.length == 2) {
return true;
} else {
return false;
}
}
@Override
@ -58,11 +61,11 @@ public class MythicMobsSign extends DSign {
if ( !lines[1].equals("") && !lines[2].equals("")) {
String mob = lines[1];
if (mob != null) {
String[] atributes = lines[2].split(",");
if (atributes.length == 2) {
String[] attributes = lines[2].split(",");
if (attributes.length == 2) {
this.mob = mob;
maxinterval = IntegerUtil.parseInt(atributes[0]);
amount = IntegerUtil.parseInt(atributes[1]);
maxinterval = IntegerUtil.parseInt(attributes[0]);
amount = IntegerUtil.parseInt(attributes[1]);
}
}
}
@ -73,30 +76,36 @@ public class MythicMobsSign extends DSign {
@Override
public void onTrigger() {
if (initialized && !active) {
MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
taskId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, scheduler, 0L, 20L);
active = true;
if ( !initialized || active) {
return;
}
MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
taskId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, scheduler, 0L, 20L);
active = true;
}
@Override
public void onDisable() {
if (initialized && active) {
killTask();
interval = 0;
active = false;
if ( !initialized || !active) {
return;
}
killTask();
interval = 0;
active = false;
}
public void killTask() {
if (initialized && active) {
if (taskId != -1) {
plugin.getServer().getScheduler().cancelTask(taskId);
taskId = -1;
}
if ( !initialized || !active) {
return;
}
if (taskId != -1) {
plugin.getServer().getScheduler().cancelTask(taskId);
taskId = -1;
}
}
@ -111,20 +120,20 @@ public class MythicMobsSign extends DSign {
public void run() {
if (sign.interval <= 0) {
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);
double x = spawnLoc.getX();
double y = spawnLoc.getY();
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);
setMythicMobs();
if (mythicMob != null) {
new DMob(mythicMob, sign.getGWorld(), null, mob);
new DMob(mythicMob, sign.getGameWorld(), null, mob);
}
// 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() {
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
@ -163,9 +162,14 @@ public class MythicMobsSign extends DSign {
&& !mythicMobs.contains(entity) && entity.isCustomNameVisible() && !(entity instanceof Player)) {
mythicMob = (LivingEntity) entity;
mythicMobs.add(entity);
org.bukkit.Bukkit.broadcastMessage("[DXL Debug] MythicMob counter: " + mythicMobs.size());
return;
}
}
}
@Override
public DSignType getType() {
return type;
}
}

View File

@ -8,12 +8,10 @@ import org.bukkit.block.Sign;
public class PlaceSign extends DSign {
public static String name = "Place";
public String buildPermissions = "dxl.sign.place";
public boolean onDungeonInit = false;
private DSignType type = DSignTypeDefault.PLACE;
public PlaceSign(Sign sign, GameWorld gWorld) {
super(sign, gWorld);
public PlaceSign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
}
@Override
@ -24,17 +22,13 @@ public class PlaceSign extends DSign {
@Override
public void onInit() {
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);
}
@Override
public String getPermissions() {
return buildPermissions;
public DSignType getType() {
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 static String name = "Ready";
public String buildPermissions = "dxl.sign.ready";
public boolean onDungeonInit = true;
private DSignType type = DSignTypeDefault.READY;
public ReadySign(Sign sign, GameWorld gWorld) {
super(sign, gWorld);
public ReadySign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
}
@Override
@ -28,20 +26,22 @@ public class ReadySign extends DSign {
@Override
public void onInit() {
if (getTriggers().isEmpty()) {
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGWorld());
if (trigger != null) {
trigger.addListener(this);
addTrigger(trigger);
}
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
getSign().setLine(1, ChatColor.DARK_GREEN + "Ready");
getSign().setLine(2, "");
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
getSign().update();
} else {
if ( !getTriggers().isEmpty()) {
getSign().getBlock().setType(Material.AIR);
return;
}
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGameWorld());
if (trigger != null) {
trigger.addListener(this);
addTrigger(trigger);
}
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
getSign().setLine(1, ChatColor.DARK_GREEN + "Ready");
getSign().setLine(2, "");
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
getSign().update();
}
@Override
@ -58,26 +58,27 @@ public class ReadySign extends DSign {
}
private void ready(DPlayer dplayer) {
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;
} else {
MessageUtil.sendMessage(dplayer.player, plugin.getDMessages().get("Error_Ready"));
}
}
if (dplayer == null) {
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 {
MessageUtil.sendMessage(dplayer.getPlayer(), plugin.getDMessages().get("Error_Ready"));
}
}
@Override
public String getPermissions() {
return buildPermissions;
public DSignType getType() {
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 static String name = "Redstone";
public String buildPermissions = "dxl.sign.redstone";
public boolean onDungeonInit = false;
private DSignType type = DSignTypeDefault.REDSTONE;
// Variables
private boolean initialized;
@ -71,32 +69,39 @@ public class RedstoneSign extends DSign {
@Override
public void onTrigger() {
if (initialized && !active) {
if (delay > 0) {
enableTaskId = DungeonsXL.getPlugin().getServer().getScheduler().scheduleSyncRepeatingTask(DungeonsXL.getPlugin(), new DelayedPower(true), delay, delay + offDelay);
if (repeat != 1) {
repeatsToDo = repeat;
disableTaskId = DungeonsXL.getPlugin().getServer().getScheduler().scheduleSyncRepeatingTask(DungeonsXL.getPlugin(), new DelayedPower(false), delay + offDelay, delay + offDelay);
}
} else {
power();
}
active = true;
if ( !initialized || active) {
return;
}
if (delay > 0) {
enableTaskId = DungeonsXL.getPlugin().getServer().getScheduler().scheduleSyncRepeatingTask(DungeonsXL.getPlugin(), new DelayedPower(true), delay, delay + offDelay);
if (repeat != 1) {
repeatsToDo = repeat;
disableTaskId = DungeonsXL.getPlugin().getServer().getScheduler().scheduleSyncRepeatingTask(DungeonsXL.getPlugin(), new DelayedPower(false), delay + offDelay, delay + offDelay);
}
} else {
power();
}
active = true;
}
@Override
public void onDisable() {
if (initialized && active) {
unpower();
disableTask(enableTaskId);
disableTask(disableTaskId);
enableTaskId = -1;
disableTaskId = -1;
active = false;
if ( !initialized || !active) {
return;
}
unpower();
disableTask(enableTaskId);
disableTask(disableTaskId);
enableTaskId = -1;
disableTaskId = -1;
active = false;
}
public void power() {
@ -108,21 +113,18 @@ public class RedstoneSign extends DSign {
}
public void disableTask(int taskId) {
if (taskId != -1) {
if (DungeonsXL.getPlugin().getServer().getScheduler().isCurrentlyRunning(taskId) || DungeonsXL.getPlugin().getServer().getScheduler().isQueued(taskId)) {
DungeonsXL.getPlugin().getServer().getScheduler().cancelTask(taskId);
}
if (taskId == -1) {
return;
}
if (DungeonsXL.getPlugin().getServer().getScheduler().isCurrentlyRunning(taskId) || DungeonsXL.getPlugin().getServer().getScheduler().isQueued(taskId)) {
DungeonsXL.getPlugin().getServer().getScheduler().cancelTask(taskId);
}
}
@Override
public String getPermissions() {
return buildPermissions;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
public DSignType getType() {
return type;
}
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.entity.Player;
public class SoundMsgSign extends DSign {
public class SoundMessageSign extends DSign {
public static String name = "SoundMsg";
public String buildPermissions = "dxl.sign.soundmsg";
public boolean onDungeonInit = false;
private DSignType type = DSignTypeDefault.SOUND_MESSAGE;
// Variables
private boolean initialized;
@ -21,8 +19,8 @@ public class SoundMsgSign extends DSign {
private String msg;
private CopyOnWriteArrayList<Player> done = new CopyOnWriteArrayList<Player>();
public SoundMsgSign(Sign sign, GameWorld gWorld) {
super(sign, gWorld);
public SoundMessageSign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
}
@Override
@ -39,7 +37,7 @@ public class SoundMsgSign extends DSign {
String lines[] = getSign().getLines();
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) {
this.msg = msg;
getSign().getBlock().setType(Material.AIR);
@ -60,20 +58,17 @@ public class SoundMsgSign extends DSign {
public boolean onPlayerTrigger(Player player) {
if (initialized) {
remove();
if (done.size() >= getGWorld().world.getPlayers().size()) {
if (done.size() >= getGameWorld().getWorld().getPlayers().size()) {
remove();
}
}
return true;
}
@Override
public String getPermissions() {
return buildPermissions;
public DSignType getType() {
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 static String name = "Start";
public String buildPermissions = "dxl.sign.start";
public boolean onDungeonInit = true;
private DSignType type = DSignTypeDefault.START;
public StartSign(Sign sign, GameWorld gWorld) {
super(sign, gWorld);
public StartSign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
}
@Override
@ -22,17 +20,13 @@ public class StartSign extends DSign {
@Override
public void onInit() {
getGWorld().locStart = getSign().getLocation();
getGameWorld().setLocStart(getSign().getLocation());
getSign().getBlock().setType(Material.AIR);
}
@Override
public String getPermissions() {
return buildPermissions;
public DSignType getType() {
return type;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
}

View File

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

View File

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

View File

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