How did this happen? We're smarter than this!

This commit is contained in:
Daniel Saukel 2020-03-19 16:35:30 +01:00
parent d0042949fc
commit 53cd13b0ec
2 changed files with 19 additions and 21 deletions

View File

@ -169,6 +169,25 @@ public class DGameWorld extends DInstanceWorld implements GameWorld {
public DungeonSign createDungeonSign(Sign sign, String[] lines) {
DungeonSign dSign = super.createDungeonSign(sign, lines);
String[] triggerTypes = lines[3].replaceAll("\\s", "").split(",");
for (String triggerString : triggerTypes) {
if (triggerString.isEmpty()) {
continue;
}
String id = triggerString.substring(0, 1);
String value = null;
if (triggerString.length() > 1) {
value = triggerString.substring(1);
}
Trigger trigger = Trigger.getOrCreate(plugin, id, value, dSign);
if (trigger != null) {
trigger.addListener(dSign);
dSign.addTrigger(trigger);
}
}
if (dSign.isOnDungeonInit()) {
dSign.initialize();
}

View File

@ -27,7 +27,6 @@ import de.erethon.dungeonsxl.api.player.InstancePlayer;
import de.erethon.dungeonsxl.api.player.PlayerCache;
import de.erethon.dungeonsxl.api.sign.DungeonSign;
import de.erethon.dungeonsxl.api.world.InstanceWorld;
import de.erethon.dungeonsxl.trigger.Trigger;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
@ -118,26 +117,6 @@ public abstract class DInstanceWorld implements InstanceWorld {
Constructor constructor = clss.getConstructor(DungeonsAPI.class, Sign.class, String[].class, InstanceWorld.class);
DungeonSign dSign = (DungeonSign) constructor.newInstance(plugin, sign, lines, this);
signs.put(sign.getBlock(), dSign);
String[] triggerTypes = lines[3].replaceAll("\\s", "").split(",");
for (String triggerString : triggerTypes) {
if (triggerString.isEmpty()) {
continue;
}
String id = triggerString.substring(0, 1);
String value = null;
if (triggerString.length() > 1) {
value = triggerString.substring(1);
}
Trigger trigger = Trigger.getOrCreate(plugin, id, value, dSign);
if (trigger != null) {
trigger.addListener(dSign);
dSign.addTrigger(trigger);
}
}
return dSign;
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException