diff --git a/src/com/dre/dungeonsxl/DConfig.java b/src/com/dre/dungeonsxl/DConfig.java index b19d0dbb..4efb0ab8 100644 --- a/src/com/dre/dungeonsxl/DConfig.java +++ b/src/com/dre/dungeonsxl/DConfig.java @@ -3,6 +3,7 @@ package com.dre.dungeonsxl; import java.io.File; import java.io.IOException; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -16,23 +17,32 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; public class DConfig { - public File file; + public static DConfig mainConfig = new DConfig(); + + private File file; private CopyOnWriteArrayList dClasses = new CopyOnWriteArrayList(); - public Map msgs = new HashMap(); + private Map msgs = new HashMap(); + + private CopyOnWriteArrayList invitedPlayers = new CopyOnWriteArrayList(); + private CopyOnWriteArrayList secureObjects = new CopyOnWriteArrayList(); - public CopyOnWriteArrayList invitedPlayers = new CopyOnWriteArrayList(); - public CopyOnWriteArrayList secureObjects = new CopyOnWriteArrayList(); + private boolean isLobbyDisabled = false; + private int timeToNextPlay = 0; + private int timeToNextLoot = 0; - public boolean isLobbyDisabled = false; - public int timeToNextPlay = 0; - public int timeToNextLoot = 0; - - public int timeUntilKickOfflinePlayer = -1; + private int timeUntilKickOfflinePlayer = -1; //Spout - public boolean spoutCraftOnly = false; - public String spoutTexturepackURL; + private boolean spoutCraftOnly = false; + private String spoutTexturepackURL; + + //MobTypes + private Set mobTypes = new HashSet(); + + public DConfig(){ + + } public DConfig(File file){ this.file=file; @@ -143,29 +153,45 @@ public class DConfig { /* Lobby */ if(configFile.contains("isLobbyDisabled")){ isLobbyDisabled = configFile.getBoolean("isLobbyDisabled"); + } else { + isLobbyDisabled = mainConfig.isLobbyDisabled; } /* Times */ if(configFile.contains("timeToNextPlay")){ timeToNextPlay = configFile.getInt("timeToNextPlay"); + } else { + timeToNextPlay = mainConfig.timeToNextPlay; } if(configFile.contains("timeToNextLoot")){ timeToNextLoot = configFile.getInt("timeToNextLoot"); + } else { + timeToNextLoot = mainConfig.timeToNextLoot; } if(configFile.contains("timeUntilKickOfflinePlayer")){ timeUntilKickOfflinePlayer = configFile.getInt("timeUntilKickOfflinePlayer"); + } else { + timeUntilKickOfflinePlayer = mainConfig.timeUntilKickOfflinePlayer; } /* Spout */ if(configFile.contains("spout.spoutCraftOnly")){ spoutCraftOnly = configFile.getBoolean("spout.spoutCraftOnly"); + } else { + spoutCraftOnly = mainConfig.spoutCraftOnly; } if(configFile.contains("spout.spoutTexturepackURL")){ spoutTexturepackURL = configFile.getString("spout.spoutTexturepackURL"); + } else { + spoutTexturepackURL = mainConfig.spoutTexturepackURL; } + + /* Mobtypes */ + configSetionMessages = configFile.getConfigurationSection("mobTypes"); + this.mobTypes = DMobType.load(configSetionMessages); } public void save(){ @@ -197,13 +223,25 @@ public class DConfig { } } - //Get + //Getters and Setters public CopyOnWriteArrayList getClasses(){ - return dClasses; + if(this.dClasses != null){ + if(!this.dClasses.isEmpty()){ + return this.dClasses; + } + } + + return mainConfig.dClasses; } public DClass getClass(String name){ - for(DClass dClass:dClasses){ + for(DClass dClass:this.dClasses){ + if(dClass.name.equals(name)){ + return dClass; + } + } + + for(DClass dClass:mainConfig.dClasses){ if(dClass.name.equals(name)){ return dClass; } @@ -211,7 +249,69 @@ public class DConfig { return null; } - public String getMsg(int id){ - return this.msgs.get(id); + public String getMsg(int id, boolean returnMainConfig){ + String msg = this.msgs.get(id); + if(msg != null){ + return this.msgs.get(id); + } + if(returnMainConfig){ + return mainConfig.msgs.get(id); + } + + return null; + } + + public void setMsg(String msg, int id) { + this.msgs.put(id, msg); + } + + public CopyOnWriteArrayList getInvitedPlayers() { + CopyOnWriteArrayList tmpInvitedPlayers = new CopyOnWriteArrayList(); + tmpInvitedPlayers.addAll(this.invitedPlayers); + tmpInvitedPlayers.addAll(mainConfig.invitedPlayers); + return tmpInvitedPlayers; + } + + public void addInvitedPlayer(String player) { + this.invitedPlayers.add(player); + } + + public void removeInvitedPlayers(String player) { + this.invitedPlayers.remove(player); + } + + public CopyOnWriteArrayList getSecureObjects() { + CopyOnWriteArrayList tmpSecureObjects = new CopyOnWriteArrayList(); + tmpSecureObjects.addAll(this.secureObjects); + tmpSecureObjects.addAll(mainConfig.secureObjects); + return tmpSecureObjects; + } + + public boolean isLobbyDisabled() { + return isLobbyDisabled; + } + + public int getTimeToNextPlay() { + return timeToNextPlay; + } + + public int getTimeToNextLoot() { + return timeToNextLoot; + } + + public int getTimeUntilKickOfflinePlayer() { + return timeUntilKickOfflinePlayer; + } + + public boolean isSpoutCraftOnly() { + return spoutCraftOnly; + } + + public String getSpoutTexturepackURL() { + return spoutTexturepackURL; + } + + public Set getMobTypes() { + return mobTypes; } } diff --git a/src/com/dre/dungeonsxl/DGSign.java b/src/com/dre/dungeonsxl/DGSign.java index 4972ce33..1e971dc1 100644 --- a/src/com/dre/dungeonsxl/DGSign.java +++ b/src/com/dre/dungeonsxl/DGSign.java @@ -246,7 +246,7 @@ public class DGSign { if(file!=null){ DConfig confReader=new DConfig(file); if(confReader!=null){ - P.p.msg(player, P.p.language.get("Error_Cooldown",""+confReader.timeToNextPlay)); + P.p.msg(player, P.p.language.get("Error_Cooldown",""+confReader.getTimeToNextPlay())); } } } diff --git a/src/com/dre/dungeonsxl/DMobType.java b/src/com/dre/dungeonsxl/DMobType.java index 8a8e1ea6..3d39750f 100644 --- a/src/com/dre/dungeonsxl/DMobType.java +++ b/src/com/dre/dungeonsxl/DMobType.java @@ -1,6 +1,5 @@ package com.dre.dungeonsxl; -import java.io.File; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -9,8 +8,6 @@ import java.util.Set; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; @@ -25,8 +22,6 @@ import com.dre.dungeonsxl.game.DMob; import com.dre.dungeonsxl.game.GameWorld; public class DMobType { - private static Set mobTypes = new HashSet(); - private String name; private EntityType type; @@ -50,8 +45,6 @@ public class DMobType { /* Methods */ public DMobType(String name, EntityType type){ - mobTypes.add(this); - this.name=name; this.type=type; } @@ -107,135 +100,139 @@ public class DMobType { } //Load Config - public static void load(File file){ - FileConfiguration configFile = YamlConfiguration.loadConfiguration(file); - - //Read Mobs - for(String mobName:configFile.getKeys(false)){ - EntityType type=EntityType.fromName(configFile.getString(mobName+".Type")); - - if (type!=null) { - DMobType mobType=new DMobType(mobName, type); - - //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 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()), P.p.parseInt(splittedEnchantment[1]), true); + public static Set load(ConfigurationSection configFile){ + Set set = new HashSet(); + if(configFile!=null){ + //Read Mobs + for(String mobName:configFile.getKeys(false)){ + EntityType type=EntityType.fromName(configFile.getString(mobName+".Type")); + + if (type!=null) { + DMobType mobType=new DMobType(mobName, type); + set.add(mobType); + + //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 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()), P.p.parseInt(splittedEnchantment[1]), true); + } else { + itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), 1, true); + } } else { - itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), 1, true); + P.p.log(P.p.language.get("Log_Error_MobEnchantment",splittedEnchantment[0])); } - } else { - P.p.log(P.p.language.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.drops.put(item, chance); } - - /* 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.drops.put(item, chance); } + + //Spout Skin + if(configFile.contains(mobName+".spoutSkinURL")){ + mobType.spoutSkinURL = configFile.getString(mobName+".spoutSkinURL"); + } + } else { + P.p.log(P.p.language.get("Log_Error_MobType",configFile.getString(mobName+".Type"))); } - - //Spout Skin - if(configFile.contains(mobName+".spoutSkinURL")){ - mobType.spoutSkinURL = configFile.getString(mobName+".spoutSkinURL"); - } - } else { - P.p.log(P.p.language.get("Log_Error_MobType",configFile.getString(mobName+".Type"))); } } + return set; } - //Clear - public static void clear(){ - mobTypes.clear(); - } - //Get - public static DMobType get(String name){ - for(DMobType mobType:DMobType.mobTypes){ + public static DMobType get(String name, Set mobTypes){ + for(DMobType mobType:mobTypes){ if(mobType.name.equalsIgnoreCase(name)){ return mobType; } } + for(DMobType mobType:P.p.mainConfig.defaultDungeon.getMobTypes()){ + if(mobType.name.equalsIgnoreCase(name)){ + return mobType; + } + } + return null; } } diff --git a/src/com/dre/dungeonsxl/DPlayer.java b/src/com/dre/dungeonsxl/DPlayer.java index 96bfe9c7..7bacdf88 100644 --- a/src/com/dre/dungeonsxl/DPlayer.java +++ b/src/com/dre/dungeonsxl/DPlayer.java @@ -81,7 +81,7 @@ public class DPlayer { if(isEditing) this.player.setGameMode(GameMode.CREATIVE); else this.player.setGameMode(GameMode.SURVIVAL); if(!isEditing){ - if(GameWorld.get(world).config.isLobbyDisabled){ + if(GameWorld.get(world).config.isLobbyDisabled()){ this.ready(); } } @@ -90,11 +90,11 @@ public class DPlayer { if(!isEditing){ if(p.isSpoutEnabled){ GameWorld gworld = GameWorld.get(world); - if(gworld.config.spoutTexturepackURL!=null){ + if(gworld.config.getSpoutTexturepackURL()!=null){ SpoutPlayer sPlayer = Spout.getServer().getPlayer(player.getName()); if(sPlayer!=null){ sPlayer.sendNotification(ChatColor.GOLD+"DungeonsXL",ChatColor.RED+"Download texturepack!", Material.FIREBALL); - sPlayer.setTexturePack(gworld.config.spoutTexturepackURL); + sPlayer.setTexturePack(gworld.config.getSpoutTexturepackURL()); } } } diff --git a/src/com/dre/dungeonsxl/DPortal.java b/src/com/dre/dungeonsxl/DPortal.java index 78623cd6..dd24234d 100644 --- a/src/com/dre/dungeonsxl/DPortal.java +++ b/src/com/dre/dungeonsxl/DPortal.java @@ -98,7 +98,7 @@ public class DPortal { /* Check Spout */ boolean spoutCheck = true; if(P.p.isSpoutEnabled){ - if(dgroup.getGworld().config.spoutCraftOnly){ + if(dgroup.getGworld().config.isSpoutCraftOnly()){ if(!Spout.getServer().getPlayer(player.getName()).isSpoutCraftEnabled()){ spoutCheck = false; } diff --git a/src/com/dre/dungeonsxl/EditWorld.java b/src/com/dre/dungeonsxl/EditWorld.java index a66d29fb..e3911fa4 100644 --- a/src/com/dre/dungeonsxl/EditWorld.java +++ b/src/com/dre/dungeonsxl/EditWorld.java @@ -222,7 +222,7 @@ public class EditWorld { }else{ if(exist(eworldname)){ DConfig config=new DConfig(new File(p.getDataFolder()+"/dungeons/"+eworldname, "config.yml")); - config.invitedPlayers.add(player.toLowerCase()); + config.addInvitedPlayer(player.toLowerCase()); config.save(); return true; } @@ -241,7 +241,7 @@ public class EditWorld { }else{ if(exist(eworldname)){ DConfig config=new DConfig(new File(p.getDataFolder()+"/dungeons/"+eworldname, "config.yml")); - config.invitedPlayers.remove(player.toLowerCase()); + config.removeInvitedPlayers(player.toLowerCase()); config.save(); return true; } @@ -259,7 +259,7 @@ public class EditWorld { }else{ if(exist(eworldname)){ DConfig config=new DConfig(new File(p.getDataFolder()+"/dungeons/"+eworldname, "config.yml")); - return config.invitedPlayers.contains(player.toLowerCase()); + return config.getInvitedPlayers().contains(player.toLowerCase()); } } diff --git a/src/com/dre/dungeonsxl/MainConfig.java b/src/com/dre/dungeonsxl/MainConfig.java index 09992d10..4c759326 100644 --- a/src/com/dre/dungeonsxl/MainConfig.java +++ b/src/com/dre/dungeonsxl/MainConfig.java @@ -57,6 +57,7 @@ public class MainConfig { ConfigurationSection configSetion = configFile.getConfigurationSection("default"); if(configSetion!=null){ defaultDungeon = new DConfig(configSetion); + DConfig.mainConfig = defaultDungeon; } } diff --git a/src/com/dre/dungeonsxl/P.java b/src/com/dre/dungeonsxl/P.java index e25a80b2..b524257c 100644 --- a/src/com/dre/dungeonsxl/P.java +++ b/src/com/dre/dungeonsxl/P.java @@ -65,11 +65,14 @@ public class P extends JavaPlugin{ //Commands getCommand("dungeonsxl").setExecutor(new CommandListener()); - + + //Load Language + language = new LanguageReader(new File(p.getDataFolder(), "languages/en.yml")); + //Load Config mainConfig=new MainConfig(new File(p.getDataFolder(), "config.yml")); - //Load Language + //Load Language 2 language = new LanguageReader(new File(p.getDataFolder(), "languages/"+mainConfig.language+".yml")); //Init Commands @@ -130,7 +133,6 @@ public class P extends JavaPlugin{ DGroup.dgroups.clear(); DGSign.dgsigns.clear(); DLootInventory.LootInventorys.clear(); - DMobType.clear(); DPlayer.players.clear(); DPortal.portals.clear(); LeaveSign.lsigns.clear(); @@ -248,9 +250,6 @@ public class P extends JavaPlugin{ DGSign.load(configFile); LeaveSign.load(configFile); - //Load mob types - DMobType.load(new File(p.getDataFolder(), "mobs.yml")); - //Load saved players DSavePlayer.load(); } diff --git a/src/com/dre/dungeonsxl/commands/CMDMsg.java b/src/com/dre/dungeonsxl/commands/CMDMsg.java index bb91563e..9e67685c 100644 --- a/src/com/dre/dungeonsxl/commands/CMDMsg.java +++ b/src/com/dre/dungeonsxl/commands/CMDMsg.java @@ -31,7 +31,7 @@ public class CMDMsg extends DCommand{ DConfig confreader = new DConfig(new File(p.getDataFolder()+"/dungeons/"+eworld.dungeonname, "config.yml")); if(args.length==2){ - String msg=confreader.msgs.get(id); + String msg=confreader.getMsg(id, true); if(msg!=null){ p.msg(player, ChatColor.WHITE+msg); }else{ @@ -51,14 +51,14 @@ public class CMDMsg extends DCommand{ String[] splitMsg=msg.split("\""); if(splitMsg.length>1){ msg=splitMsg[1]; - String old=confreader.msgs.get(id); + String old=confreader.getMsg(id, false); if(old==null){ p.msg(player, p.language.get("Cmd_Msg_Added",""+id)); }else{ p.msg(player, p.language.get("Cmd_Msg_Updated",""+id)); } - confreader.msgs.put(id, msg); + confreader.setMsg(msg, id); confreader.save(); }else{ p.msg(player, p.language.get("Error_MsgFormat")); diff --git a/src/com/dre/dungeonsxl/commands/CMDReload.java b/src/com/dre/dungeonsxl/commands/CMDReload.java index fc14f899..5faf5dae 100644 --- a/src/com/dre/dungeonsxl/commands/CMDReload.java +++ b/src/com/dre/dungeonsxl/commands/CMDReload.java @@ -4,7 +4,6 @@ package com.dre.dungeonsxl.commands; import java.io.File; import org.bukkit.command.CommandSender; -import com.dre.dungeonsxl.DMobType; import com.dre.dungeonsxl.LanguageReader; import com.dre.dungeonsxl.MainConfig; @@ -33,10 +32,6 @@ public class CMDReload extends DCommand{ //Load Language p.language = new LanguageReader(new File(p.getDataFolder(), "languages/"+p.mainConfig.language+".yml")); - //Mobtype - DMobType.clear(); - DMobType.load(new File(p.getDataFolder(), "mobs.yml")); - p.msg(sender, p.language.get("Cmd_Reload_Done")); } } diff --git a/src/com/dre/dungeonsxl/game/GameWorld.java b/src/com/dre/dungeonsxl/game/GameWorld.java index 4c37740a..703753fe 100644 --- a/src/com/dre/dungeonsxl/game/GameWorld.java +++ b/src/com/dre/dungeonsxl/game/GameWorld.java @@ -108,7 +108,7 @@ public class GameWorld { sign.setLine(3, ChatColor.DARK_BLUE+"############"); sign.update(); } else if (lines[1].equalsIgnoreCase("classes")){ - if(!config.isLobbyDisabled){ + if(!config.isLobbyDisabled()){ int[] direction=DGSign.getDirection(block.getData()); int directionX=direction[0]; int directionZ=direction[1]; @@ -188,7 +188,7 @@ public class GameWorld { } if(lines[1].equalsIgnoreCase("msg")){ if(lines[2]!=""&&lines[3]!=""){ - String msg = config.getMsg(p.parseInt(lines[2])); + String msg = config.getMsg(p.parseInt(lines[2]),true); if(msg!=null){ messages.add(new GameMessage(block.getLocation(),msg,p.parseInt(lines[3]),false)); block.setTypeId(0); @@ -197,7 +197,7 @@ public class GameWorld { } if(lines[1].equalsIgnoreCase("soundmsg")){ if(lines[2]!=""&&lines[3]!=""){ - String msg = config.getMsg(p.parseInt(lines[2])); + String msg = config.getMsg(p.parseInt(lines[2]),true); if(msg!=null){ messages.add(new GameMessage(block.getLocation(),msg,p.parseInt(lines[3]),true)); block.setTypeId(0); @@ -296,7 +296,7 @@ public class GameWorld { if(dungeonFolder.isDirectory()){ DConfig config=new DConfig(new File(p.getDataFolder()+"/dungeons/"+dungeon, "config.yml")); - if(config.timeToNextPlay!=0){ + if(config.getTimeToNextPlay()!=0){ //read PlayerConfig File file=new File(p.getDataFolder()+"/dungeons/"+dungeon, "players.yml"); @@ -312,7 +312,7 @@ public class GameWorld { if(playerConfig.contains(player.getName())){ Long time=playerConfig.getLong(player.getName()); - if(time+(config.timeToNextPlay*1000*60*60)>System.currentTimeMillis()){ + if(time+(config.getTimeToNextPlay()*1000*60*60)>System.currentTimeMillis()){ return false; } } @@ -347,7 +347,7 @@ public class GameWorld { gworld.config = new DConfig(new File(p.getDataFolder()+"/dungeons/"+gworld.dungeonname, "config.yml")); //Secure Objects - gworld.secureObjects=gworld.config.secureObjects; + gworld.secureObjects=gworld.config.getSecureObjects(); //World p.copyDirectory(file,new File("DXL_Game_"+gworld.id)); diff --git a/src/com/dre/dungeonsxl/game/MobSpawner.java b/src/com/dre/dungeonsxl/game/MobSpawner.java index 5e0cbcf1..a9c4d0c0 100644 --- a/src/com/dre/dungeonsxl/game/MobSpawner.java +++ b/src/com/dre/dungeonsxl/game/MobSpawner.java @@ -39,52 +39,53 @@ public class MobSpawner { public void update(){ World world=this.block.getWorld(); - - for(Player player:world.getPlayers()){ - if(player.getWorld()==world){ - if(player.getLocation().distance(this.block.getLocation())1){ - amount--; - }else{ - mobspawners.remove(this); + + //Check custom mobs + DMobType mobType = DMobType.get(this.mob, gworld.config.getMobTypes()); + + if(mobType!=null){ + mobType.spawn(GameWorld.get(world), this.block.getLocation()); } + + //Set the amount + if(amount!=-1){ + if(amount>1){ + amount--; + }else{ + mobspawners.remove(this); + } + } + this.interval=this.maxinterval; } - this.interval=this.maxinterval; + this.interval--; + return; } - this.interval--; - return; } } } - } //Static diff --git a/src/com/dre/dungeonsxl/listener/PlayerListener.java b/src/com/dre/dungeonsxl/listener/PlayerListener.java index c94cfb47..5967e151 100644 --- a/src/com/dre/dungeonsxl/listener/PlayerListener.java +++ b/src/com/dre/dungeonsxl/listener/PlayerListener.java @@ -194,7 +194,7 @@ public class PlayerListener implements Listener{ DPlayer dplayer=DPlayer.get(player); GameWorld gworld=GameWorld.get(dplayer.world); if(dplayer!=null){ - for(Material material:gworld.config.secureObjects){ + for(Material material:gworld.config.getSecureObjects()){ if(material==event.getItemDrop().getItemStack().getType()){ event.setCancelled(true); p.msg(player,p.language.get("Error_Drop")); @@ -295,7 +295,7 @@ public class PlayerListener implements Listener{ //Check GameWorld GameWorld gWorld = GameWorld.get(player.getWorld()); if(gWorld != null){ - int timeUntilKickOfflinePlayer = gWorld.config.timeUntilKickOfflinePlayer; + int timeUntilKickOfflinePlayer = gWorld.config.getTimeUntilKickOfflinePlayer(); if(timeUntilKickOfflinePlayer == 0){ dPlayer.leave();