diff --git a/src/com/dre/dungeonsxl/ConfigReader.java b/src/com/dre/dungeonsxl/ConfigReader.java deleted file mode 100644 index 8ff00d37..00000000 --- a/src/com/dre/dungeonsxl/ConfigReader.java +++ /dev/null @@ -1,195 +0,0 @@ -package com.dre.dungeonsxl; - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.CopyOnWriteArrayList; - -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.inventory.ItemStack; - -public class ConfigReader { - public static P p=P.p; - - public File file; - - private CopyOnWriteArrayList dclasses=new CopyOnWriteArrayList(); - public CopyOnWriteArrayList invitedPlayer = new CopyOnWriteArrayList(); - public Map msgs=new HashMap(); - public CopyOnWriteArrayList secureobjects=new CopyOnWriteArrayList(); - - public boolean isLobbyDisabled=false; - public int timeToNextPlay=0; - public int timeToNextLoot=0; - - public ConfigReader(File file){ - this.file=file; - - FileConfiguration configFile = YamlConfiguration.loadConfiguration(file); - - //Read Classes - int id=0; - String preString; - do{ - id++; - preString="classes."+id+"."; - if(configFile.contains(preString)){ - String name=configFile.getString(preString+".name"); - boolean hasDog=configFile.getBoolean(preString+".hasdog"); - @SuppressWarnings("unchecked") - List items=(List) configFile.getList(preString+".items"); - - CopyOnWriteArrayList istacks=new CopyOnWriteArrayList(); - - for(String item:items){ - String[] itemsplit=item.split(","); - if(itemsplit.length>0){ - int itemId=0,itemData=0,itemSize=1,itemLvlEnchantment=1; - Enchantment itemEnchantment=null; - - //Check Id & Data - String[] idAndData=itemsplit[0].split("/"); - - itemId=Integer.parseInt(idAndData[0]); - - if(idAndData.length>1){ - itemData=Integer.parseInt(idAndData[1]); - } - - //Size - if(itemsplit.length>1){ - itemSize=Integer.parseInt(itemsplit[1]); - } - - //Enchantment - if(itemsplit.length>2){ - String[] enchantmentSplit=itemsplit[2].split("/"); - - itemEnchantment=Enchantment.getByName(enchantmentSplit[0]); - - if(enchantmentSplit.length>1){ - itemLvlEnchantment=Integer.parseInt(enchantmentSplit[1]); - } - } - - //Add Item to Stacks - ItemStack istack=new ItemStack(itemId,itemSize,(short) itemData); - if(itemEnchantment!=null){ - istack.addEnchantment(itemEnchantment, itemLvlEnchantment); - } - - istacks.add(istack); - } - } - dclasses.add(new DClass(name,istacks,hasDog)); - } - }while(configFile.contains(preString)); - - //Read Messages - ConfigurationSection configSetion = configFile.getConfigurationSection("message"); - if(configSetion!=null){ - Set list=configSetion.getKeys(false); - for(String messagePath:list){ - int messageId=Integer.parseInt(messagePath); - this.msgs.put(messageId,configSetion.getString(messagePath)); - } - } - - //Read Secure Objects - if(configFile.contains("secureobjects")){ - @SuppressWarnings("unchecked") - List secureobjectlist=(List) configFile.getList("secureobjects"); - for(int i:secureobjectlist){ - this.secureobjects.add(Material.getMaterial(i)); - } - } - - //Read Invited Player - if(configFile.contains("invitedplayers")){ - @SuppressWarnings("unchecked") - List invitedplayers=(List) configFile.getList("invitedplayers"); - for(String i:invitedplayers){ - this.invitedPlayer.add(i); - } - } - - //Read Tutorial-Mode - if(configFile.contains("tutorialdungeon")){ - p.tutorialDungeon=configFile.getString("tutorialdungeon"); - p.tutorialStartGroup=configFile.getString("tutorialstartgroup"); - p.tutorialEndGroup=configFile.getString("tutorialendgroup"); - } - - //Read Lobby disabled - if(configFile.contains("islobbydisabled")){ - isLobbyDisabled=configFile.getBoolean("islobbydisabled"); - } - - if(configFile.contains("timetonextplay")){ - timeToNextPlay=configFile.getInt("timetonextplay"); - } - - if(configFile.contains("timetonextloot")){ - timeToNextLoot=configFile.getInt("timetonextloot"); - } - - } - - public String getMsg(int id){ - return this.msgs.get(id); - } - - - //Save - public void save(){ - FileConfiguration configFile = YamlConfiguration.loadConfiguration(this.file); - - //Classes don't save - - //Messages - for(Integer msgs:this.msgs.keySet()){ - configFile.set("message."+msgs, this.msgs.get(msgs)); - } - - //Secure Objects - CopyOnWriteArrayList secureobjectsids=new CopyOnWriteArrayList(); - - for(Material mat:this.secureobjects){ - secureobjectsids.add(mat.getId()); - } - - configFile.set("secureobjects", secureobjectsids); - - //Invited Players - configFile.set("invitedplayers", this.invitedPlayer); - - try { - configFile.save(this.file); - } catch (IOException e) { - e.printStackTrace(); - } - } - - //Classes - - public CopyOnWriteArrayList getClasses(){ - return dclasses; - } - - public DClass getClass(String name){ - for(DClass dclass:dclasses){ - if(dclass.name.equals(name)){ - return dclass; - } - } - return null; - } - -} diff --git a/src/com/dre/dungeonsxl/DConfig.java b/src/com/dre/dungeonsxl/DConfig.java new file mode 100644 index 00000000..0dcb7d08 --- /dev/null +++ b/src/com/dre/dungeonsxl/DConfig.java @@ -0,0 +1,188 @@ +package com.dre.dungeonsxl; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.CopyOnWriteArrayList; + +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.inventory.ItemStack; + +public class DConfig { + public File file; + + private CopyOnWriteArrayList dClasses = new CopyOnWriteArrayList(); + public Map msgs = new HashMap(); + + public CopyOnWriteArrayList invitedPlayers = new CopyOnWriteArrayList(); + public CopyOnWriteArrayList secureObjects = new CopyOnWriteArrayList(); + + public boolean isLobbyDisabled = false; + public int timeToNextPlay = 0; + public int timeToNextLoot = 0; + + public DConfig(File file){ + this.file=file; + + FileConfiguration configFile = YamlConfiguration.loadConfiguration(file); + + load(configFile); + } + + public DConfig(ConfigurationSection configFile){ + load(configFile); + } + + //Load & Save + public void load(ConfigurationSection configFile){ + + /* Classes */ + ConfigurationSection configSetionClasses = configFile.getConfigurationSection("classes"); + if(configSetionClasses!=null){ + Set list = configSetionClasses.getKeys(false); + for (String className:list) { + String name = className; + boolean hasDog = configSetionClasses.getBoolean(className+".hasdog"); + + /* Items */ + List items = configSetionClasses.getStringList(className+".items"); + CopyOnWriteArrayList istacks=new CopyOnWriteArrayList(); + + for(String item:items){ + String[] itemsplit=item.split(","); + if(itemsplit.length>0){ + int itemId=0,itemData=0,itemSize=1,itemLvlEnchantment=1; + Enchantment itemEnchantment=null; + + //Check Id & Data + String[] idAndData=itemsplit[0].split("/"); + itemId=Integer.parseInt(idAndData[0]); + + if(idAndData.length>1){ + itemData=Integer.parseInt(idAndData[1]); + } + + //Size + if(itemsplit.length>1){ + itemSize=Integer.parseInt(itemsplit[1]); + } + + //Enchantment + if(itemsplit.length>2){ + String[] enchantmentSplit=itemsplit[2].split("/"); + + itemEnchantment=Enchantment.getByName(enchantmentSplit[0]); + + if(enchantmentSplit.length>1){ + itemLvlEnchantment=Integer.parseInt(enchantmentSplit[1]); + } + } + + //Add Item to Stacks + ItemStack istack=new ItemStack(itemId,itemSize,(short) itemData); + if(itemEnchantment!=null){ + istack.addEnchantment(itemEnchantment, itemLvlEnchantment); + } + + istacks.add(istack); + } + } + this.dClasses.add(new DClass(name,istacks,hasDog)); + } + } + + /* Messages */ + ConfigurationSection configSetionMessages = configFile.getConfigurationSection("message"); + if (configSetionMessages != null) { + Set list = configSetionMessages.getKeys(false); + for (String messagePath:list) { + int messageId = Integer.parseInt(messagePath); + this.msgs.put(messageId,configSetionMessages.getString(messagePath)); + } + } + + /* Secure Objects */ + if(configFile.contains("secureobjects")){ + List secureobjectlist = configFile.getIntegerList("secureobjects"); + for(int i:secureobjectlist){ + this.secureObjects.add(Material.getMaterial(i)); + } + } + + /* Invited Players */ + if(configFile.contains("invitedplayers")){ + List invitedplayers = configFile.getStringList("invitedplayers"); + for(String i:invitedplayers){ + this.invitedPlayers.add(i); + } + } + + /* Lobby */ + if(configFile.contains("islobbydisabled")){ + isLobbyDisabled = configFile.getBoolean("islobbydisabled"); + } + + /* Times */ + if(configFile.contains("timetonextplay")){ + timeToNextPlay = configFile.getInt("timetonextplay"); + } + + if(configFile.contains("timetonextloot")){ + timeToNextLoot = configFile.getInt("timetonextloot"); + } + } + + public void save(){ + if(this.file!=null){ + FileConfiguration configFile = YamlConfiguration.loadConfiguration(this.file); + + //Messages + for(Integer msgs:this.msgs.keySet()){ + configFile.set("message."+msgs, this.msgs.get(msgs)); + } + + //Secure Objects + CopyOnWriteArrayList secureobjectsids=new CopyOnWriteArrayList(); + + for(Material mat:this.secureObjects){ + secureobjectsids.add(mat.getId()); + } + + configFile.set("secureobjects", secureobjectsids); + + //Invited Players + configFile.set("invitedplayers", this.invitedPlayers); + + try { + configFile.save(this.file); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + //Get + public CopyOnWriteArrayList getClasses(){ + return dClasses; + } + + public DClass getClass(String name){ + for(DClass dClass:dClasses){ + if(dClass.name.equals(name)){ + return dClass; + } + } + return null; + } + + public String getMsg(int id){ + return this.msgs.get(id); + } +} diff --git a/src/com/dre/dungeonsxl/DGSign.java b/src/com/dre/dungeonsxl/DGSign.java index 5e2baab6..98a2a8ee 100644 --- a/src/com/dre/dungeonsxl/DGSign.java +++ b/src/com/dre/dungeonsxl/DGSign.java @@ -246,7 +246,7 @@ public class DGSign { else{ File file=new File(P.p.getDataFolder()+"/dungeons/"+dgsign.dungeonName, "config.yml"); if(file!=null){ - ConfigReader confReader=new ConfigReader(file); + DConfig confReader=new DConfig(file); if(confReader!=null){ P.p.msg(player, P.p.language.get("Error_Cooldown",""+confReader.timeToNextPlay)); } diff --git a/src/com/dre/dungeonsxl/DPlayer.java b/src/com/dre/dungeonsxl/DPlayer.java index b97e23f1..2f49067f 100644 --- a/src/com/dre/dungeonsxl/DPlayer.java +++ b/src/com/dre/dungeonsxl/DPlayer.java @@ -84,7 +84,7 @@ public class DPlayer { if(isEditing) this.player.setGameMode(GameMode.CREATIVE); else this.player.setGameMode(GameMode.SURVIVAL); if(!isEditing){ - if(GameWorld.get(world).confReader.isLobbyDisabled){ + if(GameWorld.get(world).config.isLobbyDisabled){ this.ready(); } } @@ -156,8 +156,8 @@ public class DPlayer { //Tutorial Permissions if(gworld.isTutorial){ - p.permission.playerAddGroup(this.player, p.tutorialEndGroup); - p.permission.playerRemoveGroup(this.player, p.tutorialStartGroup); + p.permission.playerAddGroup(this.player, p.mainConfig.tutorialEndGroup); + p.permission.playerRemoveGroup(this.player, p.mainConfig.tutorialStartGroup); } } } @@ -284,7 +284,7 @@ public class DPlayer { GameWorld gworld=GameWorld.get(this.player.getWorld()); if(gworld==null) return; - DClass dclass=gworld.confReader.getClass(classname); + DClass dclass=gworld.config.getClass(classname); if(dclass!=null){ if(this.dclass!=dclass){ this.dclass=dclass; diff --git a/src/com/dre/dungeonsxl/EditWorld.java b/src/com/dre/dungeonsxl/EditWorld.java index b128ff6f..a66d29fb 100644 --- a/src/com/dre/dungeonsxl/EditWorld.java +++ b/src/com/dre/dungeonsxl/EditWorld.java @@ -221,9 +221,9 @@ public class EditWorld { eworld.invitedPlayers.add(player.toLowerCase()); }else{ if(exist(eworldname)){ - ConfigReader confreader=new ConfigReader(new File(p.getDataFolder()+"/dungeons/"+eworldname, "config.yml")); - confreader.invitedPlayer.add(player.toLowerCase()); - confreader.save(); + DConfig config=new DConfig(new File(p.getDataFolder()+"/dungeons/"+eworldname, "config.yml")); + config.invitedPlayers.add(player.toLowerCase()); + config.save(); return true; } } @@ -240,15 +240,14 @@ public class EditWorld { eworld.invitedPlayers.remove(player.toLowerCase()); }else{ if(exist(eworldname)){ - ConfigReader confreader=new ConfigReader(new File(p.getDataFolder()+"/dungeons/"+eworldname, "config.yml")); - confreader.invitedPlayer.remove(player.toLowerCase()); - confreader.save(); + DConfig config=new DConfig(new File(p.getDataFolder()+"/dungeons/"+eworldname, "config.yml")); + config.invitedPlayers.remove(player.toLowerCase()); + config.save(); return true; } } return false; - } public static boolean isInvitedPlayer(String eworldname,String player){ @@ -259,8 +258,8 @@ public class EditWorld { return eworld.invitedPlayers.contains(player.toLowerCase()); }else{ if(exist(eworldname)){ - ConfigReader confreader=new ConfigReader(new File(p.getDataFolder()+"/dungeons/"+eworldname, "config.yml")); - return confreader.invitedPlayer.contains(player.toLowerCase()); + DConfig config=new DConfig(new File(p.getDataFolder()+"/dungeons/"+eworldname, "config.yml")); + return config.invitedPlayers.contains(player.toLowerCase()); } } diff --git a/src/com/dre/dungeonsxl/MainConfig.java b/src/com/dre/dungeonsxl/MainConfig.java new file mode 100644 index 00000000..163850f8 --- /dev/null +++ b/src/com/dre/dungeonsxl/MainConfig.java @@ -0,0 +1,58 @@ +package com.dre.dungeonsxl; + +import java.io.File; + +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; + +public class MainConfig { + + public String language = "de"; + public boolean economyActivated = false; + + /* Tutorial */ + public boolean tutorialActivated = false; + public String tutorialDungeon = "tutorial"; + public String tutorialStartGroup = "default"; + public String tutorialEndGroup = "player"; + + /* Default Dungeon Settings */ + public DConfig defaultDungeon; + + public MainConfig(File file){ + FileConfiguration configFile = YamlConfiguration.loadConfiguration(file); + + /* Main Config */ + if(configFile.contains("language")){ + this.language = configFile.getString("language"); + } + + if(configFile.contains("economyActivated")){ + this.economyActivated = configFile.getBoolean("economyActivated"); + } + + if(configFile.contains("tutorial.activated")){ + this.tutorialActivated = configFile.getBoolean("tutorial.activated"); + } + + if(configFile.contains("tutorial.dungeon")){ + this.tutorialDungeon = configFile.getString("tutorial.dungeon"); + } + + if(configFile.contains("tutorial.startgroup")){ + this.tutorialStartGroup = configFile.getString("tutorial.startgroup"); + } + + if(configFile.contains("tutorial.endgroup")){ + this.tutorialEndGroup = configFile.getString("tutorial.endgroup"); + } + + /* Default Dungeon Config */ + ConfigurationSection configSetion = configFile.getConfigurationSection("default"); + if(configSetion!=null){ + defaultDungeon = new DConfig(configSetion); + } + + } +} diff --git a/src/com/dre/dungeonsxl/P.java b/src/com/dre/dungeonsxl/P.java index a11699f9..46e02431 100644 --- a/src/com/dre/dungeonsxl/P.java +++ b/src/com/dre/dungeonsxl/P.java @@ -42,32 +42,27 @@ public class P extends JavaPlugin{ private static Listener blocklistener; //Main Config Reader - public ConfigReader mainConfig; + public MainConfig mainConfig; //Language Reader public LanguageReader language; - //Tutorial - public String tutorialDungeon; - public String tutorialStartGroup; - public String tutorialEndGroup; - //Chatspyer public CopyOnWriteArrayList chatSpyer=new CopyOnWriteArrayList(); @Override public void onEnable(){ - p=this; + p = this; //Commands getCommand("dungeonsxl").setExecutor(new CommandListener()); //Load Config - mainConfig=new ConfigReader(new File(p.getDataFolder(), "config.yml")); + mainConfig=new MainConfig(new File(p.getDataFolder(), "config.yml")); //Load Language - language = new LanguageReader(new File(p.getDataFolder(), "languages/de.yml")); + language = new LanguageReader(new File(p.getDataFolder(), "languages/"+mainConfig.language+".yml")); //Init Classes new DCommandRoot(); @@ -79,9 +74,9 @@ public class P extends JavaPlugin{ this.setupPermissions(); //Listener - entitylistener=new EntityListener(); - playerlistener=new PlayerListener(); - blocklistener=new BlockListener(); + entitylistener = new EntityListener(); + playerlistener = new PlayerListener(); + blocklistener = new BlockListener(); Bukkit.getServer().getPluginManager().registerEvents(entitylistener,this); Bukkit.getServer().getPluginManager().registerEvents(playerlistener,this); @@ -122,29 +117,31 @@ public class P extends JavaPlugin{ DPlayer.update(true); //Tutorial Mode - for(Player player:p.getServer().getOnlinePlayers()){ - if(DPlayer.get(player)==null){ - if(p.tutorialDungeon!=null && p.tutorialStartGroup!=null && p.tutorialEndGroup!=null){ - for(String group:p.permission.getPlayerGroups(player)){ - if(p.tutorialStartGroup.equalsIgnoreCase(group)){ - DGroup dgroup=new DGroup(player, p.tutorialDungeon); - if(dgroup.gworld==null){ - dgroup.gworld=GameWorld.load(DGroup.get(player).dungeonname); - dgroup.gworld.isTutorial=true; - } - if(dgroup.gworld!=null){ - if(dgroup.gworld.locLobby==null){ - new DPlayer(player,dgroup.gworld.world,dgroup.gworld.world.getSpawnLocation(), false); - }else{ - new DPlayer(player,dgroup.gworld.world,dgroup.gworld.locLobby, false); - } - }else{ - p.msg(player,p.language.get("Error_TutorialNotExist")); - } - } - } - } - } + if(p.mainConfig.tutorialActivated){ + for(Player player:p.getServer().getOnlinePlayers()){ + if(DPlayer.get(player)==null){ + if(p.mainConfig.tutorialDungeon!=null && p.mainConfig.tutorialStartGroup!=null && p.mainConfig.tutorialEndGroup!=null){ + for(String group:p.permission.getPlayerGroups(player)){ + if(p.mainConfig.tutorialStartGroup.equalsIgnoreCase(group)){ + DGroup dgroup=new DGroup(player, p.mainConfig.tutorialDungeon); + if(dgroup.gworld==null){ + dgroup.gworld=GameWorld.load(DGroup.get(player).dungeonname); + dgroup.gworld.isTutorial=true; + } + if(dgroup.gworld!=null){ + if(dgroup.gworld.locLobby==null){ + new DPlayer(player,dgroup.gworld.world,dgroup.gworld.world.getSpawnLocation(), false); + }else{ + new DPlayer(player,dgroup.gworld.world,dgroup.gworld.locLobby, false); + } + }else{ + p.msg(player,p.language.get("Error_TutorialNotExist")); + } + } + } + } + } + } } } }, 0L, 20L); diff --git a/src/com/dre/dungeonsxl/commands/CMDMsg.java b/src/com/dre/dungeonsxl/commands/CMDMsg.java index 954153ea..504ba289 100644 --- a/src/com/dre/dungeonsxl/commands/CMDMsg.java +++ b/src/com/dre/dungeonsxl/commands/CMDMsg.java @@ -4,7 +4,7 @@ import java.io.File; import org.bukkit.ChatColor; import org.bukkit.entity.Player; -import com.dre.dungeonsxl.ConfigReader; +import com.dre.dungeonsxl.DConfig; import com.dre.dungeonsxl.EditWorld; public class CMDMsg extends DCommand{ @@ -25,7 +25,7 @@ public class CMDMsg extends DCommand{ try{ int id=Integer.parseInt(args[1]); - ConfigReader confreader=new ConfigReader(new File(p.getDataFolder()+"/dungeons/"+eworld.dungeonname, "config.yml")); + DConfig confreader = new DConfig(new File(p.getDataFolder()+"/dungeons/"+eworld.dungeonname, "config.yml")); if(args.length==2){ String msg=confreader.msgs.get(id); diff --git a/src/com/dre/dungeonsxl/game/GameMessage.java b/src/com/dre/dungeonsxl/game/GameMessage.java index a0d03e5d..d1901c6e 100644 --- a/src/com/dre/dungeonsxl/game/GameMessage.java +++ b/src/com/dre/dungeonsxl/game/GameMessage.java @@ -20,7 +20,7 @@ public class GameMessage { public GameMessage(Block block, int msgid,GameWorld gworld,int radius){ this.block=block; - this.msg=gworld.confReader.getMsg(msgid); + this.msg=gworld.config.getMsg(msgid); this.gworld=gworld; this.radius=radius; diff --git a/src/com/dre/dungeonsxl/game/GameWorld.java b/src/com/dre/dungeonsxl/game/GameWorld.java index c096a768..91c11928 100644 --- a/src/com/dre/dungeonsxl/game/GameWorld.java +++ b/src/com/dre/dungeonsxl/game/GameWorld.java @@ -22,8 +22,8 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Spider; -import com.dre.dungeonsxl.ConfigReader; import com.dre.dungeonsxl.DClass; +import com.dre.dungeonsxl.DConfig; import com.dre.dungeonsxl.DGSign; import com.dre.dungeonsxl.DPlayer; import com.dre.dungeonsxl.P; @@ -50,7 +50,7 @@ public class GameWorld { public CopyOnWriteArrayList signClass=new CopyOnWriteArrayList(); public CopyOnWriteArrayList dmobs = new CopyOnWriteArrayList(); public CopyOnWriteArrayList gchests = new CopyOnWriteArrayList(); - public ConfigReader confReader; + public DConfig config; public GameWorld(){ gworlds.add(this); @@ -110,13 +110,13 @@ public class GameWorld { sign.update(); } if(lines[1].equalsIgnoreCase("classes")){ - if(!confReader.isLobbyDisabled){ + if(!config.isLobbyDisabled){ int[] direction=DGSign.getDirection(block.getData()); int directionX=direction[0]; int directionZ=direction[1]; int xx=0,zz=0; - for(DClass dclass:this.confReader.getClasses()){ + for(DClass dclass:this.config.getClasses()){ //Check existing signs boolean isContinued=true; @@ -279,9 +279,9 @@ public class GameWorld { File dungeonFolder=new File(p.getDataFolder()+"/dungeons/"+dungeon); if(dungeonFolder.isDirectory()){ - ConfigReader confReader=new ConfigReader(new File(p.getDataFolder()+"/dungeons/"+dungeon, "config.yml")); + DConfig config=new DConfig(new File(p.getDataFolder()+"/dungeons/"+dungeon, "config.yml")); - if(confReader.timeToNextPlay!=0){ + if(config.timeToNextPlay!=0){ //read PlayerConfig File file=new File(p.getDataFolder()+"/dungeons/"+dungeon, "players.yml"); @@ -298,7 +298,7 @@ public class GameWorld { if(playerConfig.contains(player.getName())){ Long time=playerConfig.getLong(player.getName()); - if(time+(confReader.timeToNextPlay*1000*60*60)>System.currentTimeMillis()){ + if(time+(config.timeToNextPlay*1000*60*60)>System.currentTimeMillis()){ return false; } } @@ -330,10 +330,10 @@ public class GameWorld { //Config einlesen - gworld.confReader=new ConfigReader(new File(p.getDataFolder()+"/dungeons/"+gworld.dungeonname, "config.yml")); + gworld.config = new DConfig(new File(p.getDataFolder()+"/dungeons/"+gworld.dungeonname, "config.yml")); //Secure Objects - gworld.secureobjects=gworld.confReader.secureobjects; + gworld.secureobjects=gworld.config.secureObjects; //World p.copyDirectory(file,new File("DXL_Game_"+gworld.id)); diff --git a/src/com/dre/dungeonsxl/listener/PlayerListener.java b/src/com/dre/dungeonsxl/listener/PlayerListener.java index fca6e7f8..b91c9e3b 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.confReader.secureobjects){ + for(Material material:gworld.config.secureObjects){ if(material==event.getItemDrop().getItemStack().getType()){ event.setCancelled(true); p.msg(player,p.language.get("Error_Drop"));