Finished new Sign system and added Triggers

Signed-off-by: Grafe <flingelfrank@hotmail.com>
This commit is contained in:
Grafe 2013-03-27 01:02:05 +01:00
parent 0ed668884a
commit 90a625cae0
22 changed files with 552 additions and 210 deletions

View File

@ -1,5 +1,5 @@
name: DungeonsXL name: DungeonsXL
version: 0.7.6 version: 0.8
main: com.dre.dungeonsxl.P main: com.dre.dungeonsxl.P
authors: [Frank Baumann] authors: [Frank Baumann]
softdepend: [Vault] softdepend: [Vault]

View File

@ -20,6 +20,7 @@ import org.getspout.spoutapi.Spout;
import org.getspout.spoutapi.player.SpoutPlayer; import org.getspout.spoutapi.player.SpoutPlayer;
import com.dre.dungeonsxl.game.GameWorld; import com.dre.dungeonsxl.game.GameWorld;
import com.dre.dungeonsxl.signs.DSign;
public class DPlayer { public class DPlayer {
public static P p=P.p; public static P p=P.p;
@ -403,7 +404,6 @@ public class DPlayer {
public static void update(boolean updateSecond){ public static void update(boolean updateSecond){
for(DPlayer dplayer:players){ for(DPlayer dplayer:players){
if(!updateSecond){ if(!updateSecond){
//Check in World
if(!dplayer.player.getWorld().equals(dplayer.world)){ if(!dplayer.player.getWorld().equals(dplayer.world)){
if(dplayer.isEditing){ if(dplayer.isEditing){
EditWorld eworld=EditWorld.get(dplayer.world); EditWorld eworld=EditWorld.get(dplayer.world);
@ -417,8 +417,6 @@ public class DPlayer {
} else { } else {
GameWorld gworld = GameWorld.get(dplayer.world); GameWorld gworld = GameWorld.get(dplayer.world);
if(gworld != null){ if(gworld != null){
if(gworld!=null){
DGroup dgroup=DGroup.get(dplayer.player); DGroup dgroup=DGroup.get(dplayer.player);
if(dplayer.checkpoint == null){ if(dplayer.checkpoint == null){
dplayer.player.teleport(dgroup.getGworld().locStart); dplayer.player.teleport(dgroup.getGworld().locStart);
@ -432,7 +430,6 @@ public class DPlayer {
} }
} }
//Respawn Items //Respawn Items
for(ItemStack istack : dplayer.respawnInventory){ for(ItemStack istack : dplayer.respawnInventory){
if(istack != null){ if(istack != null){
@ -443,8 +440,10 @@ public class DPlayer {
} }
} }
} }
}
} else { } else {
GameWorld gworld = GameWorld.get(dplayer.world);
if(gworld != null){
//Update Wolf //Update Wolf
if(dplayer.wolf!=null){ if(dplayer.wolf!=null){
if(dplayer.wolf.isDead()){ if(dplayer.wolf.isDead()){
@ -464,6 +463,16 @@ public class DPlayer {
dplayer.leave(); dplayer.leave();
} }
} }
//Check Distance Trigger Signs
for(DSign sign : gworld.dSigns){
if(sign.isDistanceTrigger()){
if(dplayer.player.getLocation().distance(sign.getSign().getLocation()) < sign.getDtDistance()){
sign.onTrigger();
}
}
}
}
} }
} }
} }

View File

@ -75,10 +75,8 @@ public class EditWorld {
out.close(); out.close();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -88,7 +86,7 @@ public class EditWorld {
Sign sign = (Sign) block.getState(); Sign sign = (Sign) block.getState();
String[] lines=sign.getLines(); String[] lines=sign.getLines();
if(lines[1].equalsIgnoreCase("lobby")){ if(lines[0].equalsIgnoreCase("[lobby]")){
this.lobby=block.getLocation(); this.lobby=block.getLocation();
} }
} }
@ -173,10 +171,8 @@ public class EditWorld {
os.close(); os.close();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -61,6 +61,7 @@ public class LanguageReader {
defaults.put("Player_PortalDeleted","&6Portal gelöscht!"); defaults.put("Player_PortalDeleted","&6Portal gelöscht!");
defaults.put("Player_PortalProgress","&6Erster Block gewählt, nun der zweite!"); defaults.put("Player_PortalProgress","&6Erster Block gewählt, nun der zweite!");
defaults.put("Player_PortalCreated","&6Portal erstellt!"); defaults.put("Player_PortalCreated","&6Portal erstellt!");
defaults.put("Player_SignCreated","&6Schild erstellt!");
/* Cmds */ /* Cmds */
defaults.put("Cmd_Chat_DungeonChat","&6Du bist nun im Dungeon-Chat"); defaults.put("Cmd_Chat_DungeonChat","&6Du bist nun im Dungeon-Chat");
@ -101,6 +102,7 @@ public class LanguageReader {
defaults.put("Error_SpoutCraftOnly","&4Du brauchst SpoutCraft um diesen Dungeon spielen zu können!"); defaults.put("Error_SpoutCraftOnly","&4Du brauchst SpoutCraft um diesen Dungeon spielen zu können!");
defaults.put("Error_NoPortal","&4Du musst ein Portal anschauen!"); defaults.put("Error_NoPortal","&4Du musst ein Portal anschauen!");
defaults.put("Error_NoPlayerCommand","&6/dxl &v1&4 kann man nicht als Spieler ausführen!"); defaults.put("Error_NoPlayerCommand","&6/dxl &v1&4 kann man nicht als Spieler ausführen!");
defaults.put("Error_SignWrongFormat","&4 Das Schild ist nicht im richtigen Format!");
/* Help */ /* Help */
defaults.put("Help_Cmd_Chat","/dxl chat - Ändert den Chat-Modus"); defaults.put("Help_Cmd_Chat","/dxl chat - Ändert den Chat-Modus");

View File

@ -50,8 +50,10 @@ public class GameWorld {
public CopyOnWriteArrayList<Sign> signClass=new CopyOnWriteArrayList<Sign>(); public CopyOnWriteArrayList<Sign> signClass=new CopyOnWriteArrayList<Sign>();
public CopyOnWriteArrayList<DMob> dmobs = new CopyOnWriteArrayList<DMob>(); public CopyOnWriteArrayList<DMob> dmobs = new CopyOnWriteArrayList<DMob>();
public CopyOnWriteArrayList<GameChest> gchests = new CopyOnWriteArrayList<GameChest>(); public CopyOnWriteArrayList<GameChest> gchests = new CopyOnWriteArrayList<GameChest>();
public CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<DSign>();
public DConfig config; public DConfig config;
public GameWorld(){ public GameWorld(){
gworlds.add(this); gworlds.add(this);
@ -74,28 +76,17 @@ public class GameWorld {
public void checkSign(Block block){ public void checkSign(Block block){
if((block.getState() instanceof Sign)){ if((block.getState() instanceof Sign)){
Sign sign = (Sign) block.getState(); Sign sign = (Sign) block.getState();
DSign.create(sign, this); dSigns.add(DSign.create(sign, this));
} }
} }
public void startGame() { public void startGame() {
this.isPlaying=true; this.isPlaying=true;
ObjectInputStream os;
try {
os = new ObjectInputStream(new FileInputStream(new File("DXL_Game_"+this.id+"/DXLData.data")));
int length=os.readInt(); for(DSign dSign : this.dSigns){
for(int i=0; i<length; i++){ if(!dSign.isOnDungeonInit()){
int x=os.readInt(); dSign.onInit();
int y=os.readInt();
int z=os.readInt();
Block block=this.world.getBlockAt(x, y, z);
this.checkSign(block);
} }
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} }
} }
@ -165,13 +156,11 @@ public class GameWorld {
} }
public void delete(){ public void delete(){
//for(GameWorld gworld:gworlds){
gworlds.remove(this); gworlds.remove(this);
p.getServer().unloadWorld(this.world,true); p.getServer().unloadWorld(this.world,true);
File dir = new File("DXL_Game_"+this.id); File dir = new File("DXL_Game_"+this.id);
p.removeDirectory(dir); p.removeDirectory(dir);
//}
} }
public static GameWorld load(String name){ public static GameWorld load(String name){

View File

@ -9,8 +9,10 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.block.BlockSpreadEvent; import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.scheduler.BukkitRunnable;
import com.dre.dungeonsxl.DGSign; import com.dre.dungeonsxl.DGSign;
import com.dre.dungeonsxl.DPortal; import com.dre.dungeonsxl.DPortal;
@ -19,6 +21,7 @@ import com.dre.dungeonsxl.EditWorld;
import com.dre.dungeonsxl.LeaveSign; import com.dre.dungeonsxl.LeaveSign;
import com.dre.dungeonsxl.game.GamePlaceableBlock; import com.dre.dungeonsxl.game.GamePlaceableBlock;
import com.dre.dungeonsxl.game.GameWorld; import com.dre.dungeonsxl.game.GameWorld;
import com.dre.dungeonsxl.signs.DSign;
public class BlockListener implements Listener { public class BlockListener implements Listener {
@ -112,8 +115,6 @@ public class BlockListener implements Listener {
//Group Signs //Group Signs
if (eworld == null) { if (eworld == null) {
if (player.isOp() || P.p.permission.has(player, "dxl.sign")) { if (player.isOp() || P.p.permission.has(player, "dxl.sign")) {
if (lines[0].equalsIgnoreCase("[DXL]")) { if (lines[0].equalsIgnoreCase("[DXL]")) {
if (lines[1].equalsIgnoreCase("Group")) { if (lines[1].equalsIgnoreCase("Group")) {
String dungeonName = lines[2]; String dungeonName = lines[2];
@ -128,8 +129,7 @@ public class BlockListener implements Listener {
} }
} }
} }
} } else if(lines[1].equalsIgnoreCase("Leave")) {
if(lines[1].equalsIgnoreCase("Leave")){
if (block.getState() instanceof Sign) { if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState(); Sign sign = (Sign) block.getState();
new LeaveSign(sign); new LeaveSign(sign);
@ -138,20 +138,31 @@ public class BlockListener implements Listener {
} }
} }
} }
} } else { //Editworld Signs
Sign sign = (Sign) block.getState();
if(sign != null){
sign.setLine(0, lines[0]);
sign.setLine(1, lines[1]);
sign.setLine(2, lines[2]);
sign.setLine(3, lines[3]);
//Editworld Signs DSign dsign = DSign.create(sign, null);
else{ if (dsign != null) {
if(lines[0].equalsIgnoreCase("[DXL]")){ if (player.isOp() || P.p.permission.has(player, dsign.getPermissions())) {
eworld.checkSign(event.getBlock()); if (dsign.check()) {
eworld.sign.add(event.getBlock()); eworld.checkSign(block);
eworld.sign.add(block);
P.p.msg(player, P.p.language.get("Player_SignCreated"));
} else { } else {
eworld.sign.remove(event.getBlock()); P.p.msg(player, P.p.language.get("Error_SignWrongFormat"));
}
} else {
P.p.msg(player, P.p.language.get("Error_NoPermissions"));
}
}
} }
} }
} }
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
@ -174,4 +185,33 @@ public class BlockListener implements Listener {
} }
@EventHandler(priority = EventPriority.NORMAL)
public void onBlockRedstoneEvent(BlockRedstoneEvent event){
new RedstoneEventTask(event).runTaskLater(P.p, 1);
}
public class RedstoneEventTask extends BukkitRunnable {
private final BlockRedstoneEvent event;
public RedstoneEventTask(BlockRedstoneEvent event) {
this.event = event;
}
public void run() {
for(GameWorld gworld : GameWorld.gworlds){
if(event.getBlock().getWorld() == gworld.world){
for(DSign sign : gworld.dSigns){
if(sign.isRedstoneTrigger()){
if(sign.getRtBlock().isBlockPowered()){
sign.onTrigger();
}
}
}
}
}
}
}
} }

View File

@ -36,23 +36,15 @@ public class EntityListener implements Listener{
World world=event.getLocation().getWorld(); World world=event.getLocation().getWorld();
EditWorld eworld = EditWorld.get(world); 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); GameWorld gworld = GameWorld.get(world);
if(gworld!=null){ if(eworld != null || gworld!=null){
if( if(
event.getSpawnReason() == SpawnReason.CHUNK_GEN || event.getSpawnReason() == SpawnReason.CHUNK_GEN ||
event.getSpawnReason() == SpawnReason.BREEDING || event.getSpawnReason() == SpawnReason.BREEDING ||
event.getSpawnReason()==SpawnReason.NATURAL){ event.getSpawnReason() == SpawnReason.NATURAL ||
event.getSpawnReason() == SpawnReason.DEFAULT)
{
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -1,5 +1,8 @@
package com.dre.dungeonsxl.signs; package com.dre.dungeonsxl.signs;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import com.dre.dungeonsxl.P; import com.dre.dungeonsxl.P;
@ -8,19 +11,72 @@ import com.dre.dungeonsxl.game.GameWorld;
public abstract class DSign { public abstract class DSign {
protected static P p = P.p; protected static P p = P.p;
public static String name = "";
public static String buildPermissions = "";
public static boolean onDungeonInit = false;
protected Sign sign; protected Sign sign;
protected GameWorld gworld; protected GameWorld gworld;
//Distance Trigger
private boolean isDistanceTrigger = false;
private int dtDistance = 5;
//Redstone Trigger
private boolean isRedstoneTrigger = false;
private Block rtBlock;
//Sign Trigger
private boolean isSignTrigger = false;
private int stId;
public abstract boolean check();
public abstract String getPermissions();
public abstract boolean isOnDungeonInit();
public DSign(Sign sign, GameWorld gworld){ public DSign(Sign sign, GameWorld gworld){
this.sign = sign; this.sign = sign;
this.gworld = gworld; this.gworld = gworld;
//Check Trigger
String[] splitted = sign.getLine(3).split(" ");
if(splitted.length > 0){
if(splitted[0].equalsIgnoreCase("R")){
if(sign.getBlock().getType() == Material.WALL_SIGN){
switch(sign.getData().getData()){
case 5:
rtBlock = sign.getBlock().getRelative(BlockFace.WEST);
break;
case 4:
rtBlock = sign.getBlock().getRelative(BlockFace.EAST);
break;
case 3:
rtBlock = sign.getBlock().getRelative(BlockFace.NORTH);
break;
case 2:
rtBlock = sign.getBlock().getRelative(BlockFace.SOUTH);
break;
}
} else {
rtBlock = sign.getBlock().getRelative(BlockFace.DOWN);
} }
public abstract boolean check(Sign sign); if(rtBlock != null){
this.isRedstoneTrigger = true;
}
} else if(splitted[0].equalsIgnoreCase("D")){
this.isDistanceTrigger = true;
if(splitted.length > 1){
dtDistance = p.parseInt(splitted[1]);
}
} else if(splitted[0].equalsIgnoreCase("T")){
this.isSignTrigger = true;
if(splitted.length > 1){
stId = p.parseInt(splitted[1]);
}
}
}
}
public void onInit(){ public void onInit(){
@ -60,8 +116,47 @@ public abstract class DSign {
dSign = new SIGNSoundMsg(sign, gworld); dSign = new SIGNSoundMsg(sign, gworld);
} else if (lines[0].equalsIgnoreCase("["+SIGNStart.name+"]")) { } else if (lines[0].equalsIgnoreCase("["+SIGNStart.name+"]")) {
dSign = new SIGNStart(sign, gworld); dSign = new SIGNStart(sign, gworld);
} else if (lines[0].equalsIgnoreCase("["+SIGNTrigger.name+"]")) {
dSign = new SIGNTrigger(sign, gworld);
}
if (dSign != null && gworld != null) {
if (dSign.isOnDungeonInit()) {
dSign.onInit();
}
} }
return dSign; return dSign;
} }
//Getter anb Setter
public boolean isRedstoneTrigger() {
return isRedstoneTrigger;
}
public boolean isDistanceTrigger() {
return isDistanceTrigger;
}
public Block getRtBlock() {
return rtBlock;
}
public int getDtDistance() {
return dtDistance;
}
public boolean isSignTrigger() {
return isSignTrigger;
}
public int getStId() {
return stId;
}
public Sign getSign() {
return sign;
}
} }

View File

@ -9,30 +9,49 @@ import com.dre.dungeonsxl.game.GameWorld;
public class SIGNCheckpoint extends DSign{ public class SIGNCheckpoint extends DSign{
public static String name = "Checkpoint"; public static String name = "Checkpoint";
public static String buildPermissions = "dxl.sign.checkpoint"; private String buildPermissions = "dxl.sign.checkpoint";
public static boolean onDungeonInit = false; private boolean onDungeonInit = false;
//Variables
private boolean initialized;
public SIGNCheckpoint(Sign sign, GameWorld gworld) { public SIGNCheckpoint(Sign sign, GameWorld gworld) {
super(sign, gworld); super(sign, gworld);
} }
@Override @Override
public boolean check(Sign sign) { public boolean check() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return true;
} }
@Override @Override
public void onInit() { public void onInit() {
sign.setTypeId(0); sign.getBlock().setTypeId(0);
initialized = true;
} }
@Override @Override
public void onTrigger() { public void onTrigger() {
if(initialized){
for(DPlayer dplayer:DPlayer.get(this.gworld.world)){ for(DPlayer dplayer:DPlayer.get(this.gworld.world)){
dplayer.setCheckpoint(this.sign.getLocation()); dplayer.setCheckpoint(this.sign.getLocation());
P.p.msg(dplayer.player, P.p.language.get("Player_CheckpointReached")); P.p.msg(dplayer.player, P.p.language.get("Player_CheckpointReached"));
} }
this.gworld.dSigns.remove(this);
}
}
@Override
public String getPermissions() {
return buildPermissions;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
} }
} }

View File

@ -8,18 +8,18 @@ import com.dre.dungeonsxl.game.GameWorld;
public class SIGNChest extends DSign{ public class SIGNChest extends DSign{
public static String name = "Chest"; public static String name = "Chest";
public static String buildPermissions = "dxl.sign.chest"; public String buildPermissions = "dxl.sign.chest";
public static boolean onDungeonInit = false; public boolean onDungeonInit = false;
public SIGNChest(Sign sign, GameWorld gworld) { public SIGNChest(Sign sign, GameWorld gworld) {
super(sign, gworld); super(sign, gworld);
} }
@Override @Override
public boolean check(Sign sign) { public boolean check() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return true;
} }
@Override @Override
@ -40,6 +40,16 @@ public class SIGNChest extends DSign{
} }
} }
sign.setTypeId(0); sign.getBlock().setTypeId(0);
}
@Override
public String getPermissions() {
return buildPermissions;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
} }
} }

View File

@ -7,18 +7,18 @@ import com.dre.dungeonsxl.game.GameWorld;
public class SIGNChunkUpdater extends DSign{ public class SIGNChunkUpdater extends DSign{
public static String name = "ChunkUpdater"; public static String name = "ChunkUpdater";
public static String buildPermissions = "dxl.sign.chunkupdater"; public String buildPermissions = "dxl.sign.chunkupdater";
public static boolean onDungeonInit = true; public boolean onDungeonInit = true;
public SIGNChunkUpdater(Sign sign, GameWorld gworld) { public SIGNChunkUpdater(Sign sign, GameWorld gworld) {
super(sign, gworld); super(sign, gworld);
} }
@Override @Override
public boolean check(Sign sign) { public boolean check() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return true;
} }
@Override @Override
@ -38,6 +38,16 @@ public class SIGNChunkUpdater extends DSign{
chunk.load(); chunk.load();
gworld.loadedChunks.add(chunk); gworld.loadedChunks.add(chunk);
} }
sign.setTypeId(0); sign.getBlock().setTypeId(0);
}
@Override
public String getPermissions() {
return buildPermissions;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
} }
} }

View File

@ -11,23 +11,24 @@ import com.dre.dungeonsxl.game.GameWorld;
public class SIGNClasses extends DSign{ public class SIGNClasses extends DSign{
public static String name = "Classes"; public static String name = "Classes";
public static String buildPermissions = "dxl.sign.classes"; public String buildPermissions = "dxl.sign.classes";
public static boolean onDungeonInit = true; public boolean onDungeonInit = true;
public SIGNClasses(Sign sign, GameWorld gworld) { public SIGNClasses(Sign sign, GameWorld gworld) {
super(sign, gworld); super(sign, gworld);
} }
@Override @Override
public boolean check(Sign sign) { public boolean check() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return true;
} }
@Override @Override
public void onInit() { public void onInit() {
if(!gworld.config.isLobbyDisabled()){ if(!gworld.config.isLobbyDisabled()){
int[] direction=DGSign.getDirection(sign.getBlock().getData()); int[] direction=DGSign.getDirection(sign.getBlock().getData());
int directionX=direction[0]; int directionX=direction[0];
int directionZ=direction[1]; int directionZ=direction[1];
@ -54,16 +55,28 @@ public class SIGNClasses extends DSign{
classSign.setLine(2, ""); classSign.setLine(2, "");
classSign.setLine(3, ChatColor.DARK_BLUE+"############"); classSign.setLine(3, ChatColor.DARK_BLUE+"############");
classSign.update(); classSign.update();
gworld.signClass.add(classSign); gworld.signClass.add(classSign);
}else{ }else{
break; break;
} }
xx=xx+directionX; xx=xx+directionX;
zz=zz+directionZ; zz=zz+directionZ;
} }
} }
} else { } else {
sign.setTypeId(0); sign.getBlock().setTypeId(0);
} }
} }
@Override
public String getPermissions() {
return buildPermissions;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -7,18 +7,18 @@ import com.dre.dungeonsxl.game.GameWorld;
public class SIGNEnd extends DSign{ public class SIGNEnd extends DSign{
public static String name = "End"; public static String name = "End";
public static String buildPermissions = "dxl.sign.end"; public String buildPermissions = "dxl.sign.end";
public static boolean onDungeonInit = false; public boolean onDungeonInit = false;
public SIGNEnd(Sign sign, GameWorld gworld) { public SIGNEnd(Sign sign, GameWorld gworld) {
super(sign, gworld); super(sign, gworld);
} }
@Override @Override
public boolean check(Sign sign) { public boolean check() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return true;
} }
@Override @Override
@ -30,4 +30,14 @@ public class SIGNEnd extends DSign{
sign.setLine(3, ChatColor.DARK_BLUE+"############"); sign.setLine(3, ChatColor.DARK_BLUE+"############");
sign.update(); sign.update();
} }
@Override
public String getPermissions() {
return buildPermissions;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -7,18 +7,18 @@ import com.dre.dungeonsxl.game.GameWorld;
public class SIGNLeave extends DSign{ public class SIGNLeave extends DSign{
public static String name = "Leave"; public static String name = "Leave";
public static String buildPermissions = "dxl.sign.leave"; public String buildPermissions = "dxl.sign.leave";
public static boolean onDungeonInit = true; public boolean onDungeonInit = true;
public SIGNLeave(Sign sign, GameWorld gworld) { public SIGNLeave(Sign sign, GameWorld gworld) {
super(sign, gworld); super(sign, gworld);
} }
@Override @Override
public boolean check(Sign sign) { public boolean check() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return true;
} }
@Override @Override
@ -30,4 +30,14 @@ public class SIGNLeave extends DSign{
sign.setLine(3, ChatColor.BLUE+"############"); sign.setLine(3, ChatColor.BLUE+"############");
sign.update(); sign.update();
} }
@Override
public String getPermissions() {
return buildPermissions;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -6,23 +6,33 @@ import com.dre.dungeonsxl.game.GameWorld;
public class SIGNLobby extends DSign{ public class SIGNLobby extends DSign{
public static String name = "Lobby"; public static String name = "Lobby";
public static String buildPermissions = "dxl.sign.lobby"; public String buildPermissions = "dxl.sign.lobby";
public static boolean onDungeonInit = true; public boolean onDungeonInit = true;
public SIGNLobby(Sign sign, GameWorld gworld) { public SIGNLobby(Sign sign, GameWorld gworld) {
super(sign, gworld); super(sign, gworld);
} }
@Override @Override
public boolean check(Sign sign) { public boolean check() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return true;
} }
@Override @Override
public void onInit() { public void onInit() {
gworld.locLobby = sign.getLocation(); gworld.locLobby = sign.getLocation();
sign.setTypeId(0); sign.getBlock().setTypeId(0);
}
@Override
public String getPermissions() {
return buildPermissions;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
} }
} }

View File

@ -16,8 +16,8 @@ import com.dre.dungeonsxl.game.GameWorld;
public class SIGNMob extends DSign{ public class SIGNMob extends DSign{
public static String name = "Mob"; public static String name = "Mob";
public static String buildPermissions = "dxl.sign.mob"; public String buildPermissions = "dxl.sign.mob";
public static boolean onDungeonInit = false; public boolean onDungeonInit = false;
//Variables //Variables
@ -25,16 +25,17 @@ public class SIGNMob extends DSign{
private int maxinterval = 1; private int maxinterval = 1;
private int interval = 0; private int interval = 0;
private int amount = 1; private int amount = 1;
private boolean initialized;
public SIGNMob(Sign sign, GameWorld gworld) { public SIGNMob(Sign sign, GameWorld gworld) {
super(sign, gworld); super(sign, gworld);
} }
@Override @Override
public boolean check(Sign sign) { public boolean check() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return true;
} }
@Override @Override
@ -51,15 +52,21 @@ public class SIGNMob extends DSign{
} }
} }
} }
sign.setTypeId(0); sign.getBlock().setTypeId(0);
initialized = true;
} }
@Override @Override
public void onTrigger() { public void onTrigger() {
if(initialized){
MobSpawnScheduler scheduler = new MobSpawnScheduler(this); MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
int id = p.getServer().getScheduler().scheduleSyncRepeatingTask(p, scheduler, 0L, 20L); int id = p.getServer().getScheduler().scheduleSyncRepeatingTask(p, scheduler, 0L, 20L);
scheduler.id = id; scheduler.id = id;
initialized = false;
}
} }
public class MobSpawnScheduler implements Runnable{ public class MobSpawnScheduler implements Runnable{
@ -105,6 +112,7 @@ public class SIGNMob extends DSign{
amount--; amount--;
}else{ }else{
p.getServer().getScheduler().cancelTask(this.id); p.getServer().getScheduler().cancelTask(this.id);
sign.gworld.dSigns.remove(this);
} }
} }
@ -113,4 +121,14 @@ public class SIGNMob extends DSign{
sign.interval--; sign.interval--;
} }
} }
@Override
public String getPermissions() {
return buildPermissions;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -7,21 +7,22 @@ import com.dre.dungeonsxl.game.GameWorld;
public class SIGNMsg extends DSign{ public class SIGNMsg extends DSign{
public static String name = "Msg"; public static String name = "Msg";
public static String buildPermissions = "dxl.sign.msg"; public String buildPermissions = "dxl.sign.msg";
public static boolean onDungeonInit = false; public boolean onDungeonInit = false;
//Variables //Variables
private String msg; private String msg;
private boolean initialized;
public SIGNMsg(Sign sign, GameWorld gworld) { public SIGNMsg(Sign sign, GameWorld gworld) {
super(sign, gworld); super(sign, gworld);
} }
@Override @Override
public boolean check(Sign sign) { public boolean check() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return true;
} }
@Override @Override
@ -32,15 +33,31 @@ public class SIGNMsg extends DSign{
String msg = gworld.config.getMsg(p.parseInt(lines[1]),true); String msg = gworld.config.getMsg(p.parseInt(lines[1]),true);
if(msg!=null){ if(msg!=null){
this.msg = msg; this.msg = msg;
sign.setTypeId(0); sign.getBlock().setTypeId(0);
} }
} }
initialized = true;
} }
@Override @Override
public void onTrigger() { public void onTrigger() {
if(initialized){
for(Player player : gworld.world.getPlayers()){ for(Player player : gworld.world.getPlayers()){
p.msg(player, msg); p.msg(player, msg);
} }
this.gworld.dSigns.remove(this);
}
}
@Override
public String getPermissions() {
return buildPermissions;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
} }
} }

View File

@ -8,24 +8,34 @@ import com.dre.dungeonsxl.game.GameWorld;
public class SIGNPlace extends DSign{ public class SIGNPlace extends DSign{
public static String name = "Place"; public static String name = "Place";
public static String buildPermissions = "dxl.sign.place"; public String buildPermissions = "dxl.sign.place";
public static boolean onDungeonInit = false; public boolean onDungeonInit = false;
public SIGNPlace(Sign sign, GameWorld gworld) { public SIGNPlace(Sign sign, GameWorld gworld) {
super(sign, gworld); super(sign, gworld);
} }
@Override @Override
public boolean check(Sign sign) { public boolean check() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return true;
} }
@Override @Override
public void onInit() { public void onInit() {
String lines[] = sign.getLines(); String lines[] = sign.getLines();
gworld.placeableBlocks.add(new GamePlaceableBlock(sign.getBlock(), lines[1], lines[2]) ); gworld.placeableBlocks.add(new GamePlaceableBlock(sign.getBlock(), lines[1], lines[2]) );
sign.setTypeId(0); sign.getBlock().setTypeId(0);
}
@Override
public String getPermissions() {
return buildPermissions;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
} }
} }

View File

@ -7,18 +7,18 @@ import com.dre.dungeonsxl.game.GameWorld;
public class SIGNReady extends DSign{ public class SIGNReady extends DSign{
public static String name = "Ready"; public static String name = "Ready";
public static String buildPermissions = "dxl.sign.ready"; public String buildPermissions = "dxl.sign.ready";
public static boolean onDungeonInit = true; public boolean onDungeonInit = true;
public SIGNReady(Sign sign, GameWorld gworld) { public SIGNReady(Sign sign, GameWorld gworld) {
super(sign, gworld); super(sign, gworld);
} }
@Override @Override
public boolean check(Sign sign) { public boolean check() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return true;
} }
@Override @Override
@ -30,4 +30,14 @@ public class SIGNReady extends DSign{
sign.setLine(3, ChatColor.BLUE+"############"); sign.setLine(3, ChatColor.BLUE+"############");
sign.update(); sign.update();
} }
@Override
public String getPermissions() {
return buildPermissions;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
} }

View File

@ -12,10 +12,11 @@ import com.dre.dungeonsxl.game.GameWorld;
public class SIGNSoundMsg extends DSign{ public class SIGNSoundMsg extends DSign{
public static String name = "SoundMsg"; public static String name = "SoundMsg";
public static String buildPermissions = "dxl.sign.soundmsg"; public String buildPermissions = "dxl.sign.soundmsg";
public static boolean onDungeonInit = false; public boolean onDungeonInit = false;
//Variables //Variables
private boolean initialized;
private String msg; private String msg;
public SIGNSoundMsg(Sign sign, GameWorld gworld) { public SIGNSoundMsg(Sign sign, GameWorld gworld) {
@ -23,10 +24,10 @@ public class SIGNSoundMsg extends DSign{
} }
@Override @Override
public boolean check(Sign sign) { public boolean check() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return true;
} }
@Override @Override
@ -37,13 +38,16 @@ public class SIGNSoundMsg extends DSign{
String msg = gworld.config.getMsg(p.parseInt(lines[1]),true); String msg = gworld.config.getMsg(p.parseInt(lines[1]),true);
if(msg!=null){ if(msg!=null){
this.msg = msg; this.msg = msg;
sign.setTypeId(0); sign.getBlock().setTypeId(0);
} }
} }
initialized = true;
} }
@Override @Override
public void onTrigger() { public void onTrigger() {
if(initialized){
if(P.p.isSpoutEnabled){ if(P.p.isSpoutEnabled){
for(Player player : gworld.world.getPlayers()){ for(Player player : gworld.world.getPlayers()){
SpoutPlayer sPlayer = Spout.getServer().getPlayer(player.getName()); SpoutPlayer sPlayer = Spout.getServer().getPlayer(player.getName());
@ -52,5 +56,18 @@ public class SIGNSoundMsg extends DSign{
} }
} }
} }
this.gworld.dSigns.remove(this);
}
}
@Override
public String getPermissions() {
return buildPermissions;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
} }
} }

View File

@ -6,23 +6,33 @@ import com.dre.dungeonsxl.game.GameWorld;
public class SIGNStart extends DSign{ public class SIGNStart extends DSign{
public static String name = "Start"; public static String name = "Start";
public static String buildPermissions = "dxl.sign.start"; public String buildPermissions = "dxl.sign.start";
public static boolean onDungeonInit = true; public boolean onDungeonInit = true;
public SIGNStart(Sign sign, GameWorld gworld) { public SIGNStart(Sign sign, GameWorld gworld) {
super(sign, gworld); super(sign, gworld);
} }
@Override @Override
public boolean check(Sign sign) { public boolean check() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return true;
} }
@Override @Override
public void onInit() { public void onInit() {
gworld.locStart = sign.getLocation(); gworld.locStart = sign.getLocation();
sign.setTypeId(0); sign.getBlock().setTypeId(0);
}
@Override
public String getPermissions() {
return buildPermissions;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
} }
} }

View File

@ -0,0 +1,55 @@
package com.dre.dungeonsxl.signs;
import org.bukkit.block.Sign;
import com.dre.dungeonsxl.game.GameWorld;
public class SIGNTrigger extends DSign{
public static String name = "Trigger";
public String buildPermissions = "dxl.sign.trigger";
public boolean onDungeonInit = false;
//Variables
private int triggerId;
private boolean initialized;
public SIGNTrigger(Sign sign, GameWorld gworld) {
super(sign, gworld);
}
@Override
public boolean check() {
return true;
}
@Override
public void onInit() {
triggerId = p.parseInt(sign.getLine(1));
sign.getBlock().setTypeId(0);
initialized = true;
}
@Override
public void onTrigger() {
if(initialized){
for(DSign dsign : this.gworld.dSigns){
if(dsign.isSignTrigger()){
if(triggerId == dsign.getStId()){
dsign.onTrigger();
}
}
}
}
}
@Override
public String getPermissions() {
return buildPermissions;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
}