From 19a1060324534ebe3e42bed076badcb7153c31dd Mon Sep 17 00:00:00 2001 From: Grafe Date: Tue, 26 Mar 2013 13:50:35 +0100 Subject: [PATCH] Moved GameCheckpoint to SIGNCheckpoint Signed-off-by: Grafe --- src/com/dre/dungeonsxl/DPlayer.java | 13 ++--- src/com/dre/dungeonsxl/P.java | 3 -- .../dre/dungeonsxl/game/GameCheckpoint.java | 49 ------------------- .../dungeonsxl/listener/PlayerListener.java | 6 +-- .../dre/dungeonsxl/signs/SIGNCheckpoint.java | 20 +++----- 5 files changed, 14 insertions(+), 77 deletions(-) delete mode 100644 src/com/dre/dungeonsxl/game/GameCheckpoint.java diff --git a/src/com/dre/dungeonsxl/DPlayer.java b/src/com/dre/dungeonsxl/DPlayer.java index 7bacdf88..ec0aa306 100644 --- a/src/com/dre/dungeonsxl/DPlayer.java +++ b/src/com/dre/dungeonsxl/DPlayer.java @@ -19,7 +19,6 @@ import org.bukkit.inventory.ItemStack; import org.getspout.spoutapi.Spout; import org.getspout.spoutapi.player.SpoutPlayer; -import com.dre.dungeonsxl.game.GameCheckpoint; import com.dre.dungeonsxl.game.GameWorld; public class DPlayer { @@ -41,7 +40,7 @@ public class DPlayer { public boolean isFinished=false; public DClass dclass; - public GameCheckpoint checkpoint; + public Location checkpoint; public Wolf wolf; public int wolfRespawnTime=30; public long offlineTime; @@ -130,7 +129,6 @@ public class DPlayer { try { file.createNewFile(); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } @@ -142,7 +140,6 @@ public class DPlayer { try { playerConfig.save(file); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } @@ -212,7 +209,7 @@ public class DPlayer { if(this.checkpoint==null){ this.player.teleport(dgroup.getGworld().locStart); }else{ - this.player.teleport(this.checkpoint.location); + this.player.teleport(this.checkpoint); } if(this.wolf!=null){ this.wolf.teleport(this.player); @@ -360,7 +357,7 @@ public class DPlayer { } } - public void setCheckpoint(GameCheckpoint checkpoint){ + public void setCheckpoint(Location checkpoint){ this.checkpoint=checkpoint; } @@ -429,9 +426,9 @@ public class DPlayer { dplayer.wolf.teleport(dgroup.getGworld().locStart); } }else{ - dplayer.player.teleport(dplayer.checkpoint.location); + dplayer.player.teleport(dplayer.checkpoint); if(dplayer.wolf!=null){ - dplayer.wolf.teleport(dplayer.checkpoint.location); + dplayer.wolf.teleport(dplayer.checkpoint); } } diff --git a/src/com/dre/dungeonsxl/P.java b/src/com/dre/dungeonsxl/P.java index ae56d9b9..5a8aa356 100644 --- a/src/com/dre/dungeonsxl/P.java +++ b/src/com/dre/dungeonsxl/P.java @@ -30,7 +30,6 @@ import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; import com.dre.dungeonsxl.commands.DCommandRoot; -import com.dre.dungeonsxl.game.GameCheckpoint; import com.dre.dungeonsxl.game.GameWorld; import com.dre.dungeonsxl.listener.BlockListener; import com.dre.dungeonsxl.listener.CommandListener; @@ -139,7 +138,6 @@ public class P extends JavaPlugin{ DPortal.portals.clear(); LeaveSign.lsigns.clear(); DCommandRoot.root.commands.clear(); - GameCheckpoint.gcheckpoints.clear(); //Delete Worlds GameWorld.deleteAll(); @@ -190,7 +188,6 @@ public class P extends JavaPlugin{ p.getServer().getScheduler().scheduleSyncRepeatingTask(p, new Runnable() { public void run() { GameWorld.update(); - GameCheckpoint.update(); DPlayer.update(true); } }, 0L, 20L); diff --git a/src/com/dre/dungeonsxl/game/GameCheckpoint.java b/src/com/dre/dungeonsxl/game/GameCheckpoint.java deleted file mode 100644 index af39313b..00000000 --- a/src/com/dre/dungeonsxl/game/GameCheckpoint.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.dre.dungeonsxl.game; - -import java.util.concurrent.CopyOnWriteArrayList; - -import org.bukkit.Location; - -import com.dre.dungeonsxl.DPlayer; -import com.dre.dungeonsxl.P; - - -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); - P.p.msg(dplayer.player, P.p.language.get("Player_CheckpointReached"));//ChatColor.GOLD+"Checkpoint erreicht!"); - gpoint.dplayerHasUsed.add(dplayer); - } - } - } - } - } - - -} diff --git a/src/com/dre/dungeonsxl/listener/PlayerListener.java b/src/com/dre/dungeonsxl/listener/PlayerListener.java index 5967e151..cc1bdf1e 100644 --- a/src/com/dre/dungeonsxl/listener/PlayerListener.java +++ b/src/com/dre/dungeonsxl/listener/PlayerListener.java @@ -236,13 +236,13 @@ public class PlayerListener implements Listener{ dplayer.wolf.teleport(dgroup.getGworld().locStart); } }else{ - event.setRespawnLocation(dplayer.checkpoint.location); + event.setRespawnLocation(dplayer.checkpoint); //Da einige Plugins einen anderen Respawn setzen wird ein Scheduler gestartet der den Player nach einer Sekunde teleportiert. - p.getServer().getScheduler().scheduleSyncDelayedTask(p, new RespawnRunnable(player,dplayer.checkpoint.location), 10); + p.getServer().getScheduler().scheduleSyncDelayedTask(p, new RespawnRunnable(player,dplayer.checkpoint), 10); if(dplayer.wolf!=null){ - dplayer.wolf.teleport(dplayer.checkpoint.location); + dplayer.wolf.teleport(dplayer.checkpoint); } } } diff --git a/src/com/dre/dungeonsxl/signs/SIGNCheckpoint.java b/src/com/dre/dungeonsxl/signs/SIGNCheckpoint.java index 3f5f4d52..29d85baf 100644 --- a/src/com/dre/dungeonsxl/signs/SIGNCheckpoint.java +++ b/src/com/dre/dungeonsxl/signs/SIGNCheckpoint.java @@ -2,7 +2,8 @@ package com.dre.dungeonsxl.signs; import org.bukkit.block.Sign; -import com.dre.dungeonsxl.game.GameCheckpoint; +import com.dre.dungeonsxl.DPlayer; +import com.dre.dungeonsxl.P; import com.dre.dungeonsxl.game.GameWorld; public class SIGNCheckpoint extends DSign{ @@ -13,7 +14,6 @@ public class SIGNCheckpoint extends DSign{ public SIGNCheckpoint(Sign sign, GameWorld gworld) { super(sign, gworld); - // TODO Auto-generated constructor stub } @Override @@ -25,22 +25,14 @@ public class SIGNCheckpoint extends DSign{ @Override public void onInit() { - String lines[] = sign.getLines(); - int radius = 0; - - if(lines[1] != null ){ - if(lines[1].length() > 0){ - radius = p.parseInt(lines[1]); - } - } - - new GameCheckpoint(gworld, sign.getLocation(), radius); sign.setTypeId(0); } @Override public void onTrigger() { - // TODO Auto-generated method stub - + for(DPlayer dplayer:DPlayer.get(this.gworld.world)){ + dplayer.setCheckpoint(this.sign.getLocation()); + P.p.msg(dplayer.player, P.p.language.get("Player_CheckpointReached")); + } } }