mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2025-02-17 21:02:12 +01:00
Fix deprecated signs crashing server
This commit is contained in:
parent
d60d3f3345
commit
cafe90e40e
@ -86,7 +86,9 @@ import de.erethon.vignette.api.VignetteAPI;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -112,18 +114,18 @@ public class DungeonsXL extends DREPlugin implements DungeonsAPI {
|
||||
public static final File LOOT_TABLES = new File(SCRIPTS, "loottables");
|
||||
public static final File MOBS = new File(SCRIPTS, "mobs");
|
||||
public static final File SIGNS = new File(SCRIPTS, "signs");
|
||||
public static final Set<String> LEGACY_SIGNS = new HashSet<>();
|
||||
public static final Map<String, Class<? extends DungeonSign>> LEGACY_SIGNS = new HashMap<>();
|
||||
|
||||
static {
|
||||
LEGACY_SIGNS.add("CHEST");
|
||||
LEGACY_SIGNS.add("EXTERNALMOB");
|
||||
LEGACY_SIGNS.add("FLOOR");
|
||||
LEGACY_SIGNS.put("CHEST", RewardChestSign.class);
|
||||
LEGACY_SIGNS.put("EXTERNALMOB", MobSign.class);
|
||||
LEGACY_SIGNS.put("FLOOR", EndSign.class);
|
||||
}
|
||||
|
||||
private PlayerCache playerCache = new PlayerCache();
|
||||
private Collection<Game> gameCache = new ArrayList<>();
|
||||
private Registry<String, PlayerClass> classRegistry = new Registry<>();
|
||||
private Registry<String, Class<? extends DungeonSign>> signRegistry = new Registry<>();
|
||||
private Registry<String, Class<? extends DungeonSign>> signRegistry = new SignRegistry();
|
||||
private Registry<String, Class<? extends Requirement>> requirementRegistry = new Registry<>();
|
||||
private Registry<String, Class<? extends Reward>> rewardRegistry = new Registry<>();
|
||||
private Registry<String, Dungeon> dungeonRegistry = new Registry<>();
|
||||
@ -133,6 +135,20 @@ public class DungeonsXL extends DREPlugin implements DungeonsAPI {
|
||||
private Registry<String, ExternalMobProvider> externalMobProviderRegistry = new Registry<>();
|
||||
private Registry<String, PlayerGroup> playerGroupCache = new Registry<>();
|
||||
|
||||
@Deprecated
|
||||
private class SignRegistry extends Registry<String, Class<? extends DungeonSign>> {
|
||||
|
||||
@Override
|
||||
public Class<? extends DungeonSign> get(String key) {
|
||||
Class<? extends DungeonSign> clss = super.get(key);
|
||||
if (clss == null) {
|
||||
return LEGACY_SIGNS.get(key.toUpperCase());
|
||||
}
|
||||
return clss;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean loadingWorld;
|
||||
|
||||
private GlobalData globalData;
|
||||
@ -230,18 +246,12 @@ public class DungeonsXL extends DREPlugin implements DungeonsAPI {
|
||||
signRegistry.add("Block", BlockSign.class);
|
||||
signRegistry.add("BossShop", BossShopSign.class);
|
||||
signRegistry.add("Checkpoint", CheckpointSign.class);
|
||||
// Deprecated
|
||||
signRegistry.add("Chest", RewardChestSign.class);
|
||||
signRegistry.add("Classes", ClassesSign.class);
|
||||
//signRegistry.add("CMD", CommandSign.class); TODO: REIMPLEMENT
|
||||
signRegistry.add("Drop", DropSign.class);
|
||||
signRegistry.add("DungeonChest", DungeonChestSign.class);
|
||||
signRegistry.add("End", EndSign.class);
|
||||
// Deprecated
|
||||
signRegistry.add("ExternalMob", MobSign.class);
|
||||
signRegistry.add("Flag", FlagSign.class);
|
||||
// Deprecated
|
||||
signRegistry.add("Floor", EndSign.class);
|
||||
signRegistry.add("Hologram", HologramSign.class);
|
||||
signRegistry.add("Interact", InteractSign.class);
|
||||
signRegistry.add("Leave", LeaveSign.class);
|
||||
|
@ -90,41 +90,37 @@ public class DSignListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sign != null) {
|
||||
sign.setLine(0, lines[0]);
|
||||
sign.setLine(1, lines[1]);
|
||||
sign.setLine(2, lines[2]);
|
||||
sign.setLine(3, lines[3]);
|
||||
if (sign == null) {
|
||||
return;
|
||||
}
|
||||
sign.setLine(0, lines[0]);
|
||||
sign.setLine(1, lines[1]);
|
||||
sign.setLine(2, lines[2]);
|
||||
sign.setLine(3, lines[3]);
|
||||
|
||||
for (Entry<String, Class<? extends DungeonSign>> registryEntry : api.getSignRegistry().entrySet()) {
|
||||
if (!lines[0].equalsIgnoreCase("[" + registryEntry.getKey() + "]")) {
|
||||
continue;
|
||||
}
|
||||
if (DungeonsXL.LEGACY_SIGNS.contains(registryEntry.getKey().toUpperCase())) {
|
||||
MessageUtil.sendMessage(player, ChatColor.RED + "https://erethon.de/resources/dxl-signs/deprecated.gif");
|
||||
MessageUtil.sendMessage(player, ChatColor.LIGHT_PURPLE + "https://github.com/DRE2N/DungeonsXL/wiki/Legacy-support#updating");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (DungeonsXL.LEGACY_SIGNS.containsKey(lines[0].substring(1, lines[0].length() - 2).toUpperCase())) {
|
||||
MessageUtil.sendMessage(player, ChatColor.RED + "https://erethon.de/resources/dxl-signs/deprecated.gif");
|
||||
MessageUtil.sendMessage(player, ChatColor.LIGHT_PURPLE + "https://github.com/DRE2N/DungeonsXL/wiki/Legacy-support#updating");
|
||||
return;
|
||||
}
|
||||
|
||||
DungeonSign dsign = editWorld.createDungeonSign(sign, sign.getLines());
|
||||
if (dsign == null) {
|
||||
return;
|
||||
}
|
||||
DungeonSign dsign = editWorld.createDungeonSign(sign, sign.getLines());
|
||||
if (dsign == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DPermission.hasPermission(player, dsign.getBuildPermission())) {
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_NO_PERMISSIONS.getMessage());
|
||||
return;
|
||||
}
|
||||
if (!DPermission.hasPermission(player, dsign.getBuildPermission())) {
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_NO_PERMISSIONS.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (dsign.validate()) {
|
||||
editWorld.registerSign(block);
|
||||
MessageUtil.sendMessage(player, DMessage.PLAYER_SIGN_CREATED.getMessage());
|
||||
if (dsign.validate()) {
|
||||
editWorld.registerSign(block);
|
||||
MessageUtil.sendMessage(player, DMessage.PLAYER_SIGN_CREATED.getMessage());
|
||||
|
||||
} else {
|
||||
editWorld.removeDungeonSign(block);
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_SIGN_WRONG_FORMAT.getMessage());
|
||||
}
|
||||
} else {
|
||||
editWorld.removeDungeonSign(block);
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_SIGN_WRONG_FORMAT.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user