Added new config system

This commit is contained in:
Grafe 2013-01-29 00:10:15 +01:00
parent e3936cd282
commit bf34312f30
13 changed files with 296 additions and 203 deletions

View File

@ -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<DClass> dClasses = new CopyOnWriteArrayList<DClass>();
public Map<Integer,String> msgs = new HashMap<Integer,String>();
private Map<Integer,String> msgs = new HashMap<Integer,String>();
public CopyOnWriteArrayList<String> invitedPlayers = new CopyOnWriteArrayList<String>();
public CopyOnWriteArrayList<Material> secureObjects = new CopyOnWriteArrayList<Material>();
private CopyOnWriteArrayList<String> invitedPlayers = new CopyOnWriteArrayList<String>();
private CopyOnWriteArrayList<Material> secureObjects = new CopyOnWriteArrayList<Material>();
public boolean isLobbyDisabled = false;
public int timeToNextPlay = 0;
public int timeToNextLoot = 0;
private boolean isLobbyDisabled = false;
private int timeToNextPlay = 0;
private 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<DMobType> mobTypes = new HashSet<DMobType>();
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<DClass> 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<String> getInvitedPlayers() {
CopyOnWriteArrayList<String> tmpInvitedPlayers = new CopyOnWriteArrayList<String>();
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<Material> getSecureObjects() {
CopyOnWriteArrayList<Material> tmpSecureObjects = new CopyOnWriteArrayList<Material>();
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<DMobType> getMobTypes() {
return mobTypes;
}
}

View File

@ -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()));
}
}
}

View File

@ -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<DMobType> mobTypes = new HashSet<DMobType>();
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);
public static Set<DMobType> load(ConfigurationSection configFile){
Set<DMobType> set = new HashSet<DMobType>();
if(configFile!=null){
//Read Mobs
for(String mobName:configFile.getKeys(false)){
EntityType type=EntityType.fromName(configFile.getString(mobName+".Type"));
//Read Mobs
for(String mobName:configFile.getKeys(false)){
EntityType type=EntityType.fromName(configFile.getString(mobName+".Type"));
if (type!=null) {
DMobType mobType=new DMobType(mobName, type);
set.add(mobType);
if (type!=null) {
DMobType mobType=new DMobType(mobName, type);
//Load MaxHealth
if(configFile.contains(mobName+".MaxHealth")){
mobType.maxHealth=configFile.getInt(mobName+".MaxHealth");
}
//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();
}
//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+".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+".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+".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();
}
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");
}
//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");
}
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;
//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;
/* 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"));
}
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();
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);
/* 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 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));
}
/* 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");
}
/* 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);
/* 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");
//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")));
}
} 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<DMobType> 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;
}
}

View File

@ -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());
}
}
}

View File

@ -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;
}

View File

@ -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());
}
}

View File

@ -57,6 +57,7 @@ public class MainConfig {
ConfigurationSection configSetion = configFile.getConfigurationSection("default");
if(configSetion!=null){
defaultDungeon = new DConfig(configSetion);
DConfig.mainConfig = defaultDungeon;
}
}

View File

@ -66,10 +66,13 @@ 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();
}

View File

@ -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"));

View File

@ -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"));
}
}

View File

@ -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));

View File

@ -39,52 +39,53 @@ public class MobSpawner {
public void update(){
World world=this.block.getWorld();
GameWorld gworld = GameWorld.get(world);
if(gworld != null){
for(Player player:world.getPlayers()){
if(player.getWorld()==world){
if(player.getLocation().distance(this.block.getLocation())<this.radius){
if(this.interval<=0){
for(Player player:world.getPlayers()){
if(player.getWorld()==world){
if(player.getLocation().distance(this.block.getLocation())<this.radius){
if(this.interval<=0){
//Check normal mobs
if(EntityType.fromName(this.mob)!=null){
if(EntityType.fromName(this.mob).isAlive()){
LivingEntity entity=(LivingEntity)world.spawnEntity(this.block.getLocation(), EntityType.fromName(this.mob));
//Check normal mobs
if(EntityType.fromName(this.mob)!=null){
if(EntityType.fromName(this.mob).isAlive()){
LivingEntity entity=(LivingEntity)world.spawnEntity(this.block.getLocation(), EntityType.fromName(this.mob));
//Add Bow to normal Skeletons
if(entity.getType() == EntityType.SKELETON){
Skeleton skeleton = (Skeleton) entity;
if(skeleton.getSkeletonType()==SkeletonType.NORMAL){
skeleton.getEquipment().setItemInHand(new ItemStack(Material.BOW));
//Add Bow to normal Skeletons
if(entity.getType() == EntityType.SKELETON){
Skeleton skeleton = (Skeleton) entity;
if(skeleton.getSkeletonType()==SkeletonType.NORMAL){
skeleton.getEquipment().setItemInHand(new ItemStack(Material.BOW));
}
}
new DMob(entity,this.live,GameWorld.get(world),null);
}
new DMob(entity,this.live,GameWorld.get(world),null);
}
}
//Check custom mobs
DMobType mobType = DMobType.get(this.mob);
//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);
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

View File

@ -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();