mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
Solidify Trigger Recognition on Signs
This commit is contained in:
parent
c82d45ced4
commit
b4bfb39b3d
@ -31,13 +31,23 @@ public abstract class DSign {
|
||||
|
||||
// Check Trigger
|
||||
if (gworld != null) {
|
||||
String[] typeSplit = sign.getLine(3).split(",");
|
||||
for (String typeSplitPart : typeSplit) {
|
||||
String[] splitted = typeSplitPart.split(" ");
|
||||
Trigger trigger = Trigger.getOrCreate(splitted, this);
|
||||
if (trigger != null) {
|
||||
trigger.addListener(this);
|
||||
this.triggers.add(trigger);
|
||||
String line3 = sign.getLine(3).replaceAll("\\s", "");
|
||||
String[] triggerTypes = line3.split(",");
|
||||
|
||||
for (String triggerString : triggerTypes) {
|
||||
if (!triggerString.equals("")) {
|
||||
|
||||
String type = triggerString.substring(0, 1);
|
||||
String value = null;
|
||||
if (triggerString.length() > 1) {
|
||||
value = triggerString.substring(1);
|
||||
}
|
||||
|
||||
Trigger trigger = Trigger.getOrCreate(type, value, this);
|
||||
if (trigger != null) {
|
||||
trigger.addListener(this);
|
||||
this.triggers.add(trigger);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,47 +23,45 @@ public abstract class Trigger {
|
||||
|
||||
public abstract void unregister(GameWorld gworld);
|
||||
|
||||
public static Trigger getOrCreate(String[] splitted, DSign dsign) {
|
||||
public static Trigger getOrCreate(String type, String value, DSign dsign) {
|
||||
Trigger trigger = null;
|
||||
|
||||
if (splitted.length > 0) {
|
||||
if (splitted[0].equalsIgnoreCase("R")) {
|
||||
if (type.equalsIgnoreCase("R")) {
|
||||
|
||||
trigger = RedstoneTrigger.getOrCreate(dsign.getSign(), dsign.getGameWorld());
|
||||
trigger = RedstoneTrigger.getOrCreate(dsign.getSign(), dsign.getGameWorld());
|
||||
|
||||
} else if (splitted[0].equalsIgnoreCase("D")) {
|
||||
|
||||
if (splitted.length > 1) {
|
||||
trigger = new DistanceTrigger(P.p.parseInt(splitted[1]), dsign.getSign().getLocation());
|
||||
} else {
|
||||
trigger = new DistanceTrigger(dsign.getSign().getLocation());
|
||||
}
|
||||
|
||||
} else if (splitted[0].equalsIgnoreCase("T")) {
|
||||
|
||||
if (splitted.length > 1) {
|
||||
trigger = SignTrigger.getOrCreate(P.p.parseInt(splitted[1]), dsign.getGameWorld());
|
||||
}
|
||||
|
||||
} else if (splitted[0].equalsIgnoreCase("I")) {
|
||||
|
||||
if (splitted.length > 1) {
|
||||
trigger = InteractTrigger.getOrCreate(P.p.parseInt(splitted[1]), dsign.getGameWorld());
|
||||
}
|
||||
|
||||
} else if (splitted[0].equalsIgnoreCase("M")) {
|
||||
|
||||
if (splitted.length > 1) {
|
||||
trigger = MobTrigger.getOrCreate(splitted[1], dsign.getGameWorld());
|
||||
}
|
||||
|
||||
} else if (splitted[0].equalsIgnoreCase("U")) {
|
||||
|
||||
if (splitted.length > 1) {
|
||||
trigger = UseItemTrigger.getOrCreate(splitted[1], dsign.getGameWorld());
|
||||
}
|
||||
} else if (type.equalsIgnoreCase("D")) {
|
||||
|
||||
if (value != null) {
|
||||
trigger = new DistanceTrigger(P.p.parseInt(value), dsign.getSign().getLocation());
|
||||
} else {
|
||||
trigger = new DistanceTrigger(dsign.getSign().getLocation());
|
||||
}
|
||||
|
||||
} else if (type.equalsIgnoreCase("T")) {
|
||||
|
||||
if (value != null) {
|
||||
trigger = SignTrigger.getOrCreate(P.p.parseInt(value), dsign.getGameWorld());
|
||||
}
|
||||
|
||||
} else if (type.equalsIgnoreCase("I")) {
|
||||
|
||||
if (value != null) {
|
||||
trigger = InteractTrigger.getOrCreate(P.p.parseInt(value), dsign.getGameWorld());
|
||||
}
|
||||
|
||||
} else if (type.equalsIgnoreCase("M")) {
|
||||
|
||||
if (value != null) {
|
||||
trigger = MobTrigger.getOrCreate(value, dsign.getGameWorld());
|
||||
}
|
||||
|
||||
} else if (type.equalsIgnoreCase("U")) {
|
||||
|
||||
if (value != null) {
|
||||
trigger = UseItemTrigger.getOrCreate(value, dsign.getGameWorld());
|
||||
}
|
||||
|
||||
}
|
||||
return trigger;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user