mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-12-01 06:53:26 +01:00
General cleanup
Finished to large extent. Including: - Replaced many field references with getters and setters - Replaced many "if (...) { if (...) {" blocks with "if (!...) {return}" to clean up the code a littlebit - Changed package naming to "io.github.dre2n" - Rewrote the command system - Rewrote the lives system - Rewrote the permissions system to use SuperPerms instead when possible - Rewrote the multi version handler and added code to support Minecraft 1.9 (obviously untested) - Added CommandsXL command signs - Renamed "dungeons" folder to "maps" and prepared a bit more for the upcoming multi floor support - Bugfixes - ...and a looooot more
This commit is contained in:
parent
c98e52a925
commit
cf17fcf32c
@ -1,17 +0,0 @@
|
|||||||
package com.dre.dungeonsxl;
|
|
||||||
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public class DClass {
|
|
||||||
public CopyOnWriteArrayList<ItemStack> items = new CopyOnWriteArrayList<ItemStack>();
|
|
||||||
public String name;
|
|
||||||
public boolean hasDog;
|
|
||||||
|
|
||||||
public DClass(String name, CopyOnWriteArrayList<ItemStack> items, boolean hasDog) {
|
|
||||||
this.items = items;
|
|
||||||
this.name = name;
|
|
||||||
this.hasDog = hasDog;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,133 +0,0 @@
|
|||||||
package com.dre.dungeonsxl;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
|
||||||
|
|
||||||
public class DGroup {
|
|
||||||
public static CopyOnWriteArrayList<DGroup> dgroups = new CopyOnWriteArrayList<DGroup>();
|
|
||||||
|
|
||||||
private CopyOnWriteArrayList<Player> players = new CopyOnWriteArrayList<Player>();
|
|
||||||
private String dungeonname;
|
|
||||||
private GameWorld gworld;
|
|
||||||
public boolean isPlaying;
|
|
||||||
|
|
||||||
public DGroup(Player player, String dungeonname) {
|
|
||||||
dgroups.add(this);
|
|
||||||
|
|
||||||
this.getPlayers().add(player);
|
|
||||||
this.isPlaying = false;
|
|
||||||
this.setDungeonname(dungeonname);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addPlayer(Player player) {
|
|
||||||
// Send message
|
|
||||||
for (Player groupPlayer : this.getPlayers()) {
|
|
||||||
P.p.msg(groupPlayer, P.p.language.get("Player_JoinGroup", player.getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add player
|
|
||||||
this.getPlayers().add(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removePlayer(Player player) {
|
|
||||||
this.getPlayers().remove(player);
|
|
||||||
DGSign.updatePerGroup(this);
|
|
||||||
|
|
||||||
// Send message
|
|
||||||
for (Player groupPlayer : this.getPlayers()) {
|
|
||||||
P.p.msg(groupPlayer, P.p.language.get("Player_LeftGroup", player.getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check group
|
|
||||||
if (this.isEmpty()) {
|
|
||||||
this.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return this.getPlayers().isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove() {
|
|
||||||
dgroups.remove(this);
|
|
||||||
DGSign.updatePerGroup(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startGame() {
|
|
||||||
this.isPlaying = true;
|
|
||||||
getGworld().startGame();
|
|
||||||
for (Player player : getPlayers()) {
|
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
|
||||||
dplayer.respawn();
|
|
||||||
if (P.p.mainConfig.enableEconomy) {
|
|
||||||
File file = new File(P.p.getDataFolder() + "/dungeons/" + dungeonname + "/config.yml");
|
|
||||||
if (file != null) {
|
|
||||||
DConfig confReader = new DConfig(file);
|
|
||||||
if (confReader != null) {
|
|
||||||
P.p.economy.withdrawPlayer(player, confReader.getFee());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DGSign.updatePerGroup(this);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Statics
|
|
||||||
public static DGroup get(Player player) {
|
|
||||||
for (DGroup dgroup : dgroups) {
|
|
||||||
if (dgroup.getPlayers().contains(player)) {
|
|
||||||
return dgroup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DGroup get(GameWorld gworld) {
|
|
||||||
for (DGroup dgroup : dgroups) {
|
|
||||||
if (dgroup.getGworld() == gworld) {
|
|
||||||
return dgroup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void leaveGroup(Player player) {
|
|
||||||
for (DGroup dgroup : dgroups) {
|
|
||||||
if (dgroup.getPlayers().contains(player)) {
|
|
||||||
dgroup.getPlayers().remove(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getters and setters
|
|
||||||
|
|
||||||
public CopyOnWriteArrayList<Player> getPlayers() {
|
|
||||||
return players;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayers(CopyOnWriteArrayList<Player> players) {
|
|
||||||
this.players = players;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameWorld getGworld() {
|
|
||||||
return gworld;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGworld(GameWorld gworld) {
|
|
||||||
this.gworld = gworld;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDungeonname() {
|
|
||||||
return dungeonname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDungeonname(String dungeonname) {
|
|
||||||
this.dungeonname = dungeonname;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
package com.dre.dungeonsxl;
|
|
||||||
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.InventoryView;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public class DLootInventory {
|
|
||||||
public static CopyOnWriteArrayList<DLootInventory> LootInventorys = new CopyOnWriteArrayList<DLootInventory>();
|
|
||||||
|
|
||||||
public Inventory inventory;
|
|
||||||
public InventoryView inventoryView;
|
|
||||||
public Player player;
|
|
||||||
|
|
||||||
public long time;
|
|
||||||
|
|
||||||
public DLootInventory(Player player, ItemStack[] istacks) {
|
|
||||||
LootInventorys.add(this);
|
|
||||||
|
|
||||||
this.inventory = Bukkit.createInventory(player, 54, "Belohnungen");
|
|
||||||
for (ItemStack istack : istacks) {
|
|
||||||
if (istack != null) {
|
|
||||||
this.inventory.addItem(istack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DLootInventory get(Player player) {
|
|
||||||
for (DLootInventory inventory : LootInventorys) {
|
|
||||||
if (inventory.player == player) {
|
|
||||||
return inventory;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
package com.dre.dungeonsxl;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
|
|
||||||
public class MainConfig {
|
|
||||||
|
|
||||||
public String language = "en";
|
|
||||||
public boolean enableEconomy = false;
|
|
||||||
|
|
||||||
/* Tutorial */
|
|
||||||
public boolean tutorialActivated = false;
|
|
||||||
public String tutorialDungeon = "tutorial";
|
|
||||||
public String tutorialStartGroup = "default";
|
|
||||||
public String tutorialEndGroup = "player";
|
|
||||||
|
|
||||||
/* Default Dungeon Settings */
|
|
||||||
public DConfig defaultDungeon;
|
|
||||||
|
|
||||||
public MainConfig(File file) {
|
|
||||||
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
|
|
||||||
|
|
||||||
/* Main Config */
|
|
||||||
if (configFile.contains("language")) {
|
|
||||||
this.language = configFile.getString("language");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configFile.contains("enableEconomy")) {
|
|
||||||
this.enableEconomy = configFile.getBoolean("enableEconomy");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configFile.contains("tutorial.activated")) {
|
|
||||||
this.tutorialActivated = configFile.getBoolean("tutorial.activated");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configFile.contains("tutorial.dungeon")) {
|
|
||||||
this.tutorialDungeon = configFile.getString("tutorial.dungeon");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configFile.contains("tutorial.startgroup")) {
|
|
||||||
this.tutorialStartGroup = configFile.getString("tutorial.startgroup");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configFile.contains("tutorial.endgroup")) {
|
|
||||||
this.tutorialEndGroup = configFile.getString("tutorial.endgroup");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Default Dungeon Config */
|
|
||||||
ConfigurationSection configSetion = configFile.getConfigurationSection("default");
|
|
||||||
if (configSetion != null) {
|
|
||||||
defaultDungeon = new DConfig(configSetion);
|
|
||||||
DConfig.mainConfig = defaultDungeon;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,466 +0,0 @@
|
|||||||
package com.dre.dungeonsxl;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.nio.channels.FileChannel;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
|
||||||
import net.milkbowl.vault.permission.Permission;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.commands.DCommandRoot;
|
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
|
||||||
import com.dre.dungeonsxl.listener.BlockListener;
|
|
||||||
import com.dre.dungeonsxl.listener.CommandListener;
|
|
||||||
import com.dre.dungeonsxl.listener.EntityListener;
|
|
||||||
import com.dre.dungeonsxl.listener.HangingListener;
|
|
||||||
import com.dre.dungeonsxl.listener.PlayerListener;
|
|
||||||
import com.dre.dungeonsxl.listener.WorldListener;
|
|
||||||
import com.dre.dungeonsxl.listener.player.PlayerDeathListener;
|
|
||||||
import com.dre.dungeonsxl.multiversionhandler.MultiVersionHandler;
|
|
||||||
|
|
||||||
public class P extends JavaPlugin {
|
|
||||||
public static P p;
|
|
||||||
|
|
||||||
// Lives
|
|
||||||
public HashMap<Player, Integer> lives;
|
|
||||||
|
|
||||||
// Listener
|
|
||||||
private static Listener entityListener;
|
|
||||||
private static Listener playerListener;
|
|
||||||
private static Listener blockListener;
|
|
||||||
private static Listener worldListener;
|
|
||||||
private static Listener hangingListener;
|
|
||||||
private static Listener playerDeathListener;
|
|
||||||
|
|
||||||
// Main Config Reader
|
|
||||||
public MainConfig mainConfig;
|
|
||||||
|
|
||||||
// Language Reader
|
|
||||||
public LanguageReader language;
|
|
||||||
|
|
||||||
// Chatspyer
|
|
||||||
public CopyOnWriteArrayList<Player> chatSpyer = new CopyOnWriteArrayList<Player>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
|
||||||
p = this;
|
|
||||||
|
|
||||||
// Lives
|
|
||||||
lives = new HashMap<Player, Integer>();
|
|
||||||
|
|
||||||
// Commands
|
|
||||||
getCommand("dungeonsxl").setExecutor(new CommandListener());
|
|
||||||
|
|
||||||
// Load Language
|
|
||||||
language = new LanguageReader(new File(p.getDataFolder(), "languages/en.yml"));
|
|
||||||
|
|
||||||
// Load Config
|
|
||||||
mainConfig = new MainConfig(new File(p.getDataFolder(), "config.yml"));
|
|
||||||
|
|
||||||
// Load Language 2
|
|
||||||
language = new LanguageReader(new File(p.getDataFolder(), "languages/" + mainConfig.language + ".yml"));
|
|
||||||
|
|
||||||
// Init Commands
|
|
||||||
new DCommandRoot();
|
|
||||||
|
|
||||||
// InitFolders
|
|
||||||
this.initFolders();
|
|
||||||
|
|
||||||
// Setup Permissions
|
|
||||||
this.setupPermissions();
|
|
||||||
|
|
||||||
// Setup Economy
|
|
||||||
this.setupEconomy();
|
|
||||||
|
|
||||||
// Listener
|
|
||||||
entityListener = new EntityListener();
|
|
||||||
playerListener = new PlayerListener();
|
|
||||||
blockListener = new BlockListener();
|
|
||||||
worldListener = new WorldListener();
|
|
||||||
hangingListener = new HangingListener();
|
|
||||||
playerDeathListener = new PlayerDeathListener();
|
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(entityListener, this);
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(playerListener, this);
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(blockListener, this);
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(worldListener, this);
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(hangingListener, this);
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(playerDeathListener, this);
|
|
||||||
|
|
||||||
// Load All
|
|
||||||
this.loadAll();
|
|
||||||
|
|
||||||
// Scheduler
|
|
||||||
this.initSchedulers();
|
|
||||||
|
|
||||||
// MSG
|
|
||||||
this.log(this.getDescription().getName() + " enabled!");
|
|
||||||
if (!(MultiVersionHandler.supported.contains(MultiVersionHandler.getInternals()))) {
|
|
||||||
this.log("Warning: Your CraftBukkit version is deprecated. DungeonsXL does not support it.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
|
||||||
// Save
|
|
||||||
this.saveData();
|
|
||||||
language.save();
|
|
||||||
|
|
||||||
// DPlayer leaves World
|
|
||||||
for (DPlayer dplayer : DPlayer.players) {
|
|
||||||
dplayer.leave();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete all Data
|
|
||||||
DGroup.dgroups.clear();
|
|
||||||
DGSign.dgsigns.clear();
|
|
||||||
DLootInventory.LootInventorys.clear();
|
|
||||||
DPlayer.players.clear();
|
|
||||||
DPortal.portals.clear();
|
|
||||||
LeaveSign.lsigns.clear();
|
|
||||||
DCommandRoot.root.commands.clear();
|
|
||||||
|
|
||||||
// Delete Worlds
|
|
||||||
GameWorld.deleteAll();
|
|
||||||
EditWorld.deleteAll();
|
|
||||||
|
|
||||||
// Disable listeners
|
|
||||||
HandlerList.unregisterAll(p);
|
|
||||||
|
|
||||||
// Stop shedulers
|
|
||||||
p.getServer().getScheduler().cancelTasks(this);
|
|
||||||
|
|
||||||
// MSG
|
|
||||||
this.log(this.getDescription().getName() + " disabled!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init.
|
|
||||||
public void initFolders() {
|
|
||||||
// Check Folder
|
|
||||||
File folder = new File(this.getDataFolder() + "");
|
|
||||||
if (!folder.exists()) {
|
|
||||||
folder.mkdir();
|
|
||||||
}
|
|
||||||
|
|
||||||
folder = new File(this.getDataFolder() + File.separator + "dungeons");
|
|
||||||
if (!folder.exists()) {
|
|
||||||
folder.mkdir();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initSchedulers() {
|
|
||||||
p.getServer().getScheduler().scheduleSyncRepeatingTask(p, new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
for (GameWorld gworld : GameWorld.gworlds) {
|
|
||||||
if (gworld.world.getPlayers().isEmpty()) {
|
|
||||||
if (DPlayer.get(gworld.world).isEmpty()) {
|
|
||||||
gworld.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (EditWorld eworld : EditWorld.eworlds) {
|
|
||||||
if (eworld.world.getPlayers().isEmpty()) {
|
|
||||||
eworld.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 0L, 1200L);
|
|
||||||
|
|
||||||
p.getServer().getScheduler().scheduleSyncRepeatingTask(p, new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
GameWorld.update();
|
|
||||||
DPlayer.update(true);
|
|
||||||
}
|
|
||||||
}, 0L, 20L);
|
|
||||||
|
|
||||||
p.getServer().getScheduler().scheduleSyncRepeatingTask(p, new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
DPlayer.update(false);
|
|
||||||
}
|
|
||||||
}, 0L, 2L);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Permissions
|
|
||||||
public Permission permission = null;
|
|
||||||
|
|
||||||
private Boolean setupPermissions() {
|
|
||||||
RegisteredServiceProvider<Permission> permissionProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
|
|
||||||
if (permissionProvider != null) {
|
|
||||||
permission = permissionProvider.getProvider();
|
|
||||||
}
|
|
||||||
return (permission != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean GroupEnabled(String group) {
|
|
||||||
|
|
||||||
for (String agroup : permission.getGroups()) {
|
|
||||||
if (agroup.equalsIgnoreCase(group)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Economy
|
|
||||||
public Economy economy = null;
|
|
||||||
|
|
||||||
private Boolean setupEconomy() {
|
|
||||||
if (mainConfig.enableEconomy) {
|
|
||||||
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
|
||||||
if (economyProvider != null) {
|
|
||||||
economy = economyProvider.getProvider();
|
|
||||||
}
|
|
||||||
return (economy != null);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save and Load
|
|
||||||
public void saveData() {
|
|
||||||
File file = new File(this.getDataFolder(), "data.yml");
|
|
||||||
FileConfiguration configFile = new YamlConfiguration();
|
|
||||||
|
|
||||||
DPortal.save(configFile);
|
|
||||||
DGSign.save(configFile);
|
|
||||||
LeaveSign.save(configFile);
|
|
||||||
|
|
||||||
try {
|
|
||||||
configFile.save(file);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadAll() {
|
|
||||||
// Load world data
|
|
||||||
File file = new File(this.getDataFolder(), "data.yml");
|
|
||||||
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
|
|
||||||
|
|
||||||
DPortal.load(configFile);
|
|
||||||
DGSign.load(configFile);
|
|
||||||
LeaveSign.load(configFile);
|
|
||||||
|
|
||||||
// Load saved players
|
|
||||||
DSavePlayer.load();
|
|
||||||
|
|
||||||
// Check Worlds
|
|
||||||
this.checkWorlds();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkWorlds() {
|
|
||||||
File serverDir = new File(".");
|
|
||||||
|
|
||||||
for (File file : serverDir.listFiles()) {
|
|
||||||
if (file.getName().contains("DXL_Edit_") && file.isDirectory()) {
|
|
||||||
for (File dungeonFile : file.listFiles()) {
|
|
||||||
if (dungeonFile.getName().contains(".id_")) {
|
|
||||||
String dungeonName = dungeonFile.getName().substring(4);
|
|
||||||
this.copyDirectory(file, new File(p.getDataFolder(), "/dungeons/" + dungeonName));
|
|
||||||
this.deletenotusingfiles(new File(p.getDataFolder(), "/dungeons/" + dungeonName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.removeDirectory(file);
|
|
||||||
} else if (file.getName().contains("DXL_Game_") && file.isDirectory()) {
|
|
||||||
this.removeDirectory(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// File Control
|
|
||||||
public boolean removeDirectory(File directory) {
|
|
||||||
if (directory.isDirectory()) {
|
|
||||||
for (File f : directory.listFiles()) {
|
|
||||||
if (!removeDirectory(f))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return directory.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void copyFile(File in, File out) throws IOException {
|
|
||||||
FileChannel inChannel = null;
|
|
||||||
FileChannel outChannel = null;
|
|
||||||
try {
|
|
||||||
inChannel = new FileInputStream(in).getChannel();
|
|
||||||
outChannel = new FileOutputStream(out).getChannel();
|
|
||||||
inChannel.transferTo(0, inChannel.size(), outChannel);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
if (inChannel != null)
|
|
||||||
inChannel.close();
|
|
||||||
if (outChannel != null)
|
|
||||||
outChannel.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] excludedFiles = { "config.yml", "uid.dat", "DXLData.data" };
|
|
||||||
|
|
||||||
public void copyDirectory(File sourceLocation, File targetLocation) {
|
|
||||||
if (sourceLocation.isDirectory()) {
|
|
||||||
if (!targetLocation.exists()) {
|
|
||||||
targetLocation.mkdir();
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] children = sourceLocation.list();
|
|
||||||
for (int i = 0; i < children.length; i++) {
|
|
||||||
boolean isOk = true;
|
|
||||||
for (String excluded : excludedFiles) {
|
|
||||||
if (children[i].contains(excluded)) {
|
|
||||||
isOk = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isOk) {
|
|
||||||
copyDirectory(new File(sourceLocation, children[i]), new File(targetLocation, children[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
if (!targetLocation.getParentFile().exists()) {
|
|
||||||
|
|
||||||
createDirectory(targetLocation.getParentFile().getAbsolutePath());
|
|
||||||
targetLocation.createNewFile();
|
|
||||||
|
|
||||||
} else if (!targetLocation.exists()) {
|
|
||||||
|
|
||||||
targetLocation.createNewFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
InputStream in = new FileInputStream(sourceLocation);
|
|
||||||
OutputStream out = new FileOutputStream(targetLocation);
|
|
||||||
|
|
||||||
byte[] buf = new byte[1024];
|
|
||||||
int len;
|
|
||||||
while ((len = in.read(buf)) > 0) {
|
|
||||||
out.write(buf, 0, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
in.close();
|
|
||||||
out.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (e.getMessage().contains("Zugriff") || e.getMessage().contains("Access"))
|
|
||||||
P.p.log("Error: " + e.getMessage() + " // Access denied");
|
|
||||||
else
|
|
||||||
P.p.log("Error: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void createDirectory(String s) {
|
|
||||||
|
|
||||||
if (!new File(s).getParentFile().exists()) {
|
|
||||||
|
|
||||||
createDirectory(new File(s).getParent());
|
|
||||||
}
|
|
||||||
|
|
||||||
new File(s).mkdir();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deletenotusingfiles(File directory) {
|
|
||||||
File[] files = directory.listFiles();
|
|
||||||
for (File file : files) {
|
|
||||||
if (file.getName().equalsIgnoreCase("uid.dat") || file.getName().contains(".id_")) {
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Msg
|
|
||||||
public void msg(CommandSender sender, String msg) {
|
|
||||||
msg = replaceColors(msg);
|
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "[DXL] " + ChatColor.WHITE + msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void msg(CommandSender sender, String msg, boolean zusatz) {
|
|
||||||
msg = replaceColors(msg);
|
|
||||||
if (zusatz) {
|
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "[DXL]" + ChatColor.WHITE + msg);
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(ChatColor.WHITE + msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String replaceColors(String msg) {
|
|
||||||
if (msg != null) {
|
|
||||||
msg = msg.replace("&0", ChatColor.getByChar("0").toString());
|
|
||||||
msg = msg.replace("&1", ChatColor.getByChar("1").toString());
|
|
||||||
msg = msg.replace("&2", ChatColor.getByChar("2").toString());
|
|
||||||
msg = msg.replace("&3", ChatColor.getByChar("3").toString());
|
|
||||||
msg = msg.replace("&4", ChatColor.getByChar("4").toString());
|
|
||||||
msg = msg.replace("&5", ChatColor.getByChar("5").toString());
|
|
||||||
msg = msg.replace("&6", ChatColor.getByChar("6").toString());
|
|
||||||
msg = msg.replace("&7", ChatColor.getByChar("7").toString());
|
|
||||||
msg = msg.replace("&8", ChatColor.getByChar("8").toString());
|
|
||||||
msg = msg.replace("&9", ChatColor.getByChar("9").toString());
|
|
||||||
msg = msg.replace("&a", ChatColor.getByChar("a").toString());
|
|
||||||
msg = msg.replace("&b", ChatColor.getByChar("b").toString());
|
|
||||||
msg = msg.replace("&c", ChatColor.getByChar("c").toString());
|
|
||||||
msg = msg.replace("&d", ChatColor.getByChar("d").toString());
|
|
||||||
msg = msg.replace("&e", ChatColor.getByChar("e").toString());
|
|
||||||
msg = msg.replace("&f", ChatColor.getByChar("f").toString());
|
|
||||||
msg = msg.replace("&k", ChatColor.getByChar("k").toString());
|
|
||||||
msg = msg.replace("&l", ChatColor.getByChar("l").toString());
|
|
||||||
msg = msg.replace("&m", ChatColor.getByChar("m").toString());
|
|
||||||
msg = msg.replace("&n", ChatColor.getByChar("n").toString());
|
|
||||||
msg = msg.replace("&o", ChatColor.getByChar("o").toString());
|
|
||||||
msg = msg.replace("&r", ChatColor.getByChar("r").toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Misc.
|
|
||||||
public EntityType getEntitiyType(String name) {
|
|
||||||
for (EntityType type : EntityType.values()) {
|
|
||||||
if (name.equalsIgnoreCase(type.name())) {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int parseInt(String string) {
|
|
||||||
return NumberUtils.toInt(string, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Player getOfflinePlayer(String player, UUID uuid) {
|
|
||||||
return MultiVersionHandler.getOfflinePlayer(player, uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Player getOfflinePlayer(String player, UUID uuid, Location location) {
|
|
||||||
return MultiVersionHandler.getOfflinePlayer(player, uuid, location);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// LOGGING
|
|
||||||
// -------------------------------------------- //
|
|
||||||
public void log(String msg) {
|
|
||||||
this.msg(Bukkit.getConsoleSender(), msg);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.DPlayer;
|
|
||||||
|
|
||||||
public class CMDChat extends DCommand {
|
|
||||||
|
|
||||||
public CMDChat() {
|
|
||||||
this.command = "chat";
|
|
||||||
this.args = 0;
|
|
||||||
this.help = p.language.get("Help_Cmd_Chat");
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
|
||||||
|
|
||||||
if (dplayer != null) {
|
|
||||||
if (dplayer.isInDungeonChat) {
|
|
||||||
dplayer.isInDungeonChat = false;
|
|
||||||
p.msg(player, p.language.get("Cmd_Chat_NormalChat"));
|
|
||||||
} else {
|
|
||||||
dplayer.isInDungeonChat = true;
|
|
||||||
p.msg(player, p.language.get("Cmd_Chat_DungeonChat"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_NotInDungeon"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class CMDChatSpy extends DCommand {
|
|
||||||
public CMDChatSpy() {
|
|
||||||
this.command = "chatspy";
|
|
||||||
this.args = 0;
|
|
||||||
this.help = p.language.get("Help_Cmd_Chatspy");
|
|
||||||
this.permissions = "dxl.chatspy";
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
if (p.chatSpyer.contains(player)) {
|
|
||||||
p.chatSpyer.remove(player);
|
|
||||||
p.msg(player, p.language.get("Cmd_Chatspy_Stopped"));
|
|
||||||
} else {
|
|
||||||
p.chatSpyer.add(player);
|
|
||||||
p.msg(player, p.language.get("Cmd_Chatspy_Start"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.DPlayer;
|
|
||||||
import com.dre.dungeonsxl.EditWorld;
|
|
||||||
|
|
||||||
public class CMDCreate extends DCommand {
|
|
||||||
|
|
||||||
public CMDCreate() {
|
|
||||||
this.args = 1;
|
|
||||||
this.command = "create";
|
|
||||||
this.help = p.language.get("Help_Cmd_Create");
|
|
||||||
this.permissions = "dxl.create";
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
this.isConsoleCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
String name = args[1];
|
|
||||||
|
|
||||||
if (sender instanceof ConsoleCommandSender) {
|
|
||||||
if (name.length() <= 15) {
|
|
||||||
// Msg create
|
|
||||||
p.log(p.language.get("Log_NewDungeon"));
|
|
||||||
p.log(p.language.get("Log_GenerateNewWorld"));
|
|
||||||
|
|
||||||
// Create World
|
|
||||||
EditWorld eworld = new EditWorld();
|
|
||||||
eworld.generate();
|
|
||||||
eworld.dungeonname = name;
|
|
||||||
eworld.save();
|
|
||||||
eworld.delete();
|
|
||||||
|
|
||||||
// MSG Done
|
|
||||||
p.log(p.language.get("Log_WorldGenerationFinished"));
|
|
||||||
} else {
|
|
||||||
p.msg(sender, p.language.get("Error_NameToLong"));
|
|
||||||
}
|
|
||||||
} else if (sender instanceof Player) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
if (DPlayer.get(player) == null) {
|
|
||||||
if (name.length() <= 15) {
|
|
||||||
// Msg create
|
|
||||||
p.log(p.language.get("Log_NewDungeon"));
|
|
||||||
p.log(p.language.get("Log_GenerateNewWorld"));
|
|
||||||
|
|
||||||
// Create World
|
|
||||||
EditWorld eworld = new EditWorld();
|
|
||||||
eworld.generate();
|
|
||||||
eworld.dungeonname = name;
|
|
||||||
|
|
||||||
// MSG Done
|
|
||||||
p.log(p.language.get("Log_WorldGenerationFinished"));
|
|
||||||
|
|
||||||
// Tp Player
|
|
||||||
if (eworld.lobby == null) {
|
|
||||||
new DPlayer(player, eworld.world, eworld.world.getSpawnLocation(), true);
|
|
||||||
} else {
|
|
||||||
new DPlayer(player, eworld.world, eworld.lobby, true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_NameToLong"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_LeaveDungeon"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.DPortal;
|
|
||||||
|
|
||||||
public class CMDDeletePortal extends DCommand {
|
|
||||||
|
|
||||||
public CMDDeletePortal() {
|
|
||||||
this.command = "deleteportal";
|
|
||||||
this.args = 0;
|
|
||||||
this.help = p.language.get("Help_Cmd_DeletePortal");
|
|
||||||
this.permissions = "dxl.deleteportal";
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
DPortal dPortal = DPortal.get(player.getTargetBlock((Set<Material>) null, 20).getLocation());
|
|
||||||
|
|
||||||
if (dPortal != null) {
|
|
||||||
dPortal.delete();
|
|
||||||
p.msg(player, p.language.get("Player_PortalDeleted"));
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_NoPortal"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.DGroup;
|
|
||||||
import com.dre.dungeonsxl.DPlayer;
|
|
||||||
import com.dre.dungeonsxl.EditWorld;
|
|
||||||
|
|
||||||
public class CMDEdit extends DCommand {
|
|
||||||
|
|
||||||
public CMDEdit() {
|
|
||||||
this.command = "edit";
|
|
||||||
this.args = 1;
|
|
||||||
this.help = p.language.get("Help_Cmd_Edit");
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
String dungeonName = args[1];
|
|
||||||
EditWorld eworld = EditWorld.load(dungeonName);
|
|
||||||
DGroup dgroup = DGroup.get(player);
|
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
|
||||||
|
|
||||||
if (EditWorld.isInvitedPlayer(dungeonName, player.getUniqueId(), player.getName()) || p.permission.has(player, "dxl.edit") || player.isOp()) {
|
|
||||||
if (dplayer == null) {
|
|
||||||
if (dgroup == null) {
|
|
||||||
if (eworld != null) {
|
|
||||||
if (eworld.lobby == null) {
|
|
||||||
new DPlayer(player, eworld.world, eworld.world.getSpawnLocation(), true);
|
|
||||||
} else {
|
|
||||||
new DPlayer(player, eworld.world, eworld.lobby, true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_DungeonNotExist", dungeonName));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_LeaveGroup"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_LeaveDungeon"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_NoPermission"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.DGroup;
|
|
||||||
import com.dre.dungeonsxl.DPlayer;
|
|
||||||
import com.dre.dungeonsxl.EditWorld;
|
|
||||||
|
|
||||||
public class CMDEscape extends DCommand {
|
|
||||||
|
|
||||||
public CMDEscape() {
|
|
||||||
this.command = "escape";
|
|
||||||
this.args = 0;
|
|
||||||
this.help = p.language.get("Help_Cmd_Escape");
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
|
||||||
if (dplayer != null) {
|
|
||||||
|
|
||||||
if (dplayer.isEditing) {
|
|
||||||
dplayer.escape();
|
|
||||||
|
|
||||||
EditWorld eworld = EditWorld.get(dplayer.world);
|
|
||||||
if (eworld != null) {
|
|
||||||
if (eworld.world.getPlayers().isEmpty()) {
|
|
||||||
eworld.deleteNoSave();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_LeaveDungeon"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
DGroup dgroup = DGroup.get(player);
|
|
||||||
if (dgroup != null) {
|
|
||||||
dgroup.removePlayer(player);
|
|
||||||
p.msg(player, p.language.get("Cmd_Leave_Success"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
p.msg(player, p.language.get("Error_NotInDungeon"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class CMDHelp extends DCommand {
|
|
||||||
|
|
||||||
public CMDHelp() {
|
|
||||||
this.command = "help";
|
|
||||||
this.args = -1;
|
|
||||||
this.help = p.language.get("Help_Cmd_Help");
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
this.isConsoleCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
boolean isConsole = false, isPlayer = false;
|
|
||||||
|
|
||||||
if (sender instanceof ConsoleCommandSender) {
|
|
||||||
isConsole = true;
|
|
||||||
} else if (sender instanceof Player) {
|
|
||||||
isPlayer = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int page = 1;
|
|
||||||
int pages = (int) Math.ceil(DCommandRoot.root.commands.size() / 6.0);
|
|
||||||
|
|
||||||
if (args.length > 1) {
|
|
||||||
try {
|
|
||||||
page = p.parseInt(args[1]);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
page = 1;
|
|
||||||
}
|
|
||||||
if (page < 1)
|
|
||||||
page = 1;
|
|
||||||
if (page > pages)
|
|
||||||
page = pages;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.msg(sender, ChatColor.GREEN + "============[ " + ChatColor.GOLD + "Help DungeonsXL - " + page + "/" + pages + ChatColor.GREEN + " ]============", false);
|
|
||||||
|
|
||||||
int i = -1;
|
|
||||||
int ipage = 1;
|
|
||||||
for (DCommand command : DCommandRoot.root.commands) {
|
|
||||||
if ((command.isConsoleCommand && isConsole) || (command.isPlayerCommand && isPlayer)) {
|
|
||||||
i++;
|
|
||||||
if (i > 5) {
|
|
||||||
i = 0;
|
|
||||||
ipage++;
|
|
||||||
}
|
|
||||||
if (ipage == page) {
|
|
||||||
p.msg(sender, ChatColor.YELLOW + command.help, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p.msg(sender, ChatColor.GREEN + "==============[ " + ChatColor.GOLD + "By Frank Baumann" + ChatColor.GREEN + " ]==============", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.EditWorld;
|
|
||||||
import com.dre.dungeonsxl.util.OfflinePlayerUtil;
|
|
||||||
|
|
||||||
public class CMDInvite extends DCommand {
|
|
||||||
|
|
||||||
public CMDInvite() {
|
|
||||||
this.args = 2;
|
|
||||||
this.command = "invite";
|
|
||||||
this.help = p.language.get("Help_Cmd_Invite");
|
|
||||||
this.permissions = "dxl.invite";
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
this.isConsoleCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
if (EditWorld.addInvitedPlayer(args[2], OfflinePlayerUtil.getUniqueIdFromName(args[1]))) {
|
|
||||||
p.msg(sender, p.language.get("Cmd_Invite_Success", args[1], args[2]));
|
|
||||||
} else {
|
|
||||||
p.msg(sender, p.language.get("Error_DungeonNotExist", args[2]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.DGroup;
|
|
||||||
import com.dre.dungeonsxl.DPlayer;
|
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
|
||||||
|
|
||||||
public class CMDLeave extends DCommand {
|
|
||||||
|
|
||||||
public CMDLeave() {
|
|
||||||
this.command = "leave";
|
|
||||||
this.args = 0;
|
|
||||||
this.help = p.language.get("Help_Cmd_Leave");
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
|
||||||
|
|
||||||
if (GameWorld.get(player.getWorld()) != null) {
|
|
||||||
if (GameWorld.get(player.getWorld()).isTutorial) {
|
|
||||||
p.msg(player, p.language.get("Error_NoLeaveInTutorial"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dplayer != null) {
|
|
||||||
dplayer.leave();
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
DGroup dgroup = DGroup.get(player);
|
|
||||||
if (dgroup != null) {
|
|
||||||
dgroup.removePlayer(player);
|
|
||||||
p.msg(player, p.language.get("Cmd_Leave_Success"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
p.msg(player, p.language.get("Error_NotInDungeon"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
public class CMDList extends DCommand {
|
|
||||||
|
|
||||||
public CMDList() {
|
|
||||||
this.command = "list";
|
|
||||||
this.args = 0;
|
|
||||||
this.help = p.language.get("Help_Cmd_List");
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
this.isConsoleCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
|
|
||||||
File dungeonsfolder = new File(p.getDataFolder() + "/dungeons");
|
|
||||||
if (dungeonsfolder.exists()) {
|
|
||||||
p.msg(sender, ChatColor.DARK_GREEN + "-----[ " + ChatColor.GOLD + "Dungeons " + ChatColor.RED + dungeonsfolder.list().length + ChatColor.DARK_GREEN + "]-----");
|
|
||||||
|
|
||||||
for (String dungeon : dungeonsfolder.list()) {
|
|
||||||
p.msg(sender, dungeon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.P;
|
|
||||||
|
|
||||||
public class CMDLives extends DCommand {
|
|
||||||
|
|
||||||
public CMDLives() {
|
|
||||||
this.command = "lives";
|
|
||||||
this.args = 1;
|
|
||||||
this.help = p.language.get("Help_Cmd_Lives");
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
String lives = "";
|
|
||||||
if (P.p.lives.containsKey(player)) {
|
|
||||||
lives = String.valueOf(P.p.lives.get(player));
|
|
||||||
p.msg(player, p.language.get("Cmd_Lives").replaceAll("v1", player.getName()).replaceAll("v2", lives));
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_NotInDungeon"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.DConfig;
|
|
||||||
import com.dre.dungeonsxl.EditWorld;
|
|
||||||
|
|
||||||
public class CMDMsg extends DCommand {
|
|
||||||
|
|
||||||
public CMDMsg() {
|
|
||||||
this.args = -1;
|
|
||||||
this.command = "msg";
|
|
||||||
this.help = p.language.get("Help_Cmd_Msg");
|
|
||||||
this.permissions = "dxl.msg";
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
EditWorld eworld = EditWorld.get(player.getWorld());
|
|
||||||
|
|
||||||
if (eworld != null) {
|
|
||||||
if (args.length > 1) {
|
|
||||||
try {
|
|
||||||
int id = p.parseInt(args[1]);
|
|
||||||
|
|
||||||
DConfig confreader = new DConfig(new File(p.getDataFolder() + "/dungeons/" + eworld.dungeonname, "config.yml"));
|
|
||||||
|
|
||||||
if (args.length == 2) {
|
|
||||||
String msg = confreader.getMsg(id, true);
|
|
||||||
if (msg != null) {
|
|
||||||
p.msg(player, ChatColor.WHITE + msg);
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_MsgIdNotExist", "" + id));
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
String msg = "";
|
|
||||||
int i = 0;
|
|
||||||
for (String arg : args) {
|
|
||||||
i++;
|
|
||||||
if (i > 2) {
|
|
||||||
msg = msg + " " + arg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] splitMsg = msg.split("\"");
|
|
||||||
if (splitMsg.length > 1) {
|
|
||||||
msg = splitMsg[1];
|
|
||||||
String old = confreader.getMsg(id, false);
|
|
||||||
if (old == null) {
|
|
||||||
p.msg(player, p.language.get("Cmd_Msg_Added", "" + id));
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Cmd_Msg_Updated", "" + id));
|
|
||||||
}
|
|
||||||
|
|
||||||
confreader.setMsg(msg, id);
|
|
||||||
confreader.save();
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_MsgFormat"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
p.msg(player, p.language.get("Error_MsgNoInt"));
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this.displayHelp(player);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_NotInDungeon"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.DConfig;
|
|
||||||
import com.dre.dungeonsxl.DGroup;
|
|
||||||
import com.dre.dungeonsxl.DPlayer;
|
|
||||||
import com.dre.dungeonsxl.EditWorld;
|
|
||||||
import com.dre.dungeonsxl.P;
|
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
|
||||||
|
|
||||||
public class CMDPlay extends DCommand {
|
|
||||||
|
|
||||||
public CMDPlay() {
|
|
||||||
this.command = "play";
|
|
||||||
this.args = -1;
|
|
||||||
this.help = p.language.get("Help_Cmd_Play");
|
|
||||||
this.permissions = "dxl.play";
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
|
||||||
String dungeonname;
|
|
||||||
|
|
||||||
if (dplayer == null) {
|
|
||||||
if (args.length > 1) {
|
|
||||||
dungeonname = args[1];
|
|
||||||
|
|
||||||
if (EditWorld.exist(dungeonname)) {
|
|
||||||
if (GameWorld.canPlayDungeon(dungeonname, player)) {
|
|
||||||
if (GameWorld.checkRequirements(dungeonname, player)) {
|
|
||||||
if (DGroup.get(player) == null) {
|
|
||||||
DGroup dgroup = new DGroup(player, dungeonname);
|
|
||||||
if (dgroup != null) {
|
|
||||||
if (dgroup.getGworld() == null) {
|
|
||||||
dgroup.setGworld(GameWorld.load(DGroup.get(player).getDungeonname()));
|
|
||||||
}
|
|
||||||
if (dgroup.getGworld().locLobby == null) {
|
|
||||||
new DPlayer(player, dgroup.getGworld().world, dgroup.getGworld().world.getSpawnLocation(), false);
|
|
||||||
} else {
|
|
||||||
new DPlayer(player, dgroup.getGworld().world, dgroup.getGworld().locLobby, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_LeaveGroup"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
P.p.msg(player, P.p.language.get("Error_Requirements"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
File file = new File(p.getDataFolder() + "/dungeons/" + dungeonname + "/config.yml");
|
|
||||||
if (file != null) {
|
|
||||||
DConfig confReader = new DConfig(file);
|
|
||||||
if (confReader != null) {
|
|
||||||
P.p.msg(player, P.p.language.get("Error_Cooldown", "" + confReader.getTimeToNextPlay()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_DungeonNotExist", dungeonname));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.displayHelp(player);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_LeaveDungeon"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.DPlayer;
|
|
||||||
import com.dre.dungeonsxl.DPortal;
|
|
||||||
|
|
||||||
public class CMDPortal extends DCommand {
|
|
||||||
|
|
||||||
public CMDPortal() {
|
|
||||||
this.command = "portal";
|
|
||||||
this.args = 0;
|
|
||||||
this.help = p.language.get("Help_Cmd_Portal");
|
|
||||||
this.permissions = "dxl.portal";
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
|
||||||
if (dplayer == null) {
|
|
||||||
DPortal dportal = DPortal.get(player);
|
|
||||||
if (dportal == null) {
|
|
||||||
dportal = new DPortal(false);
|
|
||||||
dportal.player = player;
|
|
||||||
dportal.world = player.getWorld();
|
|
||||||
player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD));
|
|
||||||
p.msg(player, p.language.get("Player_PortalIntroduction"));
|
|
||||||
} else {
|
|
||||||
DPortal.portals.remove(dportal);
|
|
||||||
p.msg(player, p.language.get("Player_PortalAbort"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_LeaveDungeon"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import com.dre.dungeonsxl.LanguageReader;
|
|
||||||
import com.dre.dungeonsxl.MainConfig;
|
|
||||||
|
|
||||||
public class CMDReload extends DCommand {
|
|
||||||
|
|
||||||
public CMDReload() {
|
|
||||||
this.command = "reload";
|
|
||||||
this.args = 0;
|
|
||||||
this.help = p.language.get("Help_Cmd_Reload");
|
|
||||||
this.permissions = "dxl.reload";
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
this.isConsoleCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
p.msg(sender, p.language.get("Cmd_Reload_Start"));
|
|
||||||
|
|
||||||
// Save
|
|
||||||
p.saveData();
|
|
||||||
p.language.save();
|
|
||||||
|
|
||||||
// Load Config
|
|
||||||
p.mainConfig = new MainConfig(new File(p.getDataFolder(), "config.yml"));
|
|
||||||
|
|
||||||
// Load Language
|
|
||||||
p.language = new LanguageReader(new File(p.getDataFolder(), "languages/" + p.mainConfig.language + ".yml"));
|
|
||||||
|
|
||||||
p.msg(sender, p.language.get("Cmd_Reload_Done"));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.EditWorld;
|
|
||||||
|
|
||||||
public class CMDSave extends DCommand {
|
|
||||||
|
|
||||||
public CMDSave() {
|
|
||||||
this.command = "save";
|
|
||||||
this.args = 0;
|
|
||||||
this.help = p.language.get("Help_Cmd_Save");
|
|
||||||
this.permissions = "dxl.save";
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
EditWorld eworld = EditWorld.get(player.getWorld());
|
|
||||||
if (eworld != null) {
|
|
||||||
eworld.save();
|
|
||||||
p.msg(player, p.language.get("Cmd_Save_Success"));
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_NotInDungeon"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.DGroup;
|
|
||||||
import com.dre.dungeonsxl.DPlayer;
|
|
||||||
import com.dre.dungeonsxl.EditWorld;
|
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
|
||||||
|
|
||||||
public class CMDTest extends DCommand {
|
|
||||||
|
|
||||||
public CMDTest() {
|
|
||||||
this.command = "test";
|
|
||||||
this.args = -1;
|
|
||||||
this.help = p.language.get("Help_Cmd_Test");
|
|
||||||
this.permissions = "dxl.test";
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
|
||||||
String dungeonname;
|
|
||||||
|
|
||||||
if (dplayer == null) {
|
|
||||||
if (args.length > 1) {
|
|
||||||
dungeonname = args[1];
|
|
||||||
|
|
||||||
if (EditWorld.exist(dungeonname)) {
|
|
||||||
if (DGroup.get(player) == null) {
|
|
||||||
DGroup dgroup = new DGroup(player, dungeonname);
|
|
||||||
if (dgroup != null) {
|
|
||||||
if (dgroup.getGworld() == null) {
|
|
||||||
dgroup.setGworld(GameWorld.load(DGroup.get(player).getDungeonname()));
|
|
||||||
}
|
|
||||||
|
|
||||||
DPlayer newDPlayer;
|
|
||||||
|
|
||||||
if (dgroup.getGworld().locLobby == null) {
|
|
||||||
newDPlayer = new DPlayer(player, dgroup.getGworld().world, dgroup.getGworld().world.getSpawnLocation(), false);
|
|
||||||
} else {
|
|
||||||
newDPlayer = new DPlayer(player, dgroup.getGworld().world, dgroup.getGworld().locLobby, false);
|
|
||||||
}
|
|
||||||
newDPlayer.isinTestMode = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_LeaveGroup"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_DungeonNotExist", dungeonname));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.displayHelp(player);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.msg(player, p.language.get("Error_LeaveDungeon"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.EditWorld;
|
|
||||||
import com.dre.dungeonsxl.util.OfflinePlayerUtil;
|
|
||||||
|
|
||||||
public class CMDUninvite extends DCommand {
|
|
||||||
|
|
||||||
public CMDUninvite() {
|
|
||||||
this.args = 2;
|
|
||||||
this.command = "uninvite";
|
|
||||||
this.help = p.language.get("Help_Cmd_Uninvite");
|
|
||||||
this.permissions = "dxl.uninvite";
|
|
||||||
this.isPlayerCommand = true;
|
|
||||||
this.isConsoleCommand = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
|
||||||
if (EditWorld.removeInvitedPlayer(args[2], OfflinePlayerUtil.getUniqueIdFromName(args[1]), args[1])) {
|
|
||||||
p.msg(sender, p.language.get("Cmd_Uninvite_Success", args[1], args[2]));
|
|
||||||
} else {
|
|
||||||
p.msg(sender, p.language.get("Error_DungeonNotExist", args[2]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.P;
|
|
||||||
|
|
||||||
public abstract class DCommand {
|
|
||||||
public P p = P.p;
|
|
||||||
|
|
||||||
public boolean costsMoney;
|
|
||||||
public String command;
|
|
||||||
public int args;
|
|
||||||
public String help;
|
|
||||||
public String permissions;
|
|
||||||
public boolean isPlayerCommand = false;
|
|
||||||
public boolean isConsoleCommand = false;
|
|
||||||
|
|
||||||
// TODO : Add Aliases
|
|
||||||
|
|
||||||
public DCommand() {
|
|
||||||
costsMoney = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void displayHelp(CommandSender sender) {
|
|
||||||
p.msg(sender, ChatColor.RED + this.help);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean playerHasPermissions(Player player) {
|
|
||||||
if (this.permissions == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (p.permission.has(player, this.permissions) || player.isOp()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Abstracts
|
|
||||||
public abstract void onExecute(String[] args, CommandSender sender);
|
|
||||||
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.commands;
|
|
||||||
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
|
|
||||||
public class DCommandRoot {
|
|
||||||
// Variables
|
|
||||||
public static DCommandRoot root;
|
|
||||||
|
|
||||||
public CopyOnWriteArrayList<DCommand> commands = new CopyOnWriteArrayList<DCommand>();
|
|
||||||
|
|
||||||
// Commands
|
|
||||||
public CMDCreate cmdCreate = new CMDCreate();
|
|
||||||
public CMDSave cmdSave = new CMDSave();
|
|
||||||
public CMDLeave cmdLeave = new CMDLeave();
|
|
||||||
public CMDEscape cmdEscape = new CMDEscape();
|
|
||||||
public CMDEdit cmdEdit = new CMDEdit();
|
|
||||||
public CMDPortal cmdPortal = new CMDPortal();
|
|
||||||
public CMDDeletePortal cmdDeletePortal = new CMDDeletePortal();
|
|
||||||
public CMDChat cmdChat = new CMDChat();
|
|
||||||
public CMDChatSpy cmdChatSpy = new CMDChatSpy();
|
|
||||||
public CMDLives cmdLives = new CMDLives();
|
|
||||||
public CMDList cmdList = new CMDList();
|
|
||||||
public CMDUninvite cmdUninvite = new CMDUninvite();
|
|
||||||
public CMDInvite cmdInvite = new CMDInvite();
|
|
||||||
public CMDMsg cmdMsg = new CMDMsg();
|
|
||||||
public CMDPlay cmdPlay = new CMDPlay();
|
|
||||||
public CMDTest cmdTest = new CMDTest();
|
|
||||||
public CMDHelp cmdHelp = new CMDHelp();
|
|
||||||
public CMDReload cmdReload = new CMDReload();
|
|
||||||
|
|
||||||
// Methods
|
|
||||||
public DCommandRoot() {
|
|
||||||
root = this;
|
|
||||||
|
|
||||||
// Add Commands
|
|
||||||
this.commands.add(cmdCreate);
|
|
||||||
this.commands.add(cmdSave);
|
|
||||||
this.commands.add(cmdLeave);
|
|
||||||
this.commands.add(cmdEscape);
|
|
||||||
this.commands.add(cmdEdit);
|
|
||||||
this.commands.add(cmdPortal);
|
|
||||||
this.commands.add(cmdDeletePortal);
|
|
||||||
this.commands.add(cmdChat);
|
|
||||||
this.commands.add(cmdChatSpy);
|
|
||||||
this.commands.add(cmdLives);
|
|
||||||
this.commands.add(cmdList);
|
|
||||||
this.commands.add(cmdUninvite);
|
|
||||||
this.commands.add(cmdInvite);
|
|
||||||
this.commands.add(cmdMsg);
|
|
||||||
this.commands.add(cmdPlay);
|
|
||||||
this.commands.add(cmdTest);
|
|
||||||
this.commands.add(cmdHelp);
|
|
||||||
this.commands.add(cmdReload);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,185 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.game;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.P;
|
|
||||||
|
|
||||||
public class GamePlaceableBlock {
|
|
||||||
|
|
||||||
// Variables
|
|
||||||
private Block block;
|
|
||||||
private Set<Material> mats = new HashSet<Material>();
|
|
||||||
|
|
||||||
private boolean onTop = false;
|
|
||||||
private boolean onBottom = false;
|
|
||||||
private boolean onNorth = false;
|
|
||||||
private boolean onSouth = false;
|
|
||||||
private boolean onEast = false;
|
|
||||||
private boolean onWest = false;
|
|
||||||
|
|
||||||
public GamePlaceableBlock(Block block, String ids, String directions) {
|
|
||||||
this.block = block;
|
|
||||||
|
|
||||||
// Split ids
|
|
||||||
if (!ids.equals("")) {
|
|
||||||
String[] splittedIds = ids.split(",");
|
|
||||||
for (String id : splittedIds) {
|
|
||||||
Material mat = Material.getMaterial(P.p.parseInt(id));
|
|
||||||
if (mat != null) {
|
|
||||||
mats.add(mat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read directions
|
|
||||||
if (directions.length() == 6) {
|
|
||||||
for (int direction = 0; direction < 6; direction++) {
|
|
||||||
boolean positive = String.valueOf(directions.charAt(direction)).equals("x");
|
|
||||||
|
|
||||||
if (positive) {
|
|
||||||
if (direction == 0)
|
|
||||||
onTop = true;
|
|
||||||
if (direction == 1)
|
|
||||||
onBottom = true;
|
|
||||||
|
|
||||||
if (block.getType() == Material.WALL_SIGN) {
|
|
||||||
int data = block.getData();
|
|
||||||
switch (data) {
|
|
||||||
case 3:
|
|
||||||
if (direction == 2)
|
|
||||||
onNorth = true;
|
|
||||||
if (direction == 3)
|
|
||||||
onEast = true;
|
|
||||||
if (direction == 4)
|
|
||||||
onSouth = true;
|
|
||||||
if (direction == 5)
|
|
||||||
onWest = true;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
if (direction == 5)
|
|
||||||
onNorth = true;
|
|
||||||
if (direction == 2)
|
|
||||||
onEast = true;
|
|
||||||
if (direction == 3)
|
|
||||||
onSouth = true;
|
|
||||||
if (direction == 4)
|
|
||||||
onWest = true;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (direction == 4)
|
|
||||||
onNorth = true;
|
|
||||||
if (direction == 5)
|
|
||||||
onEast = true;
|
|
||||||
if (direction == 2)
|
|
||||||
onSouth = true;
|
|
||||||
if (direction == 3)
|
|
||||||
onWest = true;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
if (direction == 3)
|
|
||||||
onNorth = true;
|
|
||||||
if (direction == 4)
|
|
||||||
onEast = true;
|
|
||||||
if (direction == 5)
|
|
||||||
onSouth = true;
|
|
||||||
if (direction == 2)
|
|
||||||
onWest = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
int data = block.getData();
|
|
||||||
switch (data) {
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
case 15:
|
|
||||||
if (direction == 2)
|
|
||||||
onNorth = true;
|
|
||||||
if (direction == 3)
|
|
||||||
onEast = true;
|
|
||||||
if (direction == 4)
|
|
||||||
onSouth = true;
|
|
||||||
if (direction == 5)
|
|
||||||
onWest = true;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
case 3:
|
|
||||||
case 5:
|
|
||||||
case 6:
|
|
||||||
if (direction == 5)
|
|
||||||
onNorth = true;
|
|
||||||
if (direction == 2)
|
|
||||||
onEast = true;
|
|
||||||
if (direction == 3)
|
|
||||||
onSouth = true;
|
|
||||||
if (direction == 4)
|
|
||||||
onWest = true;
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
case 7:
|
|
||||||
case 9:
|
|
||||||
case 10:
|
|
||||||
if (direction == 4)
|
|
||||||
onNorth = true;
|
|
||||||
if (direction == 5)
|
|
||||||
onEast = true;
|
|
||||||
if (direction == 2)
|
|
||||||
onSouth = true;
|
|
||||||
if (direction == 3)
|
|
||||||
onWest = true;
|
|
||||||
break;
|
|
||||||
case 12:
|
|
||||||
case 11:
|
|
||||||
case 13:
|
|
||||||
case 14:
|
|
||||||
if (direction == 3)
|
|
||||||
onNorth = true;
|
|
||||||
if (direction == 4)
|
|
||||||
onEast = true;
|
|
||||||
if (direction == 5)
|
|
||||||
onSouth = true;
|
|
||||||
if (direction == 2)
|
|
||||||
onWest = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
onTop = true;
|
|
||||||
onBottom = true;
|
|
||||||
onNorth = true;
|
|
||||||
onEast = true;
|
|
||||||
onSouth = true;
|
|
||||||
onWest = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Canbuild
|
|
||||||
public static boolean canBuildHere(Block block, BlockFace blockFace, Material mat, GameWorld gworld) {
|
|
||||||
for (GamePlaceableBlock gPBlock : gworld.placeableBlocks) {
|
|
||||||
if (gPBlock.block.getFace(block) == BlockFace.SELF) {
|
|
||||||
if (gPBlock.mats.contains(mat) || gPBlock.mats.isEmpty()) {
|
|
||||||
if (blockFace == BlockFace.NORTH && gPBlock.onNorth)
|
|
||||||
return true;
|
|
||||||
if (blockFace == BlockFace.SOUTH && gPBlock.onSouth)
|
|
||||||
return true;
|
|
||||||
if (blockFace == BlockFace.EAST && gPBlock.onEast)
|
|
||||||
return true;
|
|
||||||
if (blockFace == BlockFace.WEST && gPBlock.onWest)
|
|
||||||
return true;
|
|
||||||
if (blockFace == BlockFace.UP && gPBlock.onTop)
|
|
||||||
return true;
|
|
||||||
if (blockFace == BlockFace.DOWN && gPBlock.onBottom)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,333 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.game;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
|
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.WorldCreator;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.Spider;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.DConfig;
|
|
||||||
import com.dre.dungeonsxl.DPlayer;
|
|
||||||
import com.dre.dungeonsxl.P;
|
|
||||||
import com.dre.dungeonsxl.signs.DSign;
|
|
||||||
import com.dre.dungeonsxl.EditWorld;
|
|
||||||
import com.dre.dungeonsxl.trigger.RedstoneTrigger;
|
|
||||||
|
|
||||||
public class GameWorld {
|
|
||||||
private static P p = P.p;
|
|
||||||
public static CopyOnWriteArrayList<GameWorld> gworlds = new CopyOnWriteArrayList<GameWorld>();
|
|
||||||
|
|
||||||
// Variables placeable
|
|
||||||
public boolean isTutorial;
|
|
||||||
|
|
||||||
public CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks = new CopyOnWriteArrayList<GamePlaceableBlock>();
|
|
||||||
public World world;
|
|
||||||
public String dungeonname;
|
|
||||||
public Location locLobby;
|
|
||||||
public Location locStart;
|
|
||||||
public boolean isPlaying = false;
|
|
||||||
public int id;
|
|
||||||
public CopyOnWriteArrayList<Material> secureObjects = new CopyOnWriteArrayList<Material>();
|
|
||||||
public CopyOnWriteArrayList<Chunk> loadedChunks = new CopyOnWriteArrayList<Chunk>();
|
|
||||||
|
|
||||||
public CopyOnWriteArrayList<Sign> signClass = new CopyOnWriteArrayList<Sign>();
|
|
||||||
public CopyOnWriteArrayList<DMob> dmobs = new CopyOnWriteArrayList<DMob>();
|
|
||||||
public CopyOnWriteArrayList<GameChest> gchests = new CopyOnWriteArrayList<GameChest>();
|
|
||||||
public CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<DSign>();
|
|
||||||
public DConfig config;
|
|
||||||
|
|
||||||
public GameWorld() {
|
|
||||||
gworlds.add(this);
|
|
||||||
|
|
||||||
// ID
|
|
||||||
this.id = -1;
|
|
||||||
int i = -1;
|
|
||||||
while (this.id == -1) {
|
|
||||||
i++;
|
|
||||||
boolean exist = false;
|
|
||||||
for (GameWorld gworld : gworlds) {
|
|
||||||
if (gworld.id == i) {
|
|
||||||
exist = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!exist)
|
|
||||||
this.id = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkSign(Block block) {
|
|
||||||
if ((block.getState() instanceof Sign)) {
|
|
||||||
Sign sign = (Sign) block.getState();
|
|
||||||
dSigns.add(DSign.create(sign, this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startGame() {
|
|
||||||
this.isPlaying = true;
|
|
||||||
|
|
||||||
for (DSign dSign : this.dSigns) {
|
|
||||||
if (dSign != null) {
|
|
||||||
if (!dSign.isOnDungeonInit()) {
|
|
||||||
dSign.onInit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (RedstoneTrigger.hasTriggers(this)) {
|
|
||||||
for (RedstoneTrigger trigger : RedstoneTrigger.getTriggersArray(this)) {
|
|
||||||
trigger.onTrigger();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (DSign dSign : this.dSigns) {
|
|
||||||
if (dSign != null) {
|
|
||||||
if (!dSign.hasTriggers()) {
|
|
||||||
dSign.onTrigger();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void msg(String msg) {
|
|
||||||
for (DPlayer dplayer : DPlayer.get(this.world)) {
|
|
||||||
p.msg(dplayer.player, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Static
|
|
||||||
public static GameWorld get(World world) {
|
|
||||||
for (GameWorld gworld : gworlds) {
|
|
||||||
if (gworld.world.equals(world)) {
|
|
||||||
return gworld;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void deleteAll() {
|
|
||||||
for (GameWorld gworld : gworlds) {
|
|
||||||
gworld.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canPlayDungeon(String dungeon, Player player) {
|
|
||||||
|
|
||||||
if (p.permission.has(player, "dungeonsxl.ignoretimelimit") || player.isOp()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (new File(p.getDataFolder() + "/dungeons/" + dungeon).isDirectory()) {
|
|
||||||
DConfig config = new DConfig(new File(p.getDataFolder() + "/dungeons/" + dungeon, "config.yml"));
|
|
||||||
|
|
||||||
if (config.getTimeToNextPlay() != 0) {
|
|
||||||
// read PlayerConfig
|
|
||||||
Long time = getPlayerTime(dungeon, player);
|
|
||||||
if (time != -1) {
|
|
||||||
if (time + (config.getTimeToNextPlay() * 1000 * 60 * 60) > System.currentTimeMillis()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean checkRequirements(String dungeon, Player player) {
|
|
||||||
/*if (p.permission.has(player, "dungeonsxl.ignoreRequirements") || player.isOp()) {
|
|
||||||
return true;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (new File(p.getDataFolder() + "/dungeons/" + dungeon).isDirectory() == false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DConfig config = new DConfig(new File(p.getDataFolder() + "/dungeons/" + dungeon, "config.yml"));
|
|
||||||
|
|
||||||
if (p.mainConfig.enableEconomy) {
|
|
||||||
if (!(P.p.economy.getBalance(player) >= config.getFee())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.getFinished() != null && config.getFinishedAll() != null) {
|
|
||||||
if (!config.getFinished().isEmpty()) {
|
|
||||||
|
|
||||||
long bestTime = 0;
|
|
||||||
int numOfNeeded = 0;
|
|
||||||
boolean doneTheOne = false;
|
|
||||||
|
|
||||||
if (config.getFinished().size() == config.getFinishedAll().size()) {
|
|
||||||
doneTheOne = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String played : config.getFinished()) {
|
|
||||||
for (String dungeonName : new File(p.getDataFolder() + "/dungeons").list()) {
|
|
||||||
if (new File(p.getDataFolder() + "/dungeons/" + dungeonName).isDirectory()) {
|
|
||||||
if (played.equalsIgnoreCase(dungeonName) || played.equalsIgnoreCase("any")) {
|
|
||||||
|
|
||||||
Long time = getPlayerTime(dungeonName, player);
|
|
||||||
if (time != -1) {
|
|
||||||
if (config.getFinishedAll().contains(played)) {
|
|
||||||
numOfNeeded++;
|
|
||||||
} else {
|
|
||||||
doneTheOne = true;
|
|
||||||
}
|
|
||||||
if (bestTime < time) {
|
|
||||||
bestTime = time;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bestTime == 0) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (config.getTimeLastPlayed() != 0) {
|
|
||||||
if (System.currentTimeMillis() - bestTime > config.getTimeLastPlayed() * (long) 3600000) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numOfNeeded < config.getFinishedAll().size() || !doneTheOne) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long getPlayerTime(String dungeon, Player player) {
|
|
||||||
File file = new File(p.getDataFolder() + "/dungeons/" + dungeon, "players.yml");
|
|
||||||
|
|
||||||
if (!file.exists()) {
|
|
||||||
try {
|
|
||||||
file.createNewFile();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file);
|
|
||||||
if (playerConfig.contains(player.getUniqueId().toString())) {
|
|
||||||
return playerConfig.getLong(player.getUniqueId().toString());
|
|
||||||
}
|
|
||||||
if (playerConfig.contains(player.getName())) {
|
|
||||||
return playerConfig.getLong(player.getName());
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void delete() {
|
|
||||||
gworlds.remove(this);
|
|
||||||
p.getServer().unloadWorld(this.world, true);
|
|
||||||
File dir = new File("DXL_Game_" + this.id);
|
|
||||||
p.removeDirectory(dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GameWorld load(String name) {
|
|
||||||
|
|
||||||
File file = new File(p.getDataFolder(), "/dungeons/" + name);
|
|
||||||
|
|
||||||
if (file.exists()) {
|
|
||||||
GameWorld gworld = new GameWorld();
|
|
||||||
gworld.dungeonname = name;
|
|
||||||
|
|
||||||
// Unload empty eworlds
|
|
||||||
for (EditWorld eworld : EditWorld.eworlds) {
|
|
||||||
if (eworld.world.getPlayers().isEmpty()) {
|
|
||||||
eworld.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Config einlesen
|
|
||||||
gworld.config = new DConfig(new File(p.getDataFolder() + "/dungeons/" + gworld.dungeonname, "config.yml"));
|
|
||||||
|
|
||||||
// Secure Objects
|
|
||||||
gworld.secureObjects = gworld.config.getSecureObjects();
|
|
||||||
|
|
||||||
// World
|
|
||||||
p.copyDirectory(file, new File("DXL_Game_" + gworld.id));
|
|
||||||
|
|
||||||
// Id File
|
|
||||||
File idFile = new File("DXL_Game_" + gworld.id + "/.id_" + name);
|
|
||||||
try {
|
|
||||||
idFile.createNewFile();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
gworld.world = p.getServer().createWorld(WorldCreator.name("DXL_Game_" + gworld.id));
|
|
||||||
|
|
||||||
ObjectInputStream os;
|
|
||||||
try {
|
|
||||||
os = new ObjectInputStream(new FileInputStream(new File(p.getDataFolder() + "/dungeons/" + gworld.dungeonname + "/DXLData.data")));
|
|
||||||
|
|
||||||
int length = os.readInt();
|
|
||||||
for (int i = 0; i < length; i++) {
|
|
||||||
int x = os.readInt();
|
|
||||||
int y = os.readInt();
|
|
||||||
int z = os.readInt();
|
|
||||||
Block block = gworld.world.getBlockAt(x, y, z);
|
|
||||||
gworld.checkSign(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
os.close();
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return gworld;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void update() {
|
|
||||||
for (GameWorld gworld : gworlds) {
|
|
||||||
// Update Spiders
|
|
||||||
for (LivingEntity mob : gworld.world.getLivingEntities()) {
|
|
||||||
if (mob.getType() == EntityType.SPIDER || mob.getType() == EntityType.CAVE_SPIDER) {
|
|
||||||
Spider spider = (Spider) mob;
|
|
||||||
if (spider.getTarget() != null) {
|
|
||||||
if (spider.getTarget().getType() == EntityType.PLAYER) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (Entity player : spider.getNearbyEntities(10, 10, 10)) {
|
|
||||||
if (player.getType() == EntityType.PLAYER) {
|
|
||||||
spider.setTarget((LivingEntity) player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.listener;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.P;
|
|
||||||
import com.dre.dungeonsxl.commands.DCommand;
|
|
||||||
import com.dre.dungeonsxl.commands.DCommandRoot;
|
|
||||||
|
|
||||||
public class CommandListener implements CommandExecutor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd_notused, String arg, String[] args) {
|
|
||||||
if (args.length > 0) {
|
|
||||||
String cmd = args[0];
|
|
||||||
|
|
||||||
for (DCommand command : DCommandRoot.root.commands) {
|
|
||||||
if (cmd.equals(command.command)) {
|
|
||||||
if (sender instanceof ConsoleCommandSender) {
|
|
||||||
if (!command.isConsoleCommand) {
|
|
||||||
P.p.msg(sender, P.p.language.get("Log_Error_NoConsoleCommand", command.command));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
if (!command.isPlayerCommand) {
|
|
||||||
P.p.msg(player, P.p.language.get("Error_NoPlayerCommand", command.command));
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (!command.playerHasPermissions(player)) {
|
|
||||||
P.p.msg(player, P.p.language.get("Error_NoPermissions"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command.args == args.length - 1 || command.args == -1) {
|
|
||||||
command.onExecute(args, sender);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
command.displayHelp(sender);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
P.p.msg(sender, P.p.language.get("Error_CmdNotExist1", cmd));
|
|
||||||
P.p.msg(sender, P.p.language.get("Error_CmdNotExist2"));
|
|
||||||
} else {
|
|
||||||
DCommandRoot.root.cmdHelp.onExecute(args, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.listener.player;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.DConfig;
|
|
||||||
import com.dre.dungeonsxl.DPlayer;
|
|
||||||
import com.dre.dungeonsxl.P;
|
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
|
||||||
|
|
||||||
public class PlayerDeathListener implements Listener {
|
|
||||||
|
|
||||||
P p = P.p;
|
|
||||||
int lives = -1;
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void onDeath(PlayerDeathEvent event) {
|
|
||||||
Player player = event.getEntity();
|
|
||||||
DPlayer dPlayer = DPlayer.get(player);
|
|
||||||
|
|
||||||
GameWorld gameWorld = GameWorld.get(player.getLocation().getWorld());
|
|
||||||
if (gameWorld != null) {
|
|
||||||
DConfig dConfig = gameWorld.config;
|
|
||||||
|
|
||||||
if (dPlayer != null) {
|
|
||||||
if (dConfig != null) {
|
|
||||||
if (dConfig.getKeepInventoryOnDeath()) {
|
|
||||||
dPlayer.respawnInventory = event.getEntity().getInventory().getContents();
|
|
||||||
dPlayer.respawnArmor = event.getEntity().getInventory().getArmorContents();
|
|
||||||
// Delete all drops
|
|
||||||
for (ItemStack istack : event.getDrops()) {
|
|
||||||
istack.setType(Material.AIR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p.lives.containsKey(player)) {
|
|
||||||
lives = p.lives.get(player) - 1;
|
|
||||||
p.lives.put(player, lives);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lives == 0 && dPlayer.isReady) {
|
|
||||||
Bukkit.broadcastMessage(p.language.get("Player_DeathKick").replaceAll("v1", player.getName()).replaceAll("&", "\u00a7"));
|
|
||||||
player.performCommand("dxl leave");
|
|
||||||
} else if ( !(lives == -1)) {
|
|
||||||
p.msg(player, p.language.get("Player_Death").replaceAll("v1", String.valueOf(lives)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.multiversionhandler;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.P;
|
|
||||||
|
|
||||||
public class MultiVersionHandler {
|
|
||||||
|
|
||||||
private static String version = P.p.getServer().getVersion();
|
|
||||||
|
|
||||||
public static String supported = "v1_8_R1,v1_8_R2,v1_8_R3";
|
|
||||||
|
|
||||||
public static String getInternals() {
|
|
||||||
String internals = "v1_8_R3";
|
|
||||||
if (version.contains("1.8.4") || version.contains("1.8.5") || version.contains("1.8.6") || version.contains("1.8.7") || version.contains("1.8.8")) {
|
|
||||||
internals = "v1_8_R3";
|
|
||||||
} else if (version.contains("1.8.3")) {
|
|
||||||
internals = "v1_8_R2";
|
|
||||||
} else if (version.contains("1.8") && !version.contains("1.8.")) {
|
|
||||||
internals = "v1_8_R1";
|
|
||||||
} else if (version.contains("1.7.10")) {
|
|
||||||
internals = "v1_7_R4";
|
|
||||||
} else if (version.contains("1.7.8") || version.contains("1.7.9")) {
|
|
||||||
internals = "v1_7_R3";
|
|
||||||
}
|
|
||||||
return internals;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Player getOfflinePlayer(String player, UUID uuid) {
|
|
||||||
Player pplayer = null;
|
|
||||||
if (getInternals().equals("v1_8_R3")) {
|
|
||||||
pplayer = v1_8_R3.getOfflinePlayer(player, uuid);
|
|
||||||
} else if (getInternals().equals("v1_8_R2")) {
|
|
||||||
pplayer = v1_8_R2.getOfflinePlayer(player, uuid);
|
|
||||||
} else if (getInternals().equals("v1_8_R1")) {
|
|
||||||
pplayer = v1_8_R1.getOfflinePlayer(player, uuid);
|
|
||||||
} else if (getInternals().equals("v1_8_R2")) {
|
|
||||||
pplayer = v1_8_R1.getOfflinePlayer(player, uuid);
|
|
||||||
} else if (getInternals().equals("v1_7_R4")) {
|
|
||||||
pplayer = v1_7_R4.getOfflinePlayer(player, uuid);
|
|
||||||
} else if (getInternals().equals("v1_7_R3")) {
|
|
||||||
pplayer = v1_7_R3.getOfflinePlayer(player, uuid);
|
|
||||||
}
|
|
||||||
return pplayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Player getOfflinePlayer(String player, UUID uuid, Location location) {
|
|
||||||
Player pplayer = null;
|
|
||||||
if (getInternals().equals("v1_8_R3")) {
|
|
||||||
pplayer = v1_8_R3.getOfflinePlayer(player, uuid, location);
|
|
||||||
} else if (getInternals().equals("v1_8_R2")) {
|
|
||||||
pplayer = v1_8_R2.getOfflinePlayer(player, uuid, location);
|
|
||||||
} else if (getInternals().equals("v1_8_R1")) {
|
|
||||||
pplayer = v1_8_R1.getOfflinePlayer(player, uuid, location);
|
|
||||||
} else if (getInternals().equals("v1_8_R2")) {
|
|
||||||
pplayer = v1_8_R1.getOfflinePlayer(player, uuid, location);
|
|
||||||
} else if (getInternals().equals("v1_7_R4")) {
|
|
||||||
pplayer = v1_7_R4.getOfflinePlayer(player, uuid, location);
|
|
||||||
} else if (getInternals().equals("v1_7_R3")) {
|
|
||||||
pplayer = v1_7_R3.getOfflinePlayer(player, uuid, location);
|
|
||||||
}
|
|
||||||
return pplayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,161 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.signs;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.P;
|
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
|
||||||
import com.dre.dungeonsxl.trigger.Trigger;
|
|
||||||
|
|
||||||
public abstract class DSign {
|
|
||||||
protected static P p = P.p;
|
|
||||||
|
|
||||||
protected Sign sign;
|
|
||||||
protected GameWorld gworld;
|
|
||||||
|
|
||||||
// List of Triggers
|
|
||||||
protected Set<Trigger> triggers = new HashSet<Trigger>();
|
|
||||||
|
|
||||||
public abstract boolean check();
|
|
||||||
|
|
||||||
public abstract String getPermissions();
|
|
||||||
|
|
||||||
public abstract boolean isOnDungeonInit();
|
|
||||||
|
|
||||||
public DSign(Sign sign, GameWorld gworld) {
|
|
||||||
this.sign = sign;
|
|
||||||
this.gworld = gworld;
|
|
||||||
|
|
||||||
// Check Trigger
|
|
||||||
if (gworld != null) {
|
|
||||||
String line3 = sign.getLine(3).replaceAll("\\s", "");
|
|
||||||
String[] triggerTypes = line3.split(",");
|
|
||||||
|
|
||||||
for (String triggerString : triggerTypes) {
|
|
||||||
if (!triggerString.equals("")) {
|
|
||||||
|
|
||||||
String type = triggerString.substring(0, 1);
|
|
||||||
String value = null;
|
|
||||||
if (triggerString.length() > 1) {
|
|
||||||
value = triggerString.substring(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Trigger trigger = Trigger.getOrCreate(type, value, this);
|
|
||||||
if (trigger != null) {
|
|
||||||
trigger.addListener(this);
|
|
||||||
this.triggers.add(trigger);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onInit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onTrigger() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onPlayerTrigger(Player player) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onDisable() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onUpdate() {
|
|
||||||
for (Trigger trigger : triggers) {
|
|
||||||
if (!trigger.triggered) {
|
|
||||||
onDisable();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (triggers.size() == 1) {
|
|
||||||
if (trigger.player != null) {
|
|
||||||
if (onPlayerTrigger(trigger.player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onTrigger();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove() {
|
|
||||||
for (Trigger trigger : triggers) {
|
|
||||||
trigger.removeListener(this);
|
|
||||||
}
|
|
||||||
gworld.dSigns.remove(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasTriggers() {
|
|
||||||
return !triggers.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DSign create(Sign sign, GameWorld gworld) {
|
|
||||||
String[] lines = sign.getLines();
|
|
||||||
DSign dSign = null;
|
|
||||||
|
|
||||||
if (lines[0].equalsIgnoreCase("[" + SIGNCheckpoint.name + "]")) {
|
|
||||||
dSign = new SIGNCheckpoint(sign, gworld);
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SIGNChest.name + "]")) {
|
|
||||||
dSign = new SIGNChest(sign, gworld);
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SIGNChunkUpdater.name + "]")) {
|
|
||||||
dSign = new SIGNChunkUpdater(sign, gworld);
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SIGNClasses.name + "]")) {
|
|
||||||
dSign = new SIGNClasses(sign, gworld);
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SIGNEnd.name + "]")) {
|
|
||||||
dSign = new SIGNEnd(sign, gworld);
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SIGNLeave.name + "]")) {
|
|
||||||
dSign = new SIGNLeave(sign, gworld);
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SIGNLobby.name + "]")) {
|
|
||||||
dSign = new SIGNLobby(sign, gworld);
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SIGNMob.name + "]")) {
|
|
||||||
dSign = new SIGNMob(sign, gworld);
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SIGNMsg.name + "]")) {
|
|
||||||
dSign = new SIGNMsg(sign, gworld);
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SIGNPlace.name + "]")) {
|
|
||||||
dSign = new SIGNPlace(sign, gworld);
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SIGNReady.name + "]")) {
|
|
||||||
dSign = new SIGNReady(sign, gworld);
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SIGNSoundMsg.name + "]")) {
|
|
||||||
dSign = new SIGNSoundMsg(sign, gworld);
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SIGNStart.name + "]")) {
|
|
||||||
dSign = new SIGNStart(sign, gworld);
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SIGNTrigger.name + "]")) {
|
|
||||||
dSign = new SIGNTrigger(sign, gworld);
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SIGNInteract.name + "]")) {
|
|
||||||
dSign = new SIGNInteract(sign, gworld);
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SIGNRedstone.name + "]")) {
|
|
||||||
dSign = new SIGNRedstone(sign, gworld);
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SIGNBlock.name + "]")) {
|
|
||||||
dSign = new SIGNBlock(sign, gworld);
|
|
||||||
} else if (lines[0].equalsIgnoreCase("[" + SIGNMythicMobs.name + "]")) {
|
|
||||||
dSign = new SIGNMythicMobs(sign, gworld);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dSign != null && gworld != null) {
|
|
||||||
if (dSign.isOnDungeonInit()) {
|
|
||||||
dSign.onInit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return dSign;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getter and Setter
|
|
||||||
public GameWorld getGameWorld() {
|
|
||||||
return gworld;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Sign getSign() {
|
|
||||||
return sign;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.signs;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.game.GameChest;
|
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
|
||||||
|
|
||||||
public class SIGNChest extends DSign {
|
|
||||||
|
|
||||||
public static String name = "Chest";
|
|
||||||
public String buildPermissions = "dxl.sign.chest";
|
|
||||||
public boolean onDungeonInit = false;
|
|
||||||
|
|
||||||
// Variables
|
|
||||||
private double moneyReward;
|
|
||||||
|
|
||||||
public SIGNChest(Sign sign, GameWorld gworld) {
|
|
||||||
super(sign, gworld);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean check() {
|
|
||||||
String lines[] = sign.getLines();
|
|
||||||
if (lines[1].equals("")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInit() {
|
|
||||||
String lines[] = sign.getLines();
|
|
||||||
if (!lines[1].equals("")) {
|
|
||||||
moneyReward = Double.parseDouble(lines[1]);
|
|
||||||
}
|
|
||||||
for (int i = -1; i <= 1; i++) {
|
|
||||||
if (sign.getBlock().getRelative(i, 0, 0).getType() == Material.CHEST) {
|
|
||||||
new GameChest(sign.getBlock().getRelative(i, 0, 0), gworld, moneyReward);
|
|
||||||
}
|
|
||||||
if (sign.getBlock().getRelative(0, 0, i).getType() == Material.CHEST) {
|
|
||||||
new GameChest(sign.getBlock().getRelative(0, 0, i), gworld, moneyReward);
|
|
||||||
}
|
|
||||||
if (sign.getBlock().getRelative(0, i, 0).getType() == Material.CHEST) {
|
|
||||||
new GameChest(sign.getBlock().getRelative(0, i, 0), gworld, moneyReward);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sign.getBlock().setType(Material.AIR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPermissions() {
|
|
||||||
return buildPermissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.signs;
|
|
||||||
|
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
|
||||||
|
|
||||||
public class SIGNChunkUpdater extends DSign {
|
|
||||||
|
|
||||||
public static String name = "ChunkUpdater";
|
|
||||||
public String buildPermissions = "dxl.sign.chunkupdater";
|
|
||||||
public boolean onDungeonInit = true;
|
|
||||||
|
|
||||||
public SIGNChunkUpdater(Sign sign, GameWorld gworld) {
|
|
||||||
super(sign, gworld);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean check() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInit() {
|
|
||||||
String lines[] = sign.getLines();
|
|
||||||
Chunk chunk = gworld.world.getChunkAt(sign.getBlock());
|
|
||||||
if (!lines[1].equals("")) {
|
|
||||||
Integer radius = p.parseInt(lines[1]);
|
|
||||||
for (int x = -radius; x < radius; x++) {
|
|
||||||
for (int z = -radius; z < radius; z++) {
|
|
||||||
Chunk chunk1 = gworld.world.getChunkAt(chunk.getX() - x, chunk.getZ() - z);
|
|
||||||
chunk1.load();
|
|
||||||
gworld.loadedChunks.add(chunk1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
chunk.load();
|
|
||||||
gworld.loadedChunks.add(chunk);
|
|
||||||
}
|
|
||||||
sign.getBlock().setType(Material.AIR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPermissions() {
|
|
||||||
return buildPermissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.signs;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.DClass;
|
|
||||||
import com.dre.dungeonsxl.DGSign;
|
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
|
||||||
|
|
||||||
public class SIGNClasses extends DSign {
|
|
||||||
|
|
||||||
public static String name = "Classes";
|
|
||||||
public String buildPermissions = "dxl.sign.classes";
|
|
||||||
public boolean onDungeonInit = true;
|
|
||||||
|
|
||||||
public SIGNClasses(Sign sign, GameWorld gworld) {
|
|
||||||
super(sign, gworld);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean check() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInit() {
|
|
||||||
if (!gworld.config.isLobbyDisabled()) {
|
|
||||||
|
|
||||||
int[] direction = DGSign.getDirection(sign.getBlock().getData());
|
|
||||||
int directionX = direction[0];
|
|
||||||
int directionZ = direction[1];
|
|
||||||
|
|
||||||
int xx = 0, zz = 0;
|
|
||||||
for (DClass dclass : gworld.config.getClasses()) {
|
|
||||||
|
|
||||||
// Check existing signs
|
|
||||||
boolean isContinued = true;
|
|
||||||
for (Sign isusedsign : gworld.signClass) {
|
|
||||||
if (dclass.name.equalsIgnoreCase(ChatColor.stripColor(isusedsign.getLine(1)))) {
|
|
||||||
isContinued = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isContinued) {
|
|
||||||
Block classBlock = sign.getBlock().getRelative(xx, 0, zz);
|
|
||||||
|
|
||||||
if (classBlock.getData() == sign.getData().getData() && classBlock.getType() == Material.WALL_SIGN && (classBlock.getState() instanceof Sign)) {
|
|
||||||
Sign classSign = (Sign) classBlock.getState();
|
|
||||||
|
|
||||||
classSign.setLine(0, ChatColor.DARK_BLUE + "############");
|
|
||||||
classSign.setLine(1, ChatColor.DARK_GREEN + dclass.name);
|
|
||||||
classSign.setLine(2, "");
|
|
||||||
classSign.setLine(3, ChatColor.DARK_BLUE + "############");
|
|
||||||
classSign.update();
|
|
||||||
|
|
||||||
gworld.signClass.add(classSign);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
xx = xx + directionX;
|
|
||||||
zz = zz + directionZ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sign.getBlock().setType(Material.AIR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPermissions() {
|
|
||||||
return buildPermissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.signs;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.DPlayer;
|
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
|
||||||
import com.dre.dungeonsxl.trigger.InteractTrigger;
|
|
||||||
|
|
||||||
public class SIGNEnd extends DSign {
|
|
||||||
|
|
||||||
public static String name = "End";
|
|
||||||
public String buildPermissions = "dxl.sign.end";
|
|
||||||
public boolean onDungeonInit = false;
|
|
||||||
|
|
||||||
public SIGNEnd(Sign sign, GameWorld gworld) {
|
|
||||||
super(sign, gworld);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean check() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInit() {
|
|
||||||
if (triggers.isEmpty()) {
|
|
||||||
InteractTrigger trigger = InteractTrigger.getOrCreate(0, sign.getBlock(), gworld);
|
|
||||||
if (trigger != null) {
|
|
||||||
trigger.addListener(this);
|
|
||||||
this.triggers.add(trigger);
|
|
||||||
}
|
|
||||||
sign.setLine(0, ChatColor.DARK_BLUE + "############");
|
|
||||||
sign.setLine(1, ChatColor.DARK_GREEN + "End");
|
|
||||||
sign.setLine(2, "");
|
|
||||||
sign.setLine(3, ChatColor.DARK_BLUE + "############");
|
|
||||||
sign.update();
|
|
||||||
} else {
|
|
||||||
sign.getBlock().setType(Material.AIR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPlayerTrigger(Player player) {
|
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
|
||||||
if (dplayer != null) {
|
|
||||||
if (!dplayer.isFinished) {
|
|
||||||
dplayer.finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTrigger() {
|
|
||||||
for (DPlayer dplayer : DPlayer.players) {
|
|
||||||
dplayer.finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPermissions() {
|
|
||||||
return buildPermissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.signs;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.DPlayer;
|
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
|
||||||
import com.dre.dungeonsxl.trigger.InteractTrigger;
|
|
||||||
|
|
||||||
public class SIGNLeave extends DSign {
|
|
||||||
|
|
||||||
public static String name = "Leave";
|
|
||||||
public String buildPermissions = "dxl.sign.leave";
|
|
||||||
public boolean onDungeonInit = true;
|
|
||||||
|
|
||||||
public SIGNLeave(Sign sign, GameWorld gworld) {
|
|
||||||
super(sign, gworld);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean check() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInit() {
|
|
||||||
if (triggers.isEmpty()) {
|
|
||||||
InteractTrigger trigger = InteractTrigger.getOrCreate(0, sign.getBlock(), gworld);
|
|
||||||
if (trigger != null) {
|
|
||||||
trigger.addListener(this);
|
|
||||||
this.triggers.add(trigger);
|
|
||||||
}
|
|
||||||
sign.setLine(0, ChatColor.DARK_BLUE + "############");
|
|
||||||
sign.setLine(1, ChatColor.DARK_GREEN + "Leave");
|
|
||||||
sign.setLine(2, "");
|
|
||||||
sign.setLine(3, ChatColor.DARK_BLUE + "############");
|
|
||||||
sign.update();
|
|
||||||
} else {
|
|
||||||
sign.getBlock().setType(Material.AIR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPlayerTrigger(Player player) {
|
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
|
||||||
if (dplayer != null) {
|
|
||||||
dplayer.leave();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTrigger() {
|
|
||||||
for (DPlayer dplayer : DPlayer.players) {
|
|
||||||
dplayer.leave();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPermissions() {
|
|
||||||
return buildPermissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.signs;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.game.GamePlaceableBlock;
|
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
|
||||||
|
|
||||||
public class SIGNPlace extends DSign {
|
|
||||||
|
|
||||||
public static String name = "Place";
|
|
||||||
public String buildPermissions = "dxl.sign.place";
|
|
||||||
public boolean onDungeonInit = false;
|
|
||||||
|
|
||||||
public SIGNPlace(Sign sign, GameWorld gworld) {
|
|
||||||
super(sign, gworld);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean check() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInit() {
|
|
||||||
String lines[] = sign.getLines();
|
|
||||||
gworld.placeableBlocks.add(new GamePlaceableBlock(sign.getBlock(), lines[1], lines[2]));
|
|
||||||
sign.getBlock().setType(Material.AIR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPermissions() {
|
|
||||||
return buildPermissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,84 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.signs;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.dre.dungeonsxl.DPlayer;
|
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
|
||||||
import com.dre.dungeonsxl.trigger.InteractTrigger;
|
|
||||||
import com.dre.dungeonsxl.P;
|
|
||||||
|
|
||||||
public class SIGNReady extends DSign {
|
|
||||||
|
|
||||||
public static String name = "Ready";
|
|
||||||
public String buildPermissions = "dxl.sign.ready";
|
|
||||||
public boolean onDungeonInit = true;
|
|
||||||
|
|
||||||
public SIGNReady(Sign sign, GameWorld gworld) {
|
|
||||||
super(sign, gworld);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean check() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInit() {
|
|
||||||
if (triggers.isEmpty()) {
|
|
||||||
InteractTrigger trigger = InteractTrigger.getOrCreate(0, sign.getBlock(), gworld);
|
|
||||||
if (trigger != null) {
|
|
||||||
trigger.addListener(this);
|
|
||||||
this.triggers.add(trigger);
|
|
||||||
}
|
|
||||||
sign.setLine(0, ChatColor.DARK_BLUE + "############");
|
|
||||||
sign.setLine(1, ChatColor.DARK_GREEN + "Ready");
|
|
||||||
sign.setLine(2, "");
|
|
||||||
sign.setLine(3, ChatColor.DARK_BLUE + "############");
|
|
||||||
sign.update();
|
|
||||||
} else {
|
|
||||||
sign.getBlock().setType(Material.AIR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPlayerTrigger(Player player) {
|
|
||||||
ready(DPlayer.get(player));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTrigger() {
|
|
||||||
for (DPlayer dplayer : DPlayer.players) {
|
|
||||||
ready(dplayer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ready(DPlayer dplayer) {
|
|
||||||
if (dplayer != null) {
|
|
||||||
if (!dplayer.isReady) {
|
|
||||||
if (gworld.signClass.isEmpty() || dplayer.dclass != null) {
|
|
||||||
dplayer.ready();
|
|
||||||
P.p.msg(dplayer.player, p.language.get("Player_Ready"));
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
P.p.msg(dplayer.player, p.language.get("Error_Ready"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPermissions() {
|
|
||||||
return buildPermissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
package com.dre.dungeonsxl.util;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.Server;
|
|
||||||
|
|
||||||
public class OfflinePlayerUtil {
|
|
||||||
|
|
||||||
static Server server = Bukkit.getServer();
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public static UUID getUniqueIdFromName(String name) {
|
|
||||||
OfflinePlayer player = server.getOfflinePlayer(name);
|
|
||||||
UUID uuid = player.getUniqueId();
|
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
442
src/io/github/dre2n/dungeonsxl/DungeonsXL.java
Normal file
442
src/io/github/dre2n/dungeonsxl/DungeonsXL.java
Normal file
@ -0,0 +1,442 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.command.DCommands;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.DLootInventory;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.Dungeons;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.file.DMessages;
|
||||||
|
import io.github.dre2n.dungeonsxl.file.MainConfig;
|
||||||
|
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||||
|
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.global.LeaveSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.listener.BlockListener;
|
||||||
|
import io.github.dre2n.dungeonsxl.listener.CommandListener;
|
||||||
|
import io.github.dre2n.dungeonsxl.listener.EntityListener;
|
||||||
|
import io.github.dre2n.dungeonsxl.listener.HangingListener;
|
||||||
|
import io.github.dre2n.dungeonsxl.listener.PlayerListener;
|
||||||
|
import io.github.dre2n.dungeonsxl.listener.WorldListener;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DSavePlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.FileUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.VersionUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.VersionUtil.Internals;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class DungeonsXL extends JavaPlugin {
|
||||||
|
|
||||||
|
private static DungeonsXL plugin;
|
||||||
|
|
||||||
|
private MainConfig mainConfig;
|
||||||
|
private DMessages dMessages;
|
||||||
|
private VersionUtil versionUtil;
|
||||||
|
private DCommands dCommands;
|
||||||
|
private Dungeons dungeons;
|
||||||
|
|
||||||
|
private CopyOnWriteArrayList<Player> chatSpyers = new CopyOnWriteArrayList<Player>();
|
||||||
|
private CopyOnWriteArrayList<DLootInventory> dLootInventories = new CopyOnWriteArrayList<DLootInventory>();
|
||||||
|
private CopyOnWriteArrayList<EditWorld> editWorlds = new CopyOnWriteArrayList<EditWorld>();
|
||||||
|
private CopyOnWriteArrayList<GameWorld> gameWorlds = new CopyOnWriteArrayList<GameWorld>();
|
||||||
|
private CopyOnWriteArrayList<GroupSign> groupSigns = new CopyOnWriteArrayList<GroupSign>();
|
||||||
|
private CopyOnWriteArrayList<LeaveSign> leaveSigns = new CopyOnWriteArrayList<LeaveSign>();
|
||||||
|
private CopyOnWriteArrayList<DPortal> dPortals = new CopyOnWriteArrayList<DPortal>();
|
||||||
|
private CopyOnWriteArrayList<DGroup> dGroups = new CopyOnWriteArrayList<DGroup>();
|
||||||
|
private CopyOnWriteArrayList<DPlayer> dPlayers = new CopyOnWriteArrayList<DPlayer>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
plugin = this;
|
||||||
|
getDataFolder().mkdir();
|
||||||
|
|
||||||
|
// Load Language
|
||||||
|
dMessages = new DMessages(new File(plugin.getDataFolder(), "languages/en.yml"));
|
||||||
|
|
||||||
|
// Load Config
|
||||||
|
mainConfig = new MainConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||||
|
|
||||||
|
// Load Language 2
|
||||||
|
loadDMessages(new File(plugin.getDataFolder(), "languages/" + mainConfig.getLanguage() + ".yml"));
|
||||||
|
loadVersionUtil();
|
||||||
|
loadDCommands();
|
||||||
|
loadDungeons();
|
||||||
|
|
||||||
|
// InitFolders
|
||||||
|
initFolders();
|
||||||
|
|
||||||
|
// Setup Permissions
|
||||||
|
setupPermissions();
|
||||||
|
|
||||||
|
// Setup Economy
|
||||||
|
setupEconomy();
|
||||||
|
|
||||||
|
getCommand("dungeonsxl").setExecutor(new CommandListener());
|
||||||
|
Bukkit.getServer().getPluginManager().registerEvents(new EntityListener(), this);
|
||||||
|
Bukkit.getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
||||||
|
Bukkit.getServer().getPluginManager().registerEvents(new BlockListener(), this);
|
||||||
|
Bukkit.getServer().getPluginManager().registerEvents(new WorldListener(), this);
|
||||||
|
Bukkit.getServer().getPluginManager().registerEvents(new HangingListener(), this);
|
||||||
|
|
||||||
|
// Load All
|
||||||
|
loadAll();
|
||||||
|
|
||||||
|
// Scheduler
|
||||||
|
initSchedulers();
|
||||||
|
|
||||||
|
// MSG
|
||||||
|
log("ItemsXL " + getDescription().getVersion() + " for Spigot 1.8.9 loaded succesfully!");
|
||||||
|
if (versionUtil.getInternals() == Internals.OUTDATED) {
|
||||||
|
log("Warning: Your CraftBukkit version is deprecated. DungeonsXL does not support it.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
// Save
|
||||||
|
saveData();
|
||||||
|
dMessages.save();
|
||||||
|
|
||||||
|
// DPlayer leaves World
|
||||||
|
for (DPlayer dplayer : dPlayers) {
|
||||||
|
dplayer.leave();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete all Data
|
||||||
|
dGroups.clear();
|
||||||
|
groupSigns.clear();
|
||||||
|
dLootInventories.clear();
|
||||||
|
dPlayers.clear();
|
||||||
|
dPortals.clear();
|
||||||
|
leaveSigns.clear();
|
||||||
|
dCommands.getDCommands().clear();
|
||||||
|
|
||||||
|
// Delete Worlds
|
||||||
|
GameWorld.deleteAll();
|
||||||
|
EditWorld.deleteAll();
|
||||||
|
|
||||||
|
// Disable listeners
|
||||||
|
HandlerList.unregisterAll(plugin);
|
||||||
|
|
||||||
|
// Stop shedulers
|
||||||
|
plugin.getServer().getScheduler().cancelTasks(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init.
|
||||||
|
public void initFolders() {
|
||||||
|
if ( !getDataFolder().exists()) {
|
||||||
|
getDataFolder().mkdir();
|
||||||
|
}
|
||||||
|
|
||||||
|
File dungeons = new File(getDataFolder() + "/dungeons");
|
||||||
|
if ( !dungeons.exists()) {
|
||||||
|
dungeons.mkdir();
|
||||||
|
}
|
||||||
|
|
||||||
|
File languages = new File(getDataFolder() + "/languages");
|
||||||
|
if ( !languages.exists()) {
|
||||||
|
languages.mkdir();
|
||||||
|
}
|
||||||
|
|
||||||
|
File maps = new File(getDataFolder() + "/maps");
|
||||||
|
if ( !maps.exists()) {
|
||||||
|
maps.mkdir();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initSchedulers() {
|
||||||
|
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (GameWorld gworld : gameWorlds) {
|
||||||
|
if (gworld.world.getPlayers().isEmpty()) {
|
||||||
|
if (DPlayer.get(gworld.world).isEmpty()) {
|
||||||
|
gworld.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (EditWorld eworld : editWorlds) {
|
||||||
|
if (eworld.world.getPlayers().isEmpty()) {
|
||||||
|
eworld.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0L, 1200L);
|
||||||
|
|
||||||
|
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
GameWorld.update();
|
||||||
|
DPlayer.update(true);
|
||||||
|
}
|
||||||
|
}, 0L, 20L);
|
||||||
|
|
||||||
|
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
DPlayer.update(false);
|
||||||
|
}
|
||||||
|
}, 0L, 2L);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Permissions
|
||||||
|
public Permission permission = null;
|
||||||
|
|
||||||
|
private Boolean setupPermissions() {
|
||||||
|
RegisteredServiceProvider<Permission> permissionProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
|
||||||
|
if (permissionProvider != null) {
|
||||||
|
permission = permissionProvider.getProvider();
|
||||||
|
}
|
||||||
|
return permission != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean GroupEnabled(String group) {
|
||||||
|
|
||||||
|
for (String agroup : permission.getGroups()) {
|
||||||
|
if (agroup.equalsIgnoreCase(group)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Economy
|
||||||
|
public Economy economy = null;
|
||||||
|
|
||||||
|
private Boolean setupEconomy() {
|
||||||
|
if (mainConfig.enableEconomy()) {
|
||||||
|
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||||
|
if (economyProvider != null) {
|
||||||
|
economy = economyProvider.getProvider();
|
||||||
|
}
|
||||||
|
return economy != null;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save and Load
|
||||||
|
public void saveData() {
|
||||||
|
File file = new File(getDataFolder(), "data.yml");
|
||||||
|
FileConfiguration configFile = new YamlConfiguration();
|
||||||
|
|
||||||
|
DPortal.save(configFile);
|
||||||
|
GroupSign.save(configFile);
|
||||||
|
LeaveSign.save(configFile);
|
||||||
|
|
||||||
|
try {
|
||||||
|
configFile.save(file);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadAll() {
|
||||||
|
// Load world data
|
||||||
|
File file = new File(getDataFolder(), "data.yml");
|
||||||
|
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
|
||||||
|
|
||||||
|
DPortal.load(configFile);
|
||||||
|
GroupSign.load(configFile);
|
||||||
|
LeaveSign.load(configFile);
|
||||||
|
|
||||||
|
// Load saved players
|
||||||
|
DSavePlayer.load();
|
||||||
|
|
||||||
|
// Check Worlds
|
||||||
|
checkWorlds();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkWorlds() {
|
||||||
|
File serverDir = new File(".");
|
||||||
|
|
||||||
|
for (File file : serverDir.listFiles()) {
|
||||||
|
if (file.getName().contains("DXL_Edit_") && file.isDirectory()) {
|
||||||
|
for (File dungeonFile : file.listFiles()) {
|
||||||
|
if (dungeonFile.getName().contains(".id_")) {
|
||||||
|
String dungeonName = dungeonFile.getName().substring(4);
|
||||||
|
FileUtil.copyDirectory(file, new File(plugin.getDataFolder(), "/maps/" + dungeonName));
|
||||||
|
FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + dungeonName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FileUtil.removeDirectory(file);
|
||||||
|
} else if (file.getName().contains("DXL_Game_") && file.isDirectory()) {
|
||||||
|
FileUtil.removeDirectory(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// LOGGING
|
||||||
|
// -------------------------------------------- //
|
||||||
|
public void log(String msg) {
|
||||||
|
MessageUtil.sendMessage(Bukkit.getConsoleSender(), msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getters & loaders
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the plugin instance
|
||||||
|
*/
|
||||||
|
public static DungeonsXL getPlugin() {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the loaded instance of MainConfig
|
||||||
|
*/
|
||||||
|
public MainConfig getMainConfig() {
|
||||||
|
return mainConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load / reload a new instance of MainConfig
|
||||||
|
*/
|
||||||
|
public void loadMainConfig(File file) {
|
||||||
|
mainConfig = new MainConfig(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the loaded instance of VersionUtil
|
||||||
|
*/
|
||||||
|
public VersionUtil getVersion() {
|
||||||
|
return versionUtil;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load / reload a new instance of VersionUtil
|
||||||
|
*/
|
||||||
|
public void loadVersionUtil() {
|
||||||
|
versionUtil = new VersionUtil();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the loaded instance of DMessages
|
||||||
|
*/
|
||||||
|
public DMessages getDMessages() {
|
||||||
|
return dMessages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load / reload a new instance of DMessages
|
||||||
|
*/
|
||||||
|
public void loadDMessages(File file) {
|
||||||
|
dMessages = new DMessages(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the loaded instance of DCommands
|
||||||
|
*/
|
||||||
|
public DCommands getDCommands() {
|
||||||
|
return dCommands;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load / reload a new instance of DCommands
|
||||||
|
*/
|
||||||
|
public void loadDCommands() {
|
||||||
|
dCommands = new DCommands();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the loaded instance of Dungeons
|
||||||
|
*/
|
||||||
|
public Dungeons getDungeons() {
|
||||||
|
return dungeons;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load / reload a new instance of Dungeons
|
||||||
|
*/
|
||||||
|
public void loadDungeons() {
|
||||||
|
dungeons = new Dungeons();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the chatSpyers
|
||||||
|
*/
|
||||||
|
public CopyOnWriteArrayList<Player> getChatSpyers() {
|
||||||
|
return chatSpyers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the dLootInventories
|
||||||
|
*/
|
||||||
|
public CopyOnWriteArrayList<DLootInventory> getDLootInventories() {
|
||||||
|
return dLootInventories;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the editWorlds
|
||||||
|
*/
|
||||||
|
public CopyOnWriteArrayList<EditWorld> getEditWorlds() {
|
||||||
|
return editWorlds;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the defaultConfig
|
||||||
|
*/
|
||||||
|
public WorldConfig getDefaultConfig() {
|
||||||
|
return WorldConfig.defaultConfig;// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the gameWorlds
|
||||||
|
*/
|
||||||
|
public CopyOnWriteArrayList<GameWorld> getGameWorlds() {
|
||||||
|
return gameWorlds;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the groupSigns
|
||||||
|
*/
|
||||||
|
public CopyOnWriteArrayList<GroupSign> getGroupSigns() {
|
||||||
|
return groupSigns;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the dPortals
|
||||||
|
*/
|
||||||
|
public CopyOnWriteArrayList<DPortal> getDPortals() {
|
||||||
|
return dPortals;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the leaveSigns
|
||||||
|
*/
|
||||||
|
public CopyOnWriteArrayList<LeaveSign> getLeaveSigns() {
|
||||||
|
return leaveSigns;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the dGroups
|
||||||
|
*/
|
||||||
|
public CopyOnWriteArrayList<DGroup> getDGroups() {
|
||||||
|
return dGroups;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the dPlayers
|
||||||
|
*/
|
||||||
|
public CopyOnWriteArrayList<DPlayer> getDPlayers() {
|
||||||
|
return dPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
39
src/io/github/dre2n/dungeonsxl/command/ChatCommand.java
Normal file
39
src/io/github/dre2n/dungeonsxl/command/ChatCommand.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ChatCommand extends DCommand {
|
||||||
|
|
||||||
|
public ChatCommand() {
|
||||||
|
setCommand("chat");
|
||||||
|
setMinArgs(0);
|
||||||
|
setMaxArgs(0);
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_Chat"));
|
||||||
|
setPlayerCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
|
||||||
|
if (dplayer != null) {
|
||||||
|
if (dplayer.isInDungeonChat) {
|
||||||
|
dplayer.isInDungeonChat = false;
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Chat_NormalChat"));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
dplayer.isInDungeonChat = true;
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Chat_DungeonChat"));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
33
src/io/github/dre2n/dungeonsxl/command/ChatSpyCommand.java
Normal file
33
src/io/github/dre2n/dungeonsxl/command/ChatSpyCommand.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ChatSpyCommand extends DCommand {
|
||||||
|
|
||||||
|
public ChatSpyCommand() {
|
||||||
|
setCommand("chatspy");
|
||||||
|
setMinArgs(0);
|
||||||
|
setMaxArgs(0);
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_Chatspy"));
|
||||||
|
setPermission("dxl.chatspy");
|
||||||
|
setPlayerCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (plugin.getChatSpyers().contains(player)) {
|
||||||
|
plugin.getChatSpyers().remove(player);
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Chatspy_Stopped"));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
plugin.getChatSpyers().add(player);
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Chatspy_Start"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
82
src/io/github/dre2n/dungeonsxl/command/CreateCommand.java
Normal file
82
src/io/github/dre2n/dungeonsxl/command/CreateCommand.java
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class CreateCommand extends DCommand {
|
||||||
|
|
||||||
|
public CreateCommand() {
|
||||||
|
setMinArgs(1);
|
||||||
|
setMaxArgs(1);
|
||||||
|
setCommand("create");
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_Create"));
|
||||||
|
setPermission("dxl.create");
|
||||||
|
setPlayerCommand(true);
|
||||||
|
setConsoleCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
String name = args[1];
|
||||||
|
|
||||||
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
|
if (name.length() <= 15) {
|
||||||
|
// Msg create
|
||||||
|
plugin.log(plugin.getDMessages().get("Log_NewDungeon"));
|
||||||
|
plugin.log(plugin.getDMessages().get("Log_GenerateNewWorld"));
|
||||||
|
|
||||||
|
// Create World
|
||||||
|
EditWorld eworld = new EditWorld();
|
||||||
|
eworld.generate();
|
||||||
|
eworld.dungeonname = name;
|
||||||
|
eworld.save();
|
||||||
|
eworld.delete();
|
||||||
|
|
||||||
|
// MSG Done
|
||||||
|
plugin.log(plugin.getDMessages().get("Log_WorldGenerationFinished"));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(sender, plugin.getDMessages().get("Error_NameToLong"));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (sender instanceof Player) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (DPlayer.get(player) == null) {
|
||||||
|
if (name.length() <= 15) {
|
||||||
|
// Msg create
|
||||||
|
plugin.log(plugin.getDMessages().get("Log_NewDungeon"));
|
||||||
|
plugin.log(plugin.getDMessages().get("Log_GenerateNewWorld"));
|
||||||
|
|
||||||
|
// Create World
|
||||||
|
EditWorld eworld = new EditWorld();
|
||||||
|
eworld.generate();
|
||||||
|
eworld.dungeonname = name;
|
||||||
|
|
||||||
|
// MSG Done
|
||||||
|
plugin.log(plugin.getDMessages().get("Log_WorldGenerationFinished"));
|
||||||
|
|
||||||
|
// Tp Player
|
||||||
|
if (eworld.lobby == null) {
|
||||||
|
new DPlayer(player, eworld.world, eworld.world.getSpawnLocation(), true);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
new DPlayer(player, eworld.world, eworld.lobby, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NameToLong"));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
147
src/io/github/dre2n/dungeonsxl/command/DCommand.java
Normal file
147
src/io/github/dre2n/dungeonsxl/command/DCommand.java
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public abstract class DCommand {
|
||||||
|
|
||||||
|
public DungeonsXL plugin = DungeonsXL.getPlugin();
|
||||||
|
|
||||||
|
public boolean costsMoney;
|
||||||
|
private String command;
|
||||||
|
private int minArgs;
|
||||||
|
private int maxArgs;
|
||||||
|
private String help;
|
||||||
|
private String permission;
|
||||||
|
private boolean isPlayerCommand = false;
|
||||||
|
private boolean isConsoleCommand = false;
|
||||||
|
|
||||||
|
public DCommand() {
|
||||||
|
costsMoney = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void displayHelp(CommandSender sender) {
|
||||||
|
MessageUtil.sendMessage(sender, ChatColor.RED + help);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean playerHasPermissions(Player player) {
|
||||||
|
if (player.hasPermission(permission) || permission == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the command
|
||||||
|
*/
|
||||||
|
public String getCommand() {
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param command
|
||||||
|
* the command to set
|
||||||
|
*/
|
||||||
|
public void setCommand(String command) {
|
||||||
|
this.command = command;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the minimal amount of arguments
|
||||||
|
*/
|
||||||
|
public int getMinArgs() {
|
||||||
|
return minArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param minArgs
|
||||||
|
* the minimal amount of arguments to set
|
||||||
|
*/
|
||||||
|
public void setMinArgs(int minArgs) {
|
||||||
|
this.minArgs = minArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the maximum amount of arguments
|
||||||
|
*/
|
||||||
|
public int getMaxArgs() {
|
||||||
|
return maxArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param maxArgs
|
||||||
|
* the maximum amount of arguments to set
|
||||||
|
*/
|
||||||
|
public void setMaxArgs(int maxArgs) {
|
||||||
|
this.maxArgs = maxArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the help
|
||||||
|
*/
|
||||||
|
public String getHelp() {
|
||||||
|
return help;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param help
|
||||||
|
* the help to set
|
||||||
|
*/
|
||||||
|
public void setHelp(String help) {
|
||||||
|
this.help = help;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the permission
|
||||||
|
*/
|
||||||
|
public String getPermission() {
|
||||||
|
return permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param permission
|
||||||
|
* the permission to set
|
||||||
|
*/
|
||||||
|
public void setPermission(String permission) {
|
||||||
|
this.permission = permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the isPlayerCommand
|
||||||
|
*/
|
||||||
|
public boolean isPlayerCommand() {
|
||||||
|
return isPlayerCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param isPlayerCommand
|
||||||
|
* the isPlayerCommand to set
|
||||||
|
*/
|
||||||
|
public void setPlayerCommand(boolean isPlayerCommand) {
|
||||||
|
this.isPlayerCommand = isPlayerCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the isConsoleCommand
|
||||||
|
*/
|
||||||
|
public boolean isConsoleCommand() {
|
||||||
|
return isConsoleCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param isConsoleCommand
|
||||||
|
* the isConsoleCommand to set
|
||||||
|
*/
|
||||||
|
public void setConsoleCommand(boolean isConsoleCommand) {
|
||||||
|
this.isConsoleCommand = isConsoleCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Abstracts
|
||||||
|
public abstract void onExecute(String[] args, CommandSender sender);
|
||||||
|
|
||||||
|
}
|
55
src/io/github/dre2n/dungeonsxl/command/DCommands.java
Normal file
55
src/io/github/dre2n/dungeonsxl/command/DCommands.java
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
public class DCommands {
|
||||||
|
|
||||||
|
private CopyOnWriteArrayList<DCommand> dCommands = new CopyOnWriteArrayList<DCommand>();
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
public DCommands() {
|
||||||
|
// Add Commands
|
||||||
|
dCommands.add(new HelpCommand());
|
||||||
|
dCommands.add(new CreateCommand());
|
||||||
|
dCommands.add(new SaveCommand());
|
||||||
|
dCommands.add(new LeaveCommand());
|
||||||
|
dCommands.add(new EscapeCommand());
|
||||||
|
dCommands.add(new EditCommand());
|
||||||
|
dCommands.add(new PortalCommand());
|
||||||
|
dCommands.add(new DeletePortalCommand());
|
||||||
|
dCommands.add(new MainCommand());
|
||||||
|
dCommands.add(new ChatCommand());
|
||||||
|
dCommands.add(new ChatSpyCommand());
|
||||||
|
dCommands.add(new LivesCommand());
|
||||||
|
dCommands.add(new ListCommand());
|
||||||
|
dCommands.add(new UninviteCommand());
|
||||||
|
dCommands.add(new InviteCommand());
|
||||||
|
dCommands.add(new MsgCommand());
|
||||||
|
dCommands.add(new PlayCommand());
|
||||||
|
dCommands.add(new TestCommand());
|
||||||
|
dCommands.add(new ReloadCommand());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param command
|
||||||
|
* usually the first command variable
|
||||||
|
*/
|
||||||
|
public DCommand getDCommand(String command) {
|
||||||
|
for (DCommand dCommand : dCommands) {
|
||||||
|
if (dCommand.getCommand().equals(command)) {
|
||||||
|
return dCommand;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the dCommands
|
||||||
|
*/
|
||||||
|
public List<DCommand> getDCommands() {
|
||||||
|
return dCommands;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class DeletePortalCommand extends DCommand {
|
||||||
|
|
||||||
|
public DeletePortalCommand() {
|
||||||
|
setCommand("deleteportal");
|
||||||
|
setMinArgs(0);
|
||||||
|
setMaxArgs(0);
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_DeletePortal"));
|
||||||
|
setPermission("dxl.deleteportal");
|
||||||
|
setPlayerCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
DPortal dPortal = DPortal.get(player.getTargetBlock((Set<Material>) null, 20).getLocation());
|
||||||
|
|
||||||
|
if (dPortal != null) {
|
||||||
|
dPortal.delete();
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalDeleted"));
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoPortal"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
54
src/io/github/dre2n/dungeonsxl/command/EditCommand.java
Normal file
54
src/io/github/dre2n/dungeonsxl/command/EditCommand.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class EditCommand extends DCommand {
|
||||||
|
|
||||||
|
public EditCommand() {
|
||||||
|
setCommand("edit");
|
||||||
|
setMinArgs(1);
|
||||||
|
setMaxArgs(1);
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_Edit"));
|
||||||
|
setPlayerCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
String dungeonName = args[1];
|
||||||
|
EditWorld eworld = EditWorld.load(dungeonName);
|
||||||
|
DGroup dgroup = DGroup.get(player);
|
||||||
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
|
||||||
|
if (EditWorld.isInvitedPlayer(dungeonName, player.getUniqueId(), player.getName()) || player.hasPermission("dxl.edit")) {
|
||||||
|
if (dplayer == null) {
|
||||||
|
if (dgroup == null) {
|
||||||
|
if (eworld != null) {
|
||||||
|
if (eworld.lobby == null) {
|
||||||
|
new DPlayer(player, eworld.world, eworld.world.getSpawnLocation(), true);
|
||||||
|
} else {
|
||||||
|
new DPlayer(player, eworld.world, eworld.lobby, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_DungeonNotExist", dungeonName));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveGroup"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoPermission"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
54
src/io/github/dre2n/dungeonsxl/command/EscapeCommand.java
Normal file
54
src/io/github/dre2n/dungeonsxl/command/EscapeCommand.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class EscapeCommand extends DCommand {
|
||||||
|
|
||||||
|
public EscapeCommand() {
|
||||||
|
setCommand("escape");
|
||||||
|
setMinArgs(0);
|
||||||
|
setMaxArgs(0);
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_Escape"));
|
||||||
|
setPlayerCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
if (dplayer != null) {
|
||||||
|
|
||||||
|
if (dplayer.isEditing) {
|
||||||
|
dplayer.escape();
|
||||||
|
|
||||||
|
EditWorld eworld = EditWorld.get(dplayer.world);
|
||||||
|
if (eworld != null) {
|
||||||
|
if (eworld.world.getPlayers().isEmpty()) {
|
||||||
|
eworld.deleteNoSave();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
DGroup dgroup = DGroup.get(player);
|
||||||
|
if (dgroup != null) {
|
||||||
|
dgroup.removePlayer(player);
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Leave_Success"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
51
src/io/github/dre2n/dungeonsxl/command/HelpCommand.java
Normal file
51
src/io/github/dre2n/dungeonsxl/command/HelpCommand.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.util.IntegerUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
public class HelpCommand extends DCommand {
|
||||||
|
|
||||||
|
public HelpCommand() {
|
||||||
|
setCommand("help");
|
||||||
|
setMinArgs(0);
|
||||||
|
setMaxArgs(1);
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_Help"));
|
||||||
|
setPlayerCommand(true);
|
||||||
|
setConsoleCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
List<DCommand> dCommandList = plugin.getDCommands().getDCommands();
|
||||||
|
ArrayList<DCommand> toSend = new ArrayList<DCommand>();
|
||||||
|
|
||||||
|
int page = 1;
|
||||||
|
if (args.length == 2) {
|
||||||
|
page = IntegerUtil.parseInt(args[1], 1);
|
||||||
|
}
|
||||||
|
int send = 0;
|
||||||
|
int max = 0;
|
||||||
|
int min = 0;
|
||||||
|
for (DCommand dCommand : dCommandList) {
|
||||||
|
send++;
|
||||||
|
if (send >= page * 5 - 4 && send <= page * 5) {
|
||||||
|
min = page * 5 - 4;
|
||||||
|
max = page * 5;
|
||||||
|
toSend.add(dCommand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageUtil.sendPluginTag(sender, plugin);
|
||||||
|
MessageUtil.sendCenteredMessage(sender, "&4&l[ &6" + min + "-" + max + " &4/&6 " + send + " &4|&6 " + page + " &4&l]");
|
||||||
|
|
||||||
|
for (DCommand dCommand : toSend) {
|
||||||
|
MessageUtil.sendMessage(sender, "&b" + dCommand.getCommand() + "&7 - " + dCommand.getHelp());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
30
src/io/github/dre2n/dungeonsxl/command/InviteCommand.java
Normal file
30
src/io/github/dre2n/dungeonsxl/command/InviteCommand.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.UUIDUtil;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
public class InviteCommand extends DCommand {
|
||||||
|
|
||||||
|
public InviteCommand() {
|
||||||
|
setMinArgs(2);
|
||||||
|
setMaxArgs(2);
|
||||||
|
setCommand("invite");
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_Invite"));
|
||||||
|
setPermission("dxl.invite");
|
||||||
|
setPlayerCommand(true);
|
||||||
|
setConsoleCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
if (EditWorld.addInvitedPlayer(args[2], UUIDUtil.getUniqueIdFromName(args[1]))) {
|
||||||
|
MessageUtil.sendMessage(sender, plugin.getDMessages().get("Cmd_Invite_Success", args[1], args[2]));
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(sender, plugin.getDMessages().get("Error_DungeonNotExist", args[2]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
49
src/io/github/dre2n/dungeonsxl/command/LeaveCommand.java
Normal file
49
src/io/github/dre2n/dungeonsxl/command/LeaveCommand.java
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class LeaveCommand extends DCommand {
|
||||||
|
|
||||||
|
public LeaveCommand() {
|
||||||
|
setCommand("leave");
|
||||||
|
setMinArgs(0);
|
||||||
|
setMaxArgs(0);
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_Leave"));
|
||||||
|
setPlayerCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
|
||||||
|
if (GameWorld.get(player.getWorld()) != null) {
|
||||||
|
if (GameWorld.get(player.getWorld()).isTutorial) {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoLeaveInTutorial"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dplayer != null) {
|
||||||
|
dplayer.leave();
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Leave_Success"));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
DGroup dgroup = DGroup.get(player);
|
||||||
|
if (dgroup != null) {
|
||||||
|
dgroup.removePlayer(player);
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Leave_Success"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
113
src/io/github/dre2n/dungeonsxl/command/ListCommand.java
Normal file
113
src/io/github/dre2n/dungeonsxl/command/ListCommand.java
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.DungeonConfig;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.IntegerUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
public class ListCommand extends DCommand {
|
||||||
|
|
||||||
|
public ListCommand() {
|
||||||
|
setCommand("list");
|
||||||
|
setMinArgs(0);
|
||||||
|
setMaxArgs(2);
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_List"));
|
||||||
|
setPlayerCommand(true);
|
||||||
|
setConsoleCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
File dungeonFolder = new File(plugin.getDataFolder() + "/dungeons");
|
||||||
|
File mapFolder = new File(plugin.getDataFolder() + "/maps");
|
||||||
|
ArrayList<File> dungeonList = new ArrayList<File>();
|
||||||
|
for (File file : dungeonFolder.listFiles()) {
|
||||||
|
dungeonList.add(file);
|
||||||
|
}
|
||||||
|
ArrayList<File> mapList = new ArrayList<File>();
|
||||||
|
for (File file : mapFolder.listFiles()) {
|
||||||
|
mapList.add(file);
|
||||||
|
}
|
||||||
|
ArrayList<File> loadedList = new ArrayList<File>();
|
||||||
|
for (EditWorld editWorld : plugin.getEditWorlds()) {
|
||||||
|
loadedList.add(editWorld.world.getWorldFolder());
|
||||||
|
}
|
||||||
|
for (GameWorld gameWorld : plugin.getGameWorlds()) {
|
||||||
|
loadedList.add(gameWorld.world.getWorldFolder());
|
||||||
|
}
|
||||||
|
ArrayList<String> toSend = new ArrayList<String>();
|
||||||
|
|
||||||
|
ArrayList<File> fileList = mapList;
|
||||||
|
boolean specified = false;
|
||||||
|
byte listType = 0;
|
||||||
|
if (args.length >= 2) {
|
||||||
|
if (args[1].equalsIgnoreCase("dungeons") || args[1].equalsIgnoreCase("d")) {
|
||||||
|
specified = true;
|
||||||
|
fileList = dungeonList;
|
||||||
|
listType = 1;
|
||||||
|
|
||||||
|
} else if (args[1].equalsIgnoreCase("maps") || args[1].equalsIgnoreCase("m")) {
|
||||||
|
specified = true;
|
||||||
|
|
||||||
|
} else if (args[1].equalsIgnoreCase("loaded") || args[1].equalsIgnoreCase("l")) {
|
||||||
|
specified = true;
|
||||||
|
fileList = loadedList;
|
||||||
|
listType = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int page = 1;
|
||||||
|
if (args.length == 3) {
|
||||||
|
page = IntegerUtil.parseInt(args[2], 1);
|
||||||
|
|
||||||
|
} else if (args.length == 2 & !specified) {
|
||||||
|
page = IntegerUtil.parseInt(args[1], 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int send = 0;
|
||||||
|
int max = 0;
|
||||||
|
int min = 0;
|
||||||
|
for (File file : fileList) {
|
||||||
|
send++;
|
||||||
|
if (send >= page * 5 - 4 && send <= page * 5) {
|
||||||
|
min = page * 5 - 4;
|
||||||
|
max = page * 5;
|
||||||
|
toSend.add(file.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageUtil.sendPluginTag(sender, plugin);
|
||||||
|
MessageUtil.sendCenteredMessage(sender, "&4&l[ &6" + min + "-" + max + " &4/&6 " + send + " &4|&6 " + page + " &4&l]");
|
||||||
|
|
||||||
|
if (listType == 0) {
|
||||||
|
MessageUtil.sendMessage(sender, "&4Map&7 | &eInvited");
|
||||||
|
|
||||||
|
for (String map : toSend) {
|
||||||
|
WorldConfig worldConfig = new WorldConfig(new File(mapFolder + "/" + map, "config.yml"));
|
||||||
|
MessageUtil.sendMessage(sender, "&b" + map + "&7 | &e" + worldConfig.getInvitedPlayers().contains(sender));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (listType == 1) {
|
||||||
|
MessageUtil.sendMessage(sender, "&4Dungeon&7 | &eMap count");
|
||||||
|
|
||||||
|
for (String dungeon : toSend) {
|
||||||
|
DungeonConfig dungeonConfig = new DungeonConfig(new File(dungeonFolder, dungeon + ".yml"));
|
||||||
|
int count = dungeonConfig.getFloors().size() + 2;
|
||||||
|
MessageUtil.sendMessage(sender, "&b" + dungeon + "&7 | &e" + count);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (listType == 2) {
|
||||||
|
MessageUtil.sendMessage(sender, "&4Loaded map");
|
||||||
|
for (String map : toSend) {
|
||||||
|
MessageUtil.sendMessage(sender, "&b" + map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
49
src/io/github/dre2n/dungeonsxl/command/LivesCommand.java
Normal file
49
src/io/github/dre2n/dungeonsxl/command/LivesCommand.java
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class LivesCommand extends DCommand {
|
||||||
|
|
||||||
|
public LivesCommand() {
|
||||||
|
setCommand("lives");
|
||||||
|
setMinArgs(0);
|
||||||
|
setMaxArgs(1);
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_Lives"));
|
||||||
|
setPlayerCommand(true);
|
||||||
|
setConsoleCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
Player player = null;
|
||||||
|
|
||||||
|
if (args.length == 2) {
|
||||||
|
if (Bukkit.getServer().getPlayer(args[1]) != null) {
|
||||||
|
player = Bukkit.getServer().getPlayer(args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (sender instanceof Player) {
|
||||||
|
player = (Player) sender;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(sender, DungeonsXL.getPlugin().getDMessages().get("Error_NoConsoleCommand", getCommand()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DPlayer dPlayer = DPlayer.get(player);
|
||||||
|
if (dPlayer != null) {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Lives").replaceAll("v1", player.getName()).replaceAll("v2", String.valueOf(dPlayer.lives)));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
51
src/io/github/dre2n/dungeonsxl/command/MainCommand.java
Normal file
51
src/io/github/dre2n/dungeonsxl/command/MainCommand.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.VersionUtil.Internals;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
|
public class MainCommand extends DCommand {
|
||||||
|
|
||||||
|
public MainCommand() {
|
||||||
|
setCommand("main");
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_main"));
|
||||||
|
setPlayerCommand(true);
|
||||||
|
setConsoleCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
PluginManager plugins = Bukkit.getServer().getPluginManager();
|
||||||
|
|
||||||
|
int dungeons = new File(plugin.getDataFolder() + "/dungeons").listFiles().length;
|
||||||
|
int loaded = plugin.getEditWorlds().size() + plugin.getGameWorlds().size();
|
||||||
|
int players = plugin.getDPlayers().size();
|
||||||
|
Internals internals = DungeonsXL.getPlugin().getVersion().getInternals();
|
||||||
|
String vault = "";
|
||||||
|
if (plugins.getPlugin("Vault") != null) {
|
||||||
|
vault = plugins.getPlugin("Vault").getDescription().getVersion();
|
||||||
|
}
|
||||||
|
String mythicMobs = "";
|
||||||
|
if (plugins.getPlugin("MythicMobs") != null) {
|
||||||
|
mythicMobs = plugins.getPlugin("MythicMobs").getDescription().getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageUtil.sendCenteredMessage(sender, "&4" + MessageUtil.BIG_D[0] + "&f" + MessageUtil.BIG_X[0] + MessageUtil.BIG_L[0]);
|
||||||
|
MessageUtil.sendCenteredMessage(sender, "&4" + MessageUtil.BIG_D[1] + "&f" + MessageUtil.BIG_X[1] + MessageUtil.BIG_L[1]);
|
||||||
|
MessageUtil.sendCenteredMessage(sender, "&4" + MessageUtil.BIG_D[2] + "&f" + MessageUtil.BIG_X[2] + MessageUtil.BIG_L[2]);
|
||||||
|
MessageUtil.sendCenteredMessage(sender, "&4" + MessageUtil.BIG_D[3] + "&f" + MessageUtil.BIG_X[3] + MessageUtil.BIG_L[3]);
|
||||||
|
MessageUtil.sendCenteredMessage(sender, "&4" + MessageUtil.BIG_D[4] + "&f" + MessageUtil.BIG_X[4] + MessageUtil.BIG_L[4]);
|
||||||
|
MessageUtil.sendCenteredMessage(sender, "&b&l####### " + plugin.getDMessages().get("Cmd_Main_Welcome") + "&7 v" + plugin.getDescription().getVersion() + " &b&l#######");
|
||||||
|
MessageUtil.sendCenteredMessage(sender, plugin.getDMessages().get("Cmd_Main_Loaded", String.valueOf(dungeons), String.valueOf(loaded), String.valueOf(players)));
|
||||||
|
MessageUtil.sendCenteredMessage(sender, plugin.getDMessages().get("Cmd_Main_Compatibility", String.valueOf(internals), vault, mythicMobs));
|
||||||
|
MessageUtil.sendCenteredMessage(sender, plugin.getDMessages().get("Cmd_Main_Help"));
|
||||||
|
MessageUtil.sendCenteredMessage(sender, "&7\u00a92012-2015 Frank Baumann & contributors; lcsd. under GPLv3.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
91
src/io/github/dre2n/dungeonsxl/command/MsgCommand.java
Normal file
91
src/io/github/dre2n/dungeonsxl/command/MsgCommand.java
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.IntegerUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class MsgCommand extends DCommand {
|
||||||
|
|
||||||
|
public MsgCommand() {
|
||||||
|
setMinArgs( -1);
|
||||||
|
setMaxArgs( -1);
|
||||||
|
setCommand("msg");
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_Msg"));
|
||||||
|
setPermission("dxl.msg");
|
||||||
|
setPlayerCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
EditWorld eworld = EditWorld.get(player.getWorld());
|
||||||
|
|
||||||
|
if (eworld != null) {
|
||||||
|
if (args.length > 1) {
|
||||||
|
try {
|
||||||
|
int id = IntegerUtil.parseInt(args[1]);
|
||||||
|
|
||||||
|
WorldConfig confreader = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + eworld.dungeonname, "config.yml"));
|
||||||
|
|
||||||
|
if (args.length == 2) {
|
||||||
|
String msg = confreader.getMsg(id, true);
|
||||||
|
|
||||||
|
if (msg != null) {
|
||||||
|
MessageUtil.sendMessage(player, ChatColor.WHITE + msg);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_MsgIdNotExist", "" + id));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
String msg = "";
|
||||||
|
int i = 0;
|
||||||
|
for (String arg : args) {
|
||||||
|
i++;
|
||||||
|
if (i > 2) {
|
||||||
|
msg = msg + " " + arg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] splitMsg = msg.split("\"");
|
||||||
|
|
||||||
|
if (splitMsg.length > 1) {
|
||||||
|
msg = splitMsg[1];
|
||||||
|
String old = confreader.getMsg(id, false);
|
||||||
|
if (old == null) {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Msg_Added", "" + id));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Msg_Updated", "" + id));
|
||||||
|
}
|
||||||
|
|
||||||
|
confreader.setMsg(msg, id);
|
||||||
|
confreader.save();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_MsgFormat"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_MsgNoInt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
displayHelp(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
87
src/io/github/dre2n/dungeonsxl/command/PlayCommand.java
Normal file
87
src/io/github/dre2n/dungeonsxl/command/PlayCommand.java
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class PlayCommand extends DCommand {
|
||||||
|
|
||||||
|
public PlayCommand() {
|
||||||
|
setCommand("play");
|
||||||
|
setMinArgs(1);
|
||||||
|
setMaxArgs(2);
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_Play"));
|
||||||
|
setPermission("dxl.play");
|
||||||
|
setPlayerCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
|
||||||
|
if (dplayer != null) {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length != 2) {
|
||||||
|
displayHelp(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String dungeonname = args[1];
|
||||||
|
|
||||||
|
if ( !EditWorld.exist(dungeonname)) {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_DungeonNotExist", dungeonname));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !GameWorld.canPlayDungeon(dungeonname, player)) {
|
||||||
|
File file = new File(plugin.getDataFolder() + "/maps/" + dungeonname + "/config.yml");
|
||||||
|
|
||||||
|
if (file != null) {
|
||||||
|
WorldConfig confReader = new WorldConfig(file);
|
||||||
|
|
||||||
|
if (confReader != null) {
|
||||||
|
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_Cooldown", "" + confReader.getTimeToNextPlay()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !GameWorld.checkRequirements(dungeonname, player)) {
|
||||||
|
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_Requirements"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DGroup.get(player) != null) {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveGroup"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DGroup dgroup = new DGroup(player, dungeonname);
|
||||||
|
|
||||||
|
if (dgroup != null) {
|
||||||
|
if (dgroup.getGworld() == null) {
|
||||||
|
dgroup.setGworld(GameWorld.load(DGroup.get(player).getDungeonname()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dgroup.getGworld().locLobby == null) {
|
||||||
|
new DPlayer(player, dgroup.getGworld().world, dgroup.getGworld().world.getSpawnLocation(), false);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
new DPlayer(player, dgroup.getGworld().world, dgroup.getGworld().locLobby, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
48
src/io/github/dre2n/dungeonsxl/command/PortalCommand.java
Normal file
48
src/io/github/dre2n/dungeonsxl/command/PortalCommand.java
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class PortalCommand extends DCommand {
|
||||||
|
|
||||||
|
public PortalCommand() {
|
||||||
|
setCommand("portal");
|
||||||
|
setMinArgs(0);
|
||||||
|
setMaxArgs(0);
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_Portal"));
|
||||||
|
setPermission("dxl.portal");
|
||||||
|
setPlayerCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
|
||||||
|
if (dplayer == null) {
|
||||||
|
DPortal dportal = DPortal.get(player);
|
||||||
|
|
||||||
|
if (dportal == null) {
|
||||||
|
dportal = new DPortal(false);
|
||||||
|
dportal.setPlayer(player);
|
||||||
|
dportal.setWorld(player.getWorld());
|
||||||
|
player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD));
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalIntroduction"));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
plugin.getDPortals().remove(dportal);
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalAbort"));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
59
src/io/github/dre2n/dungeonsxl/command/ReloadCommand.java
Normal file
59
src/io/github/dre2n/dungeonsxl/command/ReloadCommand.java
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.VersionUtil.Internals;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
|
public class ReloadCommand extends DCommand {
|
||||||
|
|
||||||
|
public ReloadCommand() {
|
||||||
|
setCommand("reload");
|
||||||
|
setMinArgs(0);
|
||||||
|
setMaxArgs(0);
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_Reload"));
|
||||||
|
setPermission("dxl.reload");
|
||||||
|
setPlayerCommand(true);
|
||||||
|
setConsoleCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
PluginManager plugins = Bukkit.getServer().getPluginManager();
|
||||||
|
|
||||||
|
int dungeons = new File(plugin.getDataFolder() + "/dungeons").listFiles().length;
|
||||||
|
int loaded = plugin.getEditWorlds().size() + plugin.getGameWorlds().size();
|
||||||
|
int players = plugin.getDPlayers().size();
|
||||||
|
Internals internals = DungeonsXL.getPlugin().getVersion().getInternals();
|
||||||
|
String vault = "";
|
||||||
|
if (plugins.getPlugin("Vault") != null) {
|
||||||
|
vault = plugins.getPlugin("Vault").getDescription().getVersion();
|
||||||
|
}
|
||||||
|
String mythicMobs = "";
|
||||||
|
if (plugins.getPlugin("MythicMobs") != null) {
|
||||||
|
mythicMobs = plugins.getPlugin("MythicMobs").getDescription().getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save
|
||||||
|
plugin.saveData();
|
||||||
|
plugin.getDMessages().save();
|
||||||
|
|
||||||
|
// Load Config
|
||||||
|
plugin.loadMainConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||||
|
plugin.loadDMessages(new File(plugin.getDataFolder(), "languages/" + plugin.getMainConfig().getLanguage() + ".yml"));
|
||||||
|
plugin.loadVersionUtil();
|
||||||
|
plugin.loadDCommands();
|
||||||
|
plugin.loadDungeons();
|
||||||
|
|
||||||
|
MessageUtil.sendPluginTag(sender, plugin);
|
||||||
|
MessageUtil.sendCenteredMessage(sender, plugin.getDMessages().get("Cmd_Reload_Done"));
|
||||||
|
MessageUtil.sendCenteredMessage(sender, plugin.getDMessages().get("Cmd_Main_Loaded", String.valueOf(dungeons), String.valueOf(loaded), String.valueOf(players)));
|
||||||
|
MessageUtil.sendCenteredMessage(sender, plugin.getDMessages().get("Cmd_Main_Compatibility", String.valueOf(internals), vault, mythicMobs));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
33
src/io/github/dre2n/dungeonsxl/command/SaveCommand.java
Normal file
33
src/io/github/dre2n/dungeonsxl/command/SaveCommand.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class SaveCommand extends DCommand {
|
||||||
|
|
||||||
|
public SaveCommand() {
|
||||||
|
setCommand("save");
|
||||||
|
setMinArgs(0);
|
||||||
|
setMaxArgs(0);
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_Save"));
|
||||||
|
setPermission("dxl.save");
|
||||||
|
setPlayerCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
EditWorld eworld = EditWorld.get(player.getWorld());
|
||||||
|
if (eworld != null) {
|
||||||
|
eworld.save();
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Save_Success"));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
73
src/io/github/dre2n/dungeonsxl/command/TestCommand.java
Normal file
73
src/io/github/dre2n/dungeonsxl/command/TestCommand.java
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class TestCommand extends DCommand {
|
||||||
|
|
||||||
|
public TestCommand() {
|
||||||
|
setCommand("test");
|
||||||
|
setMinArgs(1);
|
||||||
|
setMaxArgs(2);
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_Test"));
|
||||||
|
setPermission("dxl.test");
|
||||||
|
setPlayerCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
|
||||||
|
if (dplayer != null) {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length != 2) {
|
||||||
|
displayHelp(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String dungeonname = args[1];
|
||||||
|
|
||||||
|
if ( !EditWorld.exist(dungeonname)) {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_DungeonNotExist", dungeonname));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DGroup.get(player) != null) {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveGroup"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DGroup.get(player) != null) {
|
||||||
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveGroup"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DGroup dgroup = new DGroup(player, dungeonname);
|
||||||
|
|
||||||
|
if (dgroup.getGworld() == null) {
|
||||||
|
dgroup.setGworld(GameWorld.load(DGroup.get(player).getDungeonname()));
|
||||||
|
}
|
||||||
|
|
||||||
|
DPlayer newDPlayer;
|
||||||
|
|
||||||
|
if (dgroup.getGworld().locLobby == null) {
|
||||||
|
newDPlayer = new DPlayer(player, dgroup.getGworld().world, dgroup.getGworld().world.getSpawnLocation(), false);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
newDPlayer = new DPlayer(player, dgroup.getGworld().world, dgroup.getGworld().locLobby, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
newDPlayer.isinTestMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
31
src/io/github/dre2n/dungeonsxl/command/UninviteCommand.java
Normal file
31
src/io/github/dre2n/dungeonsxl/command/UninviteCommand.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.UUIDUtil;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
public class UninviteCommand extends DCommand {
|
||||||
|
|
||||||
|
public UninviteCommand() {
|
||||||
|
setCommand("uninvite");
|
||||||
|
setMinArgs(2);
|
||||||
|
setMaxArgs(2);
|
||||||
|
setHelp(plugin.getDMessages().get("Help_Cmd_Uninvite"));
|
||||||
|
setPermission("dxl.uninvite");
|
||||||
|
setPlayerCommand(true);
|
||||||
|
setConsoleCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
if (EditWorld.removeInvitedPlayer(args[2], UUIDUtil.getUniqueIdFromName(args[1]), args[1])) {
|
||||||
|
MessageUtil.sendMessage(sender, plugin.getDMessages().get("Cmd_Uninvite_Success", args[1], args[2]));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(sender, plugin.getDMessages().get("Error_DungeonNotExist", args[2]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
103
src/io/github/dre2n/dungeonsxl/dungeon/DLootInventory.java
Normal file
103
src/io/github/dre2n/dungeonsxl/dungeon/DLootInventory.java
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.dungeon;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryView;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class DLootInventory {
|
||||||
|
|
||||||
|
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
||||||
|
|
||||||
|
private Inventory inventory;
|
||||||
|
private InventoryView inventoryView;
|
||||||
|
private Player player;
|
||||||
|
|
||||||
|
private long time;
|
||||||
|
|
||||||
|
public DLootInventory(Player player, ItemStack[] istacks) {
|
||||||
|
plugin.getDLootInventories().add(this);
|
||||||
|
|
||||||
|
inventory = Bukkit.createInventory(player, 54, DungeonsXL.getPlugin().getDMessages().get("Player_Treasures"));
|
||||||
|
for (ItemStack istack : istacks) {
|
||||||
|
if (istack != null) {
|
||||||
|
inventory.addItem(istack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DLootInventory get(Player player) {
|
||||||
|
for (DLootInventory inventory : plugin.getDLootInventories()) {
|
||||||
|
if (inventory.player == player) {
|
||||||
|
return inventory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the inventory
|
||||||
|
*/
|
||||||
|
public Inventory getInventory() {
|
||||||
|
return inventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param inventory
|
||||||
|
* the inventory to set
|
||||||
|
*/
|
||||||
|
public void setInventory(Inventory inventory) {
|
||||||
|
this.inventory = inventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the inventoryView
|
||||||
|
*/
|
||||||
|
public InventoryView getInventoryView() {
|
||||||
|
return inventoryView;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param inventoryView
|
||||||
|
* the inventoryView to set
|
||||||
|
*/
|
||||||
|
public void setInventoryView(InventoryView inventoryView) {
|
||||||
|
this.inventoryView = inventoryView;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the player
|
||||||
|
*/
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param player
|
||||||
|
* the player to set
|
||||||
|
*/
|
||||||
|
public void setPlayer(Player player) {
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the time
|
||||||
|
*/
|
||||||
|
public long getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param time
|
||||||
|
* the time to set
|
||||||
|
*/
|
||||||
|
public void setTime(long time) {
|
||||||
|
this.time = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
36
src/io/github/dre2n/dungeonsxl/dungeon/Dungeon.java
Normal file
36
src/io/github/dre2n/dungeonsxl/dungeon/Dungeon.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.dungeon;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class Dungeon {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private DungeonConfig config;
|
||||||
|
|
||||||
|
public Dungeon(File file) {
|
||||||
|
this.name = file.getName().replaceAll(".yml", "");
|
||||||
|
this.config = new DungeonConfig(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dungeon(String name) {
|
||||||
|
this.name = name;
|
||||||
|
this.config = new DungeonConfig(new File(DungeonsXL.getPlugin().getDataFolder() + "/dungeons", name + ".yml"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the config
|
||||||
|
*/
|
||||||
|
public DungeonConfig getConfig() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
134
src/io/github/dre2n/dungeonsxl/dungeon/DungeonConfig.java
Normal file
134
src/io/github/dre2n/dungeonsxl/dungeon/DungeonConfig.java
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.dungeon;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
|
public class DungeonConfig extends WorldConfig {
|
||||||
|
|
||||||
|
private String startFloor;
|
||||||
|
private String endFloor;
|
||||||
|
private List<String> floors = new ArrayList<String>();
|
||||||
|
private int floorCount;
|
||||||
|
private boolean removeWhenPlayed;
|
||||||
|
|
||||||
|
public DungeonConfig(File file) {
|
||||||
|
super(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DungeonConfig(ConfigurationSection configFile) {
|
||||||
|
super(configFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(ConfigurationSection configFile) {
|
||||||
|
super.load(configFile);
|
||||||
|
|
||||||
|
/* Floors */
|
||||||
|
if (configFile.contains("floors")) {
|
||||||
|
floors = configFile.getStringList("floors");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configFile.contains("startFloor")) {
|
||||||
|
startFloor = configFile.getString("startFloor");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configFile.contains("endFloor")) {
|
||||||
|
startFloor = configFile.getString("endFloor");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configFile.contains("floorCount")) {
|
||||||
|
floorCount = configFile.getInt("floorCount");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configFile.contains("removeWhenPlayed")) {
|
||||||
|
removeWhenPlayed = configFile.getBoolean("removeWhenPlayed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the startFloor
|
||||||
|
*/
|
||||||
|
public String getStartFloor() {
|
||||||
|
return startFloor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param startFloor
|
||||||
|
* the startFloor to set
|
||||||
|
*/
|
||||||
|
public void setStartFloor(String startFloor) {
|
||||||
|
this.startFloor = startFloor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the endFloor
|
||||||
|
*/
|
||||||
|
public String getEndFloor() {
|
||||||
|
return endFloor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param endFloor
|
||||||
|
* the endFloor to set
|
||||||
|
*/
|
||||||
|
public void setEndFloor(String endFloor) {
|
||||||
|
this.endFloor = endFloor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the floors
|
||||||
|
*/
|
||||||
|
public List<String> getFloors() {
|
||||||
|
return floors;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param gameWorld
|
||||||
|
* the gameWorld to add
|
||||||
|
*/
|
||||||
|
public void addFloor(String gameWorld) {
|
||||||
|
floors.add(gameWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param gameWorld
|
||||||
|
* the gameWorld to remove
|
||||||
|
*/
|
||||||
|
public void removeFloor(String gameWorld) {
|
||||||
|
floors.remove(gameWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the floorCount
|
||||||
|
*/
|
||||||
|
public int getFloorCount() {
|
||||||
|
return floorCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param floorCount
|
||||||
|
* the floorCount to set
|
||||||
|
*/
|
||||||
|
public void setFloorCount(int floorCount) {
|
||||||
|
this.floorCount = floorCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the removeWhenPlayed
|
||||||
|
*/
|
||||||
|
public boolean isRemoveWhenPlayed() {
|
||||||
|
return removeWhenPlayed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param removeWhenPlayed
|
||||||
|
* the removeWhenPlayed to set
|
||||||
|
*/
|
||||||
|
public void setRemoveWhenPlayed(boolean removeWhenPlayed) {
|
||||||
|
this.removeWhenPlayed = removeWhenPlayed;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
59
src/io/github/dre2n/dungeonsxl/dungeon/Dungeons.java
Normal file
59
src/io/github/dre2n/dungeonsxl/dungeon/Dungeons.java
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.dungeon;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Dungeons {
|
||||||
|
|
||||||
|
private List<Dungeon> dungeons = new ArrayList<Dungeon>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the dungeons
|
||||||
|
*/
|
||||||
|
public List<Dungeon> getDungeons() {
|
||||||
|
return dungeons;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* the name of the Dungeon
|
||||||
|
* @return the Dungeon that has the name
|
||||||
|
*/
|
||||||
|
public Dungeon getDungeon(String name) {
|
||||||
|
for (Dungeon dungeon : dungeons) {
|
||||||
|
if (dungeon.getName().equals(name)) {
|
||||||
|
return dungeon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* the name of the Dungeon
|
||||||
|
* @return the Dungeon that has the name
|
||||||
|
*/
|
||||||
|
public Dungeon loadDungeon(String name) {
|
||||||
|
Dungeon dungeon = new Dungeon(name);
|
||||||
|
dungeons.add(dungeon);
|
||||||
|
return dungeon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dungeon
|
||||||
|
* the dungeon to add
|
||||||
|
*/
|
||||||
|
public void addDungeon(Dungeon dungeon) {
|
||||||
|
dungeons.add(dungeon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dungeon
|
||||||
|
* the dungeon to remove
|
||||||
|
*/
|
||||||
|
public void removeDungeon(Dungeon dungeon) {
|
||||||
|
dungeons.remove(dungeon);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,273 +1,277 @@
|
|||||||
package com.dre.dungeonsxl;
|
package io.github.dre2n.dungeonsxl.dungeon;
|
||||||
|
|
||||||
import java.io.File;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import java.io.FileInputStream;
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
import java.io.FileNotFoundException;
|
import io.github.dre2n.dungeonsxl.util.FileUtil;
|
||||||
import java.io.FileOutputStream;
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
import java.io.File;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.FileInputStream;
|
||||||
import java.util.UUID;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import org.bukkit.Location;
|
import java.io.ObjectInputStream;
|
||||||
import org.bukkit.World;
|
import java.io.ObjectOutputStream;
|
||||||
import org.bukkit.WorldCreator;
|
import java.util.UUID;
|
||||||
import org.bukkit.WorldType;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
public class EditWorld {
|
import org.bukkit.WorldType;
|
||||||
private static P p = P.p;
|
import org.bukkit.block.Block;
|
||||||
public static CopyOnWriteArrayList<EditWorld> eworlds = new CopyOnWriteArrayList<EditWorld>();
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
// Variables
|
|
||||||
public World world;
|
public class EditWorld {
|
||||||
public String owner;
|
|
||||||
public String name;
|
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
||||||
public String dungeonname;
|
|
||||||
public int id;
|
// Variables
|
||||||
public Location lobby;
|
public World world;
|
||||||
public CopyOnWriteArrayList<String> invitedPlayers = new CopyOnWriteArrayList<String>();
|
public String owner;
|
||||||
public CopyOnWriteArrayList<Block> sign = new CopyOnWriteArrayList<Block>();
|
public String name;
|
||||||
|
public String dungeonname;
|
||||||
public EditWorld() {
|
public int id;
|
||||||
eworlds.add(this);
|
public Location lobby;
|
||||||
|
public CopyOnWriteArrayList<String> invitedPlayers = new CopyOnWriteArrayList<String>();
|
||||||
// ID
|
public CopyOnWriteArrayList<Block> sign = new CopyOnWriteArrayList<Block>();
|
||||||
this.id = -1;
|
|
||||||
int i = -1;
|
public EditWorld() {
|
||||||
while (this.id == -1) {
|
plugin.getEditWorlds().add(this);
|
||||||
i++;
|
|
||||||
boolean exist = false;
|
// ID
|
||||||
for (EditWorld eworld : eworlds) {
|
id = -1;
|
||||||
if (eworld.id == i) {
|
int i = -1;
|
||||||
exist = true;
|
while (id == -1) {
|
||||||
break;
|
i++;
|
||||||
}
|
boolean exist = false;
|
||||||
}
|
for (EditWorld eworld : plugin.getEditWorlds()) {
|
||||||
if (!exist)
|
if (eworld.id == i) {
|
||||||
this.id = i;
|
exist = true;
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
name = "DXL_Edit_" + this.id;
|
}
|
||||||
}
|
if ( !exist) {
|
||||||
|
id = i;
|
||||||
public void generate() {
|
}
|
||||||
WorldCreator creator = WorldCreator.name(name);
|
}
|
||||||
creator.type(WorldType.FLAT);
|
|
||||||
creator.generateStructures(false);
|
name = "DXL_Edit_" + id;
|
||||||
|
}
|
||||||
this.world = p.getServer().createWorld(creator);
|
|
||||||
}
|
public void generate() {
|
||||||
|
WorldCreator creator = WorldCreator.name(name);
|
||||||
public void save() {
|
creator.type(WorldType.FLAT);
|
||||||
this.world.save();
|
creator.generateStructures(false);
|
||||||
try {
|
|
||||||
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(new File(p.getDataFolder(), "/dungeons/" + this.dungeonname + "/DXLData.data")));
|
world = plugin.getServer().createWorld(creator);
|
||||||
out.writeInt(this.sign.size());
|
}
|
||||||
for (Block sign : this.sign) {
|
|
||||||
out.writeInt(sign.getX());
|
public void save() {
|
||||||
out.writeInt(sign.getY());
|
world.save();
|
||||||
out.writeInt(sign.getZ());
|
|
||||||
}
|
try {
|
||||||
out.close();
|
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(new File(plugin.getDataFolder(), "/maps/" + dungeonname + "/DXLData.data")));
|
||||||
|
out.writeInt(sign.size());
|
||||||
} catch (FileNotFoundException e) {
|
for (Block sign : this.sign) {
|
||||||
e.printStackTrace();
|
out.writeInt(sign.getX());
|
||||||
} catch (IOException e) {
|
out.writeInt(sign.getY());
|
||||||
e.printStackTrace();
|
out.writeInt(sign.getZ());
|
||||||
}
|
}
|
||||||
}
|
out.close();
|
||||||
|
} catch (IOException exception) {
|
||||||
public void checkSign(Block block) {
|
}
|
||||||
if ((block.getState() instanceof Sign)) {
|
}
|
||||||
Sign sign = (Sign) block.getState();
|
|
||||||
String[] lines = sign.getLines();
|
public void checkSign(Block block) {
|
||||||
|
if (block.getState() instanceof Sign) {
|
||||||
if (lines[0].equalsIgnoreCase("[lobby]")) {
|
Sign sign = (Sign) block.getState();
|
||||||
this.lobby = block.getLocation();
|
String[] lines = sign.getLines();
|
||||||
}
|
|
||||||
}
|
if (lines[0].equalsIgnoreCase("[lobby]")) {
|
||||||
}
|
lobby = block.getLocation();
|
||||||
|
}
|
||||||
public void delete() {
|
}
|
||||||
eworlds.remove(this);
|
}
|
||||||
for (Player player : this.world.getPlayers()) {
|
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
public void delete() {
|
||||||
dplayer.leave();
|
plugin.getEditWorlds().remove(this);
|
||||||
}
|
for (Player player : world.getPlayers()) {
|
||||||
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
p.getServer().unloadWorld(this.world, true);
|
dplayer.leave();
|
||||||
File dir = new File("DXL_Edit_" + this.id);
|
}
|
||||||
p.copyDirectory(dir, new File(p.getDataFolder(), "/dungeons/" + this.dungeonname));
|
|
||||||
p.deletenotusingfiles(new File(p.getDataFolder(), "/dungeons/" + this.dungeonname));
|
plugin.getServer().unloadWorld(world, true);
|
||||||
p.removeDirectory(dir);
|
File dir = new File("DXL_Edit_" + id);
|
||||||
}
|
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + dungeonname));
|
||||||
|
FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + dungeonname));
|
||||||
public void deleteNoSave() {
|
FileUtil.removeDirectory(dir);
|
||||||
eworlds.remove(this);
|
}
|
||||||
for (Player player : this.world.getPlayers()) {
|
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
public void deleteNoSave() {
|
||||||
dplayer.leave();
|
plugin.getEditWorlds().remove(this);
|
||||||
}
|
for (Player player : world.getPlayers()) {
|
||||||
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
File dir = new File("DXL_Edit_" + this.id);
|
dplayer.leave();
|
||||||
p.copyDirectory(dir, new File(p.getDataFolder(), "/dungeons/" + this.dungeonname));
|
}
|
||||||
p.deletenotusingfiles(new File(p.getDataFolder(), "/dungeons/" + this.dungeonname));
|
|
||||||
p.getServer().unloadWorld(this.world, true);
|
File dir = new File("DXL_Edit_" + id);
|
||||||
p.removeDirectory(dir);
|
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + dungeonname));
|
||||||
}
|
FileUtil.deletenotusingfiles(new File(plugin.getDataFolder(), "/maps/" + dungeonname));
|
||||||
|
plugin.getServer().unloadWorld(world, true);
|
||||||
// Static
|
FileUtil.removeDirectory(dir);
|
||||||
public static EditWorld get(World world) {
|
}
|
||||||
for (EditWorld eworld : eworlds) {
|
|
||||||
if (eworld.world.equals(world)) {
|
// Static
|
||||||
return eworld;
|
public static EditWorld get(World world) {
|
||||||
}
|
for (EditWorld eworld : plugin.getEditWorlds()) {
|
||||||
}
|
if (eworld.world.equals(world)) {
|
||||||
|
return eworld;
|
||||||
return null;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EditWorld get(String name) {
|
return null;
|
||||||
for (EditWorld eworld : eworlds) {
|
}
|
||||||
if (eworld.dungeonname.equalsIgnoreCase(name)) {
|
|
||||||
return eworld;
|
public static EditWorld get(String name) {
|
||||||
}
|
for (EditWorld eworld : plugin.getEditWorlds()) {
|
||||||
}
|
if (eworld.dungeonname.equalsIgnoreCase(name)) {
|
||||||
|
return eworld;
|
||||||
return null;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteAll() {
|
return null;
|
||||||
for (EditWorld eworld : eworlds) {
|
}
|
||||||
eworld.delete();
|
|
||||||
}
|
public static void deleteAll() {
|
||||||
}
|
for (EditWorld eworld : plugin.getEditWorlds()) {
|
||||||
|
eworld.delete();
|
||||||
public static EditWorld load(String name) {
|
}
|
||||||
for (EditWorld eworld : eworlds) {
|
}
|
||||||
|
|
||||||
if (eworld.dungeonname.equalsIgnoreCase(name)) {
|
public static EditWorld load(String name) {
|
||||||
return eworld;
|
for (EditWorld eworld : plugin.getEditWorlds()) {
|
||||||
}
|
|
||||||
}
|
if (eworld.dungeonname.equalsIgnoreCase(name)) {
|
||||||
|
return eworld;
|
||||||
File file = new File(p.getDataFolder(), "/dungeons/" + name);
|
}
|
||||||
|
}
|
||||||
if (file.exists()) {
|
|
||||||
EditWorld eworld = new EditWorld();
|
File file = new File(plugin.getDataFolder(), "/maps/" + name);
|
||||||
eworld.dungeonname = name;
|
|
||||||
// World
|
if (file.exists()) {
|
||||||
p.copyDirectory(file, new File("DXL_Edit_" + eworld.id));
|
EditWorld eworld = new EditWorld();
|
||||||
|
eworld.dungeonname = name;
|
||||||
// Id File
|
// World
|
||||||
File idFile = new File("DXL_Edit_" + eworld.id + "/.id_" + name);
|
FileUtil.copyDirectory(file, new File("DXL_Edit_" + eworld.id));
|
||||||
try {
|
|
||||||
idFile.createNewFile();
|
// Id File
|
||||||
} catch (IOException e) {
|
File idFile = new File("DXL_Edit_" + eworld.id + "/.id_" + name);
|
||||||
e.printStackTrace();
|
try {
|
||||||
}
|
idFile.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
eworld.world = p.getServer().createWorld(WorldCreator.name("DXL_Edit_" + eworld.id));
|
e.printStackTrace();
|
||||||
|
}
|
||||||
try {
|
|
||||||
ObjectInputStream os = new ObjectInputStream(new FileInputStream(new File(p.getDataFolder(), "/dungeons/" + eworld.dungeonname + "/DXLData.data")));
|
eworld.world = plugin.getServer().createWorld(WorldCreator.name("DXL_Edit_" + eworld.id));
|
||||||
int length = os.readInt();
|
|
||||||
for (int i = 0; i < length; i++) {
|
try {
|
||||||
int x = os.readInt();
|
ObjectInputStream os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder(), "/maps/" + eworld.dungeonname + "/DXLData.data")));
|
||||||
int y = os.readInt();
|
int length = os.readInt();
|
||||||
int z = os.readInt();
|
for (int i = 0; i < length; i++) {
|
||||||
Block block = eworld.world.getBlockAt(x, y, z);
|
int x = os.readInt();
|
||||||
eworld.checkSign(block);
|
int y = os.readInt();
|
||||||
eworld.sign.add(block);
|
int z = os.readInt();
|
||||||
}
|
Block block = eworld.world.getBlockAt(x, y, z);
|
||||||
os.close();
|
eworld.checkSign(block);
|
||||||
|
eworld.sign.add(block);
|
||||||
} catch (FileNotFoundException e) {
|
}
|
||||||
e.printStackTrace();
|
os.close();
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
} catch (FileNotFoundException e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
return eworld;
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return eworld;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean exist(String name) {
|
return null;
|
||||||
// Cheack Loaded EditWorlds
|
}
|
||||||
for (EditWorld eworld : eworlds) {
|
|
||||||
if (eworld.dungeonname.equalsIgnoreCase(name)) {
|
public static boolean exist(String name) {
|
||||||
return true;
|
// Cheack Loaded EditWorlds
|
||||||
}
|
for (EditWorld eworld : plugin.getEditWorlds()) {
|
||||||
}
|
if (eworld.dungeonname.equalsIgnoreCase(name)) {
|
||||||
|
return true;
|
||||||
// Cheack Unloaded Worlds
|
}
|
||||||
File file = new File(p.getDataFolder(), "/dungeons/" + name);
|
}
|
||||||
|
|
||||||
if (file.exists()) {
|
// Cheack Unloaded Worlds
|
||||||
return true;
|
File file = new File(plugin.getDataFolder(), "/maps/" + name);
|
||||||
}
|
|
||||||
|
if (file.exists()) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void msg(String msg) {
|
return false;
|
||||||
for (DPlayer dplayer : DPlayer.get(this.world)) {
|
}
|
||||||
p.msg(dplayer.player, msg);
|
|
||||||
}
|
public void msg(String msg) {
|
||||||
}
|
for (DPlayer dplayer : DPlayer.get(world)) {
|
||||||
|
MessageUtil.sendMessage(dplayer.player, msg);
|
||||||
// Invite
|
}
|
||||||
public static boolean addInvitedPlayer(String eworldname, UUID uuid) {
|
}
|
||||||
if (exist(eworldname)) {
|
|
||||||
DConfig config = new DConfig(new File(p.getDataFolder() + "/dungeons/" + eworldname, "config.yml"));
|
// Invite
|
||||||
config.addInvitedPlayer(uuid.toString());
|
public static boolean addInvitedPlayer(String eworldname, UUID uuid) {
|
||||||
config.save();
|
if (exist(eworldname)) {
|
||||||
return true;
|
WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + eworldname, "config.yml"));
|
||||||
}
|
config.addInvitedPlayer(uuid.toString());
|
||||||
|
config.save();
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean removeInvitedPlayer(String eworldname, UUID uuid, String name) {
|
return false;
|
||||||
|
}
|
||||||
if (exist(eworldname)) {
|
|
||||||
DConfig config = new DConfig(new File(p.getDataFolder() + "/dungeons/" + eworldname, "config.yml"));
|
public static boolean removeInvitedPlayer(String eworldname, UUID uuid, String name) {
|
||||||
config.removeInvitedPlayers(uuid.toString(), name.toLowerCase());
|
|
||||||
config.save();
|
if (exist(eworldname)) {
|
||||||
|
WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + eworldname, "config.yml"));
|
||||||
// Kick Player
|
config.removeInvitedPlayers(uuid.toString(), name.toLowerCase());
|
||||||
EditWorld eworld = EditWorld.get(eworldname);
|
config.save();
|
||||||
if (eworld != null) {
|
|
||||||
DPlayer player = DPlayer.get(name);
|
// Kick Player
|
||||||
|
EditWorld eworld = EditWorld.get(eworldname);
|
||||||
if (player != null) {
|
if (eworld != null) {
|
||||||
if (eworld.world.getPlayers().contains(player.player)) {
|
DPlayer player = DPlayer.get(name);
|
||||||
player.leave();
|
|
||||||
}
|
if (player != null) {
|
||||||
}
|
if (eworld.world.getPlayers().contains(player.player)) {
|
||||||
}
|
player.leave();
|
||||||
|
}
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInvitedPlayer(String eworldname, UUID uuid, String name) {
|
return false;
|
||||||
if (exist(eworldname)) {
|
}
|
||||||
DConfig config = new DConfig(new File(p.getDataFolder() + "/dungeons/" + eworldname, "config.yml"));
|
|
||||||
// get player from both a 0.9.1 and lower and 0.9.2 and higher file
|
public static boolean isInvitedPlayer(String eworldname, UUID uuid, String name) {
|
||||||
if (config.getInvitedPlayers().contains(name.toLowerCase()) || config.getInvitedPlayers().contains(uuid.toString()))
|
if (exist(eworldname)) {
|
||||||
return true;
|
WorldConfig config = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + eworldname, "config.yml"));
|
||||||
}
|
// get player from both a 0.9.1 and lower and 0.9.2 and higher file
|
||||||
|
if (config.getInvitedPlayers().contains(name.toLowerCase()) || config.getInvitedPlayers().contains(uuid.toString())) {
|
||||||
return false;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,414 +1,419 @@
|
|||||||
package com.dre.dungeonsxl;
|
package io.github.dre2n.dungeonsxl.dungeon;
|
||||||
|
|
||||||
import java.io.File;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import java.io.IOException;
|
import io.github.dre2n.dungeonsxl.mob.DMobType;
|
||||||
import java.util.HashMap;
|
import io.github.dre2n.dungeonsxl.player.DClass;
|
||||||
import java.util.HashSet;
|
import io.github.dre2n.dungeonsxl.util.IntegerUtil;
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
import java.io.File;
|
||||||
import java.util.Map;
|
import java.io.IOException;
|
||||||
import java.util.Set;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import org.bukkit.Material;
|
import java.util.List;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import java.util.Map;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import java.util.Set;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
public class DConfig {
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
public static DConfig mainConfig = new DConfig();
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
private File file;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
private boolean keepInventory = false;
|
public class WorldConfig {
|
||||||
private boolean keepInventoryOnEnter = false;
|
|
||||||
private boolean keepInventoryOnEscape = false;
|
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
||||||
private boolean keepInventoryOnFinish = false;
|
|
||||||
private boolean keepInventoryOnDeath = true;
|
public static WorldConfig defaultConfig = new WorldConfig();
|
||||||
|
|
||||||
private CopyOnWriteArrayList<DClass> dClasses = new CopyOnWriteArrayList<DClass>();
|
private File file;
|
||||||
private Map<Integer, String> msgs = new HashMap<Integer, String>();
|
|
||||||
|
private boolean keepInventory = false;
|
||||||
private CopyOnWriteArrayList<String> invitedPlayers = new CopyOnWriteArrayList<String>();
|
private boolean keepInventoryOnEnter = false;
|
||||||
private CopyOnWriteArrayList<Material> secureObjects = new CopyOnWriteArrayList<Material>();
|
private boolean keepInventoryOnEscape = false;
|
||||||
|
private boolean keepInventoryOnFinish = false;
|
||||||
private int initialLives = 3;
|
private boolean keepInventoryOnDeath = true;
|
||||||
|
|
||||||
private boolean isLobbyDisabled = false;
|
private CopyOnWriteArrayList<DClass> dClasses = new CopyOnWriteArrayList<DClass>();
|
||||||
private int timeToNextPlay = 0;
|
private Map<Integer, String> msgs = new HashMap<Integer, String>();
|
||||||
private int timeToNextLoot = 0;
|
|
||||||
|
private CopyOnWriteArrayList<String> invitedPlayers = new CopyOnWriteArrayList<String>();
|
||||||
private int timeUntilKickOfflinePlayer = -1;
|
private CopyOnWriteArrayList<Material> secureObjects = new CopyOnWriteArrayList<Material>();
|
||||||
|
|
||||||
private double fee = 0;
|
private int initialLives = 3;
|
||||||
|
|
||||||
private List<String> finishedOne;
|
private boolean isLobbyDisabled = false;
|
||||||
private List<String> finishedAll;
|
private int timeToNextPlay = 0;
|
||||||
private int timeLastPlayed = 0;
|
private int timeToNextLoot = 0;
|
||||||
|
|
||||||
// MobTypes
|
private int timeUntilKickOfflinePlayer = -1;
|
||||||
private Set<DMobType> mobTypes = new HashSet<DMobType>();
|
|
||||||
|
private double fee = 0;
|
||||||
public DConfig() {
|
|
||||||
|
private List<String> finishedOne;
|
||||||
}
|
private List<String> finishedAll;
|
||||||
|
private int timeLastPlayed = 0;
|
||||||
public DConfig(File file) {
|
|
||||||
this.file = file;
|
// MobTypes
|
||||||
|
private Set<DMobType> mobTypes = new HashSet<DMobType>();
|
||||||
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
|
|
||||||
|
public WorldConfig() {
|
||||||
load(configFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DConfig(ConfigurationSection configFile) {
|
public WorldConfig(File file) {
|
||||||
load(configFile);
|
this.file = file;
|
||||||
}
|
|
||||||
|
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
|
||||||
// Load & Save
|
|
||||||
public void load(ConfigurationSection configFile) {
|
load(configFile);
|
||||||
|
}
|
||||||
/* Classes */
|
|
||||||
ConfigurationSection configSetionClasses = configFile.getConfigurationSection("classes");
|
public WorldConfig(ConfigurationSection configFile) {
|
||||||
if (configSetionClasses != null) {
|
load(configFile);
|
||||||
Set<String> list = configSetionClasses.getKeys(false);
|
}
|
||||||
for (String className : list) {
|
|
||||||
String name = className;
|
// Load & Save
|
||||||
boolean hasDog = configSetionClasses.getBoolean(className + ".dog");
|
@SuppressWarnings("deprecation")
|
||||||
|
public void load(ConfigurationSection configFile) {
|
||||||
/* Items */
|
/* Classes */
|
||||||
List<String> items = configSetionClasses.getStringList(className + ".items");
|
ConfigurationSection configSetionClasses = configFile.getConfigurationSection("classes");
|
||||||
CopyOnWriteArrayList<ItemStack> istacks = new CopyOnWriteArrayList<ItemStack>();
|
if (configSetionClasses != null) {
|
||||||
|
Set<String> list = configSetionClasses.getKeys(false);
|
||||||
for (String item : items) {
|
for (String className : list) {
|
||||||
String[] itemsplit = item.split(",");
|
String name = className;
|
||||||
if (itemsplit.length > 0) {
|
boolean hasDog = configSetionClasses.getBoolean(className + ".dog");
|
||||||
int itemId = 0, itemData = 0, itemSize = 1, itemLvlEnchantment = 1;
|
/* Items */
|
||||||
Enchantment itemEnchantment = null;
|
List<String> items = configSetionClasses.getStringList(className + ".items");
|
||||||
|
CopyOnWriteArrayList<ItemStack> istacks = new CopyOnWriteArrayList<ItemStack>();
|
||||||
// Check Id & Data
|
|
||||||
String[] idAndData = itemsplit[0].split("/");
|
for (String item : items) {
|
||||||
itemId = P.p.parseInt(idAndData[0]);
|
String[] itemsplit = item.split(",");
|
||||||
|
if (itemsplit.length > 0) {
|
||||||
if (idAndData.length > 1) {
|
int itemId = 0, itemData = 0, itemSize = 1, itemLvlEnchantment = 1;
|
||||||
itemData = P.p.parseInt(idAndData[1]);
|
Enchantment itemEnchantment = null;
|
||||||
}
|
// Check Id & Data
|
||||||
|
String[] idAndData = itemsplit[0].split("/");
|
||||||
// Size
|
itemId = IntegerUtil.parseInt(idAndData[0]);
|
||||||
if (itemsplit.length > 1) {
|
|
||||||
itemSize = P.p.parseInt(itemsplit[1]);
|
if (idAndData.length > 1) {
|
||||||
}
|
itemData = IntegerUtil.parseInt(idAndData[1]);
|
||||||
|
}
|
||||||
// Enchantment
|
|
||||||
if (itemsplit.length > 2) {
|
// Size
|
||||||
String[] enchantmentSplit = itemsplit[2].split("/");
|
if (itemsplit.length > 1) {
|
||||||
|
itemSize = IntegerUtil.parseInt(itemsplit[1]);
|
||||||
itemEnchantment = Enchantment.getByName(enchantmentSplit[0]);
|
}
|
||||||
|
// Enchantment
|
||||||
if (enchantmentSplit.length > 1) {
|
if (itemsplit.length > 2) {
|
||||||
itemLvlEnchantment = P.p.parseInt(enchantmentSplit[1]);
|
String[] enchantmentSplit = itemsplit[2].split("/");
|
||||||
}
|
|
||||||
}
|
itemEnchantment = Enchantment.getByName(enchantmentSplit[0]);
|
||||||
|
|
||||||
// Add Item to Stacks
|
if (enchantmentSplit.length > 1) {
|
||||||
ItemStack istack = new ItemStack(itemId, itemSize, (short) itemData);
|
itemLvlEnchantment = IntegerUtil.parseInt(enchantmentSplit[1]);
|
||||||
if (itemEnchantment != null) {
|
}
|
||||||
istack.addEnchantment(itemEnchantment, itemLvlEnchantment);
|
}
|
||||||
}
|
|
||||||
|
// Add Item to Stacks
|
||||||
istacks.add(istack);
|
ItemStack istack = new ItemStack(itemId, itemSize, (short) itemData);
|
||||||
}
|
if (itemEnchantment != null) {
|
||||||
}
|
istack.addEnchantment(itemEnchantment, itemLvlEnchantment);
|
||||||
|
}
|
||||||
/* Create Class */
|
istacks.add(istack);
|
||||||
this.dClasses.add(new DClass(name, istacks, hasDog));
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/* Create Class */
|
||||||
/* Messages */
|
dClasses.add(new DClass(name, istacks, hasDog));
|
||||||
ConfigurationSection configSetionMessages = configFile.getConfigurationSection("message");
|
}
|
||||||
if (configSetionMessages != null) {
|
}
|
||||||
Set<String> list = configSetionMessages.getKeys(false);
|
|
||||||
for (String messagePath : list) {
|
/* Messages */
|
||||||
int messageId = P.p.parseInt(messagePath);
|
ConfigurationSection configSetionMessages = configFile.getConfigurationSection("message");
|
||||||
this.msgs.put(messageId, configSetionMessages.getString(messagePath));
|
if (configSetionMessages != null) {
|
||||||
}
|
Set<String> list = configSetionMessages.getKeys(false);
|
||||||
}
|
for (String messagePath : list) {
|
||||||
|
int messageId = IntegerUtil.parseInt(messagePath);
|
||||||
/* Secure Objects */
|
msgs.put(messageId, configSetionMessages.getString(messagePath));
|
||||||
if (configFile.contains("secureObjects")) {
|
}
|
||||||
List<Integer> secureobjectlist = configFile.getIntegerList("secureObjects");
|
}
|
||||||
for (int i : secureobjectlist) {
|
|
||||||
this.secureObjects.add(Material.getMaterial(i));
|
/* Secure Objects */
|
||||||
}
|
if (configFile.contains("secureObjects")) {
|
||||||
}
|
List<Integer> secureobjectlist = configFile.getIntegerList("secureObjects");
|
||||||
|
for (int i : secureobjectlist) {
|
||||||
/* Invited Players */
|
secureObjects.add(Material.getMaterial(i));
|
||||||
if (configFile.contains("invitedPlayers")) {
|
}
|
||||||
List<String> invitedplayers = configFile.getStringList("invitedPlayers");
|
}
|
||||||
for (String i : invitedplayers) {
|
|
||||||
this.invitedPlayers.add(i);
|
/* Invited Players */
|
||||||
}
|
if (configFile.contains("invitedPlayers")) {
|
||||||
}
|
List<String> invitedplayers = configFile.getStringList("invitedPlayers");
|
||||||
|
for (String i : invitedplayers) {
|
||||||
/* Keep Inventory */
|
invitedPlayers.add(i);
|
||||||
if (configFile.contains("keepInventory")) {
|
}
|
||||||
if (!configFile.contains("keepInventoryOnEnter")) {
|
}
|
||||||
keepInventoryOnEnter = configFile.getBoolean("keepInventory");
|
|
||||||
}
|
/* Keep Inventory */
|
||||||
if (!configFile.contains("keepInventoryOnEscape")) {
|
if (configFile.contains("keepInventory")) {
|
||||||
keepInventoryOnEscape = configFile.getBoolean("keepInventory");
|
if ( !configFile.contains("keepInventoryOnEnter")) {
|
||||||
}
|
keepInventoryOnEnter = configFile.getBoolean("keepInventory");
|
||||||
if (!configFile.contains("keepInventoryOnFinish")) {
|
}
|
||||||
keepInventoryOnFinish = configFile.getBoolean("keepInventory");
|
if ( !configFile.contains("keepInventoryOnEscape")) {
|
||||||
}
|
keepInventoryOnEscape = configFile.getBoolean("keepInventory");
|
||||||
} else {
|
}
|
||||||
if (mainConfig.keepInventory) {
|
if ( !configFile.contains("keepInventoryOnFinish")) {
|
||||||
keepInventoryOnEnter = mainConfig.keepInventory;
|
keepInventoryOnFinish = configFile.getBoolean("keepInventory");
|
||||||
keepInventoryOnEscape = mainConfig.keepInventory;
|
}
|
||||||
keepInventoryOnFinish = mainConfig.keepInventory;
|
} else {
|
||||||
}
|
if (plugin.getDefaultConfig().keepInventory) {
|
||||||
}
|
keepInventoryOnEnter = plugin.getDefaultConfig().keepInventory;
|
||||||
|
keepInventoryOnEscape = plugin.getDefaultConfig().keepInventory;
|
||||||
if (configFile.contains("keepInventoryOnEnter")) {
|
keepInventoryOnFinish = plugin.getDefaultConfig().keepInventory;
|
||||||
keepInventoryOnEnter = configFile.getBoolean("keepInventoryOnEnter");
|
}
|
||||||
} else {
|
}
|
||||||
keepInventoryOnEnter = mainConfig.keepInventoryOnEnter;
|
|
||||||
}
|
if (configFile.contains("keepInventoryOnEnter")) {
|
||||||
|
keepInventoryOnEnter = configFile.getBoolean("keepInventoryOnEnter");
|
||||||
if (configFile.contains("keepInventoryOnEscape")) {
|
} else {
|
||||||
keepInventoryOnEscape = configFile.getBoolean("keepInventoryOnEscape");
|
keepInventoryOnEnter = plugin.getDefaultConfig().keepInventoryOnEnter;
|
||||||
} else {
|
}
|
||||||
keepInventoryOnEscape = mainConfig.keepInventoryOnEscape;
|
|
||||||
}
|
if (configFile.contains("keepInventoryOnEscape")) {
|
||||||
|
keepInventoryOnEscape = configFile.getBoolean("keepInventoryOnEscape");
|
||||||
if (configFile.contains("keepInventoryOnFinish")) {
|
} else {
|
||||||
keepInventoryOnFinish = configFile.getBoolean("keepInventoryOnFinish");
|
keepInventoryOnEscape = plugin.getDefaultConfig().keepInventoryOnEscape;
|
||||||
} else {
|
}
|
||||||
keepInventoryOnFinish = mainConfig.keepInventoryOnFinish;
|
|
||||||
}
|
if (configFile.contains("keepInventoryOnFinish")) {
|
||||||
|
keepInventoryOnFinish = configFile.getBoolean("keepInventoryOnFinish");
|
||||||
if (configFile.contains("keepInventoryOnDeath")) {
|
} else {
|
||||||
keepInventoryOnDeath = configFile.getBoolean("keepInventoryOnDeath");
|
keepInventoryOnFinish = plugin.getDefaultConfig().keepInventoryOnFinish;
|
||||||
} else {
|
}
|
||||||
keepInventoryOnDeath = mainConfig.keepInventoryOnDeath;
|
|
||||||
}
|
if (configFile.contains("keepInventoryOnDeath")) {
|
||||||
|
keepInventoryOnDeath = configFile.getBoolean("keepInventoryOnDeath");
|
||||||
/* Lives */
|
} else {
|
||||||
if (configFile.contains("initialLives")) {
|
keepInventoryOnDeath = plugin.getDefaultConfig().keepInventoryOnDeath;
|
||||||
initialLives = configFile.getInt("initialLives");
|
}
|
||||||
} else {
|
|
||||||
initialLives = mainConfig.getInitialLives();
|
/* Lives */
|
||||||
}
|
if (configFile.contains("initialLives")) {
|
||||||
|
initialLives = configFile.getInt("initialLives");
|
||||||
/* Lobby */
|
} else {
|
||||||
if (configFile.contains("isLobbyDisabled")) {
|
initialLives = plugin.getDefaultConfig().getInitialLives();
|
||||||
isLobbyDisabled = configFile.getBoolean("isLobbyDisabled");
|
}
|
||||||
} else {
|
|
||||||
isLobbyDisabled = mainConfig.isLobbyDisabled;
|
/* Lobby */
|
||||||
}
|
if (configFile.contains("isLobbyDisabled")) {
|
||||||
|
isLobbyDisabled = configFile.getBoolean("isLobbyDisabled");
|
||||||
/* Times */
|
} else {
|
||||||
if (configFile.contains("timeToNextPlay")) {
|
isLobbyDisabled = plugin.getDefaultConfig().isLobbyDisabled;
|
||||||
timeToNextPlay = configFile.getInt("timeToNextPlay");
|
}
|
||||||
} else {
|
|
||||||
timeToNextPlay = mainConfig.timeToNextPlay;
|
/* Times */
|
||||||
}
|
if (configFile.contains("timeToNextPlay")) {
|
||||||
|
timeToNextPlay = configFile.getInt("timeToNextPlay");
|
||||||
if (configFile.contains("timeToNextLoot")) {
|
} else {
|
||||||
timeToNextLoot = configFile.getInt("timeToNextLoot");
|
timeToNextPlay = plugin.getDefaultConfig().timeToNextPlay;
|
||||||
} else {
|
}
|
||||||
timeToNextLoot = mainConfig.timeToNextLoot;
|
|
||||||
}
|
if (configFile.contains("timeToNextLoot")) {
|
||||||
|
timeToNextLoot = configFile.getInt("timeToNextLoot");
|
||||||
if (configFile.contains("timeUntilKickOfflinePlayer")) {
|
} else {
|
||||||
timeUntilKickOfflinePlayer = configFile.getInt("timeUntilKickOfflinePlayer");
|
timeToNextLoot = plugin.getDefaultConfig().timeToNextLoot;
|
||||||
} else {
|
}
|
||||||
timeUntilKickOfflinePlayer = mainConfig.timeUntilKickOfflinePlayer;
|
|
||||||
}
|
if (configFile.contains("timeUntilKickOfflinePlayer")) {
|
||||||
|
timeUntilKickOfflinePlayer = configFile.getInt("timeUntilKickOfflinePlayer");
|
||||||
/* Dungeon Requirements */
|
} else {
|
||||||
if (configFile.contains("fee")) {
|
timeUntilKickOfflinePlayer = plugin.getDefaultConfig().timeUntilKickOfflinePlayer;
|
||||||
fee = configFile.getDouble("fee");
|
}
|
||||||
} else {
|
|
||||||
fee = mainConfig.fee;
|
/* Dungeon Requirements */
|
||||||
}
|
if (configFile.contains("fee")) {
|
||||||
|
fee = configFile.getDouble("fee");
|
||||||
if (configFile.contains("mustFinishOne")) {
|
} else {
|
||||||
finishedOne = configFile.getStringList("mustFinishOne");
|
fee = plugin.getDefaultConfig().fee;
|
||||||
} else {
|
}
|
||||||
finishedOne = new ArrayList<String>();
|
|
||||||
}
|
if (configFile.contains("mustFinishOne")) {
|
||||||
|
finishedOne = configFile.getStringList("mustFinishOne");
|
||||||
if (configFile.contains("mustFinishAll")) {
|
} else {
|
||||||
finishedAll = configFile.getStringList("mustFinishAll");
|
finishedOne = new ArrayList<String>();
|
||||||
} else {
|
}
|
||||||
finishedAll = new ArrayList<String>();
|
|
||||||
}
|
if (configFile.contains("mustFinishAll")) {
|
||||||
|
finishedAll = configFile.getStringList("mustFinishAll");
|
||||||
if (configFile.contains("timeLastPlayed")) {
|
} else {
|
||||||
timeLastPlayed = configFile.getInt("timeLastPlayed");
|
finishedAll = new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mobtypes */
|
if (configFile.contains("timeLastPlayed")) {
|
||||||
configSetionMessages = configFile.getConfigurationSection("mobTypes");
|
timeLastPlayed = configFile.getInt("timeLastPlayed");
|
||||||
this.mobTypes = DMobType.load(configSetionMessages);
|
}
|
||||||
}
|
|
||||||
|
/* Mobtypes */
|
||||||
public void save() {
|
configSetionMessages = configFile.getConfigurationSection("mobTypes");
|
||||||
if (this.file != null) {
|
mobTypes = DMobType.load(configSetionMessages);
|
||||||
FileConfiguration configFile = YamlConfiguration.loadConfiguration(this.file);
|
}
|
||||||
|
|
||||||
// Messages
|
@SuppressWarnings("deprecation")
|
||||||
for (Integer msgs : this.msgs.keySet()) {
|
public void save() {
|
||||||
configFile.set("message." + msgs, this.msgs.get(msgs));
|
if (file != null) {
|
||||||
}
|
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
|
||||||
|
|
||||||
// Secure Objects
|
// Messages
|
||||||
CopyOnWriteArrayList<Integer> secureObjectsids = new CopyOnWriteArrayList<Integer>();
|
for (Integer msgs : this.msgs.keySet()) {
|
||||||
|
configFile.set("message." + msgs, this.msgs.get(msgs));
|
||||||
for (Material mat : this.secureObjects) {
|
}
|
||||||
secureObjectsids.add(mat.getId());
|
|
||||||
}
|
// Secure Objects
|
||||||
|
CopyOnWriteArrayList<Integer> secureObjectsids = new CopyOnWriteArrayList<Integer>();
|
||||||
configFile.set("secureObjects", secureObjectsids);
|
|
||||||
|
for (Material mat : secureObjects) {
|
||||||
// Invited Players
|
secureObjectsids.add(mat.getId());
|
||||||
configFile.set("invitedPlayers", this.invitedPlayers);
|
}
|
||||||
|
|
||||||
try {
|
configFile.set("secureObjects", secureObjectsids);
|
||||||
configFile.save(this.file);
|
|
||||||
} catch (IOException e) {
|
// Invited Players
|
||||||
e.printStackTrace();
|
configFile.set("invitedPlayers", invitedPlayers);
|
||||||
}
|
|
||||||
}
|
try {
|
||||||
}
|
configFile.save(file);
|
||||||
|
} catch (IOException e) {
|
||||||
// Getters and Setters
|
e.printStackTrace();
|
||||||
public CopyOnWriteArrayList<DClass> getClasses() {
|
}
|
||||||
if (this.dClasses != null) {
|
}
|
||||||
if (!this.dClasses.isEmpty()) {
|
}
|
||||||
return this.dClasses;
|
|
||||||
}
|
// Getters and Setters
|
||||||
}
|
public CopyOnWriteArrayList<DClass> getClasses() {
|
||||||
|
if (dClasses != null) {
|
||||||
return mainConfig.dClasses;
|
if ( !dClasses.isEmpty()) {
|
||||||
}
|
return dClasses;
|
||||||
|
}
|
||||||
public DClass getClass(String name) {
|
}
|
||||||
for (DClass dClass : this.dClasses) {
|
|
||||||
if (dClass.name.equals(name)) {
|
return plugin.getDefaultConfig().dClasses;
|
||||||
return dClass;
|
}
|
||||||
}
|
|
||||||
}
|
public DClass getClass(String name) {
|
||||||
|
for (DClass dClass : dClasses) {
|
||||||
for (DClass dClass : mainConfig.dClasses) {
|
if (dClass.getName().equals(name)) {
|
||||||
if (dClass.name.equals(name)) {
|
return dClass;
|
||||||
return dClass;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null;
|
for (DClass dClass : plugin.getDefaultConfig().dClasses) {
|
||||||
}
|
if (dClass.getName().equals(name)) {
|
||||||
|
return dClass;
|
||||||
public String getMsg(int id, boolean returnMainConfig) {
|
}
|
||||||
String msg = this.msgs.get(id);
|
}
|
||||||
if (msg != null) {
|
return null;
|
||||||
return this.msgs.get(id);
|
}
|
||||||
}
|
|
||||||
if (returnMainConfig) {
|
public String getMsg(int id, boolean returnMainConfig) {
|
||||||
return mainConfig.msgs.get(id);
|
String msg = msgs.get(id);
|
||||||
}
|
if (msg != null) {
|
||||||
|
return msgs.get(id);
|
||||||
return null;
|
}
|
||||||
}
|
if (returnMainConfig) {
|
||||||
|
return plugin.getDefaultConfig().msgs.get(id);
|
||||||
public void setMsg(String msg, int id) {
|
}
|
||||||
this.msgs.put(id, msg);
|
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
public CopyOnWriteArrayList<String> getInvitedPlayers() {
|
|
||||||
CopyOnWriteArrayList<String> tmpInvitedPlayers = new CopyOnWriteArrayList<String>();
|
public void setMsg(String msg, int id) {
|
||||||
tmpInvitedPlayers.addAll(this.invitedPlayers);
|
msgs.put(id, msg);
|
||||||
tmpInvitedPlayers.addAll(mainConfig.invitedPlayers);
|
}
|
||||||
return tmpInvitedPlayers;
|
|
||||||
}
|
public CopyOnWriteArrayList<String> getInvitedPlayers() {
|
||||||
|
CopyOnWriteArrayList<String> tmpInvitedPlayers = new CopyOnWriteArrayList<String>();
|
||||||
public void addInvitedPlayer(String uuid) {
|
tmpInvitedPlayers.addAll(invitedPlayers);
|
||||||
this.invitedPlayers.add(uuid);
|
tmpInvitedPlayers.addAll(plugin.getDefaultConfig().invitedPlayers);
|
||||||
}
|
return tmpInvitedPlayers;
|
||||||
|
}
|
||||||
public void removeInvitedPlayers(String uuid, String name) {
|
|
||||||
this.invitedPlayers.remove(uuid);
|
public void addInvitedPlayer(String uuid) {
|
||||||
// remove player from a 0.9.1 and lower file
|
invitedPlayers.add(uuid);
|
||||||
this.invitedPlayers.remove(name);
|
}
|
||||||
}
|
|
||||||
|
public void removeInvitedPlayers(String uuid, String name) {
|
||||||
public CopyOnWriteArrayList<Material> getSecureObjects() {
|
invitedPlayers.remove(uuid);
|
||||||
CopyOnWriteArrayList<Material> tmpSecureObjects = new CopyOnWriteArrayList<Material>();
|
// remove player from a 0.9.1 and lower file
|
||||||
tmpSecureObjects.addAll(this.secureObjects);
|
invitedPlayers.remove(name);
|
||||||
tmpSecureObjects.addAll(mainConfig.secureObjects);
|
}
|
||||||
return tmpSecureObjects;
|
|
||||||
}
|
public CopyOnWriteArrayList<Material> getSecureObjects() {
|
||||||
|
CopyOnWriteArrayList<Material> tmpSecureObjects = new CopyOnWriteArrayList<Material>();
|
||||||
public boolean getKeepInventoryOnEnter() {
|
tmpSecureObjects.addAll(secureObjects);
|
||||||
return keepInventoryOnEnter;
|
tmpSecureObjects.addAll(plugin.getDefaultConfig().secureObjects);
|
||||||
}
|
return tmpSecureObjects;
|
||||||
|
}
|
||||||
public boolean getKeepInventoryOnEscape() {
|
|
||||||
return keepInventoryOnEscape;
|
public boolean getKeepInventoryOnEnter() {
|
||||||
}
|
return keepInventoryOnEnter;
|
||||||
|
}
|
||||||
public boolean getKeepInventoryOnFinish() {
|
|
||||||
return keepInventoryOnFinish;
|
public boolean getKeepInventoryOnEscape() {
|
||||||
}
|
return keepInventoryOnEscape;
|
||||||
|
}
|
||||||
public boolean getKeepInventoryOnDeath() {
|
|
||||||
return keepInventoryOnDeath;
|
public boolean getKeepInventoryOnFinish() {
|
||||||
}
|
return keepInventoryOnFinish;
|
||||||
|
}
|
||||||
public int getInitialLives() {
|
|
||||||
return initialLives;
|
public boolean getKeepInventoryOnDeath() {
|
||||||
}
|
return keepInventoryOnDeath;
|
||||||
|
}
|
||||||
public boolean isLobbyDisabled() {
|
|
||||||
return isLobbyDisabled;
|
public int getInitialLives() {
|
||||||
}
|
return initialLives;
|
||||||
|
}
|
||||||
public int getTimeToNextPlay() {
|
|
||||||
return timeToNextPlay;
|
public boolean isLobbyDisabled() {
|
||||||
}
|
return isLobbyDisabled;
|
||||||
|
}
|
||||||
public int getTimeToNextLoot() {
|
|
||||||
return timeToNextLoot;
|
public int getTimeToNextPlay() {
|
||||||
}
|
return timeToNextPlay;
|
||||||
|
}
|
||||||
public int getTimeUntilKickOfflinePlayer() {
|
|
||||||
return timeUntilKickOfflinePlayer;
|
public int getTimeToNextLoot() {
|
||||||
}
|
return timeToNextLoot;
|
||||||
|
}
|
||||||
public int getTimeLastPlayed() {
|
|
||||||
return timeLastPlayed;
|
public int getTimeUntilKickOfflinePlayer() {
|
||||||
}
|
return timeUntilKickOfflinePlayer;
|
||||||
|
}
|
||||||
public double getFee() {
|
|
||||||
return fee;
|
public int getTimeLastPlayed() {
|
||||||
}
|
return timeLastPlayed;
|
||||||
|
}
|
||||||
public List<String> getFinishedAll() {
|
|
||||||
return finishedAll;
|
public double getFee() {
|
||||||
}
|
return fee;
|
||||||
|
}
|
||||||
public List<String> getFinished() {
|
|
||||||
List<String> merge = new ArrayList<String>();
|
public List<String> getFinishedAll() {
|
||||||
merge.addAll(finishedAll);
|
return finishedAll;
|
||||||
merge.addAll(finishedOne);
|
}
|
||||||
return merge;
|
|
||||||
}
|
public List<String> getFinished() {
|
||||||
|
List<String> merge = new ArrayList<String>();
|
||||||
public Set<DMobType> getMobTypes() {
|
merge.addAll(finishedAll);
|
||||||
return mobTypes;
|
merge.addAll(finishedOne);
|
||||||
}
|
return merge;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
public Set<DMobType> getMobTypes() {
|
||||||
|
return mobTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,100 +1,107 @@
|
|||||||
package com.dre.dungeonsxl.game;
|
package io.github.dre2n.dungeonsxl.dungeon.game;
|
||||||
|
|
||||||
import net.milkbowl.vault.item.Items;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import net.milkbowl.vault.item.ItemInfo;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import org.bukkit.ChatColor;
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
import org.bukkit.block.Block;
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
import org.bukkit.block.Chest;
|
import net.milkbowl.vault.item.ItemInfo;
|
||||||
import org.bukkit.entity.Player;
|
import net.milkbowl.vault.item.Items;
|
||||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
|
||||||
import org.bukkit.inventory.InventoryView;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Chest;
|
||||||
import com.dre.dungeonsxl.DGroup;
|
import org.bukkit.entity.Player;
|
||||||
import com.dre.dungeonsxl.DPlayer;
|
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||||
import com.dre.dungeonsxl.P;
|
import org.bukkit.inventory.InventoryView;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
public class GameChest {
|
|
||||||
|
public class GameChest {
|
||||||
// Variables
|
|
||||||
public boolean isUsed = false;
|
// Variables
|
||||||
public Chest chest;
|
public boolean isUsed = false;
|
||||||
public GameWorld gworld;
|
public Chest chest;
|
||||||
public double moneyReward;
|
public GameWorld gWorld;
|
||||||
|
public double moneyReward;
|
||||||
public GameChest(Block chest, GameWorld gworld, double moneyReward) {
|
|
||||||
if (chest.getState() instanceof Chest) {
|
public GameChest(Block chest, GameWorld gWorld, double moneyReward) {
|
||||||
this.chest = (Chest) chest.getState();
|
if (chest.getState() instanceof Chest) {
|
||||||
|
this.chest = (Chest) chest.getState();
|
||||||
this.gworld = gworld;
|
|
||||||
|
this.gWorld = gWorld;
|
||||||
this.moneyReward = moneyReward;
|
|
||||||
|
this.moneyReward = moneyReward;
|
||||||
gworld.gchests.add(this);
|
|
||||||
}
|
gWorld.gameChests.add(this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void addTreasure(DGroup dgroup) {
|
|
||||||
if (dgroup != null) {
|
public void addTreasure(DGroup dgroup) {
|
||||||
for (Player player : dgroup.getPlayers()) {
|
if (dgroup != null) {
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
for (Player player : dgroup.getPlayers()) {
|
||||||
if (dplayer != null) {
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
dplayer.treasureMoney = dplayer.treasureMoney + moneyReward;
|
if (dplayer != null) {
|
||||||
String msg = "";
|
dplayer.treasureMoney = dplayer.treasureMoney + moneyReward;
|
||||||
for (ItemStack istack : this.chest.getInventory().getContents()) {
|
String msg = "";
|
||||||
if (istack != null) {
|
for (ItemStack istack : chest.getInventory().getContents()) {
|
||||||
dplayer.treasureInv.addItem(istack);
|
|
||||||
String name;
|
if (istack != null) {
|
||||||
if (istack.hasItemMeta() && istack.getItemMeta().hasDisplayName()) {
|
dplayer.treasureInv.addItem(istack);
|
||||||
name = istack.getItemMeta().getDisplayName();
|
String name;
|
||||||
} else {
|
|
||||||
ItemInfo itemInfo = Items.itemByStack(istack);
|
if (istack.hasItemMeta() && istack.getItemMeta().hasDisplayName()) {
|
||||||
if (itemInfo != null) {
|
name = istack.getItemMeta().getDisplayName();
|
||||||
name = itemInfo.getName();
|
|
||||||
} else {
|
} else {
|
||||||
name = istack.getType().name();
|
ItemInfo itemInfo = Items.itemByStack(istack);
|
||||||
}
|
if (itemInfo != null) {
|
||||||
}
|
name = itemInfo.getName();
|
||||||
msg = msg + ChatColor.RED + " " + istack.getAmount() + " " + name + ChatColor.GOLD + ",";
|
} else {
|
||||||
}
|
name = istack.getType().name();
|
||||||
}
|
}
|
||||||
msg = msg.substring(0, msg.length() - 1);
|
}
|
||||||
|
msg = msg + ChatColor.RED + " " + istack.getAmount() + " " + name + ChatColor.GOLD + ",";
|
||||||
P.p.msg(player, P.p.language.get("Player_LootAdded", msg));
|
}
|
||||||
if (moneyReward != 0) {
|
}
|
||||||
P.p.msg(player, P.p.language.get("Player_LootAdded", String.valueOf(moneyReward)));
|
|
||||||
}
|
msg = msg.substring(0, msg.length() - 1);
|
||||||
}
|
|
||||||
}
|
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_LootAdded", msg));
|
||||||
}
|
if (moneyReward != 0) {
|
||||||
}
|
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_LootAdded", String.valueOf(moneyReward)));
|
||||||
|
}
|
||||||
// Statics
|
}
|
||||||
public static void onOpenInventory(InventoryOpenEvent event) {
|
}
|
||||||
InventoryView inventory = event.getView();
|
}
|
||||||
|
}
|
||||||
GameWorld gworld = GameWorld.get(event.getPlayer().getWorld());
|
|
||||||
|
// Statics
|
||||||
if (gworld != null) {
|
public static void onOpenInventory(InventoryOpenEvent event) {
|
||||||
if (inventory.getTopInventory().getHolder() instanceof Chest) {
|
InventoryView inventory = event.getView();
|
||||||
Chest chest = (Chest) inventory.getTopInventory().getHolder();
|
|
||||||
|
GameWorld gWorld = GameWorld.get(event.getPlayer().getWorld());
|
||||||
for (GameChest gchest : gworld.gchests) {
|
|
||||||
if (gchest.chest.equals(chest)) {
|
if (gWorld != null) {
|
||||||
if (!gchest.isUsed) {
|
if (inventory.getTopInventory().getHolder() instanceof Chest) {
|
||||||
if (gchest.chest.getLocation().distance(chest.getLocation()) < 1) {
|
Chest chest = (Chest) inventory.getTopInventory().getHolder();
|
||||||
gchest.addTreasure(DGroup.get(gworld));
|
|
||||||
gchest.isUsed = true;
|
for (GameChest gchest : gWorld.gameChests) {
|
||||||
event.setCancelled(true);
|
if (gchest.chest.equals(chest)) {
|
||||||
}
|
|
||||||
} else {
|
if ( !gchest.isUsed) {
|
||||||
P.p.msg(P.p.getServer().getPlayer(event.getPlayer().getUniqueId()), ChatColor.RED + "Diese Kiste wurde schon geöffnet!");
|
if (gchest.chest.getLocation().distance(chest.getLocation()) < 1) {
|
||||||
event.setCancelled(true);
|
gchest.addTreasure(DGroup.get(gWorld));
|
||||||
}
|
gchest.isUsed = true;
|
||||||
}
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
} else {
|
||||||
}
|
MessageUtil.sendMessage(DungeonsXL.getPlugin().getServer().getPlayer(event.getPlayer().getUniqueId()), DungeonsXL.getPlugin().getDMessages().get("Error_ChestIsOpened"));
|
||||||
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,228 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.dungeon.game;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.util.IntegerUtil;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
|
public class GamePlaceableBlock {
|
||||||
|
|
||||||
|
// Variables
|
||||||
|
private Block block;
|
||||||
|
private Set<Material> mats = new HashSet<Material>();
|
||||||
|
|
||||||
|
private boolean onTop = false;
|
||||||
|
private boolean onBottom = false;
|
||||||
|
private boolean onNorth = false;
|
||||||
|
private boolean onSouth = false;
|
||||||
|
private boolean onEast = false;
|
||||||
|
private boolean onWest = false;
|
||||||
|
|
||||||
|
public GamePlaceableBlock(Block block, String ids, String directions) {
|
||||||
|
this.block = block;
|
||||||
|
|
||||||
|
// Split ids
|
||||||
|
if ( !ids.equals("")) {
|
||||||
|
String[] splittedIds = ids.split(",");
|
||||||
|
for (String id : splittedIds) {
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
Material mat = Material.getMaterial(IntegerUtil.parseInt(id));
|
||||||
|
if (mat != null) {
|
||||||
|
mats.add(mat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read directions
|
||||||
|
if (directions.length() == 6) {
|
||||||
|
for (int direction = 0; direction < 6; direction++) {
|
||||||
|
boolean positive = String.valueOf(directions.charAt(direction)).equals("x");
|
||||||
|
|
||||||
|
if (positive) {
|
||||||
|
if (direction == 0) {
|
||||||
|
onTop = true;
|
||||||
|
}
|
||||||
|
if (direction == 1) {
|
||||||
|
onBottom = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block.getType() == Material.WALL_SIGN) {
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
int data = block.getData();
|
||||||
|
switch (data) {
|
||||||
|
case 3:
|
||||||
|
if (direction == 2) {
|
||||||
|
onNorth = true;
|
||||||
|
}
|
||||||
|
if (direction == 3) {
|
||||||
|
onEast = true;
|
||||||
|
}
|
||||||
|
if (direction == 4) {
|
||||||
|
onSouth = true;
|
||||||
|
}
|
||||||
|
if (direction == 5) {
|
||||||
|
onWest = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if (direction == 5) {
|
||||||
|
onNorth = true;
|
||||||
|
}
|
||||||
|
if (direction == 2) {
|
||||||
|
onEast = true;
|
||||||
|
}
|
||||||
|
if (direction == 3) {
|
||||||
|
onSouth = true;
|
||||||
|
}
|
||||||
|
if (direction == 4) {
|
||||||
|
onWest = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (direction == 4) {
|
||||||
|
onNorth = true;
|
||||||
|
}
|
||||||
|
if (direction == 5) {
|
||||||
|
onEast = true;
|
||||||
|
}
|
||||||
|
if (direction == 2) {
|
||||||
|
onSouth = true;
|
||||||
|
}
|
||||||
|
if (direction == 3) {
|
||||||
|
onWest = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
if (direction == 3) {
|
||||||
|
onNorth = true;
|
||||||
|
}
|
||||||
|
if (direction == 4) {
|
||||||
|
onEast = true;
|
||||||
|
}
|
||||||
|
if (direction == 5) {
|
||||||
|
onSouth = true;
|
||||||
|
}
|
||||||
|
if (direction == 2) {
|
||||||
|
onWest = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
int data = block.getData();
|
||||||
|
switch (data) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 15:
|
||||||
|
if (direction == 2) {
|
||||||
|
onNorth = true;
|
||||||
|
}
|
||||||
|
if (direction == 3) {
|
||||||
|
onEast = true;
|
||||||
|
}
|
||||||
|
if (direction == 4) {
|
||||||
|
onSouth = true;
|
||||||
|
}
|
||||||
|
if (direction == 5) {
|
||||||
|
onWest = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
case 3:
|
||||||
|
case 5:
|
||||||
|
case 6:
|
||||||
|
if (direction == 5) {
|
||||||
|
onNorth = true;
|
||||||
|
}
|
||||||
|
if (direction == 2) {
|
||||||
|
onEast = true;
|
||||||
|
}
|
||||||
|
if (direction == 3) {
|
||||||
|
onSouth = true;
|
||||||
|
}
|
||||||
|
if (direction == 4) {
|
||||||
|
onWest = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
case 7:
|
||||||
|
case 9:
|
||||||
|
case 10:
|
||||||
|
if (direction == 4) {
|
||||||
|
onNorth = true;
|
||||||
|
}
|
||||||
|
if (direction == 5) {
|
||||||
|
onEast = true;
|
||||||
|
}
|
||||||
|
if (direction == 2) {
|
||||||
|
onSouth = true;
|
||||||
|
}
|
||||||
|
if (direction == 3) {
|
||||||
|
onWest = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
case 11:
|
||||||
|
case 13:
|
||||||
|
case 14:
|
||||||
|
if (direction == 3) {
|
||||||
|
onNorth = true;
|
||||||
|
}
|
||||||
|
if (direction == 4) {
|
||||||
|
onEast = true;
|
||||||
|
}
|
||||||
|
if (direction == 5) {
|
||||||
|
onSouth = true;
|
||||||
|
}
|
||||||
|
if (direction == 2) {
|
||||||
|
onWest = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
onTop = true;
|
||||||
|
onBottom = true;
|
||||||
|
onNorth = true;
|
||||||
|
onEast = true;
|
||||||
|
onSouth = true;
|
||||||
|
onWest = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Canbuild
|
||||||
|
public static boolean canBuildHere(Block block, BlockFace blockFace, Material mat, GameWorld gWorld) {
|
||||||
|
for (GamePlaceableBlock gPBlock : gWorld.placeableBlocks) {
|
||||||
|
if (gPBlock.block.getFace(block) == BlockFace.SELF) {
|
||||||
|
if (gPBlock.mats.contains(mat) || gPBlock.mats.isEmpty()) {
|
||||||
|
if (blockFace == BlockFace.NORTH && gPBlock.onNorth) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (blockFace == BlockFace.SOUTH && gPBlock.onSouth) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (blockFace == BlockFace.EAST && gPBlock.onEast) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (blockFace == BlockFace.WEST && gPBlock.onWest) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (blockFace == BlockFace.UP && gPBlock.onTop) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (blockFace == BlockFace.DOWN && gPBlock.onBottom) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
368
src/io/github/dre2n/dungeonsxl/dungeon/game/GameWorld.java
Normal file
368
src/io/github/dre2n/dungeonsxl/dungeon/game/GameWorld.java
Normal file
@ -0,0 +1,368 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.dungeon.game;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.DungeonConfig;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.mob.DMob;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.trigger.RedstoneTrigger;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.FileUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Spider;
|
||||||
|
|
||||||
|
public class GameWorld {
|
||||||
|
|
||||||
|
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
||||||
|
|
||||||
|
// Variables placeable
|
||||||
|
public boolean isTutorial;
|
||||||
|
|
||||||
|
public CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks = new CopyOnWriteArrayList<GamePlaceableBlock>();
|
||||||
|
public World world;
|
||||||
|
public String dungeonname;
|
||||||
|
public Location locLobby;
|
||||||
|
public Location locStart;
|
||||||
|
public boolean isPlaying = false;
|
||||||
|
public int id;
|
||||||
|
public CopyOnWriteArrayList<Material> secureObjects = new CopyOnWriteArrayList<Material>();
|
||||||
|
public CopyOnWriteArrayList<Chunk> loadedChunks = new CopyOnWriteArrayList<Chunk>();
|
||||||
|
|
||||||
|
public CopyOnWriteArrayList<Sign> signClass = new CopyOnWriteArrayList<Sign>();
|
||||||
|
public CopyOnWriteArrayList<DMob> dMobs = new CopyOnWriteArrayList<DMob>();
|
||||||
|
public CopyOnWriteArrayList<GameChest> gameChests = new CopyOnWriteArrayList<GameChest>();
|
||||||
|
public CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<DSign>();
|
||||||
|
private WorldConfig worldConfig;
|
||||||
|
|
||||||
|
public GameWorld() {
|
||||||
|
plugin.getGameWorlds().add(this);
|
||||||
|
|
||||||
|
// ID
|
||||||
|
id = -1;
|
||||||
|
int i = -1;
|
||||||
|
while (id == -1) {
|
||||||
|
i++;
|
||||||
|
boolean exist = false;
|
||||||
|
for (GameWorld gWorld : plugin.getGameWorlds()) {
|
||||||
|
if (gWorld.id == i) {
|
||||||
|
exist = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !exist) {
|
||||||
|
id = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkSign(Block block) {
|
||||||
|
if (block.getState() instanceof Sign) {
|
||||||
|
Sign sign = (Sign) block.getState();
|
||||||
|
dSigns.add(DSign.create(sign, this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startGame() {
|
||||||
|
isPlaying = true;
|
||||||
|
|
||||||
|
for (DSign dSign : dSigns) {
|
||||||
|
if (dSign != null) {
|
||||||
|
if ( !dSign.isOnDungeonInit()) {
|
||||||
|
dSign.onInit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (RedstoneTrigger.hasTriggers(this)) {
|
||||||
|
for (RedstoneTrigger trigger : RedstoneTrigger.getTriggersArray(this)) {
|
||||||
|
trigger.onTrigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (DSign dSign : dSigns) {
|
||||||
|
if (dSign != null) {
|
||||||
|
if ( !dSign.hasTriggers()) {
|
||||||
|
dSign.onTrigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void msg(String msg) {
|
||||||
|
for (DPlayer dplayer : DPlayer.get(world)) {
|
||||||
|
MessageUtil.sendMessage(dplayer.player, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the worldConfig
|
||||||
|
*/
|
||||||
|
public WorldConfig getConfig() {
|
||||||
|
return worldConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param worldConfig
|
||||||
|
* the worldConfig to set
|
||||||
|
*/
|
||||||
|
public void setConfig(WorldConfig worldConfig) {
|
||||||
|
this.worldConfig = worldConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the Dungeon that contains the GameWorld
|
||||||
|
*/
|
||||||
|
public Dungeon getDungeon() {
|
||||||
|
for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
|
||||||
|
DungeonConfig dungeonConfig = dungeon.getConfig();
|
||||||
|
if (dungeonConfig.getFloors().contains(this) || dungeonConfig.getStartFloor().equals(this) || dungeonConfig.getEndFloor().equals(this)) {
|
||||||
|
return dungeon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Statics
|
||||||
|
|
||||||
|
public static GameWorld get(World world) {
|
||||||
|
for (GameWorld gWorld : plugin.getGameWorlds()) {
|
||||||
|
if (gWorld.world.equals(world)) {
|
||||||
|
return gWorld;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void deleteAll() {
|
||||||
|
for (GameWorld gWorld : plugin.getGameWorlds()) {
|
||||||
|
gWorld.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean canPlayDungeon(String dungeon, Player player) {
|
||||||
|
|
||||||
|
if (player.hasPermission("dungeonsxl.ignoretimelimit")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (new File(plugin.getDataFolder() + "/maps/" + dungeon).isDirectory()) {
|
||||||
|
WorldConfig worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + dungeon, "config.yml"));
|
||||||
|
|
||||||
|
if (worldConfig.getTimeToNextPlay() != 0) {
|
||||||
|
// read PlayerConfig
|
||||||
|
Long time = getPlayerTime(dungeon, player);
|
||||||
|
if (time != -1) {
|
||||||
|
if (time + worldConfig.getTimeToNextPlay() * 1000 * 60 * 60 > System.currentTimeMillis()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean checkRequirements(String dungeon, Player player) {
|
||||||
|
/* if (plugin.permission.has(player, "dungeonsxl.ignoreRequirements") || player.isOp()) {
|
||||||
|
* return true; } */
|
||||||
|
|
||||||
|
if (new File(plugin.getDataFolder() + "/maps/" + dungeon).isDirectory() == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
WorldConfig worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + dungeon, "config.yml"));
|
||||||
|
|
||||||
|
if (plugin.getMainConfig().enableEconomy()) {
|
||||||
|
if ( !(DungeonsXL.getPlugin().economy.getBalance(player) >= worldConfig.getFee())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worldConfig.getFinished() != null && worldConfig.getFinishedAll() != null) {
|
||||||
|
if ( !worldConfig.getFinished().isEmpty()) {
|
||||||
|
|
||||||
|
long bestTime = 0;
|
||||||
|
int numOfNeeded = 0;
|
||||||
|
boolean doneTheOne = false;
|
||||||
|
|
||||||
|
if (worldConfig.getFinished().size() == worldConfig.getFinishedAll().size()) {
|
||||||
|
doneTheOne = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String played : worldConfig.getFinished()) {
|
||||||
|
for (String dungeonName : new File(plugin.getDataFolder() + "/maps").list()) {
|
||||||
|
if (new File(plugin.getDataFolder() + "/maps/" + dungeonName).isDirectory()) {
|
||||||
|
if (played.equalsIgnoreCase(dungeonName) || played.equalsIgnoreCase("any")) {
|
||||||
|
|
||||||
|
Long time = getPlayerTime(dungeonName, player);
|
||||||
|
if (time != -1) {
|
||||||
|
if (worldConfig.getFinishedAll().contains(played)) {
|
||||||
|
numOfNeeded++;
|
||||||
|
} else {
|
||||||
|
doneTheOne = true;
|
||||||
|
}
|
||||||
|
if (bestTime < time) {
|
||||||
|
bestTime = time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bestTime == 0) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if (worldConfig.getTimeLastPlayed() != 0) {
|
||||||
|
if (System.currentTimeMillis() - bestTime > worldConfig.getTimeLastPlayed() * (long) 3600000) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numOfNeeded < worldConfig.getFinishedAll().size() || !doneTheOne) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getPlayerTime(String dungeon, Player player) {
|
||||||
|
File file = new File(plugin.getDataFolder() + "/maps/" + dungeon, "players.yml");
|
||||||
|
|
||||||
|
if ( !file.exists()) {
|
||||||
|
try {
|
||||||
|
file.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file);
|
||||||
|
if (playerConfig.contains(player.getUniqueId().toString())) {
|
||||||
|
return playerConfig.getLong(player.getUniqueId().toString());
|
||||||
|
}
|
||||||
|
if (playerConfig.contains(player.getName())) {
|
||||||
|
return playerConfig.getLong(player.getName());
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete() {
|
||||||
|
plugin.getGameWorlds().remove(this);
|
||||||
|
plugin.getServer().unloadWorld(world, true);
|
||||||
|
File dir = new File("DXL_Game_" + id);
|
||||||
|
FileUtil.removeDirectory(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GameWorld load(String name) {
|
||||||
|
|
||||||
|
File file = new File(plugin.getDataFolder(), "/maps/" + name);
|
||||||
|
|
||||||
|
if (file.exists()) {
|
||||||
|
GameWorld gWorld = new GameWorld();
|
||||||
|
gWorld.dungeonname = name;
|
||||||
|
|
||||||
|
// Unload empty eworlds
|
||||||
|
for (EditWorld eworld : plugin.getEditWorlds()) {
|
||||||
|
if (eworld.world.getPlayers().isEmpty()) {
|
||||||
|
eworld.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Config einlesen
|
||||||
|
gWorld.worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + gWorld.dungeonname, "config.yml"));
|
||||||
|
|
||||||
|
// Secure Objects
|
||||||
|
gWorld.secureObjects = gWorld.worldConfig.getSecureObjects();
|
||||||
|
|
||||||
|
// World
|
||||||
|
FileUtil.copyDirectory(file, new File("DXL_Game_" + gWorld.id));
|
||||||
|
|
||||||
|
// Id File
|
||||||
|
File idFile = new File("DXL_Game_" + gWorld.id + "/.id_" + name);
|
||||||
|
try {
|
||||||
|
idFile.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
gWorld.world = plugin.getServer().createWorld(WorldCreator.name("DXL_Game_" + gWorld.id));
|
||||||
|
|
||||||
|
ObjectInputStream os;
|
||||||
|
try {
|
||||||
|
os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder() + "/maps/" + gWorld.dungeonname + "/DXLData.data")));
|
||||||
|
|
||||||
|
int length = os.readInt();
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
int x = os.readInt();
|
||||||
|
int y = os.readInt();
|
||||||
|
int z = os.readInt();
|
||||||
|
Block block = gWorld.world.getBlockAt(x, y, z);
|
||||||
|
gWorld.checkSign(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
os.close();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return gWorld;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void update() {
|
||||||
|
for (GameWorld gWorld : plugin.getGameWorlds()) {
|
||||||
|
// Update Spiders
|
||||||
|
for (LivingEntity mob : gWorld.world.getLivingEntities()) {
|
||||||
|
if (mob.getType() == EntityType.SPIDER || mob.getType() == EntityType.CAVE_SPIDER) {
|
||||||
|
Spider spider = (Spider) mob;
|
||||||
|
if (spider.getTarget() != null) {
|
||||||
|
if (spider.getTarget().getType() == EntityType.PLAYER) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Entity player : spider.getNearbyEntities(10, 10, 10)) {
|
||||||
|
if (player.getType() == EntityType.PLAYER) {
|
||||||
|
spider.setTarget((LivingEntity) player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,185 +1,195 @@
|
|||||||
package com.dre.dungeonsxl;
|
package io.github.dre2n.dungeonsxl.file;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
public class LanguageReader {
|
public class DMessages {
|
||||||
private Map<String, String> entries = new TreeMap<String, String>();
|
|
||||||
private Map<String, String> defaults = new TreeMap<String, String>();
|
private Map<String, String> entries = new TreeMap<String, String>();
|
||||||
|
private Map<String, String> defaults = new TreeMap<String, String>();
|
||||||
private File file;
|
|
||||||
private boolean changed;
|
private File file;
|
||||||
|
private boolean changed;
|
||||||
public LanguageReader(File file) {
|
|
||||||
this.setDefaults();
|
public DMessages(File file) {
|
||||||
|
setDefaults();
|
||||||
/* Load */
|
|
||||||
this.file = file;
|
/* Load */
|
||||||
|
this.file = file;
|
||||||
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
|
|
||||||
|
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
|
||||||
Set<String> keySet = configFile.getKeys(false);
|
|
||||||
for (String key : keySet) {
|
Set<String> keySet = configFile.getKeys(false);
|
||||||
entries.put(key, configFile.getString(key));
|
for (String key : keySet) {
|
||||||
}
|
entries.put(key, configFile.getString(key));
|
||||||
|
}
|
||||||
/* Check */
|
|
||||||
this.check();
|
/* Check */
|
||||||
}
|
check();
|
||||||
|
}
|
||||||
private void setDefaults() {
|
|
||||||
|
private void setDefaults() {
|
||||||
/* Log */
|
|
||||||
defaults.put("Log_NewDungeon", "&6New Dungeon");
|
/* Log */
|
||||||
defaults.put("Log_GenerateNewWorld", "&6Generate new world...");
|
defaults.put("Log_NewDungeon", "&6New Dungeon");
|
||||||
defaults.put("Log_WorldGenerationFinished", "&6World generation finished!");
|
defaults.put("Log_GenerateNewWorld", "&6Generate new world...");
|
||||||
defaults.put("Log_Error_MobEnchantment", "&4Error at loading mob.yml: Enchantment &6&v1&4 doesn't exist!");
|
defaults.put("Log_WorldGenerationFinished", "&6World generation finished!");
|
||||||
defaults.put("Log_Error_MobType", "&4Error at loading mob.yml: Mob &6&v1&4 doesn't exist!");
|
defaults.put("Log_Error_MobEnchantment", "&4Error at loading mob.yml: Enchantment &6&v1&4 doesn't exist!");
|
||||||
defaults.put("Log_Error_NoConsoleCommand", "&6/dxl &v1&4 can not be executed as Console!");
|
defaults.put("Log_Error_MobType", "&4Error at loading mob.yml: Mob &6&v1&4 doesn't exist!");
|
||||||
|
defaults.put("Log_Error_NoConsoleCommand", "&6/dxl &v1&4 can not be executed as Console!");
|
||||||
/* Player */
|
|
||||||
defaults.put("Player_CheckpointReached", "&6Checkpoint reached!");
|
/* Player */
|
||||||
defaults.put("Player_LootAdded", "&4&v1&6 have been added to your reward inventory!");
|
defaults.put("Player_CheckpointReached", "&6Checkpoint reached!");
|
||||||
defaults.put("Player_Ready", "&6You are now ready for the Dungeon!");
|
defaults.put("Player_LootAdded", "&4&v1&6 have been added to your reward inventory!");
|
||||||
defaults.put("Player_FinishedDungeon", "&6You successfully finished the Dungeon!");
|
defaults.put("Player_Ready", "&6You are now ready for the Dungeon!");
|
||||||
defaults.put("Player_WaitForOtherPlayers", "&6Waiting for teammates...");
|
defaults.put("Player_FinishedDungeon", "&6You successfully finished the Dungeon!");
|
||||||
defaults.put("Player_LeaveGroup", "&6You have successfully left your group!");
|
defaults.put("Player_WaitForOtherPlayers", "&6Waiting for teammates...");
|
||||||
defaults.put("Player_Offline", "&Player &4&v1&6 went offline. In &4&v2&6 seconds he will autmatically be kicked from the Dungeon!");
|
defaults.put("Player_LeaveGroup", "&6You have successfully left your group!");
|
||||||
defaults.put("Player_OfflineNever", "&Player &4&v1&6 went offline. He will &4not&6 be kicked from the Dungeon automatically!");
|
defaults.put("Player_Offline", "&Player &4&v1&6 went offline. In &4&v2&6 seconds he will autmatically be kicked from the Dungeon!");
|
||||||
defaults.put("Player_LeftGroup", "&Player &4&v1&6 has left the Group!");
|
defaults.put("Player_OfflineNever", "&Player &4&v1&6 went offline. He will &4not&6 be kicked from the Dungeon automatically!");
|
||||||
defaults.put("Player_JoinGroup", "&Player &4&v1&6 has joined the Group!");
|
defaults.put("Player_LeftGroup", "&Player &4&v1&6 has left the Group!");
|
||||||
defaults.put("Player_PortalAbort", "&6Portal creation cancelled!");
|
defaults.put("Player_JoinGroup", "&Player &4&v1&6 has joined the Group!");
|
||||||
defaults.put("Player_PortalIntroduction", "&6Click the two edges of the Portal with the wooden sword!");
|
defaults.put("Player_PortalAbort", "&6Portal creation cancelled!");
|
||||||
defaults.put("Player_PortalDeleted", "&6Portal deleted!");
|
defaults.put("Player_PortalIntroduction", "&6Click the two edges of the Portal with the wooden sword!");
|
||||||
defaults.put("Player_PortalProgress", "&6First Block, now the second one!");
|
defaults.put("Player_PortalDeleted", "&6Portal deleted!");
|
||||||
defaults.put("Player_PortalCreated", "&6Portal created!");
|
defaults.put("Player_PortalProgress", "&6First Block, now the second one!");
|
||||||
defaults.put("Player_SignCreated", "&6Sign created!");
|
defaults.put("Player_PortalCreated", "&6Portal created!");
|
||||||
defaults.put("Player_SignCopied", "&6Copied!");
|
defaults.put("Player_SignCreated", "&6Sign created!");
|
||||||
defaults.put("Player_BlockInfo", "&6Block-ID: &2&v1");
|
defaults.put("Player_SignCopied", "&6Copied!");
|
||||||
defaults.put("Player_Death", "&6You died, lives left: &2v1");
|
defaults.put("Player_BlockInfo", "&6Block-ID: &2&v1");
|
||||||
defaults.put("Player_DeathKick", "&2v1&6 died and lost his last life.");
|
defaults.put("Player_Death", "&6You died, lives left: &2v1");
|
||||||
|
defaults.put("Player_DeathKick", "&2v1&6 died and lost his last life.");
|
||||||
/* Cmds */
|
defaults.put("Player_Treasures", "&1Treasures");
|
||||||
defaults.put("Cmd_Chat_DungeonChat", "&6You have entered the Dungeon-chat");
|
|
||||||
defaults.put("Cmd_Chat_NormalChat", "&6You are now in the public chat");
|
/* Cmds */
|
||||||
defaults.put("Cmd_Chatspy_Stopped", "&6You stopped spying the DXL-chat!");
|
defaults.put("Cmd_Chat_DungeonChat", "&6You have entered the Dungeon-chat");
|
||||||
defaults.put("Cmd_Chatspy_Start", "&You started spying the DXL-chat!");
|
defaults.put("Cmd_Chat_NormalChat", "&6You are now in the public chat");
|
||||||
defaults.put("Cmd_Invite_Success", "&6Player &4&v1&6 was successfully invited to edit the Dungeon &4&v2&6!");
|
defaults.put("Cmd_Chatspy_Stopped", "&6You stopped spying the DXL-chat!");
|
||||||
defaults.put("Cmd_Leave_Success", "&6You have successfully left your group!");
|
defaults.put("Cmd_Chatspy_Start", "&You started spying the DXL-chat!");
|
||||||
defaults.put("Cmd_Msg_Added", "&6New Message (&4&v1&6) added!");
|
defaults.put("Cmd_Invite_Success", "&6Player &4&v1&6 was successfully invited to edit the Dungeon &4&v2&6!");
|
||||||
defaults.put("Cmd_Msg_Updated", "&6Message (&4&v1&6) updated!");
|
defaults.put("Cmd_Leave_Success", "&6You have successfully left your group!");
|
||||||
defaults.put("Cmd_Reload_Start", "&6Reloading DungeonsXL...");
|
defaults.put("Cmd_Main_Welcome", "&7Welcome to &4Dungeons&fXL");
|
||||||
defaults.put("Cmd_Reload_Done", "&6DungeonsXL was successfully reloaded!");
|
defaults.put("Cmd_Main_Loaded", "&eDungeons: &o[&v1] &eLoaded: &o[&v2] &ePlayers: &o[&v3]");
|
||||||
defaults.put("Cmd_Save_Success", "&6Dungeon saved!");
|
defaults.put("Cmd_Main_Compatibility", "&eInternals: &o[&v1] &eVault: &o[&v2] &eMythicMobs: &o[&v3]");
|
||||||
defaults.put("Cmd_Uninvite_Success", "&4&v1&6 was successfully uninvited to edit the Dungeon &4&v1&6!");
|
defaults.put("Cmd_Main_Help", "&7Type in &o/dxl help&r&7 for further information.");
|
||||||
defaults.put("Cmd_Lives", "&4v1&6 has &4v2 &6lives left.");
|
defaults.put("Cmd_Msg_Added", "&6New Message (&4&v1&6) added!");
|
||||||
|
defaults.put("Cmd_Msg_Updated", "&6Message (&4&v1&6) updated!");
|
||||||
/* Errors */
|
defaults.put("Cmd_Reload_Done", "&7Successfully reloaded DungeonsXL.");
|
||||||
defaults.put("Error_Enderchest", "&4You cannot use an enderchest while in a Dungeon!");
|
defaults.put("Cmd_Save_Success", "&6Dungeon saved!");
|
||||||
defaults.put("Error_Bed", "&4You cannot use a bed while in a Dungeon!");
|
defaults.put("Cmd_Uninvite_Success", "&4&v1&6 was successfully uninvited to edit the Dungeon &4&v1&6!");
|
||||||
defaults.put("Error_Dispenser", "&4You cannot access this dispenser!");
|
defaults.put("Cmd_Lives", "&4v1&6 has &4v2 &6lives left.");
|
||||||
defaults.put("Error_Ready", "&4Choose your class first!");
|
|
||||||
defaults.put("Error_Cooldown", "&4You can only enter this Dungeon every &6&v1&4 hours!");
|
/* Errors */
|
||||||
defaults.put("Error_Requirements", "&4You don't fulfill the requirements for this Dungeon!");
|
defaults.put("Error_ChestIsOpened", "&4This chest has already been opened.");
|
||||||
defaults.put("Error_Leftklick", "&4You have to use Left-Click on this sign!");
|
defaults.put("Error_Enderchest", "&4You cannot use an enderchest while in a Dungeon!");
|
||||||
defaults.put("Error_Drop", "&4You cannot drop safe items");
|
defaults.put("Error_Bed", "&4You cannot use a bed while in a Dungeon!");
|
||||||
defaults.put("Error_Cmd", "&4Commands are not allowed while in a dungeon!");
|
defaults.put("Error_Dispenser", "&4You cannot access this dispenser!");
|
||||||
defaults.put("Error_NotInGroup", "&4You have to join a group first!");
|
defaults.put("Error_Ready", "&4Choose your class first!");
|
||||||
defaults.put("Error_NoPermissions", "&4You have no permission to do this!");
|
defaults.put("Error_Cooldown", "&4You can only enter this Dungeon every &6&v1&4 hours!");
|
||||||
defaults.put("Error_CmdNotExist1", "&4Command &6&v1&4 does not exist!");
|
defaults.put("Error_Requirements", "&4You don't fulfill the requirements for this Dungeon!");
|
||||||
defaults.put("Error_CmdNotExist2", "&4Pleaser enter &6/dxl help&4 for help!");
|
defaults.put("Error_Leftklick", "&4You have to use Left-Click on this sign!");
|
||||||
defaults.put("Error_NotInDungeon", "&4You are not in a dungeon!");
|
defaults.put("Error_Drop", "&4You cannot drop safe items");
|
||||||
defaults.put("Error_DungeonNotExist", "&4Dungeon &6&v1&4 does not exist!");
|
defaults.put("Error_Cmd", "&4Commands are not allowed while in a dungeon!");
|
||||||
defaults.put("Error_LeaveDungeon", "&4You have to leave your current dungeon first!");
|
defaults.put("Error_NotInGroup", "&4You have to join a group first!");
|
||||||
defaults.put("Error_NameToLong", "&4The name may not be longer than 15 characters!");
|
defaults.put("Error_NoPermissions", "&4You have no permission to do this!");
|
||||||
defaults.put("Error_LeaveGroup", "&4You have to leave your group first!");
|
defaults.put("Error_CmdNotExist1", "&4Command &6&v1&4 does not exist!");
|
||||||
defaults.put("Error_NoLeaveInTutorial", "&4You cannot use this command in the tutorial!");
|
defaults.put("Error_CmdNotExist2", "&4Pleaser enter &6/dxl help&4 for help!");
|
||||||
defaults.put("Error_MsgIdNotExist", "&4Message with Id &6&v1&4 does not exist!");
|
defaults.put("Error_NotInDungeon", "&4You are not in a dungeon!");
|
||||||
defaults.put("Error_MsgFormat", "&4The Message has to be between \"!");
|
defaults.put("Error_DungeonNotExist", "&4Dungeon &6&v1&4 does not exist!");
|
||||||
defaults.put("Error_MsgNoInt", "&4Argument <id> has to include a number!");
|
defaults.put("Error_LeaveDungeon", "&4You have to leave your current dungeon first!");
|
||||||
defaults.put("Error_TutorialNotExist", "&4Tutorial dungeon does not exist!");
|
defaults.put("Error_NameToLong", "&4The name may not be longer than 15 characters!");
|
||||||
defaults.put("Error_NoPortal", "&4You have to look at a portal!");
|
defaults.put("Error_LeaveGroup", "&4You have to leave your group first!");
|
||||||
defaults.put("Error_NoPlayerCommand", "&6/dxl &v1&4 can not be executed as player!");
|
defaults.put("Error_NoLeaveInTutorial", "&4You cannot use this command in the tutorial!");
|
||||||
defaults.put("Error_SignWrongFormat", "&4The sign is not written correctly!");
|
defaults.put("Error_MsgIdNotExist", "&4Message with Id &6&v1&4 does not exist!");
|
||||||
|
defaults.put("Error_MsgFormat", "&4The Message has to be between \"!");
|
||||||
/* Help */
|
defaults.put("Error_MsgNoInt", "&4Argument <id> has to include a number!");
|
||||||
defaults.put("Help_Cmd_Chat", "/dxl chat - Change the Chat-Mode");
|
defaults.put("Error_TutorialNotExist", "&4Tutorial dungeon does not exist!");
|
||||||
defaults.put("Help_Cmd_Chatspy", "/dxl chatspy - Dis/enables the spymode");
|
defaults.put("Error_NoPortal", "&4You have to look at a portal!");
|
||||||
defaults.put("Help_Cmd_Create", "/dxl create <name> - Creates a new dungeon");
|
defaults.put("Error_NoPlayerCommand", "&6/dxl &v1&4 cannot be executed as player!");
|
||||||
defaults.put("Help_Cmd_Edit", "/dxl edit <name> - Edit an existing dungeon");
|
defaults.put("Error_NoPlayerCommand", "&6/dxl &v1&4 cannot be executed as console!");
|
||||||
defaults.put("Help_Cmd_Help", "/dxl help - Shows the help page");
|
defaults.put("Error_SignWrongFormat", "&4The sign is not written correctly!");
|
||||||
defaults.put("Help_Cmd_Invite", "/dxl invite <player> <dungeon> - Invite a player to edit a dungeon");
|
|
||||||
defaults.put("Help_Cmd_Leave", "/dxl leave - Leaves the current dungeon");
|
/* Help */
|
||||||
defaults.put("Help_Cmd_Escape", "/dxl escape - Leaves the current dungeon, without saving!");
|
defaults.put("Help_Cmd_Chat", "/dxl chat - Change the Chat-Mode");
|
||||||
defaults.put("Help_Cmd_List", "/dxl list - Lists all dungeons");
|
defaults.put("Help_Cmd_Chatspy", "/dxl chatspy - Dis/enables the spymode");
|
||||||
defaults.put("Help_Cmd_Msg", "/dxl msg <id> '[msg]' - Show or edit a message");
|
defaults.put("Help_Cmd_Create", "/dxl create <name> - Creates a new dungeon");
|
||||||
defaults.put("Help_Cmd_Portal", "/dxl portal - Creates a portal that leads into a dungeon");
|
defaults.put("Help_Cmd_Edit", "/dxl edit <name> - Edit an existing dungeon");
|
||||||
defaults.put("Help_Cmd_DeletePortal", "/dxl deleteportal - Deletes the portal you are looking at");
|
defaults.put("Help_Cmd_Help", "/dxl help <page> - Shows the help page");
|
||||||
defaults.put("Help_Cmd_Reload", "/dxl reload - Reloads the plugin");
|
defaults.put("Help_Cmd_Invite", "/dxl invite <player> <dungeon> - Invite a player to edit a dungeon");
|
||||||
defaults.put("Help_Cmd_Save", "/dxl save - Saves the current dungeon");
|
defaults.put("Help_Cmd_Leave", "/dxl leave - Leaves the current dungeon");
|
||||||
defaults.put("Help_Cmd_Play", "/dxl play [dungeon]");
|
defaults.put("Help_Cmd_Escape", "/dxl escape - Leaves the current dungeon, without saving!");
|
||||||
defaults.put("Help_Cmd_Test", "/dxl test [dungeon] - Tests a dungeon");
|
defaults.put("Help_Cmd_List", "/dxl list <page> - Lists all dungeons");
|
||||||
defaults.put("Help_Cmd_Lives", "/dxl lives <player> - Shows the lives a player has left");
|
defaults.put("Help_Cmd_Main", "/dxl - General status information");
|
||||||
defaults.put("Help_Cmd_Uninvite", "/dxl uninvite <player> <dungeon> - Uninvite a player to edit a dungeon");
|
defaults.put("Help_Cmd_Msg", "/dxl msg <id> '[msg]' - Show or edit a message");
|
||||||
}
|
defaults.put("Help_Cmd_Portal", "/dxl portal - Creates a portal that leads into a dungeon");
|
||||||
|
defaults.put("Help_Cmd_DeletePortal", "/dxl deleteportal - Deletes the portal you are looking at");
|
||||||
private void check() {
|
defaults.put("Help_Cmd_Reload", "/dxl reload - Reloads the plugin");
|
||||||
for (String defaultEntry : defaults.keySet()) {
|
defaults.put("Help_Cmd_Save", "/dxl save - Saves the current dungeon");
|
||||||
if (!entries.containsKey(defaultEntry)) {
|
defaults.put("Help_Cmd_Play", "/dxl play [dungeon]");
|
||||||
entries.put(defaultEntry, defaults.get(defaultEntry));
|
defaults.put("Help_Cmd_Test", "/dxl test [dungeon] - Tests a dungeon");
|
||||||
changed = true;
|
defaults.put("Help_Cmd_Lives", "/dxl lives <player> - Shows the lives a player has left");
|
||||||
}
|
defaults.put("Help_Cmd_Uninvite", "/dxl uninvite <player> <dungeon> - Uninvite a player to edit a dungeon");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private void check() {
|
||||||
public void save() {
|
for (String defaultEntry : defaults.keySet()) {
|
||||||
if (changed) {
|
if ( !entries.containsKey(defaultEntry)) {
|
||||||
/* Copy old File */
|
entries.put(defaultEntry, defaults.get(defaultEntry));
|
||||||
File source = new File(file.getPath());
|
changed = true;
|
||||||
String filePath = file.getPath();
|
}
|
||||||
File temp = new File(filePath.substring(0, filePath.length() - 4) + "_old.yml");
|
}
|
||||||
|
}
|
||||||
if (temp.exists())
|
|
||||||
temp.delete();
|
public void save() {
|
||||||
|
if (changed) {
|
||||||
source.renameTo(temp);
|
/* Copy old File */
|
||||||
|
File source = new File(file.getPath());
|
||||||
/* Save */
|
String filePath = file.getPath();
|
||||||
FileConfiguration configFile = new YamlConfiguration();
|
File temp = new File(filePath.substring(0, filePath.length() - 4) + "_old.yml");
|
||||||
|
|
||||||
for (String key : entries.keySet()) {
|
if (temp.exists()) {
|
||||||
configFile.set(key, entries.get(key));
|
temp.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
source.renameTo(temp);
|
||||||
configFile.save(file);
|
|
||||||
} catch (IOException e) {
|
/* Save */
|
||||||
e.printStackTrace();
|
FileConfiguration configFile = new YamlConfiguration();
|
||||||
}
|
|
||||||
}
|
for (String key : entries.keySet()) {
|
||||||
}
|
configFile.set(key, entries.get(key));
|
||||||
|
}
|
||||||
public String get(String key, String... args) {
|
|
||||||
String entry = entries.get(key);
|
try {
|
||||||
|
configFile.save(file);
|
||||||
if (entry != null) {
|
} catch (IOException e) {
|
||||||
int i = 0;
|
e.printStackTrace();
|
||||||
for (String arg : args) {
|
}
|
||||||
i++;
|
}
|
||||||
if(arg != null){
|
}
|
||||||
entry = entry.replace("&v" + i, arg);
|
|
||||||
} else {
|
public String get(String key, String... args) {
|
||||||
entry = entry.replace("&v" + i, "null");
|
String entry = entries.get(key);
|
||||||
}
|
|
||||||
}
|
if (entry != null) {
|
||||||
}
|
int i = 0;
|
||||||
|
for (String arg : args) {
|
||||||
return entry;
|
i++;
|
||||||
}
|
if (arg != null) {
|
||||||
}
|
entry = entry.replace("&v" + i, arg);
|
||||||
|
} else {
|
||||||
|
entry = entry.replace("&v" + i, "null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
111
src/io/github/dre2n/dungeonsxl/file/MainConfig.java
Normal file
111
src/io/github/dre2n/dungeonsxl/file/MainConfig.java
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.file;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
public class MainConfig {
|
||||||
|
|
||||||
|
private String language = "en";
|
||||||
|
private boolean enableEconomy = false;
|
||||||
|
|
||||||
|
/* Tutorial */
|
||||||
|
private boolean tutorialActivated = false;
|
||||||
|
private String tutorialDungeon = "tutorial";
|
||||||
|
private String tutorialStartGroup = "default";
|
||||||
|
private String tutorialEndGroup = "player";
|
||||||
|
|
||||||
|
/* Default Dungeon Settings */
|
||||||
|
public WorldConfig defaultDungeon;
|
||||||
|
|
||||||
|
public MainConfig(File file) {
|
||||||
|
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
|
||||||
|
|
||||||
|
/* Main Config */
|
||||||
|
if (configFile.contains("language")) {
|
||||||
|
language = configFile.getString("language");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configFile.contains("enableEconomy")) {
|
||||||
|
enableEconomy = configFile.getBoolean("enableEconomy");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configFile.contains("tutorial.activated")) {
|
||||||
|
tutorialActivated = configFile.getBoolean("tutorial.activated");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configFile.contains("tutorial.dungeon")) {
|
||||||
|
tutorialDungeon = configFile.getString("tutorial.dungeon");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configFile.contains("tutorial.startgroup")) {
|
||||||
|
tutorialStartGroup = configFile.getString("tutorial.startgroup");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configFile.contains("tutorial.endgroup")) {
|
||||||
|
tutorialEndGroup = configFile.getString("tutorial.endgroup");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Default Dungeon Config */
|
||||||
|
ConfigurationSection configSetion = configFile.getConfigurationSection("default");
|
||||||
|
if (configSetion != null) {
|
||||||
|
defaultDungeon = new WorldConfig(configSetion);
|
||||||
|
WorldConfig.defaultConfig = defaultDungeon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the language
|
||||||
|
*/
|
||||||
|
public String getLanguage() {
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param language
|
||||||
|
* the language to set
|
||||||
|
*/
|
||||||
|
public void setLanguage(String language) {
|
||||||
|
this.language = language;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the enableEconomy
|
||||||
|
*/
|
||||||
|
public boolean enableEconomy() {
|
||||||
|
return enableEconomy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the tutorialActivated
|
||||||
|
*/
|
||||||
|
public boolean isTutorialActivated() {
|
||||||
|
return tutorialActivated;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the tutorialDungeon
|
||||||
|
*/
|
||||||
|
public String getTutorialDungeon() {
|
||||||
|
return tutorialDungeon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the tutorialStartGroup
|
||||||
|
*/
|
||||||
|
public String getTutorialStartGroup() {
|
||||||
|
return tutorialStartGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the tutorialEndGroup
|
||||||
|
*/
|
||||||
|
public String getTutorialEndGroup() {
|
||||||
|
return tutorialEndGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,241 +1,325 @@
|
|||||||
package com.dre.dungeonsxl;
|
package io.github.dre2n.dungeonsxl.global;
|
||||||
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
import org.bukkit.Material;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import org.bukkit.Location;
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
import org.bukkit.World;
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
public class DPortal {
|
import org.bukkit.entity.Player;
|
||||||
public static P p = P.p;
|
|
||||||
|
public class DPortal {
|
||||||
public static CopyOnWriteArrayList<DPortal> portals = new CopyOnWriteArrayList<DPortal>();
|
|
||||||
|
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
||||||
public World world;
|
|
||||||
public Block block1, block2;
|
private World world;
|
||||||
public boolean isActive;
|
private Block block1;
|
||||||
public Player player;
|
private Block block2;
|
||||||
|
private boolean isActive;
|
||||||
public DPortal(boolean active) {
|
private Player player;
|
||||||
portals.add(this);
|
|
||||||
this.isActive = active;
|
public DPortal(boolean active) {
|
||||||
}
|
plugin.getDPortals().add(this);
|
||||||
|
isActive = active;
|
||||||
public void create() {
|
}
|
||||||
this.player = null;
|
|
||||||
|
public void create() {
|
||||||
if (this.block1 != null && this.block2 != null) {
|
player = null;
|
||||||
int x1 = block1.getX(), y1 = block1.getY(), z1 = block1.getZ();
|
|
||||||
int x2 = block2.getX(), y2 = block2.getY(), z2 = block2.getZ();
|
if (block1 != null && block2 != null) {
|
||||||
int xcount = 0, ycount = 0, zcount = 0;
|
int x1 = block1.getX(), y1 = block1.getY(), z1 = block1.getZ();
|
||||||
|
int x2 = block2.getX(), y2 = block2.getY(), z2 = block2.getZ();
|
||||||
if (x1 > x2) {
|
int xcount = 0, ycount = 0, zcount = 0;
|
||||||
xcount = -1;
|
|
||||||
} else if (x1 < x2) {
|
if (x1 > x2) {
|
||||||
xcount = 1;
|
xcount = -1;
|
||||||
}
|
} else if (x1 < x2) {
|
||||||
if (y1 > y2) {
|
xcount = 1;
|
||||||
ycount = -1;
|
}
|
||||||
} else if (y1 < y2) {
|
if (y1 > y2) {
|
||||||
ycount = 1;
|
ycount = -1;
|
||||||
}
|
} else if (y1 < y2) {
|
||||||
if (z1 > z2) {
|
ycount = 1;
|
||||||
zcount = -1;
|
}
|
||||||
} else if (z1 < z2) {
|
if (z1 > z2) {
|
||||||
zcount = 1;
|
zcount = -1;
|
||||||
}
|
} else if (z1 < z2) {
|
||||||
|
zcount = 1;
|
||||||
int xx = x1;
|
}
|
||||||
do {
|
|
||||||
int yy = y1;
|
int xx = x1;
|
||||||
do {
|
do {
|
||||||
int zz = z1;
|
int yy = y1;
|
||||||
do {
|
do {
|
||||||
Material type = this.world.getBlockAt(xx, yy, zz).getType();
|
int zz = z1;
|
||||||
if (type == Material.AIR || type == Material.WATER || type == Material.STATIONARY_WATER || type == Material.LAVA || type == Material.STATIONARY_LAVA || type == Material.SAPLING
|
do {
|
||||||
|| type == Material.WEB || type == Material.LONG_GRASS || type == Material.DEAD_BUSH || type == Material.PISTON_EXTENSION || type == Material.YELLOW_FLOWER
|
Material type = world.getBlockAt(xx, yy, zz).getType();
|
||||||
|| type == Material.RED_ROSE || type == Material.BROWN_MUSHROOM || type == Material.RED_MUSHROOM || type == Material.TORCH || type == Material.FIRE
|
if (type == Material.AIR || type == Material.WATER || type == Material.STATIONARY_WATER || type == Material.LAVA || type == Material.STATIONARY_LAVA
|
||||||
|| type == Material.CROPS || type == Material.REDSTONE_WIRE || type == Material.REDSTONE_TORCH_OFF || type == Material.SNOW || type == Material.REDSTONE_TORCH_ON) {
|
|| type == Material.SAPLING || type == Material.WEB || type == Material.LONG_GRASS || type == Material.DEAD_BUSH || type == Material.PISTON_EXTENSION
|
||||||
this.world.getBlockAt(xx, yy, zz).setType(Material.PORTAL);
|
|| type == Material.YELLOW_FLOWER || type == Material.RED_ROSE || type == Material.BROWN_MUSHROOM || type == Material.RED_MUSHROOM || type == Material.TORCH
|
||||||
}
|
|| type == Material.FIRE || type == Material.CROPS || type == Material.REDSTONE_WIRE || type == Material.REDSTONE_TORCH_OFF || type == Material.SNOW
|
||||||
|
|| type == Material.REDSTONE_TORCH_ON) {
|
||||||
zz = zz + zcount;
|
world.getBlockAt(xx, yy, zz).setType(Material.PORTAL);
|
||||||
} while (zz != z2 + zcount);
|
}
|
||||||
|
|
||||||
yy = yy + ycount;
|
zz = zz + zcount;
|
||||||
} while (yy != y2 + ycount);
|
} while (zz != z2 + zcount);
|
||||||
|
|
||||||
xx = xx + xcount;
|
yy = yy + ycount;
|
||||||
} while (xx != x2 + xcount);
|
} while (yy != y2 + ycount);
|
||||||
|
|
||||||
} else {
|
xx = xx + xcount;
|
||||||
portals.remove(this);
|
} while (xx != x2 + xcount);
|
||||||
}
|
|
||||||
}
|
} else {
|
||||||
|
plugin.getDPortals().remove(this);
|
||||||
public void teleport(Player player) {
|
}
|
||||||
|
}
|
||||||
DGroup dgroup = DGroup.get(player);
|
|
||||||
if (dgroup != null) {
|
public void teleport(Player player) {
|
||||||
if (dgroup.getGworld() == null) {
|
|
||||||
dgroup.setGworld(GameWorld.load(DGroup.get(player).getDungeonname()));
|
DGroup dgroup = DGroup.get(player);
|
||||||
}
|
if (dgroup != null) {
|
||||||
|
if (dgroup.getGworld() == null) {
|
||||||
if (dgroup.getGworld() != null) {
|
dgroup.setGworld(GameWorld.load(DGroup.get(player).getDungeonname()));
|
||||||
|
}
|
||||||
if (dgroup.getGworld().locLobby == null) {
|
|
||||||
new DPlayer(player, dgroup.getGworld().world, dgroup.getGworld().world.getSpawnLocation(), false);
|
if (dgroup.getGworld() != null) {
|
||||||
} else {
|
|
||||||
new DPlayer(player, dgroup.getGworld().world, dgroup.getGworld().locLobby, false);
|
if (dgroup.getGworld().locLobby == null) {
|
||||||
}
|
new DPlayer(player, dgroup.getGworld().world, dgroup.getGworld().world.getSpawnLocation(), false);
|
||||||
|
} else {
|
||||||
} else {
|
new DPlayer(player, dgroup.getGworld().world, dgroup.getGworld().locLobby, false);
|
||||||
p.msg(player, p.language.get("Error_DungeonNotExist", DGroup.get(player).getDungeonname()));
|
}
|
||||||
}
|
|
||||||
|
} else {
|
||||||
} else {
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_DungeonNotExist", DGroup.get(player).getDungeonname()));
|
||||||
p.msg(player, p.language.get("Error_NotInGroup"));
|
}
|
||||||
}
|
|
||||||
|
} else {
|
||||||
}
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInGroup"));
|
||||||
|
}
|
||||||
public void delete() {
|
|
||||||
portals.remove(this);
|
}
|
||||||
|
|
||||||
int x1 = block1.getX(), y1 = block1.getY(), z1 = block1.getZ();
|
public void delete() {
|
||||||
int x2 = block2.getX(), y2 = block2.getY(), z2 = block2.getZ();
|
plugin.getDPortals().remove(this);
|
||||||
int xcount = 0, ycount = 0, zcount = 0;
|
|
||||||
|
int x1 = block1.getX(), y1 = block1.getY(), z1 = block1.getZ();
|
||||||
if (x1 > x2) {
|
int x2 = block2.getX(), y2 = block2.getY(), z2 = block2.getZ();
|
||||||
xcount = -1;
|
int xcount = 0, ycount = 0, zcount = 0;
|
||||||
} else if (x1 < x2) {
|
|
||||||
xcount = 1;
|
if (x1 > x2) {
|
||||||
}
|
xcount = -1;
|
||||||
if (y1 > y2) {
|
} else if (x1 < x2) {
|
||||||
ycount = -1;
|
xcount = 1;
|
||||||
} else if (y1 < y2) {
|
}
|
||||||
ycount = 1;
|
if (y1 > y2) {
|
||||||
}
|
ycount = -1;
|
||||||
if (z1 > z2) {
|
} else if (y1 < y2) {
|
||||||
zcount = -1;
|
ycount = 1;
|
||||||
} else if (z1 < z2) {
|
}
|
||||||
zcount = 1;
|
if (z1 > z2) {
|
||||||
}
|
zcount = -1;
|
||||||
|
} else if (z1 < z2) {
|
||||||
int xx = x1;
|
zcount = 1;
|
||||||
do {
|
}
|
||||||
int yy = y1;
|
|
||||||
do {
|
int xx = x1;
|
||||||
int zz = z1;
|
do {
|
||||||
do {
|
int yy = y1;
|
||||||
Material type = this.world.getBlockAt(xx, yy, zz).getType();
|
do {
|
||||||
|
int zz = z1;
|
||||||
if (type == Material.PORTAL) {
|
do {
|
||||||
this.world.getBlockAt(xx, yy, zz).setType(Material.AIR);
|
Material type = world.getBlockAt(xx, yy, zz).getType();
|
||||||
}
|
|
||||||
|
if (type == Material.PORTAL) {
|
||||||
zz = zz + zcount;
|
world.getBlockAt(xx, yy, zz).setType(Material.AIR);
|
||||||
} while (zz != z2 + zcount);
|
}
|
||||||
|
|
||||||
yy = yy + ycount;
|
zz = zz + zcount;
|
||||||
} while (yy != y2 + ycount);
|
} while (zz != z2 + zcount);
|
||||||
|
|
||||||
xx = xx + xcount;
|
yy = yy + ycount;
|
||||||
} while (xx != x2 + xcount);
|
} while (yy != y2 + ycount);
|
||||||
}
|
|
||||||
|
xx = xx + xcount;
|
||||||
// Statics
|
} while (xx != x2 + xcount);
|
||||||
public static DPortal get(Location location) {
|
}
|
||||||
return get(location.getBlock());
|
|
||||||
}
|
// Statics
|
||||||
|
public static DPortal get(Location location) {
|
||||||
public static DPortal get(Block block) {
|
return get(location.getBlock());
|
||||||
for (DPortal portal : portals) {
|
}
|
||||||
int x1 = portal.block1.getX(), y1 = portal.block1.getY(), z1 = portal.block1.getZ();
|
|
||||||
int x2 = portal.block2.getX(), y2 = portal.block2.getY(), z2 = portal.block2.getZ();
|
public static DPortal get(Block block) {
|
||||||
int x3 = block.getX(), y3 = block.getY(), z3 = block.getZ();
|
for (DPortal portal : plugin.getDPortals()) {
|
||||||
|
int x1 = portal.block1.getX(), y1 = portal.block1.getY(), z1 = portal.block1.getZ();
|
||||||
if (x1 > x2) {
|
int x2 = portal.block2.getX(), y2 = portal.block2.getY(), z2 = portal.block2.getZ();
|
||||||
if (x3 < x2 || x3 > x1)
|
int x3 = block.getX(), y3 = block.getY(), z3 = block.getZ();
|
||||||
continue;
|
|
||||||
} else {
|
if (x1 > x2) {
|
||||||
if (x3 > x2 || x3 < x1)
|
if (x3 < x2 || x3 > x1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if (y1 > y2) {
|
if (x3 > x2 || x3 < x1) {
|
||||||
if (y3 < y2 || y3 > y1)
|
continue;
|
||||||
continue;
|
}
|
||||||
} else {
|
}
|
||||||
if (y3 > y2 || y3 < y1)
|
|
||||||
continue;
|
if (y1 > y2) {
|
||||||
}
|
if (y3 < y2 || y3 > y1) {
|
||||||
|
continue;
|
||||||
if (z1 > z2) {
|
}
|
||||||
if (z3 < z2 || z3 > z1)
|
} else {
|
||||||
continue;
|
if (y3 > y2 || y3 < y1) {
|
||||||
} else {
|
continue;
|
||||||
if (z3 > z2 || z3 < z1)
|
}
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
|
if (z1 > z2) {
|
||||||
return portal;
|
if (z3 < z2 || z3 > z1) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
return null;
|
} else {
|
||||||
}
|
if (z3 > z2 || z3 < z1) {
|
||||||
|
continue;
|
||||||
public static DPortal get(Player player) {
|
}
|
||||||
for (DPortal portal : portals) {
|
}
|
||||||
if (portal.player == player) {
|
|
||||||
return portal;
|
return portal;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save and Load
|
public static DPortal get(Player player) {
|
||||||
public static void save(FileConfiguration configFile) {
|
for (DPortal portal : plugin.getDPortals()) {
|
||||||
int id = 0;
|
if (portal.player == player) {
|
||||||
for (DPortal dportal : portals) {
|
return portal;
|
||||||
id++;
|
}
|
||||||
if (dportal.isActive) {
|
}
|
||||||
String preString = "portal." + dportal.world.getName() + "." + id;
|
return null;
|
||||||
// Location1
|
}
|
||||||
configFile.set(preString + ".loc1.x", dportal.block1.getX());
|
|
||||||
configFile.set(preString + ".loc1.y", dportal.block1.getY());
|
// Save and Load
|
||||||
configFile.set(preString + ".loc1.z", dportal.block1.getZ());
|
public static void save(FileConfiguration configFile) {
|
||||||
// Location1
|
int id = 0;
|
||||||
configFile.set(preString + ".loc2.x", dportal.block2.getX());
|
for (DPortal dportal : plugin.getDPortals()) {
|
||||||
configFile.set(preString + ".loc2.y", dportal.block2.getY());
|
id++;
|
||||||
configFile.set(preString + ".loc2.z", dportal.block2.getZ());
|
if (dportal.isActive) {
|
||||||
}
|
String preString = "portal." + dportal.world.getName() + "." + id;
|
||||||
}
|
// Location1
|
||||||
}
|
configFile.set(preString + ".loc1.x", dportal.block1.getX());
|
||||||
|
configFile.set(preString + ".loc1.y", dportal.block1.getY());
|
||||||
public static void load(FileConfiguration configFile) {
|
configFile.set(preString + ".loc1.z", dportal.block1.getZ());
|
||||||
for (World world : p.getServer().getWorlds()) {
|
// Location1
|
||||||
if (configFile.contains("portal." + world.getName())) {
|
configFile.set(preString + ".loc2.x", dportal.block2.getX());
|
||||||
int id = 0;
|
configFile.set(preString + ".loc2.y", dportal.block2.getY());
|
||||||
String preString;
|
configFile.set(preString + ".loc2.z", dportal.block2.getZ());
|
||||||
do {
|
}
|
||||||
id++;
|
}
|
||||||
preString = "portal." + world.getName() + "." + id + ".";
|
}
|
||||||
if (configFile.contains(preString)) {
|
|
||||||
DPortal dportal = new DPortal(true);
|
public static void load(FileConfiguration configFile) {
|
||||||
dportal.world = world;
|
for (World world : plugin.getServer().getWorlds()) {
|
||||||
dportal.block1 = world.getBlockAt(configFile.getInt(preString + "loc1.x"), configFile.getInt(preString + "loc1.y"), configFile.getInt(preString + "loc1.z"));
|
if (configFile.contains("portal." + world.getName())) {
|
||||||
dportal.block2 = world.getBlockAt(configFile.getInt(preString + "loc2.x"), configFile.getInt(preString + "loc2.y"), configFile.getInt(preString + "loc2.z"));
|
int id = 0;
|
||||||
dportal.create();
|
String preString;
|
||||||
}
|
do {
|
||||||
} while (configFile.contains(preString));
|
id++;
|
||||||
}
|
preString = "portal." + world.getName() + "." + id + ".";
|
||||||
}
|
if (configFile.contains(preString)) {
|
||||||
}
|
DPortal dportal = new DPortal(true);
|
||||||
|
dportal.world = world;
|
||||||
}
|
dportal.block1 = world.getBlockAt(configFile.getInt(preString + "loc1.x"), configFile.getInt(preString + "loc1.y"), configFile.getInt(preString + "loc1.z"));
|
||||||
|
dportal.block2 = world.getBlockAt(configFile.getInt(preString + "loc2.x"), configFile.getInt(preString + "loc2.y"), configFile.getInt(preString + "loc2.z"));
|
||||||
|
dportal.create();
|
||||||
|
}
|
||||||
|
} while (configFile.contains(preString));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the world
|
||||||
|
*/
|
||||||
|
public World getWorld() {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param world
|
||||||
|
* the world to set
|
||||||
|
*/
|
||||||
|
public void setWorld(World world) {
|
||||||
|
this.world = world;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the block1
|
||||||
|
*/
|
||||||
|
public Block getBlock1() {
|
||||||
|
return block1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param block1
|
||||||
|
* the block1 to set
|
||||||
|
*/
|
||||||
|
public void setBlock1(Block block1) {
|
||||||
|
this.block1 = block1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the block2
|
||||||
|
*/
|
||||||
|
public Block getBlock2() {
|
||||||
|
return block2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param block2
|
||||||
|
* the block2 to set
|
||||||
|
*/
|
||||||
|
public void setBlock2(Block block2) {
|
||||||
|
this.block2 = block2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the isActive
|
||||||
|
*/
|
||||||
|
public boolean isActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param isActive
|
||||||
|
* the isActive to set
|
||||||
|
*/
|
||||||
|
public void setActive(boolean isActive) {
|
||||||
|
this.isActive = isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the player
|
||||||
|
*/
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param player
|
||||||
|
* the player to set
|
||||||
|
*/
|
||||||
|
public void setPlayer(Player player) {
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,375 +1,399 @@
|
|||||||
package com.dre.dungeonsxl;
|
package io.github.dre2n.dungeonsxl.global;
|
||||||
|
|
||||||
import java.io.File;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
import org.bukkit.ChatColor;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import org.bukkit.Material;
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
import java.io.File;
|
||||||
import org.bukkit.block.Sign;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
public class DGSign {
|
import org.bukkit.block.Sign;
|
||||||
public static CopyOnWriteArrayList<DGSign> dgsigns = new CopyOnWriteArrayList<DGSign>();
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
// Sign Labels
|
|
||||||
public static String strIsPlaying = ChatColor.DARK_RED + "Is Playing";
|
public class GroupSign {
|
||||||
public static String strFull = ChatColor.DARK_RED + "Full";
|
|
||||||
public static String strJoinGrp = ChatColor.DARK_GREEN + "Join Group";
|
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
||||||
public static String strNewGrp = ChatColor.DARK_GREEN + "New Group";
|
|
||||||
|
// Sign Labels
|
||||||
// Variables
|
public static final String strIsPlaying = ChatColor.DARK_RED + "Is Playing";
|
||||||
public DGroup[] dgroups;
|
public static final String strFull = ChatColor.DARK_RED + "Full";
|
||||||
public String dungeonName;
|
public static final String strJoinGrp = ChatColor.DARK_GREEN + "Join Group";
|
||||||
public int maxPlayersPerGroup;
|
public static final String strNewGrp = ChatColor.DARK_GREEN + "New Group";
|
||||||
public Block startSign;
|
|
||||||
public int directionX = 0, directionZ = 0;
|
// Variables
|
||||||
public int verticalSigns;
|
private DGroup[] dgroups;
|
||||||
|
private String dungeonName;
|
||||||
public DGSign(Block startSign, String dungeonName, int maxGroups, int maxPlayersPerGroup) {
|
private int maxPlayersPerGroup;
|
||||||
dgsigns.add(this);
|
private Block startSign;
|
||||||
|
private int directionX = 0, directionZ = 0;
|
||||||
this.startSign = startSign;
|
private int verticalSigns;
|
||||||
this.dungeonName = dungeonName;
|
|
||||||
this.dgroups = new DGroup[maxGroups];
|
public GroupSign(Block startSign, String dungeonName, int maxGroups, int maxPlayersPerGroup) {
|
||||||
this.maxPlayersPerGroup = maxPlayersPerGroup;
|
plugin.getGroupSigns().add(this);
|
||||||
this.verticalSigns = (int) Math.ceil((float) (1 + maxPlayersPerGroup) / 4);
|
|
||||||
|
this.startSign = startSign;
|
||||||
int[] direction = getDirection(this.startSign.getData());
|
this.dungeonName = dungeonName;
|
||||||
this.directionX = direction[0];
|
dgroups = new DGroup[maxGroups];
|
||||||
this.directionZ = direction[1];
|
this.maxPlayersPerGroup = maxPlayersPerGroup;
|
||||||
|
verticalSigns = (int) Math.ceil((float) (1 + maxPlayersPerGroup) / 4);
|
||||||
this.update();
|
|
||||||
}
|
@SuppressWarnings("deprecation")
|
||||||
|
int[] direction = getDirection(this.startSign.getData());
|
||||||
public void update() {
|
directionX = direction[0];
|
||||||
int i = 0;
|
directionZ = direction[1];
|
||||||
for (DGroup dgroup : this.dgroups) {
|
|
||||||
if ((this.startSign.getRelative(i * directionX, 0, i * directionZ).getState() instanceof Sign)) {
|
update();
|
||||||
Sign sign = (Sign) this.startSign.getRelative(i * directionX, 0, i * directionZ).getState();
|
}
|
||||||
|
|
||||||
// Reset Signs
|
public void update() {
|
||||||
sign.setLine(0, "");
|
int i = 0;
|
||||||
sign.setLine(1, "");
|
for (DGroup dgroup : dgroups) {
|
||||||
sign.setLine(2, "");
|
if (startSign.getRelative(i * directionX, 0, i * directionZ).getState() instanceof Sign) {
|
||||||
sign.setLine(3, "");
|
Sign sign = (Sign) startSign.getRelative(i * directionX, 0, i * directionZ).getState();
|
||||||
|
|
||||||
int yy = -1;
|
// Reset Signs
|
||||||
while (sign.getBlock().getRelative(0, yy, 0).getState() instanceof Sign) {
|
sign.setLine(0, "");
|
||||||
Sign subsign = (Sign) sign.getBlock().getRelative(0, yy, 0).getState();
|
sign.setLine(1, "");
|
||||||
subsign.setLine(0, "");
|
sign.setLine(2, "");
|
||||||
subsign.setLine(1, "");
|
sign.setLine(3, "");
|
||||||
subsign.setLine(2, "");
|
|
||||||
subsign.setLine(3, "");
|
int yy = -1;
|
||||||
subsign.update();
|
while (sign.getBlock().getRelative(0, yy, 0).getState() instanceof Sign) {
|
||||||
yy--;
|
Sign subsign = (Sign) sign.getBlock().getRelative(0, yy, 0).getState();
|
||||||
}
|
subsign.setLine(0, "");
|
||||||
|
subsign.setLine(1, "");
|
||||||
// Set Signs
|
subsign.setLine(2, "");
|
||||||
if (dgroup != null) {
|
subsign.setLine(3, "");
|
||||||
if (dgroup.isPlaying) {
|
subsign.update();
|
||||||
sign.setLine(0, strIsPlaying);
|
yy--;
|
||||||
} else if (dgroup.getPlayers().size() >= this.maxPlayersPerGroup) {
|
}
|
||||||
sign.setLine(0, strFull);
|
|
||||||
} else {
|
// Set Signs
|
||||||
sign.setLine(0, strJoinGrp);
|
if (dgroup != null) {
|
||||||
}
|
if (dgroup.isPlaying()) {
|
||||||
int j = 1;
|
sign.setLine(0, strIsPlaying);
|
||||||
Sign rowSign = sign;
|
} else if (dgroup.getPlayers().size() >= maxPlayersPerGroup) {
|
||||||
for (Player player : dgroup.getPlayers()) {
|
sign.setLine(0, strFull);
|
||||||
if (j > 3) {
|
} else {
|
||||||
j = 0;
|
sign.setLine(0, strJoinGrp);
|
||||||
rowSign = (Sign) sign.getBlock().getRelative(0, -1, 0).getState();
|
}
|
||||||
}
|
int j = 1;
|
||||||
if (rowSign != null) {
|
Sign rowSign = sign;
|
||||||
rowSign.setLine(j, player.getName());
|
for (Player player : dgroup.getPlayers()) {
|
||||||
}
|
if (j > 3) {
|
||||||
j++;
|
j = 0;
|
||||||
rowSign.update();
|
rowSign = (Sign) sign.getBlock().getRelative(0, -1, 0).getState();
|
||||||
}
|
}
|
||||||
} else {
|
if (rowSign != null) {
|
||||||
sign.setLine(0, strNewGrp);
|
rowSign.setLine(j, player.getName());
|
||||||
}
|
}
|
||||||
sign.update();
|
j++;
|
||||||
}
|
rowSign.update();
|
||||||
i++;
|
}
|
||||||
}
|
} else {
|
||||||
}
|
sign.setLine(0, strNewGrp);
|
||||||
|
}
|
||||||
// Static
|
sign.update();
|
||||||
|
}
|
||||||
public static DGSign tryToCreate(Block startSign, String dungeonName, int maxGroups, int maxPlayersPerGroup) {
|
i++;
|
||||||
World world = startSign.getWorld();
|
}
|
||||||
int direction = startSign.getData();
|
}
|
||||||
int x = startSign.getX(), y = startSign.getY(), z = startSign.getZ();
|
|
||||||
|
// Static
|
||||||
int verticalSigns = (int) Math.ceil((float) (1 + maxPlayersPerGroup) / 4);
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
CopyOnWriteArrayList<Block> changeBlocks = new CopyOnWriteArrayList<Block>();
|
public static GroupSign tryToCreate(Block startSign, String dungeonName, int maxGroups, int maxPlayersPerGroup) {
|
||||||
|
World world = startSign.getWorld();
|
||||||
int xx, yy, zz;
|
int direction = startSign.getData();
|
||||||
switch (direction) {
|
int x = startSign.getX(), y = startSign.getY(), z = startSign.getZ();
|
||||||
case 2:
|
|
||||||
zz = z;
|
int verticalSigns = (int) Math.ceil((float) (1 + maxPlayersPerGroup) / 4);
|
||||||
for (yy = y; yy > y - verticalSigns; yy--) {
|
|
||||||
for (xx = x; xx > x - maxGroups; xx--) {
|
CopyOnWriteArrayList<Block> changeBlocks = new CopyOnWriteArrayList<Block>();
|
||||||
Block block = world.getBlockAt(xx, yy, zz);
|
|
||||||
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
|
int xx, yy, zz;
|
||||||
return null;
|
switch (direction) {
|
||||||
}
|
case 2:
|
||||||
if (block.getRelative(0, 0, 1).getType() == Material.AIR) {
|
zz = z;
|
||||||
return null;
|
for (yy = y; yy > y - verticalSigns; yy--) {
|
||||||
}
|
for (xx = x; xx > x - maxGroups; xx--) {
|
||||||
changeBlocks.add(block);
|
Block block = world.getBlockAt(xx, yy, zz);
|
||||||
}
|
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
|
||||||
}
|
return null;
|
||||||
break;
|
}
|
||||||
case 3:
|
if (block.getRelative(0, 0, 1).getType() == Material.AIR) {
|
||||||
zz = z;
|
return null;
|
||||||
for (yy = y; yy > y - verticalSigns; yy--) {
|
}
|
||||||
for (xx = x; xx < x + maxGroups; xx++) {
|
changeBlocks.add(block);
|
||||||
|
}
|
||||||
Block block = world.getBlockAt(xx, yy, zz);
|
}
|
||||||
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
|
break;
|
||||||
return null;
|
case 3:
|
||||||
}
|
zz = z;
|
||||||
if (block.getRelative(0, 0, -1).getType() == Material.AIR) {
|
for (yy = y; yy > y - verticalSigns; yy--) {
|
||||||
return null;
|
for (xx = x; xx < x + maxGroups; xx++) {
|
||||||
}
|
|
||||||
changeBlocks.add(block);
|
Block block = world.getBlockAt(xx, yy, zz);
|
||||||
}
|
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
|
||||||
}
|
return null;
|
||||||
break;
|
}
|
||||||
case 4:
|
if (block.getRelative(0, 0, -1).getType() == Material.AIR) {
|
||||||
xx = x;
|
return null;
|
||||||
for (yy = y; yy > y - verticalSigns; yy--) {
|
}
|
||||||
for (zz = z; zz < z + maxGroups; zz++) {
|
changeBlocks.add(block);
|
||||||
Block block = world.getBlockAt(xx, yy, zz);
|
}
|
||||||
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
|
}
|
||||||
return null;
|
break;
|
||||||
}
|
case 4:
|
||||||
if (block.getRelative(1, 0, 0).getType() == Material.AIR) {
|
xx = x;
|
||||||
return null;
|
for (yy = y; yy > y - verticalSigns; yy--) {
|
||||||
}
|
for (zz = z; zz < z + maxGroups; zz++) {
|
||||||
changeBlocks.add(block);
|
Block block = world.getBlockAt(xx, yy, zz);
|
||||||
}
|
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
|
||||||
}
|
return null;
|
||||||
break;
|
}
|
||||||
case 5:
|
if (block.getRelative(1, 0, 0).getType() == Material.AIR) {
|
||||||
xx = x;
|
return null;
|
||||||
for (yy = y; yy > y - verticalSigns; yy--) {
|
}
|
||||||
for (zz = z; zz > z - maxGroups; zz--) {
|
changeBlocks.add(block);
|
||||||
Block block = world.getBlockAt(xx, yy, zz);
|
}
|
||||||
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
|
}
|
||||||
return null;
|
break;
|
||||||
}
|
case 5:
|
||||||
if (block.getRelative(-1, 0, 0).getType() == Material.AIR) {
|
xx = x;
|
||||||
return null;
|
for (yy = y; yy > y - verticalSigns; yy--) {
|
||||||
}
|
for (zz = z; zz > z - maxGroups; zz--) {
|
||||||
changeBlocks.add(block);
|
Block block = world.getBlockAt(xx, yy, zz);
|
||||||
}
|
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
|
||||||
}
|
return null;
|
||||||
break;
|
}
|
||||||
}
|
if (block.getRelative( -1, 0, 0).getType() == Material.AIR) {
|
||||||
|
return null;
|
||||||
for (Block block : changeBlocks) {
|
}
|
||||||
block.setTypeIdAndData(68, startSign.getData(), true);
|
changeBlocks.add(block);
|
||||||
}
|
}
|
||||||
DGSign sign = new DGSign(startSign, dungeonName, maxGroups, maxPlayersPerGroup);
|
}
|
||||||
|
break;
|
||||||
return sign;
|
}
|
||||||
}
|
|
||||||
|
for (Block block : changeBlocks) {
|
||||||
public static boolean isRelativeSign(Block block, int x, int z) {
|
block.setTypeIdAndData(68, startSign.getData(), true);
|
||||||
DGSign dgsign = getSign(block.getRelative(x, 0, z));
|
}
|
||||||
if (dgsign != null) {
|
GroupSign sign = new GroupSign(startSign, dungeonName, maxGroups, maxPlayersPerGroup);
|
||||||
if (x == -1 && dgsign.startSign.getData() == 4)
|
|
||||||
return true;
|
return sign;
|
||||||
if (x == 1 && dgsign.startSign.getData() == 5)
|
}
|
||||||
return true;
|
|
||||||
if (z == -1 && dgsign.startSign.getData() == 2)
|
@SuppressWarnings("deprecation")
|
||||||
return true;
|
public static boolean isRelativeSign(Block block, int x, int z) {
|
||||||
if (z == 1 && dgsign.startSign.getData() == 3)
|
GroupSign dgsign = getSign(block.getRelative(x, 0, z));
|
||||||
return true;
|
if (dgsign != null) {
|
||||||
}
|
if (x == -1 && dgsign.startSign.getData() == 4) {
|
||||||
|
return true;
|
||||||
return false;
|
}
|
||||||
}
|
if (x == 1 && dgsign.startSign.getData() == 5) {
|
||||||
|
return true;
|
||||||
public static DGSign getSign(Block block) {
|
}
|
||||||
if (block.getType() == Material.WALL_SIGN) {
|
if (z == -1 && dgsign.startSign.getData() == 2) {
|
||||||
int x = block.getX(), y = block.getY(), z = block.getZ();
|
return true;
|
||||||
for (DGSign dgsign : dgsigns) {
|
}
|
||||||
int sx1 = dgsign.startSign.getX(), sy1 = dgsign.startSign.getY(), sz1 = dgsign.startSign.getZ();
|
if (z == 1 && dgsign.startSign.getData() == 3) {
|
||||||
int sx2 = sx1 + (dgsign.dgroups.length - 1) * dgsign.directionX;
|
return true;
|
||||||
int sy2 = sy1 - dgsign.verticalSigns + 1;
|
}
|
||||||
int sz2 = sz1 + (dgsign.dgroups.length - 1) * dgsign.directionZ;
|
}
|
||||||
|
|
||||||
if (sx1 > sx2) {
|
return false;
|
||||||
if (x < sx2 || x > sx1)
|
}
|
||||||
continue;
|
|
||||||
} else if (sx1 < sx2) {
|
public static GroupSign getSign(Block block) {
|
||||||
if (x > sx2 || x < sx1)
|
if (block.getType() == Material.WALL_SIGN) {
|
||||||
continue;
|
int x = block.getX(), y = block.getY(), z = block.getZ();
|
||||||
} else {
|
for (GroupSign dgsign : plugin.getGroupSigns()) {
|
||||||
if (x != sx1)
|
int sx1 = dgsign.startSign.getX(), sy1 = dgsign.startSign.getY(), sz1 = dgsign.startSign.getZ();
|
||||||
continue;
|
int sx2 = sx1 + (dgsign.dgroups.length - 1) * dgsign.directionX;
|
||||||
}
|
int sy2 = sy1 - dgsign.verticalSigns + 1;
|
||||||
if (sy1 > sy2) {
|
int sz2 = sz1 + (dgsign.dgroups.length - 1) * dgsign.directionZ;
|
||||||
if (y < sy2 || y > sy1)
|
|
||||||
continue;
|
if (sx1 > sx2) {
|
||||||
} else {
|
if (x < sx2 || x > sx1) {
|
||||||
if (y != sy1)
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
} else if (sx1 < sx2) {
|
||||||
if (sz1 > sz2) {
|
if (x > sx2 || x < sx1) {
|
||||||
if (z < sz2 || z > sz1)
|
continue;
|
||||||
continue;
|
}
|
||||||
} else if (sz1 < sz2) {
|
} else {
|
||||||
if (z > sz2 || z < sz1)
|
if (x != sx1) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
}
|
||||||
if (z != sz1)
|
}
|
||||||
continue;
|
if (sy1 > sy2) {
|
||||||
}
|
if (y < sy2 || y > sy1) {
|
||||||
|
continue;
|
||||||
return dgsign;
|
}
|
||||||
}
|
} else {
|
||||||
}
|
if (y != sy1) {
|
||||||
return null;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public static boolean playerInteract(Block block, Player player) {
|
if (sz1 > sz2) {
|
||||||
int x = block.getX(), y = block.getY(), z = block.getZ();
|
if (z < sz2 || z > sz1) {
|
||||||
DGSign dgsign = getSign(block);
|
continue;
|
||||||
if (dgsign != null) {
|
}
|
||||||
if (GameWorld.canPlayDungeon(dgsign.dungeonName, player)) {
|
} else if (sz1 < sz2) {
|
||||||
if (GameWorld.checkRequirements(dgsign.dungeonName, player)) {
|
if (z > sz2 || z < sz1) {
|
||||||
int sx1 = dgsign.startSign.getX(), sy1 = dgsign.startSign.getY(), sz1 = dgsign.startSign.getZ();
|
continue;
|
||||||
|
}
|
||||||
Block topBlock = block.getRelative(0, sy1 - y, 0);
|
} else {
|
||||||
|
if (z != sz1) {
|
||||||
int column;
|
continue;
|
||||||
if (dgsign.directionX != 0) {
|
}
|
||||||
column = Math.abs(x - sx1);
|
}
|
||||||
} else {
|
|
||||||
column = Math.abs(z - sz1);
|
return dgsign;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ((topBlock.getState() instanceof Sign)) {
|
return null;
|
||||||
Sign topSign = (Sign) topBlock.getState();
|
}
|
||||||
if (topSign.getLine(0).equals(strNewGrp)) {
|
|
||||||
if (DGroup.get(player) == null) {
|
public static boolean playerInteract(Block block, Player player) {
|
||||||
dgsign.dgroups[column] = new DGroup(player, dgsign.dungeonName);
|
int x = block.getX(), y = block.getY(), z = block.getZ();
|
||||||
dgsign.update();
|
GroupSign dgsign = getSign(block);
|
||||||
}
|
if (dgsign != null) {
|
||||||
} else if (topSign.getLine(0).equals(strJoinGrp)) {
|
if (GameWorld.canPlayDungeon(dgsign.dungeonName, player)) {
|
||||||
if (DGroup.get(player) == null) {
|
if (GameWorld.checkRequirements(dgsign.dungeonName, player)) {
|
||||||
dgsign.dgroups[column].addPlayer(player);
|
int sx1 = dgsign.startSign.getX(), sy1 = dgsign.startSign.getY(), sz1 = dgsign.startSign.getZ();
|
||||||
dgsign.update();
|
|
||||||
}
|
Block topBlock = block.getRelative(0, sy1 - y, 0);
|
||||||
}
|
|
||||||
|
int column;
|
||||||
}
|
if (dgsign.directionX != 0) {
|
||||||
} else {
|
column = Math.abs(x - sx1);
|
||||||
P.p.msg(player, P.p.language.get("Error_Requirements"));
|
} else {
|
||||||
}
|
column = Math.abs(z - sz1);
|
||||||
} else {
|
}
|
||||||
File file = new File(P.p.getDataFolder() + "/dungeons/" + dgsign.dungeonName, "config.yml");
|
|
||||||
if (file != null) {
|
if (topBlock.getState() instanceof Sign) {
|
||||||
DConfig confReader = new DConfig(file);
|
Sign topSign = (Sign) topBlock.getState();
|
||||||
if (confReader != null) {
|
if (topSign.getLine(0).equals(strNewGrp)) {
|
||||||
P.p.msg(player, P.p.language.get("Error_Cooldown", "" + confReader.getTimeToNextPlay()));
|
if (DGroup.get(player) == null) {
|
||||||
}
|
dgsign.dgroups[column] = new DGroup(player, dgsign.dungeonName);
|
||||||
}
|
dgsign.update();
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
} else if (topSign.getLine(0).equals(strJoinGrp)) {
|
||||||
|
if (DGroup.get(player) == null) {
|
||||||
return false;
|
dgsign.dgroups[column].addPlayer(player);
|
||||||
}
|
dgsign.update();
|
||||||
|
}
|
||||||
public static void updatePerGroup(DGroup dgroupsearch) {
|
}
|
||||||
|
|
||||||
for (DGSign dgsign : dgsigns) {
|
}
|
||||||
int i = 0;
|
|
||||||
for (DGroup dgroup : dgsign.dgroups) {
|
} else {
|
||||||
if (dgroup != null) {
|
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_Requirements"));
|
||||||
if (dgroup == dgroupsearch) {
|
}
|
||||||
if (dgroupsearch.isEmpty())
|
|
||||||
dgsign.dgroups[i] = null;
|
} else {
|
||||||
dgsign.update();
|
File file = new File(DungeonsXL.getPlugin().getDataFolder() + "/maps/" + dgsign.dungeonName, "config.yml");
|
||||||
}
|
if (file != null) {
|
||||||
}
|
WorldConfig confReader = new WorldConfig(file);
|
||||||
i++;
|
if (confReader != null) {
|
||||||
}
|
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_Cooldown", "" + confReader.getTimeToNextPlay()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public static int[] getDirection(byte data) {
|
return true;
|
||||||
int[] direction = new int[2];
|
}
|
||||||
switch (data) {
|
|
||||||
case 2:
|
return false;
|
||||||
direction[0] = -1;
|
}
|
||||||
break;
|
|
||||||
case 3:
|
public static void updatePerGroup(DGroup dgroupsearch) {
|
||||||
direction[0] = 1;
|
|
||||||
break;
|
for (GroupSign dgsign : plugin.getGroupSigns()) {
|
||||||
case 4:
|
int i = 0;
|
||||||
direction[1] = 1;
|
for (DGroup dgroup : dgsign.dgroups) {
|
||||||
break;
|
if (dgroup != null) {
|
||||||
case 5:
|
if (dgroup == dgroupsearch) {
|
||||||
direction[1] = -1;
|
if (dgroupsearch.isEmpty()) {
|
||||||
break;
|
dgsign.dgroups[i] = null;
|
||||||
}
|
}
|
||||||
return direction;
|
dgsign.update();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Save and Load
|
i++;
|
||||||
public static void save(FileConfiguration configFile) {
|
}
|
||||||
int id = 0;
|
}
|
||||||
|
}
|
||||||
for (DGSign dgsign : dgsigns) {
|
|
||||||
id++;
|
public static int[] getDirection(byte data) {
|
||||||
String preString = "groupsign." + dgsign.startSign.getWorld().getName() + "." + id;
|
int[] direction = new int[2];
|
||||||
|
switch (data) {
|
||||||
// Location
|
case 2:
|
||||||
configFile.set(preString + ".x", dgsign.startSign.getX());
|
direction[0] = -1;
|
||||||
configFile.set(preString + ".y", dgsign.startSign.getY());
|
break;
|
||||||
configFile.set(preString + ".z", dgsign.startSign.getZ());
|
case 3:
|
||||||
|
direction[0] = 1;
|
||||||
// Etc.
|
break;
|
||||||
configFile.set(preString + ".dungeon", dgsign.dungeonName);
|
case 4:
|
||||||
configFile.set(preString + ".maxGroups", dgsign.dgroups.length);
|
direction[1] = 1;
|
||||||
configFile.set(preString + ".maxPlayersPerGroup", dgsign.maxPlayersPerGroup);
|
break;
|
||||||
|
case 5:
|
||||||
}
|
direction[1] = -1;
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
public static void load(FileConfiguration configFile) {
|
return direction;
|
||||||
for (World world : P.p.getServer().getWorlds()) {
|
}
|
||||||
if (configFile.contains("groupsign." + world.getName())) {
|
|
||||||
int id = 0;
|
// Save and Load
|
||||||
String preString;
|
public static void save(FileConfiguration configFile) {
|
||||||
do {
|
int id = 0;
|
||||||
id++;
|
|
||||||
preString = "groupsign." + world.getName() + "." + id + ".";
|
for (GroupSign dgsign : plugin.getGroupSigns()) {
|
||||||
if (configFile.contains(preString)) {
|
id++;
|
||||||
String dungeonName = configFile.getString(preString + ".dungeon");
|
String preString = "groupsign." + dgsign.startSign.getWorld().getName() + "." + id;
|
||||||
int maxGroups = configFile.getInt(preString + ".maxGroups");
|
|
||||||
int maxPlayersPerGroup = configFile.getInt(preString + ".maxPlayersPerGroup");
|
// Location
|
||||||
Block startSign = world.getBlockAt(configFile.getInt(preString + ".x"), configFile.getInt(preString + ".y"), configFile.getInt(preString + ".z"));
|
configFile.set(preString + ".x", dgsign.startSign.getX());
|
||||||
|
configFile.set(preString + ".y", dgsign.startSign.getY());
|
||||||
new DGSign(startSign, dungeonName, maxGroups, maxPlayersPerGroup);
|
configFile.set(preString + ".z", dgsign.startSign.getZ());
|
||||||
}
|
|
||||||
} while (configFile.contains(preString));
|
// Etc.
|
||||||
}
|
configFile.set(preString + ".dungeon", dgsign.dungeonName);
|
||||||
}
|
configFile.set(preString + ".maxGroups", dgsign.dgroups.length);
|
||||||
|
configFile.set(preString + ".maxPlayersPerGroup", dgsign.maxPlayersPerGroup);
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void load(FileConfiguration configFile) {
|
||||||
|
for (World world : DungeonsXL.getPlugin().getServer().getWorlds()) {
|
||||||
|
if (configFile.contains("groupsign." + world.getName())) {
|
||||||
|
int id = 0;
|
||||||
|
String preString;
|
||||||
|
do {
|
||||||
|
id++;
|
||||||
|
preString = "groupsign." + world.getName() + "." + id + ".";
|
||||||
|
if (configFile.contains(preString)) {
|
||||||
|
String dungeonName = configFile.getString(preString + ".dungeon");
|
||||||
|
int maxGroups = configFile.getInt(preString + ".maxGroups");
|
||||||
|
int maxPlayersPerGroup = configFile.getInt(preString + ".maxPlayersPerGroup");
|
||||||
|
Block startSign = world.getBlockAt(configFile.getInt(preString + ".x"), configFile.getInt(preString + ".y"), configFile.getInt(preString + ".z"));
|
||||||
|
|
||||||
|
new GroupSign(startSign, dungeonName, maxGroups, maxPlayersPerGroup);
|
||||||
|
}
|
||||||
|
} while (configFile.contains(preString));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,115 +1,124 @@
|
|||||||
package com.dre.dungeonsxl;
|
package io.github.dre2n.dungeonsxl.global;
|
||||||
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import org.bukkit.ChatColor;
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
import org.bukkit.Material;
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
public class LeaveSign {
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
public static CopyOnWriteArrayList<LeaveSign> lsigns = new CopyOnWriteArrayList<LeaveSign>();
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public Sign sign;
|
public class LeaveSign {
|
||||||
|
|
||||||
public LeaveSign(Sign sign) {
|
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
||||||
lsigns.add(this);
|
|
||||||
|
private Sign sign;
|
||||||
this.sign = sign;
|
|
||||||
this.setText();
|
public LeaveSign(Sign sign) {
|
||||||
}
|
plugin.getLeaveSigns().add(this);
|
||||||
|
|
||||||
public void setText() {
|
this.sign = sign;
|
||||||
this.sign.setLine(0, ChatColor.BLUE + "############");
|
setText();
|
||||||
this.sign.setLine(1, ChatColor.DARK_GREEN + "Leave");
|
}
|
||||||
this.sign.setLine(2, "");
|
|
||||||
this.sign.setLine(3, ChatColor.BLUE + "############");
|
public void setText() {
|
||||||
this.sign.update();
|
sign.setLine(0, ChatColor.BLUE + "############");
|
||||||
}
|
sign.setLine(1, ChatColor.DARK_GREEN + "Leave");
|
||||||
|
sign.setLine(2, "");
|
||||||
public static boolean playerInteract(Block block, Player player) {
|
sign.setLine(3, ChatColor.BLUE + "############");
|
||||||
|
sign.update();
|
||||||
LeaveSign lsign = getSign(block);
|
}
|
||||||
|
|
||||||
if (lsign != null) {
|
public static boolean playerInteract(Block block, Player player) {
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
|
||||||
if (dplayer != null) {
|
LeaveSign lsign = getSign(block);
|
||||||
dplayer.leave();
|
|
||||||
return true;
|
if (lsign != null) {
|
||||||
} else {
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
DGroup dgroup = DGroup.get(player);
|
if (dplayer != null) {
|
||||||
if (dgroup != null) {
|
dplayer.leave();
|
||||||
dgroup.removePlayer(player);
|
return true;
|
||||||
P.p.msg(player, P.p.language.get("Player_LeaveGroup"));// ChatColor.YELLOW+"Du hast deine Gruppe erfolgreich verlassen!");
|
} else {
|
||||||
return true;
|
DGroup dgroup = DGroup.get(player);
|
||||||
}
|
if (dgroup != null) {
|
||||||
}
|
dgroup.removePlayer(player);
|
||||||
}
|
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_LeaveGroup"));// ChatColor.YELLOW+"Du hast deine Gruppe erfolgreich verlassen!");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public static boolean isRelativeSign(Block block, int x, int z) {
|
}
|
||||||
LeaveSign lsign = getSign(block.getRelative(x, 0, z));
|
return false;
|
||||||
if (lsign != null) {
|
}
|
||||||
if (x == -1 && lsign.sign.getData().getData() == 4)
|
|
||||||
return true;
|
@SuppressWarnings("deprecation")
|
||||||
if (x == 1 && lsign.sign.getData().getData() == 5)
|
public static boolean isRelativeSign(Block block, int x, int z) {
|
||||||
return true;
|
LeaveSign lsign = getSign(block.getRelative(x, 0, z));
|
||||||
if (z == -1 && lsign.sign.getData().getData() == 2)
|
if (lsign != null) {
|
||||||
return true;
|
if (x == -1 && lsign.sign.getData().getData() == 4) {
|
||||||
if (z == 1 && lsign.sign.getData().getData() == 3)
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
if (x == 1 && lsign.sign.getData().getData() == 5) {
|
||||||
|
return true;
|
||||||
return false;
|
}
|
||||||
}
|
if (z == -1 && lsign.sign.getData().getData() == 2) {
|
||||||
|
return true;
|
||||||
public static LeaveSign getSign(Block block) {
|
}
|
||||||
if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) {
|
if (z == 1 && lsign.sign.getData().getData() == 3) {
|
||||||
for (LeaveSign leavesign : lsigns) {
|
return true;
|
||||||
if (block.getWorld() == leavesign.sign.getWorld()) {
|
}
|
||||||
if (block.getLocation().distance(leavesign.sign.getBlock().getLocation()) < 1) {
|
}
|
||||||
return leavesign;
|
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
public static LeaveSign getSign(Block block) {
|
||||||
return null;
|
if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) {
|
||||||
}
|
for (LeaveSign leavesign : plugin.getLeaveSigns()) {
|
||||||
|
if (block.getWorld() == leavesign.sign.getWorld()) {
|
||||||
// Save and Load
|
if (block.getLocation().distance(leavesign.sign.getBlock().getLocation()) < 1) {
|
||||||
public static void save(FileConfiguration configFile) {
|
return leavesign;
|
||||||
int id = 0;
|
}
|
||||||
for (LeaveSign lsign : lsigns) {
|
}
|
||||||
id++;
|
}
|
||||||
String preString = "leavesign." + lsign.sign.getWorld().getName() + "." + id;
|
}
|
||||||
configFile.set(preString + ".x", lsign.sign.getX());
|
return null;
|
||||||
configFile.set(preString + ".y", lsign.sign.getY());
|
}
|
||||||
configFile.set(preString + ".z", lsign.sign.getZ());
|
|
||||||
}
|
// Save and Load
|
||||||
}
|
public static void save(FileConfiguration configFile) {
|
||||||
|
int id = 0;
|
||||||
public static void load(FileConfiguration configFile) {
|
for (LeaveSign lsign : plugin.getLeaveSigns()) {
|
||||||
for (World world : P.p.getServer().getWorlds()) {
|
id++;
|
||||||
if (configFile.contains("leavesign." + world.getName())) {
|
String preString = "leavesign." + lsign.sign.getWorld().getName() + "." + id;
|
||||||
int id = 0;
|
configFile.set(preString + ".x", lsign.sign.getX());
|
||||||
String preString;
|
configFile.set(preString + ".y", lsign.sign.getY());
|
||||||
do {
|
configFile.set(preString + ".z", lsign.sign.getZ());
|
||||||
id++;
|
}
|
||||||
preString = "leavesign." + world.getName() + "." + id + ".";
|
}
|
||||||
if (configFile.contains(preString)) {
|
|
||||||
Block block = world.getBlockAt(configFile.getInt(preString + ".x"), configFile.getInt(preString + ".y"), configFile.getInt(preString + ".z"));
|
public static void load(FileConfiguration configFile) {
|
||||||
if (block.getState() instanceof Sign) {
|
for (World world : DungeonsXL.getPlugin().getServer().getWorlds()) {
|
||||||
Sign sign = (Sign) block.getState();
|
if (configFile.contains("leavesign." + world.getName())) {
|
||||||
new LeaveSign(sign);
|
int id = 0;
|
||||||
}
|
String preString;
|
||||||
}
|
do {
|
||||||
} while (configFile.contains(preString));
|
id++;
|
||||||
}
|
preString = "leavesign." + world.getName() + "." + id + ".";
|
||||||
}
|
if (configFile.contains(preString)) {
|
||||||
}
|
Block block = world.getBlockAt(configFile.getInt(preString + ".x"), configFile.getInt(preString + ".y"), configFile.getInt(preString + ".z"));
|
||||||
|
if (block.getState() instanceof Sign) {
|
||||||
}
|
Sign sign = (Sign) block.getState();
|
||||||
|
new LeaveSign(sign);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (configFile.contains(preString));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,214 +1,219 @@
|
|||||||
package com.dre.dungeonsxl.listener;
|
package io.github.dre2n.dungeonsxl.listener;
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import org.bukkit.block.Sign;
|
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||||
import org.bukkit.entity.Player;
|
import io.github.dre2n.dungeonsxl.dungeon.game.GamePlaceableBlock;
|
||||||
import org.bukkit.Location;
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
import org.bukkit.Material;
|
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||||
import org.bukkit.event.EventHandler;
|
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||||
import org.bukkit.event.EventPriority;
|
import io.github.dre2n.dungeonsxl.global.LeaveSign;
|
||||||
import org.bukkit.event.Listener;
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import io.github.dre2n.dungeonsxl.trigger.RedstoneTrigger;
|
||||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
import io.github.dre2n.dungeonsxl.util.IntegerUtil;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
|
||||||
import org.bukkit.event.block.BlockSpreadEvent;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
import com.dre.dungeonsxl.DGSign;
|
import org.bukkit.entity.Player;
|
||||||
import com.dre.dungeonsxl.DPortal;
|
import org.bukkit.event.EventHandler;
|
||||||
import com.dre.dungeonsxl.P;
|
import org.bukkit.event.EventPriority;
|
||||||
import com.dre.dungeonsxl.EditWorld;
|
import org.bukkit.event.Listener;
|
||||||
import com.dre.dungeonsxl.LeaveSign;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import com.dre.dungeonsxl.game.GamePlaceableBlock;
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import com.dre.dungeonsxl.signs.DSign;
|
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||||
import com.dre.dungeonsxl.trigger.RedstoneTrigger;
|
import org.bukkit.event.block.BlockSpreadEvent;
|
||||||
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
public class BlockListener implements Listener {
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
public class BlockListener implements Listener {
|
||||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
|
||||||
if (event.getBlock().getType() == Material.PORTAL) {
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
if (DPortal.get(event.getBlock()) != null) {
|
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||||
event.setCancelled(true);
|
if (event.getBlock().getType() == Material.PORTAL) {
|
||||||
}
|
if (DPortal.get(event.getBlock()) != null) {
|
||||||
}
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
}
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
|
||||||
Block block = event.getBlock();
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
// Deny DPortal destroying
|
Block block = event.getBlock();
|
||||||
if (block.getType() == Material.PORTAL) {
|
|
||||||
if (DPortal.get(event.getBlock()) != null) {
|
// Deny DPortal destroying
|
||||||
event.setCancelled(true);
|
if (block.getType() == Material.PORTAL) {
|
||||||
}
|
if (DPortal.get(event.getBlock()) != null) {
|
||||||
}
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
// Deny DGSignblocks destroying
|
}
|
||||||
if (DGSign.isRelativeSign(block, 1, 0) || DGSign.isRelativeSign(block, -1, 0) || DGSign.isRelativeSign(block, 0, 1) || DGSign.isRelativeSign(block, 0, -1)) {
|
|
||||||
event.setCancelled(true);
|
// Deny DGSignblocks destroying
|
||||||
}
|
if (GroupSign.isRelativeSign(block, 1, 0) || GroupSign.isRelativeSign(block, -1, 0) || GroupSign.isRelativeSign(block, 0, 1) || GroupSign.isRelativeSign(block, 0, -1)) {
|
||||||
|
event.setCancelled(true);
|
||||||
// DGSign destroying
|
}
|
||||||
if (DGSign.getSign(block) != null) {
|
|
||||||
DGSign.dgsigns.remove(DGSign.getSign(block));
|
// DGSign destroying
|
||||||
}
|
if (GroupSign.getSign(block) != null) {
|
||||||
|
DungeonsXL.getPlugin().getGroupSigns().remove(GroupSign.getSign(block));
|
||||||
// Deny LeaveSignblocks destroying
|
}
|
||||||
if (LeaveSign.isRelativeSign(block, 1, 0) || LeaveSign.isRelativeSign(block, -1, 0) || LeaveSign.isRelativeSign(block, 0, 1) || LeaveSign.isRelativeSign(block, 0, -1)) {
|
|
||||||
event.setCancelled(true);
|
// Deny LeaveSignblocks destroying
|
||||||
}
|
if (LeaveSign.isRelativeSign(block, 1, 0) || LeaveSign.isRelativeSign(block, -1, 0) || LeaveSign.isRelativeSign(block, 0, 1) || LeaveSign.isRelativeSign(block, 0, -1)) {
|
||||||
|
event.setCancelled(true);
|
||||||
// LeaveSign destroying
|
}
|
||||||
if (LeaveSign.getSign(block) != null) {
|
|
||||||
event.setCancelled(true);
|
// LeaveSign destroying
|
||||||
// LeaveSign.lsigns.remove(LeaveSign.getSign(block));
|
if (LeaveSign.getSign(block) != null) {
|
||||||
}
|
event.setCancelled(true);
|
||||||
|
// LeaveSign.lsigns.remove(LeaveSign.getSign(block));
|
||||||
// Editworld Signs
|
}
|
||||||
EditWorld eworld = EditWorld.get(block.getWorld());
|
|
||||||
if (eworld != null) {
|
// Editworld Signs
|
||||||
eworld.sign.remove(event.getBlock());
|
EditWorld eworld = EditWorld.get(block.getWorld());
|
||||||
}
|
if (eworld != null) {
|
||||||
|
eworld.sign.remove(event.getBlock());
|
||||||
// Deny GameWorld Blocks
|
}
|
||||||
GameWorld gworld = GameWorld.get(block.getWorld());
|
|
||||||
if (gworld != null) {
|
// Deny GameWorld Blocks
|
||||||
event.setCancelled(true);
|
GameWorld gworld = GameWorld.get(block.getWorld());
|
||||||
}
|
if (gworld != null) {
|
||||||
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
}
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
|
||||||
Block block = event.getBlock();
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
// Deny GameWorld Blocks
|
Block block = event.getBlock();
|
||||||
GameWorld gworld = GameWorld.get(block.getWorld());
|
|
||||||
if (gworld != null) {
|
// Deny GameWorld Blocks
|
||||||
if (!GamePlaceableBlock.canBuildHere(block, block.getFace(event.getBlockAgainst()), event.getItemInHand().getType(), gworld)) {
|
GameWorld gworld = GameWorld.get(block.getWorld());
|
||||||
|
if (gworld != null) {
|
||||||
// Workaround for a bug that would allow 3-Block-high jumping
|
if ( !GamePlaceableBlock.canBuildHere(block, block.getFace(event.getBlockAgainst()), event.getItemInHand().getType(), gworld)) {
|
||||||
Location loc = event.getPlayer().getLocation();
|
|
||||||
if (loc.getY() > block.getY() + 1.0 && loc.getY() <= block.getY() + 1.5) {
|
// Workaround for a bug that would allow 3-Block-high jumping
|
||||||
if (loc.getX() >= block.getX() - 0.3 && loc.getX() <= block.getX() + 1.3) {
|
Location loc = event.getPlayer().getLocation();
|
||||||
if (loc.getZ() >= block.getZ() - 0.3 && loc.getZ() <= block.getZ() + 1.3) {
|
if (loc.getY() > block.getY() + 1.0 && loc.getY() <= block.getY() + 1.5) {
|
||||||
loc.setX(block.getX() + 0.5);
|
if (loc.getX() >= block.getX() - 0.3 && loc.getX() <= block.getX() + 1.3) {
|
||||||
loc.setY(block.getY());
|
if (loc.getZ() >= block.getZ() - 0.3 && loc.getZ() <= block.getZ() + 1.3) {
|
||||||
loc.setZ(block.getZ() + 0.5);
|
loc.setX(block.getX() + 0.5);
|
||||||
event.getPlayer().teleport(loc);
|
loc.setY(block.getY());
|
||||||
}
|
loc.setZ(block.getZ() + 0.5);
|
||||||
}
|
event.getPlayer().teleport(loc);
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
}
|
||||||
}
|
}
|
||||||
}
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
}
|
||||||
public void onSignChange(SignChangeEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
Block block = event.getBlock();
|
public void onSignChange(SignChangeEvent event) {
|
||||||
String[] lines = event.getLines();
|
Player player = event.getPlayer();
|
||||||
EditWorld eworld = EditWorld.get(player.getWorld());
|
Block block = event.getBlock();
|
||||||
|
String[] lines = event.getLines();
|
||||||
// Group Signs
|
EditWorld eworld = EditWorld.get(player.getWorld());
|
||||||
if (eworld == null) {
|
|
||||||
if (player.isOp() || P.p.permission.has(player, "dxl.sign")) {
|
// Group Signs
|
||||||
if (lines[0].equalsIgnoreCase("[DXL]")) {
|
if (eworld == null) {
|
||||||
if (lines[1].equalsIgnoreCase("Group")) {
|
if (player.isOp() || player.hasPermission("dxl.sign")) {
|
||||||
String dungeonName = lines[2];
|
if (lines[0].equalsIgnoreCase("[DXL]")) {
|
||||||
|
if (lines[1].equalsIgnoreCase("Group")) {
|
||||||
String[] data = lines[3].split("\\,");
|
String dungeonName = lines[2];
|
||||||
if (data.length == 2) {
|
|
||||||
int maxGroups = P.p.parseInt(data[0]);
|
String[] data = lines[3].split("\\,");
|
||||||
int maxPlayersPerGroup = P.p.parseInt(data[1]);
|
if (data.length == 2) {
|
||||||
if (maxGroups > 0 && maxPlayersPerGroup > 0) {
|
int maxGroups = IntegerUtil.parseInt(data[0]);
|
||||||
if (DGSign.tryToCreate(event.getBlock(), dungeonName, maxGroups, maxPlayersPerGroup) != null) {
|
int maxPlayersPerGroup = IntegerUtil.parseInt(data[1]);
|
||||||
event.setCancelled(true);
|
if (maxGroups > 0 && maxPlayersPerGroup > 0) {
|
||||||
}
|
if (GroupSign.tryToCreate(event.getBlock(), dungeonName, maxGroups, maxPlayersPerGroup) != null) {
|
||||||
}
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (lines[1].equalsIgnoreCase("Leave")) {
|
}
|
||||||
if (block.getState() instanceof Sign) {
|
}
|
||||||
Sign sign = (Sign) block.getState();
|
} else if (lines[1].equalsIgnoreCase("Leave")) {
|
||||||
new LeaveSign(sign);
|
if (block.getState() instanceof Sign) {
|
||||||
}
|
Sign sign = (Sign) block.getState();
|
||||||
event.setCancelled(true);
|
new LeaveSign(sign);
|
||||||
}
|
}
|
||||||
}
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else { // Editworld Signs
|
}
|
||||||
Sign sign = (Sign) block.getState();
|
}
|
||||||
if (sign != null) {
|
} else { // Editworld Signs
|
||||||
sign.setLine(0, lines[0]);
|
Sign sign = (Sign) block.getState();
|
||||||
sign.setLine(1, lines[1]);
|
if (sign != null) {
|
||||||
sign.setLine(2, lines[2]);
|
sign.setLine(0, lines[0]);
|
||||||
sign.setLine(3, lines[3]);
|
sign.setLine(1, lines[1]);
|
||||||
|
sign.setLine(2, lines[2]);
|
||||||
DSign dsign = DSign.create(sign, null);
|
sign.setLine(3, lines[3]);
|
||||||
|
|
||||||
if (dsign != null) {
|
DSign dsign = DSign.create(sign, null);
|
||||||
if (player.isOp() || P.p.permission.has(player, dsign.getPermissions())) {
|
|
||||||
if (dsign.check()) {
|
if (dsign != null) {
|
||||||
eworld.checkSign(block);
|
if (player.isOp() || player.hasPermission(dsign.getPermissions())) {
|
||||||
eworld.sign.add(block);
|
if (dsign.check()) {
|
||||||
P.p.msg(player, P.p.language.get("Player_SignCreated"));
|
eworld.checkSign(block);
|
||||||
} else {
|
eworld.sign.add(block);
|
||||||
P.p.msg(player, P.p.language.get("Error_SignWrongFormat"));
|
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_SignCreated"));
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
P.p.msg(player, P.p.language.get("Error_NoPermissions"));
|
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_SignWrongFormat"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
} else {
|
||||||
}
|
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_NoPermissions"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
}
|
||||||
public void onBlockSpread(BlockSpreadEvent event) {
|
}
|
||||||
Block block = event.getBlock();
|
}
|
||||||
// Block the Spread off Vines
|
|
||||||
if (block.getType() == Material.VINE) {
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
// Check GameWorlds
|
public void onBlockSpread(BlockSpreadEvent event) {
|
||||||
GameWorld gworld = GameWorld.get(event.getBlock().getWorld());
|
Block block = event.getBlock();
|
||||||
if (gworld != null) {
|
// Block the Spread off Vines
|
||||||
event.setCancelled(true);
|
if (block.getType() == Material.VINE) {
|
||||||
}
|
// Check GameWorlds
|
||||||
|
GameWorld gworld = GameWorld.get(event.getBlock().getWorld());
|
||||||
// Check EditWorlds
|
if (gworld != null) {
|
||||||
EditWorld eworld = EditWorld.get(event.getBlock().getWorld());
|
event.setCancelled(true);
|
||||||
if (eworld != null) {
|
}
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
// Check EditWorlds
|
||||||
}
|
EditWorld eworld = EditWorld.get(event.getBlock().getWorld());
|
||||||
|
if (eworld != null) {
|
||||||
}
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
}
|
||||||
public void onBlockRedstoneEvent(BlockRedstoneEvent event) {
|
|
||||||
new RedstoneEventTask(event.getBlock()).runTaskLater(P.p, 1);
|
}
|
||||||
}
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public class RedstoneEventTask extends BukkitRunnable {
|
public void onBlockRedstoneEvent(BlockRedstoneEvent event) {
|
||||||
private final Block block;
|
new RedstoneEventTask(event.getBlock()).runTaskLater(DungeonsXL.getPlugin(), 1);
|
||||||
|
}
|
||||||
public RedstoneEventTask(final Block block) {
|
|
||||||
this.block = block;
|
public class RedstoneEventTask extends BukkitRunnable {
|
||||||
}
|
private final Block block;
|
||||||
|
|
||||||
public void run() {
|
public RedstoneEventTask(final Block block) {
|
||||||
for (GameWorld gworld : GameWorld.gworlds) {
|
this.block = block;
|
||||||
if (block.getWorld() == gworld.world) {
|
}
|
||||||
RedstoneTrigger.updateAll(gworld);
|
|
||||||
}
|
@Override
|
||||||
}
|
public void run() {
|
||||||
}
|
for (GameWorld gworld : DungeonsXL.getPlugin().getGameWorlds()) {
|
||||||
|
if (block.getWorld() == gworld.world) {
|
||||||
}
|
RedstoneTrigger.updateAll(gworld);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
65
src/io/github/dre2n/dungeonsxl/listener/CommandListener.java
Normal file
65
src/io/github/dre2n/dungeonsxl/listener/CommandListener.java
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.listener;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.command.DCommand;
|
||||||
|
import io.github.dre2n.dungeonsxl.file.DMessages;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class CommandListener implements CommandExecutor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command cmd_notused, String arg, String[] args) {
|
||||||
|
DungeonsXL plugin = DungeonsXL.getPlugin();
|
||||||
|
|
||||||
|
if (args.length > 0) {
|
||||||
|
DMessages dMessages = plugin.getDMessages();
|
||||||
|
DCommand dCommand = plugin.getDCommands().getDCommand(args[0]);
|
||||||
|
|
||||||
|
if (dCommand != null) {
|
||||||
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
|
if ( !dCommand.isConsoleCommand()) {
|
||||||
|
MessageUtil.sendMessage(sender, dMessages.get("Log_Error_NoConsoleCommand", dCommand.getCommand()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if ( !dCommand.isPlayerCommand()) {
|
||||||
|
MessageUtil.sendMessage(player, dMessages.get("Error_NoPlayerCommand", dCommand.getCommand()));
|
||||||
|
return false;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (dCommand.getPermission() != null) {
|
||||||
|
if ( !dCommand.playerHasPermissions(player)) {
|
||||||
|
MessageUtil.sendMessage(player, dMessages.get("Error_NoPermissions"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dCommand.getMinArgs() <= args.length - 1 & dCommand.getMaxArgs() >= args.length - 1 || dCommand.getMinArgs() == -1) {
|
||||||
|
dCommand.onExecute(args, sender);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
dCommand.displayHelp(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.getDCommands().getDCommand("main").onExecute(null, sender);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,209 +1,211 @@
|
|||||||
package com.dre.dungeonsxl.listener;
|
package io.github.dre2n.dungeonsxl.listener;
|
||||||
|
|
||||||
import java.util.List;
|
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
import org.bukkit.Material;
|
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||||
import org.bukkit.World;
|
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||||
import org.bukkit.block.Block;
|
import io.github.dre2n.dungeonsxl.mob.DMob;
|
||||||
import org.bukkit.entity.Entity;
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
import java.util.List;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.Projectile;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.World;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
import org.bukkit.entity.Projectile;
|
||||||
import org.bukkit.event.entity.EntityCombustEvent;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||||
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
import com.dre.dungeonsxl.DGSign;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import com.dre.dungeonsxl.DPlayer;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import com.dre.dungeonsxl.DPortal;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import com.dre.dungeonsxl.EditWorld;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import com.dre.dungeonsxl.game.DMob;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
|
|
||||||
public class EntityListener implements Listener {
|
public class EntityListener implements Listener {
|
||||||
|
|
||||||
// Remove drops from breaking Signs
|
// Remove drops from breaking Signs
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onItemSpawn(ItemSpawnEvent event) {
|
public void onItemSpawn(ItemSpawnEvent event) {
|
||||||
if (GameWorld.get(event.getLocation().getWorld()) != null) {
|
if (GameWorld.get(event.getLocation().getWorld()) != null) {
|
||||||
if (event.getEntity().getItemStack().getType() == Material.SIGN) {
|
if (event.getEntity().getItemStack().getType() == Material.SIGN) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||||
World world = event.getLocation().getWorld();
|
World world = event.getLocation().getWorld();
|
||||||
|
|
||||||
EditWorld eworld = EditWorld.get(world);
|
EditWorld eworld = EditWorld.get(world);
|
||||||
GameWorld gworld = GameWorld.get(world);
|
GameWorld gworld = GameWorld.get(world);
|
||||||
|
|
||||||
if (eworld != null || gworld != null) {
|
if (eworld != null || gworld != null) {
|
||||||
if (event.getSpawnReason() == SpawnReason.CHUNK_GEN || event.getSpawnReason() == SpawnReason.BREEDING || event.getSpawnReason() == SpawnReason.NATURAL
|
if (event.getSpawnReason() == SpawnReason.CHUNK_GEN || event.getSpawnReason() == SpawnReason.BREEDING || event.getSpawnReason() == SpawnReason.NATURAL
|
||||||
|| event.getSpawnReason() == SpawnReason.DEFAULT) {
|
|| event.getSpawnReason() == SpawnReason.DEFAULT) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
World world = event.getEntity().getWorld();
|
World world = event.getEntity().getWorld();
|
||||||
|
|
||||||
if (event.getEntity() instanceof LivingEntity) {
|
if (event.getEntity() instanceof LivingEntity) {
|
||||||
LivingEntity entity = (LivingEntity) event.getEntity();
|
LivingEntity entity = event.getEntity();
|
||||||
GameWorld gworld = GameWorld.get(world);
|
GameWorld gworld = GameWorld.get(world);
|
||||||
if (gworld != null) {
|
if (gworld != null) {
|
||||||
if (gworld.isPlaying) {
|
if (gworld.isPlaying) {
|
||||||
if (entity.getType() != EntityType.PLAYER) {
|
if (entity.getType() != EntityType.PLAYER) {
|
||||||
event.getDrops().clear();
|
event.getDrops().clear();
|
||||||
DMob.onDeath(event);
|
DMob.onDeath(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onEntityDamage(EntityDamageEvent event) {
|
public void onEntityDamage(EntityDamageEvent event) {
|
||||||
World world = event.getEntity().getWorld();
|
World world = event.getEntity().getWorld();
|
||||||
GameWorld gworld = GameWorld.get(world);
|
GameWorld gworld = GameWorld.get(world);
|
||||||
if (gworld != null) {
|
if (gworld != null) {
|
||||||
// Deny all Damage in Lobby
|
// Deny all Damage in Lobby
|
||||||
if (!gworld.isPlaying) {
|
if ( !gworld.isPlaying) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
// Deny all Damage from Players to Players
|
// Deny all Damage from Players to Players
|
||||||
if (event instanceof EntityDamageByEntityEvent) {
|
if (event instanceof EntityDamageByEntityEvent) {
|
||||||
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;
|
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;
|
||||||
Entity entity = sub.getDamager();
|
Entity entity = sub.getDamager();
|
||||||
Entity entity2 = sub.getEntity();
|
Entity entity2 = sub.getEntity();
|
||||||
|
|
||||||
if (entity instanceof Projectile) {
|
if (entity instanceof Projectile) {
|
||||||
entity = (Entity) ((Projectile) entity).getShooter();
|
entity = (Entity) ((Projectile) entity).getShooter();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity instanceof Player && entity2 instanceof Player) {
|
if (entity instanceof Player && entity2 instanceof Player) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity instanceof LivingEntity && entity2 instanceof LivingEntity) {
|
if (entity instanceof LivingEntity && entity2 instanceof LivingEntity) {
|
||||||
if (!(entity instanceof Player) && !(entity2 instanceof Player)) {
|
if ( !(entity instanceof Player) && !(entity2 instanceof Player)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Dogs
|
// Check Dogs
|
||||||
if (entity instanceof Player || entity2 instanceof Player) {
|
if (entity instanceof Player || entity2 instanceof Player) {
|
||||||
for (DPlayer dplayer : DPlayer.get(gworld.world)) {
|
for (DPlayer dplayer : DPlayer.get(gworld.world)) {
|
||||||
if (dplayer.wolf != null) {
|
if (dplayer.wolf != null) {
|
||||||
if (entity == dplayer.wolf || entity2 == dplayer.wolf) {
|
if (entity == dplayer.wolf || entity2 == dplayer.wolf) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (DPlayer dplayer : DPlayer.get(gworld.world)) {
|
for (DPlayer dplayer : DPlayer.get(gworld.world)) {
|
||||||
if (dplayer.wolf != null) {
|
if (dplayer.wolf != null) {
|
||||||
if (entity instanceof Player || entity2 instanceof Player) {
|
if (entity instanceof Player || entity2 instanceof Player) {
|
||||||
if (entity == dplayer.wolf || entity2 == dplayer.wolf) {
|
if (entity == dplayer.wolf || entity2 == dplayer.wolf) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (entity == dplayer.wolf || entity2 == dplayer.wolf) {
|
} else {
|
||||||
event.setCancelled(false);
|
if (entity == dplayer.wolf || entity2 == dplayer.wolf) {
|
||||||
return;
|
event.setCancelled(false);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Deny food in Lobby
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
// Deny food in Lobby
|
||||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
World world = event.getEntity().getWorld();
|
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||||
|
World world = event.getEntity().getWorld();
|
||||||
GameWorld gworld = GameWorld.get(world);
|
|
||||||
if (gworld != null) {
|
GameWorld gworld = GameWorld.get(world);
|
||||||
if (!gworld.isPlaying) {
|
if (gworld != null) {
|
||||||
event.setCancelled(true);
|
if ( !gworld.isPlaying) {
|
||||||
}
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Zombie/skeleton combustion from the sun.
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
// Zombie/skeleton combustion from the sun.
|
||||||
public void onEntityCombust(EntityCombustEvent event) {
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
GameWorld gworld = GameWorld.get(event.getEntity().getWorld());
|
public void onEntityCombust(EntityCombustEvent event) {
|
||||||
if (gworld != null) {
|
GameWorld gworld = GameWorld.get(event.getEntity().getWorld());
|
||||||
event.setCancelled(true);
|
if (gworld != null) {
|
||||||
}
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Allow Other combustion
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
// Allow Other combustion
|
||||||
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
GameWorld gworld = GameWorld.get(event.getEntity().getWorld());
|
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
|
||||||
if (gworld != null) {
|
GameWorld gworld = GameWorld.get(event.getEntity().getWorld());
|
||||||
if (event.isCancelled()) {
|
if (gworld != null) {
|
||||||
event.setCancelled(false);
|
if (event.isCancelled()) {
|
||||||
}
|
event.setCancelled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Explosions
|
|
||||||
@EventHandler
|
// Explosions
|
||||||
public void onEntityExplode(EntityExplodeEvent event) {
|
@EventHandler
|
||||||
GameWorld gworld = GameWorld.get(event.getEntity().getWorld());
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
|
GameWorld gworld = GameWorld.get(event.getEntity().getWorld());
|
||||||
if (gworld != null) {
|
|
||||||
if (event.getEntity() instanceof LivingEntity) {
|
if (gworld != null) {
|
||||||
// Disable Creeper explosions in gameworlds
|
if (event.getEntity() instanceof LivingEntity) {
|
||||||
event.setCancelled(true);
|
// Disable Creeper explosions in gameworlds
|
||||||
return;
|
event.setCancelled(true);
|
||||||
} else {
|
return;
|
||||||
// Disable drops from TNT
|
|
||||||
event.setYield(0);
|
} else {
|
||||||
}
|
// Disable drops from TNT
|
||||||
|
event.setYield(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent Portal and Sign Destroying
|
}
|
||||||
List<Block> blocklist = event.blockList();
|
|
||||||
for (Block block : blocklist) {
|
// Prevent Portal and Sign Destroying
|
||||||
// Portals
|
List<Block> blocklist = event.blockList();
|
||||||
if (block.getType() == Material.PORTAL) {
|
for (Block block : blocklist) {
|
||||||
if (DPortal.get(block) != null) {
|
// Portals
|
||||||
event.setCancelled(true);
|
if (block.getType() == Material.PORTAL) {
|
||||||
return;
|
if (DPortal.get(block) != null) {
|
||||||
}
|
event.setCancelled(true);
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
// Signs
|
}
|
||||||
if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) {
|
|
||||||
if (DGSign.getSign(block) != null) {
|
// Signs
|
||||||
event.setCancelled(true);
|
if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) {
|
||||||
return;
|
if (GroupSign.getSign(block) != null) {
|
||||||
}
|
event.setCancelled(true);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +1,19 @@
|
|||||||
package com.dre.dungeonsxl.listener;
|
package io.github.dre2n.dungeonsxl.listener;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||||
|
|
||||||
public class HangingListener implements Listener {
|
public class HangingListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {
|
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {
|
||||||
GameWorld gworld = GameWorld.get(event.getEntity().getWorld());
|
GameWorld gworld = GameWorld.get(event.getEntity().getWorld());
|
||||||
if (gworld != null) {
|
if (gworld != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -1,21 +1,22 @@
|
|||||||
package com.dre.dungeonsxl.listener;
|
package io.github.dre2n.dungeonsxl.listener;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||||
|
|
||||||
public class WorldListener implements Listener {
|
public class WorldListener implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||||
GameWorld gWorld = GameWorld.get(event.getWorld());
|
GameWorld gWorld = GameWorld.get(event.getWorld());
|
||||||
if (gWorld != null) {
|
if (gWorld != null) {
|
||||||
if (gWorld.loadedChunks.contains(event.getChunk())) {
|
if (gWorld.loadedChunks.contains(event.getChunk())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
@ -1,87 +1,92 @@
|
|||||||
package com.dre.dungeonsxl.game;
|
package io.github.dre2n.dungeonsxl.mob;
|
||||||
|
|
||||||
import java.util.Random;
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.trigger.MobTrigger;
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import java.util.Random;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import com.dre.dungeonsxl.DMobType;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import com.dre.dungeonsxl.trigger.MobTrigger;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class DMob {
|
public class DMob {
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
public LivingEntity entity;
|
private LivingEntity entity;
|
||||||
public DMobType type;
|
private DMobType type;
|
||||||
|
|
||||||
public String trigger;
|
private String trigger;
|
||||||
|
|
||||||
public DMob(LivingEntity entity, GameWorld gworld, DMobType type) {
|
public DMob(LivingEntity entity, GameWorld gworld, DMobType type) {
|
||||||
gworld.dmobs.add(this);
|
gworld.dMobs.add(this);
|
||||||
|
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
||||||
/* Remove DropChance of equipment */
|
/* Remove DropChance of equipment */
|
||||||
this.entity.getEquipment().setHelmetDropChance(0);
|
this.entity.getEquipment().setHelmetDropChance(0);
|
||||||
this.entity.getEquipment().setChestplateDropChance(0);
|
this.entity.getEquipment().setChestplateDropChance(0);
|
||||||
this.entity.getEquipment().setLeggingsDropChance(0);
|
this.entity.getEquipment().setLeggingsDropChance(0);
|
||||||
this.entity.getEquipment().setBootsDropChance(0);
|
this.entity.getEquipment().setBootsDropChance(0);
|
||||||
this.entity.getEquipment().setItemInHandDropChance(0);
|
this.entity.getEquipment().setItemInHandDropChance(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DMob(LivingEntity entity, GameWorld gworld, DMobType type, String trigger) {
|
public DMob(LivingEntity entity, GameWorld gworld, DMobType type, String trigger) {
|
||||||
gworld.dmobs.add(this);
|
gworld.dMobs.add(this);
|
||||||
|
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.trigger = trigger;
|
this.trigger = trigger;
|
||||||
|
|
||||||
/* Remove DropChance of equipment */
|
/* Remove DropChance of equipment */
|
||||||
this.entity.getEquipment().setHelmetDropChance(0);
|
this.entity.getEquipment().setHelmetDropChance(0);
|
||||||
this.entity.getEquipment().setChestplateDropChance(0);
|
this.entity.getEquipment().setChestplateDropChance(0);
|
||||||
this.entity.getEquipment().setLeggingsDropChance(0);
|
this.entity.getEquipment().setLeggingsDropChance(0);
|
||||||
this.entity.getEquipment().setBootsDropChance(0);
|
this.entity.getEquipment().setBootsDropChance(0);
|
||||||
this.entity.getEquipment().setItemInHandDropChance(0);
|
this.entity.getEquipment().setItemInHandDropChance(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Statics
|
// Statics
|
||||||
public static void onDeath(EntityDeathEvent event) {
|
@SuppressWarnings("deprecation")
|
||||||
if (event.getEntity() instanceof LivingEntity) {
|
public static void onDeath(EntityDeathEvent event) {
|
||||||
LivingEntity victim = (LivingEntity) event.getEntity();
|
if (event.getEntity() instanceof LivingEntity) {
|
||||||
GameWorld gworld = GameWorld.get(victim.getWorld());
|
LivingEntity victim = event.getEntity();
|
||||||
String name = null;
|
GameWorld gworld = GameWorld.get(victim.getWorld());
|
||||||
|
String name = null;
|
||||||
if (gworld != null) {
|
|
||||||
for (DMob dmob : gworld.dmobs) {
|
if (gworld != null) {
|
||||||
if (dmob.entity == victim) {
|
for (DMob dmob : gworld.dMobs) {
|
||||||
if (dmob.type != null) {
|
if (dmob.entity == victim) {
|
||||||
for (ItemStack item : dmob.type.getDrops().keySet()) {
|
|
||||||
Random randomGenerator = new Random();
|
if (dmob.type != null) {
|
||||||
int random = randomGenerator.nextInt(100);
|
for (ItemStack item : dmob.type.getDrops().keySet()) {
|
||||||
|
Random randomGenerator = new Random();
|
||||||
if (dmob.type.getDrops().get(item) > random) {
|
int random = randomGenerator.nextInt(100);
|
||||||
event.getDrops().add(item);
|
|
||||||
}
|
if (dmob.type.getDrops().get(item) > random) {
|
||||||
}
|
event.getDrops().add(item);
|
||||||
name = dmob.type.getName();
|
}
|
||||||
} else if (dmob.type == null && dmob.trigger != null) {// <=MythicMobs mob
|
}
|
||||||
name = dmob.trigger;
|
name = dmob.type.getName();
|
||||||
} else {
|
|
||||||
name = victim.getType().getName();
|
} else if (dmob.type == null && dmob.trigger != null) {// <=MythicMobs mob
|
||||||
}
|
name = dmob.trigger;
|
||||||
|
|
||||||
MobTrigger trigger = MobTrigger.get(name, gworld);
|
} else {
|
||||||
if (trigger != null) {
|
name = victim.getType().getName();
|
||||||
trigger.onTrigger();
|
}
|
||||||
}
|
|
||||||
|
MobTrigger trigger = MobTrigger.get(name, gworld);
|
||||||
gworld.dmobs.remove(dmob);
|
if (trigger != null) {
|
||||||
return;
|
trigger.onTrigger();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
gworld.dMobs.remove(dmob);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,246 +1,274 @@
|
|||||||
package com.dre.dungeonsxl;
|
package io.github.dre2n.dungeonsxl.mob;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import java.util.HashMap;
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
import java.util.HashSet;
|
import io.github.dre2n.dungeonsxl.util.IntegerUtil;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Arrays;
|
||||||
import org.bukkit.Location;
|
import java.util.HashMap;
|
||||||
import org.bukkit.Material;
|
import java.util.HashSet;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import java.util.Map;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import java.util.Set;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Ocelot;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Skeleton;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import com.dre.dungeonsxl.game.DMob;
|
import org.bukkit.entity.Ocelot;
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
import org.bukkit.entity.Skeleton;
|
||||||
|
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||||
public class DMobType {
|
import org.bukkit.inventory.ItemStack;
|
||||||
private String name;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
private EntityType type;
|
|
||||||
|
public class DMobType {
|
||||||
private int maxHealth;
|
|
||||||
|
private String name;
|
||||||
private ItemStack ItemHand;
|
private EntityType type;
|
||||||
private ItemStack ItemHelmet;
|
|
||||||
private ItemStack ItemChestplate;
|
private int maxHealth;
|
||||||
private ItemStack ItemLeggings;
|
|
||||||
private ItemStack ItemBoots;
|
private ItemStack ItemHand;
|
||||||
|
private ItemStack ItemHelmet;
|
||||||
private Map<ItemStack, Integer> drops = new HashMap<ItemStack, Integer>();
|
private ItemStack ItemChestplate;
|
||||||
|
private ItemStack ItemLeggings;
|
||||||
public Map<ItemStack, Integer> getDrops() {
|
private ItemStack ItemBoots;
|
||||||
return this.drops;
|
|
||||||
}
|
private Map<ItemStack, Integer> drops = new HashMap<ItemStack, Integer>();
|
||||||
|
|
||||||
/* Extra Values for different Mob Types */
|
/* Extra Values for different Mob Types */
|
||||||
private boolean isWitherSkeleton = false;
|
private boolean isWitherSkeleton = false;
|
||||||
private String ocelotType = null;
|
private String ocelotType = null;
|
||||||
|
|
||||||
/* Methods */
|
/* Methods */
|
||||||
public DMobType(String name, EntityType type) {
|
public DMobType(String name, EntityType type) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawn(GameWorld gWorld, Location loc) {
|
public void spawn(GameWorld gWorld, Location loc) {
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
if (type.isAlive()) {
|
if (type.isAlive()) {
|
||||||
LivingEntity entity = (LivingEntity) gWorld.world.spawnEntity(loc, type);
|
LivingEntity entity = (LivingEntity) gWorld.world.spawnEntity(loc, type);
|
||||||
|
|
||||||
/* Set the Items */
|
/* Set the Items */
|
||||||
entity.getEquipment().setItemInHand(ItemHand);
|
entity.getEquipment().setItemInHand(ItemHand);
|
||||||
entity.getEquipment().setHelmet(ItemHelmet);
|
entity.getEquipment().setHelmet(ItemHelmet);
|
||||||
entity.getEquipment().setChestplate(ItemChestplate);
|
entity.getEquipment().setChestplate(ItemChestplate);
|
||||||
entity.getEquipment().setLeggings(ItemLeggings);
|
entity.getEquipment().setLeggings(ItemLeggings);
|
||||||
entity.getEquipment().setBoots(ItemBoots);
|
entity.getEquipment().setBoots(ItemBoots);
|
||||||
|
|
||||||
/* Check mob specified stuff */
|
/* Check mob specified stuff */
|
||||||
if (type == EntityType.SKELETON) {
|
if (type == EntityType.SKELETON) {
|
||||||
if (isWitherSkeleton) {
|
if (isWitherSkeleton) {
|
||||||
((Skeleton) entity).setSkeletonType(SkeletonType.WITHER);
|
((Skeleton) entity).setSkeletonType(SkeletonType.WITHER);
|
||||||
} else {
|
} else {
|
||||||
((Skeleton) entity).setSkeletonType(SkeletonType.NORMAL);
|
((Skeleton) entity).setSkeletonType(SkeletonType.NORMAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == EntityType.OCELOT) {
|
if (type == EntityType.OCELOT) {
|
||||||
Ocelot ocelot = (Ocelot) entity;
|
Ocelot ocelot = (Ocelot) entity;
|
||||||
if (ocelotType != null) {
|
if (ocelotType != null) {
|
||||||
if (ocelotType.equalsIgnoreCase("BLACK_CAT")) {
|
if (ocelotType.equalsIgnoreCase("BLACK_CAT")) {
|
||||||
ocelot.setCatType(Ocelot.Type.BLACK_CAT);
|
ocelot.setCatType(Ocelot.Type.BLACK_CAT);
|
||||||
} else if (ocelotType.equalsIgnoreCase("RED_CAT")) {
|
} else if (ocelotType.equalsIgnoreCase("RED_CAT")) {
|
||||||
ocelot.setCatType(Ocelot.Type.RED_CAT);
|
ocelot.setCatType(Ocelot.Type.RED_CAT);
|
||||||
} else if (ocelotType.equalsIgnoreCase("SIAMESE_CAT")) {
|
} else if (ocelotType.equalsIgnoreCase("SIAMESE_CAT")) {
|
||||||
ocelot.setCatType(Ocelot.Type.SIAMESE_CAT);
|
ocelot.setCatType(Ocelot.Type.SIAMESE_CAT);
|
||||||
} else if (ocelotType.equalsIgnoreCase("WILD_OCELOT")) {
|
} else if (ocelotType.equalsIgnoreCase("WILD_OCELOT")) {
|
||||||
ocelot.setCatType(Ocelot.Type.WILD_OCELOT);
|
ocelot.setCatType(Ocelot.Type.WILD_OCELOT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set Health */
|
/* Set Health */
|
||||||
if (maxHealth > 0) {
|
if (maxHealth > 0) {
|
||||||
entity.setMaxHealth(maxHealth);
|
entity.setMaxHealth(maxHealth);
|
||||||
entity.setHealth(maxHealth);
|
entity.setHealth(maxHealth);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disable Despawning */
|
/* Disable Despawning */
|
||||||
entity.setRemoveWhenFarAway(false);
|
entity.setRemoveWhenFarAway(false);
|
||||||
|
|
||||||
/* Spawn Mob */
|
/* Spawn Mob */
|
||||||
new DMob(entity, gWorld, this);
|
new DMob(entity, gWorld, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load Config
|
// Load Config
|
||||||
public static Set<DMobType> load(ConfigurationSection configFile) {
|
@SuppressWarnings("deprecation")
|
||||||
Set<DMobType> set = new HashSet<DMobType>();
|
public static Set<DMobType> load(ConfigurationSection configFile) {
|
||||||
if (configFile != null) {
|
Set<DMobType> set = new HashSet<DMobType>();
|
||||||
// Read Mobs
|
if (configFile != null) {
|
||||||
for (String mobName : configFile.getKeys(false)) {
|
// Read Mobs
|
||||||
EntityType type = EntityType.fromName(configFile.getString(mobName + ".Type"));
|
for (String mobName : configFile.getKeys(false)) {
|
||||||
|
EntityType type = EntityType.fromName(configFile.getString(mobName + ".Type"));
|
||||||
if (type != null) {
|
|
||||||
DMobType mobType = new DMobType(mobName, type);
|
if (type != null) {
|
||||||
set.add(mobType);
|
DMobType mobType = new DMobType(mobName, type);
|
||||||
|
set.add(mobType);
|
||||||
// Load MaxHealth
|
|
||||||
if (configFile.contains(mobName + ".MaxHealth")) {
|
// Load MaxHealth
|
||||||
mobType.maxHealth = configFile.getInt(mobName + ".MaxHealth");
|
if (configFile.contains(mobName + ".MaxHealth")) {
|
||||||
}
|
mobType.maxHealth = configFile.getInt(mobName + ".MaxHealth");
|
||||||
|
}
|
||||||
// Load Items
|
|
||||||
if (configFile.contains(mobName + ".ItemHelmet")) {
|
// Load Items
|
||||||
mobType.ItemHelmet = new ItemStack(configFile.getInt(mobName + ".ItemHelmet"));// CraftItemStack.asNMSCopy(new
|
if (configFile.contains(mobName + ".ItemHelmet")) {
|
||||||
// ItemStack(configFile.getInt(mobName+".ItemHelmet"))).getItem();
|
mobType.ItemHelmet = new ItemStack(configFile.getInt(mobName + ".ItemHelmet"));// CraftItemStack.asNMSCopy(new
|
||||||
}
|
// ItemStack(configFile.getInt(mobName+".ItemHelmet"))).getItem();
|
||||||
|
}
|
||||||
if (configFile.contains(mobName + ".ItemChestplate")) {
|
|
||||||
mobType.ItemChestplate = new ItemStack(configFile.getInt(mobName + ".ItemChestplate"));// CraftItemStack.asNMSCopy(new
|
if (configFile.contains(mobName + ".ItemChestplate")) {
|
||||||
// ItemStack(configFile.getInt(mobName+".ItemChestplate"))).getItem();
|
mobType.ItemChestplate = new ItemStack(configFile.getInt(mobName + ".ItemChestplate"));// CraftItemStack.asNMSCopy(new
|
||||||
}
|
// ItemStack(configFile.getInt(mobName+".ItemChestplate"))).getItem();
|
||||||
|
}
|
||||||
if (configFile.contains(mobName + ".ItemBoots")) {
|
|
||||||
mobType.ItemBoots = new ItemStack(configFile.getInt(mobName + ".ItemBoots"));// CraftItemStack.asNMSCopy(new
|
if (configFile.contains(mobName + ".ItemBoots")) {
|
||||||
// ItemStack(configFile.getInt(mobName+".ItemBoots"))).getItem();
|
mobType.ItemBoots = new ItemStack(configFile.getInt(mobName + ".ItemBoots"));// CraftItemStack.asNMSCopy(new
|
||||||
}
|
// ItemStack(configFile.getInt(mobName+".ItemBoots"))).getItem();
|
||||||
|
}
|
||||||
if (configFile.contains(mobName + ".ItemLeggings")) {
|
|
||||||
mobType.ItemLeggings = new ItemStack(configFile.getInt(mobName + ".ItemLeggings"));// CraftItemStack.asNMSCopy(new
|
if (configFile.contains(mobName + ".ItemLeggings")) {
|
||||||
// ItemStack(configFile.getInt(mobName+".ItemLeggings"))).getItem();
|
mobType.ItemLeggings = new ItemStack(configFile.getInt(mobName + ".ItemLeggings"));// CraftItemStack.asNMSCopy(new
|
||||||
}
|
// ItemStack(configFile.getInt(mobName+".ItemLeggings"))).getItem();
|
||||||
|
}
|
||||||
if (configFile.contains(mobName + ".ItemHand")) {
|
|
||||||
mobType.ItemHand = new ItemStack(configFile.getInt(mobName + ".ItemHand"));// CraftItemStack.asNMSCopy(new
|
if (configFile.contains(mobName + ".ItemHand")) {
|
||||||
// ItemStack(configFile.getInt(mobName+".ItemHand"))).getItem();
|
mobType.ItemHand = new ItemStack(configFile.getInt(mobName + ".ItemHand"));// CraftItemStack.asNMSCopy(new
|
||||||
}
|
// ItemStack(configFile.getInt(mobName+".ItemHand"))).getItem();
|
||||||
|
}
|
||||||
// Load different Mob options
|
|
||||||
if (configFile.contains(mobName + ".isWitherSkeleton")) {
|
// Load different Mob options
|
||||||
mobType.isWitherSkeleton = configFile.getBoolean(mobName + ".isWitherSkeleton");
|
if (configFile.contains(mobName + ".isWitherSkeleton")) {
|
||||||
}
|
mobType.isWitherSkeleton = configFile.getBoolean(mobName + ".isWitherSkeleton");
|
||||||
|
}
|
||||||
if (configFile.contains(mobName + ".ocelotType")) {
|
|
||||||
mobType.ocelotType = configFile.getString(mobName + ".ocelotType");
|
if (configFile.contains(mobName + ".ocelotType")) {
|
||||||
}
|
mobType.ocelotType = configFile.getString(mobName + ".ocelotType");
|
||||||
|
}
|
||||||
// Drops
|
|
||||||
ConfigurationSection configSetion = configFile.getConfigurationSection(mobName + ".drops");
|
// Drops
|
||||||
if (configSetion != null) {
|
ConfigurationSection configSetion = configFile.getConfigurationSection(mobName + ".drops");
|
||||||
Set<String> list = configSetion.getKeys(false);
|
if (configSetion != null) {
|
||||||
for (String dropPath : list) {
|
Set<String> list = configSetion.getKeys(false);
|
||||||
ItemStack item = null;
|
for (String dropPath : list) {
|
||||||
ItemMeta itemMeta = null;
|
ItemStack item = null;
|
||||||
int chance = 100;
|
ItemMeta itemMeta = null;
|
||||||
|
int chance = 100;
|
||||||
/* Item Stack */
|
|
||||||
Material mat = Material.getMaterial(configSetion.getInt(dropPath + ".id"));
|
/* Item Stack */
|
||||||
int amount = 1;
|
Material mat = Material.getMaterial(configSetion.getInt(dropPath + ".id"));
|
||||||
short data = 0;
|
int amount = 1;
|
||||||
|
short data = 0;
|
||||||
if (configSetion.contains(dropPath + ".amount")) {
|
|
||||||
amount = configSetion.getInt(dropPath + ".amount");
|
if (configSetion.contains(dropPath + ".amount")) {
|
||||||
}
|
amount = configSetion.getInt(dropPath + ".amount");
|
||||||
if (configSetion.contains(dropPath + ".data")) {
|
}
|
||||||
data = Short.parseShort(configSetion.getString(dropPath + ".data"));
|
if (configSetion.contains(dropPath + ".data")) {
|
||||||
}
|
data = Short.parseShort(configSetion.getString(dropPath + ".data"));
|
||||||
|
}
|
||||||
item = new ItemStack(mat, amount, data);
|
|
||||||
itemMeta = item.getItemMeta();
|
item = new ItemStack(mat, amount, data);
|
||||||
|
itemMeta = item.getItemMeta();
|
||||||
/* Enchantments */
|
|
||||||
if (configSetion.contains(dropPath + ".enchantments")) {
|
/* Enchantments */
|
||||||
for (String enchantment : configSetion.getStringList(dropPath + ".enchantments")) {
|
if (configSetion.contains(dropPath + ".enchantments")) {
|
||||||
String[] splittedEnchantment = enchantment.split(" ");
|
for (String enchantment : configSetion.getStringList(dropPath + ".enchantments")) {
|
||||||
if (Enchantment.getByName(splittedEnchantment[0].toUpperCase()) != null) {
|
String[] splittedEnchantment = enchantment.split(" ");
|
||||||
if (splittedEnchantment.length > 1) {
|
if (Enchantment.getByName(splittedEnchantment[0].toUpperCase()) != null) {
|
||||||
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), P.p.parseInt(splittedEnchantment[1]), true);
|
if (splittedEnchantment.length > 1) {
|
||||||
} else {
|
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), IntegerUtil.parseInt(splittedEnchantment[1]), true);
|
||||||
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), 1, true);
|
} else {
|
||||||
}
|
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), 1, true);
|
||||||
} else {
|
}
|
||||||
P.p.log(P.p.language.get("Log_Error_MobEnchantment", splittedEnchantment[0]));
|
} else {
|
||||||
}
|
DungeonsXL.getPlugin().log(DungeonsXL.getPlugin().getDMessages().get("Log_Error_MobEnchantment", splittedEnchantment[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* Item Name */
|
|
||||||
if (configSetion.contains(dropPath + ".name")) {
|
/* Item Name */
|
||||||
itemMeta.setDisplayName(configSetion.getString(dropPath + ".name"));
|
if (configSetion.contains(dropPath + ".name")) {
|
||||||
}
|
itemMeta.setDisplayName(configSetion.getString(dropPath + ".name"));
|
||||||
|
}
|
||||||
/* Item Lore */
|
|
||||||
if (configSetion.contains(dropPath + ".lore")) {
|
/* Item Lore */
|
||||||
String[] lore = configSetion.getString(dropPath + ".lore").split("//");
|
if (configSetion.contains(dropPath + ".lore")) {
|
||||||
itemMeta.setLore(Arrays.asList(lore));
|
String[] lore = configSetion.getString(dropPath + ".lore").split("//");
|
||||||
}
|
itemMeta.setLore(Arrays.asList(lore));
|
||||||
|
}
|
||||||
/* Drop chance */
|
|
||||||
if (configSetion.contains(dropPath + ".chance")) {
|
/* Drop chance */
|
||||||
chance = configSetion.getInt(dropPath + ".chance");
|
if (configSetion.contains(dropPath + ".chance")) {
|
||||||
}
|
chance = configSetion.getInt(dropPath + ".chance");
|
||||||
|
}
|
||||||
/* Add Item to the drops map */
|
|
||||||
item.setItemMeta(itemMeta);
|
/* Add Item to the drops map */
|
||||||
mobType.drops.put(item, chance);
|
item.setItemMeta(itemMeta);
|
||||||
}
|
mobType.getDrops().put(item, chance);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
|
||||||
P.p.log(P.p.language.get("Log_Error_MobType", configFile.getString(mobName + ".Type")));
|
} else {
|
||||||
}
|
DungeonsXL.getPlugin().log(DungeonsXL.getPlugin().getDMessages().get("Log_Error_MobType", configFile.getString(mobName + ".Type")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return set;
|
}
|
||||||
}
|
return set;
|
||||||
|
}
|
||||||
// Get
|
|
||||||
public static DMobType get(String name, Set<DMobType> mobTypes) {
|
// Get
|
||||||
for (DMobType mobType : mobTypes) {
|
public static DMobType get(String name, Set<DMobType> mobTypes) {
|
||||||
if (mobType.name.equalsIgnoreCase(name)) {
|
for (DMobType mobType : mobTypes) {
|
||||||
return mobType;
|
if (mobType.name.equalsIgnoreCase(name)) {
|
||||||
}
|
return mobType;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (P.p.mainConfig.defaultDungeon != null) {
|
|
||||||
for (DMobType mobType : P.p.mainConfig.defaultDungeon.getMobTypes()) {
|
if (DungeonsXL.getPlugin().getMainConfig().defaultDungeon != null) {
|
||||||
if (mobType.name.equalsIgnoreCase(name)) {
|
for (DMobType mobType : DungeonsXL.getPlugin().getMainConfig().defaultDungeon.getMobTypes()) {
|
||||||
return mobType;
|
if (mobType.name.equalsIgnoreCase(name)) {
|
||||||
}
|
return mobType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
public String getName() {
|
|
||||||
return name;
|
/**
|
||||||
}
|
* @return the name
|
||||||
}
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* the name to set
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the drops
|
||||||
|
*/
|
||||||
|
public Map<ItemStack, Integer> getDrops() {
|
||||||
|
return drops;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param drops
|
||||||
|
* the drops to set
|
||||||
|
*/
|
||||||
|
public void setDrops(Map<ItemStack, Integer> drops) {
|
||||||
|
this.drops = drops;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
64
src/io/github/dre2n/dungeonsxl/player/DClass.java
Normal file
64
src/io/github/dre2n/dungeonsxl/player/DClass.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.player;
|
||||||
|
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class DClass {
|
||||||
|
|
||||||
|
private CopyOnWriteArrayList<ItemStack> items = new CopyOnWriteArrayList<ItemStack>();
|
||||||
|
private String name;
|
||||||
|
private boolean hasDog;
|
||||||
|
|
||||||
|
public DClass(String name, CopyOnWriteArrayList<ItemStack> items, boolean hasDog) {
|
||||||
|
this.items = items;
|
||||||
|
this.name = name;
|
||||||
|
this.hasDog = hasDog;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the items
|
||||||
|
*/
|
||||||
|
public CopyOnWriteArrayList<ItemStack> getItems() {
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param itemStack
|
||||||
|
* the ItemStack to add
|
||||||
|
*/
|
||||||
|
public void setItems(ItemStack itemStack) {
|
||||||
|
items.add(itemStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* the name to set
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if the class has a dog
|
||||||
|
*/
|
||||||
|
public boolean hasDog() {
|
||||||
|
return hasDog;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param hasDog
|
||||||
|
* set if the class has a dog
|
||||||
|
*/
|
||||||
|
public void setDog(boolean hasDog) {
|
||||||
|
this.hasDog = hasDog;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
153
src/io/github/dre2n/dungeonsxl/player/DGroup.java
Normal file
153
src/io/github/dre2n/dungeonsxl/player/DGroup.java
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.player;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class DGroup {
|
||||||
|
|
||||||
|
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
||||||
|
|
||||||
|
private CopyOnWriteArrayList<Player> players = new CopyOnWriteArrayList<Player>();
|
||||||
|
private String dungeonname;
|
||||||
|
private GameWorld gWorld;
|
||||||
|
private boolean playing;
|
||||||
|
|
||||||
|
public DGroup(Player player, String dungeonname) {
|
||||||
|
plugin.getDGroups().add(this);
|
||||||
|
|
||||||
|
getPlayers().add(player);
|
||||||
|
playing = false;
|
||||||
|
setDungeonname(dungeonname);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getters and setters
|
||||||
|
|
||||||
|
public CopyOnWriteArrayList<Player> getPlayers() {
|
||||||
|
return players;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayers(CopyOnWriteArrayList<Player> players) {
|
||||||
|
this.players = players;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameWorld getGworld() {
|
||||||
|
return gWorld;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGworld(GameWorld gWorld) {
|
||||||
|
this.gWorld = gWorld;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDungeonname() {
|
||||||
|
return dungeonname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDungeonname(String dungeonname) {
|
||||||
|
this.dungeonname = dungeonname;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if the group is playing
|
||||||
|
*/
|
||||||
|
public boolean isPlaying() {
|
||||||
|
return playing;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param playing
|
||||||
|
* set if the group is playing
|
||||||
|
*/
|
||||||
|
public void setPlaying(boolean playing) {
|
||||||
|
this.playing = playing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPlayer(Player player) {
|
||||||
|
// Send message
|
||||||
|
for (Player groupPlayer : getPlayers()) {
|
||||||
|
MessageUtil.sendMessage(groupPlayer, DungeonsXL.getPlugin().getDMessages().get("Player_JoinGroup", player.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add player
|
||||||
|
getPlayers().add(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePlayer(Player player) {
|
||||||
|
getPlayers().remove(player);
|
||||||
|
GroupSign.updatePerGroup(this);
|
||||||
|
|
||||||
|
// Send message
|
||||||
|
for (Player groupPlayer : getPlayers()) {
|
||||||
|
MessageUtil.sendMessage(groupPlayer, DungeonsXL.getPlugin().getDMessages().get("Player_LeftGroup", player.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check group
|
||||||
|
if (isEmpty()) {
|
||||||
|
remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return getPlayers().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove() {
|
||||||
|
plugin.getDGroups().remove(this);
|
||||||
|
GroupSign.updatePerGroup(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startGame() {
|
||||||
|
playing = true;
|
||||||
|
getGworld().startGame();
|
||||||
|
for (Player player : getPlayers()) {
|
||||||
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
dplayer.respawn();
|
||||||
|
if (DungeonsXL.getPlugin().getMainConfig().enableEconomy()) {
|
||||||
|
File file = new File(DungeonsXL.getPlugin().getDataFolder() + "/maps/" + dungeonname + "/config.yml");
|
||||||
|
if (file != null) {
|
||||||
|
WorldConfig confReader = new WorldConfig(file);
|
||||||
|
if (confReader != null) {
|
||||||
|
DungeonsXL.getPlugin().economy.withdrawPlayer(player, confReader.getFee());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GroupSign.updatePerGroup(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Statics
|
||||||
|
public static DGroup get(Player player) {
|
||||||
|
for (DGroup dgroup : plugin.getDGroups()) {
|
||||||
|
if (dgroup.getPlayers().contains(player)) {
|
||||||
|
return dgroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DGroup get(GameWorld gWorld) {
|
||||||
|
for (DGroup dgroup : plugin.getDGroups()) {
|
||||||
|
if (dgroup.getGworld() == gWorld) {
|
||||||
|
return dgroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void leaveGroup(Player player) {
|
||||||
|
for (DGroup dgroup : plugin.getDGroups()) {
|
||||||
|
if (dgroup.getPlayers().contains(player)) {
|
||||||
|
dgroup.getPlayers().remove(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -1,182 +1,181 @@
|
|||||||
package com.dre.dungeonsxl;
|
package io.github.dre2n.dungeonsxl.player;
|
||||||
|
|
||||||
import java.io.File;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import java.io.IOException;
|
import io.github.dre2n.dungeonsxl.util.MiscUtil;
|
||||||
import java.util.ArrayList;
|
import io.github.dre2n.dungeonsxl.util.offlineplayerutil.OfflinePlayerUtil;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.UUID;
|
import java.io.File;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import org.bukkit.GameMode;
|
import java.util.Collection;
|
||||||
import org.bukkit.Location;
|
import java.util.UUID;
|
||||||
import org.bukkit.World;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.World;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import com.dre.dungeonsxl.util.DUtility;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
public class DSavePlayer {
|
import org.bukkit.potion.PotionEffect;
|
||||||
private static P p = P.p;
|
|
||||||
|
public class DSavePlayer {
|
||||||
private static CopyOnWriteArrayList<DSavePlayer> savePlayers = new CopyOnWriteArrayList<DSavePlayer>();
|
|
||||||
|
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
||||||
// Variables
|
|
||||||
private String playerName;
|
private static CopyOnWriteArrayList<DSavePlayer> savePlayers = new CopyOnWriteArrayList<DSavePlayer>();
|
||||||
private String uuid;
|
|
||||||
|
// Variables
|
||||||
private Location oldLocation;
|
private String playerName;
|
||||||
private ItemStack[] oldInventory;
|
private String uuid;
|
||||||
private ItemStack[] oldArmor;
|
|
||||||
private int oldLvl;
|
private Location oldLocation;
|
||||||
private int oldExp;
|
private ItemStack[] oldInventory;
|
||||||
private int oldHealth;
|
private ItemStack[] oldArmor;
|
||||||
private int oldFoodLevel;
|
private int oldLvl;
|
||||||
private int oldFireTicks;
|
private int oldExp;
|
||||||
private GameMode oldGamemode;
|
private int oldHealth;
|
||||||
private Collection<PotionEffect> oldPotionEffects;
|
private int oldFoodLevel;
|
||||||
|
private int oldFireTicks;
|
||||||
public DSavePlayer(String playerName, UUID uuid, Location oldLocation, ItemStack[] oldInventory, ItemStack[] oldArmor, int oldLvl, int oldExp, int oldHealth, int oldFoodLevel, int oldFireTicks,
|
private GameMode oldGamemode;
|
||||||
GameMode oldGamemode, Collection<PotionEffect> oldPotionEffects) {
|
private Collection<PotionEffect> oldPotionEffects;
|
||||||
savePlayers.add(this);
|
|
||||||
|
public DSavePlayer(String playerName, UUID uuid, Location oldLocation, ItemStack[] oldInventory, ItemStack[] oldArmor, int oldLvl, int oldExp, int oldHealth, int oldFoodLevel, int oldFireTicks,
|
||||||
this.playerName = playerName;
|
GameMode oldGamemode, Collection<PotionEffect> oldPotionEffects) {
|
||||||
this.uuid = uuid.toString();
|
savePlayers.add(this);
|
||||||
|
|
||||||
this.oldLocation = oldLocation;
|
this.playerName = playerName;
|
||||||
this.oldInventory = oldInventory;
|
this.uuid = uuid.toString();
|
||||||
this.oldArmor = oldArmor;
|
|
||||||
this.oldExp = oldExp;
|
this.oldLocation = oldLocation;
|
||||||
this.oldHealth = oldHealth;
|
this.oldInventory = oldInventory;
|
||||||
this.oldFoodLevel = oldFoodLevel;
|
this.oldArmor = oldArmor;
|
||||||
this.oldGamemode = oldGamemode;
|
this.oldExp = oldExp;
|
||||||
this.oldLvl = oldLvl;
|
this.oldHealth = oldHealth;
|
||||||
this.oldFireTicks = oldFireTicks;
|
this.oldFoodLevel = oldFoodLevel;
|
||||||
this.oldPotionEffects = oldPotionEffects;
|
this.oldGamemode = oldGamemode;
|
||||||
|
this.oldLvl = oldLvl;
|
||||||
save();
|
this.oldFireTicks = oldFireTicks;
|
||||||
}
|
this.oldPotionEffects = oldPotionEffects;
|
||||||
|
|
||||||
public void reset(boolean keepInventory) {
|
save();
|
||||||
Player onlinePlayer = p.getServer().getPlayer(this.playerName);
|
}
|
||||||
|
|
||||||
try{
|
public void reset(boolean keepInventory) {
|
||||||
if (onlinePlayer != null) {
|
@SuppressWarnings("deprecation")
|
||||||
/* Player is online */
|
Player player = plugin.getServer().getPlayer(playerName);
|
||||||
if (!keepInventory) {
|
boolean offline = false;
|
||||||
onlinePlayer.getInventory().setContents(this.oldInventory);
|
if (player == null) {
|
||||||
onlinePlayer.getInventory().setArmorContents(this.oldArmor);
|
player = OfflinePlayerUtil.getOfflinePlayer(playerName, UUID.fromString(uuid), oldLocation);
|
||||||
onlinePlayer.setTotalExperience(this.oldExp);
|
offline = true;
|
||||||
onlinePlayer.setLevel(this.oldLvl);
|
}
|
||||||
onlinePlayer.setHealth(this.oldHealth);
|
if (player == null) {
|
||||||
onlinePlayer.setFoodLevel(this.oldFoodLevel);
|
return;
|
||||||
onlinePlayer.setGameMode(this.oldGamemode);
|
}
|
||||||
onlinePlayer.setFireTicks(this.oldFireTicks);
|
|
||||||
for (PotionEffect effect : onlinePlayer.getActivePotionEffects()) {
|
try {
|
||||||
onlinePlayer.removePotionEffect(effect.getType());
|
if ( !keepInventory) {
|
||||||
}
|
player.getInventory().setContents(oldInventory);
|
||||||
onlinePlayer.addPotionEffects(this.oldPotionEffects);
|
player.getInventory().setArmorContents(oldArmor);
|
||||||
}
|
player.setTotalExperience(oldExp);
|
||||||
DUtility.secureTeleport(onlinePlayer, this.oldLocation);
|
player.setLevel(oldLvl);
|
||||||
} else {
|
player.setHealth(oldHealth);
|
||||||
/* Player is offline */
|
player.setFoodLevel(oldFoodLevel);
|
||||||
Player offlinePlayer = p.getOfflinePlayer(this.playerName, UUID.fromString(uuid), this.oldLocation);
|
player.setGameMode(oldGamemode);
|
||||||
if (offlinePlayer != null && !keepInventory) {
|
player.setFireTicks(oldFireTicks);
|
||||||
offlinePlayer.getInventory().setContents(this.oldInventory);
|
for (PotionEffect effect : player.getActivePotionEffects()) {
|
||||||
offlinePlayer.getInventory().setArmorContents(this.oldArmor);
|
player.removePotionEffect(effect.getType());
|
||||||
offlinePlayer.setTotalExperience(this.oldExp);
|
}
|
||||||
offlinePlayer.setLevel(this.oldLvl);
|
// Causes NPE if offline
|
||||||
offlinePlayer.setHealth(this.oldHealth);
|
if ( !offline) {
|
||||||
offlinePlayer.setFoodLevel(this.oldFoodLevel);
|
player.addPotionEffects(oldPotionEffects);
|
||||||
offlinePlayer.setGameMode(this.oldGamemode);
|
|
||||||
offlinePlayer.setFireTicks(this.oldFireTicks);
|
} else {
|
||||||
for (PotionEffect effect : offlinePlayer.getActivePotionEffects()) {
|
player.saveData();
|
||||||
offlinePlayer.removePotionEffect(effect.getType());
|
}
|
||||||
}
|
}
|
||||||
//causes NP
|
|
||||||
//offlinePlayer.addPotionEffects(this.oldPotionEffects);
|
if ( !offline) {
|
||||||
|
MiscUtil.secureTeleport(player, oldLocation);
|
||||||
offlinePlayer.saveData();
|
}
|
||||||
}
|
|
||||||
}
|
} catch (NullPointerException exception) {
|
||||||
} catch (NullPointerException exception) {
|
plugin.log("Corrupted playerdata detected and removed!");
|
||||||
P.p.log("Corrupt playerdata detected and removed!");
|
}
|
||||||
}
|
|
||||||
|
savePlayers.remove(this);
|
||||||
savePlayers.remove(this);
|
save();
|
||||||
save();
|
}
|
||||||
|
|
||||||
}
|
// Static
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
// Static
|
public static void save() {
|
||||||
public static void save() {
|
FileConfiguration configFile = new YamlConfiguration();
|
||||||
FileConfiguration configFile = new YamlConfiguration();
|
|
||||||
|
for (DSavePlayer savePlayer : savePlayers) {
|
||||||
for (DSavePlayer savePlayer : savePlayers) {
|
configFile.set(savePlayer.playerName + ".uuid", savePlayer.uuid);
|
||||||
configFile.set(savePlayer.playerName + ".uuid", savePlayer.uuid);
|
configFile.set(savePlayer.playerName + ".oldGamemode", savePlayer.oldGamemode.getValue());
|
||||||
configFile.set(savePlayer.playerName + ".oldGamemode", savePlayer.oldGamemode.getValue());
|
configFile.set(savePlayer.playerName + ".oldFireTicks", savePlayer.oldFireTicks);
|
||||||
configFile.set(savePlayer.playerName + ".oldFireTicks", savePlayer.oldFireTicks);
|
configFile.set(savePlayer.playerName + ".oldFoodLevel", savePlayer.oldFoodLevel);
|
||||||
configFile.set(savePlayer.playerName + ".oldFoodLevel", savePlayer.oldFoodLevel);
|
configFile.set(savePlayer.playerName + ".oldHealth", savePlayer.oldHealth);
|
||||||
configFile.set(savePlayer.playerName + ".oldHealth", savePlayer.oldHealth);
|
configFile.set(savePlayer.playerName + ".oldExp", savePlayer.oldExp);
|
||||||
configFile.set(savePlayer.playerName + ".oldExp", savePlayer.oldExp);
|
configFile.set(savePlayer.playerName + ".oldLvl", savePlayer.oldLvl);
|
||||||
configFile.set(savePlayer.playerName + ".oldLvl", savePlayer.oldLvl);
|
configFile.set(savePlayer.playerName + ".oldArmor", savePlayer.oldArmor);
|
||||||
configFile.set(savePlayer.playerName + ".oldArmor", savePlayer.oldArmor);
|
configFile.set(savePlayer.playerName + ".oldInventory", savePlayer.oldInventory);
|
||||||
configFile.set(savePlayer.playerName + ".oldInventory", savePlayer.oldInventory);
|
configFile.set(savePlayer.playerName + ".oldLocation.x", savePlayer.oldLocation.getX());
|
||||||
configFile.set(savePlayer.playerName + ".oldLocation.x", savePlayer.oldLocation.getX());
|
configFile.set(savePlayer.playerName + ".oldLocation.y", savePlayer.oldLocation.getY());
|
||||||
configFile.set(savePlayer.playerName + ".oldLocation.y", savePlayer.oldLocation.getY());
|
configFile.set(savePlayer.playerName + ".oldLocation.z", savePlayer.oldLocation.getZ());
|
||||||
configFile.set(savePlayer.playerName + ".oldLocation.z", savePlayer.oldLocation.getZ());
|
configFile.set(savePlayer.playerName + ".oldLocation.yaw", savePlayer.oldLocation.getYaw());
|
||||||
configFile.set(savePlayer.playerName + ".oldLocation.yaw", savePlayer.oldLocation.getYaw());
|
configFile.set(savePlayer.playerName + ".oldLocation.pitch", savePlayer.oldLocation.getPitch());
|
||||||
configFile.set(savePlayer.playerName + ".oldLocation.pitch", savePlayer.oldLocation.getPitch());
|
configFile.set(savePlayer.playerName + ".oldLocation.world", savePlayer.oldLocation.getWorld().getName());
|
||||||
configFile.set(savePlayer.playerName + ".oldLocation.world", savePlayer.oldLocation.getWorld().getName());
|
configFile.set(savePlayer.playerName + ".oldPotionEffects", savePlayer.oldPotionEffects);
|
||||||
configFile.set(savePlayer.playerName + ".oldPotionEffects", savePlayer.oldPotionEffects);
|
}
|
||||||
}
|
|
||||||
|
try {
|
||||||
try {
|
configFile.save(new File(plugin.getDataFolder(), "savePlayers.yml"));
|
||||||
configFile.save(new File(p.getDataFolder(), "savePlayers.yml"));
|
} catch (IOException e) {
|
||||||
} catch (IOException e) {
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@SuppressWarnings({"unchecked", "deprecation"})
|
||||||
@SuppressWarnings("unchecked")
|
public static void load() {
|
||||||
public static void load() {
|
FileConfiguration configFile = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "savePlayers.yml"));
|
||||||
FileConfiguration configFile = YamlConfiguration.loadConfiguration(new File(p.getDataFolder(), "savePlayers.yml"));
|
|
||||||
|
for (String playerName : configFile.getKeys(false)) {
|
||||||
for (String playerName : configFile.getKeys(false)) {
|
// Load uuid
|
||||||
// Load uuid
|
UUID uuid = UUID.fromString(configFile.getString(playerName + ".uuid"));
|
||||||
UUID uuid = UUID.fromString(configFile.getString(playerName + ".uuid"));
|
|
||||||
|
// Load inventory data
|
||||||
// Load inventory data
|
ArrayList<ItemStack> oldInventoryList = (ArrayList<ItemStack>) configFile.get(playerName + ".oldInventory");
|
||||||
ArrayList<ItemStack> oldInventoryList = (ArrayList<ItemStack>) configFile.get(playerName + ".oldInventory");
|
ArrayList<ItemStack> oldArmorList = (ArrayList<ItemStack>) configFile.get(playerName + ".oldArmor");
|
||||||
ArrayList<ItemStack> oldArmorList = (ArrayList<ItemStack>) configFile.get(playerName + ".oldArmor");
|
|
||||||
|
ItemStack[] oldInventory = oldInventoryList.toArray(new ItemStack[oldInventoryList.size()]);
|
||||||
ItemStack[] oldInventory = oldInventoryList.toArray(new ItemStack[oldInventoryList.size()]);
|
ItemStack[] oldArmor = oldArmorList.toArray(new ItemStack[oldArmorList.size()]);
|
||||||
ItemStack[] oldArmor = oldArmorList.toArray(new ItemStack[oldArmorList.size()]);
|
|
||||||
|
// Load other data
|
||||||
// Load other data
|
int oldLvl = configFile.getInt(playerName + ".oldLvl");
|
||||||
int oldLvl = configFile.getInt(playerName + ".oldLvl");
|
int oldExp = configFile.getInt(playerName + ".oldExp");
|
||||||
int oldExp = configFile.getInt(playerName + ".oldExp");
|
int oldHealth = configFile.getInt(playerName + ".oldHealth");
|
||||||
int oldHealth = configFile.getInt(playerName + ".oldHealth");
|
int oldFoodLevel = configFile.getInt(playerName + ".oldFoodLevel");
|
||||||
int oldFoodLevel = configFile.getInt(playerName + ".oldFoodLevel");
|
int oldFireTicks = configFile.getInt(playerName + ".oldFireTicks");
|
||||||
int oldFireTicks = configFile.getInt(playerName + ".oldFireTicks");
|
GameMode oldGamemode = GameMode.getByValue(configFile.getInt(playerName + ".oldGamemode"));
|
||||||
GameMode oldGamemode = GameMode.getByValue(configFile.getInt(playerName + ".oldGamemode"));
|
Collection<PotionEffect> oldPotionEffects = (Collection<PotionEffect>) configFile.get(playerName + ".oldPotionEffects");
|
||||||
Collection<PotionEffect> oldPotionEffects = (Collection<PotionEffect>) configFile.get(playerName + ".oldPotionEffects");
|
|
||||||
|
// Location
|
||||||
// Location
|
World world = plugin.getServer().getWorld(configFile.getString(playerName + ".oldLocation.world"));
|
||||||
World world = p.getServer().getWorld(configFile.getString(playerName + ".oldLocation.world"));
|
if (world == null) {
|
||||||
if (world == null) {
|
world = plugin.getServer().getWorlds().get(0);
|
||||||
world = p.getServer().getWorlds().get(0);
|
}
|
||||||
}
|
|
||||||
|
Location oldLocation = new Location(world, configFile.getDouble(playerName + ".oldLocation.x"), configFile.getDouble(playerName + ".oldLocation.y"), configFile.getDouble(playerName
|
||||||
Location oldLocation = new Location(world, configFile.getDouble(playerName + ".oldLocation.x"), configFile.getDouble(playerName + ".oldLocation.y"), configFile.getDouble(playerName
|
+ ".oldLocation.z"), configFile.getInt(playerName + ".oldLocation.yaw"), configFile.getInt(playerName + ".oldLocation.pitch"));
|
||||||
+ ".oldLocation.z"), configFile.getInt(playerName + ".oldLocation.yaw"), configFile.getInt(playerName + ".oldLocation.pitch"));
|
|
||||||
|
// Create Player
|
||||||
// Create Player
|
DSavePlayer savePlayer = new DSavePlayer(playerName, uuid, oldLocation, oldInventory, oldArmor, oldLvl, oldExp, oldHealth, oldFoodLevel, oldFireTicks, oldGamemode, oldPotionEffects);
|
||||||
DSavePlayer savePlayer = new DSavePlayer(playerName, uuid, oldLocation, oldInventory, oldArmor, oldLvl, oldExp, oldHealth, oldFoodLevel, oldFireTicks, oldGamemode, oldPotionEffects);
|
savePlayer.reset(false);
|
||||||
savePlayer.reset(false);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
@ -1,15 +1,17 @@
|
|||||||
package com.dre.dungeonsxl.signs;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.IntegerUtil;
|
||||||
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
import org.bukkit.block.Sign;
|
||||||
|
|
||||||
public class SIGNBlock extends DSign {
|
|
||||||
|
|
||||||
|
public class BlockSign extends DSign {
|
||||||
|
|
||||||
public static String name = "Block";
|
public static String name = "Block";
|
||||||
public String buildPermissions = "dxl.sign.block";
|
public String buildPermissions = "dxl.sign.block";
|
||||||
public boolean onDungeonInit = false;
|
public boolean onDungeonInit = false;
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
private boolean active;
|
private boolean active;
|
||||||
@ -17,74 +19,76 @@ public class SIGNBlock extends DSign {
|
|||||||
private int onBlockId = 0;
|
private int onBlockId = 0;
|
||||||
private byte offBlockData = 0x0;
|
private byte offBlockData = 0x0;
|
||||||
private byte onBlockData = 0x0;
|
private byte onBlockData = 0x0;
|
||||||
|
|
||||||
public SIGNBlock(Sign sign, GameWorld gworld) {
|
public BlockSign(Sign sign, GameWorld gworld) {
|
||||||
super(sign, gworld);
|
super(sign, gworld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
String lines[] = sign.getLines();
|
String lines[] = getSign().getLines();
|
||||||
if (!lines[1].equals("")) {
|
if ( !lines[1].equals("")) {
|
||||||
String line1[] = lines[1].split(",");
|
String line1[] = lines[1].split(",");
|
||||||
Material offBlock = Material.matchMaterial(line1[0]);
|
Material offBlock = Material.matchMaterial(line1[0]);
|
||||||
if (offBlock != null) {
|
if (offBlock != null) {
|
||||||
offBlockId = offBlock.getId();
|
offBlockId = offBlock.getId();
|
||||||
} else {
|
} else {
|
||||||
offBlockId = p.parseInt(line1[0]);
|
offBlockId = IntegerUtil.parseInt(line1[0]);
|
||||||
}
|
}
|
||||||
if (line1.length > 1) {
|
if (line1.length > 1) {
|
||||||
offBlockData = (byte) p.parseInt(line1[1]);
|
offBlockData = (byte) IntegerUtil.parseInt(line1[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lines[2].equals("")) {
|
if ( !lines[2].equals("")) {
|
||||||
String line2[] = lines[2].split(",");
|
String line2[] = lines[2].split(",");
|
||||||
Material onBlock = Material.matchMaterial(line2[0]);
|
Material onBlock = Material.matchMaterial(line2[0]);
|
||||||
if (onBlock != null) {
|
if (onBlock != null) {
|
||||||
onBlockId = onBlock.getId();
|
onBlockId = onBlock.getId();
|
||||||
} else {
|
} else {
|
||||||
onBlockId = p.parseInt(line2[0]);
|
onBlockId = IntegerUtil.parseInt(line2[0]);
|
||||||
}
|
}
|
||||||
if (line2.length > 1) {
|
if (line2.length > 1) {
|
||||||
onBlockData = (byte) p.parseInt(line2[1]);
|
onBlockData = (byte) IntegerUtil.parseInt(line2[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sign.getBlock().setTypeIdAndData(offBlockId, offBlockData, true);
|
getSign().getBlock().setTypeIdAndData(offBlockId, offBlockData, true);
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
if (initialized && !active) {
|
if (initialized && !active) {
|
||||||
sign.getBlock().setTypeIdAndData(onBlockId, onBlockData, true);
|
getSign().getBlock().setTypeIdAndData(onBlockId, onBlockData, true);
|
||||||
active = true;
|
active = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
if (initialized && active) {
|
if (initialized && active) {
|
||||||
sign.getBlock().setTypeIdAndData(offBlockId, offBlockData, true);
|
getSign().getBlock().setTypeIdAndData(offBlockId, offBlockData, true);
|
||||||
active = false;
|
active = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public String getPermissions() {
|
||||||
return buildPermissions;
|
return buildPermissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOnDungeonInit() {
|
public boolean isOnDungeonInit() {
|
||||||
return onDungeonInit;
|
return onDungeonInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,80 +1,79 @@
|
|||||||
package com.dre.dungeonsxl.signs;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
import org.bukkit.Material;
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
import org.bukkit.block.Sign;
|
import io.github.dre2n.dungeonsxl.util.MessageUtil;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import com.dre.dungeonsxl.DPlayer;
|
|
||||||
import com.dre.dungeonsxl.P;
|
import org.bukkit.Material;
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
public class SIGNCheckpoint extends DSign {
|
|
||||||
|
public class CheckpointSign extends DSign {
|
||||||
public static String name = "Checkpoint";
|
|
||||||
private String buildPermissions = "dxl.sign.checkpoint";
|
public static String name = "Checkpoint";
|
||||||
private boolean onDungeonInit = false;
|
private String buildPermissions = "dxl.sign.checkpoint";
|
||||||
|
private boolean onDungeonInit = false;
|
||||||
// Variables
|
|
||||||
private boolean initialized;
|
// Variables
|
||||||
private CopyOnWriteArrayList<DPlayer> done = new CopyOnWriteArrayList<DPlayer>();
|
private boolean initialized;
|
||||||
|
private CopyOnWriteArrayList<DPlayer> done = new CopyOnWriteArrayList<DPlayer>();
|
||||||
public SIGNCheckpoint(Sign sign, GameWorld gworld) {
|
|
||||||
super(sign, gworld);
|
public CheckpointSign(Sign sign, GameWorld gWorld) {
|
||||||
}
|
super(sign, gWorld);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean check() {
|
@Override
|
||||||
// TODO Auto-generated method stub
|
public boolean check() {
|
||||||
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public void onInit() {
|
||||||
public void onInit() {
|
getSign().getBlock().setType(Material.AIR);
|
||||||
sign.getBlock().setType(Material.AIR);
|
|
||||||
|
initialized = true;
|
||||||
initialized = true;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public void onTrigger() {
|
||||||
public void onTrigger() {
|
if (initialized) {
|
||||||
if (initialized) {
|
for (DPlayer dplayer : DPlayer.get(getGWorld().world)) {
|
||||||
for (DPlayer dplayer : DPlayer.get(this.gworld.world)) {
|
dplayer.setCheckpoint(getSign().getLocation());
|
||||||
dplayer.setCheckpoint(this.sign.getLocation());
|
MessageUtil.sendMessage(dplayer.player, DungeonsXL.getPlugin().getDMessages().get("Player_CheckpointReached"));
|
||||||
P.p.msg(dplayer.player, P.p.language.get("Player_CheckpointReached"));
|
}
|
||||||
}
|
|
||||||
|
remove();
|
||||||
remove();
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public boolean onPlayerTrigger(Player player) {
|
||||||
public boolean onPlayerTrigger(Player player) {
|
if (initialized) {
|
||||||
if (initialized) {
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
DPlayer dplayer = DPlayer.get(player);
|
if (dplayer != null) {
|
||||||
if (dplayer != null) {
|
if ( !done.contains(dplayer)) {
|
||||||
if (!done.contains(dplayer)) {
|
done.add(dplayer);
|
||||||
done.add(dplayer);
|
dplayer.setCheckpoint(getSign().getLocation());
|
||||||
dplayer.setCheckpoint(this.sign.getLocation());
|
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_CheckpointReached"));
|
||||||
P.p.msg(player, P.p.language.get("Player_CheckpointReached"));
|
}
|
||||||
}
|
}
|
||||||
}
|
if (done.size() >= DPlayer.get(getGWorld().world).size()) {
|
||||||
if (done.size() >= DPlayer.get(this.gworld.world).size()) {
|
remove();
|
||||||
remove();
|
}
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public String getPermissions() {
|
||||||
public String getPermissions() {
|
return buildPermissions;
|
||||||
return buildPermissions;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public boolean isOnDungeonInit() {
|
||||||
public boolean isOnDungeonInit() {
|
return onDungeonInit;
|
||||||
return onDungeonInit;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
61
src/io/github/dre2n/dungeonsxl/sign/ChestSign.java
Normal file
61
src/io/github/dre2n/dungeonsxl/sign/ChestSign.java
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameChest;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
|
||||||
|
public class ChestSign extends DSign {
|
||||||
|
|
||||||
|
public static String name = "Chest";
|
||||||
|
public String buildPermissions = "dxl.sign.chest";
|
||||||
|
public boolean onDungeonInit = false;
|
||||||
|
|
||||||
|
// Variables
|
||||||
|
private double moneyReward;
|
||||||
|
|
||||||
|
public ChestSign(Sign sign, GameWorld gWorld) {
|
||||||
|
super(sign, gWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean check() {
|
||||||
|
String lines[] = getSign().getLines();
|
||||||
|
if (lines[1].equals("")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInit() {
|
||||||
|
String lines[] = getSign().getLines();
|
||||||
|
if ( !lines[1].equals("")) {
|
||||||
|
moneyReward = Double.parseDouble(lines[1]);
|
||||||
|
}
|
||||||
|
for (int i = -1; i <= 1; i++) {
|
||||||
|
if (getSign().getBlock().getRelative(i, 0, 0).getType() == Material.CHEST) {
|
||||||
|
new GameChest(getSign().getBlock().getRelative(i, 0, 0), getGWorld(), moneyReward);
|
||||||
|
}
|
||||||
|
if (getSign().getBlock().getRelative(0, 0, i).getType() == Material.CHEST) {
|
||||||
|
new GameChest(getSign().getBlock().getRelative(0, 0, i), getGWorld(), moneyReward);
|
||||||
|
}
|
||||||
|
if (getSign().getBlock().getRelative(0, i, 0).getType() == Material.CHEST) {
|
||||||
|
new GameChest(getSign().getBlock().getRelative(0, i, 0), getGWorld(), moneyReward);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getSign().getBlock().setType(Material.AIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPermissions() {
|
||||||
|
return buildPermissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnDungeonInit() {
|
||||||
|
return onDungeonInit;
|
||||||
|
}
|
||||||
|
}
|
56
src/io/github/dre2n/dungeonsxl/sign/ChunkUpdaterSign.java
Normal file
56
src/io/github/dre2n/dungeonsxl/sign/ChunkUpdaterSign.java
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.IntegerUtil;
|
||||||
|
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
|
||||||
|
public class ChunkUpdaterSign extends DSign {
|
||||||
|
|
||||||
|
public static String name = "ChunkUpdater";
|
||||||
|
public String buildPermissions = "dxl.sign.chunkupdater";
|
||||||
|
public boolean onDungeonInit = true;
|
||||||
|
|
||||||
|
public ChunkUpdaterSign(Sign sign, GameWorld gWorld) {
|
||||||
|
super(sign, gWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean check() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInit() {
|
||||||
|
String lines[] = getSign().getLines();
|
||||||
|
Chunk chunk = getGWorld().world.getChunkAt(getSign().getBlock());
|
||||||
|
if ( !lines[1].equals("")) {
|
||||||
|
Integer radius = IntegerUtil.parseInt(lines[1]);
|
||||||
|
for (int x = -radius; x < radius; x++) {
|
||||||
|
for (int z = -radius; z < radius; z++) {
|
||||||
|
Chunk chunk1 = getGWorld().world.getChunkAt(chunk.getX() - x, chunk.getZ() - z);
|
||||||
|
chunk1.load();
|
||||||
|
getGWorld().loadedChunks.add(chunk1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
chunk.load();
|
||||||
|
getGWorld().loadedChunks.add(chunk);
|
||||||
|
}
|
||||||
|
getSign().getBlock().setType(Material.AIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPermissions() {
|
||||||
|
return buildPermissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnDungeonInit() {
|
||||||
|
return onDungeonInit;
|
||||||
|
}
|
||||||
|
}
|
82
src/io/github/dre2n/dungeonsxl/sign/ClassesSign.java
Normal file
82
src/io/github/dre2n/dungeonsxl/sign/ClassesSign.java
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DClass;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
|
||||||
|
public class ClassesSign extends DSign {
|
||||||
|
|
||||||
|
public static String name = "Classes";
|
||||||
|
public String buildPermissions = "dxl.sign.classes";
|
||||||
|
public boolean onDungeonInit = true;
|
||||||
|
|
||||||
|
public ClassesSign(Sign sign, GameWorld gWorld) {
|
||||||
|
super(sign, gWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean check() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public void onInit() {
|
||||||
|
if ( !getGWorld().getConfig().isLobbyDisabled()) {
|
||||||
|
|
||||||
|
int[] direction = GroupSign.getDirection(getSign().getBlock().getData());
|
||||||
|
int directionX = direction[0];
|
||||||
|
int directionZ = direction[1];
|
||||||
|
|
||||||
|
int xx = 0, zz = 0;
|
||||||
|
for (DClass dclass : getGWorld().getConfig().getClasses()) {
|
||||||
|
|
||||||
|
// Check existing signs
|
||||||
|
boolean isContinued = true;
|
||||||
|
for (Sign isusedsign : getGWorld().signClass) {
|
||||||
|
if (dclass.getName().equalsIgnoreCase(ChatColor.stripColor(isusedsign.getLine(1)))) {
|
||||||
|
isContinued = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isContinued) {
|
||||||
|
Block classBlock = getSign().getBlock().getRelative(xx, 0, zz);
|
||||||
|
|
||||||
|
if (classBlock.getData() == getSign().getData().getData() && classBlock.getType() == Material.WALL_SIGN && classBlock.getState() instanceof Sign) {
|
||||||
|
Sign classSign = (Sign) classBlock.getState();
|
||||||
|
|
||||||
|
classSign.setLine(0, ChatColor.DARK_BLUE + "############");
|
||||||
|
classSign.setLine(1, ChatColor.DARK_GREEN + dclass.getName());
|
||||||
|
classSign.setLine(2, "");
|
||||||
|
classSign.setLine(3, ChatColor.DARK_BLUE + "############");
|
||||||
|
classSign.update();
|
||||||
|
|
||||||
|
getGWorld().signClass.add(classSign);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
xx = xx + directionX;
|
||||||
|
zz = zz + directionZ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
getSign().getBlock().setType(Material.AIR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPermissions() {
|
||||||
|
return buildPermissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnDungeonInit() {
|
||||||
|
return onDungeonInit;
|
||||||
|
}
|
||||||
|
}
|
91
src/io/github/dre2n/dungeonsxl/sign/CommandSign.java
Normal file
91
src/io/github/dre2n/dungeonsxl/sign/CommandSign.java
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.commandsxl.CCommand;
|
||||||
|
import io.github.dre2n.commandsxl.CommandsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class CommandSign extends DSign {
|
||||||
|
|
||||||
|
public static String name = "Cmd";
|
||||||
|
public String buildPermissions = "dxl.sign.cmd";
|
||||||
|
public boolean onDungeonInit = false;
|
||||||
|
|
||||||
|
// Variables
|
||||||
|
private CCommand cCommand;
|
||||||
|
private String command;
|
||||||
|
private String executor;
|
||||||
|
private boolean initialized;
|
||||||
|
|
||||||
|
public CommandSign(Sign sign, GameWorld gWorld) {
|
||||||
|
super(sign, gWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean check() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInit() {
|
||||||
|
command = getSign().getLine(1);
|
||||||
|
executor = getSign().getLine(2);
|
||||||
|
cCommand = CommandsXL.getCCommands().getCCommand(command);
|
||||||
|
|
||||||
|
if (getTriggers().isEmpty()) {
|
||||||
|
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGWorld());
|
||||||
|
if (trigger != null) {
|
||||||
|
trigger.addListener(this);
|
||||||
|
getTriggers().add(trigger);
|
||||||
|
}
|
||||||
|
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
|
||||||
|
getSign().setLine(1, ChatColor.DARK_GREEN + command);
|
||||||
|
getSign().setLine(2, "");
|
||||||
|
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
|
||||||
|
getSign().update();
|
||||||
|
} else {
|
||||||
|
getSign().getBlock().setType(Material.AIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPlayerTrigger(Player player) {
|
||||||
|
if (executor.equalsIgnoreCase("Console")) {
|
||||||
|
cCommand.execute(player, Bukkit.getConsoleSender(), true);
|
||||||
|
|
||||||
|
} else if (executor.equalsIgnoreCase("OP")) {
|
||||||
|
cCommand.execute(player, player, true);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
cCommand.execute(player, player, false);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTrigger() {
|
||||||
|
if (initialized) {
|
||||||
|
remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPermissions() {
|
||||||
|
return buildPermissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnDungeonInit() {
|
||||||
|
return onDungeonInit;
|
||||||
|
}
|
||||||
|
}
|
220
src/io/github/dre2n/dungeonsxl/sign/DSign.java
Normal file
220
src/io/github/dre2n/dungeonsxl/sign/DSign.java
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.trigger.Trigger;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public abstract class DSign {
|
||||||
|
|
||||||
|
static DungeonsXL plugin = DungeonsXL.getPlugin();
|
||||||
|
|
||||||
|
private Sign sign;
|
||||||
|
private GameWorld gWorld;
|
||||||
|
|
||||||
|
// List of Triggers
|
||||||
|
private Set<Trigger> triggers = new HashSet<Trigger>();
|
||||||
|
|
||||||
|
public DSign(Sign sign, GameWorld gWorld) {
|
||||||
|
this.setSign(sign);
|
||||||
|
this.gWorld = gWorld;
|
||||||
|
|
||||||
|
// Check Trigger
|
||||||
|
if (gWorld != null) {
|
||||||
|
String line3 = sign.getLine(3).replaceAll("\\s", "");
|
||||||
|
String[] triggerTypes = line3.split(",");
|
||||||
|
|
||||||
|
for (String triggerString : triggerTypes) {
|
||||||
|
if ( !triggerString.equals("")) {
|
||||||
|
|
||||||
|
String type = triggerString.substring(0, 1);
|
||||||
|
String value = null;
|
||||||
|
if (triggerString.length() > 1) {
|
||||||
|
value = triggerString.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Trigger trigger = Trigger.getOrCreate(type, value, this);
|
||||||
|
if (trigger != null) {
|
||||||
|
trigger.addListener(this);
|
||||||
|
addTrigger(trigger);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the sign
|
||||||
|
*/
|
||||||
|
public Sign getSign() {
|
||||||
|
return sign;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param sign
|
||||||
|
* the sign to set
|
||||||
|
*/
|
||||||
|
public void setSign(Sign sign) {
|
||||||
|
this.sign = sign;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the gWorld
|
||||||
|
*/
|
||||||
|
public GameWorld getGWorld() {
|
||||||
|
return gWorld;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the triggers
|
||||||
|
*/
|
||||||
|
public Set<Trigger> getTriggers() {
|
||||||
|
return triggers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param trigger
|
||||||
|
* the trigger to add
|
||||||
|
*/
|
||||||
|
public void addTrigger(Trigger trigger) {
|
||||||
|
addTrigger(trigger);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param trigger
|
||||||
|
* the trigger to remove
|
||||||
|
*/
|
||||||
|
public void removeTrigger(Trigger trigger) {
|
||||||
|
triggers.remove(trigger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onInit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onTrigger() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onPlayerTrigger(Player player) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDisable() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onUpdate() {
|
||||||
|
for (Trigger trigger : triggers) {
|
||||||
|
if ( !trigger.triggered) {
|
||||||
|
onDisable();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (triggers.size() == 1) {
|
||||||
|
if (trigger.player != null) {
|
||||||
|
if (onPlayerTrigger(trigger.player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onTrigger();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove() {
|
||||||
|
for (Trigger trigger : triggers) {
|
||||||
|
trigger.removeListener(this);
|
||||||
|
}
|
||||||
|
gWorld.dSigns.remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasTriggers() {
|
||||||
|
return !triggers.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DSign create(Sign sign, GameWorld gWorld) {
|
||||||
|
String[] lines = sign.getLines();
|
||||||
|
DSign dSign = null;
|
||||||
|
|
||||||
|
if (lines[0].equalsIgnoreCase("[" + CheckpointSign.name + "]")) {
|
||||||
|
dSign = new CheckpointSign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + ChestSign.name + "]")) {
|
||||||
|
dSign = new ChestSign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + ChunkUpdaterSign.name + "]")) {
|
||||||
|
dSign = new ChunkUpdaterSign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + ClassesSign.name + "]")) {
|
||||||
|
dSign = new ClassesSign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + CommandSign.name + "]")) {
|
||||||
|
dSign = new CommandSign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + EndSign.name + "]")) {
|
||||||
|
dSign = new EndSign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + LeaveSign.name + "]")) {
|
||||||
|
dSign = new LeaveSign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + LobbySign.name + "]")) {
|
||||||
|
dSign = new LobbySign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + MobSign.name + "]")) {
|
||||||
|
dSign = new MobSign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + MsgSign.name + "]")) {
|
||||||
|
dSign = new MsgSign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + MythicMobsSign.name + "]")) {
|
||||||
|
dSign = new MythicMobsSign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + PlaceSign.name + "]")) {
|
||||||
|
dSign = new PlaceSign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + ReadySign.name + "]")) {
|
||||||
|
dSign = new ReadySign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + SoundMsgSign.name + "]")) {
|
||||||
|
dSign = new SoundMsgSign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + StartSign.name + "]")) {
|
||||||
|
dSign = new StartSign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + TriggerSign.name + "]")) {
|
||||||
|
dSign = new TriggerSign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + InteractSign.name + "]")) {
|
||||||
|
dSign = new InteractSign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + RedstoneSign.name + "]")) {
|
||||||
|
dSign = new RedstoneSign(sign, gWorld);
|
||||||
|
|
||||||
|
} else if (lines[0].equalsIgnoreCase("[" + BlockSign.name + "]")) {
|
||||||
|
dSign = new BlockSign(sign, gWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dSign != null && gWorld != null) {
|
||||||
|
if (dSign.isOnDungeonInit()) {
|
||||||
|
dSign.onInit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dSign;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Abstract methods
|
||||||
|
|
||||||
|
public abstract boolean check();
|
||||||
|
|
||||||
|
public abstract String getPermissions();
|
||||||
|
|
||||||
|
public abstract boolean isOnDungeonInit();
|
||||||
|
|
||||||
|
}
|
75
src/io/github/dre2n/dungeonsxl/sign/EndSign.java
Normal file
75
src/io/github/dre2n/dungeonsxl/sign/EndSign.java
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class EndSign extends DSign {
|
||||||
|
|
||||||
|
public static String name = "End";
|
||||||
|
public String buildPermissions = "dxl.sign.end";
|
||||||
|
public boolean onDungeonInit = false;
|
||||||
|
|
||||||
|
public EndSign(Sign sign, GameWorld gWorld) {
|
||||||
|
super(sign, gWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean check() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInit() {
|
||||||
|
if (getTriggers().isEmpty()) {
|
||||||
|
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGWorld());
|
||||||
|
if (trigger != null) {
|
||||||
|
trigger.addListener(this);
|
||||||
|
addTrigger(trigger);
|
||||||
|
}
|
||||||
|
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
|
||||||
|
getSign().setLine(1, ChatColor.DARK_GREEN + "End");
|
||||||
|
getSign().setLine(2, "");
|
||||||
|
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
|
||||||
|
getSign().update();
|
||||||
|
} else {
|
||||||
|
getSign().getBlock().setType(Material.AIR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPlayerTrigger(Player player) {
|
||||||
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
if (dplayer != null) {
|
||||||
|
if ( !dplayer.isFinished) {
|
||||||
|
dplayer.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTrigger() {
|
||||||
|
for (DPlayer dplayer : DungeonsXL.getPlugin().getDPlayers()) {
|
||||||
|
dplayer.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPermissions() {
|
||||||
|
return buildPermissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnDungeonInit() {
|
||||||
|
return onDungeonInit;
|
||||||
|
}
|
||||||
|
}
|
87
src/io/github/dre2n/dungeonsxl/sign/FloorSign.java
Normal file
87
src/io/github/dre2n/dungeonsxl/sign/FloorSign.java
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class FloorSign extends DSign {
|
||||||
|
|
||||||
|
public static String name = "Floor";
|
||||||
|
public String buildPermissions = "dxl.sign.floor";
|
||||||
|
public boolean onDungeonInit = false;
|
||||||
|
|
||||||
|
private String floor;
|
||||||
|
|
||||||
|
public FloorSign(Sign sign, GameWorld gWorld) {
|
||||||
|
super(sign, gWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean check() {
|
||||||
|
String lines[] = getSign().getLines();
|
||||||
|
if ( !lines[1].equals("") && !lines[2].equals("")) {
|
||||||
|
if (lines[1] != null) {
|
||||||
|
String[] atributes = lines[2].split(",");
|
||||||
|
if (atributes.length == 2) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInit() {
|
||||||
|
if (getTriggers().isEmpty()) {
|
||||||
|
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGWorld());
|
||||||
|
if (trigger != null) {
|
||||||
|
trigger.addListener(this);
|
||||||
|
addTrigger(trigger);
|
||||||
|
}
|
||||||
|
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
|
||||||
|
getSign().setLine(1, ChatColor.DARK_GREEN + "ENTER");
|
||||||
|
if (floor != null) {
|
||||||
|
getSign().setLine(2, ChatColor.DARK_GREEN + "NEXT FLOOR");
|
||||||
|
}
|
||||||
|
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
|
||||||
|
getSign().update();
|
||||||
|
} else {
|
||||||
|
getSign().getBlock().setType(Material.AIR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPlayerTrigger(Player player) {
|
||||||
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
if (dplayer != null) {
|
||||||
|
if ( !dplayer.isFinished) {
|
||||||
|
dplayer.finishFloor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTrigger() {
|
||||||
|
for (DPlayer dplayer : DungeonsXL.getPlugin().getDPlayers()) {
|
||||||
|
dplayer.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPermissions() {
|
||||||
|
return buildPermissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnDungeonInit() {
|
||||||
|
return onDungeonInit;
|
||||||
|
}
|
||||||
|
}
|
@ -1,102 +1,103 @@
|
|||||||
package com.dre.dungeonsxl.signs;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.IntegerUtil;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
public class InteractSign extends DSign {
|
||||||
import com.dre.dungeonsxl.EditWorld;
|
|
||||||
import com.dre.dungeonsxl.trigger.InteractTrigger;
|
|
||||||
|
|
||||||
public class SIGNInteract extends DSign {
|
|
||||||
public static String name = "Interact";
|
public static String name = "Interact";
|
||||||
public String buildPermissions = "dxl.sign.trigger";
|
public String buildPermissions = "dxl.sign.trigger";
|
||||||
public boolean onDungeonInit = true;
|
public boolean onDungeonInit = true;
|
||||||
|
|
||||||
public SIGNInteract(Sign sign, GameWorld gworld) {
|
public InteractSign(Sign sign, GameWorld gWorld) {
|
||||||
super(sign, gworld);
|
super(sign, gWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
Set<Integer> used = new HashSet<Integer>();
|
Set<Integer> used = new HashSet<Integer>();
|
||||||
for (Block block : EditWorld.get(sign.getLocation().getWorld()).sign) {
|
for (Block block : EditWorld.get(getSign().getLocation().getWorld()).sign) {
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
if (!block.getChunk().isLoaded()) {
|
if ( !block.getChunk().isLoaded()) {
|
||||||
block.getChunk().load();
|
block.getChunk().load();
|
||||||
}
|
}
|
||||||
if (block.getState() instanceof Sign) {
|
if (block.getState() instanceof Sign) {
|
||||||
Sign rsign = (Sign) block.getState();
|
Sign rsign = (Sign) block.getState();
|
||||||
if (rsign.getLine(0).equalsIgnoreCase("[" + name + "]")) {
|
if (rsign.getLine(0).equalsIgnoreCase("[" + name + "]")) {
|
||||||
used.add(p.parseInt(rsign.getLine(1)));
|
used.add(IntegerUtil.parseInt(rsign.getLine(1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = 1;
|
int id = 1;
|
||||||
if (sign.getLine(1).equalsIgnoreCase("")) {
|
if (getSign().getLine(1).equalsIgnoreCase("")) {
|
||||||
if (used.size() != 0) {
|
if (used.size() != 0) {
|
||||||
while (used.contains(id)) {
|
while (used.contains(id)) {
|
||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
id = p.parseInt(sign.getLine(1));
|
id = IntegerUtil.parseInt(getSign().getLine(1));
|
||||||
if (id == 0 || used.contains(id)) {
|
if (id == 0 || used.contains(id)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sign.setLine(1, id + "");
|
getSign().setLine(1, id + "");
|
||||||
p.getServer().getScheduler().scheduleSyncDelayedTask(p, new UpdateTask(), 2);
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new UpdateTask(), 2);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
InteractTrigger trigger = InteractTrigger.getOrCreate(p.parseInt(sign.getLine(1)), sign.getBlock(), gworld);
|
InteractTrigger trigger = InteractTrigger.getOrCreate(IntegerUtil.parseInt(getSign().getLine(1)), getSign().getBlock(), getGWorld());
|
||||||
if (trigger != null) {
|
if (trigger != null) {
|
||||||
trigger.addListener(this);
|
trigger.addListener(this);
|
||||||
this.triggers.add(trigger);
|
addTrigger(trigger);
|
||||||
}
|
}
|
||||||
|
|
||||||
sign.setLine(0, ChatColor.DARK_BLUE + "############");
|
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
|
||||||
sign.setLine(1, ChatColor.GREEN + sign.getLine(2));
|
getSign().setLine(1, ChatColor.GREEN + getSign().getLine(2));
|
||||||
sign.setLine(2, ChatColor.GREEN + sign.getLine(3));
|
getSign().setLine(2, ChatColor.GREEN + getSign().getLine(3));
|
||||||
sign.setLine(3, ChatColor.DARK_BLUE + "############");
|
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
|
||||||
sign.update();
|
getSign().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPlayerTrigger(Player player) {
|
public boolean onPlayerTrigger(Player player) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public String getPermissions() {
|
||||||
return buildPermissions;
|
return buildPermissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOnDungeonInit() {
|
public boolean isOnDungeonInit() {
|
||||||
return onDungeonInit;
|
return onDungeonInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UpdateTask implements Runnable {
|
public class UpdateTask implements Runnable {
|
||||||
|
|
||||||
public UpdateTask() {
|
public UpdateTask() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
sign.update();
|
getSign().update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
73
src/io/github/dre2n/dungeonsxl/sign/LeaveSign.java
Normal file
73
src/io/github/dre2n/dungeonsxl/sign/LeaveSign.java
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class LeaveSign extends DSign {
|
||||||
|
|
||||||
|
public static String name = "Leave";
|
||||||
|
public String buildPermissions = "dxl.sign.leave";
|
||||||
|
public boolean onDungeonInit = true;
|
||||||
|
|
||||||
|
public LeaveSign(Sign sign, GameWorld gWorld) {
|
||||||
|
super(sign, gWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean check() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInit() {
|
||||||
|
if (getTriggers().isEmpty()) {
|
||||||
|
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGWorld());
|
||||||
|
if (trigger != null) {
|
||||||
|
trigger.addListener(this);
|
||||||
|
addTrigger(trigger);
|
||||||
|
}
|
||||||
|
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
|
||||||
|
getSign().setLine(1, ChatColor.DARK_GREEN + "Leave");
|
||||||
|
getSign().setLine(2, "");
|
||||||
|
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
|
||||||
|
getSign().update();
|
||||||
|
} else {
|
||||||
|
getSign().getBlock().setType(Material.AIR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPlayerTrigger(Player player) {
|
||||||
|
DPlayer dplayer = DPlayer.get(player);
|
||||||
|
if (dplayer != null) {
|
||||||
|
dplayer.leave();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTrigger() {
|
||||||
|
for (DPlayer dplayer : DungeonsXL.getPlugin().getDPlayers()) {
|
||||||
|
dplayer.leave();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPermissions() {
|
||||||
|
return buildPermissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnDungeonInit() {
|
||||||
|
return onDungeonInit;
|
||||||
|
}
|
||||||
|
}
|
@ -1,40 +1,40 @@
|
|||||||
package com.dre.dungeonsxl.signs;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
import org.bukkit.block.Sign;
|
||||||
|
|
||||||
public class SIGNLobby extends DSign {
|
public class LobbySign extends DSign {
|
||||||
|
|
||||||
public static String name = "Lobby";
|
public static String name = "Lobby";
|
||||||
public String buildPermissions = "dxl.sign.lobby";
|
public String buildPermissions = "dxl.sign.lobby";
|
||||||
public boolean onDungeonInit = true;
|
public boolean onDungeonInit = true;
|
||||||
|
|
||||||
public SIGNLobby(Sign sign, GameWorld gworld) {
|
public LobbySign(Sign sign, GameWorld gWorld) {
|
||||||
super(sign, gworld);
|
super(sign, gWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
gworld.locLobby = sign.getLocation();
|
getGWorld().locLobby = getSign().getLocation();
|
||||||
sign.getBlock().setType(Material.AIR);
|
getSign().getBlock().setType(Material.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissions() {
|
public String getPermissions() {
|
||||||
return buildPermissions;
|
return buildPermissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOnDungeonInit() {
|
public boolean isOnDungeonInit() {
|
||||||
return onDungeonInit;
|
return onDungeonInit;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,170 +1,172 @@
|
|||||||
package com.dre.dungeonsxl.signs;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
|
||||||
import org.bukkit.World;
|
import io.github.dre2n.dungeonsxl.mob.DMob;
|
||||||
import org.bukkit.block.Sign;
|
import io.github.dre2n.dungeonsxl.mob.DMobType;
|
||||||
import org.bukkit.entity.EntityType;
|
import io.github.dre2n.dungeonsxl.util.IntegerUtil;
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Skeleton;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.World;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import com.dre.dungeonsxl.DMobType;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import com.dre.dungeonsxl.game.DMob;
|
import org.bukkit.entity.Skeleton;
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
public class SIGNMob extends DSign {
|
|
||||||
|
public class MobSign extends DSign {
|
||||||
public static String name = "Mob";
|
|
||||||
public String buildPermissions = "dxl.sign.mob";
|
public static String name = "Mob";
|
||||||
public boolean onDungeonInit = false;
|
public String buildPermissions = "dxl.sign.mob";
|
||||||
|
public boolean onDungeonInit = false;
|
||||||
// Variables
|
|
||||||
private String mob;
|
// Variables
|
||||||
private int maxinterval = 1;
|
private String mob;
|
||||||
private int interval = 0;
|
private int maxinterval = 1;
|
||||||
private int amount = 1;
|
private int interval = 0;
|
||||||
private boolean initialized;
|
private int amount = 1;
|
||||||
private boolean active;
|
private boolean initialized;
|
||||||
private int taskId = -1;
|
private boolean active;
|
||||||
|
private int taskId = -1;
|
||||||
public SIGNMob(Sign sign, GameWorld gworld) {
|
|
||||||
super(sign, gworld);
|
public MobSign(Sign sign, GameWorld gWorld) {
|
||||||
}
|
super(sign, gWorld);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean check() {
|
@Override
|
||||||
String lines[] = sign.getLines();
|
public boolean check() {
|
||||||
if (!lines[1].equals("") && !lines[2].equals("")) {
|
String lines[] = getSign().getLines();
|
||||||
if (lines[1] != null) {
|
if ( !lines[1].equals("") && !lines[2].equals("")) {
|
||||||
String[] atributes = lines[2].split(",");
|
if (lines[1] != null) {
|
||||||
if (atributes.length == 2) {
|
String[] atributes = lines[2].split(",");
|
||||||
return true;
|
if (atributes.length == 2) {
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void onInit() {
|
@Override
|
||||||
String lines[] = sign.getLines();
|
public void onInit() {
|
||||||
if (!lines[1].equals("") && !lines[2].equals("")) {
|
String lines[] = getSign().getLines();
|
||||||
String mob = lines[1];
|
if ( !lines[1].equals("") && !lines[2].equals("")) {
|
||||||
if (mob != null) {
|
String mob = lines[1];
|
||||||
String[] atributes = lines[2].split(",");
|
if (mob != null) {
|
||||||
if (atributes.length == 2) {
|
String[] atributes = lines[2].split(",");
|
||||||
this.mob = mob;
|
if (atributes.length == 2) {
|
||||||
this.maxinterval = p.parseInt(atributes[0]);
|
this.mob = mob;
|
||||||
this.amount = p.parseInt(atributes[1]);
|
maxinterval = IntegerUtil.parseInt(atributes[0]);
|
||||||
}
|
amount = IntegerUtil.parseInt(atributes[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sign.getBlock().setType(Material.AIR);
|
}
|
||||||
|
getSign().getBlock().setType(Material.AIR);
|
||||||
initialized = true;
|
|
||||||
}
|
initialized = true;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void onTrigger() {
|
@Override
|
||||||
if (initialized && !active) {
|
public void onTrigger() {
|
||||||
MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
|
if (initialized && !active) {
|
||||||
|
MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
|
||||||
taskId = p.getServer().getScheduler().scheduleSyncRepeatingTask(p, scheduler, 0L, 20L);
|
|
||||||
|
taskId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, scheduler, 0L, 20L);
|
||||||
active = true;
|
|
||||||
}
|
active = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
@Override
|
||||||
if (initialized && active) {
|
public void onDisable() {
|
||||||
killTask();
|
if (initialized && active) {
|
||||||
interval = 0;
|
killTask();
|
||||||
active = false;
|
interval = 0;
|
||||||
}
|
active = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void killTask() {
|
|
||||||
if (initialized && active) {
|
public void killTask() {
|
||||||
if (taskId != -1) {
|
if (initialized && active) {
|
||||||
p.getServer().getScheduler().cancelTask(taskId);
|
if (taskId != -1) {
|
||||||
taskId = -1;
|
plugin.getServer().getScheduler().cancelTask(taskId);
|
||||||
}
|
taskId = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public class MobSpawnScheduler implements Runnable {
|
|
||||||
private SIGNMob sign;
|
public class MobSpawnScheduler implements Runnable {
|
||||||
|
private MobSign sign;
|
||||||
public MobSpawnScheduler(SIGNMob sign) {
|
|
||||||
this.sign = sign;
|
public MobSpawnScheduler(MobSign sign) {
|
||||||
}
|
this.sign = sign;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void run() {
|
@SuppressWarnings("deprecation")
|
||||||
if (sign.interval <= 0) {
|
@Override
|
||||||
World world = sign.sign.getWorld();
|
public void run() {
|
||||||
GameWorld gworld = GameWorld.get(world);
|
if (sign.interval <= 0) {
|
||||||
|
World world = sign.getSign().getWorld();
|
||||||
if (gworld != null) {
|
GameWorld gWorld = GameWorld.get(world);
|
||||||
Location spawnLoc = sign.sign.getLocation().add(0.5, 0, 0.5);
|
|
||||||
|
if (gWorld != null) {
|
||||||
// Check normal mobs
|
Location spawnLoc = sign.getSign().getLocation().add(0.5, 0, 0.5);
|
||||||
if (EntityType.fromName(sign.mob) != null) {
|
|
||||||
if (EntityType.fromName(sign.mob).isAlive()) {
|
// Check normal mobs
|
||||||
LivingEntity entity = (LivingEntity) world.spawnEntity(spawnLoc, EntityType.fromName(sign.mob));
|
if (EntityType.fromName(sign.mob) != null) {
|
||||||
|
if (EntityType.fromName(sign.mob).isAlive()) {
|
||||||
// Add Bow to normal Skeletons
|
LivingEntity entity = (LivingEntity) world.spawnEntity(spawnLoc, EntityType.fromName(sign.mob));
|
||||||
if (entity.getType() == EntityType.SKELETON) {
|
|
||||||
Skeleton skeleton = (Skeleton) entity;
|
// Add Bow to normal Skeletons
|
||||||
if (skeleton.getSkeletonType() == SkeletonType.NORMAL) {
|
if (entity.getType() == EntityType.SKELETON) {
|
||||||
skeleton.getEquipment().setItemInHand(new ItemStack(Material.BOW));
|
Skeleton skeleton = (Skeleton) entity;
|
||||||
}
|
if (skeleton.getSkeletonType() == SkeletonType.NORMAL) {
|
||||||
}
|
skeleton.getEquipment().setItemInHand(new ItemStack(Material.BOW));
|
||||||
|
}
|
||||||
// Disable Despawning
|
}
|
||||||
entity.setRemoveWhenFarAway(false);
|
|
||||||
|
// Disable Despawning
|
||||||
new DMob(entity, sign.gworld, null);
|
entity.setRemoveWhenFarAway(false);
|
||||||
}
|
|
||||||
}
|
new DMob(entity, sign.getGWorld(), null);
|
||||||
|
}
|
||||||
// Check custom mobs
|
}
|
||||||
DMobType mobType = DMobType.get(sign.mob, gworld.config.getMobTypes());
|
|
||||||
|
// Check custom mobs
|
||||||
if (mobType != null) {
|
DMobType mobType = DMobType.get(sign.mob, gWorld.getConfig().getMobTypes());
|
||||||
mobType.spawn(GameWorld.get(world), spawnLoc);
|
|
||||||
}
|
if (mobType != null) {
|
||||||
|
mobType.spawn(GameWorld.get(world), spawnLoc);
|
||||||
// Set the amount
|
}
|
||||||
if (amount != -1) {
|
|
||||||
if (amount > 1) {
|
// Set the amount
|
||||||
amount--;
|
if (amount != -1) {
|
||||||
} else {
|
if (amount > 1) {
|
||||||
killTask();
|
amount--;
|
||||||
sign.remove();
|
} else {
|
||||||
}
|
killTask();
|
||||||
}
|
sign.remove();
|
||||||
|
}
|
||||||
sign.interval = sign.maxinterval;
|
}
|
||||||
} else {
|
|
||||||
sign.killTask();
|
sign.interval = sign.maxinterval;
|
||||||
}
|
} else {
|
||||||
}
|
sign.killTask();
|
||||||
sign.interval--;
|
}
|
||||||
}
|
}
|
||||||
}
|
sign.interval--;
|
||||||
|
}
|
||||||
@Override
|
}
|
||||||
public String getPermissions() {
|
|
||||||
return buildPermissions;
|
@Override
|
||||||
}
|
public String getPermissions() {
|
||||||
|
return buildPermissions;
|
||||||
@Override
|
}
|
||||||
public boolean isOnDungeonInit() {
|
|
||||||
return onDungeonInit;
|
@Override
|
||||||
}
|
public boolean isOnDungeonInit() {
|
||||||
}
|
return onDungeonInit;
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user