This commit is contained in:
Daniel Saukel 2017-10-04 23:57:12 +02:00
parent 2be85aa1cf
commit cb6add4fc8
45 changed files with 150 additions and 136 deletions

View File

@ -96,7 +96,7 @@ public class Announcer {
if (multiFloor) { if (multiFloor) {
dungeonName = identifier; dungeonName = identifier;
Dungeon dungeon = DungeonsXL.getInstance().getDungeons().getByName(identifier); Dungeon dungeon = plugin.getDungeons().getByName(identifier);
if (dungeon != null) { if (dungeon != null) {
mapName = dungeon.getConfig().getStartFloor().getName(); mapName = dungeon.getConfig().getStartFloor().getName();
} }
@ -137,7 +137,7 @@ public class Announcer {
if (multiFloor) { if (multiFloor) {
dungeonName = identifier; dungeonName = identifier;
Dungeon dungeon = DungeonsXL.getInstance().getDungeons().getByName(identifier); Dungeon dungeon = plugin.getDungeons().getByName(identifier);
if (dungeon != null) { if (dungeon != null) {
mapName = dungeon.getConfig().getStartFloor().getName(); mapName = dungeon.getConfig().getStartFloor().getName();
} }
@ -423,7 +423,7 @@ public class Announcer {
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
DGroup dGroup = dGroups.get(groupCount); DGroup dGroup = dGroups.get(groupCount);
if (!DungeonsXL.getInstance().getDGroups().contains(dGroup)) { if (!plugin.getDGroups().contains(dGroup)) {
dGroups.set(groupCount, null); dGroups.set(groupCount, null);
} else if (dGroup != null) { } else if (dGroup != null) {
@ -436,7 +436,7 @@ public class Announcer {
boolean full = playerCount >= maxPlayersPerGroup; boolean full = playerCount >= maxPlayersPerGroup;
ItemStack button = new ItemStack(Material.WOOL, playerCount, DungeonsXL.getInstance().getMainConfig().getGroupColorPriority().get(groupCount).getWoolData()); ItemStack button = new ItemStack(Material.WOOL, playerCount, plugin.getMainConfig().getGroupColorPriority().get(groupCount).getWoolData());
ItemMeta meta = button.getItemMeta(); ItemMeta meta = button.getItemMeta();
meta.setDisplayName(name + (full ? ChatColor.DARK_RED : ChatColor.GREEN) + " [" + playerCount + "/" + maxPlayersPerGroup + "]"); meta.setDisplayName(name + (full ? ChatColor.DARK_RED : ChatColor.GREEN) + " [" + playerCount + "/" + maxPlayersPerGroup + "]");
meta.setLore(lore); meta.setLore(lore);

View File

@ -44,7 +44,7 @@ public class AnnouncerCache {
announcers.add(new Announcer(script)); announcers.add(new Announcer(script));
} }
} }
startAnnouncerTask(DungeonsXL.getInstance().getMainConfig().getAnnouncmentInterval()); startAnnouncerTask(plugin.getMainConfig().getAnnouncmentInterval());
} }
/** /**

View File

@ -67,8 +67,8 @@ public class CreateCommand extends DRECommand {
MessageUtil.log(plugin, DMessage.LOG_GENERATE_NEW_WORLD.getMessage()); MessageUtil.log(plugin, DMessage.LOG_GENERATE_NEW_WORLD.getMessage());
// Create World // Create World
DResourceWorld resource = new DResourceWorld(DungeonsXL.getInstance().getDWorlds(), name); DResourceWorld resource = new DResourceWorld(plugin.getDWorlds(), name);
DungeonsXL.getInstance().getDWorlds().addResource(resource); plugin.getDWorlds().addResource(resource);
DEditWorld editWorld = resource.generate(); DEditWorld editWorld = resource.generate();
editWorld.save(); editWorld.save();
editWorld.delete(); editWorld.delete();
@ -89,8 +89,8 @@ public class CreateCommand extends DRECommand {
MessageUtil.log(plugin, DMessage.LOG_GENERATE_NEW_WORLD.getMessage()); MessageUtil.log(plugin, DMessage.LOG_GENERATE_NEW_WORLD.getMessage());
// Create World // Create World
DResourceWorld resource = new DResourceWorld(DungeonsXL.getInstance().getDWorlds(), name); DResourceWorld resource = new DResourceWorld(plugin.getDWorlds(), name);
DungeonsXL.getInstance().getDWorlds().addResource(resource); plugin.getDWorlds().addResource(resource);
DEditWorld editWorld = resource.generate(); DEditWorld editWorld = resource.generate();
// MSG Done // MSG Done

View File

@ -69,7 +69,7 @@ public class ImportCommand extends DRECommand {
MessageUtil.log(plugin, DMessage.LOG_NEW_MAP.getMessage()); MessageUtil.log(plugin, DMessage.LOG_NEW_MAP.getMessage());
MessageUtil.log(plugin, DMessage.LOG_IMPORT_WORLD.getMessage()); MessageUtil.log(plugin, DMessage.LOG_IMPORT_WORLD.getMessage());
if (!DungeonsXL.getInstance().getMainConfig().areTweaksEnabled()) { if (!plugin.getMainConfig().areTweaksEnabled()) {
FileUtil.copyDirectory(source, target, new String[]{"playerdata", "stats"}); FileUtil.copyDirectory(source, target, new String[]{"playerdata", "stats"});
} else { } else {
@ -81,7 +81,7 @@ public class ImportCommand extends DRECommand {
}.runTaskAsynchronously(plugin); }.runTaskAsynchronously(plugin);
} }
DungeonsXL.getInstance().getDWorlds().addResource(new DResourceWorld(DungeonsXL.getInstance().getDWorlds(), args[1])); plugin.getDWorlds().addResource(new DResourceWorld(plugin.getDWorlds(), args[1]));
MessageUtil.sendMessage(sender, DMessage.CMD_IMPORT_SUCCESS.getMessage(args[1])); MessageUtil.sendMessage(sender, DMessage.CMD_IMPORT_SUCCESS.getMessage(args[1]));
} }

View File

@ -39,7 +39,7 @@ import org.bukkit.entity.Player;
public class ListCommand extends DRECommand { public class ListCommand extends DRECommand {
DungeonsXL plugin = DungeonsXL.getInstance(); DungeonsXL plugin = DungeonsXL.getInstance();
DWorldCache worlds = DungeonsXL.getInstance().getDWorlds(); DWorldCache worlds = plugin.getDWorlds();
public ListCommand() { public ListCommand() {
setCommand("list"); setCommand("list");
@ -54,7 +54,7 @@ public class ListCommand extends DRECommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
ArrayList<String> dungeonList = new ArrayList<>(); ArrayList<String> dungeonList = new ArrayList<>();
for (Dungeon dungeon : DungeonsXL.getInstance().getDungeons().getDungeons()) { for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
dungeonList.add(dungeon.getName()); dungeonList.add(dungeon.getName());
} }
ArrayList<String> mapList = new ArrayList<>(); ArrayList<String> mapList = new ArrayList<>();
@ -78,7 +78,7 @@ public class ListCommand extends DRECommand {
if (args.length >= 2) { if (args.length >= 2) {
if (args[1].equalsIgnoreCase("dungeons") || args[1].equalsIgnoreCase("d")) { if (args[1].equalsIgnoreCase("dungeons") || args[1].equalsIgnoreCase("d")) {
if (args.length >= 3) { if (args.length >= 3) {
Dungeon dungeon = DungeonsXL.getInstance().getDungeons().getByName(args[2]); Dungeon dungeon = plugin.getDungeons().getByName(args[2]);
if (dungeon != null) { if (dungeon != null) {
MessageUtil.sendPluginTag(sender, plugin); MessageUtil.sendPluginTag(sender, plugin);
MessageUtil.sendCenteredMessage(sender, "&4&l[ &6" + dungeon.getName() + " &4&l]"); MessageUtil.sendCenteredMessage(sender, "&4&l[ &6" + dungeon.getName() + " &4&l]");

View File

@ -33,6 +33,8 @@ import org.bukkit.plugin.PluginManager;
*/ */
public class MainCommand extends DRECommand { public class MainCommand extends DRECommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public MainCommand() { public MainCommand() {
setCommand("main"); setCommand("main");
setHelp(DMessage.HELP_CMD_MAIN.getMessage()); setHelp(DMessage.HELP_CMD_MAIN.getMessage());
@ -47,8 +49,8 @@ public class MainCommand extends DRECommand {
int maps = DungeonsXL.MAPS.listFiles().length; int maps = DungeonsXL.MAPS.listFiles().length;
int dungeons = DungeonsXL.DUNGEONS.listFiles().length; int dungeons = DungeonsXL.DUNGEONS.listFiles().length;
int loaded = DungeonsXL.getInstance().getDWorlds().getEditWorlds().size() + DungeonsXL.getInstance().getDWorlds().getGameWorlds().size(); int loaded = plugin.getDWorlds().getEditWorlds().size() + plugin.getDWorlds().getGameWorlds().size();
int players = DungeonsXL.getInstance().getDPlayers().getDGamePlayers().size(); int players = plugin.getDPlayers().getDGamePlayers().size();
Internals internals = CompatibilityHandler.getInstance().getInternals(); Internals internals = CompatibilityHandler.getInstance().getInternals();
String vault = ""; String vault = "";
if (plugins.getPlugin("Vault") != null) { if (plugins.getPlugin("Vault") != null) {
@ -64,7 +66,7 @@ public class MainCommand extends DRECommand {
MessageUtil.sendCenteredMessage(sender, "&4" + D[2] + "&f" + X[2] + L[2]); MessageUtil.sendCenteredMessage(sender, "&4" + D[2] + "&f" + X[2] + L[2]);
MessageUtil.sendCenteredMessage(sender, "&4" + D[3] + "&f" + X[3] + L[3]); MessageUtil.sendCenteredMessage(sender, "&4" + D[3] + "&f" + X[3] + L[3]);
MessageUtil.sendCenteredMessage(sender, "&4" + D[4] + "&f" + X[4] + L[4]); MessageUtil.sendCenteredMessage(sender, "&4" + D[4] + "&f" + X[4] + L[4]);
MessageUtil.sendCenteredMessage(sender, "&b&l###### " + DMessage.CMD_MAIN_WELCOME.getMessage() + "&7 v" + DungeonsXL.getInstance().getDescription().getVersion() + " &b&l######"); MessageUtil.sendCenteredMessage(sender, "&b&l###### " + DMessage.CMD_MAIN_WELCOME.getMessage() + "&7 v" + plugin.getDescription().getVersion() + " &b&l######");
MessageUtil.sendCenteredMessage(sender, DMessage.CMD_MAIN_LOADED.getMessage(String.valueOf(maps), String.valueOf(dungeons), String.valueOf(loaded), String.valueOf(players))); MessageUtil.sendCenteredMessage(sender, DMessage.CMD_MAIN_LOADED.getMessage(String.valueOf(maps), String.valueOf(dungeons), String.valueOf(loaded), String.valueOf(players)));
MessageUtil.sendCenteredMessage(sender, DMessage.CMD_MAIN_COMPATIBILITY.getMessage(String.valueOf(internals), vault, itemsxl)); MessageUtil.sendCenteredMessage(sender, DMessage.CMD_MAIN_COMPATIBILITY.getMessage(String.valueOf(internals), vault, itemsxl));
MessageUtil.sendCenteredMessage(sender, DMessage.CMD_MAIN_HELP.getMessage()); MessageUtil.sendCenteredMessage(sender, DMessage.CMD_MAIN_HELP.getMessage());

View File

@ -38,6 +38,8 @@ import org.bukkit.entity.Player;
*/ */
public class PlayCommand extends DRECommand { public class PlayCommand extends DRECommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public PlayCommand() { public PlayCommand() {
setCommand("play"); setCommand("play");
setMinArgs(1); setMinArgs(1);
@ -51,15 +53,15 @@ public class PlayCommand extends DRECommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender; Player player = (Player) sender;
DGlobalPlayer dPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player); DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player);
if (dPlayer instanceof DInstancePlayer) { if (dPlayer instanceof DInstancePlayer) {
MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_DUNGEON.getMessage()); MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_DUNGEON.getMessage());
return; return;
} }
Dungeon dungeon = DungeonsXL.getInstance().getDungeons().getByName(args[1]); Dungeon dungeon = plugin.getDungeons().getByName(args[1]);
if (dungeon == null) { if (dungeon == null) {
DResourceWorld resource = DungeonsXL.getInstance().getDWorlds().getResourceByName(args[1]); DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[1]);
if (resource != null) { if (resource != null) {
dungeon = new Dungeon(resource); dungeon = new Dungeon(resource);
} else { } else {
@ -77,7 +79,7 @@ public class PlayCommand extends DRECommand {
DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.COMMAND); DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.COMMAND);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
DungeonsXL.getInstance().getDGroups().remove(dGroup); plugin.getDGroups().remove(dGroup);
dGroup = null; dGroup = null;
} }
} }

View File

@ -34,6 +34,8 @@ import org.bukkit.inventory.ItemStack;
*/ */
public class PortalCommand extends DRECommand { public class PortalCommand extends DRECommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public PortalCommand() { public PortalCommand() {
setCommand("portal"); setCommand("portal");
setMinArgs(0); setMinArgs(0);
@ -46,7 +48,7 @@ public class PortalCommand extends DRECommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender; Player player = (Player) sender;
DGlobalPlayer dGlobalPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player); DGlobalPlayer dGlobalPlayer = plugin.getDPlayers().getByPlayer(player);
if (dGlobalPlayer instanceof DGamePlayer) { if (dGlobalPlayer instanceof DGamePlayer) {
MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_DUNGEON.getMessage()); MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_DUNGEON.getMessage());
@ -66,7 +68,7 @@ public class PortalCommand extends DRECommand {
DPortal dPortal = dGlobalPlayer.getPortal(); DPortal dPortal = dGlobalPlayer.getPortal();
if (dPortal == null) { if (dPortal == null) {
dPortal = new DPortal(DungeonsXL.getInstance().getGlobalProtections().generateId(DPortal.class, player.getWorld()), player.getWorld(), material, false); dPortal = new DPortal(plugin.getGlobalProtections().generateId(DPortal.class, player.getWorld()), player.getWorld(), material, false);
dGlobalPlayer.setCreatingPortal(dPortal); dGlobalPlayer.setCreatingPortal(dPortal);
dPortal.setWorld(player.getWorld()); dPortal.setWorld(player.getWorld());
dGlobalPlayer.setCachedItem(player.getItemInHand()); dGlobalPlayer.setCachedItem(player.getItemInHand());

View File

@ -53,7 +53,7 @@ public class ReloadCommand extends DRECommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
List<DInstancePlayer> dPlayers = DungeonsXL.getInstance().getDPlayers().getDInstancePlayers(); List<DInstancePlayer> dPlayers = plugin.getDPlayers().getDInstancePlayers();
if (!dPlayers.isEmpty() && args.length == 1 && CompatibilityHandler.getInstance().isSpigot() && sender instanceof Player) { if (!dPlayers.isEmpty() && args.length == 1 && CompatibilityHandler.getInstance().isSpigot() && sender instanceof Player) {
MessageUtil.sendMessage(sender, DMessage.CMD_RELOAD_PLAYERS.getMessage()); MessageUtil.sendMessage(sender, DMessage.CMD_RELOAD_PLAYERS.getMessage());
ClickEvent onClick = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/dungeonsxl reload -force"); ClickEvent onClick = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/dungeonsxl reload -force");
@ -78,8 +78,8 @@ public class ReloadCommand extends DRECommand {
int maps = DungeonsXL.MAPS.listFiles().length; int maps = DungeonsXL.MAPS.listFiles().length;
int dungeons = DungeonsXL.DUNGEONS.listFiles().length; int dungeons = DungeonsXL.DUNGEONS.listFiles().length;
int loaded = DungeonsXL.getInstance().getDWorlds().getEditWorlds().size() + DungeonsXL.getInstance().getDWorlds().getGameWorlds().size(); int loaded = plugin.getDWorlds().getEditWorlds().size() + plugin.getDWorlds().getGameWorlds().size();
int players = DungeonsXL.getInstance().getDPlayers().getDGamePlayers().size(); int players = plugin.getDPlayers().getDGamePlayers().size();
Internals internals = CompatibilityHandler.getInstance().getInternals(); Internals internals = CompatibilityHandler.getInstance().getInternals();
String vault = ""; String vault = "";
if (plugins.getPlugin("Vault") != null) { if (plugins.getPlugin("Vault") != null) {

View File

@ -38,6 +38,8 @@ import org.bukkit.configuration.file.FileConfiguration;
*/ */
public class RenameCommand extends DRECommand { public class RenameCommand extends DRECommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public RenameCommand() { public RenameCommand() {
setCommand("rename"); setCommand("rename");
setMinArgs(2); setMinArgs(2);
@ -50,7 +52,7 @@ public class RenameCommand extends DRECommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
DResourceWorld resource = DungeonsXL.getInstance().getDWorlds().getResourceByName(args[1]); DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[1]);
if (resource == null) { if (resource == null) {
MessageUtil.sendMessage(sender, DMessage.ERROR_NO_SUCH_MAP.getMessage(args[1])); MessageUtil.sendMessage(sender, DMessage.ERROR_NO_SUCH_MAP.getMessage(args[1]));
return; return;
@ -60,7 +62,7 @@ public class RenameCommand extends DRECommand {
resource.getFolder().renameTo(new File(DungeonsXL.MAPS, args[2])); resource.getFolder().renameTo(new File(DungeonsXL.MAPS, args[2]));
resource.getSignData().updateFile(resource); resource.getSignData().updateFile(resource);
for (Dungeon dungeon : DungeonsXL.getInstance().getDungeons().getDungeons()) { for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
DungeonConfig dConfig = dungeon.getConfig(); DungeonConfig dConfig = dungeon.getConfig();
FileConfiguration config = dConfig.getConfig(); FileConfiguration config = dConfig.getConfig();
File file = dConfig.getFile(); File file = dConfig.getFile();
@ -90,7 +92,7 @@ public class RenameCommand extends DRECommand {
} }
boolean changed = false; boolean changed = false;
for (GlobalProtection protection : DungeonsXL.getInstance().getGlobalProtections().getProtections()) { for (GlobalProtection protection : plugin.getGlobalProtections().getProtections()) {
if (protection instanceof GroupSign) { if (protection instanceof GroupSign) {
Dungeon dungeon = ((GroupSign) protection).getDungeon(); Dungeon dungeon = ((GroupSign) protection).getDungeon();
if (dungeon.getName().equals(args[1])) { if (dungeon.getName().equals(args[1])) {
@ -108,7 +110,7 @@ public class RenameCommand extends DRECommand {
} }
if (changed) { if (changed) {
DungeonsXL.getInstance().getGlobalProtections().saveAll(); plugin.getGlobalProtections().saveAll();
} }
MessageUtil.sendMessage(sender, DMessage.CMD_RENAME_SUCCESS.getMessage(args[1], args[2])); MessageUtil.sendMessage(sender, DMessage.CMD_RENAME_SUCCESS.getMessage(args[1], args[2]));

View File

@ -117,7 +117,7 @@ public class StatusCommand extends DRECommand {
String vaultVersionCorrect = getSymbol(vaultVersion.startsWith("1.6")); String vaultVersionCorrect = getSymbol(vaultVersion.startsWith("1.6"));
String permissionPluginCorrect = getSymbol(plugin.getPermissionProvider() != null && plugin.getPermissionProvider().hasGroupSupport()); String permissionPluginCorrect = getSymbol(plugin.getPermissionProvider() != null && plugin.getPermissionProvider().hasGroupSupport());
String economyPluginCorrect = getSymbol(!DungeonsXL.getInstance().getMainConfig().isEconomyEnabled() || plugin.getEconomyProvider() != null); String economyPluginCorrect = getSymbol(!plugin.getMainConfig().isEconomyEnabled() || plugin.getEconomyProvider() != null);
String commandsxlVersionCorrect = getSymbol(commandsxlVersion.startsWith("2.1")); String commandsxlVersionCorrect = getSymbol(commandsxlVersion.startsWith("2.1"));
String itemsxlVersionCorrect = getSymbol(itemsxlVersion.startsWith("0.2")); String itemsxlVersionCorrect = getSymbol(itemsxlVersion.startsWith("0.2"));
String citizensVersionCorrect = getSymbol(citizensVersion.startsWith("2.0")); String citizensVersionCorrect = getSymbol(citizensVersion.startsWith("2.0"));

View File

@ -48,6 +48,8 @@ import org.bukkit.scheduler.BukkitRunnable;
*/ */
public class Game { public class Game {
DungeonsXL plugin = DungeonsXL.getInstance();
private boolean tutorial; private boolean tutorial;
private List<DGroup> dGroups = new ArrayList<>(); private List<DGroup> dGroups = new ArrayList<>();
private boolean started; private boolean started;
@ -73,7 +75,7 @@ public class Game {
} }
public Game(DGroup dGroup, DGameWorld world) { public Game(DGroup dGroup, DGameWorld world) {
DungeonsXL.getInstance().getGames().add(this); plugin.getGames().add(this);
tutorial = false; tutorial = false;
started = false; started = false;
@ -88,7 +90,7 @@ public class Game {
} }
public Game(DGroup dGroup, DResourceWorld resource) { public Game(DGroup dGroup, DResourceWorld resource) {
DungeonsXL.getInstance().getGames().add(this); plugin.getGames().add(this);
tutorial = false; tutorial = false;
started = false; started = false;
@ -108,7 +110,7 @@ public class Game {
} }
public Game(List<DGroup> dGroups, GameType type, DGameWorld world) { public Game(List<DGroup> dGroups, GameType type, DGameWorld world) {
DungeonsXL.getInstance().getGames().add(this); plugin.getGames().add(this);
this.dGroups = dGroups; this.dGroups = dGroups;
this.type = type; this.type = type;
@ -269,7 +271,7 @@ public class Game {
finalRules.apply(dungeonConfig.getDefaultValues()); finalRules.apply(dungeonConfig.getDefaultValues());
} }
finalRules.apply(DungeonsXL.getInstance().getMainConfig().getDefaultWorldConfig()); finalRules.apply(plugin.getMainConfig().getDefaultWorldConfig());
finalRules.apply(GameRuleProvider.DEFAULT_VALUES); finalRules.apply(GameRuleProvider.DEFAULT_VALUES);
@ -396,7 +398,7 @@ public class Game {
public void delete() { public void delete() {
GameSign gameSign = GameSign.getByGame(this); GameSign gameSign = GameSign.getByGame(this);
DungeonsXL.getInstance().getGames().remove(this); plugin.getGames().remove(this);
if (gameSign != null) { if (gameSign != null) {
gameSign.update(); gameSign.update();
@ -445,7 +447,7 @@ public class Game {
mobSign.initializeTask(); mobSign.initializeTask();
} }
} }
}.runTaskLater(DungeonsXL.getInstance(), delay * 20); }.runTaskLater(plugin, delay * 20);
} }
/** /**

View File

@ -182,7 +182,7 @@ public class DPortal extends GlobalProtection {
DGroup dGroup = DGroup.getByPlayer(player); DGroup dGroup = DGroup.getByPlayer(player);
if (dGroup == null) { if (dGroup == null) {
MessageUtil.sendMessage(player, DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.ERROR_JOIN_GROUP)); MessageUtil.sendMessage(player, DMessage.ERROR_JOIN_GROUP.getMessage());
return; return;
} }

View File

@ -436,17 +436,17 @@ public class GameSign extends GlobalProtection {
DGroup dGroup = DGroup.getByPlayer(player); DGroup dGroup = DGroup.getByPlayer(player);
if (dGroup == null) { if (dGroup == null) {
MessageUtil.sendMessage(player, DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.ERROR_JOIN_GROUP)); MessageUtil.sendMessage(player, DMessage.ERROR_JOIN_GROUP.getMessage());
return true; return true;
} }
if (!dGroup.getCaptain().equals(player)) { if (!dGroup.getCaptain().equals(player)) {
MessageUtil.sendMessage(player, DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.ERROR_NOT_CAPTAIN)); MessageUtil.sendMessage(player, DMessage.ERROR_NOT_CAPTAIN.getMessage());
return true; return true;
} }
if (Game.getByDGroup(dGroup) != null) { if (Game.getByDGroup(dGroup) != null) {
MessageUtil.sendMessage(player, DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.ERROR_LEAVE_GAME)); MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_GAME.getMessage());
return true; return true;
} }

View File

@ -93,8 +93,8 @@ public abstract class GlobalProtection {
public boolean onBreak(DGlobalPlayer dPlayer) { public boolean onBreak(DGlobalPlayer dPlayer) {
if (dPlayer.isInBreakMode()) { if (dPlayer.isInBreakMode()) {
delete(); delete();
MessageUtil.sendMessage(dPlayer.getPlayer(), DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.PLAYER_PROTECTED_BLOCK_DELETED)); MessageUtil.sendMessage(dPlayer.getPlayer(), DMessage.PLAYER_PROTECTED_BLOCK_DELETED.getMessage());
MessageUtil.sendMessage(dPlayer.getPlayer(), DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.CMD_BREAK_PROTECTED_MODE)); MessageUtil.sendMessage(dPlayer.getPlayer(), DMessage.CMD_BREAK_PROTECTED_MODE.getMessage());
dPlayer.setInBreakMode(false); dPlayer.setInBreakMode(false);
return false; return false;

View File

@ -34,10 +34,12 @@ import org.bukkit.configuration.file.YamlConfiguration;
*/ */
public class GlobalProtectionCache { public class GlobalProtectionCache {
DungeonsXL plugin = DungeonsXL.getInstance();
private Set<GlobalProtection> protections = new HashSet<>(); private Set<GlobalProtection> protections = new HashSet<>();
public GlobalProtectionCache() { public GlobalProtectionCache() {
Bukkit.getPluginManager().registerEvents(new GlobalProtectionListener(), DungeonsXL.getInstance()); Bukkit.getPluginManager().registerEvents(new GlobalProtectionListener(), plugin);
} }
/** /**
@ -101,7 +103,7 @@ public class GlobalProtectionCache {
* Save all protections to the default file * Save all protections to the default file
*/ */
public void saveAll() { public void saveAll() {
saveAll(DungeonsXL.getInstance().getGlobalData().getConfig()); saveAll(plugin.getGlobalData().getConfig());
} }
/** /**
@ -122,7 +124,7 @@ public class GlobalProtectionCache {
protection.save(config); protection.save(config);
} }
DungeonsXL.getInstance().getGlobalData().save(); plugin.getGlobalData().save();
} }
/** /**
@ -159,7 +161,7 @@ public class GlobalProtectionCache {
/* SUBJECT TO CHANGE */ /* SUBJECT TO CHANGE */
@Deprecated @Deprecated
public void loadAll() { public void loadAll() {
FileConfiguration data = DungeonsXL.getInstance().getGlobalData().getConfig(); FileConfiguration data = plugin.getGlobalData().getConfig();
for (World world : Bukkit.getWorlds()) { for (World world : Bukkit.getWorlds()) {
// GameSigns // GameSigns

View File

@ -45,6 +45,8 @@ import org.bukkit.inventory.ItemStack;
*/ */
public class GlobalProtectionListener implements Listener { public class GlobalProtectionListener implements Listener {
DungeonsXL plugin = DungeonsXL.getInstance();
@EventHandler @EventHandler
public void onBlockBreakWithSignOnIt(BlockBreakEvent event) { public void onBlockBreakWithSignOnIt(BlockBreakEvent event) {
Block block = event.getBlock(); Block block = event.getBlock();
@ -73,9 +75,9 @@ public class GlobalProtectionListener implements Listener {
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock(); Block block = event.getBlock();
Player player = event.getPlayer(); Player player = event.getPlayer();
DGlobalPlayer dGlobalPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player); DGlobalPlayer dGlobalPlayer = plugin.getDPlayers().getByPlayer(player);
GlobalProtection protection = DungeonsXL.getInstance().getGlobalProtections().getByBlock(block); GlobalProtection protection = plugin.getGlobalProtections().getByBlock(block);
if (protection != null) { if (protection != null) {
if (protection.onBreak(dGlobalPlayer)) { if (protection.onBreak(dGlobalPlayer)) {
event.setCancelled(true); event.setCancelled(true);
@ -101,7 +103,7 @@ public class GlobalProtectionListener implements Listener {
public void onEntityExplode(EntityExplodeEvent event) { public void onEntityExplode(EntityExplodeEvent event) {
List<Block> blocklist = event.blockList(); List<Block> blocklist = event.blockList();
for (Block block : blocklist) { for (Block block : blocklist) {
if (DungeonsXL.getInstance().getGlobalProtections().isProtectedBlock(block)) { if (plugin.getGlobalProtections().isProtectedBlock(block)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -138,7 +140,7 @@ public class GlobalProtectionListener implements Listener {
@EventHandler @EventHandler
public void onPortalCreation(PlayerInteractEvent event) { public void onPortalCreation(PlayerInteractEvent event) {
DGlobalPlayer dPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(event.getPlayer()); DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(event.getPlayer());
if (!dPlayer.isCreatingPortal()) { if (!dPlayer.isCreatingPortal()) {
return; return;
} }
@ -148,7 +150,7 @@ public class GlobalProtectionListener implements Listener {
return; return;
} }
for (GlobalProtection protection : DungeonsXL.getInstance().getGlobalProtections().getProtections(DPortal.class)) { for (GlobalProtection protection : plugin.getGlobalProtections().getProtections(DPortal.class)) {
DPortal dPortal = (DPortal) protection; DPortal dPortal = (DPortal) protection;
if (dPortal.isActive() || dPortal != dPlayer.getPortal()) { if (dPortal.isActive() || dPortal != dPlayer.getPortal()) {
continue; continue;
@ -175,7 +177,7 @@ public class GlobalProtectionListener implements Listener {
@EventHandler @EventHandler
public void onInteract(PlayerInteractEvent event) { public void onInteract(PlayerInteractEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (DungeonsXL.getInstance().getDPlayers().getByPlayer(player).isInBreakMode()) { if (plugin.getDPlayers().getByPlayer(player).isInBreakMode()) {
return; return;
} }
Block clickedBlock = event.getClickedBlock(); Block clickedBlock = event.getClickedBlock();
@ -245,7 +247,7 @@ public class GlobalProtectionListener implements Listener {
if (block.getState() instanceof Sign) { if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState(); Sign sign = (Sign) block.getState();
new LeaveSign(DungeonsXL.getInstance().getGlobalProtections().generateId(LeaveSign.class, sign.getWorld()), sign); new LeaveSign(plugin.getGlobalProtections().generateId(LeaveSign.class, sign.getWorld()), sign);
} }
event.setCancelled(true); event.setCancelled(true);

View File

@ -410,7 +410,7 @@ public class GroupSign extends GlobalProtection {
} }
if (DGroup.getByPlayer(player) != null) { if (DGroup.getByPlayer(player) != null) {
MessageUtil.sendMessage(player, DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.ERROR_LEAVE_GROUP)); MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_GROUP.getMessage());
return true; return true;
} }

View File

@ -47,7 +47,7 @@ public class ExternalMobProviderCache {
} }
// Custom providers // Custom providers
for (Entry<String, Object> customExternalMobProvider : DungeonsXL.getInstance().getMainConfig().getExternalMobProviders().entrySet()) { for (Entry<String, Object> customExternalMobProvider : plugin.getMainConfig().getExternalMobProviders().entrySet()) {
providers.add(new CustomExternalMobProvider(customExternalMobProvider)); providers.add(new CustomExternalMobProvider(customExternalMobProvider));
} }
} }

View File

@ -66,7 +66,7 @@ public class DEditPlayer extends DInstancePlayer {
// Permission bridge // Permission bridge
if (plugin.getPermissionProvider() != null) { if (plugin.getPermissionProvider() != null) {
for (String permission : DungeonsXL.getInstance().getMainConfig().getEditPermissions()) { for (String permission : plugin.getMainConfig().getEditPermissions()) {
plugin.getPermissionProvider().playerAddTransient(world.getName(), player, permission); plugin.getPermissionProvider().playerAddTransient(world.getName(), player, permission);
} }
} }
@ -110,7 +110,7 @@ public class DEditPlayer extends DInstancePlayer {
public void delete() { public void delete() {
// Permission bridge // Permission bridge
if (plugin.getPermissionProvider() != null) { if (plugin.getPermissionProvider() != null) {
for (String permission : DungeonsXL.getInstance().getMainConfig().getEditPermissions()) { for (String permission : plugin.getMainConfig().getEditPermissions()) {
plugin.getPermissionProvider().playerRemoveTransient(getWorld().getName(), player, permission); plugin.getPermissionProvider().playerRemoveTransient(getWorld().getName(), player, permission);
} }
} }

View File

@ -234,7 +234,7 @@ public class DGamePlayer extends DInstancePlayer {
return; return;
} }
DClass dClass = DungeonsXL.getInstance().getDClasses().getByName(className); DClass dClass = plugin.getDClasses().getByName(className);
if (dClass != null) { if (dClass != null) {
if (this.dClass != dClass) { if (this.dClass != dClass) {
this.dClass = dClass; this.dClass = dClass;
@ -513,12 +513,12 @@ public class DGamePlayer extends DInstancePlayer {
// Tutorial Permissions // Tutorial Permissions
if (game.isTutorial() && plugin.getPermissionProvider().hasGroupSupport()) { if (game.isTutorial() && plugin.getPermissionProvider().hasGroupSupport()) {
String endGroup = DungeonsXL.getInstance().getMainConfig().getTutorialEndGroup(); String endGroup = plugin.getMainConfig().getTutorialEndGroup();
if (plugin.isGroupEnabled(endGroup)) { if (plugin.isGroupEnabled(endGroup)) {
plugin.getPermissionProvider().playerAddGroup(getPlayer(), endGroup); plugin.getPermissionProvider().playerAddGroup(getPlayer(), endGroup);
} }
String startGroup = DungeonsXL.getInstance().getMainConfig().getTutorialStartGroup(); String startGroup = plugin.getMainConfig().getTutorialStartGroup();
if (plugin.isGroupEnabled(startGroup)) { if (plugin.isGroupEnabled(startGroup)) {
plugin.getPermissionProvider().playerRemoveGroup(getPlayer(), startGroup); plugin.getPermissionProvider().playerRemoveGroup(getPlayer(), startGroup);
} }

View File

@ -72,7 +72,7 @@ public class DGlobalPlayer implements PlayerWrapper {
reset(false); reset(false);
} }
DungeonsXL.getInstance().getDPlayers().addPlayer(this); plugin.getDPlayers().addPlayer(this);
} }
public DGlobalPlayer(DGlobalPlayer dPlayer) { public DGlobalPlayer(DGlobalPlayer dPlayer) {
@ -84,7 +84,7 @@ public class DGlobalPlayer implements PlayerWrapper {
respawnInventory = dPlayer.getRespawnInventory(); respawnInventory = dPlayer.getRespawnInventory();
respawnArmor = dPlayer.getRespawnArmor(); respawnArmor = dPlayer.getRespawnArmor();
DungeonsXL.getInstance().getDPlayers().addPlayer(this); plugin.getDPlayers().addPlayer(this);
} }
/* Getters and setters */ /* Getters and setters */
@ -136,7 +136,7 @@ public class DGlobalPlayer implements PlayerWrapper {
* @return if the player is in group chat * @return if the player is in group chat
*/ */
public boolean isInGroupChat() { public boolean isInGroupChat() {
if (!DungeonsXL.getInstance().getMainConfig().isChatEnabled()) { if (!plugin.getMainConfig().isChatEnabled()) {
return false; return false;
} }
return groupChat; return groupChat;
@ -154,7 +154,7 @@ public class DGlobalPlayer implements PlayerWrapper {
* @return if the player spies the DXL chat channels * @return if the player spies the DXL chat channels
*/ */
public boolean isInChatSpyMode() { public boolean isInChatSpyMode() {
if (!DungeonsXL.getInstance().getMainConfig().isChatEnabled()) { if (!plugin.getMainConfig().isChatEnabled()) {
return false; return false;
} }
return chatSpyMode; return chatSpyMode;
@ -366,8 +366,8 @@ public class DGlobalPlayer implements PlayerWrapper {
return; return;
} }
final String startGroup = DungeonsXL.getInstance().getMainConfig().getTutorialStartGroup(); final String startGroup = plugin.getMainConfig().getTutorialStartGroup();
if ((DungeonsXL.getInstance().getMainConfig().getTutorialDungeon() == null || startGroup == null)) { if ((plugin.getMainConfig().getTutorialDungeon() == null || startGroup == null)) {
return; return;
} }
@ -375,7 +375,7 @@ public class DGlobalPlayer implements PlayerWrapper {
plugin.getPermissionProvider().playerAddGroup(player, startGroup); plugin.getPermissionProvider().playerAddGroup(player, startGroup);
} }
DGroup dGroup = new DGroup(player, DungeonsXL.getInstance().getMainConfig().getTutorialDungeon(), false); DGroup dGroup = new DGroup(player, plugin.getMainConfig().getTutorialDungeon(), false);
DGroupCreateEvent createEvent = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.GROUP_SIGN); DGroupCreateEvent createEvent = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.GROUP_SIGN);
Bukkit.getPluginManager().callEvent(createEvent); Bukkit.getPluginManager().callEvent(createEvent);
@ -391,7 +391,7 @@ public class DGlobalPlayer implements PlayerWrapper {
DGameWorld gameWorld = null; DGameWorld gameWorld = null;
if (dGroup.getGameWorld() == null) { if (dGroup.getGameWorld() == null) {
DResourceWorld resource = DungeonsXL.getInstance().getDWorlds().getResourceByName(dGroup.getMapName()); DResourceWorld resource = plugin.getDWorlds().getResourceByName(dGroup.getMapName());
if (resource == null) { if (resource == null) {
MessageUtil.sendMessage(player, DMessage.ERROR_TUTORIAL_NOT_EXIST.getMessage()); MessageUtil.sendMessage(player, DMessage.ERROR_TUTORIAL_NOT_EXIST.getMessage());
return; return;

View File

@ -57,7 +57,7 @@ import org.bukkit.scheduler.BukkitTask;
public class DGroup { public class DGroup {
DungeonsXL plugin = DungeonsXL.getInstance(); DungeonsXL plugin = DungeonsXL.getInstance();
DPlayerCache dPlayers = DungeonsXL.getInstance().getDPlayers(); DPlayerCache dPlayers = plugin.getDPlayers();
private String name; private String name;
private UUID captain; private UUID captain;
@ -81,7 +81,7 @@ public class DGroup {
} }
public DGroup(String name, Player player) { public DGroup(String name, Player player) {
DungeonsXL.getInstance().getDGroups().add(this); plugin.getDGroups().add(this);
this.name = name; this.name = name;
setCaptain(player); setCaptain(player);
@ -103,10 +103,10 @@ public class DGroup {
@Deprecated @Deprecated
public DGroup(String name, Player captain, List<Player> players, String identifier, boolean multiFloor) { public DGroup(String name, Player captain, List<Player> players, String identifier, boolean multiFloor) {
DungeonsXL.getInstance().getDGroups().add(this); plugin.getDGroups().add(this);
this.name = name; this.name = name;
DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(DungeonsXL.getInstance().getDPlayers().getByPlayer(captain), true, this); DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(plugin.getDPlayers().getByPlayer(captain), true, this);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
@ -120,14 +120,14 @@ public class DGroup {
} }
} }
dungeon = DungeonsXL.getInstance().getDungeons().getByName(identifier); dungeon = plugin.getDungeons().getByName(identifier);
if (multiFloor && dungeon != null) { if (multiFloor && dungeon != null) {
// Real dungeon // Real dungeon
unplayedFloors = new ArrayList<>(dungeon.getConfig().getFloors()); unplayedFloors = new ArrayList<>(dungeon.getConfig().getFloors());
} else { } else {
// Artificial dungeon // Artificial dungeon
DResourceWorld resource = DungeonsXL.getInstance().getDWorlds().getResourceByName(identifier); DResourceWorld resource = plugin.getDWorlds().getResourceByName(identifier);
dungeon = new Dungeon(resource); dungeon = new Dungeon(resource);
} }
@ -144,10 +144,10 @@ public class DGroup {
} }
public DGroup(String name, Player captain, List<Player> players, Dungeon dungeon) { public DGroup(String name, Player captain, List<Player> players, Dungeon dungeon) {
DungeonsXL.getInstance().getDGroups().add(this); plugin.getDGroups().add(this);
this.name = name; this.name = name;
DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(DungeonsXL.getInstance().getDPlayers().getByPlayer(captain), true, this); DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(plugin.getDPlayers().getByPlayer(captain), true, this);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
@ -287,7 +287,7 @@ public class DGroup {
GroupSign.updatePerGroup(this); GroupSign.updatePerGroup(this);
if (message) { if (message) {
sendMessage(DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.PLAYER_LEFT_GROUP, player.getName())); sendMessage(DMessage.PLAYER_LEFT_GROUP.getMessage(player.getName()));
} }
if (isEmpty()) { if (isEmpty()) {
@ -318,18 +318,18 @@ public class DGroup {
if (DGroup.getByPlayer(player) != null) { if (DGroup.getByPlayer(player) != null) {
if (!silent) { if (!silent) {
MessageUtil.sendMessage(getCaptain(), DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.ERROR_IN_GROUP, player.getName())); MessageUtil.sendMessage(getCaptain(), DMessage.ERROR_IN_GROUP.getMessage(player.getName()));
} }
return; return;
} }
if (!silent) { if (!silent) {
MessageUtil.sendMessage(player, DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.PLAYER_INVITED, getCaptain().getName(), name)); MessageUtil.sendMessage(player, DMessage.PLAYER_INVITED.getMessage(getCaptain().getName(), name));
} }
// Send message // Send message
if (!silent) { if (!silent) {
sendMessage(DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.GROUP_INVITED_PLAYER, getCaptain().getName(), player.getName(), name)); sendMessage(DMessage.GROUP_INVITED_PLAYER.getMessage(getCaptain().getName(), player.getName(), name));
} }
// Add player // Add player
@ -347,19 +347,19 @@ public class DGroup {
if (DGroup.getByPlayer(player) != this) { if (DGroup.getByPlayer(player) != this) {
if (!silent) { if (!silent) {
MessageUtil.sendMessage(getCaptain(), DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.ERROR_NOT_IN_GROUP, player.getName(), name)); MessageUtil.sendMessage(getCaptain(), DMessage.ERROR_NOT_IN_GROUP.getMessage(player.getName(), name));
} }
return; return;
} }
if (!silent) { if (!silent) {
MessageUtil.sendMessage(player, DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.PLAYER_UNINVITED, player.getName(), name)); MessageUtil.sendMessage(player, DMessage.PLAYER_UNINVITED.getMessage(player.getName(), name));
} }
// Send message // Send message
if (!silent) { if (!silent) {
for (Player groupPlayer : players.getOnlinePlayers()) { for (Player groupPlayer : players.getOnlinePlayers()) {
MessageUtil.sendMessage(groupPlayer, DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.GROUP_UNINVITED_PLAYER, getCaptain().getName(), player.getName(), name)); MessageUtil.sendMessage(groupPlayer, DMessage.GROUP_UNINVITED_PLAYER.getMessage(getCaptain().getName(), player.getName(), name));
} }
} }
@ -421,13 +421,13 @@ public class DGroup {
* the name of the dungeon * the name of the dungeon
*/ */
public boolean setDungeon(String name) { public boolean setDungeon(String name) {
dungeon = DungeonsXL.getInstance().getDungeons().getByName(name); dungeon = plugin.getDungeons().getByName(name);
if (dungeon != null) { if (dungeon != null) {
unplayedFloors = dungeon.getConfig().getFloors(); unplayedFloors = dungeon.getConfig().getFloors();
return true; return true;
} else { } else {
DResourceWorld resource = DungeonsXL.getInstance().getDWorlds().getResourceByName(name); DResourceWorld resource = plugin.getDWorlds().getResourceByName(name);
if (resource != null) { if (resource != null) {
dungeon = new Dungeon(resource); dungeon = new Dungeon(resource);
return true; return true;
@ -736,7 +736,7 @@ public class DGroup {
public void delete() { public void delete() {
Game game = Game.getByDGroup(this); Game game = Game.getByDGroup(this);
DungeonsXL.getInstance().getDGroups().remove(this); plugin.getDGroups().remove(this);
if (game != null) { if (game != null) {
game.removeDGroup(this); game.removeDGroup(this);
@ -756,7 +756,7 @@ public class DGroup {
game.fetchRules(); game.fetchRules();
GameRuleProvider rules = game.getRules(); GameRuleProvider rules = game.getRules();
color = DungeonsXL.getInstance().getMainConfig().getGroupColorPriority().get(game.getDGroups().indexOf(this)); color = plugin.getMainConfig().getGroupColorPriority().get(game.getDGroups().indexOf(this));
for (DGroup dGroup : game.getDGroups()) { for (DGroup dGroup : game.getDGroups()) {
if (dGroup == null) { if (dGroup == null) {
@ -807,7 +807,7 @@ public class DGroup {
dPlayer.respawn(); dPlayer.respawn();
if (DungeonsXL.getInstance().getMainConfig().isSendFloorTitleEnabled()) { if (plugin.getMainConfig().isSendFloorTitleEnabled()) {
if (rules.getTitle() != null || rules.getSubTitle() != null) { if (rules.getTitle() != null || rules.getSubTitle() != null) {
String title = rules.getTitle() == null ? "" : rules.getTitle(); String title = rules.getTitle() == null ? "" : rules.getTitle();
String subtitle = rules.getSubTitle() == null ? "" : rules.getSubTitle(); String subtitle = rules.getSubTitle() == null ? "" : rules.getSubTitle();

View File

@ -31,7 +31,7 @@ import org.bukkit.potion.PotionEffect;
*/ */
public abstract class DInstancePlayer extends DGlobalPlayer { public abstract class DInstancePlayer extends DGlobalPlayer {
MainConfig config = DungeonsXL.getInstance().getMainConfig(); MainConfig config = plugin.getMainConfig();
private World world; private World world;
@ -90,7 +90,7 @@ public abstract class DInstancePlayer extends DGlobalPlayer {
new DGlobalPlayer(this); new DGlobalPlayer(this);
} else { } else {
DungeonsXL.getInstance().getDPlayers().removePlayer(this); plugin.getDPlayers().removePlayer(this);
} }
} }
@ -101,13 +101,13 @@ public abstract class DInstancePlayer extends DGlobalPlayer {
* the message to send * the message to send
*/ */
public void chat(String message) { public void chat(String message) {
DInstanceWorld instance = DungeonsXL.getInstance().getDWorlds().getInstanceByWorld(world); DInstanceWorld instance = plugin.getDWorlds().getInstanceByWorld(world);
if (instance == null) { if (instance == null) {
return; return;
} }
instance.sendMessage(ParsingUtil.replaceChatPlaceholders(config.getChatFormatGame(), this) + message); instance.sendMessage(ParsingUtil.replaceChatPlaceholders(config.getChatFormatGame(), this) + message);
for (DGlobalPlayer player : DungeonsXL.getInstance().getDPlayers().getDGlobalPlayers()) { for (DGlobalPlayer player : plugin.getDPlayers().getDGlobalPlayers()) {
if (player.isInChatSpyMode()) { if (player.isInChatSpyMode()) {
if (!instance.getWorld().getPlayers().contains(player.getPlayer())) { if (!instance.getWorld().getPlayers().contains(player.getPlayer())) {
player.sendMessage(ParsingUtil.replaceChatPlaceholders(config.getChatFormatSpy(), this) + message); player.sendMessage(ParsingUtil.replaceChatPlaceholders(config.getChatFormatSpy(), this) + message);

View File

@ -34,7 +34,7 @@ import org.bukkit.scheduler.BukkitTask;
public class DPlayerCache { public class DPlayerCache {
DungeonsXL plugin = DungeonsXL.getInstance(); DungeonsXL plugin = DungeonsXL.getInstance();
MainConfig mainConfig = DungeonsXL.getInstance().getMainConfig(); MainConfig mainConfig = plugin.getMainConfig();
private BukkitTask secureModeTask; private BukkitTask secureModeTask;
private BukkitTask updateTask; private BukkitTask updateTask;

View File

@ -62,14 +62,13 @@ import org.bukkit.inventory.meta.BookMeta;
*/ */
public class DPlayerListener implements Listener { public class DPlayerListener implements Listener {
DungeonsXL plugin; DungeonsXL plugin = DungeonsXL.getInstance();
DPlayerCache dPlayers; DPlayerCache dPlayers;
MainConfig config = DungeonsXL.getInstance().getMainConfig(); MainConfig config = plugin.getMainConfig();
public static final String ALL = "@all "; public static final String ALL = "@all ";
public DPlayerListener(DPlayerCache dPlayers) { public DPlayerListener(DPlayerCache dPlayers) {
this.plugin = DungeonsXL.getInstance();
this.dPlayers = dPlayers; this.dPlayers = dPlayers;
} }
@ -378,7 +377,7 @@ public class DPlayerListener implements Listener {
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onPlayerLogin(PlayerLoginEvent event) { public void onPlayerLogin(PlayerLoginEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
MainConfig config = DungeonsXL.getInstance().getMainConfig(); MainConfig config = plugin.getMainConfig();
if (!config.isTutorialActivated()) { if (!config.isTutorialActivated()) {
return; return;
@ -401,7 +400,7 @@ public class DPlayerListener implements Listener {
continue; continue;
} }
if (DungeonsXL.getInstance().getDWorlds().getGameWorlds().size() >= config.getMaxInstances()) { if (plugin.getDWorlds().getGameWorlds().size() >= config.getMaxInstances()) {
event.setResult(PlayerLoginEvent.Result.KICK_FULL); event.setResult(PlayerLoginEvent.Result.KICK_FULL);
event.setKickMessage(DMessage.ERROR_TOO_MANY_TUTORIALS.getMessage()); event.setKickMessage(DMessage.ERROR_TOO_MANY_TUTORIALS.getMessage());
} }
@ -470,7 +469,7 @@ public class DPlayerListener implements Listener {
if (isCitizensNPC(player)) { if (isCitizensNPC(player)) {
return; return;
} }
DungeonsXL.getInstance().getDPlayers().getByPlayer(player).applyRespawnInventory(); plugin.getDPlayers().getByPlayer(player).applyRespawnInventory();
DGlobalPlayer dPlayer = DGamePlayer.getByPlayer(player); DGlobalPlayer dPlayer = DGamePlayer.getByPlayer(player);
if (dPlayer == null) { if (dPlayer == null) {

View File

@ -37,7 +37,7 @@ public class DLootInventory {
public DLootInventory(Player player, ItemStack[] itemStacks) { public DLootInventory(Player player, ItemStack[] itemStacks) {
DungeonsXL.getInstance().getDLootInventories().add(this); DungeonsXL.getInstance().getDLootInventories().add(this);
inventory = Bukkit.createInventory(player, 54, ChatColor.translateAlternateColorCodes('&', DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.PLAYER_TREASURES))); inventory = Bukkit.createInventory(player, 54, ChatColor.translateAlternateColorCodes('&', DMessage.PLAYER_TREASURES.getMessage()));
for (ItemStack itemStack : itemStacks) { for (ItemStack itemStack : itemStacks) {
if (itemStack != null) { if (itemStack != null) {
inventory.addItem(itemStack); inventory.addItem(itemStack);

View File

@ -80,7 +80,7 @@ public class ItemReward extends Reward {
} else { } else {
new DLootInventory(player, items.subList(0, 54).toArray(new ItemStack[54])); new DLootInventory(player, items.subList(0, 54).toArray(new ItemStack[54]));
DungeonsXL.getInstance().getDPlayers().getByPlayer(player).setRewardItems(new CopyOnWriteArrayList<>(items.subList(54, items.size()))); plugin.getDPlayers().getByPlayer(player).setRewardItems(new CopyOnWriteArrayList<>(items.subList(54, items.size())));
MessageUtil.sendMessage(player, DMessage.ERROR_TOO_MANY_REWARDS.getMessage()); MessageUtil.sendMessage(player, DMessage.ERROR_TOO_MANY_REWARDS.getMessage());
} }
} }

View File

@ -39,6 +39,8 @@ import org.bukkit.inventory.ItemStack;
*/ */
public class RewardListener implements Listener { public class RewardListener implements Listener {
DungeonsXL plugin = DungeonsXL.getInstance();
@EventHandler @EventHandler
public void onInventoryClose(InventoryCloseEvent event) { public void onInventoryClose(InventoryCloseEvent event) {
if (!(event.getPlayer() instanceof Player)) { if (!(event.getPlayer() instanceof Player)) {
@ -46,7 +48,7 @@ public class RewardListener implements Listener {
} }
Player player = (Player) event.getPlayer(); Player player = (Player) event.getPlayer();
for (DLootInventory inventory : DungeonsXL.getInstance().getDLootInventories()) { for (DLootInventory inventory : plugin.getDLootInventories()) {
if (event.getView() != inventory.getInventoryView()) { if (event.getView() != inventory.getInventoryView()) {
continue; continue;
} }
@ -61,7 +63,7 @@ public class RewardListener implements Listener {
} }
} }
DungeonsXL.getInstance().getDLootInventories().remove(inventory); plugin.getDLootInventories().remove(inventory);
} }
} }
@ -94,7 +96,7 @@ public class RewardListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
if (!DungeonsXL.getInstance().getMainConfig().getOpenInventories() && !DPermissions.hasPermission(event.getPlayer(), DPermissions.INSECURE)) { if (!plugin.getMainConfig().getOpenInventories() && !DPermissions.hasPermission(event.getPlayer(), DPermissions.INSECURE)) {
World world = event.getPlayer().getWorld(); World world = event.getPlayer().getWorld();
if (event.getInventory().getType() != InventoryType.CREATIVE && DEditWorld.getByWorld(world) != null) { if (event.getInventory().getType() != InventoryType.CREATIVE && DEditWorld.getByWorld(world) != null) {
event.setCancelled(true); event.setCancelled(true);
@ -105,7 +107,7 @@ public class RewardListener implements Listener {
@EventHandler @EventHandler
public void onPlayerMove(PlayerMoveEvent event) { public void onPlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (DungeonsXL.getInstance().getDWorlds().getInstanceByWorld(player.getWorld()) != null) { if (plugin.getDWorlds().getInstanceByWorld(player.getWorld()) != null) {
return; return;
} }
DLootInventory inventory = DLootInventory.getByPlayer(player); DLootInventory inventory = DLootInventory.getByPlayer(player);

View File

@ -167,7 +167,7 @@ public class ChestSign extends DSign {
} }
if (!lines[2].isEmpty()) { if (!lines[2].isEmpty()) {
lootTable = DungeonsXL.getInstance().getDLootTables().getByName(lines[2]); lootTable = plugin.getDLootTables().getByName(lines[2]);
} }
if (chest == null) { if (chest == null) {

View File

@ -39,7 +39,7 @@ import org.bukkit.entity.Player;
*/ */
public abstract class DSign { public abstract class DSign {
DungeonsXL plugin = DungeonsXL.getInstance(); protected DungeonsXL plugin = DungeonsXL.getInstance();
public static final String ERROR_0 = ChatColor.DARK_RED + "## ERROR ##"; public static final String ERROR_0 = ChatColor.DARK_RED + "## ERROR ##";
public static final String ERROR_1 = ChatColor.WHITE + "Please"; public static final String ERROR_1 = ChatColor.WHITE + "Please";

View File

@ -62,7 +62,7 @@ public class FloorSign extends DSign {
@Override @Override
public void onInit() { public void onInit() {
if (!lines[1].isEmpty()) { if (!lines[1].isEmpty()) {
floor = DungeonsXL.getInstance().getDWorlds().getResourceByName(lines[1]); floor = plugin.getDWorlds().getResourceByName(lines[1]);
} }
if (!getTriggers().isEmpty()) { if (!getTriggers().isEmpty()) {
@ -104,7 +104,7 @@ public class FloorSign extends DSign {
@Override @Override
public void onTrigger() { public void onTrigger() {
for (DGamePlayer dPlayer : DungeonsXL.getInstance().getDPlayers().getDGamePlayers()) { for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) {
dPlayer.finishFloor(floor); dPlayer.finishFloor(floor);
} }
} }

View File

@ -81,7 +81,7 @@ public class LeaveSign extends DSign {
@Override @Override
public void onTrigger() { public void onTrigger() {
for (DGamePlayer dPlayer : DungeonsXL.getInstance().getDPlayers().getDGamePlayers()) { for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) {
DGamePlayerEscapeEvent event = new DGamePlayerEscapeEvent(dPlayer); DGamePlayerEscapeEvent event = new DGamePlayerEscapeEvent(dPlayer);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);

View File

@ -61,7 +61,7 @@ public class ResourcePackSign extends DSign {
/* Actions */ /* Actions */
@Override @Override
public boolean check() { public boolean check() {
return DungeonsXL.getInstance().getMainConfig().getResourcePacks().get(lines[1]) != null || lines[1].equalsIgnoreCase("reset"); return plugin.getMainConfig().getResourcePacks().get(lines[1]) != null || lines[1].equalsIgnoreCase("reset");
} }
@Override @Override
@ -71,7 +71,7 @@ public class ResourcePackSign extends DSign {
// Placeholder to reset to default // Placeholder to reset to default
url = "http://google.com"; url = "http://google.com";
} else { } else {
url = DungeonsXL.getInstance().getMainConfig().getResourcePacks().get(lines[1]); url = plugin.getMainConfig().getResourcePacks().get(lines[1]);
} }
if (url instanceof String) { if (url instanceof String) {

View File

@ -44,12 +44,12 @@ public class ScriptSign extends DSign {
@Override @Override
public boolean check() { public boolean check() {
return DungeonsXL.getInstance().getSignScripts().getByName(lines[1]) != null; return plugin.getSignScripts().getByName(lines[1]) != null;
} }
@Override @Override
public void onInit() { public void onInit() {
SignScript script = DungeonsXL.getInstance().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());
getGameWorld().getDSigns().add(dSign); getGameWorld().getDSigns().add(dSign);

View File

@ -36,7 +36,7 @@ public class ClassesSign extends DSign {
public ClassesSign(Sign sign, String[] lines, DGameWorld gameWorld) { public ClassesSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld); super(sign, lines, gameWorld);
dClass = DungeonsXL.getInstance().getDClasses().getByName(sign.getLine(1)); dClass = plugin.getDClasses().getByName(sign.getLine(1));
} }
/* Getters and setters */ /* Getters and setters */
@ -58,7 +58,7 @@ public class ClassesSign extends DSign {
/* Actions */ /* Actions */
@Override @Override
public boolean check() { public boolean check() {
return DungeonsXL.getInstance().getDClasses().getByName(lines[1]) != null; return plugin.getDClasses().getByName(lines[1]) != null;
} }
@Override @Override

View File

@ -18,7 +18,6 @@ package io.github.dre2n.dungeonsxl.sign.lobby;
import io.github.dre2n.commons.chat.MessageUtil; import io.github.dre2n.commons.chat.MessageUtil;
import io.github.dre2n.commons.misc.NumberUtil; import io.github.dre2n.commons.misc.NumberUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessage; import io.github.dre2n.dungeonsxl.config.DMessage;
import io.github.dre2n.dungeonsxl.game.GameType; import io.github.dre2n.dungeonsxl.game.GameType;
import io.github.dre2n.dungeonsxl.game.GameTypeDefault; import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
@ -88,8 +87,8 @@ public class ReadySign extends DSign {
@Override @Override
public void onInit() { public void onInit() {
if (DungeonsXL.getInstance().getGameTypes().getBySign(this) != null) { if (plugin.getGameTypes().getBySign(this) != null) {
gameType = DungeonsXL.getInstance().getGameTypes().getBySign(this); gameType = plugin.getGameTypes().getBySign(this);
} else { } else {
gameType = GameTypeDefault.CUSTOM; gameType = GameTypeDefault.CUSTOM;
@ -129,7 +128,7 @@ public class ReadySign extends DSign {
public void run() { public void run() {
onTrigger(); onTrigger();
} }
}.runTaskLater(DungeonsXL.getInstance(), (long) (autoStart * 20)); }.runTaskLater(plugin, (long) (autoStart * 20));
if (!DGroup.getByPlayer(player).isPlaying()) { if (!DGroup.getByPlayer(player).isPlaying()) {
ProgressBar.sendProgressBar(getGame().getPlayers(), (int) Math.ceil(autoStart)); ProgressBar.sendProgressBar(getGame().getPlayers(), (int) Math.ceil(autoStart));
@ -168,7 +167,7 @@ public class ReadySign extends DSign {
} }
if (dPlayer.isReady()) { if (dPlayer.isReady()) {
MessageUtil.sendMessage(dPlayer.getPlayer(), DungeonsXL.getInstance().getMessageConfig().getMessage(dPlayer.isReady() ? DMessage.PLAYER_READY : DMessage.ERROR_READY)); MessageUtil.sendMessage(dPlayer.getPlayer(), plugin.getMessageConfig().getMessage(dPlayer.isReady() ? DMessage.PLAYER_READY : DMessage.ERROR_READY));
} }
} }

View File

@ -61,7 +61,7 @@ public class HologramSign extends DSign {
Location location = getSign().getLocation(); Location location = getSign().getLocation();
location = location.add(0.5, NumberUtil.parseDouble(lines[2]), 0.5); location = location.add(0.5, NumberUtil.parseDouble(lines[2]), 0.5);
hologram = HologramsAPI.createHologram(DungeonsXL.getInstance(), location); hologram = HologramsAPI.createHologram(plugin, location);
for (String line : holoLines) { for (String line : holoLines) {
if (line.startsWith("Item:")) { if (line.startsWith("Item:")) {
String id = line.replace("Item:", ""); String id = line.replace("Item:", "");

View File

@ -129,7 +129,7 @@ public class DMobSign extends DSign implements MobSign {
@Override @Override
public void initializeTask() { public void initializeTask() {
task = new MobSpawnTask(this).runTaskTimer(DungeonsXL.getInstance(), 0L, 20L); task = new MobSpawnTask(this).runTaskTimer(plugin, 0L, 20L);
} }
@Override @Override

View File

@ -141,7 +141,7 @@ public class ExternalMobSign extends DSign implements MobSign {
@Override @Override
public void initializeTask() { public void initializeTask() {
task = new ExternalMobSpawnTask(this, provider).runTaskTimer(DungeonsXL.getInstance(), 0L, 20L); task = new ExternalMobSpawnTask(this, provider).runTaskTimer(plugin, 0L, 20L);
} }
/** /**
@ -228,7 +228,7 @@ public class ExternalMobSign extends DSign implements MobSign {
initialAmount = amount; initialAmount = amount;
if (attributes.length == 3) { if (attributes.length == 3) {
provider = DungeonsXL.getInstance().getExternalMobProviders().getByIdentifier(attributes[2]); provider = plugin.getExternalMobProviders().getByIdentifier(attributes[2]);
} else { } else {
provider = ExternalMobPlugin.MYTHIC_MOBS; provider = ExternalMobPlugin.MYTHIC_MOBS;
} }

View File

@ -39,7 +39,7 @@ import org.bukkit.scheduler.BukkitRunnable;
*/ */
public class DEditWorld extends DInstanceWorld { public class DEditWorld extends DInstanceWorld {
DWorldCache worlds = DungeonsXL.getInstance().getDWorlds(); DWorldCache worlds = plugin.getDWorlds();
public static String ID_FILE_PREFIX = ".id_"; public static String ID_FILE_PREFIX = ".id_";
@ -121,7 +121,7 @@ public class DEditWorld extends DInstanceWorld {
getWorld().save(); getWorld().save();
if (!DungeonsXL.getInstance().getMainConfig().areTweaksEnabled()) { if (!plugin.getMainConfig().areTweaksEnabled()) {
FileUtil.copyDirectory(getFolder(), getResource().getFolder(), DungeonsXL.EXCLUDED_FILES); FileUtil.copyDirectory(getFolder(), getResource().getFolder(), DungeonsXL.EXCLUDED_FILES);
FileUtil.deleteUnusedFiles(getResource().getFolder()); FileUtil.deleteUnusedFiles(getResource().getFolder());
@ -162,7 +162,7 @@ public class DEditWorld extends DInstanceWorld {
dPlayer.leave(); dPlayer.leave();
} }
if (!DungeonsXL.getInstance().getMainConfig().areTweaksEnabled()) { if (!plugin.getMainConfig().areTweaksEnabled()) {
if (save) { if (save) {
Bukkit.unloadWorld(getWorld(), true); Bukkit.unloadWorld(getWorld(), true);
} }

View File

@ -119,7 +119,7 @@ public class DGameWorld extends DInstanceWorld {
*/ */
public Game getGame() { public Game getGame() {
if (game == null) { if (game == null) {
for (Game game : DungeonsXL.getInstance().getGames()) { for (Game game : plugin.getGames()) {
if (game.getWorld() == this) { if (game.getWorld() == this) {
this.game = game; this.game = game;
} }
@ -434,7 +434,7 @@ public class DGameWorld extends DInstanceWorld {
* @return the Dungeon that contains the DGameWorld * @return the Dungeon that contains the DGameWorld
*/ */
public Dungeon getDungeon() { public Dungeon getDungeon() {
for (Dungeon dungeon : DungeonsXL.getInstance().getDungeons().getDungeons()) { for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
if (dungeon.getConfig().containsFloor(getResource())) { if (dungeon.getConfig().containsFloor(getResource())) {
return dungeon; return dungeon;
} }
@ -493,7 +493,7 @@ public class DGameWorld extends DInstanceWorld {
return; return;
} }
if (!DungeonsXL.getInstance().getMainConfig().areTweaksEnabled()) { if (!plugin.getMainConfig().areTweaksEnabled()) {
Bukkit.unloadWorld(getWorld(), false); Bukkit.unloadWorld(getWorld(), false);
FileUtil.removeDirectory(getFolder()); FileUtil.removeDirectory(getFolder());
worlds.removeInstance(this); worlds.removeInstance(this);

View File

@ -31,7 +31,7 @@ import org.bukkit.World;
public abstract class DInstanceWorld { public abstract class DInstanceWorld {
DungeonsXL plugin = DungeonsXL.getInstance(); DungeonsXL plugin = DungeonsXL.getInstance();
DWorldCache worlds = DungeonsXL.getInstance().getDWorlds(); DWorldCache worlds = plugin.getDWorlds();
private DResourceWorld resourceWorld; private DResourceWorld resourceWorld;
private File folder; private File folder;

View File

@ -213,7 +213,7 @@ public class DResourceWorld {
final DInstanceWorld instance = game ? new DGameWorld(this, instanceFolder, id) : new DEditWorld(this, instanceFolder, id); final DInstanceWorld instance = game ? new DGameWorld(this, instanceFolder, id) : new DEditWorld(this, instanceFolder, id);
if (!DungeonsXL.getInstance().getMainConfig().areTweaksEnabled()) { if (!plugin.getMainConfig().areTweaksEnabled()) {
FileUtil.copyDirectory(folder, instanceFolder, DungeonsXL.EXCLUDED_FILES); FileUtil.copyDirectory(folder, instanceFolder, DungeonsXL.EXCLUDED_FILES);
instance.world = Bukkit.createWorld(WorldCreator.name(name)); instance.world = Bukkit.createWorld(WorldCreator.name(name));
@ -288,7 +288,7 @@ public class DResourceWorld {
return null; return null;
} }
if (!DungeonsXL.getInstance().getMainConfig().areTweaksEnabled()) { if (!plugin.getMainConfig().areTweaksEnabled()) {
editWorld.world = creator.createWorld(); editWorld.world = creator.createWorld();
} else { } else {

View File

@ -38,7 +38,7 @@ import org.bukkit.scheduler.BukkitTask;
public class DWorldCache { public class DWorldCache {
DungeonsXL plugin = DungeonsXL.getInstance(); DungeonsXL plugin = DungeonsXL.getInstance();
MainConfig mainConfig = DungeonsXL.getInstance().getMainConfig(); MainConfig mainConfig = plugin.getMainConfig();
public static final File RAW = new File(DungeonsXL.MAPS, ".raw"); public static final File RAW = new File(DungeonsXL.MAPS, ".raw");