From b5d4efae67be23bfcb528915fa73008c60d5f9af Mon Sep 17 00:00:00 2001 From: Frank Baumann Date: Mon, 24 Sep 2012 16:34:45 +0200 Subject: [PATCH] First Commit --- DungeonsXL/.classpath | 9 + DungeonsXL/.project | 17 + .../.settings/org.eclipse.jdt.core.prefs | 12 + DungeonsXL/plugin.yml | 9 + .../src/com/dre/dungeonsxl/ConfigReader.java | 189 ++++++ DungeonsXL/src/com/dre/dungeonsxl/DClass.java | 25 + DungeonsXL/src/com/dre/dungeonsxl/DGSign.java | 341 +++++++++++ DungeonsXL/src/com/dre/dungeonsxl/DGroup.java | 78 +++ .../com/dre/dungeonsxl/DOfflinePlayer.java | 45 ++ .../src/com/dre/dungeonsxl/DPlayer.java | 537 ++++++++++++++++++ .../src/com/dre/dungeonsxl/DPortal.java | 200 +++++++ .../src/com/dre/dungeonsxl/DungeonsXL.java | 419 ++++++++++++++ .../src/com/dre/dungeonsxl/EditWorld.java | 289 ++++++++++ .../src/com/dre/dungeonsxl/LeaveSign.java | 110 ++++ .../com/dre/dungeonsxl/commands/CMDChat.java | 33 ++ .../dre/dungeonsxl/commands/CMDChatSpy.java | 26 + .../dre/dungeonsxl/commands/CMDCreate.java | 53 ++ .../com/dre/dungeonsxl/commands/CMDEdit.java | 51 ++ .../com/dre/dungeonsxl/commands/CMDHelp.java | 49 ++ .../dre/dungeonsxl/commands/CMDInvite.java | 25 + .../com/dre/dungeonsxl/commands/CMDLeave.java | 42 ++ .../com/dre/dungeonsxl/commands/CMDList.java | 30 + .../com/dre/dungeonsxl/commands/CMDMsg.java | 78 +++ .../dre/dungeonsxl/commands/CMDPortal.java | 39 ++ .../com/dre/dungeonsxl/commands/CMDSave.java | 30 + .../com/dre/dungeonsxl/commands/CMDTest.java | 85 +++ .../dre/dungeonsxl/commands/CMDUninvite.java | 25 + .../com/dre/dungeonsxl/commands/DCommand.java | 43 ++ .../dre/dungeonsxl/commands/DCommandRoot.java | 46 ++ .../src/com/dre/dungeonsxl/game/DMob.java | 54 ++ .../dre/dungeonsxl/game/GameCheckpoint.java | 50 ++ .../com/dre/dungeonsxl/game/GameChest.java | 82 +++ .../com/dre/dungeonsxl/game/GameMessage.java | 49 ++ .../com/dre/dungeonsxl/game/GameWorld.java | 397 +++++++++++++ .../com/dre/dungeonsxl/game/MobSpawner.java | 69 +++ .../dungeonsxl/listener/BlockListener.java | 174 ++++++ .../dungeonsxl/listener/CommandListener.java | 51 ++ .../dungeonsxl/listener/EntityListener.java | 221 +++++++ .../dungeonsxl/listener/PlayerListener.java | 337 +++++++++++ DungeonsXL/worldconfig.yml | 56 ++ 40 files changed, 4475 insertions(+) create mode 100644 DungeonsXL/.classpath create mode 100644 DungeonsXL/.project create mode 100644 DungeonsXL/.settings/org.eclipse.jdt.core.prefs create mode 100644 DungeonsXL/plugin.yml create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/ConfigReader.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/DClass.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/DGSign.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/DGroup.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/DOfflinePlayer.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/DPlayer.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/DPortal.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/DungeonsXL.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/EditWorld.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/LeaveSign.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/commands/CMDChat.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/commands/CMDChatSpy.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/commands/CMDCreate.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/commands/CMDEdit.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/commands/CMDHelp.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/commands/CMDInvite.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/commands/CMDLeave.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/commands/CMDList.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/commands/CMDMsg.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/commands/CMDPortal.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/commands/CMDSave.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/commands/CMDTest.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/commands/CMDUninvite.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/commands/DCommand.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/commands/DCommandRoot.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/game/DMob.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/game/GameCheckpoint.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/game/GameChest.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/game/GameMessage.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/game/GameWorld.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/game/MobSpawner.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/listener/BlockListener.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/listener/CommandListener.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/listener/EntityListener.java create mode 100644 DungeonsXL/src/com/dre/dungeonsxl/listener/PlayerListener.java create mode 100644 DungeonsXL/worldconfig.yml diff --git a/DungeonsXL/.classpath b/DungeonsXL/.classpath new file mode 100644 index 00000000..3673157d --- /dev/null +++ b/DungeonsXL/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/DungeonsXL/.project b/DungeonsXL/.project new file mode 100644 index 00000000..43105bb1 --- /dev/null +++ b/DungeonsXL/.project @@ -0,0 +1,17 @@ + + + DungeonsXL + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/DungeonsXL/.settings/org.eclipse.jdt.core.prefs b/DungeonsXL/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..44df9613 --- /dev/null +++ b/DungeonsXL/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +#Tue Apr 24 15:20:11 CEST 2012 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/DungeonsXL/plugin.yml b/DungeonsXL/plugin.yml new file mode 100644 index 00000000..b59fbda1 --- /dev/null +++ b/DungeonsXL/plugin.yml @@ -0,0 +1,9 @@ +name: DungeonsXL +version: 2.8.5 +main: com.dre.dungeonsxl.DungeonsXL +authors: [Frank Baumann] +softdepend: [Vault] +commands: + dungeonsxl: + description: Reference command for DungeonsXL. + aliases: [dxl,dungeon] \ No newline at end of file diff --git a/DungeonsXL/src/com/dre/dungeonsxl/ConfigReader.java b/DungeonsXL/src/com/dre/dungeonsxl/ConfigReader.java new file mode 100644 index 00000000..b6875941 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/ConfigReader.java @@ -0,0 +1,189 @@ +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.concurrent.CopyOnWriteArrayList; + +import org.bukkit.Material; +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 DungeonsXL p=DungeonsXL.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 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 + id=0; + do{ + id++; + preString="message."+id; + if(configFile.contains(preString)){ + this.msgs.put(id,configFile.getString(preString)); + } + }while(configFile.contains(preString)); + + //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"); + } + + } + + 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 { + p.log("SAVE"+this.file); + 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/DungeonsXL/src/com/dre/dungeonsxl/DClass.java b/DungeonsXL/src/com/dre/dungeonsxl/DClass.java new file mode 100644 index 00000000..a4f271eb --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/DClass.java @@ -0,0 +1,25 @@ +package com.dre.dungeonsxl; + +import java.util.concurrent.CopyOnWriteArrayList; + +import org.bukkit.inventory.ItemStack; + +public class DClass { + + + //Variables + public CopyOnWriteArrayList items=new CopyOnWriteArrayList(); + public String name; + public boolean hasDog; + + public DClass(String name,CopyOnWriteArrayList items,boolean hasDog){ + this.items=items; + this.name=name; + this.hasDog=hasDog; + } + + + + + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/DGSign.java b/DungeonsXL/src/com/dre/dungeonsxl/DGSign.java new file mode 100644 index 00000000..1c8b5a23 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/DGSign.java @@ -0,0 +1,341 @@ +package com.dre.dungeonsxl; + +import java.io.File; +import java.util.concurrent.CopyOnWriteArrayList; + +import org.bukkit.ChatColor; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.Sign; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +import com.dre.dungeonsxl.game.GameWorld; + +public class DGSign { + public static CopyOnWriteArrayList dgsigns=new CopyOnWriteArrayList(); + + //Sign Labels + public static String strIsPlaying=ChatColor.DARK_RED + "Is Playing"; + public static String strFull=ChatColor.DARK_RED + "Full"; + public static String strJoinGrp=ChatColor.DARK_GREEN + "Join Group"; + public static String strNewGrp=ChatColor.DARK_GREEN + "New Group"; + + //Variables + public DGroup[] dgroups; + public String dungeonName; + public int maxPlayersPerGroup; + public Block startSign; + public int directionX=0,directionZ=0; + public int verticalSigns; + + public DGSign(Block startSign,String dungeonName, int maxGroups, int maxPlayersPerGroup){ + dgsigns.add(this); + + this.startSign=startSign; + this.dungeonName=dungeonName; + this.dgroups=new DGroup[maxGroups]; + this.maxPlayersPerGroup=maxPlayersPerGroup; + this.verticalSigns=(int)Math.ceil((float)(1+maxPlayersPerGroup)/4); + + int[] direction=getDirection(this.startSign.getData()); + this.directionX=direction[0]; + this.directionZ=direction[1]; + + this.update(); + } + + public void update(){ + int i = 0; + for(DGroup dgroup:this.dgroups){ + if((this.startSign.getRelative(i*directionX, 0, i*directionZ).getState() instanceof Sign)){ + Sign sign = (Sign) this.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.players.size()>=this.maxPlayersPerGroup){ + sign.setLine(0, strFull); + }else{ + sign.setLine(0, strJoinGrp); + } + int j=1; + Sign rowSign=sign; + for(Player player:dgroup.players){ + 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++; + } + } + + + //Static + + public static DGSign tryToCreate(Block startSign,String dungeonName, int maxGroups, int maxPlayersPerGroup){ + World world=startSign.getWorld(); + int direction=startSign.getData(); + int x=startSign.getX(),y=startSign.getY(),z=startSign.getZ(); + + int verticalSigns=(int)Math.ceil((float)(1+maxPlayersPerGroup)/4); + + CopyOnWriteArrayList changeBlocks=new CopyOnWriteArrayList(); + + int xx,yy,zz; + switch(direction){ + case 2: + zz=z; + for(yy=y;yy>y-verticalSigns;yy--){ + for(xx=x;xx>x-maxGroups;xx--){ + Block block=world.getBlockAt(xx,yy,zz); + if(block.getTypeId()!=0 && block.getTypeId()!=68){ + return null; + } + if(block.getRelative(0, 0, 1).getTypeId()==0){ + return null; + } + changeBlocks.add(block); + } + } + break; + case 3: + zz=z; + for(yy=y;yy>y-verticalSigns;yy--){ + for(xx=x;xxy-verticalSigns;yy--){ + for(zz=z;zzy-verticalSigns;yy--){ + for(zz=z;zz>z-maxGroups;zz--){ + Block block=world.getBlockAt(xx,yy,zz); + if(block.getTypeId()!=0 && block.getTypeId()!=68){ + return null; + } + if(block.getRelative(-1, 0, 0).getTypeId()==0){ + return null; + } + changeBlocks.add(block); + } + } + break; + } + + for(Block block:changeBlocks){ + block.setTypeIdAndData(68, startSign.getData(), true); + } + DGSign sign=new DGSign(startSign,dungeonName,maxGroups,maxPlayersPerGroup); + + return sign; + } + + public static boolean isRelativeSign(Block block,int x,int z){ + DGSign dgsign=getSign(block.getRelative(x,0,z)); + if(dgsign!=null){ + if(x==-1 && dgsign.startSign.getData()==4) return true; + if(x==1 && dgsign.startSign.getData()==5) return true; + if(z==-1 && dgsign.startSign.getData()==2) return true; + if(z==1 && dgsign.startSign.getData()==3) return true; + } + + return false; + } + + public static DGSign getSign(Block block){ + if(block.getTypeId()==68){ + int x=block.getX(),y=block.getY(),z=block.getZ(); + for(DGSign dgsign:dgsigns){ + 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(xsx1) continue;}else if(sx1sx2 || xsy2){if(ysy1) continue;}else{if(y!=sy1) continue;} + if(sz1>sz2){if(zsz1) continue;}else if(sz1sz2 || z dgroups=new CopyOnWriteArrayList(); + + //Variables + public CopyOnWriteArrayList players=new CopyOnWriteArrayList(); + public String dungeonname; + public GameWorld gworld; + public boolean isPlaying; + + + public DGroup(Player player, String dungeonname){ + dgroups.add(this); + + this.players.add(player); + this.isPlaying=false; + this.dungeonname=dungeonname; + } + + public void removePlayer(Player player) { + this.players.remove(player); + DGSign.updatePerGroup(this); + } + + public boolean isEmpty() { + return this.players.isEmpty(); + } + + public void remove() { + dgroups.remove(this); + DGSign.updatePerGroup(this); + } + + public void startGame(){ + this.isPlaying=true; + gworld.startGame(); + for(Player player:players){ + DPlayer dplayer=DPlayer.get(player); + dplayer.respawn(); + } + DGSign.updatePerGroup(this); + + } + + //Statics + public static DGroup get(Player player){ + for(DGroup dgroup:dgroups){ + if(dgroup.players.contains(player)){ + return dgroup; + } + } + return null; + } + + public static DGroup get(GameWorld gworld){ + for(DGroup dgroup:dgroups){ + if(dgroup.gworld==gworld){ + return dgroup; + } + } + return null; + } + + public static void leaveGroup(Player player){ + for(DGroup dgroup:dgroups){ + if(dgroup.players.contains(player)){ + dgroup.players.remove(player); + } + } + } + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/DOfflinePlayer.java b/DungeonsXL/src/com/dre/dungeonsxl/DOfflinePlayer.java new file mode 100644 index 00000000..e5204015 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/DOfflinePlayer.java @@ -0,0 +1,45 @@ +package com.dre.dungeonsxl; + +import java.util.concurrent.CopyOnWriteArrayList; + +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class DOfflinePlayer { + public static CopyOnWriteArrayList players=new CopyOnWriteArrayList(); + + //Variables + public String name; + public Location oldLocation; + public ItemStack[] oldInventory; + public ItemStack[] oldArmor; + public int oldLvl; + public int oldExp; + public int oldHealth; + public int oldFoodLevel; + public GameMode oldGamemode; + + public DOfflinePlayer(){ + players.add(this); + } + + //Static + public static void check(Player player){ + for(DOfflinePlayer offplayer:players){ + if(offplayer.name.equalsIgnoreCase(player.getName())){ + players.remove(offplayer); + + player.teleport(offplayer.oldLocation); + player.getInventory().setContents(offplayer.oldInventory); + player.getInventory().setArmorContents(offplayer.oldArmor); + player.setTotalExperience(offplayer.oldExp); + player.setLevel(offplayer.oldLvl); + player.setHealth(offplayer.oldHealth); + player.setFoodLevel(offplayer.oldFoodLevel); + player.setGameMode(offplayer.oldGamemode); + } + } + } +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/DPlayer.java b/DungeonsXL/src/com/dre/dungeonsxl/DPlayer.java new file mode 100644 index 00000000..2e24d39f --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/DPlayer.java @@ -0,0 +1,537 @@ +package com.dre.dungeonsxl; + +import java.io.File; +import java.io.IOException; +import java.util.concurrent.CopyOnWriteArrayList; + +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wolf; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import com.dre.dungeonsxl.game.GameCheckpoint; +import com.dre.dungeonsxl.game.GameWorld; + +public class DPlayer { + public DungeonsXL p=DungeonsXL.p; + + public static CopyOnWriteArrayList players=new CopyOnWriteArrayList(); + + //Variables + public Player player; + public World world; + + public DPlayer oldDPlayer=null; + public int isinTestMode=0; + + public Location oldLocation; + public ItemStack[] oldInventory; + public ItemStack[] oldArmor; + public int oldLvl; + public int oldExp; + public int oldHealth; + public int oldFoodLevel; + public GameMode oldGamemode; + + public boolean isEditing; + public boolean isInWorldChat=false; + public boolean isReady=false; + public boolean isFinished=false; + + public DClass dclass; + public GameCheckpoint checkpoint; + public CopyOnWriteArrayList classItems=new CopyOnWriteArrayList(); + public Wolf wolf; + public int wolfRespawnTime=30; + public int offlineTime; + public int invItemInHand; + public CopyOnWriteArrayList respawnInventory=new CopyOnWriteArrayList(); + + public Inventory treasureInv = DungeonsXL.p.getServer().createInventory(player, 45, "Belohnungen"); + + public DPlayer(Player player, World world, Location teleport, boolean isEditing){ + players.add(this); + this.player=player; + this.world=world; + + this.oldLocation=player.getLocation(); + this.oldInventory=player.getInventory().getContents(); + this.oldArmor=player.getInventory().getArmorContents(); + this.oldExp=player.getTotalExperience(); + this.oldHealth=player.getHealth(); + this.oldFoodLevel=player.getFoodLevel(); + this.oldGamemode=player.getGameMode(); + this.oldLvl=player.getLevel(); + + this.player.teleport(teleport); + this.player.getInventory().clear(); + this.player.getInventory().setArmorContents(null); + this.player.setTotalExperience(0); + this.player.setHealth(20); + this.player.setFoodLevel(20); + this.isEditing=isEditing; + if(isEditing) this.player.setGameMode(GameMode.CREATIVE); else this.player.setGameMode(GameMode.SURVIVAL); + + if(!isEditing){ + if(GameWorld.get(world).confReader.isLobbyDisabled){ + this.ready(); + } + } + } + + public void goOffline(){ + offlineTime=1; + } + + public void leave(){ + remove(this); + + if(this.oldDPlayer!=null){ + this.oldDPlayer.isinTestMode=0; + } + + this.player.teleport(this.oldLocation); + this.player.getInventory().setContents(this.oldInventory); + this.player.getInventory().setArmorContents(this.oldArmor); + this.player.setTotalExperience(this.oldExp); + this.player.setLevel(this.oldLvl); + this.player.setHealth(oldHealth); + this.player.setFoodLevel(oldFoodLevel); + this.player.setGameMode(oldGamemode); + + + if(this.isEditing){ + EditWorld eworld=EditWorld.get(this.world); + if(eworld!=null){ + eworld.save(); + } + }else{ + GameWorld gworld=GameWorld.get(this.world); + DGroup dgroup=DGroup.get(this.player); + if(dgroup!=null){ + dgroup.removePlayer(this.player); + if(dgroup.isEmpty()){ + dgroup.remove(); + } + } + + //Belohnung + if(this.oldDPlayer==null&&this.isinTestMode!=2){//Nur wenn man nicht am Testen ist + if(isFinished){ + this.addTreasure(); + + //Set Time + File file=new File(p.getDataFolder()+"/dungeons/"+gworld.dungeonname, "players.yml"); + + if(!file.exists()){ + try { + file.createNewFile(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file); + + playerConfig.set(player.getName(), System.currentTimeMillis()); + + try { + playerConfig.save(file); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + //Tutorial Permissions + if(gworld.isTutorial){ + p.permission.playerAddGroup(this.player, p.tutorialEndGroup); + p.permission.playerRemoveGroup(this.player, p.tutorialStartGroup); + } + } + } + + //Give Secure Objects other Players + if(!dgroup.isEmpty()){ + int i=0; + Player groupplayer; + do{ + groupplayer=dgroup.players.get(i); + if(groupplayer!=null){ + for(ItemStack istack:this.player.getInventory()){ + if(istack!=null){ + if(gworld.secureobjects.contains(istack.getType())){ + groupplayer.getInventory().addItem(istack); + } + } + } + DungeonsXL.p.updateInventory(groupplayer); + } + i++; + }while(groupplayer==null); + + } + } + + + + + + + DungeonsXL.p.updateInventory(this.player); + } + + public void ready(){ + this.isReady=true; + + DGroup dgroup=DGroup.get(this.player); + if(!dgroup.isPlaying){ + if(dgroup!=null){ + for(Player player:dgroup.players){ + DPlayer dplayer=get(player); + if(!dplayer.isReady){ + return; + } + } + } + + + dgroup.startGame(); + }else{ + this.respawn(); + } + } + + public void respawn(){ + DGroup dgroup=DGroup.get(this.player); + if(this.checkpoint==null){ + this.player.teleport(dgroup.gworld.locStart); + }else{ + this.player.teleport(this.checkpoint.location); + } + if(this.wolf!=null){ + this.wolf.teleport(this.player); + } + + //Respawn Items + for(ItemStack istack:this.respawnInventory){ + if(istack!=null){ + this.player.getInventory().addItem(istack); + } + } + this.respawnInventory.clear(); + DungeonsXL.p.updateInventory(this.player); + } + + public void finish(){ + DungeonsXL.p.msg(this.player, ChatColor.YELLOW+"Du hast den Dungeon erfolgreich beendet!"); + this.isFinished=true; + + + DGroup dgroup=DGroup.get(this.player); + if(dgroup.isPlaying){ + if(dgroup!=null){ + for(Player player:dgroup.players){ + DPlayer dplayer=get(player); + if(!dplayer.isFinished){ + DungeonsXL.p.msg(this.player, ChatColor.YELLOW+"Noch auf Mitspieler warten..."); + return; + } + } + + + + for(Player player:dgroup.players){ + DPlayer dplayer=get(player); + dplayer.leave(); + } + } + } + + + + } + + public void msg(String msg){ + if(this.isEditing){ + EditWorld eworld=EditWorld.get(this.world); + eworld.msg(msg); + for(Player player:p.chatSpyer){ + if(!eworld.world.getPlayers().contains(player)){ + p.msg(player, ChatColor.GREEN+"[Chatspy] "+ChatColor.WHITE+msg); + } + } + + }else{ + GameWorld gworld=GameWorld.get(this.world); + gworld.msg(msg); + for(Player player:p.chatSpyer){ + if(!gworld.world.getPlayers().contains(player)){ + p.msg(player, ChatColor.GREEN+"[Chatspy] "+ChatColor.WHITE+msg); + } + } + } + } + + public void setClass(String classname) { + GameWorld gworld=GameWorld.get(this.player.getWorld()); + if(gworld==null) return; + + DClass dclass=gworld.confReader.getClass(classname); + if(dclass!=null){ + if(this.dclass!=dclass){ + this.dclass=dclass; + + //Set Dog + if(this.wolf!=null){ + this.wolf.remove(); + this.wolf=null; + } + + if(dclass.hasDog){ + this.wolf=(Wolf) this.world.spawnCreature(this.player.getLocation(), EntityType.WOLF); + this.wolf.setTamed(true); + this.wolf.setOwner(this.player); + this.wolf.setHealth(this.wolf.getMaxHealth()); + } + + //Delete Inventory + this.classItems.clear(); + this.player.getInventory().clear(); + this.player.getInventory().setArmorContents(null); + player.getInventory().setItemInHand(new ItemStack(0)); + DungeonsXL.p.updateInventory(this.player); + + //Set Inventory + for(ItemStack istack:dclass.items){ + + //Leggings + if(istack.getTypeId()==300|| + istack.getTypeId()==304|| + istack.getTypeId()==308|| + istack.getTypeId()==312|| + istack.getTypeId()==316) + { + this.player.getInventory().setLeggings(istack); + } + //Helmet + else if(istack.getTypeId()==298|| + istack.getTypeId()==302|| + istack.getTypeId()==306|| + istack.getTypeId()==310|| + istack.getTypeId()==314) + { + this.player.getInventory().setHelmet(istack); + } + //Chestplate + else if(istack.getTypeId()==299|| + istack.getTypeId()==303|| + istack.getTypeId()==307|| + istack.getTypeId()==311|| + istack.getTypeId()==315) + { + this.player.getInventory().setChestplate(istack); + } + //Boots + else if(istack.getTypeId()==301|| + istack.getTypeId()==305|| + istack.getTypeId()==309|| + istack.getTypeId()==313|| + istack.getTypeId()==317) + { + this.player.getInventory().setBoots(istack); + } + + else{ + this.player.getInventory().addItem(istack); + } + + + + DungeonsXL.p.updateInventory(this.player); + } + + for(int i=0;i<36;i++){ + ItemStack istack=this.player.getInventory().getItem(i); + if(istack!=null){ + this.classItems.add(i); + } + } + + + DungeonsXL.p.updateInventory(this.player); + + } + } + } + + public void setCheckpoint(GameCheckpoint checkpoint){ + this.checkpoint=checkpoint; + } + + public void addTreasure(){ + for(ItemStack istack:this.treasureInv.getContents()){ + if(istack!=null){ + this.player.getInventory().addItem(istack); + } + } + } + //Static + public static void remove(DPlayer player){ + players.remove(player); + } + + public static DPlayer get(Player player){ + EditWorld eworld=EditWorld.get(player.getWorld()); + boolean isEditing=false; + if(eworld!=null){ + isEditing=true; + } + for(DPlayer dplayer:players){ + if(dplayer.player.equals(player)){ + if(dplayer.isEditing==isEditing){ + return dplayer; + } + } + } + return null; + } + + public static CopyOnWriteArrayList get(World world){ + CopyOnWriteArrayList dplayers=new CopyOnWriteArrayList(); + + for(DPlayer dplayer:players){ + if(dplayer.world==world){ + dplayers.add(dplayer); + } + } + + return dplayers; + } + + public static void update(boolean updateSecond){ + for(DPlayer dplayer:players){ + if(!updateSecond){ + //Check in World + if(dplayer.isinTestMode!=1){ + if(!dplayer.player.getWorld().equals(dplayer.world)){ + if(dplayer.isEditing){ + EditWorld eworld=EditWorld.get(dplayer.world); + if(eworld!=null){ + if(eworld.lobby==null){ + dplayer.player.teleport(eworld.world.getSpawnLocation()); + }else{ + dplayer.player.teleport(eworld.lobby); + } + } + }else{ + GameWorld gworld=GameWorld.get(dplayer.world); + if(gworld!=null){ + if(gworld!=null){ + + DGroup dgroup=DGroup.get(dplayer.player); + if(dplayer.checkpoint==null){ + dplayer.player.teleport(dgroup.gworld.locStart); + if(dplayer.wolf!=null){ + dplayer.wolf.teleport(dgroup.gworld.locStart); + } + }else{ + dplayer.player.teleport(dplayer.checkpoint.location); + if(dplayer.wolf!=null){ + dplayer.wolf.teleport(dplayer.checkpoint.location); + } + } + + + //Respawn Items + for(ItemStack istack:dplayer.respawnInventory){ + if(istack!=null){ + dplayer.player.getInventory().addItem(istack); + } + } + dplayer.respawnInventory.clear(); + DungeonsXL.p.updateInventory(dplayer.player); + } + } + } + } + } + }else{ + //Update Wolf + if(dplayer.wolf!=null){ + if(dplayer.wolf.isDead()){ + if(dplayer.wolfRespawnTime<=0){ + dplayer.wolf=(Wolf) dplayer.world.spawnCreature(dplayer.player.getLocation(), EntityType.WOLF); + dplayer.wolf.setTamed(true); + dplayer.wolf.setOwner(dplayer.player); + dplayer.wolfRespawnTime=30; + } + dplayer.wolfRespawnTime--; + } + } + //Update Offline Players + if(dplayer.offlineTime>0){ + dplayer.offlineTime++; + if(dplayer.offlineTime>300){ + DOfflinePlayer offplayer=new DOfflinePlayer(); + offplayer.name=dplayer.player.getName(); + offplayer.oldLocation=dplayer.oldLocation; + offplayer.oldInventory=dplayer.oldInventory; + offplayer.oldArmor=dplayer.oldArmor; + offplayer.oldExp=dplayer.oldExp; + offplayer.oldHealth=dplayer.oldHealth; + offplayer.oldFoodLevel=dplayer.oldFoodLevel; + offplayer.oldGamemode=dplayer.oldGamemode; + offplayer.oldLvl=dplayer.oldLvl; + + remove(dplayer); + + if(dplayer.isEditing){ + EditWorld eworld=EditWorld.get(dplayer.world); + if(eworld!=null){ + eworld.save(); + } + }else{ + GameWorld gworld=GameWorld.get(dplayer.world); + DGroup dgroup=DGroup.get(dplayer.player); + if(dgroup!=null){ + dgroup.removePlayer(dplayer.player); + if(dgroup.isEmpty()){ + dgroup.remove(); + gworld.delete(); + } + } + } + + } + + } + } + + //Update ClassItems + for(Integer istackplace:dplayer.classItems){ + ItemStack istack=dplayer.player.getInventory().getItem(istackplace); + + if(istack!=null){ + if(istack.getTypeId()!=0){ + if(istack.getTypeId()>255 && istack.getTypeId()<318){ + istack.setDurability((short) 0); + } + }else{ + dplayer.classItems.remove(istackplace); + } + }else{ + dplayer.classItems.remove(istackplace); + } + } + } + } + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/DPortal.java b/DungeonsXL/src/com/dre/dungeonsxl/DPortal.java new file mode 100644 index 00000000..35672fdb --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/DPortal.java @@ -0,0 +1,200 @@ +package com.dre.dungeonsxl; + +import java.util.concurrent.CopyOnWriteArrayList; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +import com.dre.dungeonsxl.game.GameWorld; + +public class DPortal { + public static DungeonsXL p=DungeonsXL.p; + + public static CopyOnWriteArrayList portals = new CopyOnWriteArrayList(); + + //Variables + public World world; + public Block block1,block2; + public Player player; + public boolean isActive; + public String type; + + + public DPortal(boolean active){ + portals.add(this); + this.isActive=active; + } + + public boolean fillwithportal(){ + if(this.block1!=null && this.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(x1y2){ycount=-1;}else if(y1z2){zcount=-1;}else if(z1x2){ + if(x3x1) continue; + }else{ + if(x3>x2 || x3y2){ + if(y3y1) continue; + }else{ + if(y3>y2 || y3z2){ + if(z3z1) continue; + }else{ + if(z3>z2 || z3 chatSpyer=new CopyOnWriteArrayList(); + + + @Override + public void onEnable(){ + p=this; + + //Commands + getCommand("dungeonsxl").setExecutor(new CommandListener()); + + //MSG + this.log(this.getDescription().getName()+" enabled!"); + + //Init Classes + new DCommandRoot(); + + //InitFolders + this.initFolders(); + + //Setup Permissions + this.setupPermissions(); + + //Listener + entitylistener=new EntityListener(); + playerlistener=new PlayerListener(); + blocklistener=new BlockListener(); + + Bukkit.getServer().getPluginManager().registerEvents(entitylistener,this); + Bukkit.getServer().getPluginManager().registerEvents(playerlistener,this); + Bukkit.getServer().getPluginManager().registerEvents(blocklistener,this); + + //Load All + this.loadAll(); + + //Load Config + mainConfig=new ConfigReader(new File(p.getDataFolder(), "config.yml")); + + // -------------------------------------------- // + // Update Sheduler + // -------------------------------------------- // + + p.getServer().getScheduler().scheduleSyncRepeatingTask(p, new Runnable() { + public void run() { + for(GameWorld gworld:GameWorld.gworlds){ + if(gworld.world.getPlayers().isEmpty()){ + if(DPlayer.get(gworld.world).isEmpty()){ + gworld.delete(); + } + } + } + for(EditWorld eworld:EditWorld.eworlds){ + if(eworld.world.getPlayers().isEmpty()){ + + eworld.delete(); + } + } + } + }, 0L, 1200L); + + p.getServer().getScheduler().scheduleSyncRepeatingTask(p, new Runnable() { + public void run() { + MobSpawner.updateAll(); + GameWorld.update(); + GameMessage.updateAll(); + GameCheckpoint.update(); + 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,ChatColor.RED+"Tutorial Dungeon existiert nicht!"); + } + } + } + } + } + } + } + }, 0L, 20L); + + p.getServer().getScheduler().scheduleSyncRepeatingTask(p, new Runnable() { + public void run() { + DPlayer.update(false); + } + }, 0L, 2L); + } + + + @Override + public void onDisable(){ + //Save + this.saveAll(); + + //MSG + this.log(this.getDescription().getName()+" disabled!"); + + //DPlayer leaves World + for(DPlayer dplayer:DPlayer.players){ + dplayer.leave(); + } + + //Delete all Data + DPortal.portals.clear(); + DGSign.dgsigns.clear(); + LeaveSign.lsigns.clear(); + + //Delete Worlds + GameWorld.deleteAll(); + EditWorld.deleteAll(); + } + + + //Init. + public void initFolders(){ + //Check Folder + File folder = new File(this.getDataFolder()+""); + if(!folder.exists()){ + folder.mkdir(); + } + + folder = new File(this.getDataFolder()+File.separator+"dungeons"); + if(!folder.exists()){ + folder.mkdir(); + } + } + + + //Permissions + public Permission permission = null; + + private Boolean setupPermissions() + { + RegisteredServiceProvider permissionProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class); + if (permissionProvider != null) { + permission = permissionProvider.getProvider(); + } + return (permission != null); + } + + public Boolean GroupEnabled(String group){ + + for(String agroup:permission.getGroups()){ + if(agroup.equalsIgnoreCase(group)){ + return true; + } + } + + return false; + } + + + //Save and Load + public void saveAll(){ + File file = new File(this.getDataFolder(), "data.yml"); + FileConfiguration configFile = new YamlConfiguration(); + + DPortal.save(configFile); + DGSign.save(configFile); + LeaveSign.save(configFile); + + try { + configFile.save(file); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + public void loadAll(){ + File file = new File(this.getDataFolder(), "data.yml"); + FileConfiguration configFile = YamlConfiguration.loadConfiguration(file); + + DPortal.load(configFile); + DGSign.load(configFile); + LeaveSign.load(configFile); + } + + + //File Control + public boolean removeDirectory(File directory) { + if (directory.isDirectory()) { + for (File f : directory.listFiles()) { + if (!removeDirectory(f)) return false; + } + } + return directory.delete(); + } + + public void copyFile(File in, File out) throws IOException { + FileChannel inChannel = new FileInputStream(in).getChannel(); + FileChannel outChannel = new FileOutputStream(out).getChannel(); + try { + inChannel.transferTo(0, inChannel.size(), outChannel); + } catch (IOException e) { + throw e; + } finally { + if (inChannel != null) + inChannel.close(); + if (outChannel != null) + outChannel.close(); + } + } + + public String[] excludedFiles={"config.yml"}; + + public void copyDirectory(File sourceLocation, File targetLocation) { + + if (sourceLocation.isDirectory()) { + + if (!targetLocation.exists()) { + targetLocation.mkdir(); + } + + String[] children = sourceLocation.list(); + for (int i = 0; i < children.length; i++) { + boolean isOk=true; + for (String excluded:excludedFiles){ + if(children[i].contains(excluded)){ + isOk=false; + break; + } + } + if(isOk){ + copyDirectory(new File(sourceLocation, children[i]), new File( + targetLocation, children[i])); + } + + } + } else { + + try { + + if (!targetLocation.getParentFile().exists()) { + + createDirectory(targetLocation.getParentFile().getAbsolutePath()); + targetLocation.createNewFile(); + + } else if (!targetLocation.exists()) { + + targetLocation.createNewFile(); + } + + InputStream in = new FileInputStream(sourceLocation); + OutputStream out = new FileOutputStream(targetLocation); + + byte[] buf = new byte[1024]; + int len; + while ((len = in.read(buf)) > 0) { + out.write(buf, 0, len); + } + in.close(); + out.close(); + + } catch (Exception e) { + + if (e.getMessage().contains("Zugriff") + || e.getMessage().contains("Access")) + DungeonsXL.p.log("Error: " + e.getMessage() + " // Access denied"); + else + DungeonsXL.p.log("Error: " + e.getMessage()); + } + } + } + + public void createDirectory(String s) { + + if (!new File(s).getParentFile().exists()) { + + createDirectory(new File(s).getParent()); + } + + new File(s).mkdir(); + } + + public void deletenotusingfiles(File directory){ + File[] files=directory.listFiles(); + for(File file:files){ + if(file.getName().equalsIgnoreCase("uid.dat")){ + file.delete(); + } + } + } + + //Misc + public void updateInventory(Player p) { + CraftPlayer c = (CraftPlayer) p; + for (int i = 0;i < 36;i++) { + int nativeindex = i; + if (i < 9) nativeindex = i + 36; + ItemStack olditem = c.getInventory().getItem(i); + net.minecraft.server.ItemStack item = null; + if (olditem != null && olditem.getType() != Material.AIR) { + item = new net.minecraft.server.ItemStack(0, 0, 0); + item.id = olditem.getTypeId(); + item.count = olditem.getAmount(); + item.b = olditem.getDurability(); + } + if(olditem != null){ + if(olditem.getEnchantments().size()==0) { + Packet103SetSlot pack = new Packet103SetSlot(0, nativeindex, item); + c.getHandle().netServerHandler.sendPacket(pack); + } + } + } + } + + //Msg + + public void msg(Player player,String msg){ + player.sendMessage(ChatColor.DARK_GREEN+"[DXL] "+ChatColor.WHITE+msg); + } + + public void msg(Player player,String msg, boolean zusatz){ + if(zusatz){ + player.sendMessage(ChatColor.DARK_GREEN+"[DXL]"+ChatColor.WHITE+msg); + }else{ + player.sendMessage(ChatColor.WHITE+msg); + } + + } + + //Misc. + + public EntityType getEntitiyType(String name){ + for(EntityType type:EntityType.values()){ + if(name.equalsIgnoreCase(type.getName())){ + return type; + } + } + + return null; + } + + // -------------------------------------------- // + // LOGGING + // -------------------------------------------- // + public void log(Object msg) + { + log(Level.INFO, msg); + } + + public void log(Level level, Object msg) + { + Logger.getLogger("Minecraft").log(level, "["+this.getDescription().getFullName()+"] "+msg); + } + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/EditWorld.java b/DungeonsXL/src/com/dre/dungeonsxl/EditWorld.java new file mode 100644 index 00000000..5d6ec63b --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/EditWorld.java @@ -0,0 +1,289 @@ +package com.dre.dungeonsxl; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.concurrent.CopyOnWriteArrayList; + +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.WorldCreator; +import org.bukkit.WorldType; +import org.bukkit.block.Block; +import org.bukkit.block.Sign; +import org.bukkit.entity.Player; + +public class EditWorld { + private static DungeonsXL p=DungeonsXL.p; + public static CopyOnWriteArrayList eworlds=new CopyOnWriteArrayList(); + + //Variables + public World world; + public String owner; + public String name; + public String dungeonname; + public int id; + public Location lobby; + public CopyOnWriteArrayList invitedPlayers=new CopyOnWriteArrayList(); + public CopyOnWriteArrayList sign=new CopyOnWriteArrayList(); + + public EditWorld(){ + eworlds.add(this); + + //ID + this.id=-1; + int i=-1; + while(this.id==-1){ + i++; + boolean exist=false; + for(EditWorld eworld:eworlds){ + if(eworld.id==i){ + exist=true; + break; + } + } + if(!exist) this.id=i; + } + + name="DXL_Edit_"+this.id; + } + + public void generate(){ + WorldCreator creator=WorldCreator.name(name); + creator.type(WorldType.FLAT); + creator.generateStructures(false); + + this.world=p.getServer().createWorld(creator); + } + + public void save(){ + this.world.save(); + p.copyDirectory(new File("DXL_Edit_"+this.id),new File("plugins/DungeonsXL/dungeons/"+this.dungeonname)); + p.deletenotusingfiles(new File("plugins/DungeonsXL/dungeons/"+this.dungeonname)); + try { + ObjectOutputStream out=new ObjectOutputStream(new FileOutputStream(new File("plugins/DungeonsXL/dungeons/"+this.dungeonname+"/DXLData.data"))); + out.writeInt(this.sign.size()); + for(Block sign:this.sign){ + out.writeInt(sign.getX()); + out.writeInt(sign.getY()); + out.writeInt(sign.getZ()); + } + out.close(); + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + //Check Configuration + /*File file=new File("plugins/DungeonsXL/dungeons/"+this.dungeonname+"/config.yml"); + if(!file.exists()){ + File copyfile=new File("plugins/DungeonsXL/config.yml"); + if(copyfile.exists()){ + try { + DungeonsXL.p.copyFile(copyfile,file); + } catch (IOException e) { + e.printStackTrace(); + } + }else{ + try { + file.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } + } + }*/ + + } + + public void checkSign(Block block){ + if((block.getState() instanceof Sign)){ + Sign sign = (Sign) block.getState(); + String[] lines=sign.getLines(); + + if(lines[1].equalsIgnoreCase("lobby")){ + this.lobby=block.getLocation(); + } + } + } + + public void delete(){ + eworlds.remove(this); + for(Player player:this.world.getPlayers()){ + DPlayer dplayer=DPlayer.get(player); + dplayer.leave(); + } + + p.getServer().unloadWorld(this.world,true); + File dir = new File("DXL_Edit_"+this.id); + p.removeDirectory(dir); + } + + //Static + public static EditWorld get(World world){ + for(EditWorld eworld:eworlds){ + if(eworld.world.equals(world)){ + return eworld; + } + } + + return null; + } + + public static EditWorld get(String name){ + for(EditWorld eworld:eworlds){ + if(eworld.name.equalsIgnoreCase(name)){ + return eworld; + } + } + + return null; + } + + public static void deleteAll(){ + for(EditWorld eworld:eworlds){ + eworlds.remove(eworld); + for(Player player:eworld.world.getPlayers()){ + DPlayer dplayer=DPlayer.get(player); + dplayer.leave(); + } + + p.getServer().unloadWorld(eworld.world,true); + File dir = new File("DXL_Edit_"+eworld.id); + p.removeDirectory(dir); + } + } + + public static EditWorld load(String name){ + for(EditWorld eworld:eworlds){ + + if(eworld.dungeonname.equalsIgnoreCase(name)){ + return eworld; + } + } + + File file=new File("plugins/DungeonsXL/dungeons/"+name); + + if(file.exists()){ + EditWorld eworld = new EditWorld(); + eworld.dungeonname=name; + //World + p.copyDirectory(file,new File("DXL_Edit_"+eworld.id)); + + eworld.world=p.getServer().createWorld(WorldCreator.name("DXL_Edit_"+eworld.id)); + + try { + ObjectInputStream os=new ObjectInputStream(new FileInputStream(new File("plugins/DungeonsXL/dungeons/"+eworld.dungeonname+"/DXLData.data"))); + int length=os.readInt(); + for(int i=0; i lsigns=new CopyOnWriteArrayList(); + + public Sign sign; + + public LeaveSign(Sign sign){ + lsigns.add(this); + + this.sign=sign; + this.setText(); + } + + public void setText(){ + this.sign.setLine(0, ChatColor.BLUE+"############"); + this.sign.setLine(1, ChatColor.DARK_GREEN+"Leave"); + this.sign.setLine(2, ""); + this.sign.setLine(3, ChatColor.BLUE+"############"); + this.sign.update(); + } + + public static boolean playerInteract(Block block, Player player) { + + LeaveSign lsign=getSign(block); + + if(lsign!=null){ + DPlayer dplayer=DPlayer.get(player); + if(dplayer!=null){ + dplayer.leave(); + return true; + }else{ + DGroup dgroup=DGroup.get(player); + if(dgroup!=null){ + dgroup.removePlayer(player); + DungeonsXL.p.msg(player,ChatColor.YELLOW+"Du hast deine Gruppe erfolgreich verlassen!"); + return true; + } + } + } + return false; + } + + public static boolean isRelativeSign(Block block,int x,int z){ + LeaveSign lsign=getSign(block.getRelative(x,0,z)); + if(lsign!=null){ + if(x==-1 && lsign.sign.getData().getData()==4) return true; + if(x==1 && lsign.sign.getData().getData()==5) return true; + if(z==-1 && lsign.sign.getData().getData()==2) return true; + if(z==1 && lsign.sign.getData().getData()==3) return true; + } + + return false; + } + + public static LeaveSign getSign(Block block) { + if(block.getTypeId()==68||block.getTypeId()==63){ + for(LeaveSign leavesign:lsigns){ + if(block.getWorld()==leavesign.sign.getWorld()){ + if(block.getLocation().distance(leavesign.sign.getBlock().getLocation())<1){ + return leavesign; + } + } + } + } + return null; + } + + //Save and Load + public static void save(FileConfiguration configFile){ + int id = 0; + for(LeaveSign lsign:lsigns){ + id++; + String preString="leavesign."+lsign.sign.getWorld().getName()+"."+id; + configFile.set(preString+".x",lsign.sign.getX()); + configFile.set(preString+".y",lsign.sign.getY()); + configFile.set(preString+".z",lsign.sign.getZ()); + } + } + + public static void load(FileConfiguration configFile) { + for(World world:DungeonsXL.p.getServer().getWorlds()){ + if(configFile.contains("leavesign."+world.getName())){ + int id=0; + String preString; + do{ + id++; + preString="leavesign."+world.getName()+"."+id+"."; + if(configFile.contains(preString)){ + Block block=world.getBlockAt(configFile.getInt(preString+".x"),configFile.getInt(preString+".y"),configFile.getInt(preString+".z")); + if(block.getState() instanceof Sign){ + Sign sign = (Sign) block.getState(); + new LeaveSign(sign); + } + } + }while(configFile.contains(preString)); + } + } + } + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDChat.java b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDChat.java new file mode 100644 index 00000000..84fb1fc1 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDChat.java @@ -0,0 +1,33 @@ +package com.dre.dungeonsxl.commands; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import com.dre.dungeonsxl.DPlayer; + +public class CMDChat extends DCommand{ + + public CMDChat(){ + this.command="chat"; + this.args=0; + this.help="/dxl chat - Ändert den Chat-Modus"; + } + + + @Override + public void onExecute(String[] args, Player player) { + DPlayer dplayer=DPlayer.get(player); + if(dplayer!=null){ + if(dplayer.isInWorldChat) { + dplayer.isInWorldChat=false; + p.msg(player,ChatColor.YELLOW+"Du bist nun im öffentlichen Chat"); + }else{ + dplayer.isInWorldChat=true; + p.msg(player,ChatColor.YELLOW+"Du bist nun im Dungeon-Chat"); + } + }else{ + p.msg(player,ChatColor.RED+"Du bist in keinem Dungeon!"); + } + } + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDChatSpy.java b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDChatSpy.java new file mode 100644 index 00000000..029a229f --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDChatSpy.java @@ -0,0 +1,26 @@ +package com.dre.dungeonsxl.commands; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +public class CMDChatSpy extends DCommand{ + public CMDChatSpy(){ + this.command="chatspy"; + this.args=0; + this.help="/dxl chatspy - Spionier den DXL-Chat"; + this.permissions="dxl.chatspy"; + } + + @Override + public void onExecute(String[] args, Player player) { + if(p.chatSpyer.contains(player)){ + p.chatSpyer.remove(player); + p.msg(player, ChatColor.GOLD+"Du hast aufgehört den DXL-Chat auszuspähen!"); + } + + else{ + p.chatSpyer.add(player); + p.msg(player, ChatColor.GOLD+"Du hast begonnen den DXL-Chat auszuspähen!"); + } + } +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDCreate.java b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDCreate.java new file mode 100644 index 00000000..76cc82ce --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDCreate.java @@ -0,0 +1,53 @@ +package com.dre.dungeonsxl.commands; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import com.dre.dungeonsxl.DPlayer; +import com.dre.dungeonsxl.EditWorld; + +public class CMDCreate extends DCommand { + + public CMDCreate(){ + this.args=1; + this.command="create"; + this.help="/dxl create - Create a new Dungeon"; + this.permissions="dxl.create"; + } + + @Override + public void onExecute(String[] args, Player player) { + String name=args[1]; + + if(DPlayer.get(player)==null){ + if(name.length()<=15){ + + //Msg create + p.log("New Dungeon: "+name); + p.log("Generate new world..."); + + //Create World + EditWorld eworld=new EditWorld(); + eworld.generate(); + eworld.dungeonname=name; + + //MSG Done + p.log("World generation finished!"); + + //Tp Player + if(eworld.lobby==null){ + new DPlayer(player,eworld.world,eworld.world.getSpawnLocation(), true); + }else{ + new DPlayer(player,eworld.world,eworld.lobby, true); + } + }else{ + p.msg(player, ChatColor.RED+"Der Name darf nicht länger sein als 15 Zeichen!"); + } + }else{ + p.msg(player, ChatColor.RED+"Du musst zuerst aus dem aktuellen Dungeon raus!"); + } + + } + + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDEdit.java b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDEdit.java new file mode 100644 index 00000000..ee8ce029 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDEdit.java @@ -0,0 +1,51 @@ +package com.dre.dungeonsxl.commands; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import com.dre.dungeonsxl.DGroup; +import com.dre.dungeonsxl.DPlayer; +import com.dre.dungeonsxl.EditWorld; + +public class CMDEdit extends DCommand{ + + public CMDEdit(){ + this.command="edit"; + this.args=1; + this.help="/dxl edit - Edit a existing dungeon"; + } + + @Override + public void onExecute(String[] args, Player player) { + String dungeonname=args[1]; + + EditWorld eworld=EditWorld.load(dungeonname); + + + DGroup dgroup=DGroup.get(player); + DPlayer dplayer=DPlayer.get(player); + + if(EditWorld.isInvitedPlayer(dungeonname,player.getName())||p.permission.has(player, "dxl.edit")||player.isOp()){ + 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{ + p.msg(player,ChatColor.RED+"Dungeon existiert nicht!"); + } + }else{ + p.msg(player,ChatColor.RED+"Du musst zuerst deine Gruppe verlassen!"); + } + }else{ + p.msg(player,ChatColor.RED+"Du musst zuerst den aktuellen Dungeon verlassen!"); + } + } + + } + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDHelp.java b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDHelp.java new file mode 100644 index 00000000..54f54cf1 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDHelp.java @@ -0,0 +1,49 @@ +package com.dre.dungeonsxl.commands; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +public class CMDHelp extends DCommand{ + + public CMDHelp(){ + this.command="help"; + this.args=-1; + this.help="/dxl help - Displays the Help-Page"; + } + + @Override + public void onExecute(String[] args, Player player) { + int page=1; + int pages=(int)(DCommandRoot.root.commands.size()/6); + + if(args.length>1){ + try{ + page=Integer.parseInt(args[1]); + }catch(NumberFormatException e){ + page=1; + } + if(page<1) page=1; + if(page>pages) page=pages; + } + + + + p.msg(player, ChatColor.GREEN+"============[ "+ChatColor.GOLD+"Help DungeonsXL - "+page+"/"+pages+ChatColor.GREEN+" ]============",false); + + int i=0; + int ipage=1; + for(DCommand command:DCommandRoot.root.commands){ + i++; + if(i>6){ + i=0; + ipage++; + } + if(ipage==page){ + p.msg(player, ChatColor.YELLOW+command.help,false); + } + } + + p.msg(player, ChatColor.GREEN+"==============[ "+ChatColor.GOLD+"By Frank Baumann"+ChatColor.GREEN+" ]==============",false); + } + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDInvite.java b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDInvite.java new file mode 100644 index 00000000..8b197fc4 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDInvite.java @@ -0,0 +1,25 @@ +package com.dre.dungeonsxl.commands; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import com.dre.dungeonsxl.EditWorld; + +public class CMDInvite extends DCommand{ + public CMDInvite(){ + this.args=2; + this.command="invite"; + this.help="/dxl invite - Invites a Player to edit a Dungeon"; + this.permissions="dxl.invite"; + } + + @Override + public void onExecute(String[] args, Player player) { + if(EditWorld.addInvitedPlayer(args[2], args[1])){ + p.msg(player, ChatColor.GREEN+"Spieler "+ChatColor.GOLD+args[1]+ChatColor.GREEN+" wurde erfolgreich eingeladen am Dungeon "+ChatColor.GOLD+args[2]+ChatColor.GREEN+" zu arbeiten!"); + }else{ + p.msg(player, ChatColor.RED+"Spieler "+ChatColor.GOLD+args[1]+ChatColor.RED+" konnte nicht eingeladen werden. Existiert der Dungeon?"); + } + + } +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDLeave.java b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDLeave.java new file mode 100644 index 00000000..bb91263e --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDLeave.java @@ -0,0 +1,42 @@ +package com.dre.dungeonsxl.commands; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import com.dre.dungeonsxl.DGroup; +import com.dre.dungeonsxl.DPlayer; +import com.dre.dungeonsxl.game.GameWorld; + +public class CMDLeave extends DCommand { + + public CMDLeave(){ + this.command="leave"; + this.args=0; + this.help="/dxl leave - leaves the current dungeon."; + } + + @Override + public void onExecute(String[] args, Player player) { + DPlayer dplayer=DPlayer.get(player); + + if(GameWorld.get(player.getWorld())!=null){ + if(GameWorld.get(player.getWorld()).isTutorial){ + p.msg(player,ChatColor.RED+"Du kannst diesen Befehl nicht in einem Tutorial benutzen!"); + return; + } + } + + if(dplayer!=null){ + dplayer.leave(); + return; + }else{ + DGroup dgroup=DGroup.get(player); + if(dgroup!=null){ + dgroup.removePlayer(player); + p.msg(player,ChatColor.YELLOW+"Du hast deine Gruppe erfolgreich verlassen!"); + return; + } + p.msg(player,ChatColor.RED+"You aren't in a dungeon!"); + } + } +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDList.java b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDList.java new file mode 100644 index 00000000..c1beb0fb --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDList.java @@ -0,0 +1,30 @@ +package com.dre.dungeonsxl.commands; + +import java.io.File; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +public class CMDList extends DCommand{ + + public CMDList(){ + this.command="list"; + this.args=0; + this.help="/dxl list - Zeigt alle Dungeons an"; + } + + + @Override + public void onExecute(String[] args, Player player) { + + File dungeonsfolder=new File(p.getDataFolder()+"/dungeons"); + if(dungeonsfolder.exists()){ + p.msg(player, ChatColor.DARK_GREEN+"-----[ "+ChatColor.GOLD+"Dungeons "+ChatColor.RED+dungeonsfolder.list().length+ChatColor.DARK_GREEN+"]-----"); + + for(String dungeon:dungeonsfolder.list()){ + p.msg(player, dungeon); + } + } + } + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDMsg.java b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDMsg.java new file mode 100644 index 00000000..e3a8da61 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDMsg.java @@ -0,0 +1,78 @@ +package com.dre.dungeonsxl.commands; + +import java.io.File; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import com.dre.dungeonsxl.ConfigReader; +import com.dre.dungeonsxl.EditWorld; + +public class CMDMsg extends DCommand{ + + public CMDMsg(){ + this.args=-1; + this.command="msg"; + this.help="/dxl msg '[msg]' - Display the msg or change the msg"; + this.permissions="dxl.msg"; + } + + @Override + public void onExecute(String[] args, Player player) { + EditWorld eworld=EditWorld.get(player.getWorld()); + + if(eworld!=null){ + if(args.length>1){ + try{ + int id=Integer.parseInt(args[1]); + + ConfigReader confreader=new ConfigReader(new File(p.getDataFolder()+"/dungeons/"+eworld.dungeonname, "config.yml")); + + if(args.length==2){ + String msg=confreader.msgs.get(id); + if(msg!=null){ + p.msg(player, ChatColor.GOLD+"Msg("+id+"):"+ChatColor.WHITE+msg); + }else{ + p.msg(player, ChatColor.RED+"Nachricht mit der Id "+ChatColor.GOLD+id+ChatColor.RED+" existiert nicht!"); + } + + }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.msgs.get(id); + if(old==null){ + p.msg(player, ChatColor.GREEN+"Neue Nachricht ("+ChatColor.GOLD+id+ChatColor.GREEN+") hinzugefügt!"); + }else{ + p.msg(player, ChatColor.GREEN+"Nachricht ("+ChatColor.GOLD+id+ChatColor.GREEN+") aktualisiert!"); + } + + confreader.msgs.put(id, msg); + confreader.save(); + }else{ + p.msg(player, ChatColor.RED+"Du musst die Nachricht zwischen ' einfügen!"); + } + } + }catch(NumberFormatException e){ + p.msg(player, ChatColor.RED+"Parameter muss eine Zahl beinhalten!"); + } + + }else{ + this.displayhelp(player); + } + }else{ + p.msg(player, ChatColor.RED+"Du musst einen Dungeon bearbeiten um diesen Befehl zu benutzen!"); + } + + } + + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDPortal.java b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDPortal.java new file mode 100644 index 00000000..b1ef9157 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDPortal.java @@ -0,0 +1,39 @@ +package com.dre.dungeonsxl.commands; + +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import com.dre.dungeonsxl.DPlayer; +import com.dre.dungeonsxl.DPortal; + +public class CMDPortal extends DCommand{ + + public CMDPortal(){ + this.command="portal"; + this.args=0; + this.help="/dxl portal - Create a portal that goes in a dungeon or out a dungeon"; + this.permissions="dxl.portal"; + } + + @Override + public void onExecute(String[] args, Player player) { + + + + DPortal dportal=new DPortal(false); + dportal.player=player; + dportal.world=player.getWorld(); + player.getInventory().setItemInHand(new ItemStack(268)); + + //Check Destination + DPlayer dplayer=DPlayer.get(player); + if(dplayer!=null){ //Is player in EditWorld + dportal.type="toworld"; + }else{ //Is player in normal World + dportal.type="todungeon"; + } + + + } + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDSave.java b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDSave.java new file mode 100644 index 00000000..03294331 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDSave.java @@ -0,0 +1,30 @@ +package com.dre.dungeonsxl.commands; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import com.dre.dungeonsxl.EditWorld; + +public class CMDSave extends DCommand{ + + public CMDSave(){ + this.command="save"; + this.args=0; + this.help="/dxl save - Save the current dungeon."; + this.permissions="dxl.save"; + } + + + @Override + public void onExecute(String[] args, Player player) { + EditWorld eworld=EditWorld.get(player.getWorld()); + if(eworld!=null){ + eworld.save(); + p.msg(player,ChatColor.GOLD+"Dungeon erfolgreich gespeichert!"); + }else{ + p.msg(player,ChatColor.RED+"Du musst einen Dungeon editieren, um ihn zu speichern!"); + } + + + } +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDTest.java b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDTest.java new file mode 100644 index 00000000..01aa96c6 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDTest.java @@ -0,0 +1,85 @@ +package com.dre.dungeonsxl.commands; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import com.dre.dungeonsxl.DGroup; +import com.dre.dungeonsxl.DPlayer; +import com.dre.dungeonsxl.EditWorld; +import com.dre.dungeonsxl.game.GameWorld; + +public class CMDTest extends DCommand { + + public CMDTest(){ + this.command="test"; + this.args=-1; + this.help="/dxl test [dungeon] - Test a Dungeon"; + this.permissions="dxl.test"; + } + + @Override + public void onExecute(String[] args, Player player) { + DPlayer dplayer=DPlayer.get(player); + String dungeonname; + + if(dplayer==null){ + if(args.length>1){ + dungeonname=args[1]; + + if(EditWorld.exist(dungeonname)){ + DGroup dgroup=new DGroup(player, dungeonname); + if(dgroup!=null){ + if(dgroup.gworld==null){ + dgroup.gworld=GameWorld.load(DGroup.get(player).dungeonname); + } + + DPlayer newDPlayer; + + if(dgroup.gworld.locLobby==null){ + newDPlayer=new DPlayer(player,dgroup.gworld.world,dgroup.gworld.world.getSpawnLocation(), false); + }else{ + newDPlayer=new DPlayer(player,dgroup.gworld.world,dgroup.gworld.locLobby, false); + } + newDPlayer.isinTestMode=2; + } + }else{ + p.msg(player, ChatColor.RED+"Dungeon "+ChatColor.GOLD+dungeonname+ChatColor.RED+" existiert nicht!"); + } + }else{ + this.displayhelp(player); + } + }else if(dplayer.isEditing){ + + if(args.length>1){ + dungeonname=args[1]; + }else{ + dungeonname=EditWorld.get(dplayer.world).dungeonname; + } + + DGroup dgroup=new DGroup(player, dungeonname); + if(dgroup!=null){ + if(dgroup.gworld==null){ + dgroup.gworld=GameWorld.load(DGroup.get(player).dungeonname); + } + + DPlayer newDPlayer; + + if(dgroup.gworld.locLobby==null){ + newDPlayer=new DPlayer(player,dgroup.gworld.world,dgroup.gworld.world.getSpawnLocation(), false); + }else{ + newDPlayer=new DPlayer(player,dgroup.gworld.world,dgroup.gworld.locLobby, false); + } + + newDPlayer.oldDPlayer=dplayer; + dplayer.isinTestMode=1; + } + + }else{ + p.msg(player, ChatColor.RED+"Du must zuerst den aktuellen Dungeon verlassen!"); + } + + + + } + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDUninvite.java b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDUninvite.java new file mode 100644 index 00000000..94b0213e --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/commands/CMDUninvite.java @@ -0,0 +1,25 @@ +package com.dre.dungeonsxl.commands; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import com.dre.dungeonsxl.EditWorld; + +public class CMDUninvite extends DCommand{ + public CMDUninvite(){ + this.args=2; + this.command="uninvite"; + this.help="/dxl uninvite - Uninvites a Player to edit a Dungeon"; + this.permissions="dxl.uninvite"; + } + + @Override + public void onExecute(String[] args, Player player) { + if(EditWorld.removeInvitedPlayer(args[2], args[1])){ + p.msg(player, ChatColor.GREEN+"Spieler "+ChatColor.GOLD+args[1]+ChatColor.GREEN+" wurde erfolgreich ausgeladen am Dungeon "+ChatColor.GOLD+args[2]+ChatColor.GREEN+" zu arbeiten!"); + }else{ + p.msg(player, ChatColor.RED+"Spieler "+ChatColor.GOLD+args[1]+ChatColor.GOLD+" konnte nicht ausgeladen werden. Existiert der Dungeon?"); + } + + } +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/commands/DCommand.java b/DungeonsXL/src/com/dre/dungeonsxl/commands/DCommand.java new file mode 100644 index 00000000..1b7f1303 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/commands/DCommand.java @@ -0,0 +1,43 @@ +package com.dre.dungeonsxl.commands; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import com.dre.dungeonsxl.DungeonsXL; + +public abstract class DCommand { + public DungeonsXL p=DungeonsXL.p; + + public Player player; + public boolean costsMoney; + public String command; + public int args; + public String help; + public String permissions; + + // TODO : Add Aliases + + public DCommand(){ + costsMoney = false; + } + + public void displayhelp(Player player){ + p.msg(player,ChatColor.RED+this.help); + } + + public boolean playerHasPermissions(Player player){ + if(this.permissions==null){ + return true; + } + if(DungeonsXL.p.permission.has(player, this.permissions)||player.isOp()){ + return true; + } + + return false; + } + + //Abstracts + public abstract void onExecute(String[] args, Player player); + + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/commands/DCommandRoot.java b/DungeonsXL/src/com/dre/dungeonsxl/commands/DCommandRoot.java new file mode 100644 index 00000000..08990d28 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/commands/DCommandRoot.java @@ -0,0 +1,46 @@ +package com.dre.dungeonsxl.commands; + +import java.util.concurrent.CopyOnWriteArrayList; + +public class DCommandRoot { + //Variables + public static DCommandRoot root; + + public CopyOnWriteArrayList commands=new CopyOnWriteArrayList(); + + //Commands + public CMDCreate cmdCreate=new CMDCreate(); + public CMDSave cmdSave=new CMDSave(); + public CMDLeave cmdLeave=new CMDLeave(); + public CMDEdit cmdEdit=new CMDEdit(); + public CMDPortal cmdPortal=new CMDPortal(); + public CMDChat cmdChat=new CMDChat(); + public CMDChatSpy cmdChatSpy=new CMDChatSpy(); + public CMDList cmdList=new CMDList(); + public CMDUninvite cmdUninvite=new CMDUninvite(); + public CMDInvite cmdInvite=new CMDInvite(); + public CMDMsg cmdMsg=new CMDMsg(); + public CMDTest cmdTest=new CMDTest(); + public CMDHelp cmdHelp=new CMDHelp(); + //Methods + public DCommandRoot(){ + root=this; + + //Add Commands + this.commands.add(cmdCreate); + this.commands.add(cmdSave); + this.commands.add(cmdLeave); + this.commands.add(cmdEdit); + this.commands.add(cmdPortal); + this.commands.add(cmdChat); + this.commands.add(cmdChatSpy); + this.commands.add(cmdList); + this.commands.add(cmdUninvite); + this.commands.add(cmdInvite); + this.commands.add(cmdMsg); + this.commands.add(cmdTest); + this.commands.add(cmdHelp); + } + + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/game/DMob.java b/DungeonsXL/src/com/dre/dungeonsxl/game/DMob.java new file mode 100644 index 00000000..54077681 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/game/DMob.java @@ -0,0 +1,54 @@ +package com.dre.dungeonsxl.game; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Monster; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; + +public class DMob { + + //Variables + public LivingEntity entity; + public int live; + + public DMob(LivingEntity entity, int live, GameWorld gworld){ + gworld.dmobs.add(this); + + this.entity=entity; + this.live=live; + } + + //Statics + public static void onDamage(EntityDamageEvent event){ + if(event.getEntity() instanceof LivingEntity){ + LivingEntity victim=(LivingEntity) event.getEntity(); + + GameWorld gworld=GameWorld.get(victim.getWorld()); + + if(gworld!=null){ + for(DMob dmob:gworld.dmobs){ + if(dmob.entity==victim){ + dmob.live=dmob.live-event.getDamage(); + dmob.entity.damage(1); + dmob.entity.setHealth(dmob.entity.getMaxHealth()); + + if(event instanceof EntityDamageByEntityEvent){ + EntityDamageByEntityEvent eByEEvent=(EntityDamageByEntityEvent) event; + if(dmob.entity instanceof Monster && eByEEvent.getDamager() instanceof LivingEntity){ + Monster mob=(Monster)dmob.entity; + mob.setTarget((LivingEntity) eByEEvent.getDamager()); + } + } + + + if(dmob.live<=0){ + dmob.entity.damage(dmob.entity.getMaxHealth()); + gworld.dmobs.remove(dmob); + } + event.setCancelled(true); + } + } + } + } + } +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/game/GameCheckpoint.java b/DungeonsXL/src/com/dre/dungeonsxl/game/GameCheckpoint.java new file mode 100644 index 00000000..f0769fa3 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/game/GameCheckpoint.java @@ -0,0 +1,50 @@ +package com.dre.dungeonsxl.game; + +import java.util.concurrent.CopyOnWriteArrayList; + +import org.bukkit.ChatColor; +import org.bukkit.Location; + +import com.dre.dungeonsxl.DPlayer; +import com.dre.dungeonsxl.DungeonsXL; + + +public class GameCheckpoint { + public static CopyOnWriteArrayList gcheckpoints=new CopyOnWriteArrayList(); + + //Variables + public GameWorld gworld; + public Location location; + public int radius; + public CopyOnWriteArrayList dplayerHasUsed=new CopyOnWriteArrayList(); + + public GameCheckpoint(GameWorld gworld, Location location, int radius){ + gcheckpoints.add(this); + + this.location=location; + this.radius=radius; + if(this.radius==0){ + this.radius=5; + } + this.gworld=gworld; + } + + + //Statics + + public static void update(){ + for(GameCheckpoint gpoint:gcheckpoints){ + for(DPlayer dplayer:DPlayer.get(gpoint.gworld.world)){ + if(!gpoint.dplayerHasUsed.contains(dplayer)){ + if(dplayer.player.getLocation().distance(gpoint.location)<=gpoint.radius){ + dplayer.setCheckpoint(gpoint); + DungeonsXL.p.msg(dplayer.player, ChatColor.GOLD+"Checkpoint erreicht!"); + gpoint.dplayerHasUsed.add(dplayer); + } + } + } + } + } + + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/game/GameChest.java b/DungeonsXL/src/com/dre/dungeonsxl/game/GameChest.java new file mode 100644 index 00000000..49c38f1c --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/game/GameChest.java @@ -0,0 +1,82 @@ +package com.dre.dungeonsxl.game; + +import org.bukkit.ChatColor; +import org.bukkit.block.Block; +import org.bukkit.block.Chest; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.InventoryOpenEvent; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; + +import com.dre.dungeonsxl.DGroup; +import com.dre.dungeonsxl.DPlayer; +import com.dre.dungeonsxl.DungeonsXL; + +public class GameChest { + + //Variables + public boolean isUsed=false; + public Chest chest; + public GameWorld gworld; + + public GameChest(Block chest, GameWorld gworld){ + if(chest.getState() instanceof Chest ){ + this.chest=(Chest)chest.getState(); + + this.gworld=gworld; + + gworld.gchests.add(this); + } + } + + + public void addTreasure(DGroup dgroup){ + if(dgroup!=null){ + for(Player player:dgroup.players){ + DPlayer dplayer=DPlayer.get(player); + if(dplayer!=null){ + String msg=ChatColor.GOLD+"Deinem Belohnungsinventar sind"; + for(ItemStack istack:this.chest.getInventory().getContents()){ + if(istack!=null){ + dplayer.treasureInv.addItem(istack); + msg=msg+ChatColor.RED+" "+istack.getAmount()+" "+istack.getType().name()+ChatColor.GOLD+","; + } + } + msg=msg.substring(0,msg.length()-1); + msg=msg+" hinzugefügt worden!"; + + DungeonsXL.p.msg(player, msg); + } + } + } + } + + //Statics + public static void onOpenInventory(InventoryOpenEvent event){ + InventoryView inventory=event.getView(); + + GameWorld gworld=GameWorld.get(event.getPlayer().getWorld()); + + if(gworld!=null){ + if(inventory.getTopInventory().getHolder() instanceof Chest){ + Chest chest=(Chest) inventory.getTopInventory().getHolder(); + + for(GameChest gchest:gworld.gchests){ + if(gchest.chest.equals(chest)){ + if(!gchest.isUsed){ + if(gchest.chest.getLocation().distance(chest.getLocation())<1){ + gchest.addTreasure(DGroup.get(gworld)); + gchest.isUsed=true; + event.setCancelled(true); + } + }else{ + DungeonsXL.p.msg(DungeonsXL.p.getServer().getPlayer(event.getPlayer().getName()), ChatColor.RED+"Diese Kiste wurde schon geöffnet!"); + event.setCancelled(true); + } + } + } + } + } + } + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/game/GameMessage.java b/DungeonsXL/src/com/dre/dungeonsxl/game/GameMessage.java new file mode 100644 index 00000000..a1f6f738 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/game/GameMessage.java @@ -0,0 +1,49 @@ +package com.dre.dungeonsxl.game; + +import java.util.concurrent.CopyOnWriteArrayList; + +import org.bukkit.block.Block; + +import com.dre.dungeonsxl.DPlayer; +import com.dre.dungeonsxl.DungeonsXL; + +public class GameMessage { + public static CopyOnWriteArrayList gmessages=new CopyOnWriteArrayList(); + + //Variables + public CopyOnWriteArrayList playerDone=new CopyOnWriteArrayList(); + + public Block block; + public String msg; + public GameWorld gworld; + public int radius; + + public GameMessage(Block block, int msgid,GameWorld gworld,int radius){ + this.block=block; + this.msg=gworld.confReader.getMsg(msgid); + this.gworld=gworld; + this.radius=radius; + + if(this.msg!=null){ + gmessages.add(this); + } + } + + + //Static + + public static void updateAll(){ + for(GameMessage gmessage:gmessages){ + for(DPlayer dplayer:DPlayer.get(gmessage.gworld.world)){ + if(!gmessage.playerDone.contains(dplayer)){ + if(dplayer.player.getLocation().distance(gmessage.block.getLocation()) gworlds=new CopyOnWriteArrayList(); + + //Variables placeable + public boolean isTutorial; + + public CopyOnWriteArrayList placeableBlocks=new CopyOnWriteArrayList(); + public World world; + public String dungeonname; + public Location locLobby; + public Location locStart; + public CopyOnWriteArrayList blocksEnd=new CopyOnWriteArrayList(); + public CopyOnWriteArrayList blocksReady=new CopyOnWriteArrayList(); + public CopyOnWriteArrayList blocksLeave=new CopyOnWriteArrayList(); + public boolean isPlaying=false; + public int id; + public CopyOnWriteArrayList secureobjects = new CopyOnWriteArrayList(); + + public CopyOnWriteArrayList signClass=new CopyOnWriteArrayList(); + public CopyOnWriteArrayList dmobs = new CopyOnWriteArrayList(); + public CopyOnWriteArrayList gchests = new CopyOnWriteArrayList(); + public ConfigReader confReader; + + public GameWorld(){ + gworlds.add(this); + + //ID + this.id=-1; + int i=-1; + while(this.id==-1){ + i++; + boolean exist=false; + for(GameWorld gworld:gworlds){ + if(gworld.id==i){ + exist=true; + break; + } + } + if(!exist) this.id=i; + } + } + + public void checkSign(Block block){ + if((block.getState() instanceof Sign)){ + Sign sign = (Sign) block.getState(); + String[] lines=sign.getLines(); + + if(!isPlaying){ + if(lines[1].equalsIgnoreCase("lobby")){ + this.locLobby=block.getLocation(); + block.setTypeId(0); + } + if(lines[1].equalsIgnoreCase("ready")){ + this.blocksReady.add(block); + sign.setLine(0, ChatColor.BLUE+"############"); + sign.setLine(1, ChatColor.DARK_GREEN+"Bereit"); + sign.setLine(2, ""); + sign.setLine(3, ChatColor.BLUE+"############"); + sign.update(); + } + if(lines[1].equalsIgnoreCase("leave")){ + this.blocksLeave.add(block); + sign.setLine(0, ChatColor.BLUE+"############"); + sign.setLine(1, ChatColor.DARK_GREEN+"Leave"); + sign.setLine(2, ""); + sign.setLine(3, ChatColor.BLUE+"############"); + sign.update(); + } + if(lines[1].equalsIgnoreCase("start")){ + this.locStart=block.getLocation(); + block.setTypeId(0); + } + if(lines[1].equalsIgnoreCase("end")){ + this.blocksEnd.add(block); + sign.setLine(0, ChatColor.DARK_BLUE+"############"); + sign.setLine(1, ChatColor.DARK_GREEN+"Ende"); + sign.setLine(2, ""); + sign.setLine(3, ChatColor.DARK_BLUE+"############"); + sign.update(); + } + if(lines[1].equalsIgnoreCase("classes")){ + if(!confReader.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()){ + + //Check existing signs + boolean isContinued=true; + for(Sign isusedsign:this.signClass){ + if(dclass.name.equalsIgnoreCase(ChatColor.stripColor(isusedsign.getLine(1)))){ + isContinued=false; + } + } + + if(isContinued){ + Block classBlock=block.getRelative(xx,0,zz); + + if(classBlock.getData()==sign.getData().getData()&&classBlock.getTypeId()==68&&(classBlock.getState() instanceof Sign)){ + Sign classSign = (Sign) classBlock.getState(); + + classSign.setLine(0, ChatColor.DARK_BLUE+"############"); + classSign.setLine(1, ChatColor.DARK_GREEN+dclass.name); + classSign.setLine(2, ""); + classSign.setLine(3, ChatColor.DARK_BLUE+"############"); + classSign.update(); + this.signClass.add(classSign); + }else{ + break; + } + xx=xx+directionX; + zz=zz+directionZ; + } + } + } + else{ + block.setTypeId(0); + } + + } + + }else{ + if(lines[1].equalsIgnoreCase("mob")){ + if(lines[2]!=""&&lines[3]!=""){ + EntityType mob=p.getEntitiyType(lines[2]); + if(mob!=null){ + String[] atributes=lines[3].split(","); + if(atributes.length==3){ + new MobSpawner(block, mob, Integer.parseInt(atributes[0]), Integer.parseInt(atributes[1]), Integer.parseInt(atributes[2]),0); + } + if(atributes.length==4){ + new MobSpawner(block, mob, Integer.parseInt(atributes[0]), Integer.parseInt(atributes[1]), Integer.parseInt(atributes[2]),Integer.parseInt(atributes[3])); + } + } + } + block.setTypeId(0); + } + if(lines[1].equalsIgnoreCase("place")){ + placeableBlocks.add(block); + block.setTypeId(0); + } + if(lines[1].equalsIgnoreCase("msg")){ + if(lines[2]!=""&&lines[3]!=""){ + new GameMessage(block,Integer.parseInt(lines[2]),this,Integer.parseInt(lines[3])); + block.setTypeId(0); + } + } + if(lines[1].equalsIgnoreCase("checkpoint")){ + int radius=0; + + + if(lines[2]!=null ){ + if(lines[2].length()>0){ + radius=Integer.parseInt(lines[2]); + } + } + + new GameCheckpoint(this,block.getLocation(),radius); + block.setTypeId(0); + } + if(lines[1].equalsIgnoreCase("chest")){ + if(sign.getTypeId()==63){ + for(int x=-1;x<=1;x++){ + if(sign.getBlock().getRelative(x, 0, 0).getTypeId()==54){ + new GameChest(sign.getBlock().getRelative(x, 0, 0),this); + } + } + for(int z=-1;z<=1;z++){ + if(sign.getBlock().getRelative(0, 0, z).getTypeId()==54){ + if(sign.getBlock().getRelative(0, 0, z)!=null){ + new GameChest(sign.getBlock().getRelative(0, 0, z),this); + } + } + } + } + block.setTypeId(0); + } + } + } + } + + public void startGame() { + this.isPlaying=true; + ObjectInputStream os; + try { + os = new ObjectInputStream(new FileInputStream(new File("DXL_Game_"+this.id+"/DXLData.data"))); + + int length=os.readInt(); + for(int i=0; iSystem.currentTimeMillis()){ + return false; + } + } + } + }else{ + return false; + } + + return true; + } + + public void delete(){ + //for(GameWorld gworld:gworlds){ + gworlds.remove(this); + + p.getServer().unloadWorld(this.world,true); + File dir = new File("DXL_Game_"+this.id); + p.removeDirectory(dir); + //} + } + + public static GameWorld load(String name){ + + File file=new File("plugins/DungeonsXL/dungeons/"+name); + + if(file.exists()){ + GameWorld gworld = new GameWorld(); + gworld.dungeonname=name; + + + //Config einlesen + gworld.confReader=new ConfigReader(new File(p.getDataFolder()+"/dungeons/"+gworld.dungeonname, "config.yml")); + + //Secure Objects + gworld.secureobjects=gworld.confReader.secureobjects; + + //World + p.copyDirectory(file,new File("DXL_Game_"+gworld.id)); + + gworld.world=p.getServer().createWorld(WorldCreator.name("DXL_Game_"+gworld.id)); + + ObjectInputStream os; + try { + os = new ObjectInputStream(new FileInputStream(new File("DXL_Game_"+gworld.id+"/DXLData.data"))); + + int length=os.readInt(); + for(int i=0; i mobspawners=new CopyOnWriteArrayList(); + + //Variables + public EntityType mob; + public Block block; + public int maxinterval; + public int interval=0; + public int ammount; + public int radius; + private int live; + + + public MobSpawner(Block block, EntityType mob, int interval, int ammount, int radius, int live){ + mobspawners.add(this); + + this.block=block; + this.mob=mob; + this.maxinterval=interval; + this.ammount=ammount; + this.radius=radius; + this.live=live; + } + + public void update(){ + World world=this.block.getWorld(); + + for(Player player:world.getPlayers()){ + if(player.getLocation().distance(this.block.getLocation())0){ + new DMob(mob,live,GameWorld.get(world)); + } + + if(ammount!=-1){ + if(ammount>1){ + ammount--; + }else{ + mobspawners.remove(this); + } + } + this.interval=this.maxinterval; + } + this.interval--; + return; + } + } + + } + + //Static + public static void updateAll(){ + for(MobSpawner spawner:mobspawners){ + spawner.update(); + } + } + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/listener/BlockListener.java b/DungeonsXL/src/com/dre/dungeonsxl/listener/BlockListener.java new file mode 100644 index 00000000..439db15f --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/listener/BlockListener.java @@ -0,0 +1,174 @@ +package com.dre.dungeonsxl.listener; + +import org.bukkit.block.Block; +import org.bukkit.block.Sign; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.block.BlockSpreadEvent; +import org.bukkit.event.block.SignChangeEvent; + +import com.dre.dungeonsxl.DGSign; +import com.dre.dungeonsxl.DPortal; +import com.dre.dungeonsxl.DungeonsXL; +import com.dre.dungeonsxl.EditWorld; +import com.dre.dungeonsxl.LeaveSign; +import com.dre.dungeonsxl.game.GameWorld; + +public class BlockListener implements Listener { + + @EventHandler(priority = EventPriority.HIGH) + public void onBlockPhysics(BlockPhysicsEvent event){ + if(event.getBlock().getTypeId()==90){ + if(DPortal.get(event.getBlock())!=null){ + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onBlockBreak(BlockBreakEvent event){ + Block block=event.getBlock(); + + //Deny DPortal destroying + if(block.getTypeId()==90){ + if(DPortal.get(event.getBlock())!=null){ + event.setCancelled(true); + } + } + + //Deny DGSignblocks destroying + if(DGSign.isRelativeSign(block,1, 0)|| + DGSign.isRelativeSign(block,-1, 0)|| + DGSign.isRelativeSign(block,0, 1)|| + DGSign.isRelativeSign(block,0, -1) + ) + { + event.setCancelled(true); + } + + //DGSign destroying + if(DGSign.getSign(block)!=null){ + DGSign.dgsigns.remove(DGSign.getSign(block)); + } + + //Deny LeaveSignblocks destroying + if(LeaveSign.isRelativeSign(block,1, 0)|| + LeaveSign.isRelativeSign(block,-1, 0)|| + LeaveSign.isRelativeSign(block,0, 1)|| + LeaveSign.isRelativeSign(block,0, -1) + ) + { + event.setCancelled(true); + } + + //LeaveSign destroying + if(LeaveSign.getSign(block)!=null){ + event.setCancelled(true); + //LeaveSign.lsigns.remove(LeaveSign.getSign(block)); + } + + //Editworld Signs + EditWorld eworld=EditWorld.get(block.getWorld()); + if(eworld!=null){ + eworld.sign.remove(event.getBlock()); + } + + //Deny GameWorld Blocks + GameWorld gworld=GameWorld.get(block.getWorld()); + if(gworld!=null){ + event.setCancelled(true); + } + + } + + @EventHandler(priority = EventPriority.HIGH) + public void onBlockPlace(BlockPlaceEvent event){ + Block block=event.getBlock(); + + //Deny GameWorld Blocks + GameWorld gworld=GameWorld.get(block.getWorld()); + if(gworld!=null){ + if(!gworld.canBuild(block)){ + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.NORMAL) + public void onSignChange(SignChangeEvent event){ + Player player=event.getPlayer(); + Block block=event.getBlock(); + String[] lines=event.getLines(); + EditWorld eworld=EditWorld.get(player.getWorld()); + + //Group Signs + if(eworld==null){ + if(player.isOp() || DungeonsXL.p.permission.has(player, "dxl.sign")){ + + + if(lines[0].equalsIgnoreCase("[DXL]")){ + if(lines[1].equalsIgnoreCase("Group")){ + String dungeonName=lines[2]; + + String[] data = lines[3].split("\\,"); + if(data.length==2){ + int maxGroups=Integer.parseInt(data[0]); + int maxPlayersPerGroup=Integer.parseInt(data[1]); + if(maxGroups>0 && maxPlayersPerGroup>0){ + if(DGSign.tryToCreate(event.getBlock(), dungeonName, maxGroups, maxPlayersPerGroup)!=null){ + event.setCancelled(true); + } + } + } + } + if(lines[1].equalsIgnoreCase("Leave")){ + if(block.getState() instanceof Sign){ + Sign sign = (Sign) block.getState(); + new LeaveSign(sign); + } + event.setCancelled(true); + } + } + } + } + + //Editworld Signs + + else{ + if(lines[0].equalsIgnoreCase("[DXL]")){ + eworld.checkSign(event.getBlock()); + eworld.sign.add(event.getBlock()); + }else{ + eworld.sign.remove(event.getBlock()); + } + } + + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void onBlockSpread(BlockSpreadEvent event){ + Block block=event.getBlock(); + //Block the Spread off Vines + if(block.getTypeId()==106){ + //Check GameWorlds + GameWorld gworld=GameWorld.get(event.getBlock().getWorld()); + if(gworld!=null){ + event.setCancelled(true); + } + + //Check EditWorlds + EditWorld eworld=EditWorld.get(event.getBlock().getWorld()); + if(eworld!=null){ + event.setCancelled(true); + } + } + + } + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/listener/CommandListener.java b/DungeonsXL/src/com/dre/dungeonsxl/listener/CommandListener.java new file mode 100644 index 00000000..394aab3c --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/listener/CommandListener.java @@ -0,0 +1,51 @@ +package com.dre.dungeonsxl.listener; + +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.dre.dungeonsxl.DungeonsXL; +import com.dre.dungeonsxl.commands.DCommand; +import com.dre.dungeonsxl.commands.DCommandRoot; + +public class CommandListener implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command cmd_notused, String arg, String[] args) { + + //Only Playercommands + if(sender instanceof Player){ + Player player = (Player) sender; + if(args.length > 0){ + String cmd = args[0]; + + for(DCommand command:DCommandRoot.root.commands){ + if(cmd.equals(command.command)){ + if(command.playerHasPermissions(player)){ + if(command.args==args.length-1||command.args==-1){ + command.onExecute(args,player); + }else{ + command.displayhelp(player); + } + } + else{ + DungeonsXL.p.msg(player, ChatColor.RED+"Du hast keine Permissions dazu!"); + } + return true; + } + } + + DungeonsXL.p.msg(player, ChatColor.RED+"Befehl "+ChatColor.GOLD+cmd+ChatColor.RED+" existiert nicht!"); + DungeonsXL.p.msg(player, ChatColor.RED+"Bitte gib "+ChatColor.GOLD+"/dxl help"+ChatColor.RED+" für Hilfe ein!"); + }else{ + DCommandRoot.root.cmdHelp.onExecute(args,player); + } + } + return false; + } + + + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/listener/EntityListener.java b/DungeonsXL/src/com/dre/dungeonsxl/listener/EntityListener.java new file mode 100644 index 00000000..7bba7848 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/listener/EntityListener.java @@ -0,0 +1,221 @@ +package com.dre.dungeonsxl.listener; + +import java.util.List; + +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.event.entity.EntityCombustByEntityEvent; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.FoodLevelChangeEvent; + +import com.dre.dungeonsxl.DGSign; +import com.dre.dungeonsxl.DPlayer; +import com.dre.dungeonsxl.DPortal; +import com.dre.dungeonsxl.EditWorld; +import com.dre.dungeonsxl.game.DMob; +import com.dre.dungeonsxl.game.GameWorld; + +public class EntityListener implements Listener{ + + @EventHandler(priority = EventPriority.HIGH) + public void onCreatureSpawn(CreatureSpawnEvent event){ + World world=event.getLocation().getWorld(); + + EditWorld eworld=EditWorld.get(world); + + if(eworld!=null){ + if( + event.getSpawnReason()==SpawnReason.CHUNK_GEN|| + event.getSpawnReason()==SpawnReason.BREEDING|| + event.getSpawnReason()==SpawnReason.NATURAL){ + event.setCancelled(true); + } + } + + GameWorld gworld=GameWorld.get(world); + + if(gworld!=null){ + if( + event.getSpawnReason()==SpawnReason.CHUNK_GEN|| + event.getSpawnReason()==SpawnReason.BREEDING|| + event.getSpawnReason()==SpawnReason.NATURAL){ + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onEntityDeath(EntityDeathEvent event){ + World world=event.getEntity().getWorld(); + //Deny all drops from mobs + if (event.getEntity() instanceof LivingEntity) + { + LivingEntity entity = (LivingEntity) event.getEntity(); + GameWorld gworld=GameWorld.get(world); + if(gworld!=null){ + if(gworld.isPlaying){ + if(entity.getType()!=EntityType.PLAYER){ + event.getDrops().clear(); + } + } + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onEntityDamage(EntityDamageEvent event){ + World world=event.getEntity().getWorld(); + GameWorld gworld=GameWorld.get(world); + if(gworld!=null){ + //Deny all Damage in Lobby + if(!gworld.isPlaying){ + event.setCancelled(true); + } + //Deny all Damage from Players to Players + if (event instanceof EntityDamageByEntityEvent) + { + EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent)event; + + DMob.onDamage(sub); + + Entity entity = sub.getDamager(); + Entity entity2 = sub.getEntity(); + + if(entity instanceof Projectile) + { + entity = ((Projectile) entity).getShooter(); + } + + if(entity instanceof Player && entity2 instanceof Player) + { + event.setCancelled(true); + } + + if(entity instanceof LivingEntity && entity2 instanceof LivingEntity){ + if(!(entity instanceof Player) && !(entity2 instanceof Player)){ + event.setCancelled(true); + } + + //Check Dogs + if(entity instanceof Player || entity2 instanceof Player){ + for(DPlayer dplayer:DPlayer.get(gworld.world)){ + if(dplayer.wolf!=null){ + if(entity==dplayer.wolf || entity2==dplayer.wolf){ + event.setCancelled(true); + return; + } + } + } + } + + for(DPlayer dplayer:DPlayer.get(gworld.world)){ + if(dplayer.wolf!=null){ + if(entity instanceof Player || entity2 instanceof Player){ + if(entity==dplayer.wolf || entity2==dplayer.wolf){ + event.setCancelled(true); + return; + } + }else{ + if(entity==dplayer.wolf || entity2==dplayer.wolf){ + event.setCancelled(false); + return; + } + } + } + } + + } + } + } + } + + //Deny food in Lobby + @EventHandler(priority = EventPriority.HIGH) + public void onFoodLevelChange(FoodLevelChangeEvent event){ + World world=event.getEntity().getWorld(); + + GameWorld gworld=GameWorld.get(world); + if(gworld!=null){ + if(!gworld.isPlaying){ + event.setCancelled(true); + } + } + } + + // Zombie/skeleton combustion from the sun. + @EventHandler(priority = EventPriority.HIGH) + public void onEntityCombust(EntityCombustEvent event) + { + GameWorld gworld = GameWorld.get(event.getEntity().getWorld()); + if(gworld != null) + { + event.setCancelled(true); + } + } + + //Allow Other combustion + @EventHandler(priority = EventPriority.HIGH) + public void onEntityCombustByEntity(EntityCombustByEntityEvent event){ + GameWorld gworld=GameWorld.get(event.getEntity().getWorld()); + if(gworld!=null){ + if(event.isCancelled()){ + event.setCancelled(false); + } + } + } + + //Explosions + @EventHandler + public void onEntityExplode(EntityExplodeEvent event) + { + GameWorld gworld=GameWorld.get(event.getEntity().getWorld()); + if(gworld!=null){ + if(event.getEntity() instanceof LivingEntity){ + //Disable Creeper explosions in gameworlds + event.setCancelled(true); + return; + }else{ + //Disable drops from TNT + event.setYield(0); + } + + + } + + //Prevent Portal and Sign Destroying + List blocklist=event.blockList (); + for(Block block:blocklist){ + //Portals + if(block.getTypeId()==90){ + if(DPortal.get(block)!=null){ + event.setCancelled(true); + return; + } + } + + //Signs + if(block.getTypeId()==68 || block.getTypeId()==63){ + if(DGSign.getSign(block)!=null){ + event.setCancelled(true); + return; + } + } + } + } + + +} diff --git a/DungeonsXL/src/com/dre/dungeonsxl/listener/PlayerListener.java b/DungeonsXL/src/com/dre/dungeonsxl/listener/PlayerListener.java new file mode 100644 index 00000000..a5d350d7 --- /dev/null +++ b/DungeonsXL/src/com/dre/dungeonsxl/listener/PlayerListener.java @@ -0,0 +1,337 @@ +package com.dre.dungeonsxl.listener; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.Sign; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryOpenEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerPortalEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.inventory.ItemStack; +import com.dre.dungeonsxl.DGSign; +import com.dre.dungeonsxl.DGroup; +import com.dre.dungeonsxl.DPlayer; +import com.dre.dungeonsxl.DPortal; +import com.dre.dungeonsxl.DungeonsXL; +import com.dre.dungeonsxl.EditWorld; +import com.dre.dungeonsxl.LeaveSign; +import com.dre.dungeonsxl.game.GameChest; +import com.dre.dungeonsxl.game.GameWorld; + +public class PlayerListener implements Listener{ + public DungeonsXL p=DungeonsXL.p; + + + @EventHandler(priority = EventPriority.HIGHEST) + public void onPlayerInteract(PlayerInteractEvent event){ + Player player = event.getPlayer(); + Block clickedBlock=event.getClickedBlock(); + + //Check Portals + if(event.getItem()!=null){ + if(event.getItem().getType()==Material.WOOD_SWORD){ + if(clickedBlock!=null){ + for(DPortal dportal:DPortal.portals){ + if(!dportal.isActive){ + if(dportal.player==player){ + if(dportal.block1==null){ + dportal.block1=event.getClickedBlock(); + }else if(dportal.block2==null){ + dportal.block2=event.getClickedBlock(); + dportal.isActive=true; + dportal.fillwithportal(); + } + event.setCancelled(true); + } + } + } + } + } + } + + //Check Signs + if(clickedBlock!=null){ + + if(clickedBlock.getTypeId()==68 || clickedBlock.getTypeId()==63){ + //Check Group Signs + if(DGSign.playerInteract(event.getClickedBlock(), player)){ + event.setCancelled(true); + } + + + //Leave Sign + + if(LeaveSign.playerInteract(event.getClickedBlock(), player)){ + event.setCancelled(true); + } + + DPlayer dplayer=DPlayer.get(player); + if(dplayer!=null){ + + + + //Check GameWorld Signs + GameWorld gworld=GameWorld.get(player.getWorld()); + if(gworld!=null){ + //Ready Sign + for(Block blockReady:gworld.blocksReady){ + if(blockReady.getLocation().distance(clickedBlock.getLocation())<1){ + if(!dplayer.isReady){ + if(gworld.signClass.isEmpty() || dplayer.dclass!=null){ + dplayer.ready(); + p.msg(player,ChatColor.GOLD+"Du bist nun bereit für den Dungeon!"); + return; + }else{ + p.msg(player,ChatColor.RED+"Wähle zuerst eine Klasse!"); + } + } + } + } + + //End Sign + for(Block blockEnd:gworld.blocksEnd){ + if(blockEnd.getLocation().distance(clickedBlock.getLocation())<1){ + if(!dplayer.isFinished){ + dplayer.finish(); + return; + } + } + } + + //Leave Sign + for(Block blockLeave:gworld.blocksLeave){ + if(blockLeave.getLocation().distance(clickedBlock.getLocation())<1){ + dplayer.leave(); + } + } + + + //Class Signs + + for(Sign classSign:gworld.signClass){ + if(classSign!=null){ + if(classSign.getLocation().distance(clickedBlock.getLocation())<1){ + if(event.getAction()==Action.LEFT_CLICK_BLOCK){ + dplayer.setClass(ChatColor.stripColor(classSign.getLine(1))); + }else{ + p.msg(player,ChatColor.RED+"Du musst die Klasse mit Links-klick auswählen!"); + } + return; + } + } + } + } + } + } + } + + } + + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerDropItem(PlayerDropItemEvent event){ + Player player=event.getPlayer(); + + //Deny dropping things at the lobby + DGroup dgroup=DGroup.get(player); + if(dgroup!=null){ + if(!dgroup.isPlaying){ + event.setCancelled(true); + return; + } + if(!DPlayer.get(player).isReady){ + event.setCancelled(true); + return; + } + + DPlayer dplayer=DPlayer.get(player); + GameWorld gworld=GameWorld.get(dplayer.world); + if(dplayer!=null){ + for(Material material:gworld.confReader.secureobjects){ + if(material==event.getItemDrop().getItemStack().getType()){ + event.setCancelled(true); + p.msg(player,ChatColor.RED+"Du kannst keine sicheren Objekte droppen"); + return; + } + } + /*if(dplayer.invItemInHand==event.getItemDrop().getItemStack().getTypeId()){ + dplayer.invItemInHand=0; + }else{ + p.msg(player,ChatColor.RED+"Du kannst keine sicheren Objekte droppen"); + event.setCancelled(true); + return; + }*/ + } + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerRespawn(PlayerRespawnEvent event){ + Player player=event.getPlayer(); + DPlayer dplayer=DPlayer.get(player); + if(dplayer!=null){ + if(dplayer.isEditing){ + EditWorld eworld=EditWorld.get(dplayer.world); + if(eworld!=null){ + if(eworld.lobby==null){ + event.setRespawnLocation(eworld.world.getSpawnLocation()); + }else{ + event.setRespawnLocation(eworld.lobby); + } + } + }else{ + GameWorld gworld=GameWorld.get(dplayer.world); + if(gworld!=null){ + DGroup dgroup=DGroup.get(dplayer.player); + if(dplayer.checkpoint==null){ + event.setRespawnLocation(dgroup.gworld.locStart); + if(dplayer.wolf!=null){ + dplayer.wolf.teleport(dgroup.gworld.locStart); + } + }else{ + event.setRespawnLocation(dplayer.checkpoint.location); + if(dplayer.wolf!=null){ + dplayer.wolf.teleport(dplayer.checkpoint.location); + } + } + + + //Respawn Items + for(ItemStack istack:dplayer.respawnInventory){ + if(istack!=null){ + dplayer.player.getInventory().addItem(istack); + } + } + dplayer.respawnInventory.clear(); + DungeonsXL.p.updateInventory(dplayer.player); + + /*if(gworld.locLobby==null){ + event.setRespawnLocation(gworld.world.getSpawnLocation()); + }else{ + event.setRespawnLocation(gworld.locLobby); + } + dplayer.isReady=false;*/ + } + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerPortalEvent(PlayerPortalEvent event){ + Player player=event.getPlayer(); + Location location=event.getFrom(); + DPortal dportal=DPortal.get(location); + if(dportal!=null){ + event.setCancelled(true); + dportal.teleport(player); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerTeleport(PlayerTeleportEvent event){ + Player player=event.getPlayer(); + DPlayer dplayer=DPlayer.get(player); + if(dplayer!=null){ + if(dplayer.world!=event.getTo().getWorld()){ + if(!player.isOp()){ + event.setCancelled(true); + } + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerChat(AsyncPlayerChatEvent event){ + Player player=event.getPlayer(); + DPlayer dplayer=DPlayer.get(player); + if(dplayer!=null){ + if(dplayer.isInWorldChat){ + dplayer.msg(player.getDisplayName()+": "+event.getMessage()); + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerChat(PlayerChatEvent event){ + Player player=event.getPlayer(); + DPlayer dplayer=DPlayer.get(player); + if(dplayer!=null){ + if(dplayer.isInWorldChat){ + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerQuit(PlayerQuitEvent event){ + DPlayer dplayer=DPlayer.get(event.getPlayer()); + if(dplayer!=null){ + //dplayer.goOffline(); + dplayer.leave(); + dplayer.player.kickPlayer("You have left the game!"); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerJoin(PlayerJoinEvent event){ + + + + + //DOfflinePlayer.check(event.getPlayer()); + } + + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerDeath(PlayerDeathEvent event){ + DPlayer dplayer=DPlayer.get(event.getEntity()); + if(dplayer!=null){ + dplayer.respawnInventory.addAll(event.getDrops()); + + //Delete all drops + for(ItemStack istack:event.getDrops()){ + istack.setTypeId(0); + } + } + } + + //Deny Player Cmds + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerCommand(PlayerCommandPreprocessEvent event){ + if(DungeonsXL.p.permission.has(event.getPlayer(), "dungeonsxl.cmd")||event.getPlayer().isOp()){ + return; + } + + DPlayer dplayer=DPlayer.get(event.getPlayer()); + if(dplayer!=null){ + if(!dplayer.isEditing){ + String[] splittedCmd=event.getMessage().split(" "); + if(!splittedCmd[0].equalsIgnoreCase("/dungeon") && !splittedCmd[0].equalsIgnoreCase("/dungeonsxl") && !splittedCmd[0].equalsIgnoreCase("/dxl")){ + p.msg(event.getPlayer(), ChatColor.RED+"Befehle sind während des Dungeons nicht erlaubt"); + event.setCancelled(true); + } + } + } + } + + + //Inventory Events + @EventHandler(priority = EventPriority.HIGH) + public void onInventoryOpen(InventoryOpenEvent event){ + GameChest.onOpenInventory(event); + } +} diff --git a/DungeonsXL/worldconfig.yml b/DungeonsXL/worldconfig.yml new file mode 100644 index 00000000..eadfb312 --- /dev/null +++ b/DungeonsXL/worldconfig.yml @@ -0,0 +1,56 @@ +classes: + 1: + name: Krieger + items: + - 276,1 + - 302,1 + - 303,1 + - 304,1 + - 305,1 + - 364,1 + hasdog: false + 2: + name: Tank + items: + - 279,1 + - 310,1 + - 307,1 + - 308,1 + - 309,1 + - 364,3 + hasdog: false + 3: + name: Jäger + items: + - 261,1 + - 262,128 + - 268,1 + - 298,1 + - 299,1 + - 300,1 + - 301,1 + - 364,3 + - 363,10 + hasdog: true + 4: + name: Bogenschütze + items: + - 261,1 + - 262,128 + - 272,1 + - 302,1 + - 299,1 + - 300,1 + - 301,1 + - 364,3 + 5: + name: Magier + items: + - 298, 1 + - 315, 1 + - 373,16385,3 + - 373,16389,3 + - 373,16387,2 + - 373,16387,2 + - 373,16394,3 + - 364,8 \ No newline at end of file