mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-12-01 06:53:26 +01:00
parent
e6055dd4f0
commit
b236431456
@ -61,7 +61,7 @@ public class BedSign extends DSign {
|
|||||||
}
|
}
|
||||||
getSign().getBlock().setType(VanillaItem.AIR.getMaterial());
|
getSign().getBlock().setType(VanillaItem.AIR.getMaterial());
|
||||||
} else {
|
} else {
|
||||||
markAsErroneous();
|
markAsErroneous("No bed attached");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,21 +48,31 @@ public class BlockSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
if (!lines[1].isEmpty()) {
|
if (lines[1].isEmpty()) {
|
||||||
String line1[] = lines[1].split(",");
|
offBlock = VanillaItem.AIR;
|
||||||
|
} else if (lines[2].isEmpty()) {
|
||||||
|
onBlock = VanillaItem.AIR;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] line1 = lines[1].split(",");
|
||||||
offBlock = plugin.getCaliburn().getExItem(line1[0]);
|
offBlock = plugin.getCaliburn().getExItem(line1[0]);
|
||||||
|
if (offBlock == null) {
|
||||||
|
markAsErroneous("Could not recognize offBlock, input: " + lines[1]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (line1.length > 1) {
|
if (line1.length > 1) {
|
||||||
offBlockData = (byte) NumberUtil.parseInt(line1[1]);
|
offBlockData = (byte) NumberUtil.parseInt(line1[1]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!lines[2].isEmpty()) {
|
String[] line2 = lines[2].split(",");
|
||||||
String line2[] = lines[2].split(",");
|
|
||||||
onBlock = plugin.getCaliburn().getExItem(line2[0]);
|
onBlock = plugin.getCaliburn().getExItem(line2[0]);
|
||||||
|
if (onBlock == null) {
|
||||||
|
markAsErroneous("Could not recognize onBlock, input: " + lines[2]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (line2.length > 1) {
|
if (line2.length > 1) {
|
||||||
onBlockData = (byte) NumberUtil.parseInt(line2[1]);
|
onBlockData = (byte) NumberUtil.parseInt(line2[1]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
getSign().getBlock().setType(offBlock.getMaterial());
|
getSign().getBlock().setType(offBlock.getMaterial());
|
||||||
getSign().getBlock().setData(offBlockData);
|
getSign().getBlock().setData(offBlockData);
|
||||||
|
@ -67,8 +67,11 @@ public class BossShopSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
if (bossShop == null || bossShop.getAPI().getShop(lines[1]) == null) {
|
if (bossShop == null) {
|
||||||
markAsErroneous();
|
markAsErroneous("BossShop not enabled");
|
||||||
|
return;
|
||||||
|
} else if (bossShop.getAPI().getShop(lines[1]) == null) {
|
||||||
|
markAsErroneous("No such BossShop");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ public class ChestSign extends DSign {
|
|||||||
getSign().getBlock().setType(VanillaItem.AIR.getMaterial());
|
getSign().getBlock().setType(VanillaItem.AIR.getMaterial());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
markAsErroneous();
|
markAsErroneous("No chest attached");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,8 @@ public abstract class DSign {
|
|||||||
// List of Triggers
|
// List of Triggers
|
||||||
private Set<Trigger> triggers = new HashSet<>();
|
private Set<Trigger> triggers = new HashSet<>();
|
||||||
|
|
||||||
|
private boolean erroneous;
|
||||||
|
|
||||||
public DSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
public DSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||||
this.sign = sign;
|
this.sign = sign;
|
||||||
this.lines = lines;
|
this.lines = lines;
|
||||||
@ -168,6 +170,10 @@ public abstract class DSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onUpdate() {
|
public void onUpdate() {
|
||||||
|
if (erroneous) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (Trigger trigger : triggers) {
|
for (Trigger trigger : triggers) {
|
||||||
if (!trigger.isTriggered()) {
|
if (!trigger.isTriggered()) {
|
||||||
onDisable();
|
onDisable();
|
||||||
@ -197,17 +203,26 @@ public abstract class DSign {
|
|||||||
return !triggers.isEmpty();
|
return !triggers.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isErroneous() {
|
||||||
|
return erroneous;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a placeholder to show that the sign is setup incorrectly.
|
* Set a placeholder to show that the sign is setup incorrectly.
|
||||||
|
*
|
||||||
|
* @param reason
|
||||||
|
* the reason why the sign is marked as erroneous
|
||||||
*/
|
*/
|
||||||
public void markAsErroneous() {
|
public void markAsErroneous(String reason) {
|
||||||
|
erroneous = true;
|
||||||
sign.setLine(0, ERROR_0);
|
sign.setLine(0, ERROR_0);
|
||||||
sign.setLine(1, ERROR_1);
|
sign.setLine(1, ERROR_1);
|
||||||
sign.setLine(2, ERROR_2);
|
sign.setLine(2, ERROR_2);
|
||||||
sign.setLine(3, ERROR_3);
|
sign.setLine(3, ERROR_3);
|
||||||
sign.update();
|
sign.update();
|
||||||
|
|
||||||
DMessage.LOG_ERROR_SIGN_SETUP.getMessage(sign.getX() + ", " + sign.getY() + ", " + sign.getZ());
|
MessageUtil.log(plugin, DMessage.LOG_ERROR_SIGN_SETUP.getMessage(sign.getX() + ", " + sign.getY() + ", " + sign.getZ()));
|
||||||
|
MessageUtil.log(plugin, getType().getName() + ": " + reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Statics */
|
/* Statics */
|
||||||
|
@ -95,7 +95,7 @@ public class OpenDoorSign extends DSign {
|
|||||||
getSign().getBlock().setType(VanillaItem.AIR.getMaterial());
|
getSign().getBlock().setType(VanillaItem.AIR.getMaterial());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
markAsErroneous();
|
markAsErroneous("No door attached");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class ResourcePackSign extends DSign {
|
|||||||
resourcePack = (String) url;
|
resourcePack = (String) url;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
markAsErroneous();
|
markAsErroneous("Unknown resourcepack format");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,9 @@ public class ScriptSign extends DSign {
|
|||||||
SignScript script = plugin.getSignScripts().getByName(name);
|
SignScript script = plugin.getSignScripts().getByName(name);
|
||||||
for (String[] lines : script.getSigns()) {
|
for (String[] lines : script.getSigns()) {
|
||||||
DSign dSign = DSign.create(getSign(), lines, getGameWorld());
|
DSign dSign = DSign.create(getSign(), lines, getGameWorld());
|
||||||
|
if (dSign.isErroneous()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
getGameWorld().getDSigns().add(dSign);
|
getGameWorld().getDSigns().add(dSign);
|
||||||
|
|
||||||
dSign.onInit();
|
dSign.onInit();
|
||||||
|
@ -71,7 +71,7 @@ public class ClassesSign extends DSign {
|
|||||||
getGameWorld().getClassesSigns().add(getSign());
|
getGameWorld().getClassesSigns().add(getSign());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
markAsErroneous();
|
markAsErroneous("No such class");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class HologramSign extends DSign {
|
|||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
if (Bukkit.getPluginManager().getPlugin("HolographicDisplays") == null) {
|
if (Bukkit.getPluginManager().getPlugin("HolographicDisplays") == null) {
|
||||||
markAsErroneous();
|
markAsErroneous("HolographicDisplays not enabled");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getSign().getBlock().setType(VanillaItem.AIR.getMaterial());
|
getSign().getBlock().setType(VanillaItem.AIR.getMaterial());
|
||||||
|
@ -81,7 +81,7 @@ public class SoundMessageSign extends DSign {
|
|||||||
getSign().getBlock().setType(VanillaItem.AIR.getMaterial());
|
getSign().getBlock().setType(VanillaItem.AIR.getMaterial());
|
||||||
initialized = true;
|
initialized = true;
|
||||||
} else {
|
} else {
|
||||||
markAsErroneous();
|
markAsErroneous("1. Line is empty; expected input: sound name");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ public class ExternalMobSign extends DSign implements MobSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
markAsErroneous();
|
markAsErroneous("Could not fetch a known external mob provider from " + lines[2]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ import de.erethon.dungeonsxl.mob.DMob;
|
|||||||
import de.erethon.dungeonsxl.player.DGroup;
|
import de.erethon.dungeonsxl.player.DGroup;
|
||||||
import de.erethon.dungeonsxl.sign.DSign;
|
import de.erethon.dungeonsxl.sign.DSign;
|
||||||
import de.erethon.dungeonsxl.sign.DSignType;
|
import de.erethon.dungeonsxl.sign.DSignType;
|
||||||
import de.erethon.dungeonsxl.sign.DSignTypeDefault;
|
|
||||||
import de.erethon.dungeonsxl.sign.LocationSign;
|
import de.erethon.dungeonsxl.sign.LocationSign;
|
||||||
import de.erethon.dungeonsxl.sign.lobby.StartSign;
|
import de.erethon.dungeonsxl.sign.lobby.StartSign;
|
||||||
import de.erethon.dungeonsxl.sign.mob.MobSign;
|
import de.erethon.dungeonsxl.sign.mob.MobSign;
|
||||||
@ -174,7 +173,7 @@ public class DGameWorld extends DInstanceWorld {
|
|||||||
|
|
||||||
// Try the matching location
|
// Try the matching location
|
||||||
for (DSign dSign : dSigns) {
|
for (DSign dSign : dSigns) {
|
||||||
if (dSign.getType() == DSignTypeDefault.START) {
|
if (dSign instanceof StartSign) {
|
||||||
if (((StartSign) dSign).getId() == index) {
|
if (((StartSign) dSign).getId() == index) {
|
||||||
return ((LocationSign) dSign).getLocation();
|
return ((LocationSign) dSign).getLocation();
|
||||||
}
|
}
|
||||||
@ -183,7 +182,7 @@ public class DGameWorld extends DInstanceWorld {
|
|||||||
|
|
||||||
// Try any location
|
// Try any location
|
||||||
for (DSign dSign : dSigns) {
|
for (DSign dSign : dSigns) {
|
||||||
if (dSign.getType() == DSignTypeDefault.START) {
|
if (dSign instanceof StartSign) {
|
||||||
return ((LocationSign) dSign).getLocation();
|
return ((LocationSign) dSign).getLocation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -479,13 +478,11 @@ public class DGameWorld extends DInstanceWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (DSign dSign : dSigns) {
|
for (DSign dSign : dSigns) {
|
||||||
if (dSign != null) {
|
if (dSign != null && !dSign.isErroneous() && !dSign.hasTriggers()) {
|
||||||
if (!dSign.hasTriggers()) {
|
|
||||||
dSign.onTrigger();
|
dSign.onTrigger();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete this instance.
|
* Delete this instance.
|
||||||
|
Loading…
Reference in New Issue
Block a user