mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2025-02-03 05:51:38 +01:00
Continue rewrite (including sign system rewrite)
This commit is contained in:
parent
e0a87dd2ac
commit
56f98e6826
@ -1,3 +1,6 @@
|
|||||||
|
/* TODO: Cleanup - Overhaul DPlayer, GameWorld, GameChest & Listeners - MiscUtil - FileUtil -
|
||||||
|
* Variable names - Triggers */
|
||||||
|
|
||||||
package io.github.dre2n.dungeonsxl;
|
package io.github.dre2n.dungeonsxl;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.command.DCommands;
|
import io.github.dre2n.dungeonsxl.command.DCommands;
|
||||||
@ -20,6 +23,7 @@ import io.github.dre2n.dungeonsxl.listener.WorldListener;
|
|||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
import io.github.dre2n.dungeonsxl.player.DSavePlayer;
|
import io.github.dre2n.dungeonsxl.player.DSavePlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSigns;
|
||||||
import io.github.dre2n.dungeonsxl.util.FileUtil;
|
import io.github.dre2n.dungeonsxl.util.FileUtil;
|
||||||
import io.github.dre2n.dungeonsxl.util.VersionUtil;
|
import io.github.dre2n.dungeonsxl.util.VersionUtil;
|
||||||
import io.github.dre2n.dungeonsxl.util.VersionUtil.Internals;
|
import io.github.dre2n.dungeonsxl.util.VersionUtil.Internals;
|
||||||
@ -31,7 +35,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -49,6 +52,7 @@ public class DungeonsXL extends JavaPlugin {
|
|||||||
private DMessages dMessages;
|
private DMessages dMessages;
|
||||||
private VersionUtil versionUtil;
|
private VersionUtil versionUtil;
|
||||||
private DCommands dCommands;
|
private DCommands dCommands;
|
||||||
|
private DSigns dSigns;
|
||||||
private Dungeons dungeons;
|
private Dungeons dungeons;
|
||||||
|
|
||||||
private CopyOnWriteArrayList<Player> chatSpyers = new CopyOnWriteArrayList<Player>();
|
private CopyOnWriteArrayList<Player> chatSpyers = new CopyOnWriteArrayList<Player>();
|
||||||
@ -67,15 +71,14 @@ public class DungeonsXL extends JavaPlugin {
|
|||||||
getDataFolder().mkdir();
|
getDataFolder().mkdir();
|
||||||
|
|
||||||
// Load Language
|
// Load Language
|
||||||
dMessages = new DMessages(new File(plugin.getDataFolder(), "languages/en.yml"));
|
loadDMessages(new File(plugin.getDataFolder(), "languages/en.yml"));
|
||||||
|
|
||||||
// Load Config
|
// Load Config
|
||||||
mainConfig = new MainConfig(new File(plugin.getDataFolder(), "config.yml"));
|
loadMainConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||||
|
|
||||||
// Load Language 2
|
// Load Language 2
|
||||||
loadDMessages(new File(plugin.getDataFolder(), "languages/" + mainConfig.getLanguage() + ".yml"));
|
loadDMessages(new File(plugin.getDataFolder(), "languages/" + mainConfig.getLanguage() + ".yml"));
|
||||||
loadVersionUtil();
|
loadVersionUtil();
|
||||||
loadDCommands();
|
loadDCommands();
|
||||||
|
loadDSigns();
|
||||||
loadDungeons();
|
loadDungeons();
|
||||||
|
|
||||||
// InitFolders
|
// InitFolders
|
||||||
@ -88,11 +91,11 @@ public class DungeonsXL extends JavaPlugin {
|
|||||||
loadEconomyProvider();
|
loadEconomyProvider();
|
||||||
|
|
||||||
getCommand("dungeonsxl").setExecutor(new CommandListener());
|
getCommand("dungeonsxl").setExecutor(new CommandListener());
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new EntityListener(), this);
|
getServer().getPluginManager().registerEvents(new EntityListener(), this);
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new BlockListener(), this);
|
getServer().getPluginManager().registerEvents(new BlockListener(), this);
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new WorldListener(), this);
|
getServer().getPluginManager().registerEvents(new WorldListener(), this);
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new HangingListener(), this);
|
getServer().getPluginManager().registerEvents(new HangingListener(), this);
|
||||||
|
|
||||||
// Load All
|
// Load All
|
||||||
loadAll();
|
loadAll();
|
||||||
@ -167,14 +170,14 @@ public class DungeonsXL extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (GameWorld gworld : gameWorlds) {
|
for (GameWorld gworld : gameWorlds) {
|
||||||
if (gworld.world.getPlayers().isEmpty()) {
|
if (gworld.getWorld().getPlayers().isEmpty()) {
|
||||||
if (DPlayer.get(gworld.world).isEmpty()) {
|
if (DPlayer.get(gworld.getWorld()).isEmpty()) {
|
||||||
gworld.delete();
|
gworld.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (EditWorld eworld : editWorlds) {
|
for (EditWorld eworld : editWorlds) {
|
||||||
if (eworld.world.getPlayers().isEmpty()) {
|
if (eworld.getWorld().getPlayers().isEmpty()) {
|
||||||
eworld.delete();
|
eworld.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,6 +211,7 @@ public class DungeonsXL extends JavaPlugin {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
configFile.save(file);
|
configFile.save(file);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -243,6 +247,7 @@ public class DungeonsXL extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileUtil.removeDirectory(file);
|
FileUtil.removeDirectory(file);
|
||||||
|
|
||||||
} else if (file.getName().contains("DXL_Game_") && file.isDirectory()) {
|
} else if (file.getName().contains("DXL_Game_") && file.isDirectory()) {
|
||||||
FileUtil.removeDirectory(file);
|
FileUtil.removeDirectory(file);
|
||||||
}
|
}
|
||||||
@ -276,6 +281,7 @@ public class DungeonsXL extends JavaPlugin {
|
|||||||
this.economyProvider = economyProvider.getProvider();
|
this.economyProvider = economyProvider.getProvider();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (NoClassDefFoundError error) {
|
} catch (NoClassDefFoundError error) {
|
||||||
getLogger().info("Could not hook into Vault to register an economy provider!");
|
getLogger().info("Could not hook into Vault to register an economy provider!");
|
||||||
}
|
}
|
||||||
@ -297,6 +303,7 @@ public class DungeonsXL extends JavaPlugin {
|
|||||||
if (permissionProvider != null) {
|
if (permissionProvider != null) {
|
||||||
this.permissionProvider = permissionProvider.getProvider();
|
this.permissionProvider = permissionProvider.getProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (NoClassDefFoundError error) {
|
} catch (NoClassDefFoundError error) {
|
||||||
getLogger().info("Could not hook into Vault to register a permission provider!");
|
getLogger().info("Could not hook into Vault to register a permission provider!");
|
||||||
}
|
}
|
||||||
@ -372,6 +379,20 @@ public class DungeonsXL extends JavaPlugin {
|
|||||||
dCommands = new DCommands();
|
dCommands = new DCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the dSigns
|
||||||
|
*/
|
||||||
|
public DSigns getDSigns() {
|
||||||
|
return dSigns;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load / reload a new instance of Dungeons
|
||||||
|
*/
|
||||||
|
public void loadDSigns() {
|
||||||
|
dSigns = new DSigns();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the loaded instance of Dungeons
|
* @return the loaded instance of Dungeons
|
||||||
*/
|
*/
|
||||||
|
@ -21,18 +21,18 @@ public class ChatCommand extends DCommand {
|
|||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
|
||||||
if (dplayer != null) {
|
if (dplayer == null) {
|
||||||
if (dplayer.isInDungeonChat) {
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
|
||||||
dplayer.isInDungeonChat = false;
|
return;
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Chat_NormalChat"));
|
}
|
||||||
|
|
||||||
} else {
|
if (dplayer.isInDungeonChat()) {
|
||||||
dplayer.isInDungeonChat = true;
|
dplayer.setInDungeonChat(false);
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Chat_DungeonChat"));
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Chat_NormalChat"));
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
|
dplayer.setInDungeonChat(true);
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Chat_DungeonChat"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,11 +31,11 @@ public class CreateCommand extends DCommand {
|
|||||||
plugin.getLogger().info(plugin.getDMessages().get("Log_GenerateNewWorld"));
|
plugin.getLogger().info(plugin.getDMessages().get("Log_GenerateNewWorld"));
|
||||||
|
|
||||||
// Create World
|
// Create World
|
||||||
EditWorld eworld = new EditWorld();
|
EditWorld editWorld = new EditWorld();
|
||||||
eworld.generate();
|
editWorld.generate();
|
||||||
eworld.dungeonname = name;
|
editWorld.setMapName(name);
|
||||||
eworld.save();
|
editWorld.save();
|
||||||
eworld.delete();
|
editWorld.delete();
|
||||||
|
|
||||||
// MSG Done
|
// MSG Done
|
||||||
plugin.getLogger().info(plugin.getDMessages().get("Log_WorldGenerationFinished"));
|
plugin.getLogger().info(plugin.getDMessages().get("Log_WorldGenerationFinished"));
|
||||||
@ -47,34 +47,34 @@ public class CreateCommand extends DCommand {
|
|||||||
} else if (sender instanceof Player) {
|
} else if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (DPlayer.get(player) == null) {
|
if (DPlayer.get(player) != null) {
|
||||||
if (name.length() <= 15) {
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
|
||||||
// Msg create
|
return;
|
||||||
plugin.getLogger().info(plugin.getDMessages().get("Log_NewDungeon"));
|
}
|
||||||
plugin.getLogger().info(plugin.getDMessages().get("Log_GenerateNewWorld"));
|
|
||||||
|
if (name.length() <= 15) {
|
||||||
// Create World
|
// Msg create
|
||||||
EditWorld eworld = new EditWorld();
|
plugin.getLogger().info(plugin.getDMessages().get("Log_NewDungeon"));
|
||||||
eworld.generate();
|
plugin.getLogger().info(plugin.getDMessages().get("Log_GenerateNewWorld"));
|
||||||
eworld.dungeonname = name;
|
|
||||||
|
// Create World
|
||||||
// MSG Done
|
EditWorld editWorld = new EditWorld();
|
||||||
plugin.getLogger().info(plugin.getDMessages().get("Log_WorldGenerationFinished"));
|
editWorld.generate();
|
||||||
|
editWorld.setMapName(name);
|
||||||
// Tp Player
|
|
||||||
if (eworld.lobby == null) {
|
// MSG Done
|
||||||
new DPlayer(player, eworld.world, eworld.world.getSpawnLocation(), true);
|
plugin.getLogger().info(plugin.getDMessages().get("Log_WorldGenerationFinished"));
|
||||||
|
|
||||||
} else {
|
// Tp Player
|
||||||
new DPlayer(player, eworld.world, eworld.lobby, true);
|
if (editWorld.getLobby() == null) {
|
||||||
}
|
new DPlayer(player, editWorld.getWorld(), editWorld.getWorld().getSpawnLocation(), true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NameToLong"));
|
new DPlayer(player, editWorld.getWorld(), editWorld.getLobby(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NameToLong"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ public class DeletePortalCommand extends DCommand {
|
|||||||
if (dPortal != null) {
|
if (dPortal != null) {
|
||||||
dPortal.delete();
|
dPortal.delete();
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalDeleted"));
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalDeleted"));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoPortal"));
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoPortal"));
|
||||||
}
|
}
|
||||||
|
@ -27,26 +27,31 @@ public class EditCommand extends DCommand {
|
|||||||
DGroup dgroup = DGroup.get(player);
|
DGroup dgroup = DGroup.get(player);
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
|
||||||
if (EditWorld.isInvitedPlayer(dungeonName, player.getUniqueId(), player.getName()) || player.hasPermission("dxl.edit")) {
|
if ( !(EditWorld.isInvitedPlayer(dungeonName, player.getUniqueId(), player.getName()) || player.hasPermission("dxl.edit"))) {
|
||||||
if (dplayer == null) {
|
|
||||||
if (dgroup == null) {
|
|
||||||
if (eworld != null) {
|
|
||||||
if (eworld.lobby == null) {
|
|
||||||
new DPlayer(player, eworld.world, eworld.world.getSpawnLocation(), true);
|
|
||||||
} else {
|
|
||||||
new DPlayer(player, eworld.world, eworld.lobby, true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_DungeonNotExist", dungeonName));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveGroup"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoPermission"));
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoPermission"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dplayer != null) {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dgroup != null) {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveGroup"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eworld == null) {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_DungeonNotExist", dungeonName));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eworld.getLobby() == null) {
|
||||||
|
new DPlayer(player, eworld.getWorld(), eworld.getWorld().getSpawnLocation(), true);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
new DPlayer(player, eworld.getWorld(), eworld.getLobby(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,21 +24,21 @@ public class EscapeCommand extends DCommand {
|
|||||||
DPlayer dplayer = DPlayer.get(player);
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
if (dplayer != null) {
|
if (dplayer != null) {
|
||||||
|
|
||||||
if (dplayer.isEditing) {
|
if ( !dplayer.isEditing()) {
|
||||||
dplayer.escape();
|
|
||||||
|
|
||||||
EditWorld eworld = EditWorld.get(dplayer.world);
|
|
||||||
if (eworld != null) {
|
|
||||||
if (eworld.world.getPlayers().isEmpty()) {
|
|
||||||
eworld.deleteNoSave();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
|
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 {
|
} else {
|
||||||
DGroup dgroup = DGroup.get(player);
|
DGroup dgroup = DGroup.get(player);
|
||||||
|
@ -22,6 +22,7 @@ public class InviteCommand extends DCommand {
|
|||||||
public void onExecute(String[] args, CommandSender sender) {
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
if (EditWorld.addInvitedPlayer(args[2], UUIDUtil.getUniqueIdFromName(args[1]))) {
|
if (EditWorld.addInvitedPlayer(args[2], UUIDUtil.getUniqueIdFromName(args[1]))) {
|
||||||
MessageUtil.sendMessage(sender, plugin.getDMessages().get("Cmd_Invite_Success", args[1], args[2]));
|
MessageUtil.sendMessage(sender, plugin.getDMessages().get("Cmd_Invite_Success", args[1], args[2]));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MessageUtil.sendMessage(sender, plugin.getDMessages().get("Error_DungeonNotExist", args[2]));
|
MessageUtil.sendMessage(sender, plugin.getDMessages().get("Error_DungeonNotExist", args[2]));
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public class LeaveCommand extends DCommand {
|
|||||||
DPlayer dplayer = DPlayer.get(player);
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
|
||||||
if (GameWorld.get(player.getWorld()) != null) {
|
if (GameWorld.get(player.getWorld()) != null) {
|
||||||
if (GameWorld.get(player.getWorld()).isTutorial) {
|
if (GameWorld.get(player.getWorld()).isTutorial()) {
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoLeaveInTutorial"));
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoLeaveInTutorial"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,10 @@ public class ListCommand extends DCommand {
|
|||||||
}
|
}
|
||||||
ArrayList<String> loadedList = new ArrayList<String>();
|
ArrayList<String> loadedList = new ArrayList<String>();
|
||||||
for (EditWorld editWorld : plugin.getEditWorlds()) {
|
for (EditWorld editWorld : plugin.getEditWorlds()) {
|
||||||
loadedList.add(editWorld.world.getWorldFolder().getName());
|
loadedList.add(editWorld.getWorld().getWorldFolder().getName());
|
||||||
}
|
}
|
||||||
for (GameWorld gameWorld : plugin.getGameWorlds()) {
|
for (GameWorld gameWorld : plugin.getGameWorlds()) {
|
||||||
loadedList.add(gameWorld.world.getWorldFolder().getName());
|
loadedList.add(gameWorld.getWorld().getWorldFolder().getName());
|
||||||
}
|
}
|
||||||
ArrayList<String> toSend = new ArrayList<String>();
|
ArrayList<String> toSend = new ArrayList<String>();
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public class LivesCommand extends DCommand {
|
|||||||
|
|
||||||
DPlayer dPlayer = DPlayer.get(player);
|
DPlayer dPlayer = DPlayer.get(player);
|
||||||
if (dPlayer != null) {
|
if (dPlayer != null) {
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Lives").replaceAll("v1", player.getName()).replaceAll("v2", String.valueOf(dPlayer.lives)));
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Lives").replaceAll("v1", player.getName()).replaceAll("v2", String.valueOf(dPlayer.getLives())));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
|
||||||
|
@ -25,65 +25,65 @@ public class MsgCommand extends DCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
EditWorld eworld = EditWorld.get(player.getWorld());
|
EditWorld editWorld = EditWorld.get(player.getWorld());
|
||||||
|
|
||||||
if (eworld != null) {
|
if (editWorld == null) {
|
||||||
if (args.length > 1) {
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
|
||||||
try {
|
return;
|
||||||
int id = IntegerUtil.parseInt(args[1]);
|
}
|
||||||
|
|
||||||
|
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"));
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_MsgIdNotExist", "" + id));
|
||||||
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 {
|
} 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 {
|
} catch (NumberFormatException e) {
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_MsgNoInt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -90,17 +90,17 @@ public class PlayCommand extends DCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DGroup dgroup = new DGroup(player, identifier, multiFloor);
|
DGroup dGroup = new DGroup(player, identifier, multiFloor);
|
||||||
|
|
||||||
if (dgroup.getGWorld() == null) {
|
if (dGroup.getGWorld() == null) {
|
||||||
dgroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName()));
|
dGroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dgroup.getGWorld().locLobby == null) {
|
if (dGroup.getGWorld().getLocLobby() == null) {
|
||||||
new DPlayer(player, dgroup.getGWorld().world, dgroup.getGWorld().world.getSpawnLocation(), false);
|
new DPlayer(player, dGroup.getGWorld().getWorld(), dGroup.getGWorld().getWorld().getSpawnLocation(), false);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
new DPlayer(player, dgroup.getGWorld().world, dgroup.getGWorld().locLobby, false);
|
new DPlayer(player, dGroup.getGWorld().getWorld(), dGroup.getGWorld().getLocLobby(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,23 +25,22 @@ public class PortalCommand extends DCommand {
|
|||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
|
||||||
if (dplayer == null) {
|
if (dplayer != null) {
|
||||||
DPortal dportal = DPortal.get(player);
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
|
||||||
|
}
|
||||||
if (dportal == null) {
|
|
||||||
dportal = new DPortal(false);
|
DPortal dportal = DPortal.get(player);
|
||||||
dportal.setPlayer(player);
|
|
||||||
dportal.setWorld(player.getWorld());
|
if (dportal == null) {
|
||||||
player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD));
|
dportal = new DPortal(false);
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalIntroduction"));
|
dportal.setPlayer(player);
|
||||||
|
dportal.setWorld(player.getWorld());
|
||||||
} else {
|
player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD));
|
||||||
plugin.getDPortals().remove(dportal);
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalIntroduction"));
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalAbort"));
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
|
plugin.getDPortals().remove(dportal);
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalAbort"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,22 +65,22 @@ public class TestCommand extends DCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DGroup dgroup = new DGroup(player, identifier, multiFloor);
|
DGroup dGroup = new DGroup(player, identifier, multiFloor);
|
||||||
|
|
||||||
if (dgroup.getGWorld() == null) {
|
if (dGroup.getGWorld() == null) {
|
||||||
dgroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName()));
|
dGroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DPlayer newDPlayer;
|
DPlayer newDPlayer;
|
||||||
|
|
||||||
if (dgroup.getGWorld().locLobby == null) {
|
if (dGroup.getGWorld().getLocLobby() == null) {
|
||||||
newDPlayer = new DPlayer(player, dgroup.getGWorld().world, dgroup.getGWorld().world.getSpawnLocation(), false);
|
newDPlayer = new DPlayer(player, dGroup.getGWorld().getWorld(), dGroup.getGWorld().getWorld().getSpawnLocation(), false);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
newDPlayer = new DPlayer(player, dgroup.getGWorld().world, dgroup.getGWorld().locLobby, false);
|
newDPlayer = new DPlayer(player, dGroup.getGWorld().getWorld(), dGroup.getGWorld().getLocLobby(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
newDPlayer.isinTestMode = true;
|
newDPlayer.setIsInTestMode(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,13 @@ public class DLootInventory {
|
|||||||
|
|
||||||
private long time;
|
private long time;
|
||||||
|
|
||||||
public DLootInventory(Player player, ItemStack[] istacks) {
|
public DLootInventory(Player player, ItemStack[] itemStacks) {
|
||||||
plugin.getDLootInventories().add(this);
|
plugin.getDLootInventories().add(this);
|
||||||
|
|
||||||
inventory = Bukkit.createInventory(player, 54, ChatColor.translateAlternateColorCodes('&', DungeonsXL.getPlugin().getDMessages().get("Player_Treasures")));
|
inventory = Bukkit.createInventory(player, 54, ChatColor.translateAlternateColorCodes('&', DungeonsXL.getPlugin().getDMessages().get("Player_Treasures")));
|
||||||
for (ItemStack istack : istacks) {
|
for (ItemStack itemStack : itemStacks) {
|
||||||
if (istack != null) {
|
if (itemStack != null) {
|
||||||
inventory.addItem(istack);
|
inventory.addItem(itemStack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
@ -28,14 +28,14 @@ public class EditWorld {
|
|||||||
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
public World world;
|
private World world;
|
||||||
public String owner;
|
private String owner;
|
||||||
public String name;
|
private String name;
|
||||||
public String dungeonname;
|
private String mapName;
|
||||||
public int id;
|
private int id;
|
||||||
public Location lobby;
|
private Location lobby;
|
||||||
public CopyOnWriteArrayList<String> invitedPlayers = new CopyOnWriteArrayList<String>();
|
private CopyOnWriteArrayList<String> invitedPlayers = new CopyOnWriteArrayList<String>();
|
||||||
public CopyOnWriteArrayList<Block> sign = new CopyOnWriteArrayList<Block>();
|
private CopyOnWriteArrayList<Block> sign = new CopyOnWriteArrayList<Block>();
|
||||||
|
|
||||||
public EditWorld() {
|
public EditWorld() {
|
||||||
plugin.getEditWorlds().add(this);
|
plugin.getEditWorlds().add(this);
|
||||||
@ -46,8 +46,8 @@ public class EditWorld {
|
|||||||
while (id == -1) {
|
while (id == -1) {
|
||||||
i++;
|
i++;
|
||||||
boolean exist = false;
|
boolean exist = false;
|
||||||
for (EditWorld eworld : plugin.getEditWorlds()) {
|
for (EditWorld editWorld : plugin.getEditWorlds()) {
|
||||||
if (eworld.id == i) {
|
if (editWorld.id == i) {
|
||||||
exist = true;
|
exist = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ public class EditWorld {
|
|||||||
world.save();
|
world.save();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(new File(plugin.getDataFolder(), "/maps/" + dungeonname + "/DXLData.data")));
|
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(new File(plugin.getDataFolder(), "/maps/" + mapName + "/DXLData.data")));
|
||||||
out.writeInt(sign.size());
|
out.writeInt(sign.size());
|
||||||
for (Block sign : this.sign) {
|
for (Block sign : this.sign) {
|
||||||
out.writeInt(sign.getX());
|
out.writeInt(sign.getX());
|
||||||
@ -104,8 +104,8 @@ public class EditWorld {
|
|||||||
|
|
||||||
plugin.getServer().unloadWorld(world, true);
|
plugin.getServer().unloadWorld(world, true);
|
||||||
File dir = new File("DXL_Edit_" + id);
|
File dir = new File("DXL_Edit_" + id);
|
||||||
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + dungeonname));
|
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName));
|
||||||
FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + dungeonname));
|
FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
|
||||||
FileUtil.removeDirectory(dir);
|
FileUtil.removeDirectory(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,17 +117,17 @@ public class EditWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
File dir = new File("DXL_Edit_" + id);
|
File dir = new File("DXL_Edit_" + id);
|
||||||
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + dungeonname));
|
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName));
|
||||||
FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + dungeonname));
|
FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
|
||||||
plugin.getServer().unloadWorld(world, true);
|
plugin.getServer().unloadWorld(world, true);
|
||||||
FileUtil.removeDirectory(dir);
|
FileUtil.removeDirectory(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
public static EditWorld get(World world) {
|
public static EditWorld get(World world) {
|
||||||
for (EditWorld eworld : plugin.getEditWorlds()) {
|
for (EditWorld editWorld : plugin.getEditWorlds()) {
|
||||||
if (eworld.world.equals(world)) {
|
if (editWorld.world.equals(world)) {
|
||||||
return eworld;
|
return editWorld;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,9 +135,9 @@ public class EditWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static EditWorld get(String name) {
|
public static EditWorld get(String name) {
|
||||||
for (EditWorld eworld : plugin.getEditWorlds()) {
|
for (EditWorld editWorld : plugin.getEditWorlds()) {
|
||||||
if (eworld.dungeonname.equalsIgnoreCase(name)) {
|
if (editWorld.mapName.equalsIgnoreCase(name)) {
|
||||||
return eworld;
|
return editWorld;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,47 +145,47 @@ public class EditWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteAll() {
|
public static void deleteAll() {
|
||||||
for (EditWorld eworld : plugin.getEditWorlds()) {
|
for (EditWorld editWorld : plugin.getEditWorlds()) {
|
||||||
eworld.delete();
|
editWorld.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EditWorld load(String name) {
|
public static EditWorld load(String name) {
|
||||||
for (EditWorld eworld : plugin.getEditWorlds()) {
|
for (EditWorld editWorld : plugin.getEditWorlds()) {
|
||||||
|
|
||||||
if (eworld.dungeonname.equalsIgnoreCase(name)) {
|
if (editWorld.mapName.equalsIgnoreCase(name)) {
|
||||||
return eworld;
|
return editWorld;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = new File(plugin.getDataFolder(), "/maps/" + name);
|
File file = new File(plugin.getDataFolder(), "/maps/" + name);
|
||||||
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
EditWorld eworld = new EditWorld();
|
EditWorld editWorld = new EditWorld();
|
||||||
eworld.dungeonname = name;
|
editWorld.mapName = name;
|
||||||
// World
|
// World
|
||||||
FileUtil.copyDirectory(file, new File("DXL_Edit_" + eworld.id));
|
FileUtil.copyDirectory(file, new File("DXL_Edit_" + editWorld.id));
|
||||||
|
|
||||||
// Id File
|
// Id File
|
||||||
File idFile = new File("DXL_Edit_" + eworld.id + "/.id_" + name);
|
File idFile = new File("DXL_Edit_" + editWorld.id + "/.id_" + name);
|
||||||
try {
|
try {
|
||||||
idFile.createNewFile();
|
idFile.createNewFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
eworld.world = plugin.getServer().createWorld(WorldCreator.name("DXL_Edit_" + eworld.id));
|
editWorld.world = plugin.getServer().createWorld(WorldCreator.name("DXL_Edit_" + editWorld.id));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ObjectInputStream os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder(), "/maps/" + eworld.dungeonname + "/DXLData.data")));
|
ObjectInputStream os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder(), "/maps/" + editWorld.mapName + "/DXLData.data")));
|
||||||
int length = os.readInt();
|
int length = os.readInt();
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
int x = os.readInt();
|
int x = os.readInt();
|
||||||
int y = os.readInt();
|
int y = os.readInt();
|
||||||
int z = os.readInt();
|
int z = os.readInt();
|
||||||
Block block = eworld.world.getBlockAt(x, y, z);
|
Block block = editWorld.world.getBlockAt(x, y, z);
|
||||||
eworld.checkSign(block);
|
editWorld.checkSign(block);
|
||||||
eworld.sign.add(block);
|
editWorld.sign.add(block);
|
||||||
}
|
}
|
||||||
os.close();
|
os.close();
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ public class EditWorld {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return eworld;
|
return editWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -203,8 +203,8 @@ public class EditWorld {
|
|||||||
|
|
||||||
public static boolean exist(String name) {
|
public static boolean exist(String name) {
|
||||||
// Cheack Loaded EditWorlds
|
// Cheack Loaded EditWorlds
|
||||||
for (EditWorld eworld : plugin.getEditWorlds()) {
|
for (EditWorld editWorld : plugin.getEditWorlds()) {
|
||||||
if (eworld.dungeonname.equalsIgnoreCase(name)) {
|
if (editWorld.mapName.equalsIgnoreCase(name)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -221,14 +221,14 @@ public class EditWorld {
|
|||||||
|
|
||||||
public void msg(String msg) {
|
public void msg(String msg) {
|
||||||
for (DPlayer dplayer : DPlayer.get(world)) {
|
for (DPlayer dplayer : DPlayer.get(world)) {
|
||||||
MessageUtil.sendMessage(dplayer.player, msg);
|
MessageUtil.sendMessage(dplayer.getPlayer(), msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invite
|
// Invite
|
||||||
public static boolean addInvitedPlayer(String eworldname, UUID uuid) {
|
public static boolean addInvitedPlayer(String editWorldname, UUID uuid) {
|
||||||
if (exist(eworldname)) {
|
if (exist(editWorldname)) {
|
||||||
WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + eworldname, "config.yml"));
|
WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + editWorldname, "config.yml"));
|
||||||
config.addInvitedPlayer(uuid.toString());
|
config.addInvitedPlayer(uuid.toString());
|
||||||
config.save();
|
config.save();
|
||||||
return true;
|
return true;
|
||||||
@ -237,20 +237,19 @@ public class EditWorld {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean removeInvitedPlayer(String eworldname, UUID uuid, String name) {
|
public static boolean removeInvitedPlayer(String editWorldName, UUID uuid, String name) {
|
||||||
|
if (exist(editWorldName)) {
|
||||||
if (exist(eworldname)) {
|
WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml"));
|
||||||
WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + eworldname, "config.yml"));
|
|
||||||
config.removeInvitedPlayers(uuid.toString(), name.toLowerCase());
|
config.removeInvitedPlayers(uuid.toString(), name.toLowerCase());
|
||||||
config.save();
|
config.save();
|
||||||
|
|
||||||
// Kick Player
|
// Kick Player
|
||||||
EditWorld eworld = EditWorld.get(eworldname);
|
EditWorld editWorld = EditWorld.get(editWorldName);
|
||||||
if (eworld != null) {
|
if (editWorld != null) {
|
||||||
DPlayer player = DPlayer.get(name);
|
DPlayer player = DPlayer.get(name);
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
if (eworld.world.getPlayers().contains(player.player)) {
|
if (editWorld.world.getPlayers().contains(player.getPlayer())) {
|
||||||
player.leave();
|
player.leave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -262,16 +261,139 @@ public class EditWorld {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInvitedPlayer(String eworldname, UUID uuid, String name) {
|
public static boolean isInvitedPlayer(String editWorldname, UUID uuid, String name) {
|
||||||
if (exist(eworldname)) {
|
if ( !exist(editWorldname)) {
|
||||||
WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + eworldname, "config.yml"));
|
return false;
|
||||||
// get player from both a 0.9.1 and lower and 0.9.2 and higher file
|
|
||||||
if (config.getInvitedPlayers().contains(name.toLowerCase()) || config.getInvitedPlayers().contains(uuid.toString())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -263,31 +263,33 @@ public class WorldConfig {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void save() {
|
public void save() {
|
||||||
if (file != null) {
|
if (file == null) {
|
||||||
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
|
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
|
} catch (IOException e) {
|
||||||
for (Integer msgs : this.msgs.keySet()) {
|
e.printStackTrace();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,58 +18,71 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
public class GameChest {
|
public class GameChest {
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
public boolean isUsed = false;
|
private boolean isUsed = false;
|
||||||
public Chest chest;
|
private Chest chest;
|
||||||
public GameWorld gWorld;
|
private GameWorld gameWorld;
|
||||||
public double moneyReward;
|
private double moneyReward;
|
||||||
|
|
||||||
public GameChest(Block chest, GameWorld gWorld, double moneyReward) {
|
public GameChest(Block chest, GameWorld gameWorld, double moneyReward) {
|
||||||
if (chest.getState() instanceof Chest) {
|
if ( !(chest.getState() instanceof Chest)) {
|
||||||
this.chest = (Chest) chest.getState();
|
return;
|
||||||
|
|
||||||
this.gWorld = gWorld;
|
|
||||||
|
|
||||||
this.moneyReward = moneyReward;
|
|
||||||
|
|
||||||
gWorld.gameChests.add(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.chest = (Chest) chest.getState();
|
||||||
|
|
||||||
|
this.gameWorld = gameWorld;
|
||||||
|
|
||||||
|
this.moneyReward = moneyReward;
|
||||||
|
|
||||||
|
gameWorld.getGameChests().add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTreasure(DGroup dgroup) {
|
public void addTreasure(DGroup dGroup) {
|
||||||
if (dgroup != null) {
|
if (dGroup == null) {
|
||||||
for (Player player : dgroup.getPlayers()) {
|
return;
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
}
|
||||||
if (dplayer != null) {
|
|
||||||
dplayer.treasureMoney = dplayer.treasureMoney + moneyReward;
|
for (Player player : dGroup.getPlayers()) {
|
||||||
String msg = "";
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
for (ItemStack istack : chest.getInventory().getContents()) {
|
if (dplayer == null) {
|
||||||
|
continue;
|
||||||
if (istack != null) {
|
}
|
||||||
dplayer.treasureInv.addItem(istack);
|
|
||||||
String name;
|
dplayer.setTreasureMoney(dplayer.getTreasureMoney() + moneyReward);
|
||||||
|
String msg = "";
|
||||||
if (istack.hasItemMeta() && istack.getItemMeta().hasDisplayName()) {
|
for (ItemStack itemStack : chest.getInventory().getContents()) {
|
||||||
name = istack.getItemMeta().getDisplayName();
|
|
||||||
|
if (itemStack == null) {
|
||||||
} else {
|
continue;
|
||||||
ItemInfo itemInfo = Items.itemByStack(istack);
|
}
|
||||||
if (itemInfo != null) {
|
|
||||||
name = itemInfo.getName();
|
dplayer.getTreasureInv().addItem(itemStack);
|
||||||
} else {
|
String name;
|
||||||
name = istack.getType().name();
|
|
||||||
}
|
if ( !itemStack.hasItemMeta()) {
|
||||||
}
|
continue;
|
||||||
msg = msg + ChatColor.RED + " " + istack.getAmount() + " " + name + ChatColor.GOLD + ",";
|
}
|
||||||
}
|
|
||||||
}
|
if (itemStack.getItemMeta().hasDisplayName()) {
|
||||||
|
name = itemStack.getItemMeta().getDisplayName();
|
||||||
|
|
||||||
msg = msg.substring(0, msg.length() - 1);
|
} else {
|
||||||
|
ItemInfo itemInfo = Items.itemByStack(itemStack);
|
||||||
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_LootAdded", msg));
|
if (itemInfo != null) {
|
||||||
if (moneyReward != 0) {
|
name = itemInfo.getName();
|
||||||
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_LootAdded", String.valueOf(moneyReward)));
|
} 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) {
|
public static void onOpenInventory(InventoryOpenEvent event) {
|
||||||
InventoryView inventory = event.getView();
|
InventoryView inventory = event.getView();
|
||||||
|
|
||||||
GameWorld gWorld = GameWorld.get(event.getPlayer().getWorld());
|
GameWorld gameWorld = GameWorld.get(event.getPlayer().getWorld());
|
||||||
|
|
||||||
if (gWorld != null) {
|
if (gameWorld == null) {
|
||||||
if (inventory.getTopInventory().getHolder() instanceof Chest) {
|
return;
|
||||||
Chest chest = (Chest) inventory.getTopInventory().getHolder();
|
}
|
||||||
|
|
||||||
for (GameChest gchest : gWorld.gameChests) {
|
if (inventory.getTopInventory().getHolder() instanceof Chest) {
|
||||||
if (gchest.chest.equals(chest)) {
|
return;
|
||||||
|
}
|
||||||
if ( !gchest.isUsed) {
|
|
||||||
if (gchest.chest.getLocation().distance(chest.getLocation()) < 1) {
|
Chest chest = (Chest) inventory.getTopInventory().getHolder();
|
||||||
gchest.addTreasure(DGroup.get(gWorld));
|
|
||||||
gchest.isUsed = true;
|
for (GameChest gameChest : gameWorld.getGameChests()) {
|
||||||
event.setCancelled(true);
|
if ( !gameChest.chest.equals(chest)) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
} else {
|
|
||||||
MessageUtil.sendMessage(DungeonsXL.getPlugin().getServer().getPlayer(event.getPlayer().getUniqueId()), DungeonsXL.getPlugin().getDMessages().get("Error_ChestIsOpened"));
|
if ( !gameChest.isUsed) {
|
||||||
event.setCancelled(true);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class GamePlaceableBlock {
|
|||||||
String[] splittedIds = ids.split(",");
|
String[] splittedIds = ids.split(",");
|
||||||
for (String id : splittedIds) {
|
for (String id : splittedIds) {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
Material mat = Material.getMaterial(IntegerUtil.parseInt(id));
|
Material mat = Material.getMaterial(IntegerUtil.parseInt(id));
|
||||||
if (mat != null) {
|
if (mat != null) {
|
||||||
mats.add(mat);
|
mats.add(mat);
|
||||||
}
|
}
|
||||||
@ -42,151 +42,192 @@ public class GamePlaceableBlock {
|
|||||||
for (int direction = 0; direction < 6; direction++) {
|
for (int direction = 0; direction < 6; direction++) {
|
||||||
boolean positive = String.valueOf(directions.charAt(direction)).equals("x");
|
boolean positive = String.valueOf(directions.charAt(direction)).equals("x");
|
||||||
|
|
||||||
if (positive) {
|
if ( !positive) {
|
||||||
if (direction == 0) {
|
continue;
|
||||||
onTop = true;
|
}
|
||||||
}
|
|
||||||
if (direction == 1) {
|
if (direction == 0) {
|
||||||
onBottom = true;
|
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) {
|
} else {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
int data = block.getData();
|
int data = block.getData();
|
||||||
switch (data) {
|
switch (data) {
|
||||||
case 3:
|
case 0:
|
||||||
if (direction == 2) {
|
case 1:
|
||||||
onNorth = true;
|
case 2:
|
||||||
}
|
case 15:
|
||||||
if (direction == 3) {
|
if (direction == 2) {
|
||||||
onEast = true;
|
onNorth = true;
|
||||||
}
|
}
|
||||||
if (direction == 4) {
|
|
||||||
onSouth = true;
|
if (direction == 3) {
|
||||||
}
|
onEast = true;
|
||||||
if (direction == 5) {
|
}
|
||||||
onWest = true;
|
|
||||||
}
|
if (direction == 4) {
|
||||||
break;
|
onSouth = true;
|
||||||
case 4:
|
}
|
||||||
if (direction == 5) {
|
|
||||||
onNorth = true;
|
if (direction == 5) {
|
||||||
}
|
onWest = true;
|
||||||
if (direction == 2) {
|
}
|
||||||
onEast = true;
|
|
||||||
}
|
break;
|
||||||
if (direction == 3) {
|
case 4:
|
||||||
onSouth = true;
|
case 3:
|
||||||
}
|
case 5:
|
||||||
if (direction == 4) {
|
case 6:
|
||||||
onWest = true;
|
if (direction == 5) {
|
||||||
}
|
onNorth = true;
|
||||||
break;
|
}
|
||||||
case 2:
|
|
||||||
if (direction == 4) {
|
if (direction == 2) {
|
||||||
onNorth = true;
|
onEast = true;
|
||||||
}
|
}
|
||||||
if (direction == 5) {
|
|
||||||
onEast = true;
|
if (direction == 3) {
|
||||||
}
|
onSouth = true;
|
||||||
if (direction == 2) {
|
}
|
||||||
onSouth = true;
|
|
||||||
}
|
if (direction == 4) {
|
||||||
if (direction == 3) {
|
onWest = true;
|
||||||
onWest = true;
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 5:
|
|
||||||
if (direction == 3) {
|
case 8:
|
||||||
onNorth = true;
|
case 7:
|
||||||
}
|
case 9:
|
||||||
if (direction == 4) {
|
case 10:
|
||||||
onEast = true;
|
if (direction == 4) {
|
||||||
}
|
onNorth = true;
|
||||||
if (direction == 5) {
|
}
|
||||||
onSouth = true;
|
|
||||||
}
|
if (direction == 5) {
|
||||||
if (direction == 2) {
|
onEast = true;
|
||||||
onWest = true;
|
}
|
||||||
}
|
|
||||||
break;
|
if (direction == 2) {
|
||||||
}
|
onSouth = true;
|
||||||
} else {
|
}
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
int data = block.getData();
|
if (direction == 3) {
|
||||||
switch (data) {
|
onWest = true;
|
||||||
case 0:
|
}
|
||||||
case 1:
|
|
||||||
case 2:
|
break;
|
||||||
case 15:
|
case 12:
|
||||||
if (direction == 2) {
|
case 11:
|
||||||
onNorth = true;
|
case 13:
|
||||||
}
|
case 14:
|
||||||
if (direction == 3) {
|
if (direction == 3) {
|
||||||
onEast = true;
|
onNorth = true;
|
||||||
}
|
}
|
||||||
if (direction == 4) {
|
|
||||||
onSouth = true;
|
if (direction == 4) {
|
||||||
}
|
onEast = true;
|
||||||
if (direction == 5) {
|
}
|
||||||
onWest = true;
|
|
||||||
}
|
if (direction == 5) {
|
||||||
break;
|
onSouth = true;
|
||||||
case 4:
|
}
|
||||||
case 3:
|
|
||||||
case 5:
|
if (direction == 2) {
|
||||||
case 6:
|
onWest = true;
|
||||||
if (direction == 5) {
|
}
|
||||||
onNorth = true;
|
|
||||||
}
|
break;
|
||||||
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 {
|
} else {
|
||||||
onTop = true;
|
onTop = true;
|
||||||
onBottom = true;
|
onBottom = true;
|
||||||
@ -198,31 +239,42 @@ public class GamePlaceableBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Canbuild
|
// Canbuild
|
||||||
public static boolean canBuildHere(Block block, BlockFace blockFace, Material mat, GameWorld gWorld) {
|
public static boolean canBuildHere(Block block, BlockFace blockFace, Material mat, GameWorld gameWorld) {
|
||||||
for (GamePlaceableBlock gPBlock : gWorld.placeableBlocks) {
|
for (GamePlaceableBlock gPBlock : gameWorld.getPlaceableBlocks()) {
|
||||||
if (gPBlock.block.getFace(block) == BlockFace.SELF) {
|
if (gPBlock.block.getFace(block) != BlockFace.SELF) {
|
||||||
if (gPBlock.mats.contains(mat) || gPBlock.mats.isEmpty()) {
|
continue;
|
||||||
if (blockFace == BlockFace.NORTH && gPBlock.onNorth) {
|
}
|
||||||
return true;
|
|
||||||
}
|
if ( !(gPBlock.mats.contains(mat) || gPBlock.mats.isEmpty())) {
|
||||||
if (blockFace == BlockFace.SOUTH && gPBlock.onSouth) {
|
continue;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
if (blockFace == BlockFace.EAST && gPBlock.onEast) {
|
if (blockFace == BlockFace.NORTH && gPBlock.onNorth) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (blockFace == BlockFace.WEST && gPBlock.onWest) {
|
|
||||||
return true;
|
if (blockFace == BlockFace.SOUTH && gPBlock.onSouth) {
|
||||||
}
|
return true;
|
||||||
if (blockFace == BlockFace.UP && gPBlock.onTop) {
|
}
|
||||||
return true;
|
|
||||||
}
|
if (blockFace == BlockFace.EAST && gPBlock.onEast) {
|
||||||
if (blockFace == BlockFace.DOWN && gPBlock.onBottom) {
|
return true;
|
||||||
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,22 +39,22 @@ public class GameWorld {
|
|||||||
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
||||||
|
|
||||||
// Variables placeable
|
// Variables placeable
|
||||||
public boolean isTutorial;
|
private boolean isTutorial;
|
||||||
|
|
||||||
public CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks = new CopyOnWriteArrayList<GamePlaceableBlock>();
|
private CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks = new CopyOnWriteArrayList<GamePlaceableBlock>();
|
||||||
public World world;
|
private World world;
|
||||||
public String dungeonname;
|
private String mapName;
|
||||||
public Location locLobby;
|
private Location locLobby;
|
||||||
public Location locStart;
|
private Location locStart;
|
||||||
public boolean isPlaying = false;
|
private boolean isPlaying = false;
|
||||||
public int id;
|
private int id;
|
||||||
public CopyOnWriteArrayList<Material> secureObjects = new CopyOnWriteArrayList<Material>();
|
private CopyOnWriteArrayList<Material> secureObjects = new CopyOnWriteArrayList<Material>();
|
||||||
public CopyOnWriteArrayList<Chunk> loadedChunks = new CopyOnWriteArrayList<Chunk>();
|
private CopyOnWriteArrayList<Chunk> loadedChunks = new CopyOnWriteArrayList<Chunk>();
|
||||||
|
|
||||||
public CopyOnWriteArrayList<Sign> signClass = new CopyOnWriteArrayList<Sign>();
|
private CopyOnWriteArrayList<Sign> signClass = new CopyOnWriteArrayList<Sign>();
|
||||||
public CopyOnWriteArrayList<DMob> dMobs = new CopyOnWriteArrayList<DMob>();
|
private CopyOnWriteArrayList<DMob> dMobs = new CopyOnWriteArrayList<DMob>();
|
||||||
public CopyOnWriteArrayList<GameChest> gameChests = new CopyOnWriteArrayList<GameChest>();
|
private CopyOnWriteArrayList<GameChest> gameChests = new CopyOnWriteArrayList<GameChest>();
|
||||||
public CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<DSign>();
|
private CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<DSign>();
|
||||||
private WorldConfig worldConfig;
|
private WorldConfig worldConfig;
|
||||||
|
|
||||||
public GameWorld() {
|
public GameWorld() {
|
||||||
@ -66,8 +66,8 @@ public class GameWorld {
|
|||||||
while (id == -1) {
|
while (id == -1) {
|
||||||
i++;
|
i++;
|
||||||
boolean exist = false;
|
boolean exist = false;
|
||||||
for (GameWorld gWorld : plugin.getGameWorlds()) {
|
for (GameWorld gameWorld : plugin.getGameWorlds()) {
|
||||||
if (gWorld.id == i) {
|
if (gameWorld.id == i) {
|
||||||
exist = true;
|
exist = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ public class GameWorld {
|
|||||||
|
|
||||||
for (DSign dSign : dSigns) {
|
for (DSign dSign : dSigns) {
|
||||||
if (dSign != null) {
|
if (dSign != null) {
|
||||||
if ( !dSign.isOnDungeonInit()) {
|
if ( !dSign.getType().isOnDungeonInit()) {
|
||||||
dSign.onInit();
|
dSign.onInit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,10 +111,220 @@ public class GameWorld {
|
|||||||
|
|
||||||
public void msg(String msg) {
|
public void msg(String msg) {
|
||||||
for (DPlayer dplayer : DPlayer.get(world)) {
|
for (DPlayer dplayer : DPlayer.get(world)) {
|
||||||
MessageUtil.sendMessage(dplayer.player, msg);
|
MessageUtil.sendMessage(dplayer.getPlayer(), msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the isTutorial
|
||||||
|
*/
|
||||||
|
public boolean isTutorial() {
|
||||||
|
return isTutorial;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param isTutorial
|
||||||
|
* the isTutorial to set
|
||||||
|
*/
|
||||||
|
public void setTutorial(boolean isTutorial) {
|
||||||
|
this.isTutorial = isTutorial;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the placeableBlocks
|
||||||
|
*/
|
||||||
|
public CopyOnWriteArrayList<GamePlaceableBlock> getPlaceableBlocks() {
|
||||||
|
return placeableBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param placeableBlocks
|
||||||
|
* the placeableBlocks to set
|
||||||
|
*/
|
||||||
|
public void setPlaceableBlocks(CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks) {
|
||||||
|
this.placeableBlocks = placeableBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the world
|
||||||
|
*/
|
||||||
|
public World getWorld() {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param world
|
||||||
|
* the world to set
|
||||||
|
*/
|
||||||
|
public void setWorld(World world) {
|
||||||
|
this.world = world;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the mapName
|
||||||
|
*/
|
||||||
|
public String getMapName() {
|
||||||
|
return mapName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mapName
|
||||||
|
* the mapName to set
|
||||||
|
*/
|
||||||
|
public void setMapName(String mapName) {
|
||||||
|
this.mapName = mapName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the locLobby
|
||||||
|
*/
|
||||||
|
public Location getLocLobby() {
|
||||||
|
return locLobby;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param locLobby
|
||||||
|
* the locLobby to set
|
||||||
|
*/
|
||||||
|
public void setLocLobby(Location locLobby) {
|
||||||
|
this.locLobby = locLobby;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the locStart
|
||||||
|
*/
|
||||||
|
public Location getLocStart() {
|
||||||
|
return locStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param locStart
|
||||||
|
* the locStart to set
|
||||||
|
*/
|
||||||
|
public void setLocStart(Location locStart) {
|
||||||
|
this.locStart = locStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the isPlaying
|
||||||
|
*/
|
||||||
|
public boolean isPlaying() {
|
||||||
|
return isPlaying;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param isPlaying
|
||||||
|
* the isPlaying to set
|
||||||
|
*/
|
||||||
|
public void setPlaying(boolean isPlaying) {
|
||||||
|
this.isPlaying = isPlaying;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the id
|
||||||
|
*/
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id
|
||||||
|
* the id to set
|
||||||
|
*/
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the secureObjects
|
||||||
|
*/
|
||||||
|
public CopyOnWriteArrayList<Material> getSecureObjects() {
|
||||||
|
return secureObjects;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param secureObjects
|
||||||
|
* the secureObjects to set
|
||||||
|
*/
|
||||||
|
public void setSecureObjects(CopyOnWriteArrayList<Material> secureObjects) {
|
||||||
|
this.secureObjects = secureObjects;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the loadedChunks
|
||||||
|
*/
|
||||||
|
public CopyOnWriteArrayList<Chunk> getLoadedChunks() {
|
||||||
|
return loadedChunks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param loadedChunks
|
||||||
|
* the loadedChunks to set
|
||||||
|
*/
|
||||||
|
public void setLoadedChunks(CopyOnWriteArrayList<Chunk> loadedChunks) {
|
||||||
|
this.loadedChunks = loadedChunks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the signClass
|
||||||
|
*/
|
||||||
|
public CopyOnWriteArrayList<Sign> getSignClass() {
|
||||||
|
return signClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param signClass
|
||||||
|
* the signClass to set
|
||||||
|
*/
|
||||||
|
public void setSignClass(CopyOnWriteArrayList<Sign> signClass) {
|
||||||
|
this.signClass = signClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the dMobs
|
||||||
|
*/
|
||||||
|
public CopyOnWriteArrayList<DMob> getdMobs() {
|
||||||
|
return dMobs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dMobs
|
||||||
|
* the dMobs to set
|
||||||
|
*/
|
||||||
|
public void setdMobs(CopyOnWriteArrayList<DMob> dMobs) {
|
||||||
|
this.dMobs = dMobs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the gameChests
|
||||||
|
*/
|
||||||
|
public CopyOnWriteArrayList<GameChest> getGameChests() {
|
||||||
|
return gameChests;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param gameChests
|
||||||
|
* the gameChests to set
|
||||||
|
*/
|
||||||
|
public void setGameChests(CopyOnWriteArrayList<GameChest> gameChests) {
|
||||||
|
this.gameChests = gameChests;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the dSigns
|
||||||
|
*/
|
||||||
|
public CopyOnWriteArrayList<DSign> getdSigns() {
|
||||||
|
return dSigns;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dSigns
|
||||||
|
* the dSigns to set
|
||||||
|
*/
|
||||||
|
public void setdSigns(CopyOnWriteArrayList<DSign> dSigns) {
|
||||||
|
this.dSigns = dSigns;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the worldConfig
|
* @return the worldConfig
|
||||||
*/
|
*/
|
||||||
@ -147,9 +357,9 @@ public class GameWorld {
|
|||||||
// Statics
|
// Statics
|
||||||
|
|
||||||
public static GameWorld get(World world) {
|
public static GameWorld get(World world) {
|
||||||
for (GameWorld gWorld : plugin.getGameWorlds()) {
|
for (GameWorld gameWorld : plugin.getGameWorlds()) {
|
||||||
if (gWorld.world.equals(world)) {
|
if (gameWorld.world.equals(world)) {
|
||||||
return gWorld;
|
return gameWorld;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,8 +367,8 @@ public class GameWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteAll() {
|
public static void deleteAll() {
|
||||||
for (GameWorld gWorld : plugin.getGameWorlds()) {
|
for (GameWorld gameWorld : plugin.getGameWorlds()) {
|
||||||
gWorld.delete();
|
gameWorld.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +407,7 @@ public class GameWorld {
|
|||||||
|
|
||||||
WorldConfig worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + dungeon, "config.yml"));
|
WorldConfig worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + dungeon, "config.yml"));
|
||||||
|
|
||||||
if (plugin.getMainConfig().enableEconomy()) {
|
if (plugin.getEconomyProvider() != null) {
|
||||||
if ( !(DungeonsXL.getPlugin().getEconomyProvider().getBalance(player) >= worldConfig.getFee())) {
|
if ( !(DungeonsXL.getPlugin().getEconomyProvider().getBalance(player) >= worldConfig.getFee())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -289,46 +499,46 @@ public class GameWorld {
|
|||||||
File file = new File(plugin.getDataFolder(), "/maps/" + name);
|
File file = new File(plugin.getDataFolder(), "/maps/" + name);
|
||||||
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
GameWorld gWorld = new GameWorld();
|
GameWorld gameWorld = new GameWorld();
|
||||||
gWorld.dungeonname = name;
|
gameWorld.mapName = name;
|
||||||
|
|
||||||
// Unload empty eworlds
|
// Unload empty eworlds
|
||||||
for (EditWorld eworld : plugin.getEditWorlds()) {
|
for (EditWorld eworld : plugin.getEditWorlds()) {
|
||||||
if (eworld.world.getPlayers().isEmpty()) {
|
if (eworld.getWorld().getPlayers().isEmpty()) {
|
||||||
eworld.delete();
|
eworld.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config einlesen
|
// Config einlesen
|
||||||
gWorld.worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + gWorld.dungeonname, "config.yml"));
|
gameWorld.worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + gameWorld.mapName, "config.yml"));
|
||||||
|
|
||||||
// Secure Objects
|
// Secure Objects
|
||||||
gWorld.secureObjects = gWorld.worldConfig.getSecureObjects();
|
gameWorld.secureObjects = gameWorld.worldConfig.getSecureObjects();
|
||||||
|
|
||||||
// World
|
// World
|
||||||
FileUtil.copyDirectory(file, new File("DXL_Game_" + gWorld.id));
|
FileUtil.copyDirectory(file, new File("DXL_Game_" + gameWorld.id));
|
||||||
|
|
||||||
// Id File
|
// Id File
|
||||||
File idFile = new File("DXL_Game_" + gWorld.id + "/.id_" + name);
|
File idFile = new File("DXL_Game_" + gameWorld.id + "/.id_" + name);
|
||||||
try {
|
try {
|
||||||
idFile.createNewFile();
|
idFile.createNewFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
gWorld.world = plugin.getServer().createWorld(WorldCreator.name("DXL_Game_" + gWorld.id));
|
gameWorld.world = plugin.getServer().createWorld(WorldCreator.name("DXL_Game_" + gameWorld.id));
|
||||||
|
|
||||||
ObjectInputStream os;
|
ObjectInputStream os;
|
||||||
try {
|
try {
|
||||||
os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder() + "/maps/" + gWorld.dungeonname + "/DXLData.data")));
|
os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder() + "/maps/" + gameWorld.mapName + "/DXLData.data")));
|
||||||
|
|
||||||
int length = os.readInt();
|
int length = os.readInt();
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
int x = os.readInt();
|
int x = os.readInt();
|
||||||
int y = os.readInt();
|
int y = os.readInt();
|
||||||
int z = os.readInt();
|
int z = os.readInt();
|
||||||
Block block = gWorld.world.getBlockAt(x, y, z);
|
Block block = gameWorld.world.getBlockAt(x, y, z);
|
||||||
gWorld.checkSign(block);
|
gameWorld.checkSign(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
os.close();
|
os.close();
|
||||||
@ -338,16 +548,16 @@ public class GameWorld {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return gWorld;
|
return gameWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void update() {
|
public static void update() {
|
||||||
for (GameWorld gWorld : plugin.getGameWorlds()) {
|
for (GameWorld gameWorld : plugin.getGameWorlds()) {
|
||||||
// Update Spiders
|
// Update Spiders
|
||||||
for (LivingEntity mob : gWorld.world.getLivingEntities()) {
|
for (LivingEntity mob : gameWorld.world.getLivingEntities()) {
|
||||||
if (mob.getType() == EntityType.SPIDER || mob.getType() == EntityType.CAVE_SPIDER) {
|
if (mob.getType() == EntityType.SPIDER || mob.getType() == EntityType.CAVE_SPIDER) {
|
||||||
Spider spider = (Spider) mob;
|
Spider spider = (Spider) mob;
|
||||||
if (spider.getTarget() != null) {
|
if (spider.getTarget() != null) {
|
||||||
|
@ -35,7 +35,6 @@ public class DMessages {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setDefaults() {
|
private void setDefaults() {
|
||||||
|
|
||||||
/* Log */
|
/* Log */
|
||||||
defaults.put("Log_NewDungeon", "&6New Dungeon");
|
defaults.put("Log_NewDungeon", "&6New Dungeon");
|
||||||
defaults.put("Log_GenerateNewWorld", "&6Generate new world...");
|
defaults.put("Log_GenerateNewWorld", "&6Generate new world...");
|
||||||
@ -147,45 +146,52 @@ public class DMessages {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
if (changed) {
|
if ( !changed) {
|
||||||
/* Copy old File */
|
return;
|
||||||
File source = new File(file.getPath());
|
}
|
||||||
String filePath = file.getPath();
|
|
||||||
File temp = new File(filePath.substring(0, filePath.length() - 4) + "_old.yml");
|
/* 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()) {
|
} catch (IOException e) {
|
||||||
temp.delete();
|
e.printStackTrace();
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String get(String key, String... args) {
|
public String get(String key, String... args) {
|
||||||
String entry = entries.get(key);
|
String entry = entries.get(key);
|
||||||
|
|
||||||
if (entry != null) {
|
if (entry == null) {
|
||||||
int i = 0;
|
return entry;
|
||||||
for (String arg : args) {
|
}
|
||||||
i++;
|
|
||||||
if (arg != null) {
|
int i = 0;
|
||||||
entry = entry.replace("&v" + i, arg);
|
for (String arg : args) {
|
||||||
} else {
|
i++;
|
||||||
entry = entry.replace("&v" + i, "null");
|
|
||||||
}
|
if (arg != null) {
|
||||||
|
entry = entry.replace("&v" + i, arg);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
entry = entry.replace("&v" + i, "null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,84 +31,10 @@ public class DPortal {
|
|||||||
public void create() {
|
public void create() {
|
||||||
player = null;
|
player = null;
|
||||||
|
|
||||||
if (block1 != null && block2 != 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 {
|
|
||||||
plugin.getDPortals().remove(this);
|
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 x1 = block1.getX(), y1 = block1.getY(), z1 = block1.getZ();
|
||||||
int x2 = block2.getX(), y2 = block2.getY(), z2 = block2.getZ();
|
int x2 = block2.getX(), y2 = block2.getY(), z2 = block2.getZ();
|
||||||
@ -130,6 +56,80 @@ public class DPortal {
|
|||||||
zcount = 1;
|
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;
|
int xx = x1;
|
||||||
do {
|
do {
|
||||||
int yy = y1;
|
int yy = y1;
|
||||||
@ -167,6 +167,7 @@ public class DPortal {
|
|||||||
if (x3 < x2 || x3 > x1) {
|
if (x3 < x2 || x3 > x1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (x3 > x2 || x3 < x1) {
|
if (x3 > x2 || x3 < x1) {
|
||||||
continue;
|
continue;
|
||||||
@ -177,6 +178,7 @@ public class DPortal {
|
|||||||
if (y3 < y2 || y3 > y1) {
|
if (y3 < y2 || y3 > y1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (y3 > y2 || y3 < y1) {
|
if (y3 > y2 || y3 < y1) {
|
||||||
continue;
|
continue;
|
||||||
@ -205,6 +207,7 @@ public class DPortal {
|
|||||||
return portal;
|
return portal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,37 +216,44 @@ public class DPortal {
|
|||||||
int id = 0;
|
int id = 0;
|
||||||
for (DPortal dportal : plugin.getDPortals()) {
|
for (DPortal dportal : plugin.getDPortals()) {
|
||||||
id++;
|
id++;
|
||||||
if (dportal.isActive) {
|
|
||||||
String preString = "portal." + dportal.world.getName() + "." + id;
|
if ( !dportal.isActive) {
|
||||||
// Location1
|
continue;
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
public static void load(FileConfiguration configFile) {
|
||||||
for (World world : plugin.getServer().getWorlds()) {
|
for (World world : plugin.getServer().getWorlds()) {
|
||||||
if (configFile.contains("portal." + world.getName())) {
|
if ( !configFile.contains("portal." + world.getName())) {
|
||||||
int id = 0;
|
return;
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public class GroupSign {
|
|||||||
public static final String strNewGrp = ChatColor.DARK_GREEN + "New Group";
|
public static final String strNewGrp = ChatColor.DARK_GREEN + "New Group";
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
private DGroup[] dgroups;
|
private DGroup[] dGroups;
|
||||||
private boolean multiFloor;
|
private boolean multiFloor;
|
||||||
private String dungeonName;
|
private String dungeonName;
|
||||||
private String mapName;
|
private String mapName;
|
||||||
@ -42,7 +42,7 @@ public class GroupSign {
|
|||||||
plugin.getGroupSigns().add(this);
|
plugin.getGroupSigns().add(this);
|
||||||
|
|
||||||
this.startSign = startSign;
|
this.startSign = startSign;
|
||||||
dgroups = new DGroup[maxGroups];
|
dGroups = new DGroup[maxGroups];
|
||||||
this.multiFloor = multiFloor;
|
this.multiFloor = multiFloor;
|
||||||
if (multiFloor) {
|
if (multiFloor) {
|
||||||
dungeonName = identifier;
|
dungeonName = identifier;
|
||||||
@ -83,54 +83,66 @@ public class GroupSign {
|
|||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (DGroup dgroup : dgroups) {
|
for (DGroup dGroup : dGroups) {
|
||||||
if (startSign.getRelative(i * directionX, 0, i * directionZ).getState() instanceof Sign) {
|
if ( !(startSign.getRelative(i * directionX, 0, i * directionZ).getState() instanceof Sign)) {
|
||||||
Sign sign = (Sign) startSign.getRelative(i * directionX, 0, i * directionZ).getState();
|
i++;
|
||||||
|
continue;
|
||||||
// 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,19 +163,25 @@ public class GroupSign {
|
|||||||
switch (direction) {
|
switch (direction) {
|
||||||
case 2:
|
case 2:
|
||||||
zz = z;
|
zz = z;
|
||||||
|
|
||||||
for (yy = y; yy > y - verticalSigns; yy--) {
|
for (yy = y; yy > y - verticalSigns; yy--) {
|
||||||
for (xx = x; xx > x - maxGroups; xx--) {
|
for (xx = x; xx > x - maxGroups; xx--) {
|
||||||
Block block = world.getBlockAt(xx, yy, zz);
|
Block block = world.getBlockAt(xx, yy, zz);
|
||||||
|
|
||||||
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
|
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block.getRelative(0, 0, 1).getType() == Material.AIR) {
|
if (block.getRelative(0, 0, 1).getType() == Material.AIR) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
changeBlocks.add(block);
|
changeBlocks.add(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
zz = z;
|
zz = z;
|
||||||
for (yy = y; yy > y - verticalSigns; yy--) {
|
for (yy = y; yy > y - verticalSigns; yy--) {
|
||||||
@ -173,48 +191,61 @@ public class GroupSign {
|
|||||||
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
|
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block.getRelative(0, 0, -1).getType() == Material.AIR) {
|
if (block.getRelative(0, 0, -1).getType() == Material.AIR) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
changeBlocks.add(block);
|
changeBlocks.add(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
xx = x;
|
xx = x;
|
||||||
for (yy = y; yy > y - verticalSigns; yy--) {
|
for (yy = y; yy > y - verticalSigns; yy--) {
|
||||||
for (zz = z; zz < z + maxGroups; zz++) {
|
for (zz = z; zz < z + maxGroups; zz++) {
|
||||||
|
|
||||||
Block block = world.getBlockAt(xx, yy, zz);
|
Block block = world.getBlockAt(xx, yy, zz);
|
||||||
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
|
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block.getRelative(1, 0, 0).getType() == Material.AIR) {
|
if (block.getRelative(1, 0, 0).getType() == Material.AIR) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
changeBlocks.add(block);
|
changeBlocks.add(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
xx = x;
|
xx = x;
|
||||||
for (yy = y; yy > y - verticalSigns; yy--) {
|
for (yy = y; yy > y - verticalSigns; yy--) {
|
||||||
for (zz = z; zz > z - maxGroups; zz--) {
|
for (zz = z; zz > z - maxGroups; zz--) {
|
||||||
|
|
||||||
Block block = world.getBlockAt(xx, yy, zz);
|
Block block = world.getBlockAt(xx, yy, zz);
|
||||||
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
|
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block.getRelative( -1, 0, 0).getType() == Material.AIR) {
|
if (block.getRelative( -1, 0, 0).getType() == Material.AIR) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
changeBlocks.add(block);
|
changeBlocks.add(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Block block : changeBlocks) {
|
for (Block block : changeBlocks) {
|
||||||
block.setTypeIdAndData(68, startSign.getData(), true);
|
block.setTypeIdAndData(68, startSign.getData(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupSign sign = new GroupSign(startSign, mapName, maxGroups, maxPlayersPerGroup, multiFloor);
|
GroupSign sign = new GroupSign(startSign, mapName, maxGroups, maxPlayersPerGroup, multiFloor);
|
||||||
|
|
||||||
return sign;
|
return sign;
|
||||||
@ -222,142 +253,162 @@ public class GroupSign {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static boolean isRelativeSign(Block block, int x, int z) {
|
public static boolean isRelativeSign(Block block, int x, int z) {
|
||||||
GroupSign dgsign = getSign(block.getRelative(x, 0, z));
|
GroupSign groupSign = getSign(block.getRelative(x, 0, z));
|
||||||
if (dgsign != null) {
|
if (groupSign == null) {
|
||||||
if (x == -1 && dgsign.startSign.getData() == 4) {
|
return false;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
if (x == -1 && groupSign.startSign.getData() == 4) {
|
||||||
}
|
return true;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
if (x == 1 && groupSign.startSign.getData() == 5) {
|
||||||
|
return true;
|
||||||
public static boolean playerInteract(Block block, Player player) {
|
}
|
||||||
int x = block.getX(), y = block.getY(), z = block.getZ();
|
|
||||||
GroupSign dgsign = getSign(block);
|
if (z == -1 && groupSign.startSign.getData() == 2) {
|
||||||
if (dgsign != null) {
|
return true;
|
||||||
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();
|
if (z == 1 && groupSign.startSign.getData() == 3) {
|
||||||
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
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 x = block.getX(), y = block.getY(), z = block.getZ();
|
||||||
int i = 0;
|
for (GroupSign groupSign : plugin.getGroupSigns()) {
|
||||||
for (DGroup dgroup : dgsign.dgroups) {
|
int sx1 = groupSign.startSign.getX(), sy1 = groupSign.startSign.getY(), sz1 = groupSign.startSign.getZ();
|
||||||
if (dgroup != null) {
|
int sx2 = sx1 + (groupSign.dGroups.length - 1) * groupSign.directionX;
|
||||||
if (dgroup == dgroupsearch) {
|
int sy2 = sy1 - groupSign.verticalSigns + 1;
|
||||||
if (dgroupsearch.isEmpty()) {
|
int sz2 = sz1 + (groupSign.dGroups.length - 1) * groupSign.directionZ;
|
||||||
dgsign.dgroups[i] = null;
|
|
||||||
}
|
if (sx1 > sx2) {
|
||||||
dgsign.update();
|
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++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -365,16 +416,20 @@ public class GroupSign {
|
|||||||
|
|
||||||
public static int[] getDirection(byte data) {
|
public static int[] getDirection(byte data) {
|
||||||
int[] direction = new int[2];
|
int[] direction = new int[2];
|
||||||
|
|
||||||
switch (data) {
|
switch (data) {
|
||||||
case 2:
|
case 2:
|
||||||
direction[0] = -1;
|
direction[0] = -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
direction[0] = 1;
|
direction[0] = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
direction[1] = 1;
|
direction[1] = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
direction[1] = -1;
|
direction[1] = -1;
|
||||||
break;
|
break;
|
||||||
@ -386,51 +441,54 @@ public class GroupSign {
|
|||||||
public static void save(FileConfiguration configFile) {
|
public static void save(FileConfiguration configFile) {
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
|
||||||
for (GroupSign dgsign : plugin.getGroupSigns()) {
|
for (GroupSign groupSign : plugin.getGroupSigns()) {
|
||||||
id++;
|
id++;
|
||||||
String preString = "groupsign." + dgsign.startSign.getWorld().getName() + "." + id;
|
String preString = "groupsign." + groupSign.startSign.getWorld().getName() + "." + id;
|
||||||
|
|
||||||
// Location
|
// Location
|
||||||
configFile.set(preString + ".x", dgsign.startSign.getX());
|
configFile.set(preString + ".x", groupSign.startSign.getX());
|
||||||
configFile.set(preString + ".y", dgsign.startSign.getY());
|
configFile.set(preString + ".y", groupSign.startSign.getY());
|
||||||
configFile.set(preString + ".z", dgsign.startSign.getZ());
|
configFile.set(preString + ".z", groupSign.startSign.getZ());
|
||||||
|
|
||||||
// Etc.
|
// Etc.
|
||||||
if (dgsign.multiFloor) {
|
if (groupSign.multiFloor) {
|
||||||
configFile.set(preString + ".dungeon", dgsign.dungeonName);
|
configFile.set(preString + ".dungeon", groupSign.dungeonName);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
configFile.set(preString + ".dungeon", dgsign.mapName);
|
configFile.set(preString + ".dungeon", groupSign.mapName);
|
||||||
}
|
}
|
||||||
configFile.set(preString + ".maxGroups", dgsign.dgroups.length);
|
|
||||||
configFile.set(preString + ".maxPlayersPerGroup", dgsign.maxPlayersPerGroup);
|
configFile.set(preString + ".maxGroups", groupSign.dGroups.length);
|
||||||
configFile.set(preString + ".multiFloor", dgsign.multiFloor);
|
configFile.set(preString + ".maxPlayersPerGroup", groupSign.maxPlayersPerGroup);
|
||||||
|
configFile.set(preString + ".multiFloor", groupSign.multiFloor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void load(FileConfiguration configFile) {
|
public static void load(FileConfiguration configFile) {
|
||||||
for (World world : DungeonsXL.getPlugin().getServer().getWorlds()) {
|
for (World world : DungeonsXL.getPlugin().getServer().getWorlds()) {
|
||||||
if (configFile.contains("groupsign." + world.getName())) {
|
if ( !configFile.contains("groupsign." + world.getName())) {
|
||||||
int id = 0;
|
continue;
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,37 +38,21 @@ public class LeaveSign {
|
|||||||
|
|
||||||
LeaveSign lsign = getSign(block);
|
LeaveSign lsign = getSign(block);
|
||||||
|
|
||||||
if (lsign != null) {
|
if (lsign == null) {
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
return false;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
if (dplayer != null) {
|
||||||
public static boolean isRelativeSign(Block block, int x, int z) {
|
dplayer.leave();
|
||||||
LeaveSign lsign = getSign(block.getRelative(x, 0, z));
|
return true;
|
||||||
if (lsign != null) {
|
|
||||||
if (x == -1 && lsign.sign.getData().getData() == 4) {
|
} else {
|
||||||
return true;
|
DGroup dgroup = DGroup.get(player);
|
||||||
}
|
if (dgroup != null) {
|
||||||
if (x == 1 && lsign.sign.getData().getData() == 5) {
|
dgroup.removePlayer(player);
|
||||||
return true;
|
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_LeaveGroup"));// ChatColor.YELLOW+"Du hast deine Gruppe erfolgreich verlassen!");
|
||||||
}
|
|
||||||
if (z == -1 && lsign.sign.getData().getData() == 2) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (z == 1 && lsign.sign.getData().getData() == 3) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,16 +60,47 @@ public class LeaveSign {
|
|||||||
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) {
|
||||||
|
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) {
|
public static LeaveSign getSign(Block block) {
|
||||||
if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) {
|
if ( !(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST)) {
|
||||||
for (LeaveSign leavesign : plugin.getLeaveSigns()) {
|
return null;
|
||||||
if (block.getWorld() == leavesign.sign.getWorld()) {
|
}
|
||||||
if (block.getLocation().distance(leavesign.sign.getBlock().getLocation()) < 1) {
|
|
||||||
return leavesign;
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,21 +118,25 @@ public class LeaveSign {
|
|||||||
|
|
||||||
public static void load(FileConfiguration configFile) {
|
public static void load(FileConfiguration configFile) {
|
||||||
for (World world : DungeonsXL.getPlugin().getServer().getWorlds()) {
|
for (World world : DungeonsXL.getPlugin().getServer().getWorlds()) {
|
||||||
if (configFile.contains("leavesign." + world.getName())) {
|
if ( !configFile.contains("leavesign." + world.getName())) {
|
||||||
int id = 0;
|
continue;
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ public class BlockListener implements Listener {
|
|||||||
// Editworld Signs
|
// Editworld Signs
|
||||||
EditWorld eworld = EditWorld.get(block.getWorld());
|
EditWorld eworld = EditWorld.get(block.getWorld());
|
||||||
if (eworld != null) {
|
if (eworld != null) {
|
||||||
eworld.sign.remove(event.getBlock());
|
eworld.getSign().remove(event.getBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deny GameWorld Blocks
|
// Deny GameWorld Blocks
|
||||||
@ -161,10 +161,10 @@ public class BlockListener implements Listener {
|
|||||||
DSign dsign = DSign.create(sign, null);
|
DSign dsign = DSign.create(sign, null);
|
||||||
|
|
||||||
if (dsign != null) {
|
if (dsign != null) {
|
||||||
if (player.isOp() || player.hasPermission(dsign.getPermissions())) {
|
if (player.isOp() || player.hasPermission(dsign.getType().getBuildPermission())) {
|
||||||
if (dsign.check()) {
|
if (dsign.check()) {
|
||||||
eworld.checkSign(block);
|
eworld.checkSign(block);
|
||||||
eworld.sign.add(block);
|
eworld.getSign().add(block);
|
||||||
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_SignCreated"));
|
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_SignCreated"));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -214,7 +214,7 @@ public class BlockListener implements Listener {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (GameWorld gworld : DungeonsXL.getPlugin().getGameWorlds()) {
|
for (GameWorld gworld : DungeonsXL.getPlugin().getGameWorlds()) {
|
||||||
if (block.getWorld() == gworld.world) {
|
if (block.getWorld() == gworld.getWorld()) {
|
||||||
RedstoneTrigger.updateAll(gworld);
|
RedstoneTrigger.updateAll(gworld);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class EntityListener implements Listener {
|
|||||||
LivingEntity entity = event.getEntity();
|
LivingEntity entity = event.getEntity();
|
||||||
GameWorld gworld = GameWorld.get(world);
|
GameWorld gworld = GameWorld.get(world);
|
||||||
if (gworld != null) {
|
if (gworld != null) {
|
||||||
if (gworld.isPlaying) {
|
if (gworld.isPlaying()) {
|
||||||
if (entity.getType() != EntityType.PLAYER) {
|
if (entity.getType() != EntityType.PLAYER) {
|
||||||
event.getDrops().clear();
|
event.getDrops().clear();
|
||||||
DMob.onDeath(event);
|
DMob.onDeath(event);
|
||||||
@ -82,7 +82,7 @@ public class EntityListener implements Listener {
|
|||||||
GameWorld gworld = GameWorld.get(world);
|
GameWorld gworld = GameWorld.get(world);
|
||||||
if (gworld != null) {
|
if (gworld != null) {
|
||||||
// Deny all Damage in Lobby
|
// Deny all Damage in Lobby
|
||||||
if ( !gworld.isPlaying) {
|
if ( !gworld.isPlaying()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
// Deny all Damage from Players to Players
|
// Deny all Damage from Players to Players
|
||||||
@ -106,9 +106,9 @@ public class EntityListener implements Listener {
|
|||||||
|
|
||||||
// Check Dogs
|
// Check Dogs
|
||||||
if (entity instanceof Player || entity2 instanceof Player) {
|
if (entity instanceof Player || entity2 instanceof Player) {
|
||||||
for (DPlayer dplayer : DPlayer.get(gworld.world)) {
|
for (DPlayer dplayer : DPlayer.get(gworld.getWorld())) {
|
||||||
if (dplayer.wolf != null) {
|
if (dplayer.getWolf() != null) {
|
||||||
if (entity == dplayer.wolf || entity2 == dplayer.wolf) {
|
if (entity == dplayer.getWolf() || entity2 == dplayer.getWolf()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -116,16 +116,16 @@ public class EntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (DPlayer dplayer : DPlayer.get(gworld.world)) {
|
for (DPlayer dplayer : DPlayer.get(gworld.getWorld())) {
|
||||||
if (dplayer.wolf != null) {
|
if (dplayer.getWolf() != null) {
|
||||||
if (entity instanceof Player || entity2 instanceof Player) {
|
if (entity instanceof Player || entity2 instanceof Player) {
|
||||||
if (entity == dplayer.wolf || entity2 == dplayer.wolf) {
|
if (entity == dplayer.getWolf() || entity2 == dplayer.getWolf()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (entity == dplayer.wolf || entity2 == dplayer.wolf) {
|
if (entity == dplayer.getWolf() || entity2 == dplayer.getWolf()) {
|
||||||
event.setCancelled(false);
|
event.setCancelled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ public class EntityListener implements Listener {
|
|||||||
|
|
||||||
GameWorld gworld = GameWorld.get(world);
|
GameWorld gworld = GameWorld.get(world);
|
||||||
if (gworld != null) {
|
if (gworld != null) {
|
||||||
if ( !gworld.isPlaying) {
|
if ( !gworld.isPlaying()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,9 +58,9 @@ public class PlayerListener implements Listener {
|
|||||||
WorldConfig dConfig = gameWorld.getConfig();
|
WorldConfig dConfig = gameWorld.getConfig();
|
||||||
|
|
||||||
if (dPlayer != null) {
|
if (dPlayer != null) {
|
||||||
dPlayer.lives = dPlayer.lives - 1;
|
dPlayer.setLives(dPlayer.getLives() - 1);
|
||||||
|
|
||||||
if (dPlayer.lives == 0 && dPlayer.isReady) {
|
if (dPlayer.getLives() == 0 && dPlayer.isReady()) {
|
||||||
Bukkit.broadcastMessage(plugin.getDMessages().get("Player_DeathKick").replaceAll("v1", player.getName()).replaceAll("&", "\u00a7"));
|
Bukkit.broadcastMessage(plugin.getDMessages().get("Player_DeathKick").replaceAll("v1", player.getName()).replaceAll("&", "\u00a7"));
|
||||||
// TODO: This Runnable is a workaround for a bug I couldn't find, yet...
|
// TODO: This Runnable is a workaround for a bug I couldn't find, yet...
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@ -69,13 +69,13 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 1L);
|
}.runTaskLater(plugin, 1L);
|
||||||
|
|
||||||
} else if ( !(dPlayer.lives == -1)) {
|
} else if ( !(dPlayer.getLives() == -1)) {
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_Death").replaceAll("v1", String.valueOf(dPlayer.lives)));
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_Death").replaceAll("v1", String.valueOf(dPlayer.getLives())));
|
||||||
|
|
||||||
} else if (dConfig != null) {
|
} else if (dConfig != null) {
|
||||||
if (dConfig.getKeepInventoryOnDeath()) {
|
if (dConfig.getKeepInventoryOnDeath()) {
|
||||||
dPlayer.respawnInventory = event.getEntity().getInventory().getContents();
|
dPlayer.setRespawnInventory(event.getEntity().getInventory().getContents());
|
||||||
dPlayer.respawnArmor = event.getEntity().getInventory().getArmorContents();
|
dPlayer.setRespawnArmor(event.getEntity().getInventory().getArmorContents());
|
||||||
// Delete all drops
|
// Delete all drops
|
||||||
for (ItemStack istack : event.getDrops()) {
|
for (ItemStack istack : event.getDrops()) {
|
||||||
istack.setType(Material.AIR);
|
istack.setType(Material.AIR);
|
||||||
@ -224,11 +224,11 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Class Signs
|
// Class Signs
|
||||||
for (Sign classSign : gworld.signClass) {
|
for (Sign classSign : gworld.getSignClass()) {
|
||||||
if (classSign != null) {
|
if (classSign != null) {
|
||||||
if (classSign.getLocation().distance(clickedBlock.getLocation()) < 1) {
|
if (classSign.getLocation().distance(clickedBlock.getLocation()) < 1) {
|
||||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
dplayer.setClass(ChatColor.stripColor(classSign.getLine(1)));
|
dplayer.setDClass(ChatColor.stripColor(classSign.getLine(1)));
|
||||||
} else {
|
} else {
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_Leftklick"));
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_Leftklick"));
|
||||||
}
|
}
|
||||||
@ -254,13 +254,13 @@ public class PlayerListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( !DPlayer.get(player).isReady) {
|
if ( !DPlayer.get(player).isReady()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
GameWorld gworld = GameWorld.get(dplayer.world);
|
GameWorld gworld = GameWorld.get(dplayer.getWorld());
|
||||||
if (dplayer != null) {
|
if (dplayer != null) {
|
||||||
for (Material material : gworld.getConfig().getSecureObjects()) {
|
for (Material material : gworld.getConfig().getSecureObjects()) {
|
||||||
if (material == event.getItemDrop().getItemStack().getType()) {
|
if (material == event.getItemDrop().getItemStack().getType()) {
|
||||||
@ -279,45 +279,45 @@ public class PlayerListener implements Listener {
|
|||||||
DPlayer dplayer = DPlayer.get(player);
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
|
||||||
if (dplayer != null) {
|
if (dplayer != null) {
|
||||||
if (dplayer.isEditing) {
|
if (dplayer.isEditing()) {
|
||||||
EditWorld eworld = EditWorld.get(dplayer.world);
|
EditWorld eworld = EditWorld.get(dplayer.getWorld());
|
||||||
if (eworld != null) {
|
if (eworld != null) {
|
||||||
if (eworld.lobby == null) {
|
if (eworld.getLobby() == null) {
|
||||||
event.setRespawnLocation(eworld.world.getSpawnLocation());
|
event.setRespawnLocation(eworld.getWorld().getSpawnLocation());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
event.setRespawnLocation(eworld.lobby);
|
event.setRespawnLocation(eworld.getLobby());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
GameWorld gworld = GameWorld.get(dplayer.world);
|
GameWorld gworld = GameWorld.get(dplayer.getWorld());
|
||||||
|
|
||||||
if (gworld != null) {
|
if (gworld != null) {
|
||||||
DGroup dgroup = DGroup.get(dplayer.player);
|
DGroup dgroup = DGroup.get(dplayer.getPlayer());
|
||||||
|
|
||||||
if (dplayer.checkpoint == null) {
|
if (dplayer.getCheckpoint() == null) {
|
||||||
event.setRespawnLocation(dgroup.getGWorld().locStart);
|
event.setRespawnLocation(dgroup.getGWorld().getLocStart());
|
||||||
|
|
||||||
// Da einige Plugins einen anderen Respawn setzen wird
|
// Da einige Plugins einen anderen Respawn setzen wird
|
||||||
// ein Scheduler gestartet der den Player nach einer
|
// ein Scheduler gestartet der den Player nach einer
|
||||||
// Sekunde teleportiert.
|
// Sekunde teleportiert.
|
||||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RespawnRunnable(player, dgroup.getGWorld().locStart), 10);
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RespawnRunnable(player, dgroup.getGWorld().getLocStart()), 10);
|
||||||
|
|
||||||
if (dplayer.wolf != null) {
|
if (dplayer.getWolf() != null) {
|
||||||
dplayer.wolf.teleport(dgroup.getGWorld().locStart);
|
dplayer.getWolf().teleport(dgroup.getGWorld().getLocStart());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
event.setRespawnLocation(dplayer.checkpoint);
|
event.setRespawnLocation(dplayer.getCheckpoint());
|
||||||
|
|
||||||
// Da einige Plugins einen anderen Respawn setzen wird
|
// Da einige Plugins einen anderen Respawn setzen wird
|
||||||
// ein Scheduler gestartet der den Player nach einer
|
// ein Scheduler gestartet der den Player nach einer
|
||||||
// Sekunde teleportiert.
|
// Sekunde teleportiert.
|
||||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RespawnRunnable(player, dplayer.checkpoint), 10);
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RespawnRunnable(player, dplayer.getCheckpoint()), 10);
|
||||||
|
|
||||||
if (dplayer.wolf != null) {
|
if (dplayer.getWolf() != null) {
|
||||||
dplayer.wolf.teleport(dplayer.checkpoint);
|
dplayer.getWolf().teleport(dplayer.getCheckpoint());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -343,7 +343,7 @@ public class PlayerListener implements Listener {
|
|||||||
DPlayer dplayer = DPlayer.get(player);
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
|
||||||
if (dplayer != null) {
|
if (dplayer != null) {
|
||||||
if (dplayer.world != event.getTo().getWorld()) {
|
if (dplayer.getWorld() != event.getTo().getWorld()) {
|
||||||
if ( !player.isOp()) {
|
if ( !player.isOp()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -356,7 +356,7 @@ public class PlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
if (dplayer != null) {
|
if (dplayer != null) {
|
||||||
if (dplayer.isInDungeonChat) {
|
if (dplayer.isInDungeonChat()) {
|
||||||
dplayer.msg(player.getDisplayName() + ": " + event.getMessage());
|
dplayer.msg(player.getDisplayName() + ": " + event.getMessage());
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -378,14 +378,14 @@ public class PlayerListener implements Listener {
|
|||||||
dPlayer.leave();
|
dPlayer.leave();
|
||||||
|
|
||||||
} else if (timeUntilKickOfflinePlayer > 0) {
|
} else if (timeUntilKickOfflinePlayer > 0) {
|
||||||
dPlayer.msg(plugin.getDMessages().get("Player_Offline", dPlayer.player.getName(), "" + timeUntilKickOfflinePlayer));
|
dPlayer.msg(plugin.getDMessages().get("Player_Offline", dPlayer.getPlayer().getName(), "" + timeUntilKickOfflinePlayer));
|
||||||
dPlayer.offlineTime = System.currentTimeMillis() + timeUntilKickOfflinePlayer * 1000;
|
dPlayer.setOfflineTime(System.currentTimeMillis() + timeUntilKickOfflinePlayer * 1000);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dPlayer.msg(plugin.getDMessages().get("Player_OfflineNeverKick", dPlayer.player.getName()));
|
dPlayer.msg(plugin.getDMessages().get("Player_OfflineNeverKick", dPlayer.getPlayer().getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (dPlayer.isEditing) {
|
} else if (dPlayer.isEditing()) {
|
||||||
dPlayer.leave();
|
dPlayer.leave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -398,15 +398,15 @@ public class PlayerListener implements Listener {
|
|||||||
// Check dplayers
|
// Check dplayers
|
||||||
DPlayer dplayer = DPlayer.get(player.getName());
|
DPlayer dplayer = DPlayer.get(player.getName());
|
||||||
if (dplayer != null) {
|
if (dplayer != null) {
|
||||||
DGroup dgroup = DGroup.get(dplayer.player);
|
DGroup dgroup = DGroup.get(dplayer.getPlayer());
|
||||||
if (dgroup != null) {
|
if (dgroup != null) {
|
||||||
dgroup.getPlayers().remove(dplayer.player);
|
dgroup.getPlayers().remove(dplayer.getPlayer());
|
||||||
dgroup.getPlayers().add(player);
|
dgroup.getPlayers().add(player);
|
||||||
}
|
}
|
||||||
dplayer.player = player;
|
dplayer.setPlayer(player);
|
||||||
|
|
||||||
// Check offlineTime
|
// Check offlineTime
|
||||||
dplayer.offlineTime = 0;
|
dplayer.setOfflineTime(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tutorial Mode
|
// Tutorial Mode
|
||||||
@ -419,14 +419,14 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
if (dgroup.getGWorld() == null) {
|
if (dgroup.getGWorld() == null) {
|
||||||
dgroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName()));
|
dgroup.setGWorld(GameWorld.load(DGroup.get(player).getMapName()));
|
||||||
dgroup.getGWorld().isTutorial = true;
|
dgroup.getGWorld().setTutorial(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dgroup.getGWorld() != null) {
|
if (dgroup.getGWorld() != null) {
|
||||||
if (dgroup.getGWorld().locLobby == null) {
|
if (dgroup.getGWorld().getLocLobby() == null) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
new DPlayer(player, dgroup.getGWorld().world, dgroup.getGWorld().locLobby, false);
|
new DPlayer(player, dgroup.getGWorld().getWorld(), dgroup.getGWorld().getLocLobby(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -448,7 +448,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
DPlayer dplayer = DPlayer.get(event.getPlayer());
|
DPlayer dplayer = DPlayer.get(event.getPlayer());
|
||||||
if (dplayer != null) {
|
if (dplayer != null) {
|
||||||
if (dplayer.isEditing && event.getPlayer().hasPermission("dungeonsxl.cmdedit") || event.getPlayer().isOp()) {
|
if (dplayer.isEditing() && event.getPlayer().hasPermission("dungeonsxl.cmdedit") || event.getPlayer().isOp()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,11 +523,11 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
if (dplayer != null) {
|
if (dplayer != null) {
|
||||||
// Respawn Items
|
// Respawn Items
|
||||||
if (dplayer.respawnInventory != null || dplayer.respawnArmor != null) {
|
if (dplayer.getRespawnInventory() != null || dplayer.getRespawnArmor() != null) {
|
||||||
player.getInventory().setContents(dplayer.respawnInventory);
|
player.getInventory().setContents(dplayer.getRespawnInventory());
|
||||||
player.getInventory().setArmorContents(dplayer.respawnArmor);
|
player.getInventory().setArmorContents(dplayer.getRespawnArmor());
|
||||||
dplayer.respawnInventory = null;
|
dplayer.setRespawnInventory(null);
|
||||||
dplayer.respawnArmor = null;
|
dplayer.setRespawnArmor(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public class WorldListener implements Listener {
|
|||||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||||
GameWorld gWorld = GameWorld.get(event.getWorld());
|
GameWorld gWorld = GameWorld.get(event.getWorld());
|
||||||
if (gWorld != null) {
|
if (gWorld != null) {
|
||||||
if (gWorld.loadedChunks.contains(event.getChunk())) {
|
if (gWorld.getLoadedChunks().contains(event.getChunk())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@ public class DMob {
|
|||||||
|
|
||||||
private String trigger;
|
private String trigger;
|
||||||
|
|
||||||
public DMob(LivingEntity entity, GameWorld gworld, DMobType type) {
|
public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type) {
|
||||||
gworld.dMobs.add(this);
|
gameWorld.getdMobs().add(this);
|
||||||
|
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@ -31,8 +31,8 @@ public class DMob {
|
|||||||
this.entity.getEquipment().setItemInHandDropChance(0);
|
this.entity.getEquipment().setItemInHandDropChance(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DMob(LivingEntity entity, GameWorld gworld, DMobType type, String trigger) {
|
public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type, String trigger) {
|
||||||
gworld.dMobs.add(this);
|
gameWorld.getdMobs().add(this);
|
||||||
|
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@ -49,42 +49,46 @@ public class DMob {
|
|||||||
// Statics
|
// Statics
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static void onDeath(EntityDeathEvent event) {
|
public static void onDeath(EntityDeathEvent event) {
|
||||||
if (event.getEntity() instanceof LivingEntity) {
|
if ( !(event.getEntity() instanceof LivingEntity)) {
|
||||||
LivingEntity victim = event.getEntity();
|
return;
|
||||||
GameWorld gworld = GameWorld.get(victim.getWorld());
|
}
|
||||||
String name = null;
|
|
||||||
|
LivingEntity victim = event.getEntity();
|
||||||
if (gworld != null) {
|
GameWorld gameWorld = GameWorld.get(victim.getWorld());
|
||||||
for (DMob dmob : gworld.dMobs) {
|
String name = null;
|
||||||
if (dmob.entity == victim) {
|
|
||||||
|
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) {
|
if (dMob.type.getDrops().get(item) > random) {
|
||||||
for (ItemStack item : dmob.type.getDrops().keySet()) {
|
event.getDrops().add(item);
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,177 +48,184 @@ public class DMobType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void spawn(GameWorld gWorld, Location loc) {
|
public void spawn(GameWorld gWorld, Location loc) {
|
||||||
if (type != null) {
|
if (type == null) {
|
||||||
if (type.isAlive()) {
|
return;
|
||||||
LivingEntity entity = (LivingEntity) gWorld.world.spawnEntity(loc, type);
|
}
|
||||||
|
|
||||||
/* Set the Items */
|
if ( !type.isAlive()) {
|
||||||
entity.getEquipment().setItemInHand(ItemHand);
|
return;
|
||||||
entity.getEquipment().setHelmet(ItemHelmet);
|
}
|
||||||
entity.getEquipment().setChestplate(ItemChestplate);
|
|
||||||
entity.getEquipment().setLeggings(ItemLeggings);
|
LivingEntity entity = (LivingEntity) gWorld.getWorld().spawnEntity(loc, type);
|
||||||
entity.getEquipment().setBoots(ItemBoots);
|
|
||||||
|
/* Set the Items */
|
||||||
/* Check mob specified stuff */
|
entity.getEquipment().setItemInHand(ItemHand);
|
||||||
if (type == EntityType.SKELETON) {
|
entity.getEquipment().setHelmet(ItemHelmet);
|
||||||
if (isWitherSkeleton) {
|
entity.getEquipment().setChestplate(ItemChestplate);
|
||||||
((Skeleton) entity).setSkeletonType(SkeletonType.WITHER);
|
entity.getEquipment().setLeggings(ItemLeggings);
|
||||||
} else {
|
entity.getEquipment().setBoots(ItemBoots);
|
||||||
((Skeleton) entity).setSkeletonType(SkeletonType.NORMAL);
|
|
||||||
}
|
/* Check mob specified stuff */
|
||||||
}
|
if (type == EntityType.SKELETON) {
|
||||||
|
if (isWitherSkeleton) {
|
||||||
if (type == EntityType.OCELOT) {
|
((Skeleton) entity).setSkeletonType(SkeletonType.WITHER);
|
||||||
Ocelot ocelot = (Ocelot) entity;
|
} else {
|
||||||
if (ocelotType != null) {
|
((Skeleton) entity).setSkeletonType(SkeletonType.NORMAL);
|
||||||
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 == 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
|
// Load Config
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static Set<DMobType> load(ConfigurationSection configFile) {
|
public static Set<DMobType> load(ConfigurationSection configFile) {
|
||||||
Set<DMobType> set = new HashSet<DMobType>();
|
Set<DMobType> set = new HashSet<DMobType>();
|
||||||
if (configFile != null) {
|
|
||||||
// Read Mobs
|
if (configFile == null) {
|
||||||
for (String mobName : configFile.getKeys(false)) {
|
return null;
|
||||||
EntityType type = EntityType.fromName(configFile.getString(mobName + ".Type"));
|
}
|
||||||
|
|
||||||
if (type != null) {
|
// Read Mobs
|
||||||
DMobType mobType = new DMobType(mobName, type);
|
for (String mobName : configFile.getKeys(false)) {
|
||||||
set.add(mobType);
|
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
|
/* Item Stack */
|
||||||
if (configFile.contains(mobName + ".MaxHealth")) {
|
Material mat = Material.getMaterial(configSetion.getInt(dropPath + ".id"));
|
||||||
mobType.maxHealth = configFile.getInt(mobName + ".MaxHealth");
|
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
|
item = new ItemStack(mat, amount, data);
|
||||||
if (configFile.contains(mobName + ".ItemHelmet")) {
|
itemMeta = item.getItemMeta();
|
||||||
mobType.ItemHelmet = new ItemStack(configFile.getInt(mobName + ".ItemHelmet"));// CraftItemStack.asNMSCopy(new
|
|
||||||
// ItemStack(configFile.getInt(mobName+".ItemHelmet"))).getItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configFile.contains(mobName + ".ItemChestplate")) {
|
/* Enchantments */
|
||||||
mobType.ItemChestplate = new ItemStack(configFile.getInt(mobName + ".ItemChestplate"));// CraftItemStack.asNMSCopy(new
|
if (configSetion.contains(dropPath + ".enchantments")) {
|
||||||
// ItemStack(configFile.getInt(mobName+".ItemChestplate"))).getItem();
|
for (String enchantment : configSetion.getStringList(dropPath + ".enchantments")) {
|
||||||
}
|
String[] splittedEnchantment = enchantment.split(" ");
|
||||||
|
if (Enchantment.getByName(splittedEnchantment[0].toUpperCase()) != null) {
|
||||||
if (configFile.contains(mobName + ".ItemBoots")) {
|
if (splittedEnchantment.length > 1) {
|
||||||
mobType.ItemBoots = new ItemStack(configFile.getInt(mobName + ".ItemBoots"));// CraftItemStack.asNMSCopy(new
|
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), IntegerUtil.parseInt(splittedEnchantment[1]), true);
|
||||||
// ItemStack(configFile.getInt(mobName+".ItemBoots"))).getItem();
|
} else {
|
||||||
}
|
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), 1, true);
|
||||||
|
|
||||||
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]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} 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 {
|
/* Item Name */
|
||||||
DungeonsXL.getPlugin().getLogger().info(DungeonsXL.getPlugin().getDMessages().get("Log_Error_MobType", configFile.getString(mobName + ".Type")));
|
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;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ public class DGroup {
|
|||||||
private String dungeonName;
|
private String dungeonName;
|
||||||
private String mapName;
|
private String mapName;
|
||||||
private List<String> unplayedFloors = new ArrayList<String>();
|
private List<String> unplayedFloors = new ArrayList<String>();
|
||||||
private GameWorld gWorld;
|
private GameWorld gameWorld;
|
||||||
private boolean playing;
|
private boolean playing;
|
||||||
private int floorCount;
|
private int floorCount;
|
||||||
|
|
||||||
@ -34,6 +34,7 @@ public class DGroup {
|
|||||||
this.dungeonName = identifier;
|
this.dungeonName = identifier;
|
||||||
this.mapName = plugin.getDungeons().getDungeon(dungeonName).getConfig().getStartFloor();
|
this.mapName = plugin.getDungeons().getDungeon(dungeonName).getConfig().getStartFloor();
|
||||||
this.unplayedFloors = plugin.getDungeons().getDungeon(dungeonName).getConfig().getFloors();
|
this.unplayedFloors = plugin.getDungeons().getDungeon(dungeonName).getConfig().getFloors();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.mapName = identifier;
|
this.mapName = identifier;
|
||||||
}
|
}
|
||||||
@ -84,18 +85,18 @@ public class DGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the gWorld
|
* @return the gameWorld
|
||||||
*/
|
*/
|
||||||
public GameWorld getGWorld() {
|
public GameWorld getGWorld() {
|
||||||
return gWorld;
|
return gameWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param gWorld
|
* @param gameWorld
|
||||||
* the gWorld to set
|
* the gameWorld to set
|
||||||
*/
|
*/
|
||||||
public void setGWorld(GameWorld gWorld) {
|
public void setGWorld(GameWorld gameWorld) {
|
||||||
this.gWorld = gWorld;
|
this.gameWorld = gameWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -212,7 +213,7 @@ public class DGroup {
|
|||||||
|
|
||||||
public void startGame() {
|
public void startGame() {
|
||||||
playing = true;
|
playing = true;
|
||||||
gWorld.startGame();
|
gameWorld.startGame();
|
||||||
floorCount++;
|
floorCount++;
|
||||||
|
|
||||||
double fee;
|
double fee;
|
||||||
@ -244,19 +245,19 @@ public class DGroup {
|
|||||||
// Statics
|
// Statics
|
||||||
|
|
||||||
public static DGroup get(Player player) {
|
public static DGroup get(Player player) {
|
||||||
for (DGroup dgroup : plugin.getDGroups()) {
|
for (DGroup dGroup : plugin.getDGroups()) {
|
||||||
if (dgroup.getPlayers().contains(player)) {
|
if (dGroup.getPlayers().contains(player)) {
|
||||||
return dgroup;
|
return dGroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DGroup get(GameWorld gWorld) {
|
public static DGroup get(GameWorld gameWorld) {
|
||||||
for (DGroup dgroup : plugin.getDGroups()) {
|
for (DGroup dGroup : plugin.getDGroups()) {
|
||||||
if (dgroup.getGWorld() == gWorld) {
|
if (dGroup.getGWorld() == gameWorld) {
|
||||||
return dgroup;
|
return dGroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,9 +265,9 @@ public class DGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void leaveGroup(Player player) {
|
public static void leaveGroup(Player player) {
|
||||||
for (DGroup dgroup : plugin.getDGroups()) {
|
for (DGroup dGroup : plugin.getDGroups()) {
|
||||||
if (dgroup.getPlayers().contains(player)) {
|
if (dGroup.getPlayers().contains(player)) {
|
||||||
dgroup.getPlayers().remove(player);
|
dGroup.getPlayers().remove(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,37 +38,37 @@ public class DPlayer {
|
|||||||
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
public Player player;
|
private Player player;
|
||||||
public World world;
|
private World world;
|
||||||
|
|
||||||
public boolean isinTestMode = false;
|
private boolean isInTestMode = false;
|
||||||
|
|
||||||
public DSavePlayer savePlayer;
|
private DSavePlayer savePlayer;
|
||||||
|
|
||||||
public boolean isEditing;
|
private boolean isEditing;
|
||||||
public boolean isInDungeonChat = false;
|
private boolean isInDungeonChat = false;
|
||||||
public boolean isReady = false;
|
private boolean isReady = false;
|
||||||
public boolean isFinished = false;
|
private boolean isFinished = false;
|
||||||
|
|
||||||
public DClass dclass;
|
private DClass dClass;
|
||||||
public Location checkpoint;
|
private Location checkpoint;
|
||||||
public Wolf wolf;
|
private Wolf wolf;
|
||||||
public int wolfRespawnTime = 30;
|
private int wolfRespawnTime = 30;
|
||||||
public long offlineTime;
|
private long offlineTime;
|
||||||
public ItemStack[] respawnInventory;
|
private ItemStack[] respawnInventory;
|
||||||
public ItemStack[] respawnArmor;
|
private ItemStack[] respawnArmor;
|
||||||
public String[] linesCopy;
|
private String[] linesCopy;
|
||||||
|
|
||||||
public Inventory treasureInv = DungeonsXL.getPlugin().getServer().createInventory(player, 45, plugin.getDMessages().get("Player_Treasures"));
|
private Inventory treasureInv = DungeonsXL.getPlugin().getServer().createInventory(getPlayer(), 45, plugin.getDMessages().get("Player_Treasures"));
|
||||||
public double treasureMoney = 0;
|
private double treasureMoney = 0;
|
||||||
|
|
||||||
public int initialLives = -1;
|
private int initialLives = -1;
|
||||||
public int lives;
|
private int lives;
|
||||||
|
|
||||||
public DPlayer(Player player, World world, Location teleport, boolean isEditing) {
|
public DPlayer(Player player, World world, Location teleport, boolean isEditing) {
|
||||||
plugin.getDPlayers().add(this);
|
plugin.getDPlayers().add(this);
|
||||||
|
|
||||||
this.player = player;
|
this.setPlayer(player);
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
|
||||||
double health = ((Damageable) player).getHealth();
|
double health = ((Damageable) player).getHealth();
|
||||||
@ -79,11 +79,11 @@ public class DPlayer {
|
|||||||
this.isEditing = isEditing;
|
this.isEditing = isEditing;
|
||||||
|
|
||||||
if (this.isEditing) {
|
if (this.isEditing) {
|
||||||
this.player.setGameMode(GameMode.CREATIVE);
|
this.getPlayer().setGameMode(GameMode.CREATIVE);
|
||||||
clearPlayerData();
|
clearPlayerData();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.player.setGameMode(GameMode.SURVIVAL);
|
this.getPlayer().setGameMode(GameMode.SURVIVAL);
|
||||||
WorldConfig dConfig = GameWorld.get(world).getConfig();
|
WorldConfig dConfig = GameWorld.get(world).getConfig();
|
||||||
if ( !dConfig.getKeepInventoryOnEnter()) {
|
if ( !dConfig.getKeepInventoryOnEnter()) {
|
||||||
clearPlayerData();
|
clearPlayerData();
|
||||||
@ -95,18 +95,18 @@ public class DPlayer {
|
|||||||
lives = initialLives;
|
lives = initialLives;
|
||||||
}
|
}
|
||||||
|
|
||||||
MiscUtil.secureTeleport(this.player, teleport);
|
MiscUtil.secureTeleport(this.getPlayer(), teleport);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearPlayerData() {
|
public void clearPlayerData() {
|
||||||
player.getInventory().clear();
|
getPlayer().getInventory().clear();
|
||||||
player.getInventory().setArmorContents(null);
|
getPlayer().getInventory().setArmorContents(null);
|
||||||
player.setTotalExperience(0);
|
getPlayer().setTotalExperience(0);
|
||||||
player.setLevel(0);
|
getPlayer().setLevel(0);
|
||||||
player.setHealth(20);
|
getPlayer().setHealth(20);
|
||||||
player.setFoodLevel(20);
|
getPlayer().setFoodLevel(20);
|
||||||
for (PotionEffect effect : player.getActivePotionEffects()) {
|
for (PotionEffect effect : getPlayer().getActivePotionEffects()) {
|
||||||
player.removePotionEffect(effect.getType());
|
getPlayer().removePotionEffect(effect.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,22 +135,22 @@ public class DPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
GameWorld gWorld = GameWorld.get(world);
|
GameWorld gameWorld = GameWorld.get(world);
|
||||||
DGroup dGroup = DGroup.get(player);
|
DGroup dGroup = DGroup.get(getPlayer());
|
||||||
if (dGroup != null) {
|
if (dGroup != null) {
|
||||||
dGroup.removePlayer(player);
|
dGroup.removePlayer(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Belohnung
|
// Belohnung
|
||||||
if ( !isinTestMode) {// Nur wenn man nicht am Testen ist
|
if ( !isInTestMode) {// Nur wenn man nicht am Testen ist
|
||||||
if (isFinished) {
|
if (isFinished) {
|
||||||
addTreasure();
|
addTreasure();
|
||||||
if (plugin.getEconomyProvider() != null) {
|
if (plugin.getEconomyProvider() != null) {
|
||||||
plugin.getEconomyProvider().depositPlayer(player, treasureMoney);
|
plugin.getEconomyProvider().depositPlayer(getPlayer(), treasureMoney);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Time
|
// Set Time
|
||||||
File file = new File(plugin.getDataFolder() + "/maps/" + gWorld.dungeonname, "players.yml");
|
File file = new File(plugin.getDataFolder() + "/maps/" + gameWorld.getMapName(), "players.yml");
|
||||||
|
|
||||||
if ( !file.exists()) {
|
if ( !file.exists()) {
|
||||||
try {
|
try {
|
||||||
@ -162,7 +162,7 @@ public class DPlayer {
|
|||||||
|
|
||||||
FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file);
|
FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file);
|
||||||
|
|
||||||
playerConfig.set(player.getUniqueId().toString(), System.currentTimeMillis());
|
playerConfig.set(getPlayer().getUniqueId().toString(), System.currentTimeMillis());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
playerConfig.save(file);
|
playerConfig.save(file);
|
||||||
@ -171,15 +171,15 @@ public class DPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tutorial Permissions
|
// Tutorial Permissions
|
||||||
if (gWorld.isTutorial) {
|
if (gameWorld.isTutorial()) {
|
||||||
String endGroup = plugin.getMainConfig().getTutorialEndGroup();
|
String endGroup = plugin.getMainConfig().getTutorialEndGroup();
|
||||||
if (plugin.isGroupEnabled(endGroup)) {
|
if (plugin.isGroupEnabled(endGroup)) {
|
||||||
plugin.getPermissionProvider().playerAddGroup(player, endGroup);
|
plugin.getPermissionProvider().playerAddGroup(getPlayer(), endGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
String startGroup = plugin.getMainConfig().getTutorialStartGroup();
|
String startGroup = plugin.getMainConfig().getTutorialStartGroup();
|
||||||
if (plugin.isGroupEnabled(startGroup)) {
|
if (plugin.isGroupEnabled(startGroup)) {
|
||||||
plugin.getPermissionProvider().playerRemoveGroup(player, startGroup);
|
plugin.getPermissionProvider().playerRemoveGroup(getPlayer(), startGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,9 +194,9 @@ public class DPlayer {
|
|||||||
groupplayer = dGroup.getPlayers().get(i);
|
groupplayer = dGroup.getPlayers().get(i);
|
||||||
if (groupplayer != null) {
|
if (groupplayer != null) {
|
||||||
org.bukkit.Bukkit.broadcastMessage("14");
|
org.bukkit.Bukkit.broadcastMessage("14");
|
||||||
for (ItemStack istack : player.getInventory()) {
|
for (ItemStack istack : getPlayer().getInventory()) {
|
||||||
if (istack != null) {
|
if (istack != null) {
|
||||||
if (gWorld.secureObjects.contains(istack.getType())) {
|
if (gameWorld.getSecureObjects().contains(istack.getType())) {
|
||||||
groupplayer.getInventory().addItem(istack);
|
groupplayer.getInventory().addItem(istack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,7 +212,7 @@ public class DPlayer {
|
|||||||
public void ready() {
|
public void ready() {
|
||||||
isReady = true;
|
isReady = true;
|
||||||
|
|
||||||
DGroup dGroup = DGroup.get(player);
|
DGroup dGroup = DGroup.get(getPlayer());
|
||||||
if ( !dGroup.isPlaying()) {
|
if ( !dGroup.isPlaying()) {
|
||||||
if (dGroup != null) {
|
if (dGroup != null) {
|
||||||
for (Player player : dGroup.getPlayers()) {
|
for (Player player : dGroup.getPlayers()) {
|
||||||
@ -230,21 +230,21 @@ public class DPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void respawn() {
|
public void respawn() {
|
||||||
DGroup dGroup = DGroup.get(player);
|
DGroup dGroup = DGroup.get(getPlayer());
|
||||||
if (checkpoint == null) {
|
if (checkpoint == null) {
|
||||||
MiscUtil.secureTeleport(player, dGroup.getGWorld().locStart);
|
MiscUtil.secureTeleport(getPlayer(), dGroup.getGWorld().getLocStart());
|
||||||
} else {
|
} else {
|
||||||
MiscUtil.secureTeleport(player, checkpoint);
|
MiscUtil.secureTeleport(getPlayer(), checkpoint);
|
||||||
}
|
}
|
||||||
if (wolf != null) {
|
if (wolf != null) {
|
||||||
wolf.teleport(player);
|
wolf.teleport(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Respawn Items
|
// Respawn Items
|
||||||
if (GameWorld.get(world).getConfig().getKeepInventoryOnDeath()) {
|
if (GameWorld.get(world).getConfig().getKeepInventoryOnDeath()) {
|
||||||
if (respawnInventory != null || respawnArmor != null) {
|
if (respawnInventory != null || respawnArmor != null) {
|
||||||
player.getInventory().setContents(respawnInventory);
|
getPlayer().getInventory().setContents(respawnInventory);
|
||||||
player.getInventory().setArmorContents(respawnArmor);
|
getPlayer().getInventory().setArmorContents(respawnArmor);
|
||||||
respawnInventory = null;
|
respawnInventory = null;
|
||||||
respawnArmor = null;
|
respawnArmor = null;
|
||||||
}
|
}
|
||||||
@ -253,10 +253,10 @@ public class DPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void finishFloor(String specifiedFloor) {
|
public void finishFloor(String specifiedFloor) {
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_FinishedDungeon"));
|
MessageUtil.sendMessage(getPlayer(), plugin.getDMessages().get("Player_FinishedDungeon"));
|
||||||
isFinished = true;
|
isFinished = true;
|
||||||
|
|
||||||
DGroup dGroup = DGroup.get(player);
|
DGroup dGroup = DGroup.get(getPlayer());
|
||||||
if (dGroup == null) {
|
if (dGroup == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -268,7 +268,7 @@ public class DPlayer {
|
|||||||
for (Player player : dGroup.getPlayers()) {
|
for (Player player : dGroup.getPlayers()) {
|
||||||
DPlayer dplayer = get(player);
|
DPlayer dplayer = get(player);
|
||||||
if ( !dplayer.isFinished) {
|
if ( !dplayer.isFinished) {
|
||||||
MessageUtil.sendMessage(this.player, plugin.getDMessages().get("Player_WaitForOtherPlayers"));
|
MessageUtil.sendMessage(this.getPlayer(), plugin.getDMessages().get("Player_WaitForOtherPlayers"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -308,16 +308,16 @@ public class DPlayer {
|
|||||||
dGroup.setGWorld(GameWorld.load(newFloor));
|
dGroup.setGWorld(GameWorld.load(newFloor));
|
||||||
for (Player player : dGroup.getPlayers()) {
|
for (Player player : dGroup.getPlayers()) {
|
||||||
DPlayer dPlayer = get(player);
|
DPlayer dPlayer = get(player);
|
||||||
dPlayer.checkpoint = dGroup.getGWorld().locStart;
|
dPlayer.checkpoint = dGroup.getGWorld().getLocStart();
|
||||||
}
|
}
|
||||||
dGroup.startGame();
|
dGroup.startGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finish() {
|
public void finish() {
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_FinishedDungeon"));
|
MessageUtil.sendMessage(getPlayer(), plugin.getDMessages().get("Player_FinishedDungeon"));
|
||||||
isFinished = true;
|
isFinished = true;
|
||||||
|
|
||||||
DGroup dGroup = DGroup.get(player);
|
DGroup dGroup = DGroup.get(getPlayer());
|
||||||
if (dGroup == null) {
|
if (dGroup == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -329,7 +329,7 @@ public class DPlayer {
|
|||||||
for (Player player : dGroup.getPlayers()) {
|
for (Player player : dGroup.getPlayers()) {
|
||||||
DPlayer dplayer = get(player);
|
DPlayer dplayer = get(player);
|
||||||
if ( !dplayer.isFinished) {
|
if ( !dplayer.isFinished) {
|
||||||
MessageUtil.sendMessage(this.player, plugin.getDMessages().get("Player_WaitForOtherPlayers"));
|
MessageUtil.sendMessage(this.getPlayer(), plugin.getDMessages().get("Player_WaitForOtherPlayers"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,15 +345,15 @@ public class DPlayer {
|
|||||||
EditWorld eworld = EditWorld.get(world);
|
EditWorld eworld = EditWorld.get(world);
|
||||||
eworld.msg(msg);
|
eworld.msg(msg);
|
||||||
for (Player player : plugin.getChatSpyers()) {
|
for (Player player : plugin.getChatSpyers()) {
|
||||||
if ( !eworld.world.getPlayers().contains(player)) {
|
if ( !eworld.getWorld().getPlayers().contains(player)) {
|
||||||
MessageUtil.sendMessage(player, ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + msg);
|
MessageUtil.sendMessage(player, ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GameWorld gWorld = GameWorld.get(world);
|
GameWorld gameWorld = GameWorld.get(world);
|
||||||
gWorld.msg(msg);
|
gameWorld.msg(msg);
|
||||||
for (Player player : plugin.getChatSpyers()) {
|
for (Player player : plugin.getChatSpyers()) {
|
||||||
if ( !gWorld.world.getPlayers().contains(player)) {
|
if ( !gameWorld.getWorld().getPlayers().contains(player)) {
|
||||||
MessageUtil.sendMessage(player, ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + msg);
|
MessageUtil.sendMessage(player, ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -367,7 +367,7 @@ public class DPlayer {
|
|||||||
String[] lines = sign.getLines();
|
String[] lines = sign.getLines();
|
||||||
if (lines[0].equals("") && lines[1].equals("") && lines[2].equals("") && lines[3].equals("")) {
|
if (lines[0].equals("") && lines[1].equals("") && lines[2].equals("") && lines[3].equals("")) {
|
||||||
if (linesCopy != null) {
|
if (linesCopy != null) {
|
||||||
SignChangeEvent event = new SignChangeEvent(block, player, linesCopy);
|
SignChangeEvent event = new SignChangeEvent(block, getPlayer(), linesCopy);
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
if ( !event.isCancelled()) {
|
if ( !event.isCancelled()) {
|
||||||
sign.setLine(0, event.getLine(0));
|
sign.setLine(0, event.getLine(0));
|
||||||
@ -379,27 +379,162 @@ public class DPlayer {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
linesCopy = lines;
|
linesCopy = lines;
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_SignCopied"));
|
MessageUtil.sendMessage(getPlayer(), plugin.getDMessages().get("Player_SignCopied"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String info = "" + block.getType();
|
String info = "" + block.getType();
|
||||||
if (block.getData() != 0) {
|
if (block.getData() != 0) {
|
||||||
info = info + "," + block.getData();
|
info = info + "," + block.getData();
|
||||||
}
|
}
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_BlockInfo", info));
|
MessageUtil.sendMessage(getPlayer(), plugin.getDMessages().get("Player_BlockInfo", info));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClass(String classname) {
|
public void addTreasure() {
|
||||||
GameWorld gWorld = GameWorld.get(player.getWorld());
|
new DLootInventory(getPlayer(), treasureInv.getContents());
|
||||||
if (gWorld == null) {
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the player
|
||||||
|
*/
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param player
|
||||||
|
* the player to set
|
||||||
|
*/
|
||||||
|
public void setPlayer(Player player) {
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the world
|
||||||
|
*/
|
||||||
|
public World getWorld() {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param world
|
||||||
|
* the world to set
|
||||||
|
*/
|
||||||
|
public void setWorld(World world) {
|
||||||
|
this.world = world;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the isinTestMode
|
||||||
|
*/
|
||||||
|
public boolean isIsinTestMode() {
|
||||||
|
return isInTestMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param isInTestMode
|
||||||
|
* the isInTestMode to set
|
||||||
|
*/
|
||||||
|
public void setIsInTestMode(boolean isInTestMode) {
|
||||||
|
this.isInTestMode = isInTestMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the savePlayer
|
||||||
|
*/
|
||||||
|
public DSavePlayer getSavePlayer() {
|
||||||
|
return savePlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param savePlayer
|
||||||
|
* the savePlayer to set
|
||||||
|
*/
|
||||||
|
public void setSavePlayer(DSavePlayer savePlayer) {
|
||||||
|
this.savePlayer = savePlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the isEditing
|
||||||
|
*/
|
||||||
|
public boolean isEditing() {
|
||||||
|
return isEditing;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param isEditing
|
||||||
|
* the isEditing to set
|
||||||
|
*/
|
||||||
|
public void setEditing(boolean isEditing) {
|
||||||
|
this.isEditing = isEditing;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the isInDungeonChat
|
||||||
|
*/
|
||||||
|
public boolean isInDungeonChat() {
|
||||||
|
return isInDungeonChat;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param isInDungeonChat
|
||||||
|
* the isInDungeonChat to set
|
||||||
|
*/
|
||||||
|
public void setInDungeonChat(boolean isInDungeonChat) {
|
||||||
|
this.isInDungeonChat = isInDungeonChat;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the isReady
|
||||||
|
*/
|
||||||
|
public boolean isReady() {
|
||||||
|
return isReady;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param isReady
|
||||||
|
* the isReady to set
|
||||||
|
*/
|
||||||
|
public void setReady(boolean isReady) {
|
||||||
|
this.isReady = isReady;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the isFinished
|
||||||
|
*/
|
||||||
|
public boolean isFinished() {
|
||||||
|
return isFinished;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param isFinished
|
||||||
|
* the isFinished to set
|
||||||
|
*/
|
||||||
|
public void setFinished(boolean isFinished) {
|
||||||
|
this.isFinished = isFinished;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the dClass
|
||||||
|
*/
|
||||||
|
public DClass getDClass() {
|
||||||
|
return dClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dClass
|
||||||
|
* the dClass to set
|
||||||
|
*/
|
||||||
|
public void setDClass(String className) {
|
||||||
|
GameWorld gameWorld = GameWorld.get(getPlayer().getWorld());
|
||||||
|
if (gameWorld == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DClass dclass = gWorld.getConfig().getClass(classname);
|
DClass dClass = gameWorld.getConfig().getClass(className);
|
||||||
if (dclass != null) {
|
if (dClass != null) {
|
||||||
if (this.dclass != dclass) {
|
if (this.dClass != dClass) {
|
||||||
this.dclass = dclass;
|
this.dClass = dClass;
|
||||||
|
|
||||||
/* Set Dog */
|
/* Set Dog */
|
||||||
if (wolf != null) {
|
if (wolf != null) {
|
||||||
@ -407,77 +542,235 @@ public class DPlayer {
|
|||||||
wolf = null;
|
wolf = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dclass.hasDog()) {
|
if (dClass.hasDog()) {
|
||||||
wolf = (Wolf) world.spawnEntity(player.getLocation(), EntityType.WOLF);
|
wolf = (Wolf) world.spawnEntity(getPlayer().getLocation(), EntityType.WOLF);
|
||||||
wolf.setTamed(true);
|
wolf.setTamed(true);
|
||||||
wolf.setOwner(player);
|
wolf.setOwner(getPlayer());
|
||||||
|
|
||||||
double maxHealth = ((Damageable) wolf).getMaxHealth();
|
double maxHealth = ((Damageable) wolf).getMaxHealth();
|
||||||
wolf.setHealth(maxHealth);
|
wolf.setHealth(maxHealth);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete Inventory */
|
/* Delete Inventory */
|
||||||
player.getInventory().clear();
|
getPlayer().getInventory().clear();
|
||||||
player.getInventory().setArmorContents(null);
|
getPlayer().getInventory().setArmorContents(null);
|
||||||
player.getInventory().setItemInHand(new ItemStack(Material.AIR));
|
getPlayer().getInventory().setItemInHand(new ItemStack(Material.AIR));
|
||||||
|
|
||||||
// Remove Potion Effects
|
// Remove Potion Effects
|
||||||
for (PotionEffect effect : player.getActivePotionEffects()) {
|
for (PotionEffect effect : getPlayer().getActivePotionEffects()) {
|
||||||
player.removePotionEffect(effect.getType());
|
getPlayer().removePotionEffect(effect.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset lvl
|
// Reset lvl
|
||||||
player.setTotalExperience(0);
|
getPlayer().setTotalExperience(0);
|
||||||
player.setLevel(0);
|
getPlayer().setLevel(0);
|
||||||
|
|
||||||
/* Set Inventory */
|
/* Set Inventory */
|
||||||
for (ItemStack istack : dclass.getItems()) {
|
for (ItemStack istack : dClass.getItems()) {
|
||||||
|
|
||||||
// Leggings
|
// Leggings
|
||||||
if (istack.getType() == Material.LEATHER_LEGGINGS || istack.getType() == Material.CHAINMAIL_LEGGINGS || istack.getType() == Material.IRON_LEGGINGS
|
if (istack.getType() == Material.LEATHER_LEGGINGS || istack.getType() == Material.CHAINMAIL_LEGGINGS || istack.getType() == Material.IRON_LEGGINGS
|
||||||
|| istack.getType() == Material.DIAMOND_LEGGINGS || istack.getType() == Material.GOLD_LEGGINGS) {
|
|| istack.getType() == Material.DIAMOND_LEGGINGS || istack.getType() == Material.GOLD_LEGGINGS) {
|
||||||
player.getInventory().setLeggings(istack);
|
getPlayer().getInventory().setLeggings(istack);
|
||||||
}
|
}
|
||||||
// Helmet
|
// Helmet
|
||||||
else if (istack.getType() == Material.LEATHER_HELMET || istack.getType() == Material.CHAINMAIL_HELMET || istack.getType() == Material.IRON_HELMET
|
else if (istack.getType() == Material.LEATHER_HELMET || istack.getType() == Material.CHAINMAIL_HELMET || istack.getType() == Material.IRON_HELMET
|
||||||
|| istack.getType() == Material.DIAMOND_HELMET || istack.getType() == Material.GOLD_HELMET) {
|
|| istack.getType() == Material.DIAMOND_HELMET || istack.getType() == Material.GOLD_HELMET) {
|
||||||
player.getInventory().setHelmet(istack);
|
getPlayer().getInventory().setHelmet(istack);
|
||||||
}
|
}
|
||||||
// Chestplate
|
// Chestplate
|
||||||
else if (istack.getType() == Material.LEATHER_CHESTPLATE || istack.getType() == Material.CHAINMAIL_CHESTPLATE || istack.getType() == Material.IRON_CHESTPLATE
|
else if (istack.getType() == Material.LEATHER_CHESTPLATE || istack.getType() == Material.CHAINMAIL_CHESTPLATE || istack.getType() == Material.IRON_CHESTPLATE
|
||||||
|| istack.getType() == Material.DIAMOND_CHESTPLATE || istack.getType() == Material.GOLD_CHESTPLATE) {
|
|| istack.getType() == Material.DIAMOND_CHESTPLATE || istack.getType() == Material.GOLD_CHESTPLATE) {
|
||||||
player.getInventory().setChestplate(istack);
|
getPlayer().getInventory().setChestplate(istack);
|
||||||
}
|
}
|
||||||
// Boots
|
// Boots
|
||||||
else if (istack.getType() == Material.LEATHER_BOOTS || istack.getType() == Material.CHAINMAIL_BOOTS || istack.getType() == Material.IRON_BOOTS
|
else if (istack.getType() == Material.LEATHER_BOOTS || istack.getType() == Material.CHAINMAIL_BOOTS || istack.getType() == Material.IRON_BOOTS
|
||||||
|| istack.getType() == Material.DIAMOND_BOOTS || istack.getType() == Material.GOLD_BOOTS) {
|
|| istack.getType() == Material.DIAMOND_BOOTS || istack.getType() == Material.GOLD_BOOTS) {
|
||||||
player.getInventory().setBoots(istack);
|
getPlayer().getInventory().setBoots(istack);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
player.getInventory().addItem(istack);
|
getPlayer().getInventory().addItem(istack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the checkpoint
|
||||||
|
*/
|
||||||
|
public Location getCheckpoint() {
|
||||||
|
return checkpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param checkpoint
|
||||||
|
* the checkpoint to set
|
||||||
|
*/
|
||||||
public void setCheckpoint(Location checkpoint) {
|
public void setCheckpoint(Location checkpoint) {
|
||||||
this.checkpoint = checkpoint;
|
this.checkpoint = checkpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTreasure() {
|
/**
|
||||||
new DLootInventory(player, treasureInv.getContents());
|
* @return the wolf
|
||||||
|
*/
|
||||||
|
public Wolf getWolf() {
|
||||||
|
return wolf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param wolf
|
||||||
|
* the wolf to set
|
||||||
|
*/
|
||||||
|
public void setWolf(Wolf wolf) {
|
||||||
|
this.wolf = wolf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the wolfRespawnTime
|
||||||
|
*/
|
||||||
|
public int getWolfRespawnTime() {
|
||||||
|
return wolfRespawnTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param wolfRespawnTime
|
||||||
|
* the wolfRespawnTime to set
|
||||||
|
*/
|
||||||
|
public void setWolfRespawnTime(int wolfRespawnTime) {
|
||||||
|
this.wolfRespawnTime = wolfRespawnTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the offlineTime
|
||||||
|
*/
|
||||||
|
public long getOfflineTime() {
|
||||||
|
return offlineTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param offlineTime
|
||||||
|
* the offlineTime to set
|
||||||
|
*/
|
||||||
|
public void setOfflineTime(long offlineTime) {
|
||||||
|
this.offlineTime = offlineTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the respawnInventory
|
||||||
|
*/
|
||||||
|
public ItemStack[] getRespawnInventory() {
|
||||||
|
return respawnInventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param respawnInventory
|
||||||
|
* the respawnInventory to set
|
||||||
|
*/
|
||||||
|
public void setRespawnInventory(ItemStack[] respawnInventory) {
|
||||||
|
this.respawnInventory = respawnInventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the respawnArmor
|
||||||
|
*/
|
||||||
|
public ItemStack[] getRespawnArmor() {
|
||||||
|
return respawnArmor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param respawnArmor
|
||||||
|
* the respawnArmor to set
|
||||||
|
*/
|
||||||
|
public void setRespawnArmor(ItemStack[] respawnArmor) {
|
||||||
|
this.respawnArmor = respawnArmor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the linesCopy
|
||||||
|
*/
|
||||||
|
public String[] getLinesCopy() {
|
||||||
|
return linesCopy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param linesCopy
|
||||||
|
* the linesCopy to set
|
||||||
|
*/
|
||||||
|
public void setLinesCopy(String[] linesCopy) {
|
||||||
|
this.linesCopy = linesCopy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the treasureInv
|
||||||
|
*/
|
||||||
|
public Inventory getTreasureInv() {
|
||||||
|
return treasureInv;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param treasureInv
|
||||||
|
* the treasureInv to set
|
||||||
|
*/
|
||||||
|
public void setTreasureInv(Inventory treasureInv) {
|
||||||
|
this.treasureInv = treasureInv;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the treasureMoney
|
||||||
|
*/
|
||||||
|
public double getTreasureMoney() {
|
||||||
|
return treasureMoney;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param treasureMoney
|
||||||
|
* the treasureMoney to set
|
||||||
|
*/
|
||||||
|
public void setTreasureMoney(double treasureMoney) {
|
||||||
|
this.treasureMoney = treasureMoney;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the initialLives
|
||||||
|
*/
|
||||||
|
public int getInitialLives() {
|
||||||
|
return initialLives;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param initialLives
|
||||||
|
* the initialLives to set
|
||||||
|
*/
|
||||||
|
public void setInitialLives(int initialLives) {
|
||||||
|
this.initialLives = initialLives;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the lives
|
||||||
|
*/
|
||||||
|
public int getLives() {
|
||||||
|
return lives;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param lives
|
||||||
|
* the lives to set
|
||||||
|
*/
|
||||||
|
public void setLives(int lives) {
|
||||||
|
this.lives = lives;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
|
||||||
public static void remove(DPlayer player) {
|
public static void remove(DPlayer player) {
|
||||||
plugin.getDPlayers().remove(player);
|
plugin.getDPlayers().remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DPlayer get(Player player) {
|
public static DPlayer get(Player player) {
|
||||||
for (DPlayer dplayer : plugin.getDPlayers()) {
|
for (DPlayer dplayer : plugin.getDPlayers()) {
|
||||||
if (dplayer.player.equals(player)) {
|
if (dplayer.getPlayer().equals(player)) {
|
||||||
return dplayer;
|
return dplayer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -486,7 +779,7 @@ public class DPlayer {
|
|||||||
|
|
||||||
public static DPlayer get(String name) {
|
public static DPlayer get(String name) {
|
||||||
for (DPlayer dplayer : plugin.getDPlayers()) {
|
for (DPlayer dplayer : plugin.getDPlayers()) {
|
||||||
if (dplayer.player.getName().equalsIgnoreCase(name)) {
|
if (dplayer.getPlayer().getName().equalsIgnoreCase(name)) {
|
||||||
return dplayer;
|
return dplayer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -508,27 +801,27 @@ public class DPlayer {
|
|||||||
public static void update(boolean updateSecond) {
|
public static void update(boolean updateSecond) {
|
||||||
for (DPlayer dplayer : plugin.getDPlayers()) {
|
for (DPlayer dplayer : plugin.getDPlayers()) {
|
||||||
if ( !updateSecond) {
|
if ( !updateSecond) {
|
||||||
if ( !dplayer.player.getWorld().equals(dplayer.world)) {
|
if ( !dplayer.getPlayer().getWorld().equals(dplayer.world)) {
|
||||||
if (dplayer.isEditing) {
|
if (dplayer.isEditing) {
|
||||||
EditWorld eworld = EditWorld.get(dplayer.world);
|
EditWorld eworld = EditWorld.get(dplayer.world);
|
||||||
if (eworld != null) {
|
if (eworld != null) {
|
||||||
if (eworld.lobby == null) {
|
if (eworld.getLobby() == null) {
|
||||||
MiscUtil.secureTeleport(dplayer.player, eworld.world.getSpawnLocation());
|
MiscUtil.secureTeleport(dplayer.getPlayer(), eworld.getWorld().getSpawnLocation());
|
||||||
} else {
|
} else {
|
||||||
MiscUtil.secureTeleport(dplayer.player, eworld.lobby);
|
MiscUtil.secureTeleport(dplayer.getPlayer(), eworld.getLobby());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GameWorld gWorld = GameWorld.get(dplayer.world);
|
GameWorld gameWorld = GameWorld.get(dplayer.world);
|
||||||
if (gWorld != null) {
|
if (gameWorld != null) {
|
||||||
DGroup dGroup = DGroup.get(dplayer.player);
|
DGroup dGroup = DGroup.get(dplayer.getPlayer());
|
||||||
if (dplayer.checkpoint == null) {
|
if (dplayer.checkpoint == null) {
|
||||||
MiscUtil.secureTeleport(dplayer.player, dGroup.getGWorld().locStart);
|
MiscUtil.secureTeleport(dplayer.getPlayer(), dGroup.getGWorld().getLocStart());
|
||||||
if (dplayer.wolf != null) {
|
if (dplayer.wolf != null) {
|
||||||
dplayer.wolf.teleport(dGroup.getGWorld().locStart);
|
dplayer.wolf.teleport(dGroup.getGWorld().getLocStart());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MiscUtil.secureTeleport(dplayer.player, dplayer.checkpoint);
|
MiscUtil.secureTeleport(dplayer.getPlayer(), dplayer.checkpoint);
|
||||||
if (dplayer.wolf != null) {
|
if (dplayer.wolf != null) {
|
||||||
dplayer.wolf.teleport(dplayer.checkpoint);
|
dplayer.wolf.teleport(dplayer.checkpoint);
|
||||||
}
|
}
|
||||||
@ -536,8 +829,8 @@ public class DPlayer {
|
|||||||
|
|
||||||
// Respawn Items
|
// Respawn Items
|
||||||
if (dplayer.respawnInventory != null || dplayer.respawnArmor != null) {
|
if (dplayer.respawnInventory != null || dplayer.respawnArmor != null) {
|
||||||
dplayer.player.getInventory().setContents(dplayer.respawnInventory);
|
dplayer.getPlayer().getInventory().setContents(dplayer.respawnInventory);
|
||||||
dplayer.player.getInventory().setArmorContents(dplayer.respawnArmor);
|
dplayer.getPlayer().getInventory().setArmorContents(dplayer.respawnArmor);
|
||||||
dplayer.respawnInventory = null;
|
dplayer.respawnInventory = null;
|
||||||
dplayer.respawnArmor = null;
|
dplayer.respawnArmor = null;
|
||||||
}
|
}
|
||||||
@ -545,16 +838,16 @@ public class DPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GameWorld gWorld = GameWorld.get(dplayer.world);
|
GameWorld gameWorld = GameWorld.get(dplayer.world);
|
||||||
|
|
||||||
if (gWorld != null) {
|
if (gameWorld != null) {
|
||||||
// Update Wolf
|
// Update Wolf
|
||||||
if (dplayer.wolf != null) {
|
if (dplayer.wolf != null) {
|
||||||
if (dplayer.wolf.isDead()) {
|
if (dplayer.wolf.isDead()) {
|
||||||
if (dplayer.wolfRespawnTime <= 0) {
|
if (dplayer.wolfRespawnTime <= 0) {
|
||||||
dplayer.wolf = (Wolf) dplayer.world.spawnEntity(dplayer.player.getLocation(), EntityType.WOLF);
|
dplayer.wolf = (Wolf) dplayer.world.spawnEntity(dplayer.getPlayer().getLocation(), EntityType.WOLF);
|
||||||
dplayer.wolf.setTamed(true);
|
dplayer.wolf.setTamed(true);
|
||||||
dplayer.wolf.setOwner(dplayer.player);
|
dplayer.wolf.setOwner(dplayer.getPlayer());
|
||||||
dplayer.wolfRespawnTime = 30;
|
dplayer.wolfRespawnTime = 30;
|
||||||
}
|
}
|
||||||
dplayer.wolfRespawnTime--;
|
dplayer.wolfRespawnTime--;
|
||||||
@ -569,7 +862,7 @@ public class DPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check Distance Trigger Signs
|
// Check Distance Trigger Signs
|
||||||
DistanceTrigger.triggerAllInDistance(dplayer.player, gWorld);
|
DistanceTrigger.triggerAllInDistance(dplayer.getPlayer(), gameWorld);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,7 @@ import org.bukkit.block.Sign;
|
|||||||
|
|
||||||
public class BlockSign extends DSign {
|
public class BlockSign extends DSign {
|
||||||
|
|
||||||
public static String name = "Block";
|
private DSignType type = DSignTypeDefault.BLOCK;
|
||||||
public String buildPermissions = "dxl.sign.block";
|
|
||||||
public boolean onDungeonInit = false;
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
@ -49,11 +47,14 @@ public class BlockSign extends DSign {
|
|||||||
if ( !lines[2].equals("")) {
|
if ( !lines[2].equals("")) {
|
||||||
String line2[] = lines[2].split(",");
|
String line2[] = lines[2].split(",");
|
||||||
Material onBlock = Material.matchMaterial(line2[0]);
|
Material onBlock = Material.matchMaterial(line2[0]);
|
||||||
|
|
||||||
if (onBlock != null) {
|
if (onBlock != null) {
|
||||||
onBlockId = onBlock.getId();
|
onBlockId = onBlock.getId();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
onBlockId = IntegerUtil.parseInt(line2[0]);
|
onBlockId = IntegerUtil.parseInt(line2[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line2.length > 1) {
|
if (line2.length > 1) {
|
||||||
onBlockData = (byte) IntegerUtil.parseInt(line2[1]);
|
onBlockData = (byte) IntegerUtil.parseInt(line2[1]);
|
||||||
}
|
}
|
||||||
@ -82,13 +83,8 @@ public class BlockSign extends DSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,16 +13,14 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class CheckpointSign extends DSign {
|
public class CheckpointSign extends DSign {
|
||||||
|
|
||||||
public static String name = "Checkpoint";
|
private DSignType type = DSignTypeDefault.CHECKPOINT;
|
||||||
private String buildPermissions = "dxl.sign.checkpoint";
|
|
||||||
private boolean onDungeonInit = false;
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
private CopyOnWriteArrayList<DPlayer> done = new CopyOnWriteArrayList<DPlayer>();
|
private CopyOnWriteArrayList<DPlayer> done = new CopyOnWriteArrayList<DPlayer>();
|
||||||
|
|
||||||
public CheckpointSign(Sign sign, GameWorld gWorld) {
|
public CheckpointSign(Sign sign, GameWorld gameWorld) {
|
||||||
super(sign, gWorld);
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -39,41 +37,43 @@ public class CheckpointSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
if (initialized) {
|
if ( !initialized) {
|
||||||
for (DPlayer dplayer : DPlayer.get(getGWorld().world)) {
|
return;
|
||||||
dplayer.setCheckpoint(getSign().getLocation());
|
|
||||||
MessageUtil.sendMessage(dplayer.player, DungeonsXL.getPlugin().getDMessages().get("Player_CheckpointReached"));
|
|
||||||
}
|
|
||||||
|
|
||||||
remove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (DPlayer dplayer : DPlayer.get(getGameWorld().getWorld())) {
|
||||||
|
dplayer.setCheckpoint(getSign().getLocation());
|
||||||
|
MessageUtil.sendMessage(dplayer.getPlayer(), DungeonsXL.getPlugin().getDMessages().get("Player_CheckpointReached"));
|
||||||
|
}
|
||||||
|
|
||||||
|
remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPlayerTrigger(Player player) {
|
public boolean onPlayerTrigger(Player player) {
|
||||||
if (initialized) {
|
if ( !initialized) {
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
return true;
|
||||||
if (dplayer != null) {
|
}
|
||||||
if ( !done.contains(dplayer)) {
|
|
||||||
done.add(dplayer);
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
dplayer.setCheckpoint(getSign().getLocation());
|
if (dplayer != null) {
|
||||||
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_CheckpointReached"));
|
if ( !done.contains(dplayer)) {
|
||||||
}
|
done.add(dplayer);
|
||||||
}
|
dplayer.setCheckpoint(getSign().getLocation());
|
||||||
if (done.size() >= DPlayer.get(getGWorld().world).size()) {
|
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_CheckpointReached"));
|
||||||
remove();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (done.size() >= DPlayer.get(getGameWorld().getWorld()).size()) {
|
||||||
|
remove();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,7 @@ import org.bukkit.block.Sign;
|
|||||||
|
|
||||||
public class ChestSign extends DSign {
|
public class ChestSign extends DSign {
|
||||||
|
|
||||||
public static String name = "Chest";
|
private DSignType type = DSignTypeDefault.CHEST;
|
||||||
public String buildPermissions = "dxl.sign.chest";
|
|
||||||
public boolean onDungeonInit = false;
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
private double moneyReward;
|
private double moneyReward;
|
||||||
@ -25,6 +23,7 @@ public class ChestSign extends DSign {
|
|||||||
if (lines[1].equals("")) {
|
if (lines[1].equals("")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,15 +33,18 @@ public class ChestSign extends DSign {
|
|||||||
if ( !lines[1].equals("")) {
|
if ( !lines[1].equals("")) {
|
||||||
moneyReward = Double.parseDouble(lines[1]);
|
moneyReward = Double.parseDouble(lines[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = -1; i <= 1; i++) {
|
for (int i = -1; i <= 1; i++) {
|
||||||
if (getSign().getBlock().getRelative(i, 0, 0).getType() == Material.CHEST) {
|
if (getSign().getBlock().getRelative(i, 0, 0).getType() == Material.CHEST) {
|
||||||
new GameChest(getSign().getBlock().getRelative(i, 0, 0), getGWorld(), moneyReward);
|
new GameChest(getSign().getBlock().getRelative(i, 0, 0), getGameWorld(), moneyReward);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getSign().getBlock().getRelative(0, 0, i).getType() == Material.CHEST) {
|
if (getSign().getBlock().getRelative(0, 0, i).getType() == Material.CHEST) {
|
||||||
new GameChest(getSign().getBlock().getRelative(0, 0, i), getGWorld(), moneyReward);
|
new GameChest(getSign().getBlock().getRelative(0, 0, i), getGameWorld(), moneyReward);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getSign().getBlock().getRelative(0, i, 0).getType() == Material.CHEST) {
|
if (getSign().getBlock().getRelative(0, i, 0).getType() == Material.CHEST) {
|
||||||
new GameChest(getSign().getBlock().getRelative(0, i, 0), getGWorld(), moneyReward);
|
new GameChest(getSign().getBlock().getRelative(0, i, 0), getGameWorld(), moneyReward);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,12 +52,8 @@ public class ChestSign extends DSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -9,48 +9,43 @@ import org.bukkit.block.Sign;
|
|||||||
|
|
||||||
public class ChunkUpdaterSign extends DSign {
|
public class ChunkUpdaterSign extends DSign {
|
||||||
|
|
||||||
public static String name = "ChunkUpdater";
|
private DSignType type = DSignTypeDefault.CHUNK_UPDATER;
|
||||||
public String buildPermissions = "dxl.sign.chunkupdater";
|
|
||||||
public boolean onDungeonInit = true;
|
|
||||||
|
|
||||||
public ChunkUpdaterSign(Sign sign, GameWorld gWorld) {
|
public ChunkUpdaterSign(Sign sign, GameWorld gameWorld) {
|
||||||
super(sign, gWorld);
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
String lines[] = getSign().getLines();
|
String lines[] = getSign().getLines();
|
||||||
Chunk chunk = getGWorld().world.getChunkAt(getSign().getBlock());
|
Chunk chunk = getGameWorld().getWorld().getChunkAt(getSign().getBlock());
|
||||||
|
|
||||||
if ( !lines[1].equals("")) {
|
if ( !lines[1].equals("")) {
|
||||||
Integer radius = IntegerUtil.parseInt(lines[1]);
|
Integer radius = IntegerUtil.parseInt(lines[1]);
|
||||||
for (int x = -radius; x < radius; x++) {
|
for (int x = -radius; x < radius; x++) {
|
||||||
for (int z = -radius; z < radius; z++) {
|
for (int z = -radius; z < radius; z++) {
|
||||||
Chunk chunk1 = getGWorld().world.getChunkAt(chunk.getX() - x, chunk.getZ() - z);
|
Chunk chunk1 = getGameWorld().getWorld().getChunkAt(chunk.getX() - x, chunk.getZ() - z);
|
||||||
chunk1.load();
|
chunk1.load();
|
||||||
getGWorld().loadedChunks.add(chunk1);
|
getGameWorld().getLoadedChunks().add(chunk1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
chunk.load();
|
chunk.load();
|
||||||
getGWorld().loadedChunks.add(chunk);
|
getGameWorld().getLoadedChunks().add(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
getSign().getBlock().setType(Material.AIR);
|
getSign().getBlock().setType(Material.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,10 @@ import org.bukkit.block.Sign;
|
|||||||
|
|
||||||
public class ClassesSign extends DSign {
|
public class ClassesSign extends DSign {
|
||||||
|
|
||||||
public static String name = "Classes";
|
private DSignType type = DSignTypeDefault.CLASSES;
|
||||||
public String buildPermissions = "dxl.sign.classes";
|
|
||||||
public boolean onDungeonInit = true;
|
|
||||||
|
|
||||||
public ClassesSign(Sign sign, GameWorld gWorld) {
|
public ClassesSign(Sign sign, GameWorld gameWorld) {
|
||||||
super(sign, gWorld);
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -27,56 +25,55 @@ public class ClassesSign extends DSign {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
if ( !getGWorld().getConfig().isLobbyDisabled()) {
|
if (getGameWorld().getConfig().isLobbyDisabled()) {
|
||||||
|
getSign().getBlock().setType(Material.AIR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] direction = GroupSign.getDirection(getSign().getBlock().getData());
|
||||||
|
int 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());
|
// Check existing signs
|
||||||
int directionX = direction[0];
|
boolean isContinued = true;
|
||||||
int directionZ = direction[1];
|
for (Sign isusedsign : getGameWorld().getSignClass()) {
|
||||||
|
if (dclass.getName().equalsIgnoreCase(ChatColor.stripColor(isusedsign.getLine(1)))) {
|
||||||
int xx = 0, zz = 0;
|
isContinued = false;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} 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
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class CommandSign extends DSign {
|
public class CommandSign extends DSign {
|
||||||
|
|
||||||
public static String name = "Cmd";
|
private DSignType type = DSignTypeDefault.COMMAND;
|
||||||
public String buildPermissions = "dxl.sign.cmd";
|
|
||||||
public boolean onDungeonInit = false;
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
private CCommand cCommand;
|
private CCommand cCommand;
|
||||||
@ -23,14 +21,12 @@ public class CommandSign extends DSign {
|
|||||||
private String executor;
|
private String executor;
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
|
|
||||||
public CommandSign(Sign sign, GameWorld gWorld) {
|
public CommandSign(Sign sign, GameWorld gameWorld) {
|
||||||
super(sign, gWorld);
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,20 +37,23 @@ public class CommandSign extends DSign {
|
|||||||
cCommand = CommandsXL.getCCommands().getCCommand(command);
|
cCommand = CommandsXL.getCCommands().getCCommand(command);
|
||||||
|
|
||||||
if (getTriggers().isEmpty()) {
|
if (getTriggers().isEmpty()) {
|
||||||
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGWorld());
|
|
||||||
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);
|
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;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +68,7 @@ public class CommandSign extends DSign {
|
|||||||
} else {
|
} else {
|
||||||
cCommand.execute(player, player, false);
|
cCommand.execute(player, player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,12 +80,8 @@ public class CommandSign extends DSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
|
|||||||
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.Trigger;
|
import io.github.dre2n.dungeonsxl.trigger.Trigger;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -15,35 +17,38 @@ public abstract class DSign {
|
|||||||
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
||||||
|
|
||||||
private Sign sign;
|
private Sign sign;
|
||||||
private GameWorld gWorld;
|
private GameWorld gameWorld;
|
||||||
|
|
||||||
// List of Triggers
|
// List of Triggers
|
||||||
private Set<Trigger> triggers = new HashSet<Trigger>();
|
private Set<Trigger> triggers = new HashSet<Trigger>();
|
||||||
|
|
||||||
public DSign(Sign sign, GameWorld gWorld) {
|
public DSign(Sign sign, GameWorld gameWorld) {
|
||||||
this.setSign(sign);
|
this.setSign(sign);
|
||||||
this.gWorld = gWorld;
|
this.gameWorld = gameWorld;
|
||||||
|
|
||||||
// Check Trigger
|
// Check Trigger
|
||||||
if (gWorld != null) {
|
if (gameWorld == null) {
|
||||||
String line3 = sign.getLine(3).replaceAll("\\s", "");
|
return;
|
||||||
String[] triggerTypes = line3.split(",");
|
}
|
||||||
|
|
||||||
|
String line3 = sign.getLine(3).replaceAll("\\s", "");
|
||||||
|
String[] triggerTypes = line3.split(",");
|
||||||
|
|
||||||
|
for (String triggerString : triggerTypes) {
|
||||||
|
if (triggerString.equals("")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (String triggerString : triggerTypes) {
|
String type = triggerString.substring(0, 1);
|
||||||
if ( !triggerString.equals("")) {
|
String value = null;
|
||||||
|
if (triggerString.length() > 1) {
|
||||||
String type = triggerString.substring(0, 1);
|
value = triggerString.substring(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);
|
||||||
Trigger trigger = Trigger.getOrCreate(type, value, this);
|
addTrigger(trigger);
|
||||||
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() {
|
public GameWorld getGameWorld() {
|
||||||
return gWorld;
|
return gameWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,11 +99,9 @@ public abstract class DSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onPlayerTrigger(Player player) {
|
public boolean onPlayerTrigger(Player player) {
|
||||||
@ -106,7 +109,6 @@ public abstract class DSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpdate() {
|
public void onUpdate() {
|
||||||
@ -115,12 +117,17 @@ public abstract class DSign {
|
|||||||
onDisable();
|
onDisable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (triggers.size() == 1) {
|
|
||||||
if (trigger.player != null) {
|
if (triggers.size() != 1) {
|
||||||
if (onPlayerTrigger(trigger.player)) {
|
continue;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
}
|
if (trigger.player == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onPlayerTrigger(trigger.player)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,83 +138,40 @@ public abstract class DSign {
|
|||||||
for (Trigger trigger : triggers) {
|
for (Trigger trigger : triggers) {
|
||||||
trigger.removeListener(this);
|
trigger.removeListener(this);
|
||||||
}
|
}
|
||||||
gWorld.dSigns.remove(this);
|
gameWorld.getdSigns().remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasTriggers() {
|
public boolean hasTriggers() {
|
||||||
return !triggers.isEmpty();
|
return !triggers.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: API to add custom signs
|
public static DSign create(Sign sign, GameWorld gameWorld) {
|
||||||
public static DSign create(Sign sign, GameWorld gWorld) {
|
|
||||||
String[] lines = sign.getLines();
|
String[] lines = sign.getLines();
|
||||||
DSign dSign = null;
|
DSign dSign = null;
|
||||||
|
|
||||||
if (lines[0].equalsIgnoreCase("[" + BlockSign.name + "]")) {
|
for (DSignType type : plugin.getDSigns().getDSigns()) {
|
||||||
dSign = new BlockSign(sign, gWorld);
|
if ( !lines[0].equalsIgnoreCase("[" + type.getName() + "]")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + CheckpointSign.name + "]")) {
|
try {
|
||||||
dSign = new CheckpointSign(sign, gWorld);
|
Constructor<? extends DSign> constructor = type.getHandler().getConstructor(Sign.class, GameWorld.class);
|
||||||
|
dSign = constructor.newInstance(sign, gameWorld);
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + ChestSign.name + "]")) {
|
|
||||||
dSign = new ChestSign(sign, gWorld);
|
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException exception) {
|
||||||
|
plugin.getLogger().info("DungeonsXL could not find the handler class of the sign " + type.getName() + ".");
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + ChunkUpdaterSign.name + "]")) {
|
if ( !(type instanceof DSignTypeDefault)) {
|
||||||
dSign = new ChunkUpdaterSign(sign, gWorld);
|
plugin.getLogger().info("Please note that this sign is an unsupported feature added by an addon!");
|
||||||
|
}
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + ClassesSign.name + "]")) {
|
}
|
||||||
dSign = new ClassesSign(sign, gWorld);
|
|
||||||
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + CommandSign.name + "]")) {
|
|
||||||
dSign = new CommandSign(sign, gWorld);
|
|
||||||
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + EndSign.name + "]")) {
|
|
||||||
dSign = new EndSign(sign, gWorld);
|
|
||||||
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + FloorSign.name + "]")) {
|
|
||||||
dSign = new FloorSign(sign, gWorld);
|
|
||||||
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + InteractSign.name + "]")) {
|
|
||||||
dSign = new InteractSign(sign, gWorld);
|
|
||||||
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + LeaveSign.name + "]")) {
|
|
||||||
dSign = new LeaveSign(sign, gWorld);
|
|
||||||
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + LobbySign.name + "]")) {
|
|
||||||
dSign = new LobbySign(sign, gWorld);
|
|
||||||
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + MobSign.name + "]")) {
|
|
||||||
dSign = new MobSign(sign, gWorld);
|
|
||||||
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + MsgSign.name + "]")) {
|
|
||||||
dSign = new MsgSign(sign, gWorld);
|
|
||||||
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + MythicMobsSign.name + "]")) {
|
|
||||||
dSign = new MythicMobsSign(sign, gWorld);
|
|
||||||
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + PlaceSign.name + "]")) {
|
|
||||||
dSign = new PlaceSign(sign, gWorld);
|
|
||||||
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + ReadySign.name + "]")) {
|
|
||||||
dSign = new ReadySign(sign, gWorld);
|
|
||||||
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + RedstoneSign.name + "]")) {
|
|
||||||
dSign = new RedstoneSign(sign, gWorld);
|
|
||||||
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SoundMsgSign.name + "]")) {
|
|
||||||
dSign = new SoundMsgSign(sign, gWorld);
|
|
||||||
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + StartSign.name + "]")) {
|
|
||||||
dSign = new StartSign(sign, gWorld);
|
|
||||||
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + TriggerSign.name + "]")) {
|
|
||||||
dSign = new TriggerSign(sign, gWorld);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dSign != null && gWorld != null) {
|
if ( !(dSign != null && gameWorld != null)) {
|
||||||
if (dSign.isOnDungeonInit()) {
|
return dSign;
|
||||||
dSign.onInit();
|
}
|
||||||
}
|
|
||||||
|
if (dSign.getType().isOnDungeonInit()) {
|
||||||
|
dSign.onInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
return dSign;
|
return dSign;
|
||||||
@ -217,8 +181,6 @@ public abstract class DSign {
|
|||||||
|
|
||||||
public abstract boolean check();
|
public abstract boolean check();
|
||||||
|
|
||||||
public abstract String getPermissions();
|
public abstract DSignType getType();
|
||||||
|
|
||||||
public abstract boolean isOnDungeonInit();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
25
src/io/github/dre2n/dungeonsxl/sign/DSignType.java
Normal file
25
src/io/github/dre2n/dungeonsxl/sign/DSignType.java
Normal 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();
|
||||||
|
|
||||||
|
}
|
58
src/io/github/dre2n/dungeonsxl/sign/DSignTypeDefault.java
Normal file
58
src/io/github/dre2n/dungeonsxl/sign/DSignTypeDefault.java
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
39
src/io/github/dre2n/dungeonsxl/sign/DSigns.java
Normal file
39
src/io/github/dre2n/dungeonsxl/sign/DSigns.java
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
|
||||||
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||||
@ -12,12 +11,10 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class EndSign extends DSign {
|
public class EndSign extends DSign {
|
||||||
|
|
||||||
public static String name = "End";
|
private DSignType type = DSignTypeDefault.END;
|
||||||
public String buildPermissions = "dxl.sign.end";
|
|
||||||
public boolean onDungeonInit = false;
|
|
||||||
|
|
||||||
public EndSign(Sign sign, GameWorld gWorld) {
|
public EndSign(Sign sign, GameWorld gameWorld) {
|
||||||
super(sign, gWorld);
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -27,27 +24,29 @@ public class EndSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
if (getTriggers().isEmpty()) {
|
if ( !getTriggers().isEmpty()) {
|
||||||
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGWorld());
|
|
||||||
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 {
|
|
||||||
getSign().getBlock().setType(Material.AIR);
|
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
|
@Override
|
||||||
public boolean onPlayerTrigger(Player player) {
|
public boolean onPlayerTrigger(Player player) {
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
if (dplayer != null) {
|
if (dplayer != null) {
|
||||||
if ( !dplayer.isFinished) {
|
if ( !dplayer.isFinished()) {
|
||||||
dplayer.finish();
|
dplayer.finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,18 +55,14 @@ public class EndSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
for (DPlayer dplayer : DungeonsXL.getPlugin().getDPlayers()) {
|
for (DPlayer dplayer : plugin.getDPlayers()) {
|
||||||
dplayer.finish();
|
dplayer.finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
|
||||||
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||||
@ -12,14 +11,12 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class FloorSign extends DSign {
|
public class FloorSign extends DSign {
|
||||||
|
|
||||||
public static String name = "Floor";
|
private DSignType type = DSignTypeDefault.FLOOR;
|
||||||
public String buildPermissions = "dxl.sign.floor";
|
|
||||||
public boolean onDungeonInit = false;
|
|
||||||
|
|
||||||
private String floor;
|
private String floor;
|
||||||
|
|
||||||
public FloorSign(Sign sign, GameWorld gWorld) {
|
public FloorSign(Sign sign, GameWorld gameWorld) {
|
||||||
super(sign, gWorld);
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -34,52 +31,50 @@ public class FloorSign extends DSign {
|
|||||||
floor = lines[1];
|
floor = lines[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getTriggers().isEmpty()) {
|
if ( !getTriggers().isEmpty()) {
|
||||||
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGWorld());
|
|
||||||
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 {
|
|
||||||
getSign().getBlock().setType(Material.AIR);
|
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
|
@Override
|
||||||
public boolean onPlayerTrigger(Player player) {
|
public boolean onPlayerTrigger(Player player) {
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
if (dplayer != null) {
|
if (dplayer != null) {
|
||||||
if ( !dplayer.isFinished) {
|
if ( !dplayer.isFinished()) {
|
||||||
dplayer.finishFloor(floor);
|
dplayer.finishFloor(floor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
for (DPlayer dplayer : DungeonsXL.getPlugin().getDPlayers()) {
|
for (DPlayer dplayer : plugin.getDPlayers()) {
|
||||||
dplayer.finish();
|
dplayer.finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,27 +14,29 @@ import org.bukkit.block.Sign;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class InteractSign extends DSign {
|
public class InteractSign extends DSign {
|
||||||
public static String name = "Interact";
|
|
||||||
public String buildPermissions = "dxl.sign.trigger";
|
|
||||||
public boolean onDungeonInit = true;
|
|
||||||
|
|
||||||
public InteractSign(Sign sign, GameWorld gWorld) {
|
private DSignType type = DSignTypeDefault.INTERACT;
|
||||||
super(sign, gWorld);
|
|
||||||
|
public InteractSign(Sign sign, GameWorld gameWorld) {
|
||||||
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
Set<Integer> used = new HashSet<Integer>();
|
Set<Integer> used = new HashSet<Integer>();
|
||||||
for (Block block : EditWorld.get(getSign().getLocation().getWorld()).sign) {
|
for (Block block : EditWorld.get(getSign().getLocation().getWorld()).getSign()) {
|
||||||
if (block != null) {
|
if (block == null) {
|
||||||
if ( !block.getChunk().isLoaded()) {
|
continue;
|
||||||
block.getChunk().load();
|
}
|
||||||
}
|
|
||||||
if (block.getState() instanceof Sign) {
|
if ( !block.getChunk().isLoaded()) {
|
||||||
Sign rsign = (Sign) block.getState();
|
block.getChunk().load();
|
||||||
if (rsign.getLine(0).equalsIgnoreCase("[" + name + "]")) {
|
}
|
||||||
used.add(IntegerUtil.parseInt(rsign.getLine(1)));
|
|
||||||
}
|
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++;
|
id++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
id = IntegerUtil.parseInt(getSign().getLine(1));
|
id = IntegerUtil.parseInt(getSign().getLine(1));
|
||||||
if (id == 0 || used.contains(id)) {
|
if (id == 0 || used.contains(id)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -62,7 +66,7 @@ public class InteractSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
InteractTrigger trigger = InteractTrigger.getOrCreate(IntegerUtil.parseInt(getSign().getLine(1)), getSign().getBlock(), getGWorld());
|
InteractTrigger trigger = InteractTrigger.getOrCreate(IntegerUtil.parseInt(getSign().getLine(1)), getSign().getBlock(), getGameWorld());
|
||||||
if (trigger != null) {
|
if (trigger != null) {
|
||||||
trigger.addListener(this);
|
trigger.addListener(this);
|
||||||
addTrigger(trigger);
|
addTrigger(trigger);
|
||||||
@ -81,13 +85,8 @@ public class InteractSign extends DSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UpdateTask implements Runnable {
|
public class UpdateTask implements Runnable {
|
||||||
@ -100,4 +99,5 @@ public class InteractSign extends DSign {
|
|||||||
getSign().update();
|
getSign().update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,37 +12,34 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class LeaveSign extends DSign {
|
public class LeaveSign extends DSign {
|
||||||
|
|
||||||
public static String name = "Leave";
|
private DSignType type = DSignTypeDefault.LEAVE;
|
||||||
public String buildPermissions = "dxl.sign.leave";
|
|
||||||
public boolean onDungeonInit = true;
|
|
||||||
|
|
||||||
public LeaveSign(Sign sign, GameWorld gWorld) {
|
public LeaveSign(Sign sign, GameWorld gameWorld) {
|
||||||
super(sign, gWorld);
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
if (getTriggers().isEmpty()) {
|
if ( !getTriggers().isEmpty()) {
|
||||||
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGWorld());
|
|
||||||
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 {
|
|
||||||
getSign().getBlock().setType(Material.AIR);
|
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
|
@Override
|
||||||
@ -51,6 +48,7 @@ public class LeaveSign extends DSign {
|
|||||||
if (dplayer != null) {
|
if (dplayer != null) {
|
||||||
dplayer.leave();
|
dplayer.leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,12 +60,8 @@ public class LeaveSign extends DSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,34 +7,26 @@ import org.bukkit.block.Sign;
|
|||||||
|
|
||||||
public class LobbySign extends DSign {
|
public class LobbySign extends DSign {
|
||||||
|
|
||||||
public static String name = "Lobby";
|
private DSignType type = DSignTypeDefault.LOBBY;
|
||||||
public String buildPermissions = "dxl.sign.lobby";
|
|
||||||
public boolean onDungeonInit = true;
|
|
||||||
|
|
||||||
public LobbySign(Sign sign, GameWorld gWorld) {
|
public LobbySign(Sign sign, GameWorld gameWorld) {
|
||||||
super(sign, gWorld);
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
getGWorld().locLobby = getSign().getLocation();
|
getGameWorld().setLocLobby(getSign().getLocation());
|
||||||
getSign().getBlock().setType(Material.AIR);
|
getSign().getBlock().setType(Material.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -10,19 +10,17 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class MsgSign extends DSign {
|
public class MessageSign extends DSign {
|
||||||
|
|
||||||
public static String name = "Msg";
|
private DSignType type = DSignTypeDefault.MESSAGE;
|
||||||
public String buildPermissions = "dxl.sign.msg";
|
|
||||||
public boolean onDungeonInit = false;
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
private String msg;
|
private String msg;
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
private CopyOnWriteArrayList<Player> done = new CopyOnWriteArrayList<Player>();
|
private CopyOnWriteArrayList<Player> done = new CopyOnWriteArrayList<Player>();
|
||||||
|
|
||||||
public MsgSign(Sign sign, GameWorld gWorld) {
|
public MessageSign(Sign sign, GameWorld gameWorld) {
|
||||||
super(sign, gWorld);
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -39,7 +37,7 @@ public class MsgSign extends DSign {
|
|||||||
String lines[] = getSign().getLines();
|
String lines[] = getSign().getLines();
|
||||||
|
|
||||||
if ( !lines[1].equals("")) {
|
if ( !lines[1].equals("")) {
|
||||||
String msg = getGWorld().getConfig().getMsg(IntegerUtil.parseInt(lines[1]), true);
|
String msg = getGameWorld().getConfig().getMsg(IntegerUtil.parseInt(lines[1]), true);
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
getSign().getBlock().setType(Material.AIR);
|
getSign().getBlock().setType(Material.AIR);
|
||||||
@ -51,22 +49,26 @@ public class MsgSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPlayerTrigger(Player player) {
|
public boolean onPlayerTrigger(Player player) {
|
||||||
if (initialized) {
|
if ( !initialized) {
|
||||||
if ( !done.contains(player)) {
|
return true;
|
||||||
MessageUtil.sendMessage(player, msg);
|
|
||||||
done.add(player);
|
|
||||||
}
|
|
||||||
if (done.size() >= getGWorld().world.getPlayers().size()) {
|
|
||||||
remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !done.contains(player)) {
|
||||||
|
MessageUtil.sendMessage(player, msg);
|
||||||
|
done.add(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (done.size() >= getGameWorld().getWorld().getPlayers().size()) {
|
||||||
|
remove();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
for (Player player : getGWorld().world.getPlayers()) {
|
for (Player player : getGameWorld().getWorld().getPlayers()) {
|
||||||
MessageUtil.sendMessage(player, msg);
|
MessageUtil.sendMessage(player, msg);
|
||||||
}
|
}
|
||||||
remove();
|
remove();
|
||||||
@ -74,12 +76,8 @@ public class MsgSign extends DSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -17,9 +17,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
public class MobSign extends DSign {
|
public class MobSign extends DSign {
|
||||||
|
|
||||||
public static String name = "Mob";
|
private DSignType type = DSignTypeDefault.MOB;
|
||||||
public String buildPermissions = "dxl.sign.mob";
|
|
||||||
public boolean onDungeonInit = false;
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
private String mob;
|
private String mob;
|
||||||
@ -30,23 +28,28 @@ public class MobSign extends DSign {
|
|||||||
private boolean active;
|
private boolean active;
|
||||||
private int taskId = -1;
|
private int taskId = -1;
|
||||||
|
|
||||||
public MobSign(Sign sign, GameWorld gWorld) {
|
public MobSign(Sign sign, GameWorld gameWorld) {
|
||||||
super(sign, gWorld);
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
String lines[] = getSign().getLines();
|
String lines[] = getSign().getLines();
|
||||||
if ( !lines[1].equals("") && !lines[2].equals("")) {
|
if (lines[1].equals("") || lines[2].equals("")) {
|
||||||
if (lines[1] != null) {
|
return false;
|
||||||
String[] atributes = lines[2].split(",");
|
|
||||||
if (atributes.length == 2) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
if (lines[1] == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] atributes = lines[2].split(",");
|
||||||
|
if (atributes.length == 2) {
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -55,11 +58,11 @@ public class MobSign extends DSign {
|
|||||||
if ( !lines[1].equals("") && !lines[2].equals("")) {
|
if ( !lines[1].equals("") && !lines[2].equals("")) {
|
||||||
String mob = lines[1];
|
String mob = lines[1];
|
||||||
if (mob != null) {
|
if (mob != null) {
|
||||||
String[] atributes = lines[2].split(",");
|
String[] attributes = lines[2].split(",");
|
||||||
if (atributes.length == 2) {
|
if (attributes.length == 2) {
|
||||||
this.mob = mob;
|
this.mob = mob;
|
||||||
maxinterval = IntegerUtil.parseInt(atributes[0]);
|
maxinterval = IntegerUtil.parseInt(attributes[0]);
|
||||||
amount = IntegerUtil.parseInt(atributes[1]);
|
amount = IntegerUtil.parseInt(attributes[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,30 +73,36 @@ public class MobSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
if (initialized && !active) {
|
if ( !initialized || active) {
|
||||||
MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
|
return;
|
||||||
|
|
||||||
taskId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, scheduler, 0L, 20L);
|
|
||||||
|
|
||||||
active = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
|
||||||
|
|
||||||
|
taskId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, scheduler, 0L, 20L);
|
||||||
|
|
||||||
|
active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
if (initialized && active) {
|
if ( !initialized || !active) {
|
||||||
killTask();
|
return;
|
||||||
interval = 0;
|
|
||||||
active = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
killTask();
|
||||||
|
interval = 0;
|
||||||
|
active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void killTask() {
|
public void killTask() {
|
||||||
if (initialized && active) {
|
if ( !initialized || !active) {
|
||||||
if (taskId != -1) {
|
return;
|
||||||
plugin.getServer().getScheduler().cancelTask(taskId);
|
}
|
||||||
taskId = -1;
|
|
||||||
}
|
if (taskId != -1) {
|
||||||
|
plugin.getServer().getScheduler().cancelTask(taskId);
|
||||||
|
taskId = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,9 +118,9 @@ public class MobSign extends DSign {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (sign.interval <= 0) {
|
if (sign.interval <= 0) {
|
||||||
World world = sign.getSign().getWorld();
|
World world = sign.getSign().getWorld();
|
||||||
GameWorld gWorld = GameWorld.get(world);
|
GameWorld gameWorld = GameWorld.get(world);
|
||||||
|
|
||||||
if (gWorld != null) {
|
if (gameWorld != null) {
|
||||||
Location spawnLoc = sign.getSign().getLocation().add(0.5, 0, 0.5);
|
Location spawnLoc = sign.getSign().getLocation().add(0.5, 0, 0.5);
|
||||||
|
|
||||||
// Check normal mobs
|
// Check normal mobs
|
||||||
@ -130,12 +139,12 @@ public class MobSign extends DSign {
|
|||||||
// Disable Despawning
|
// Disable Despawning
|
||||||
entity.setRemoveWhenFarAway(false);
|
entity.setRemoveWhenFarAway(false);
|
||||||
|
|
||||||
new DMob(entity, sign.getGWorld(), null);
|
new DMob(entity, sign.getGameWorld(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check custom mobs
|
// Check custom mobs
|
||||||
DMobType mobType = DMobType.get(sign.mob, gWorld.getConfig().getMobTypes());
|
DMobType mobType = DMobType.get(sign.mob, gameWorld.getConfig().getMobTypes());
|
||||||
|
|
||||||
if (mobType != null) {
|
if (mobType != null) {
|
||||||
mobType.spawn(GameWorld.get(world), spawnLoc);
|
mobType.spawn(GameWorld.get(world), spawnLoc);
|
||||||
@ -161,12 +170,8 @@ public class MobSign extends DSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class MythicMobsSign extends DSign {
|
public class MythicMobsSign extends DSign {
|
||||||
|
|
||||||
public static String name = "MythicMobs";
|
private DSignType type = DSignTypeDefault.MYTHIC_MOBS;
|
||||||
public String buildPermissions = "dxl.sign.mob";
|
|
||||||
public boolean onDungeonInit = false;
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
private String mob;
|
private String mob;
|
||||||
@ -33,23 +31,28 @@ public class MythicMobsSign extends DSign {
|
|||||||
private LivingEntity mythicMob;
|
private LivingEntity mythicMob;
|
||||||
private ArrayList<Entity> mythicMobs = new ArrayList<Entity>();
|
private ArrayList<Entity> mythicMobs = new ArrayList<Entity>();
|
||||||
|
|
||||||
public MythicMobsSign(Sign sign, GameWorld gWorld) {
|
public MythicMobsSign(Sign sign, GameWorld gameWorld) {
|
||||||
super(sign, gWorld);
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
String lines[] = getSign().getLines();
|
String lines[] = getSign().getLines();
|
||||||
if ( !lines[1].equals("") && !lines[2].equals("")) {
|
if (lines[1].equals("") || lines[2].equals("")) {
|
||||||
if (lines[1] != null) {
|
return false;
|
||||||
String[] atributes = lines[2].split(",");
|
|
||||||
if (atributes.length == 2) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
if (lines[1] == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] atributes = lines[2].split(",");
|
||||||
|
if (atributes.length == 2) {
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -58,11 +61,11 @@ public class MythicMobsSign extends DSign {
|
|||||||
if ( !lines[1].equals("") && !lines[2].equals("")) {
|
if ( !lines[1].equals("") && !lines[2].equals("")) {
|
||||||
String mob = lines[1];
|
String mob = lines[1];
|
||||||
if (mob != null) {
|
if (mob != null) {
|
||||||
String[] atributes = lines[2].split(",");
|
String[] attributes = lines[2].split(",");
|
||||||
if (atributes.length == 2) {
|
if (attributes.length == 2) {
|
||||||
this.mob = mob;
|
this.mob = mob;
|
||||||
maxinterval = IntegerUtil.parseInt(atributes[0]);
|
maxinterval = IntegerUtil.parseInt(attributes[0]);
|
||||||
amount = IntegerUtil.parseInt(atributes[1]);
|
amount = IntegerUtil.parseInt(attributes[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,30 +76,36 @@ public class MythicMobsSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
if (initialized && !active) {
|
if ( !initialized || active) {
|
||||||
MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
|
return;
|
||||||
|
|
||||||
taskId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, scheduler, 0L, 20L);
|
|
||||||
|
|
||||||
active = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
|
||||||
|
|
||||||
|
taskId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, scheduler, 0L, 20L);
|
||||||
|
|
||||||
|
active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
if (initialized && active) {
|
if ( !initialized || !active) {
|
||||||
killTask();
|
return;
|
||||||
interval = 0;
|
|
||||||
active = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
killTask();
|
||||||
|
interval = 0;
|
||||||
|
active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void killTask() {
|
public void killTask() {
|
||||||
if (initialized && active) {
|
if ( !initialized || !active) {
|
||||||
if (taskId != -1) {
|
return;
|
||||||
plugin.getServer().getScheduler().cancelTask(taskId);
|
}
|
||||||
taskId = -1;
|
|
||||||
}
|
if (taskId != -1) {
|
||||||
|
plugin.getServer().getScheduler().cancelTask(taskId);
|
||||||
|
taskId = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,20 +120,20 @@ public class MythicMobsSign extends DSign {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (sign.interval <= 0) {
|
if (sign.interval <= 0) {
|
||||||
World world = sign.getSign().getWorld();
|
World world = sign.getSign().getWorld();
|
||||||
GameWorld gWorld = GameWorld.get(world);
|
GameWorld gameWorld = GameWorld.get(world);
|
||||||
|
|
||||||
if (gWorld != null) {
|
if (gameWorld != null) {
|
||||||
spawnLoc = sign.getSign().getLocation().add(0.5, 0, 0.5);
|
spawnLoc = sign.getSign().getLocation().add(0.5, 0, 0.5);
|
||||||
double x = spawnLoc.getX();
|
double x = spawnLoc.getX();
|
||||||
double y = spawnLoc.getY();
|
double y = spawnLoc.getY();
|
||||||
double z = spawnLoc.getZ();
|
double z = spawnLoc.getZ();
|
||||||
|
|
||||||
String command = "mm mobs spawn " + mob + " " + amount + " DXL_Game_" + gWorld.id + "," + x + "," + y + "," + z;
|
String command = "mm mobs spawn " + mob + " " + amount + " DXL_Game_" + gameWorld.getId() + "," + x + "," + y + "," + z;
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command);
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command);
|
||||||
|
|
||||||
setMythicMobs();
|
setMythicMobs();
|
||||||
if (mythicMob != null) {
|
if (mythicMob != null) {
|
||||||
new DMob(mythicMob, sign.getGWorld(), null, mob);
|
new DMob(mythicMob, sign.getGameWorld(), null, mob);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the amount
|
// Set the amount
|
||||||
@ -146,16 +155,6 @@ public class MythicMobsSign extends DSign {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPermissions() {
|
|
||||||
return buildPermissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setMythicMobs() {
|
private void setMythicMobs() {
|
||||||
for (Entity entity : spawnLoc.getChunk().getEntities()) {
|
for (Entity entity : spawnLoc.getChunk().getEntities()) {
|
||||||
if (entity.getLocation().getX() >= spawnLoc.getX() - 1 && entity.getLocation().getX() <= spawnLoc.getX() + 1 && entity.getLocation().getY() >= spawnLoc.getY() - 1
|
if (entity.getLocation().getX() >= spawnLoc.getX() - 1 && entity.getLocation().getX() <= spawnLoc.getX() + 1 && entity.getLocation().getY() >= spawnLoc.getY() - 1
|
||||||
@ -163,9 +162,14 @@ public class MythicMobsSign extends DSign {
|
|||||||
&& !mythicMobs.contains(entity) && entity.isCustomNameVisible() && !(entity instanceof Player)) {
|
&& !mythicMobs.contains(entity) && entity.isCustomNameVisible() && !(entity instanceof Player)) {
|
||||||
mythicMob = (LivingEntity) entity;
|
mythicMob = (LivingEntity) entity;
|
||||||
mythicMobs.add(entity);
|
mythicMobs.add(entity);
|
||||||
org.bukkit.Bukkit.broadcastMessage("[DXL Debug] MythicMob counter: " + mythicMobs.size());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DSignType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,10 @@ import org.bukkit.block.Sign;
|
|||||||
|
|
||||||
public class PlaceSign extends DSign {
|
public class PlaceSign extends DSign {
|
||||||
|
|
||||||
public static String name = "Place";
|
private DSignType type = DSignTypeDefault.PLACE;
|
||||||
public String buildPermissions = "dxl.sign.place";
|
|
||||||
public boolean onDungeonInit = false;
|
|
||||||
|
|
||||||
public PlaceSign(Sign sign, GameWorld gWorld) {
|
public PlaceSign(Sign sign, GameWorld gameWorld) {
|
||||||
super(sign, gWorld);
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -24,17 +22,13 @@ public class PlaceSign extends DSign {
|
|||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
String lines[] = getSign().getLines();
|
String lines[] = getSign().getLines();
|
||||||
getGWorld().placeableBlocks.add(new GamePlaceableBlock(getSign().getBlock(), lines[1], lines[2]));
|
getGameWorld().getPlaceableBlocks().add(new GamePlaceableBlock(getSign().getBlock(), lines[1], lines[2]));
|
||||||
getSign().getBlock().setType(Material.AIR);
|
getSign().getBlock().setType(Material.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,10 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class ReadySign extends DSign {
|
public class ReadySign extends DSign {
|
||||||
|
|
||||||
public static String name = "Ready";
|
private DSignType type = DSignTypeDefault.READY;
|
||||||
public String buildPermissions = "dxl.sign.ready";
|
|
||||||
public boolean onDungeonInit = true;
|
|
||||||
|
|
||||||
public ReadySign(Sign sign, GameWorld gWorld) {
|
public ReadySign(Sign sign, GameWorld gameWorld) {
|
||||||
super(sign, gWorld);
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -28,20 +26,22 @@ public class ReadySign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
if (getTriggers().isEmpty()) {
|
if ( !getTriggers().isEmpty()) {
|
||||||
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGWorld());
|
|
||||||
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 {
|
|
||||||
getSign().getBlock().setType(Material.AIR);
|
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
|
@Override
|
||||||
@ -58,26 +58,27 @@ public class ReadySign extends DSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ready(DPlayer dplayer) {
|
private void ready(DPlayer dplayer) {
|
||||||
if (dplayer != null) {
|
if (dplayer == null) {
|
||||||
if ( !dplayer.isReady) {
|
return;
|
||||||
if (getGWorld().signClass.isEmpty() || dplayer.dclass != null) {
|
}
|
||||||
dplayer.ready();
|
|
||||||
MessageUtil.sendMessage(dplayer.player, plugin.getDMessages().get("Player_Ready"));
|
if (dplayer.isReady()) {
|
||||||
return;
|
return;
|
||||||
} else {
|
}
|
||||||
MessageUtil.sendMessage(dplayer.player, plugin.getDMessages().get("Error_Ready"));
|
|
||||||
}
|
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
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,7 @@ import org.bukkit.block.Sign;
|
|||||||
|
|
||||||
public class RedstoneSign extends DSign {
|
public class RedstoneSign extends DSign {
|
||||||
|
|
||||||
public static String name = "Redstone";
|
private DSignType type = DSignTypeDefault.REDSTONE;
|
||||||
public String buildPermissions = "dxl.sign.redstone";
|
|
||||||
public boolean onDungeonInit = false;
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
@ -71,32 +69,39 @@ public class RedstoneSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
if (initialized && !active) {
|
if ( !initialized || active) {
|
||||||
if (delay > 0) {
|
return;
|
||||||
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 (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
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
if (initialized && active) {
|
if ( !initialized || !active) {
|
||||||
unpower();
|
return;
|
||||||
|
|
||||||
disableTask(enableTaskId);
|
|
||||||
disableTask(disableTaskId);
|
|
||||||
enableTaskId = -1;
|
|
||||||
disableTaskId = -1;
|
|
||||||
|
|
||||||
active = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unpower();
|
||||||
|
|
||||||
|
disableTask(enableTaskId);
|
||||||
|
disableTask(disableTaskId);
|
||||||
|
enableTaskId = -1;
|
||||||
|
disableTaskId = -1;
|
||||||
|
|
||||||
|
active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void power() {
|
public void power() {
|
||||||
@ -108,21 +113,18 @@ public class RedstoneSign extends DSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void disableTask(int taskId) {
|
public void disableTask(int taskId) {
|
||||||
if (taskId != -1) {
|
if (taskId == -1) {
|
||||||
if (DungeonsXL.getPlugin().getServer().getScheduler().isCurrentlyRunning(taskId) || DungeonsXL.getPlugin().getServer().getScheduler().isQueued(taskId)) {
|
return;
|
||||||
DungeonsXL.getPlugin().getServer().getScheduler().cancelTask(taskId);
|
}
|
||||||
}
|
|
||||||
|
if (DungeonsXL.getPlugin().getServer().getScheduler().isCurrentlyRunning(taskId) || DungeonsXL.getPlugin().getServer().getScheduler().isQueued(taskId)) {
|
||||||
|
DungeonsXL.getPlugin().getServer().getScheduler().cancelTask(taskId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DelayedPower implements Runnable {
|
public class DelayedPower implements Runnable {
|
||||||
@ -155,4 +157,5 @@ public class RedstoneSign extends DSign {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,9 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class SoundMsgSign extends DSign {
|
public class SoundMessageSign extends DSign {
|
||||||
|
|
||||||
public static String name = "SoundMsg";
|
private DSignType type = DSignTypeDefault.SOUND_MESSAGE;
|
||||||
public String buildPermissions = "dxl.sign.soundmsg";
|
|
||||||
public boolean onDungeonInit = false;
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
@ -21,8 +19,8 @@ public class SoundMsgSign extends DSign {
|
|||||||
private String msg;
|
private String msg;
|
||||||
private CopyOnWriteArrayList<Player> done = new CopyOnWriteArrayList<Player>();
|
private CopyOnWriteArrayList<Player> done = new CopyOnWriteArrayList<Player>();
|
||||||
|
|
||||||
public SoundMsgSign(Sign sign, GameWorld gWorld) {
|
public SoundMessageSign(Sign sign, GameWorld gameWorld) {
|
||||||
super(sign, gWorld);
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -39,7 +37,7 @@ public class SoundMsgSign extends DSign {
|
|||||||
String lines[] = getSign().getLines();
|
String lines[] = getSign().getLines();
|
||||||
|
|
||||||
if ( !lines[1].equals("")) {
|
if ( !lines[1].equals("")) {
|
||||||
String msg = getGWorld().getConfig().getMsg(IntegerUtil.parseInt(lines[1]), true);
|
String msg = getGameWorld().getConfig().getMsg(IntegerUtil.parseInt(lines[1]), true);
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
getSign().getBlock().setType(Material.AIR);
|
getSign().getBlock().setType(Material.AIR);
|
||||||
@ -60,20 +58,17 @@ public class SoundMsgSign extends DSign {
|
|||||||
public boolean onPlayerTrigger(Player player) {
|
public boolean onPlayerTrigger(Player player) {
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
remove();
|
remove();
|
||||||
if (done.size() >= getGWorld().world.getPlayers().size()) {
|
if (done.size() >= getGameWorld().getWorld().getPlayers().size()) {
|
||||||
remove();
|
remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -7,12 +7,10 @@ import org.bukkit.block.Sign;
|
|||||||
|
|
||||||
public class StartSign extends DSign {
|
public class StartSign extends DSign {
|
||||||
|
|
||||||
public static String name = "Start";
|
private DSignType type = DSignTypeDefault.START;
|
||||||
public String buildPermissions = "dxl.sign.start";
|
|
||||||
public boolean onDungeonInit = true;
|
|
||||||
|
|
||||||
public StartSign(Sign sign, GameWorld gWorld) {
|
public StartSign(Sign sign, GameWorld gameWorld) {
|
||||||
super(sign, gWorld);
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -22,17 +20,13 @@ public class StartSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
getGWorld().locStart = getSign().getLocation();
|
getGameWorld().setLocStart(getSign().getLocation());
|
||||||
getSign().getBlock().setType(Material.AIR);
|
getSign().getBlock().setType(Material.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -13,31 +13,33 @@ import org.bukkit.block.Block;
|
|||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
|
|
||||||
public class TriggerSign extends DSign {
|
public class TriggerSign extends DSign {
|
||||||
public static String name = "Trigger";
|
|
||||||
public String buildPermissions = "dxl.sign.trigger";
|
private DSignType type = DSignTypeDefault.TRIGGER;
|
||||||
public boolean onDungeonInit = true;
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
private int triggerId;
|
private int triggerId;
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
|
|
||||||
public TriggerSign(Sign sign, GameWorld gWorld) {
|
public TriggerSign(Sign sign, GameWorld gameWorld) {
|
||||||
super(sign, gWorld);
|
super(sign, gameWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
Set<Integer> used = new HashSet<Integer>();
|
Set<Integer> used = new HashSet<Integer>();
|
||||||
for (Block block : EditWorld.get(getSign().getLocation().getWorld()).sign) {
|
for (Block block : EditWorld.get(getSign().getLocation().getWorld()).getSign()) {
|
||||||
if (block != null) {
|
if (block == null) {
|
||||||
if ( !block.getChunk().isLoaded()) {
|
continue;
|
||||||
block.getChunk().load();
|
}
|
||||||
}
|
|
||||||
if (block.getState() instanceof Sign) {
|
if ( !block.getChunk().isLoaded()) {
|
||||||
Sign rsign = (Sign) block.getState();
|
block.getChunk().load();
|
||||||
if (rsign.getLine(0).equalsIgnoreCase("[" + name + "]")) {
|
}
|
||||||
used.add(IntegerUtil.parseInt(rsign.getLine(1)));
|
|
||||||
}
|
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++;
|
id++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
id = IntegerUtil.parseInt(getSign().getLine(1));
|
id = IntegerUtil.parseInt(getSign().getLine(1));
|
||||||
if (used.contains(id)) {
|
if (used.contains(id)) {
|
||||||
@ -73,32 +76,31 @@ public class TriggerSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
if (initialized) {
|
if ( !initialized) {
|
||||||
SignTrigger trigger = SignTrigger.get(triggerId, getGWorld());
|
return;
|
||||||
if (trigger != null) {
|
}
|
||||||
trigger.onTrigger(true);
|
|
||||||
}
|
SignTrigger trigger = SignTrigger.get(triggerId, getGameWorld());
|
||||||
|
if (trigger != null) {
|
||||||
|
trigger.onTrigger(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
if (initialized) {
|
if ( !initialized) {
|
||||||
SignTrigger trigger = SignTrigger.get(triggerId, getGWorld());
|
return;
|
||||||
if (trigger != null) {
|
}
|
||||||
trigger.onTrigger(false);
|
|
||||||
}
|
SignTrigger trigger = SignTrigger.get(triggerId, getGameWorld());
|
||||||
|
if (trigger != null) {
|
||||||
|
trigger.onTrigger(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public DSignType getType() {
|
||||||
return buildPermissions;
|
return type;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UpdateTask implements Runnable {
|
public class UpdateTask implements Runnable {
|
||||||
|
@ -31,7 +31,6 @@ public class DistanceTrigger extends Trigger {
|
|||||||
triggered = true;
|
triggered = true;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
updateDSigns();
|
updateDSigns();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -53,12 +52,18 @@ public class DistanceTrigger extends Trigger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void triggerAllInDistance(Player player, GameWorld gworld) {
|
public static void triggerAllInDistance(Player player, GameWorld gWorld) {
|
||||||
if (hasTriggers(gworld)) {
|
if ( !hasTriggers(gWorld)) {
|
||||||
for (DistanceTrigger trigger : getTriggersArray(gworld)) {
|
return;
|
||||||
if (player.getLocation().distance(trigger.loc) < trigger.distance) {
|
}
|
||||||
trigger.onTrigger(player);
|
|
||||||
}
|
if ( !player.getLocation().getWorld().equals(gWorld.getWorld())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (DistanceTrigger trigger : getTriggersArray(gWorld)) {
|
||||||
|
if (player.getLocation().distance(trigger.loc) < trigger.distance) {
|
||||||
|
trigger.onTrigger(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public abstract class Trigger {
|
|||||||
|
|
||||||
if (type.equalsIgnoreCase("R")) {
|
if (type.equalsIgnoreCase("R")) {
|
||||||
|
|
||||||
trigger = RedstoneTrigger.getOrCreate(dsign.getSign(), dsign.getGWorld());
|
trigger = RedstoneTrigger.getOrCreate(dsign.getSign(), dsign.getGameWorld());
|
||||||
|
|
||||||
} else if (type.equalsIgnoreCase("D")) {
|
} else if (type.equalsIgnoreCase("D")) {
|
||||||
|
|
||||||
@ -41,25 +41,25 @@ public abstract class Trigger {
|
|||||||
} else if (type.equalsIgnoreCase("T")) {
|
} else if (type.equalsIgnoreCase("T")) {
|
||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
trigger = SignTrigger.getOrCreate(IntegerUtil.parseInt(value), dsign.getGWorld());
|
trigger = SignTrigger.getOrCreate(IntegerUtil.parseInt(value), dsign.getGameWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (type.equalsIgnoreCase("I")) {
|
} else if (type.equalsIgnoreCase("I")) {
|
||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
trigger = InteractTrigger.getOrCreate(IntegerUtil.parseInt(value), dsign.getGWorld());
|
trigger = InteractTrigger.getOrCreate(IntegerUtil.parseInt(value), dsign.getGameWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (type.equalsIgnoreCase("M")) {
|
} else if (type.equalsIgnoreCase("M")) {
|
||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
trigger = MobTrigger.getOrCreate(value, dsign.getGWorld());
|
trigger = MobTrigger.getOrCreate(value, dsign.getGameWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (type.equalsIgnoreCase("U")) {
|
} else if (type.equalsIgnoreCase("U")) {
|
||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
trigger = UseItemTrigger.getOrCreate(value, dsign.getGWorld());
|
trigger = UseItemTrigger.getOrCreate(value, dsign.getGameWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ public abstract class Trigger {
|
|||||||
|
|
||||||
public void addListener(DSign dsign) {
|
public void addListener(DSign dsign) {
|
||||||
if (dsigns.isEmpty()) {
|
if (dsigns.isEmpty()) {
|
||||||
register(dsign.getGWorld());
|
register(dsign.getGameWorld());
|
||||||
}
|
}
|
||||||
dsigns.add(dsign);
|
dsigns.add(dsign);
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ public abstract class Trigger {
|
|||||||
public void removeListener(DSign dsign) {
|
public void removeListener(DSign dsign) {
|
||||||
dsigns.remove(dsign);
|
dsigns.remove(dsign);
|
||||||
if (dsigns.isEmpty()) {
|
if (dsigns.isEmpty()) {
|
||||||
unregister(dsign.getGWorld());
|
unregister(dsign.getGameWorld());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user