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
version: 0.7.6
version: 0.8
main: com.dre.dungeonsxl.P
authors: [Frank Baumann]
softdepend: [Vault]

View File

@ -20,6 +20,7 @@ import org.getspout.spoutapi.Spout;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.dre.dungeonsxl.game.GameWorld;
import com.dre.dungeonsxl.signs.DSign;
public class DPlayer {
public static P p=P.p;
@ -403,67 +404,75 @@ public class DPlayer {
public static void update(boolean updateSecond){
for(DPlayer dplayer:players){
if(!updateSecond){
//Check in World
if(!dplayer.player.getWorld().equals(dplayer.world)){
if(dplayer.isEditing){
EditWorld eworld=EditWorld.get(dplayer.world);
if(eworld!=null){
if(eworld.lobby==null){
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.getGworld().locStart);
if(dplayer.wolf!=null){
dplayer.wolf.teleport(dgroup.getGworld().locStart);
}
}else{
dplayer.player.teleport(dplayer.checkpoint);
if(dplayer.wolf!=null){
dplayer.wolf.teleport(dplayer.checkpoint);
}
} else {
GameWorld gworld = GameWorld.get(dplayer.world);
if(gworld != null){
DGroup dgroup=DGroup.get(dplayer.player);
if(dplayer.checkpoint == null){
dplayer.player.teleport(dgroup.getGworld().locStart);
if(dplayer.wolf != null){
dplayer.wolf.teleport(dgroup.getGworld().locStart);
}
//Respawn Items
for(ItemStack istack:dplayer.respawnInventory){
if(istack!=null){
dplayer.player.getInventory().addItem(istack);
}
}else{
dplayer.player.teleport(dplayer.checkpoint);
if(dplayer.wolf != null){
dplayer.wolf.teleport(dplayer.checkpoint);
}
dplayer.respawnInventory.clear();
}
//Respawn Items
for(ItemStack istack : dplayer.respawnInventory){
if(istack != null){
dplayer.player.getInventory().addItem(istack);
}
}
dplayer.respawnInventory.clear();
}
}
}
} else {
GameWorld gworld = GameWorld.get(dplayer.world);
if(gworld != null){
//Update Wolf
if(dplayer.wolf!=null){
if(dplayer.wolf.isDead()){
if(dplayer.wolfRespawnTime<=0){
dplayer.wolf=(Wolf) dplayer.world.spawnEntity(dplayer.player.getLocation(), EntityType.WOLF);
dplayer.wolf.setTamed(true);
dplayer.wolf.setOwner(dplayer.player);
dplayer.wolfRespawnTime=30;
}
dplayer.wolfRespawnTime--;
}
}
//Kick offline players
if(dplayer.offlineTime > 0){
if(dplayer.offlineTime < System.currentTimeMillis()){
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();
}
}
}
}
}else{
//Update Wolf
if(dplayer.wolf!=null){
if(dplayer.wolf.isDead()){
if(dplayer.wolfRespawnTime<=0){
dplayer.wolf=(Wolf) dplayer.world.spawnEntity(dplayer.player.getLocation(), EntityType.WOLF);
dplayer.wolf.setTamed(true);
dplayer.wolf.setOwner(dplayer.player);
dplayer.wolfRespawnTime=30;
}
dplayer.wolfRespawnTime--;
}
}
//Kick offline players
if(dplayer.offlineTime > 0){
if(dplayer.offlineTime < System.currentTimeMillis()){
dplayer.leave();
}
}
}
}
}

View File

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

View File

@ -61,6 +61,7 @@ public class LanguageReader {
defaults.put("Player_PortalDeleted","&6Portal gelöscht!");
defaults.put("Player_PortalProgress","&6Erster Block gewählt, nun der zweite!");
defaults.put("Player_PortalCreated","&6Portal erstellt!");
defaults.put("Player_SignCreated","&6Schild erstellt!");
/* Cmds */
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_NoPortal","&4Du musst ein Portal anschauen!");
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 */
defaults.put("Help_Cmd_Chat","/dxl chat - Ändert den Chat-Modus");

View File

@ -50,7 +50,9 @@ public class GameWorld {
public CopyOnWriteArrayList<Sign> signClass=new CopyOnWriteArrayList<Sign>();
public CopyOnWriteArrayList<DMob> dmobs = new CopyOnWriteArrayList<DMob>();
public CopyOnWriteArrayList<GameChest> gchests = new CopyOnWriteArrayList<GameChest>();
public CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<DSign>();
public DConfig config;
public GameWorld(){
gworlds.add(this);
@ -74,28 +76,17 @@ public class GameWorld {
public void checkSign(Block block){
if((block.getState() instanceof Sign)){
Sign sign = (Sign) block.getState();
DSign.create(sign, this);
dSigns.add(DSign.create(sign, this));
}
}
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; i<length; i++){
int x=os.readInt();
int y=os.readInt();
int z=os.readInt();
Block block=this.world.getBlockAt(x, y, z);
this.checkSign(block);
for(DSign dSign : this.dSigns){
if(!dSign.isOnDungeonInit()){
dSign.onInit();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
@ -165,13 +156,11 @@ public class GameWorld {
}
public void delete(){
//for(GameWorld gworld:gworlds){
gworlds.remove(this);
gworlds.remove(this);
p.getServer().unloadWorld(this.world,true);
File dir = new File("DXL_Game_"+this.id);
p.removeDirectory(dir);
//}
p.getServer().unloadWorld(this.world,true);
File dir = new File("DXL_Game_"+this.id);
p.removeDirectory(dir);
}
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.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.scheduler.BukkitRunnable;
import com.dre.dungeonsxl.DGSign;
import com.dre.dungeonsxl.DPortal;
@ -19,6 +21,7 @@ import com.dre.dungeonsxl.EditWorld;
import com.dre.dungeonsxl.LeaveSign;
import com.dre.dungeonsxl.game.GamePlaceableBlock;
import com.dre.dungeonsxl.game.GameWorld;
import com.dre.dungeonsxl.signs.DSign;
public class BlockListener implements Listener {
@ -74,8 +77,8 @@ public class BlockListener implements Listener {
}
//Editworld Signs
EditWorld eworld=EditWorld.get(block.getWorld());
if(eworld!=null){
EditWorld eworld = EditWorld.get(block.getWorld());
if(eworld != null){
eworld.sign.remove(event.getBlock());
}
@ -104,33 +107,30 @@ public class BlockListener implements Listener {
@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());
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() || P.p.permission.has(player, "dxl.sign")){
if(lines[0].equalsIgnoreCase("[DXL]")){
if(lines[1].equalsIgnoreCase("Group")){
String dungeonName=lines[2];
if (eworld == null) {
if (player.isOp() || P.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=P.p.parseInt(data[0]);
int maxPlayersPerGroup=P.p.parseInt(data[1]);
if(maxGroups>0 && maxPlayersPerGroup>0){
if(DGSign.tryToCreate(event.getBlock(), dungeonName, maxGroups, maxPlayersPerGroup)!=null){
if (data.length == 2) {
int maxGroups = P.p.parseInt(data[0]);
int maxPlayersPerGroup = P.p.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){
} else if(lines[1].equalsIgnoreCase("Leave")) {
if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState();
new LeaveSign(sign);
}
@ -138,20 +138,31 @@ public class BlockListener implements Listener {
}
}
}
}
//Editworld Signs
else{
if(lines[0].equalsIgnoreCase("[DXL]")){
eworld.checkSign(event.getBlock());
eworld.sign.add(event.getBlock());
}else{
eworld.sign.remove(event.getBlock());
} 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]);
DSign dsign = DSign.create(sign, null);
if (dsign != null) {
if (player.isOp() || P.p.permission.has(player, dsign.getPermissions())) {
if (dsign.check()) {
eworld.checkSign(block);
eworld.sign.add(block);
P.p.msg(player, P.p.language.get("Player_SignCreated"));
} else {
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)
@ -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

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

View File

@ -1,5 +1,8 @@
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 com.dre.dungeonsxl.P;
@ -8,20 +11,73 @@ import com.dre.dungeonsxl.game.GameWorld;
public abstract class DSign {
protected static P p = P.p;
public static String name = "";
public static String buildPermissions = "";
public static boolean onDungeonInit = false;
protected Sign sign;
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){
this.sign = sign;
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);
}
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 abstract boolean check(Sign sign);
public void onInit(){
}
@ -60,8 +116,47 @@ public abstract class DSign {
dSign = new SIGNSoundMsg(sign, gworld);
} else if (lines[0].equalsIgnoreCase("["+SIGNStart.name+"]")) {
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;
}
//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 static String name = "Checkpoint";
public static String buildPermissions = "dxl.sign.checkpoint";
public static boolean onDungeonInit = false;
private String buildPermissions = "dxl.sign.checkpoint";
private boolean onDungeonInit = false;
//Variables
private boolean initialized;
public SIGNCheckpoint(Sign sign, GameWorld gworld) {
super(sign, gworld);
}
@Override
public boolean check(Sign sign) {
public boolean check() {
// TODO Auto-generated method stub
return false;
return true;
}
@Override
public void onInit() {
sign.setTypeId(0);
sign.getBlock().setTypeId(0);
initialized = true;
}
@Override
public void onTrigger() {
for(DPlayer dplayer:DPlayer.get(this.gworld.world)){
dplayer.setCheckpoint(this.sign.getLocation());
P.p.msg(dplayer.player, P.p.language.get("Player_CheckpointReached"));
if(initialized){
for(DPlayer dplayer:DPlayer.get(this.gworld.world)){
dplayer.setCheckpoint(this.sign.getLocation());
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 static String name = "Chest";
public static String buildPermissions = "dxl.sign.chest";
public static boolean onDungeonInit = false;
public String buildPermissions = "dxl.sign.chest";
public boolean onDungeonInit = false;
public SIGNChest(Sign sign, GameWorld gworld) {
super(sign, gworld);
}
@Override
public boolean check(Sign sign) {
public boolean check() {
// TODO Auto-generated method stub
return false;
return true;
}
@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 static String name = "ChunkUpdater";
public static String buildPermissions = "dxl.sign.chunkupdater";
public static boolean onDungeonInit = true;
public String buildPermissions = "dxl.sign.chunkupdater";
public boolean onDungeonInit = true;
public SIGNChunkUpdater(Sign sign, GameWorld gworld) {
super(sign, gworld);
}
@Override
public boolean check(Sign sign) {
public boolean check() {
// TODO Auto-generated method stub
return false;
return true;
}
@Override
@ -38,6 +38,16 @@ public class SIGNChunkUpdater extends DSign{
chunk.load();
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,30 +11,31 @@ import com.dre.dungeonsxl.game.GameWorld;
public class SIGNClasses extends DSign{
public static String name = "Classes";
public static String buildPermissions = "dxl.sign.classes";
public static boolean onDungeonInit = true;
public String buildPermissions = "dxl.sign.classes";
public boolean onDungeonInit = true;
public SIGNClasses(Sign sign, GameWorld gworld) {
super(sign, gworld);
}
@Override
public boolean check(Sign sign) {
public boolean check() {
// TODO Auto-generated method stub
return false;
return true;
}
@Override
public void onInit() {
if(!gworld.config.isLobbyDisabled()){
int[] direction=DGSign.getDirection(sign.getBlock().getData());
int directionX=direction[0];
int directionZ=direction[1];
int xx=0,zz=0;
for(DClass dclass:gworld.config.getClasses()){
//Check existing signs
boolean isContinued=true;
for(Sign isusedsign:gworld.signClass){
@ -42,11 +43,11 @@ public class SIGNClasses extends DSign{
isContinued=false;
}
}
if(isContinued){
Block classBlock=sign.getBlock().getRelative(xx,0,zz);
if(classBlock.getData()==sign.getData().getData()&&classBlock.getTypeId()==68&&(classBlock.getState() instanceof Sign)){
if(classBlock.getData() == sign.getData().getData() && classBlock.getTypeId() == 68 && (classBlock.getState() instanceof Sign)){
Sign classSign = (Sign) classBlock.getState();
classSign.setLine(0, ChatColor.DARK_BLUE+"############");
@ -54,16 +55,28 @@ public class SIGNClasses extends DSign{
classSign.setLine(2, "");
classSign.setLine(3, ChatColor.DARK_BLUE+"############");
classSign.update();
gworld.signClass.add(classSign);
}else{
break;
}
xx=xx+directionX;
zz=zz+directionZ;
}
}
} 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 static String name = "End";
public static String buildPermissions = "dxl.sign.end";
public static boolean onDungeonInit = false;
public String buildPermissions = "dxl.sign.end";
public boolean onDungeonInit = false;
public SIGNEnd(Sign sign, GameWorld gworld) {
super(sign, gworld);
}
@Override
public boolean check(Sign sign) {
public boolean check() {
// TODO Auto-generated method stub
return false;
return true;
}
@Override
@ -30,4 +30,14 @@ public class SIGNEnd extends DSign{
sign.setLine(3, ChatColor.DARK_BLUE+"############");
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 static String name = "Leave";
public static String buildPermissions = "dxl.sign.leave";
public static boolean onDungeonInit = true;
public String buildPermissions = "dxl.sign.leave";
public boolean onDungeonInit = true;
public SIGNLeave(Sign sign, GameWorld gworld) {
super(sign, gworld);
}
@Override
public boolean check(Sign sign) {
public boolean check() {
// TODO Auto-generated method stub
return false;
return true;
}
@Override
@ -30,4 +30,14 @@ public class SIGNLeave extends DSign{
sign.setLine(3, ChatColor.BLUE+"############");
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 static String name = "Lobby";
public static String buildPermissions = "dxl.sign.lobby";
public static boolean onDungeonInit = true;
public String buildPermissions = "dxl.sign.lobby";
public boolean onDungeonInit = true;
public SIGNLobby(Sign sign, GameWorld gworld) {
super(sign, gworld);
}
@Override
public boolean check(Sign sign) {
public boolean check() {
// TODO Auto-generated method stub
return false;
return true;
}
@Override
public void onInit() {
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 static String name = "Mob";
public static String buildPermissions = "dxl.sign.mob";
public static boolean onDungeonInit = false;
public String buildPermissions = "dxl.sign.mob";
public boolean onDungeonInit = false;
//Variables
@ -25,16 +25,17 @@ public class SIGNMob extends DSign{
private int maxinterval = 1;
private int interval = 0;
private int amount = 1;
private boolean initialized;
public SIGNMob(Sign sign, GameWorld gworld) {
super(sign, gworld);
}
@Override
public boolean check(Sign sign) {
public boolean check() {
// TODO Auto-generated method stub
return false;
return true;
}
@Override
@ -51,15 +52,21 @@ public class SIGNMob extends DSign{
}
}
}
sign.setTypeId(0);
sign.getBlock().setTypeId(0);
initialized = true;
}
@Override
public void onTrigger() {
MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
int id = p.getServer().getScheduler().scheduleSyncRepeatingTask(p, scheduler, 0L, 20L);
scheduler.id = id;
if(initialized){
MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
int id = p.getServer().getScheduler().scheduleSyncRepeatingTask(p, scheduler, 0L, 20L);
scheduler.id = id;
initialized = false;
}
}
public class MobSpawnScheduler implements Runnable{
@ -105,6 +112,7 @@ public class SIGNMob extends DSign{
amount--;
}else{
p.getServer().getScheduler().cancelTask(this.id);
sign.gworld.dSigns.remove(this);
}
}
@ -113,4 +121,14 @@ public class SIGNMob extends DSign{
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 static String name = "Msg";
public static String buildPermissions = "dxl.sign.msg";
public static boolean onDungeonInit = false;
public String buildPermissions = "dxl.sign.msg";
public boolean onDungeonInit = false;
//Variables
private String msg;
private boolean initialized;
public SIGNMsg(Sign sign, GameWorld gworld) {
super(sign, gworld);
}
@Override
public boolean check(Sign sign) {
public boolean check() {
// TODO Auto-generated method stub
return false;
return true;
}
@Override
@ -32,15 +33,31 @@ public class SIGNMsg extends DSign{
String msg = gworld.config.getMsg(p.parseInt(lines[1]),true);
if(msg!=null){
this.msg = msg;
sign.setTypeId(0);
sign.getBlock().setTypeId(0);
}
}
initialized = true;
}
@Override
public void onTrigger() {
for(Player player : gworld.world.getPlayers()){
p.msg(player, msg);
if(initialized){
for(Player player : gworld.world.getPlayers()){
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 static String name = "Place";
public static String buildPermissions = "dxl.sign.place";
public static boolean onDungeonInit = false;
public String buildPermissions = "dxl.sign.place";
public boolean onDungeonInit = false;
public SIGNPlace(Sign sign, GameWorld gworld) {
super(sign, gworld);
}
@Override
public boolean check(Sign sign) {
public boolean check() {
// TODO Auto-generated method stub
return false;
return true;
}
@Override
public void onInit() {
String lines[] = sign.getLines();
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 static String name = "Ready";
public static String buildPermissions = "dxl.sign.ready";
public static boolean onDungeonInit = true;
public String buildPermissions = "dxl.sign.ready";
public boolean onDungeonInit = true;
public SIGNReady(Sign sign, GameWorld gworld) {
super(sign, gworld);
}
@Override
public boolean check(Sign sign) {
public boolean check() {
// TODO Auto-generated method stub
return false;
return true;
}
@Override
@ -30,4 +30,14 @@ public class SIGNReady extends DSign{
sign.setLine(3, ChatColor.BLUE+"############");
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 static String name = "SoundMsg";
public static String buildPermissions = "dxl.sign.soundmsg";
public static boolean onDungeonInit = false;
public String buildPermissions = "dxl.sign.soundmsg";
public boolean onDungeonInit = false;
//Variables
private boolean initialized;
private String msg;
public SIGNSoundMsg(Sign sign, GameWorld gworld) {
@ -23,10 +24,10 @@ public class SIGNSoundMsg extends DSign{
}
@Override
public boolean check(Sign sign) {
public boolean check() {
// TODO Auto-generated method stub
return false;
return true;
}
@Override
@ -37,20 +38,36 @@ public class SIGNSoundMsg extends DSign{
String msg = gworld.config.getMsg(p.parseInt(lines[1]),true);
if(msg!=null){
this.msg = msg;
sign.setTypeId(0);
sign.getBlock().setTypeId(0);
}
}
initialized = true;
}
@Override
public void onTrigger() {
if(P.p.isSpoutEnabled){
for(Player player : gworld.world.getPlayers()){
SpoutPlayer sPlayer = Spout.getServer().getPlayer(player.getName());
if(sPlayer.isSpoutCraftEnabled()){
SpoutManager.getSoundManager().playCustomMusic(P.p, sPlayer, this.msg, false, this.sign.getLocation());
if(initialized){
if(P.p.isSpoutEnabled){
for(Player player : gworld.world.getPlayers()){
SpoutPlayer sPlayer = Spout.getServer().getPlayer(player.getName());
if(sPlayer.isSpoutCraftEnabled()){
SpoutManager.getSoundManager().playCustomMusic(P.p, sPlayer, this.msg, false, this.sign.getLocation());
}
}
}
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 static String name = "Start";
public static String buildPermissions = "dxl.sign.start";
public static boolean onDungeonInit = true;
public String buildPermissions = "dxl.sign.start";
public boolean onDungeonInit = true;
public SIGNStart(Sign sign, GameWorld gworld) {
super(sign, gworld);
}
@Override
public boolean check(Sign sign) {
public boolean check() {
// TODO Auto-generated method stub
return false;
return true;
}
@Override
public void onInit() {
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;
}
}