mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
Dependency injection
This commit is contained in:
parent
4cf0c393cd
commit
9a9fee8deb
@ -23,15 +23,19 @@ import de.erethon.commons.config.MessageConfig;
|
||||
import de.erethon.commons.javaplugin.DREPlugin;
|
||||
import de.erethon.commons.javaplugin.DREPluginSettings;
|
||||
import de.erethon.commons.misc.FileUtil;
|
||||
import de.erethon.dungeonsxl.announcer.Announcer;
|
||||
import de.erethon.dungeonsxl.announcer.AnnouncerCache;
|
||||
import de.erethon.dungeonsxl.announcer.AnnouncerListener;
|
||||
import de.erethon.dungeonsxl.announcer.AnnouncerTask;
|
||||
import de.erethon.dungeonsxl.command.DCommandCache;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.config.GlobalData;
|
||||
import de.erethon.dungeonsxl.config.MainConfig;
|
||||
import de.erethon.dungeonsxl.dungeon.DungeonCache;
|
||||
import de.erethon.dungeonsxl.game.Game;
|
||||
import de.erethon.dungeonsxl.game.GameTypeCache;
|
||||
import de.erethon.dungeonsxl.global.GlobalData;
|
||||
import de.erethon.dungeonsxl.global.GlobalProtectionCache;
|
||||
import de.erethon.dungeonsxl.global.GlobalProtectionListener;
|
||||
import de.erethon.dungeonsxl.mob.DMobListener;
|
||||
import de.erethon.dungeonsxl.mob.DMobType;
|
||||
import de.erethon.dungeonsxl.mob.ExternalMobProviderCache;
|
||||
@ -40,9 +44,11 @@ import de.erethon.dungeonsxl.player.DGroup;
|
||||
import de.erethon.dungeonsxl.player.DPermission;
|
||||
import de.erethon.dungeonsxl.player.DPlayerCache;
|
||||
import de.erethon.dungeonsxl.requirement.RequirementTypeCache;
|
||||
import de.erethon.dungeonsxl.reward.RewardListener;
|
||||
import de.erethon.dungeonsxl.reward.RewardTypeCache;
|
||||
import de.erethon.dungeonsxl.sign.DSignTypeCache;
|
||||
import de.erethon.dungeonsxl.sign.SignScriptCache;
|
||||
import de.erethon.dungeonsxl.trigger.TriggerListener;
|
||||
import de.erethon.dungeonsxl.trigger.TriggerTypeCache;
|
||||
import de.erethon.dungeonsxl.util.NoReload;
|
||||
import de.erethon.dungeonsxl.world.DWorldCache;
|
||||
@ -121,30 +127,23 @@ public class DungeonsXL extends DREPlugin {
|
||||
public void onEnable() {
|
||||
super.onEnable();
|
||||
instance = this;
|
||||
|
||||
DPermission.register();
|
||||
initFolders();
|
||||
loadCore();
|
||||
loadCaliburnAPI();
|
||||
DPermission.register();
|
||||
loadConfig();
|
||||
createCaches();
|
||||
initCaches();
|
||||
loadData();
|
||||
|
||||
new NoReload(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Save
|
||||
saveData();
|
||||
messageConfig.save();
|
||||
|
||||
dGroups.clear();
|
||||
|
||||
// Delete DWorlds
|
||||
dWorlds.deleteAllInstances();
|
||||
|
||||
// Disable listeners
|
||||
HandlerList.unregisterAll(this);
|
||||
|
||||
// Stop shedulers
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
}
|
||||
|
||||
@ -210,31 +209,46 @@ public class DungeonsXL extends DREPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadCore() {
|
||||
loadCaliburnAPI();
|
||||
// Load Language
|
||||
loadMessageConfig(new File(LANGUAGES, "english.yml"));
|
||||
// Load Config
|
||||
loadGlobalData(new File(getDataFolder(), "data.yml"));
|
||||
loadMainConfig(new File(getDataFolder(), "config.yml"));
|
||||
// Load Language 2
|
||||
loadMessageConfig(new File(LANGUAGES, mainConfig.getLanguage() + ".yml"));
|
||||
loadGameTypes();
|
||||
loadRequirementTypes();
|
||||
loadRewardTypes();
|
||||
loadTriggers();
|
||||
loadDSigns();
|
||||
loadDWorlds(MAPS);
|
||||
loadDungeons(DUNGEONS);
|
||||
loadGlobalProtections();
|
||||
loadExternalMobProviders();
|
||||
loadDPlayers();
|
||||
loadAnnouncers(ANNOUNCERS);
|
||||
loadDClasses(CLASSES);
|
||||
loadLootTables(LOOT_TABLES);
|
||||
loadMobs(MOBS);
|
||||
loadSignScripts(SIGNS);
|
||||
loadDCommandCache();
|
||||
public void loadConfig() {
|
||||
messageConfig = new MessageConfig(DMessage.class, new File(LANGUAGES, "english.yml"));
|
||||
globalData = new GlobalData(new File(getDataFolder(), "data.yml"));
|
||||
mainConfig = new MainConfig(this, new File(getDataFolder(), "config.yml"));
|
||||
messageConfig = new MessageConfig(DMessage.class, new File(LANGUAGES, mainConfig.getLanguage() + ".yml"));
|
||||
}
|
||||
|
||||
public void createCaches() {
|
||||
gameTypes = new GameTypeCache();
|
||||
requirementTypes = new RequirementTypeCache();
|
||||
rewardTypes = new RewardTypeCache();
|
||||
triggers = new TriggerTypeCache();
|
||||
dSigns = new DSignTypeCache(this);
|
||||
dWorlds = new DWorldCache(this);
|
||||
dungeons = new DungeonCache(this);
|
||||
protections = new GlobalProtectionCache(this);
|
||||
dMobProviders = new ExternalMobProviderCache(this);
|
||||
dPlayers = new DPlayerCache(this);
|
||||
announcers = new AnnouncerCache();
|
||||
dClasses = new DClassCache(this);
|
||||
signScripts = new SignScriptCache();
|
||||
dCommands = new DCommandCache(this);
|
||||
}
|
||||
|
||||
public void initCaches() {
|
||||
// Game types
|
||||
// Requirements
|
||||
Bukkit.getPluginManager().registerEvents(new RewardListener(this), this);
|
||||
Bukkit.getPluginManager().registerEvents(new TriggerListener(this), this);
|
||||
dSigns.init();
|
||||
dWorlds.init(MAPS);
|
||||
dungeons.init(DUNGEONS);
|
||||
Bukkit.getPluginManager().registerEvents(new GlobalProtectionListener(this), this);
|
||||
dMobProviders.init();
|
||||
dPlayers.init();
|
||||
initAnnouncerCache(ANNOUNCERS);
|
||||
dClasses.init(CLASSES);
|
||||
Bukkit.getPluginManager().registerEvents(new DMobListener(), this);
|
||||
signScripts.init(SIGNS);
|
||||
dCommands.register(this);
|
||||
}
|
||||
|
||||
// Save and load
|
||||
@ -264,11 +278,14 @@ public class DungeonsXL extends DREPlugin {
|
||||
return caliburn;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of CaliburnAPI if none exists
|
||||
*/
|
||||
private void loadCaliburnAPI() {
|
||||
caliburn = CaliburnAPI.getInstance() == null ? new CaliburnAPI(this) : CaliburnAPI.getInstance();
|
||||
if (LOOT_TABLES.isDirectory()) {
|
||||
FileUtil.getFilesForFolder(LOOT_TABLES).forEach(s -> new LootTable(caliburn, s));
|
||||
}
|
||||
if (MOBS.isDirectory()) {
|
||||
FileUtil.getFilesForFolder(MOBS).forEach(s -> caliburn.getExMobs().add(new DMobType(this, s)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -278,13 +295,9 @@ public class DungeonsXL extends DREPlugin {
|
||||
return globalData;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of GlobalData
|
||||
*
|
||||
* @param file the file to load from
|
||||
*/
|
||||
public void loadGlobalData(File file) {
|
||||
globalData = new GlobalData(file);
|
||||
@Override
|
||||
public DCommandCache getCommandCache() {
|
||||
return dCommands;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -294,268 +307,120 @@ public class DungeonsXL extends DREPlugin {
|
||||
return mainConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of MainConfig
|
||||
*
|
||||
* @param file the file to load from
|
||||
*/
|
||||
public void loadMainConfig(File file) {
|
||||
mainConfig = new MainConfig(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of MessageConfig
|
||||
*
|
||||
* @param file the file to load from
|
||||
*/
|
||||
public void loadMessageConfig(File file) {
|
||||
messageConfig = new MessageConfig(DMessage.class, file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loaded instance of DCommandCache
|
||||
*/
|
||||
@Override
|
||||
public DCommandCache getCommandCache() {
|
||||
return dCommands;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of DCommandCache
|
||||
*/
|
||||
public void loadDCommandCache() {
|
||||
dCommands = new DCommandCache(this);
|
||||
dCommands.register(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dSigns
|
||||
*/
|
||||
public DSignTypeCache getDSigns() {
|
||||
public DSignTypeCache getDSignCache() {
|
||||
return dSigns;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of DSignTypeCache
|
||||
*/
|
||||
public void loadDSigns() {
|
||||
dSigns = new DSignTypeCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the game types
|
||||
*/
|
||||
public GameTypeCache getGameTypes() {
|
||||
public GameTypeCache getGameTypeCache() {
|
||||
return gameTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of GameTypeCache
|
||||
*/
|
||||
public void loadGameTypes() {
|
||||
gameTypes = new GameTypeCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the requirement types
|
||||
*/
|
||||
public RequirementTypeCache getRequirementTypes() {
|
||||
public RequirementTypeCache getRequirementTypeCache() {
|
||||
return requirementTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of RequirementTypeCache
|
||||
*/
|
||||
public void loadRequirementTypes() {
|
||||
requirementTypes = new RequirementTypeCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the reward types
|
||||
*/
|
||||
public RewardTypeCache getRewardTypes() {
|
||||
public RewardTypeCache getRewardTypeCache() {
|
||||
return rewardTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of RewardTypeCache
|
||||
*/
|
||||
public void loadRewardTypes() {
|
||||
rewardTypes = new RewardTypeCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the triggers
|
||||
*/
|
||||
public TriggerTypeCache getTriggers() {
|
||||
public TriggerTypeCache getTriggerCache() {
|
||||
return triggers;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of TriggerTypeCache
|
||||
*/
|
||||
public void loadTriggers() {
|
||||
triggers = new TriggerTypeCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loaded instance of DungeonCache
|
||||
*/
|
||||
public DungeonCache getDungeons() {
|
||||
public DungeonCache getDungeonCache() {
|
||||
return dungeons;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of DungeonCache
|
||||
*
|
||||
* @param folder the folder to load from
|
||||
*/
|
||||
public void loadDungeons(File folder) {
|
||||
dungeons = new DungeonCache(folder);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loaded instance of GlobalProtectionCache
|
||||
*/
|
||||
public GlobalProtectionCache getGlobalProtections() {
|
||||
public GlobalProtectionCache getGlobalProtectionCache() {
|
||||
return protections;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of GlobalProtectionCache
|
||||
*/
|
||||
public void loadGlobalProtections() {
|
||||
protections = new GlobalProtectionCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loaded instance of ExternalMobProviderCache
|
||||
*/
|
||||
public ExternalMobProviderCache getExternalMobProviders() {
|
||||
public ExternalMobProviderCache getExternalMobProviderCache() {
|
||||
return dMobProviders;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of ExternalMobProviderCache
|
||||
*/
|
||||
public void loadExternalMobProviders() {
|
||||
dMobProviders = new ExternalMobProviderCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loaded instance of DPlayerCache
|
||||
*/
|
||||
public DPlayerCache getDPlayers() {
|
||||
public DPlayerCache getDPlayerCache() {
|
||||
return dPlayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of DPlayerCache
|
||||
*/
|
||||
public void loadDPlayers() {
|
||||
dPlayers = new DPlayerCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loaded instance of AnnouncerCache
|
||||
*/
|
||||
public AnnouncerCache getAnnouncers() {
|
||||
public AnnouncerCache getAnnouncerCache() {
|
||||
return announcers;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of AnnouncerCache
|
||||
*
|
||||
* @param folder the folder to load from
|
||||
*/
|
||||
public void loadAnnouncers(File folder) {
|
||||
announcers = new AnnouncerCache(folder);
|
||||
private void initAnnouncerCache(File file) {
|
||||
if (file.isDirectory()) {
|
||||
for (File script : FileUtil.getFilesForFolder(file)) {
|
||||
announcers.addAnnouncer(new Announcer(this, script));
|
||||
}
|
||||
}
|
||||
if (!announcers.getAnnouncers().isEmpty()) {
|
||||
announcers.setAnnouncerTask(new AnnouncerTask(this).runTaskTimer(this, mainConfig.getAnnouncmentInterval(), mainConfig.getAnnouncmentInterval()));
|
||||
}
|
||||
Bukkit.getPluginManager().registerEvents(new AnnouncerListener(this), this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loaded instance of DClasseCache
|
||||
* @return the loaded instance of DClassCache
|
||||
*/
|
||||
public DClassCache getDClasses() {
|
||||
public DClassCache getDClassCache() {
|
||||
return dClasses;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of DClasseCache
|
||||
*
|
||||
* @param folder the folder to load from
|
||||
*/
|
||||
public void loadDClasses(File folder) {
|
||||
dClasses = new DClassCache(folder);
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload loot tables
|
||||
*
|
||||
* @param folder the folder to load from
|
||||
*/
|
||||
public void loadLootTables(File folder) {
|
||||
for (File script : FileUtil.getFilesForFolder(folder)) {
|
||||
new LootTable(caliburn, script);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload DMob types
|
||||
*
|
||||
* @param folder the folder to load from
|
||||
*/
|
||||
public void loadMobs(File folder) {
|
||||
if (folder.isDirectory()) {
|
||||
for (File script : FileUtil.getFilesForFolder(folder)) {
|
||||
caliburn.getExMobs().add(new DMobType(script));
|
||||
}
|
||||
}
|
||||
Bukkit.getPluginManager().registerEvents(new DMobListener(), this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loaded instance of SignScriptCache
|
||||
*/
|
||||
public SignScriptCache getSignScripts() {
|
||||
public SignScriptCache getSignScriptCache() {
|
||||
return signScripts;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of SignScriptCache
|
||||
*
|
||||
* @param folder the folder to load from
|
||||
*/
|
||||
public void loadSignScripts(File folder) {
|
||||
signScripts = new SignScriptCache(folder);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loaded instance of DWorldCache
|
||||
*/
|
||||
public DWorldCache getDWorlds() {
|
||||
public DWorldCache getDWorldCache() {
|
||||
return dWorlds;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of DWorldCache
|
||||
*
|
||||
* @param folder the folder to load from
|
||||
*/
|
||||
public void loadDWorlds(File folder) {
|
||||
dWorlds = new DWorldCache(MAPS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the games
|
||||
*/
|
||||
public List<Game> getGames() {
|
||||
public List<Game> getGameCache() {
|
||||
return games;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dGroups
|
||||
*/
|
||||
public List<DGroup> getDGroups() {
|
||||
public List<DGroup> getDGroupCache() {
|
||||
return dGroups;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ import org.bukkit.material.Wool;
|
||||
*/
|
||||
public class Announcer {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
private DungeonsXL plugin;
|
||||
|
||||
private String name;
|
||||
|
||||
@ -73,17 +73,21 @@ public class Announcer {
|
||||
private AnnouncerStartGameTask startTask;
|
||||
|
||||
/**
|
||||
* @param plugin the plugin instance
|
||||
* @param file the script file
|
||||
*/
|
||||
public Announcer(File file) {
|
||||
this(file.getName().substring(0, file.getName().length() - 4), YamlConfiguration.loadConfiguration(file));
|
||||
public Announcer(DungeonsXL plugin, File file) {
|
||||
this(plugin, file.getName().substring(0, file.getName().length() - 4), YamlConfiguration.loadConfiguration(file));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param plugin the plugin instance
|
||||
* @param name the name of the Announcer
|
||||
* @param config the config that stores the information
|
||||
*/
|
||||
public Announcer(String name, FileConfiguration config) {
|
||||
public Announcer(DungeonsXL plugin, String name, FileConfiguration config) {
|
||||
this.plugin = plugin;
|
||||
|
||||
this.name = name;
|
||||
|
||||
description = config.getStringList("description");
|
||||
@ -94,7 +98,7 @@ public class Announcer {
|
||||
if (multiFloor) {
|
||||
dungeonName = identifier;
|
||||
|
||||
Dungeon dungeon = plugin.getDungeons().getByName(identifier);
|
||||
Dungeon dungeon = plugin.getDungeonCache().getByName(identifier);
|
||||
if (dungeon != null) {
|
||||
mapName = dungeon.getConfig().getStartFloor().getName();
|
||||
}
|
||||
@ -128,7 +132,7 @@ public class Announcer {
|
||||
if (multiFloor) {
|
||||
dungeonName = identifier;
|
||||
|
||||
Dungeon dungeon = plugin.getDungeons().getByName(identifier);
|
||||
Dungeon dungeon = plugin.getDungeonCache().getByName(identifier);
|
||||
if (dungeon != null) {
|
||||
mapName = dungeon.getConfig().getStartFloor().getName();
|
||||
}
|
||||
@ -374,7 +378,7 @@ public class Announcer {
|
||||
DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.ANNOUNCER);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
dGroups.set(buttons.indexOf(button), new DGroup(player, color));
|
||||
dGroups.set(buttons.indexOf(button), new DGroup(plugin, player, color));
|
||||
}
|
||||
|
||||
} else if (dGroup == null && pGroup != null) {
|
||||
@ -391,7 +395,7 @@ public class Announcer {
|
||||
|
||||
if (areRequirementsFulfilled()) {
|
||||
if (startTask == null) {
|
||||
startTask = new AnnouncerStartGameTask(this);
|
||||
startTask = new AnnouncerStartGameTask(plugin, this);
|
||||
startTask.runTaskLater(plugin, 20 * 30L);
|
||||
} else {
|
||||
startTask.getProgressBar().addPlayer(player);
|
||||
@ -412,7 +416,7 @@ public class Announcer {
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
DGroup dGroup = dGroups.get(groupCount);
|
||||
if (!plugin.getDGroups().contains(dGroup)) {
|
||||
if (!plugin.getDGroupCache().contains(dGroup)) {
|
||||
dGroups.set(groupCount, null);
|
||||
|
||||
} else if (dGroup != null) {
|
||||
|
@ -16,14 +16,11 @@
|
||||
*/
|
||||
package de.erethon.dungeonsxl.announcer;
|
||||
|
||||
import de.erethon.commons.misc.FileUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
/**
|
||||
@ -33,22 +30,10 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
*/
|
||||
public class AnnouncerCache {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
private BukkitTask announcerTask;
|
||||
|
||||
private List<Announcer> announcers = new ArrayList<>();
|
||||
|
||||
public AnnouncerCache(File file) {
|
||||
if (file.isDirectory()) {
|
||||
for (File script : FileUtil.getFilesForFolder(file)) {
|
||||
announcers.add(new Announcer(script));
|
||||
}
|
||||
}
|
||||
startAnnouncerTask(plugin.getMainConfig().getAnnouncmentInterval());
|
||||
Bukkit.getPluginManager().registerEvents(new AnnouncerListener(), plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name
|
||||
* @return the announcer that has the name
|
||||
@ -106,14 +91,10 @@ public class AnnouncerCache {
|
||||
}
|
||||
|
||||
/**
|
||||
* start a new AnnouncerTask
|
||||
*
|
||||
* @param period the period ticks
|
||||
* @param announcerTask the AnnouncerTask to set
|
||||
*/
|
||||
public void startAnnouncerTask(long period) {
|
||||
if (!announcers.isEmpty()) {
|
||||
announcerTask = new AnnouncerTask(this).runTaskTimer(plugin, period, period);
|
||||
}
|
||||
public void setAnnouncerTask(BukkitTask announcerTask) {
|
||||
this.announcerTask = announcerTask;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,6 +30,12 @@ import org.bukkit.material.Wool;
|
||||
*/
|
||||
public class AnnouncerListener implements Listener {
|
||||
|
||||
private AnnouncerCache announcers;
|
||||
|
||||
public AnnouncerListener(DungeonsXL plugin) {
|
||||
announcers = plugin.getAnnouncerCache();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onButtonClick(InventoryClickEvent event) {
|
||||
if (!(event.getWhoClicked() instanceof Player)) {
|
||||
@ -39,7 +45,7 @@ public class AnnouncerListener implements Listener {
|
||||
|
||||
Inventory gui = event.getInventory();
|
||||
ItemStack button = event.getCurrentItem();
|
||||
Announcer announcer = DungeonsXL.getInstance().getAnnouncers().getByGUI(gui);
|
||||
Announcer announcer = announcers.getByGUI(gui);
|
||||
if (announcer != null && button != null && button.getData() instanceof Wool) {
|
||||
announcer.clickGroupButton(player, button);
|
||||
}
|
||||
|
@ -33,12 +33,15 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
*/
|
||||
public class AnnouncerStartGameTask extends BukkitRunnable {
|
||||
|
||||
private DungeonsXL plugin;
|
||||
|
||||
private Announcer announcer;
|
||||
private ProgressBar bar;
|
||||
|
||||
public AnnouncerStartGameTask(Announcer announcer) {
|
||||
this.announcer = announcer;
|
||||
public AnnouncerStartGameTask(DungeonsXL plugin, Announcer announcer) {
|
||||
this.plugin = plugin;
|
||||
|
||||
this.announcer = announcer;
|
||||
HashSet<Player> players = new HashSet<>();
|
||||
for (DGroup dGroup : announcer.getDGroups()) {
|
||||
if (dGroup == null) {
|
||||
@ -49,7 +52,7 @@ public class AnnouncerStartGameTask extends BukkitRunnable {
|
||||
}
|
||||
}
|
||||
bar = new ProgressBar(players, 30);
|
||||
bar.runTaskTimer(DungeonsXL.getInstance(), 0L, 20L);
|
||||
bar.send(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,7 +77,7 @@ public class AnnouncerStartGameTask extends BukkitRunnable {
|
||||
}
|
||||
|
||||
if (game == null) {
|
||||
DResourceWorld resource = DungeonsXL.getInstance().getDWorlds().getResourceByName(announcer.getMapName());
|
||||
DResourceWorld resource = plugin.getDWorldCache().getResourceByName(announcer.getMapName());
|
||||
if (resource == null) {
|
||||
dGroup.sendMessage(DMessage.ERROR_NO_SUCH_MAP.getMessage(announcer.getMapName()));
|
||||
cancel();
|
||||
@ -86,7 +89,7 @@ public class AnnouncerStartGameTask extends BukkitRunnable {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
game = new Game(dGroup, gameWorld);
|
||||
game = new Game(plugin, dGroup, gameWorld);
|
||||
} else {
|
||||
game.getDGroups().add(dGroup);
|
||||
}
|
||||
@ -101,7 +104,7 @@ public class AnnouncerStartGameTask extends BukkitRunnable {
|
||||
}
|
||||
|
||||
for (Player player : game.getPlayers()) {
|
||||
new DGamePlayer(player, game.getWorld());
|
||||
new DGamePlayer(plugin, player, game.getWorld());
|
||||
}
|
||||
|
||||
announcer.endStartTask();
|
||||
|
@ -29,11 +29,15 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
*/
|
||||
public class AnnouncerTask extends BukkitRunnable {
|
||||
|
||||
private DungeonsXL plugin;
|
||||
|
||||
private List<Announcer> announcers;
|
||||
private int index;
|
||||
|
||||
public AnnouncerTask(AnnouncerCache announcers) {
|
||||
this.announcers = announcers.getAnnouncers();
|
||||
public AnnouncerTask(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
this.announcers = plugin.getAnnouncerCache().getAnnouncers();
|
||||
index = 0;
|
||||
}
|
||||
|
||||
@ -42,7 +46,7 @@ public class AnnouncerTask extends BukkitRunnable {
|
||||
Announcer announcer = announcers.get(index);
|
||||
List<String> worlds = announcer.getWorlds();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
DGlobalPlayer dPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player);
|
||||
DGlobalPlayer dPlayer = plugin.getDPlayerCache().getByPlayer(player);
|
||||
if (!(dPlayer instanceof DInstancePlayer) && dPlayer.isAnnouncerEnabled()) {
|
||||
if (worlds.isEmpty() || worlds.contains(player.getWorld().getName())) {
|
||||
announcer.send(player);
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.player.DGlobalPlayer;
|
||||
@ -28,9 +27,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class BreakCommand extends DRECommand {
|
||||
public class BreakCommand extends DCommand {
|
||||
|
||||
public BreakCommand() {
|
||||
public BreakCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("break");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(0);
|
||||
@ -42,7 +42,7 @@ public class BreakCommand extends DRECommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DGlobalPlayer dGlobalPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player);
|
||||
DGlobalPlayer dGlobalPlayer = dPlayers.getByPlayer(player);
|
||||
|
||||
if (dGlobalPlayer.isInBreakMode()) {
|
||||
dGlobalPlayer.setInBreakMode(false);
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.player.DEditPlayer;
|
||||
@ -30,9 +29,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class ChatCommand extends DRECommand {
|
||||
public class ChatCommand extends DCommand {
|
||||
|
||||
public ChatCommand() {
|
||||
public ChatCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("chat");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(0);
|
||||
@ -44,7 +44,7 @@ public class ChatCommand extends DRECommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DGlobalPlayer dPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player);
|
||||
DGlobalPlayer dPlayer = dPlayers.getByPlayer(player);
|
||||
|
||||
if (DGroup.getByPlayer(player) == null && !(dPlayer instanceof DEditPlayer)) {
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_JOIN_GROUP.getMessage());
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.player.DGlobalPlayer;
|
||||
@ -28,9 +27,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class ChatSpyCommand extends DRECommand {
|
||||
public class ChatSpyCommand extends DCommand {
|
||||
|
||||
public ChatSpyCommand() {
|
||||
public ChatSpyCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("chatSpy");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(0);
|
||||
@ -42,7 +42,7 @@ public class ChatSpyCommand extends DRECommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DGlobalPlayer dPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player);
|
||||
DGlobalPlayer dPlayer = dPlayers.getByPlayer(player);
|
||||
|
||||
dPlayer.setInChatSpyMode(!dPlayer.isInChatSpyMode());
|
||||
MessageUtil.sendMessage(player, (dPlayer.isInChatSpyMode() ? DMessage.CMD_CHATSPY_START : DMessage.CMD_CHATSPY_STOPPED).getMessage());
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.player.DEditPlayer;
|
||||
@ -33,11 +32,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class CreateCommand extends DRECommand {
|
||||
public class CreateCommand extends DCommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
public CreateCommand() {
|
||||
public CreateCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setMinArgs(1);
|
||||
setMaxArgs(1);
|
||||
setCommand("create");
|
||||
@ -67,8 +65,8 @@ public class CreateCommand extends DRECommand {
|
||||
MessageUtil.log(plugin, DMessage.LOG_GENERATE_NEW_WORLD.getMessage());
|
||||
|
||||
// Create World
|
||||
DResourceWorld resource = new DResourceWorld(plugin.getDWorlds(), name);
|
||||
plugin.getDWorlds().addResource(resource);
|
||||
DResourceWorld resource = new DResourceWorld(plugin, name);
|
||||
instances.addResource(resource);
|
||||
DEditWorld editWorld = resource.generate();
|
||||
editWorld.save();
|
||||
editWorld.delete();
|
||||
@ -89,15 +87,15 @@ public class CreateCommand extends DRECommand {
|
||||
MessageUtil.log(plugin, DMessage.LOG_GENERATE_NEW_WORLD.getMessage());
|
||||
|
||||
// Create World
|
||||
DResourceWorld resource = new DResourceWorld(plugin.getDWorlds(), name);
|
||||
plugin.getDWorlds().addResource(resource);
|
||||
DResourceWorld resource = new DResourceWorld(plugin, name);
|
||||
instances.addResource(resource);
|
||||
DEditWorld editWorld = resource.generate();
|
||||
|
||||
// MSG Done
|
||||
MessageUtil.log(plugin, DMessage.LOG_WORLD_GENERATION_FINISHED.getMessage());
|
||||
|
||||
// Tp Player
|
||||
new DEditPlayer(player, editWorld);
|
||||
new DEditPlayer(plugin, player, editWorld);
|
||||
}
|
||||
}
|
||||
|
||||
|
42
src/main/java/de/erethon/dungeonsxl/command/DCommand.java
Normal file
42
src/main/java/de/erethon/dungeonsxl/command/DCommand.java
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2018 Frank Baumann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.MainConfig;
|
||||
import de.erethon.dungeonsxl.player.DPlayerCache;
|
||||
import de.erethon.dungeonsxl.world.DWorldCache;
|
||||
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public abstract class DCommand extends DRECommand {
|
||||
|
||||
protected DungeonsXL plugin;
|
||||
protected MainConfig config;
|
||||
protected DPlayerCache dPlayers;
|
||||
protected DWorldCache instances;
|
||||
|
||||
protected DCommand(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
config = plugin.getMainConfig();
|
||||
dPlayers = plugin.getDPlayerCache();
|
||||
instances = plugin.getDWorldCache();
|
||||
}
|
||||
|
||||
}
|
@ -19,7 +19,6 @@ package de.erethon.dungeonsxl.command;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.commons.command.DRECommandCache;
|
||||
import de.erethon.commons.compatibility.CompatibilityHandler;
|
||||
import de.erethon.commons.javaplugin.DREPlugin;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
|
||||
/**
|
||||
@ -29,72 +28,104 @@ import de.erethon.dungeonsxl.DungeonsXL;
|
||||
*/
|
||||
public class DCommandCache extends DRECommandCache {
|
||||
|
||||
public static BreakCommand BREAK = new BreakCommand();
|
||||
public static ChatCommand CHAT = new ChatCommand();
|
||||
public static ChatSpyCommand CHAT_SPY = new ChatSpyCommand();
|
||||
public static CreateCommand CREATE = new CreateCommand();
|
||||
public static EditCommand EDIT = new EditCommand();
|
||||
public static EnterCommand ENTER = new EnterCommand();
|
||||
public static EscapeCommand ESCAPE = new EscapeCommand();
|
||||
public static DeleteCommand DELETE = new DeleteCommand();
|
||||
public static DungeonItemCommand DUNGEON_ITEM = new DungeonItemCommand();
|
||||
public static GameCommand GAME = new GameCommand();
|
||||
public static GroupCommand GROUP = new GroupCommand();
|
||||
public static HelpCommand HELP = new HelpCommand();
|
||||
public static ImportCommand IMPORT = new ImportCommand();
|
||||
public static InviteCommand INVITE = new InviteCommand();
|
||||
public static JoinCommand JOIN = new JoinCommand();
|
||||
public static KickCommand KICK = new KickCommand();
|
||||
public static LeaveCommand LEAVE = new LeaveCommand();
|
||||
public static ListCommand LIST = new ListCommand();
|
||||
public static LivesCommand LIVES = new LivesCommand();
|
||||
public static MainCommand MAIN = new MainCommand();
|
||||
public static MsgCommand MESSAGE = new MsgCommand();
|
||||
public static PlayCommand PLAY = new PlayCommand();
|
||||
public static PortalCommand PORTAL = new PortalCommand();
|
||||
public static DRECommand RELOAD = CompatibilityHandler.getInstance().isSpigot() ? new ReloadCommand() : new ReloadCommandNoSpigot();
|
||||
public static RenameCommand RENAME = new RenameCommand();
|
||||
public static ResourcePackCommand RESOURCE_PACK = new ResourcePackCommand();
|
||||
public static SaveCommand SAVE = new SaveCommand();
|
||||
public static StatusCommand STATUS = new StatusCommand();
|
||||
public static TestCommand TEST = new TestCommand();
|
||||
public static UninviteCommand UNINVITE = new UninviteCommand();
|
||||
public static final String LABEL = "dungeonsxl";
|
||||
|
||||
public DCommandCache(DREPlugin plugin) {
|
||||
super("dungeonsxl", plugin,
|
||||
BREAK,
|
||||
CREATE,
|
||||
DELETE,
|
||||
DUNGEON_ITEM,
|
||||
EDIT,
|
||||
ENTER,
|
||||
ESCAPE,
|
||||
GAME,
|
||||
GROUP,
|
||||
HELP,
|
||||
IMPORT,
|
||||
INVITE,
|
||||
JOIN,
|
||||
KICK,
|
||||
LEAVE,
|
||||
LIST,
|
||||
LIVES,
|
||||
MAIN,
|
||||
MESSAGE,
|
||||
PLAY,
|
||||
PORTAL,
|
||||
RELOAD,
|
||||
RENAME,
|
||||
RESOURCE_PACK,
|
||||
SAVE,
|
||||
STATUS,
|
||||
TEST,
|
||||
UNINVITE,
|
||||
new DeletePortalCommand()
|
||||
);
|
||||
if (DungeonsXL.getInstance().getMainConfig().isChatEnabled()) {
|
||||
addCommand(CHAT);
|
||||
addCommand(CHAT_SPY);
|
||||
public BreakCommand breakCmd;
|
||||
public ChatCommand chat;
|
||||
public ChatSpyCommand chatSpy;
|
||||
public CreateCommand create;
|
||||
public EditCommand edit;
|
||||
public EnterCommand enter;
|
||||
public EscapeCommand escape;
|
||||
public DeleteCommand delete;
|
||||
public DungeonItemCommand dungeonItem;
|
||||
public GameCommand game;
|
||||
public GroupCommand group;
|
||||
public HelpCommand help;
|
||||
public ImportCommand importCmd;
|
||||
public InviteCommand invite;
|
||||
public JoinCommand join;
|
||||
public KickCommand kick;
|
||||
public LeaveCommand leave;
|
||||
public ListCommand list;
|
||||
public LivesCommand lives;
|
||||
public MainCommand main;
|
||||
public MsgCommand message;
|
||||
public PlayCommand play;
|
||||
public PortalCommand portal;
|
||||
public DRECommand reload;
|
||||
public RenameCommand rename;
|
||||
public ResourcePackCommand resourcePack;
|
||||
public SaveCommand save;
|
||||
public StatusCommand status;
|
||||
public TestCommand test;
|
||||
public UninviteCommand uninvite;
|
||||
|
||||
public DCommandCache(DungeonsXL plugin) {
|
||||
super(LABEL, plugin);
|
||||
|
||||
breakCmd = new BreakCommand(plugin);
|
||||
chat = new ChatCommand(plugin);
|
||||
chatSpy = new ChatSpyCommand(plugin);
|
||||
create = new CreateCommand(plugin);
|
||||
edit = new EditCommand(plugin);
|
||||
enter = new EnterCommand(plugin);
|
||||
escape = new EscapeCommand(plugin);
|
||||
delete = new DeleteCommand(plugin);
|
||||
dungeonItem = new DungeonItemCommand(plugin);
|
||||
game = new GameCommand(plugin);
|
||||
group = new GroupCommand(plugin);
|
||||
help = new HelpCommand(plugin);
|
||||
importCmd = new ImportCommand(plugin);
|
||||
invite = new InviteCommand(plugin);
|
||||
join = new JoinCommand(plugin);
|
||||
kick = new KickCommand(plugin);
|
||||
leave = new LeaveCommand(plugin);
|
||||
list = new ListCommand(plugin);
|
||||
lives = new LivesCommand(plugin);
|
||||
main = new MainCommand(plugin);
|
||||
message = new MsgCommand(plugin);
|
||||
play = new PlayCommand(plugin);
|
||||
portal = new PortalCommand(plugin);
|
||||
reload = CompatibilityHandler.getInstance().isSpigot() ? new ReloadCommand(plugin) : new ReloadCommandNoSpigot(plugin);
|
||||
rename = new RenameCommand(plugin);
|
||||
resourcePack = new ResourcePackCommand(plugin);
|
||||
save = new SaveCommand(plugin);
|
||||
status = new StatusCommand(plugin);
|
||||
test = new TestCommand(plugin);
|
||||
uninvite = new UninviteCommand(plugin);
|
||||
|
||||
addCommand(breakCmd);
|
||||
addCommand(create);
|
||||
addCommand(delete);
|
||||
addCommand(dungeonItem);
|
||||
addCommand(edit);
|
||||
addCommand(enter);
|
||||
addCommand(escape);
|
||||
addCommand(game);
|
||||
addCommand(group);
|
||||
addCommand(help);
|
||||
addCommand(importCmd);
|
||||
addCommand(invite);
|
||||
addCommand(join);
|
||||
addCommand(kick);
|
||||
addCommand(leave);
|
||||
addCommand(list);
|
||||
addCommand(lives);
|
||||
addCommand(main);
|
||||
addCommand(message);
|
||||
addCommand(play);
|
||||
addCommand(portal);
|
||||
addCommand(reload);
|
||||
addCommand(rename);
|
||||
addCommand(resourcePack);
|
||||
addCommand(save);
|
||||
addCommand(status);
|
||||
addCommand(test);
|
||||
addCommand(uninvite);
|
||||
if (plugin.getMainConfig().isChatEnabled()) {
|
||||
addCommand(chat);
|
||||
addCommand(chatSpy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.commons.compatibility.CompatibilityHandler;
|
||||
import de.erethon.commons.misc.FileUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
@ -25,7 +24,6 @@ import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.player.DPermission;
|
||||
import de.erethon.dungeonsxl.world.DEditWorld;
|
||||
import de.erethon.dungeonsxl.world.DResourceWorld;
|
||||
import de.erethon.dungeonsxl.world.DWorldCache;
|
||||
import java.io.File;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
@ -35,9 +33,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class DeleteCommand extends DRECommand {
|
||||
public class DeleteCommand extends DCommand {
|
||||
|
||||
public DeleteCommand() {
|
||||
public DeleteCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("delete");
|
||||
setMinArgs(1);
|
||||
setMaxArgs(2);
|
||||
@ -49,9 +48,7 @@ public class DeleteCommand extends DRECommand {
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
DWorldCache dWorlds = DungeonsXL.getInstance().getDWorlds();
|
||||
|
||||
DResourceWorld resource = dWorlds.getResourceByName(args[1]);
|
||||
DResourceWorld resource = instances.getResourceByName(args[1]);
|
||||
if (resource == null) {
|
||||
MessageUtil.sendMessage(sender, DMessage.ERROR_NO_SUCH_MAP.getMessage(args[1]));
|
||||
return;
|
||||
@ -72,12 +69,12 @@ public class DeleteCommand extends DRECommand {
|
||||
return;
|
||||
}
|
||||
|
||||
for (DEditWorld editWorld : dWorlds.getEditWorlds()) {
|
||||
for (DEditWorld editWorld : instances.getEditWorlds()) {
|
||||
if (editWorld.getResource().equals(resource)) {
|
||||
editWorld.delete(false);
|
||||
}
|
||||
}
|
||||
dWorlds.removeResource(resource);
|
||||
instances.removeResource(resource);
|
||||
FileUtil.removeDir(resource.getFolder());
|
||||
|
||||
if (args[2].equalsIgnoreCase("true")) {
|
||||
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2018 Frank Baumann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.global.DPortal;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
* @deprecated Use BreakCommand instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class DeletePortalCommand extends DRECommand {
|
||||
|
||||
public DeletePortalCommand() {
|
||||
setCommand("deleteportal");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(0);
|
||||
setHelp("/dxl deleteportal - Deletes the portal you are looking at");
|
||||
setPermission("dxl.portal");
|
||||
setPlayerCommand(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DPortal dPortal = DPortal.getByLocation(player.getTargetBlock((Set<Material>) null, 20).getLocation());
|
||||
|
||||
if (dPortal != null) {
|
||||
dPortal.delete();
|
||||
MessageUtil.sendMessage(player, DMessage.PLAYER_PROTECTED_BLOCK_DELETED.getMessage());
|
||||
|
||||
} else {
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_NO_PROTECTED_BLOCK.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.player.DPermission;
|
||||
import de.erethon.dungeonsxl.util.NBTUtil;
|
||||
@ -29,9 +29,10 @@ import org.bukkit.inventory.PlayerInventory;
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class DungeonItemCommand extends DRECommand {
|
||||
public class DungeonItemCommand extends DCommand {
|
||||
|
||||
public DungeonItemCommand() {
|
||||
public DungeonItemCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("dungeonItem");
|
||||
setAliases("di");
|
||||
setMinArgs(0);
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.player.DEditPlayer;
|
||||
@ -27,18 +26,16 @@ import de.erethon.dungeonsxl.player.DInstancePlayer;
|
||||
import de.erethon.dungeonsxl.player.DPermission;
|
||||
import de.erethon.dungeonsxl.world.DEditWorld;
|
||||
import de.erethon.dungeonsxl.world.DResourceWorld;
|
||||
import de.erethon.dungeonsxl.world.DWorldCache;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
||||
*/
|
||||
public class EditCommand extends DRECommand {
|
||||
public class EditCommand extends DCommand {
|
||||
|
||||
DWorldCache worlds = DungeonsXL.getInstance().getDWorlds();
|
||||
|
||||
public EditCommand() {
|
||||
public EditCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("edit");
|
||||
setMinArgs(1);
|
||||
setMaxArgs(1);
|
||||
@ -51,12 +48,12 @@ public class EditCommand extends DRECommand {
|
||||
Player player = (Player) sender;
|
||||
String mapName = args[1];
|
||||
|
||||
if (!worlds.exists(mapName)) {
|
||||
if (!instances.exists(mapName)) {
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_DUNGEON_NOT_EXIST.getMessage(mapName));
|
||||
return;
|
||||
}
|
||||
|
||||
DResourceWorld resource = worlds.getResourceByName(mapName);
|
||||
DResourceWorld resource = instances.getResourceByName(mapName);
|
||||
if (resource == null) {
|
||||
MessageUtil.sendMessage(sender, DMessage.ERROR_NO_SUCH_MAP.getMessage(mapName));
|
||||
return;
|
||||
@ -74,7 +71,7 @@ public class EditCommand extends DRECommand {
|
||||
}
|
||||
|
||||
DGroup dGroup = DGroup.getByPlayer(player);
|
||||
DGlobalPlayer dPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player);
|
||||
DGlobalPlayer dPlayer = dPlayers.getByPlayer(player);
|
||||
|
||||
if (dPlayer instanceof DInstancePlayer) {
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_DUNGEON.getMessage());
|
||||
@ -86,7 +83,7 @@ public class EditCommand extends DRECommand {
|
||||
return;
|
||||
}
|
||||
|
||||
new DEditPlayer(player, editWorld);
|
||||
new DEditPlayer(plugin, player, editWorld);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.game.Game;
|
||||
import de.erethon.dungeonsxl.player.DGamePlayer;
|
||||
@ -30,9 +30,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class EnterCommand extends DRECommand {
|
||||
public class EnterCommand extends DCommand {
|
||||
|
||||
public EnterCommand() {
|
||||
public EnterCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setMinArgs(1);
|
||||
setMaxArgs(2);
|
||||
setCommand("enter");
|
||||
@ -73,7 +74,7 @@ public class EnterCommand extends DRECommand {
|
||||
}
|
||||
|
||||
if (joining == null) {
|
||||
joining = new DGroup(captain, game.getDungeon());
|
||||
joining = new DGroup(plugin, captain, game.getDungeon());
|
||||
}
|
||||
|
||||
if (joining.getCaptain() != captain && !DPermission.hasPermission(sender, DPermission.BYPASS)) {
|
||||
@ -86,7 +87,7 @@ public class EnterCommand extends DRECommand {
|
||||
joining.sendMessage(DMessage.CMD_ENTER_SUCCESS.getMessage(joining.getName(), target.getName()));
|
||||
|
||||
for (Player player : joining.getPlayers().getOnlinePlayers()) {
|
||||
new DGamePlayer(player, game.getWorld(), game.getType());
|
||||
new DGamePlayer(plugin, player, game.getWorld(), game.getType());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.player.DEditPlayer;
|
||||
import de.erethon.dungeonsxl.player.DGamePlayer;
|
||||
@ -30,9 +30,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Milan Albrecht, Daniel Saukel
|
||||
*/
|
||||
public class EscapeCommand extends DRECommand {
|
||||
public class EscapeCommand extends DCommand {
|
||||
|
||||
public EscapeCommand() {
|
||||
public EscapeCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("escape");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(0);
|
||||
|
@ -17,7 +17,7 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.game.Game;
|
||||
import de.erethon.dungeonsxl.player.DGroup;
|
||||
@ -29,9 +29,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class GameCommand extends DRECommand {
|
||||
public class GameCommand extends DCommand {
|
||||
|
||||
public GameCommand() {
|
||||
public GameCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("game");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(0);
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
||||
@ -33,9 +32,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class GroupCommand extends DRECommand {
|
||||
public class GroupCommand extends DCommand {
|
||||
|
||||
public GroupCommand() {
|
||||
public GroupCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("group");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(2);
|
||||
@ -122,7 +122,7 @@ public class GroupCommand extends DRECommand {
|
||||
return;
|
||||
}
|
||||
|
||||
DGroup dGroup = new DGroup(args[2], player);
|
||||
DGroup dGroup = new DGroup(plugin, args[2], player);
|
||||
DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.COMMAND);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
@ -266,7 +266,7 @@ public class GroupCommand extends DRECommand {
|
||||
}
|
||||
|
||||
public void showHelp(String page) {
|
||||
MessageUtil.sendPluginTag(sender, DungeonsXL.getInstance());
|
||||
MessageUtil.sendPluginTag(sender, plugin);
|
||||
switch (page) {
|
||||
default:
|
||||
MessageUtil.sendCenteredMessage(sender, "&4&l[ &61-5 &4/ &67 &4| &61 &4&l]");
|
||||
|
@ -29,11 +29,10 @@ import org.bukkit.command.CommandSender;
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class HelpCommand extends DRECommand {
|
||||
public class HelpCommand extends DCommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
public HelpCommand() {
|
||||
public HelpCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("help");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(1);
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.commons.misc.FileUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
@ -32,11 +31,10 @@ import org.bukkit.command.CommandSender;
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class ImportCommand extends DRECommand {
|
||||
public class ImportCommand extends DCommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
public ImportCommand() {
|
||||
public ImportCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setMinArgs(1);
|
||||
setMaxArgs(1);
|
||||
setCommand("import");
|
||||
@ -71,12 +69,12 @@ public class ImportCommand extends DRECommand {
|
||||
|
||||
FileUtil.copyDir(source, target, "playerdata", "stats");
|
||||
|
||||
DResourceWorld resource = new DResourceWorld(plugin.getDWorlds(), args[1]);
|
||||
DResourceWorld resource = new DResourceWorld(plugin, args[1]);
|
||||
if (world.getEnvironment() != Environment.NORMAL) {
|
||||
resource.getConfig(true).setWorldEnvironment(world.getEnvironment());
|
||||
resource.getConfig().save();
|
||||
}
|
||||
plugin.getDWorlds().addResource(resource);
|
||||
instances.addResource(resource);
|
||||
MessageUtil.sendMessage(sender, DMessage.CMD_IMPORT_SUCCESS.getMessage(args[1]));
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.player.DPermission;
|
||||
@ -29,9 +28,10 @@ import org.bukkit.command.CommandSender;
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class InviteCommand extends DRECommand {
|
||||
public class InviteCommand extends DCommand {
|
||||
|
||||
public InviteCommand() {
|
||||
public InviteCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setMinArgs(2);
|
||||
setMaxArgs(2);
|
||||
setCommand("invite");
|
||||
@ -43,7 +43,7 @@ public class InviteCommand extends DRECommand {
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
DResourceWorld resource = DungeonsXL.getInstance().getDWorlds().getResourceByName(args[2]);
|
||||
DResourceWorld resource = instances.getResourceByName(args[2]);
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]);
|
||||
|
||||
if (resource != null) {
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.announcer.Announcer;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
@ -30,9 +29,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class JoinCommand extends DRECommand {
|
||||
public class JoinCommand extends DCommand {
|
||||
|
||||
public JoinCommand() {
|
||||
public JoinCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("join");
|
||||
setMinArgs(1);
|
||||
setMaxArgs(1);
|
||||
@ -43,13 +43,13 @@ public class JoinCommand extends DRECommand {
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
DGlobalPlayer player = DungeonsXL.getInstance().getDPlayers().getByPlayer((Player) sender);
|
||||
DGlobalPlayer player = dPlayers.getByPlayer((Player) sender);
|
||||
if (player instanceof DInstancePlayer) {
|
||||
MessageUtil.sendMessage(sender, DMessage.ERROR_LEAVE_GAME.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
Announcer announcer = DungeonsXL.getInstance().getAnnouncers().getByName(args[1]);
|
||||
Announcer announcer = plugin.getAnnouncerCache().getByName(args[1]);
|
||||
if (announcer != null) {
|
||||
announcer.showGUI((Player) sender);
|
||||
}
|
||||
|
@ -17,8 +17,7 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import static de.erethon.dungeonsxl.command.DCommandCache.LEAVE;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.player.DPermission;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -28,9 +27,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class KickCommand extends DRECommand {
|
||||
public class KickCommand extends DCommand {
|
||||
|
||||
public KickCommand() {
|
||||
public KickCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("kick");
|
||||
setMinArgs(1);
|
||||
setMaxArgs(1);
|
||||
@ -45,7 +45,7 @@ public class KickCommand extends DRECommand {
|
||||
Player player = Bukkit.getPlayer(args[1]);
|
||||
|
||||
if (player != null) {
|
||||
LEAVE.onExecute(new String[]{LEAVE.getCommand()}, player);
|
||||
plugin.getCommandCache().leave.onExecute(new String[]{plugin.getCommandCache().leave.getCommand()}, player);
|
||||
MessageUtil.sendMessage(sender, DMessage.CMD_KICK_SUCCESS.getMessage(player.getName()));
|
||||
|
||||
} else {
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.event.dplayer.DPlayerLeaveDGroupEvent;
|
||||
@ -36,9 +35,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class LeaveCommand extends DRECommand {
|
||||
public class LeaveCommand extends DCommand {
|
||||
|
||||
public LeaveCommand() {
|
||||
public LeaveCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("leave");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(0);
|
||||
@ -50,7 +50,7 @@ public class LeaveCommand extends DRECommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DGlobalPlayer dPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player);
|
||||
DGlobalPlayer dPlayer = dPlayers.getByPlayer(player);
|
||||
Game game = Game.getByPlayer(player);
|
||||
|
||||
if (game != null && game.isTutorial()) {
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.commons.misc.NumberUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
@ -36,12 +35,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class ListCommand extends DRECommand {
|
||||
public class ListCommand extends DCommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
DWorldCache worlds = plugin.getDWorlds();
|
||||
|
||||
public ListCommand() {
|
||||
public ListCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("list");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(3);
|
||||
@ -54,7 +51,7 @@ public class ListCommand extends DRECommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
ArrayList<String> dungeonList = new ArrayList<>();
|
||||
for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
|
||||
for (Dungeon dungeon : plugin.getDungeonCache().getDungeons()) {
|
||||
dungeonList.add(dungeon.getName());
|
||||
}
|
||||
ArrayList<String> mapList = new ArrayList<>();
|
||||
@ -64,10 +61,10 @@ public class ListCommand extends DRECommand {
|
||||
}
|
||||
}
|
||||
ArrayList<String> loadedList = new ArrayList<>();
|
||||
for (DEditWorld editWorld : worlds.getEditWorlds()) {
|
||||
for (DEditWorld editWorld : instances.getEditWorlds()) {
|
||||
loadedList.add(editWorld.getWorld().getWorldFolder().getName() + " / " + editWorld.getName());
|
||||
}
|
||||
for (DGameWorld gameWorld : worlds.getGameWorlds()) {
|
||||
for (DGameWorld gameWorld : instances.getGameWorlds()) {
|
||||
loadedList.add(gameWorld.getWorld().getWorldFolder().getName() + " / " + gameWorld.getName());
|
||||
}
|
||||
ArrayList<String> toSend = new ArrayList<>();
|
||||
@ -78,7 +75,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 = plugin.getDungeons().getByName(args[2]);
|
||||
Dungeon dungeon = plugin.getDungeonCache().getByName(args[2]);
|
||||
if (dungeon != null) {
|
||||
MessageUtil.sendPluginTag(sender, plugin);
|
||||
MessageUtil.sendCenteredMessage(sender, "&4&l[ &6" + dungeon.getName() + " &4&l]");
|
||||
@ -133,7 +130,7 @@ public class ListCommand extends DRECommand {
|
||||
for (String map : toSend) {
|
||||
boolean invited = false;
|
||||
if (sender instanceof Player) {
|
||||
DResourceWorld resource = worlds.getResourceByName(map);
|
||||
DResourceWorld resource = instances.getResourceByName(map);
|
||||
if (resource != null) {
|
||||
invited = resource.isInvitedPlayer((Player) sender);
|
||||
}
|
||||
@ -145,7 +142,7 @@ public class ListCommand extends DRECommand {
|
||||
case 1:
|
||||
MessageUtil.sendMessage(sender, "&4Dungeon&7 | &eMap count");
|
||||
for (String dungeon : toSend) {
|
||||
DungeonConfig dungeonConfig = new DungeonConfig(new File(DungeonsXL.DUNGEONS, dungeon + ".yml"));
|
||||
DungeonConfig dungeonConfig = new DungeonConfig(plugin, new File(DungeonsXL.DUNGEONS, dungeon + ".yml"));
|
||||
int count = dungeonConfig.getFloors().size() + 2;
|
||||
MessageUtil.sendMessage(sender, "&b" + dungeon + "&7 | &e" + count);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.player.DGamePlayer;
|
||||
import de.erethon.dungeonsxl.player.DGroup;
|
||||
@ -29,9 +29,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class LivesCommand extends DRECommand {
|
||||
public class LivesCommand extends DCommand {
|
||||
|
||||
public LivesCommand() {
|
||||
public LivesCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("lives");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(1);
|
||||
|
@ -18,7 +18,6 @@ package de.erethon.dungeonsxl.command;
|
||||
|
||||
import static de.erethon.commons.chat.FatLetter.*;
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.commons.compatibility.CompatibilityHandler;
|
||||
import de.erethon.commons.compatibility.Internals;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
@ -31,11 +30,10 @@ import org.bukkit.plugin.PluginManager;
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class MainCommand extends DRECommand {
|
||||
public class MainCommand extends DCommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
public MainCommand() {
|
||||
public MainCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("main");
|
||||
setHelp(DMessage.HELP_CMD_MAIN.getMessage());
|
||||
setPermission(DPermission.MAIN.getNode());
|
||||
@ -49,8 +47,8 @@ public class MainCommand extends DRECommand {
|
||||
|
||||
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 = instances.getEditWorlds().size() + instances.getGameWorlds().size();
|
||||
int players = dPlayers.getDGamePlayers().size();
|
||||
Internals internals = CompatibilityHandler.getInstance().getInternals();
|
||||
String vault = "";
|
||||
if (plugins.getPlugin("Vault") != null) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.player.DPermission;
|
||||
import de.erethon.dungeonsxl.world.DEditWorld;
|
||||
@ -29,9 +29,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class MsgCommand extends DRECommand {
|
||||
public class MsgCommand extends DCommand {
|
||||
|
||||
public MsgCommand() {
|
||||
public MsgCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setMinArgs(-1);
|
||||
setMaxArgs(-1);
|
||||
setCommand("msg");
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.dungeon.Dungeon;
|
||||
@ -37,11 +36,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class PlayCommand extends DRECommand {
|
||||
public class PlayCommand extends DCommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
public PlayCommand() {
|
||||
public PlayCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("play");
|
||||
setMinArgs(1);
|
||||
setMaxArgs(1);
|
||||
@ -54,17 +52,17 @@ public class PlayCommand extends DRECommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||
DGlobalPlayer dPlayer = dPlayers.getByPlayer(player);
|
||||
if (dPlayer instanceof DInstancePlayer) {
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_DUNGEON.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
Dungeon dungeon = plugin.getDungeons().getByName(args[1]);
|
||||
Dungeon dungeon = plugin.getDungeonCache().getByName(args[1]);
|
||||
if (dungeon == null) {
|
||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[1]);
|
||||
DResourceWorld resource = instances.getResourceByName(args[1]);
|
||||
if (resource != null) {
|
||||
dungeon = new Dungeon(resource);
|
||||
dungeon = new Dungeon(plugin, resource);
|
||||
} else {
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_DUNGEON_NOT_EXIST.getMessage(args[1]));
|
||||
return;
|
||||
@ -76,11 +74,11 @@ public class PlayCommand extends DRECommand {
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_GROUP.getMessage());
|
||||
return;
|
||||
} else if (dGroup == null) {
|
||||
dGroup = new DGroup(player, dungeon);
|
||||
dGroup = new DGroup(plugin, player, dungeon);
|
||||
DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.COMMAND);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
plugin.getDGroups().remove(dGroup);
|
||||
plugin.getDGroupCache().remove(dGroup);
|
||||
dGroup = null;
|
||||
}
|
||||
}
|
||||
@ -95,9 +93,9 @@ public class PlayCommand extends DRECommand {
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_TOO_MANY_INSTANCES.getMessage());
|
||||
return;
|
||||
}
|
||||
new Game(dGroup, gameWorld);
|
||||
new Game(plugin, dGroup, gameWorld);
|
||||
for (Player groupPlayer : dGroup.getPlayers().getOnlinePlayers()) {
|
||||
new DGamePlayer(groupPlayer, dGroup.getGameWorld());
|
||||
new DGamePlayer(plugin, groupPlayer, dGroup.getGameWorld());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,6 @@ import de.erethon.caliburn.CaliburnAPI;
|
||||
import de.erethon.caliburn.item.ExItem;
|
||||
import de.erethon.caliburn.item.VanillaItem;
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.global.DPortal;
|
||||
@ -33,12 +32,12 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class PortalCommand extends DRECommand {
|
||||
public class PortalCommand extends DCommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
CaliburnAPI caliburn = plugin.getCaliburn();
|
||||
|
||||
public PortalCommand() {
|
||||
public PortalCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("portal");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(1);
|
||||
@ -50,7 +49,7 @@ public class PortalCommand extends DRECommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DGlobalPlayer dGlobalPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||
DGlobalPlayer dGlobalPlayer = dPlayers.getByPlayer(player);
|
||||
|
||||
if (dGlobalPlayer instanceof DGamePlayer) {
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_DUNGEON.getMessage());
|
||||
@ -70,7 +69,7 @@ public class PortalCommand extends DRECommand {
|
||||
DPortal dPortal = dGlobalPlayer.getPortal();
|
||||
|
||||
if (dPortal == null) {
|
||||
dPortal = new DPortal(plugin.getGlobalProtections().generateId(DPortal.class, player.getWorld()), player.getWorld(), material, false);
|
||||
dPortal = new DPortal(plugin, plugin.getGlobalProtectionCache().generateId(DPortal.class, player.getWorld()), player.getWorld(), material, false);
|
||||
dGlobalPlayer.setCreatingPortal(dPortal);
|
||||
dPortal.setWorld(player.getWorld());
|
||||
dGlobalPlayer.setCachedItem(player.getItemInHand());
|
||||
|
@ -18,7 +18,6 @@ package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.DefaultFontInfo;
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.commons.compatibility.CompatibilityHandler;
|
||||
import de.erethon.commons.compatibility.Internals;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
@ -37,11 +36,10 @@ import org.bukkit.plugin.PluginManager;
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class ReloadCommand extends DRECommand {
|
||||
public class ReloadCommand extends DCommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
public ReloadCommand() {
|
||||
public ReloadCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("reload");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(1);
|
||||
@ -53,8 +51,8 @@ public class ReloadCommand extends DRECommand {
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
List<DInstancePlayer> dPlayers = plugin.getDPlayers().getDInstancePlayers();
|
||||
if (!dPlayers.isEmpty() && args.length == 1 && CompatibilityHandler.getInstance().isSpigot() && sender instanceof Player) {
|
||||
List<DInstancePlayer> dPlayers = this.dPlayers.getDInstancePlayers();
|
||||
if (!dPlayers.isEmpty() && args.length == 1 && sender instanceof Player) {
|
||||
MessageUtil.sendMessage(sender, DMessage.CMD_RELOAD_PLAYERS.getMessage());
|
||||
ClickEvent onClick = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/dungeonsxl reload -force");
|
||||
String message = DefaultFontInfo.center(DMessage.MISC_OKAY.getMessage());
|
||||
@ -78,8 +76,8 @@ public class ReloadCommand extends DRECommand {
|
||||
|
||||
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 = instances.getEditWorlds().size() + instances.getGameWorlds().size();
|
||||
int players = this.dPlayers.getDGamePlayers().size();
|
||||
Internals internals = CompatibilityHandler.getInstance().getInternals();
|
||||
String vault = "";
|
||||
if (plugins.getPlugin("Vault") != null) {
|
||||
@ -91,7 +89,9 @@ public class ReloadCommand extends DRECommand {
|
||||
}
|
||||
|
||||
plugin.onDisable();
|
||||
plugin.loadCore();
|
||||
plugin.initFolders();
|
||||
plugin.createCaches();
|
||||
plugin.initCaches();
|
||||
plugin.loadData();
|
||||
|
||||
MessageUtil.sendPluginTag(sender, plugin);
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.commons.compatibility.CompatibilityHandler;
|
||||
import de.erethon.commons.compatibility.Internals;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
@ -33,11 +32,10 @@ import org.bukkit.plugin.PluginManager;
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class ReloadCommandNoSpigot extends DRECommand {
|
||||
public class ReloadCommandNoSpigot extends DCommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
public ReloadCommandNoSpigot() {
|
||||
public ReloadCommandNoSpigot(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("reload");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(1);
|
||||
@ -49,7 +47,7 @@ public class ReloadCommandNoSpigot extends DRECommand {
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
List<DInstancePlayer> dPlayers = plugin.getDPlayers().getDInstancePlayers();
|
||||
List<DInstancePlayer> dPlayers = this.dPlayers.getDInstancePlayers();
|
||||
|
||||
PluginManager plugins = Bukkit.getPluginManager();
|
||||
|
||||
@ -65,8 +63,8 @@ public class ReloadCommandNoSpigot extends DRECommand {
|
||||
|
||||
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 = instances.getEditWorlds().size() + instances.getGameWorlds().size();
|
||||
int players = this.dPlayers.getDGamePlayers().size();
|
||||
Internals internals = CompatibilityHandler.getInstance().getInternals();
|
||||
String vault = "";
|
||||
if (plugins.getPlugin("Vault") != null) {
|
||||
@ -78,7 +76,9 @@ public class ReloadCommandNoSpigot extends DRECommand {
|
||||
}
|
||||
|
||||
plugin.onDisable();
|
||||
plugin.loadCore();
|
||||
plugin.initFolders();
|
||||
plugin.createCaches();
|
||||
plugin.initCaches();
|
||||
plugin.loadData();
|
||||
|
||||
MessageUtil.sendPluginTag(sender, plugin);
|
||||
|
@ -17,14 +17,11 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.dungeon.Dungeon;
|
||||
import de.erethon.dungeonsxl.dungeon.DungeonConfig;
|
||||
import de.erethon.dungeonsxl.global.GameSign;
|
||||
import de.erethon.dungeonsxl.global.GlobalProtection;
|
||||
import de.erethon.dungeonsxl.global.GroupSign;
|
||||
import de.erethon.dungeonsxl.global.JoinSign;
|
||||
import de.erethon.dungeonsxl.player.DPermission;
|
||||
import de.erethon.dungeonsxl.world.DEditWorld;
|
||||
@ -38,11 +35,10 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class RenameCommand extends DRECommand {
|
||||
public class RenameCommand extends DCommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
public RenameCommand() {
|
||||
public RenameCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("rename");
|
||||
setMinArgs(2);
|
||||
setMaxArgs(2);
|
||||
@ -54,7 +50,7 @@ public class RenameCommand extends DRECommand {
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[1]);
|
||||
DResourceWorld resource = instances.getResourceByName(args[1]);
|
||||
if (resource == null) {
|
||||
MessageUtil.sendMessage(sender, DMessage.ERROR_NO_SUCH_MAP.getMessage(args[1]));
|
||||
return;
|
||||
@ -64,13 +60,13 @@ public class RenameCommand extends DRECommand {
|
||||
resource.getFolder().renameTo(new File(DungeonsXL.MAPS, args[2]));
|
||||
resource.getSignData().updateFile(resource);
|
||||
|
||||
for (DEditWorld editWorld : plugin.getDWorlds().getEditWorlds()) {
|
||||
for (DEditWorld editWorld : instances.getEditWorlds()) {
|
||||
if (editWorld.getResource() == resource) {
|
||||
editWorld.delete(true);
|
||||
}
|
||||
}
|
||||
|
||||
for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
|
||||
for (Dungeon dungeon : plugin.getDungeonCache().getDungeons()) {
|
||||
DungeonConfig dConfig = dungeon.getConfig();
|
||||
FileConfiguration config = dConfig.getConfig();
|
||||
File file = dConfig.getFile();
|
||||
@ -100,7 +96,7 @@ public class RenameCommand extends DRECommand {
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
for (GlobalProtection protection : plugin.getGlobalProtections().getProtections().toArray(new GlobalProtection[]{})) {
|
||||
for (GlobalProtection protection : plugin.getGlobalProtectionCache().getProtections().toArray(new GlobalProtection[]{})) {
|
||||
if (!(protection instanceof JoinSign)) {
|
||||
continue;
|
||||
}
|
||||
@ -116,7 +112,7 @@ public class RenameCommand extends DRECommand {
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
plugin.getGlobalProtections().saveAll();
|
||||
plugin.getGlobalProtectionCache().saveAll();
|
||||
}
|
||||
|
||||
MessageUtil.sendMessage(sender, DMessage.CMD_RENAME_SUCCESS.getMessage(args[1], args[2]));
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.player.DPermission;
|
||||
@ -27,9 +26,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class ResourcePackCommand extends DRECommand {
|
||||
public class ResourcePackCommand extends DCommand {
|
||||
|
||||
public ResourcePackCommand() {
|
||||
public ResourcePackCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("resourcepack");
|
||||
setMinArgs(1);
|
||||
setMaxArgs(1);
|
||||
@ -48,7 +48,7 @@ public class ResourcePackCommand extends DRECommand {
|
||||
return;
|
||||
}
|
||||
|
||||
String url = (String) DungeonsXL.getInstance().getMainConfig().getResourcePacks().get(args[1]);
|
||||
String url = (String) config.getResourcePacks().get(args[1]);
|
||||
if (url == null) {
|
||||
MessageUtil.sendMessage(sender, DMessage.ERROR_NO_SUCH_RESOURCE_PACK.getMessage(args[1]));
|
||||
return;
|
||||
|
@ -17,10 +17,8 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.config.MainConfig;
|
||||
import de.erethon.dungeonsxl.config.MainConfig.BackupMode;
|
||||
import de.erethon.dungeonsxl.player.DPermission;
|
||||
import de.erethon.dungeonsxl.world.DEditWorld;
|
||||
@ -30,11 +28,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class SaveCommand extends DRECommand {
|
||||
public class SaveCommand extends DCommand {
|
||||
|
||||
MainConfig mainConfig = DungeonsXL.getInstance().getMainConfig();
|
||||
|
||||
public SaveCommand() {
|
||||
public SaveCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("save");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(0);
|
||||
@ -48,7 +45,7 @@ public class SaveCommand extends DRECommand {
|
||||
Player player = (Player) sender;
|
||||
DEditWorld editWorld = DEditWorld.getByWorld(player.getWorld());
|
||||
if (editWorld != null) {
|
||||
BackupMode backupMode = mainConfig.getBackupMode();
|
||||
BackupMode backupMode = config.getBackupMode();
|
||||
if (backupMode == BackupMode.ON_SAVE || backupMode == BackupMode.ON_DISABLE_AND_SAVE) {
|
||||
editWorld.getResource().backup();
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.commons.compatibility.CompatibilityHandler;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
@ -31,16 +30,16 @@ import org.bukkit.plugin.PluginManager;
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class StatusCommand extends DRECommand {
|
||||
public class StatusCommand extends DCommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
CompatibilityHandler compat = CompatibilityHandler.getInstance();
|
||||
PluginManager manager = Bukkit.getPluginManager();
|
||||
private CompatibilityHandler compat = CompatibilityHandler.getInstance();
|
||||
private PluginManager manager = Bukkit.getPluginManager();
|
||||
|
||||
public static final String TRUE = ChatColor.GREEN + "\u2714";
|
||||
public static final String FALSE = ChatColor.DARK_RED + "\u2718";
|
||||
|
||||
public StatusCommand() {
|
||||
public StatusCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("status");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(0);
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.dungeon.Dungeon;
|
||||
@ -36,9 +35,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class TestCommand extends DRECommand {
|
||||
public class TestCommand extends DCommand {
|
||||
|
||||
public TestCommand() {
|
||||
public TestCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("test");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(0);
|
||||
@ -51,7 +51,7 @@ public class TestCommand extends DRECommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DGlobalPlayer dPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player);
|
||||
DGlobalPlayer dPlayer = dPlayers.getByPlayer(player);
|
||||
|
||||
if (!(dPlayer instanceof DEditPlayer)) {
|
||||
DGroup dGroup = DGroup.getByPlayer(player);
|
||||
@ -85,14 +85,14 @@ public class TestCommand extends DRECommand {
|
||||
DEditPlayer editPlayer = (DEditPlayer) dPlayer;
|
||||
editPlayer.leave();
|
||||
DResourceWorld resource = editPlayer.getEditWorld().getResource();
|
||||
Dungeon dungeon = new Dungeon(resource);
|
||||
Dungeon dungeon = new Dungeon(plugin, resource);
|
||||
DGameWorld instance = resource.instantiateAsGameWorld(false);
|
||||
if (instance == null) {
|
||||
MessageUtil.sendMessage(player, DMessage.ERROR_TOO_MANY_INSTANCES.getMessage());
|
||||
return;
|
||||
}
|
||||
Game game = new Game(new DGroup(player, dungeon), GameTypeDefault.TEST, instance);
|
||||
new DGamePlayer(player, game.getWorld(), GameTypeDefault.TEST);
|
||||
Game game = new Game(plugin, new DGroup(plugin, player, dungeon), GameTypeDefault.TEST, instance);
|
||||
new DGamePlayer(plugin, player, game.getWorld(), GameTypeDefault.TEST);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.command;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.command.DRECommand;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.player.DPermission;
|
||||
@ -29,9 +28,10 @@ import org.bukkit.command.CommandSender;
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class UninviteCommand extends DRECommand {
|
||||
public class UninviteCommand extends DCommand {
|
||||
|
||||
public UninviteCommand() {
|
||||
public UninviteCommand(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
setCommand("uninvite");
|
||||
setMinArgs(2);
|
||||
setMaxArgs(2);
|
||||
@ -43,7 +43,7 @@ public class UninviteCommand extends DRECommand {
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
DResourceWorld resource = DungeonsXL.getInstance().getDWorlds().getResourceByName(args[2]);
|
||||
DResourceWorld resource = instances.getResourceByName(args[2]);
|
||||
if (resource == null) {
|
||||
MessageUtil.sendMessage(sender, DMessage.ERROR_DUNGEON_NOT_EXIST.getMessage(args[2]));
|
||||
return;
|
||||
|
@ -39,6 +39,8 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
*/
|
||||
public class MainConfig extends DREConfig {
|
||||
|
||||
private DungeonsXL plugin;
|
||||
|
||||
public enum BackupMode {
|
||||
ON_DISABLE,
|
||||
ON_DISABLE_AND_SAVE,
|
||||
@ -108,9 +110,11 @@ public class MainConfig extends DREConfig {
|
||||
/* Default Dungeon Settings */
|
||||
private WorldConfig defaultWorldConfig;
|
||||
|
||||
public MainConfig(File file) {
|
||||
public MainConfig(DungeonsXL plugin, File file) {
|
||||
super(file, CONFIG_VERSION);
|
||||
|
||||
this.plugin = plugin;
|
||||
|
||||
if (initialize) {
|
||||
initialize();
|
||||
}
|
||||
@ -234,7 +238,7 @@ public class MainConfig extends DREConfig {
|
||||
*/
|
||||
public Dungeon getTutorialDungeon() {
|
||||
if (tutorialDungeon == null) {
|
||||
tutorialDungeon = DungeonsXL.getInstance().getDungeons().getByName(tutorialDungeonName, true);
|
||||
tutorialDungeon = plugin.getDungeonCache().getByName(tutorialDungeonName, true);
|
||||
}
|
||||
return tutorialDungeon;
|
||||
}
|
||||
@ -695,7 +699,7 @@ public class MainConfig extends DREConfig {
|
||||
/* Default Dungeon Config */
|
||||
ConfigurationSection configSection = config.getConfigurationSection("default");
|
||||
if (configSection != null) {
|
||||
defaultWorldConfig = new WorldConfig(configSection);
|
||||
defaultWorldConfig = new WorldConfig(plugin, configSection);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,8 @@ import java.util.List;
|
||||
*/
|
||||
public class Dungeon {
|
||||
|
||||
private DungeonsXL plugin;
|
||||
|
||||
private String name;
|
||||
private DungeonConfig config;
|
||||
private DResourceWorld map;
|
||||
@ -38,20 +40,26 @@ public class Dungeon {
|
||||
/**
|
||||
* Real dungeon
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
* @param file the file to load from
|
||||
*/
|
||||
public Dungeon(File file) {
|
||||
public Dungeon(DungeonsXL plugin, File file) {
|
||||
this.plugin = plugin;
|
||||
|
||||
name = file.getName().replaceAll(".yml", "");
|
||||
config = new DungeonConfig(file);
|
||||
config = new DungeonConfig(plugin, file);
|
||||
map = config.getStartFloor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Artificial dungeon
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
* @param resource the only resource world
|
||||
*/
|
||||
public Dungeon(DResourceWorld resource) {
|
||||
public Dungeon(DungeonsXL plugin, DResourceWorld resource) {
|
||||
this.plugin = plugin;
|
||||
|
||||
name = resource.getName();
|
||||
map = resource;
|
||||
}
|
||||
@ -113,7 +121,7 @@ public class Dungeon {
|
||||
* @return false if there are setup errors
|
||||
*/
|
||||
public boolean isSetupCorrect() {
|
||||
for (DResourceWorld resource : DungeonsXL.getInstance().getDWorlds().getResources()) {
|
||||
for (DResourceWorld resource : plugin.getDWorldCache().getResources()) {
|
||||
if (resource.getName().equals(name)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -31,17 +31,21 @@ import java.util.List;
|
||||
*/
|
||||
public class DungeonCache {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
private DungeonsXL plugin;
|
||||
|
||||
private List<Dungeon> dungeons = new ArrayList<>();
|
||||
|
||||
public DungeonCache(File folder) {
|
||||
public DungeonCache(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void init(File folder) {
|
||||
if (!folder.exists()) {
|
||||
folder.mkdir();
|
||||
}
|
||||
|
||||
for (File file : folder.listFiles()) {
|
||||
Dungeon dungeon = new Dungeon(file);
|
||||
Dungeon dungeon = new Dungeon(plugin, file);
|
||||
|
||||
if (dungeon.isSetupCorrect()) {
|
||||
dungeons.add(dungeon);
|
||||
@ -73,9 +77,9 @@ public class DungeonCache {
|
||||
}
|
||||
|
||||
if (artificial) {
|
||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(name);
|
||||
DResourceWorld resource = plugin.getDWorldCache().getResourceByName(name);
|
||||
if (resource != null) {
|
||||
return new Dungeon(resource);
|
||||
return new Dungeon(plugin, resource);
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,7 +98,7 @@ public class DungeonCache {
|
||||
* @return the Dungeon that has the name
|
||||
*/
|
||||
public Dungeon loadDungeon(String name) {
|
||||
Dungeon dungeon = new Dungeon(Dungeon.getFileFromName(name));
|
||||
Dungeon dungeon = new Dungeon(plugin, Dungeon.getFileFromName(name));
|
||||
dungeons.add(dungeon);
|
||||
return dungeon;
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ package de.erethon.dungeonsxl.dungeon;
|
||||
import de.erethon.commons.config.DREConfig;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.world.DResourceWorld;
|
||||
import de.erethon.dungeonsxl.world.DWorldCache;
|
||||
import de.erethon.dungeonsxl.world.WorldConfig;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@ -32,7 +31,7 @@ import java.util.List;
|
||||
*/
|
||||
public class DungeonConfig extends DREConfig {
|
||||
|
||||
DWorldCache worlds = DungeonsXL.getInstance().getDWorlds();
|
||||
private DungeonsXL plugin;
|
||||
|
||||
public static final int CONFIG_VERSION = 1;
|
||||
|
||||
@ -44,9 +43,11 @@ public class DungeonConfig extends DREConfig {
|
||||
private WorldConfig overrideValues;
|
||||
private WorldConfig defaultValues;
|
||||
|
||||
public DungeonConfig(File file) {
|
||||
public DungeonConfig(DungeonsXL plugin, File file) {
|
||||
super(file, CONFIG_VERSION);
|
||||
|
||||
this.plugin = plugin;
|
||||
|
||||
if (initialize) {
|
||||
initialize();
|
||||
}
|
||||
@ -176,14 +177,14 @@ public class DungeonConfig extends DREConfig {
|
||||
* @return true if the floor is either in the list or the start / end floor.
|
||||
*/
|
||||
public boolean containsFloor(String mapName) {
|
||||
return containsFloor(worlds.getResourceByName(mapName));
|
||||
return containsFloor(plugin.getDWorldCache().getResourceByName(mapName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
if (config.contains("floors")) {
|
||||
for (String floor : config.getStringList("floors")) {
|
||||
DResourceWorld resource = worlds.getResourceByName(floor);
|
||||
DResourceWorld resource = plugin.getDWorldCache().getResourceByName(floor);
|
||||
if (resource != null) {
|
||||
floors.add(resource);
|
||||
}
|
||||
@ -191,11 +192,11 @@ public class DungeonConfig extends DREConfig {
|
||||
}
|
||||
|
||||
if (config.contains("startFloor")) {
|
||||
startFloor = worlds.getResourceByName(config.getString("startFloor"));
|
||||
startFloor = plugin.getDWorldCache().getResourceByName(config.getString("startFloor"));
|
||||
}
|
||||
|
||||
if (config.contains("endFloor")) {
|
||||
endFloor = worlds.getResourceByName(config.getString("endFloor"));
|
||||
endFloor = plugin.getDWorldCache().getResourceByName(config.getString("endFloor"));
|
||||
}
|
||||
|
||||
if (config.contains("floorCount")) {
|
||||
@ -207,11 +208,11 @@ public class DungeonConfig extends DREConfig {
|
||||
}
|
||||
|
||||
if (config.contains("overrideValues")) {
|
||||
overrideValues = new WorldConfig(config.getConfigurationSection("overrideValues"));
|
||||
overrideValues = new WorldConfig(plugin, config.getConfigurationSection("overrideValues"));
|
||||
}
|
||||
|
||||
if (config.contains("defaultValues")) {
|
||||
defaultValues = new WorldConfig(config.getConfigurationSection("defaultValues"));
|
||||
defaultValues = new WorldConfig(plugin, config.getConfigurationSection("defaultValues"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
*/
|
||||
public class Game {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
private DungeonsXL plugin;
|
||||
|
||||
private boolean tutorial;
|
||||
private List<DGroup> dGroups = new ArrayList<>();
|
||||
@ -59,8 +59,9 @@ public class Game {
|
||||
private Map<String, Integer> gameKills = new HashMap<>();
|
||||
private Map<String, Integer> waveKills = new HashMap<>();
|
||||
|
||||
public Game(DGroup dGroup) {
|
||||
DungeonsXL.getInstance().getGames().add(this);
|
||||
public Game(DungeonsXL plugin, DGroup dGroup) {
|
||||
this.plugin = plugin;
|
||||
plugin.getGameCache().add(this);
|
||||
|
||||
tutorial = false;
|
||||
started = false;
|
||||
@ -73,8 +74,9 @@ public class Game {
|
||||
dGroup.setScore(rules.getInitialScore());
|
||||
}
|
||||
|
||||
public Game(DGroup dGroup, DGameWorld world) {
|
||||
plugin.getGames().add(this);
|
||||
public Game(DungeonsXL plugin, DGroup dGroup, DGameWorld world) {
|
||||
this.plugin = plugin;
|
||||
plugin.getGameCache().add(this);
|
||||
|
||||
tutorial = false;
|
||||
started = false;
|
||||
@ -88,12 +90,13 @@ public class Game {
|
||||
dGroup.setScore(rules.getInitialScore());
|
||||
}
|
||||
|
||||
public Game(DGroup dGroup, GameType type, DGameWorld world) {
|
||||
this(new ArrayList<>(Arrays.asList(dGroup)), type, world);
|
||||
public Game(DungeonsXL plugin, DGroup dGroup, GameType type, DGameWorld world) {
|
||||
this(plugin, new ArrayList<>(Arrays.asList(dGroup)), type, world);
|
||||
}
|
||||
|
||||
public Game(List<DGroup> dGroups, GameType type, DGameWorld world) {
|
||||
plugin.getGames().add(this);
|
||||
public Game(DungeonsXL plugin, List<DGroup> dGroups, GameType type, DGameWorld world) {
|
||||
this.plugin = plugin;
|
||||
plugin.getGameCache().add(this);
|
||||
|
||||
this.dGroups = dGroups;
|
||||
this.type = type;
|
||||
@ -368,9 +371,9 @@ public class Game {
|
||||
* Remove the Game from the List
|
||||
*/
|
||||
public void delete() {
|
||||
GameSign gameSign = GameSign.getByGame(this);
|
||||
GameSign gameSign = GameSign.getByGame(plugin, this);
|
||||
|
||||
plugin.getGames().remove(this);
|
||||
plugin.getGameCache().remove(this);
|
||||
|
||||
if (gameSign != null) {
|
||||
gameSign.update();
|
||||
@ -431,7 +434,7 @@ public class Game {
|
||||
|
||||
/* Statics */
|
||||
public static Game getByDGroup(DGroup dGroup) {
|
||||
for (Game game : DungeonsXL.getInstance().getGames()) {
|
||||
for (Game game : DungeonsXL.getInstance().getGameCache()) {
|
||||
if (game.getDGroups().contains(dGroup)) {
|
||||
return game;
|
||||
}
|
||||
@ -445,7 +448,7 @@ public class Game {
|
||||
}
|
||||
|
||||
public static Game getByGameWorld(DGameWorld gameWorld) {
|
||||
for (Game game : DungeonsXL.getInstance().getGames()) {
|
||||
for (Game game : DungeonsXL.getInstance().getGameCache()) {
|
||||
if (gameWorld.equals(game.getWorld())) {
|
||||
return game;
|
||||
}
|
||||
|
@ -52,19 +52,19 @@ public class DPortal extends GlobalProtection {
|
||||
private boolean active;
|
||||
private Set<Block> blocks;
|
||||
|
||||
public DPortal(int id, World world, boolean active) {
|
||||
this(id, world, VanillaItem.NETHER_PORTAL, active);
|
||||
public DPortal(DungeonsXL plugin, int id, World world, boolean active) {
|
||||
this(plugin, id, world, VanillaItem.NETHER_PORTAL, active);
|
||||
}
|
||||
|
||||
public DPortal(int id, World world, ExItem material, boolean active) {
|
||||
super(world, id);
|
||||
public DPortal(DungeonsXL plugin, int id, World world, ExItem material, boolean active) {
|
||||
super(plugin, world, id);
|
||||
|
||||
this.material = material;
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public DPortal(int id, Block block1, Block block2, ExItem material, byte axis, boolean active) {
|
||||
super(block1.getWorld(), id);
|
||||
public DPortal(DungeonsXL plugin, int id, Block block1, Block block2, ExItem material, byte axis, boolean active) {
|
||||
super(plugin, block1.getWorld(), id);
|
||||
|
||||
this.block1 = block1;
|
||||
this.block2 = block2;
|
||||
@ -233,14 +233,14 @@ public class DPortal extends GlobalProtection {
|
||||
}
|
||||
|
||||
if (game == null) {
|
||||
game = new Game(dGroup, target);
|
||||
game = new Game(plugin, dGroup, target);
|
||||
|
||||
} else {
|
||||
game.setWorld(target);
|
||||
dGroup.setGameWorld(target);
|
||||
}
|
||||
|
||||
new DGamePlayer(player, target);
|
||||
new DGamePlayer(plugin, player, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -332,19 +332,21 @@ public class DPortal extends GlobalProtection {
|
||||
|
||||
/* Statics */
|
||||
/**
|
||||
* @param plugin the plugin instance
|
||||
* @param location a location covered by the returned portal
|
||||
* @return the portal at the location, null if there is none
|
||||
*/
|
||||
public static DPortal getByLocation(Location location) {
|
||||
return getByBlock(location.getBlock());
|
||||
public static DPortal getByLocation(DungeonsXL plugin, Location location) {
|
||||
return getByBlock(plugin, location.getBlock());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param plugin the plugin instance
|
||||
* @param block a block covered by the returned portal
|
||||
* @return the portal that the block belongs to, null if it belongs to none
|
||||
*/
|
||||
public static DPortal getByBlock(Block block) {
|
||||
for (GlobalProtection protection : DungeonsXL.getInstance().getGlobalProtections().getProtections(DPortal.class)) {
|
||||
public static DPortal getByBlock(DungeonsXL plugin, Block block) {
|
||||
for (GlobalProtection protection : plugin.getGlobalProtectionCache().getProtections(DPortal.class)) {
|
||||
DPortal portal = (DPortal) protection;
|
||||
if (portal.getBlock1() == null || portal.getBlock2() == null) {
|
||||
continue;
|
||||
|
@ -45,8 +45,8 @@ public class GameSign extends JoinSign {
|
||||
|
||||
private Game game;
|
||||
|
||||
public GameSign(int id, Block startSign, String identifier, int maxGroupsPerGame) {
|
||||
super(id, startSign, identifier, maxGroupsPerGame);
|
||||
public GameSign(DungeonsXL plugin, int id, Block startSign, String identifier, int maxGroupsPerGame) {
|
||||
super(plugin, id, startSign, identifier, maxGroupsPerGame);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -153,7 +153,7 @@ public class GameSign extends JoinSign {
|
||||
return;
|
||||
}
|
||||
|
||||
game = new Game(dGroup);
|
||||
game = new Game(plugin, dGroup);
|
||||
dGroup.setDungeon(dungeon);
|
||||
update();
|
||||
|
||||
@ -165,15 +165,16 @@ public class GameSign extends JoinSign {
|
||||
|
||||
/* Statics */
|
||||
/**
|
||||
* @param plugin the plugin instance
|
||||
* @param block a block which is protected by the returned GameSign
|
||||
* @return the game sign the block belongs to, null if it belongs to none
|
||||
*/
|
||||
public static GameSign getByBlock(Block block) {
|
||||
public static GameSign getByBlock(DungeonsXL plugin, Block block) {
|
||||
if (!Category.SIGNS.containsBlock(block)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (GlobalProtection protection : DungeonsXL.getInstance().getGlobalProtections().getProtections(GameSign.class)) {
|
||||
for (GlobalProtection protection : plugin.getGlobalProtectionCache().getProtections(GameSign.class)) {
|
||||
GameSign gameSign = (GameSign) protection;
|
||||
Block start = gameSign.startSign;
|
||||
if (start == block || (start.getX() == block.getX() && start.getZ() == block.getZ() && (start.getY() >= block.getY() && start.getY() - gameSign.verticalSigns <= block.getY()))) {
|
||||
@ -185,11 +186,12 @@ public class GameSign extends JoinSign {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param plugin the plugin instance
|
||||
* @param game the game to check
|
||||
* @return the game that this sign creates
|
||||
*/
|
||||
public static GameSign getByGame(Game game) {
|
||||
for (GlobalProtection protection : DungeonsXL.getInstance().getGlobalProtections().getProtections(GameSign.class)) {
|
||||
public static GameSign getByGame(DungeonsXL plugin, Game game) {
|
||||
for (GlobalProtection protection : plugin.getGlobalProtectionCache().getProtections(GameSign.class)) {
|
||||
GameSign gameSign = (GameSign) protection;
|
||||
if (gameSign.game == game) {
|
||||
return gameSign;
|
||||
@ -198,7 +200,7 @@ public class GameSign extends JoinSign {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static GameSign tryToCreate(SignChangeEvent event) {
|
||||
public static GameSign tryToCreate(DungeonsXL plugin, SignChangeEvent event) {
|
||||
if (!event.getLine(0).equalsIgnoreCase(SIGN_TAG)) {
|
||||
return null;
|
||||
}
|
||||
@ -209,10 +211,10 @@ public class GameSign extends JoinSign {
|
||||
String identifier = event.getLine(2);
|
||||
int maxGroupsPerGame = NumberUtil.parseInt(event.getLine(3), 1);
|
||||
|
||||
return tryToCreate(event.getBlock(), identifier, maxGroupsPerGame);
|
||||
return tryToCreate(plugin, event.getBlock(), identifier, maxGroupsPerGame);
|
||||
}
|
||||
|
||||
public static GameSign tryToCreate(Block startSign, String identifier, int maxGroupsPerGame) {
|
||||
public static GameSign tryToCreate(DungeonsXL plugin, Block startSign, String identifier, int maxGroupsPerGame) {
|
||||
World world = startSign.getWorld();
|
||||
BlockFace facing = ((Attachable) startSign.getState().getData()).getAttachedFace().getOppositeFace();
|
||||
int x = startSign.getX(), y = startSign.getY(), z = startSign.getZ();
|
||||
@ -229,7 +231,7 @@ public class GameSign extends JoinSign {
|
||||
|
||||
verticalSigns--;
|
||||
}
|
||||
GameSign sign = new GameSign(DungeonsXL.getInstance().getGlobalProtections().generateId(GameSign.class, world), startSign, identifier, maxGroupsPerGame);
|
||||
GameSign sign = new GameSign(plugin, plugin.getGlobalProtectionCache().generateId(GameSign.class, world), startSign, identifier, maxGroupsPerGame);
|
||||
|
||||
LWCUtil.removeProtection(startSign);
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.erethon.dungeonsxl.config;
|
||||
package de.erethon.dungeonsxl.global;
|
||||
|
||||
import de.erethon.commons.config.DREConfig;
|
||||
import java.io.File;
|
@ -32,15 +32,20 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
*/
|
||||
public abstract class GlobalProtection {
|
||||
|
||||
public static final String SIGN_TAG = "[DXL]";
|
||||
protected DungeonsXL plugin;
|
||||
protected GlobalProtectionCache protections;
|
||||
private FileConfiguration config;
|
||||
|
||||
FileConfiguration config = DungeonsXL.getInstance().getGlobalData().getConfig();
|
||||
GlobalProtectionCache protections = DungeonsXL.getInstance().getGlobalProtections();
|
||||
public static final String SIGN_TAG = "[DXL]";
|
||||
|
||||
private World world;
|
||||
private int id;
|
||||
|
||||
protected GlobalProtection(World world, int id) {
|
||||
protected GlobalProtection(DungeonsXL plugin, World world, int id) {
|
||||
this.plugin = plugin;
|
||||
protections = plugin.getGlobalProtectionCache();
|
||||
config = plugin.getGlobalData().getConfig();
|
||||
|
||||
this.world = world;
|
||||
this.id = id;
|
||||
|
||||
|
@ -36,12 +36,12 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
*/
|
||||
public class GlobalProtectionCache {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
private DungeonsXL plugin;
|
||||
|
||||
private Set<GlobalProtection> protections = new HashSet<>();
|
||||
|
||||
public GlobalProtectionCache() {
|
||||
Bukkit.getPluginManager().registerEvents(new GlobalProtectionListener(), plugin);
|
||||
public GlobalProtectionCache(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -187,7 +187,7 @@ public class GlobalProtectionCache {
|
||||
int maxGroupsPerGame = data.getInt(preString + ".maxGroupsPerGame");
|
||||
Block startSign = world.getBlockAt(data.getInt(preString + ".x"), data.getInt(preString + ".y"), data.getInt(preString + ".z"));
|
||||
|
||||
new GameSign(id, startSign, mapName, maxGroupsPerGame);
|
||||
new GameSign(plugin, id, startSign, mapName, maxGroupsPerGame);
|
||||
}
|
||||
|
||||
} while (data.contains(preString));
|
||||
@ -207,7 +207,7 @@ public class GlobalProtectionCache {
|
||||
int maxPlayersPerGroup = data.getInt(preString + ".maxPlayersPerGroup");
|
||||
Block startSign = world.getBlockAt(data.getInt(preString + ".x"), data.getInt(preString + ".y"), data.getInt(preString + ".z"));
|
||||
|
||||
new GroupSign(id, startSign, mapName, maxPlayersPerGroup, groupName);
|
||||
new GroupSign(plugin, id, startSign, mapName, maxPlayersPerGroup, groupName);
|
||||
}
|
||||
} while (data.contains(preString));
|
||||
}
|
||||
@ -224,7 +224,7 @@ public class GlobalProtectionCache {
|
||||
Block block = world.getBlockAt(data.getInt(preString + ".x"), data.getInt(preString + ".y"), data.getInt(preString + ".z"));
|
||||
if (block.getState() instanceof Sign) {
|
||||
Sign sign = (Sign) block.getState();
|
||||
new LeaveSign(id, sign);
|
||||
new LeaveSign(plugin, id, sign);
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ public class GlobalProtectionCache {
|
||||
Block block2 = world.getBlockAt(data.getInt(preString + "loc2.x"), data.getInt(preString + "loc2.y"), data.getInt(preString + "loc2.z"));
|
||||
ExItem material = plugin.getCaliburn().getExItem(data.getString(preString + "material"));
|
||||
String axis = data.getString(preString + "axis");
|
||||
DPortal dPortal = new DPortal(id, block1, block2, material != null ? material : VanillaItem.NETHER_PORTAL, (byte) (axis != null && axis.equals("z") ? 2 : 1), true);
|
||||
DPortal dPortal = new DPortal(plugin, id, block1, block2, material != null ? material : VanillaItem.NETHER_PORTAL, (byte) (axis != null && axis.equals("z") ? 2 : 1), true);
|
||||
dPortal.create(null);
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class GlobalProtectionListener implements Listener {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
private DungeonsXL plugin;
|
||||
|
||||
public GlobalProtectionListener(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onBlockBreakWithSignOnIt(BlockBreakEvent event) {
|
||||
@ -79,9 +83,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 = plugin.getDPlayerCache().getByPlayer(player);
|
||||
|
||||
GlobalProtection protection = plugin.getGlobalProtections().getByBlock(block);
|
||||
GlobalProtection protection = plugin.getGlobalProtectionCache().getByBlock(block);
|
||||
if (protection != null) {
|
||||
if (protection.onBreak(dGlobalPlayer)) {
|
||||
event.setCancelled(true);
|
||||
@ -91,7 +95,7 @@ public class GlobalProtectionListener implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (DPortal.getByBlock(event.getBlock()) != null) {
|
||||
if (DPortal.getByBlock(plugin, event.getBlock()) != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -99,7 +103,7 @@ public class GlobalProtectionListener implements Listener {
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onPlayerBucketFill(PlayerBucketFillEvent event) {
|
||||
Block block = event.getBlockClicked();
|
||||
if (DPortal.getByBlock(block) != null) {
|
||||
if (DPortal.getByBlock(plugin, block) != null) {
|
||||
event.setCancelled(true);
|
||||
// Workaround for a bug of Bukkit
|
||||
event.getPlayer().sendBlockChange(block.getLocation(), block.getType(), (byte) 0);
|
||||
@ -108,14 +112,14 @@ public class GlobalProtectionListener implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onBlockSpread(BlockSpreadEvent event) {
|
||||
if (DPortal.getByBlock(event.getBlock()) != null) {
|
||||
if (DPortal.getByBlock(plugin, event.getBlock()) != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
if (DPortal.getByBlock(event.getBlock()) != null) {
|
||||
if (DPortal.getByBlock(plugin, event.getBlock()) != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -124,7 +128,7 @@ public class GlobalProtectionListener implements Listener {
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
List<Block> blocklist = event.blockList();
|
||||
for (Block block : blocklist) {
|
||||
if (plugin.getGlobalProtections().isProtectedBlock(block)) {
|
||||
if (plugin.getGlobalProtectionCache().isProtectedBlock(block)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -133,7 +137,7 @@ public class GlobalProtectionListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
DPortal dPortal = DPortal.getByLocation(player.getEyeLocation());
|
||||
DPortal dPortal = DPortal.getByLocation(plugin, player.getEyeLocation());
|
||||
if (dPortal == null) {
|
||||
return;
|
||||
}
|
||||
@ -167,14 +171,14 @@ public class GlobalProtectionListener implements Listener {
|
||||
Block block7 = block2.getRelative(BlockFace.SOUTH);
|
||||
Block block8 = block4.getRelative(BlockFace.NORTH);
|
||||
Block block9 = block4.getRelative(BlockFace.SOUTH);
|
||||
return (DPortal.getByBlock(block1) != null || DPortal.getByBlock(block2) != null || DPortal.getByBlock(block3) != null
|
||||
|| DPortal.getByBlock(block4) != null || DPortal.getByBlock(block5) != null || DPortal.getByBlock(block6) != null
|
||||
|| DPortal.getByBlock(block7) != null || DPortal.getByBlock(block8) != null || DPortal.getByBlock(block9) != null);
|
||||
return (DPortal.getByBlock(plugin, block1) != null || DPortal.getByBlock(plugin, block2) != null || DPortal.getByBlock(plugin, block3) != null
|
||||
|| DPortal.getByBlock(plugin, block4) != null || DPortal.getByBlock(plugin, block5) != null || DPortal.getByBlock(plugin, block6) != null
|
||||
|| DPortal.getByBlock(plugin, block7) != null || DPortal.getByBlock(plugin, block8) != null || DPortal.getByBlock(plugin, block9) != null);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onPortalCreation(PlayerInteractEvent event) {
|
||||
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(event.getPlayer());
|
||||
DGlobalPlayer dPlayer = plugin.getDPlayerCache().getByPlayer(event.getPlayer());
|
||||
if (!dPlayer.isCreatingPortal()) {
|
||||
return;
|
||||
}
|
||||
@ -184,7 +188,7 @@ public class GlobalProtectionListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
for (GlobalProtection protection : plugin.getGlobalProtections().getProtections(DPortal.class)) {
|
||||
for (GlobalProtection protection : plugin.getGlobalProtectionCache().getProtections(DPortal.class)) {
|
||||
DPortal dPortal = (DPortal) protection;
|
||||
if (dPortal.isActive() || dPortal != dPlayer.getPortal()) {
|
||||
continue;
|
||||
@ -209,7 +213,7 @@ public class GlobalProtectionListener implements Listener {
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (plugin.getDPlayers().getByPlayer(player).isInBreakMode()) {
|
||||
if (plugin.getDPlayerCache().getByPlayer(player).isInBreakMode()) {
|
||||
return;
|
||||
}
|
||||
Block clickedBlock = event.getClickedBlock();
|
||||
@ -218,19 +222,19 @@ public class GlobalProtectionListener implements Listener {
|
||||
}
|
||||
|
||||
if (Category.SIGNS.containsBlock(clickedBlock)) {
|
||||
GroupSign groupSign = GroupSign.getByBlock(clickedBlock);
|
||||
GroupSign groupSign = GroupSign.getByBlock(plugin, clickedBlock);
|
||||
if (groupSign != null) {
|
||||
groupSign.onPlayerInteract(clickedBlock, player);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
GameSign gameSign = GameSign.getByBlock(clickedBlock);
|
||||
GameSign gameSign = GameSign.getByBlock(plugin, clickedBlock);
|
||||
if (gameSign != null) {
|
||||
gameSign.onPlayerInteract(clickedBlock, player);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
LeaveSign leaveSign = LeaveSign.getByBlock(clickedBlock);
|
||||
LeaveSign leaveSign = LeaveSign.getByBlock(plugin, clickedBlock);
|
||||
if (leaveSign != null) {
|
||||
leaveSign.onPlayerInteract(player);
|
||||
event.setCancelled(true);
|
||||
@ -260,18 +264,18 @@ public class GlobalProtectionListener implements Listener {
|
||||
}
|
||||
|
||||
if (lines[1].equalsIgnoreCase(GroupSign.GROUP_SIGN_TAG)) {
|
||||
if (GroupSign.tryToCreate(event) != null) {
|
||||
if (GroupSign.tryToCreate(plugin, event) != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
} else if (lines[1].equalsIgnoreCase(GameSign.GAME_SIGN_TAG)) {
|
||||
if (GameSign.tryToCreate(event) != null) {
|
||||
if (GameSign.tryToCreate(plugin, event) != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
} else if (lines[1].equalsIgnoreCase(LeaveSign.LEAVE_SIGN_TAG)) {
|
||||
Sign sign = (Sign) state;
|
||||
new LeaveSign(plugin.getGlobalProtections().generateId(LeaveSign.class, sign.getWorld()), sign);
|
||||
new LeaveSign(plugin, plugin.getGlobalProtectionCache().generateId(LeaveSign.class, sign.getWorld()), sign);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ public class GroupSign extends JoinSign {
|
||||
private String groupName;
|
||||
private DGroup group;
|
||||
|
||||
public GroupSign(int id, Block startSign, String identifier, int maxPlayersPerGroup, String groupName) {
|
||||
super(id, startSign, identifier, maxPlayersPerGroup);
|
||||
public GroupSign(DungeonsXL plugin, int id, Block startSign, String identifier, int maxPlayersPerGroup, String groupName) {
|
||||
super(plugin, id, startSign, identifier, maxPlayersPerGroup);
|
||||
this.groupName = groupName;
|
||||
}
|
||||
|
||||
@ -146,9 +146,9 @@ public class GroupSign extends JoinSign {
|
||||
}
|
||||
|
||||
if (groupName != null) {
|
||||
group = new DGroup(groupName, player, dungeon);
|
||||
group = new DGroup(plugin, groupName, player, dungeon);
|
||||
} else {
|
||||
group = new DGroup(player, dungeon);
|
||||
group = new DGroup(plugin, player, dungeon);
|
||||
}
|
||||
update();
|
||||
|
||||
@ -160,15 +160,16 @@ public class GroupSign extends JoinSign {
|
||||
|
||||
/* Statics */
|
||||
/**
|
||||
* @param plugin the plugin instance
|
||||
* @param block a block which is protected by the returned GroupSign
|
||||
* @return the group sign the block belongs to, null if it belongs to none
|
||||
*/
|
||||
public static GroupSign getByBlock(Block block) {
|
||||
public static GroupSign getByBlock(DungeonsXL plugin, Block block) {
|
||||
if (!Category.SIGNS.containsBlock(block)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (GlobalProtection protection : DungeonsXL.getInstance().getGlobalProtections().getProtections(GroupSign.class)) {
|
||||
for (GlobalProtection protection : plugin.getGlobalProtectionCache().getProtections(GroupSign.class)) {
|
||||
GroupSign groupSign = (GroupSign) protection;
|
||||
Block start = groupSign.startSign;
|
||||
if (start == block || (start.getX() == block.getX() && start.getZ() == block.getZ() && (start.getY() >= block.getY() && start.getY() - groupSign.verticalSigns <= block.getY()))) {
|
||||
@ -179,7 +180,7 @@ public class GroupSign extends JoinSign {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static GroupSign tryToCreate(SignChangeEvent event) {
|
||||
public static GroupSign tryToCreate(DungeonsXL plugin, SignChangeEvent event) {
|
||||
if (!event.getLine(0).equalsIgnoreCase(SIGN_TAG)) {
|
||||
return null;
|
||||
}
|
||||
@ -199,10 +200,10 @@ public class GroupSign extends JoinSign {
|
||||
groupName = data[1];
|
||||
}
|
||||
|
||||
return tryToCreate(event.getBlock(), identifier, maxPlayersPerGroup, groupName);
|
||||
return tryToCreate(plugin, event.getBlock(), identifier, maxPlayersPerGroup, groupName);
|
||||
}
|
||||
|
||||
public static GroupSign tryToCreate(Block startSign, String identifier, int maxPlayersPerGroup, String groupName) {
|
||||
public static GroupSign tryToCreate(DungeonsXL plugin, Block startSign, String identifier, int maxPlayersPerGroup, String groupName) {
|
||||
World world = startSign.getWorld();
|
||||
BlockFace facing = ((Attachable) startSign.getState().getData()).getAttachedFace().getOppositeFace();
|
||||
int x = startSign.getX(), y = startSign.getY(), z = startSign.getZ();
|
||||
@ -219,7 +220,7 @@ public class GroupSign extends JoinSign {
|
||||
|
||||
verticalSigns--;
|
||||
}
|
||||
GroupSign sign = new GroupSign(DungeonsXL.getInstance().getGlobalProtections().generateId(GroupSign.class, world), startSign, identifier, maxPlayersPerGroup, groupName);
|
||||
GroupSign sign = new GroupSign(plugin, plugin.getGlobalProtectionCache().generateId(GroupSign.class, world), startSign, identifier, maxPlayersPerGroup, groupName);
|
||||
|
||||
LWCUtil.removeProtection(startSign);
|
||||
|
||||
|
@ -37,15 +37,15 @@ public class JoinSign extends GlobalProtection {
|
||||
protected int verticalSigns;
|
||||
protected Set<Block> blocks;
|
||||
|
||||
protected JoinSign(int id, Block startSign, String identifier, int maxElements) {
|
||||
super(startSign.getWorld(), id);
|
||||
protected JoinSign(DungeonsXL plugin, int id, Block startSign, String identifier, int maxElements) {
|
||||
super(plugin, startSign.getWorld(), id);
|
||||
|
||||
this.startSign = startSign;
|
||||
dungeon = DungeonsXL.getInstance().getDungeons().getByName(identifier);
|
||||
dungeon = plugin.getDungeonCache().getByName(identifier);
|
||||
if (dungeon == null) {
|
||||
DResourceWorld resource = DungeonsXL.getInstance().getDWorlds().getResourceByName(identifier);
|
||||
DResourceWorld resource = plugin.getDWorldCache().getResourceByName(identifier);
|
||||
if (resource != null) {
|
||||
dungeon = new Dungeon(resource);
|
||||
dungeon = new Dungeon(plugin, resource);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,8 @@ public class LeaveSign extends GlobalProtection {
|
||||
private Sign sign;
|
||||
private Set<Block> blocks;
|
||||
|
||||
public LeaveSign(int id, Sign sign) {
|
||||
super(sign.getWorld(), id);
|
||||
public LeaveSign(DungeonsXL plugin, int id, Sign sign) {
|
||||
super(plugin, sign.getWorld(), id);
|
||||
|
||||
this.sign = sign;
|
||||
setText();
|
||||
@ -99,11 +99,12 @@ public class LeaveSign extends GlobalProtection {
|
||||
|
||||
/* Statics */
|
||||
/**
|
||||
* @param plugin the plugin instance
|
||||
* @param block a block which is protected by the returned LeaveSign
|
||||
* @return the leave sign the block belongs to, null if it belongs to none
|
||||
*/
|
||||
public static LeaveSign getByBlock(Block block) {
|
||||
for (GlobalProtection protection : DungeonsXL.getInstance().getGlobalProtections().getProtections(LeaveSign.class)) {
|
||||
public static LeaveSign getByBlock(DungeonsXL plugin, Block block) {
|
||||
for (GlobalProtection protection : plugin.getGlobalProtectionCache().getProtections(LeaveSign.class)) {
|
||||
LeaveSign leaveSign = (LeaveSign) protection;
|
||||
|
||||
if (leaveSign.getBlocks().contains(block)) {
|
||||
|
@ -22,6 +22,7 @@ import de.erethon.caliburn.mob.ExMob;
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.misc.EnumUtil;
|
||||
import de.erethon.commons.misc.NumberUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||
import java.io.File;
|
||||
@ -50,7 +51,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
@Deprecated
|
||||
public class DMobType extends ExMob {
|
||||
|
||||
CaliburnAPI caliburn = CaliburnAPI.getInstance();
|
||||
private CaliburnAPI caliburn;
|
||||
|
||||
private String name;
|
||||
private EntityType type;
|
||||
@ -70,17 +71,21 @@ public class DMobType extends ExMob {
|
||||
private String ocelotType = null;
|
||||
|
||||
/**
|
||||
* @param plugin the plugin instance
|
||||
* @param file the script file
|
||||
*/
|
||||
public DMobType(File file) {
|
||||
this(file.getName().substring(0, file.getName().length() - 4), YamlConfiguration.loadConfiguration(file));
|
||||
public DMobType(DungeonsXL plugin, File file) {
|
||||
this(plugin, file.getName().substring(0, file.getName().length() - 4), YamlConfiguration.loadConfiguration(file));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param plugin the plugin instance
|
||||
* @param name the name of the DMobType
|
||||
* @param config the config that stores the information
|
||||
*/
|
||||
public DMobType(String name, FileConfiguration config) {
|
||||
public DMobType(DungeonsXL plugin, String name, FileConfiguration config) {
|
||||
caliburn = plugin.getCaliburn();
|
||||
|
||||
this.name = name;
|
||||
|
||||
// Read Mobs
|
||||
@ -196,9 +201,7 @@ public class DMobType extends ExMob {
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -31,12 +31,16 @@ import org.bukkit.Bukkit;
|
||||
*/
|
||||
public class ExternalMobProviderCache {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
private DungeonsXL plugin;
|
||||
|
||||
private Set<ExternalMobProvider> providers = new HashSet<>();
|
||||
private CitizensMobProvider citizensMobProvider;
|
||||
|
||||
public ExternalMobProviderCache() {
|
||||
public ExternalMobProviderCache(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
// Supported providers
|
||||
providers.addAll(Arrays.asList(ExternalMobPlugin.values()));
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
package de.erethon.dungeonsxl.player;
|
||||
|
||||
import de.erethon.caliburn.CaliburnAPI;
|
||||
import de.erethon.commons.compatibility.CompatibilityHandler;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -32,19 +32,20 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class DClass {
|
||||
|
||||
CaliburnAPI caliburn = CaliburnAPI.getInstance();
|
||||
CompatibilityHandler compat = CompatibilityHandler.getInstance();
|
||||
private CaliburnAPI caliburn;
|
||||
|
||||
private String name;
|
||||
|
||||
private List<ItemStack> items = new ArrayList<>();
|
||||
private boolean dog;
|
||||
|
||||
public DClass(File file) {
|
||||
this(file.getName().substring(0, file.getName().length() - 4), YamlConfiguration.loadConfiguration(file));
|
||||
public DClass(DungeonsXL plugin, File file) {
|
||||
this(plugin, file.getName().substring(0, file.getName().length() - 4), YamlConfiguration.loadConfiguration(file));
|
||||
}
|
||||
|
||||
public DClass(String name, FileConfiguration config) {
|
||||
public DClass(DungeonsXL plugin, String name, FileConfiguration config) {
|
||||
caliburn = plugin.getCaliburn();
|
||||
|
||||
this.name = name;
|
||||
|
||||
if (config.contains("items")) {
|
||||
|
@ -17,6 +17,7 @@
|
||||
package de.erethon.dungeonsxl.player;
|
||||
|
||||
import de.erethon.commons.misc.FileUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -28,12 +29,18 @@ import java.util.List;
|
||||
*/
|
||||
public class DClassCache {
|
||||
|
||||
private DungeonsXL plugin;
|
||||
|
||||
private List<DClass> dClasses = new ArrayList<>();
|
||||
|
||||
public DClassCache(File file) {
|
||||
public DClassCache(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void init(File file) {
|
||||
if (file.isDirectory()) {
|
||||
for (File script : FileUtil.getFilesForFolder(file)) {
|
||||
dClasses.add(new DClass(script));
|
||||
dClasses.add(new DClass(plugin, script));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ public class DEditPlayer extends DInstancePlayer {
|
||||
private String[] linesCopy;
|
||||
private DEditWorld editWorld;
|
||||
|
||||
public DEditPlayer(Player player, DEditWorld world) {
|
||||
super(player, world.getWorld());
|
||||
public DEditPlayer(DungeonsXL plugin, Player player, DEditWorld world) {
|
||||
super(plugin, player, world.getWorld());
|
||||
editWorld = world;
|
||||
|
||||
// Set gamemode a few ticks later to avoid incompatibilities with plugins that force a gamemode
|
||||
@ -190,7 +190,7 @@ public class DEditPlayer extends DInstancePlayer {
|
||||
|
||||
/* Statics */
|
||||
public static DEditPlayer getByPlayer(Player player) {
|
||||
for (DEditPlayer dPlayer : DungeonsXL.getInstance().getDPlayers().getDEditPlayers()) {
|
||||
for (DEditPlayer dPlayer : DungeonsXL.getInstance().getDPlayerCache().getDEditPlayers()) {
|
||||
if (dPlayer.getPlayer().equals(player)) {
|
||||
return dPlayer;
|
||||
}
|
||||
@ -199,7 +199,7 @@ public class DEditPlayer extends DInstancePlayer {
|
||||
}
|
||||
|
||||
public static DEditPlayer getByName(String name) {
|
||||
for (DEditPlayer dPlayer : DungeonsXL.getInstance().getDPlayers().getDEditPlayers()) {
|
||||
for (DEditPlayer dPlayer : DungeonsXL.getInstance().getDPlayerCache().getDEditPlayers()) {
|
||||
if (dPlayer.getName().equalsIgnoreCase(name)) {
|
||||
return dPlayer;
|
||||
}
|
||||
@ -210,7 +210,7 @@ public class DEditPlayer extends DInstancePlayer {
|
||||
public static CopyOnWriteArrayList<DEditPlayer> getByWorld(World world) {
|
||||
CopyOnWriteArrayList<DEditPlayer> dPlayers = new CopyOnWriteArrayList<>();
|
||||
|
||||
for (DEditPlayer dPlayer : DungeonsXL.getInstance().getDPlayers().getDEditPlayers()) {
|
||||
for (DEditPlayer dPlayer : DungeonsXL.getInstance().getDPlayerCache().getDEditPlayers()) {
|
||||
if (dPlayer.getWorld() == world) {
|
||||
dPlayers.add(dPlayer);
|
||||
}
|
||||
|
@ -81,12 +81,12 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
|
||||
private DGroupTag groupTag;
|
||||
|
||||
public DGamePlayer(Player player, DGameWorld world) {
|
||||
super(player, world.getWorld());
|
||||
public DGamePlayer(DungeonsXL plugin, Player player, DGameWorld world) {
|
||||
super(plugin, player, world.getWorld());
|
||||
|
||||
Game game = Game.getByGameWorld(world);
|
||||
if (game == null) {
|
||||
game = new Game(DGroup.getByPlayer(player));
|
||||
game = new Game(plugin, DGroup.getByPlayer(player));
|
||||
}
|
||||
|
||||
GameRuleProvider rules = game.getRules();
|
||||
@ -111,8 +111,8 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
}
|
||||
}
|
||||
|
||||
public DGamePlayer(Player player, DGameWorld world, GameType ready) {
|
||||
this(player, world);
|
||||
public DGamePlayer(DungeonsXL plugin, Player player, DGameWorld world, GameType ready) {
|
||||
this(plugin, player, world);
|
||||
if (ready != null) {
|
||||
ready(ready);
|
||||
}
|
||||
@ -215,7 +215,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
return;
|
||||
}
|
||||
|
||||
DClass dClass = plugin.getDClasses().getByName(className);
|
||||
DClass dClass = plugin.getDClassCache().getByName(className);
|
||||
if (dClass == null || this.dClass == dClass) {
|
||||
return;
|
||||
}
|
||||
@ -396,7 +396,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
* Creates a new group tag for the player.
|
||||
*/
|
||||
public void initDGroupTag() {
|
||||
groupTag = new DGroupTag(this);
|
||||
groupTag = new DGroupTag(plugin, this);
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
@ -679,7 +679,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
|
||||
Game game = Game.getByGameWorld(dGroup.getGameWorld());
|
||||
if (game == null) {
|
||||
game = new Game(dGroup, gameType, dGroup.getGameWorld());
|
||||
game = new Game(plugin, dGroup, gameType, dGroup.getGameWorld());
|
||||
|
||||
} else {
|
||||
game.setType(gameType);
|
||||
@ -978,7 +978,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
|
||||
/* Statics */
|
||||
public static DGamePlayer getByPlayer(Player player) {
|
||||
for (DGamePlayer dPlayer : DungeonsXL.getInstance().getDPlayers().getDGamePlayers()) {
|
||||
for (DGamePlayer dPlayer : DungeonsXL.getInstance().getDPlayerCache().getDGamePlayers()) {
|
||||
if (dPlayer.getPlayer().equals(player)) {
|
||||
return dPlayer;
|
||||
}
|
||||
@ -987,7 +987,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
}
|
||||
|
||||
public static DGamePlayer getByName(String name) {
|
||||
for (DGamePlayer dPlayer : DungeonsXL.getInstance().getDPlayers().getDGamePlayers()) {
|
||||
for (DGamePlayer dPlayer : DungeonsXL.getInstance().getDPlayerCache().getDGamePlayers()) {
|
||||
if (dPlayer.getPlayer().getName().equalsIgnoreCase(name) || dPlayer.getName().equalsIgnoreCase(name)) {
|
||||
return dPlayer;
|
||||
}
|
||||
@ -999,7 +999,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
public static List<DGamePlayer> getByWorld(World world) {
|
||||
List<DGamePlayer> dPlayers = new ArrayList<>();
|
||||
|
||||
for (DGamePlayer dPlayer : DungeonsXL.getInstance().getDPlayers().getDGamePlayers()) {
|
||||
for (DGamePlayer dPlayer : DungeonsXL.getInstance().getDPlayerCache().getDGamePlayers()) {
|
||||
if (dPlayer.getWorld() == world) {
|
||||
dPlayers.add(dPlayer);
|
||||
}
|
||||
|
@ -46,9 +46,9 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
*/
|
||||
public class DGlobalPlayer implements PlayerWrapper {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
protected DungeonsXL plugin;
|
||||
|
||||
boolean is1_9 = Internals.isAtLeast(Internals.v1_9_R1);
|
||||
protected boolean is1_9 = Internals.isAtLeast(Internals.v1_9_R1);
|
||||
|
||||
protected Player player;
|
||||
|
||||
@ -65,11 +65,13 @@ public class DGlobalPlayer implements PlayerWrapper {
|
||||
private ItemStack[] respawnArmor;
|
||||
private List<ItemStack> rewardItems;
|
||||
|
||||
public DGlobalPlayer(Player player) {
|
||||
this(player, false);
|
||||
public DGlobalPlayer(DungeonsXL plugin, Player player) {
|
||||
this(plugin, player, false);
|
||||
}
|
||||
|
||||
public DGlobalPlayer(Player player, boolean reset) {
|
||||
public DGlobalPlayer(DungeonsXL plugin, Player player, boolean reset) {
|
||||
this.plugin = plugin;
|
||||
|
||||
this.player = player;
|
||||
|
||||
loadPlayerData(new File(DungeonsXL.PLAYERS, player.getUniqueId().toString() + ".yml"));
|
||||
@ -77,11 +79,13 @@ public class DGlobalPlayer implements PlayerWrapper {
|
||||
reset(false);
|
||||
}
|
||||
|
||||
plugin.getDPlayers().addPlayer(this);
|
||||
plugin.getDPlayerCache().addPlayer(this);
|
||||
}
|
||||
|
||||
public DGlobalPlayer(DGlobalPlayer dPlayer) {
|
||||
plugin = dPlayer.plugin;
|
||||
player = dPlayer.getPlayer();
|
||||
data = dPlayer.getData();
|
||||
breakMode = dPlayer.isInBreakMode();
|
||||
chatSpyMode = dPlayer.isInChatSpyMode();
|
||||
creatingPortal = dPlayer.getPortal();
|
||||
@ -89,7 +93,7 @@ public class DGlobalPlayer implements PlayerWrapper {
|
||||
respawnInventory = dPlayer.getRespawnInventory();
|
||||
respawnArmor = dPlayer.getRespawnArmor();
|
||||
|
||||
plugin.getDPlayers().addPlayer(this);
|
||||
plugin.getDPlayerCache().addPlayer(this);
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
@ -397,7 +401,7 @@ public class DGlobalPlayer implements PlayerWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
DGroup dGroup = new DGroup("Tutorial", player, dungeon);
|
||||
DGroup dGroup = new DGroup(plugin, "Tutorial", player, dungeon);
|
||||
|
||||
DGroupCreateEvent createEvent = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.GROUP_SIGN);
|
||||
Bukkit.getPluginManager().callEvent(createEvent);
|
||||
@ -409,8 +413,8 @@ public class DGlobalPlayer implements PlayerWrapper {
|
||||
// The maxInstances check is already done in the listener
|
||||
DGameWorld gameWorld = dungeon.getMap().instantiateAsGameWorld(true);
|
||||
dGroup.setGameWorld(gameWorld);
|
||||
new Game(dGroup, gameWorld).setTutorial(true);
|
||||
new DGamePlayer(player, gameWorld);
|
||||
new Game(plugin, dGroup, gameWorld).setTutorial(true);
|
||||
new DGamePlayer(plugin, player, gameWorld);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,8 +55,8 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
*/
|
||||
public class DGroup {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
DPlayerCache dPlayers = plugin.getDPlayers();
|
||||
DungeonsXL plugin;
|
||||
DPlayerCache dPlayers;
|
||||
|
||||
private String name;
|
||||
private Player captain;
|
||||
@ -75,16 +75,19 @@ public class DGroup {
|
||||
private int initialLives = -1;
|
||||
private int lives = -1;
|
||||
|
||||
public DGroup(Player player) {
|
||||
this("Group " + DungeonsXL.getInstance().getDGroups().size(), player);
|
||||
public DGroup(DungeonsXL plugin, Player player) {
|
||||
this(plugin, "Group " + plugin.getDGroupCache().size(), player);
|
||||
}
|
||||
|
||||
public DGroup(Player player, DColor color) {
|
||||
this(color.toString().replace("_", " "), player);
|
||||
public DGroup(DungeonsXL plugin, Player player, DColor color) {
|
||||
this(plugin, color.toString().replace("_", " "), player);
|
||||
}
|
||||
|
||||
public DGroup(String name, Player player) {
|
||||
plugin.getDGroups().add(this);
|
||||
public DGroup(DungeonsXL plugin, String name, Player player) {
|
||||
this.plugin = plugin;
|
||||
dPlayers = plugin.getDPlayerCache();
|
||||
|
||||
plugin.getDGroupCache().add(this);
|
||||
this.name = name;
|
||||
|
||||
setCaptain(player);
|
||||
@ -94,19 +97,22 @@ public class DGroup {
|
||||
floorCount = 0;
|
||||
}
|
||||
|
||||
public DGroup(Player player, Dungeon dungeon) {
|
||||
this(DungeonsXL.getInstance().getMainConfig().getGroupColorPriority().get(DungeonsXL.getInstance().getDGroups().size()).toString(), player, dungeon);
|
||||
public DGroup(DungeonsXL plugin, Player player, Dungeon dungeon) {
|
||||
this(plugin, plugin.getMainConfig().getGroupColorPriority().get(plugin.getDGroupCache().size()).toString(), player, dungeon);
|
||||
}
|
||||
|
||||
public DGroup(String name, Player player, Dungeon dungeon) {
|
||||
this(name, player, new ArrayList<Player>(), dungeon);
|
||||
public DGroup(DungeonsXL plugin, String name, Player player, Dungeon dungeon) {
|
||||
this(plugin, name, player, new ArrayList<Player>(), dungeon);
|
||||
}
|
||||
|
||||
public DGroup(String name, Player captain, List<Player> players, Dungeon dungeon) {
|
||||
plugin.getDGroups().add(this);
|
||||
public DGroup(DungeonsXL plugin, String name, Player captain, List<Player> players, Dungeon dungeon) {
|
||||
this.plugin = plugin;
|
||||
dPlayers = plugin.getDPlayerCache();
|
||||
|
||||
plugin.getDGroupCache().add(this);
|
||||
this.name = name;
|
||||
|
||||
DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(plugin.getDPlayers().getByPlayer(captain), true, this);
|
||||
DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(plugin.getDPlayerCache().getByPlayer(captain), true, this);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
@ -242,7 +248,7 @@ public class DGroup {
|
||||
*/
|
||||
public void removePlayer(Player player, boolean message) {
|
||||
players.remove(player.getUniqueId());
|
||||
plugin.getGlobalProtections().updateGroupSigns(this);
|
||||
plugin.getGlobalProtectionCache().updateGroupSigns(this);
|
||||
|
||||
if (message) {
|
||||
sendMessage(DMessage.PLAYER_LEFT_GROUP.getMessage(player.getName()));
|
||||
@ -377,15 +383,15 @@ public class DGroup {
|
||||
* @return if the action was successful
|
||||
*/
|
||||
public boolean setDungeon(String name) {
|
||||
dungeon = plugin.getDungeons().getByName(name);
|
||||
dungeon = plugin.getDungeonCache().getByName(name);
|
||||
if (dungeon != null) {
|
||||
unplayedFloors = dungeon.getConfig().getFloors();
|
||||
return true;
|
||||
|
||||
} else {
|
||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(name);
|
||||
DResourceWorld resource = plugin.getDWorldCache().getResourceByName(name);
|
||||
if (resource != null) {
|
||||
dungeon = new Dungeon(resource);
|
||||
dungeon = new Dungeon(plugin, resource);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -682,7 +688,7 @@ public class DGroup {
|
||||
public void delete() {
|
||||
Game game = Game.getByDGroup(this);
|
||||
|
||||
plugin.getDGroups().remove(this);
|
||||
plugin.getDGroupCache().remove(this);
|
||||
|
||||
if (game != null) {
|
||||
game.removeDGroup(this);
|
||||
@ -699,7 +705,7 @@ public class DGroup {
|
||||
timeIsRunningTask.cancel();
|
||||
}
|
||||
|
||||
plugin.getGlobalProtections().updateGroupSigns(this);
|
||||
plugin.getGlobalProtectionCache().updateGroupSigns(this);
|
||||
}
|
||||
|
||||
public void startGame(Game game) {
|
||||
@ -721,7 +727,7 @@ public class DGroup {
|
||||
for (Player player : dGroup.getPlayers().getOnlinePlayers()) {
|
||||
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
|
||||
if (dPlayer == null) {
|
||||
dPlayer = new DGamePlayer(player, gameWorld);
|
||||
dPlayer = new DGamePlayer(plugin, player, gameWorld);
|
||||
}
|
||||
if (rules.isGroupTagEnabled()) {
|
||||
dPlayer.initDGroupTag();
|
||||
@ -812,7 +818,7 @@ public class DGroup {
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getGlobalProtections().updateGroupSigns(this);
|
||||
plugin.getGlobalProtectionCache().updateGroupSigns(this);
|
||||
nextFloor = null;
|
||||
initialLives = rules.getInitialGroupLives();
|
||||
lives = initialLives;
|
||||
@ -885,7 +891,7 @@ public class DGroup {
|
||||
|
||||
/* Statics */
|
||||
public static DGroup getByName(String name) {
|
||||
for (DGroup dGroup : DungeonsXL.getInstance().getDGroups()) {
|
||||
for (DGroup dGroup : DungeonsXL.getInstance().getDGroupCache()) {
|
||||
if (dGroup.getName().equalsIgnoreCase(name) || dGroup.getRawName().equalsIgnoreCase(name)) {
|
||||
return dGroup;
|
||||
}
|
||||
@ -895,7 +901,7 @@ public class DGroup {
|
||||
}
|
||||
|
||||
public static DGroup getByPlayer(Player player) {
|
||||
for (DGroup dGroup : DungeonsXL.getInstance().getDGroups()) {
|
||||
for (DGroup dGroup : DungeonsXL.getInstance().getDGroupCache()) {
|
||||
if (dGroup.getPlayers().contains(player)) {
|
||||
return dGroup;
|
||||
}
|
||||
@ -905,7 +911,7 @@ public class DGroup {
|
||||
}
|
||||
|
||||
public static void leaveGroup(Player player) {
|
||||
for (DGroup dGroup : DungeonsXL.getInstance().getDGroups()) {
|
||||
for (DGroup dGroup : DungeonsXL.getInstance().getDGroupCache()) {
|
||||
if (dGroup.getPlayers().contains(player)) {
|
||||
dGroup.getPlayers().remove(player);
|
||||
}
|
||||
@ -918,7 +924,7 @@ public class DGroup {
|
||||
*/
|
||||
public static List<DGroup> getByGameWorld(DGameWorld gameWorld) {
|
||||
List<DGroup> dGroups = new ArrayList<>();
|
||||
for (DGroup dGroup : DungeonsXL.getInstance().getDGroups()) {
|
||||
for (DGroup dGroup : DungeonsXL.getInstance().getDGroupCache()) {
|
||||
if (dGroup.getGameWorld().equals(gameWorld)) {
|
||||
dGroups.add(dGroup);
|
||||
}
|
||||
|
@ -28,11 +28,11 @@ public class DGroupTag {
|
||||
private DGamePlayer player;
|
||||
private Hologram hologram;
|
||||
|
||||
public DGroupTag(DGamePlayer player) {
|
||||
public DGroupTag(DungeonsXL plugin, DGamePlayer player) {
|
||||
this.player = player;
|
||||
DGroup group = player.getDGroup();
|
||||
if (group != null) {
|
||||
hologram = HologramsAPI.createHologram(DungeonsXL.getInstance(), player.getPlayer().getLocation().clone().add(0, 3.5, 0));
|
||||
hologram = HologramsAPI.createHologram(plugin, player.getPlayer().getLocation().clone().add(0, 3.5, 0));
|
||||
hologram.appendItemLine(group.getDColor().getWoolMaterial().toItemStack());
|
||||
hologram.appendTextLine(group.getName());
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package de.erethon.dungeonsxl.player;
|
||||
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.MainConfig;
|
||||
import de.erethon.dungeonsxl.util.ParsingUtil;
|
||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||
@ -31,12 +32,15 @@ import org.bukkit.potion.PotionEffect;
|
||||
*/
|
||||
public abstract class DInstancePlayer extends DGlobalPlayer {
|
||||
|
||||
MainConfig config = plugin.getMainConfig();
|
||||
MainConfig config;
|
||||
|
||||
private World world;
|
||||
|
||||
DInstancePlayer(Player player, World world) {
|
||||
super(player, false);
|
||||
DInstancePlayer(DungeonsXL plugin, Player player, World world) {
|
||||
super(plugin, player, false);
|
||||
|
||||
config = plugin.getMainConfig();
|
||||
|
||||
this.world = world;
|
||||
getData().savePlayerState(player);
|
||||
}
|
||||
@ -88,7 +92,7 @@ public abstract class DInstancePlayer extends DGlobalPlayer {
|
||||
new DGlobalPlayer(this);
|
||||
|
||||
} else {
|
||||
plugin.getDPlayers().removePlayer(this);
|
||||
plugin.getDPlayerCache().removePlayer(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,14 +102,14 @@ public abstract class DInstancePlayer extends DGlobalPlayer {
|
||||
* @param message the message to send
|
||||
*/
|
||||
public void chat(String message) {
|
||||
DInstanceWorld instance = plugin.getDWorlds().getInstanceByWorld(world);
|
||||
DInstanceWorld instance = plugin.getDWorldCache().getInstanceByWorld(world);
|
||||
if (instance == null) {
|
||||
return;
|
||||
}
|
||||
String chatFormat = instance instanceof DGameWorld ? config.getChatFormatGame() : config.getChatFormatEdit();
|
||||
instance.sendMessage(ParsingUtil.replaceChatPlaceholders(chatFormat, this) + message);
|
||||
|
||||
for (DGlobalPlayer player : plugin.getDPlayers().getDGlobalPlayers()) {
|
||||
for (DGlobalPlayer player : plugin.getDPlayerCache().getDGlobalPlayers()) {
|
||||
if (player.isInChatSpyMode()) {
|
||||
if (!instance.getWorld().getPlayers().contains(player.getPlayer())) {
|
||||
player.sendMessage(ParsingUtil.replaceChatPlaceholders(config.getChatFormatSpy(), this) + message);
|
||||
|
@ -35,8 +35,8 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
*/
|
||||
public class DPlayerCache {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
MainConfig mainConfig = plugin.getMainConfig();
|
||||
private DungeonsXL plugin;
|
||||
private MainConfig config;
|
||||
|
||||
private BukkitTask secureModeTask;
|
||||
private BukkitTask updateTask;
|
||||
@ -44,14 +44,20 @@ public class DPlayerCache {
|
||||
|
||||
private CopyOnWriteArrayList<DGlobalPlayer> dGlobalPlayers = new CopyOnWriteArrayList<>();
|
||||
|
||||
public DPlayerCache() {
|
||||
if (mainConfig.isSecureModeEnabled()) {
|
||||
startSecureModeTask(mainConfig.getSecureModeCheckInterval());
|
||||
public DPlayerCache(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
config = plugin.getMainConfig();
|
||||
|
||||
if (config.isSecureModeEnabled()) {
|
||||
startSecureModeTask(config.getSecureModeCheckInterval());
|
||||
}
|
||||
startUpdateTask(2L);
|
||||
startLazyUpdateTask(20L);
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new DPlayerListener(this), plugin);
|
||||
Bukkit.getPluginManager().registerEvents(new DPlayerListener(plugin), plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,7 +70,7 @@ public class DPlayerCache {
|
||||
return dGlobalPlayer;
|
||||
}
|
||||
}
|
||||
return new DGlobalPlayer(player);
|
||||
return new DGlobalPlayer(plugin, player);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,7 +92,7 @@ public class DPlayerCache {
|
||||
*/
|
||||
public Collection<DInstancePlayer> getByInstance(DInstanceWorld instance) {
|
||||
Collection<DInstancePlayer> players = new ArrayList<>();
|
||||
plugin.getDWorlds().getInstances().forEach(i -> i.getPlayers().forEach(p -> players.add(p)));
|
||||
plugin.getDWorldCache().getInstances().forEach(i -> i.getPlayers().forEach(p -> players.add(p)));
|
||||
return players;
|
||||
}
|
||||
|
||||
@ -160,7 +166,7 @@ public class DPlayerCache {
|
||||
*/
|
||||
public void loadAll() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
new DGlobalPlayer(player);
|
||||
new DGlobalPlayer(plugin, player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,7 +201,7 @@ public class DPlayerCache {
|
||||
* @param period the period in ticks
|
||||
*/
|
||||
public void startSecureModeTask(long period) {
|
||||
secureModeTask = new SecureModeTask().runTaskTimer(plugin, period, period);
|
||||
secureModeTask = new SecureModeTask(plugin).runTaskTimer(plugin, period, period);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -211,7 +217,7 @@ public class DPlayerCache {
|
||||
* @param period the period in ticks
|
||||
*/
|
||||
public void startUpdateTask(long period) {
|
||||
updateTask = new UpdateTask().runTaskTimer(plugin, period, period);
|
||||
updateTask = new UpdateTask(plugin).runTaskTimer(plugin, period, period);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,7 +233,7 @@ public class DPlayerCache {
|
||||
* @param period the period in ticks
|
||||
*/
|
||||
public void startLazyUpdateTask(long period) {
|
||||
lazyUpdateTask = new LazyUpdateTask().runTaskTimer(plugin, period, period);
|
||||
lazyUpdateTask = new LazyUpdateTask(plugin).runTaskTimer(plugin, period, period);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ package de.erethon.dungeonsxl.player;
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.compatibility.Internals;
|
||||
import de.erethon.commons.config.DREConfig;
|
||||
import de.erethon.commons.javaplugin.DREPlugin;
|
||||
import de.erethon.commons.misc.EnumUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -45,7 +45,7 @@ import org.bukkit.potion.PotionEffect;
|
||||
*/
|
||||
public class DPlayerData extends DREConfig {
|
||||
|
||||
boolean is1_9 = Internals.isAtLeast(Internals.v1_9_R1);
|
||||
protected boolean is1_9 = Internals.isAtLeast(Internals.v1_9_R1);
|
||||
|
||||
public static final int CONFIG_VERSION = 4;
|
||||
|
||||
@ -383,7 +383,7 @@ public class DPlayerData extends DREConfig {
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
MessageUtil.log(DungeonsXL.getInstance(), DMessage.LOG_NEW_PLAYER_DATA.getMessage(file.getName()));
|
||||
MessageUtil.log(DREPlugin.getInstance(), DMessage.LOG_NEW_PLAYER_DATA.getMessage(file.getName()));
|
||||
} catch (IOException exception) {
|
||||
}
|
||||
}
|
||||
|
@ -65,15 +65,18 @@ import org.bukkit.inventory.meta.BookMeta;
|
||||
*/
|
||||
public class DPlayerListener implements Listener {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
MainConfig config = plugin.getMainConfig();
|
||||
DWorldCache worlds = plugin.getDWorlds();
|
||||
DPlayerCache dPlayers;
|
||||
private DungeonsXL plugin;
|
||||
private MainConfig config;
|
||||
private DWorldCache worlds;
|
||||
private DPlayerCache dPlayers;
|
||||
|
||||
public static final String ALL = "@all ";
|
||||
|
||||
public DPlayerListener(DPlayerCache dPlayers) {
|
||||
this.dPlayers = dPlayers;
|
||||
public DPlayerListener(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
config = plugin.getMainConfig();
|
||||
worlds = plugin.getDWorldCache();
|
||||
dPlayers = plugin.getDPlayerCache();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -372,7 +375,7 @@ public class DPlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
DGlobalPlayer dPlayer = new DGlobalPlayer(player);
|
||||
DGlobalPlayer dPlayer = new DGlobalPlayer(plugin, player);
|
||||
if (dPlayer.getData().wasInGame()) {
|
||||
dPlayer.reset(dPlayer.getData().getKeepInventoryAfterLogout());
|
||||
}
|
||||
@ -447,7 +450,7 @@ public class DPlayerListener implements Listener {
|
||||
if (isCitizensNPC(player)) {
|
||||
return;
|
||||
}
|
||||
plugin.getDPlayers().getByPlayer(player).applyRespawnInventory();
|
||||
plugin.getDPlayerCache().getByPlayer(player).applyRespawnInventory();
|
||||
|
||||
DGlobalPlayer dPlayer = DGamePlayer.getByPlayer(player);
|
||||
if (dPlayer == null) {
|
||||
@ -485,7 +488,7 @@ public class DPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
// Because some plugins set another respawn point, DXL teleports a few ticks later.
|
||||
new RespawnTask(player, respawn).runTaskLater(plugin, 10);
|
||||
new RespawnTask(plugin, player, respawn).runTaskLater(plugin, 10);
|
||||
|
||||
// Don't forget Doge!
|
||||
if (gamePlayer.getWolf() != null) {
|
||||
|
@ -24,9 +24,15 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
*/
|
||||
public class LazyUpdateTask extends BukkitRunnable {
|
||||
|
||||
private DungeonsXL plugin;
|
||||
|
||||
public LazyUpdateTask(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (DGamePlayer dPlayer : DungeonsXL.getInstance().getDPlayers().getDGamePlayers()) {
|
||||
for (DGamePlayer dPlayer : plugin.getDPlayerCache().getDGamePlayers()) {
|
||||
dPlayer.update(true);
|
||||
}
|
||||
}
|
||||
|
@ -27,10 +27,14 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
*/
|
||||
public class RespawnTask extends BukkitRunnable {
|
||||
|
||||
private DPlayerCache dPlayers;
|
||||
|
||||
private Player player;
|
||||
private Location location;
|
||||
|
||||
public RespawnTask(Player player, Location location) {
|
||||
public RespawnTask(DungeonsXL plugin, Player player, Location location) {
|
||||
dPlayers = plugin.getDPlayerCache();
|
||||
|
||||
this.location = location;
|
||||
this.player = player;
|
||||
}
|
||||
@ -41,7 +45,7 @@ public class RespawnTask extends BukkitRunnable {
|
||||
PlayerUtil.secureTeleport(player, location);
|
||||
}
|
||||
|
||||
DGlobalPlayer dPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player);
|
||||
DGlobalPlayer dPlayer = dPlayers.getByPlayer(player);
|
||||
|
||||
if (dPlayer == null) {
|
||||
return;
|
||||
|
@ -26,12 +26,18 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
*/
|
||||
public class SecureModeTask extends BukkitRunnable {
|
||||
|
||||
private DungeonsXL plugin;
|
||||
|
||||
public SecureModeTask(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
DGlobalPlayer dGlobalPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player);
|
||||
DGlobalPlayer dGlobalPlayer = plugin.getDPlayerCache().getByPlayer(player);
|
||||
if (dGlobalPlayer == null) {
|
||||
dGlobalPlayer = new DGlobalPlayer(player);
|
||||
dGlobalPlayer = new DGlobalPlayer(plugin, player);
|
||||
}
|
||||
|
||||
if (!(dGlobalPlayer instanceof DGamePlayer || dGlobalPlayer instanceof DEditPlayer)) {
|
||||
|
@ -17,8 +17,6 @@
|
||||
package de.erethon.dungeonsxl.player;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.config.MessageConfig;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.event.dplayer.DPlayerKickEvent;
|
||||
import de.erethon.dungeonsxl.game.Game;
|
||||
@ -32,8 +30,6 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
*/
|
||||
public class TimeIsRunningTask extends BukkitRunnable {
|
||||
|
||||
MessageConfig messageConfig = DungeonsXL.getInstance().getMessageConfig();
|
||||
|
||||
private DGroup dGroup;
|
||||
private int time;
|
||||
private int timeLeft;
|
||||
|
@ -24,9 +24,15 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
*/
|
||||
public class UpdateTask extends BukkitRunnable {
|
||||
|
||||
private DungeonsXL plugin;
|
||||
|
||||
public UpdateTask(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (DInstancePlayer dPlayer : DungeonsXL.getInstance().getDPlayers().getDInstancePlayers()) {
|
||||
for (DInstancePlayer dPlayer : plugin.getDPlayerCache().getDInstancePlayers()) {
|
||||
dPlayer.update(false);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
package de.erethon.dungeonsxl.requirement;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.game.Game;
|
||||
import de.erethon.dungeonsxl.game.GameRuleProvider;
|
||||
@ -35,6 +36,10 @@ public class FeeLevelRequirement extends Requirement {
|
||||
private int fee;
|
||||
private Boolean keepInventory;
|
||||
|
||||
public FeeLevelRequirement(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
/**
|
||||
* @return the fee
|
||||
|
@ -19,6 +19,7 @@ package de.erethon.dungeonsxl.requirement;
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -27,12 +28,17 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public class FeeMoneyRequirement extends Requirement {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
private Economy econ;
|
||||
|
||||
private RequirementType type = RequirementTypeDefault.FEE_MONEY;
|
||||
|
||||
private double fee;
|
||||
|
||||
public FeeMoneyRequirement(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
econ = plugin.getEconomyProvider();
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
/**
|
||||
* @return the fee
|
||||
@ -61,21 +67,21 @@ public class FeeMoneyRequirement extends Requirement {
|
||||
|
||||
@Override
|
||||
public boolean check(Player player) {
|
||||
if (plugin.getEconomyProvider() == null) {
|
||||
if (econ == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return plugin.getEconomyProvider().getBalance(player) >= fee;
|
||||
return econ.getBalance(player) >= fee;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void demand(Player player) {
|
||||
if (plugin.getEconomyProvider() == null) {
|
||||
if (econ == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getEconomyProvider().withdrawPlayer(player, fee);
|
||||
MessageUtil.sendMessage(player, DMessage.REQUIREMENT_FEE.getMessage(plugin.getEconomyProvider().format(fee)));
|
||||
econ.withdrawPlayer(player, fee);
|
||||
MessageUtil.sendMessage(player, DMessage.REQUIREMENT_FEE.getMessage(econ.format(fee)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ package de.erethon.dungeonsxl.requirement;
|
||||
|
||||
import de.erethon.caliburn.CaliburnAPI;
|
||||
import de.erethon.caliburn.item.ExItem;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import java.util.List;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -28,12 +29,17 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class ForbiddenItemsRequirement extends Requirement {
|
||||
|
||||
CaliburnAPI caliburn = CaliburnAPI.getInstance();
|
||||
private CaliburnAPI caliburn;
|
||||
|
||||
private RequirementType type = RequirementTypeDefault.FORBIDDEN_ITEMS;
|
||||
|
||||
private List<ExItem> forbiddenItems;
|
||||
|
||||
public ForbiddenItemsRequirement(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
caliburn = plugin.getCaliburn();
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
/**
|
||||
* @return the forbidden items
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package de.erethon.dungeonsxl.requirement;
|
||||
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.player.DGroup;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -30,6 +31,10 @@ public class GroupSizeRequirement extends Requirement {
|
||||
private int minimum;
|
||||
private int maximum;
|
||||
|
||||
public GroupSizeRequirement(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the group minimum
|
||||
*/
|
||||
|
@ -18,6 +18,7 @@ package de.erethon.dungeonsxl.requirement;
|
||||
|
||||
import de.erethon.caliburn.CaliburnAPI;
|
||||
import de.erethon.caliburn.item.ExItem;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -29,12 +30,17 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class KeyItemsRequirement extends Requirement {
|
||||
|
||||
CaliburnAPI caliburn = CaliburnAPI.getInstance();
|
||||
private CaliburnAPI caliburn;
|
||||
|
||||
private RequirementType type = RequirementTypeDefault.KEY_ITEMS;
|
||||
|
||||
private List<ExItem> keyItems;
|
||||
|
||||
public KeyItemsRequirement(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
caliburn = plugin.getCaliburn();
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
/**
|
||||
* @return the forbidden items
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package de.erethon.dungeonsxl.requirement;
|
||||
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.player.DPermission;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -31,6 +32,10 @@ public class PermissionRequirement extends Requirement {
|
||||
|
||||
private List<String> permissions = new ArrayList<>();
|
||||
|
||||
public PermissionRequirement(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
/**
|
||||
* @return the permission the player must have to play the dungeon
|
||||
|
@ -17,6 +17,7 @@
|
||||
package de.erethon.dungeonsxl.requirement;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.event.requirement.RequirementRegistrationEvent;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -31,12 +32,18 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public abstract class Requirement {
|
||||
|
||||
public static Requirement create(RequirementType type) {
|
||||
protected DungeonsXL plugin;
|
||||
|
||||
protected Requirement(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public static Requirement create(DungeonsXL plugin, RequirementType type) {
|
||||
Requirement requirement = null;
|
||||
|
||||
try {
|
||||
Constructor<? extends Requirement> constructor = type.getHandler().getConstructor();
|
||||
requirement = constructor.newInstance();
|
||||
Constructor<? extends Requirement> constructor = type.getHandler().getConstructor(DungeonsXL.class);
|
||||
requirement = constructor.newInstance(plugin);
|
||||
|
||||
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException exception) {
|
||||
MessageUtil.log("An error occurred while accessing the handler class of the requirement " + type.getIdentifier() + ": " + exception.getClass().getSimpleName());
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package de.erethon.dungeonsxl.reward;
|
||||
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -31,6 +32,10 @@ public class ItemReward extends Reward {
|
||||
|
||||
private List<ItemStack> items = new ArrayList<>();
|
||||
|
||||
public ItemReward(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
/**
|
||||
* @return the reward items
|
||||
@ -68,7 +73,7 @@ public class ItemReward extends Reward {
|
||||
/* Actions */
|
||||
@Override
|
||||
public void giveTo(Player player) {
|
||||
plugin.getDPlayers().getByPlayer(player).setRewardItems(items);
|
||||
plugin.getDPlayerCache().getByPlayer(player).setRewardItems(items);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
package de.erethon.dungeonsxl.reward;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -29,6 +30,10 @@ public class LevelReward extends Reward {
|
||||
|
||||
private int levels;
|
||||
|
||||
public LevelReward(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the levels
|
||||
*/
|
||||
|
@ -17,7 +17,9 @@
|
||||
package de.erethon.dungeonsxl.reward;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
@ -25,10 +27,17 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public class MoneyReward extends Reward {
|
||||
|
||||
private Economy econ;
|
||||
|
||||
private RewardType type = RewardTypeDefault.MONEY;
|
||||
|
||||
private double money;
|
||||
|
||||
public MoneyReward(DungeonsXL plugin) {
|
||||
super(plugin);
|
||||
econ = plugin.getEconomyProvider();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the money
|
||||
*/
|
||||
@ -52,11 +61,11 @@ public class MoneyReward extends Reward {
|
||||
|
||||
@Override
|
||||
public void giveTo(Player player) {
|
||||
if (plugin.getEconomyProvider() == null || money == 0) {
|
||||
if (econ == null || money == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getEconomyProvider().depositPlayer(player, money);
|
||||
econ.depositPlayer(player, money);
|
||||
MessageUtil.sendMessage(player, DMessage.REWARD_GENERAL.getMessage(plugin.getEconomyProvider().format(money)));
|
||||
}
|
||||
|
||||
|
@ -31,14 +31,18 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public abstract class Reward {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
protected DungeonsXL plugin;
|
||||
|
||||
public static Reward create(RewardType type) {
|
||||
protected Reward(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public static Reward create(DungeonsXL plugin, RewardType type) {
|
||||
Reward reward = null;
|
||||
|
||||
try {
|
||||
Constructor<? extends Reward> constructor = type.getHandler().getConstructor();
|
||||
reward = constructor.newInstance();
|
||||
Constructor<? extends Reward> constructor = type.getHandler().getConstructor(DungeonsXL.class);
|
||||
reward = constructor.newInstance(plugin);
|
||||
|
||||
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException exception) {
|
||||
MessageUtil.log("An error occurred while accessing the handler class of the reward " + type.getIdentifier() + ": " + exception.getClass().getSimpleName());
|
||||
|
@ -42,7 +42,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class RewardListener implements Listener {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
private DungeonsXL plugin;
|
||||
|
||||
public RewardListener(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/*@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
@ -109,8 +113,8 @@ public class RewardListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||
if (plugin.getDWorlds().getInstanceByWorld(player.getWorld()) != null) {
|
||||
DGlobalPlayer dPlayer = plugin.getDPlayerCache().getByPlayer(player);
|
||||
if (plugin.getDWorldCache().getInstanceByWorld(player.getWorld()) != null) {
|
||||
return;
|
||||
}
|
||||
Block block = player.getLocation().getBlock();
|
||||
|
@ -16,11 +16,9 @@
|
||||
*/
|
||||
package de.erethon.dungeonsxl.reward;
|
||||
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
/**
|
||||
* RewardType instance manager.
|
||||
@ -33,7 +31,6 @@ public class RewardTypeCache {
|
||||
|
||||
public RewardTypeCache() {
|
||||
types.addAll(Arrays.asList(RewardTypeDefault.values()));
|
||||
Bukkit.getPluginManager().registerEvents(new RewardListener(), DungeonsXL.getInstance());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,6 +20,7 @@ import de.erethon.caliburn.category.Category;
|
||||
import de.erethon.caliburn.item.VanillaItem;
|
||||
import de.erethon.commons.misc.BlockUtil;
|
||||
import de.erethon.commons.misc.NumberUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||
import de.erethon.dungeonsxl.world.block.TeamBed;
|
||||
import org.bukkit.block.Block;
|
||||
@ -34,8 +35,8 @@ public class BedSign extends DSign {
|
||||
|
||||
private int team;
|
||||
|
||||
public BedSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
public BedSign(DungeonsXL plugin, Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(plugin, sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
@ -57,7 +58,7 @@ public class BedSign extends DSign {
|
||||
|
||||
if (Category.BEDS.containsBlock(block)) {
|
||||
if (getGame().getDGroups().size() > team) {
|
||||
getGameWorld().addGameBlock(new TeamBed(block, getGame().getDGroups().get(team)));
|
||||
getGameWorld().addGameBlock(new TeamBed(plugin, block, getGame().getDGroups().get(team)));
|
||||
}
|
||||
getSign().getBlock().setType(VanillaItem.AIR.getMaterial());
|
||||
} else {
|
||||
|
@ -19,6 +19,7 @@ package de.erethon.dungeonsxl.sign;
|
||||
import de.erethon.caliburn.item.ExItem;
|
||||
import de.erethon.caliburn.item.VanillaItem;
|
||||
import de.erethon.commons.misc.NumberUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.util.MagicValueUtil;
|
||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||
import org.bukkit.block.Sign;
|
||||
@ -38,8 +39,8 @@ public class BlockSign extends DSign {
|
||||
private byte offBlockData = 0x0;
|
||||
private byte onBlockData = 0x0;
|
||||
|
||||
public BlockSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
public BlockSign(DungeonsXL plugin, Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(plugin, sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,6 +18,7 @@ package de.erethon.dungeonsxl.sign;
|
||||
|
||||
import de.erethon.caliburn.item.VanillaItem;
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.trigger.InteractTrigger;
|
||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||
@ -39,8 +40,8 @@ public class BossShopSign extends DSign {
|
||||
|
||||
private String shopName;
|
||||
|
||||
public BossShopSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
public BossShopSign(DungeonsXL plugin, Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(plugin, sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
/* Getters and setters*/
|
||||
|
@ -18,6 +18,7 @@ package de.erethon.dungeonsxl.sign;
|
||||
|
||||
import de.erethon.caliburn.item.VanillaItem;
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.player.DGamePlayer;
|
||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||
@ -36,8 +37,8 @@ public class CheckpointSign extends DSign {
|
||||
private boolean initialized;
|
||||
private CopyOnWriteArrayList<DGamePlayer> done = new CopyOnWriteArrayList<>();
|
||||
|
||||
public CheckpointSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
public CheckpointSign(DungeonsXL plugin, Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(plugin, sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,6 +20,7 @@ import de.erethon.caliburn.category.Category;
|
||||
import de.erethon.caliburn.item.VanillaItem;
|
||||
import de.erethon.caliburn.loottable.LootTable;
|
||||
import de.erethon.commons.misc.NumberUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||
import de.erethon.dungeonsxl.world.block.RewardChest;
|
||||
import java.util.Arrays;
|
||||
@ -44,8 +45,8 @@ public class ChestSign extends DSign {
|
||||
private ItemStack[] chestContent;
|
||||
private LootTable lootTable;
|
||||
|
||||
public ChestSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
public ChestSign(DungeonsXL plugin, Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(plugin, sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
@ -178,7 +179,7 @@ public class ChestSign extends DSign {
|
||||
itemReward = list.toArray(new ItemStack[list.size()]);
|
||||
}
|
||||
|
||||
getGameWorld().addGameBlock(new RewardChest(chest, moneyReward, levelReward, itemReward));
|
||||
getGameWorld().addGameBlock(new RewardChest(plugin, chest, moneyReward, levelReward, itemReward));
|
||||
getSign().getBlock().setType(VanillaItem.AIR.getMaterial());
|
||||
|
||||
} else {
|
||||
|
@ -18,6 +18,7 @@ package de.erethon.dungeonsxl.sign;
|
||||
|
||||
import de.erethon.caliburn.item.VanillaItem;
|
||||
import de.erethon.commons.misc.NumberUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.block.Sign;
|
||||
@ -29,8 +30,8 @@ public class ChunkUpdaterSign extends DSign {
|
||||
|
||||
private DSignType type = DSignTypeDefault.CHUNK_UPDATER;
|
||||
|
||||
public ChunkUpdaterSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
public ChunkUpdaterSign(DungeonsXL plugin, Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(plugin, sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,6 +18,7 @@ package de.erethon.dungeonsxl.sign;
|
||||
|
||||
import de.erethon.caliburn.item.VanillaItem;
|
||||
import de.erethon.commons.misc.NumberUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.trigger.InteractTrigger;
|
||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||
import io.github.dre2n.commandsxl.CommandsXL;
|
||||
@ -44,8 +45,8 @@ public class CommandSign extends DSign {
|
||||
private String executor;
|
||||
private boolean initialized;
|
||||
|
||||
public CommandSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
public CommandSign(DungeonsXL plugin, Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(plugin, sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,7 +39,7 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public abstract class DSign {
|
||||
|
||||
protected DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
protected DungeonsXL plugin;
|
||||
|
||||
public static final String ERROR_0 = ChatColor.DARK_RED + "## ERROR ##";
|
||||
public static final String ERROR_1 = ChatColor.WHITE + "Please";
|
||||
@ -55,7 +55,9 @@ public abstract class DSign {
|
||||
|
||||
private boolean erroneous;
|
||||
|
||||
public DSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
protected DSign(DungeonsXL plugin, Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
this.plugin = plugin;
|
||||
|
||||
this.sign = sign;
|
||||
this.lines = lines;
|
||||
this.gameWorld = gameWorld;
|
||||
@ -79,7 +81,7 @@ public abstract class DSign {
|
||||
value = triggerString.substring(1);
|
||||
}
|
||||
|
||||
Trigger trigger = Trigger.getOrCreate(type, value, this);
|
||||
Trigger trigger = Trigger.getOrCreate(plugin, type, value, this);
|
||||
if (trigger != null) {
|
||||
trigger.addListener(this);
|
||||
addTrigger(trigger);
|
||||
@ -221,21 +223,21 @@ public abstract class DSign {
|
||||
}
|
||||
|
||||
/* Statics */
|
||||
public static DSign create(Sign sign, DGameWorld gameWorld) {
|
||||
return create(sign, sign.getLines(), gameWorld);
|
||||
public static DSign create(DungeonsXL plugin, Sign sign, DGameWorld gameWorld) {
|
||||
return create(plugin, sign, sign.getLines(), gameWorld);
|
||||
}
|
||||
|
||||
public static DSign create(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
public static DSign create(DungeonsXL plugin, Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
DSign dSign = null;
|
||||
|
||||
for (DSignType type : DungeonsXL.getInstance().getDSigns().getDSigns()) {
|
||||
for (DSignType type : plugin.getDSignCache().getDSigns()) {
|
||||
if (!lines[0].equalsIgnoreCase("[" + type.getName() + "]")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
Constructor<? extends DSign> constructor = type.getHandler().getConstructor(Sign.class, String[].class, DGameWorld.class);
|
||||
dSign = constructor.newInstance(sign, lines, gameWorld);
|
||||
Constructor<? extends DSign> constructor = type.getHandler().getConstructor(DungeonsXL.class, Sign.class, String[].class, DGameWorld.class);
|
||||
dSign = constructor.newInstance(plugin, sign, lines, gameWorld);
|
||||
|
||||
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException exception) {
|
||||
MessageUtil.log("An error occurred while accessing the handler class of the sign " + type.getName() + ": " + exception.getClass().getSimpleName());
|
||||
|
@ -17,6 +17,7 @@
|
||||
package de.erethon.dungeonsxl.sign;
|
||||
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.player.DGamePlayer;
|
||||
import de.erethon.dungeonsxl.player.DPermission;
|
||||
@ -39,6 +40,12 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
*/
|
||||
public class DSignListener implements Listener {
|
||||
|
||||
private DungeonsXL plugin;
|
||||
|
||||
public DSignListener(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@ -97,7 +104,7 @@ public class DSignListener implements Listener {
|
||||
sign.setLine(2, lines[2]);
|
||||
sign.setLine(3, lines[3]);
|
||||
|
||||
DSign dsign = DSign.create(sign, null);
|
||||
DSign dsign = DSign.create(plugin, sign, null);
|
||||
|
||||
if (dsign == null) {
|
||||
return;
|
||||
|
@ -29,11 +29,17 @@ import org.bukkit.Bukkit;
|
||||
*/
|
||||
public class DSignTypeCache {
|
||||
|
||||
private DungeonsXL plugin;
|
||||
|
||||
private List<DSignType> types = new ArrayList<>();
|
||||
|
||||
public DSignTypeCache() {
|
||||
public DSignTypeCache(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
types.addAll(Arrays.asList(DSignTypeDefault.values()));
|
||||
Bukkit.getPluginManager().registerEvents(new DSignListener(), DungeonsXL.getInstance());
|
||||
Bukkit.getPluginManager().registerEvents(new DSignListener(plugin), plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,6 +19,7 @@ package de.erethon.dungeonsxl.sign;
|
||||
import de.erethon.caliburn.item.ExItem;
|
||||
import de.erethon.caliburn.item.VanillaItem;
|
||||
import de.erethon.commons.misc.NumberUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Sign;
|
||||
@ -35,8 +36,8 @@ public class DropSign extends DSign {
|
||||
private ItemStack item;
|
||||
private double interval = -1;
|
||||
|
||||
public DropSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
public DropSign(DungeonsXL plugin, Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(plugin, sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
|
@ -17,6 +17,7 @@
|
||||
package de.erethon.dungeonsxl.sign;
|
||||
|
||||
import de.erethon.caliburn.item.VanillaItem;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.dungeon.Dungeon;
|
||||
import de.erethon.dungeonsxl.player.DGamePlayer;
|
||||
@ -36,8 +37,8 @@ public class EndSign extends DSign {
|
||||
|
||||
private DResourceWorld floor;
|
||||
|
||||
public EndSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
public EndSign(DungeonsXL plugin, Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(plugin, sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,7 +63,7 @@ public class EndSign extends DSign {
|
||||
@Override
|
||||
public void onInit() {
|
||||
if (!lines[1].isEmpty()) {
|
||||
floor = plugin.getDWorlds().getResourceByName(lines[1]);
|
||||
floor = plugin.getDWorldCache().getResourceByName(lines[1]);
|
||||
}
|
||||
|
||||
if (!getTriggers().isEmpty()) {
|
||||
|
@ -17,6 +17,7 @@
|
||||
package de.erethon.dungeonsxl.sign;
|
||||
|
||||
import de.erethon.commons.misc.NumberUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||
import de.erethon.dungeonsxl.world.block.TeamFlag;
|
||||
import org.bukkit.block.Sign;
|
||||
@ -30,8 +31,8 @@ public class FlagSign extends DSign {
|
||||
|
||||
private int team;
|
||||
|
||||
public FlagSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
public FlagSign(DungeonsXL plugin, Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(plugin, sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
@ -50,7 +51,7 @@ public class FlagSign extends DSign {
|
||||
public void onInit() {
|
||||
this.team = NumberUtil.parseInt(lines[1]);
|
||||
if (getGame().getDGroups().size() > team) {
|
||||
getGameWorld().addGameBlock(new TeamFlag(getSign().getBlock(), getGame().getDGroups().get(team)));
|
||||
getGameWorld().addGameBlock(new TeamFlag(plugin, getSign().getBlock(), getGame().getDGroups().get(team)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
package de.erethon.dungeonsxl.sign;
|
||||
|
||||
import de.erethon.commons.misc.NumberUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.trigger.InteractTrigger;
|
||||
import de.erethon.dungeonsxl.world.DEditWorld;
|
||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||
@ -34,8 +35,8 @@ public class InteractSign extends DSign {
|
||||
|
||||
private DSignType type = DSignTypeDefault.INTERACT;
|
||||
|
||||
public InteractSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
public InteractSign(DungeonsXL plugin, Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(plugin, sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,6 +17,7 @@
|
||||
package de.erethon.dungeonsxl.sign;
|
||||
|
||||
import de.erethon.caliburn.item.VanillaItem;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.event.dplayer.instance.game.DGamePlayerEscapeEvent;
|
||||
import de.erethon.dungeonsxl.player.DGamePlayer;
|
||||
@ -34,8 +35,8 @@ public class LeaveSign extends DSign {
|
||||
|
||||
private DSignType type = DSignTypeDefault.LEAVE;
|
||||
|
||||
public LeaveSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
public LeaveSign(DungeonsXL plugin, Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(plugin, sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -81,7 +82,7 @@ public class LeaveSign extends DSign {
|
||||
|
||||
@Override
|
||||
public void onTrigger() {
|
||||
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) {
|
||||
for (DGamePlayer dPlayer : plugin.getDPlayerCache().getDGamePlayers()) {
|
||||
DGamePlayerEscapeEvent event = new DGamePlayerEscapeEvent(dPlayer);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user