mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 21:48:43 +01:00
Refactor listeners; resolves #93
This commit is contained in:
parent
4b0e691a2b
commit
70d66515bd
@ -22,7 +22,7 @@ import io.github.dre2n.commons.config.MessageConfig;
|
|||||||
import io.github.dre2n.commons.javaplugin.BRPlugin;
|
import io.github.dre2n.commons.javaplugin.BRPlugin;
|
||||||
import io.github.dre2n.commons.javaplugin.BRPluginSettings;
|
import io.github.dre2n.commons.javaplugin.BRPluginSettings;
|
||||||
import io.github.dre2n.dungeonsxl.announcer.Announcers;
|
import io.github.dre2n.dungeonsxl.announcer.Announcers;
|
||||||
import io.github.dre2n.dungeonsxl.command.*;
|
import io.github.dre2n.dungeonsxl.command.DCommands;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.config.GlobalData;
|
import io.github.dre2n.dungeonsxl.config.GlobalData;
|
||||||
import io.github.dre2n.dungeonsxl.config.MainConfig;
|
import io.github.dre2n.dungeonsxl.config.MainConfig;
|
||||||
@ -30,7 +30,6 @@ import io.github.dre2n.dungeonsxl.dungeon.Dungeons;
|
|||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameTypes;
|
import io.github.dre2n.dungeonsxl.game.GameTypes;
|
||||||
import io.github.dre2n.dungeonsxl.global.GlobalProtections;
|
import io.github.dre2n.dungeonsxl.global.GlobalProtections;
|
||||||
import io.github.dre2n.dungeonsxl.listener.*;
|
|
||||||
import io.github.dre2n.dungeonsxl.loottable.DLootTables;
|
import io.github.dre2n.dungeonsxl.loottable.DLootTables;
|
||||||
import io.github.dre2n.dungeonsxl.mob.DMobTypes;
|
import io.github.dre2n.dungeonsxl.mob.DMobTypes;
|
||||||
import io.github.dre2n.dungeonsxl.mob.ExternalMobProviders;
|
import io.github.dre2n.dungeonsxl.mob.ExternalMobProviders;
|
||||||
@ -44,11 +43,6 @@ import io.github.dre2n.dungeonsxl.reward.DLootInventory;
|
|||||||
import io.github.dre2n.dungeonsxl.reward.RewardTypes;
|
import io.github.dre2n.dungeonsxl.reward.RewardTypes;
|
||||||
import io.github.dre2n.dungeonsxl.sign.DSignTypes;
|
import io.github.dre2n.dungeonsxl.sign.DSignTypes;
|
||||||
import io.github.dre2n.dungeonsxl.sign.SignScripts;
|
import io.github.dre2n.dungeonsxl.sign.SignScripts;
|
||||||
import io.github.dre2n.dungeonsxl.task.AnnouncerTask;
|
|
||||||
import io.github.dre2n.dungeonsxl.task.LazyUpdateTask;
|
|
||||||
import io.github.dre2n.dungeonsxl.task.SecureModeTask;
|
|
||||||
import io.github.dre2n.dungeonsxl.task.UpdateTask;
|
|
||||||
import io.github.dre2n.dungeonsxl.task.WorldUnloadTask;
|
|
||||||
import io.github.dre2n.dungeonsxl.trigger.TriggerTypes;
|
import io.github.dre2n.dungeonsxl.trigger.TriggerTypes;
|
||||||
import io.github.dre2n.dungeonsxl.util.NoReload;
|
import io.github.dre2n.dungeonsxl.util.NoReload;
|
||||||
import io.github.dre2n.dungeonsxl.world.DWorlds;
|
import io.github.dre2n.dungeonsxl.world.DWorlds;
|
||||||
@ -56,7 +50,6 @@ import java.io.File;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main class of DungeonsXL.
|
* The main class of DungeonsXL.
|
||||||
@ -102,12 +95,6 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
private SignScripts signScripts;
|
private SignScripts signScripts;
|
||||||
private DWorlds dWorlds;
|
private DWorlds dWorlds;
|
||||||
|
|
||||||
private BukkitTask announcerTask;
|
|
||||||
private BukkitTask worldUnloadTask;
|
|
||||||
private BukkitTask lazyUpdateTask;
|
|
||||||
private BukkitTask updateTask;
|
|
||||||
private BukkitTask secureModeTask;
|
|
||||||
|
|
||||||
private CopyOnWriteArrayList<DLootInventory> dLootInventories = new CopyOnWriteArrayList<>();
|
private CopyOnWriteArrayList<DLootInventory> dLootInventories = new CopyOnWriteArrayList<>();
|
||||||
private CopyOnWriteArrayList<Game> games = new CopyOnWriteArrayList<>();
|
private CopyOnWriteArrayList<Game> games = new CopyOnWriteArrayList<>();
|
||||||
private CopyOnWriteArrayList<DGroup> dGroups = new CopyOnWriteArrayList<>();
|
private CopyOnWriteArrayList<DGroup> dGroups = new CopyOnWriteArrayList<>();
|
||||||
@ -138,29 +125,8 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
DPermissions.register();
|
DPermissions.register();
|
||||||
initFolders();
|
initFolders();
|
||||||
loadCore();
|
loadCore();
|
||||||
|
|
||||||
manager.registerEvents(new EntityListener(), this);
|
|
||||||
manager.registerEvents(new GUIListener(), this);
|
|
||||||
manager.registerEvents(new PlayerListener(), this);
|
|
||||||
manager.registerEvents(new BlockListener(), this);
|
|
||||||
manager.registerEvents(new WorldListener(), this);
|
|
||||||
manager.registerEvents(new HangingListener(), this);
|
|
||||||
if (manager.getPlugin("Citizens") != null) {
|
|
||||||
manager.registerEvents(new CitizensListener(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load All
|
|
||||||
loadData();
|
loadData();
|
||||||
|
|
||||||
// Tasks
|
|
||||||
startAnnouncerTask(mainConfig.getAnnouncmentInterval());
|
|
||||||
startWorldUnloadTask(1200L);
|
|
||||||
startLazyUpdateTask(20L);
|
|
||||||
startUpdateTask(20L);
|
|
||||||
if (mainConfig.isSecureModeEnabled()) {
|
|
||||||
startSecureModeTask(mainConfig.getSecureModeCheckInterval());
|
|
||||||
}
|
|
||||||
|
|
||||||
new NoReload(this);
|
new NoReload(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,78 +544,6 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
dWorlds = new DWorlds(MAPS);
|
dWorlds = new DWorlds(MAPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the AnnouncerTask
|
|
||||||
*/
|
|
||||||
public BukkitTask getAnnouncerTask() {
|
|
||||||
return announcerTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* start a new AnnouncerTask
|
|
||||||
*/
|
|
||||||
public void startAnnouncerTask(long period) {
|
|
||||||
if (!announcers.getAnnouncers().isEmpty()) {
|
|
||||||
announcerTask = new AnnouncerTask(announcers).runTaskTimer(this, period, period);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the worldUnloadTask
|
|
||||||
*/
|
|
||||||
public BukkitTask getWorldUnloadTask() {
|
|
||||||
return worldUnloadTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* start a new WorldUnloadTask
|
|
||||||
*/
|
|
||||||
public void startWorldUnloadTask(long period) {
|
|
||||||
worldUnloadTask = new WorldUnloadTask().runTaskTimer(this, period, period);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the lazyUpdateTask
|
|
||||||
*/
|
|
||||||
public BukkitTask getLazyUpdateTask() {
|
|
||||||
return lazyUpdateTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* start a new LazyUpdateTask
|
|
||||||
*/
|
|
||||||
public void startLazyUpdateTask(long period) {
|
|
||||||
lazyUpdateTask = new LazyUpdateTask().runTaskTimer(this, period, period);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the updateTask
|
|
||||||
*/
|
|
||||||
public BukkitTask getUpdateTask() {
|
|
||||||
return updateTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* start a new LazyUpdateTask
|
|
||||||
*/
|
|
||||||
public void startUpdateTask(long period) {
|
|
||||||
updateTask = new UpdateTask().runTaskTimer(this, period, period);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the secureModeTask
|
|
||||||
*/
|
|
||||||
public BukkitTask getSecureModeTask() {
|
|
||||||
return secureModeTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* start a new SecureModeTask
|
|
||||||
*/
|
|
||||||
public void startSecureModeTask(long period) {
|
|
||||||
updateTask = new SecureModeTask().runTaskTimer(this, period, period);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the dLootInventories
|
* @return the dLootInventories
|
||||||
*/
|
*/
|
||||||
|
@ -25,7 +25,6 @@ import io.github.dre2n.dungeonsxl.config.DMessages;
|
|||||||
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import io.github.dre2n.dungeonsxl.task.AnnouncerStartGameTask;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -14,11 +14,10 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.listener;
|
package io.github.dre2n.dungeonsxl.announcer;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.guiutil.ButtonClickEvent;
|
import io.github.dre2n.commons.util.guiutil.ButtonClickEvent;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.announcer.Announcer;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -28,7 +27,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
/**
|
/**
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class GUIListener implements Listener {
|
public class AnnouncerListener implements Listener {
|
||||||
|
|
||||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
@ -14,10 +14,9 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.announcer;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.announcer.Announcer;
|
|
||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
@ -14,11 +14,9 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.announcer;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.announcer.Announcer;
|
|
||||||
import io.github.dre2n.dungeonsxl.announcer.Announcers;
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
||||||
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -17,11 +17,14 @@
|
|||||||
package io.github.dre2n.dungeonsxl.announcer;
|
package io.github.dre2n.dungeonsxl.announcer;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.FileUtil;
|
import io.github.dre2n.commons.util.FileUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Announcer instance manager.
|
* Announcer instance manager.
|
||||||
@ -30,6 +33,10 @@ import org.bukkit.inventory.Inventory;
|
|||||||
*/
|
*/
|
||||||
public class Announcers {
|
public class Announcers {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
|
private BukkitTask announcerTask;
|
||||||
|
|
||||||
private List<Announcer> announcers = new ArrayList<>();
|
private List<Announcer> announcers = new ArrayList<>();
|
||||||
|
|
||||||
public Announcers(File file) {
|
public Announcers(File file) {
|
||||||
@ -38,6 +45,8 @@ public class Announcers {
|
|||||||
announcers.add(new Announcer(script));
|
announcers.add(new Announcer(script));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
startAnnouncerTask(plugin.getMainConfig().getAnnouncmentInterval());
|
||||||
|
Bukkit.getPluginManager().registerEvents(new AnnouncerListener(), plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,4 +98,20 @@ public class Announcers {
|
|||||||
announcers.remove(announcer);
|
announcers.remove(announcer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the AnnouncerTask
|
||||||
|
*/
|
||||||
|
public BukkitTask getAnnouncerTask() {
|
||||||
|
return announcerTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* start a new AnnouncerTask
|
||||||
|
*/
|
||||||
|
public void startAnnouncerTask(long period) {
|
||||||
|
if (!announcers.isEmpty()) {
|
||||||
|
announcerTask = new AnnouncerTask(this).runTaskTimer(plugin, period, period);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ import io.github.dre2n.commons.util.NumberUtil;
|
|||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
|
|
||||||
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.DungeonConfig;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
|
@ -20,9 +20,9 @@ import io.github.dre2n.commons.command.BRCommand;
|
|||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.WorldConfig;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -20,8 +20,8 @@ import io.github.dre2n.commons.command.BRCommand;
|
|||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
|
|
||||||
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.DungeonConfig;
|
||||||
import io.github.dre2n.dungeonsxl.global.GameSign;
|
import io.github.dre2n.dungeonsxl.global.GameSign;
|
||||||
import io.github.dre2n.dungeonsxl.global.GlobalProtection;
|
import io.github.dre2n.dungeonsxl.global.GlobalProtection;
|
||||||
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||||
|
@ -53,12 +53,12 @@ public class StatusCommand extends BRCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
String minecraftVersion = compat.getVersion().toString();
|
String minecraftVersion = compat.getVersion().toString();
|
||||||
String bukkitVersion = Bukkit.getName() + " " + Bukkit.getBukkitVersion();
|
String bukkitVersion = Bukkit.getName() + (compat.isSpigot() ? " (Spigot)" : new String()) + " " + Bukkit.getBukkitVersion();
|
||||||
String internalsVersion = compat.getInternals().toString();
|
String internalsVersion = compat.getInternals().toString();
|
||||||
String dungeonsxlVersion = plugin.getDescription().getVersion();
|
String dungeonsxlVersion = plugin.getDescription().getVersion();
|
||||||
|
|
||||||
String internalsVersionCorrect = getSymbol(plugin.getSettings().getInternals().contains(compat.getInternals()));
|
String internalsVersionCorrect = getSymbol(plugin.getSettings().getInternals().contains(compat.getInternals()));
|
||||||
String bukkitVersionCorrect = getSymbol(bukkitVersion.startsWith("Spigot"));
|
String bukkitVersionCorrect = getSymbol(bukkitVersion.contains("Spigot"));
|
||||||
String dungeonsxlVersionCorrect = getSymbol(!dungeonsxlVersion.contains("SNAPSHOT"));
|
String dungeonsxlVersionCorrect = getSymbol(!dungeonsxlVersion.contains("SNAPSHOT"));
|
||||||
|
|
||||||
MessageUtil.sendCenteredMessage(sender, "&4&l=> &6STATUS &4&l<=");
|
MessageUtil.sendCenteredMessage(sender, "&4&l=> &6STATUS &4&l<=");
|
||||||
|
@ -23,6 +23,7 @@ import io.github.dre2n.commons.util.EnumUtil;
|
|||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.util.DColor;
|
import io.github.dre2n.dungeonsxl.util.DColor;
|
||||||
import static io.github.dre2n.dungeonsxl.util.DColor.*;
|
import static io.github.dre2n.dungeonsxl.util.DColor.*;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.WorldConfig;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package io.github.dre2n.dungeonsxl.dungeon;
|
package io.github.dre2n.dungeonsxl.dungeon;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -14,12 +14,13 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.config;
|
package io.github.dre2n.dungeonsxl.dungeon;
|
||||||
|
|
||||||
import io.github.dre2n.commons.config.BRConfig;
|
import io.github.dre2n.commons.config.BRConfig;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||||
import io.github.dre2n.dungeonsxl.world.DWorlds;
|
import io.github.dre2n.dungeonsxl.world.DWorlds;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.WorldConfig;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -19,16 +19,16 @@ package io.github.dre2n.dungeonsxl.game;
|
|||||||
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
|
|
||||||
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
|
||||||
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.DungeonConfig;
|
||||||
import io.github.dre2n.dungeonsxl.global.GameSign;
|
import io.github.dre2n.dungeonsxl.global.GameSign;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import io.github.dre2n.dungeonsxl.sign.DSign;
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
import io.github.dre2n.dungeonsxl.sign.MobSign;
|
import io.github.dre2n.dungeonsxl.sign.mob.MobSign;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.ProgressTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.ProgressTrigger;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.WorldConfig;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -48,7 +48,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
*/
|
*/
|
||||||
public class Game {
|
public class Game {
|
||||||
|
|
||||||
static DungeonsXL plugin = DungeonsXL.getInstance();
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
private boolean tutorial;
|
private boolean tutorial;
|
||||||
private List<DGroup> dGroups = new ArrayList<>();
|
private List<DGroup> dGroups = new ArrayList<>();
|
||||||
@ -461,7 +461,7 @@ public class Game {
|
|||||||
|
|
||||||
/* Statics */
|
/* Statics */
|
||||||
public static Game getByDGroup(DGroup dGroup) {
|
public static Game getByDGroup(DGroup dGroup) {
|
||||||
for (Game game : plugin.getGames()) {
|
for (Game game : DungeonsXL.getInstance().getGames()) {
|
||||||
if (game.getDGroups().contains(dGroup)) {
|
if (game.getDGroups().contains(dGroup)) {
|
||||||
return game;
|
return game;
|
||||||
}
|
}
|
||||||
@ -475,7 +475,7 @@ public class Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Game getByGameWorld(DGameWorld gameWorld) {
|
public static Game getByGameWorld(DGameWorld gameWorld) {
|
||||||
for (Game game : plugin.getGames()) {
|
for (Game game : DungeonsXL.getInstance().getGames()) {
|
||||||
if (gameWorld.equals(game.getWorld())) {
|
if (gameWorld.equals(game.getWorld())) {
|
||||||
return game;
|
return game;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
|||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import static io.github.dre2n.dungeonsxl.global.GlobalProtection.plugin;
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -14,59 +14,39 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.listener;
|
package io.github.dre2n.dungeonsxl.global;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
|
||||||
import io.github.dre2n.dungeonsxl.global.DPortal;
|
|
||||||
import io.github.dre2n.dungeonsxl.global.GameSign;
|
|
||||||
import io.github.dre2n.dungeonsxl.global.GlobalProtection;
|
|
||||||
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
|
||||||
import io.github.dre2n.dungeonsxl.global.LeaveSign;
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPlayers;
|
|
||||||
import io.github.dre2n.dungeonsxl.sign.DSign;
|
|
||||||
import io.github.dre2n.dungeonsxl.task.RedstoneEventTask;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import java.util.List;
|
||||||
import io.github.dre2n.dungeonsxl.world.DInstanceWorld;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockIgniteEvent;
|
|
||||||
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
|
||||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
|
||||||
import org.bukkit.event.block.BlockSpreadEvent;
|
import org.bukkit.event.block.BlockSpreadEvent;
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.event.player.PlayerPortalEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel, Wooyoung Son
|
* @author Daniel Saukel, Wooyoung Son, Frank Baumann, Milan Albrecht
|
||||||
*/
|
*/
|
||||||
public class BlockListener implements Listener {
|
public class GlobalProtectionListener implements Listener {
|
||||||
|
|
||||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
DPlayers dPlayers = plugin.getDPlayers();
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void onPhysics(BlockPhysicsEvent event) {
|
|
||||||
if (DPortal.getByBlock(event.getBlock()) != null) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBreakWithSignOnIt(BlockBreakEvent event) {
|
public void onBlockBreakWithSignOnIt(BlockBreakEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
@ -83,66 +63,120 @@ public class BlockListener implements Listener {
|
|||||||
|
|
||||||
//let onBreak() method to handle the sign
|
//let onBreak() method to handle the sign
|
||||||
BlockBreakEvent bbe = new BlockBreakEvent(blockAbove, player);
|
BlockBreakEvent bbe = new BlockBreakEvent(blockAbove, player);
|
||||||
onBreak(bbe);
|
onBlockBreak(bbe);
|
||||||
|
|
||||||
//follow the onBreak()
|
//follow the onBreak()
|
||||||
event.setCancelled(bbe.isCancelled());
|
event.setCancelled(bbe.isCancelled());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler
|
||||||
public void onBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
DGlobalPlayer dGlobalPlayer = dPlayers.getByPlayer(player);
|
DGlobalPlayer dGlobalPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||||
|
|
||||||
GlobalProtection protection = plugin.getGlobalProtections().getByBlock(event.getBlock());
|
GlobalProtection protection = plugin.getGlobalProtections().getByBlock(block);
|
||||||
if (protection != null) {
|
if (protection != null) {
|
||||||
if (protection.onBreak(dGlobalPlayer)) {
|
if (protection.onBreak(dGlobalPlayer)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// DEditWorld Signs
|
@EventHandler
|
||||||
DEditWorld editWorld = DEditWorld.getByWorld(block.getWorld());
|
public void onBlockSpread(BlockSpreadEvent event) {
|
||||||
if (editWorld != null) {
|
if (DPortal.getByBlock(event.getBlock()) != null) {
|
||||||
editWorld.getSigns().remove(event.getBlock());
|
event.setCancelled(true);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Deny DGameWorld block breaking
|
@EventHandler
|
||||||
DGameWorld gameWorld = DGameWorld.getByWorld(block.getWorld());
|
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||||
if (gameWorld != null) {
|
if (DPortal.getByBlock(event.getBlock()) != null) {
|
||||||
if (gameWorld.onBreak(event)) {
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
|
List<Block> blocklist = event.blockList();
|
||||||
|
for (Block block : blocklist) {
|
||||||
|
if (DungeonsXL.getInstance().getGlobalProtections().isProtectedBlock(block)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler
|
||||||
public void onPlace(BlockPlaceEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
Block block = event.getBlock();
|
Player player = event.getPlayer();
|
||||||
|
DPortal dPortal = DPortal.getByLocation(player.getEyeLocation());
|
||||||
// Deny DGameWorld Blocks
|
if (dPortal == null) {
|
||||||
DGameWorld gameWorld = DGameWorld.getByWorld(block.getWorld());
|
|
||||||
if (gameWorld == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gameWorld.onPlace(event.getPlayer(), block, event.getBlockAgainst(), event.getItemInHand())) {
|
Block blockFrom = event.getFrom().getBlock();
|
||||||
|
Block blockTo = event.getTo().getBlock();
|
||||||
|
if (blockFrom.equals(blockTo)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dPortal.teleport(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerPortal(PlayerPortalEvent event) {
|
||||||
|
Block block1 = event.getFrom().getBlock();
|
||||||
|
Block block2 = block1.getRelative(BlockFace.WEST);
|
||||||
|
Block block3 = block1.getRelative(BlockFace.NORTH);
|
||||||
|
Block block4 = block1.getRelative(BlockFace.EAST);
|
||||||
|
Block block5 = block1.getRelative(BlockFace.SOUTH);
|
||||||
|
if (DPortal.getByBlock(block1) != null || DPortal.getByBlock(block2) != null || DPortal.getByBlock(block3) != null || DPortal.getByBlock(block4) != null || DPortal.getByBlock(block5) != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
/* SUBJECT TO CHANGE */
|
||||||
|
@Deprecated
|
||||||
|
@EventHandler
|
||||||
|
public void onInteract(PlayerInteractEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (plugin.getDPlayers().getByPlayer(player).isInBreakMode()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Block clickedBlock = event.getClickedBlock();
|
||||||
|
if (clickedBlock == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clickedBlock.getType() == Material.WALL_SIGN || clickedBlock.getType() == Material.SIGN_POST) {
|
||||||
|
// Check Group Signs
|
||||||
|
if (GroupSign.playerInteract(clickedBlock, player)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check Game Signs
|
||||||
|
if (GameSign.playerInteract(clickedBlock, player)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
LeaveSign leaveSign = LeaveSign.getByBlock(clickedBlock);
|
||||||
|
if (leaveSign != null) {
|
||||||
|
leaveSign.onPlayerInteract(player);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@EventHandler
|
||||||
public void onSignChange(SignChangeEvent event) {
|
public void onSignChange(SignChangeEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
String[] lines = event.getLines();
|
String[] lines = event.getLines();
|
||||||
DEditWorld editWorld = DEditWorld.getByWorld(player.getWorld());
|
|
||||||
|
|
||||||
// Group Signs
|
// Group Signs
|
||||||
if (editWorld == null) {
|
if (DEditWorld.getByWorld(player.getWorld()) == null) {
|
||||||
if (!DPermissions.hasPermission(player, DPermissions.SIGN)) {
|
if (!DPermissions.hasPermission(player, DPermissions.SIGN)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -181,64 +215,6 @@ public class BlockListener implements Listener {
|
|||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { // Editworld Signs
|
|
||||||
Sign sign = (Sign) block.getState();
|
|
||||||
if (sign != null) {
|
|
||||||
sign.setLine(0, lines[0]);
|
|
||||||
sign.setLine(1, lines[1]);
|
|
||||||
sign.setLine(2, lines[2]);
|
|
||||||
sign.setLine(3, lines[3]);
|
|
||||||
|
|
||||||
DSign dsign = DSign.create(sign, null);
|
|
||||||
|
|
||||||
if (dsign == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!DPermissions.hasPermission(player, dsign.getType().getBuildPermission())) {
|
|
||||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.ERROR_NO_PERMISSIONS));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dsign.check()) {
|
|
||||||
editWorld.registerSign(block);
|
|
||||||
editWorld.getSigns().add(block);
|
|
||||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.PLAYER_SIGN_CREATED));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.ERROR_SIGN_WRONG_FORMAT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
|
||||||
public void onSpread(BlockSpreadEvent event) {
|
|
||||||
Block block = event.getSource();
|
|
||||||
|
|
||||||
DInstanceWorld instance = plugin.getDWorlds().getInstanceByName(block.getWorld().getName());
|
|
||||||
if (instance != null && block.getType() == Material.VINE) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
} else if (DPortal.getByBlock(block) != null) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
|
||||||
public void onRedstoneEvent(BlockRedstoneEvent event) {
|
|
||||||
new RedstoneEventTask(event.getBlock()).runTaskLater(plugin, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void onIgnite(BlockIgniteEvent event) {
|
|
||||||
if (plugin.getDWorlds().getInstanceByName(event.getBlock().getWorld().getName()) == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.getCause() != IgniteCause.FLINT_AND_STEEL) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -20,6 +20,7 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -37,6 +38,10 @@ public class GlobalProtections {
|
|||||||
|
|
||||||
private Set<GlobalProtection> protections = new HashSet<>();
|
private Set<GlobalProtection> protections = new HashSet<>();
|
||||||
|
|
||||||
|
public GlobalProtections() {
|
||||||
|
Bukkit.getPluginManager().registerEvents(new GlobalProtectionListener(), plugin);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the protection which covers this location
|
* @return the protection which covers this location
|
||||||
*/
|
*/
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2012-2017 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 io.github.dre2n.dungeonsxl.listener;
|
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
|
||||||
import io.github.dre2n.dungeonsxl.mob.CitizensMobProvider;
|
|
||||||
import net.citizensnpcs.api.CitizensAPI;
|
|
||||||
import net.citizensnpcs.api.event.NPCDeathEvent;
|
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Daniel Saukel
|
|
||||||
*/
|
|
||||||
public class CitizensListener implements Listener {
|
|
||||||
|
|
||||||
CitizensMobProvider provider = DungeonsXL.getInstance().getExternalMobProviders().getCitizensMobProvider();
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onNPCDeath(NPCDeathEvent event) {
|
|
||||||
NPC npc = event.getNPC();
|
|
||||||
if (provider.getSpawnedNPCs().contains(npc)) {
|
|
||||||
CitizensAPI.getNPCRegistry().deregister(npc);
|
|
||||||
provider.removeSpawnedNPC(npc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,284 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2012-2017 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 io.github.dre2n.dungeonsxl.listener;
|
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
|
||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
|
||||||
import io.github.dre2n.dungeonsxl.mob.DMob;
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
|
||||||
import java.util.List;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.Projectile;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
|
||||||
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
|
||||||
import org.bukkit.event.entity.EntityCombustEvent;
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
|
||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Frank Baumann, Tobias Schmitz, Milan Albrecht, Daniel Saukel
|
|
||||||
*/
|
|
||||||
public class EntityListener implements Listener {
|
|
||||||
|
|
||||||
// Remove drops from breaking Signs
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void onItemSpawn(ItemSpawnEvent event) {
|
|
||||||
if (DGameWorld.getByWorld(event.getLocation().getWorld()) != null) {
|
|
||||||
if (event.getEntity().getItemStack().getType() == Material.SIGN) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
|
||||||
World world = event.getLocation().getWorld();
|
|
||||||
|
|
||||||
DEditWorld editWorld = DEditWorld.getByWorld(world);
|
|
||||||
DGameWorld gameWorld = DGameWorld.getByWorld(world);
|
|
||||||
|
|
||||||
if (editWorld != null || gameWorld != null) {
|
|
||||||
switch (event.getSpawnReason()) {
|
|
||||||
case CHUNK_GEN:
|
|
||||||
case JOCKEY:
|
|
||||||
case MOUNT:
|
|
||||||
case NATURAL:
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void onDeath(EntityDeathEvent event) {
|
|
||||||
World world = event.getEntity().getWorld();
|
|
||||||
|
|
||||||
if (event.getEntity() instanceof LivingEntity) {
|
|
||||||
LivingEntity entity = event.getEntity();
|
|
||||||
DGameWorld gameWorld = DGameWorld.getByWorld(world);
|
|
||||||
if (gameWorld != null) {
|
|
||||||
if (gameWorld.isPlaying()) {
|
|
||||||
DMob dMob = DMob.getByEntity(entity);
|
|
||||||
if (dMob != null) {
|
|
||||||
dMob.onDeath(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void onDamage(EntityDamageEvent event) {
|
|
||||||
World world = event.getEntity().getWorld();
|
|
||||||
DGameWorld gameWorld = DGameWorld.getByWorld(world);
|
|
||||||
|
|
||||||
if (gameWorld == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deny all Damage in Lobby
|
|
||||||
if (!gameWorld.isPlaying()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean dead = ((LivingEntity) event.getEntity()).getHealth() - event.getFinalDamage() <= 0;
|
|
||||||
if (dead && DMob.getByEntity(event.getEntity()) != null) {
|
|
||||||
String killer = null;
|
|
||||||
|
|
||||||
if (event instanceof EntityDamageByEntityEvent) {
|
|
||||||
Entity damager = ((EntityDamageByEntityEvent) event).getDamager();
|
|
||||||
|
|
||||||
if (damager instanceof Projectile) {
|
|
||||||
if (((Projectile) damager).getShooter() instanceof Player) {
|
|
||||||
damager = (Player) ((Projectile) damager).getShooter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (damager instanceof Player) {
|
|
||||||
killer = damager.getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gameWorld.getGame().addKill(killer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void onDamageByEntity(EntityDamageByEntityEvent event) {
|
|
||||||
World world = event.getEntity().getWorld();
|
|
||||||
DGameWorld gameWorld = DGameWorld.getByWorld(world);
|
|
||||||
|
|
||||||
if (gameWorld == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Game game = gameWorld.getGame();
|
|
||||||
|
|
||||||
if (game == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!game.hasStarted()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean pvp = game.getRules().isPlayerVersusPlayer();
|
|
||||||
boolean friendlyFire = game.getRules().isFriendlyFire();
|
|
||||||
|
|
||||||
Entity attackerEntity = event.getDamager();
|
|
||||||
Entity attackedEntity = event.getEntity();
|
|
||||||
|
|
||||||
if (attackerEntity instanceof Projectile) {
|
|
||||||
attackerEntity = (Entity) ((Projectile) attackerEntity).getShooter();
|
|
||||||
}
|
|
||||||
|
|
||||||
Player attackerPlayer = null;
|
|
||||||
Player attackedPlayer = null;
|
|
||||||
|
|
||||||
DGroup attackerDGroup = null;
|
|
||||||
DGroup attackedDGroup = null;
|
|
||||||
|
|
||||||
if (!(attackerEntity instanceof LivingEntity) || !(attackedEntity instanceof LivingEntity)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attackerEntity instanceof Player && attackedEntity instanceof Player) {
|
|
||||||
attackerPlayer = (Player) attackerEntity;
|
|
||||||
attackedPlayer = (Player) attackedEntity;
|
|
||||||
|
|
||||||
attackerDGroup = DGroup.getByPlayer(attackerPlayer);
|
|
||||||
attackedDGroup = DGroup.getByPlayer(attackedPlayer);
|
|
||||||
|
|
||||||
if (!pvp) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attackerDGroup != null && attackedDGroup != null) {
|
|
||||||
if (!friendlyFire && attackerDGroup.equals(attackedDGroup)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check Dogs
|
|
||||||
if (attackerEntity instanceof Player || attackedEntity instanceof Player) {
|
|
||||||
for (DGamePlayer dPlayer : DGamePlayer.getByWorld(gameWorld.getWorld())) {
|
|
||||||
if (dPlayer.getWolf() != null) {
|
|
||||||
if (attackerEntity == dPlayer.getWolf() || attackedEntity == dPlayer.getWolf()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (DGamePlayer dPlayer : DGamePlayer.getByWorld(gameWorld.getWorld())) {
|
|
||||||
if (dPlayer.getWolf() != null) {
|
|
||||||
if (attackerEntity instanceof Player || attackedEntity instanceof Player) {
|
|
||||||
if (attackerEntity == dPlayer.getWolf() || attackedEntity == dPlayer.getWolf()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (attackerEntity == dPlayer.getWolf() || attackedEntity == dPlayer.getWolf()) {
|
|
||||||
event.setCancelled(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deny food in Lobby
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
|
||||||
World world = event.getEntity().getWorld();
|
|
||||||
|
|
||||||
DGameWorld gameWorld = DGameWorld.getByWorld(world);
|
|
||||||
if (gameWorld != null) {
|
|
||||||
if (!gameWorld.isPlaying()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Zombie/skeleton combustion from the sun.
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
|
||||||
public void onCombust(EntityCombustEvent event) {
|
|
||||||
DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
|
|
||||||
if (gameWorld != null) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow Other combustion
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void onCombustByEntity(EntityCombustByEntityEvent event) {
|
|
||||||
DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
|
|
||||||
if (gameWorld != null) {
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
event.setCancelled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Explosions
|
|
||||||
@EventHandler
|
|
||||||
public void onExplode(EntityExplodeEvent event) {
|
|
||||||
DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
|
|
||||||
|
|
||||||
if (gameWorld != null) {
|
|
||||||
if (event.getEntity() instanceof LivingEntity) {
|
|
||||||
// Disable Creeper explosions in gameWorlds
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Disable drops from TNT
|
|
||||||
event.setYield(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prevent GlobalProtection destroying
|
|
||||||
List<Block> blocklist = event.blockList();
|
|
||||||
for (Block block : blocklist) {
|
|
||||||
if (DungeonsXL.getInstance().getGlobalProtections().isProtectedBlock(block)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2012-2017 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 io.github.dre2n.dungeonsxl.listener;
|
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
|
||||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Frank Baumann
|
|
||||||
*/
|
|
||||||
public class WorldListener implements Listener {
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
|
||||||
DGameWorld gameWorld = DGameWorld.getByWorld(event.getWorld());
|
|
||||||
if (gameWorld != null) {
|
|
||||||
if (gameWorld.getLoadedChunks().contains(event.getChunk())) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
|
||||||
public void onWeatherChange(WeatherChangeEvent event) {
|
|
||||||
if (DEditWorld.getByWorld(event.getWorld()) != null) {
|
|
||||||
if (event.toWeatherState()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -21,17 +21,20 @@ import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import net.citizensnpcs.api.CitizensAPI;
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
|
import net.citizensnpcs.api.event.NPCDeathEvent;
|
||||||
import net.citizensnpcs.api.npc.AbstractNPC;
|
import net.citizensnpcs.api.npc.AbstractNPC;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ExternalMobProvider implementation for Citizens.
|
* ExternalMobProvider implementation for Citizens.
|
||||||
*
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class CitizensMobProvider implements ExternalMobProvider {
|
public class CitizensMobProvider implements ExternalMobProvider, Listener {
|
||||||
|
|
||||||
private DNPCRegistry registry = new DNPCRegistry();
|
private DNPCRegistry registry = new DNPCRegistry();
|
||||||
private String identifier = "CI";
|
private String identifier = "CI";
|
||||||
@ -100,4 +103,14 @@ public class CitizensMobProvider implements ExternalMobProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Listeners */
|
||||||
|
@EventHandler
|
||||||
|
public void onNPCDeath(NPCDeathEvent event) {
|
||||||
|
NPC npc = event.getNPC();
|
||||||
|
if (spawnedNPCs.contains(npc)) {
|
||||||
|
CitizensAPI.getNPCRegistry().deregister(npc);
|
||||||
|
removeSpawnedNPC(npc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2012-2017 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 io.github.dre2n.dungeonsxl.mob;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||||
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel, Frank Baumann
|
||||||
|
*/
|
||||||
|
public class DMobListener implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||||
|
World world = event.getLocation().getWorld();
|
||||||
|
|
||||||
|
DEditWorld editWorld = DEditWorld.getByWorld(world);
|
||||||
|
DGameWorld gameWorld = DGameWorld.getByWorld(world);
|
||||||
|
|
||||||
|
if (editWorld != null || gameWorld != null) {
|
||||||
|
switch (event.getSpawnReason()) {
|
||||||
|
case CHUNK_GEN:
|
||||||
|
case JOCKEY:
|
||||||
|
case MOUNT:
|
||||||
|
case NATURAL:
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
|
World world = event.getEntity().getWorld();
|
||||||
|
|
||||||
|
if (event.getEntity() instanceof LivingEntity) {
|
||||||
|
LivingEntity entity = event.getEntity();
|
||||||
|
DGameWorld gameWorld = DGameWorld.getByWorld(world);
|
||||||
|
if (gameWorld != null) {
|
||||||
|
if (gameWorld.isPlaying()) {
|
||||||
|
DMob dMob = DMob.getByEntity(entity);
|
||||||
|
if (dMob != null) {
|
||||||
|
dMob.onDeath(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zombie / Skeleton combustion from the sun.
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityCombust(EntityCombustEvent event) {
|
||||||
|
DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
|
||||||
|
if (gameWorld != null) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow other combustion
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
|
||||||
|
DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
|
||||||
|
if (gameWorld != null) {
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
event.setCancelled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -17,9 +17,11 @@
|
|||||||
package io.github.dre2n.dungeonsxl.mob;
|
package io.github.dre2n.dungeonsxl.mob;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.FileUtil;
|
import io.github.dre2n.commons.util.FileUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
@ -34,6 +36,7 @@ public class DMobTypes {
|
|||||||
dMobTypes.add(new DMobType(script));
|
dMobTypes.add(new DMobType(script));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Bukkit.getPluginManager().registerEvents(new DMobListener(), DungeonsXL.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,15 +31,19 @@ import org.bukkit.Bukkit;
|
|||||||
*/
|
*/
|
||||||
public class ExternalMobProviders {
|
public class ExternalMobProviders {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
private Set<ExternalMobProvider> providers = new HashSet<>();
|
private Set<ExternalMobProvider> providers = new HashSet<>();
|
||||||
|
|
||||||
public ExternalMobProviders() {
|
public ExternalMobProviders() {
|
||||||
// Supported providers
|
// Supported providers
|
||||||
providers.addAll(Arrays.asList(ExternalMobPlugin.values()));
|
providers.addAll(Arrays.asList(ExternalMobPlugin.values()));
|
||||||
if (Bukkit.getPluginManager().getPlugin("Citizens") != null) {
|
if (Bukkit.getPluginManager().getPlugin("Citizens") != null) {
|
||||||
providers.add(new CitizensMobProvider());
|
CitizensMobProvider citizens = new CitizensMobProvider();
|
||||||
|
providers.add(citizens);
|
||||||
|
Bukkit.getPluginManager().registerEvents(citizens, plugin);
|
||||||
} else {
|
} else {
|
||||||
MessageUtil.log("Could not find compatible Citizens plugin. The mob provider Citizens (\"CI\") will not get enabled...");
|
MessageUtil.log(plugin, "Could not find compatible Citizens plugin. The mob provider Citizens (\"CI\") will not get enabled...");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom providers
|
// Custom providers
|
||||||
|
@ -14,12 +14,10 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.player;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||||
import io.github.dre2n.dungeonsxl.player.DEditPlayer;
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import io.github.dre2n.dungeonsxl.world.DInstanceWorld;
|
import io.github.dre2n.dungeonsxl.world.DInstanceWorld;
|
@ -20,7 +20,6 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
|||||||
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.event.dplayer.instance.DInstancePlayerUpdateEvent;
|
import io.github.dre2n.dungeonsxl.event.dplayer.instance.DInstancePlayerUpdateEvent;
|
||||||
import io.github.dre2n.dungeonsxl.task.CreateDInstancePlayerTask;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
@ -33,7 +33,6 @@ import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
|||||||
import io.github.dre2n.dungeonsxl.mob.DMob;
|
import io.github.dre2n.dungeonsxl.mob.DMob;
|
||||||
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
||||||
import io.github.dre2n.dungeonsxl.reward.Reward;
|
import io.github.dre2n.dungeonsxl.reward.Reward;
|
||||||
import io.github.dre2n.dungeonsxl.task.CreateDInstancePlayerTask;
|
|
||||||
import io.github.dre2n.dungeonsxl.trigger.DistanceTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.DistanceTrigger;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||||
|
@ -22,7 +22,6 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
|||||||
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.config.PlayerData;
|
|
||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.global.DPortal;
|
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||||
@ -46,7 +45,7 @@ public class DGlobalPlayer {
|
|||||||
|
|
||||||
protected Player player;
|
protected Player player;
|
||||||
|
|
||||||
private PlayerData data;
|
private DPlayerData data;
|
||||||
|
|
||||||
private boolean breakMode;
|
private boolean breakMode;
|
||||||
private boolean chatSpyMode;
|
private boolean chatSpyMode;
|
||||||
@ -102,15 +101,15 @@ public class DGlobalPlayer {
|
|||||||
/**
|
/**
|
||||||
* @return the saved data
|
* @return the saved data
|
||||||
*/
|
*/
|
||||||
public PlayerData getData() {
|
public DPlayerData getData() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load / reload a new instance of PlayerData
|
* Load / reload a new instance of DPlayerData
|
||||||
*/
|
*/
|
||||||
public void loadPlayerData(File file) {
|
public void loadPlayerData(File file) {
|
||||||
data = new PlayerData(file);
|
data = new DPlayerData(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,8 +20,8 @@ import io.github.dre2n.commons.util.NumberUtil;
|
|||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
|
|
||||||
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.DungeonConfig;
|
||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupDisbandEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupDisbandEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishDungeonEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishDungeonEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishFloorEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishFloorEvent;
|
||||||
@ -35,7 +35,6 @@ import io.github.dre2n.dungeonsxl.game.GameRules;
|
|||||||
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||||
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
||||||
import io.github.dre2n.dungeonsxl.reward.Reward;
|
import io.github.dre2n.dungeonsxl.reward.Reward;
|
||||||
import io.github.dre2n.dungeonsxl.task.TimeIsRunningTask;
|
|
||||||
import io.github.dre2n.dungeonsxl.util.DColor;
|
import io.github.dre2n.dungeonsxl.util.DColor;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.config;
|
package io.github.dre2n.dungeonsxl.player;
|
||||||
|
|
||||||
import io.github.dre2n.commons.compatibility.CompatibilityHandler;
|
import io.github.dre2n.commons.compatibility.CompatibilityHandler;
|
||||||
import io.github.dre2n.commons.compatibility.Internals;
|
import io.github.dre2n.commons.compatibility.Internals;
|
||||||
@ -22,6 +22,7 @@ import io.github.dre2n.commons.config.BRConfig;
|
|||||||
import io.github.dre2n.commons.util.EnumUtil;
|
import io.github.dre2n.commons.util.EnumUtil;
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -41,7 +42,7 @@ import org.bukkit.potion.PotionEffect;
|
|||||||
*
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class PlayerData extends BRConfig {
|
public class DPlayerData extends BRConfig {
|
||||||
|
|
||||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
boolean is1_9 = Internals.andHigher(Internals.v1_9_R1).contains(CompatibilityHandler.getInstance().getInternals());
|
boolean is1_9 = Internals.andHigher(Internals.v1_9_R1).contains(CompatibilityHandler.getInstance().getInternals());
|
||||||
@ -68,7 +69,7 @@ public class PlayerData extends BRConfig {
|
|||||||
// Stats
|
// Stats
|
||||||
private Map<String, Long> timeLastPlayed = new HashMap<>();
|
private Map<String, Long> timeLastPlayed = new HashMap<>();
|
||||||
|
|
||||||
public PlayerData(File file) {
|
public DPlayerData(File file) {
|
||||||
super(file, CONFIG_VERSION);
|
super(file, CONFIG_VERSION);
|
||||||
|
|
||||||
if (initialize) {
|
if (initialize) {
|
File diff suppressed because it is too large
Load Diff
@ -16,21 +16,42 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.player;
|
package io.github.dre2n.dungeonsxl.player;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.config.MainConfig;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DGlobalPlayer instance manager.
|
* DGlobalPlayer instance manager.
|
||||||
*
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class DPlayers {
|
public class DPlayers implements Listener {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
MainConfig mainConfig = plugin.getMainConfig();
|
||||||
|
|
||||||
|
private BukkitTask secureModeTask;
|
||||||
|
private BukkitTask updateTask;
|
||||||
|
private BukkitTask lazyUpdateTask;
|
||||||
|
|
||||||
private CopyOnWriteArrayList<DGlobalPlayer> dGlobalPlayers = new CopyOnWriteArrayList<>();
|
private CopyOnWriteArrayList<DGlobalPlayer> dGlobalPlayers = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
|
public DPlayers() {
|
||||||
|
if (mainConfig.isSecureModeEnabled()) {
|
||||||
|
startSecureModeTask(mainConfig.getSecureModeCheckInterval());
|
||||||
|
}
|
||||||
|
startUpdateTask(2L);
|
||||||
|
startLazyUpdateTask(20L);
|
||||||
|
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the DGlobalPlayer which represents the player
|
* @return the DGlobalPlayer which represents the player
|
||||||
*/
|
*/
|
||||||
@ -144,4 +165,47 @@ public class DPlayers {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Tasks */
|
||||||
|
/**
|
||||||
|
* @return the secureModeTask
|
||||||
|
*/
|
||||||
|
public BukkitTask getSecureModeTask() {
|
||||||
|
return secureModeTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* start a new SecureModeTask
|
||||||
|
*/
|
||||||
|
public void startSecureModeTask(long period) {
|
||||||
|
secureModeTask = new SecureModeTask().runTaskTimer(plugin, period, period);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the updateTask
|
||||||
|
*/
|
||||||
|
public BukkitTask getUpdateTask() {
|
||||||
|
return updateTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* start a new LazyUpdateTask
|
||||||
|
*/
|
||||||
|
public void startUpdateTask(long period) {
|
||||||
|
updateTask = new UpdateTask().runTaskTimer(plugin, period, period);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the lazyUpdateTask
|
||||||
|
*/
|
||||||
|
public BukkitTask getLazyUpdateTask() {
|
||||||
|
return lazyUpdateTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* start a new LazyUpdateTask
|
||||||
|
*/
|
||||||
|
public void startLazyUpdateTask(long period) {
|
||||||
|
lazyUpdateTask = new LazyUpdateTask().runTaskTimer(plugin, period, period);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,9 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.player;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,15 +24,9 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
*/
|
*/
|
||||||
public class LazyUpdateTask extends BukkitRunnable {
|
public class LazyUpdateTask extends BukkitRunnable {
|
||||||
|
|
||||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (DGameWorld gameWorld : plugin.getDWorlds().getGameWorlds()) {
|
for (DGamePlayer dPlayer : DungeonsXL.getInstance().getDPlayers().getDGamePlayers()) {
|
||||||
gameWorld.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) {
|
|
||||||
dPlayer.update(true);
|
dPlayer.update(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,11 +14,10 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.player;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
@ -14,13 +14,9 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.player;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.player.DEditPlayer;
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.player;
|
||||||
|
|
||||||
import io.github.dre2n.commons.config.MessageConfig;
|
import io.github.dre2n.commons.config.MessageConfig;
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
@ -22,8 +22,6 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
|
|||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
|
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
|
||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
@ -14,10 +14,9 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.player;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
/**
|
/**
|
@ -18,8 +18,8 @@ package io.github.dre2n.dungeonsxl.requirement;
|
|||||||
|
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.config.PlayerData;
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPlayerData;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ public class FeeLevelRequirement extends Requirement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerData data = dPlayer.getData();
|
DPlayerData data = dPlayer.getData();
|
||||||
data.setOldLevel(data.getOldLevel() - fee);
|
data.setOldLevel(data.getOldLevel() - fee);
|
||||||
|
|
||||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.REQUIREMENT_FEE, fee + " levels"));
|
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.REQUIREMENT_FEE, fee + " levels"));
|
||||||
|
@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2012-2017 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 io.github.dre2n.dungeonsxl.reward;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.block.RewardChest;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Chest;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.inventory.InventoryView;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Frank Baumann, Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class RewardListener implements Listener {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryClose(InventoryCloseEvent event) {
|
||||||
|
if (!(event.getPlayer() instanceof Player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Player player = (Player) event.getPlayer();
|
||||||
|
|
||||||
|
for (DLootInventory inventory : plugin.getDLootInventories()) {
|
||||||
|
if (event.getView() != inventory.getInventoryView()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (System.currentTimeMillis() - inventory.getTime() <= 500) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ItemStack istack : inventory.getInventory().getContents()) {
|
||||||
|
if (istack != null) {
|
||||||
|
player.getWorld().dropItem(player.getLocation(), istack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.getDLootInventories().remove(inventory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||||
|
if (!(event.getPlayer() instanceof Player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
InventoryView inventory = event.getView();
|
||||||
|
|
||||||
|
DGameWorld gameWorld = DGameWorld.getByWorld(event.getPlayer().getWorld());
|
||||||
|
|
||||||
|
if (gameWorld == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(inventory.getTopInventory().getHolder() instanceof Chest)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Chest chest = (Chest) inventory.getTopInventory().getHolder();
|
||||||
|
|
||||||
|
for (RewardChest rewardChest : gameWorld.getRewardChests()) {
|
||||||
|
if (!rewardChest.getChest().equals(chest)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
rewardChest.onOpen((Player) event.getPlayer());
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plugin.getMainConfig().getOpenInventories() && !DPermissions.hasPermission(event.getPlayer(), DPermissions.INSECURE)) {
|
||||||
|
World world = event.getPlayer().getWorld();
|
||||||
|
if (event.getInventory().getType() != InventoryType.CREATIVE && DEditWorld.getByWorld(world) != null) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
DLootInventory inventory = DLootInventory.getByPlayer(player);
|
||||||
|
if (inventory != null && player.getLocation().getBlock().getRelative(0, 1, 0).getType() != Material.PORTAL && player.getLocation().getBlock().getRelative(0, -1, 0).getType() != Material.PORTAL
|
||||||
|
&& player.getLocation().getBlock().getRelative(1, 0, 0).getType() != Material.PORTAL && player.getLocation().getBlock().getRelative(-1, 0, 0).getType() != Material.PORTAL
|
||||||
|
&& player.getLocation().getBlock().getRelative(0, 0, 1).getType() != Material.PORTAL && player.getLocation().getBlock().getRelative(0, 0, -1).getType() != Material.PORTAL) {
|
||||||
|
inventory.setInventoryView(player.openInventory(inventory.getInventory()));
|
||||||
|
inventory.setTime(System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -16,9 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.reward;
|
package io.github.dre2n.dungeonsxl.reward;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RewardType instance manager.
|
* RewardType instance manager.
|
||||||
@ -27,10 +29,13 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class RewardTypes {
|
public class RewardTypes {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
private List<RewardType> types = new ArrayList<>();
|
private List<RewardType> types = new ArrayList<>();
|
||||||
|
|
||||||
public RewardTypes() {
|
public RewardTypes() {
|
||||||
types.addAll(Arrays.asList(RewardTypeDefault.values()));
|
types.addAll(Arrays.asList(RewardTypeDefault.values()));
|
||||||
|
Bukkit.getPluginManager().registerEvents(new RewardListener(), plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2012-2017 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 io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
|
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Frank Baumann, Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class DSignListener implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Block clickedBlock = event.getClickedBlock();
|
||||||
|
if (clickedBlock == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
|
||||||
|
if (dPlayer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DGameWorld gameWorld = DGameWorld.getByWorld(player.getWorld());
|
||||||
|
if (gameWorld == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
InteractTrigger trigger = InteractTrigger.getByBlock(clickedBlock, gameWorld);
|
||||||
|
if (trigger != null) {
|
||||||
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
|
trigger.onTrigger(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Sign classSign : gameWorld.getClassesSigns()) {
|
||||||
|
if (classSign != null) {
|
||||||
|
if (classSign.getLocation().distance(clickedBlock.getLocation()) < 1) {
|
||||||
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
|
dPlayer.setDClass(ChatColor.stripColor(classSign.getLine(1)));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onSignChange(SignChangeEvent event) {
|
||||||
|
String[] lines = event.getLines();
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Block block = event.getBlock();
|
||||||
|
Sign sign = (Sign) block.getState();
|
||||||
|
DEditWorld editWorld = DEditWorld.getByWorld(sign.getWorld());
|
||||||
|
if (editWorld == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sign != null) {
|
||||||
|
sign.setLine(0, lines[0]);
|
||||||
|
sign.setLine(1, lines[1]);
|
||||||
|
sign.setLine(2, lines[2]);
|
||||||
|
sign.setLine(3, lines[3]);
|
||||||
|
|
||||||
|
DSign dsign = DSign.create(sign, null);
|
||||||
|
|
||||||
|
if (dsign == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!DPermissions.hasPermission(player, dsign.getType().getBuildPermission())) {
|
||||||
|
MessageUtil.sendMessage(player, DMessages.ERROR_NO_PERMISSIONS.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dsign.check()) {
|
||||||
|
editWorld.registerSign(block);
|
||||||
|
editWorld.getSigns().add(block);
|
||||||
|
MessageUtil.sendMessage(player, DMessages.PLAYER_SIGN_CREATED.getMessage());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, DMessages.ERROR_SIGN_WRONG_FORMAT.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -17,6 +17,17 @@
|
|||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.lobby.ClassesSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.lobby.LobbySign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.lobby.ReadySign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.lobby.StartSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.message.ActionBarSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.message.HologramSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.message.MessageSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.message.SoundMessageSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.message.TitleSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.mob.DMobSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.mob.ExternalMobSign;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation of DSignType.
|
* Default implementation of DSignType.
|
||||||
|
@ -16,9 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DSignType instance manager.
|
* DSignType instance manager.
|
||||||
@ -27,10 +29,13 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class DSignTypes {
|
public class DSignTypes {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
private List<DSignType> types = new ArrayList<>();
|
private List<DSignType> types = new ArrayList<>();
|
||||||
|
|
||||||
public DSignTypes() {
|
public DSignTypes() {
|
||||||
types.addAll(Arrays.asList(DSignTypeDefault.values()));
|
types.addAll(Arrays.asList(DSignTypeDefault.values()));
|
||||||
|
Bukkit.getPluginManager().registerEvents(new DSignListener(), plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,9 +14,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.sign.RedstoneSign;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
@ -19,12 +19,12 @@ package io.github.dre2n.dungeonsxl.sign;
|
|||||||
import io.github.dre2n.caliburn.CaliburnAPI;
|
import io.github.dre2n.caliburn.CaliburnAPI;
|
||||||
import io.github.dre2n.caliburn.item.UniversalItem;
|
import io.github.dre2n.caliburn.item.UniversalItem;
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
import io.github.dre2n.dungeonsxl.task.DropItemTask;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
||||||
@ -79,13 +79,23 @@ public class DropSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
Location spawnLocation = getSign().getLocation().add(0.5, 0, 0.5);
|
final Location spawnLocation = getSign().getLocation().add(0.5, 0, 0.5);
|
||||||
if (interval < 0) {
|
if (interval < 0) {
|
||||||
getSign().getWorld().dropItem(spawnLocation, item);
|
getSign().getWorld().dropItem(spawnLocation, item);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
long period = (long) interval * 20;
|
long period = (long) interval * 20;
|
||||||
new DropItemTask(item, spawnLocation).runTaskTimer(plugin, period, period);
|
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
spawnLocation.getWorld().dropItem(spawnLocation, item);
|
||||||
|
} catch (NullPointerException exception) {
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskTimer(plugin, period, period);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
import io.github.dre2n.dungeonsxl.task.SignUpdateTask;
|
|
||||||
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
import io.github.dre2n.dungeonsxl.task.DelayedPowerTask;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
@ -17,7 +17,6 @@
|
|||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
import io.github.dre2n.dungeonsxl.task.SignUpdateTask;
|
|
||||||
import io.github.dre2n.dungeonsxl.trigger.SignTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.SignTrigger;
|
||||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
|
@ -14,9 +14,13 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign.lobby;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.player.DClass;
|
import io.github.dre2n.dungeonsxl.player.DClass;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignType;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
@ -26,6 +30,8 @@ import org.bukkit.block.Sign;
|
|||||||
*/
|
*/
|
||||||
public class ClassesSign extends DSign {
|
public class ClassesSign extends DSign {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
private DSignType type = DSignTypeDefault.CLASSES;
|
private DSignType type = DSignTypeDefault.CLASSES;
|
||||||
|
|
||||||
private DClass dClass;
|
private DClass dClass;
|
@ -14,8 +14,11 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign.lobby;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignType;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
@ -14,15 +14,19 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign.lobby;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignType;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||||
import io.github.dre2n.dungeonsxl.util.ProgressBar;
|
import io.github.dre2n.dungeonsxl.util.ProgressBar;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
@ -37,6 +41,8 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
*/
|
*/
|
||||||
public class ReadySign extends DSign {
|
public class ReadySign extends DSign {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
private DSignType type = DSignTypeDefault.READY;
|
private DSignType type = DSignTypeDefault.READY;
|
||||||
|
|
||||||
private GameType gameType;
|
private GameType gameType;
|
@ -14,9 +14,12 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign.lobby;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignType;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
@ -14,9 +14,12 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign.message;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignType;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignTypeDefault;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.PerPlayerSign;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign.message;
|
||||||
|
|
||||||
import com.gmail.filoghost.holographicdisplays.api.Hologram;
|
import com.gmail.filoghost.holographicdisplays.api.Hologram;
|
||||||
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
|
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
|
||||||
@ -24,6 +24,10 @@ import io.github.dre2n.commons.compatibility.CompatibilityHandler;
|
|||||||
import io.github.dre2n.commons.compatibility.Version;
|
import io.github.dre2n.commons.compatibility.Version;
|
||||||
import io.github.dre2n.commons.util.EnumUtil;
|
import io.github.dre2n.commons.util.EnumUtil;
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignType;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -57,7 +61,7 @@ public class HologramSign extends DSign {
|
|||||||
Location location = getSign().getLocation();
|
Location location = getSign().getLocation();
|
||||||
location = location.add(0.5, NumberUtil.parseDouble(lines[2]), 0.5);
|
location = location.add(0.5, NumberUtil.parseDouble(lines[2]), 0.5);
|
||||||
|
|
||||||
hologram = HologramsAPI.createHologram(plugin, location);
|
hologram = HologramsAPI.createHologram(DungeonsXL.getInstance(), location);
|
||||||
for (String line : holoLines) {
|
for (String line : holoLines) {
|
||||||
if (line.startsWith("Item:")) {
|
if (line.startsWith("Item:")) {
|
||||||
String id = line.replace("Item:", "");
|
String id = line.replace("Item:", "");
|
@ -14,10 +14,13 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign.message;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignType;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
@ -14,9 +14,12 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign.message;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignType;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
@ -14,9 +14,12 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign.message;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignType;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignTypeDefault;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.PerPlayerSign;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
@ -14,10 +14,13 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign.mob;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
import io.github.dre2n.dungeonsxl.task.MobSpawnTask;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignType;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
@ -126,7 +129,7 @@ public class DMobSign extends DSign implements MobSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeTask() {
|
public void initializeTask() {
|
||||||
task = new MobSpawnTask(this).runTaskTimer(plugin, 0L, 20L);
|
task = new MobSpawnTask(this).runTaskTimer(DungeonsXL.getInstance(), 0L, 20L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -14,12 +14,15 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign.mob;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.mob.ExternalMobPlugin;
|
import io.github.dre2n.dungeonsxl.mob.ExternalMobPlugin;
|
||||||
import io.github.dre2n.dungeonsxl.mob.ExternalMobProvider;
|
import io.github.dre2n.dungeonsxl.mob.ExternalMobProvider;
|
||||||
import io.github.dre2n.dungeonsxl.task.ExternalMobSpawnTask;
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignType;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSignTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -36,6 +39,8 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
*/
|
*/
|
||||||
public class ExternalMobSign extends DSign implements MobSign {
|
public class ExternalMobSign extends DSign implements MobSign {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
private DSignType type = DSignTypeDefault.EXTERNAL_MOB;
|
private DSignType type = DSignTypeDefault.EXTERNAL_MOB;
|
||||||
|
|
||||||
// Variables
|
// Variables
|
@ -14,11 +14,10 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.sign.mob;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.mob.DMob;
|
import io.github.dre2n.dungeonsxl.mob.DMob;
|
||||||
import io.github.dre2n.dungeonsxl.mob.ExternalMobProvider;
|
import io.github.dre2n.dungeonsxl.mob.ExternalMobProvider;
|
||||||
import io.github.dre2n.dungeonsxl.sign.ExternalMobSign;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign.mob;
|
||||||
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
@ -14,12 +14,11 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.sign.mob;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.mob.DMob;
|
import io.github.dre2n.dungeonsxl.mob.DMob;
|
||||||
import io.github.dre2n.dungeonsxl.mob.DMobType;
|
import io.github.dre2n.dungeonsxl.mob.DMobType;
|
||||||
import io.github.dre2n.dungeonsxl.sign.DMobSign;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2012-2017 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 io.github.dre2n.dungeonsxl.task;
|
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Frank Baumann, Daniel Saukel
|
|
||||||
*/
|
|
||||||
public class DropItemTask extends BukkitRunnable {
|
|
||||||
|
|
||||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
|
||||||
|
|
||||||
private ItemStack item;
|
|
||||||
private Location location;
|
|
||||||
|
|
||||||
public DropItemTask(ItemStack item, Location location) {
|
|
||||||
this.item = item;
|
|
||||||
this.location = location;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
location.getWorld().dropItem(location, item);
|
|
||||||
} catch (NullPointerException exception) {
|
|
||||||
cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -18,7 +18,6 @@ package io.github.dre2n.dungeonsxl.trigger;
|
|||||||
|
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
|
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
|
||||||
import static io.github.dre2n.dungeonsxl.trigger.Trigger.plugin;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,24 +14,32 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.listener;
|
package io.github.dre2n.dungeonsxl.trigger;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Frank Baumann
|
* @author Milan Albrecht, Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class HangingListener implements Listener {
|
public class TriggerListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {
|
public void onRedstoneEvent(final BlockRedstoneEvent event) {
|
||||||
DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
|
new BukkitRunnable() {
|
||||||
if (gameWorld != null) {
|
@Override
|
||||||
event.setCancelled(true);
|
public void run() {
|
||||||
}
|
for (DGameWorld gameWorld : DungeonsXL.getInstance().getDWorlds().getGameWorlds()) {
|
||||||
|
if (event.getBlock().getWorld() == gameWorld.getWorld()) {
|
||||||
|
RedstoneTrigger.updateAll(gameWorld);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskLater(DungeonsXL.getInstance(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -16,9 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.trigger;
|
package io.github.dre2n.dungeonsxl.trigger;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TriggerType instance manager.
|
* TriggerType instance manager.
|
||||||
@ -27,10 +29,13 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class TriggerTypes {
|
public class TriggerTypes {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
private List<TriggerType> types = new ArrayList<>();
|
private List<TriggerType> types = new ArrayList<>();
|
||||||
|
|
||||||
public TriggerTypes() {
|
public TriggerTypes() {
|
||||||
types.addAll(Arrays.asList(TriggerTypeDefault.values()));
|
types.addAll(Arrays.asList(TriggerTypeDefault.values()));
|
||||||
|
Bukkit.getPluginManager().registerEvents(new TriggerListener(), plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,11 +14,10 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.world;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.FileUtil;
|
import io.github.dre2n.commons.util.FileUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
@ -27,8 +27,8 @@ import io.github.dre2n.dungeonsxl.player.DGroup;
|
|||||||
import io.github.dre2n.dungeonsxl.sign.DSign;
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
import io.github.dre2n.dungeonsxl.sign.DSignType;
|
import io.github.dre2n.dungeonsxl.sign.DSignType;
|
||||||
import io.github.dre2n.dungeonsxl.sign.DSignTypeDefault;
|
import io.github.dre2n.dungeonsxl.sign.DSignTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.sign.MobSign;
|
import io.github.dre2n.dungeonsxl.sign.lobby.StartSign;
|
||||||
import io.github.dre2n.dungeonsxl.sign.StartSign;
|
import io.github.dre2n.dungeonsxl.sign.mob.MobSign;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.FortuneTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.FortuneTrigger;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.ProgressTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.ProgressTrigger;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.RedstoneTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.RedstoneTrigger;
|
||||||
|
@ -18,7 +18,6 @@ package io.github.dre2n.dungeonsxl.world;
|
|||||||
|
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
@ -18,11 +18,8 @@ package io.github.dre2n.dungeonsxl.world;
|
|||||||
|
|
||||||
import io.github.dre2n.commons.util.FileUtil;
|
import io.github.dre2n.commons.util.FileUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.SignData;
|
|
||||||
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
|
||||||
import io.github.dre2n.dungeonsxl.event.editworld.EditWorldGenerateEvent;
|
import io.github.dre2n.dungeonsxl.event.editworld.EditWorldGenerateEvent;
|
||||||
import io.github.dre2n.dungeonsxl.player.DEditPlayer;
|
import io.github.dre2n.dungeonsxl.player.DEditPlayer;
|
||||||
import io.github.dre2n.dungeonsxl.task.BackupResourceTask;
|
|
||||||
import io.github.dre2n.dungeonsxl.util.worldloader.WorldLoader;
|
import io.github.dre2n.dungeonsxl.util.worldloader.WorldLoader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -0,0 +1,148 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2012-2017 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 io.github.dre2n.dungeonsxl.world;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockIgniteEvent;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.block.BlockSpreadEvent;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
|
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||||
|
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||||
|
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel, Frank Baumann, Milan Albrecht
|
||||||
|
*/
|
||||||
|
public class DWorldListener implements Listener {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
DWorlds dWorlds = plugin.getDWorlds();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
|
Block block = event.getBlock();
|
||||||
|
// DEditWorld Signs
|
||||||
|
DEditWorld editWorld = DEditWorld.getByWorld(block.getWorld());
|
||||||
|
if (editWorld != null) {
|
||||||
|
editWorld.getSigns().remove(event.getBlock());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deny DGameWorld block breaking
|
||||||
|
DGameWorld gameWorld = DGameWorld.getByWorld(block.getWorld());
|
||||||
|
if (gameWorld != null) {
|
||||||
|
if (gameWorld.onBreak(event)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
|
Block block = event.getBlock();
|
||||||
|
|
||||||
|
DGameWorld gameWorld = DGameWorld.getByWorld(block.getWorld());
|
||||||
|
if (gameWorld == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gameWorld.onPlace(event.getPlayer(), block, event.getBlockAgainst(), event.getItemInHand())) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockIgnite(BlockIgniteEvent event) {
|
||||||
|
if (dWorlds.getInstanceByWorld(event.getBlock().getWorld()) == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getCause() != BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockSpread(BlockSpreadEvent event) {
|
||||||
|
Block block = event.getSource();
|
||||||
|
|
||||||
|
DInstanceWorld instance = dWorlds.getInstanceByWorld(block.getWorld());
|
||||||
|
if (instance != null && block.getType() == Material.VINE) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||||
|
DInstanceWorld instance = dWorlds.getInstanceByWorld(event.getWorld());
|
||||||
|
if (instance instanceof DGameWorld) {
|
||||||
|
if (((DGameWorld) instance).getLoadedChunks().contains(event.getChunk())) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
|
DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
|
||||||
|
|
||||||
|
if (gameWorld != null) {
|
||||||
|
if (event.getEntity() instanceof LivingEntity) {
|
||||||
|
// Disable Creeper explosions in gameWorlds
|
||||||
|
event.setCancelled(true);
|
||||||
|
} else {
|
||||||
|
// Disable drops from TNT
|
||||||
|
event.setYield(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {
|
||||||
|
DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
|
||||||
|
if (gameWorld != null) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onItemSpawn(ItemSpawnEvent event) {
|
||||||
|
if (DGameWorld.getByWorld(event.getLocation().getWorld()) != null) {
|
||||||
|
if (event.getEntity().getItemStack().getType() == Material.SIGN) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onWeatherChange(WeatherChangeEvent event) {
|
||||||
|
if (dWorlds.getInstanceByWorld(event.getWorld()) != null) {
|
||||||
|
if (event.toWeatherState()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -25,9 +25,24 @@ import java.io.File;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
import org.bukkit.WorldType;
|
import org.bukkit.WorldType;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockIgniteEvent;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.block.BlockSpreadEvent;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
|
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||||
|
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||||
|
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* World instance manager.
|
* World instance manager.
|
||||||
@ -41,6 +56,8 @@ public class DWorlds {
|
|||||||
|
|
||||||
public static final File RAW = new File(DungeonsXL.MAPS, ".raw");
|
public static final File RAW = new File(DungeonsXL.MAPS, ".raw");
|
||||||
|
|
||||||
|
private BukkitTask worldUnloadTask;
|
||||||
|
|
||||||
private Set<DResourceWorld> resources = new HashSet<>();
|
private Set<DResourceWorld> resources = new HashSet<>();
|
||||||
private Set<DInstanceWorld> instances = new HashSet<>();
|
private Set<DInstanceWorld> instances = new HashSet<>();
|
||||||
|
|
||||||
@ -54,6 +71,9 @@ public class DWorlds {
|
|||||||
if (!RAW.exists()) {
|
if (!RAW.exists()) {
|
||||||
createRaw();
|
createRaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startWorldUnloadTask(1200L);
|
||||||
|
Bukkit.getPluginManager().registerEvents(new DWorldListener(), plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Getters and setters */
|
/* Getters and setters */
|
||||||
@ -70,6 +90,13 @@ public class DWorlds {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the DInstanceWorld that represents this world
|
||||||
|
*/
|
||||||
|
public DInstanceWorld getInstanceByWorld(World world) {
|
||||||
|
return getInstanceByName(world.getName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the DInstanceWorld that has this name
|
* @return the DInstanceWorld that has this name
|
||||||
*/
|
*/
|
||||||
@ -273,4 +300,19 @@ public class DWorlds {
|
|||||||
FileUtil.removeDirectory(worldFolder);
|
FileUtil.removeDirectory(worldFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Tasks */
|
||||||
|
/**
|
||||||
|
* @return the worldUnloadTask
|
||||||
|
*/
|
||||||
|
public BukkitTask getWorldUnloadTask() {
|
||||||
|
return worldUnloadTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* start a new WorldUnloadTask
|
||||||
|
*/
|
||||||
|
public void startWorldUnloadTask(long period) {
|
||||||
|
worldUnloadTask = new WorldUnloadTask().runTaskTimer(plugin, period, period);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,9 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.config;
|
package io.github.dre2n.dungeonsxl.world;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.sign.DSign;
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.config;
|
package io.github.dre2n.dungeonsxl.world;
|
||||||
|
|
||||||
import io.github.dre2n.caliburn.CaliburnAPI;
|
import io.github.dre2n.caliburn.CaliburnAPI;
|
||||||
import io.github.dre2n.caliburn.item.UniversalItemStack;
|
import io.github.dre2n.caliburn.item.UniversalItemStack;
|
@ -14,12 +14,10 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.world;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
/**
|
/**
|
@ -14,31 +14,21 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.world;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.RedstoneTrigger;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Frank Baumann, Daniel Saukel
|
*
|
||||||
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class RedstoneEventTask extends BukkitRunnable {
|
public class WorldUpdateTask extends BukkitRunnable {
|
||||||
|
|
||||||
private Block block;
|
|
||||||
|
|
||||||
public RedstoneEventTask(final Block block) {
|
|
||||||
this.block = block;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (DGameWorld gameWorld : DungeonsXL.getInstance().getDWorlds().getGameWorlds()) {
|
for (DGameWorld gameWorld : DungeonsXL.getInstance().getDWorlds().getGameWorlds()) {
|
||||||
if (block.getWorld() == gameWorld.getWorld()) {
|
gameWorld.update();
|
||||||
RedstoneTrigger.updateAll(gameWorld);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user