mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-12-01 06:53:26 +01:00
Merge pull request #33 from Sn0wStorm/master
Extended Sign system for multiple Triggers
This commit is contained in:
commit
01760d3d30
@ -468,8 +468,10 @@ public class DPlayer {
|
||||
for(DSign sign : gworld.dSigns){
|
||||
if(sign != null){
|
||||
if(sign.isDistanceTrigger()){
|
||||
if(dplayer.player.getLocation().distance(sign.getSign().getLocation()) < sign.getDtDistance()){
|
||||
sign.onTrigger();
|
||||
if((sign.isRedstoneTrigger() == false && sign.isSignTrigger() == false) || sign.isPowered()){
|
||||
if(dplayer.player.getLocation().distance(sign.getSign().getLocation()) < sign.getDtDistance()){
|
||||
sign.onTrigger();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class CMDHelp extends DCommand{
|
||||
}
|
||||
|
||||
int page=1;
|
||||
int pages=(int)(DCommandRoot.root.commands.size()/6);
|
||||
int pages=(int)Math.ceil(DCommandRoot.root.commands.size()/6.0);
|
||||
|
||||
if(args.length>1){
|
||||
try{
|
||||
@ -40,12 +40,12 @@ public class CMDHelp extends DCommand{
|
||||
|
||||
p.msg(sender, ChatColor.GREEN+"============[ "+ChatColor.GOLD+"Help DungeonsXL - "+page+"/"+pages+ChatColor.GREEN+" ]============",false);
|
||||
|
||||
int i=0;
|
||||
int i=-1;
|
||||
int ipage=1;
|
||||
for(DCommand command:DCommandRoot.root.commands){
|
||||
if((command.isConsoleCommand && isConsole) || (command.isPlayerCommand && isPlayer)){
|
||||
i++;
|
||||
if(i>6){
|
||||
if(i>5){
|
||||
i=0;
|
||||
ipage++;
|
||||
}
|
||||
|
@ -90,6 +90,17 @@ public class GameWorld {
|
||||
}
|
||||
}
|
||||
}
|
||||
for(DSign dSign : this.dSigns){
|
||||
if(dSign != null){
|
||||
if(dSign.isRedstoneTrigger()){
|
||||
if(dSign.getRtBlock().isBlockPowered()){
|
||||
dSign.onUpdate(0,true);
|
||||
}else{
|
||||
dSign.onUpdate(0,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void msg(String msg) {
|
||||
|
@ -204,7 +204,9 @@ public class BlockListener implements Listener {
|
||||
if(sign!=null){
|
||||
if(sign.isRedstoneTrigger()){
|
||||
if(sign.getRtBlock().isBlockPowered()){
|
||||
sign.onTrigger();
|
||||
sign.onUpdate(0,true);
|
||||
}else{
|
||||
sign.onUpdate(0,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ public abstract class DSign {
|
||||
private boolean isSignTrigger = false;
|
||||
private int stId;
|
||||
|
||||
private boolean[] isPowered = new boolean[2];
|
||||
|
||||
public abstract boolean check();
|
||||
|
||||
public abstract String getPermissions();
|
||||
@ -37,42 +39,45 @@ public abstract class DSign {
|
||||
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;
|
||||
String[] typeSplit = sign.getLine(3).split(",");
|
||||
for(String typeSplitPart:typeSplit){
|
||||
String[] splitted = typeSplitPart.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);
|
||||
}
|
||||
} else {
|
||||
rtBlock = sign.getBlock().getRelative(BlockFace.DOWN);
|
||||
}
|
||||
|
||||
if(rtBlock != null){
|
||||
this.isRedstoneTrigger = true;
|
||||
}
|
||||
} else if(splitted[0].equalsIgnoreCase("D")){
|
||||
this.isDistanceTrigger = true;
|
||||
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){
|
||||
dtDistance = p.parseInt(splitted[1]);
|
||||
}
|
||||
} else if(splitted[0].equalsIgnoreCase("T")){
|
||||
this.isSignTrigger = true;
|
||||
|
||||
if(splitted.length > 1){
|
||||
stId = p.parseInt(splitted[1]);
|
||||
if(splitted.length > 1){
|
||||
stId = p.parseInt(splitted[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -86,6 +91,10 @@ public abstract class DSign {
|
||||
|
||||
}
|
||||
|
||||
public void onUpdate(int type,boolean powered){
|
||||
|
||||
}
|
||||
|
||||
public static DSign create(Sign sign, GameWorld gworld){
|
||||
String[] lines = sign.getLines();
|
||||
DSign dSign = null;
|
||||
@ -131,6 +140,18 @@ public abstract class DSign {
|
||||
|
||||
|
||||
//Getter anb Setter
|
||||
public void setPowered(int type,boolean powered) {
|
||||
isPowered[type] = powered;
|
||||
}
|
||||
|
||||
public boolean isPowered() { //0=Redstone 1=Sign
|
||||
if( (isPowered[0]||!isRedstoneTrigger()) && (isPowered[1]||!isSignTrigger()) ){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isRedstoneTrigger() {
|
||||
return isRedstoneTrigger;
|
||||
}
|
||||
|
@ -33,6 +33,18 @@ public class SIGNCheckpoint extends DSign{
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(int type,boolean powered) {
|
||||
if(initialized){
|
||||
setPowered(type,powered);
|
||||
if(!isDistanceTrigger()){
|
||||
if(isPowered()){
|
||||
onTrigger();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrigger() {
|
||||
if(initialized){
|
||||
|
@ -57,6 +57,18 @@ public class SIGNMob extends DSign{
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(int type,boolean powered) {
|
||||
if(initialized){
|
||||
setPowered(type,powered);
|
||||
if(!isDistanceTrigger()){
|
||||
if(isPowered()){
|
||||
onTrigger();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrigger() {
|
||||
if(initialized){
|
||||
|
@ -40,6 +40,18 @@ public class SIGNMsg extends DSign{
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(int type,boolean powered) {
|
||||
if(initialized){
|
||||
setPowered(type,powered);
|
||||
if(!isDistanceTrigger()){
|
||||
if(isPowered()){
|
||||
onTrigger();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrigger() {
|
||||
if(initialized){
|
||||
|
@ -45,6 +45,18 @@ public class SIGNSoundMsg extends DSign{
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(int type,boolean powered) {
|
||||
if(initialized){
|
||||
setPowered(type,powered);
|
||||
if(!isDistanceTrigger()){
|
||||
if(isPowered()){
|
||||
onTrigger();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrigger() {
|
||||
if(initialized){
|
||||
|
@ -30,6 +30,24 @@ public class SIGNTrigger extends DSign{
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(int type,boolean powered) {
|
||||
if(initialized){
|
||||
setPowered(type,powered);
|
||||
if(!isDistanceTrigger()){
|
||||
for(DSign dsign : this.gworld.dSigns){
|
||||
if(dsign != null){
|
||||
if(dsign.isSignTrigger()){
|
||||
if(triggerId == dsign.getStId()){
|
||||
dsign.onUpdate(1,isPowered());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrigger() {
|
||||
if(initialized){
|
||||
@ -37,7 +55,7 @@ public class SIGNTrigger extends DSign{
|
||||
if(dsign != null){
|
||||
if(dsign.isSignTrigger()){
|
||||
if(triggerId == dsign.getStId()){
|
||||
dsign.onTrigger();
|
||||
dsign.onUpdate(1,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user