mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
commit
4767d61198
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,4 +1,6 @@
|
||||
/nb-configuration.xml
|
||||
/target
|
||||
/dependency-reduced-pom.xml
|
||||
nb-configuration.xml
|
||||
dependency-reduced-pom.xml
|
||||
licenseheader.txt
|
||||
*dependency-reduced-pom.xml
|
||||
*nb-configuration.xml
|
||||
*/target
|
||||
|
@ -32,6 +32,7 @@ DungeonsXL also provides custom game mechanics to make these worlds interesting.
|
||||
* A powerful API: [Read more...](../../wiki/api-tutorial)
|
||||
* Different game types allow you to use your maps dynamically for different purposes. [Read more...](../../wiki/game-types)
|
||||
* Announcements sothat users can join the next match easily. [Read more...](../../wiki/announcements)
|
||||
* Great performance due to a custom, asynchronous world loading and creation method and several other performance tweaks
|
||||
* ...and many more!
|
||||
|
||||
|
||||
@ -49,7 +50,7 @@ If you want to learn how to use DungeonsXL step by step, please have a look at t
|
||||
DungeonsXL works with 1.7.8 and higher. However, support for 1.10.x / 1.9.x has a higher priority than support for 1.8.x and lower. Some cosmetic features require the Spigot API and will therefore not work with CraftBukkit.
|
||||
|
||||
Older versions of DungeonsXL support versions since Minecraft 1.3.x, but of course, they are completely unsupported.
|
||||
* [1.7.8-1.10](../../tree/master)
|
||||
* [1.7.8-1.10.2](../../tree/master)
|
||||
* [1.7.5](../../tree/50f772d14281bfe278dba2559d1758cc459c1a30)
|
||||
* [1.7.2](../../tree/eccf82b7335dfb0723e3cd37a57df1a968ea7842)
|
||||
* [1.6.4](../../tree/780145cf783ea76fe1bfee04cf89216bd4f92e1d)
|
||||
|
13
abstract/pom.xml
Normal file
13
abstract/pom.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>dungeonsxl-abstract</artifactId>
|
||||
<version>${parent.version}</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>dungeonsxl-abstract</name>
|
||||
<parent>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>dungeonsxl</artifactId>
|
||||
<version>0.14${buildNo}</version>
|
||||
</parent>
|
||||
</project>
|
@ -14,33 +14,16 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.world;
|
||||
package io.github.dre2n.dungeonsxl.util.worldloader;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class Worlds {
|
||||
abstract class InternalsProvider {
|
||||
|
||||
/*private Set<ResourceWorld> resourceWorlds;
|
||||
|
||||
public Worlds(File folder) {
|
||||
for (File file : folder.listFiles()) {
|
||||
resourceWorlds.add(new ResourceWorld());
|
||||
}
|
||||
}*/
|
||||
|
||||
@Deprecated
|
||||
public static boolean exists(String name) {
|
||||
for (File world : io.github.dre2n.dungeonsxl.DungeonsXL.MAPS.listFiles()) {
|
||||
if (world.isDirectory() && world.getName().equalsIgnoreCase(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
abstract World createWorld(WorldCreator creator);
|
||||
|
||||
}
|
65
core/pom.xml
Normal file
65
core/pom.xml
Normal file
@ -0,0 +1,65 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>dungeonsxl-core</artifactId>
|
||||
<version>${parent.version}</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>dungeonsxl-core</name>
|
||||
<parent>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>dungeonsxl</artifactId>
|
||||
<version>0.14${buildNo}</version>
|
||||
</parent>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>.</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>src/main/resources/</directory>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>dungeonsxl-abstract</artifactId>
|
||||
<version>${parent.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>dungeonsxl-craftbukkit_1_10_R1</artifactId>
|
||||
<version>${parent.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>dungeonsxl-craftbukkit_1_9_R2</artifactId>
|
||||
<version>${parent.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>dungeonsxl-craftbukkit_1_9_R1</artifactId>
|
||||
<version>${parent.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -17,13 +17,11 @@
|
||||
package io.github.dre2n.dungeonsxl;
|
||||
|
||||
import io.github.dre2n.caliburn.CaliburnAPI;
|
||||
import io.github.dre2n.commons.command.BRCommands;
|
||||
import io.github.dre2n.commons.compatibility.Internals;
|
||||
import io.github.dre2n.commons.compatibility.Version;
|
||||
import io.github.dre2n.commons.config.MessageConfig;
|
||||
import io.github.dre2n.commons.javaplugin.BRPlugin;
|
||||
import io.github.dre2n.commons.javaplugin.BRPluginSettings;
|
||||
import io.github.dre2n.commons.util.FileUtil;
|
||||
import io.github.dre2n.dungeonsxl.announcer.Announcers;
|
||||
import io.github.dre2n.dungeonsxl.command.*;
|
||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
@ -53,8 +51,7 @@ import io.github.dre2n.dungeonsxl.task.SecureModeTask;
|
||||
import io.github.dre2n.dungeonsxl.task.UpdateTask;
|
||||
import io.github.dre2n.dungeonsxl.task.WorldUnloadTask;
|
||||
import io.github.dre2n.dungeonsxl.trigger.TriggerTypes;
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DWorlds;
|
||||
import io.github.dre2n.itemsxl.ItemsXL;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
@ -70,6 +67,7 @@ public class DungeonsXL extends BRPlugin {
|
||||
private static DungeonsXL instance;
|
||||
|
||||
public static final String[] EXCLUDED_FILES = {"config.yml", "uid.dat", "DXLData.data"};
|
||||
public static File BACKUPS;
|
||||
public static File DUNGEONS;
|
||||
public static File LANGUAGES;
|
||||
public static File MAPS;
|
||||
@ -86,7 +84,7 @@ public class DungeonsXL extends BRPlugin {
|
||||
private MainConfig mainConfig;
|
||||
private MessageConfig messageConfig;
|
||||
|
||||
private BRCommands dCommands;
|
||||
private DCommands dCommands;
|
||||
private DSignTypes dSigns;
|
||||
private GameTypes gameTypes;
|
||||
private RequirementTypes requirementTypes;
|
||||
@ -100,6 +98,7 @@ public class DungeonsXL extends BRPlugin {
|
||||
private DClasses dClasses;
|
||||
private DMobTypes dMobTypes;
|
||||
private SignScripts signScripts;
|
||||
private DWorlds dWorlds;
|
||||
|
||||
private BukkitTask announcerTask;
|
||||
private BukkitTask worldUnloadTask;
|
||||
@ -108,8 +107,6 @@ public class DungeonsXL extends BRPlugin {
|
||||
private BukkitTask secureModeTask;
|
||||
|
||||
private CopyOnWriteArrayList<DLootInventory> dLootInventories = new CopyOnWriteArrayList<>();
|
||||
private CopyOnWriteArrayList<EditWorld> editWorlds = new CopyOnWriteArrayList<>();
|
||||
private CopyOnWriteArrayList<GameWorld> gameWorlds = new CopyOnWriteArrayList<>();
|
||||
private CopyOnWriteArrayList<Game> games = new CopyOnWriteArrayList<>();
|
||||
private CopyOnWriteArrayList<DGroup> dGroups = new CopyOnWriteArrayList<>();
|
||||
|
||||
@ -149,7 +146,6 @@ public class DungeonsXL extends BRPlugin {
|
||||
loadMainConfig(new File(getDataFolder(), "config.yml"));
|
||||
// Load Language 2
|
||||
loadMessageConfig(new File(LANGUAGES, mainConfig.getLanguage() + ".yml"));
|
||||
loadDCommands();
|
||||
DPermissions.register();
|
||||
loadGameTypes();
|
||||
loadRequirementTypes();
|
||||
@ -164,6 +160,8 @@ public class DungeonsXL extends BRPlugin {
|
||||
loadDClasses(CLASSES);
|
||||
loadDMobTypes(MOBS);
|
||||
loadSignScripts(SIGNS);
|
||||
loadDWorlds(MAPS);
|
||||
loadDCommands();
|
||||
|
||||
manager.registerEvents(new EntityListener(), this);
|
||||
manager.registerEvents(new GUIListener(), this);
|
||||
@ -190,6 +188,7 @@ public class DungeonsXL extends BRPlugin {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
mainConfig.setTweaksEnabled(false);
|
||||
// Save
|
||||
saveData();
|
||||
messageConfig.save();
|
||||
@ -203,17 +202,17 @@ public class DungeonsXL extends BRPlugin {
|
||||
dLootInventories.clear();
|
||||
dGroups.clear();
|
||||
|
||||
// Delete Worlds
|
||||
GameWorld.deleteAll();
|
||||
gameWorlds.clear();
|
||||
EditWorld.deleteAll();
|
||||
editWorlds.clear();
|
||||
// Delete DWorlds
|
||||
dWorlds.deleteAllInstances();
|
||||
|
||||
// Disable listeners
|
||||
HandlerList.unregisterAll(this);
|
||||
|
||||
// Stop shedulers
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
|
||||
// DebukkIt
|
||||
debug.save();
|
||||
}
|
||||
|
||||
// Init.
|
||||
@ -222,6 +221,11 @@ public class DungeonsXL extends BRPlugin {
|
||||
getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
BACKUPS = new File(getDataFolder(), "backups");
|
||||
if (!BACKUPS.exists()) {
|
||||
BACKUPS.mkdir();
|
||||
}
|
||||
|
||||
DUNGEONS = new File(getDataFolder(), "dungeons");
|
||||
if (!DUNGEONS.exists()) {
|
||||
DUNGEONS.mkdir();
|
||||
@ -272,37 +276,14 @@ public class DungeonsXL extends BRPlugin {
|
||||
public void saveData() {
|
||||
protections.saveAll();
|
||||
DSavePlayer.save();
|
||||
for (EditWorld editWorld : editWorlds) {
|
||||
editWorld.save();
|
||||
}
|
||||
dWorlds.saveAll();
|
||||
}
|
||||
|
||||
public void loadAll() {
|
||||
protections.loadAll();
|
||||
dPlayers.loadAll();
|
||||
DSavePlayer.load();
|
||||
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(getDataFolder(), "/maps/" + dungeonName), EXCLUDED_FILES);
|
||||
FileUtil.deleteUnusedFiles(new File(getDataFolder(), "/maps/" + dungeonName));
|
||||
}
|
||||
}
|
||||
|
||||
FileUtil.removeDirectory(file);
|
||||
|
||||
} else if (file.getName().contains("DXL_Game_") && file.isDirectory()) {
|
||||
FileUtil.removeDirectory(file);
|
||||
}
|
||||
}
|
||||
dWorlds.check();
|
||||
}
|
||||
|
||||
/* Getters and loaders */
|
||||
@ -375,10 +356,10 @@ public class DungeonsXL extends BRPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loaded instance of BRCommands
|
||||
* @return the loaded instance of DCommands
|
||||
*/
|
||||
@Override
|
||||
public BRCommands getCommands() {
|
||||
public DCommands getCommands() {
|
||||
return dCommands;
|
||||
}
|
||||
|
||||
@ -386,36 +367,7 @@ public class DungeonsXL extends BRPlugin {
|
||||
* load / reload a new instance of DCommands
|
||||
*/
|
||||
public void loadDCommands() {
|
||||
dCommands = new BRCommands(
|
||||
"dungeonsxl",
|
||||
this,
|
||||
new HelpCommand(),
|
||||
new BreakCommand(),
|
||||
new ChatCommand(),
|
||||
new ChatSpyCommand(),
|
||||
new CreateCommand(),
|
||||
new EditCommand(),
|
||||
new EscapeCommand(),
|
||||
new GameCommand(),
|
||||
new GroupCommand(),
|
||||
new InviteCommand(),
|
||||
new JoinCommand(),
|
||||
new EnterCommand(),
|
||||
new LeaveCommand(),
|
||||
new ListCommand(),
|
||||
new LivesCommand(),
|
||||
new MainCommand(),
|
||||
new UninviteCommand(),
|
||||
new MsgCommand(),
|
||||
new PlayCommand(),
|
||||
new PortalCommand(),
|
||||
new DeletePortalCommand(),
|
||||
new ReloadCommand(),
|
||||
new SaveCommand(),
|
||||
new StatusCommand(),
|
||||
new TestCommand()
|
||||
);
|
||||
|
||||
dCommands = new DCommands(this);
|
||||
dCommands.register(this);
|
||||
}
|
||||
|
||||
@ -602,19 +554,17 @@ public class DungeonsXL extends BRPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the worldUnloadTask
|
||||
* @return the loaded instance of DWorlds
|
||||
*/
|
||||
public BukkitTask getWorldUnloadTask() {
|
||||
return worldUnloadTask;
|
||||
public DWorlds getDWorlds() {
|
||||
return dWorlds;
|
||||
}
|
||||
|
||||
/**
|
||||
* start a new AnnouncerTask
|
||||
* load / reload a new instance of DWorlds
|
||||
*/
|
||||
public void startAnnouncerTask(long period) {
|
||||
if (!announcers.getAnnouncers().isEmpty()) {
|
||||
announcerTask = new AnnouncerTask(announcers).runTaskTimer(this, 0L, period);
|
||||
}
|
||||
public void loadDWorlds(File folder) {
|
||||
dWorlds = new DWorlds(MAPS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -624,11 +574,27 @@ public class DungeonsXL extends BRPlugin {
|
||||
return announcerTask;
|
||||
}
|
||||
|
||||
/**
|
||||
* start a new AnnouncerTask
|
||||
*/
|
||||
public void startAnnouncerTask(long period) {
|
||||
if (!announcers.getAnnouncers().isEmpty()) {
|
||||
announcerTask = new AnnouncerTask(announcers).runTaskTimer(this, period, period);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the worldUnloadTask
|
||||
*/
|
||||
public BukkitTask getWorldUnloadTask() {
|
||||
return worldUnloadTask;
|
||||
}
|
||||
|
||||
/**
|
||||
* start a new WorldUnloadTask
|
||||
*/
|
||||
public void startWorldUnloadTask(long period) {
|
||||
worldUnloadTask = new WorldUnloadTask().runTaskTimer(this, 0L, period);
|
||||
worldUnloadTask = new WorldUnloadTask().runTaskTimer(this, period, period);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -642,7 +608,7 @@ public class DungeonsXL extends BRPlugin {
|
||||
* start a new LazyUpdateTask
|
||||
*/
|
||||
public void startLazyUpdateTask(long period) {
|
||||
lazyUpdateTask = new LazyUpdateTask().runTaskTimer(this, 0L, period);
|
||||
lazyUpdateTask = new LazyUpdateTask().runTaskTimer(this, period, period);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -656,7 +622,7 @@ public class DungeonsXL extends BRPlugin {
|
||||
* start a new LazyUpdateTask
|
||||
*/
|
||||
public void startUpdateTask(long period) {
|
||||
updateTask = new UpdateTask().runTaskTimer(this, 0L, period);
|
||||
updateTask = new UpdateTask().runTaskTimer(this, period, period);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -670,7 +636,7 @@ public class DungeonsXL extends BRPlugin {
|
||||
* start a new SecureModeTask
|
||||
*/
|
||||
public void startSecureModeTask(long period) {
|
||||
updateTask = new SecureModeTask().runTaskTimer(this, 0L, period);
|
||||
updateTask = new SecureModeTask().runTaskTimer(this, period, period);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -680,20 +646,6 @@ public class DungeonsXL extends BRPlugin {
|
||||
return dLootInventories;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the editWorlds
|
||||
*/
|
||||
public List<EditWorld> getEditWorlds() {
|
||||
return editWorlds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the gameWorlds
|
||||
*/
|
||||
public List<GameWorld> getGameWorlds() {
|
||||
return gameWorlds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the games
|
||||
*/
|
||||
@ -708,4 +660,7 @@ public class DungeonsXL extends BRPlugin {
|
||||
return dGroups;
|
||||
}
|
||||
|
||||
// DebukkIt
|
||||
public final io.github.dre2n.debukkit.DebukkIt debug = new io.github.dre2n.debukkit.DebukkIt(this);
|
||||
|
||||
}
|
@ -96,7 +96,7 @@ public class Announcer {
|
||||
|
||||
Dungeon dungeon = plugin.getDungeons().getByName(identifier);
|
||||
if (dungeon != null) {
|
||||
mapName = dungeon.getConfig().getStartFloor();
|
||||
mapName = dungeon.getConfig().getStartFloor().getName();
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -137,7 +137,7 @@ public class Announcer {
|
||||
|
||||
Dungeon dungeon = plugin.getDungeons().getByName(identifier);
|
||||
if (dungeon != null) {
|
||||
mapName = dungeon.getConfig().getStartFloor();
|
||||
mapName = dungeon.getConfig().getStartFloor().getName();
|
||||
}
|
||||
|
||||
} else {
|
@ -23,7 +23,8 @@ import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import io.github.dre2n.dungeonsxl.player.DEditPlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||
import java.io.File;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
@ -50,7 +51,7 @@ public class CreateCommand extends BRCommand {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
String name = args[1];
|
||||
|
||||
if (new File(plugin.getDataFolder(), "/maps/" + name).exists()) {
|
||||
if (new File(DungeonsXL.MAPS, name).exists()) {
|
||||
MessageUtil.sendMessage(sender, DMessages.ERROR_NAME_IN_USE.getMessage(name));
|
||||
return;
|
||||
}
|
||||
@ -62,13 +63,13 @@ public class CreateCommand extends BRCommand {
|
||||
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
// Msg create
|
||||
MessageUtil.log(plugin, DMessages.LOG_NEW_DUNGEON.getMessage());
|
||||
MessageUtil.log(plugin, DMessages.LOG_NEW_MAP.getMessage());
|
||||
MessageUtil.log(plugin, DMessages.LOG_GENERATE_NEW_WORLD.getMessage());
|
||||
|
||||
// Create World
|
||||
EditWorld editWorld = new EditWorld();
|
||||
editWorld.generate();
|
||||
editWorld.setMapName(name);
|
||||
DResourceWorld resource = new DResourceWorld(plugin.getDWorlds(), name);
|
||||
plugin.getDWorlds().addResource(resource);
|
||||
DEditWorld editWorld = resource.generate();
|
||||
editWorld.save();
|
||||
editWorld.delete();
|
||||
|
||||
@ -84,19 +85,19 @@ public class CreateCommand extends BRCommand {
|
||||
}
|
||||
|
||||
// Msg create
|
||||
MessageUtil.log(plugin, DMessages.LOG_NEW_DUNGEON.getMessage());
|
||||
MessageUtil.log(plugin, DMessages.LOG_NEW_MAP.getMessage());
|
||||
MessageUtil.log(plugin, DMessages.LOG_GENERATE_NEW_WORLD.getMessage());
|
||||
|
||||
// Create World
|
||||
EditWorld editWorld = new EditWorld();
|
||||
editWorld.generate();
|
||||
editWorld.setMapName(name);
|
||||
DResourceWorld resource = new DResourceWorld(plugin.getDWorlds(), name);
|
||||
plugin.getDWorlds().addResource(resource);
|
||||
DEditWorld editWorld = resource.generate();
|
||||
|
||||
// MSG Done
|
||||
MessageUtil.log(plugin, DMessages.LOG_WORLD_GENERATION_FINISHED.getMessage());
|
||||
|
||||
// Tp Player
|
||||
new DEditPlayer(player, editWorld.getWorld());
|
||||
DEditPlayer.create(player, editWorld);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2016 Frank Baumann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.command;
|
||||
|
||||
import io.github.dre2n.commons.command.BRCommands;
|
||||
import io.github.dre2n.commons.javaplugin.BRPlugin;
|
||||
|
||||
/**
|
||||
* An enumeration of all command instances.
|
||||
*
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class DCommands extends BRCommands {
|
||||
|
||||
public static BreakCommand BREAK = new BreakCommand();
|
||||
public static ChatCommand CHAT = new ChatCommand();
|
||||
public static ChatSpyCommand CHAT_SPY = new ChatSpyCommand();
|
||||
public static CreateCommand CREATE = new CreateCommand();
|
||||
public static EditCommand EDIT = new EditCommand();
|
||||
public static EnterCommand ENTER = new EnterCommand();
|
||||
public static EscapeCommand ESCAPE = new EscapeCommand();
|
||||
public static GameCommand GAME = new GameCommand();
|
||||
public static GroupCommand GROUP = new GroupCommand();
|
||||
public static HelpCommand HELP = new HelpCommand();
|
||||
public static ImportCommand IMPORT = new ImportCommand();
|
||||
public static InviteCommand INVITE = new InviteCommand();
|
||||
public static JoinCommand JOIN = new JoinCommand();
|
||||
public static KickCommand KICK = new KickCommand();
|
||||
public static LeaveCommand LEAVE = new LeaveCommand();
|
||||
public static ListCommand LIST = new ListCommand();
|
||||
public static LivesCommand LIVES = new LivesCommand();
|
||||
public static MainCommand MAIN = new MainCommand();
|
||||
public static MsgCommand MESSAGE = new MsgCommand();
|
||||
public static PlayCommand PLAY = new PlayCommand();
|
||||
public static PortalCommand PORTAL = new PortalCommand();
|
||||
public static ReloadCommand RELOAD = new ReloadCommand();
|
||||
public static SaveCommand SAVE = new SaveCommand();
|
||||
public static StatusCommand STATUS = new StatusCommand();
|
||||
public static TestCommand TEST = new TestCommand();
|
||||
public static UninviteCommand UNINVITE = new UninviteCommand();
|
||||
|
||||
public DCommands(BRPlugin plugin) {
|
||||
super("dungeonsxl", plugin,
|
||||
BREAK,
|
||||
CHAT,
|
||||
CHAT_SPY,
|
||||
CREATE,
|
||||
EDIT,
|
||||
ENTER,
|
||||
ESCAPE,
|
||||
GAME,
|
||||
GROUP,
|
||||
HELP,
|
||||
IMPORT,
|
||||
INVITE,
|
||||
JOIN,
|
||||
KICK,
|
||||
LEAVE,
|
||||
LIST,
|
||||
LIVES,
|
||||
MAIN,
|
||||
MESSAGE,
|
||||
PLAY,
|
||||
PORTAL,
|
||||
RELOAD,
|
||||
SAVE,
|
||||
STATUS,
|
||||
TEST,
|
||||
UNINVITE,
|
||||
new DeletePortalCommand()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -21,10 +21,13 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import io.github.dre2n.dungeonsxl.player.DEditPlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DWorlds;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -34,6 +37,7 @@ import org.bukkit.entity.Player;
|
||||
public class EditCommand extends BRCommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
DWorlds worlds = plugin.getDWorlds();
|
||||
|
||||
public EditCommand() {
|
||||
setCommand("edit");
|
||||
@ -46,18 +50,24 @@ public class EditCommand extends BRCommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
String mapName = args[1];
|
||||
EditWorld editWorld = EditWorld.load(mapName);
|
||||
DGroup dGroup = DGroup.getByPlayer(player);
|
||||
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
|
||||
|
||||
if (!(EditWorld.isInvitedPlayer(mapName, player.getUniqueId(), player.getName()) || DPermissions.hasPermission(player, DPermissions.EDIT))) {
|
||||
if (!worlds.exists(mapName)) {
|
||||
MessageUtil.sendMessage(player, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(mapName));
|
||||
return;
|
||||
}
|
||||
|
||||
DResourceWorld resource = worlds.getResourceByName(mapName);
|
||||
DEditWorld editWorld = resource.instantiateAsEditWorld();
|
||||
DGroup dGroup = DGroup.getByPlayer(player);
|
||||
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||
|
||||
if (!(resource.isInvitedPlayer(player) || DPermissions.hasPermission(player, DPermissions.EDIT))) {
|
||||
MessageUtil.sendMessage(player, DMessages.ERROR_NO_PERMISSIONS.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (dPlayer != null) {
|
||||
if (dPlayer instanceof DInstancePlayer) {
|
||||
MessageUtil.sendMessage(player, DMessages.ERROR_LEAVE_DUNGEON.getMessage());
|
||||
return;
|
||||
}
|
||||
@ -67,13 +77,7 @@ public class EditCommand extends BRCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (editWorld == null) {
|
||||
MessageUtil.sendMessage(player, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(mapName));
|
||||
return;
|
||||
}
|
||||
|
||||
new DEditPlayer(player, editWorld.getWorld());
|
||||
|
||||
DEditPlayer.create(player, editWorld);
|
||||
}
|
||||
|
||||
}
|
@ -68,7 +68,7 @@ public class EnterCommand extends BRCommand {
|
||||
}
|
||||
|
||||
if (joining == null) {
|
||||
joining = new DGroup(captain, game.getWorld().getMapName(), game.getDungeon() != null);
|
||||
joining = new DGroup(captain, game.getWorld().getName(), game.getDungeon() != null);
|
||||
}
|
||||
|
||||
if (joining.getCaptain() != captain && !DPermissions.hasPermission(sender, DPermissions.BYPASS)) {
|
||||
@ -81,7 +81,7 @@ public class EnterCommand extends BRCommand {
|
||||
joining.sendMessage(DMessages.CMD_ENTER_SUCCESS.getMessage(joining.getName(), targetName));
|
||||
|
||||
for (Player player : joining.getPlayers()) {
|
||||
new DGamePlayer(player, game.getWorld()).ready();
|
||||
DGamePlayer.create(player, game.getWorld(), true);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import io.github.dre2n.dungeonsxl.player.DEditPlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -52,13 +52,13 @@ public class EscapeCommand extends BRCommand {
|
||||
} else if (dPlayer != null) {
|
||||
dPlayer.escape();
|
||||
|
||||
EditWorld editWorld = EditWorld.getByWorld(dPlayer.getWorld());
|
||||
DEditWorld editWorld = DEditWorld.getByWorld(dPlayer.getWorld());
|
||||
if (editWorld == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (editWorld.getWorld().getPlayers().isEmpty()) {
|
||||
editWorld.deleteNoSave();
|
||||
editWorld.delete(false);
|
||||
}
|
||||
|
||||
} else {
|
@ -23,7 +23,7 @@ import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import io.github.dre2n.dungeonsxl.game.Game;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -52,7 +52,7 @@ public class GameCommand extends BRCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
GameWorld gameWorld = dGroup.getGameWorld();
|
||||
DGameWorld gameWorld = dGroup.getGameWorld();
|
||||
if (gameWorld == null) {
|
||||
MessageUtil.sendMessage(sender, DMessages.ERROR_NO_GAME.getMessage());
|
||||
return;
|
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2016 Frank Baumann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.command;
|
||||
|
||||
import io.github.dre2n.commons.command.BRCommand;
|
||||
import io.github.dre2n.commons.util.FileUtil;
|
||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||
import java.io.File;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class ImportCommand extends BRCommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
public ImportCommand() {
|
||||
setMinArgs(1);
|
||||
setMaxArgs(1);
|
||||
setCommand("import");
|
||||
setHelp(DMessages.HELP_CMD_IMPORT.getMessage());
|
||||
setPermission(DPermissions.IMPORT.getNode());
|
||||
setPlayerCommand(true);
|
||||
setConsoleCommand(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
final File target = new File(DungeonsXL.MAPS, args[1]);
|
||||
final File source = new File(Bukkit.getWorldContainer(), args[1]);
|
||||
|
||||
if (!source.exists()) {
|
||||
MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_MAP.getMessage(args[1]));
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.exists()) {
|
||||
MessageUtil.sendMessage(sender, DMessages.ERROR_NAME_IN_USE.getMessage(args[1]));
|
||||
return;
|
||||
}
|
||||
|
||||
World world = Bukkit.getWorld(args[1]);
|
||||
if (world != null) {
|
||||
world.save();
|
||||
}
|
||||
|
||||
MessageUtil.log(plugin, DMessages.LOG_NEW_MAP.getMessage());
|
||||
MessageUtil.log(plugin, DMessages.LOG_IMPORT_WORLD.getMessage());
|
||||
|
||||
if (!plugin.getMainConfig().areTweaksEnabled()) {
|
||||
FileUtil.copyDirectory(source, target, new String[]{"playerdata", "stats"});
|
||||
|
||||
} else {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FileUtil.copyDirectory(source, target, new String[]{"playerdata", "stats"});
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
}
|
||||
|
||||
plugin.getDWorlds().addResource(new DResourceWorld(plugin.getDWorlds(), args[1]));
|
||||
MessageUtil.sendMessage(sender, DMessages.CMD_IMPORT_SUCCESS.getMessage(args[1]));
|
||||
}
|
||||
|
||||
}
|
@ -17,12 +17,13 @@
|
||||
package io.github.dre2n.dungeonsxl.command;
|
||||
|
||||
import io.github.dre2n.commons.command.BRCommand;
|
||||
import io.github.dre2n.commons.util.UUIDUtil;
|
||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
@ -44,9 +45,17 @@ public class InviteCommand extends BRCommand {
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
if (EditWorld.addInvitedPlayer(args[2], UUIDUtil.getUniqueIdFromName(args[1]))) {
|
||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[2]);
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[2]);
|
||||
|
||||
if (resource != null) {
|
||||
if (player != null) {
|
||||
MessageUtil.sendMessage(sender, DMessages.CMD_INVITE_SUCCESS.getMessage(args[1], args[2]));
|
||||
|
||||
} else {
|
||||
MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_PLAYER.getMessage(args[2]));
|
||||
}
|
||||
|
||||
} else {
|
||||
MessageUtil.sendMessage(sender, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(args[2]));
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2016 Frank Baumann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.command;
|
||||
|
||||
import io.github.dre2n.commons.command.BRCommand;
|
||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import static io.github.dre2n.dungeonsxl.command.DCommands.LEAVE;
|
||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class KickCommand extends BRCommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
public KickCommand() {
|
||||
setCommand("kick");
|
||||
setMinArgs(1);
|
||||
setMaxArgs(1);
|
||||
setHelp(DMessages.HELP_CMD_KICK.getMessage());
|
||||
setPermission(DPermissions.LEAVE.getNode());
|
||||
setPlayerCommand(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = Bukkit.getPlayer(args[1]);
|
||||
|
||||
if (player != null) {
|
||||
LEAVE.onExecute(new String[]{LEAVE.getCommand()}, player);
|
||||
MessageUtil.sendMessage(sender, DMessages.CMD_KICK_SUCCESS.getMessage(player.getName()));
|
||||
|
||||
} else {
|
||||
MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_PLAYER.getMessage(args[1]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -27,7 +27,7 @@ import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -53,8 +53,8 @@ public class LeaveCommand extends BRCommand {
|
||||
|
||||
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||
|
||||
if (GameWorld.getByWorld(player.getWorld()) != null) {
|
||||
if (GameWorld.getByWorld(player.getWorld()).isTutorial()) {
|
||||
if (DGameWorld.getByWorld(player.getWorld()) != null) {
|
||||
if (DGameWorld.getByWorld(player.getWorld()).isTutorial()) {
|
||||
MessageUtil.sendMessage(player, DMessages.ERROR_NO_LEAVE_IN_TUTORIAL.getMessage());
|
||||
return;
|
||||
}
|
@ -24,8 +24,9 @@ import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
|
||||
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DWorlds;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -37,6 +38,7 @@ import org.bukkit.entity.Player;
|
||||
public class ListCommand extends BRCommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
DWorlds worlds = plugin.getDWorlds();
|
||||
|
||||
public ListCommand() {
|
||||
setCommand("list");
|
||||
@ -50,21 +52,21 @@ public class ListCommand extends BRCommand {
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
File dungeonFolder = new File(plugin.getDataFolder() + "/dungeons");
|
||||
File mapFolder = new File(plugin.getDataFolder() + "/maps");
|
||||
ArrayList<String> dungeonList = new ArrayList<>();
|
||||
for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
|
||||
dungeonList.add(dungeon.getName());
|
||||
}
|
||||
ArrayList<String> mapList = new ArrayList<>();
|
||||
for (File file : mapFolder.listFiles()) {
|
||||
for (File file : DungeonsXL.MAPS.listFiles()) {
|
||||
if (!file.equals(DWorlds.RAW)) {
|
||||
mapList.add(file.getName());
|
||||
}
|
||||
}
|
||||
ArrayList<String> loadedList = new ArrayList<>();
|
||||
for (EditWorld editWorld : plugin.getEditWorlds()) {
|
||||
for (DEditWorld editWorld : worlds.getEditWorlds()) {
|
||||
loadedList.add(editWorld.getWorld().getWorldFolder().getName());
|
||||
}
|
||||
for (GameWorld gameWorld : plugin.getGameWorlds()) {
|
||||
for (DGameWorld gameWorld : worlds.getGameWorlds()) {
|
||||
loadedList.add(gameWorld.getWorld().getWorldFolder().getName());
|
||||
}
|
||||
ArrayList<String> toSend = new ArrayList<>();
|
||||
@ -130,7 +132,7 @@ public class ListCommand extends BRCommand {
|
||||
for (String map : toSend) {
|
||||
boolean invited = false;
|
||||
if (sender instanceof Player) {
|
||||
invited = EditWorld.isInvitedPlayer(map, ((Player) sender).getUniqueId(), sender.getName());
|
||||
invited = worlds.getResourceByName(map).isInvitedPlayer((Player) sender);
|
||||
}
|
||||
|
||||
MessageUtil.sendMessage(sender, "&b" + map + "&7 | &e" + invited);
|
||||
@ -139,7 +141,7 @@ public class ListCommand extends BRCommand {
|
||||
case 1:
|
||||
MessageUtil.sendMessage(sender, "&4Dungeon&7 | &eMap count");
|
||||
for (String dungeon : toSend) {
|
||||
DungeonConfig dungeonConfig = new DungeonConfig(new File(dungeonFolder, dungeon + ".yml"));
|
||||
DungeonConfig dungeonConfig = new DungeonConfig(new File(DungeonsXL.DUNGEONS, dungeon + ".yml"));
|
||||
int count = dungeonConfig.getFloors().size() + 2;
|
||||
MessageUtil.sendMessage(sender, "&b" + dungeon + "&7 | &e" + count);
|
||||
}
|
@ -24,7 +24,6 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import java.io.File;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
@ -48,9 +47,9 @@ public class MainCommand extends BRCommand {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
PluginManager plugins = Bukkit.getServer().getPluginManager();
|
||||
|
||||
int maps = new File(plugin.getDataFolder() + "/maps").listFiles().length;
|
||||
int dungeons = new File(plugin.getDataFolder() + "/dungeons").listFiles().length;
|
||||
int loaded = plugin.getEditWorlds().size() + plugin.getGameWorlds().size();
|
||||
int maps = DungeonsXL.MAPS.listFiles().length;
|
||||
int dungeons = DungeonsXL.DUNGEONS.listFiles().length;
|
||||
int loaded = plugin.getDWorlds().getEditWorlds().size() + plugin.getDWorlds().getGameWorlds().size();
|
||||
int players = plugin.getDPlayers().getDGamePlayers().size();
|
||||
Internals internals = CompatibilityHandler.getInstance().getInternals();
|
||||
String vault = "";
|
@ -17,14 +17,12 @@
|
||||
package io.github.dre2n.dungeonsxl.command;
|
||||
|
||||
import io.github.dre2n.commons.command.BRCommand;
|
||||
import io.github.dre2n.commons.util.NumberUtil;
|
||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import java.io.File;
|
||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -48,7 +46,7 @@ public class MsgCommand extends BRCommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
EditWorld editWorld = EditWorld.getByWorld(player.getWorld());
|
||||
DEditWorld editWorld = DEditWorld.getByWorld(player.getWorld());
|
||||
|
||||
if (editWorld == null) {
|
||||
MessageUtil.sendMessage(player, DMessages.ERROR_NOT_IN_DUNGEON.getMessage());
|
||||
@ -61,12 +59,12 @@ public class MsgCommand extends BRCommand {
|
||||
}
|
||||
|
||||
try {
|
||||
int id = NumberUtil.parseInt(args[1]);
|
||||
int id = Integer.parseInt(args[1]);
|
||||
|
||||
WorldConfig confreader = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + editWorld.getMapName(), "config.yml"));
|
||||
WorldConfig config = editWorld.getResource().getConfig();
|
||||
|
||||
if (args.length == 2) {
|
||||
String msg = confreader.getMsg(id, true);
|
||||
String msg = config.getMessage(id);
|
||||
|
||||
if (msg != null) {
|
||||
MessageUtil.sendMessage(player, ChatColor.WHITE + msg);
|
||||
@ -89,7 +87,7 @@ public class MsgCommand extends BRCommand {
|
||||
|
||||
if (splitMsg.length > 1) {
|
||||
msg = splitMsg[1];
|
||||
String old = confreader.getMsg(id, false);
|
||||
String old = config.getMessage(id);
|
||||
if (old == null) {
|
||||
MessageUtil.sendMessage(player, DMessages.CMD_MSG_ADDED.getMessage(String.valueOf(id)));
|
||||
|
||||
@ -97,8 +95,8 @@ public class MsgCommand extends BRCommand {
|
||||
MessageUtil.sendMessage(player, DMessages.CMD_MSG_UPDATED.getMessage(String.valueOf(id)));
|
||||
}
|
||||
|
||||
confreader.setMsg(msg, id);
|
||||
confreader.save();
|
||||
config.setMessage(id, msg);
|
||||
config.save();
|
||||
|
||||
} else {
|
||||
MessageUtil.sendMessage(player, DMessages.ERROR_MSG_FORMAT.getMessage());
|
@ -27,7 +27,6 @@ import io.github.dre2n.dungeonsxl.game.Game;
|
||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -73,7 +72,7 @@ public class PlayCommand extends BRCommand {
|
||||
Dungeon dungeon = plugin.getDungeons().getByName(args[2]);
|
||||
if (dungeon != null) {
|
||||
multiFloor = true;
|
||||
mapName = dungeon.getConfig().getStartFloor();
|
||||
mapName = dungeon.getConfig().getStartFloor().getName();
|
||||
} else {
|
||||
displayHelp(player);
|
||||
return;
|
||||
@ -84,7 +83,7 @@ public class PlayCommand extends BRCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (!multiFloor && !EditWorld.exists(identifier)) {
|
||||
if (!multiFloor && !plugin.getDWorlds().exists(identifier)) {
|
||||
MessageUtil.sendMessage(player, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(identifier));
|
||||
return;
|
||||
}
|
||||
@ -108,7 +107,7 @@ public class PlayCommand extends BRCommand {
|
||||
DungeonConfig config = dungeon.getConfig();
|
||||
|
||||
if (config != null) {
|
||||
dGroup.setMapName(config.getStartFloor());
|
||||
dGroup.setMapName(config.getStartFloor().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -146,12 +145,12 @@ public class PlayCommand extends BRCommand {
|
||||
|
||||
if (dGroup.getGameWorld().getLobbyLocation() == null) {
|
||||
for (Player groupPlayer : dGroup.getPlayers()) {
|
||||
new DGamePlayer(groupPlayer, dGroup.getGameWorld());
|
||||
DGamePlayer.create(groupPlayer, dGroup.getGameWorld());
|
||||
}
|
||||
|
||||
} else {
|
||||
for (Player groupPlayer : dGroup.getPlayers()) {
|
||||
new DGamePlayer(groupPlayer, dGroup.getGameWorld());
|
||||
DGamePlayer.create(groupPlayer, dGroup.getGameWorld());
|
||||
}
|
||||
}
|
||||
}
|
@ -49,9 +49,9 @@ public class ReloadCommand extends BRCommand {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
PluginManager plugins = Bukkit.getServer().getPluginManager();
|
||||
|
||||
int maps = new File(plugin.getDataFolder() + "/maps").listFiles().length;
|
||||
int dungeons = new File(plugin.getDataFolder() + "/dungeons").listFiles().length;
|
||||
int loaded = plugin.getEditWorlds().size() + plugin.getGameWorlds().size();
|
||||
int maps = DungeonsXL.MAPS.listFiles().length;
|
||||
int dungeons = DungeonsXL.DUNGEONS.listFiles().length;
|
||||
int loaded = plugin.getDWorlds().getEditWorlds().size() + plugin.getDWorlds().getGameWorlds().size();
|
||||
int players = plugin.getDPlayers().getDGamePlayers().size();
|
||||
Internals internals = CompatibilityHandler.getInstance().getInternals();
|
||||
String vault = "";
|
@ -20,8 +20,10 @@ import io.github.dre2n.commons.command.BRCommand;
|
||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import io.github.dre2n.dungeonsxl.config.MainConfig;
|
||||
import io.github.dre2n.dungeonsxl.config.MainConfig.BackupMode;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -31,6 +33,7 @@ import org.bukkit.entity.Player;
|
||||
public class SaveCommand extends BRCommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
MainConfig mainConfig = plugin.getMainConfig();
|
||||
|
||||
public SaveCommand() {
|
||||
setCommand("save");
|
||||
@ -44,8 +47,13 @@ public class SaveCommand extends BRCommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
EditWorld editWorld = EditWorld.getByWorld(player.getWorld());
|
||||
DEditWorld editWorld = DEditWorld.getByWorld(player.getWorld());
|
||||
if (editWorld != null) {
|
||||
BackupMode backupMode = mainConfig.getBackupMode();
|
||||
if (backupMode == BackupMode.ON_SAVE || backupMode == BackupMode.ON_DISABLE_AND_SAVE) {
|
||||
editWorld.getResource().backup(mainConfig.areTweaksEnabled());
|
||||
}
|
||||
|
||||
editWorld.save();
|
||||
MessageUtil.sendMessage(player, DMessages.CMD_SAVE_SUCCESS.getMessage());
|
||||
|
@ -25,7 +25,7 @@ import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -60,7 +60,7 @@ public class TestCommand extends BRCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
GameWorld gameWorld = dGroup.getGameWorld();
|
||||
DGameWorld gameWorld = dGroup.getGameWorld();
|
||||
if (gameWorld == null) {
|
||||
MessageUtil.sendMessage(sender, DMessages.ERROR_NOT_IN_DUNGEON.getMessage());
|
||||
return;
|
@ -17,12 +17,13 @@
|
||||
package io.github.dre2n.dungeonsxl.command;
|
||||
|
||||
import io.github.dre2n.commons.command.BRCommand;
|
||||
import io.github.dre2n.commons.util.UUIDUtil;
|
||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
@ -44,12 +45,15 @@ public class UninviteCommand extends BRCommand {
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
if (EditWorld.removeInvitedPlayer(args[2], UUIDUtil.getUniqueIdFromName(args[1]), args[1])) {
|
||||
MessageUtil.sendMessage(sender, DMessages.CMD_UNINVITE_SUCCESS.getMessage(args[1], args[2]));
|
||||
|
||||
} else {
|
||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[2]);
|
||||
if (resource == null) {
|
||||
MessageUtil.sendMessage(sender, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(args[2]));
|
||||
}
|
||||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]);
|
||||
if (resource.removeInvitedPlayer(player)) {
|
||||
MessageUtil.sendMessage(sender, DMessages.CMD_UNINVITE_SUCCESS.getMessage(args[1], args[2]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -17,6 +17,7 @@
|
||||
package io.github.dre2n.dungeonsxl.config;
|
||||
|
||||
import io.github.dre2n.commons.config.Messages;
|
||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -36,7 +37,9 @@ public enum DMessages implements Messages {
|
||||
CMD_CHATSPY_STOPPED("Cmd_Chatspy_Stopped", "&6You stopped to spy the dungeon chat."),
|
||||
CMD_CHATSPY_START("Cmd_Chatspy_Start", "&6You started to spy the dungeon chat."),
|
||||
CMD_ENTER_SUCCESS("Cmd_Enter", "&6The group &4&v1 &6successfully entered the game of the group &4&v2&6."),
|
||||
CMD_IMPORT_SUCCESS("Cmd_Import", "&6Successfully imported the world &4&v1&6."),
|
||||
CMD_INVITE_SUCCESS("Cmd_Invite_Success", "&6Player &4&v1&6 was successfully invited to edit the map &4&v2&6."),
|
||||
CMD_KICK_SUCCESS("Cmd_Kick_Success", "&6Successfully attempted to kick &4&v1&6."),
|
||||
CMD_LEAVE_SUCCESS("Cmd_Leave_Success", "&6You have successfully left your group!"),
|
||||
CMD_LIVES("Cmd_Lives", "&4&v1&6 has &4&v2 &6lives left."),
|
||||
CMD_MAIN_WELCOME("Cmd_Main_Welcome", "&7Welcome to &4Dungeons&fXL"),
|
||||
@ -64,7 +67,7 @@ public enum DMessages implements Messages {
|
||||
ERROR_LEAVE_GAME("Error_LeaveGame", "&4You have to leave your current game first!"),
|
||||
ERROR_LEAVE_GROUP("Error_LeaveGroup", "&4You have to leave your group first!"),
|
||||
ERROR_MSG_ID_NOT_EXIST("Error_MsgIdNotExist", "&4Messages with Id &6&v1&4 does not exist!"),
|
||||
ERROR_MSG_FORMAT("Error_MsgFormat", "&4The Messages has to be between \"!"),
|
||||
ERROR_MSG_FORMAT("Error_MsgFormat", "&4Please use &6\" &4to mark the beginning and the end of the message!"),
|
||||
ERROR_MSG_NO_INT("Error_MsgNoInt", "&4The argument [id] has to include a number!"),
|
||||
ERROR_NAME_IN_USE("Error_NameInUse", "&4The name &6&v1 &4is already in use."),
|
||||
ERROR_NAME_TO_LONG("Error_NameToLong", "&4The name may not be longer than 15 characters!"),
|
||||
@ -75,6 +78,7 @@ public enum DMessages implements Messages {
|
||||
ERROR_NO_PLAYER_COMMAND("Error_NoPlayerCommand", "&6/dxl &v1&4 cannot be executed as player!"),
|
||||
ERROR_NO_PROTECTED_BLOCK("Error_NoDXLBlock", "&4This is not a block protected by DungeonsXL!"),
|
||||
ERROR_NO_SUCH_GROUP("Error_NoSuchGroup", "&4The group &6&v1&4 does not exist!"),
|
||||
ERROR_NO_SUCH_MAP("Error_NoSuchMap", "&4The world &6&v1&4 does not exist!"),
|
||||
ERROR_NO_SUCH_PLAYER("Error_NoSuchPlayer", "&4The player &6&v1&4 does not exist!"),
|
||||
ERROR_NOT_CAPTAIN("Error_NotCaptain", "&4You are not the captain of your group!"),
|
||||
ERROR_NOT_IN_DUNGEON("Error_NotInDungeon", "&4You are not in a dungeon!"),
|
||||
@ -92,7 +96,8 @@ public enum DMessages implements Messages {
|
||||
HELP_CMD_CHAT("Help_Cmd_Chat", "/dxl chat - Change the chat mode"),
|
||||
HELP_CMD_CHATSPY("Help_Cmd_Chatspy", "/dxl chatspy - Dis/enables the spymode"),
|
||||
HELP_CMD_CREATE("Help_Cmd_Create", "/dxl create [name] - Creates a new dungeon map"),
|
||||
HELP_CMD_EDIT("Help_Cmd_Edit", "/dxl edit [name] - Edit an existing dungeon map"),
|
||||
HELP_CMD_EDIT("Help_Cmd_Edit", "/dxl edit [map] - Edit an existing dungeon map"),
|
||||
HELP_CMD_ENTER("Help_Cmd_Enter", "/dxl enter ([joining group]) [target group] - Let the joining group enter the game of the target group"),
|
||||
HELP_CMD_ESCAPE("Help_Cmd_Escape", "/dxl escape - Leaves the current edit world without saving"),
|
||||
HELP_CMD_GAME("Help_Cmd_Game", "/dxl game - Shows information about the current game session"),
|
||||
HELP_CMD_GROUP("Help_Cmd_Group", "/dxl group - Shows group command help"),
|
||||
@ -104,9 +109,10 @@ public enum DMessages implements Messages {
|
||||
HELP_CMD_GROUP_KICK("Help_Cmd_GroupKick", "/dxl group kick [player] - Kicks a player"),
|
||||
HELP_CMD_GROUP_SHOW("Help_Cmd_GroupShow", "/dxl group show [group] - Shows a group"),
|
||||
HELP_CMD_HELP("Help_Cmd_Help", "/dxl help [page] - Shows the help page"),
|
||||
HELP_CMD_IMPORT("Help_Cmd_Import", "/dxl import [world] - Imports a world from the world container as a dungeon map"),
|
||||
HELP_CMD_INVITE("Help_Cmd_Invite", "/dxl invite [player] [dungeon] - Invite a player to edit a dungeon"),
|
||||
HELP_CMD_JOIN("Help_Cmd_Join", "/dxl join [announcement] - Opens the GUI to join a group in an upcoming game"),
|
||||
HELP_CMD_ENTER("Help_Cmd_Enter", "/dxl enter ([joining group]) [target group] - Let the joining group enter the game of the target group"),
|
||||
HELP_CMD_KICK("Help_Cmd_Kick", "/dxl kick [player] - Kicks the player out of his group and dungeon"),
|
||||
HELP_CMD_LEAVE("Help_Cmd_Leave", "/dxl leave - Leaves the current group and dungeon or edit world"),
|
||||
HELP_CMD_LIST("Help_Cmd_List", "/dxl list ([dungeon|map|loaded]) ([dungeon]) - Lists all dungeons"),
|
||||
HELP_CMD_LIVES("Help_Cmd_Lives", "/dxl lives [player] - Shows the lives a player has left"),
|
||||
@ -131,8 +137,9 @@ public enum DMessages implements Messages {
|
||||
LOG_ERROR_MOB_ENCHANTMENT("Log_Error_MobEnchantment", "&4Error at loading mob.yml: Enchantment &6&v1&4 doesn't exist!"),
|
||||
LOG_ERROR_MOBTYPE("Log_Error_MobType", "&4Error at loading mob.yml: Mob &6&v1&4 doesn't exist!"),
|
||||
LOG_ERROR_NO_CONSOLE_COMMAND("Log_Error_NoConsoleCommand", "&6/dxl &v1&4 can not be executed as console!"),
|
||||
LOG_GENERATE_NEW_WORLD("Log_GenerateNewWorld", "&6Generate new world..."),
|
||||
LOG_NEW_DUNGEON("Log_NewDungeon", "&6New dungeon"),
|
||||
LOG_GENERATE_NEW_WORLD("Log_GenerateNewWorld", "&6Generating new world..."),
|
||||
LOG_IMPORT_WORLD("Log_ImportWorld", "&6Importing world..."),
|
||||
LOG_NEW_MAP("Log_NewDungeon", "&6Creating new map."),
|
||||
LOG_NEW_PLAYER_DATA("Log_NewPlayerData", "&6A new player data file has been created and saved as &v1."),
|
||||
LOG_WORLD_GENERATION_FINISHED("Log_WorldGenerationFinished", "&6World generation finished!"),
|
||||
PLAYER_BLOCK_INFO("Player_BlockInfo", "&6Block ID: &2&v1"),
|
||||
@ -185,6 +192,7 @@ public enum DMessages implements Messages {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
@ -205,6 +213,14 @@ public enum DMessages implements Messages {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
/**
|
||||
* Sends the message to the console.
|
||||
*/
|
||||
public void debug() {
|
||||
MessageUtil.log(DungeonsXL.getInstance(), getMessage());
|
||||
}
|
||||
|
||||
/* Statics */
|
||||
/**
|
||||
* @param identifer
|
@ -17,6 +17,9 @@
|
||||
package io.github.dre2n.dungeonsxl.config;
|
||||
|
||||
import io.github.dre2n.commons.config.BRConfig;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DWorlds;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -26,11 +29,13 @@ import java.util.List;
|
||||
*/
|
||||
public class DungeonConfig extends BRConfig {
|
||||
|
||||
DWorlds worlds = DungeonsXL.getInstance().getDWorlds();
|
||||
|
||||
public static final int CONFIG_VERSION = 1;
|
||||
|
||||
private String startFloor;
|
||||
private String endFloor;
|
||||
private List<String> floors = new ArrayList<>();
|
||||
private DResourceWorld startFloor;
|
||||
private DResourceWorld endFloor;
|
||||
private List<DResourceWorld> floors = new ArrayList<>();
|
||||
private int floorCount;
|
||||
private boolean removeWhenPlayed;
|
||||
private WorldConfig overrideValues;
|
||||
@ -48,7 +53,7 @@ public class DungeonConfig extends BRConfig {
|
||||
/**
|
||||
* @return the startFloor
|
||||
*/
|
||||
public String getStartFloor() {
|
||||
public DResourceWorld getStartFloor() {
|
||||
return startFloor;
|
||||
}
|
||||
|
||||
@ -56,14 +61,14 @@ public class DungeonConfig extends BRConfig {
|
||||
* @param startFloor
|
||||
* the startFloor to set
|
||||
*/
|
||||
public void setStartFloor(String startFloor) {
|
||||
public void setStartFloor(DResourceWorld startFloor) {
|
||||
this.startFloor = startFloor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the endFloor
|
||||
*/
|
||||
public String getEndFloor() {
|
||||
public DResourceWorld getEndFloor() {
|
||||
return endFloor;
|
||||
}
|
||||
|
||||
@ -71,31 +76,31 @@ public class DungeonConfig extends BRConfig {
|
||||
* @param endFloor
|
||||
* the endFloor to set
|
||||
*/
|
||||
public void setEndFloor(String endFloor) {
|
||||
public void setEndFloor(DResourceWorld endFloor) {
|
||||
this.endFloor = endFloor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the floors
|
||||
*/
|
||||
public List<String> getFloors() {
|
||||
public List<DResourceWorld> getFloors() {
|
||||
return floors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gameWorld
|
||||
* the gameWorld to add
|
||||
* @param resource
|
||||
* the resource to add
|
||||
*/
|
||||
public void addFloor(String gameWorld) {
|
||||
floors.add(gameWorld);
|
||||
public void addFloor(DResourceWorld resource) {
|
||||
floors.add(resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gameWorld
|
||||
* the gameWorld to remove
|
||||
* @param resource
|
||||
* the resource to remove
|
||||
*/
|
||||
public void removeFloor(String gameWorld) {
|
||||
floors.remove(gameWorld);
|
||||
public void removeFloor(DResourceWorld resource) {
|
||||
floors.remove(resource);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,18 +170,36 @@ public class DungeonConfig extends BRConfig {
|
||||
defaultValues = worldConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource
|
||||
* the DResourceWorld to check
|
||||
* @return true if the floor is either in the list or the start / end floor.
|
||||
*/
|
||||
public boolean containsFloor(DResourceWorld resource) {
|
||||
return floors.contains(resource) || startFloor.equals(resource) || endFloor.equals(resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mapName
|
||||
* the name of the map to check
|
||||
* @return true if the floor is either in the list or the start / end floor.
|
||||
*/
|
||||
public boolean containsFloor(String mapName) {
|
||||
return containsFloor(worlds.getResourceByName(mapName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
if (!config.contains("floors")) {
|
||||
config.set("floors", floors);
|
||||
config.createSection("floors");
|
||||
}
|
||||
|
||||
if (!config.contains("startFloor")) {
|
||||
config.set("startFloor", startFloor);
|
||||
config.set("startFloor", startFloor.getName());
|
||||
}
|
||||
|
||||
if (!config.contains("endFloor")) {
|
||||
config.set("endFloor", endFloor);
|
||||
config.set("endFloor", endFloor.getName());
|
||||
}
|
||||
|
||||
if (!config.contains("floorCount")) {
|
||||
@ -201,15 +224,20 @@ public class DungeonConfig extends BRConfig {
|
||||
@Override
|
||||
public void load() {
|
||||
if (config.contains("floors")) {
|
||||
floors = config.getStringList("floors");
|
||||
for (String floor : config.getStringList("floors")) {
|
||||
DResourceWorld resource = worlds.getResourceByName(floor);
|
||||
if (resource != null) {
|
||||
floors.add(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.contains("startFloor")) {
|
||||
startFloor = config.getString("startFloor");
|
||||
startFloor = worlds.getResourceByName(config.getString("startFloor"));
|
||||
}
|
||||
|
||||
if (config.contains("endFloor")) {
|
||||
endFloor = config.getString("endFloor");
|
||||
endFloor = worlds.getResourceByName(config.getString("endFloor"));
|
||||
}
|
||||
|
||||
if (config.contains("floorCount")) {
|
@ -17,6 +17,7 @@
|
||||
package io.github.dre2n.dungeonsxl.config;
|
||||
|
||||
import io.github.dre2n.commons.config.BRConfig;
|
||||
import io.github.dre2n.commons.util.EnumUtil;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -30,7 +31,14 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
*/
|
||||
public class MainConfig extends BRConfig {
|
||||
|
||||
public static final int CONFIG_VERSION = 9;
|
||||
public enum BackupMode {
|
||||
ON_DISABLE,
|
||||
ON_DISABLE_AND_SAVE,
|
||||
ON_SAVE,
|
||||
NEVER
|
||||
}
|
||||
|
||||
public static final int CONFIG_VERSION = 11;
|
||||
|
||||
private String language = "english";
|
||||
private boolean enableEconomy = false;
|
||||
@ -57,7 +65,10 @@ public class MainConfig extends BRConfig {
|
||||
/* Misc */
|
||||
private boolean sendFloorTitle = true;
|
||||
private Map<String, Object> externalMobProviders = new HashMap<>();
|
||||
|
||||
/* Performance */
|
||||
private int maxInstances = 10;
|
||||
private boolean tweaksEnabled = false;
|
||||
|
||||
/* Secure Mode */
|
||||
private boolean secureModeEnabled = false;
|
||||
@ -65,6 +76,7 @@ public class MainConfig extends BRConfig {
|
||||
private boolean openInventories = false;
|
||||
private boolean dropItems = false;
|
||||
private List<String> editCommandWhitelist = new ArrayList<>();
|
||||
private BackupMode backupMode = BackupMode.ON_DISABLE_AND_SAVE;
|
||||
|
||||
/* Permissions bridge */
|
||||
private List<String> editPermissions = new ArrayList<>();
|
||||
@ -238,6 +250,21 @@ public class MainConfig extends BRConfig {
|
||||
this.maxInstances = maxInstances;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if the performance tweaks are enabled
|
||||
*/
|
||||
public boolean areTweaksEnabled() {
|
||||
return tweaksEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param enabled
|
||||
* if the performance tweaks are enabled
|
||||
*/
|
||||
public void setTweaksEnabled(boolean enabled) {
|
||||
tweaksEnabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if the secure mode is enabled
|
||||
*/
|
||||
@ -305,6 +332,21 @@ public class MainConfig extends BRConfig {
|
||||
return editCommandWhitelist;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the backup mode
|
||||
*/
|
||||
public BackupMode getBackupMode() {
|
||||
return backupMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mode
|
||||
* the BackupMode to set
|
||||
*/
|
||||
public void setBackupMode(BackupMode mode) {
|
||||
backupMode = mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the edit mode permissions
|
||||
*/
|
||||
@ -366,6 +408,10 @@ public class MainConfig extends BRConfig {
|
||||
config.set("maxInstances", maxInstances);
|
||||
}
|
||||
|
||||
if (!config.contains("tweaksEnabled")) {
|
||||
config.set("tweaksEnabled", tweaksEnabled);
|
||||
}
|
||||
|
||||
if (!config.contains("secureMode.enabled")) {
|
||||
config.set("secureMode.enabled", secureModeEnabled);
|
||||
}
|
||||
@ -386,6 +432,10 @@ public class MainConfig extends BRConfig {
|
||||
config.set("secureMode.editCommandWhitelist", editCommandWhitelist);
|
||||
}
|
||||
|
||||
if (!config.contains("backupMode")) {
|
||||
config.set("backupMode", backupMode.toString());
|
||||
}
|
||||
|
||||
if (!config.contains("editPermissions")) {
|
||||
config.set("editPermissions", editPermissions);
|
||||
}
|
||||
@ -445,6 +495,10 @@ public class MainConfig extends BRConfig {
|
||||
maxInstances = config.getInt("maxInstances");
|
||||
}
|
||||
|
||||
if (config.contains("tweaksEnabled")) {
|
||||
tweaksEnabled = config.getBoolean("tweaksEnabled");
|
||||
}
|
||||
|
||||
if (config.contains("secureMode.enabled")) {
|
||||
secureModeEnabled = config.getBoolean("secureMode.enabled");
|
||||
}
|
||||
@ -465,6 +519,13 @@ public class MainConfig extends BRConfig {
|
||||
editCommandWhitelist = config.getStringList("secureMode.editCommandWhitelist");
|
||||
}
|
||||
|
||||
if (config.contains("backupMode")) {
|
||||
String mode = config.getString("backupMode");
|
||||
if (EnumUtil.isValidEnum(BackupMode.class, mode)) {
|
||||
backupMode = BackupMode.valueOf(mode);
|
||||
}
|
||||
}
|
||||
|
||||
if (config.contains("editPermissions")) {
|
||||
editPermissions = config.getStringList("editPermissions");
|
||||
}
|
@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2016 Frank Baumann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.config;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.List;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class SignData {
|
||||
|
||||
private File file;
|
||||
|
||||
public SignData(File file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
/**
|
||||
* @return the file
|
||||
*/
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
/**
|
||||
* Applies all signs from the file to the DEditWorld.
|
||||
* Also sets the lobby location of the DEditWorld to the location of the lobby sign if one exists.
|
||||
*
|
||||
* @param editWorld
|
||||
* the DEditWorld where the signs are
|
||||
* @throws IOException
|
||||
*/
|
||||
public void deserializeSigns(DEditWorld editWorld) {
|
||||
try {
|
||||
ObjectInputStream os = new ObjectInputStream(new FileInputStream(file));
|
||||
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 = editWorld.getWorld().getBlockAt(x, y, z);
|
||||
editWorld.getSigns().add(block);
|
||||
|
||||
if (block.getState() instanceof Sign) {
|
||||
Sign sign = (Sign) block.getState();
|
||||
String[] lines = sign.getLines();
|
||||
|
||||
if (lines[0].equalsIgnoreCase("[lobby]")) {
|
||||
editWorld.setLobbyLocation(block.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies all signs from the file to the DGameWorld.
|
||||
*
|
||||
* @param gameWorld
|
||||
* the DGameWorld where the signs are
|
||||
* @return a Set of all DSign blocks
|
||||
* @throws IOException
|
||||
*/
|
||||
public void deserializeSigns(DGameWorld gameWorld) {
|
||||
try {
|
||||
ObjectInputStream os = new ObjectInputStream(new FileInputStream(file));
|
||||
|
||||
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 = gameWorld.getWorld().getBlockAt(x, y, z);
|
||||
if (block.getState() instanceof Sign) {
|
||||
DSign dSign = DSign.create((Sign) block.getState(), gameWorld);
|
||||
gameWorld.getDSigns().add(dSign);
|
||||
}
|
||||
}
|
||||
|
||||
os.close();
|
||||
|
||||
} catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies all signs from the DEditWorld to the file.
|
||||
*
|
||||
* @param editWorld
|
||||
* the DEditWorld that contains the signs to serialize
|
||||
* @throws IOException
|
||||
*/
|
||||
public void serializeSigns(DEditWorld editWorld) {
|
||||
serializeSigns(editWorld.getSigns());
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies all signs from the sign list to the file.
|
||||
*
|
||||
* @param signs
|
||||
* the signs to serialize
|
||||
* @throws IOException
|
||||
*/
|
||||
public void serializeSigns(List<Block> signs) {
|
||||
try {
|
||||
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file));
|
||||
out.writeInt(signs.size());
|
||||
|
||||
for (Block sign : signs) {
|
||||
out.writeInt(sign.getX());
|
||||
out.writeInt(sign.getY());
|
||||
out.writeInt(sign.getZ());
|
||||
}
|
||||
|
||||
out.close();
|
||||
|
||||
} catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -60,9 +60,7 @@ public class WorldConfig extends GameRules {
|
||||
|
||||
public WorldConfig(File file) {
|
||||
this.file = file;
|
||||
|
||||
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
load(configFile);
|
||||
}
|
||||
|
||||
@ -78,7 +76,7 @@ public class WorldConfig extends GameRules {
|
||||
Set<String> list = configSectionMessages.getKeys(false);
|
||||
for (String messagePath : list) {
|
||||
int messageId = NumberUtil.parseInt(messagePath);
|
||||
msgs.put(messageId, configSectionMessages.getString(messagePath));
|
||||
setMessage(messageId, configSectionMessages.getString(messagePath));
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,11 +250,11 @@ public class WorldConfig extends GameRules {
|
||||
|
||||
List<String> secureObjectIds = new ArrayList<>();
|
||||
|
||||
for (ItemStack item : secureObjects) {
|
||||
for (ItemStack item : getSecureObjects()) {
|
||||
secureObjectIds.add(plugin.getCaliburnAPI().getItems().getCustomItemId(item));
|
||||
}
|
||||
|
||||
configFile.set("secureObjects", secureObjectIds);
|
||||
configFile.set("secureObjects", secureObjects);
|
||||
|
||||
// Invited Players
|
||||
configFile.set("invitedPlayers", invitedPlayers);
|
@ -36,7 +36,7 @@ public class Dungeon {
|
||||
public Dungeon(String name) {
|
||||
this.name = name;
|
||||
|
||||
File file = new File(DungeonsXL.getInstance().getDataFolder() + "/dungeons", name + ".yml");
|
||||
File file = new File(DungeonsXL.DUNGEONS, name + ".yml");
|
||||
if (file.exists()) {
|
||||
this.config = new DungeonConfig(file);
|
||||
}
|
||||
@ -63,4 +63,11 @@ public class Dungeon {
|
||||
return config != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false if there are setup errors
|
||||
*/
|
||||
public boolean isSetupCorrect() {
|
||||
return config.getStartFloor() == null || config.getEndFloor() == null;
|
||||
}
|
||||
|
||||
}
|
@ -29,14 +29,23 @@ public class Dungeons {
|
||||
private List<Dungeon> dungeons = new ArrayList<>();
|
||||
|
||||
public Dungeons() {
|
||||
File folder = new File(DungeonsXL.getInstance().getDataFolder() + "/dungeons");
|
||||
this(DungeonsXL.DUNGEONS);
|
||||
}
|
||||
|
||||
public Dungeons(File folder) {
|
||||
if (!folder.exists()) {
|
||||
folder.mkdir();
|
||||
}
|
||||
|
||||
for (File file : folder.listFiles()) {
|
||||
dungeons.add(new Dungeon(file));
|
||||
Dungeon dungeon = new Dungeon(file);
|
||||
|
||||
if (dungeon.isSetupCorrect()) {
|
||||
dungeons.add(dungeon);
|
||||
|
||||
} else {
|
||||
// debug
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
package io.github.dre2n.dungeonsxl.event.dgroup;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -29,10 +29,10 @@ public class DGroupFinishFloorEvent extends DGroupEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
|
||||
private GameWorld finished;
|
||||
private DGameWorld finished;
|
||||
private String next;
|
||||
|
||||
public DGroupFinishFloorEvent(DGroup dGroup, GameWorld finished, String next) {
|
||||
public DGroupFinishFloorEvent(DGroup dGroup, DGameWorld finished, String next) {
|
||||
super(dGroup);
|
||||
this.finished = finished;
|
||||
this.next = next;
|
||||
@ -41,15 +41,15 @@ public class DGroupFinishFloorEvent extends DGroupEvent implements Cancellable {
|
||||
/**
|
||||
* @return the finished
|
||||
*/
|
||||
public GameWorld getFinished() {
|
||||
public DGameWorld getFinished() {
|
||||
return finished;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param finished
|
||||
* the name of the GameWorld to set
|
||||
* the name of the DGameWorld to set
|
||||
*/
|
||||
public void setFinished(GameWorld finished) {
|
||||
public void setFinished(DGameWorld finished) {
|
||||
this.finished = finished;
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ public class DGroupFinishFloorEvent extends DGroupEvent implements Cancellable {
|
||||
|
||||
/**
|
||||
* @param next
|
||||
* the name of the GameWorld to set
|
||||
* the name of the DGameWorld to set
|
||||
*/
|
||||
public void setNext(String next) {
|
||||
this.next = next;
|
@ -17,7 +17,7 @@
|
||||
package io.github.dre2n.dungeonsxl.event.dgroup;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -29,9 +29,9 @@ public class DGroupStartFloorEvent extends DGroupEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
|
||||
private GameWorld gameWorld;
|
||||
private DGameWorld gameWorld;
|
||||
|
||||
public DGroupStartFloorEvent(DGroup dGroup, GameWorld gameWorld) {
|
||||
public DGroupStartFloorEvent(DGroup dGroup, DGameWorld gameWorld) {
|
||||
super(dGroup);
|
||||
this.gameWorld = gameWorld;
|
||||
}
|
||||
@ -39,7 +39,7 @@ public class DGroupStartFloorEvent extends DGroupEvent implements Cancellable {
|
||||
/**
|
||||
* @return the gameWorld
|
||||
*/
|
||||
public GameWorld getGameWorld() {
|
||||
public DGameWorld getGameWorld() {
|
||||
return gameWorld;
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ public class DGroupStartFloorEvent extends DGroupEvent implements Cancellable {
|
||||
* @param gameWorld
|
||||
* the gameWorld to set
|
||||
*/
|
||||
public void setGameWorld(GameWorld gameWorld) {
|
||||
public void setGameWorld(DGameWorld gameWorld) {
|
||||
this.gameWorld = gameWorld;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
package io.github.dre2n.dungeonsxl.event.dsign;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@ -31,9 +31,9 @@ public class DSignRegistrationEvent extends DSignEvent implements Cancellable {
|
||||
private boolean cancelled;
|
||||
|
||||
private Sign sign;
|
||||
private GameWorld gameWorld;
|
||||
private DGameWorld gameWorld;
|
||||
|
||||
public DSignRegistrationEvent(Sign sign, GameWorld gameWorld, DSign dSign) {
|
||||
public DSignRegistrationEvent(Sign sign, DGameWorld gameWorld, DSign dSign) {
|
||||
super(dSign);
|
||||
this.sign = sign;
|
||||
this.gameWorld = gameWorld;
|
||||
@ -57,7 +57,7 @@ public class DSignRegistrationEvent extends DSignEvent implements Cancellable {
|
||||
/**
|
||||
* @return the gameWorld
|
||||
*/
|
||||
public GameWorld getGameWorld() {
|
||||
public DGameWorld getGameWorld() {
|
||||
return gameWorld;
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ public class DSignRegistrationEvent extends DSignEvent implements Cancellable {
|
||||
* @param gameWorld
|
||||
* the gameWorld to set
|
||||
*/
|
||||
public void setGameWorld(GameWorld gameWorld) {
|
||||
public void setGameWorld(DGameWorld gameWorld) {
|
||||
this.gameWorld = gameWorld;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.event.editworld;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
/**
|
||||
@ -24,16 +24,16 @@ import org.bukkit.event.Event;
|
||||
*/
|
||||
public abstract class EditWorldEvent extends Event {
|
||||
|
||||
protected EditWorld editWorld;
|
||||
protected DEditWorld editWorld;
|
||||
|
||||
public EditWorldEvent(EditWorld editWorld) {
|
||||
public EditWorldEvent(DEditWorld editWorld) {
|
||||
this.editWorld = editWorld;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the editWorld
|
||||
*/
|
||||
public EditWorld getEditWorld() {
|
||||
public DEditWorld getEditWorld() {
|
||||
return editWorld;
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ public abstract class EditWorldEvent extends Event {
|
||||
* @param editWorld
|
||||
* the editWorld to set
|
||||
*/
|
||||
public void setEditWorld(EditWorld editWorld) {
|
||||
public void setEditWorld(DEditWorld editWorld) {
|
||||
this.editWorld = editWorld;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.event.editworld;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -28,7 +28,7 @@ public class EditWorldGenerateEvent extends EditWorldEvent implements Cancellabl
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
|
||||
public EditWorldGenerateEvent(EditWorld editWorld) {
|
||||
public EditWorldGenerateEvent(DEditWorld editWorld) {
|
||||
super(editWorld);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.event.editworld;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -28,7 +28,7 @@ public class EditWorldSaveEvent extends EditWorldEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
|
||||
public EditWorldSaveEvent(EditWorld editWorld) {
|
||||
public EditWorldSaveEvent(DEditWorld editWorld) {
|
||||
super(editWorld);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.event.editworld;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -30,7 +30,7 @@ public class EditWorldUnloadEvent extends EditWorldEvent implements Cancellable
|
||||
|
||||
private boolean save;
|
||||
|
||||
public EditWorldUnloadEvent(EditWorld editWorld, boolean save) {
|
||||
public EditWorldUnloadEvent(DEditWorld editWorld, boolean save) {
|
||||
super(editWorld);
|
||||
this.save = save;
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.event.gameworld;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
/**
|
||||
@ -24,16 +24,16 @@ import org.bukkit.event.Event;
|
||||
*/
|
||||
public abstract class GameWorldEvent extends Event {
|
||||
|
||||
protected GameWorld gameWorld;
|
||||
protected DGameWorld gameWorld;
|
||||
|
||||
public GameWorldEvent(GameWorld gameWorld) {
|
||||
public GameWorldEvent(DGameWorld gameWorld) {
|
||||
this.gameWorld = gameWorld;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the gameWorld
|
||||
*/
|
||||
public GameWorld getGameWorld() {
|
||||
public DGameWorld getGameWorld() {
|
||||
return gameWorld;
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ public abstract class GameWorldEvent extends Event {
|
||||
* @param gameWorld
|
||||
* the gameWorld to set
|
||||
*/
|
||||
public void setGameWorld(GameWorld gameWorld) {
|
||||
public void setGameWorld(DGameWorld gameWorld) {
|
||||
this.gameWorld = gameWorld;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
package io.github.dre2n.dungeonsxl.event.gameworld;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.game.Game;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -31,7 +31,7 @@ public class GameWorldStartGameEvent extends GameWorldEvent implements Cancellab
|
||||
|
||||
private Game game;
|
||||
|
||||
public GameWorldStartGameEvent(GameWorld gameWorld, Game game) {
|
||||
public GameWorldStartGameEvent(DGameWorld gameWorld, Game game) {
|
||||
super(gameWorld);
|
||||
this.game = game;
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.event.gameworld;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -29,7 +29,7 @@ public class GameWorldUnloadEvent extends GameWorldEvent implements Cancellable
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
public GameWorldUnloadEvent(GameWorld gameWorld) {
|
||||
public GameWorldUnloadEvent(DGameWorld gameWorld) {
|
||||
super(gameWorld);
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||
import io.github.dre2n.dungeonsxl.sign.MobSign;
|
||||
import io.github.dre2n.dungeonsxl.trigger.ProgressTrigger;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@ -49,7 +50,7 @@ public class Game {
|
||||
private List<DGroup> dGroups = new ArrayList<>();
|
||||
private boolean started;
|
||||
private GameType type = GameTypeDefault.DEFAULT;
|
||||
private GameWorld world;
|
||||
private DGameWorld world;
|
||||
private GameRules rules;
|
||||
private int waveCount;
|
||||
private Map<String, Integer> gameKills = new HashMap<>();
|
||||
@ -63,7 +64,7 @@ public class Game {
|
||||
plugin.getGames().add(this);
|
||||
}
|
||||
|
||||
public Game(DGroup dGroup, GameWorld world) {
|
||||
public Game(DGroup dGroup, DGameWorld world) {
|
||||
dGroups.add(dGroup);
|
||||
started = false;
|
||||
this.world = world;
|
||||
@ -77,17 +78,19 @@ public class Game {
|
||||
|
||||
dGroups.add(dGroup);
|
||||
started = false;
|
||||
world = new GameWorld();
|
||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(worldName);
|
||||
if (resource != null) {
|
||||
world = resource.instantiateAsGameWorld();
|
||||
}
|
||||
dGroup.setGameWorld(world);
|
||||
world.load(worldName);
|
||||
fetchRules();
|
||||
}
|
||||
|
||||
public Game(DGroup dGroup, GameType type, GameWorld world) {
|
||||
public Game(DGroup dGroup, GameType type, DGameWorld world) {
|
||||
this(new ArrayList<>(Arrays.asList(dGroup)), type, world);
|
||||
}
|
||||
|
||||
public Game(List<DGroup> dGroups, GameType type, GameWorld world) {
|
||||
public Game(List<DGroup> dGroups, GameType type, DGameWorld world) {
|
||||
this.dGroups = dGroups;
|
||||
this.type = type;
|
||||
this.world = world;
|
||||
@ -155,17 +158,17 @@ public class Game {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the GameWorld connected to the Game
|
||||
* @return the DGameWorld connected to the Game
|
||||
*/
|
||||
public GameWorld getWorld() {
|
||||
public DGameWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* the GameWorld to connect to the Game
|
||||
* the DGameWorld to connect to the Game
|
||||
*/
|
||||
public void setWorld(GameWorld world) {
|
||||
public void setWorld(DGameWorld world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@ -234,8 +237,8 @@ public class Game {
|
||||
*
|
||||
* @return the unplayed floors
|
||||
*/
|
||||
public List<String> getUnplayedFloors() {
|
||||
List<String> unplayedFloors = new ArrayList<>();
|
||||
public List<DResourceWorld> getUnplayedFloors() {
|
||||
List<DResourceWorld> unplayedFloors = new ArrayList<>();
|
||||
for (DGroup dGroup : dGroups) {
|
||||
if (dGroup.getUnplayedFloors().size() < unplayedFloors.size()) {
|
||||
unplayedFloors = dGroup.getUnplayedFloors();
|
||||
@ -374,7 +377,7 @@ public class Game {
|
||||
}
|
||||
|
||||
int delay = rules.getTimeToNextWave();
|
||||
sendMessage(plugin.getMessageConfig().getMessage(DMessages.GROUP_WAVE_FINISHED, String.valueOf(waveCount), String.valueOf(delay)));
|
||||
sendMessage(DMessages.GROUP_WAVE_FINISHED.getMessage(String.valueOf(waveCount), String.valueOf(delay)));
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
@ -425,7 +428,7 @@ public class Game {
|
||||
return getByDGroup(DGroup.getByPlayer(player));
|
||||
}
|
||||
|
||||
public static Game getByGameWorld(GameWorld gameWorld) {
|
||||
public static Game getByGameWorld(DGameWorld gameWorld) {
|
||||
for (Game game : plugin.getGames()) {
|
||||
if (game.getWorld().equals(gameWorld)) {
|
||||
return game;
|
||||
@ -436,7 +439,7 @@ public class Game {
|
||||
}
|
||||
|
||||
public static Game getByWorld(World world) {
|
||||
GameWorld gameWorld = GameWorld.getByWorld(world);
|
||||
DGameWorld gameWorld = DGameWorld.getByWorld(world);
|
||||
if (gameWorld != null) {
|
||||
return getByGameWorld(gameWorld);
|
||||
} else {
|
@ -17,7 +17,7 @@
|
||||
package io.github.dre2n.dungeonsxl.game;
|
||||
|
||||
import io.github.dre2n.commons.util.NumberUtil;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Material;
|
||||
@ -254,7 +254,7 @@ public class GamePlaceableBlock {
|
||||
}
|
||||
|
||||
// Can build
|
||||
public static boolean canBuildHere(Block block, BlockFace blockFace, Material mat, GameWorld gameWorld) {
|
||||
public static boolean canBuildHere(Block block, BlockFace blockFace, Material mat, DGameWorld gameWorld) {
|
||||
for (GamePlaceableBlock gamePlacableBlock : gameWorld.getPlaceableBlocks()) {
|
||||
if (gamePlacableBlock.block.getFace(block) != BlockFace.SELF) {
|
||||
continue;
|
@ -16,8 +16,6 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.game;
|
||||
|
||||
import io.github.dre2n.caliburn.item.UniversalItem;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
||||
import io.github.dre2n.dungeonsxl.reward.Reward;
|
||||
import java.util.ArrayList;
|
||||
@ -241,6 +239,9 @@ public class GameRules {
|
||||
* @return the requirements
|
||||
*/
|
||||
public List<Requirement> getRequirements() {
|
||||
if (requirements == null) {
|
||||
requirements = new ArrayList<>();
|
||||
}
|
||||
return requirements;
|
||||
}
|
||||
|
||||
@ -248,6 +249,9 @@ public class GameRules {
|
||||
* @return all maps needed to be finished to play this map
|
||||
*/
|
||||
public List<String> getFinishedAll() {
|
||||
if (finishedAll == null) {
|
||||
finishedAll = new ArrayList<>();
|
||||
}
|
||||
return finishedAll;
|
||||
}
|
||||
|
||||
@ -256,6 +260,13 @@ public class GameRules {
|
||||
* least one has to be finished
|
||||
*/
|
||||
public List<String> getFinished() {
|
||||
if (finishedAll == null) {
|
||||
finishedAll = new ArrayList<>();
|
||||
}
|
||||
if (finishedOne == null) {
|
||||
finishedOne = new ArrayList<>();
|
||||
}
|
||||
|
||||
List<String> merge = new ArrayList<>();
|
||||
merge.addAll(finishedAll);
|
||||
merge.addAll(finishedOne);
|
||||
@ -266,6 +277,9 @@ public class GameRules {
|
||||
* @return the rewards
|
||||
*/
|
||||
public List<Reward> getRewards() {
|
||||
if (rewards == null) {
|
||||
rewards = new ArrayList<>();
|
||||
}
|
||||
return rewards;
|
||||
}
|
||||
|
||||
@ -274,6 +288,9 @@ public class GameRules {
|
||||
* @return the gameCommandWhitelist
|
||||
*/
|
||||
public List<String> getGameCommandWhitelist() {
|
||||
if (gameCommandWhitelist == null) {
|
||||
gameCommandWhitelist = new ArrayList<>();
|
||||
}
|
||||
return gameCommandWhitelist;
|
||||
}
|
||||
|
||||
@ -281,6 +298,9 @@ public class GameRules {
|
||||
* @return the gamePermissions
|
||||
*/
|
||||
public List<String> getGamePermissions() {
|
||||
if (gamePermissions == null) {
|
||||
gamePermissions = new ArrayList<>();
|
||||
}
|
||||
return gamePermissions;
|
||||
}
|
||||
|
||||
@ -288,28 +308,24 @@ public class GameRules {
|
||||
/**
|
||||
* @param id
|
||||
* the id of the message
|
||||
* @param returnMainConfig
|
||||
* if a default value shall be returned
|
||||
*/
|
||||
public String getMsg(int id, boolean returnMainConfig) {
|
||||
String msg = msgs.get(id);
|
||||
if (msg != null) {
|
||||
public String getMessage(int id) {
|
||||
if (msgs == null) {
|
||||
msgs = new HashMap<>();
|
||||
}
|
||||
return msgs.get(id);
|
||||
}
|
||||
if (returnMainConfig) {
|
||||
return DungeonsXL.getInstance().getMainConfig().getDefaultWorldConfig().msgs.get(id);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg
|
||||
* the message to set
|
||||
* @param id
|
||||
* the ID of the message
|
||||
* @param msg
|
||||
* the message to set
|
||||
*/
|
||||
public void setMsg(String msg, int id) {
|
||||
public void setMessage(int id, String msg) {
|
||||
if (msgs == null) {
|
||||
msgs = new HashMap<>();
|
||||
}
|
||||
msgs.put(id, msg);
|
||||
}
|
||||
|
||||
@ -317,6 +333,9 @@ public class GameRules {
|
||||
* @return the objects to get passed to another player of the group when this player leaves
|
||||
*/
|
||||
public List<ItemStack> getSecureObjects() {
|
||||
if (secureObjects == null) {
|
||||
secureObjects = new ArrayList<>();
|
||||
}
|
||||
return secureObjects;
|
||||
}
|
||||
|
||||
@ -451,8 +470,17 @@ public class GameRules {
|
||||
}
|
||||
|
||||
/* Misc */
|
||||
if (msgs == null) {
|
||||
msgs = defaultValues.msgs;
|
||||
} else if (defaultValues.msgs != null) {
|
||||
msgs.putAll(defaultValues.msgs);
|
||||
}
|
||||
|
||||
if (secureObjects == null) {
|
||||
secureObjects = defaultValues.secureObjects;
|
||||
} else if (defaultValues.secureObjects != null) {
|
||||
secureObjects.addAll(defaultValues.secureObjects);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -22,7 +22,7 @@ import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import io.github.dre2n.dungeonsxl.game.Game;
|
||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Location;
|
||||
@ -167,7 +167,7 @@ public class DPortal extends GlobalProtection {
|
||||
return;
|
||||
}
|
||||
|
||||
GameWorld target = dGroup.getGameWorld();
|
||||
DGameWorld target = dGroup.getGameWorld();
|
||||
Game game = Game.getByDGroup(dGroup);
|
||||
|
||||
if (target == null && game != null) {
|
||||
@ -186,7 +186,7 @@ public class DPortal extends GlobalProtection {
|
||||
}
|
||||
|
||||
if (target == null && dGroup.getMapName() != null) {
|
||||
target = new GameWorld(dGroup.getMapName());
|
||||
target = plugin.getDWorlds().getResourceByName(dGroup.getMapName()).instantiateAsGameWorld();//TO DO
|
||||
dGroup.setGameWorld(target);
|
||||
}
|
||||
|
||||
@ -202,7 +202,7 @@ public class DPortal extends GlobalProtection {
|
||||
dGroup.setGameWorld(target);
|
||||
}
|
||||
|
||||
new DGamePlayer(player, target);
|
||||
DGamePlayer.create(player, target);
|
||||
}
|
||||
|
||||
@Override
|
@ -65,7 +65,7 @@ public class GameSign extends GlobalProtection {
|
||||
dungeonName = identifier;
|
||||
Dungeon dungeon = plugin.getDungeons().getByName(identifier);
|
||||
if (dungeon != null) {
|
||||
mapName = dungeon.getConfig().getStartFloor();
|
||||
mapName = dungeon.getConfig().getStartFloor().getName();
|
||||
} else {
|
||||
mapName = "invalid";
|
||||
}
|
||||
@ -469,7 +469,7 @@ public class GameSign extends GlobalProtection {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (plugin.getGameWorlds().size() >= plugin.getMainConfig().getMaxInstances()) {
|
||||
if (plugin.getDWorlds().getGameWorlds().size() >= plugin.getMainConfig().getMaxInstances()) {
|
||||
MessageUtil.sendMessage(player, DMessages.ERROR_TOO_MANY_INSTANCES.getMessage());
|
||||
return true;
|
||||
}
|
@ -64,7 +64,7 @@ public class GroupSign extends GlobalProtection {
|
||||
dungeonName = identifier;
|
||||
Dungeon dungeon = plugin.getDungeons().getByName(identifier);
|
||||
if (dungeon != null) {
|
||||
mapName = dungeon.getConfig().getStartFloor();
|
||||
mapName = dungeon.getConfig().getStartFloor().getName();
|
||||
} else {
|
||||
mapName = "invalid";
|
||||
}
|
@ -34,8 +34,8 @@ import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import io.github.dre2n.dungeonsxl.player.DPlayers;
|
||||
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||
import io.github.dre2n.dungeonsxl.task.RedstoneEventTask;
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -91,15 +91,15 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
// EditWorld Signs
|
||||
EditWorld editWorld = EditWorld.getByWorld(block.getWorld());
|
||||
// DEditWorld Signs
|
||||
DEditWorld editWorld = DEditWorld.getByWorld(block.getWorld());
|
||||
if (editWorld != null) {
|
||||
editWorld.getSigns().remove(event.getBlock());
|
||||
return;
|
||||
}
|
||||
|
||||
// Deny GameWorld block breaking
|
||||
GameWorld gameWorld = GameWorld.getByWorld(block.getWorld());
|
||||
// Deny DGameWorld block breaking
|
||||
DGameWorld gameWorld = DGameWorld.getByWorld(block.getWorld());
|
||||
if (gameWorld != null) {
|
||||
for (DSign dSign : gameWorld.getDSigns()) {
|
||||
if (dSign.getSign().equals(block)) {
|
||||
@ -128,8 +128,8 @@ public class BlockListener implements Listener {
|
||||
public void onPlace(BlockPlaceEvent event) {
|
||||
Block block = event.getBlock();
|
||||
|
||||
// Deny GameWorld Blocks
|
||||
GameWorld gameWorld = GameWorld.getByWorld(block.getWorld());
|
||||
// Deny DGameWorld Blocks
|
||||
DGameWorld gameWorld = DGameWorld.getByWorld(block.getWorld());
|
||||
if (gameWorld == null) {
|
||||
return;
|
||||
}
|
||||
@ -162,7 +162,7 @@ public class BlockListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
String[] lines = event.getLines();
|
||||
EditWorld editWorld = EditWorld.getByWorld(player.getWorld());
|
||||
DEditWorld editWorld = DEditWorld.getByWorld(player.getWorld());
|
||||
|
||||
// Group Signs
|
||||
if (editWorld == null) {
|
||||
@ -231,7 +231,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
if (dsign.check()) {
|
||||
editWorld.checkSign(block);
|
||||
editWorld.registerSign(block);
|
||||
editWorld.getSigns().add(block);
|
||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.PLAYER_SIGN_CREATED));
|
||||
|
||||
@ -251,13 +251,13 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
// Check GameWorlds
|
||||
GameWorld gameWorld = GameWorld.getByWorld(event.getBlock().getWorld());
|
||||
DGameWorld gameWorld = DGameWorld.getByWorld(event.getBlock().getWorld());
|
||||
if (gameWorld != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// Check EditWorlds
|
||||
EditWorld editWorld = EditWorld.getByWorld(event.getBlock().getWorld());
|
||||
DEditWorld editWorld = DEditWorld.getByWorld(event.getBlock().getWorld());
|
||||
if (editWorld != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
@ -21,8 +21,8 @@ import io.github.dre2n.dungeonsxl.game.Game;
|
||||
import io.github.dre2n.dungeonsxl.mob.DMob;
|
||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import java.util.List;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -52,7 +52,7 @@ public class EntityListener implements Listener {
|
||||
// Remove drops from breaking Signs
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onItemSpawn(ItemSpawnEvent event) {
|
||||
if (GameWorld.getByWorld(event.getLocation().getWorld()) != null) {
|
||||
if (DGameWorld.getByWorld(event.getLocation().getWorld()) != null) {
|
||||
if (event.getEntity().getItemStack().getType() == Material.SIGN) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -63,8 +63,8 @@ public class EntityListener implements Listener {
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
World world = event.getLocation().getWorld();
|
||||
|
||||
EditWorld editWorld = EditWorld.getByWorld(world);
|
||||
GameWorld gameWorld = GameWorld.getByWorld(world);
|
||||
DEditWorld editWorld = DEditWorld.getByWorld(world);
|
||||
DGameWorld gameWorld = DGameWorld.getByWorld(world);
|
||||
|
||||
if (editWorld != null || gameWorld != null) {
|
||||
switch (event.getSpawnReason()) {
|
||||
@ -83,7 +83,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
if (event.getEntity() instanceof LivingEntity) {
|
||||
LivingEntity entity = event.getEntity();
|
||||
GameWorld gameWorld = GameWorld.getByWorld(world);
|
||||
DGameWorld gameWorld = DGameWorld.getByWorld(world);
|
||||
if (gameWorld != null) {
|
||||
if (gameWorld.isPlaying()) {
|
||||
DMob dMob = DMob.getByEntity(entity);
|
||||
@ -98,7 +98,7 @@ public class EntityListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onDamage(EntityDamageEvent event) {
|
||||
World world = event.getEntity().getWorld();
|
||||
GameWorld gameWorld = GameWorld.getByWorld(world);
|
||||
DGameWorld gameWorld = DGameWorld.getByWorld(world);
|
||||
|
||||
if (gameWorld == null) {
|
||||
return;
|
||||
@ -138,7 +138,7 @@ public class EntityListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
World world = event.getEntity().getWorld();
|
||||
GameWorld gameWorld = GameWorld.getByWorld(world);
|
||||
DGameWorld gameWorld = DGameWorld.getByWorld(world);
|
||||
|
||||
if (gameWorld == null) {
|
||||
return;
|
||||
@ -223,7 +223,7 @@ public class EntityListener implements Listener {
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
World world = event.getEntity().getWorld();
|
||||
|
||||
GameWorld gameWorld = GameWorld.getByWorld(world);
|
||||
DGameWorld gameWorld = DGameWorld.getByWorld(world);
|
||||
if (gameWorld != null) {
|
||||
if (!gameWorld.isPlaying()) {
|
||||
event.setCancelled(true);
|
||||
@ -234,7 +234,7 @@ public class EntityListener implements Listener {
|
||||
// Zombie/skeleton combustion from the sun.
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onCombust(EntityCombustEvent event) {
|
||||
GameWorld gameWorld = GameWorld.getByWorld(event.getEntity().getWorld());
|
||||
DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
|
||||
if (gameWorld != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -243,7 +243,7 @@ public class EntityListener implements Listener {
|
||||
// Allow Other combustion
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onCombustByEntity(EntityCombustByEntityEvent event) {
|
||||
GameWorld gameWorld = GameWorld.getByWorld(event.getEntity().getWorld());
|
||||
DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
|
||||
if (gameWorld != null) {
|
||||
if (event.isCancelled()) {
|
||||
event.setCancelled(false);
|
||||
@ -254,7 +254,7 @@ public class EntityListener implements Listener {
|
||||
// Explosions
|
||||
@EventHandler
|
||||
public void onExplode(EntityExplodeEvent event) {
|
||||
GameWorld gameWorld = GameWorld.getByWorld(event.getEntity().getWorld());
|
||||
DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
|
||||
|
||||
if (gameWorld != null) {
|
||||
if (event.getEntity() instanceof LivingEntity) {
|
@ -19,7 +19,6 @@ package io.github.dre2n.dungeonsxl.listener;
|
||||
import io.github.dre2n.commons.util.guiutil.ButtonClickEvent;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.announcer.Announcer;
|
||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user