mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 19:45:43 +01:00
Finished new Sign system and added Triggers
Signed-off-by: Grafe <flingelfrank@hotmail.com>
This commit is contained in:
parent
0ed668884a
commit
90a625cae0
@ -1,5 +1,5 @@
|
||||
name: DungeonsXL
|
||||
version: 0.7.6
|
||||
version: 0.8
|
||||
main: com.dre.dungeonsxl.P
|
||||
authors: [Frank Baumann]
|
||||
softdepend: [Vault]
|
||||
|
@ -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,7 +404,6 @@ 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);
|
||||
@ -417,8 +417,6 @@ public class DPlayer {
|
||||
} 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);
|
||||
@ -432,7 +430,6 @@ public class DPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Respawn Items
|
||||
for(ItemStack istack : dplayer.respawnInventory){
|
||||
if(istack != null){
|
||||
@ -443,8 +440,10 @@ public class DPlayer {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
GameWorld gworld = GameWorld.get(dplayer.world);
|
||||
|
||||
if(gworld != null){
|
||||
//Update Wolf
|
||||
if(dplayer.wolf!=null){
|
||||
if(dplayer.wolf.isDead()){
|
||||
@ -464,6 +463,16 @@ public class DPlayer {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
@ -50,8 +50,10 @@ 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);
|
||||
|
||||
p.getServer().unloadWorld(this.world,true);
|
||||
File dir = new File("DXL_Game_"+this.id);
|
||||
p.removeDirectory(dir);
|
||||
//}
|
||||
}
|
||||
|
||||
public static GameWorld load(String name){
|
||||
|
@ -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 {
|
||||
|
||||
@ -112,8 +115,6 @@ public class BlockListener implements Listener {
|
||||
//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];
|
||||
@ -128,8 +129,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(lines[1].equalsIgnoreCase("Leave")){
|
||||
} 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 {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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(lines[0].equalsIgnoreCase("[DXL]")){
|
||||
eworld.checkSign(event.getBlock());
|
||||
eworld.sign.add(event.getBlock());
|
||||
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 {
|
||||
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)
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -36,23 +36,15 @@ public class EntityListener implements Listener{
|
||||
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(eworld != null || gworld!=null){
|
||||
if(
|
||||
event.getSpawnReason() == SpawnReason.CHUNK_GEN ||
|
||||
event.getSpawnReason() == SpawnReason.BREEDING ||
|
||||
event.getSpawnReason()==SpawnReason.NATURAL){
|
||||
event.getSpawnReason() == SpawnReason.NATURAL ||
|
||||
event.getSpawnReason() == SpawnReason.DEFAULT)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -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,19 +11,72 @@ 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);
|
||||
}
|
||||
|
||||
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(){
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -11,23 +11,24 @@ 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];
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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,13 +38,16 @@ 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(initialized){
|
||||
if(P.p.isSpoutEnabled){
|
||||
for(Player player : gworld.world.getPlayers()){
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
55
src/com/dre/dungeonsxl/signs/SIGNTrigger.java
Normal file
55
src/com/dre/dungeonsxl/signs/SIGNTrigger.java
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user