Make DungeonsXL singleton getters static

This commit is contained in:
Daniel Saukel 2017-02-20 01:46:55 +01:00
parent 70d66515bd
commit 33f05c1678
110 changed files with 379 additions and 443 deletions

View File

@ -279,8 +279,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the loaded instance of GlobalData * @return the loaded instance of GlobalData
*/ */
public GlobalData getGlobalData() { public static GlobalData getGlobalData() {
return globalData; return instance.globalData;
} }
/** /**
@ -293,8 +293,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the loaded instance of MainConfig * @return the loaded instance of MainConfig
*/ */
public MainConfig getMainConfig() { public static MainConfig getMainConfig() {
return mainConfig; return instance.mainConfig;
} }
/** /**
@ -307,8 +307,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the loaded instance of MessageConfig * @return the loaded instance of MessageConfig
*/ */
public MessageConfig getMessageConfig() { public static MessageConfig getMessageConfig() {
return messageConfig; return instance.messageConfig;
} }
/** /**
@ -337,8 +337,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the dSigns * @return the dSigns
*/ */
public DSignTypes getDSigns() { public static DSignTypes getDSigns() {
return dSigns; return instance.dSigns;
} }
/** /**
@ -351,8 +351,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the game types * @return the game types
*/ */
public GameTypes getGameTypes() { public static GameTypes getGameTypes() {
return gameTypes; return instance.gameTypes;
} }
/** /**
@ -365,8 +365,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the requirement types * @return the requirement types
*/ */
public RequirementTypes getRequirementTypes() { public static RequirementTypes getRequirementTypes() {
return requirementTypes; return instance.requirementTypes;
} }
/** /**
@ -379,8 +379,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the reward types * @return the reward types
*/ */
public RewardTypes getRewardTypes() { public static RewardTypes getRewardTypes() {
return rewardTypes; return instance.rewardTypes;
} }
/** /**
@ -393,8 +393,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the triggers * @return the triggers
*/ */
public TriggerTypes getTriggers() { public static TriggerTypes getTriggers() {
return triggers; return instance.triggers;
} }
/** /**
@ -407,8 +407,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the loaded instance of Dungeons * @return the loaded instance of Dungeons
*/ */
public Dungeons getDungeons() { public static Dungeons getDungeons() {
return dungeons; return instance.dungeons;
} }
/** /**
@ -421,8 +421,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the loaded instance of GlobalProtections * @return the loaded instance of GlobalProtections
*/ */
public GlobalProtections getGlobalProtections() { public static GlobalProtections getGlobalProtections() {
return protections; return instance.protections;
} }
/** /**
@ -435,8 +435,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the loaded instance of ExternalMobProviders * @return the loaded instance of ExternalMobProviders
*/ */
public ExternalMobProviders getExternalMobProviders() { public static ExternalMobProviders getExternalMobProviders() {
return dMobProviders; return instance.dMobProviders;
} }
/** /**
@ -449,8 +449,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the loaded instance of DPlayers * @return the loaded instance of DPlayers
*/ */
public DPlayers getDPlayers() { public static DPlayers getDPlayers() {
return dPlayers; return instance.dPlayers;
} }
/** /**
@ -463,8 +463,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the loaded instance of Announcers * @return the loaded instance of Announcers
*/ */
public Announcers getAnnouncers() { public static Announcers getAnnouncers() {
return announcers; return instance.announcers;
} }
/** /**
@ -477,8 +477,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the loaded instance of DClasses * @return the loaded instance of DClasses
*/ */
public DClasses getDClasses() { public static DClasses getDClasses() {
return dClasses; return instance.dClasses;
} }
/** /**
@ -491,8 +491,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the loaded instance of DLootTables * @return the loaded instance of DLootTables
*/ */
public DLootTables getDLootTables() { public static DLootTables getDLootTables() {
return dLootTables; return instance.dLootTables;
} }
/** /**
@ -505,8 +505,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the loaded instance of DMobTypes * @return the loaded instance of DMobTypes
*/ */
public DMobTypes getDMobTypes() { public static DMobTypes getDMobTypes() {
return dMobTypes; return instance.dMobTypes;
} }
/** /**
@ -519,8 +519,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the loaded instance of SignScripts * @return the loaded instance of SignScripts
*/ */
public SignScripts getSignScripts() { public static SignScripts getSignScripts() {
return signScripts; return instance.signScripts;
} }
/** /**
@ -533,8 +533,8 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the loaded instance of DWorlds * @return the loaded instance of DWorlds
*/ */
public DWorlds getDWorlds() { public static DWorlds getDWorlds() {
return dWorlds; return instance.dWorlds;
} }
/** /**
@ -547,22 +547,22 @@ public class DungeonsXL extends BRPlugin {
/** /**
* @return the dLootInventories * @return the dLootInventories
*/ */
public List<DLootInventory> getDLootInventories() { public static List<DLootInventory> getDLootInventories() {
return dLootInventories; return instance.dLootInventories;
} }
/** /**
* @return the games * @return the games
*/ */
public List<Game> getGames() { public static List<Game> getGames() {
return games; return instance.games;
} }
/** /**
* @return the dGroups * @return the dGroups
*/ */
public List<DGroup> getDGroups() { public static List<DGroup> getDGroups() {
return dGroups; return instance.dGroups;
} }
} }

View File

@ -33,6 +33,7 @@ import java.util.List;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -95,7 +96,7 @@ public class Announcer {
if (multiFloor) { if (multiFloor) {
dungeonName = identifier; dungeonName = identifier;
Dungeon dungeon = plugin.getDungeons().getByName(identifier); Dungeon dungeon = DungeonsXL.getDungeons().getByName(identifier);
if (dungeon != null) { if (dungeon != null) {
mapName = dungeon.getConfig().getStartFloor().getName(); mapName = dungeon.getConfig().getStartFloor().getName();
} }
@ -136,7 +137,7 @@ public class Announcer {
if (multiFloor) { if (multiFloor) {
dungeonName = identifier; dungeonName = identifier;
Dungeon dungeon = plugin.getDungeons().getByName(identifier); Dungeon dungeon = DungeonsXL.getDungeons().getByName(identifier);
if (dungeon != null) { if (dungeon != null) {
mapName = dungeon.getConfig().getStartFloor().getName(); mapName = dungeon.getConfig().getStartFloor().getName();
} }
@ -384,7 +385,7 @@ public class Announcer {
} else if (dGroup == null && pGroup == null) { } else if (dGroup == null && pGroup == null) {
DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.ANNOUNCER); DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.ANNOUNCER);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
dGroups.set(buttons.indexOf(button), new DGroup(player)); dGroups.set(buttons.indexOf(button), new DGroup(player));
} }
@ -422,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 (!plugin.getDGroups().contains(dGroup)) { if (!DungeonsXL.getDGroups().contains(dGroup)) {
dGroups.set(groupCount, null); dGroups.set(groupCount, null);
} else if (dGroup != null) { } else if (dGroup != null) {
@ -435,7 +436,7 @@ public class Announcer {
boolean full = playerCount >= maxPlayersPerGroup; boolean full = playerCount >= maxPlayersPerGroup;
ItemStack button = new ItemStack(Material.WOOL, playerCount, plugin.getMainConfig().getGroupColorPriority().get(groupCount).getWoolData()); ItemStack button = new ItemStack(Material.WOOL, playerCount, DungeonsXL.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

@ -29,19 +29,17 @@ import org.bukkit.inventory.ItemStack;
*/ */
public class AnnouncerListener implements Listener { public class AnnouncerListener implements Listener {
DungeonsXL plugin = DungeonsXL.getInstance();
@EventHandler @EventHandler
public void onButtonClick(ButtonClickEvent event) { public void onButtonClick(ButtonClickEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
Inventory gui = event.getGUI(); Inventory gui = event.getGUI();
if (!plugin.getGUIs().contains(gui)) { if (!DungeonsXL.getInstance().getGUIs().contains(gui)) {
return; return;
} }
ItemStack button = gui.getItem(event.getSlot()); ItemStack button = gui.getItem(event.getSlot());
Announcer announcer = plugin.getAnnouncers().getByGUI(gui); Announcer announcer = DungeonsXL.getAnnouncers().getByGUI(gui);
if (announcer != null) { if (announcer != null) {
announcer.clickGroupButton(player, button); announcer.clickGroupButton(player, button);

View File

@ -30,8 +30,6 @@ import org.bukkit.scheduler.BukkitRunnable;
*/ */
public class AnnouncerStartGameTask extends BukkitRunnable { public class AnnouncerStartGameTask extends BukkitRunnable {
DungeonsXL plugin = DungeonsXL.getInstance();
private Announcer announcer; private Announcer announcer;
private ProgressBar bar; private ProgressBar bar;
@ -48,7 +46,7 @@ public class AnnouncerStartGameTask extends BukkitRunnable {
} }
} }
bar = new ProgressBar(players, 30); bar = new ProgressBar(players, 30);
bar.runTaskTimer(plugin, 0L, 20L); bar.runTaskTimer(DungeonsXL.getInstance(), 0L, 20L);
} }
/** /**
@ -73,7 +71,7 @@ public class AnnouncerStartGameTask extends BukkitRunnable {
} }
if (game == null) { if (game == null) {
game = new Game(dGroup, plugin.getDWorlds().getResourceByName(announcer.getMapName())); game = new Game(dGroup, DungeonsXL.getDWorlds().getResourceByName(announcer.getMapName()));
} else { } else {
game.getDGroups().add(dGroup); game.getDGroups().add(dGroup);
} }

View File

@ -29,8 +29,6 @@ import org.bukkit.scheduler.BukkitRunnable;
*/ */
public class AnnouncerTask extends BukkitRunnable { public class AnnouncerTask extends BukkitRunnable {
DungeonsXL plugin = DungeonsXL.getInstance();
private List<Announcer> announcers; private List<Announcer> announcers;
private int index; private int index;
@ -44,7 +42,7 @@ public class AnnouncerTask extends BukkitRunnable {
Announcer announcer = announcers.get(index); Announcer announcer = announcers.get(index);
List<String> worlds = announcer.getWorlds(); List<String> worlds = announcer.getWorlds();
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player); DGlobalPlayer dPlayer = DungeonsXL.getDPlayers().getByPlayer(player);
if (!(dPlayer instanceof DInstancePlayer) && dPlayer.isAnnouncerEnabled()) { if (!(dPlayer instanceof DInstancePlayer) && dPlayer.isAnnouncerEnabled()) {
if (worlds.isEmpty() || worlds.contains(player.getWorld().getName())) { if (worlds.isEmpty() || worlds.contains(player.getWorld().getName())) {
announcer.send(player); announcer.send(player);

View File

@ -45,8 +45,7 @@ public class Announcers {
announcers.add(new Announcer(script)); announcers.add(new Announcer(script));
} }
} }
startAnnouncerTask(plugin.getMainConfig().getAnnouncmentInterval()); startAnnouncerTask(DungeonsXL.getMainConfig().getAnnouncmentInterval());
Bukkit.getPluginManager().registerEvents(new AnnouncerListener(), plugin);
} }
/** /**

View File

@ -30,8 +30,6 @@ import org.bukkit.entity.Player;
*/ */
public class BreakCommand extends BRCommand { public class BreakCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public BreakCommand() { public BreakCommand() {
setCommand("break"); setCommand("break");
setMinArgs(0); setMinArgs(0);
@ -44,7 +42,7 @@ public class BreakCommand extends BRCommand {
@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 = plugin.getDPlayers().getByPlayer(player); DGlobalPlayer dGlobalPlayer = DungeonsXL.getDPlayers().getByPlayer(player);
if (dGlobalPlayer.isInBreakMode()) { if (dGlobalPlayer.isInBreakMode()) {
dGlobalPlayer.setInBreakMode(false); dGlobalPlayer.setInBreakMode(false);

View File

@ -30,8 +30,6 @@ import org.bukkit.entity.Player;
*/ */
public class ChatCommand extends BRCommand { public class ChatCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public ChatCommand() { public ChatCommand() {
setCommand("chat"); setCommand("chat");
setMinArgs(0); setMinArgs(0);

View File

@ -30,8 +30,6 @@ import org.bukkit.entity.Player;
*/ */
public class ChatSpyCommand extends BRCommand { public class ChatSpyCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public ChatSpyCommand() { public ChatSpyCommand() {
setCommand("chatspy"); setCommand("chatspy");
setMinArgs(0); setMinArgs(0);
@ -44,7 +42,7 @@ public class ChatSpyCommand extends BRCommand {
@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 = plugin.getDPlayers().getByPlayer(player); DGlobalPlayer dGlobalPlayer = DungeonsXL.getDPlayers().getByPlayer(player);
if (dGlobalPlayer.isInChatSpyMode()) { if (dGlobalPlayer.isInChatSpyMode()) {
dGlobalPlayer.setInChatSpyMode(false); dGlobalPlayer.setInChatSpyMode(false);

View File

@ -67,8 +67,8 @@ public class CreateCommand extends BRCommand {
MessageUtil.log(plugin, DMessages.LOG_GENERATE_NEW_WORLD.getMessage()); MessageUtil.log(plugin, DMessages.LOG_GENERATE_NEW_WORLD.getMessage());
// Create World // Create World
DResourceWorld resource = new DResourceWorld(plugin.getDWorlds(), name); DResourceWorld resource = new DResourceWorld(DungeonsXL.getDWorlds(), name);
plugin.getDWorlds().addResource(resource); DungeonsXL.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 BRCommand {
MessageUtil.log(plugin, DMessages.LOG_GENERATE_NEW_WORLD.getMessage()); MessageUtil.log(plugin, DMessages.LOG_GENERATE_NEW_WORLD.getMessage());
// Create World // Create World
DResourceWorld resource = new DResourceWorld(plugin.getDWorlds(), name); DResourceWorld resource = new DResourceWorld(DungeonsXL.getDWorlds(), name);
plugin.getDWorlds().addResource(resource); DungeonsXL.getDWorlds().addResource(resource);
DEditWorld editWorld = resource.generate(); DEditWorld editWorld = resource.generate();
// MSG Done // MSG Done

View File

@ -38,8 +38,6 @@ import org.bukkit.entity.Player;
*/ */
public class DeleteCommand extends BRCommand { public class DeleteCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public DeleteCommand() { public DeleteCommand() {
setCommand("delete"); setCommand("delete");
setMinArgs(1); setMinArgs(1);
@ -52,7 +50,7 @@ public class DeleteCommand extends BRCommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
DWorlds dWorlds = plugin.getDWorlds(); DWorlds dWorlds = DungeonsXL.getDWorlds();
DResourceWorld resource = dWorlds.getResourceByName(args[1]); DResourceWorld resource = dWorlds.getResourceByName(args[1]);
if (resource == null) { if (resource == null) {

View File

@ -33,8 +33,6 @@ import org.bukkit.entity.Player;
@Deprecated @Deprecated
public class DeletePortalCommand extends BRCommand { public class DeletePortalCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public DeletePortalCommand() { public DeletePortalCommand() {
setCommand("deleteportal"); setCommand("deleteportal");
setMinArgs(0); setMinArgs(0);

View File

@ -36,8 +36,7 @@ import org.bukkit.entity.Player;
*/ */
public class EditCommand extends BRCommand { public class EditCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance(); DWorlds worlds = DungeonsXL.getDWorlds();
DWorlds worlds = plugin.getDWorlds();
public EditCommand() { public EditCommand() {
setCommand("edit"); setCommand("edit");
@ -70,7 +69,7 @@ public class EditCommand extends BRCommand {
DEditWorld editWorld = resource.instantiateAsEditWorld(); DEditWorld editWorld = resource.instantiateAsEditWorld();
DGroup dGroup = DGroup.getByPlayer(player); DGroup dGroup = DGroup.getByPlayer(player);
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player); DGlobalPlayer dPlayer = DungeonsXL.getDPlayers().getByPlayer(player);
if (dPlayer instanceof DInstancePlayer) { if (dPlayer instanceof DInstancePlayer) {
MessageUtil.sendMessage(player, DMessages.ERROR_LEAVE_DUNGEON.getMessage()); MessageUtil.sendMessage(player, DMessages.ERROR_LEAVE_DUNGEON.getMessage());

View File

@ -33,8 +33,6 @@ import org.bukkit.entity.Player;
*/ */
public class EnterCommand extends BRCommand { public class EnterCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public EnterCommand() { public EnterCommand() {
setMinArgs(1); setMinArgs(1);
setMaxArgs(2); setMaxArgs(2);

View File

@ -32,8 +32,6 @@ import org.bukkit.entity.Player;
*/ */
public class GameCommand extends BRCommand { public class GameCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public GameCommand() { public GameCommand() {
setCommand("game"); setCommand("game");
setMinArgs(0); setMinArgs(0);

View File

@ -35,8 +35,6 @@ import org.bukkit.entity.Player;
*/ */
public class GroupCommand extends BRCommand { public class GroupCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public GroupCommand() { public GroupCommand() {
setCommand("group"); setCommand("group");
setMinArgs(0); setMinArgs(0);
@ -126,7 +124,7 @@ public class GroupCommand extends BRCommand {
DGroup dGroup = new DGroup(args[2], player); DGroup dGroup = new DGroup(args[2], player);
DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.COMMAND); DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.COMMAND);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
dGroup.delete(); dGroup.delete();
@ -149,7 +147,7 @@ public class GroupCommand extends BRCommand {
} }
DGroupDisbandEvent event = new DGroupDisbandEvent(dGroup, player, DGroupDisbandEvent.Cause.COMMAND); DGroupDisbandEvent event = new DGroupDisbandEvent(dGroup, player, DGroupDisbandEvent.Cause.COMMAND);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
dGroup.delete(); dGroup.delete();
@ -164,7 +162,7 @@ public class GroupCommand extends BRCommand {
return; return;
} }
Player toInvite = plugin.getServer().getPlayer(args[2]); Player toInvite = Bukkit.getPlayer(args[2]);
if (toInvite != null) { if (toInvite != null) {
dGroup.addInvitedPlayer(toInvite, false); dGroup.addInvitedPlayer(toInvite, false);
@ -182,7 +180,7 @@ public class GroupCommand extends BRCommand {
dGroup.clearOfflineInvitedPlayers(); dGroup.clearOfflineInvitedPlayers();
Player toUninvite = plugin.getServer().getPlayer(args[2]); Player toUninvite = Bukkit.getPlayer(args[2]);
if (toUninvite != null) { if (toUninvite != null) {
if (dGroup.getInvitedPlayers().contains(toUninvite)) { if (dGroup.getInvitedPlayers().contains(toUninvite)) {
@ -222,10 +220,10 @@ public class GroupCommand extends BRCommand {
MessageUtil.sendMessage(sender, DMessages.ERROR_JOIN_GROUP.getMessage()); MessageUtil.sendMessage(sender, DMessages.ERROR_JOIN_GROUP.getMessage());
} }
Player toKick = plugin.getServer().getPlayer(args[2]); Player toKick = Bukkit.getPlayer(args[2]);
if (toKick != null) { if (toKick != null) {
DPlayerKickEvent event = new DPlayerKickEvent(DGamePlayer.getByPlayer(toKick.getPlayer()), DPlayerKickEvent.Cause.COMMAND); DPlayerKickEvent event = new DPlayerKickEvent(DGamePlayer.getByPlayer(toKick.getPlayer()), DPlayerKickEvent.Cause.COMMAND);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (dGroup.getPlayers().contains(toKick)) { if (dGroup.getPlayers().contains(toKick)) {
@ -268,7 +266,7 @@ public class GroupCommand extends BRCommand {
} }
public void showHelp(String page) { public void showHelp(String page) {
MessageUtil.sendPluginTag(sender, plugin); MessageUtil.sendPluginTag(sender, DungeonsXL.getInstance());
switch (page) { switch (page) {
default: default:
MessageUtil.sendCenteredMessage(sender, "&4&l[ &61-5 &4/ &67 &4| &61 &4&l]"); MessageUtil.sendCenteredMessage(sender, "&4&l[ &61-5 &4/ &67 &4| &61 &4&l]");

View File

@ -69,7 +69,7 @@ public class ImportCommand extends BRCommand {
MessageUtil.log(plugin, DMessages.LOG_NEW_MAP.getMessage()); MessageUtil.log(plugin, DMessages.LOG_NEW_MAP.getMessage());
MessageUtil.log(plugin, DMessages.LOG_IMPORT_WORLD.getMessage()); MessageUtil.log(plugin, DMessages.LOG_IMPORT_WORLD.getMessage());
if (!plugin.getMainConfig().areTweaksEnabled()) { if (!DungeonsXL.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 BRCommand {
}.runTaskAsynchronously(plugin); }.runTaskAsynchronously(plugin);
} }
plugin.getDWorlds().addResource(new DResourceWorld(plugin.getDWorlds(), args[1])); DungeonsXL.getDWorlds().addResource(new DResourceWorld(DungeonsXL.getDWorlds(), args[1]));
MessageUtil.sendMessage(sender, DMessages.CMD_IMPORT_SUCCESS.getMessage(args[1])); MessageUtil.sendMessage(sender, DMessages.CMD_IMPORT_SUCCESS.getMessage(args[1]));
} }

View File

@ -31,8 +31,6 @@ import org.bukkit.command.CommandSender;
*/ */
public class InviteCommand extends BRCommand { public class InviteCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public InviteCommand() { public InviteCommand() {
setMinArgs(2); setMinArgs(2);
setMaxArgs(2); setMaxArgs(2);
@ -45,7 +43,7 @@ public class InviteCommand extends BRCommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[2]); DResourceWorld resource = DungeonsXL.getDWorlds().getResourceByName(args[2]);
OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]); OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]);
if (resource != null) { if (resource != null) {

View File

@ -32,8 +32,6 @@ import org.bukkit.entity.Player;
*/ */
public class JoinCommand extends BRCommand { public class JoinCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public JoinCommand() { public JoinCommand() {
setCommand("join"); setCommand("join");
setMinArgs(1); setMinArgs(1);
@ -45,13 +43,13 @@ public class JoinCommand extends BRCommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
DGlobalPlayer player = plugin.getDPlayers().getByPlayer((Player) sender); DGlobalPlayer player = DungeonsXL.getDPlayers().getByPlayer((Player) sender);
if (player instanceof DInstancePlayer) { if (player instanceof DInstancePlayer) {
MessageUtil.sendMessage(sender, DMessages.ERROR_LEAVE_GAME.getMessage()); MessageUtil.sendMessage(sender, DMessages.ERROR_LEAVE_GAME.getMessage());
return; return;
} }
Announcer announcer = plugin.getAnnouncers().getByName(args[1]); Announcer announcer = DungeonsXL.getAnnouncers().getByName(args[1]);
if (announcer != null) { if (announcer != null) {
announcer.showGUI((Player) sender); announcer.showGUI((Player) sender);
} }

View File

@ -31,8 +31,6 @@ import org.bukkit.entity.Player;
*/ */
public class KickCommand extends BRCommand { public class KickCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public KickCommand() { public KickCommand() {
setCommand("kick"); setCommand("kick");
setMinArgs(1); setMinArgs(1);

View File

@ -29,6 +29,7 @@ import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
import io.github.dre2n.dungeonsxl.player.DGroup; import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DInstancePlayer; import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
import io.github.dre2n.dungeonsxl.player.DPermissions; import io.github.dre2n.dungeonsxl.player.DPermissions;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -37,8 +38,6 @@ import org.bukkit.entity.Player;
*/ */
public class LeaveCommand extends BRCommand { public class LeaveCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public LeaveCommand() { public LeaveCommand() {
setCommand("leave"); setCommand("leave");
setMinArgs(0); setMinArgs(0);
@ -51,7 +50,7 @@ public class LeaveCommand extends BRCommand {
@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 = plugin.getDPlayers().getByPlayer(player); DGlobalPlayer dPlayer = DungeonsXL.getDPlayers().getByPlayer(player);
Game game = Game.getByPlayer(player); Game game = Game.getByPlayer(player);
if (game != null && game.isTutorial()) { if (game != null && game.isTutorial()) {
@ -68,14 +67,14 @@ public class LeaveCommand extends BRCommand {
if (dPlayer instanceof DGamePlayer) { if (dPlayer instanceof DGamePlayer) {
DGamePlayerEscapeEvent dPlayerEscapeEvent = new DGamePlayerEscapeEvent((DGamePlayer) dPlayer); DGamePlayerEscapeEvent dPlayerEscapeEvent = new DGamePlayerEscapeEvent((DGamePlayer) dPlayer);
plugin.getServer().getPluginManager().callEvent(dPlayerEscapeEvent); Bukkit.getPluginManager().callEvent(dPlayerEscapeEvent);
if (dPlayerEscapeEvent.isCancelled()) { if (dPlayerEscapeEvent.isCancelled()) {
return; return;
} }
} }
DPlayerLeaveDGroupEvent dPlayerLeaveDGroupEvent = new DPlayerLeaveDGroupEvent(dPlayer, dGroup); DPlayerLeaveDGroupEvent dPlayerLeaveDGroupEvent = new DPlayerLeaveDGroupEvent(dPlayer, dGroup);
plugin.getServer().getPluginManager().callEvent(dPlayerLeaveDGroupEvent); Bukkit.getPluginManager().callEvent(dPlayerLeaveDGroupEvent);
if (dPlayerLeaveDGroupEvent.isCancelled()) { if (dPlayerLeaveDGroupEvent.isCancelled()) {
return; return;
} }

View File

@ -39,7 +39,7 @@ import org.bukkit.entity.Player;
public class ListCommand extends BRCommand { public class ListCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance(); DungeonsXL plugin = DungeonsXL.getInstance();
DWorlds worlds = plugin.getDWorlds(); DWorlds worlds = DungeonsXL.getDWorlds();
public ListCommand() { public ListCommand() {
setCommand("list"); setCommand("list");
@ -54,7 +54,7 @@ public class ListCommand extends BRCommand {
@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 : plugin.getDungeons().getDungeons()) { for (Dungeon dungeon : DungeonsXL.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 BRCommand {
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 = plugin.getDungeons().getByName(args[2]); Dungeon dungeon = DungeonsXL.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

@ -32,8 +32,6 @@ import org.bukkit.entity.Player;
*/ */
public class LivesCommand extends BRCommand { public class LivesCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public LivesCommand() { public LivesCommand() {
setCommand("lives"); setCommand("lives");
setMinArgs(0); setMinArgs(0);

View File

@ -33,8 +33,6 @@ import org.bukkit.plugin.PluginManager;
*/ */
public class MainCommand extends BRCommand { public class MainCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public MainCommand() { public MainCommand() {
setCommand("main"); setCommand("main");
setHelp(DMessages.HELP_CMD_MAIN.getMessage()); setHelp(DMessages.HELP_CMD_MAIN.getMessage());
@ -49,8 +47,8 @@ public class MainCommand extends BRCommand {
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 = plugin.getDWorlds().getEditWorlds().size() + plugin.getDWorlds().getGameWorlds().size(); int loaded = DungeonsXL.getDWorlds().getEditWorlds().size() + DungeonsXL.getDWorlds().getGameWorlds().size();
int players = plugin.getDPlayers().getDGamePlayers().size(); int players = DungeonsXL.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) {
@ -66,7 +64,7 @@ public class MainCommand extends BRCommand {
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###### " + DMessages.CMD_MAIN_WELCOME.getMessage() + "&7 v" + plugin.getDescription().getVersion() + " &b&l######"); MessageUtil.sendCenteredMessage(sender, "&b&l###### " + DMessages.CMD_MAIN_WELCOME.getMessage() + "&7 v" + DungeonsXL.getInstance().getDescription().getVersion() + " &b&l######");
MessageUtil.sendCenteredMessage(sender, DMessages.CMD_MAIN_LOADED.getMessage(String.valueOf(maps), String.valueOf(dungeons), String.valueOf(loaded), String.valueOf(players))); MessageUtil.sendCenteredMessage(sender, DMessages.CMD_MAIN_LOADED.getMessage(String.valueOf(maps), String.valueOf(dungeons), String.valueOf(loaded), String.valueOf(players)));
MessageUtil.sendCenteredMessage(sender, DMessages.CMD_MAIN_COMPATIBILITY.getMessage(String.valueOf(internals), vault, itemsxl)); MessageUtil.sendCenteredMessage(sender, DMessages.CMD_MAIN_COMPATIBILITY.getMessage(String.valueOf(internals), vault, itemsxl));
MessageUtil.sendCenteredMessage(sender, DMessages.CMD_MAIN_HELP.getMessage()); MessageUtil.sendCenteredMessage(sender, DMessages.CMD_MAIN_HELP.getMessage());

View File

@ -32,8 +32,6 @@ import org.bukkit.entity.Player;
*/ */
public class MsgCommand extends BRCommand { public class MsgCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public MsgCommand() { public MsgCommand() {
setMinArgs(-1); setMinArgs(-1);
setMaxArgs(-1); setMaxArgs(-1);

View File

@ -29,6 +29,7 @@ import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DInstancePlayer; import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
import io.github.dre2n.dungeonsxl.player.DPermissions; import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.world.DResourceWorld; import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -37,8 +38,6 @@ import org.bukkit.entity.Player;
*/ */
public class PlayCommand extends BRCommand { public class PlayCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public PlayCommand() { public PlayCommand() {
setCommand("play"); setCommand("play");
setMinArgs(1); setMinArgs(1);
@ -52,15 +51,15 @@ public class PlayCommand extends BRCommand {
@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 = plugin.getDPlayers().getByPlayer(player); DGlobalPlayer dPlayer = DungeonsXL.getDPlayers().getByPlayer(player);
if (dPlayer instanceof DInstancePlayer) { if (dPlayer instanceof DInstancePlayer) {
MessageUtil.sendMessage(player, DMessages.ERROR_LEAVE_DUNGEON.getMessage()); MessageUtil.sendMessage(player, DMessages.ERROR_LEAVE_DUNGEON.getMessage());
return; return;
} }
Dungeon dungeon = plugin.getDungeons().getByName(args[1]); Dungeon dungeon = DungeonsXL.getDungeons().getByName(args[1]);
if (dungeon == null) { if (dungeon == null) {
DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[1]); DResourceWorld resource = DungeonsXL.getDWorlds().getResourceByName(args[1]);
if (resource != null) { if (resource != null) {
dungeon = new Dungeon(resource); dungeon = new Dungeon(resource);
} else { } else {
@ -73,9 +72,9 @@ public class PlayCommand extends BRCommand {
if (dGroup == null || dGroup.isPlaying()) { if (dGroup == null || dGroup.isPlaying()) {
dGroup = new DGroup(player, dungeon); dGroup = new DGroup(player, dungeon);
DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.COMMAND); DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.COMMAND);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
plugin.getDGroups().remove(dGroup); DungeonsXL.getDGroups().remove(dGroup);
dGroup = null; dGroup = null;
} }
} }

View File

@ -34,8 +34,6 @@ import org.bukkit.inventory.ItemStack;
*/ */
public class PortalCommand extends BRCommand { public class PortalCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public PortalCommand() { public PortalCommand() {
setCommand("portal"); setCommand("portal");
setMinArgs(0); setMinArgs(0);
@ -48,7 +46,7 @@ public class PortalCommand extends BRCommand {
@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 = plugin.getDPlayers().getByPlayer(player); DGlobalPlayer dGlobalPlayer = DungeonsXL.getDPlayers().getByPlayer(player);
if (dGlobalPlayer instanceof DGamePlayer) { if (dGlobalPlayer instanceof DGamePlayer) {
MessageUtil.sendMessage(player, DMessages.ERROR_LEAVE_DUNGEON.getMessage()); MessageUtil.sendMessage(player, DMessages.ERROR_LEAVE_DUNGEON.getMessage());
@ -68,7 +66,7 @@ public class PortalCommand extends BRCommand {
DPortal dPortal = dGlobalPlayer.getPortal(); DPortal dPortal = dGlobalPlayer.getPortal();
if (dPortal == null) { if (dPortal == null) {
dPortal = new DPortal(plugin.getGlobalProtections().generateId(DPortal.class, player.getWorld()), player.getWorld(), material, false); dPortal = new DPortal(DungeonsXL.getGlobalProtections().generateId(DPortal.class, player.getWorld()), player.getWorld(), material, false);
dGlobalPlayer.setCreatingPortal(dPortal); dGlobalPlayer.setCreatingPortal(dPortal);
dPortal.setWorld(player.getWorld()); dPortal.setWorld(player.getWorld());
player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD)); player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD));

View File

@ -53,7 +53,7 @@ public class ReloadCommand extends BRCommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
List<DInstancePlayer> dPlayers = plugin.getDPlayers().getDInstancePlayers(); List<DInstancePlayer> dPlayers = DungeonsXL.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, DMessages.CMD_RELOAD_PLAYERS.getMessage()); MessageUtil.sendMessage(sender, DMessages.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 BRCommand {
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 = plugin.getDWorlds().getEditWorlds().size() + plugin.getDWorlds().getGameWorlds().size(); int loaded = DungeonsXL.getDWorlds().getEditWorlds().size() + DungeonsXL.getDWorlds().getGameWorlds().size();
int players = plugin.getDPlayers().getDGamePlayers().size(); int players = DungeonsXL.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) {
@ -90,11 +90,9 @@ public class ReloadCommand extends BRCommand {
mythicMobs = plugins.getPlugin("MythicMobs").getDescription().getVersion(); mythicMobs = plugins.getPlugin("MythicMobs").getDescription().getVersion();
} }
// Save plugin.onDisable();
plugin.saveData();
plugin.getMessageConfig().save();
plugin.loadCore(); plugin.loadCore();
plugin.loadData();
MessageUtil.sendPluginTag(sender, plugin); MessageUtil.sendPluginTag(sender, plugin);
MessageUtil.sendCenteredMessage(sender, DMessages.CMD_RELOAD_DONE.getMessage()); MessageUtil.sendCenteredMessage(sender, DMessages.CMD_RELOAD_DONE.getMessage());

View File

@ -38,8 +38,6 @@ import org.bukkit.configuration.file.FileConfiguration;
*/ */
public class RenameCommand extends BRCommand { public class RenameCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public RenameCommand() { public RenameCommand() {
setCommand("rename"); setCommand("rename");
setMinArgs(2); setMinArgs(2);
@ -52,7 +50,7 @@ public class RenameCommand extends BRCommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[1]); DResourceWorld resource = DungeonsXL.getDWorlds().getResourceByName(args[1]);
if (resource == null) { if (resource == null) {
MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_MAP.getMessage(args[1])); MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_MAP.getMessage(args[1]));
return; return;
@ -62,7 +60,7 @@ public class RenameCommand extends BRCommand {
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 : plugin.getDungeons().getDungeons()) { for (Dungeon dungeon : DungeonsXL.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();
@ -92,7 +90,7 @@ public class RenameCommand extends BRCommand {
} }
boolean changed = false; boolean changed = false;
for (GlobalProtection protection : plugin.getGlobalProtections().getProtections()) { for (GlobalProtection protection : DungeonsXL.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])) {
@ -110,7 +108,7 @@ public class RenameCommand extends BRCommand {
} }
if (changed) { if (changed) {
plugin.getGlobalProtections().saveAll(); DungeonsXL.getGlobalProtections().saveAll();
} }
MessageUtil.sendMessage(sender, DMessages.CMD_RENAME_SUCCESS.getMessage(args[1], args[2])); MessageUtil.sendMessage(sender, DMessages.CMD_RENAME_SUCCESS.getMessage(args[1], args[2]));

View File

@ -30,8 +30,6 @@ import org.inventivetalent.rpapi.ResourcePackAPI;
*/ */
public class ResourcePackCommand extends BRCommand { public class ResourcePackCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public ResourcePackCommand() { public ResourcePackCommand() {
setCommand("resourcepack"); setCommand("resourcepack");
setMinArgs(1); setMinArgs(1);
@ -51,7 +49,7 @@ public class ResourcePackCommand extends BRCommand {
return; return;
} }
String url = (String) plugin.getMainConfig().getResourcePacks().get(args[1]); String url = (String) DungeonsXL.getMainConfig().getResourcePacks().get(args[1]);
if (url == null) { if (url == null) {
MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_RESOURCE_PACK.getMessage(args[1])); MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_RESOURCE_PACK.getMessage(args[1]));
return; return;

View File

@ -33,8 +33,6 @@ import org.bukkit.inventory.ItemStack;
*/ */
public class RewardsCommand extends BRCommand { public class RewardsCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public RewardsCommand() { public RewardsCommand() {
setCommand("rewards"); setCommand("rewards");
setMinArgs(0); setMinArgs(0);
@ -47,7 +45,7 @@ public class RewardsCommand extends BRCommand {
@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 = plugin.getDPlayers().getByPlayer(player); DGlobalPlayer dGlobalPlayer = DungeonsXL.getDPlayers().getByPlayer(player);
if (!dGlobalPlayer.hasRewardItemsLeft()) { if (!dGlobalPlayer.hasRewardItemsLeft()) {
MessageUtil.sendMessage(player, DMessages.ERROR_NO_REWARDS_LEFT.getMessage()); MessageUtil.sendMessage(player, DMessages.ERROR_NO_REWARDS_LEFT.getMessage());

View File

@ -32,8 +32,7 @@ import org.bukkit.entity.Player;
*/ */
public class SaveCommand extends BRCommand { public class SaveCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance(); MainConfig mainConfig = DungeonsXL.getMainConfig();
MainConfig mainConfig = plugin.getMainConfig();
public SaveCommand() { public SaveCommand() {
setCommand("save"); setCommand("save");

View File

@ -117,7 +117,7 @@ public class StatusCommand extends BRCommand {
String vaultVersionCorrect = getSymbol(vaultVersion.startsWith("1.5")); String vaultVersionCorrect = getSymbol(vaultVersion.startsWith("1.5"));
String permissionPluginCorrect = getSymbol(plugin.getPermissionProvider() != null && plugin.getPermissionProvider().hasGroupSupport()); String permissionPluginCorrect = getSymbol(plugin.getPermissionProvider() != null && plugin.getPermissionProvider().hasGroupSupport());
String economyPluginCorrect = getSymbol(!plugin.getMainConfig().isEconomyEnabled() || plugin.getEconomyProvider() != null); String economyPluginCorrect = getSymbol(!DungeonsXL.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

@ -38,8 +38,6 @@ import org.bukkit.entity.Player;
*/ */
public class TestCommand extends BRCommand { public class TestCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public TestCommand() { public TestCommand() {
setCommand("test"); setCommand("test");
setMinArgs(0); setMinArgs(0);
@ -53,7 +51,7 @@ public class TestCommand extends BRCommand {
@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 = plugin.getDPlayers().getByPlayer(player); DGlobalPlayer dPlayer = DungeonsXL.getDPlayers().getByPlayer(player);
if (!(dPlayer instanceof DEditPlayer)) { if (!(dPlayer instanceof DEditPlayer)) {
DGroup dGroup = DGroup.getByPlayer(player); DGroup dGroup = DGroup.getByPlayer(player);

View File

@ -31,8 +31,6 @@ import org.bukkit.command.CommandSender;
*/ */
public class UninviteCommand extends BRCommand { public class UninviteCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public UninviteCommand() { public UninviteCommand() {
setCommand("uninvite"); setCommand("uninvite");
setMinArgs(2); setMinArgs(2);
@ -45,7 +43,7 @@ public class UninviteCommand extends BRCommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[2]); DResourceWorld resource = DungeonsXL.getDWorlds().getResourceByName(args[2]);
if (resource == null) { if (resource == null) {
MessageUtil.sendMessage(sender, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(args[2])); MessageUtil.sendMessage(sender, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(args[2]));
return; return;

View File

@ -242,7 +242,7 @@ public enum DMessages implements Messages {
@Override @Override
public String getMessage(String... args) { public String getMessage(String... args) {
return DungeonsXL.getInstance().getMessageConfig().getMessage(this, args); return DungeonsXL.getMessageConfig().getMessage(this, args);
} }
@Override @Override

View File

@ -114,7 +114,7 @@ public class Dungeon {
* @return false if there are setup errors * @return false if there are setup errors
*/ */
public boolean isSetupCorrect() { public boolean isSetupCorrect() {
for (DResourceWorld resource : DungeonsXL.getInstance().getDWorlds().getResources()) { for (DResourceWorld resource : DungeonsXL.getDWorlds().getResources()) {
if (resource.getName().equals(name)) { if (resource.getName().equals(name)) {
return false; return false;
} }

View File

@ -32,7 +32,7 @@ import java.util.List;
*/ */
public class DungeonConfig extends BRConfig { public class DungeonConfig extends BRConfig {
DWorlds worlds = DungeonsXL.getInstance().getDWorlds(); DWorlds worlds = DungeonsXL.getDWorlds();
public static final int CONFIG_VERSION = 1; public static final int CONFIG_VERSION = 1;

View File

@ -48,8 +48,6 @@ 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;
@ -61,7 +59,7 @@ public class Game {
private Map<String, Integer> waveKills = new HashMap<>(); private Map<String, Integer> waveKills = new HashMap<>();
public Game(DGroup dGroup) { public Game(DGroup dGroup) {
plugin.getGames().add(this); DungeonsXL.getGames().add(this);
tutorial = false; tutorial = false;
started = false; started = false;
@ -75,7 +73,7 @@ public class Game {
} }
public Game(DGroup dGroup, DGameWorld world) { public Game(DGroup dGroup, DGameWorld world) {
plugin.getGames().add(this); DungeonsXL.getGames().add(this);
tutorial = false; tutorial = false;
started = false; started = false;
@ -90,7 +88,7 @@ public class Game {
} }
public Game(DGroup dGroup, DResourceWorld resource) { public Game(DGroup dGroup, DResourceWorld resource) {
plugin.getGames().add(this); DungeonsXL.getGames().add(this);
tutorial = false; tutorial = false;
started = false; started = false;
@ -110,7 +108,7 @@ public class Game {
} }
public Game(List<DGroup> dGroups, GameType type, DGameWorld world) { public Game(List<DGroup> dGroups, GameType type, DGameWorld world) {
plugin.getGames().add(this); DungeonsXL.getGames().add(this);
this.dGroups = dGroups; this.dGroups = dGroups;
this.type = type; this.type = type;
@ -271,7 +269,7 @@ public class Game {
finalRules.apply(dungeonConfig.getDefaultValues()); finalRules.apply(dungeonConfig.getDefaultValues());
} }
finalRules.apply(plugin.getMainConfig().getDefaultWorldConfig()); finalRules.apply(DungeonsXL.getMainConfig().getDefaultWorldConfig());
finalRules.apply(GameRules.DEFAULT_VALUES); finalRules.apply(GameRules.DEFAULT_VALUES);
@ -398,7 +396,7 @@ public class Game {
public void delete() { public void delete() {
GameSign gameSign = GameSign.getByGame(this); GameSign gameSign = GameSign.getByGame(this);
plugin.getGames().remove(this); DungeonsXL.getGames().remove(this);
if (gameSign != null) { if (gameSign != null) {
gameSign.update(); gameSign.update();
@ -447,7 +445,7 @@ public class Game {
mobSign.initializeTask(); mobSign.initializeTask();
} }
} }
}.runTaskLater(plugin, delay * 20); }.runTaskLater(DungeonsXL.getInstance(), delay * 20);
} }
/** /**
@ -461,7 +459,7 @@ public class Game {
/* Statics */ /* Statics */
public static Game getByDGroup(DGroup dGroup) { public static Game getByDGroup(DGroup dGroup) {
for (Game game : DungeonsXL.getInstance().getGames()) { for (Game game : DungeonsXL.getGames()) {
if (game.getDGroups().contains(dGroup)) { if (game.getDGroups().contains(dGroup)) {
return game; return game;
} }
@ -475,7 +473,7 @@ public class Game {
} }
public static Game getByGameWorld(DGameWorld gameWorld) { public static Game getByGameWorld(DGameWorld gameWorld) {
for (Game game : DungeonsXL.getInstance().getGames()) { for (Game game : DungeonsXL.getGames()) {
if (gameWorld.equals(game.getWorld())) { if (gameWorld.equals(game.getWorld())) {
return game; return game;
} }

View File

@ -18,6 +18,7 @@ package io.github.dre2n.dungeonsxl.global;
import io.github.dre2n.commons.util.BlockUtil; import io.github.dre2n.commons.util.BlockUtil;
import io.github.dre2n.commons.util.messageutil.MessageUtil; import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages; import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.game.Game; import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.player.DGamePlayer; import io.github.dre2n.dungeonsxl.player.DGamePlayer;
@ -181,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, plugin.getMessageConfig().getMessage(DMessages.ERROR_JOIN_GROUP)); MessageUtil.sendMessage(player, DungeonsXL.getMessageConfig().getMessage(DMessages.ERROR_JOIN_GROUP));
return; return;
} }
@ -325,7 +326,7 @@ public class DPortal extends GlobalProtection {
* a block covered by the returned portal * a block covered by the returned portal
*/ */
public static DPortal getByBlock(Block block) { public static DPortal getByBlock(Block block) {
for (GlobalProtection protection : protections.getProtections(DPortal.class)) { for (GlobalProtection protection : DungeonsXL.getGlobalProtections().getProtections(DPortal.class)) {
DPortal portal = (DPortal) protection; DPortal portal = (DPortal) protection;
if (portal.getBlock1() == null || portal.getBlock2() == null) { if (portal.getBlock1() == null || portal.getBlock2() == null) {
continue; continue;

View File

@ -18,6 +18,7 @@ package io.github.dre2n.dungeonsxl.global;
import io.github.dre2n.commons.util.BlockUtil; import io.github.dre2n.commons.util.BlockUtil;
import io.github.dre2n.commons.util.messageutil.MessageUtil; import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages; import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon; import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.game.Game; import io.github.dre2n.dungeonsxl.game.Game;
@ -61,9 +62,9 @@ public class GameSign extends GlobalProtection {
this.startSign = startSign; this.startSign = startSign;
games = new Game[maxGames]; games = new Game[maxGames];
dungeon = plugin.getDungeons().getByName(identifier); dungeon = DungeonsXL.getDungeons().getByName(identifier);
if (dungeon == null) { if (dungeon == null) {
DResourceWorld resource = plugin.getDWorlds().getResourceByName(identifier); DResourceWorld resource = DungeonsXL.getDWorlds().getResourceByName(identifier);
if (resource != null) { if (resource != null) {
dungeon = new Dungeon(resource); dungeon = new Dungeon(resource);
} }
@ -246,7 +247,7 @@ public class GameSign extends GlobalProtection {
} }
int x = block.getX(), y = block.getY(), z = block.getZ(); int x = block.getX(), y = block.getY(), z = block.getZ();
for (GlobalProtection protection : protections.getProtections(GameSign.class)) { for (GlobalProtection protection : DungeonsXL.getGlobalProtections().getProtections(GameSign.class)) {
GameSign gameSign = (GameSign) protection; GameSign gameSign = (GameSign) protection;
int sx1 = gameSign.startSign.getX(), sy1 = gameSign.startSign.getY(), sz1 = gameSign.startSign.getZ(); int sx1 = gameSign.startSign.getX(), sy1 = gameSign.startSign.getY(), sz1 = gameSign.startSign.getZ();
@ -302,7 +303,7 @@ public class GameSign extends GlobalProtection {
* the game to check * the game to check
*/ */
public static GameSign getByGame(Game game) { public static GameSign getByGame(Game game) {
for (GlobalProtection protection : plugin.getGlobalProtections().getProtections(GameSign.class)) { for (GlobalProtection protection : DungeonsXL.getGlobalProtections().getProtections(GameSign.class)) {
GameSign gameSign = (GameSign) protection; GameSign gameSign = (GameSign) protection;
for (Game signGame : gameSign.games) { for (Game signGame : gameSign.games) {
@ -413,7 +414,7 @@ public class GameSign extends GlobalProtection {
block.setTypeIdAndData(68, startSign.getData(), true); block.setTypeIdAndData(68, startSign.getData(), true);
} }
GameSign sign = new GameSign(protections.generateId(GameSign.class, world), startSign, mapName, maxGames, maxGroupsPerGame); GameSign sign = new GameSign(DungeonsXL.getGlobalProtections().generateId(GameSign.class, world), startSign, mapName, maxGames, maxGroupsPerGame);
return sign; return sign;
} }
@ -427,7 +428,7 @@ public class GameSign extends GlobalProtection {
return false; return false;
} }
if (plugin.getDWorlds().getGameWorlds().size() >= plugin.getMainConfig().getMaxInstances()) { if (DungeonsXL.getDWorlds().getGameWorlds().size() >= DungeonsXL.getMainConfig().getMaxInstances()) {
MessageUtil.sendMessage(player, DMessages.ERROR_TOO_MANY_INSTANCES.getMessage()); MessageUtil.sendMessage(player, DMessages.ERROR_TOO_MANY_INSTANCES.getMessage());
return true; return true;
} }
@ -435,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, plugin.getMessageConfig().getMessage(DMessages.ERROR_JOIN_GROUP)); MessageUtil.sendMessage(player, DungeonsXL.getMessageConfig().getMessage(DMessages.ERROR_JOIN_GROUP));
return true; return true;
} }
if (!dGroup.getCaptain().equals(player)) { if (!dGroup.getCaptain().equals(player)) {
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.ERROR_NOT_CAPTAIN)); MessageUtil.sendMessage(player, DungeonsXL.getMessageConfig().getMessage(DMessages.ERROR_NOT_CAPTAIN));
return true; return true;
} }
if (Game.getByDGroup(dGroup) != null) { if (Game.getByDGroup(dGroup) != null) {
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.ERROR_LEAVE_GAME)); MessageUtil.sendMessage(player, DungeonsXL.getMessageConfig().getMessage(DMessages.ERROR_LEAVE_GAME));
return true; return true;
} }

View File

@ -32,9 +32,8 @@ import org.bukkit.configuration.file.YamlConfiguration;
*/ */
public abstract class GlobalProtection { public abstract class GlobalProtection {
static DungeonsXL plugin = DungeonsXL.getInstance(); FileConfiguration config = DungeonsXL.getGlobalData().getConfig();
static FileConfiguration config = plugin.getGlobalData().getConfig(); GlobalProtections protections = DungeonsXL.getGlobalProtections();
static GlobalProtections protections = plugin.getGlobalProtections();
private World world; private World world;
private int id; private int id;
@ -94,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(), plugin.getMessageConfig().getMessage(DMessages.PLAYER_PROTECTED_BLOCK_DELETED)); MessageUtil.sendMessage(dPlayer.getPlayer(), DungeonsXL.getMessageConfig().getMessage(DMessages.PLAYER_PROTECTED_BLOCK_DELETED));
MessageUtil.sendMessage(dPlayer.getPlayer(), plugin.getMessageConfig().getMessage(DMessages.CMD_BREAK_PROTECTED_MODE)); MessageUtil.sendMessage(dPlayer.getPlayer(), DungeonsXL.getMessageConfig().getMessage(DMessages.CMD_BREAK_PROTECTED_MODE));
dPlayer.setInBreakMode(false); dPlayer.setInBreakMode(false);
return false; return false;

View File

@ -43,8 +43,6 @@ import org.bukkit.event.player.PlayerPortalEvent;
*/ */
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 +71,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 = plugin.getDPlayers().getByPlayer(player); DGlobalPlayer dGlobalPlayer = DungeonsXL.getDPlayers().getByPlayer(player);
GlobalProtection protection = plugin.getGlobalProtections().getByBlock(block); GlobalProtection protection = DungeonsXL.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 +99,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 (DungeonsXL.getGlobalProtections().isProtectedBlock(block)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -141,7 +139,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 (plugin.getDPlayers().getByPlayer(player).isInBreakMode()) { if (DungeonsXL.getDPlayers().getByPlayer(player).isInBreakMode()) {
return; return;
} }
Block clickedBlock = event.getClickedBlock(); Block clickedBlock = event.getClickedBlock();
@ -210,7 +208,7 @@ public class GlobalProtectionListener implements Listener {
} else if (lines[1].equalsIgnoreCase("Leave")) { } else if (lines[1].equalsIgnoreCase("Leave")) {
if (block.getState() instanceof Sign) { if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState(); Sign sign = (Sign) block.getState();
new LeaveSign(plugin.getGlobalProtections().generateId(LeaveSign.class, sign.getWorld()), sign); new LeaveSign(DungeonsXL.getGlobalProtections().generateId(LeaveSign.class, sign.getWorld()), sign);
} }
event.setCancelled(true); event.setCancelled(true);

View File

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

View File

@ -18,6 +18,7 @@ package io.github.dre2n.dungeonsxl.global;
import io.github.dre2n.commons.util.BlockUtil; import io.github.dre2n.commons.util.BlockUtil;
import io.github.dre2n.commons.util.messageutil.MessageUtil; import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages; import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon; import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.player.DGroup; import io.github.dre2n.dungeonsxl.player.DGroup;
@ -60,9 +61,9 @@ public class GroupSign extends GlobalProtection {
this.startSign = startSign; this.startSign = startSign;
dGroups = new DGroup[maxGroups]; dGroups = new DGroup[maxGroups];
dungeon = plugin.getDungeons().getByName(identifier); dungeon = DungeonsXL.getDungeons().getByName(identifier);
if (dungeon == null) { if (dungeon == null) {
DResourceWorld resource = plugin.getDWorlds().getResourceByName(identifier); DResourceWorld resource = DungeonsXL.getDWorlds().getResourceByName(identifier);
if (resource != null) { if (resource != null) {
dungeon = new Dungeon(resource); dungeon = new Dungeon(resource);
} }
@ -245,7 +246,7 @@ public class GroupSign extends GlobalProtection {
} }
int x = block.getX(), y = block.getY(), z = block.getZ(); int x = block.getX(), y = block.getY(), z = block.getZ();
for (GlobalProtection protection : protections.getProtections(GroupSign.class)) { for (GlobalProtection protection : DungeonsXL.getGlobalProtections().getProtections(GroupSign.class)) {
GroupSign groupSign = (GroupSign) protection; GroupSign groupSign = (GroupSign) protection;
int sx1 = groupSign.startSign.getX(), sy1 = groupSign.startSign.getY(), sz1 = groupSign.startSign.getZ(); int sx1 = groupSign.startSign.getX(), sy1 = groupSign.startSign.getY(), sz1 = groupSign.startSign.getZ();
@ -394,7 +395,7 @@ public class GroupSign extends GlobalProtection {
block.setTypeIdAndData(68, startSign.getData(), true); block.setTypeIdAndData(68, startSign.getData(), true);
} }
GroupSign sign = new GroupSign(protections.generateId(GroupSign.class, world), startSign, mapName, maxGroups, maxPlayersPerGroup); GroupSign sign = new GroupSign(DungeonsXL.getGlobalProtections().generateId(GroupSign.class, world), startSign, mapName, maxGroups, maxPlayersPerGroup);
return sign; return sign;
} }
@ -409,7 +410,7 @@ public class GroupSign extends GlobalProtection {
} }
if (DGroup.getByPlayer(player) != null) { if (DGroup.getByPlayer(player) != null) {
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.ERROR_LEAVE_GROUP)); MessageUtil.sendMessage(player, DungeonsXL.getMessageConfig().getMessage(DMessages.ERROR_LEAVE_GROUP));
return true; return true;
} }
@ -445,7 +446,7 @@ public class GroupSign extends GlobalProtection {
@Deprecated @Deprecated
public static void updatePerGroup(DGroup dGroupSearch) { public static void updatePerGroup(DGroup dGroupSearch) {
for (GlobalProtection protection : protections.getProtections(GroupSign.class)) { for (GlobalProtection protection : DungeonsXL.getGlobalProtections().getProtections(GroupSign.class)) {
GroupSign groupSign = (GroupSign) protection; GroupSign groupSign = (GroupSign) protection;
int i = 0; int i = 0;

View File

@ -18,6 +18,7 @@ package io.github.dre2n.dungeonsxl.global;
import io.github.dre2n.commons.util.BlockUtil; import io.github.dre2n.commons.util.BlockUtil;
import io.github.dre2n.commons.util.messageutil.MessageUtil; import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages; import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.player.DGamePlayer; import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.player.DGroup; import io.github.dre2n.dungeonsxl.player.DGroup;
@ -73,18 +74,14 @@ public class LeaveSign extends GlobalProtection {
if (dplayer != null) { if (dplayer != null) {
dplayer.leave(); dplayer.leave();
return;
} else { } else {
DGroup group = DGroup.getByPlayer(player); DGroup group = DGroup.getByPlayer(player);
if (group != null) { if (group != null) {
group.removePlayer(player); group.removePlayer(player);
MessageUtil.sendMessage(player, DMessages.PLAYER_LEAVE_GROUP.getMessage()); MessageUtil.sendMessage(player, DMessages.PLAYER_LEAVE_GROUP.getMessage());
return;
} }
} }
return;
} }
@Override @Override
@ -101,7 +98,7 @@ public class LeaveSign extends GlobalProtection {
* a block which is protected by the returned LeaveSign * a block which is protected by the returned LeaveSign
*/ */
public static LeaveSign getByBlock(Block block) { public static LeaveSign getByBlock(Block block) {
for (GlobalProtection protection : plugin.getGlobalProtections().getProtections(LeaveSign.class)) { for (GlobalProtection protection : DungeonsXL.getGlobalProtections().getProtections(LeaveSign.class)) {
LeaveSign leaveSign = (LeaveSign) protection; LeaveSign leaveSign = (LeaveSign) protection;
if (leaveSign.getBlocks().contains(block)) { if (leaveSign.getBlocks().contains(block)) {

View File

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

View File

@ -35,7 +35,6 @@ import org.bukkit.inventory.ItemStack;
*/ */
public class DClass { public class DClass {
DungeonsXL plugin = DungeonsXL.getInstance();
CompatibilityHandler compat = CompatibilityHandler.getInstance(); CompatibilityHandler compat = CompatibilityHandler.getInstance();
private String name; private String name;

View File

@ -18,10 +18,12 @@ package io.github.dre2n.dungeonsxl.player;
import io.github.dre2n.commons.util.messageutil.MessageUtil; import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.commons.util.playerutil.PlayerUtil; import io.github.dre2n.commons.util.playerutil.PlayerUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages; import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.event.dplayer.instance.DInstancePlayerUpdateEvent; import io.github.dre2n.dungeonsxl.event.dplayer.instance.DInstancePlayerUpdateEvent;
import io.github.dre2n.dungeonsxl.world.DEditWorld; import io.github.dre2n.dungeonsxl.world.DEditWorld;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
@ -65,7 +67,7 @@ public class DEditPlayer extends DInstancePlayer {
// Permission bridge // Permission bridge
if (plugin.getPermissionProvider() != null) { if (plugin.getPermissionProvider() != null) {
for (String permission : plugin.getMainConfig().getEditPermissions()) { for (String permission : DungeonsXL.getMainConfig().getEditPermissions()) {
plugin.getPermissionProvider().playerAddTransient(world.getName(), player, permission); plugin.getPermissionProvider().playerAddTransient(world.getName(), player, permission);
} }
} }
@ -78,7 +80,7 @@ public class DEditPlayer extends DInstancePlayer {
* the player's EditWorld * the player's EditWorld
*/ */
public static void create(Player player, DEditWorld editWorld) { public static void create(Player player, DEditWorld editWorld) {
new CreateDInstancePlayerTask(player, editWorld).runTaskTimer(plugin, 0L, 5L); new CreateDInstancePlayerTask(player, editWorld).runTaskTimer(DungeonsXL.getInstance(), 0L, 5L);
} }
/* Getters and setters */ /* Getters and setters */
@ -109,7 +111,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 : plugin.getMainConfig().getEditPermissions()) { for (String permission : DungeonsXL.getMainConfig().getEditPermissions()) {
plugin.getPermissionProvider().playerRemoveTransient(getWorld().getName(), player, permission); plugin.getPermissionProvider().playerRemoveTransient(getWorld().getName(), player, permission);
} }
} }
@ -132,7 +134,7 @@ public class DEditPlayer extends DInstancePlayer {
if (lines[0].isEmpty() && lines[1].isEmpty() && lines[2].isEmpty() && lines[3].isEmpty()) { if (lines[0].isEmpty() && lines[1].isEmpty() && lines[2].isEmpty() && lines[3].isEmpty()) {
if (linesCopy != null) { if (linesCopy != null) {
SignChangeEvent event = new SignChangeEvent(block, getPlayer(), linesCopy); SignChangeEvent event = new SignChangeEvent(block, getPlayer(), linesCopy);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
sign.setLine(0, event.getLine(0)); sign.setLine(0, event.getLine(0));
sign.setLine(1, event.getLine(1)); sign.setLine(1, event.getLine(1));
@ -171,7 +173,7 @@ public class DEditPlayer extends DInstancePlayer {
DEditWorld editWorld = DEditWorld.getByWorld(getWorld()); DEditWorld editWorld = DEditWorld.getByWorld(getWorld());
editWorld.sendMessage(message); editWorld.sendMessage(message);
for (DGlobalPlayer player : plugin.getDPlayers().getDGlobalPlayers()) { for (DGlobalPlayer player : DungeonsXL.getDPlayers().getDGlobalPlayers()) {
if (player.isInChatSpyMode()) { if (player.isInChatSpyMode()) {
if (!editWorld.getWorld().getPlayers().contains(player.getPlayer())) { if (!editWorld.getWorld().getPlayers().contains(player.getPlayer())) {
MessageUtil.sendMessage(player.getPlayer(), ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + message); MessageUtil.sendMessage(player.getPlayer(), ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + message);
@ -200,7 +202,7 @@ public class DEditPlayer extends DInstancePlayer {
} }
DInstancePlayerUpdateEvent event = new DInstancePlayerUpdateEvent(this, locationValid, false, false, false, false, false); DInstancePlayerUpdateEvent event = new DInstancePlayerUpdateEvent(this, locationValid, false, false, false, false, false);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
@ -213,7 +215,7 @@ public class DEditPlayer extends DInstancePlayer {
/* Statics */ /* Statics */
public static DEditPlayer getByPlayer(Player player) { public static DEditPlayer getByPlayer(Player player) {
for (DEditPlayer dPlayer : plugin.getDPlayers().getDEditPlayers()) { for (DEditPlayer dPlayer : DungeonsXL.getDPlayers().getDEditPlayers()) {
if (dPlayer.getPlayer().equals(player)) { if (dPlayer.getPlayer().equals(player)) {
return dPlayer; return dPlayer;
} }
@ -222,7 +224,7 @@ public class DEditPlayer extends DInstancePlayer {
} }
public static DEditPlayer getByName(String name) { public static DEditPlayer getByName(String name) {
for (DEditPlayer dPlayer : plugin.getDPlayers().getDEditPlayers()) { for (DEditPlayer dPlayer : DungeonsXL.getDPlayers().getDEditPlayers()) {
if (dPlayer.getName().equalsIgnoreCase(name)) { if (dPlayer.getName().equalsIgnoreCase(name)) {
return dPlayer; return dPlayer;
} }
@ -233,7 +235,7 @@ public class DEditPlayer extends DInstancePlayer {
public static CopyOnWriteArrayList<DEditPlayer> getByWorld(World world) { public static CopyOnWriteArrayList<DEditPlayer> getByWorld(World world) {
CopyOnWriteArrayList<DEditPlayer> dPlayers = new CopyOnWriteArrayList<>(); CopyOnWriteArrayList<DEditPlayer> dPlayers = new CopyOnWriteArrayList<>();
for (DEditPlayer dPlayer : plugin.getDPlayers().getDEditPlayers()) { for (DEditPlayer dPlayer : DungeonsXL.getDPlayers().getDEditPlayers()) {
if (dPlayer.getWorld() == world) { if (dPlayer.getWorld() == world) {
dPlayers.add(dPlayer); dPlayers.add(dPlayer);
} }

View File

@ -40,6 +40,7 @@ import io.github.dre2n.dungeonsxl.world.block.TeamFlag;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
@ -128,7 +129,7 @@ public class DGamePlayer extends DInstancePlayer {
* null if the player will not be ready from the beginning * null if the player will not be ready from the beginning
*/ */
public static void create(Player player, DGameWorld gameWorld, GameType ready) { public static void create(Player player, DGameWorld gameWorld, GameType ready) {
new CreateDInstancePlayerTask(player, gameWorld, ready).runTaskTimer(plugin, 0L, 5L); new CreateDInstancePlayerTask(player, gameWorld, ready).runTaskTimer(DungeonsXL.getInstance(), 0L, 5L);
} }
/* Getters and setters */ /* Getters and setters */
@ -232,7 +233,7 @@ public class DGamePlayer extends DInstancePlayer {
return; return;
} }
DClass dClass = plugin.getDClasses().getByName(className); DClass dClass = DungeonsXL.getDClasses().getByName(className);
if (dClass != null) { if (dClass != null) {
if (this.dClass != dClass) { if (this.dClass != dClass) {
this.dClass = dClass; this.dClass = dClass;
@ -495,12 +496,12 @@ public class DGamePlayer extends DInstancePlayer {
// Tutorial Permissions // Tutorial Permissions
if (game.isTutorial() && plugin.getPermissionProvider().hasGroupSupport()) { if (game.isTutorial() && plugin.getPermissionProvider().hasGroupSupport()) {
String endGroup = plugin.getMainConfig().getTutorialEndGroup(); String endGroup = DungeonsXL.getMainConfig().getTutorialEndGroup();
if (plugin.isGroupEnabled(endGroup)) { if (plugin.isGroupEnabled(endGroup)) {
plugin.getPermissionProvider().playerAddGroup(getPlayer(), endGroup); plugin.getPermissionProvider().playerAddGroup(getPlayer(), endGroup);
} }
String startGroup = plugin.getMainConfig().getTutorialStartGroup(); String startGroup = DungeonsXL.getMainConfig().getTutorialStartGroup();
if (plugin.isGroupEnabled(startGroup)) { if (plugin.isGroupEnabled(startGroup)) {
plugin.getPermissionProvider().playerRemoveGroup(getPlayer(), startGroup); plugin.getPermissionProvider().playerRemoveGroup(getPlayer(), startGroup);
} }
@ -547,7 +548,7 @@ public class DGamePlayer extends DInstancePlayer {
public void kill() { public void kill() {
DPlayerKickEvent dPlayerKickEvent = new DPlayerKickEvent(this, DPlayerKickEvent.Cause.DEATH); DPlayerKickEvent dPlayerKickEvent = new DPlayerKickEvent(this, DPlayerKickEvent.Cause.DEATH);
plugin.getServer().getPluginManager().callEvent(dPlayerKickEvent); Bukkit.getPluginManager().callEvent(dPlayerKickEvent);
if (!dPlayerKickEvent.isCancelled()) { if (!dPlayerKickEvent.isCancelled()) {
DGameWorld gameWorld = getDGroup().getGameWorld(); DGameWorld gameWorld = getDGroup().getGameWorld();
@ -579,7 +580,7 @@ public class DGamePlayer extends DInstancePlayer {
for (Requirement requirement : rules.getRequirements()) { for (Requirement requirement : rules.getRequirements()) {
RequirementCheckEvent event = new RequirementCheckEvent(requirement, player); RequirementCheckEvent event = new RequirementCheckEvent(requirement, player);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
continue; continue;
@ -756,7 +757,7 @@ public class DGamePlayer extends DInstancePlayer {
} }
DGamePlayerFinishEvent dPlayerFinishEvent = new DGamePlayerFinishEvent(this, hasToWait); DGamePlayerFinishEvent dPlayerFinishEvent = new DGamePlayerFinishEvent(this, hasToWait);
plugin.getServer().getPluginManager().callEvent(dPlayerFinishEvent); Bukkit.getPluginManager().callEvent(dPlayerFinishEvent);
if (dPlayerFinishEvent.isCancelled()) { if (dPlayerFinishEvent.isCancelled()) {
finished = false; finished = false;
} }
@ -793,7 +794,7 @@ public class DGamePlayer extends DInstancePlayer {
} }
DGamePlayerFinishEvent dPlayerFinishEvent = new DGamePlayerFinishEvent(this, hasToWait); DGamePlayerFinishEvent dPlayerFinishEvent = new DGamePlayerFinishEvent(this, hasToWait);
plugin.getServer().getPluginManager().callEvent(dPlayerFinishEvent); Bukkit.getPluginManager().callEvent(dPlayerFinishEvent);
if (dPlayerFinishEvent.isCancelled()) { if (dPlayerFinishEvent.isCancelled()) {
finished = false; finished = false;
} }
@ -804,7 +805,7 @@ public class DGamePlayer extends DInstancePlayer {
DGameWorld gameWorld = DGameWorld.getByWorld(getWorld()); DGameWorld gameWorld = DGameWorld.getByWorld(getWorld());
gameWorld.sendMessage(message); gameWorld.sendMessage(message);
for (DGlobalPlayer player : plugin.getDPlayers().getDGlobalPlayers()) { for (DGlobalPlayer player : DungeonsXL.getDPlayers().getDGlobalPlayers()) {
if (player.isInChatSpyMode()) { if (player.isInChatSpyMode()) {
if (!gameWorld.getWorld().getPlayers().contains(player.getPlayer())) { if (!gameWorld.getWorld().getPlayers().contains(player.getPlayer())) {
MessageUtil.sendMessage(player.getPlayer(), ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + message); MessageUtil.sendMessage(player.getPlayer(), ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + message);
@ -825,7 +826,7 @@ public class DGamePlayer extends DInstancePlayer {
} }
DGamePlayerDeathEvent dPlayerDeathEvent = new DGamePlayerDeathEvent(this, event, 1); DGamePlayerDeathEvent dPlayerDeathEvent = new DGamePlayerDeathEvent(this, event, 1);
plugin.getServer().getPluginManager().callEvent(dPlayerDeathEvent); Bukkit.getPluginManager().callEvent(dPlayerDeathEvent);
if (dPlayerDeathEvent.isCancelled()) { if (dPlayerDeathEvent.isCancelled()) {
return; return;
@ -946,7 +947,7 @@ public class DGamePlayer extends DInstancePlayer {
} }
DInstancePlayerUpdateEvent event = new DInstancePlayerUpdateEvent(this, locationValid, teleportWolf, respawnInventory, offline, kick, triggerAllInDistance); DInstancePlayerUpdateEvent event = new DInstancePlayerUpdateEvent(this, locationValid, teleportWolf, respawnInventory, offline, kick, triggerAllInDistance);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
@ -979,7 +980,7 @@ public class DGamePlayer extends DInstancePlayer {
/* Statics */ /* Statics */
public static DGamePlayer getByPlayer(Player player) { public static DGamePlayer getByPlayer(Player player) {
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) { for (DGamePlayer dPlayer : DungeonsXL.getDPlayers().getDGamePlayers()) {
if (dPlayer.getPlayer().equals(player)) { if (dPlayer.getPlayer().equals(player)) {
return dPlayer; return dPlayer;
} }
@ -988,7 +989,7 @@ public class DGamePlayer extends DInstancePlayer {
} }
public static DGamePlayer getByName(String name) { public static DGamePlayer getByName(String name) {
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) { for (DGamePlayer dPlayer : DungeonsXL.getDPlayers().getDGamePlayers()) {
if (dPlayer.getPlayer().getName().equalsIgnoreCase(name) || dPlayer.getName().equalsIgnoreCase(name)) { if (dPlayer.getPlayer().getName().equalsIgnoreCase(name) || dPlayer.getName().equalsIgnoreCase(name)) {
return dPlayer; return dPlayer;
} }
@ -1000,7 +1001,7 @@ public class DGamePlayer extends DInstancePlayer {
public static List<DGamePlayer> getByWorld(World world) { public static List<DGamePlayer> getByWorld(World world) {
List<DGamePlayer> dPlayers = new ArrayList<>(); List<DGamePlayer> dPlayers = new ArrayList<>();
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) { for (DGamePlayer dPlayer : DungeonsXL.getDPlayers().getDGamePlayers()) {
if (dPlayer.getWorld() == world) { if (dPlayer.getWorld() == world) {
dPlayers.add(dPlayer); dPlayers.add(dPlayer);
} }

View File

@ -41,7 +41,7 @@ import org.bukkit.potion.PotionEffect;
*/ */
public class DGlobalPlayer { public class DGlobalPlayer {
static DungeonsXL plugin = DungeonsXL.getInstance(); DungeonsXL plugin = DungeonsXL.getInstance();
protected Player player; protected Player player;
@ -68,7 +68,7 @@ public class DGlobalPlayer {
reset(false); reset(false);
} }
plugin.getDPlayers().addPlayer(this); DungeonsXL.getDPlayers().addPlayer(this);
} }
public DGlobalPlayer(DGlobalPlayer dPlayer) { public DGlobalPlayer(DGlobalPlayer dPlayer) {
@ -80,7 +80,7 @@ public class DGlobalPlayer {
respawnInventory = dPlayer.getRespawnInventory(); respawnInventory = dPlayer.getRespawnInventory();
respawnArmor = dPlayer.getRespawnArmor(); respawnArmor = dPlayer.getRespawnArmor();
plugin.getDPlayers().addPlayer(this); DungeonsXL.getDPlayers().addPlayer(this);
} }
/* Getters and setters */ /* Getters and setters */
@ -315,8 +315,8 @@ public class DGlobalPlayer {
return; return;
} }
final String startGroup = plugin.getMainConfig().getTutorialStartGroup(); final String startGroup = DungeonsXL.getMainConfig().getTutorialStartGroup();
if ((plugin.getMainConfig().getTutorialDungeon() == null || startGroup == null)) { if ((DungeonsXL.getMainConfig().getTutorialDungeon() == null || startGroup == null)) {
return; return;
} }
@ -324,10 +324,10 @@ public class DGlobalPlayer {
plugin.getPermissionProvider().playerAddGroup(player, startGroup); plugin.getPermissionProvider().playerAddGroup(player, startGroup);
} }
DGroup dGroup = new DGroup(player, plugin.getMainConfig().getTutorialDungeon(), false); DGroup dGroup = new DGroup(player, DungeonsXL.getMainConfig().getTutorialDungeon(), false);
DGroupCreateEvent createEvent = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.GROUP_SIGN); DGroupCreateEvent createEvent = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.GROUP_SIGN);
plugin.getServer().getPluginManager().callEvent(createEvent); Bukkit.getPluginManager().callEvent(createEvent);
if (createEvent.isCancelled()) { if (createEvent.isCancelled()) {
dGroup = null; dGroup = null;
@ -340,7 +340,7 @@ public class DGlobalPlayer {
DGameWorld gameWorld = null; DGameWorld gameWorld = null;
if (dGroup.getGameWorld() == null) { if (dGroup.getGameWorld() == null) {
DResourceWorld resource = plugin.getDWorlds().getResourceByName(dGroup.getMapName()); DResourceWorld resource = DungeonsXL.getDWorlds().getResourceByName(dGroup.getMapName());
if (resource == null) { if (resource == null) {
MessageUtil.sendMessage(player, DMessages.ERROR_TUTORIAL_NOT_EXIST.getMessage()); MessageUtil.sendMessage(player, DMessages.ERROR_TUTORIAL_NOT_EXIST.getMessage());
return; return;

View File

@ -54,8 +54,8 @@ import org.bukkit.scheduler.BukkitTask;
*/ */
public class DGroup { public class DGroup {
static DungeonsXL plugin = DungeonsXL.getInstance(); DungeonsXL plugin = DungeonsXL.getInstance();
static DPlayers dPlayers = plugin.getDPlayers(); DPlayers dPlayers = DungeonsXL.getDPlayers();
private String name; private String name;
private UUID captain; private UUID captain;
@ -75,11 +75,11 @@ public class DGroup {
private int lives = -1; private int lives = -1;
public DGroup(Player player) { public DGroup(Player player) {
this("Group_" + plugin.getDGroups().size(), player); this("Group_" + DungeonsXL.getDGroups().size(), player);
} }
public DGroup(String name, Player player) { public DGroup(String name, Player player) {
plugin.getDGroups().add(this); DungeonsXL.getDGroups().add(this);
this.name = name; this.name = name;
setCaptain(player); setCaptain(player);
@ -91,7 +91,7 @@ public class DGroup {
@Deprecated @Deprecated
public DGroup(Player player, String identifier, boolean multiFloor) { public DGroup(Player player, String identifier, boolean multiFloor) {
this("Group_" + plugin.getDGroups().size(), player, identifier, multiFloor); this("Group_" + DungeonsXL.getDGroups().size(), player, identifier, multiFloor);
} }
@Deprecated @Deprecated
@ -101,11 +101,11 @@ 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) {
plugin.getDGroups().add(this); DungeonsXL.getDGroups().add(this);
this.name = name; this.name = name;
DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(plugin.getDPlayers().getByPlayer(captain), true, this); DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(DungeonsXL.getDPlayers().getByPlayer(captain), true, this);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
this.captain = captain.getUniqueId(); this.captain = captain.getUniqueId();
@ -118,14 +118,14 @@ public class DGroup {
} }
} }
dungeon = plugin.getDungeons().getByName(identifier); dungeon = DungeonsXL.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 = plugin.getDWorlds().getResourceByName(identifier); DResourceWorld resource = DungeonsXL.getDWorlds().getResourceByName(identifier);
dungeon = new Dungeon(resource); dungeon = new Dungeon(resource);
} }
@ -134,7 +134,7 @@ public class DGroup {
} }
public DGroup(Player player, Dungeon dungeon) { public DGroup(Player player, Dungeon dungeon) {
this("Group_" + plugin.getDGroups().size(), player, dungeon); this("Group_" + DungeonsXL.getDGroups().size(), player, dungeon);
} }
public DGroup(String name, Player player, Dungeon dungeon) { public DGroup(String name, Player player, Dungeon dungeon) {
@ -142,11 +142,11 @@ 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) {
plugin.getDGroups().add(this); DungeonsXL.getDGroups().add(this);
this.name = name; this.name = name;
DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(plugin.getDPlayers().getByPlayer(captain), true, this); DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(DungeonsXL.getDPlayers().getByPlayer(captain), true, this);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
this.captain = captain.getUniqueId(); this.captain = captain.getUniqueId();
@ -256,7 +256,7 @@ public class DGroup {
*/ */
public void addPlayer(Player player, boolean message) { public void addPlayer(Player player, boolean message) {
DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(DGamePlayer.getByPlayer(player), false, this); DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(DGamePlayer.getByPlayer(player), false, this);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (message) { if (message) {
@ -289,12 +289,12 @@ public class DGroup {
GroupSign.updatePerGroup(this); GroupSign.updatePerGroup(this);
if (message) { if (message) {
sendMessage(plugin.getMessageConfig().getMessage(DMessages.PLAYER_LEFT_GROUP, player.getName())); sendMessage(DungeonsXL.getMessageConfig().getMessage(DMessages.PLAYER_LEFT_GROUP, player.getName()));
} }
if (isEmpty()) { if (isEmpty()) {
DGroupDisbandEvent event = new DGroupDisbandEvent(this, player, DGroupDisbandEvent.Cause.GROUP_IS_EMPTY); DGroupDisbandEvent event = new DGroupDisbandEvent(this, player, DGroupDisbandEvent.Cause.GROUP_IS_EMPTY);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
delete(); delete();
@ -308,7 +308,7 @@ public class DGroup {
public List<Player> getInvitedPlayers() { public List<Player> getInvitedPlayers() {
ArrayList<Player> players = new ArrayList<>(); ArrayList<Player> players = new ArrayList<>();
for (UUID uuid : invitedPlayers) { for (UUID uuid : invitedPlayers) {
players.add(plugin.getServer().getPlayer(uuid)); players.add(Bukkit.getPlayer(uuid));
} }
return players; return players;
@ -325,18 +325,18 @@ public class DGroup {
if (DGroup.getByPlayer(player) != null) { if (DGroup.getByPlayer(player) != null) {
if (!silent) { if (!silent) {
MessageUtil.sendMessage(getCaptain(), plugin.getMessageConfig().getMessage(DMessages.ERROR_IN_GROUP, player.getName())); MessageUtil.sendMessage(getCaptain(), DungeonsXL.getMessageConfig().getMessage(DMessages.ERROR_IN_GROUP, player.getName()));
} }
return; return;
} }
if (!silent) { if (!silent) {
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.PLAYER_INVITED, getCaptain().getName(), name)); MessageUtil.sendMessage(player, DungeonsXL.getMessageConfig().getMessage(DMessages.PLAYER_INVITED, getCaptain().getName(), name));
} }
// Send message // Send message
if (!silent) { if (!silent) {
sendMessage(plugin.getMessageConfig().getMessage(DMessages.GROUP_INVITED_PLAYER, getCaptain().getName(), player.getName(), name)); sendMessage(DungeonsXL.getMessageConfig().getMessage(DMessages.GROUP_INVITED_PLAYER, getCaptain().getName(), player.getName(), name));
} }
// Add player // Add player
@ -354,19 +354,19 @@ public class DGroup {
if (DGroup.getByPlayer(player) != this) { if (DGroup.getByPlayer(player) != this) {
if (!silent) { if (!silent) {
MessageUtil.sendMessage(getCaptain(), plugin.getMessageConfig().getMessage(DMessages.ERROR_NOT_IN_GROUP, player.getName(), name)); MessageUtil.sendMessage(getCaptain(), DungeonsXL.getMessageConfig().getMessage(DMessages.ERROR_NOT_IN_GROUP, player.getName(), name));
} }
return; return;
} }
if (!silent) { if (!silent) {
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.PLAYER_UNINVITED, player.getName(), name)); MessageUtil.sendMessage(player, DungeonsXL.getMessageConfig().getMessage(DMessages.PLAYER_UNINVITED, player.getName(), name));
} }
// Send message // Send message
if (!silent) { if (!silent) {
for (Player groupPlayer : getPlayers()) { for (Player groupPlayer : getPlayers()) {
MessageUtil.sendMessage(groupPlayer, plugin.getMessageConfig().getMessage(DMessages.GROUP_UNINVITED_PLAYER, getCaptain().getName(), player.getName(), name)); MessageUtil.sendMessage(groupPlayer, DungeonsXL.getMessageConfig().getMessage(DMessages.GROUP_UNINVITED_PLAYER, getCaptain().getName(), player.getName(), name));
} }
} }
@ -380,7 +380,7 @@ public class DGroup {
ArrayList<UUID> toRemove = new ArrayList<>(); ArrayList<UUID> toRemove = new ArrayList<>();
for (UUID uuid : invitedPlayers) { for (UUID uuid : invitedPlayers) {
if (plugin.getServer().getPlayer(uuid) == null) { if (Bukkit.getPlayer(uuid) == null) {
toRemove.add(uuid); toRemove.add(uuid);
} }
} }
@ -430,13 +430,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 = plugin.getDungeons().getByName(name); dungeon = DungeonsXL.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 = plugin.getDWorlds().getResourceByName(name); DResourceWorld resource = DungeonsXL.getDWorlds().getResourceByName(name);
if (resource != null) { if (resource != null) {
dungeon = new Dungeon(resource); dungeon = new Dungeon(resource);
return true; return true;
@ -529,7 +529,7 @@ public class DGroup {
*/ */
public void addReward(Reward reward) { public void addReward(Reward reward) {
RewardAdditionEvent event = new RewardAdditionEvent(reward, this); RewardAdditionEvent event = new RewardAdditionEvent(reward, this);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
@ -671,14 +671,14 @@ public class DGroup {
*/ */
public void finish() { public void finish() {
DGroupFinishDungeonEvent dGroupFinishDungeonEvent = new DGroupFinishDungeonEvent(dungeon, this); DGroupFinishDungeonEvent dGroupFinishDungeonEvent = new DGroupFinishDungeonEvent(dungeon, this);
plugin.getServer().getPluginManager().callEvent(dGroupFinishDungeonEvent); Bukkit.getPluginManager().callEvent(dGroupFinishDungeonEvent);
if (dGroupFinishDungeonEvent.isCancelled()) { if (dGroupFinishDungeonEvent.isCancelled()) {
return; return;
} }
Game.getByDGroup(this).resetWaveKills(); Game.getByDGroup(this).resetWaveKills();
DGroupRewardEvent dGroupRewardEvent = new DGroupRewardEvent(this); DGroupRewardEvent dGroupRewardEvent = new DGroupRewardEvent(this);
plugin.getServer().getPluginManager().callEvent(dGroupRewardEvent); Bukkit.getPluginManager().callEvent(dGroupRewardEvent);
for (DGamePlayer player : getDGamePlayers()) { for (DGamePlayer player : getDGamePlayers()) {
player.leave(false); player.leave(false);
if (!dGroupRewardEvent.isCancelled()) { if (!dGroupRewardEvent.isCancelled()) {
@ -716,7 +716,7 @@ public class DGroup {
} }
DGroupFinishFloorEvent event = new DGroupFinishFloorEvent(this, gameWorld, newFloor); DGroupFinishFloorEvent event = new DGroupFinishFloorEvent(this, gameWorld, newFloor);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
} }
@ -745,7 +745,7 @@ public class DGroup {
public void delete() { public void delete() {
Game game = Game.getByDGroup(this); Game game = Game.getByDGroup(this);
plugin.getDGroups().remove(this); DungeonsXL.getDGroups().remove(this);
if (game != null) { if (game != null) {
game.removeDGroup(this); game.removeDGroup(this);
@ -765,7 +765,7 @@ public class DGroup {
game.fetchRules(); game.fetchRules();
GameRules rules = game.getRules(); GameRules rules = game.getRules();
color = plugin.getMainConfig().getGroupColorPriority().get(game.getDGroups().indexOf(this)); color = DungeonsXL.getMainConfig().getGroupColorPriority().get(game.getDGroups().indexOf(this));
for (DGroup dGroup : game.getDGroups()) { for (DGroup dGroup : game.getDGroups()) {
if (dGroup == null) { if (dGroup == null) {
@ -790,7 +790,7 @@ public class DGroup {
} }
DGroupStartFloorEvent event = new DGroupStartFloorEvent(this, gameWorld); DGroupStartFloorEvent event = new DGroupStartFloorEvent(this, gameWorld);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
@ -814,7 +814,7 @@ public class DGroup {
dPlayer.respawn(); dPlayer.respawn();
if (plugin.getMainConfig().isSendFloorTitleEnabled()) { if (DungeonsXL.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();
@ -839,7 +839,7 @@ public class DGroup {
for (Requirement requirement : rules.getRequirements()) { for (Requirement requirement : rules.getRequirements()) {
RequirementDemandEvent requirementDemandEvent = new RequirementDemandEvent(requirement, player); RequirementDemandEvent requirementDemandEvent = new RequirementDemandEvent(requirement, player);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (requirementDemandEvent.isCancelled()) { if (requirementDemandEvent.isCancelled()) {
continue; continue;
@ -932,7 +932,7 @@ public class DGroup {
/* Statics */ /* Statics */
public static DGroup getByName(String name) { public static DGroup getByName(String name) {
for (DGroup dGroup : plugin.getDGroups()) { for (DGroup dGroup : DungeonsXL.getDGroups()) {
if (dGroup.getName().equalsIgnoreCase(name) || dGroup.getRawName().equalsIgnoreCase(name)) { if (dGroup.getName().equalsIgnoreCase(name) || dGroup.getRawName().equalsIgnoreCase(name)) {
return dGroup; return dGroup;
} }
@ -942,7 +942,7 @@ public class DGroup {
} }
public static DGroup getByPlayer(Player player) { public static DGroup getByPlayer(Player player) {
for (DGroup dGroup : plugin.getDGroups()) { for (DGroup dGroup : DungeonsXL.getDGroups()) {
if (dGroup.getPlayers().contains(player)) { if (dGroup.getPlayers().contains(player)) {
return dGroup; return dGroup;
} }
@ -952,7 +952,7 @@ public class DGroup {
} }
public static void leaveGroup(Player player) { public static void leaveGroup(Player player) {
for (DGroup dGroup : plugin.getDGroups()) { for (DGroup dGroup : DungeonsXL.getDGroups()) {
if (dGroup.getPlayers().contains(player)) { if (dGroup.getPlayers().contains(player)) {
dGroup.getPlayers().remove(player); dGroup.getPlayers().remove(player);
} }
@ -966,7 +966,7 @@ public class DGroup {
*/ */
public static List<DGroup> getByGameWorld(DGameWorld gameWorld) { public static List<DGroup> getByGameWorld(DGameWorld gameWorld) {
List<DGroup> dGroups = new ArrayList<>(); List<DGroup> dGroups = new ArrayList<>();
for (DGroup dGroup : plugin.getDGroups()) { for (DGroup dGroup : DungeonsXL.getDGroups()) {
if (dGroup.getGameWorld().equals(gameWorld)) { if (dGroup.getGameWorld().equals(gameWorld)) {
dGroups.add(dGroup); dGroups.add(dGroup);
} }

View File

@ -16,6 +16,7 @@
*/ */
package io.github.dre2n.dungeonsxl.player; package io.github.dre2n.dungeonsxl.player;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@ -100,7 +101,7 @@ public abstract class DInstancePlayer extends DGlobalPlayer {
new DGlobalPlayer(this); new DGlobalPlayer(this);
} else { } else {
plugin.getDPlayers().removePlayer(this); DungeonsXL.getDPlayers().removePlayer(this);
} }
} }

View File

@ -31,6 +31,7 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -44,7 +45,6 @@ import org.bukkit.potion.PotionEffect;
*/ */
public class DPlayerData extends BRConfig { public class DPlayerData extends BRConfig {
DungeonsXL plugin = DungeonsXL.getInstance();
boolean is1_9 = Internals.andHigher(Internals.v1_9_R1).contains(CompatibilityHandler.getInstance().getInternals()); boolean is1_9 = Internals.andHigher(Internals.v1_9_R1).contains(CompatibilityHandler.getInstance().getInternals());
public static final int CONFIG_VERSION = 2; public static final int CONFIG_VERSION = 2;
@ -317,7 +317,7 @@ public class DPlayerData extends BRConfig {
if (!file.exists()) { if (!file.exists()) {
try { try {
file.createNewFile(); file.createNewFile();
MessageUtil.log(plugin, DMessages.LOG_NEW_PLAYER_DATA.getMessage(file.getName())); MessageUtil.log(DungeonsXL.getInstance(), DMessages.LOG_NEW_PLAYER_DATA.getMessage(file.getName()));
} catch (IOException exception) { } catch (IOException exception) {
} }
} }
@ -357,7 +357,7 @@ public class DPlayerData extends BRConfig {
oldLocation = (Location) config.get(PREFIX_STATE_PERSISTENCE + "oldLocation"); oldLocation = (Location) config.get(PREFIX_STATE_PERSISTENCE + "oldLocation");
if (oldLocation.getWorld() == null) { if (oldLocation.getWorld() == null) {
oldLocation = plugin.getServer().getWorlds().get(0).getSpawnLocation(); oldLocation = Bukkit.getWorlds().get(0).getSpawnLocation();
} }
} }

View File

@ -39,6 +39,7 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
@ -60,10 +61,15 @@ import org.bukkit.inventory.meta.BookMeta;
/** /**
* @author Daniel Saukel, Frank Baumann, Milan Albrecht * @author Daniel Saukel, Frank Baumann, Milan Albrecht
*/ */
public class DPlayerListener { public class DPlayerListener implements Listener {
DungeonsXL plugin = DungeonsXL.getInstance(); DungeonsXL plugin;
DPlayers dPlayers = plugin.getDPlayers(); DPlayers dPlayers;
public DPlayerListener(DPlayers dPlayers) {
this.plugin = DungeonsXL.getInstance();
this.dPlayers = dPlayers;
}
@EventHandler @EventHandler
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
@ -247,7 +253,7 @@ public class DPlayerListener {
return; return;
} else { } else {
commandWhitelist.addAll(plugin.getMainConfig().getEditCommandWhitelist()); commandWhitelist.addAll(DungeonsXL.getMainConfig().getEditCommandWhitelist());
} }
} else if (game != null) { } else if (game != null) {
@ -298,7 +304,7 @@ public class DPlayerListener {
return; return;
} }
if (dPlayer instanceof DEditPlayer && !plugin.getMainConfig().getDropItems() && !DPermissions.hasPermission(player, DPermissions.INSECURE)) { if (dPlayer instanceof DEditPlayer && !DungeonsXL.getMainConfig().getDropItems() && !DPermissions.hasPermission(player, DPermissions.INSECURE)) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -346,7 +352,7 @@ public class DPlayerListener {
return; return;
} }
if (!plugin.getMainConfig().isTutorialActivated()) { if (!DungeonsXL.getMainConfig().isTutorialActivated()) {
return; return;
} }
@ -360,7 +366,7 @@ public class DPlayerListener {
@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 = plugin.getMainConfig(); MainConfig config = DungeonsXL.getMainConfig();
if (!config.isTutorialActivated()) { if (!config.isTutorialActivated()) {
return; return;
@ -383,7 +389,7 @@ public class DPlayerListener {
continue; continue;
} }
if (plugin.getDWorlds().getGameWorlds().size() >= config.getMaxInstances()) { if (DungeonsXL.getDWorlds().getGameWorlds().size() >= config.getMaxInstances()) {
event.setResult(PlayerLoginEvent.Result.KICK_FULL); event.setResult(PlayerLoginEvent.Result.KICK_FULL);
event.setKickMessage(DMessages.ERROR_TOO_MANY_TUTORIALS.getMessage()); event.setKickMessage(DMessages.ERROR_TOO_MANY_TUTORIALS.getMessage());
} }
@ -447,7 +453,7 @@ public class DPlayerListener {
if (isCitizensNPC(player)) { if (isCitizensNPC(player)) {
return; return;
} }
plugin.getDPlayers().getByPlayer(player).applyRespawnInventory(); DungeonsXL.getDPlayers().getByPlayer(player).applyRespawnInventory();
DGlobalPlayer dPlayer = DGamePlayer.getByPlayer(player); DGlobalPlayer dPlayer = DGamePlayer.getByPlayer(player);
if (dPlayer == null) { if (dPlayer == null) {
@ -575,7 +581,7 @@ public class DPlayerListener {
if (dGlobalPlayer.isCreatingPortal()) { if (dGlobalPlayer.isCreatingPortal()) {
if (item.getType() == Material.WOOD_SWORD) { if (item.getType() == Material.WOOD_SWORD) {
if (clickedBlock != null) { if (clickedBlock != null) {
for (GlobalProtection protection : plugin.getGlobalProtections().getProtections(DPortal.class)) { for (GlobalProtection protection : DungeonsXL.getGlobalProtections().getProtections(DPortal.class)) {
DPortal dPortal = (DPortal) protection; DPortal dPortal = (DPortal) protection;
if (!dPortal.isActive()) { if (!dPortal.isActive()) {
if (dPortal == dGlobalPlayer.getPortal()) { if (dPortal == dGlobalPlayer.getPortal()) {

View File

@ -23,7 +23,6 @@ import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
/** /**
@ -31,10 +30,10 @@ import org.bukkit.scheduler.BukkitTask;
* *
* @author Daniel Saukel * @author Daniel Saukel
*/ */
public class DPlayers implements Listener { public class DPlayers {
DungeonsXL plugin = DungeonsXL.getInstance(); DungeonsXL plugin = DungeonsXL.getInstance();
MainConfig mainConfig = plugin.getMainConfig(); MainConfig mainConfig = DungeonsXL.getMainConfig();
private BukkitTask secureModeTask; private BukkitTask secureModeTask;
private BukkitTask updateTask; private BukkitTask updateTask;
@ -49,7 +48,7 @@ public class DPlayers implements Listener {
startUpdateTask(2L); startUpdateTask(2L);
startLazyUpdateTask(20L); startLazyUpdateTask(20L);
Bukkit.getPluginManager().registerEvents(this, plugin); Bukkit.getPluginManager().registerEvents(new DPlayerListener(this), plugin);
} }
/** /**

View File

@ -26,7 +26,7 @@ public class LazyUpdateTask extends BukkitRunnable {
@Override @Override
public void run() { public void run() {
for (DGamePlayer dPlayer : DungeonsXL.getInstance().getDPlayers().getDGamePlayers()) { for (DGamePlayer dPlayer : DungeonsXL.getDPlayers().getDGamePlayers()) {
dPlayer.update(true); dPlayer.update(true);
} }
} }

View File

@ -41,7 +41,7 @@ public class RespawnTask extends BukkitRunnable {
PlayerUtil.secureTeleport(player, location); PlayerUtil.secureTeleport(player, location);
} }
DGlobalPlayer dPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player); DGlobalPlayer dPlayer = DungeonsXL.getDPlayers().getByPlayer(player);
if (dPlayer == null) { if (dPlayer == null) {
return; return;

View File

@ -29,7 +29,7 @@ public class SecureModeTask extends BukkitRunnable {
@Override @Override
public void run() { public void run() {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
DGlobalPlayer dGlobalPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player); DGlobalPlayer dGlobalPlayer = DungeonsXL.getDPlayers().getByPlayer(player);
if (dGlobalPlayer == null) { if (dGlobalPlayer == null) {
dGlobalPlayer = new DGlobalPlayer(player); dGlobalPlayer = new DGlobalPlayer(player);
} }

View File

@ -32,7 +32,7 @@ import org.bukkit.scheduler.BukkitRunnable;
*/ */
public class TimeIsRunningTask extends BukkitRunnable { public class TimeIsRunningTask extends BukkitRunnable {
MessageConfig messageConfig = DungeonsXL.getInstance().getMessageConfig(); MessageConfig messageConfig = DungeonsXL.getMessageConfig();
private DGroup dGroup; private DGroup dGroup;
private int time; private int time;

View File

@ -26,7 +26,7 @@ public class UpdateTask extends BukkitRunnable {
@Override @Override
public void run() { public void run() {
for (DInstancePlayer dPlayer : DungeonsXL.getInstance().getDPlayers().getDInstancePlayers()) { for (DInstancePlayer dPlayer : DungeonsXL.getDPlayers().getDInstancePlayers()) {
dPlayer.update(false); dPlayer.update(false);
} }
} }

View File

@ -74,7 +74,7 @@ public class FeeLevelRequirement extends Requirement {
DPlayerData data = dPlayer.getData(); DPlayerData data = dPlayer.getData();
data.setOldLevel(data.getOldLevel() - fee); data.setOldLevel(data.getOldLevel() - fee);
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.REQUIREMENT_FEE, fee + " levels")); MessageUtil.sendMessage(player, DMessages.REQUIREMENT_FEE.getMessage(fee + " levels"));
} }
} }

View File

@ -17,6 +17,7 @@
package io.github.dre2n.dungeonsxl.requirement; package io.github.dre2n.dungeonsxl.requirement;
import io.github.dre2n.commons.util.messageutil.MessageUtil; import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages; import io.github.dre2n.dungeonsxl.config.DMessages;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -26,6 +27,8 @@ import org.bukkit.entity.Player;
*/ */
public class FeeMoneyRequirement extends Requirement { public class FeeMoneyRequirement extends Requirement {
DungeonsXL plugin = DungeonsXL.getInstance();
private RequirementType type = RequirementTypeDefault.FEE_MONEY; private RequirementType type = RequirementTypeDefault.FEE_MONEY;
private double fee; private double fee;
@ -73,7 +76,7 @@ public class FeeMoneyRequirement extends Requirement {
} }
plugin.getEconomyProvider().withdrawPlayer(player, fee); plugin.getEconomyProvider().withdrawPlayer(player, fee);
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.REQUIREMENT_FEE, plugin.getEconomyProvider().format(fee))); MessageUtil.sendMessage(player, DMessages.REQUIREMENT_FEE.getMessage(plugin.getEconomyProvider().format(fee)));
} }
} }

View File

@ -32,8 +32,6 @@ import org.bukkit.entity.Player;
*/ */
public abstract class Requirement { public abstract class Requirement {
DungeonsXL plugin = DungeonsXL.getInstance();
public static Requirement create(RequirementType type) { public static Requirement create(RequirementType type) {
Requirement requirement = null; Requirement requirement = null;

View File

@ -30,16 +30,14 @@ import org.bukkit.inventory.ItemStack;
*/ */
public class DLootInventory { public class DLootInventory {
static DungeonsXL plugin = DungeonsXL.getInstance();
private Inventory inventory; private Inventory inventory;
private InventoryView inventoryView; private InventoryView inventoryView;
private Player player; private Player player;
public DLootInventory(Player player, ItemStack[] itemStacks) { public DLootInventory(Player player, ItemStack[] itemStacks) {
plugin.getDLootInventories().add(this); DungeonsXL.getDLootInventories().add(this);
inventory = Bukkit.createInventory(player, 54, ChatColor.translateAlternateColorCodes('&', plugin.getMessageConfig().getMessage(DMessages.PLAYER_TREASURES))); inventory = Bukkit.createInventory(player, 54, ChatColor.translateAlternateColorCodes('&', DungeonsXL.getMessageConfig().getMessage(DMessages.PLAYER_TREASURES)));
for (ItemStack itemStack : itemStacks) { for (ItemStack itemStack : itemStacks) {
if (itemStack != null) { if (itemStack != null) {
inventory.addItem(itemStack); inventory.addItem(itemStack);
@ -117,7 +115,7 @@ public class DLootInventory {
* the player whose DLootIntentory will be returned * the player whose DLootIntentory will be returned
*/ */
public static DLootInventory getByPlayer(Player player) { public static DLootInventory getByPlayer(Player player) {
for (DLootInventory inventory : plugin.getDLootInventories()) { for (DLootInventory inventory : DungeonsXL.getDLootInventories()) {
if (inventory.player == player) { if (inventory.player == player) {
return inventory; return inventory;
} }

View File

@ -17,6 +17,7 @@
package io.github.dre2n.dungeonsxl.reward; package io.github.dre2n.dungeonsxl.reward;
import io.github.dre2n.commons.util.messageutil.MessageUtil; import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages; import io.github.dre2n.dungeonsxl.config.DMessages;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -79,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]));
plugin.getDPlayers().getByPlayer(player).setRewardItems(new CopyOnWriteArrayList<>(items.subList(54, items.size()))); DungeonsXL.getDPlayers().getByPlayer(player).setRewardItems(new CopyOnWriteArrayList<>(items.subList(54, items.size())));
MessageUtil.sendMessage(player, DMessages.ERROR_TOO_MANY_REWARDS.getMessage()); MessageUtil.sendMessage(player, DMessages.ERROR_TOO_MANY_REWARDS.getMessage());
} }
} }

View File

@ -59,7 +59,7 @@ public class LevelReward extends Reward {
} }
player.setLevel(player.getLevel() + levels); player.setLevel(player.getLevel() + levels);
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.REWARD_GENERAL, levels + " levels")); MessageUtil.sendMessage(player, DMessages.REWARD_GENERAL.getMessage(levels + " levels"));
} }
@Override @Override

View File

@ -59,7 +59,7 @@ public class MoneyReward extends Reward {
} }
plugin.getEconomyProvider().depositPlayer(player, money); plugin.getEconomyProvider().depositPlayer(player, money);
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.REWARD_GENERAL, plugin.getEconomyProvider().format(money))); MessageUtil.sendMessage(player, DMessages.REWARD_GENERAL.getMessage(plugin.getEconomyProvider().format(money)));
} }
@Override @Override

View File

@ -39,8 +39,6 @@ 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)) {
@ -48,7 +46,7 @@ public class RewardListener implements Listener {
} }
Player player = (Player) event.getPlayer(); Player player = (Player) event.getPlayer();
for (DLootInventory inventory : plugin.getDLootInventories()) { for (DLootInventory inventory : DungeonsXL.getDLootInventories()) {
if (event.getView() != inventory.getInventoryView()) { if (event.getView() != inventory.getInventoryView()) {
continue; continue;
} }
@ -63,7 +61,7 @@ public class RewardListener implements Listener {
} }
} }
plugin.getDLootInventories().remove(inventory); DungeonsXL.getDLootInventories().remove(inventory);
} }
} }
@ -96,7 +94,7 @@ public class RewardListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
if (!plugin.getMainConfig().getOpenInventories() && !DPermissions.hasPermission(event.getPlayer(), DPermissions.INSECURE)) { if (!DungeonsXL.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);

View File

@ -29,13 +29,11 @@ import org.bukkit.Bukkit;
*/ */
public class RewardTypes { public class RewardTypes {
DungeonsXL plugin = DungeonsXL.getInstance();
private List<RewardType> types = new ArrayList<>(); private List<RewardType> types = new ArrayList<>();
public RewardTypes() { public RewardTypes() {
types.addAll(Arrays.asList(RewardTypeDefault.values())); types.addAll(Arrays.asList(RewardTypeDefault.values()));
Bukkit.getPluginManager().registerEvents(new RewardListener(), plugin); Bukkit.getPluginManager().registerEvents(new RewardListener(), DungeonsXL.getInstance());
} }
/** /**

View File

@ -60,7 +60,7 @@ public class CheckpointSign extends DSign {
for (DGamePlayer dplayer : DGamePlayer.getByWorld(getGameWorld().getWorld())) { for (DGamePlayer dplayer : DGamePlayer.getByWorld(getGameWorld().getWorld())) {
dplayer.setCheckpoint(getSign().getLocation()); dplayer.setCheckpoint(getSign().getLocation());
MessageUtil.sendMessage(dplayer.getPlayer(), plugin.getMessageConfig().getMessage(DMessages.PLAYER_CHECKPOINT_REACHED)); MessageUtil.sendMessage(dplayer.getPlayer(), DMessages.PLAYER_CHECKPOINT_REACHED.getMessage());
} }
remove(); remove();
@ -77,7 +77,7 @@ public class CheckpointSign extends DSign {
if (!done.contains(dplayer)) { if (!done.contains(dplayer)) {
done.add(dplayer); done.add(dplayer);
dplayer.setCheckpoint(getSign().getLocation()); dplayer.setCheckpoint(getSign().getLocation());
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.PLAYER_CHECKPOINT_REACHED)); MessageUtil.sendMessage(player, DMessages.PLAYER_CHECKPOINT_REACHED.getMessage());
} }
} }

View File

@ -17,6 +17,7 @@
package io.github.dre2n.dungeonsxl.sign; package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commons.util.NumberUtil; import io.github.dre2n.commons.util.NumberUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.loottable.DLootTable; import io.github.dre2n.dungeonsxl.loottable.DLootTable;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import io.github.dre2n.dungeonsxl.world.block.RewardChest; import io.github.dre2n.dungeonsxl.world.block.RewardChest;
@ -166,7 +167,7 @@ public class ChestSign extends DSign {
} }
if (!lines[2].isEmpty()) { if (!lines[2].isEmpty()) {
lootTable = plugin.getDLootTables().getByName(lines[2]); lootTable = DungeonsXL.getDLootTables().getByName(lines[2]);
} }
if (chest == null) { if (chest == null) {

View File

@ -27,6 +27,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -38,7 +39,7 @@ import org.bukkit.entity.Player;
*/ */
public abstract class DSign { public abstract class DSign {
static DungeonsXL plugin = DungeonsXL.getInstance(); 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";
@ -217,7 +218,7 @@ public abstract class DSign {
public static DSign create(Sign sign, String[] lines, DGameWorld gameWorld) { public static DSign create(Sign sign, String[] lines, DGameWorld gameWorld) {
DSign dSign = null; DSign dSign = null;
for (DSignType type : plugin.getDSigns().getDSigns()) { for (DSignType type : DungeonsXL.getDSigns().getDSigns()) {
if (!lines[0].equalsIgnoreCase("[" + type.getName() + "]")) { if (!lines[0].equalsIgnoreCase("[" + type.getName() + "]")) {
continue; continue;
} }
@ -236,7 +237,7 @@ public abstract class DSign {
if (gameWorld != null) { if (gameWorld != null) {
DSignRegistrationEvent event = new DSignRegistrationEvent(sign, gameWorld, dSign); DSignRegistrationEvent event = new DSignRegistrationEvent(sign, gameWorld, dSign);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return null; return null;

View File

@ -29,13 +29,11 @@ import org.bukkit.Bukkit;
*/ */
public class DSignTypes { public class DSignTypes {
DungeonsXL plugin = DungeonsXL.getInstance();
private List<DSignType> types = new ArrayList<>(); private List<DSignType> types = new ArrayList<>();
public DSignTypes() { public DSignTypes() {
types.addAll(Arrays.asList(DSignTypeDefault.values())); types.addAll(Arrays.asList(DSignTypeDefault.values()));
Bukkit.getPluginManager().registerEvents(new DSignListener(), plugin); Bukkit.getPluginManager().registerEvents(new DSignListener(), DungeonsXL.getInstance());
} }
/** /**

View File

@ -16,6 +16,7 @@
*/ */
package io.github.dre2n.dungeonsxl.sign; package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.player.DGamePlayer; import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger; import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
@ -61,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 = plugin.getDWorlds().getResourceByName(lines[1]); floor = DungeonsXL.getDWorlds().getResourceByName(lines[1]);
} }
if (!getTriggers().isEmpty()) { if (!getTriggers().isEmpty()) {
@ -103,7 +104,7 @@ public class FloorSign extends DSign {
@Override @Override
public void onTrigger() { public void onTrigger() {
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) { for (DGamePlayer dPlayer : DungeonsXL.getDPlayers().getDGamePlayers()) {
dPlayer.finishFloor(floor); dPlayer.finishFloor(floor);
} }
} }

View File

@ -16,10 +16,12 @@
*/ */
package io.github.dre2n.dungeonsxl.sign; package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.event.dplayer.instance.game.DGamePlayerEscapeEvent; import io.github.dre2n.dungeonsxl.event.dplayer.instance.game.DGamePlayerEscapeEvent;
import io.github.dre2n.dungeonsxl.player.DGamePlayer; import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger; import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
@ -65,7 +67,7 @@ public class LeaveSign extends DSign {
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player); DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
if (dPlayer != null) { if (dPlayer != null) {
DGamePlayerEscapeEvent event = new DGamePlayerEscapeEvent(dPlayer); DGamePlayerEscapeEvent event = new DGamePlayerEscapeEvent(dPlayer);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return false; return false;
@ -79,9 +81,9 @@ public class LeaveSign extends DSign {
@Override @Override
public void onTrigger() { public void onTrigger() {
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) { for (DGamePlayer dPlayer : DungeonsXL.getDPlayers().getDGamePlayers()) {
DGamePlayerEscapeEvent event = new DGamePlayerEscapeEvent(dPlayer); DGamePlayerEscapeEvent event = new DGamePlayerEscapeEvent(dPlayer);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;

View File

@ -16,6 +16,7 @@
*/ */
package io.github.dre2n.dungeonsxl.sign; package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger; import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -61,7 +62,7 @@ public class ResourcePackSign extends DSign {
/* Actions */ /* Actions */
@Override @Override
public boolean check() { public boolean check() {
return plugin.getMainConfig().getResourcePacks().get(lines[1]) != null || lines[1].equalsIgnoreCase("reset"); return DungeonsXL.getMainConfig().getResourcePacks().get(lines[1]) != null || lines[1].equalsIgnoreCase("reset");
} }
@Override @Override
@ -71,7 +72,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 = plugin.getMainConfig().getResourcePacks().get(lines[1]); url = DungeonsXL.getMainConfig().getResourcePacks().get(lines[1]);
} }
if (url instanceof String) { if (url instanceof String) {

View File

@ -16,6 +16,7 @@
*/ */
package io.github.dre2n.dungeonsxl.sign; package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
@ -43,12 +44,12 @@ public class ScriptSign extends DSign {
@Override @Override
public boolean check() { public boolean check() {
return plugin.getSignScripts().getByName(lines[1]) != null; return DungeonsXL.getSignScripts().getByName(lines[1]) != null;
} }
@Override @Override
public void onInit() { public void onInit() {
SignScript script = plugin.getSignScripts().getByName(name); SignScript script = DungeonsXL.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

@ -32,8 +32,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
*/ */
public class SignScript { public class SignScript {
DungeonsXL plugin = DungeonsXL.getInstance();
private String name; private String name;
private List<String[]> signs; private List<String[]> signs;

View File

@ -30,15 +30,13 @@ import org.bukkit.block.Sign;
*/ */
public class ClassesSign extends DSign { public class ClassesSign extends DSign {
DungeonsXL plugin = DungeonsXL.getInstance();
private DSignType type = DSignTypeDefault.CLASSES; private DSignType type = DSignTypeDefault.CLASSES;
private DClass dClass; private DClass dClass;
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 = plugin.getDClasses().getByName(sign.getLine(1)); dClass = DungeonsXL.getDClasses().getByName(sign.getLine(1));
} }
/* Getters and setters */ /* Getters and setters */
@ -60,7 +58,7 @@ public class ClassesSign extends DSign {
/* Actions */ /* Actions */
@Override @Override
public boolean check() { public boolean check() {
return plugin.getDClasses().getByName(lines[1]) != null; return DungeonsXL.getDClasses().getByName(lines[1]) != null;
} }
@Override @Override

View File

@ -41,8 +41,6 @@ import org.bukkit.scheduler.BukkitRunnable;
*/ */
public class ReadySign extends DSign { public class ReadySign extends DSign {
DungeonsXL plugin = DungeonsXL.getInstance();
private DSignType type = DSignTypeDefault.READY; private DSignType type = DSignTypeDefault.READY;
private GameType gameType; private GameType gameType;
@ -90,8 +88,8 @@ public class ReadySign extends DSign {
@Override @Override
public void onInit() { public void onInit() {
if (plugin.getGameTypes().getBySign(this) != null) { if (DungeonsXL.getGameTypes().getBySign(this) != null) {
gameType = plugin.getGameTypes().getBySign(this); gameType = DungeonsXL.getGameTypes().getBySign(this);
} else { } else {
gameType = GameTypeDefault.CUSTOM; gameType = GameTypeDefault.CUSTOM;
@ -131,7 +129,7 @@ public class ReadySign extends DSign {
public void run() { public void run() {
onTrigger(); onTrigger();
} }
}.runTaskLater(plugin, (long) (autoStart * 20)); }.runTaskLater(DungeonsXL.getInstance(), (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));
@ -170,7 +168,7 @@ public class ReadySign extends DSign {
} }
if (dPlayer.isReady()) { if (dPlayer.isReady()) {
MessageUtil.sendMessage(dPlayer.getPlayer(), plugin.getMessageConfig().getMessage(dPlayer.isReady() ? DMessages.PLAYER_READY : DMessages.ERROR_READY)); MessageUtil.sendMessage(dPlayer.getPlayer(), DungeonsXL.getMessageConfig().getMessage(dPlayer.isReady() ? DMessages.PLAYER_READY : DMessages.ERROR_READY));
} }
} }

View File

@ -39,8 +39,6 @@ import org.bukkit.scheduler.BukkitTask;
*/ */
public class ExternalMobSign extends DSign implements MobSign { public class ExternalMobSign extends DSign implements MobSign {
DungeonsXL plugin = DungeonsXL.getInstance();
private DSignType type = DSignTypeDefault.EXTERNAL_MOB; private DSignType type = DSignTypeDefault.EXTERNAL_MOB;
// Variables // Variables
@ -143,7 +141,7 @@ public class ExternalMobSign extends DSign implements MobSign {
@Override @Override
public void initializeTask() { public void initializeTask() {
task = new ExternalMobSpawnTask(this, provider).runTaskTimer(plugin, 0L, 20L); task = new ExternalMobSpawnTask(this, provider).runTaskTimer(DungeonsXL.getInstance(), 0L, 20L);
} }
/** /**
@ -230,7 +228,7 @@ public class ExternalMobSign extends DSign implements MobSign {
initialAmount = amount; initialAmount = amount;
if (attributes.length == 3) { if (attributes.length == 3) {
provider = plugin.getExternalMobProviders().getByIdentifier(attributes[2]); provider = DungeonsXL.getExternalMobProviders().getByIdentifier(attributes[2]);
} else { } else {
provider = ExternalMobPlugin.MYTHIC_MOBS; provider = ExternalMobPlugin.MYTHIC_MOBS;
} }

View File

@ -71,7 +71,7 @@ public class MobSpawnTask extends BukkitRunnable {
} }
// Check custom mobs // Check custom mobs
DMobType mobType = DungeonsXL.getInstance().getDMobTypes().getByName(sign.getMob()); DMobType mobType = DungeonsXL.getDMobTypes().getByName(sign.getMob());
if (mobType != null) { if (mobType != null) {
mobType.spawn(gameWorld, spawnLoc); mobType.spawn(gameWorld, spawnLoc);

View File

@ -18,6 +18,7 @@ package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent; import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -44,7 +45,7 @@ public class DistanceTrigger extends Trigger {
public void onTrigger(Player player) { public void onTrigger(Player player) {
TriggerActionEvent event = new TriggerActionEvent(this); TriggerActionEvent event = new TriggerActionEvent(this);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;

View File

@ -19,6 +19,7 @@ package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.commons.util.NumberUtil; import io.github.dre2n.commons.util.NumberUtil;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent; import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Bukkit;
/** /**
* @author Daniel Saukel * @author Daniel Saukel
@ -62,7 +63,7 @@ public class FortuneTrigger extends Trigger {
} }
TriggerActionEvent event = new TriggerActionEvent(this); TriggerActionEvent event = new TriggerActionEvent(this);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;

View File

@ -18,6 +18,7 @@ package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent; import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Bukkit;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -38,7 +39,7 @@ public class InteractTrigger extends Trigger {
public void onTrigger(Player player) { public void onTrigger(Player player) {
TriggerActionEvent event = new TriggerActionEvent(this); TriggerActionEvent event = new TriggerActionEvent(this);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;

View File

@ -18,6 +18,7 @@ package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent; import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Bukkit;
/** /**
* @author Frank Baumann, Daniel Saukel * @author Frank Baumann, Daniel Saukel
@ -34,7 +35,7 @@ public class MobTrigger extends Trigger {
public void onTrigger() { public void onTrigger() {
TriggerActionEvent event = new TriggerActionEvent(this); TriggerActionEvent event = new TriggerActionEvent(this);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;

View File

@ -16,11 +16,13 @@
*/ */
package io.github.dre2n.dungeonsxl.trigger; package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent; import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import io.github.dre2n.dungeonsxl.world.DResourceWorld; import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.bukkit.Bukkit;
/** /**
* @author Frank Baumann, Daniel Saukel * @author Frank Baumann, Daniel Saukel
@ -91,7 +93,7 @@ public class ProgressTrigger extends Trigger {
/* Actions */ /* Actions */
public void onTrigger() { public void onTrigger() {
TriggerActionEvent event = new TriggerActionEvent(this); TriggerActionEvent event = new TriggerActionEvent(this);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
@ -115,7 +117,7 @@ public class ProgressTrigger extends Trigger {
} }
public static ProgressTrigger getOrCreate(String floor, DGameWorld gameWorld) { public static ProgressTrigger getOrCreate(String floor, DGameWorld gameWorld) {
DResourceWorld resource = plugin.getDWorlds().getResourceByName(floor); DResourceWorld resource = DungeonsXL.getDWorlds().getResourceByName(floor);
if (resource != null) { if (resource != null) {
return new ProgressTrigger(resource); return new ProgressTrigger(resource);

View File

@ -18,6 +18,7 @@ package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent; import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -38,7 +39,7 @@ public class RedstoneTrigger extends Trigger {
public void onTrigger() { public void onTrigger() {
TriggerActionEvent event = new TriggerActionEvent(this); TriggerActionEvent event = new TriggerActionEvent(this);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;

View File

@ -18,6 +18,7 @@ package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent; import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Bukkit;
/** /**
* @author Frank Baumann, Daniel Saukel * @author Frank Baumann, Daniel Saukel
@ -34,7 +35,7 @@ public class SignTrigger extends Trigger {
public void onTrigger(boolean enable) { public void onTrigger(boolean enable) {
TriggerActionEvent event = new TriggerActionEvent(this); TriggerActionEvent event = new TriggerActionEvent(this);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;

View File

@ -26,6 +26,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** /**
@ -35,8 +36,6 @@ import org.bukkit.entity.Player;
*/ */
public abstract class Trigger { public abstract class Trigger {
static DungeonsXL plugin = DungeonsXL.getInstance();
private boolean triggered; private boolean triggered;
private Player player; // Holds Player for Player specific TriggerTypes private Player player; // Holds Player for Player specific TriggerTypes
@ -124,7 +123,7 @@ public abstract class Trigger {
} }
public static Trigger getOrCreate(String identifier, String value, DSign dSign) { public static Trigger getOrCreate(String identifier, String value, DSign dSign) {
TriggerType type = plugin.getTriggers().getByIdentifier(identifier); TriggerType type = DungeonsXL.getTriggers().getByIdentifier(identifier);
Trigger trigger = null; Trigger trigger = null;
if (type == TriggerTypeDefault.REDSTONE) { if (type == TriggerTypeDefault.REDSTONE) {
@ -205,7 +204,7 @@ public abstract class Trigger {
} }
TriggerRegistrationEvent event = new TriggerRegistrationEvent(trigger); TriggerRegistrationEvent event = new TriggerRegistrationEvent(trigger);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return null; return null;

View File

@ -33,7 +33,7 @@ public class TriggerListener implements Listener {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
for (DGameWorld gameWorld : DungeonsXL.getInstance().getDWorlds().getGameWorlds()) { for (DGameWorld gameWorld : DungeonsXL.getDWorlds().getGameWorlds()) {
if (event.getBlock().getWorld() == gameWorld.getWorld()) { if (event.getBlock().getWorld() == gameWorld.getWorld()) {
RedstoneTrigger.updateAll(gameWorld); RedstoneTrigger.updateAll(gameWorld);
} }

View File

@ -29,13 +29,11 @@ import org.bukkit.Bukkit;
*/ */
public class TriggerTypes { public class TriggerTypes {
DungeonsXL plugin = DungeonsXL.getInstance();
private List<TriggerType> types = new ArrayList<>(); private List<TriggerType> types = new ArrayList<>();
public TriggerTypes() { public TriggerTypes() {
types.addAll(Arrays.asList(TriggerTypeDefault.values())); types.addAll(Arrays.asList(TriggerTypeDefault.values()));
Bukkit.getPluginManager().registerEvents(new TriggerListener(), plugin); Bukkit.getPluginManager().registerEvents(new TriggerListener(), DungeonsXL.getInstance());
} }
/** /**

View File

@ -18,6 +18,7 @@ package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent; import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -41,7 +42,7 @@ public class UseItemTrigger extends Trigger {
public void onTrigger(Player player) { public void onTrigger(Player player) {
TriggerActionEvent event = new TriggerActionEvent(this); TriggerActionEvent event = new TriggerActionEvent(this);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;

View File

@ -20,6 +20,7 @@ import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.bukkit.Bukkit;
/** /**
* @author Frank Baumann, Daniel Saukel * @author Frank Baumann, Daniel Saukel
@ -51,7 +52,7 @@ public class WaveTrigger extends Trigger {
public void onTrigger() { public void onTrigger() {
TriggerActionEvent event = new TriggerActionEvent(this); TriggerActionEvent event = new TriggerActionEvent(this);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;

View File

@ -16,6 +16,7 @@
*/ */
package io.github.dre2n.dungeonsxl.util; package io.github.dre2n.dungeonsxl.util;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -38,7 +39,7 @@ public class NoReload implements Listener {
*/ */
public NoReload(Plugin plugin) { public NoReload(Plugin plugin) {
this.plugin = plugin; this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin); Bukkit.getPluginManager().registerEvents(this, plugin);
} }
@EventHandler @EventHandler

View File

@ -24,6 +24,7 @@ import io.github.dre2n.dungeonsxl.player.DEditPlayer;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
@ -38,7 +39,7 @@ import org.bukkit.scheduler.BukkitRunnable;
*/ */
public class DEditWorld extends DInstanceWorld { public class DEditWorld extends DInstanceWorld {
static DWorlds worlds = plugin.getDWorlds(); DWorlds worlds = DungeonsXL.getDWorlds();
public static String ID_FILE_PREFIX = ".id_"; public static String ID_FILE_PREFIX = ".id_";
@ -112,7 +113,7 @@ public class DEditWorld extends DInstanceWorld {
*/ */
public void save() { public void save() {
EditWorldSaveEvent event = new EditWorldSaveEvent(this); EditWorldSaveEvent event = new EditWorldSaveEvent(this);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
@ -120,7 +121,7 @@ public class DEditWorld extends DInstanceWorld {
getWorld().save(); getWorld().save();
if (!plugin.getMainConfig().areTweaksEnabled()) { if (!DungeonsXL.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());
@ -150,7 +151,7 @@ public class DEditWorld extends DInstanceWorld {
*/ */
public void delete(final boolean save) { public void delete(final boolean save) {
EditWorldUnloadEvent event = new EditWorldUnloadEvent(this, true); EditWorldUnloadEvent event = new EditWorldUnloadEvent(this, true);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
@ -161,14 +162,14 @@ public class DEditWorld extends DInstanceWorld {
dPlayer.leave(); dPlayer.leave();
} }
if (!plugin.getMainConfig().areTweaksEnabled()) { if (!DungeonsXL.getMainConfig().areTweaksEnabled()) {
if (save) { if (save) {
plugin.getServer().unloadWorld(getWorld(), true); Bukkit.unloadWorld(getWorld(), true);
} }
FileUtil.copyDirectory(getFolder(), getResource().getFolder(), DungeonsXL.EXCLUDED_FILES); FileUtil.copyDirectory(getFolder(), getResource().getFolder(), DungeonsXL.EXCLUDED_FILES);
FileUtil.deleteUnusedFiles(getResource().getFolder()); FileUtil.deleteUnusedFiles(getResource().getFolder());
if (!save) { if (!save) {
plugin.getServer().unloadWorld(getWorld(), true); Bukkit.unloadWorld(getWorld(), true);
} }
FileUtil.removeDirectory(getFolder()); FileUtil.removeDirectory(getFolder());
worlds.removeInstance(this); worlds.removeInstance(this);
@ -179,12 +180,12 @@ public class DEditWorld extends DInstanceWorld {
@Override @Override
public void run() { public void run() {
if (save) { if (save) {
plugin.getServer().unloadWorld(getWorld(), true); Bukkit.unloadWorld(getWorld(), true);
} }
FileUtil.copyDirectory(getFolder(), getResource().getFolder(), DungeonsXL.EXCLUDED_FILES); FileUtil.copyDirectory(getFolder(), getResource().getFolder(), DungeonsXL.EXCLUDED_FILES);
FileUtil.deleteUnusedFiles(getResource().getFolder()); FileUtil.deleteUnusedFiles(getResource().getFolder());
if (!save) { if (!save) {
plugin.getServer().unloadWorld(getWorld(), true); Bukkit.unloadWorld(getWorld(), true);
} }
FileUtil.removeDirectory(getFolder()); FileUtil.removeDirectory(getFolder());
worlds.removeInstance(editWorld); worlds.removeInstance(editWorld);
@ -211,7 +212,7 @@ public class DEditWorld extends DInstanceWorld {
* the DEditWorld that represents the world * the DEditWorld that represents the world
*/ */
public static DEditWorld getByName(String name) { public static DEditWorld getByName(String name) {
DInstanceWorld instance = worlds.getInstanceByName(name); DInstanceWorld instance = DungeonsXL.getDWorlds().getInstanceByName(name);
if (instance instanceof DEditWorld) { if (instance instanceof DEditWorld) {
return (DEditWorld) instance; return (DEditWorld) instance;

View File

@ -17,6 +17,7 @@
package io.github.dre2n.dungeonsxl.world; package io.github.dre2n.dungeonsxl.world;
import io.github.dre2n.commons.util.FileUtil; import io.github.dre2n.commons.util.FileUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon; import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldStartGameEvent; import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldStartGameEvent;
import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldUnloadEvent; import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldUnloadEvent;
@ -50,6 +51,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -117,7 +119,7 @@ public class DGameWorld extends DInstanceWorld {
*/ */
public Game getGame() { public Game getGame() {
if (game == null) { if (game == null) {
for (Game game : plugin.getGames()) { for (Game game : DungeonsXL.getGames()) {
if (game.getWorld() == this) { if (game.getWorld() == this) {
this.game = game; this.game = game;
} }
@ -432,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 : plugin.getDungeons().getDungeons()) { for (Dungeon dungeon : DungeonsXL.getDungeons().getDungeons()) {
if (dungeon.getConfig().containsFloor(getResource())) { if (dungeon.getConfig().containsFloor(getResource())) {
return dungeon; return dungeon;
} }
@ -446,7 +448,7 @@ public class DGameWorld extends DInstanceWorld {
*/ */
public void startGame() { public void startGame() {
GameWorldStartGameEvent event = new GameWorldStartGameEvent(this, getGame()); GameWorldStartGameEvent event = new GameWorldStartGameEvent(this, getGame());
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
@ -485,14 +487,14 @@ public class DGameWorld extends DInstanceWorld {
@Override @Override
public void delete() { public void delete() {
GameWorldUnloadEvent event = new GameWorldUnloadEvent(this); GameWorldUnloadEvent event = new GameWorldUnloadEvent(this);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
} }
if (!plugin.getMainConfig().areTweaksEnabled()) { if (!DungeonsXL.getMainConfig().areTweaksEnabled()) {
plugin.getServer().unloadWorld(getWorld(), false); Bukkit.unloadWorld(getWorld(), false);
FileUtil.removeDirectory(getFolder()); FileUtil.removeDirectory(getFolder());
worlds.removeInstance(this); worlds.removeInstance(this);
@ -501,7 +503,7 @@ public class DGameWorld extends DInstanceWorld {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
plugin.getServer().unloadWorld(getWorld(), false); Bukkit.unloadWorld(getWorld(), false);
FileUtil.removeDirectory(getFolder()); FileUtil.removeDirectory(getFolder());
worlds.removeInstance(gameWorld); worlds.removeInstance(gameWorld);
} }
@ -650,7 +652,7 @@ public class DGameWorld extends DInstanceWorld {
* the EditWorld that represents the world * the EditWorld that represents the world
*/ */
public static DGameWorld getByWorld(World world) { public static DGameWorld getByWorld(World world) {
DInstanceWorld instance = plugin.getDWorlds().getInstanceByName(world.getName()); DInstanceWorld instance = DungeonsXL.getDWorlds().getInstanceByName(world.getName());
if (instance instanceof DGameWorld) { if (instance instanceof DGameWorld) {
return (DGameWorld) instance; return (DGameWorld) instance;

View File

@ -30,8 +30,8 @@ import org.bukkit.World;
*/ */
public abstract class DInstanceWorld { public abstract class DInstanceWorld {
protected static DungeonsXL plugin = DungeonsXL.getInstance(); DungeonsXL plugin = DungeonsXL.getInstance();
protected static DWorlds worlds = plugin.getDWorlds(); DWorlds worlds = DungeonsXL.getDWorlds();
private DResourceWorld resourceWorld; private DResourceWorld resourceWorld;
private File folder; private File folder;

View File

@ -212,9 +212,9 @@ 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 (!plugin.getMainConfig().areTweaksEnabled()) { if (!DungeonsXL.getMainConfig().areTweaksEnabled()) {
FileUtil.copyDirectory(folder, instanceFolder, DungeonsXL.EXCLUDED_FILES); FileUtil.copyDirectory(folder, instanceFolder, DungeonsXL.EXCLUDED_FILES);
instance.world = plugin.getServer().createWorld(WorldCreator.name(name)); instance.world = Bukkit.createWorld(WorldCreator.name(name));
if (game) { if (game) {
signData.deserializeSigns((DGameWorld) instance); signData.deserializeSigns((DGameWorld) instance);
@ -282,12 +282,12 @@ public class DResourceWorld {
final DEditWorld editWorld = new DEditWorld(this, folder, id); final DEditWorld editWorld = new DEditWorld(this, folder, id);
EditWorldGenerateEvent event = new EditWorldGenerateEvent(editWorld); EditWorldGenerateEvent event = new EditWorldGenerateEvent(editWorld);
plugin.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return null; return null;
} }
if (!plugin.getMainConfig().areTweaksEnabled()) { if (!DungeonsXL.getMainConfig().areTweaksEnabled()) {
editWorld.world = creator.createWorld(); editWorld.world = creator.createWorld();
} else { } else {

Some files were not shown because too many files have changed in this diff Show More