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
*/
public GlobalData getGlobalData() {
return globalData;
public static GlobalData getGlobalData() {
return instance.globalData;
}
/**
@ -293,8 +293,8 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the loaded instance of MainConfig
*/
public MainConfig getMainConfig() {
return mainConfig;
public static MainConfig getMainConfig() {
return instance.mainConfig;
}
/**
@ -307,8 +307,8 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the loaded instance of MessageConfig
*/
public MessageConfig getMessageConfig() {
return messageConfig;
public static MessageConfig getMessageConfig() {
return instance.messageConfig;
}
/**
@ -337,8 +337,8 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the dSigns
*/
public DSignTypes getDSigns() {
return dSigns;
public static DSignTypes getDSigns() {
return instance.dSigns;
}
/**
@ -351,8 +351,8 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the game types
*/
public GameTypes getGameTypes() {
return gameTypes;
public static GameTypes getGameTypes() {
return instance.gameTypes;
}
/**
@ -365,8 +365,8 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the requirement types
*/
public RequirementTypes getRequirementTypes() {
return requirementTypes;
public static RequirementTypes getRequirementTypes() {
return instance.requirementTypes;
}
/**
@ -379,8 +379,8 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the reward types
*/
public RewardTypes getRewardTypes() {
return rewardTypes;
public static RewardTypes getRewardTypes() {
return instance.rewardTypes;
}
/**
@ -393,8 +393,8 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the triggers
*/
public TriggerTypes getTriggers() {
return triggers;
public static TriggerTypes getTriggers() {
return instance.triggers;
}
/**
@ -407,8 +407,8 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the loaded instance of Dungeons
*/
public Dungeons getDungeons() {
return dungeons;
public static Dungeons getDungeons() {
return instance.dungeons;
}
/**
@ -421,8 +421,8 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the loaded instance of GlobalProtections
*/
public GlobalProtections getGlobalProtections() {
return protections;
public static GlobalProtections getGlobalProtections() {
return instance.protections;
}
/**
@ -435,8 +435,8 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the loaded instance of ExternalMobProviders
*/
public ExternalMobProviders getExternalMobProviders() {
return dMobProviders;
public static ExternalMobProviders getExternalMobProviders() {
return instance.dMobProviders;
}
/**
@ -449,8 +449,8 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the loaded instance of DPlayers
*/
public DPlayers getDPlayers() {
return dPlayers;
public static DPlayers getDPlayers() {
return instance.dPlayers;
}
/**
@ -463,8 +463,8 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the loaded instance of Announcers
*/
public Announcers getAnnouncers() {
return announcers;
public static Announcers getAnnouncers() {
return instance.announcers;
}
/**
@ -477,8 +477,8 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the loaded instance of DClasses
*/
public DClasses getDClasses() {
return dClasses;
public static DClasses getDClasses() {
return instance.dClasses;
}
/**
@ -491,8 +491,8 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the loaded instance of DLootTables
*/
public DLootTables getDLootTables() {
return dLootTables;
public static DLootTables getDLootTables() {
return instance.dLootTables;
}
/**
@ -505,8 +505,8 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the loaded instance of DMobTypes
*/
public DMobTypes getDMobTypes() {
return dMobTypes;
public static DMobTypes getDMobTypes() {
return instance.dMobTypes;
}
/**
@ -519,8 +519,8 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the loaded instance of SignScripts
*/
public SignScripts getSignScripts() {
return signScripts;
public static SignScripts getSignScripts() {
return instance.signScripts;
}
/**
@ -533,8 +533,8 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the loaded instance of DWorlds
*/
public DWorlds getDWorlds() {
return dWorlds;
public static DWorlds getDWorlds() {
return instance.dWorlds;
}
/**
@ -547,22 +547,22 @@ public class DungeonsXL extends BRPlugin {
/**
* @return the dLootInventories
*/
public List<DLootInventory> getDLootInventories() {
return dLootInventories;
public static List<DLootInventory> getDLootInventories() {
return instance.dLootInventories;
}
/**
* @return the games
*/
public List<Game> getGames() {
return games;
public static List<Game> getGames() {
return instance.games;
}
/**
* @return the dGroups
*/
public List<DGroup> getDGroups() {
return dGroups;
public static List<DGroup> getDGroups() {
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.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
@ -95,7 +96,7 @@ public class Announcer {
if (multiFloor) {
dungeonName = identifier;
Dungeon dungeon = plugin.getDungeons().getByName(identifier);
Dungeon dungeon = DungeonsXL.getDungeons().getByName(identifier);
if (dungeon != null) {
mapName = dungeon.getConfig().getStartFloor().getName();
}
@ -136,7 +137,7 @@ public class Announcer {
if (multiFloor) {
dungeonName = identifier;
Dungeon dungeon = plugin.getDungeons().getByName(identifier);
Dungeon dungeon = DungeonsXL.getDungeons().getByName(identifier);
if (dungeon != null) {
mapName = dungeon.getConfig().getStartFloor().getName();
}
@ -384,7 +385,7 @@ public class Announcer {
} else if (dGroup == null && pGroup == null) {
DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.ANNOUNCER);
plugin.getServer().getPluginManager().callEvent(event);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
dGroups.set(buttons.indexOf(button), new DGroup(player));
}
@ -422,7 +423,7 @@ public class Announcer {
List<String> lore = new ArrayList<>();
DGroup dGroup = dGroups.get(groupCount);
if (!plugin.getDGroups().contains(dGroup)) {
if (!DungeonsXL.getDGroups().contains(dGroup)) {
dGroups.set(groupCount, null);
} else if (dGroup != null) {
@ -435,7 +436,7 @@ public class Announcer {
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();
meta.setDisplayName(name + (full ? ChatColor.DARK_RED : ChatColor.GREEN) + " [" + playerCount + "/" + maxPlayersPerGroup + "]");
meta.setLore(lore);

View File

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

View File

@ -30,8 +30,6 @@ import org.bukkit.scheduler.BukkitRunnable;
*/
public class AnnouncerStartGameTask extends BukkitRunnable {
DungeonsXL plugin = DungeonsXL.getInstance();
private Announcer announcer;
private ProgressBar bar;
@ -48,7 +46,7 @@ public class AnnouncerStartGameTask extends BukkitRunnable {
}
}
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) {
game = new Game(dGroup, plugin.getDWorlds().getResourceByName(announcer.getMapName()));
game = new Game(dGroup, DungeonsXL.getDWorlds().getResourceByName(announcer.getMapName()));
} else {
game.getDGroups().add(dGroup);
}

View File

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

View File

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

View File

@ -30,8 +30,6 @@ import org.bukkit.entity.Player;
*/
public class BreakCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public BreakCommand() {
setCommand("break");
setMinArgs(0);
@ -44,7 +42,7 @@ public class BreakCommand extends BRCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender;
DGlobalPlayer dGlobalPlayer = plugin.getDPlayers().getByPlayer(player);
DGlobalPlayer dGlobalPlayer = DungeonsXL.getDPlayers().getByPlayer(player);
if (dGlobalPlayer.isInBreakMode()) {
dGlobalPlayer.setInBreakMode(false);

View File

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

View File

@ -30,8 +30,6 @@ import org.bukkit.entity.Player;
*/
public class ChatSpyCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public ChatSpyCommand() {
setCommand("chatspy");
setMinArgs(0);
@ -44,7 +42,7 @@ public class ChatSpyCommand extends BRCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender;
DGlobalPlayer dGlobalPlayer = plugin.getDPlayers().getByPlayer(player);
DGlobalPlayer dGlobalPlayer = DungeonsXL.getDPlayers().getByPlayer(player);
if (dGlobalPlayer.isInChatSpyMode()) {
dGlobalPlayer.setInChatSpyMode(false);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,8 +31,6 @@ import org.bukkit.command.CommandSender;
*/
public class InviteCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public InviteCommand() {
setMinArgs(2);
setMaxArgs(2);
@ -45,7 +43,7 @@ public class InviteCommand extends BRCommand {
@Override
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]);
if (resource != null) {

View File

@ -32,8 +32,6 @@ import org.bukkit.entity.Player;
*/
public class JoinCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public JoinCommand() {
setCommand("join");
setMinArgs(1);
@ -45,13 +43,13 @@ public class JoinCommand extends BRCommand {
@Override
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) {
MessageUtil.sendMessage(sender, DMessages.ERROR_LEAVE_GAME.getMessage());
return;
}
Announcer announcer = plugin.getAnnouncers().getByName(args[1]);
Announcer announcer = DungeonsXL.getAnnouncers().getByName(args[1]);
if (announcer != null) {
announcer.showGUI((Player) sender);
}

View File

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

View File

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

View File

@ -33,8 +33,6 @@ import org.bukkit.plugin.PluginManager;
*/
public class MainCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public MainCommand() {
setCommand("main");
setHelp(DMessages.HELP_CMD_MAIN.getMessage());
@ -49,8 +47,8 @@ public class MainCommand extends BRCommand {
int maps = DungeonsXL.MAPS.listFiles().length;
int dungeons = DungeonsXL.DUNGEONS.listFiles().length;
int loaded = plugin.getDWorlds().getEditWorlds().size() + plugin.getDWorlds().getGameWorlds().size();
int players = plugin.getDPlayers().getDGamePlayers().size();
int loaded = DungeonsXL.getDWorlds().getEditWorlds().size() + DungeonsXL.getDWorlds().getGameWorlds().size();
int players = DungeonsXL.getDPlayers().getDGamePlayers().size();
Internals internals = CompatibilityHandler.getInstance().getInternals();
String vault = "";
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[3] + "&f" + X[3] + L[3]);
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_COMPATIBILITY.getMessage(String.valueOf(internals), vault, itemsxl));
MessageUtil.sendCenteredMessage(sender, DMessages.CMD_MAIN_HELP.getMessage());

View File

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

View File

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

View File

@ -53,7 +53,7 @@ public class ReloadCommand extends BRCommand {
@Override
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) {
MessageUtil.sendMessage(sender, DMessages.CMD_RELOAD_PLAYERS.getMessage());
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 dungeons = DungeonsXL.DUNGEONS.listFiles().length;
int loaded = plugin.getDWorlds().getEditWorlds().size() + plugin.getDWorlds().getGameWorlds().size();
int players = plugin.getDPlayers().getDGamePlayers().size();
int loaded = DungeonsXL.getDWorlds().getEditWorlds().size() + DungeonsXL.getDWorlds().getGameWorlds().size();
int players = DungeonsXL.getDPlayers().getDGamePlayers().size();
Internals internals = CompatibilityHandler.getInstance().getInternals();
String vault = "";
if (plugins.getPlugin("Vault") != null) {
@ -90,11 +90,9 @@ public class ReloadCommand extends BRCommand {
mythicMobs = plugins.getPlugin("MythicMobs").getDescription().getVersion();
}
// Save
plugin.saveData();
plugin.getMessageConfig().save();
plugin.onDisable();
plugin.loadCore();
plugin.loadData();
MessageUtil.sendPluginTag(sender, plugin);
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 {
DungeonsXL plugin = DungeonsXL.getInstance();
public RenameCommand() {
setCommand("rename");
setMinArgs(2);
@ -52,7 +50,7 @@ public class RenameCommand extends BRCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[1]);
DResourceWorld resource = DungeonsXL.getDWorlds().getResourceByName(args[1]);
if (resource == null) {
MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_MAP.getMessage(args[1]));
return;
@ -62,7 +60,7 @@ public class RenameCommand extends BRCommand {
resource.getFolder().renameTo(new File(DungeonsXL.MAPS, args[2]));
resource.getSignData().updateFile(resource);
for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
for (Dungeon dungeon : DungeonsXL.getDungeons().getDungeons()) {
DungeonConfig dConfig = dungeon.getConfig();
FileConfiguration config = dConfig.getConfig();
File file = dConfig.getFile();
@ -92,7 +90,7 @@ public class RenameCommand extends BRCommand {
}
boolean changed = false;
for (GlobalProtection protection : plugin.getGlobalProtections().getProtections()) {
for (GlobalProtection protection : DungeonsXL.getGlobalProtections().getProtections()) {
if (protection instanceof GroupSign) {
Dungeon dungeon = ((GroupSign) protection).getDungeon();
if (dungeon.getName().equals(args[1])) {
@ -110,7 +108,7 @@ public class RenameCommand extends BRCommand {
}
if (changed) {
plugin.getGlobalProtections().saveAll();
DungeonsXL.getGlobalProtections().saveAll();
}
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 {
DungeonsXL plugin = DungeonsXL.getInstance();
public ResourcePackCommand() {
setCommand("resourcepack");
setMinArgs(1);
@ -51,7 +49,7 @@ public class ResourcePackCommand extends BRCommand {
return;
}
String url = (String) plugin.getMainConfig().getResourcePacks().get(args[1]);
String url = (String) DungeonsXL.getMainConfig().getResourcePacks().get(args[1]);
if (url == null) {
MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_RESOURCE_PACK.getMessage(args[1]));
return;

View File

@ -33,8 +33,6 @@ import org.bukkit.inventory.ItemStack;
*/
public class RewardsCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public RewardsCommand() {
setCommand("rewards");
setMinArgs(0);
@ -47,7 +45,7 @@ public class RewardsCommand extends BRCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender;
DGlobalPlayer dGlobalPlayer = plugin.getDPlayers().getByPlayer(player);
DGlobalPlayer dGlobalPlayer = DungeonsXL.getDPlayers().getByPlayer(player);
if (!dGlobalPlayer.hasRewardItemsLeft()) {
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 {
DungeonsXL plugin = DungeonsXL.getInstance();
MainConfig mainConfig = plugin.getMainConfig();
MainConfig mainConfig = DungeonsXL.getMainConfig();
public SaveCommand() {
setCommand("save");

View File

@ -117,7 +117,7 @@ public class StatusCommand extends BRCommand {
String vaultVersionCorrect = getSymbol(vaultVersion.startsWith("1.5"));
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 itemsxlVersionCorrect = getSymbol(itemsxlVersion.startsWith("0.2"));
String citizensVersionCorrect = getSymbol(citizensVersion.startsWith("2.0"));

View File

@ -38,8 +38,6 @@ import org.bukkit.entity.Player;
*/
public class TestCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
public TestCommand() {
setCommand("test");
setMinArgs(0);
@ -53,7 +51,7 @@ public class TestCommand extends BRCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender;
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player);
DGlobalPlayer dPlayer = DungeonsXL.getDPlayers().getByPlayer(player);
if (!(dPlayer instanceof DEditPlayer)) {
DGroup dGroup = DGroup.getByPlayer(player);

View File

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

View File

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

View File

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

View File

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

View File

@ -31,7 +31,7 @@ public class DEditPlayerEscapeEvent extends DEditPlayerEvent implements Cancella
public DEditPlayerEscapeEvent(DEditPlayer dPlayer) {
super(dPlayer);
}
@Override
public HandlerList getHandlers() {
return handlers;

View File

@ -48,8 +48,6 @@ import org.bukkit.scheduler.BukkitRunnable;
*/
public class Game {
DungeonsXL plugin = DungeonsXL.getInstance();
private boolean tutorial;
private List<DGroup> dGroups = new ArrayList<>();
private boolean started;
@ -61,7 +59,7 @@ public class Game {
private Map<String, Integer> waveKills = new HashMap<>();
public Game(DGroup dGroup) {
plugin.getGames().add(this);
DungeonsXL.getGames().add(this);
tutorial = false;
started = false;
@ -75,7 +73,7 @@ public class Game {
}
public Game(DGroup dGroup, DGameWorld world) {
plugin.getGames().add(this);
DungeonsXL.getGames().add(this);
tutorial = false;
started = false;
@ -90,7 +88,7 @@ public class Game {
}
public Game(DGroup dGroup, DResourceWorld resource) {
plugin.getGames().add(this);
DungeonsXL.getGames().add(this);
tutorial = false;
started = false;
@ -110,7 +108,7 @@ public class Game {
}
public Game(List<DGroup> dGroups, GameType type, DGameWorld world) {
plugin.getGames().add(this);
DungeonsXL.getGames().add(this);
this.dGroups = dGroups;
this.type = type;
@ -271,7 +269,7 @@ public class Game {
finalRules.apply(dungeonConfig.getDefaultValues());
}
finalRules.apply(plugin.getMainConfig().getDefaultWorldConfig());
finalRules.apply(DungeonsXL.getMainConfig().getDefaultWorldConfig());
finalRules.apply(GameRules.DEFAULT_VALUES);
@ -398,7 +396,7 @@ public class Game {
public void delete() {
GameSign gameSign = GameSign.getByGame(this);
plugin.getGames().remove(this);
DungeonsXL.getGames().remove(this);
if (gameSign != null) {
gameSign.update();
@ -447,7 +445,7 @@ public class Game {
mobSign.initializeTask();
}
}
}.runTaskLater(plugin, delay * 20);
}.runTaskLater(DungeonsXL.getInstance(), delay * 20);
}
/**
@ -461,7 +459,7 @@ public class Game {
/* Statics */
public static Game getByDGroup(DGroup dGroup) {
for (Game game : DungeonsXL.getInstance().getGames()) {
for (Game game : DungeonsXL.getGames()) {
if (game.getDGroups().contains(dGroup)) {
return game;
}
@ -475,7 +473,7 @@ public class Game {
}
public static Game getByGameWorld(DGameWorld gameWorld) {
for (Game game : DungeonsXL.getInstance().getGames()) {
for (Game game : DungeonsXL.getGames()) {
if (gameWorld.equals(game.getWorld())) {
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.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
@ -181,7 +182,7 @@ public class DPortal extends GlobalProtection {
DGroup dGroup = DGroup.getByPlayer(player);
if (dGroup == null) {
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.ERROR_JOIN_GROUP));
MessageUtil.sendMessage(player, DungeonsXL.getMessageConfig().getMessage(DMessages.ERROR_JOIN_GROUP));
return;
}
@ -325,7 +326,7 @@ public class DPortal extends GlobalProtection {
* a block covered by the returned portal
*/
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;
if (portal.getBlock1() == null || portal.getBlock2() == null) {
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.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.game.Game;
@ -61,9 +62,9 @@ public class GameSign extends GlobalProtection {
this.startSign = startSign;
games = new Game[maxGames];
dungeon = plugin.getDungeons().getByName(identifier);
dungeon = DungeonsXL.getDungeons().getByName(identifier);
if (dungeon == null) {
DResourceWorld resource = plugin.getDWorlds().getResourceByName(identifier);
DResourceWorld resource = DungeonsXL.getDWorlds().getResourceByName(identifier);
if (resource != null) {
dungeon = new Dungeon(resource);
}
@ -246,7 +247,7 @@ public class GameSign extends GlobalProtection {
}
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;
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
*/
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;
for (Game signGame : gameSign.games) {
@ -413,7 +414,7 @@ public class GameSign extends GlobalProtection {
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;
}
@ -427,7 +428,7 @@ public class GameSign extends GlobalProtection {
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());
return true;
}
@ -435,17 +436,17 @@ public class GameSign extends GlobalProtection {
DGroup dGroup = DGroup.getByPlayer(player);
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;
}
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;
}
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;
}

View File

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

View File

@ -43,8 +43,6 @@ import org.bukkit.event.player.PlayerPortalEvent;
*/
public class GlobalProtectionListener implements Listener {
DungeonsXL plugin = DungeonsXL.getInstance();
@EventHandler
public void onBlockBreakWithSignOnIt(BlockBreakEvent event) {
Block block = event.getBlock();
@ -73,9 +71,9 @@ public class GlobalProtectionListener implements Listener {
public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
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.onBreak(dGlobalPlayer)) {
event.setCancelled(true);
@ -101,7 +99,7 @@ public class GlobalProtectionListener implements Listener {
public void onEntityExplode(EntityExplodeEvent event) {
List<Block> blocklist = event.blockList();
for (Block block : blocklist) {
if (DungeonsXL.getInstance().getGlobalProtections().isProtectedBlock(block)) {
if (DungeonsXL.getGlobalProtections().isProtectedBlock(block)) {
event.setCancelled(true);
}
}
@ -141,7 +139,7 @@ public class GlobalProtectionListener implements Listener {
@EventHandler
public void onInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (plugin.getDPlayers().getByPlayer(player).isInBreakMode()) {
if (DungeonsXL.getDPlayers().getByPlayer(player).isInBreakMode()) {
return;
}
Block clickedBlock = event.getClickedBlock();
@ -210,7 +208,7 @@ public class GlobalProtectionListener implements Listener {
} else if (lines[1].equalsIgnoreCase("Leave")) {
if (block.getState() instanceof Sign) {
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);

View File

@ -34,12 +34,10 @@ import org.bukkit.configuration.file.YamlConfiguration;
*/
public class GlobalProtections {
DungeonsXL plugin = DungeonsXL.getInstance();
private Set<GlobalProtection> protections = new HashSet<>();
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
*/
public void saveAll() {
saveAll(plugin.getGlobalData().getConfig());
saveAll(DungeonsXL.getGlobalData().getConfig());
}
/**
@ -124,7 +122,7 @@ public class GlobalProtections {
protection.save(config);
}
plugin.getGlobalData().save();
DungeonsXL.getGlobalData().save();
}
/**
@ -161,9 +159,9 @@ public class GlobalProtections {
/* SUBJECT TO CHANGE */
@Deprecated
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
if (data.contains("protections.gameSigns." + world.getName())) {
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.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.player.DGroup;
@ -60,9 +61,9 @@ public class GroupSign extends GlobalProtection {
this.startSign = startSign;
dGroups = new DGroup[maxGroups];
dungeon = plugin.getDungeons().getByName(identifier);
dungeon = DungeonsXL.getDungeons().getByName(identifier);
if (dungeon == null) {
DResourceWorld resource = plugin.getDWorlds().getResourceByName(identifier);
DResourceWorld resource = DungeonsXL.getDWorlds().getResourceByName(identifier);
if (resource != null) {
dungeon = new Dungeon(resource);
}
@ -245,7 +246,7 @@ public class GroupSign extends GlobalProtection {
}
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;
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);
}
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;
}
@ -409,7 +410,7 @@ public class GroupSign extends GlobalProtection {
}
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;
}
@ -445,7 +446,7 @@ public class GroupSign extends GlobalProtection {
@Deprecated
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;
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.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
@ -73,18 +74,14 @@ public class LeaveSign extends GlobalProtection {
if (dplayer != null) {
dplayer.leave();
return;
} else {
DGroup group = DGroup.getByPlayer(player);
if (group != null) {
group.removePlayer(player);
MessageUtil.sendMessage(player, DMessages.PLAYER_LEAVE_GROUP.getMessage());
return;
}
}
return;
}
@Override
@ -101,7 +98,7 @@ public class LeaveSign extends GlobalProtection {
* a block which is protected by the returned LeaveSign
*/
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;
if (leaveSign.getBlocks().contains(block)) {

View File

@ -47,7 +47,7 @@ public class ExternalMobProviders {
}
// 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));
}
}

View File

@ -35,7 +35,6 @@ import org.bukkit.inventory.ItemStack;
*/
public class DClass {
DungeonsXL plugin = DungeonsXL.getInstance();
CompatibilityHandler compat = CompatibilityHandler.getInstance();
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.playerutil.PlayerUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.event.dplayer.instance.DInstancePlayerUpdateEvent;
import io.github.dre2n.dungeonsxl.world.DEditWorld;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -65,7 +67,7 @@ public class DEditPlayer extends DInstancePlayer {
// Permission bridge
if (plugin.getPermissionProvider() != null) {
for (String permission : plugin.getMainConfig().getEditPermissions()) {
for (String permission : DungeonsXL.getMainConfig().getEditPermissions()) {
plugin.getPermissionProvider().playerAddTransient(world.getName(), player, permission);
}
}
@ -78,7 +80,7 @@ public class DEditPlayer extends DInstancePlayer {
* the player's 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 */
@ -109,7 +111,7 @@ public class DEditPlayer extends DInstancePlayer {
public void delete() {
// Permission bridge
if (plugin.getPermissionProvider() != null) {
for (String permission : plugin.getMainConfig().getEditPermissions()) {
for (String permission : DungeonsXL.getMainConfig().getEditPermissions()) {
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 (linesCopy != null) {
SignChangeEvent event = new SignChangeEvent(block, getPlayer(), linesCopy);
plugin.getServer().getPluginManager().callEvent(event);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
sign.setLine(0, event.getLine(0));
sign.setLine(1, event.getLine(1));
@ -171,7 +173,7 @@ public class DEditPlayer extends DInstancePlayer {
DEditWorld editWorld = DEditWorld.getByWorld(getWorld());
editWorld.sendMessage(message);
for (DGlobalPlayer player : plugin.getDPlayers().getDGlobalPlayers()) {
for (DGlobalPlayer player : DungeonsXL.getDPlayers().getDGlobalPlayers()) {
if (player.isInChatSpyMode()) {
if (!editWorld.getWorld().getPlayers().contains(player.getPlayer())) {
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);
plugin.getServer().getPluginManager().callEvent(event);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
@ -213,7 +215,7 @@ public class DEditPlayer extends DInstancePlayer {
/* Statics */
public static DEditPlayer getByPlayer(Player player) {
for (DEditPlayer dPlayer : plugin.getDPlayers().getDEditPlayers()) {
for (DEditPlayer dPlayer : DungeonsXL.getDPlayers().getDEditPlayers()) {
if (dPlayer.getPlayer().equals(player)) {
return dPlayer;
}
@ -222,7 +224,7 @@ public class DEditPlayer extends DInstancePlayer {
}
public static DEditPlayer getByName(String name) {
for (DEditPlayer dPlayer : plugin.getDPlayers().getDEditPlayers()) {
for (DEditPlayer dPlayer : DungeonsXL.getDPlayers().getDEditPlayers()) {
if (dPlayer.getName().equalsIgnoreCase(name)) {
return dPlayer;
}
@ -233,7 +235,7 @@ public class DEditPlayer extends DInstancePlayer {
public static CopyOnWriteArrayList<DEditPlayer> getByWorld(World world) {
CopyOnWriteArrayList<DEditPlayer> dPlayers = new CopyOnWriteArrayList<>();
for (DEditPlayer dPlayer : plugin.getDPlayers().getDEditPlayers()) {
for (DEditPlayer dPlayer : DungeonsXL.getDPlayers().getDEditPlayers()) {
if (dPlayer.getWorld() == world) {
dPlayers.add(dPlayer);
}

View File

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

View File

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

View File

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

View File

@ -16,6 +16,7 @@
*/
package io.github.dre2n.dungeonsxl.player;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
@ -100,7 +101,7 @@ public abstract class DInstancePlayer extends DGlobalPlayer {
new DGlobalPlayer(this);
} 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.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -44,7 +45,6 @@ import org.bukkit.potion.PotionEffect;
*/
public class DPlayerData extends BRConfig {
DungeonsXL plugin = DungeonsXL.getInstance();
boolean is1_9 = Internals.andHigher(Internals.v1_9_R1).contains(CompatibilityHandler.getInstance().getInternals());
public static final int CONFIG_VERSION = 2;
@ -317,7 +317,7 @@ public class DPlayerData extends BRConfig {
if (!file.exists()) {
try {
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) {
}
}
@ -357,7 +357,7 @@ public class DPlayerData extends BRConfig {
oldLocation = (Location) config.get(PREFIX_STATE_PERSISTENCE + "oldLocation");
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.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
@ -60,10 +61,15 @@ import org.bukkit.inventory.meta.BookMeta;
/**
* @author Daniel Saukel, Frank Baumann, Milan Albrecht
*/
public class DPlayerListener {
public class DPlayerListener implements Listener {
DungeonsXL plugin = DungeonsXL.getInstance();
DPlayers dPlayers = plugin.getDPlayers();
DungeonsXL plugin;
DPlayers dPlayers;
public DPlayerListener(DPlayers dPlayers) {
this.plugin = DungeonsXL.getInstance();
this.dPlayers = dPlayers;
}
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
@ -247,7 +253,7 @@ public class DPlayerListener {
return;
} else {
commandWhitelist.addAll(plugin.getMainConfig().getEditCommandWhitelist());
commandWhitelist.addAll(DungeonsXL.getMainConfig().getEditCommandWhitelist());
}
} else if (game != null) {
@ -298,7 +304,7 @@ public class DPlayerListener {
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);
}
@ -346,7 +352,7 @@ public class DPlayerListener {
return;
}
if (!plugin.getMainConfig().isTutorialActivated()) {
if (!DungeonsXL.getMainConfig().isTutorialActivated()) {
return;
}
@ -360,7 +366,7 @@ public class DPlayerListener {
@EventHandler(ignoreCancelled = true)
public void onPlayerLogin(PlayerLoginEvent event) {
Player player = event.getPlayer();
MainConfig config = plugin.getMainConfig();
MainConfig config = DungeonsXL.getMainConfig();
if (!config.isTutorialActivated()) {
return;
@ -383,7 +389,7 @@ public class DPlayerListener {
continue;
}
if (plugin.getDWorlds().getGameWorlds().size() >= config.getMaxInstances()) {
if (DungeonsXL.getDWorlds().getGameWorlds().size() >= config.getMaxInstances()) {
event.setResult(PlayerLoginEvent.Result.KICK_FULL);
event.setKickMessage(DMessages.ERROR_TOO_MANY_TUTORIALS.getMessage());
}
@ -447,7 +453,7 @@ public class DPlayerListener {
if (isCitizensNPC(player)) {
return;
}
plugin.getDPlayers().getByPlayer(player).applyRespawnInventory();
DungeonsXL.getDPlayers().getByPlayer(player).applyRespawnInventory();
DGlobalPlayer dPlayer = DGamePlayer.getByPlayer(player);
if (dPlayer == null) {
@ -575,7 +581,7 @@ public class DPlayerListener {
if (dGlobalPlayer.isCreatingPortal()) {
if (item.getType() == Material.WOOD_SWORD) {
if (clickedBlock != null) {
for (GlobalProtection protection : plugin.getGlobalProtections().getProtections(DPortal.class)) {
for (GlobalProtection protection : DungeonsXL.getGlobalProtections().getProtections(DPortal.class)) {
DPortal dPortal = (DPortal) protection;
if (!dPortal.isActive()) {
if (dPortal == dGlobalPlayer.getPortal()) {

View File

@ -23,7 +23,6 @@ import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.scheduler.BukkitTask;
/**
@ -31,10 +30,10 @@ import org.bukkit.scheduler.BukkitTask;
*
* @author Daniel Saukel
*/
public class DPlayers implements Listener {
public class DPlayers {
DungeonsXL plugin = DungeonsXL.getInstance();
MainConfig mainConfig = plugin.getMainConfig();
MainConfig mainConfig = DungeonsXL.getMainConfig();
private BukkitTask secureModeTask;
private BukkitTask updateTask;
@ -49,7 +48,7 @@ public class DPlayers implements Listener {
startUpdateTask(2L);
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
public void run() {
for (DGamePlayer dPlayer : DungeonsXL.getInstance().getDPlayers().getDGamePlayers()) {
for (DGamePlayer dPlayer : DungeonsXL.getDPlayers().getDGamePlayers()) {
dPlayer.update(true);
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -74,7 +74,7 @@ public class FeeLevelRequirement extends Requirement {
DPlayerData data = dPlayer.getData();
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;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
@ -26,6 +27,8 @@ import org.bukkit.entity.Player;
*/
public class FeeMoneyRequirement extends Requirement {
DungeonsXL plugin = DungeonsXL.getInstance();
private RequirementType type = RequirementTypeDefault.FEE_MONEY;
private double fee;
@ -73,7 +76,7 @@ public class FeeMoneyRequirement extends Requirement {
}
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 {
DungeonsXL plugin = DungeonsXL.getInstance();
public static Requirement create(RequirementType type) {
Requirement requirement = null;

View File

@ -30,16 +30,14 @@ import org.bukkit.inventory.ItemStack;
*/
public class DLootInventory {
static DungeonsXL plugin = DungeonsXL.getInstance();
private Inventory inventory;
private InventoryView inventoryView;
private Player player;
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) {
if (itemStack != null) {
inventory.addItem(itemStack);
@ -117,7 +115,7 @@ public class DLootInventory {
* the player whose DLootIntentory will be returned
*/
public static DLootInventory getByPlayer(Player player) {
for (DLootInventory inventory : plugin.getDLootInventories()) {
for (DLootInventory inventory : DungeonsXL.getDLootInventories()) {
if (inventory.player == player) {
return inventory;
}

View File

@ -17,6 +17,7 @@
package io.github.dre2n.dungeonsxl.reward;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import java.util.ArrayList;
import java.util.Arrays;
@ -79,7 +80,7 @@ public class ItemReward extends Reward {
} else {
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());
}
}

View File

@ -59,7 +59,7 @@ public class LevelReward extends Reward {
}
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

View File

@ -59,7 +59,7 @@ public class MoneyReward extends Reward {
}
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

View File

@ -39,8 +39,6 @@ import org.bukkit.inventory.ItemStack;
*/
public class RewardListener implements Listener {
DungeonsXL plugin = DungeonsXL.getInstance();
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
if (!(event.getPlayer() instanceof Player)) {
@ -48,7 +46,7 @@ public class RewardListener implements Listener {
}
Player player = (Player) event.getPlayer();
for (DLootInventory inventory : plugin.getDLootInventories()) {
for (DLootInventory inventory : DungeonsXL.getDLootInventories()) {
if (event.getView() != inventory.getInventoryView()) {
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);
}
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();
if (event.getInventory().getType() != InventoryType.CREATIVE && DEditWorld.getByWorld(world) != null) {
event.setCancelled(true);

View File

@ -29,13 +29,11 @@ import org.bukkit.Bukkit;
*/
public class RewardTypes {
DungeonsXL plugin = DungeonsXL.getInstance();
private List<RewardType> types = new ArrayList<>();
public RewardTypes() {
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())) {
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();
@ -77,7 +77,7 @@ public class CheckpointSign extends DSign {
if (!done.contains(dplayer)) {
done.add(dplayer);
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;
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.world.DGameWorld;
import io.github.dre2n.dungeonsxl.world.block.RewardChest;
@ -166,7 +167,7 @@ public class ChestSign extends DSign {
}
if (!lines[2].isEmpty()) {
lootTable = plugin.getDLootTables().getByName(lines[2]);
lootTable = DungeonsXL.getDLootTables().getByName(lines[2]);
}
if (chest == null) {

View File

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

View File

@ -29,13 +29,11 @@ import org.bukkit.Bukkit;
*/
public class DSignTypes {
DungeonsXL plugin = DungeonsXL.getInstance();
private List<DSignType> types = new ArrayList<>();
public DSignTypes() {
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;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
import io.github.dre2n.dungeonsxl.world.DGameWorld;
@ -61,7 +62,7 @@ public class FloorSign extends DSign {
@Override
public void onInit() {
if (!lines[1].isEmpty()) {
floor = plugin.getDWorlds().getResourceByName(lines[1]);
floor = DungeonsXL.getDWorlds().getResourceByName(lines[1]);
}
if (!getTriggers().isEmpty()) {
@ -103,7 +104,7 @@ public class FloorSign extends DSign {
@Override
public void onTrigger() {
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) {
for (DGamePlayer dPlayer : DungeonsXL.getDPlayers().getDGamePlayers()) {
dPlayer.finishFloor(floor);
}
}

View File

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

View File

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

View File

@ -16,6 +16,7 @@
*/
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@ -43,12 +44,12 @@ public class ScriptSign extends DSign {
@Override
public boolean check() {
return plugin.getSignScripts().getByName(lines[1]) != null;
return DungeonsXL.getSignScripts().getByName(lines[1]) != null;
}
@Override
public void onInit() {
SignScript script = plugin.getSignScripts().getByName(name);
SignScript script = DungeonsXL.getSignScripts().getByName(name);
for (String[] lines : script.getSigns()) {
DSign dSign = DSign.create(getSign(), lines, getGameWorld());
getGameWorld().getDSigns().add(dSign);

View File

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

View File

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

View File

@ -41,8 +41,6 @@ import org.bukkit.scheduler.BukkitRunnable;
*/
public class ReadySign extends DSign {
DungeonsXL plugin = DungeonsXL.getInstance();
private DSignType type = DSignTypeDefault.READY;
private GameType gameType;
@ -90,8 +88,8 @@ public class ReadySign extends DSign {
@Override
public void onInit() {
if (plugin.getGameTypes().getBySign(this) != null) {
gameType = plugin.getGameTypes().getBySign(this);
if (DungeonsXL.getGameTypes().getBySign(this) != null) {
gameType = DungeonsXL.getGameTypes().getBySign(this);
} else {
gameType = GameTypeDefault.CUSTOM;
@ -131,7 +129,7 @@ public class ReadySign extends DSign {
public void run() {
onTrigger();
}
}.runTaskLater(plugin, (long) (autoStart * 20));
}.runTaskLater(DungeonsXL.getInstance(), (long) (autoStart * 20));
if (!DGroup.getByPlayer(player).isPlaying()) {
ProgressBar.sendProgressBar(getGame().getPlayers(), (int) Math.ceil(autoStart));
@ -170,7 +168,7 @@ public class ReadySign extends DSign {
}
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 {
DungeonsXL plugin = DungeonsXL.getInstance();
private DSignType type = DSignTypeDefault.EXTERNAL_MOB;
// Variables
@ -143,7 +141,7 @@ public class ExternalMobSign extends DSign implements MobSign {
@Override
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;
if (attributes.length == 3) {
provider = plugin.getExternalMobProviders().getByIdentifier(attributes[2]);
provider = DungeonsXL.getExternalMobProviders().getByIdentifier(attributes[2]);
} else {
provider = ExternalMobPlugin.MYTHIC_MOBS;
}

View File

@ -26,7 +26,7 @@ import org.bukkit.scheduler.BukkitRunnable;
* @author Frank Baumann, Daniel Saukel
*/
public class ExternalMobSpawnTask extends BukkitRunnable {
private ExternalMobSign sign;
private ExternalMobProvider provider;

View File

@ -71,7 +71,7 @@ public class MobSpawnTask extends BukkitRunnable {
}
// Check custom mobs
DMobType mobType = DungeonsXL.getInstance().getDMobTypes().getByName(sign.getMob());
DMobType mobType = DungeonsXL.getDMobTypes().getByName(sign.getMob());
if (mobType != null) {
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.world.DGameWorld;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -44,7 +45,7 @@ public class DistanceTrigger extends Trigger {
public void onTrigger(Player player) {
TriggerActionEvent event = new TriggerActionEvent(this);
plugin.getServer().getPluginManager().callEvent(event);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;

View File

@ -19,6 +19,7 @@ package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.commons.util.NumberUtil;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Bukkit;
/**
* @author Daniel Saukel
@ -62,7 +63,7 @@ public class FortuneTrigger extends Trigger {
}
TriggerActionEvent event = new TriggerActionEvent(this);
plugin.getServer().getPluginManager().callEvent(event);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
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.world.DGameWorld;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -38,7 +39,7 @@ public class InteractTrigger extends Trigger {
public void onTrigger(Player player) {
TriggerActionEvent event = new TriggerActionEvent(this);
plugin.getServer().getPluginManager().callEvent(event);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
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.world.DGameWorld;
import org.bukkit.Bukkit;
/**
* @author Frank Baumann, Daniel Saukel
@ -34,7 +35,7 @@ public class MobTrigger extends Trigger {
public void onTrigger() {
TriggerActionEvent event = new TriggerActionEvent(this);
plugin.getServer().getPluginManager().callEvent(event);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;

View File

@ -16,11 +16,13 @@
*/
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.world.DGameWorld;
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Bukkit;
/**
* @author Frank Baumann, Daniel Saukel
@ -91,7 +93,7 @@ public class ProgressTrigger extends Trigger {
/* Actions */
public void onTrigger() {
TriggerActionEvent event = new TriggerActionEvent(this);
plugin.getServer().getPluginManager().callEvent(event);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
@ -115,7 +117,7 @@ public class ProgressTrigger extends Trigger {
}
public static ProgressTrigger getOrCreate(String floor, DGameWorld gameWorld) {
DResourceWorld resource = plugin.getDWorlds().getResourceByName(floor);
DResourceWorld resource = DungeonsXL.getDWorlds().getResourceByName(floor);
if (resource != null) {
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.world.DGameWorld;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@ -38,7 +39,7 @@ public class RedstoneTrigger extends Trigger {
public void onTrigger() {
TriggerActionEvent event = new TriggerActionEvent(this);
plugin.getServer().getPluginManager().callEvent(event);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
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.world.DGameWorld;
import org.bukkit.Bukkit;
/**
* @author Frank Baumann, Daniel Saukel
@ -34,7 +35,7 @@ public class SignTrigger extends Trigger {
public void onTrigger(boolean enable) {
TriggerActionEvent event = new TriggerActionEvent(this);
plugin.getServer().getPluginManager().callEvent(event);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;

View File

@ -26,6 +26,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
/**
@ -35,8 +36,6 @@ import org.bukkit.entity.Player;
*/
public abstract class Trigger {
static DungeonsXL plugin = DungeonsXL.getInstance();
private boolean triggered;
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) {
TriggerType type = plugin.getTriggers().getByIdentifier(identifier);
TriggerType type = DungeonsXL.getTriggers().getByIdentifier(identifier);
Trigger trigger = null;
if (type == TriggerTypeDefault.REDSTONE) {
@ -205,7 +204,7 @@ public abstract class Trigger {
}
TriggerRegistrationEvent event = new TriggerRegistrationEvent(trigger);
plugin.getServer().getPluginManager().callEvent(event);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return null;

View File

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

View File

@ -18,7 +18,7 @@ package io.github.dre2n.dungeonsxl.trigger;
/**
* Implement this to create custom trigger types.
*
*
* @author Daniel Saukel
*/
public interface TriggerType {

View File

@ -29,13 +29,11 @@ import org.bukkit.Bukkit;
*/
public class TriggerTypes {
DungeonsXL plugin = DungeonsXL.getInstance();
private List<TriggerType> types = new ArrayList<>();
public TriggerTypes() {
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.world.DGameWorld;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -41,7 +42,7 @@ public class UseItemTrigger extends Trigger {
public void onTrigger(Player player) {
TriggerActionEvent event = new TriggerActionEvent(this);
plugin.getServer().getPluginManager().callEvent(event);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;

View File

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

View File

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

View File

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

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