mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 21:48:43 +01:00
Cleanup
This commit is contained in:
parent
2be85aa1cf
commit
cb6add4fc8
@ -96,7 +96,7 @@ public class Announcer {
|
||||
if (multiFloor) {
|
||||
dungeonName = identifier;
|
||||
|
||||
Dungeon dungeon = DungeonsXL.getInstance().getDungeons().getByName(identifier);
|
||||
Dungeon dungeon = plugin.getDungeons().getByName(identifier);
|
||||
if (dungeon != null) {
|
||||
mapName = dungeon.getConfig().getStartFloor().getName();
|
||||
}
|
||||
@ -137,7 +137,7 @@ public class Announcer {
|
||||
if (multiFloor) {
|
||||
dungeonName = identifier;
|
||||
|
||||
Dungeon dungeon = DungeonsXL.getInstance().getDungeons().getByName(identifier);
|
||||
Dungeon dungeon = plugin.getDungeons().getByName(identifier);
|
||||
if (dungeon != null) {
|
||||
mapName = dungeon.getConfig().getStartFloor().getName();
|
||||
}
|
||||
@ -423,7 +423,7 @@ public class Announcer {
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
DGroup dGroup = dGroups.get(groupCount);
|
||||
if (!DungeonsXL.getInstance().getDGroups().contains(dGroup)) {
|
||||
if (!plugin.getDGroups().contains(dGroup)) {
|
||||
dGroups.set(groupCount, null);
|
||||
|
||||
} else if (dGroup != null) {
|
||||
@ -436,7 +436,7 @@ public class Announcer {
|
||||
|
||||
boolean full = playerCount >= maxPlayersPerGroup;
|
||||
|
||||
ItemStack button = new ItemStack(Material.WOOL, playerCount, DungeonsXL.getInstance().getMainConfig().getGroupColorPriority().get(groupCount).getWoolData());
|
||||
ItemStack button = new ItemStack(Material.WOOL, playerCount, plugin.getMainConfig().getGroupColorPriority().get(groupCount).getWoolData());
|
||||
ItemMeta meta = button.getItemMeta();
|
||||
meta.setDisplayName(name + (full ? ChatColor.DARK_RED : ChatColor.GREEN) + " [" + playerCount + "/" + maxPlayersPerGroup + "]");
|
||||
meta.setLore(lore);
|
||||
|
@ -44,7 +44,7 @@ public class AnnouncerCache {
|
||||
announcers.add(new Announcer(script));
|
||||
}
|
||||
}
|
||||
startAnnouncerTask(DungeonsXL.getInstance().getMainConfig().getAnnouncmentInterval());
|
||||
startAnnouncerTask(plugin.getMainConfig().getAnnouncmentInterval());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,8 +67,8 @@ public class CreateCommand extends DRECommand {
|
||||
MessageUtil.log(plugin, DMessage.LOG_GENERATE_NEW_WORLD.getMessage());
|
||||
|
||||
// Create World
|
||||
DResourceWorld resource = new DResourceWorld(DungeonsXL.getInstance().getDWorlds(), name);
|
||||
DungeonsXL.getInstance().getDWorlds().addResource(resource);
|
||||
DResourceWorld resource = new DResourceWorld(plugin.getDWorlds(), name);
|
||||
plugin.getDWorlds().addResource(resource);
|
||||
DEditWorld editWorld = resource.generate();
|
||||
editWorld.save();
|
||||
editWorld.delete();
|
||||
@ -89,8 +89,8 @@ public class CreateCommand extends DRECommand {
|
||||
MessageUtil.log(plugin, DMessage.LOG_GENERATE_NEW_WORLD.getMessage());
|
||||
|
||||
// Create World
|
||||
DResourceWorld resource = new DResourceWorld(DungeonsXL.getInstance().getDWorlds(), name);
|
||||
DungeonsXL.getInstance().getDWorlds().addResource(resource);
|
||||
DResourceWorld resource = new DResourceWorld(plugin.getDWorlds(), name);
|
||||
plugin.getDWorlds().addResource(resource);
|
||||
DEditWorld editWorld = resource.generate();
|
||||
|
||||
// MSG Done
|
||||
|
@ -69,7 +69,7 @@ public class ImportCommand extends DRECommand {
|
||||
MessageUtil.log(plugin, DMessage.LOG_NEW_MAP.getMessage());
|
||||
MessageUtil.log(plugin, DMessage.LOG_IMPORT_WORLD.getMessage());
|
||||
|
||||
if (!DungeonsXL.getInstance().getMainConfig().areTweaksEnabled()) {
|
||||
if (!plugin.getMainConfig().areTweaksEnabled()) {
|
||||
FileUtil.copyDirectory(source, target, new String[]{"playerdata", "stats"});
|
||||
|
||||
} else {
|
||||
@ -81,7 +81,7 @@ public class ImportCommand extends DRECommand {
|
||||
}.runTaskAsynchronously(plugin);
|
||||
}
|
||||
|
||||
DungeonsXL.getInstance().getDWorlds().addResource(new DResourceWorld(DungeonsXL.getInstance().getDWorlds(), args[1]));
|
||||
plugin.getDWorlds().addResource(new DResourceWorld(plugin.getDWorlds(), args[1]));
|
||||
MessageUtil.sendMessage(sender, DMessage.CMD_IMPORT_SUCCESS.getMessage(args[1]));
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ import org.bukkit.entity.Player;
|
||||
public class ListCommand extends DRECommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
DWorldCache worlds = DungeonsXL.getInstance().getDWorlds();
|
||||
DWorldCache worlds = plugin.getDWorlds();
|
||||
|
||||
public ListCommand() {
|
||||
setCommand("list");
|
||||
@ -54,7 +54,7 @@ public class ListCommand extends DRECommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
ArrayList<String> dungeonList = new ArrayList<>();
|
||||
for (Dungeon dungeon : DungeonsXL.getInstance().getDungeons().getDungeons()) {
|
||||
for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
|
||||
dungeonList.add(dungeon.getName());
|
||||
}
|
||||
ArrayList<String> mapList = new ArrayList<>();
|
||||
@ -78,7 +78,7 @@ public class ListCommand extends DRECommand {
|
||||
if (args.length >= 2) {
|
||||
if (args[1].equalsIgnoreCase("dungeons") || args[1].equalsIgnoreCase("d")) {
|
||||
if (args.length >= 3) {
|
||||
Dungeon dungeon = DungeonsXL.getInstance().getDungeons().getByName(args[2]);
|
||||
Dungeon dungeon = plugin.getDungeons().getByName(args[2]);
|
||||
if (dungeon != null) {
|
||||
MessageUtil.sendPluginTag(sender, plugin);
|
||||
MessageUtil.sendCenteredMessage(sender, "&4&l[ &6" + dungeon.getName() + " &4&l]");
|
||||
|
@ -33,6 +33,8 @@ import org.bukkit.plugin.PluginManager;
|
||||
*/
|
||||
public class MainCommand extends DRECommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
public MainCommand() {
|
||||
setCommand("main");
|
||||
setHelp(DMessage.HELP_CMD_MAIN.getMessage());
|
||||
@ -47,8 +49,8 @@ public class MainCommand extends DRECommand {
|
||||
|
||||
int maps = DungeonsXL.MAPS.listFiles().length;
|
||||
int dungeons = DungeonsXL.DUNGEONS.listFiles().length;
|
||||
int loaded = DungeonsXL.getInstance().getDWorlds().getEditWorlds().size() + DungeonsXL.getInstance().getDWorlds().getGameWorlds().size();
|
||||
int players = DungeonsXL.getInstance().getDPlayers().getDGamePlayers().size();
|
||||
int loaded = plugin.getDWorlds().getEditWorlds().size() + plugin.getDWorlds().getGameWorlds().size();
|
||||
int players = plugin.getDPlayers().getDGamePlayers().size();
|
||||
Internals internals = CompatibilityHandler.getInstance().getInternals();
|
||||
String vault = "";
|
||||
if (plugins.getPlugin("Vault") != null) {
|
||||
@ -64,7 +66,7 @@ public class MainCommand extends DRECommand {
|
||||
MessageUtil.sendCenteredMessage(sender, "&4" + D[2] + "&f" + X[2] + L[2]);
|
||||
MessageUtil.sendCenteredMessage(sender, "&4" + D[3] + "&f" + X[3] + L[3]);
|
||||
MessageUtil.sendCenteredMessage(sender, "&4" + D[4] + "&f" + X[4] + L[4]);
|
||||
MessageUtil.sendCenteredMessage(sender, "&b&l###### " + DMessage.CMD_MAIN_WELCOME.getMessage() + "&7 v" + DungeonsXL.getInstance().getDescription().getVersion() + " &b&l######");
|
||||
MessageUtil.sendCenteredMessage(sender, "&b&l###### " + DMessage.CMD_MAIN_WELCOME.getMessage() + "&7 v" + plugin.getDescription().getVersion() + " &b&l######");
|
||||
MessageUtil.sendCenteredMessage(sender, DMessage.CMD_MAIN_LOADED.getMessage(String.valueOf(maps), String.valueOf(dungeons), String.valueOf(loaded), String.valueOf(players)));
|
||||
MessageUtil.sendCenteredMessage(sender, DMessage.CMD_MAIN_COMPATIBILITY.getMessage(String.valueOf(internals), vault, itemsxl));
|
||||
MessageUtil.sendCenteredMessage(sender, DMessage.CMD_MAIN_HELP.getMessage());
|
||||
|
@ -38,6 +38,8 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public class PlayCommand extends DRECommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
public PlayCommand() {
|
||||
setCommand("play");
|
||||
setMinArgs(1);
|
||||
@ -51,15 +53,15 @@ public class PlayCommand extends DRECommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DGlobalPlayer dPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player);
|
||||
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||
if (dPlayer instanceof DInstancePlayer) {
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_DUNGEON.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
Dungeon dungeon = DungeonsXL.getInstance().getDungeons().getByName(args[1]);
|
||||
Dungeon dungeon = plugin.getDungeons().getByName(args[1]);
|
||||
if (dungeon == null) {
|
||||
DResourceWorld resource = DungeonsXL.getInstance().getDWorlds().getResourceByName(args[1]);
|
||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[1]);
|
||||
if (resource != null) {
|
||||
dungeon = new Dungeon(resource);
|
||||
} else {
|
||||
@ -77,7 +79,7 @@ public class PlayCommand extends DRECommand {
|
||||
DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.COMMAND);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
DungeonsXL.getInstance().getDGroups().remove(dGroup);
|
||||
plugin.getDGroups().remove(dGroup);
|
||||
dGroup = null;
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class PortalCommand extends DRECommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
public PortalCommand() {
|
||||
setCommand("portal");
|
||||
setMinArgs(0);
|
||||
@ -46,7 +48,7 @@ public class PortalCommand extends DRECommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DGlobalPlayer dGlobalPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player);
|
||||
DGlobalPlayer dGlobalPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||
|
||||
if (dGlobalPlayer instanceof DGamePlayer) {
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_DUNGEON.getMessage());
|
||||
@ -66,7 +68,7 @@ public class PortalCommand extends DRECommand {
|
||||
DPortal dPortal = dGlobalPlayer.getPortal();
|
||||
|
||||
if (dPortal == null) {
|
||||
dPortal = new DPortal(DungeonsXL.getInstance().getGlobalProtections().generateId(DPortal.class, player.getWorld()), player.getWorld(), material, false);
|
||||
dPortal = new DPortal(plugin.getGlobalProtections().generateId(DPortal.class, player.getWorld()), player.getWorld(), material, false);
|
||||
dGlobalPlayer.setCreatingPortal(dPortal);
|
||||
dPortal.setWorld(player.getWorld());
|
||||
dGlobalPlayer.setCachedItem(player.getItemInHand());
|
||||
|
@ -53,7 +53,7 @@ public class ReloadCommand extends DRECommand {
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
List<DInstancePlayer> dPlayers = DungeonsXL.getInstance().getDPlayers().getDInstancePlayers();
|
||||
List<DInstancePlayer> dPlayers = plugin.getDPlayers().getDInstancePlayers();
|
||||
if (!dPlayers.isEmpty() && args.length == 1 && CompatibilityHandler.getInstance().isSpigot() && sender instanceof Player) {
|
||||
MessageUtil.sendMessage(sender, DMessage.CMD_RELOAD_PLAYERS.getMessage());
|
||||
ClickEvent onClick = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/dungeonsxl reload -force");
|
||||
@ -78,8 +78,8 @@ public class ReloadCommand extends DRECommand {
|
||||
|
||||
int maps = DungeonsXL.MAPS.listFiles().length;
|
||||
int dungeons = DungeonsXL.DUNGEONS.listFiles().length;
|
||||
int loaded = DungeonsXL.getInstance().getDWorlds().getEditWorlds().size() + DungeonsXL.getInstance().getDWorlds().getGameWorlds().size();
|
||||
int players = DungeonsXL.getInstance().getDPlayers().getDGamePlayers().size();
|
||||
int loaded = plugin.getDWorlds().getEditWorlds().size() + plugin.getDWorlds().getGameWorlds().size();
|
||||
int players = plugin.getDPlayers().getDGamePlayers().size();
|
||||
Internals internals = CompatibilityHandler.getInstance().getInternals();
|
||||
String vault = "";
|
||||
if (plugins.getPlugin("Vault") != null) {
|
||||
|
@ -38,6 +38,8 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
*/
|
||||
public class RenameCommand extends DRECommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
public RenameCommand() {
|
||||
setCommand("rename");
|
||||
setMinArgs(2);
|
||||
@ -50,7 +52,7 @@ public class RenameCommand extends DRECommand {
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
DResourceWorld resource = DungeonsXL.getInstance().getDWorlds().getResourceByName(args[1]);
|
||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[1]);
|
||||
if (resource == null) {
|
||||
MessageUtil.sendMessage(sender, DMessage.ERROR_NO_SUCH_MAP.getMessage(args[1]));
|
||||
return;
|
||||
@ -60,7 +62,7 @@ public class RenameCommand extends DRECommand {
|
||||
resource.getFolder().renameTo(new File(DungeonsXL.MAPS, args[2]));
|
||||
resource.getSignData().updateFile(resource);
|
||||
|
||||
for (Dungeon dungeon : DungeonsXL.getInstance().getDungeons().getDungeons()) {
|
||||
for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
|
||||
DungeonConfig dConfig = dungeon.getConfig();
|
||||
FileConfiguration config = dConfig.getConfig();
|
||||
File file = dConfig.getFile();
|
||||
@ -90,7 +92,7 @@ public class RenameCommand extends DRECommand {
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
for (GlobalProtection protection : DungeonsXL.getInstance().getGlobalProtections().getProtections()) {
|
||||
for (GlobalProtection protection : plugin.getGlobalProtections().getProtections()) {
|
||||
if (protection instanceof GroupSign) {
|
||||
Dungeon dungeon = ((GroupSign) protection).getDungeon();
|
||||
if (dungeon.getName().equals(args[1])) {
|
||||
@ -108,7 +110,7 @@ public class RenameCommand extends DRECommand {
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
DungeonsXL.getInstance().getGlobalProtections().saveAll();
|
||||
plugin.getGlobalProtections().saveAll();
|
||||
}
|
||||
|
||||
MessageUtil.sendMessage(sender, DMessage.CMD_RENAME_SUCCESS.getMessage(args[1], args[2]));
|
||||
|
@ -117,7 +117,7 @@ public class StatusCommand extends DRECommand {
|
||||
|
||||
String vaultVersionCorrect = getSymbol(vaultVersion.startsWith("1.6"));
|
||||
String permissionPluginCorrect = getSymbol(plugin.getPermissionProvider() != null && plugin.getPermissionProvider().hasGroupSupport());
|
||||
String economyPluginCorrect = getSymbol(!DungeonsXL.getInstance().getMainConfig().isEconomyEnabled() || plugin.getEconomyProvider() != null);
|
||||
String economyPluginCorrect = getSymbol(!plugin.getMainConfig().isEconomyEnabled() || plugin.getEconomyProvider() != null);
|
||||
String commandsxlVersionCorrect = getSymbol(commandsxlVersion.startsWith("2.1"));
|
||||
String itemsxlVersionCorrect = getSymbol(itemsxlVersion.startsWith("0.2"));
|
||||
String citizensVersionCorrect = getSymbol(citizensVersion.startsWith("2.0"));
|
||||
|
@ -48,6 +48,8 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
*/
|
||||
public class Game {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
private boolean tutorial;
|
||||
private List<DGroup> dGroups = new ArrayList<>();
|
||||
private boolean started;
|
||||
@ -73,7 +75,7 @@ public class Game {
|
||||
}
|
||||
|
||||
public Game(DGroup dGroup, DGameWorld world) {
|
||||
DungeonsXL.getInstance().getGames().add(this);
|
||||
plugin.getGames().add(this);
|
||||
|
||||
tutorial = false;
|
||||
started = false;
|
||||
@ -88,7 +90,7 @@ public class Game {
|
||||
}
|
||||
|
||||
public Game(DGroup dGroup, DResourceWorld resource) {
|
||||
DungeonsXL.getInstance().getGames().add(this);
|
||||
plugin.getGames().add(this);
|
||||
|
||||
tutorial = false;
|
||||
started = false;
|
||||
@ -108,7 +110,7 @@ public class Game {
|
||||
}
|
||||
|
||||
public Game(List<DGroup> dGroups, GameType type, DGameWorld world) {
|
||||
DungeonsXL.getInstance().getGames().add(this);
|
||||
plugin.getGames().add(this);
|
||||
|
||||
this.dGroups = dGroups;
|
||||
this.type = type;
|
||||
@ -269,7 +271,7 @@ public class Game {
|
||||
finalRules.apply(dungeonConfig.getDefaultValues());
|
||||
}
|
||||
|
||||
finalRules.apply(DungeonsXL.getInstance().getMainConfig().getDefaultWorldConfig());
|
||||
finalRules.apply(plugin.getMainConfig().getDefaultWorldConfig());
|
||||
|
||||
finalRules.apply(GameRuleProvider.DEFAULT_VALUES);
|
||||
|
||||
@ -396,7 +398,7 @@ public class Game {
|
||||
public void delete() {
|
||||
GameSign gameSign = GameSign.getByGame(this);
|
||||
|
||||
DungeonsXL.getInstance().getGames().remove(this);
|
||||
plugin.getGames().remove(this);
|
||||
|
||||
if (gameSign != null) {
|
||||
gameSign.update();
|
||||
@ -445,7 +447,7 @@ public class Game {
|
||||
mobSign.initializeTask();
|
||||
}
|
||||
}
|
||||
}.runTaskLater(DungeonsXL.getInstance(), delay * 20);
|
||||
}.runTaskLater(plugin, delay * 20);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -182,7 +182,7 @@ public class DPortal extends GlobalProtection {
|
||||
DGroup dGroup = DGroup.getByPlayer(player);
|
||||
|
||||
if (dGroup == null) {
|
||||
MessageUtil.sendMessage(player, DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.ERROR_JOIN_GROUP));
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_JOIN_GROUP.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -436,17 +436,17 @@ public class GameSign extends GlobalProtection {
|
||||
DGroup dGroup = DGroup.getByPlayer(player);
|
||||
|
||||
if (dGroup == null) {
|
||||
MessageUtil.sendMessage(player, DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.ERROR_JOIN_GROUP));
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_JOIN_GROUP.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!dGroup.getCaptain().equals(player)) {
|
||||
MessageUtil.sendMessage(player, DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.ERROR_NOT_CAPTAIN));
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_NOT_CAPTAIN.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Game.getByDGroup(dGroup) != null) {
|
||||
MessageUtil.sendMessage(player, DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.ERROR_LEAVE_GAME));
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_GAME.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -93,8 +93,8 @@ public abstract class GlobalProtection {
|
||||
public boolean onBreak(DGlobalPlayer dPlayer) {
|
||||
if (dPlayer.isInBreakMode()) {
|
||||
delete();
|
||||
MessageUtil.sendMessage(dPlayer.getPlayer(), DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.PLAYER_PROTECTED_BLOCK_DELETED));
|
||||
MessageUtil.sendMessage(dPlayer.getPlayer(), DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.CMD_BREAK_PROTECTED_MODE));
|
||||
MessageUtil.sendMessage(dPlayer.getPlayer(), DMessage.PLAYER_PROTECTED_BLOCK_DELETED.getMessage());
|
||||
MessageUtil.sendMessage(dPlayer.getPlayer(), DMessage.CMD_BREAK_PROTECTED_MODE.getMessage());
|
||||
dPlayer.setInBreakMode(false);
|
||||
return false;
|
||||
|
||||
|
@ -34,10 +34,12 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
*/
|
||||
public class GlobalProtectionCache {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
private Set<GlobalProtection> protections = new HashSet<>();
|
||||
|
||||
public GlobalProtectionCache() {
|
||||
Bukkit.getPluginManager().registerEvents(new GlobalProtectionListener(), DungeonsXL.getInstance());
|
||||
Bukkit.getPluginManager().registerEvents(new GlobalProtectionListener(), plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,7 +103,7 @@ public class GlobalProtectionCache {
|
||||
* Save all protections to the default file
|
||||
*/
|
||||
public void saveAll() {
|
||||
saveAll(DungeonsXL.getInstance().getGlobalData().getConfig());
|
||||
saveAll(plugin.getGlobalData().getConfig());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,7 +124,7 @@ public class GlobalProtectionCache {
|
||||
protection.save(config);
|
||||
}
|
||||
|
||||
DungeonsXL.getInstance().getGlobalData().save();
|
||||
plugin.getGlobalData().save();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -159,7 +161,7 @@ public class GlobalProtectionCache {
|
||||
/* SUBJECT TO CHANGE */
|
||||
@Deprecated
|
||||
public void loadAll() {
|
||||
FileConfiguration data = DungeonsXL.getInstance().getGlobalData().getConfig();
|
||||
FileConfiguration data = plugin.getGlobalData().getConfig();
|
||||
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
// GameSigns
|
||||
|
@ -45,6 +45,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class GlobalProtectionListener implements Listener {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreakWithSignOnIt(BlockBreakEvent event) {
|
||||
Block block = event.getBlock();
|
||||
@ -73,9 +75,9 @@ public class GlobalProtectionListener implements Listener {
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Player player = event.getPlayer();
|
||||
DGlobalPlayer dGlobalPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player);
|
||||
DGlobalPlayer dGlobalPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||
|
||||
GlobalProtection protection = DungeonsXL.getInstance().getGlobalProtections().getByBlock(block);
|
||||
GlobalProtection protection = plugin.getGlobalProtections().getByBlock(block);
|
||||
if (protection != null) {
|
||||
if (protection.onBreak(dGlobalPlayer)) {
|
||||
event.setCancelled(true);
|
||||
@ -101,7 +103,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 (plugin.getGlobalProtections().isProtectedBlock(block)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -138,7 +140,7 @@ public class GlobalProtectionListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPortalCreation(PlayerInteractEvent event) {
|
||||
DGlobalPlayer dPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(event.getPlayer());
|
||||
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(event.getPlayer());
|
||||
if (!dPlayer.isCreatingPortal()) {
|
||||
return;
|
||||
}
|
||||
@ -148,7 +150,7 @@ public class GlobalProtectionListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
for (GlobalProtection protection : DungeonsXL.getInstance().getGlobalProtections().getProtections(DPortal.class)) {
|
||||
for (GlobalProtection protection : plugin.getGlobalProtections().getProtections(DPortal.class)) {
|
||||
DPortal dPortal = (DPortal) protection;
|
||||
if (dPortal.isActive() || dPortal != dPlayer.getPortal()) {
|
||||
continue;
|
||||
@ -175,7 +177,7 @@ public class GlobalProtectionListener implements Listener {
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (DungeonsXL.getInstance().getDPlayers().getByPlayer(player).isInBreakMode()) {
|
||||
if (plugin.getDPlayers().getByPlayer(player).isInBreakMode()) {
|
||||
return;
|
||||
}
|
||||
Block clickedBlock = event.getClickedBlock();
|
||||
@ -245,7 +247,7 @@ public class GlobalProtectionListener implements Listener {
|
||||
if (block.getState() instanceof Sign) {
|
||||
Sign sign = (Sign) block.getState();
|
||||
|
||||
new LeaveSign(DungeonsXL.getInstance().getGlobalProtections().generateId(LeaveSign.class, sign.getWorld()), sign);
|
||||
new LeaveSign(plugin.getGlobalProtections().generateId(LeaveSign.class, sign.getWorld()), sign);
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
@ -410,7 +410,7 @@ public class GroupSign extends GlobalProtection {
|
||||
}
|
||||
|
||||
if (DGroup.getByPlayer(player) != null) {
|
||||
MessageUtil.sendMessage(player, DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.ERROR_LEAVE_GROUP));
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_GROUP.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class ExternalMobProviderCache {
|
||||
}
|
||||
|
||||
// Custom providers
|
||||
for (Entry<String, Object> customExternalMobProvider : DungeonsXL.getInstance().getMainConfig().getExternalMobProviders().entrySet()) {
|
||||
for (Entry<String, Object> customExternalMobProvider : plugin.getMainConfig().getExternalMobProviders().entrySet()) {
|
||||
providers.add(new CustomExternalMobProvider(customExternalMobProvider));
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class DEditPlayer extends DInstancePlayer {
|
||||
|
||||
// Permission bridge
|
||||
if (plugin.getPermissionProvider() != null) {
|
||||
for (String permission : DungeonsXL.getInstance().getMainConfig().getEditPermissions()) {
|
||||
for (String permission : plugin.getMainConfig().getEditPermissions()) {
|
||||
plugin.getPermissionProvider().playerAddTransient(world.getName(), player, permission);
|
||||
}
|
||||
}
|
||||
@ -110,7 +110,7 @@ public class DEditPlayer extends DInstancePlayer {
|
||||
public void delete() {
|
||||
// Permission bridge
|
||||
if (plugin.getPermissionProvider() != null) {
|
||||
for (String permission : DungeonsXL.getInstance().getMainConfig().getEditPermissions()) {
|
||||
for (String permission : plugin.getMainConfig().getEditPermissions()) {
|
||||
plugin.getPermissionProvider().playerRemoveTransient(getWorld().getName(), player, permission);
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
return;
|
||||
}
|
||||
|
||||
DClass dClass = DungeonsXL.getInstance().getDClasses().getByName(className);
|
||||
DClass dClass = plugin.getDClasses().getByName(className);
|
||||
if (dClass != null) {
|
||||
if (this.dClass != dClass) {
|
||||
this.dClass = dClass;
|
||||
@ -513,12 +513,12 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
|
||||
// Tutorial Permissions
|
||||
if (game.isTutorial() && plugin.getPermissionProvider().hasGroupSupport()) {
|
||||
String endGroup = DungeonsXL.getInstance().getMainConfig().getTutorialEndGroup();
|
||||
String endGroup = plugin.getMainConfig().getTutorialEndGroup();
|
||||
if (plugin.isGroupEnabled(endGroup)) {
|
||||
plugin.getPermissionProvider().playerAddGroup(getPlayer(), endGroup);
|
||||
}
|
||||
|
||||
String startGroup = DungeonsXL.getInstance().getMainConfig().getTutorialStartGroup();
|
||||
String startGroup = plugin.getMainConfig().getTutorialStartGroup();
|
||||
if (plugin.isGroupEnabled(startGroup)) {
|
||||
plugin.getPermissionProvider().playerRemoveGroup(getPlayer(), startGroup);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class DGlobalPlayer implements PlayerWrapper {
|
||||
reset(false);
|
||||
}
|
||||
|
||||
DungeonsXL.getInstance().getDPlayers().addPlayer(this);
|
||||
plugin.getDPlayers().addPlayer(this);
|
||||
}
|
||||
|
||||
public DGlobalPlayer(DGlobalPlayer dPlayer) {
|
||||
@ -84,7 +84,7 @@ public class DGlobalPlayer implements PlayerWrapper {
|
||||
respawnInventory = dPlayer.getRespawnInventory();
|
||||
respawnArmor = dPlayer.getRespawnArmor();
|
||||
|
||||
DungeonsXL.getInstance().getDPlayers().addPlayer(this);
|
||||
plugin.getDPlayers().addPlayer(this);
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
@ -136,7 +136,7 @@ public class DGlobalPlayer implements PlayerWrapper {
|
||||
* @return if the player is in group chat
|
||||
*/
|
||||
public boolean isInGroupChat() {
|
||||
if (!DungeonsXL.getInstance().getMainConfig().isChatEnabled()) {
|
||||
if (!plugin.getMainConfig().isChatEnabled()) {
|
||||
return false;
|
||||
}
|
||||
return groupChat;
|
||||
@ -154,7 +154,7 @@ public class DGlobalPlayer implements PlayerWrapper {
|
||||
* @return if the player spies the DXL chat channels
|
||||
*/
|
||||
public boolean isInChatSpyMode() {
|
||||
if (!DungeonsXL.getInstance().getMainConfig().isChatEnabled()) {
|
||||
if (!plugin.getMainConfig().isChatEnabled()) {
|
||||
return false;
|
||||
}
|
||||
return chatSpyMode;
|
||||
@ -366,8 +366,8 @@ public class DGlobalPlayer implements PlayerWrapper {
|
||||
return;
|
||||
}
|
||||
|
||||
final String startGroup = DungeonsXL.getInstance().getMainConfig().getTutorialStartGroup();
|
||||
if ((DungeonsXL.getInstance().getMainConfig().getTutorialDungeon() == null || startGroup == null)) {
|
||||
final String startGroup = plugin.getMainConfig().getTutorialStartGroup();
|
||||
if ((plugin.getMainConfig().getTutorialDungeon() == null || startGroup == null)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -375,7 +375,7 @@ public class DGlobalPlayer implements PlayerWrapper {
|
||||
plugin.getPermissionProvider().playerAddGroup(player, startGroup);
|
||||
}
|
||||
|
||||
DGroup dGroup = new DGroup(player, DungeonsXL.getInstance().getMainConfig().getTutorialDungeon(), false);
|
||||
DGroup dGroup = new DGroup(player, plugin.getMainConfig().getTutorialDungeon(), false);
|
||||
|
||||
DGroupCreateEvent createEvent = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.GROUP_SIGN);
|
||||
Bukkit.getPluginManager().callEvent(createEvent);
|
||||
@ -391,7 +391,7 @@ public class DGlobalPlayer implements PlayerWrapper {
|
||||
DGameWorld gameWorld = null;
|
||||
|
||||
if (dGroup.getGameWorld() == null) {
|
||||
DResourceWorld resource = DungeonsXL.getInstance().getDWorlds().getResourceByName(dGroup.getMapName());
|
||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(dGroup.getMapName());
|
||||
if (resource == null) {
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_TUTORIAL_NOT_EXIST.getMessage());
|
||||
return;
|
||||
|
@ -57,7 +57,7 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
public class DGroup {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
DPlayerCache dPlayers = DungeonsXL.getInstance().getDPlayers();
|
||||
DPlayerCache dPlayers = plugin.getDPlayers();
|
||||
|
||||
private String name;
|
||||
private UUID captain;
|
||||
@ -81,7 +81,7 @@ public class DGroup {
|
||||
}
|
||||
|
||||
public DGroup(String name, Player player) {
|
||||
DungeonsXL.getInstance().getDGroups().add(this);
|
||||
plugin.getDGroups().add(this);
|
||||
this.name = name;
|
||||
|
||||
setCaptain(player);
|
||||
@ -103,10 +103,10 @@ public class DGroup {
|
||||
|
||||
@Deprecated
|
||||
public DGroup(String name, Player captain, List<Player> players, String identifier, boolean multiFloor) {
|
||||
DungeonsXL.getInstance().getDGroups().add(this);
|
||||
plugin.getDGroups().add(this);
|
||||
this.name = name;
|
||||
|
||||
DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(DungeonsXL.getInstance().getDPlayers().getByPlayer(captain), true, this);
|
||||
DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(plugin.getDPlayers().getByPlayer(captain), true, this);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
@ -120,14 +120,14 @@ public class DGroup {
|
||||
}
|
||||
}
|
||||
|
||||
dungeon = DungeonsXL.getInstance().getDungeons().getByName(identifier);
|
||||
dungeon = plugin.getDungeons().getByName(identifier);
|
||||
if (multiFloor && dungeon != null) {
|
||||
// Real dungeon
|
||||
unplayedFloors = new ArrayList<>(dungeon.getConfig().getFloors());
|
||||
|
||||
} else {
|
||||
// Artificial dungeon
|
||||
DResourceWorld resource = DungeonsXL.getInstance().getDWorlds().getResourceByName(identifier);
|
||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(identifier);
|
||||
dungeon = new Dungeon(resource);
|
||||
}
|
||||
|
||||
@ -144,10 +144,10 @@ public class DGroup {
|
||||
}
|
||||
|
||||
public DGroup(String name, Player captain, List<Player> players, Dungeon dungeon) {
|
||||
DungeonsXL.getInstance().getDGroups().add(this);
|
||||
plugin.getDGroups().add(this);
|
||||
this.name = name;
|
||||
|
||||
DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(DungeonsXL.getInstance().getDPlayers().getByPlayer(captain), true, this);
|
||||
DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(plugin.getDPlayers().getByPlayer(captain), true, this);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
@ -287,7 +287,7 @@ public class DGroup {
|
||||
GroupSign.updatePerGroup(this);
|
||||
|
||||
if (message) {
|
||||
sendMessage(DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.PLAYER_LEFT_GROUP, player.getName()));
|
||||
sendMessage(DMessage.PLAYER_LEFT_GROUP.getMessage(player.getName()));
|
||||
}
|
||||
|
||||
if (isEmpty()) {
|
||||
@ -318,18 +318,18 @@ public class DGroup {
|
||||
|
||||
if (DGroup.getByPlayer(player) != null) {
|
||||
if (!silent) {
|
||||
MessageUtil.sendMessage(getCaptain(), DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.ERROR_IN_GROUP, player.getName()));
|
||||
MessageUtil.sendMessage(getCaptain(), DMessage.ERROR_IN_GROUP.getMessage(player.getName()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!silent) {
|
||||
MessageUtil.sendMessage(player, DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.PLAYER_INVITED, getCaptain().getName(), name));
|
||||
MessageUtil.sendMessage(player, DMessage.PLAYER_INVITED.getMessage(getCaptain().getName(), name));
|
||||
}
|
||||
|
||||
// Send message
|
||||
if (!silent) {
|
||||
sendMessage(DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.GROUP_INVITED_PLAYER, getCaptain().getName(), player.getName(), name));
|
||||
sendMessage(DMessage.GROUP_INVITED_PLAYER.getMessage(getCaptain().getName(), player.getName(), name));
|
||||
}
|
||||
|
||||
// Add player
|
||||
@ -347,19 +347,19 @@ public class DGroup {
|
||||
|
||||
if (DGroup.getByPlayer(player) != this) {
|
||||
if (!silent) {
|
||||
MessageUtil.sendMessage(getCaptain(), DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.ERROR_NOT_IN_GROUP, player.getName(), name));
|
||||
MessageUtil.sendMessage(getCaptain(), DMessage.ERROR_NOT_IN_GROUP.getMessage(player.getName(), name));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!silent) {
|
||||
MessageUtil.sendMessage(player, DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.PLAYER_UNINVITED, player.getName(), name));
|
||||
MessageUtil.sendMessage(player, DMessage.PLAYER_UNINVITED.getMessage(player.getName(), name));
|
||||
}
|
||||
|
||||
// Send message
|
||||
if (!silent) {
|
||||
for (Player groupPlayer : players.getOnlinePlayers()) {
|
||||
MessageUtil.sendMessage(groupPlayer, DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.GROUP_UNINVITED_PLAYER, getCaptain().getName(), player.getName(), name));
|
||||
MessageUtil.sendMessage(groupPlayer, DMessage.GROUP_UNINVITED_PLAYER.getMessage(getCaptain().getName(), player.getName(), name));
|
||||
}
|
||||
}
|
||||
|
||||
@ -421,13 +421,13 @@ public class DGroup {
|
||||
* the name of the dungeon
|
||||
*/
|
||||
public boolean setDungeon(String name) {
|
||||
dungeon = DungeonsXL.getInstance().getDungeons().getByName(name);
|
||||
dungeon = plugin.getDungeons().getByName(name);
|
||||
if (dungeon != null) {
|
||||
unplayedFloors = dungeon.getConfig().getFloors();
|
||||
return true;
|
||||
|
||||
} else {
|
||||
DResourceWorld resource = DungeonsXL.getInstance().getDWorlds().getResourceByName(name);
|
||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(name);
|
||||
if (resource != null) {
|
||||
dungeon = new Dungeon(resource);
|
||||
return true;
|
||||
@ -736,7 +736,7 @@ public class DGroup {
|
||||
public void delete() {
|
||||
Game game = Game.getByDGroup(this);
|
||||
|
||||
DungeonsXL.getInstance().getDGroups().remove(this);
|
||||
plugin.getDGroups().remove(this);
|
||||
|
||||
if (game != null) {
|
||||
game.removeDGroup(this);
|
||||
@ -756,7 +756,7 @@ public class DGroup {
|
||||
game.fetchRules();
|
||||
GameRuleProvider rules = game.getRules();
|
||||
|
||||
color = DungeonsXL.getInstance().getMainConfig().getGroupColorPriority().get(game.getDGroups().indexOf(this));
|
||||
color = plugin.getMainConfig().getGroupColorPriority().get(game.getDGroups().indexOf(this));
|
||||
|
||||
for (DGroup dGroup : game.getDGroups()) {
|
||||
if (dGroup == null) {
|
||||
@ -807,7 +807,7 @@ public class DGroup {
|
||||
|
||||
dPlayer.respawn();
|
||||
|
||||
if (DungeonsXL.getInstance().getMainConfig().isSendFloorTitleEnabled()) {
|
||||
if (plugin.getMainConfig().isSendFloorTitleEnabled()) {
|
||||
if (rules.getTitle() != null || rules.getSubTitle() != null) {
|
||||
String title = rules.getTitle() == null ? "" : rules.getTitle();
|
||||
String subtitle = rules.getSubTitle() == null ? "" : rules.getSubTitle();
|
||||
|
@ -31,7 +31,7 @@ import org.bukkit.potion.PotionEffect;
|
||||
*/
|
||||
public abstract class DInstancePlayer extends DGlobalPlayer {
|
||||
|
||||
MainConfig config = DungeonsXL.getInstance().getMainConfig();
|
||||
MainConfig config = plugin.getMainConfig();
|
||||
|
||||
private World world;
|
||||
|
||||
@ -90,7 +90,7 @@ public abstract class DInstancePlayer extends DGlobalPlayer {
|
||||
new DGlobalPlayer(this);
|
||||
|
||||
} else {
|
||||
DungeonsXL.getInstance().getDPlayers().removePlayer(this);
|
||||
plugin.getDPlayers().removePlayer(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,13 +101,13 @@ public abstract class DInstancePlayer extends DGlobalPlayer {
|
||||
* the message to send
|
||||
*/
|
||||
public void chat(String message) {
|
||||
DInstanceWorld instance = DungeonsXL.getInstance().getDWorlds().getInstanceByWorld(world);
|
||||
DInstanceWorld instance = plugin.getDWorlds().getInstanceByWorld(world);
|
||||
if (instance == null) {
|
||||
return;
|
||||
}
|
||||
instance.sendMessage(ParsingUtil.replaceChatPlaceholders(config.getChatFormatGame(), this) + message);
|
||||
|
||||
for (DGlobalPlayer player : DungeonsXL.getInstance().getDPlayers().getDGlobalPlayers()) {
|
||||
for (DGlobalPlayer player : plugin.getDPlayers().getDGlobalPlayers()) {
|
||||
if (player.isInChatSpyMode()) {
|
||||
if (!instance.getWorld().getPlayers().contains(player.getPlayer())) {
|
||||
player.sendMessage(ParsingUtil.replaceChatPlaceholders(config.getChatFormatSpy(), this) + message);
|
||||
|
@ -34,7 +34,7 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
public class DPlayerCache {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
MainConfig mainConfig = DungeonsXL.getInstance().getMainConfig();
|
||||
MainConfig mainConfig = plugin.getMainConfig();
|
||||
|
||||
private BukkitTask secureModeTask;
|
||||
private BukkitTask updateTask;
|
||||
|
@ -62,14 +62,13 @@ import org.bukkit.inventory.meta.BookMeta;
|
||||
*/
|
||||
public class DPlayerListener implements Listener {
|
||||
|
||||
DungeonsXL plugin;
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
DPlayerCache dPlayers;
|
||||
MainConfig config = DungeonsXL.getInstance().getMainConfig();
|
||||
MainConfig config = plugin.getMainConfig();
|
||||
|
||||
public static final String ALL = "@all ";
|
||||
|
||||
public DPlayerListener(DPlayerCache dPlayers) {
|
||||
this.plugin = DungeonsXL.getInstance();
|
||||
this.dPlayers = dPlayers;
|
||||
}
|
||||
|
||||
@ -378,7 +377,7 @@ public class DPlayerListener implements Listener {
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
MainConfig config = DungeonsXL.getInstance().getMainConfig();
|
||||
MainConfig config = plugin.getMainConfig();
|
||||
|
||||
if (!config.isTutorialActivated()) {
|
||||
return;
|
||||
@ -401,7 +400,7 @@ public class DPlayerListener implements Listener {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (DungeonsXL.getInstance().getDWorlds().getGameWorlds().size() >= config.getMaxInstances()) {
|
||||
if (plugin.getDWorlds().getGameWorlds().size() >= config.getMaxInstances()) {
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_FULL);
|
||||
event.setKickMessage(DMessage.ERROR_TOO_MANY_TUTORIALS.getMessage());
|
||||
}
|
||||
@ -470,7 +469,7 @@ public class DPlayerListener implements Listener {
|
||||
if (isCitizensNPC(player)) {
|
||||
return;
|
||||
}
|
||||
DungeonsXL.getInstance().getDPlayers().getByPlayer(player).applyRespawnInventory();
|
||||
plugin.getDPlayers().getByPlayer(player).applyRespawnInventory();
|
||||
|
||||
DGlobalPlayer dPlayer = DGamePlayer.getByPlayer(player);
|
||||
if (dPlayer == null) {
|
||||
|
@ -37,7 +37,7 @@ public class DLootInventory {
|
||||
public DLootInventory(Player player, ItemStack[] itemStacks) {
|
||||
DungeonsXL.getInstance().getDLootInventories().add(this);
|
||||
|
||||
inventory = Bukkit.createInventory(player, 54, ChatColor.translateAlternateColorCodes('&', DungeonsXL.getInstance().getMessageConfig().getMessage(DMessage.PLAYER_TREASURES)));
|
||||
inventory = Bukkit.createInventory(player, 54, ChatColor.translateAlternateColorCodes('&', DMessage.PLAYER_TREASURES.getMessage()));
|
||||
for (ItemStack itemStack : itemStacks) {
|
||||
if (itemStack != null) {
|
||||
inventory.addItem(itemStack);
|
||||
|
@ -80,7 +80,7 @@ public class ItemReward extends Reward {
|
||||
|
||||
} else {
|
||||
new DLootInventory(player, items.subList(0, 54).toArray(new ItemStack[54]));
|
||||
DungeonsXL.getInstance().getDPlayers().getByPlayer(player).setRewardItems(new CopyOnWriteArrayList<>(items.subList(54, items.size())));
|
||||
plugin.getDPlayers().getByPlayer(player).setRewardItems(new CopyOnWriteArrayList<>(items.subList(54, items.size())));
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_TOO_MANY_REWARDS.getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,8 @@ 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)) {
|
||||
@ -46,7 +48,7 @@ public class RewardListener implements Listener {
|
||||
}
|
||||
Player player = (Player) event.getPlayer();
|
||||
|
||||
for (DLootInventory inventory : DungeonsXL.getInstance().getDLootInventories()) {
|
||||
for (DLootInventory inventory : plugin.getDLootInventories()) {
|
||||
if (event.getView() != inventory.getInventoryView()) {
|
||||
continue;
|
||||
}
|
||||
@ -61,7 +63,7 @@ public class RewardListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
DungeonsXL.getInstance().getDLootInventories().remove(inventory);
|
||||
plugin.getDLootInventories().remove(inventory);
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,7 +96,7 @@ public class RewardListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (!DungeonsXL.getInstance().getMainConfig().getOpenInventories() && !DPermissions.hasPermission(event.getPlayer(), DPermissions.INSECURE)) {
|
||||
if (!plugin.getMainConfig().getOpenInventories() && !DPermissions.hasPermission(event.getPlayer(), DPermissions.INSECURE)) {
|
||||
World world = event.getPlayer().getWorld();
|
||||
if (event.getInventory().getType() != InventoryType.CREATIVE && DEditWorld.getByWorld(world) != null) {
|
||||
event.setCancelled(true);
|
||||
@ -105,7 +107,7 @@ public class RewardListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (DungeonsXL.getInstance().getDWorlds().getInstanceByWorld(player.getWorld()) != null) {
|
||||
if (plugin.getDWorlds().getInstanceByWorld(player.getWorld()) != null) {
|
||||
return;
|
||||
}
|
||||
DLootInventory inventory = DLootInventory.getByPlayer(player);
|
||||
|
@ -167,7 +167,7 @@ public class ChestSign extends DSign {
|
||||
}
|
||||
|
||||
if (!lines[2].isEmpty()) {
|
||||
lootTable = DungeonsXL.getInstance().getDLootTables().getByName(lines[2]);
|
||||
lootTable = plugin.getDLootTables().getByName(lines[2]);
|
||||
}
|
||||
|
||||
if (chest == null) {
|
||||
|
@ -39,7 +39,7 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public abstract class DSign {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
protected DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
public static final String ERROR_0 = ChatColor.DARK_RED + "## ERROR ##";
|
||||
public static final String ERROR_1 = ChatColor.WHITE + "Please";
|
||||
|
@ -62,7 +62,7 @@ public class FloorSign extends DSign {
|
||||
@Override
|
||||
public void onInit() {
|
||||
if (!lines[1].isEmpty()) {
|
||||
floor = DungeonsXL.getInstance().getDWorlds().getResourceByName(lines[1]);
|
||||
floor = plugin.getDWorlds().getResourceByName(lines[1]);
|
||||
}
|
||||
|
||||
if (!getTriggers().isEmpty()) {
|
||||
@ -104,7 +104,7 @@ public class FloorSign extends DSign {
|
||||
|
||||
@Override
|
||||
public void onTrigger() {
|
||||
for (DGamePlayer dPlayer : DungeonsXL.getInstance().getDPlayers().getDGamePlayers()) {
|
||||
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) {
|
||||
dPlayer.finishFloor(floor);
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class LeaveSign extends DSign {
|
||||
|
||||
@Override
|
||||
public void onTrigger() {
|
||||
for (DGamePlayer dPlayer : DungeonsXL.getInstance().getDPlayers().getDGamePlayers()) {
|
||||
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) {
|
||||
DGamePlayerEscapeEvent event = new DGamePlayerEscapeEvent(dPlayer);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class ResourcePackSign extends DSign {
|
||||
/* Actions */
|
||||
@Override
|
||||
public boolean check() {
|
||||
return DungeonsXL.getInstance().getMainConfig().getResourcePacks().get(lines[1]) != null || lines[1].equalsIgnoreCase("reset");
|
||||
return plugin.getMainConfig().getResourcePacks().get(lines[1]) != null || lines[1].equalsIgnoreCase("reset");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -71,7 +71,7 @@ public class ResourcePackSign extends DSign {
|
||||
// Placeholder to reset to default
|
||||
url = "http://google.com";
|
||||
} else {
|
||||
url = DungeonsXL.getInstance().getMainConfig().getResourcePacks().get(lines[1]);
|
||||
url = plugin.getMainConfig().getResourcePacks().get(lines[1]);
|
||||
}
|
||||
|
||||
if (url instanceof String) {
|
||||
|
@ -44,12 +44,12 @@ public class ScriptSign extends DSign {
|
||||
|
||||
@Override
|
||||
public boolean check() {
|
||||
return DungeonsXL.getInstance().getSignScripts().getByName(lines[1]) != null;
|
||||
return plugin.getSignScripts().getByName(lines[1]) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInit() {
|
||||
SignScript script = DungeonsXL.getInstance().getSignScripts().getByName(name);
|
||||
SignScript script = plugin.getSignScripts().getByName(name);
|
||||
for (String[] lines : script.getSigns()) {
|
||||
DSign dSign = DSign.create(getSign(), lines, getGameWorld());
|
||||
getGameWorld().getDSigns().add(dSign);
|
||||
|
@ -36,7 +36,7 @@ public class ClassesSign extends DSign {
|
||||
|
||||
public ClassesSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
dClass = DungeonsXL.getInstance().getDClasses().getByName(sign.getLine(1));
|
||||
dClass = plugin.getDClasses().getByName(sign.getLine(1));
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
@ -58,7 +58,7 @@ public class ClassesSign extends DSign {
|
||||
/* Actions */
|
||||
@Override
|
||||
public boolean check() {
|
||||
return DungeonsXL.getInstance().getDClasses().getByName(lines[1]) != null;
|
||||
return plugin.getDClasses().getByName(lines[1]) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,7 +18,6 @@ package io.github.dre2n.dungeonsxl.sign.lobby;
|
||||
|
||||
import io.github.dre2n.commons.chat.MessageUtil;
|
||||
import io.github.dre2n.commons.misc.NumberUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.DMessage;
|
||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||
@ -88,8 +87,8 @@ public class ReadySign extends DSign {
|
||||
|
||||
@Override
|
||||
public void onInit() {
|
||||
if (DungeonsXL.getInstance().getGameTypes().getBySign(this) != null) {
|
||||
gameType = DungeonsXL.getInstance().getGameTypes().getBySign(this);
|
||||
if (plugin.getGameTypes().getBySign(this) != null) {
|
||||
gameType = plugin.getGameTypes().getBySign(this);
|
||||
|
||||
} else {
|
||||
gameType = GameTypeDefault.CUSTOM;
|
||||
@ -129,7 +128,7 @@ public class ReadySign extends DSign {
|
||||
public void run() {
|
||||
onTrigger();
|
||||
}
|
||||
}.runTaskLater(DungeonsXL.getInstance(), (long) (autoStart * 20));
|
||||
}.runTaskLater(plugin, (long) (autoStart * 20));
|
||||
|
||||
if (!DGroup.getByPlayer(player).isPlaying()) {
|
||||
ProgressBar.sendProgressBar(getGame().getPlayers(), (int) Math.ceil(autoStart));
|
||||
@ -168,7 +167,7 @@ public class ReadySign extends DSign {
|
||||
}
|
||||
|
||||
if (dPlayer.isReady()) {
|
||||
MessageUtil.sendMessage(dPlayer.getPlayer(), DungeonsXL.getInstance().getMessageConfig().getMessage(dPlayer.isReady() ? DMessage.PLAYER_READY : DMessage.ERROR_READY));
|
||||
MessageUtil.sendMessage(dPlayer.getPlayer(), plugin.getMessageConfig().getMessage(dPlayer.isReady() ? DMessage.PLAYER_READY : DMessage.ERROR_READY));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class HologramSign extends DSign {
|
||||
Location location = getSign().getLocation();
|
||||
location = location.add(0.5, NumberUtil.parseDouble(lines[2]), 0.5);
|
||||
|
||||
hologram = HologramsAPI.createHologram(DungeonsXL.getInstance(), location);
|
||||
hologram = HologramsAPI.createHologram(plugin, location);
|
||||
for (String line : holoLines) {
|
||||
if (line.startsWith("Item:")) {
|
||||
String id = line.replace("Item:", "");
|
||||
|
@ -129,7 +129,7 @@ public class DMobSign extends DSign implements MobSign {
|
||||
|
||||
@Override
|
||||
public void initializeTask() {
|
||||
task = new MobSpawnTask(this).runTaskTimer(DungeonsXL.getInstance(), 0L, 20L);
|
||||
task = new MobSpawnTask(this).runTaskTimer(plugin, 0L, 20L);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -141,7 +141,7 @@ public class ExternalMobSign extends DSign implements MobSign {
|
||||
|
||||
@Override
|
||||
public void initializeTask() {
|
||||
task = new ExternalMobSpawnTask(this, provider).runTaskTimer(DungeonsXL.getInstance(), 0L, 20L);
|
||||
task = new ExternalMobSpawnTask(this, provider).runTaskTimer(plugin, 0L, 20L);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -228,7 +228,7 @@ public class ExternalMobSign extends DSign implements MobSign {
|
||||
initialAmount = amount;
|
||||
|
||||
if (attributes.length == 3) {
|
||||
provider = DungeonsXL.getInstance().getExternalMobProviders().getByIdentifier(attributes[2]);
|
||||
provider = plugin.getExternalMobProviders().getByIdentifier(attributes[2]);
|
||||
} else {
|
||||
provider = ExternalMobPlugin.MYTHIC_MOBS;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
*/
|
||||
public class DEditWorld extends DInstanceWorld {
|
||||
|
||||
DWorldCache worlds = DungeonsXL.getInstance().getDWorlds();
|
||||
DWorldCache worlds = plugin.getDWorlds();
|
||||
|
||||
public static String ID_FILE_PREFIX = ".id_";
|
||||
|
||||
@ -121,7 +121,7 @@ public class DEditWorld extends DInstanceWorld {
|
||||
|
||||
getWorld().save();
|
||||
|
||||
if (!DungeonsXL.getInstance().getMainConfig().areTweaksEnabled()) {
|
||||
if (!plugin.getMainConfig().areTweaksEnabled()) {
|
||||
FileUtil.copyDirectory(getFolder(), getResource().getFolder(), DungeonsXL.EXCLUDED_FILES);
|
||||
FileUtil.deleteUnusedFiles(getResource().getFolder());
|
||||
|
||||
@ -162,7 +162,7 @@ public class DEditWorld extends DInstanceWorld {
|
||||
dPlayer.leave();
|
||||
}
|
||||
|
||||
if (!DungeonsXL.getInstance().getMainConfig().areTweaksEnabled()) {
|
||||
if (!plugin.getMainConfig().areTweaksEnabled()) {
|
||||
if (save) {
|
||||
Bukkit.unloadWorld(getWorld(), true);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ public class DGameWorld extends DInstanceWorld {
|
||||
*/
|
||||
public Game getGame() {
|
||||
if (game == null) {
|
||||
for (Game game : DungeonsXL.getInstance().getGames()) {
|
||||
for (Game game : plugin.getGames()) {
|
||||
if (game.getWorld() == this) {
|
||||
this.game = game;
|
||||
}
|
||||
@ -434,7 +434,7 @@ public class DGameWorld extends DInstanceWorld {
|
||||
* @return the Dungeon that contains the DGameWorld
|
||||
*/
|
||||
public Dungeon getDungeon() {
|
||||
for (Dungeon dungeon : DungeonsXL.getInstance().getDungeons().getDungeons()) {
|
||||
for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
|
||||
if (dungeon.getConfig().containsFloor(getResource())) {
|
||||
return dungeon;
|
||||
}
|
||||
@ -493,7 +493,7 @@ public class DGameWorld extends DInstanceWorld {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DungeonsXL.getInstance().getMainConfig().areTweaksEnabled()) {
|
||||
if (!plugin.getMainConfig().areTweaksEnabled()) {
|
||||
Bukkit.unloadWorld(getWorld(), false);
|
||||
FileUtil.removeDirectory(getFolder());
|
||||
worlds.removeInstance(this);
|
||||
|
@ -31,7 +31,7 @@ import org.bukkit.World;
|
||||
public abstract class DInstanceWorld {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
DWorldCache worlds = DungeonsXL.getInstance().getDWorlds();
|
||||
DWorldCache worlds = plugin.getDWorlds();
|
||||
|
||||
private DResourceWorld resourceWorld;
|
||||
private File folder;
|
||||
|
@ -213,7 +213,7 @@ public class DResourceWorld {
|
||||
|
||||
final DInstanceWorld instance = game ? new DGameWorld(this, instanceFolder, id) : new DEditWorld(this, instanceFolder, id);
|
||||
|
||||
if (!DungeonsXL.getInstance().getMainConfig().areTweaksEnabled()) {
|
||||
if (!plugin.getMainConfig().areTweaksEnabled()) {
|
||||
FileUtil.copyDirectory(folder, instanceFolder, DungeonsXL.EXCLUDED_FILES);
|
||||
instance.world = Bukkit.createWorld(WorldCreator.name(name));
|
||||
|
||||
@ -288,7 +288,7 @@ public class DResourceWorld {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!DungeonsXL.getInstance().getMainConfig().areTweaksEnabled()) {
|
||||
if (!plugin.getMainConfig().areTweaksEnabled()) {
|
||||
editWorld.world = creator.createWorld();
|
||||
|
||||
} else {
|
||||
|
@ -38,7 +38,7 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
public class DWorldCache {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
MainConfig mainConfig = DungeonsXL.getInstance().getMainConfig();
|
||||
MainConfig mainConfig = plugin.getMainConfig();
|
||||
|
||||
public static final File RAW = new File(DungeonsXL.MAPS, ".raw");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user