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){
|
for(DSign sign : gworld.dSigns){
|
||||||
if(sign != null){
|
if(sign != null){
|
||||||
if(sign.isDistanceTrigger()){
|
if(sign.isDistanceTrigger()){
|
||||||
if(dplayer.player.getLocation().distance(sign.getSign().getLocation()) < sign.getDtDistance()){
|
if((sign.isRedstoneTrigger() == false && sign.isSignTrigger() == false) || sign.isPowered()){
|
||||||
sign.onTrigger();
|
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 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){
|
if(args.length>1){
|
||||||
try{
|
try{
|
||||||
@ -40,12 +40,12 @@ public class CMDHelp extends DCommand{
|
|||||||
|
|
||||||
p.msg(sender, ChatColor.GREEN+"============[ "+ChatColor.GOLD+"Help DungeonsXL - "+page+"/"+pages+ChatColor.GREEN+" ]============",false);
|
p.msg(sender, ChatColor.GREEN+"============[ "+ChatColor.GOLD+"Help DungeonsXL - "+page+"/"+pages+ChatColor.GREEN+" ]============",false);
|
||||||
|
|
||||||
int i=0;
|
int i=-1;
|
||||||
int ipage=1;
|
int ipage=1;
|
||||||
for(DCommand command:DCommandRoot.root.commands){
|
for(DCommand command:DCommandRoot.root.commands){
|
||||||
if((command.isConsoleCommand && isConsole) || (command.isPlayerCommand && isPlayer)){
|
if((command.isConsoleCommand && isConsole) || (command.isPlayerCommand && isPlayer)){
|
||||||
i++;
|
i++;
|
||||||
if(i>6){
|
if(i>5){
|
||||||
i=0;
|
i=0;
|
||||||
ipage++;
|
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) {
|
public void msg(String msg) {
|
||||||
|
@ -204,7 +204,9 @@ public class BlockListener implements Listener {
|
|||||||
if(sign!=null){
|
if(sign!=null){
|
||||||
if(sign.isRedstoneTrigger()){
|
if(sign.isRedstoneTrigger()){
|
||||||
if(sign.getRtBlock().isBlockPowered()){
|
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 boolean isSignTrigger = false;
|
||||||
private int stId;
|
private int stId;
|
||||||
|
|
||||||
|
private boolean[] isPowered = new boolean[2];
|
||||||
|
|
||||||
public abstract boolean check();
|
public abstract boolean check();
|
||||||
|
|
||||||
public abstract String getPermissions();
|
public abstract String getPermissions();
|
||||||
@ -37,42 +39,45 @@ public abstract class DSign {
|
|||||||
this.gworld = gworld;
|
this.gworld = gworld;
|
||||||
|
|
||||||
//Check Trigger
|
//Check Trigger
|
||||||
String[] splitted = sign.getLine(3).split(" ");
|
String[] typeSplit = sign.getLine(3).split(",");
|
||||||
if(splitted.length > 0){
|
for(String typeSplitPart:typeSplit){
|
||||||
if(splitted[0].equalsIgnoreCase("R")){
|
String[] splitted = typeSplitPart.split(" ");
|
||||||
if(sign.getBlock().getType() == Material.WALL_SIGN){
|
if(splitted.length > 0){
|
||||||
switch(sign.getData().getData()){
|
if(splitted[0].equalsIgnoreCase("R")){
|
||||||
case 5:
|
if(sign.getBlock().getType() == Material.WALL_SIGN){
|
||||||
rtBlock = sign.getBlock().getRelative(BlockFace.WEST);
|
switch(sign.getData().getData()){
|
||||||
break;
|
case 5:
|
||||||
case 4:
|
rtBlock = sign.getBlock().getRelative(BlockFace.WEST);
|
||||||
rtBlock = sign.getBlock().getRelative(BlockFace.EAST);
|
break;
|
||||||
break;
|
case 4:
|
||||||
case 3:
|
rtBlock = sign.getBlock().getRelative(BlockFace.EAST);
|
||||||
rtBlock = sign.getBlock().getRelative(BlockFace.NORTH);
|
break;
|
||||||
break;
|
case 3:
|
||||||
case 2:
|
rtBlock = sign.getBlock().getRelative(BlockFace.NORTH);
|
||||||
rtBlock = sign.getBlock().getRelative(BlockFace.SOUTH);
|
break;
|
||||||
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){
|
if(rtBlock != null){
|
||||||
this.isRedstoneTrigger = true;
|
this.isRedstoneTrigger = true;
|
||||||
}
|
}
|
||||||
} else if(splitted[0].equalsIgnoreCase("D")){
|
} else if(splitted[0].equalsIgnoreCase("D")){
|
||||||
this.isDistanceTrigger = true;
|
this.isDistanceTrigger = true;
|
||||||
|
|
||||||
if(splitted.length > 1){
|
if(splitted.length > 1){
|
||||||
dtDistance = p.parseInt(splitted[1]);
|
dtDistance = p.parseInt(splitted[1]);
|
||||||
}
|
}
|
||||||
} else if(splitted[0].equalsIgnoreCase("T")){
|
} else if(splitted[0].equalsIgnoreCase("T")){
|
||||||
this.isSignTrigger = true;
|
this.isSignTrigger = true;
|
||||||
|
|
||||||
if(splitted.length > 1){
|
if(splitted.length > 1){
|
||||||
stId = p.parseInt(splitted[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){
|
public static DSign create(Sign sign, GameWorld gworld){
|
||||||
String[] lines = sign.getLines();
|
String[] lines = sign.getLines();
|
||||||
DSign dSign = null;
|
DSign dSign = null;
|
||||||
@ -131,6 +140,18 @@ public abstract class DSign {
|
|||||||
|
|
||||||
|
|
||||||
//Getter anb Setter
|
//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() {
|
public boolean isRedstoneTrigger() {
|
||||||
return isRedstoneTrigger;
|
return isRedstoneTrigger;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,18 @@ public class SIGNCheckpoint extends DSign{
|
|||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate(int type,boolean powered) {
|
||||||
|
if(initialized){
|
||||||
|
setPowered(type,powered);
|
||||||
|
if(!isDistanceTrigger()){
|
||||||
|
if(isPowered()){
|
||||||
|
onTrigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
if(initialized){
|
if(initialized){
|
||||||
|
@ -57,6 +57,18 @@ public class SIGNMob extends DSign{
|
|||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate(int type,boolean powered) {
|
||||||
|
if(initialized){
|
||||||
|
setPowered(type,powered);
|
||||||
|
if(!isDistanceTrigger()){
|
||||||
|
if(isPowered()){
|
||||||
|
onTrigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
if(initialized){
|
if(initialized){
|
||||||
|
@ -40,6 +40,18 @@ public class SIGNMsg extends DSign{
|
|||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate(int type,boolean powered) {
|
||||||
|
if(initialized){
|
||||||
|
setPowered(type,powered);
|
||||||
|
if(!isDistanceTrigger()){
|
||||||
|
if(isPowered()){
|
||||||
|
onTrigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
if(initialized){
|
if(initialized){
|
||||||
|
@ -45,6 +45,18 @@ public class SIGNSoundMsg extends DSign{
|
|||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate(int type,boolean powered) {
|
||||||
|
if(initialized){
|
||||||
|
setPowered(type,powered);
|
||||||
|
if(!isDistanceTrigger()){
|
||||||
|
if(isPowered()){
|
||||||
|
onTrigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
if(initialized){
|
if(initialized){
|
||||||
|
@ -30,6 +30,24 @@ public class SIGNTrigger extends DSign{
|
|||||||
initialized = true;
|
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
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
if(initialized){
|
if(initialized){
|
||||||
@ -37,7 +55,7 @@ public class SIGNTrigger extends DSign{
|
|||||||
if(dsign != null){
|
if(dsign != null){
|
||||||
if(dsign.isSignTrigger()){
|
if(dsign.isSignTrigger()){
|
||||||
if(triggerId == dsign.getStId()){
|
if(triggerId == dsign.getStId()){
|
||||||
dsign.onTrigger();
|
dsign.onUpdate(1,true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user