mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 21:48:43 +01:00
DungeonsXL Beta 0.15 PR
This commit is contained in:
commit
c750bf68f1
12
README.md
12
README.md
@ -33,6 +33,7 @@ DungeonsXL also provides custom game mechanics to make these worlds interesting.
|
|||||||
* Different game types allow you to use your maps dynamically for different purposes. [Read more...](../../wiki/game-types)
|
* 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)
|
* 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
|
* Great performance due to a custom, asynchronous world loading and creation method and several other performance tweaks
|
||||||
|
* Per dungeon resource packs
|
||||||
* ...and many more!
|
* ...and many more!
|
||||||
|
|
||||||
|
|
||||||
@ -47,10 +48,10 @@ If you want to learn how to use DungeonsXL step by step, please have a look at t
|
|||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
### Server
|
### Server
|
||||||
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. See [here](../../wiki/legacy-support) for detailed information. Some cosmetic features require the Spigot API and will therefore not work with CraftBukkit.
|
DungeonsXL works with 1.7.8 and higher. However, support for 1.11 / 1.10.x / 1.9.x has a higher priority than support for 1.8.x and lower. See [here](../../wiki/legacy-support) for detailed information. 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.
|
Older versions of DungeonsXL support versions since Minecraft 1.3.x, but of course, they are completely unsupported.
|
||||||
* [1.7.8-1.10.2](../../tree/master)
|
* [1.7.8-1.11](../../tree/master)
|
||||||
* [1.7.5](../../tree/50f772d14281bfe278dba2559d1758cc459c1a30)
|
* [1.7.5](../../tree/50f772d14281bfe278dba2559d1758cc459c1a30)
|
||||||
* [1.7.2](../../tree/eccf82b7335dfb0723e3cd37a57df1a968ea7842)
|
* [1.7.2](../../tree/eccf82b7335dfb0723e3cd37a57df1a968ea7842)
|
||||||
* [1.6.4](../../tree/780145cf783ea76fe1bfee04cf89216bd4f92e1d)
|
* [1.6.4](../../tree/780145cf783ea76fe1bfee04cf89216bd4f92e1d)
|
||||||
@ -67,10 +68,13 @@ Building DungeonsXL from source requires [Apache Maven](https://maven.apache.org
|
|||||||
Maven automatically fetches all dependencies and builds DungeonsXL; just run _build.bat_ or enter the command _mvn clean install_.
|
Maven automatically fetches all dependencies and builds DungeonsXL; just run _build.bat_ or enter the command _mvn clean install_.
|
||||||
|
|
||||||
#### BRCommons
|
#### BRCommons
|
||||||
[BRCommons](https://github.com/DRE2N/BRCommons) is a util library for common tasks. DungeonsXL contains BRCommons 1.0.1.
|
[BRCommons](https://github.com/DRE2N/BRCommons) is a util library for common tasks. DungeonsXL contains BRCommons 1.0.2.
|
||||||
|
|
||||||
#### Caliburn API
|
#### Caliburn API
|
||||||
[Caliburn](https://github.com/DRE2N/CaliburnAPI) is an API to read custom items and mobs from config files. DungeonsXL contains Caliburn Beta 0.2.
|
[Caliburn](https://github.com/DRE2N/CaliburnAPI) is an API to read custom items and mobs from config files. DungeonsXL contains Caliburn Beta 0.2.2.
|
||||||
|
|
||||||
|
#### ResourcePackAPI
|
||||||
|
inventivetalent's [ResourcePackAPI](https://www.spigotmc.org/resources/api-resourcepackapi-1-7-1-8-1-9-1-10.2397/) is an API to set the resourcepack of a player. DungeonsXL contains ResourcePackAPI 2.2.1.
|
||||||
|
|
||||||
### Java
|
### Java
|
||||||
Make sure that your server uses Java 7 or higher.
|
Make sure that your server uses Java 7 or higher.
|
||||||
|
@ -8,6 +8,6 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>io.github.dre2n</groupId>
|
<groupId>io.github.dre2n</groupId>
|
||||||
<artifactId>dungeonsxl</artifactId>
|
<artifactId>dungeonsxl</artifactId>
|
||||||
<version>0.14.4</version>
|
<version>0.15</version>
|
||||||
</parent>
|
</parent>
|
||||||
</project>
|
</project>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>io.github.dre2n</groupId>
|
<groupId>io.github.dre2n</groupId>
|
||||||
<artifactId>dungeonsxl</artifactId>
|
<artifactId>dungeonsxl</artifactId>
|
||||||
<version>0.14.4</version>
|
<version>0.15</version>
|
||||||
</parent>
|
</parent>
|
||||||
<build>
|
<build>
|
||||||
<resources>
|
<resources>
|
||||||
@ -40,6 +40,13 @@
|
|||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.github.dre2n</groupId>
|
||||||
|
<artifactId>dungeonsxl-craftbukkit_1_11_R1</artifactId>
|
||||||
|
<version>${parent.version}</version>
|
||||||
|
<type>jar</type>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.github.dre2n</groupId>
|
<groupId>io.github.dre2n</groupId>
|
||||||
<artifactId>dungeonsxl-craftbukkit_1_10_R1</artifactId>
|
<artifactId>dungeonsxl-craftbukkit_1_10_R1</artifactId>
|
||||||
|
@ -39,7 +39,6 @@ import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
|||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPlayers;
|
import io.github.dre2n.dungeonsxl.player.DPlayers;
|
||||||
import io.github.dre2n.dungeonsxl.player.DSavePlayer;
|
|
||||||
import io.github.dre2n.dungeonsxl.requirement.RequirementTypes;
|
import io.github.dre2n.dungeonsxl.requirement.RequirementTypes;
|
||||||
import io.github.dre2n.dungeonsxl.reward.DLootInventory;
|
import io.github.dre2n.dungeonsxl.reward.DLootInventory;
|
||||||
import io.github.dre2n.dungeonsxl.reward.RewardTypes;
|
import io.github.dre2n.dungeonsxl.reward.RewardTypes;
|
||||||
@ -59,21 +58,24 @@ import org.bukkit.event.HandlerList;
|
|||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The main class of DungeonsXL.
|
||||||
|
* It contains several important instances and the actions when the plugin is enabled / disabled.
|
||||||
|
*
|
||||||
* @author Frank Baumann, Tobias Schmitz, Daniel Saukel
|
* @author Frank Baumann, Tobias Schmitz, Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class DungeonsXL extends BRPlugin {
|
public class DungeonsXL extends BRPlugin {
|
||||||
|
|
||||||
private static DungeonsXL instance;
|
private static DungeonsXL instance;
|
||||||
|
|
||||||
public static final String[] EXCLUDED_FILES = {"config.yml", "uid.dat", "DXLData.data"};
|
public static final String[] EXCLUDED_FILES = {"config.yml", "uid.dat", "DXLData.data", "data"};
|
||||||
public static File BACKUPS;
|
public static File BACKUPS;
|
||||||
public static File DUNGEONS;
|
|
||||||
public static File LANGUAGES;
|
public static File LANGUAGES;
|
||||||
public static File MAPS;
|
public static File MAPS;
|
||||||
public static File PLAYERS;
|
public static File PLAYERS;
|
||||||
public static File SCRIPTS;
|
public static File SCRIPTS;
|
||||||
public static File ANNOUNCERS;
|
public static File ANNOUNCERS;
|
||||||
public static File CLASSES;
|
public static File CLASSES;
|
||||||
|
public static File DUNGEONS;
|
||||||
public static File LOOT_TABLES;
|
public static File LOOT_TABLES;
|
||||||
public static File MOBS;
|
public static File MOBS;
|
||||||
public static File SIGNS;
|
public static File SIGNS;
|
||||||
@ -132,6 +134,7 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
super.onEnable();
|
super.onEnable();
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
|
DPermissions.register();
|
||||||
initFolders();
|
initFolders();
|
||||||
loadCore();
|
loadCore();
|
||||||
|
|
||||||
@ -198,11 +201,6 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
BACKUPS.mkdir();
|
BACKUPS.mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
DUNGEONS = new File(getDataFolder(), "dungeons");
|
|
||||||
if (!DUNGEONS.exists()) {
|
|
||||||
DUNGEONS.mkdir();
|
|
||||||
}
|
|
||||||
|
|
||||||
LANGUAGES = new File(getDataFolder(), "languages");
|
LANGUAGES = new File(getDataFolder(), "languages");
|
||||||
if (!LANGUAGES.exists()) {
|
if (!LANGUAGES.exists()) {
|
||||||
LANGUAGES.mkdir();
|
LANGUAGES.mkdir();
|
||||||
@ -233,6 +231,11 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
CLASSES.mkdir();
|
CLASSES.mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DUNGEONS = new File(SCRIPTS, "dungeons");
|
||||||
|
if (!DUNGEONS.exists()) {
|
||||||
|
DUNGEONS.mkdir();
|
||||||
|
}
|
||||||
|
|
||||||
LOOT_TABLES = new File(SCRIPTS, "loottables");
|
LOOT_TABLES = new File(SCRIPTS, "loottables");
|
||||||
if (!LOOT_TABLES.exists()) {
|
if (!LOOT_TABLES.exists()) {
|
||||||
LOOT_TABLES.mkdir();
|
LOOT_TABLES.mkdir();
|
||||||
@ -250,7 +253,9 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadCore() {
|
public void loadCore() {
|
||||||
|
if (Internals.andHigher(Internals.v1_9_R1).contains(compat.getInternals())) {
|
||||||
loadCaliburnAPI();
|
loadCaliburnAPI();
|
||||||
|
}
|
||||||
// Load Language
|
// Load Language
|
||||||
loadMessageConfig(new File(LANGUAGES, "english.yml"));
|
loadMessageConfig(new File(LANGUAGES, "english.yml"));
|
||||||
// Load Config
|
// Load Config
|
||||||
@ -258,13 +263,13 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
loadMainConfig(new File(getDataFolder(), "config.yml"));
|
loadMainConfig(new File(getDataFolder(), "config.yml"));
|
||||||
// Load Language 2
|
// Load Language 2
|
||||||
loadMessageConfig(new File(LANGUAGES, mainConfig.getLanguage() + ".yml"));
|
loadMessageConfig(new File(LANGUAGES, mainConfig.getLanguage() + ".yml"));
|
||||||
DPermissions.register();
|
|
||||||
loadGameTypes();
|
loadGameTypes();
|
||||||
loadRequirementTypes();
|
loadRequirementTypes();
|
||||||
loadRewardTypes();
|
loadRewardTypes();
|
||||||
loadTriggers();
|
loadTriggers();
|
||||||
loadDSigns();
|
loadDSigns();
|
||||||
loadDungeons();
|
loadDWorlds(MAPS);
|
||||||
|
loadDungeons(DUNGEONS);
|
||||||
loadGlobalProtections();
|
loadGlobalProtections();
|
||||||
loadExternalMobProviders();
|
loadExternalMobProviders();
|
||||||
loadDPlayers();
|
loadDPlayers();
|
||||||
@ -273,21 +278,18 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
loadDLootTables(LOOT_TABLES);
|
loadDLootTables(LOOT_TABLES);
|
||||||
loadDMobTypes(MOBS);
|
loadDMobTypes(MOBS);
|
||||||
loadSignScripts(SIGNS);
|
loadSignScripts(SIGNS);
|
||||||
loadDWorlds(MAPS);
|
|
||||||
loadDCommands();
|
loadDCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save and load
|
// Save and load
|
||||||
public void saveData() {
|
public void saveData() {
|
||||||
protections.saveAll();
|
protections.saveAll();
|
||||||
DSavePlayer.save();
|
|
||||||
dWorlds.saveAll();
|
dWorlds.saveAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadData() {
|
public void loadData() {
|
||||||
protections.loadAll();
|
protections.loadAll();
|
||||||
dPlayers.loadAll();
|
dPlayers.loadAll();
|
||||||
DSavePlayer.load();
|
|
||||||
dWorlds.check();
|
dWorlds.check();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,8 +448,8 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
/**
|
/**
|
||||||
* load / reload a new instance of Dungeons
|
* load / reload a new instance of Dungeons
|
||||||
*/
|
*/
|
||||||
public void loadDungeons() {
|
public void loadDungeons(File file) {
|
||||||
dungeons = new Dungeons();
|
dungeons = new Dungeons(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,6 +44,8 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Represents a game announcement.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class Announcer {
|
public class Announcer {
|
||||||
@ -434,7 +436,7 @@ public class Announcer {
|
|||||||
|
|
||||||
boolean full = playerCount >= maxPlayersPerGroup;
|
boolean full = playerCount >= maxPlayersPerGroup;
|
||||||
|
|
||||||
ItemStack button = new ItemStack(Material.WOOL, playerCount, plugin.getMainConfig().getGroupColorPriority().get(groupCount));
|
ItemStack button = new ItemStack(Material.WOOL, playerCount, plugin.getMainConfig().getGroupColorPriority().get(groupCount).getWoolData());
|
||||||
ItemMeta meta = button.getItemMeta();
|
ItemMeta meta = button.getItemMeta();
|
||||||
meta.setDisplayName(name + (full ? ChatColor.DARK_RED : ChatColor.GREEN) + " [" + playerCount + "/" + maxPlayersPerGroup + "]");
|
meta.setDisplayName(name + (full ? ChatColor.DARK_RED : ChatColor.GREEN) + " [" + playerCount + "/" + maxPlayersPerGroup + "]");
|
||||||
meta.setLore(lore);
|
meta.setLore(lore);
|
||||||
|
@ -24,6 +24,8 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Announcer instance manager.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class Announcers {
|
public class Announcers {
|
||||||
|
@ -48,6 +48,8 @@ public class DCommands extends BRCommands {
|
|||||||
public static PlayCommand PLAY = new PlayCommand();
|
public static PlayCommand PLAY = new PlayCommand();
|
||||||
public static PortalCommand PORTAL = new PortalCommand();
|
public static PortalCommand PORTAL = new PortalCommand();
|
||||||
public static ReloadCommand RELOAD = new ReloadCommand();
|
public static ReloadCommand RELOAD = new ReloadCommand();
|
||||||
|
public static ResourcePackCommand RESOURCE_PACK = new ResourcePackCommand();
|
||||||
|
public static RewardsCommand REWARDS = new RewardsCommand();
|
||||||
public static SaveCommand SAVE = new SaveCommand();
|
public static SaveCommand SAVE = new SaveCommand();
|
||||||
public static StatusCommand STATUS = new StatusCommand();
|
public static StatusCommand STATUS = new StatusCommand();
|
||||||
public static TestCommand TEST = new TestCommand();
|
public static TestCommand TEST = new TestCommand();
|
||||||
@ -77,6 +79,8 @@ public class DCommands extends BRCommands {
|
|||||||
PLAY,
|
PLAY,
|
||||||
PORTAL,
|
PORTAL,
|
||||||
RELOAD,
|
RELOAD,
|
||||||
|
RESOURCE_PACK,
|
||||||
|
REWARDS,
|
||||||
SAVE,
|
SAVE,
|
||||||
STATUS,
|
STATUS,
|
||||||
TEST,
|
TEST,
|
||||||
|
@ -28,8 +28,9 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Frank Baumann, Daniel Saukel
|
* @author Frank Baumann, Daniel Saukel
|
||||||
* @deprecated
|
* @deprecated Use BreakCommand instead.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class DeletePortalCommand extends BRCommand {
|
public class DeletePortalCommand extends BRCommand {
|
||||||
|
|
||||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
@ -63,15 +63,15 @@ public class EditCommand extends BRCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEditWorld editWorld = resource.instantiateAsEditWorld();
|
if (!resource.isInvitedPlayer(player) && !DPermissions.hasPermission(player, DPermissions.EDIT)) {
|
||||||
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());
|
MessageUtil.sendMessage(player, DMessages.ERROR_NO_PERMISSIONS.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEditWorld editWorld = resource.instantiateAsEditWorld();
|
||||||
|
DGroup dGroup = DGroup.getByPlayer(player);
|
||||||
|
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||||
|
|
||||||
if (dPlayer instanceof DInstancePlayer) {
|
if (dPlayer instanceof DInstancePlayer) {
|
||||||
MessageUtil.sendMessage(player, DMessages.ERROR_LEAVE_DUNGEON.getMessage());
|
MessageUtil.sendMessage(player, DMessages.ERROR_LEAVE_DUNGEON.getMessage());
|
||||||
return;
|
return;
|
||||||
|
@ -24,6 +24,7 @@ import io.github.dre2n.dungeonsxl.game.Game;
|
|||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -51,6 +52,13 @@ public class EnterCommand extends BRCommand {
|
|||||||
DGroup joining = args.length == 3 ? DGroup.getByName(args[1]) : DGroup.getByPlayer(captain);
|
DGroup joining = args.length == 3 ? DGroup.getByName(args[1]) : DGroup.getByPlayer(captain);
|
||||||
DGroup target = DGroup.getByName(targetName);
|
DGroup target = DGroup.getByName(targetName);
|
||||||
|
|
||||||
|
if (target == null) {
|
||||||
|
Player targetPlayer = Bukkit.getPlayer(targetName);
|
||||||
|
if (targetPlayer != null) {
|
||||||
|
target = DGroup.getByPlayer(targetPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_GROUP.getMessage(targetName));
|
MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_GROUP.getMessage(targetName));
|
||||||
return;
|
return;
|
||||||
@ -78,7 +86,7 @@ public class EnterCommand extends BRCommand {
|
|||||||
|
|
||||||
joining.setGameWorld(game.getWorld());
|
joining.setGameWorld(game.getWorld());
|
||||||
game.addDGroup(joining);
|
game.addDGroup(joining);
|
||||||
joining.sendMessage(DMessages.CMD_ENTER_SUCCESS.getMessage(joining.getName(), targetName));
|
joining.sendMessage(DMessages.CMD_ENTER_SUCCESS.getMessage(joining.getName(), target.getName()));
|
||||||
|
|
||||||
for (Player player : joining.getPlayers()) {
|
for (Player player : joining.getPlayers()) {
|
||||||
DGamePlayer.create(player, game.getWorld(), true);
|
DGamePlayer.create(player, game.getWorld(), true);
|
||||||
|
@ -26,6 +26,7 @@ import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
|
|||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -99,7 +100,12 @@ public class GroupCommand extends BRCommand {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (args[1].equalsIgnoreCase("show") && DPermissions.hasPermission(sender, DPermissions.GROUP_ADMIN)) {
|
} else if (args[1].equalsIgnoreCase("show") && DPermissions.hasPermission(sender, DPermissions.GROUP_ADMIN)) {
|
||||||
showGroup(DGroup.getByName(args[2]));
|
DGroup group = DGroup.getByName(args[2]);
|
||||||
|
Player player = Bukkit.getPlayer(args[2]);
|
||||||
|
if (group == null && player != null) {
|
||||||
|
group = DGroup.getByPlayer(player);
|
||||||
|
}
|
||||||
|
showGroup(group);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,6 +263,8 @@ public class GroupCommand extends BRCommand {
|
|||||||
MessageUtil.sendMessage(sender, "&bPlayers: &e" + players);
|
MessageUtil.sendMessage(sender, "&bPlayers: &e" + players);
|
||||||
MessageUtil.sendMessage(sender, "&bDungeon: &e" + (dGroup.getDungeonName() == null ? "N/A" : dGroup.getDungeonName()));
|
MessageUtil.sendMessage(sender, "&bDungeon: &e" + (dGroup.getDungeonName() == null ? "N/A" : dGroup.getDungeonName()));
|
||||||
MessageUtil.sendMessage(sender, "&bMap: &e" + (dGroup.getMapName() == null ? "N/A" : dGroup.getMapName()));
|
MessageUtil.sendMessage(sender, "&bMap: &e" + (dGroup.getMapName() == null ? "N/A" : dGroup.getMapName()));
|
||||||
|
MessageUtil.sendMessage(sender, "&bScore: &e" + (dGroup.getScore() == 0 ? "N/A" : dGroup.getScore()));
|
||||||
|
MessageUtil.sendMessage(sender, "&bLives: &e" + (dGroup.getLives() == -1 ? "N/A" : dGroup.getLives()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showHelp(String page) {
|
public void showHelp(String page) {
|
||||||
|
@ -46,10 +46,11 @@ public class InviteCommand extends BRCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[2]);
|
DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[2]);
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[2]);
|
OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]);
|
||||||
|
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
|
resource.addInvitedPlayer(player);
|
||||||
MessageUtil.sendMessage(sender, DMessages.CMD_INVITE_SUCCESS.getMessage(args[1], args[2]));
|
MessageUtil.sendMessage(sender, DMessages.CMD_INVITE_SUCCESS.getMessage(args[1], args[2]));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -20,14 +20,15 @@ import io.github.dre2n.commons.command.BRCommand;
|
|||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEscapeEvent;
|
|
||||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerLeaveDGroupEvent;
|
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerLeaveDGroupEvent;
|
||||||
|
import io.github.dre2n.dungeonsxl.event.dplayer.instance.game.DGamePlayerEscapeEvent;
|
||||||
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.player.DEditPlayer;
|
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.DGlobalPlayer;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -50,15 +51,13 @@ public class LeaveCommand extends BRCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player);
|
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||||
|
Game game = Game.getByPlayer(player);
|
||||||
|
|
||||||
if (DGameWorld.getByWorld(player.getWorld()) != null) {
|
if (game != null && game.isTutorial()) {
|
||||||
if (DGameWorld.getByWorld(player.getWorld()).isTutorial()) {
|
|
||||||
MessageUtil.sendMessage(player, DMessages.ERROR_NO_LEAVE_IN_TUTORIAL.getMessage());
|
MessageUtil.sendMessage(player, DMessages.ERROR_NO_LEAVE_IN_TUTORIAL.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
DGroup dGroup = DGroup.getByPlayer(player);
|
DGroup dGroup = DGroup.getByPlayer(player);
|
||||||
|
|
||||||
@ -67,12 +66,17 @@ public class LeaveCommand extends BRCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPlayerEscapeEvent dPlayerEscapeEvent = new DPlayerEscapeEvent(dPlayer);
|
if (dPlayer instanceof DGamePlayer) {
|
||||||
|
DGamePlayerEscapeEvent dPlayerEscapeEvent = new DGamePlayerEscapeEvent((DGamePlayer) dPlayer);
|
||||||
plugin.getServer().getPluginManager().callEvent(dPlayerEscapeEvent);
|
plugin.getServer().getPluginManager().callEvent(dPlayerEscapeEvent);
|
||||||
|
if (dPlayerEscapeEvent.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DPlayerLeaveDGroupEvent dPlayerLeaveDGroupEvent = new DPlayerLeaveDGroupEvent(dPlayer, dGroup);
|
DPlayerLeaveDGroupEvent dPlayerLeaveDGroupEvent = new DPlayerLeaveDGroupEvent(dPlayer, dGroup);
|
||||||
plugin.getServer().getPluginManager().callEvent(dPlayerLeaveDGroupEvent);
|
plugin.getServer().getPluginManager().callEvent(dPlayerLeaveDGroupEvent);
|
||||||
|
if (dPlayerLeaveDGroupEvent.isCancelled()) {
|
||||||
if (dPlayerEscapeEvent.isCancelled() || dPlayerLeaveDGroupEvent.isCancelled()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
|||||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||||
import io.github.dre2n.dungeonsxl.world.DWorlds;
|
import io.github.dre2n.dungeonsxl.world.DWorlds;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -64,10 +65,10 @@ public class ListCommand extends BRCommand {
|
|||||||
}
|
}
|
||||||
ArrayList<String> loadedList = new ArrayList<>();
|
ArrayList<String> loadedList = new ArrayList<>();
|
||||||
for (DEditWorld editWorld : worlds.getEditWorlds()) {
|
for (DEditWorld editWorld : worlds.getEditWorlds()) {
|
||||||
loadedList.add(editWorld.getWorld().getWorldFolder().getName());
|
loadedList.add(editWorld.getWorld().getWorldFolder().getName() + " / " + editWorld.getName());
|
||||||
}
|
}
|
||||||
for (DGameWorld gameWorld : worlds.getGameWorlds()) {
|
for (DGameWorld gameWorld : worlds.getGameWorlds()) {
|
||||||
loadedList.add(gameWorld.getWorld().getWorldFolder().getName());
|
loadedList.add(gameWorld.getWorld().getWorldFolder().getName() + " / " + gameWorld.getName());
|
||||||
}
|
}
|
||||||
ArrayList<String> toSend = new ArrayList<>();
|
ArrayList<String> toSend = new ArrayList<>();
|
||||||
|
|
||||||
@ -132,7 +133,10 @@ public class ListCommand extends BRCommand {
|
|||||||
for (String map : toSend) {
|
for (String map : toSend) {
|
||||||
boolean invited = false;
|
boolean invited = false;
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
invited = worlds.getResourceByName(map).isInvitedPlayer((Player) sender);
|
DResourceWorld resource = worlds.getResourceByName(map);
|
||||||
|
if (resource != null) {
|
||||||
|
invited = resource.isInvitedPlayer((Player) sender);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageUtil.sendMessage(sender, "&b" + map + "&7 | &e" + invited);
|
MessageUtil.sendMessage(sender, "&b" + map + "&7 | &e" + invited);
|
||||||
|
@ -21,6 +21,7 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
|||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
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.player.DPermissions;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -61,11 +62,15 @@ public class LivesCommand extends BRCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
|
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
|
||||||
|
DGroup dGroup = dPlayer != null ? dPlayer.getDGroup() : DGroup.getByName(args[1]);
|
||||||
if (dPlayer != null) {
|
if (dPlayer != null) {
|
||||||
MessageUtil.sendMessage(player, DMessages.CMD_LIVES.getMessage(player.getName(), String.valueOf(dPlayer.getLives())));
|
MessageUtil.sendMessage(sender, DMessages.CMD_LIVES_PLAYER.getMessage(dPlayer.getName(), String.valueOf(dPlayer.getLives() == -1 ? "UNLIMITED" : dPlayer.getLives())));
|
||||||
|
|
||||||
|
} else if (dGroup != null) {
|
||||||
|
MessageUtil.sendMessage(sender, DMessages.CMD_LIVES_GROUP.getMessage(dGroup.getName(), String.valueOf(dGroup.getLives() == -1 ? "UNLIMITED" : dPlayer.getLives())));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MessageUtil.sendMessage(player, DMessages.ERROR_NOT_IN_DUNGEON.getMessage());
|
MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_PLAYER.getMessage(args[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public class MsgCommand extends BRCommand {
|
|||||||
try {
|
try {
|
||||||
int id = Integer.parseInt(args[1]);
|
int id = Integer.parseInt(args[1]);
|
||||||
|
|
||||||
WorldConfig config = editWorld.getResource().getConfig();
|
WorldConfig config = editWorld.getResource().getConfig(true);
|
||||||
|
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
String msg = config.getMessage(id);
|
String msg = config.getMessage(id);
|
||||||
|
@ -20,12 +20,13 @@ import io.github.dre2n.commons.command.BRCommand;
|
|||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
|
|
||||||
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
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.DGroup;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -49,9 +50,9 @@ public class PlayCommand extends BRCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
|
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||||
|
|
||||||
if (dPlayer != null) {
|
if (dPlayer instanceof DInstancePlayer) {
|
||||||
MessageUtil.sendMessage(player, DMessages.ERROR_LEAVE_DUNGEON.getMessage());
|
MessageUtil.sendMessage(player, DMessages.ERROR_LEAVE_DUNGEON.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -70,7 +71,7 @@ public class PlayCommand extends BRCommand {
|
|||||||
mapName = identifier;
|
mapName = identifier;
|
||||||
if (args[1].equalsIgnoreCase("dungeon") || args[1].equalsIgnoreCase("d")) {
|
if (args[1].equalsIgnoreCase("dungeon") || args[1].equalsIgnoreCase("d")) {
|
||||||
Dungeon dungeon = plugin.getDungeons().getByName(args[2]);
|
Dungeon dungeon = plugin.getDungeons().getByName(args[2]);
|
||||||
if (dungeon != null) {
|
if (dungeon != null && dungeon.isMultiFloor()) {
|
||||||
multiFloor = true;
|
multiFloor = true;
|
||||||
mapName = dungeon.getConfig().getStartFloor().getName();
|
mapName = dungeon.getConfig().getStartFloor().getName();
|
||||||
} else {
|
} else {
|
||||||
@ -96,20 +97,9 @@ public class PlayCommand extends BRCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dGroup.getMapName() == null) {
|
if (dGroup.getMapName() == null) {
|
||||||
if (!multiFloor) {
|
dGroup.setMapName(mapName);
|
||||||
dGroup.setMapName(identifier);
|
if (multiFloor) {
|
||||||
|
|
||||||
} else {
|
|
||||||
dGroup.setDungeonName(identifier);
|
dGroup.setDungeonName(identifier);
|
||||||
Dungeon dungeon = plugin.getDungeons().getByName(identifier);
|
|
||||||
|
|
||||||
if (dungeon != null) {
|
|
||||||
DungeonConfig config = dungeon.getConfig();
|
|
||||||
|
|
||||||
if (config != null) {
|
|
||||||
dGroup.setMapName(config.getStartFloor().getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -134,11 +124,11 @@ public class PlayCommand extends BRCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dGroup.getGameWorld() == null) {
|
if (dGroup.getGameWorld() == null) {
|
||||||
new Game(dGroup, dGroup.getMapName());
|
new Game(dGroup, mapName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dGroup.getGameWorld() == null) {
|
if (dGroup.getGameWorld() == null) {
|
||||||
MessageUtil.sendMessage(player, DMessages.ERROR_NOT_SAVED.getMessage(DGroup.getByPlayer(player).getMapName()));
|
MessageUtil.sendMessage(player, DMessages.ERROR_NOT_SAVED.getMessage(mapName));
|
||||||
dGroup.delete();
|
dGroup.delete();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public class PortalCommand extends BRCommand {
|
|||||||
public PortalCommand() {
|
public PortalCommand() {
|
||||||
setCommand("portal");
|
setCommand("portal");
|
||||||
setMinArgs(0);
|
setMinArgs(0);
|
||||||
setMaxArgs(0);
|
setMaxArgs(1);
|
||||||
setHelp(DMessages.HELP_CMD_PORTAL.getMessage());
|
setHelp(DMessages.HELP_CMD_PORTAL.getMessage());
|
||||||
setPermission(DPermissions.PORTAL.getNode());
|
setPermission(DPermissions.PORTAL.getNode());
|
||||||
setPlayerCommand(true);
|
setPlayerCommand(true);
|
||||||
@ -55,10 +55,20 @@ public class PortalCommand extends BRCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Material material = null;
|
||||||
|
|
||||||
|
if (args.length == 2) {
|
||||||
|
material = Material.matchMaterial(args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (material == null) {
|
||||||
|
material = Material.PORTAL;
|
||||||
|
}
|
||||||
|
|
||||||
DPortal dPortal = dGlobalPlayer.getPortal();
|
DPortal dPortal = dGlobalPlayer.getPortal();
|
||||||
|
|
||||||
if (dPortal == null) {
|
if (dPortal == null) {
|
||||||
dPortal = new DPortal(plugin.getGlobalProtections().generateId(DPortal.class, player.getWorld()), player.getWorld(), false);
|
dPortal = new DPortal(plugin.getGlobalProtections().generateId(DPortal.class, player.getWorld()), player.getWorld(), material, false);
|
||||||
dGlobalPlayer.setCreatingPortal(dPortal);
|
dGlobalPlayer.setCreatingPortal(dPortal);
|
||||||
dPortal.setWorld(player.getWorld());
|
dPortal.setWorld(player.getWorld());
|
||||||
player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD));
|
player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD));
|
||||||
|
@ -22,8 +22,8 @@ import io.github.dre2n.commons.compatibility.Internals;
|
|||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
|
import io.github.dre2n.dungeonsxl.event.DataReloadEvent;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
import java.io.File;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
@ -47,7 +47,13 @@ public class ReloadCommand extends BRCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
PluginManager plugins = Bukkit.getServer().getPluginManager();
|
PluginManager plugins = Bukkit.getPluginManager();
|
||||||
|
|
||||||
|
DataReloadEvent event = new DataReloadEvent();
|
||||||
|
plugins.callEvent(event);
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int maps = DungeonsXL.MAPS.listFiles().length;
|
int maps = DungeonsXL.MAPS.listFiles().length;
|
||||||
int dungeons = DungeonsXL.DUNGEONS.listFiles().length;
|
int dungeons = DungeonsXL.DUNGEONS.listFiles().length;
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* 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 io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.inventivetalent.rpapi.ResourcePackAPI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class ResourcePackCommand extends BRCommand {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
|
public ResourcePackCommand() {
|
||||||
|
setCommand("resourcepack");
|
||||||
|
setMinArgs(1);
|
||||||
|
setMaxArgs(1);
|
||||||
|
setHelp(DMessages.HELP_CMD_RESOURCE_PACK.getMessage());
|
||||||
|
setPermission(DPermissions.RESOURCE_PACK.getNode());
|
||||||
|
setPlayerCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (args[1].equalsIgnoreCase("reset")) {
|
||||||
|
// Placeholder to reset to default
|
||||||
|
ResourcePackAPI.setResourcepack(player, "http://google.com");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String url = (String) plugin.getMainConfig().getResourcePacks().get(args[1]);
|
||||||
|
if (url == null) {
|
||||||
|
MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_RESOURCE_PACK.getMessage(args[1]));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ResourcePackAPI.setResourcepack(player, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* 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 io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
|
import io.github.dre2n.dungeonsxl.reward.DLootInventory;
|
||||||
|
import java.util.List;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class RewardsCommand extends BRCommand {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
|
public RewardsCommand() {
|
||||||
|
setCommand("rewards");
|
||||||
|
setMinArgs(0);
|
||||||
|
setMaxArgs(0);
|
||||||
|
setHelp(DMessages.HELP_CMD_REWARDS.getMessage());
|
||||||
|
setPermission(DPermissions.REWARDS.getNode());
|
||||||
|
setPlayerCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
DGlobalPlayer dGlobalPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||||
|
|
||||||
|
if (!dGlobalPlayer.hasRewardItemsLeft()) {
|
||||||
|
MessageUtil.sendMessage(player, DMessages.ERROR_NO_REWARDS_LEFT.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ItemStack> rewardItems = dGlobalPlayer.getRewardItems();
|
||||||
|
List<ItemStack> rewards = rewardItems.subList(0, rewardItems.size() > 54 ? 53 : rewardItems.size());
|
||||||
|
new DLootInventory(player, rewards.toArray(new ItemStack[54]));
|
||||||
|
rewardItems.removeAll(rewards);
|
||||||
|
if (rewardItems.isEmpty()) {
|
||||||
|
dGlobalPlayer.setRewardItems(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -48,6 +48,7 @@ public class UninviteCommand extends BRCommand {
|
|||||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[2]);
|
DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[2]);
|
||||||
if (resource == null) {
|
if (resource == null) {
|
||||||
MessageUtil.sendMessage(sender, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(args[2]));
|
MessageUtil.sendMessage(sender, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(args[2]));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]);
|
OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]);
|
||||||
|
@ -24,6 +24,9 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* An enumeration of all messages.
|
||||||
|
* The values are fetched from the language file.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public enum DMessages implements Messages {
|
public enum DMessages implements Messages {
|
||||||
@ -41,7 +44,8 @@ public enum DMessages implements Messages {
|
|||||||
CMD_INVITE_SUCCESS("Cmd_Invite_Success", "&6Player &4&v1&6 was successfully invited to edit the map &4&v2&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_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_LEAVE_SUCCESS("Cmd_Leave_Success", "&6You have successfully left your group!"),
|
||||||
CMD_LIVES("Cmd_Lives", "&4&v1&6 has &4&v2 &6lives left."),
|
CMD_LIVES_GROUP("Cmd_Lives_Group", "&4&v1 &6have &4&v2 &6lives left."),
|
||||||
|
CMD_LIVES_PLAYER("Cmd_Lives_Player", "&4&v1 &6has &4&v2 &6lives left."),
|
||||||
CMD_MAIN_WELCOME("Cmd_Main_Welcome", "&7Welcome to &4Dungeons&fXL"),
|
CMD_MAIN_WELCOME("Cmd_Main_Welcome", "&7Welcome to &4Dungeons&fXL"),
|
||||||
CMD_MAIN_LOADED("Cmd_Main_Loaded", "&eMaps: &o[&v1] &eDungeons: &o[&v2] &eLoaded: &o[&v3] &ePlayers: &o[&v4]"),
|
CMD_MAIN_LOADED("Cmd_Main_Loaded", "&eMaps: &o[&v1] &eDungeons: &o[&v2] &eLoaded: &o[&v3] &ePlayers: &o[&v4]"),
|
||||||
CMD_MAIN_COMPATIBILITY("Cmd_Main_Compatibility", "&eInternals: &o[&v1] &eVault: &o[&v2] &eItemsXL: &o[&v3]"),
|
CMD_MAIN_COMPATIBILITY("Cmd_Main_Compatibility", "&eInternals: &o[&v1] &eVault: &o[&v2] &eItemsXL: &o[&v3]"),
|
||||||
@ -50,7 +54,7 @@ public enum DMessages implements Messages {
|
|||||||
CMD_MSG_UPDATED("Cmd_Msg_Updated", "&6Messages (&4&v1&6) updated!"),
|
CMD_MSG_UPDATED("Cmd_Msg_Updated", "&6Messages (&4&v1&6) updated!"),
|
||||||
CMD_RELOAD_DONE("Cmd_Reload_Done", "&7Successfully reloaded DungeonsXL."),
|
CMD_RELOAD_DONE("Cmd_Reload_Done", "&7Successfully reloaded DungeonsXL."),
|
||||||
CMD_SAVE_SUCCESS("Cmd_Save_Success", "&6Map saved!"),
|
CMD_SAVE_SUCCESS("Cmd_Save_Success", "&6Map saved!"),
|
||||||
CMD_UNINVITE_SUCCESS("Cmd_Uninvite_Success", "&4&v1&6 was successfully uninvited to edit the map &4&v1&6!"),
|
CMD_UNINVITE_SUCCESS("Cmd_Uninvite_Success", "&4&v1&6's permission to edit the map &4&v2&6 has been removed successfully."),
|
||||||
ERROR_BED("Error_Bed", "&4You cannot use a bed while in a dungeon!"),
|
ERROR_BED("Error_Bed", "&4You cannot use a bed while in a dungeon!"),
|
||||||
ERROR_CHEST_IS_OPENED("Error_ChestIsOpened", "&4This chest has already been opened."),
|
ERROR_CHEST_IS_OPENED("Error_ChestIsOpened", "&4This chest has already been opened."),
|
||||||
ERROR_CMD("Error_Cmd", "&4Commands are not allowed while in a dungeon!"),
|
ERROR_CMD("Error_Cmd", "&4Commands are not allowed while in a dungeon!"),
|
||||||
@ -74,22 +78,27 @@ public enum DMessages implements Messages {
|
|||||||
ERROR_NO_CONSOLE_COMMAND("Error_NoConsoleCommand", "&6/dxl &v1&4 cannot be executed as console!"),
|
ERROR_NO_CONSOLE_COMMAND("Error_NoConsoleCommand", "&6/dxl &v1&4 cannot be executed as console!"),
|
||||||
ERROR_NO_GAME("Error_NoGame", "&4You currently do not take part in a game."),
|
ERROR_NO_GAME("Error_NoGame", "&4You currently do not take part in a game."),
|
||||||
ERROR_NO_LEAVE_IN_TUTORIAL("Error_NoLeaveInTutorial", "&4You cannot use this command in the tutorial!"),
|
ERROR_NO_LEAVE_IN_TUTORIAL("Error_NoLeaveInTutorial", "&4You cannot use this command in the tutorial!"),
|
||||||
ERROR_NO_PERMISSIONS("Error_NoPermissions", "&4You have no permission to do this!"),
|
ERROR_NO_PERMISSIONS("Error_NoPermissions", "&4You do not have permission to do this!"),
|
||||||
ERROR_NO_PLAYER_COMMAND("Error_NoPlayerCommand", "&6/dxl &v1&4 cannot be executed as player!"),
|
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_PROTECTED_BLOCK("Error_NoDXLBlock", "&4This is not a block protected by DungeonsXL!"),
|
||||||
|
ERROR_NO_REWARDS_LEFT("Error_NoRewardsLeft", "&4You do not have any item rewards left."),
|
||||||
ERROR_NO_SUCH_GROUP("Error_NoSuchGroup", "&4The group &6&v1&4 does not exist!"),
|
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_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_NO_SUCH_PLAYER("Error_NoSuchPlayer", "&4The player &6&v1&4 does not exist!"),
|
||||||
|
ERROR_NO_SUCH_RESOURCE_PACK("Error_NoSuchResourcePack", "&4The resource pack &6&v1 &4is not registered in the main configuration file!"),
|
||||||
|
ERROR_NO_SUCH_SHOP("Error_NoSuchShop", "&4Shop &v1 &4not found..."),
|
||||||
ERROR_NOT_CAPTAIN("Error_NotCaptain", "&4You are not the captain of your group!"),
|
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!"),
|
ERROR_NOT_IN_DUNGEON("Error_NotInDungeon", "&4You are not in a dungeon!"),
|
||||||
ERROR_NOT_IN_GAME("Error_NotInGame", "&4The group &6&v1&4 is not member of a game."),
|
ERROR_NOT_IN_GAME("Error_NotInGame", "&4The group &6&v1&4 is not member of a game."),
|
||||||
ERROR_NOT_IN_GROUP("Error_NotInGroup", "&4The player &6&v1&4 is not member of the group &6&v2&v4."),
|
ERROR_NOT_IN_GROUP("Error_NotInGroup", "&4The player &6&v1&4 is not member of the group &6&v2&v4."),
|
||||||
ERROR_NOT_INVITED("Error_NotInvited", "&4You are not invited to the group &6&v1&4."),
|
ERROR_NOT_INVITED("Error_NotInvited", "&4You are not invited to the group &6&v1&4."),
|
||||||
ERROR_NOT_SAVED("Error_NotSaved", "&4The map &6&v1&4 has not been saved to the &6DungeonsXL/maps/ &4folder yet!"),
|
ERROR_NOT_SAVED("Error_NotSaved", "&4The map &6&v1&4 has not been saved to the &6DungeonsXL/maps/ &4folder yet!"),
|
||||||
|
ERROR_BLOCK_OWN_TEAM("Error_BlockOwnTeam", "&4This block belongs to your own group."),
|
||||||
ERROR_READY("Error_Ready", "&4Choose your class first!"),
|
ERROR_READY("Error_Ready", "&4Choose your class first!"),
|
||||||
ERROR_REQUIREMENTS("Error_Requirements", "&4You don't fulfill the requirements for this dungeon!"),
|
ERROR_REQUIREMENTS("Error_Requirements", "&4You don't fulfill the requirements for this dungeon!"),
|
||||||
ERROR_SIGN_WRONG_FORMAT("Error_SignWrongFormat", "&4The sign is not written correctly!"),
|
ERROR_SIGN_WRONG_FORMAT("Error_SignWrongFormat", "&4The sign is not written correctly!"),
|
||||||
ERROR_TOO_MANY_INSTANCES("Error_TooManyInstances", "&4There are currently too many maps instantiated. Try it again in a few minutes!"),
|
ERROR_TOO_MANY_INSTANCES("Error_TooManyInstances", "&4There are currently too many maps instantiated. Try it again in a few minutes!"),
|
||||||
|
ERROR_TOO_MANY_REWARDS("Error_TooManyRewards", "&6You won too many rewards to show all of them in one inventory. Use &4/dxl rewards &6to receive the other ones."),
|
||||||
ERROR_TOO_MANY_TUTORIALS("Error_TooManyTutorials", "&4There are currently too many tutorials running. Try it again in a few minutes!"),
|
ERROR_TOO_MANY_TUTORIALS("Error_TooManyTutorials", "&4There are currently too many tutorials running. Try it again in a few minutes!"),
|
||||||
ERROR_TUTORIAL_NOT_EXIST("Error_TutorialNotExist", "&4Tutorial dungeon does not exist!"),
|
ERROR_TUTORIAL_NOT_EXIST("Error_TutorialNotExist", "&4Tutorial dungeon does not exist!"),
|
||||||
HELP_CMD_BREAK("Help_Cmd_Break", "/dxl break - Break a block protected by DungeonsXL"),
|
HELP_CMD_BREAK("Help_Cmd_Break", "/dxl break - Break a block protected by DungeonsXL"),
|
||||||
@ -119,39 +128,59 @@ public enum DMessages implements Messages {
|
|||||||
HELP_CMD_MAIN("Help_Cmd_Main", "/dxl - General status information"),
|
HELP_CMD_MAIN("Help_Cmd_Main", "/dxl - General status information"),
|
||||||
HELP_CMD_MSG("Help_Cmd_Msg", "/dxl msg [id] '[msg]' - Show or edit a message"),
|
HELP_CMD_MSG("Help_Cmd_Msg", "/dxl msg [id] '[msg]' - Show or edit a message"),
|
||||||
HELP_CMD_PLAY("Help_Cmd_Play", "/dxl play ([dungeon|map]) [name] - Allows the player to play a dungeon without a portal"),
|
HELP_CMD_PLAY("Help_Cmd_Play", "/dxl play ([dungeon|map]) [name] - Allows the player to play a dungeon without a portal"),
|
||||||
HELP_CMD_PORTAL("Help_Cmd_Portal", "/dxl portal - Creates a portal that leads into a dungeon"),
|
HELP_CMD_PORTAL("Help_Cmd_Portal", "/dxl portal ([material=portal])- Creates a portal that leads into a dungeon"),
|
||||||
HELP_CMD_RELOAD("Help_Cmd_Reload", "/dxl reload - Reloads the plugin"),
|
HELP_CMD_RELOAD("Help_Cmd_Reload", "/dxl reload - Reloads the plugin"),
|
||||||
|
HELP_CMD_REWARDS("Help_Cmd_Rewards", "/dxl rewards - Gives all left item rewards to the player"),
|
||||||
|
HELP_CMD_RESOURCE_PACK("Help_Cmd_ResourcePack", "/dxl resourcepack [ID] - Downloads a resourcepack registered in the main configuration file; use 'reset' to reset"),
|
||||||
HELP_CMD_SAVE("Help_Cmd_Save", "/dxl save - Saves the current dungeon"),
|
HELP_CMD_SAVE("Help_Cmd_Save", "/dxl save - Saves the current dungeon"),
|
||||||
HELP_CMD_STATUS("Help_Cmd_Status", "/dxl status - Shows the technical status of DungeonsXL"),
|
HELP_CMD_STATUS("Help_Cmd_Status", "/dxl status - Shows the technical status of DungeonsXL"),
|
||||||
HELP_CMD_SETTINGS("Help_Cmd_Settings", "/dxl settings ([edit|global|player])- Opens the settings menu"),
|
HELP_CMD_SETTINGS("Help_Cmd_Settings", "/dxl settings ([edit|global|player])- Opens the settings menu"),
|
||||||
HELP_CMD_TEST("Help_Cmd_Test", "/dxl test - Starts the game in test mode"),
|
HELP_CMD_TEST("Help_Cmd_Test", "/dxl test - Starts the game in test mode"),
|
||||||
HELP_CMD_UNINVITE("Help_Cmd_Uninvite", "/dxl uninvite [player] [dungeon] - Uninvite a player to edit a dungeon"),
|
HELP_CMD_UNINVITE("Help_Cmd_Uninvite", "/dxl uninvite [player] [dungeon] - Uninvite a player to edit a dungeon"),
|
||||||
|
GROUP_BED_DESTROYED("Group_BedDestroyed", "&6The bed of the group &4&v1 &6has been destroyed by &4&v2&6!"),
|
||||||
|
GROUP_CONGRATS("Group_Congrats", "&6Congratulations!"),
|
||||||
|
GROUP_CONGRATS_SUB("Group_CongratsSub", "&l&4Your group &v1 &4won the match!"),
|
||||||
GROUP_CREATED("Group_Created", "&4&v1&6 created the group &4&v2&6!"),
|
GROUP_CREATED("Group_Created", "&4&v1&6 created the group &4&v2&6!"),
|
||||||
|
GROUP_DEATH("Group_Death", "&4&v1 &6died. &4&v2 have &4&v3 &6lives left."),
|
||||||
|
GROUP_DEATH_KICK("Group_DeathKick", "&4&v1 &6was kicked because &4&v2 &6have no lives left."),
|
||||||
|
GROUP_DEFEATED("Group_Defeated", "&4The group &4v1 &6is defeated because it lost its last score point."),
|
||||||
GROUP_DISBANDED("Group_Disbanded", "&4&v1&6 disbanded the group &4&v2&6."),
|
GROUP_DISBANDED("Group_Disbanded", "&4&v1&6 disbanded the group &4&v2&6."),
|
||||||
|
GROUP_FLAG_CAPTURED("Group_FlagCaptured", "&4&v1&6 has captured the flag of the group &4&v2&6!"),
|
||||||
|
GROUP_FLAG_LOST("Group_FlagLost", "&4&v1&6 died and lost &4&v2&6's flag."),
|
||||||
|
GROUP_FLAG_STEALING("Group_FlagStealing", "&4&v1&6 is stealing the flag of the group &4&v2&6!"),
|
||||||
GROUP_INVITED_PLAYER("Group_InvitedPlayer", "&4&v1&6 invited the player &4&v2&6 to the group &4&v3&6."),
|
GROUP_INVITED_PLAYER("Group_InvitedPlayer", "&4&v1&6 invited the player &4&v2&6 to the group &4&v3&6."),
|
||||||
GROUP_JOINED_GAME("Group_JoinedGame", "&6Your group successfully joined the game."),
|
GROUP_JOINED_GAME("Group_JoinedGame", "&6Your group successfully joined the game."),
|
||||||
|
GROUP_KILLED("Group_Killed", "&4&v1 &6was killed by &4&v2&6. &4&v3&6 have &4&v4 &6lives left."),
|
||||||
|
GROUP_KILLED_KICK("Group_KilledKick", "&4&v1&6 was killed by &4&v2&6. &4&v3 have no lives left."),
|
||||||
|
GROUP_LIVES_ADDED("Group_LivesAdded", "&6Your group received a bonus of &4&v1&6 lives."),
|
||||||
|
GROUP_LIVES_REMOVED("Group_LivesRemoved", "&6Your group lost &4&v1&6 lives!"),
|
||||||
GROUP_UNINVITED_PLAYER("Group_UninvitedPlayer", "&4&v1&6 took back the invitation for &4&v2&6 to the group &4&v3&6."),
|
GROUP_UNINVITED_PLAYER("Group_UninvitedPlayer", "&4&v1&6 took back the invitation for &4&v2&6 to the group &4&v3&6."),
|
||||||
GROUP_KICKED_PLAYER("Group_KickedPlayer", "&4&v1&6 kicked the player &4&v2&6 from the group &4&v3&6."),
|
GROUP_KICKED_PLAYER("Group_KickedPlayer", "&4&v1&6 kicked the player &4&v2&6 from the group &4&v3&6."),
|
||||||
GROUP_PLAYER_JOINED("Group_PlayerJoined", "&6Player &4&v1&6 has joined the group!"),
|
GROUP_PLAYER_JOINED("Group_PlayerJoined", "&6Player &4&v1&6 has joined the group!"),
|
||||||
GROUP_WAVE_FINISHED("Group_WaveFinished", "&6Your group finished wave no. &4&v1&6. The next one is going to start in &4&v2&6 seconds."),
|
GROUP_WAVE_FINISHED("Group_WaveFinished", "&6Your group finished wave no. &4&v1&6. The next one is going to start in &4&v2&6 seconds."),
|
||||||
LOG_ERROR_MOB_ENCHANTMENT("Log_Error_MobEnchantment", "&4Error at loading mob.yml: Enchantment &6&v1&4 doesn't exist!"),
|
LOG_DISABLED_TWEAKS("Log_DisabledTweaks", "&4Disabled performance tweaks because there is no support for this server software."),
|
||||||
|
LOG_ERROR_DUNGEON_SETUP("Log_Error_DungeonSetup", "&4The setup of dungeon &6&v1&4 is incorrect. See https://github.com/DRE2N/DungeonsXL/wiki/dungeon-configuration for reference."),
|
||||||
|
LOG_ERROR_MOB_ENCHANTMENT("Log_Error_MobEnchantment", "&4An error occurred while 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_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_ERROR_NO_CONSOLE_COMMAND("Log_Error_NoConsoleCommand", "&6/dxl &v1&4 can not be executed as console!"),
|
||||||
LOG_ERROR_SIGN_SETUP("Log_Error_SignSetup", "&4A sign at &6&v1&4 is erroneous!"),
|
LOG_ERROR_SIGN_SETUP("Log_Error_SignSetup", "&4A sign at &6&v1&4 is erroneous!"),
|
||||||
LOG_GENERATE_NEW_WORLD("Log_GenerateNewWorld", "&6Generating new world..."),
|
LOG_GENERATE_NEW_WORLD("Log_GenerateNewWorld", "&6Generating new world..."),
|
||||||
LOG_IMPORT_WORLD("Log_ImportWorld", "&6Importing world..."),
|
LOG_IMPORT_WORLD("Log_ImportWorld", "&6Importing world..."),
|
||||||
|
LOG_KILLED_CORRUPTED_PLAYER("Log_KilledCorruptedPlayer", "&4Killed player &6&v1 &4because the data to restore his main inventory is corrupted :("),
|
||||||
LOG_NEW_MAP("Log_NewDungeon", "&6Creating new map."),
|
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_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!"),
|
LOG_WORLD_GENERATION_FINISHED("Log_WorldGenerationFinished", "&6World generation finished!"),
|
||||||
PLAYER_BLOCK_INFO("Player_BlockInfo", "&6Block ID: &2&v1"),
|
PLAYER_BLOCK_INFO("Player_BlockInfo", "&6Block ID: &2&v1"),
|
||||||
PLAYER_CHECKPOINT_REACHED("Player_CheckpointReached", "&6Checkpoint reached!"),
|
PLAYER_CHECKPOINT_REACHED("Player_CheckpointReached", "&6Checkpoint reached!"),
|
||||||
PLAYER_DEATH("Player_Death", "&6You died, lives left: &2&v1"),
|
PLAYER_DEATH("Player_Death", "&4&v1 &6died and has &4&v2 &6lives left."),
|
||||||
PLAYER_DEATH_KICK("Player_DeathKick", "&2&v1&6 died and lost his last life."),
|
PLAYER_DEATH_KICK("Player_DeathKick", "&2&v1 &6lost his last life and was kicked."),
|
||||||
PLAYER_FINISHED_DUNGEON("Player_FinishedDungeon", "&6You successfully finished the dungeon!"),
|
PLAYER_FINISHED_DUNGEON("Player_FinishedDungeon", "&6You successfully finished the dungeon!"),
|
||||||
PLAYER_INVITED("Player_Invited", "&4&v1&6 invited you to the group &4&v2&6."),
|
PLAYER_INVITED("Player_Invited", "&4&v1&6 invited you to the group &4&v2&6."),
|
||||||
PLAYER_UNINVITED("Player_Uninvited", "&4&v1&6 took back your invitation to the group &4&v2&6."),
|
PLAYER_UNINVITED("Player_Uninvited", "&4&v1&6 took back your invitation to the group &4&v2&6."),
|
||||||
PLAYER_JOIN_GROUP("Player_JoinGroup", "&6You successfully joined the group!"),
|
PLAYER_JOIN_GROUP("Player_JoinGroup", "&6You successfully joined the group!"),
|
||||||
PLAYER_KICKED("Player_Kicked", "&4You have been kicked out of the group &6&v1&4."),
|
PLAYER_KICKED("Player_Kicked", "&4You have been kicked out of the group &6&v1&4."),
|
||||||
|
PLAYER_KILLED("Player_Killed", "&4&v1 &6was killed by &4&v2 &6and has &4&v3 &6lives left."),
|
||||||
|
PLAYER_KILLED_KICK("Player_KilledKick", "&4&v1&6 was killed by &4&v2 &6and lost his last life."),
|
||||||
PLAYER_LEAVE_GROUP("Player_LeaveGroup", "&6You have successfully left your group!"),
|
PLAYER_LEAVE_GROUP("Player_LeaveGroup", "&6You have successfully left your group!"),
|
||||||
PLAYER_LEFT_GROUP("Player_LeftGroup", "&6Player &4&v1&6 has left the Group!"),
|
PLAYER_LEFT_GROUP("Player_LeftGroup", "&6Player &4&v1&6 has left the Group!"),
|
||||||
PLAYER_LIVES_ADDED("Player_LivesAdded", "&6Received a bonus of &4&v1&6 lives."),
|
PLAYER_LIVES_ADDED("Player_LivesAdded", "&6Received a bonus of &4&v1&6 lives."),
|
||||||
|
@ -25,6 +25,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Represents a dungeon script. See {@link io.github.dre2n.dungeonsxl.dungeon.Dungeon}.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class DungeonConfig extends BRConfig {
|
public class DungeonConfig extends BRConfig {
|
||||||
|
@ -20,6 +20,8 @@ import io.github.dre2n.commons.config.BRConfig;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Represents the global data.yml.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class GlobalData extends BRConfig {
|
public class GlobalData extends BRConfig {
|
||||||
|
@ -16,8 +16,13 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.config;
|
package io.github.dre2n.dungeonsxl.config;
|
||||||
|
|
||||||
|
import io.github.dre2n.commons.compatibility.CompatibilityHandler;
|
||||||
|
import io.github.dre2n.commons.compatibility.Internals;
|
||||||
import io.github.dre2n.commons.config.BRConfig;
|
import io.github.dre2n.commons.config.BRConfig;
|
||||||
import io.github.dre2n.commons.util.EnumUtil;
|
import io.github.dre2n.commons.util.EnumUtil;
|
||||||
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.DColor;
|
||||||
|
import static io.github.dre2n.dungeonsxl.util.DColor.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -27,6 +32,8 @@ import java.util.Map;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Represents the main config.yml.
|
||||||
|
*
|
||||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class MainConfig extends BRConfig {
|
public class MainConfig extends BRConfig {
|
||||||
@ -38,7 +45,7 @@ public class MainConfig extends BRConfig {
|
|||||||
NEVER
|
NEVER
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final int CONFIG_VERSION = 11;
|
public static final int CONFIG_VERSION = 13;
|
||||||
|
|
||||||
private String language = "english";
|
private String language = "english";
|
||||||
private boolean enableEconomy = false;
|
private boolean enableEconomy = false;
|
||||||
@ -50,21 +57,29 @@ public class MainConfig extends BRConfig {
|
|||||||
private String tutorialEndGroup = "player";
|
private String tutorialEndGroup = "player";
|
||||||
|
|
||||||
/* Announcers */
|
/* Announcers */
|
||||||
private List<Short> groupColorPriority = new ArrayList<>(Arrays.asList(
|
private List<DColor> groupColorPriority = new ArrayList<>(Arrays.asList(
|
||||||
(short) 11,
|
DARK_BLUE,
|
||||||
(short) 14,
|
LIGHT_RED,
|
||||||
(short) 4,
|
YELLOW,
|
||||||
(short) 5,
|
LIGHT_GREEN,
|
||||||
(short) 10,
|
PURPLE,
|
||||||
(short) 1,
|
ORANGE,
|
||||||
(short) 0,
|
WHITE,
|
||||||
(short) 15
|
BLACK,
|
||||||
|
LIGHT_BLUE,
|
||||||
|
DARK_GREEN,
|
||||||
|
DARK_RED,
|
||||||
|
LIGHT_GRAY,
|
||||||
|
CYAN,
|
||||||
|
MAGENTA,
|
||||||
|
DARK_GRAY
|
||||||
));
|
));
|
||||||
private double announcementInterval = 30;
|
private double announcementInterval = 30;
|
||||||
|
|
||||||
/* Misc */
|
/* Misc */
|
||||||
private boolean sendFloorTitle = true;
|
private boolean sendFloorTitle = true;
|
||||||
private Map<String, Object> externalMobProviders = new HashMap<>();
|
private Map<String, Object> externalMobProviders = new HashMap<>();
|
||||||
|
private Map<String, Object> resourcePacks = new HashMap<>();
|
||||||
|
|
||||||
/* Performance */
|
/* Performance */
|
||||||
private int maxInstances = 10;
|
private int maxInstances = 10;
|
||||||
@ -186,16 +201,16 @@ public class MainConfig extends BRConfig {
|
|||||||
/**
|
/**
|
||||||
* @return the group colors
|
* @return the group colors
|
||||||
*/
|
*/
|
||||||
public List<Short> getGroupColorPriority() {
|
public List<DColor> getGroupColorPriority() {
|
||||||
return groupColorPriority;
|
return groupColorPriority;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dataValues
|
* @param colors
|
||||||
* wool data values
|
* the colors to set
|
||||||
*/
|
*/
|
||||||
public void setGroupColorPriority(List<Short> dataValues) {
|
public void setGroupColorPriority(List<DColor> colors) {
|
||||||
groupColorPriority = dataValues;
|
groupColorPriority = colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -235,6 +250,13 @@ public class MainConfig extends BRConfig {
|
|||||||
return externalMobProviders;
|
return externalMobProviders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the resource pack index
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getResourcePacks() {
|
||||||
|
return resourcePacks;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the maximum amount of worlds to instantiate at once
|
* @return the maximum amount of worlds to instantiate at once
|
||||||
*/
|
*/
|
||||||
@ -389,7 +411,11 @@ public class MainConfig extends BRConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!config.contains("groupColorPriority")) {
|
if (!config.contains("groupColorPriority")) {
|
||||||
config.set("groupColorPriority", groupColorPriority);
|
ArrayList<String> strings = new ArrayList<>();
|
||||||
|
for (DColor color : groupColorPriority) {
|
||||||
|
strings.add(color.toString());
|
||||||
|
}
|
||||||
|
config.set("groupColorPriority", strings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.contains("announcementInterval")) {
|
if (!config.contains("announcementInterval")) {
|
||||||
@ -404,6 +430,10 @@ public class MainConfig extends BRConfig {
|
|||||||
config.createSection("externalMobProviders");
|
config.createSection("externalMobProviders");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!config.contains("resourcePacks")) {
|
||||||
|
config.createSection("resourcePacks");
|
||||||
|
}
|
||||||
|
|
||||||
if (!config.contains("maxInstances")) {
|
if (!config.contains("maxInstances")) {
|
||||||
config.set("maxInstances", maxInstances);
|
config.set("maxInstances", maxInstances);
|
||||||
}
|
}
|
||||||
@ -476,7 +506,12 @@ public class MainConfig extends BRConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (config.contains("groupColorPriority")) {
|
if (config.contains("groupColorPriority")) {
|
||||||
groupColorPriority = config.getShortList("groupColorPriority");
|
groupColorPriority.clear();
|
||||||
|
for (String color : config.getStringList("groupColorPriority")) {
|
||||||
|
if (EnumUtil.isValidEnum(DColor.class, color)) {
|
||||||
|
groupColorPriority.add(DColor.valueOf(color));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.contains("announcementInterval")) {
|
if (config.contains("announcementInterval")) {
|
||||||
@ -491,12 +526,21 @@ public class MainConfig extends BRConfig {
|
|||||||
externalMobProviders = config.getConfigurationSection("externalMobProviders").getValues(false);
|
externalMobProviders = config.getConfigurationSection("externalMobProviders").getValues(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.contains("resourcePacks")) {
|
||||||
|
resourcePacks = config.getConfigurationSection("resourcePacks").getValues(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (config.contains("maxInstances")) {
|
if (config.contains("maxInstances")) {
|
||||||
maxInstances = config.getInt("maxInstances");
|
maxInstances = config.getInt("maxInstances");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.contains("tweaksEnabled")) {
|
if (config.contains("tweaksEnabled")) {
|
||||||
|
if (Internals.andHigher(Internals.v1_9_R1).contains(CompatibilityHandler.getInstance().getInternals())) {
|
||||||
tweaksEnabled = config.getBoolean("tweaksEnabled");
|
tweaksEnabled = config.getBoolean("tweaksEnabled");
|
||||||
|
} else {
|
||||||
|
tweaksEnabled = false;
|
||||||
|
MessageUtil.log(DMessages.LOG_DISABLED_TWEAKS.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.contains("secureMode.enabled")) {
|
if (config.contains("secureMode.enabled")) {
|
||||||
|
@ -16,23 +16,56 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.config;
|
package io.github.dre2n.dungeonsxl.config;
|
||||||
|
|
||||||
|
import io.github.dre2n.commons.compatibility.CompatibilityHandler;
|
||||||
|
import io.github.dre2n.commons.compatibility.Internals;
|
||||||
import io.github.dre2n.commons.config.BRConfig;
|
import io.github.dre2n.commons.config.BRConfig;
|
||||||
|
import io.github.dre2n.commons.util.EnumUtil;
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Represents a player's persistent data.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class PlayerData extends BRConfig {
|
public class PlayerData extends BRConfig {
|
||||||
|
|
||||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
boolean is1_9 = Internals.andHigher(Internals.v1_9_R1).contains(CompatibilityHandler.getInstance().getInternals());
|
||||||
|
|
||||||
public static final int CONFIG_VERSION = 1;
|
public static final int CONFIG_VERSION = 2;
|
||||||
|
|
||||||
|
public static final String PREFIX_STATE_PERSISTENCE = "savePlayer.";
|
||||||
|
public static final String PREFIX_STATS = "stats.";
|
||||||
|
|
||||||
|
// State persistence
|
||||||
|
private Location oldLocation;
|
||||||
|
private List<ItemStack> oldInventory;
|
||||||
|
private List<ItemStack> oldArmor;
|
||||||
|
private ItemStack oldOffHand;
|
||||||
|
private int oldLvl;
|
||||||
|
private float oldExp;
|
||||||
|
private double oldHealthScale;
|
||||||
|
private double oldHealth;
|
||||||
|
private int oldFoodLevel;
|
||||||
|
private int oldFireTicks;
|
||||||
|
private GameMode oldGameMode;
|
||||||
|
private Collection<PotionEffect> oldPotionEffects;
|
||||||
|
|
||||||
|
// Stats
|
||||||
private Map<String, Long> timeLastPlayed = new HashMap<>();
|
private Map<String, Long> timeLastPlayed = new HashMap<>();
|
||||||
|
|
||||||
public PlayerData(File file) {
|
public PlayerData(File file) {
|
||||||
@ -44,6 +77,194 @@ public class PlayerData extends BRConfig {
|
|||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Getters and setters */
|
||||||
|
/**
|
||||||
|
* @return if the player was in a game when he left the game
|
||||||
|
*/
|
||||||
|
public boolean wasInGame() {
|
||||||
|
return config.contains(PREFIX_STATE_PERSISTENCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the old location
|
||||||
|
*/
|
||||||
|
public Location getOldLocation() {
|
||||||
|
return oldLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param location
|
||||||
|
* the location to set
|
||||||
|
*/
|
||||||
|
public void setOldLocation(Location location) {
|
||||||
|
oldLocation = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the items in the old inventory
|
||||||
|
*/
|
||||||
|
public List<ItemStack> getOldInventory() {
|
||||||
|
return oldInventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param inventory
|
||||||
|
* the inventory to set
|
||||||
|
*/
|
||||||
|
public void setOldInventory(List<ItemStack> inventory) {
|
||||||
|
oldInventory = inventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the items in the old armor slots
|
||||||
|
*/
|
||||||
|
public List<ItemStack> getOldArmor() {
|
||||||
|
return oldArmor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param inventory
|
||||||
|
* the inventory to set
|
||||||
|
*/
|
||||||
|
public void setOldArmor(List<ItemStack> inventory) {
|
||||||
|
oldArmor = inventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the items in the old off-hand slot
|
||||||
|
*/
|
||||||
|
public ItemStack getOldOffHand() {
|
||||||
|
return oldOffHand;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param offHand
|
||||||
|
* the off hand item to set
|
||||||
|
*/
|
||||||
|
public void setOldOffHand(ItemStack offHand) {
|
||||||
|
oldOffHand = offHand;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the old level
|
||||||
|
*/
|
||||||
|
public int getOldLevel() {
|
||||||
|
return oldLvl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param level
|
||||||
|
* the level to set
|
||||||
|
*/
|
||||||
|
public void setOldLevel(int level) {
|
||||||
|
oldLvl = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the old exp
|
||||||
|
*/
|
||||||
|
public float getOldExp() {
|
||||||
|
return oldExp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param exp
|
||||||
|
* the amount of exp to set
|
||||||
|
*/
|
||||||
|
public void setOldExp(float exp) {
|
||||||
|
oldExp = exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the old health scale
|
||||||
|
*/
|
||||||
|
public double getOldHealthScale() {
|
||||||
|
return oldHealthScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param healthScale
|
||||||
|
* the healthScale to set
|
||||||
|
*/
|
||||||
|
public void setOldHealthScale(double healthScale) {
|
||||||
|
oldHealthScale = healthScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the old health
|
||||||
|
*/
|
||||||
|
public double getOldHealth() {
|
||||||
|
return oldHealth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param health
|
||||||
|
* the health to set
|
||||||
|
*/
|
||||||
|
public void setOldHealth(double health) {
|
||||||
|
oldHealth = health;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the old food level
|
||||||
|
*/
|
||||||
|
public int getOldFoodLevel() {
|
||||||
|
return oldFoodLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param foodLevel
|
||||||
|
* the food level to set
|
||||||
|
*/
|
||||||
|
public void setOldFoodLevel(int foodLevel) {
|
||||||
|
oldFoodLevel = foodLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the old fire ticks
|
||||||
|
*/
|
||||||
|
public int getOldFireTicks() {
|
||||||
|
return oldFireTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param fireTicks
|
||||||
|
* the fire ticks to set
|
||||||
|
*/
|
||||||
|
public void setFireTicks(int fireTicks) {
|
||||||
|
oldFireTicks = fireTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the old GameMode
|
||||||
|
*/
|
||||||
|
public GameMode getOldGameMode() {
|
||||||
|
return oldGameMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param gameMode
|
||||||
|
* the GameMode to set
|
||||||
|
*/
|
||||||
|
public void setOldGameMode(GameMode gameMode) {
|
||||||
|
oldGameMode = gameMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the old potion effects
|
||||||
|
*/
|
||||||
|
public Collection<PotionEffect> getOldPotionEffects() {
|
||||||
|
return oldPotionEffects;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param potionEffects
|
||||||
|
* the potion effects to set
|
||||||
|
*/
|
||||||
|
public void setOldPotionEffects(Collection<PotionEffect> potionEffects) {
|
||||||
|
oldPotionEffects = potionEffects;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a map of the player's finished dungeons with dates.
|
* @return a map of the player's finished dungeons with dates.
|
||||||
*/
|
*/
|
||||||
@ -76,6 +297,7 @@ public class PlayerData extends BRConfig {
|
|||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Actions */
|
||||||
/**
|
/**
|
||||||
* @param dungeon
|
* @param dungeon
|
||||||
* the finished dungeon
|
* the finished dungeon
|
||||||
@ -87,8 +309,8 @@ public class PlayerData extends BRConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
if (!config.contains("timeLastPlayed")) {
|
if (!config.contains(PREFIX_STATS + "timeLastPlayed")) {
|
||||||
config.createSection("timeLastPlayed");
|
config.createSection(PREFIX_STATS + "timeLastPlayed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
@ -104,17 +326,105 @@ public class PlayerData extends BRConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
if (config.isConfigurationSection("timeLastPlayed")) {
|
if (config.isConfigurationSection(PREFIX_STATS + "timeLastPlayed")) {
|
||||||
for (String key : config.getConfigurationSection("timeLastPlayed").getKeys(false)) {
|
for (String key : config.getConfigurationSection(PREFIX_STATS + "timeLastPlayed").getKeys(false)) {
|
||||||
timeLastPlayed.put(key, config.getLong("timeLastPlayed." + key));
|
timeLastPlayed.put(key, config.getLong(PREFIX_STATS + "timeLastPlayed." + key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!wasInGame()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
oldInventory = (List<ItemStack>) config.get(PREFIX_STATE_PERSISTENCE + "oldInventory");
|
||||||
|
oldArmor = (List<ItemStack>) config.get(PREFIX_STATE_PERSISTENCE + "oldArmor");
|
||||||
|
oldOffHand = (ItemStack) config.get(PREFIX_STATE_PERSISTENCE + "oldOffHand");
|
||||||
|
|
||||||
|
oldLvl = config.getInt(PREFIX_STATE_PERSISTENCE + "oldLvl");
|
||||||
|
oldExp = config.getInt(PREFIX_STATE_PERSISTENCE + "oldExp");
|
||||||
|
oldHealthScale = config.getDouble(PREFIX_STATE_PERSISTENCE + "oldHealthScale");
|
||||||
|
oldHealth = config.getDouble(PREFIX_STATE_PERSISTENCE + "oldHealth");
|
||||||
|
oldFoodLevel = config.getInt(PREFIX_STATE_PERSISTENCE + "oldFoodLevel");
|
||||||
|
oldFireTicks = config.getInt(PREFIX_STATE_PERSISTENCE + "oldFireTicks");
|
||||||
|
|
||||||
|
if (EnumUtil.isValidEnum(GameMode.class, config.getString(PREFIX_STATE_PERSISTENCE + "oldGameMode"))) {
|
||||||
|
oldGameMode = GameMode.valueOf(config.getString(PREFIX_STATE_PERSISTENCE + "oldGameMode"));
|
||||||
|
} else {
|
||||||
|
oldGameMode = GameMode.SURVIVAL;
|
||||||
|
}
|
||||||
|
oldPotionEffects = (Collection<PotionEffect>) config.get(PREFIX_STATE_PERSISTENCE + "oldPotionEffects");
|
||||||
|
|
||||||
|
oldLocation = (Location) config.get(PREFIX_STATE_PERSISTENCE + "oldLocation");
|
||||||
|
if (oldLocation.getWorld() == null) {
|
||||||
|
oldLocation = plugin.getServer().getWorlds().get(0).getSpawnLocation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save() {
|
public void save() {
|
||||||
config.set("timeLastPlayed", timeLastPlayed);
|
config.set(PREFIX_STATS + "timeLastPlayed", timeLastPlayed);
|
||||||
super.save();
|
super.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the player's data to the file.
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* the Player to save
|
||||||
|
*/
|
||||||
|
public void savePlayerState(Player player) {
|
||||||
|
oldGameMode = player.getGameMode();
|
||||||
|
oldFireTicks = player.getFireTicks();
|
||||||
|
oldFoodLevel = player.getFoodLevel();
|
||||||
|
oldHealthScale = player.getHealthScale();
|
||||||
|
oldHealth = player.getHealth();
|
||||||
|
oldExp = player.getExp();
|
||||||
|
oldLvl = player.getLevel();
|
||||||
|
oldArmor = new ArrayList<>(Arrays.asList(player.getInventory().getArmorContents()));
|
||||||
|
oldInventory = new ArrayList<>(Arrays.asList(player.getInventory().getContents()));
|
||||||
|
if (is1_9) {
|
||||||
|
oldOffHand = player.getInventory().getItemInOffHand();
|
||||||
|
}
|
||||||
|
oldLocation = player.getLocation();
|
||||||
|
oldPotionEffects = player.getActivePotionEffects();
|
||||||
|
|
||||||
|
config.set(PREFIX_STATE_PERSISTENCE + "oldGameMode", oldGameMode.toString());
|
||||||
|
config.set(PREFIX_STATE_PERSISTENCE + "oldFireTicks", oldFireTicks);
|
||||||
|
config.set(PREFIX_STATE_PERSISTENCE + "oldFoodLevel", oldFoodLevel);
|
||||||
|
config.set(PREFIX_STATE_PERSISTENCE + "oldHealthScale", oldHealthScale);
|
||||||
|
config.set(PREFIX_STATE_PERSISTENCE + "oldHealth", oldHealth);
|
||||||
|
config.set(PREFIX_STATE_PERSISTENCE + "oldExp", oldExp);
|
||||||
|
config.set(PREFIX_STATE_PERSISTENCE + "oldLvl", oldLvl);
|
||||||
|
config.set(PREFIX_STATE_PERSISTENCE + "oldArmor", oldArmor);
|
||||||
|
config.set(PREFIX_STATE_PERSISTENCE + "oldInventory", oldInventory);
|
||||||
|
config.set(PREFIX_STATE_PERSISTENCE + "oldOffHand", oldOffHand);
|
||||||
|
config.set(PREFIX_STATE_PERSISTENCE + "oldLocation", oldLocation);
|
||||||
|
config.set(PREFIX_STATE_PERSISTENCE + "oldPotionEffects", oldPotionEffects);
|
||||||
|
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the state data from the file
|
||||||
|
*/
|
||||||
|
public void clearPlayerState() {
|
||||||
|
oldGameMode = null;
|
||||||
|
oldFireTicks = 0;
|
||||||
|
oldFoodLevel = 0;
|
||||||
|
oldHealthScale = 0;
|
||||||
|
oldHealth = 0;
|
||||||
|
oldExp = 0;
|
||||||
|
oldLvl = 0;
|
||||||
|
oldArmor = null;
|
||||||
|
oldInventory = null;
|
||||||
|
oldOffHand = null;
|
||||||
|
oldLocation = null;
|
||||||
|
oldPotionEffects = null;
|
||||||
|
|
||||||
|
if (wasInGame()) {
|
||||||
|
config.set("savePlayer", null);
|
||||||
|
}
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,8 @@ import org.bukkit.block.Block;
|
|||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Represents the data file of a dungeon map, mainly to store signs.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class SignData {
|
public class SignData {
|
||||||
|
@ -25,26 +25,29 @@ import io.github.dre2n.commons.util.NumberUtil;
|
|||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameRules;
|
import io.github.dre2n.dungeonsxl.game.GameRules;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||||
import io.github.dre2n.dungeonsxl.requirement.FeeLevelRequirement;
|
|
||||||
import io.github.dre2n.dungeonsxl.requirement.FeeMoneyRequirement;
|
|
||||||
import io.github.dre2n.dungeonsxl.requirement.GroupSizeRequirement;
|
|
||||||
import io.github.dre2n.dungeonsxl.requirement.PermissionRequirement;
|
|
||||||
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
||||||
import io.github.dre2n.dungeonsxl.requirement.RequirementTypeDefault;
|
|
||||||
import io.github.dre2n.dungeonsxl.util.DeserializationUtil;
|
import io.github.dre2n.dungeonsxl.util.DeserializationUtil;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The world configuration is a simple game rule source.
|
||||||
|
* Besides game rules, WorldConfig also stores some map specific data such as the invited players.
|
||||||
|
* It is used directly in dungeon map config.yml files, but also part of dungeon and main config files.
|
||||||
|
*
|
||||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class WorldConfig extends GameRules {
|
public class WorldConfig extends GameRules {
|
||||||
@ -126,12 +129,7 @@ public class WorldConfig extends GameRules {
|
|||||||
keepInventoryOnDeath = configFile.getBoolean("keepInventoryOnDeath");
|
keepInventoryOnDeath = configFile.getBoolean("keepInventoryOnDeath");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build */
|
/* World interaction */
|
||||||
if (configFile.contains("build")) {
|
|
||||||
build = configFile.getBoolean("build");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* GameMode */
|
|
||||||
if (configFile.contains("gameMode")) {
|
if (configFile.contains("gameMode")) {
|
||||||
if (EnumUtil.isValidEnum(GameMode.class, configFile.getString("gameMode").toUpperCase())) {
|
if (EnumUtil.isValidEnum(GameMode.class, configFile.getString("gameMode").toUpperCase())) {
|
||||||
gameMode = GameMode.valueOf(configFile.getString("gameMode"));
|
gameMode = GameMode.valueOf(configFile.getString("gameMode"));
|
||||||
@ -140,6 +138,47 @@ public class WorldConfig extends GameRules {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (configFile.contains("breakBlocks")) {
|
||||||
|
breakBlocks = configFile.getBoolean("breakBlocks");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configFile.contains("breakPlacedBlocks")) {
|
||||||
|
breakPlacedBlocks = configFile.getBoolean("breakPlacedBlocks");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configFile.contains("breakWhitelist")) {
|
||||||
|
breakWhitelist = new HashMap<>();
|
||||||
|
for (Entry<String, Object> entry : configFile.getConfigurationSection("breakWhitelist").getValues(true).entrySet()) {
|
||||||
|
Material breakable = Material.matchMaterial(entry.getKey());
|
||||||
|
|
||||||
|
HashSet<Material> tools = new HashSet<>();
|
||||||
|
if (entry.getValue() instanceof List) {
|
||||||
|
for (String materialString : (List<String>) entry.getValue()) {
|
||||||
|
Material tool = Material.matchMaterial(materialString);
|
||||||
|
if (tool != null) {
|
||||||
|
tools.add(tool);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
breakWhitelist.put(breakable, tools);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configFile.contains("placeBlocks")) {
|
||||||
|
placeBlocks = configFile.getBoolean("placeBlocks");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configFile.contains("placeWhitelist")) {
|
||||||
|
placeWhitelist = new HashSet<>();
|
||||||
|
for (String materialString : configFile.getStringList("placeWhitelist")) {
|
||||||
|
Material material = Material.matchMaterial(materialString);
|
||||||
|
if (material != null) {
|
||||||
|
placeWhitelist.add(material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* PvP */
|
/* PvP */
|
||||||
if (configFile.contains("playerVersusPlayer")) {
|
if (configFile.contains("playerVersusPlayer")) {
|
||||||
playerVersusPlayer = configFile.getBoolean("playerVersusPlayer");
|
playerVersusPlayer = configFile.getBoolean("playerVersusPlayer");
|
||||||
@ -155,6 +194,10 @@ public class WorldConfig extends GameRules {
|
|||||||
initialLives = configFile.getInt("initialLives");
|
initialLives = configFile.getInt("initialLives");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (configFile.contains("initialGroupLives")) {
|
||||||
|
initialGroupLives = configFile.getInt("initialGroupLives");
|
||||||
|
}
|
||||||
|
|
||||||
/* Lobby */
|
/* Lobby */
|
||||||
if (configFile.contains("isLobbyDisabled")) {
|
if (configFile.contains("isLobbyDisabled")) {
|
||||||
lobbyDisabled = configFile.getBoolean("isLobbyDisabled");
|
lobbyDisabled = configFile.getBoolean("isLobbyDisabled");
|
||||||
@ -187,24 +230,10 @@ public class WorldConfig extends GameRules {
|
|||||||
requirements = new ArrayList<>();
|
requirements = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConfigurationSection requirementSection = configFile.getConfigurationSection("requirements");
|
||||||
for (String identifier : configFile.getConfigurationSection("requirements").getKeys(false)) {
|
for (String identifier : configFile.getConfigurationSection("requirements").getKeys(false)) {
|
||||||
Requirement requirement = Requirement.create(plugin.getRequirementTypes().getByIdentifier(identifier));
|
Requirement requirement = Requirement.create(plugin.getRequirementTypes().getByIdentifier(identifier));
|
||||||
|
requirement.setup(requirementSection);
|
||||||
// Check for built-in requirements
|
|
||||||
if (requirement.getType() == RequirementTypeDefault.FEE_MONEY) {
|
|
||||||
((FeeMoneyRequirement) requirement).setFee(configFile.getDouble("requirements.feeMoney"));
|
|
||||||
|
|
||||||
} else if (requirement.getType() == RequirementTypeDefault.FEE_LEVEL) {
|
|
||||||
((FeeLevelRequirement) requirement).setFee(configFile.getInt("requirements.feeLevel"));
|
|
||||||
|
|
||||||
} else if (requirement.getType() == RequirementTypeDefault.GROUP_SIZE) {
|
|
||||||
((GroupSizeRequirement) requirement).setMinimum(configFile.getInt("requirements.groupSize.minimum"));
|
|
||||||
((GroupSizeRequirement) requirement).setMaximum(configFile.getInt("requirements.groupSize.maximum"));
|
|
||||||
|
|
||||||
} else if (requirement.getType() == RequirementTypeDefault.PERMISSION) {
|
|
||||||
((PermissionRequirement) requirement).setPermissions(configFile.getStringList("requirements.permission"));
|
|
||||||
}
|
|
||||||
|
|
||||||
requirements.add(requirement);
|
requirements.add(requirement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,8 +311,10 @@ public class WorldConfig extends GameRules {
|
|||||||
* the player's unique ID
|
* the player's unique ID
|
||||||
*/
|
*/
|
||||||
public void addInvitedPlayer(String uuid) {
|
public void addInvitedPlayer(String uuid) {
|
||||||
|
if (!invitedPlayers.contains(uuid)) {
|
||||||
invitedPlayers.add(uuid);
|
invitedPlayers.add(uuid);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param uuid
|
* @param uuid
|
||||||
|
@ -21,6 +21,10 @@ import io.github.dre2n.dungeonsxl.config.DungeonConfig;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Represents a dungeon.
|
||||||
|
* While multi floor dungeon scripts are represented by {@link io.github.dre2n.dungeonsxl.config.DungeonConfig},
|
||||||
|
* single floor dungeons also get a dungeon object without a config file as a placeholder.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class Dungeon {
|
public class Dungeon {
|
||||||
|
@ -16,22 +16,21 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.dungeon;
|
package io.github.dre2n.dungeonsxl.dungeon;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Dungeon instance manager.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class Dungeons {
|
public class Dungeons {
|
||||||
|
|
||||||
private List<Dungeon> dungeons = new ArrayList<>();
|
private List<Dungeon> dungeons = new ArrayList<>();
|
||||||
|
|
||||||
public Dungeons() {
|
|
||||||
this(DungeonsXL.DUNGEONS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dungeons(File folder) {
|
public Dungeons(File folder) {
|
||||||
if (!folder.exists()) {
|
if (!folder.exists()) {
|
||||||
folder.mkdir();
|
folder.mkdir();
|
||||||
@ -44,7 +43,7 @@ public class Dungeons {
|
|||||||
dungeons.add(dungeon);
|
dungeons.add(dungeon);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// debug
|
MessageUtil.log(DMessages.LOG_ERROR_DUNGEON_SETUP.getMessage(file.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* 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.event;
|
||||||
|
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class DataReloadEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancelled) {
|
||||||
|
this.cancelled = cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -31,6 +31,7 @@ public class DGroupDisbandEvent extends DGroupEvent implements Cancellable {
|
|||||||
COMMAND,
|
COMMAND,
|
||||||
DUNGEON_FINISHED,
|
DUNGEON_FINISHED,
|
||||||
GROUP_IS_EMPTY,
|
GROUP_IS_EMPTY,
|
||||||
|
LOST,
|
||||||
CUSTOM
|
CUSTOM
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* 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.event.dgroup;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class DGroupScoreEvent extends DGroupEvent implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
|
private Player scorer;
|
||||||
|
private DGroup loserGroup;
|
||||||
|
|
||||||
|
public DGroupScoreEvent(DGroup dGroup, Player scorer, DGroup loserGroup) {
|
||||||
|
super(dGroup);
|
||||||
|
this.scorer = scorer;
|
||||||
|
this.loserGroup = loserGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the creator
|
||||||
|
*/
|
||||||
|
public Player getScorer() {
|
||||||
|
return scorer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param scorer
|
||||||
|
* the scoerer to set
|
||||||
|
*/
|
||||||
|
public void setCreator(Player scorer) {
|
||||||
|
this.scorer = scorer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the group that lost a score to the scorers
|
||||||
|
*/
|
||||||
|
public DGroup getLoserGroup() {
|
||||||
|
return loserGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param loserGroup
|
||||||
|
* the group that lost a score to the scorers to set
|
||||||
|
*/
|
||||||
|
public void setLoserGroup(DGroup loserGroup) {
|
||||||
|
this.loserGroup = loserGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancelled) {
|
||||||
|
this.cancelled = cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* 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.event.dplayer.instance;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEvent;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public abstract class DInstancePlayerEvent extends DPlayerEvent {
|
||||||
|
|
||||||
|
public DInstancePlayerEvent(DInstancePlayer dPlayer) {
|
||||||
|
super(dPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DInstancePlayer getDPlayer() {
|
||||||
|
return (DInstancePlayer) dPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDPlayer(DInstancePlayer dPlayer) {
|
||||||
|
this.dPlayer = dPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.event.dplayer;
|
package io.github.dre2n.dungeonsxl.event.dplayer.instance;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
@ -23,7 +23,7 @@ import org.bukkit.event.HandlerList;
|
|||||||
/**
|
/**
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class DPlayerUpdateEvent extends DPlayerEvent implements Cancellable {
|
public class DInstancePlayerUpdateEvent extends DInstancePlayerEvent implements Cancellable {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
@ -35,7 +35,7 @@ public class DPlayerUpdateEvent extends DPlayerEvent implements Cancellable {
|
|||||||
private boolean kick;
|
private boolean kick;
|
||||||
private boolean triggerAllInDistance;
|
private boolean triggerAllInDistance;
|
||||||
|
|
||||||
public DPlayerUpdateEvent(DInstancePlayer dPlayer, boolean locationValid, boolean teleportWolf, boolean respawnInventory, boolean offline, boolean kick, boolean triggerAllInDistance) {
|
public DInstancePlayerUpdateEvent(DInstancePlayer dPlayer, boolean locationValid, boolean teleportWolf, boolean respawnInventory, boolean offline, boolean kick, boolean triggerAllInDistance) {
|
||||||
super(dPlayer);
|
super(dPlayer);
|
||||||
this.locationValid = locationValid;
|
this.locationValid = locationValid;
|
||||||
this.teleportWolf = teleportWolf;
|
this.teleportWolf = teleportWolf;
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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.event.dplayer.instance.edit;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DEditPlayer;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class DEditPlayerEscapeEvent extends DEditPlayerEvent implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
|
public DEditPlayerEscapeEvent(DEditPlayer dPlayer) {
|
||||||
|
super(dPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancelled) {
|
||||||
|
this.cancelled = cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* 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.event.dplayer.instance.edit;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEvent;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DEditPlayer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public abstract class DEditPlayerEvent extends DPlayerEvent {
|
||||||
|
|
||||||
|
public DEditPlayerEvent(DEditPlayer dPlayer) {
|
||||||
|
super(dPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DEditPlayer getDPlayer() {
|
||||||
|
return (DEditPlayer) dPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDPlayer(DEditPlayer dPlayer) {
|
||||||
|
this.dPlayer = dPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.event.dplayer;
|
package io.github.dre2n.dungeonsxl.event.dplayer.instance.game;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
@ -24,7 +24,7 @@ import org.bukkit.event.entity.PlayerDeathEvent;
|
|||||||
/**
|
/**
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class DPlayerDeathEvent extends DPlayerEvent implements Cancellable {
|
public class DGamePlayerDeathEvent extends DGamePlayerEvent implements Cancellable {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
@ -32,7 +32,7 @@ public class DPlayerDeathEvent extends DPlayerEvent implements Cancellable {
|
|||||||
private PlayerDeathEvent bukkitEvent;
|
private PlayerDeathEvent bukkitEvent;
|
||||||
private int lostLives;
|
private int lostLives;
|
||||||
|
|
||||||
public DPlayerDeathEvent(DGamePlayer dPlayer, PlayerDeathEvent bukkitEvent, int lostLives) {
|
public DGamePlayerDeathEvent(DGamePlayer dPlayer, PlayerDeathEvent bukkitEvent, int lostLives) {
|
||||||
super(dPlayer);
|
super(dPlayer);
|
||||||
this.bukkitEvent = bukkitEvent;
|
this.bukkitEvent = bukkitEvent;
|
||||||
this.lostLives = lostLives;
|
this.lostLives = lostLives;
|
@ -14,21 +14,21 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.event.dplayer;
|
package io.github.dre2n.dungeonsxl.event.dplayer.instance.game;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class DPlayerEscapeEvent extends DPlayerEvent implements Cancellable {
|
public class DGamePlayerEscapeEvent extends DGamePlayerEvent implements Cancellable {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
public DPlayerEscapeEvent(DGlobalPlayer dPlayer) {
|
public DGamePlayerEscapeEvent(DGamePlayer dPlayer) {
|
||||||
super(dPlayer);
|
super(dPlayer);
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* 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.event.dplayer.instance.game;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEvent;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public abstract class DGamePlayerEvent extends DPlayerEvent {
|
||||||
|
|
||||||
|
public DGamePlayerEvent(DGamePlayer dPlayer) {
|
||||||
|
super(dPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DGamePlayer getDPlayer() {
|
||||||
|
return (DGamePlayer) dPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDPlayer(DGamePlayer dPlayer) {
|
||||||
|
this.dPlayer = dPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.event.dplayer;
|
package io.github.dre2n.dungeonsxl.event.dplayer.instance.game;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
@ -23,7 +23,7 @@ import org.bukkit.event.HandlerList;
|
|||||||
/**
|
/**
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class DPlayerFinishEvent extends DPlayerEvent implements Cancellable {
|
public class DGamePlayerFinishEvent extends DGamePlayerEvent implements Cancellable {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
@ -31,7 +31,7 @@ public class DPlayerFinishEvent extends DPlayerEvent implements Cancellable {
|
|||||||
private boolean first;
|
private boolean first;
|
||||||
private boolean hasToWait;
|
private boolean hasToWait;
|
||||||
|
|
||||||
public DPlayerFinishEvent(DGamePlayer dPlayer, boolean first, boolean hasToWait) {
|
public DGamePlayerFinishEvent(DGamePlayer dPlayer, boolean first, boolean hasToWait) {
|
||||||
super(dPlayer);
|
super(dPlayer);
|
||||||
this.first = first;
|
this.first = first;
|
||||||
this.hasToWait = hasToWait;
|
this.hasToWait = hasToWait;
|
@ -41,12 +41,16 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Game mostly stores for which purposes and how a {@link io.github.dre2n.dungeonsxl.dungeon.Dungeon} is used,
|
||||||
|
* the player groups and the progress.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class Game {
|
public class Game {
|
||||||
|
|
||||||
static DungeonsXL plugin = DungeonsXL.getInstance();
|
static DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
|
private boolean tutorial;
|
||||||
private List<DGroup> dGroups = new ArrayList<>();
|
private List<DGroup> dGroups = new ArrayList<>();
|
||||||
private boolean started;
|
private boolean started;
|
||||||
private GameType type = GameTypeDefault.DEFAULT;
|
private GameType type = GameTypeDefault.DEFAULT;
|
||||||
@ -57,33 +61,50 @@ public class Game {
|
|||||||
private Map<String, Integer> waveKills = new HashMap<>();
|
private Map<String, Integer> waveKills = new HashMap<>();
|
||||||
|
|
||||||
public Game(DGroup dGroup) {
|
public Game(DGroup dGroup) {
|
||||||
dGroups.add(dGroup);
|
|
||||||
started = false;
|
|
||||||
fetchRules();
|
|
||||||
|
|
||||||
plugin.getGames().add(this);
|
plugin.getGames().add(this);
|
||||||
|
|
||||||
|
tutorial = false;
|
||||||
|
started = false;
|
||||||
|
|
||||||
|
dGroups.add(dGroup);
|
||||||
|
dGroup.setGameWorld(world);
|
||||||
|
fetchRules();
|
||||||
|
dGroup.setInitialLives(rules.getInitialGroupLives());
|
||||||
|
dGroup.setLives(rules.getInitialGroupLives());
|
||||||
|
dGroup.setScore(rules.getInitialScore());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Game(DGroup dGroup, DGameWorld world) {
|
public Game(DGroup dGroup, DGameWorld world) {
|
||||||
dGroups.add(dGroup);
|
plugin.getGames().add(this);
|
||||||
|
|
||||||
|
tutorial = false;
|
||||||
started = false;
|
started = false;
|
||||||
this.world = world;
|
this.world = world;
|
||||||
fetchRules();
|
|
||||||
|
|
||||||
plugin.getGames().add(this);
|
dGroups.add(dGroup);
|
||||||
|
dGroup.setGameWorld(world);
|
||||||
|
fetchRules();
|
||||||
|
dGroup.setInitialLives(rules.getInitialGroupLives());
|
||||||
|
dGroup.setLives(rules.getInitialGroupLives());
|
||||||
|
dGroup.setScore(rules.getInitialScore());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Game(DGroup dGroup, String worldName) {
|
public Game(DGroup dGroup, String worldName) {
|
||||||
plugin.getGames().add(this);
|
plugin.getGames().add(this);
|
||||||
|
|
||||||
dGroups.add(dGroup);
|
tutorial = false;
|
||||||
started = false;
|
started = false;
|
||||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(worldName);
|
DResourceWorld resource = plugin.getDWorlds().getResourceByName(worldName);
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
world = resource.instantiateAsGameWorld();
|
world = resource.instantiateAsGameWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dGroups.add(dGroup);
|
||||||
dGroup.setGameWorld(world);
|
dGroup.setGameWorld(world);
|
||||||
fetchRules();
|
fetchRules();
|
||||||
|
dGroup.setInitialLives(rules.getInitialGroupLives());
|
||||||
|
dGroup.setLives(rules.getInitialGroupLives());
|
||||||
|
dGroup.setScore(rules.getInitialScore());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Game(DGroup dGroup, GameType type, DGameWorld world) {
|
public Game(DGroup dGroup, GameType type, DGameWorld world) {
|
||||||
@ -91,13 +112,36 @@ public class Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Game(List<DGroup> dGroups, GameType type, DGameWorld world) {
|
public Game(List<DGroup> dGroups, GameType type, DGameWorld world) {
|
||||||
|
plugin.getGames().add(this);
|
||||||
|
|
||||||
this.dGroups = dGroups;
|
this.dGroups = dGroups;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
this.tutorial = false;
|
||||||
this.started = true;
|
this.started = true;
|
||||||
fetchRules();
|
|
||||||
|
|
||||||
plugin.getGames().add(this);
|
for (DGroup dGroup : dGroups) {
|
||||||
|
dGroup.setGameWorld(world);
|
||||||
|
fetchRules();
|
||||||
|
dGroup.setInitialLives(rules.getInitialGroupLives());
|
||||||
|
dGroup.setLives(rules.getInitialGroupLives());
|
||||||
|
dGroup.setScore(rules.getInitialScore());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the tutorial
|
||||||
|
*/
|
||||||
|
public boolean isTutorial() {
|
||||||
|
return tutorial;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param tutorial
|
||||||
|
* if the DGameWorld is the tutorial
|
||||||
|
*/
|
||||||
|
public void setTutorial(boolean tutorial) {
|
||||||
|
this.tutorial = tutorial;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,6 +157,10 @@ public class Game {
|
|||||||
*/
|
*/
|
||||||
public void addDGroup(DGroup dGroup) {
|
public void addDGroup(DGroup dGroup) {
|
||||||
dGroups.add(dGroup);
|
dGroups.add(dGroup);
|
||||||
|
|
||||||
|
dGroup.setGameWorld(world);
|
||||||
|
dGroup.setInitialLives(rules.getInitialGroupLives());
|
||||||
|
dGroup.setLives(rules.getInitialGroupLives());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -430,7 +478,7 @@ public class Game {
|
|||||||
|
|
||||||
public static Game getByGameWorld(DGameWorld gameWorld) {
|
public static Game getByGameWorld(DGameWorld gameWorld) {
|
||||||
for (Game game : plugin.getGames()) {
|
for (Game game : plugin.getGames()) {
|
||||||
if (game.getWorld().equals(gameWorld)) {
|
if (gameWorld.equals(game.getWorld())) {
|
||||||
return game;
|
return game;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* 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.game;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A game goal defines what the players have to do in order to finish the game.
|
||||||
|
*
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public enum GameGoal {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default goal.
|
||||||
|
* The game ends when the end is reached.
|
||||||
|
*/
|
||||||
|
END,
|
||||||
|
/**
|
||||||
|
* The game does not end.
|
||||||
|
* Instead, the goal is to survive as long as possible to beat a highscore.
|
||||||
|
*/
|
||||||
|
HIGHSCORE,
|
||||||
|
/**
|
||||||
|
* The game ends when a player dies and only one group is left.
|
||||||
|
*/
|
||||||
|
LAST_MAN_STANDING,
|
||||||
|
/**
|
||||||
|
* The game ends when a group reachs a specific score.
|
||||||
|
*/
|
||||||
|
REACH_SCORE,
|
||||||
|
/**
|
||||||
|
* The game ends after a specific time.
|
||||||
|
* The goal is to get the highest score until then.
|
||||||
|
*/
|
||||||
|
TIME_SCORE,
|
||||||
|
/**
|
||||||
|
* The game ends after a specific time.
|
||||||
|
* The goal is to survive until then.
|
||||||
|
*/
|
||||||
|
TIME_SURVIVAL;
|
||||||
|
|
||||||
|
}
|
@ -20,12 +20,17 @@ import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
|||||||
import io.github.dre2n.dungeonsxl.reward.Reward;
|
import io.github.dre2n.dungeonsxl.reward.Reward;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* See {@link io.github.dre2n.dungeonsxl.config.WorldConfig}
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class GameRules {
|
public class GameRules {
|
||||||
@ -42,12 +47,19 @@ public class GameRules {
|
|||||||
|
|
||||||
/* World interaction */
|
/* World interaction */
|
||||||
DEFAULT_VALUES.gameMode = GameMode.SURVIVAL;
|
DEFAULT_VALUES.gameMode = GameMode.SURVIVAL;
|
||||||
DEFAULT_VALUES.build = false;
|
DEFAULT_VALUES.breakBlocks = false;
|
||||||
|
DEFAULT_VALUES.breakPlacedBlocks = false;
|
||||||
|
DEFAULT_VALUES.breakWhitelist = null;
|
||||||
|
DEFAULT_VALUES.placeBlocks = false;
|
||||||
|
DEFAULT_VALUES.placeWhitelist = null;
|
||||||
|
|
||||||
/* Fighting */
|
/* Fighting */
|
||||||
DEFAULT_VALUES.playerVersusPlayer = false;
|
DEFAULT_VALUES.playerVersusPlayer = false;
|
||||||
DEFAULT_VALUES.friendlyFire = false;
|
DEFAULT_VALUES.friendlyFire = false;
|
||||||
DEFAULT_VALUES.initialLives = 3;
|
DEFAULT_VALUES.initialLives = -1;
|
||||||
|
DEFAULT_VALUES.initialGroupLives = -1;
|
||||||
|
DEFAULT_VALUES.initialScore = 3;
|
||||||
|
DEFAULT_VALUES.scoreGoal = -1;
|
||||||
|
|
||||||
/* Timer */
|
/* Timer */
|
||||||
DEFAULT_VALUES.timeLastPlayed = 0;
|
DEFAULT_VALUES.timeLastPlayed = 0;
|
||||||
@ -81,12 +93,19 @@ public class GameRules {
|
|||||||
|
|
||||||
/* World interaction */
|
/* World interaction */
|
||||||
protected GameMode gameMode;
|
protected GameMode gameMode;
|
||||||
protected Boolean build;
|
protected Boolean breakBlocks;
|
||||||
|
protected Boolean breakPlacedBlocks;
|
||||||
|
protected Map<Material, HashSet<Material>> breakWhitelist;
|
||||||
|
protected Boolean placeBlocks;
|
||||||
|
protected Set<Material> placeWhitelist;
|
||||||
|
|
||||||
/* Fighting */
|
/* Fighting */
|
||||||
protected Boolean playerVersusPlayer;
|
protected Boolean playerVersusPlayer;
|
||||||
protected Boolean friendlyFire;
|
protected Boolean friendlyFire;
|
||||||
protected Integer initialLives;
|
protected Integer initialLives;
|
||||||
|
protected Integer initialGroupLives;
|
||||||
|
protected Integer initialScore;
|
||||||
|
protected Integer scoreGoal;
|
||||||
|
|
||||||
/* Timer */
|
/* Timer */
|
||||||
protected Integer timeLastPlayed;
|
protected Integer timeLastPlayed;
|
||||||
@ -156,10 +175,38 @@ public class GameRules {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return if players may build
|
* @return if all blocks may be destroyed
|
||||||
*/
|
*/
|
||||||
public boolean canBuild() {
|
public boolean canBreakBlocks() {
|
||||||
return build;
|
return breakBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if blocks placed in game may be destroyed
|
||||||
|
*/
|
||||||
|
public boolean canBreakPlacedBlocks() {
|
||||||
|
return breakPlacedBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the destroyable materials and the materials that may be used to break them or null if any
|
||||||
|
*/
|
||||||
|
public Map<Material, HashSet<Material>> getBreakWhitelist() {
|
||||||
|
return breakWhitelist;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if blocks may be placed
|
||||||
|
*/
|
||||||
|
public boolean canPlaceBlocks() {
|
||||||
|
return placeBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the placeable materials
|
||||||
|
*/
|
||||||
|
public Set<Material> getPlaceWhitelist() {
|
||||||
|
return placeWhitelist;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fight
|
// Fight
|
||||||
@ -184,6 +231,27 @@ public class GameRules {
|
|||||||
return initialLives;
|
return initialLives;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the initial amount of group lives
|
||||||
|
*/
|
||||||
|
public int getInitialGroupLives() {
|
||||||
|
return initialGroupLives;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the initial score
|
||||||
|
*/
|
||||||
|
public int getInitialScore() {
|
||||||
|
return initialScore;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the score goal
|
||||||
|
*/
|
||||||
|
public int getScoreGoal() {
|
||||||
|
return scoreGoal;
|
||||||
|
}
|
||||||
|
|
||||||
// Timer
|
// Timer
|
||||||
/**
|
/**
|
||||||
* @return the timeLastPlayed
|
* @return the timeLastPlayed
|
||||||
@ -353,17 +421,31 @@ public class GameRules {
|
|||||||
friendlyFire = defaultValues.isFriendlyFire();
|
friendlyFire = defaultValues.isFriendlyFire();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeToFinish == null) {
|
if (timeToFinish == null && defaultValues.getShowTime() != null) {
|
||||||
timeToFinish = defaultValues.getShowTime() ? null : -1;
|
timeToFinish = defaultValues.getShowTime() ? null : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (build == null) {
|
if (breakBlocks == null) {
|
||||||
build = defaultValues.canBuild();
|
breakBlocks = defaultValues.canBreakBlocks();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (breakPlacedBlocks == null) {
|
||||||
|
breakPlacedBlocks = defaultValues.canBreakPlacedBlocks();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (placeBlocks == null) {
|
||||||
|
placeBlocks = defaultValues.canPlaceBlocks();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gameMode == null) {
|
if (gameMode == null) {
|
||||||
gameMode = defaultValues.getGameMode();
|
gameMode = defaultValues.getGameMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (initialLives == null) {
|
||||||
|
if (defaultValues.hasLives() != null) {
|
||||||
|
initialLives = defaultValues.hasLives() ? null : -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -397,8 +479,24 @@ public class GameRules {
|
|||||||
gameMode = defaultValues.gameMode;
|
gameMode = defaultValues.gameMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (build == null) {
|
if (breakBlocks == null) {
|
||||||
build = defaultValues.build;
|
breakBlocks = defaultValues.breakBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (breakPlacedBlocks == null) {
|
||||||
|
breakPlacedBlocks = defaultValues.breakPlacedBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (breakWhitelist == null) {
|
||||||
|
breakWhitelist = defaultValues.breakWhitelist;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (placeBlocks == null) {
|
||||||
|
placeBlocks = defaultValues.placeBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (placeWhitelist == null) {
|
||||||
|
placeWhitelist = defaultValues.placeWhitelist;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fighting */
|
/* Fighting */
|
||||||
@ -414,6 +512,18 @@ public class GameRules {
|
|||||||
initialLives = defaultValues.initialLives;
|
initialLives = defaultValues.initialLives;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (initialGroupLives == null) {
|
||||||
|
initialGroupLives = defaultValues.initialGroupLives;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (initialScore == null) {
|
||||||
|
initialScore = defaultValues.initialScore;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scoreGoal == null) {
|
||||||
|
scoreGoal = defaultValues.scoreGoal;
|
||||||
|
}
|
||||||
|
|
||||||
/* Timer */
|
/* Timer */
|
||||||
if (timeLastPlayed == null) {
|
if (timeLastPlayed == null) {
|
||||||
timeLastPlayed = defaultValues.timeLastPlayed;
|
timeLastPlayed = defaultValues.timeLastPlayed;
|
||||||
|
@ -19,6 +19,8 @@ package io.github.dre2n.dungeonsxl.game;
|
|||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Implement this to create custom game types.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public interface GameType {
|
public interface GameType {
|
||||||
@ -45,71 +47,93 @@ public interface GameType {
|
|||||||
*/
|
*/
|
||||||
public void setSignName(String signName);
|
public void setSignName(String signName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the goal of the game
|
||||||
|
*/
|
||||||
|
public GameGoal getGameGoal();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param gameGoal
|
||||||
|
* the goal of the game to set
|
||||||
|
*/
|
||||||
|
public void setGameGoal(GameGoal gameGoal);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the playerVersusPlayer
|
* @return the playerVersusPlayer
|
||||||
*/
|
*/
|
||||||
public boolean isPlayerVersusPlayer();
|
public Boolean isPlayerVersusPlayer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param playerVersusPlayer
|
* @param playerVersusPlayer
|
||||||
* the playerVersusPlayer to set
|
* the playerVersusPlayer to set
|
||||||
*/
|
*/
|
||||||
public void setPlayerVersusPlayer(boolean playerVersusPlayer);
|
public void setPlayerVersusPlayer(Boolean playerVersusPlayer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the friendlyFire
|
* @return the friendlyFire
|
||||||
*/
|
*/
|
||||||
public boolean isFriendlyFire();
|
public Boolean isFriendlyFire();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param friendlyFire
|
* @param friendlyFire
|
||||||
* the friendlyFire to set
|
* the friendlyFire to set
|
||||||
*/
|
*/
|
||||||
public void setFriendlyFire(boolean friendlyFire);
|
public void setFriendlyFire(Boolean friendlyFire);
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the mobWaves
|
|
||||||
*/
|
|
||||||
public boolean hasMobWaves();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param mobWaves
|
|
||||||
* enable / disable mob waves
|
|
||||||
*/
|
|
||||||
public void setMobWaves(boolean mobWaves);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return if players get rewards after the dungeon
|
* @return if players get rewards after the dungeon
|
||||||
*/
|
*/
|
||||||
public boolean hasRewards();
|
public Boolean hasRewards();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param rewards
|
* @param rewards
|
||||||
* enable / disable rewards
|
* enable / disable rewards
|
||||||
*/
|
*/
|
||||||
public void setRewards(boolean rewards);
|
public void setRewards(Boolean rewards);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return if players shall see how long they play
|
* @return if players shall see how long they play
|
||||||
*/
|
*/
|
||||||
public boolean getShowTime();
|
public Boolean getShowTime();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param showTime
|
* @param showTime
|
||||||
* set if players shall see how long they play
|
* set if players shall see how long they play
|
||||||
*/
|
*/
|
||||||
public void setShowTime(boolean showTime);
|
public void setShowTime(Boolean showTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return if players can build
|
* @return if all blocks may be destroyed
|
||||||
*/
|
*/
|
||||||
public boolean canBuild();
|
public Boolean canBreakBlocks();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param build
|
* @param breakBlocks
|
||||||
* enable / disable building
|
* if blocks may be destroyed
|
||||||
*/
|
*/
|
||||||
public void setBuild(boolean build);
|
public void setBreakBlocks(Boolean breakBlocks);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if blocks placed in game may be destroyed
|
||||||
|
*/
|
||||||
|
public Boolean canBreakPlacedBlocks();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param breakPlacedBlocks
|
||||||
|
* if placed blocks may be destroyed
|
||||||
|
*/
|
||||||
|
public void setBreakPlacedBlocks(Boolean breakPlacedBlocks);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if blocks may be placed
|
||||||
|
*/
|
||||||
|
public Boolean canPlaceBlocks();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param placeBlocks
|
||||||
|
* if blocks may be placed
|
||||||
|
*/
|
||||||
|
public void setPlaceBlocks(Boolean placeBlocks);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the gameMode
|
* @return the gameMode
|
||||||
@ -125,12 +149,12 @@ public interface GameType {
|
|||||||
/**
|
/**
|
||||||
* @return if players lose lives
|
* @return if players lose lives
|
||||||
*/
|
*/
|
||||||
public boolean hasLives();
|
public Boolean hasLives();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param lives
|
* @param lives
|
||||||
* set if the gametype uses player lives
|
* set if the gametype uses player lives
|
||||||
*/
|
*/
|
||||||
public void setLives(boolean lives);
|
public void setLives(Boolean lives);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,53 +16,78 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.game;
|
package io.github.dre2n.dungeonsxl.game;
|
||||||
|
|
||||||
|
import static io.github.dre2n.dungeonsxl.game.GameGoal.*;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Default implementation of {@link io.github.dre2n.dungeonsxl.game.GameType}.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public enum GameTypeDefault implements GameType {
|
public enum GameTypeDefault implements GameType {
|
||||||
|
|
||||||
ADVENTURE("Adventure", "Adventure", false, false, false, true, false, true, GameMode.ADVENTURE, true),
|
ADVENTURE("Adventure", "Adventure", END, false, false, true, false, true, true, true, GameMode.ADVENTURE, true),
|
||||||
ADVENTURE_TIME_IS_RUNNING("Adventure - Time is Running", "Adventure TiR", false, false, false, true, true, true, GameMode.ADVENTURE, true),
|
ADVENTURE_TIME_IS_RUNNING("Adventure - Time is Running", "Adventure TiR", TIME_SCORE, false, false, true, true, true, true, true, GameMode.ADVENTURE, true),
|
||||||
APOCALYPSE_LAST_MAN_STANDING("Apocalypse", "Apocalypse LMS", true, true, true, true, false, false, GameMode.SURVIVAL, true),
|
APOCALYPSE("Apocalypse", "Apocalypse", HIGHSCORE, true, true, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||||
APOCALYPSE_LIMITED_MOBS("Apocalypse - Limited Mobs", "Apc Limited", true, true, true, true, false, false, GameMode.SURVIVAL, true),
|
APOCALYPSE_LAST_MAN_STANDING("Apocalypse", "Apocalypse LMS", LAST_MAN_STANDING, true, true, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||||
APOCALYPSE_TIME_IS_RUNNING("Apocalypse - Time is Running", "Apocalypse TiR", true, true, true, true, true, false, GameMode.SURVIVAL, true),
|
APOCALYPSE_LIMITED_MOBS("Apocalypse - Limited Mobs", "Apc Limited", END, true, true, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||||
PVE_LAST_MAN_STANDING("Player versus Environment - Last Man Standing", "PvE LMS", false, false, true, true, false, false, GameMode.SURVIVAL, true),
|
APOCALYPSE_TIME_IS_RUNNING("Apocalypse - Time is Running", "Apocalypse TiR", TIME_SURVIVAL, true, true, true, true, false, false, false, GameMode.SURVIVAL, true),
|
||||||
PVE_LIMITED_MOBS("Player versus Environment - Limited Mobs", "PvE Limited", false, false, true, true, false, false, GameMode.SURVIVAL, true),
|
BEDWARS("Bedwars", "Bedwars", LAST_MAN_STANDING, true, false, false, false, false, true, true, GameMode.SURVIVAL, false),
|
||||||
PVE_TIME_IS_RUNNING("Player versus Environment - Time is Running", "PvE TiR", false, false, true, true, true, false, GameMode.SURVIVAL, true),
|
PVE_LAST_MAN_STANDING("Player versus Environment - Last Man Standing", "PvE LMS", LAST_MAN_STANDING, false, false, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||||
PVP_FACTIONS_BATTLEFIELD("Player versus Player - Factions Battlefield", "FactionsPvP", true, false, false, false, false, false, GameMode.SURVIVAL, true),
|
PVE_LIMITED_MOBS("Player versus Environment - Limited Mobs", "PvE Limited", END, false, false, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||||
PVP_LAST_MAN_STANDING("Player versus Player - Last Man Standing", "PvP LMS", true, false, false, false, false, false, GameMode.SURVIVAL, true),
|
PVE_TIME_IS_RUNNING("Player versus Environment - Time is Running", "PvE TiR", TIME_SURVIVAL, false, false, true, true, false, false, false, GameMode.SURVIVAL, true),
|
||||||
QUEST("Quest", "Quest", false, false, false, true, false, false, GameMode.SURVIVAL, true),
|
PVP_FACTIONS_BATTLEFIELD("Player versus Player - Factions Battlefield", "FactionsPvP", LAST_MAN_STANDING, true, false, false, false, false, false, false, GameMode.SURVIVAL, true),
|
||||||
QUEST_TIME_IS_RUNNING("Quest - Time is Running", "Quest TiR", false, false, false, true, true, false, GameMode.SURVIVAL, true),
|
PVP_LAST_MAN_STANDING("Player versus Player - Last Man Standing", "PvP LMS", LAST_MAN_STANDING, true, false, false, false, false, false, false, GameMode.SURVIVAL, true),
|
||||||
TEST("Test", "Test", false, false, false, false, true, true, GameMode.SURVIVAL, false),
|
QUEST("Quest", "Quest", END, false, false, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||||
TUTORIAL("Tutorial", "Tutorial", false, false, false, true, false, false, GameMode.SURVIVAL, false),
|
QUEST_TIME_IS_RUNNING("Quest - Time is Running", "Quest TiR", END, false, false, true, true, false, false, false, GameMode.SURVIVAL, true),
|
||||||
DEFAULT("Default", "Default", false, false, false, true, false, false, GameMode.SURVIVAL, true);
|
TEST("Test", "Test", HIGHSCORE, false, false, false, true, true, true, true, GameMode.SURVIVAL, false),
|
||||||
|
DEFAULT("Default", "Default", END, false, false, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||||
|
CUSTOM("Custom", "Custom");
|
||||||
|
|
||||||
private String displayName;
|
private String displayName;
|
||||||
private String signName;
|
private String signName;
|
||||||
private boolean playerVersusPlayer;
|
private GameGoal gameGoal;
|
||||||
private boolean friendlyFire;
|
private Boolean playerVersusPlayer;
|
||||||
private boolean mobWaves;
|
private Boolean friendlyFire;
|
||||||
private boolean rewards;
|
private Boolean rewards;
|
||||||
private boolean showTime;
|
private Boolean showTime;
|
||||||
private boolean build;
|
private Boolean breakBlocks;
|
||||||
|
private Boolean breakPlacedBlocks;
|
||||||
|
private Boolean placeBlocks;
|
||||||
private GameMode gameMode;
|
private GameMode gameMode;
|
||||||
private boolean lives;
|
private Boolean lives;
|
||||||
|
|
||||||
GameTypeDefault(String displayName, String signName, boolean playerVersusPlayer, boolean friendlyFire, boolean mobWaves, boolean rewards, boolean showTime, boolean build, GameMode gameMode, boolean lives) {
|
GameTypeDefault(String displayName, String signName, GameGoal gameGoal, Boolean playerVersusPlayer, Boolean friendlyFire, Boolean rewards,
|
||||||
|
Boolean showTime, Boolean breakBlocks, Boolean breakPlacedBlocks, Boolean placeBlocks, GameMode gameMode, Boolean lives) {
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
this.signName = signName;
|
this.signName = signName;
|
||||||
|
this.gameGoal = gameGoal;
|
||||||
this.playerVersusPlayer = playerVersusPlayer;
|
this.playerVersusPlayer = playerVersusPlayer;
|
||||||
this.friendlyFire = friendlyFire;
|
this.friendlyFire = friendlyFire;
|
||||||
this.mobWaves = mobWaves;
|
|
||||||
this.rewards = rewards;
|
this.rewards = rewards;
|
||||||
this.showTime = showTime;
|
this.showTime = showTime;
|
||||||
this.build = build;
|
this.breakBlocks = breakBlocks;
|
||||||
|
this.breakPlacedBlocks = breakPlacedBlocks;
|
||||||
|
this.placeBlocks = placeBlocks;
|
||||||
this.gameMode = gameMode;
|
this.gameMode = gameMode;
|
||||||
this.lives = lives;
|
this.lives = lives;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameTypeDefault(String displayName, String signName) {
|
||||||
|
this.displayName = displayName;
|
||||||
|
this.signName = signName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameGoal getGameGoal() {
|
||||||
|
return gameGoal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setGameGoal(GameGoal gameGoal) {
|
||||||
|
this.gameGoal = gameGoal;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDisplayName() {
|
public String getDisplayName() {
|
||||||
return displayName;
|
return displayName;
|
||||||
@ -84,63 +109,73 @@ public enum GameTypeDefault implements GameType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPlayerVersusPlayer() {
|
public Boolean isPlayerVersusPlayer() {
|
||||||
return playerVersusPlayer;
|
return playerVersusPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerVersusPlayer(boolean playerVersusPlayer) {
|
public void setPlayerVersusPlayer(Boolean playerVersusPlayer) {
|
||||||
this.playerVersusPlayer = playerVersusPlayer;
|
this.playerVersusPlayer = playerVersusPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFriendlyFire() {
|
public Boolean isFriendlyFire() {
|
||||||
return friendlyFire;
|
return friendlyFire;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFriendlyFire(boolean friendlyFire) {
|
public void setFriendlyFire(Boolean friendlyFire) {
|
||||||
this.friendlyFire = friendlyFire;
|
this.friendlyFire = friendlyFire;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasMobWaves() {
|
public Boolean hasRewards() {
|
||||||
return mobWaves;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setMobWaves(boolean mobWaves) {
|
|
||||||
this.mobWaves = mobWaves;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasRewards() {
|
|
||||||
return rewards;
|
return rewards;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRewards(boolean rewards) {
|
public void setRewards(Boolean rewards) {
|
||||||
this.rewards = rewards;
|
this.rewards = rewards;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getShowTime() {
|
public Boolean getShowTime() {
|
||||||
return showTime;
|
return showTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setShowTime(boolean showTime) {
|
public void setShowTime(Boolean showTime) {
|
||||||
this.showTime = showTime;
|
this.showTime = showTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBuild() {
|
public Boolean canBreakBlocks() {
|
||||||
return build;
|
return breakBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBuild(boolean build) {
|
public void setBreakBlocks(Boolean breakBlocks) {
|
||||||
this.build = build;
|
this.breakBlocks = breakBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean canBreakPlacedBlocks() {
|
||||||
|
return breakPlacedBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBreakPlacedBlocks(Boolean breakPlacedBlocks) {
|
||||||
|
this.breakPlacedBlocks = breakPlacedBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean canPlaceBlocks() {
|
||||||
|
return placeBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPlaceBlocks(Boolean placeBlocks) {
|
||||||
|
this.placeBlocks = placeBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -154,12 +189,12 @@ public enum GameTypeDefault implements GameType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasLives() {
|
public Boolean hasLives() {
|
||||||
return lives;
|
return lives;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLives(boolean lives) {
|
public void setLives(Boolean lives) {
|
||||||
this.lives = lives;
|
this.lives = lives;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* GameType instance manager.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class GameTypes {
|
public class GameTypes {
|
||||||
|
@ -21,8 +21,10 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
|||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -33,25 +35,35 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A portal that leads into a dungeon.
|
||||||
|
*
|
||||||
* @author Frank Baumann, Daniel Saukel
|
* @author Frank Baumann, Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class DPortal extends GlobalProtection {
|
public class DPortal extends GlobalProtection {
|
||||||
|
|
||||||
private Block block1;
|
private Block block1;
|
||||||
private Block block2;
|
private Block block2;
|
||||||
|
private Material material = Material.PORTAL;
|
||||||
private boolean active;
|
private boolean active;
|
||||||
private Set<Block> blocks;
|
private Set<Block> blocks;
|
||||||
|
|
||||||
public DPortal(int id, World world, boolean active) {
|
public DPortal(int id, World world, boolean active) {
|
||||||
|
this(id, world, Material.PORTAL, active);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DPortal(int id, World world, Material material, boolean active) {
|
||||||
super(world, id);
|
super(world, id);
|
||||||
|
|
||||||
|
this.material = material;
|
||||||
this.active = active;
|
this.active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DPortal(int id, Block block1, Block block2, boolean active) {
|
public DPortal(int id, Block block1, Block block2, Material material, boolean active) {
|
||||||
super(block1.getWorld(), id);
|
super(block1.getWorld(), id);
|
||||||
|
|
||||||
this.block1 = block1;
|
this.block1 = block1;
|
||||||
this.block2 = block2;
|
this.block2 = block2;
|
||||||
|
this.material = material;
|
||||||
this.active = active;
|
this.active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +115,7 @@ public class DPortal extends GlobalProtection {
|
|||||||
/**
|
/**
|
||||||
* Create a new DPortal
|
* Create a new DPortal
|
||||||
*/
|
*/
|
||||||
public void create() {
|
public void create(DGlobalPlayer player) {
|
||||||
if (block1 == null || block2 == null) {
|
if (block1 == null || block2 == null) {
|
||||||
delete();
|
delete();
|
||||||
return;
|
return;
|
||||||
@ -138,11 +150,13 @@ public class DPortal extends GlobalProtection {
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
Material type = getWorld().getBlockAt(xx, yy, zz).getType();
|
Material type = getWorld().getBlockAt(xx, yy, zz).getType();
|
||||||
if (type == Material.AIR || type == Material.WATER || type == Material.STATIONARY_WATER || type == Material.LAVA || type == Material.STATIONARY_LAVA || type == Material.SAPLING
|
if (!type.isSolid()) {
|
||||||
|| type == Material.WEB || type == Material.LONG_GRASS || type == Material.DEAD_BUSH || type == Material.PISTON_EXTENSION || type == Material.YELLOW_FLOWER
|
Block block = getWorld().getBlockAt(xx, yy, zz);
|
||||||
|| type == Material.RED_ROSE || type == Material.BROWN_MUSHROOM || type == Material.RED_MUSHROOM || type == Material.TORCH || type == Material.FIRE
|
block.setType(material, false);
|
||||||
|| type == Material.CROPS || type == Material.REDSTONE_WIRE || type == Material.REDSTONE_TORCH_OFF || type == Material.SNOW || type == Material.REDSTONE_TORCH_ON) {
|
if (player != null && material == Material.PORTAL) {
|
||||||
getWorld().getBlockAt(xx, yy, zz).setType(Material.PORTAL);
|
float yaw = player.getPlayer().getLocation().getYaw();
|
||||||
|
block.setData((yaw >= -135 & yaw < -45 || yaw >= -315 & yaw < -225) ? (byte) 2 : 1, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zz = zz + zcount;
|
zz = zz + zcount;
|
||||||
@ -153,6 +167,10 @@ public class DPortal extends GlobalProtection {
|
|||||||
|
|
||||||
xx = xx + xcount;
|
xx = xx + xcount;
|
||||||
} while (xx != x2 + xcount);
|
} while (xx != x2 + xcount);
|
||||||
|
|
||||||
|
if (player != null) {
|
||||||
|
player.setCreatingPortal(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -186,9 +204,12 @@ public class DPortal extends GlobalProtection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (target == null && dGroup.getMapName() != null) {
|
if (target == null && dGroup.getMapName() != null) {
|
||||||
target = plugin.getDWorlds().getResourceByName(dGroup.getMapName()).instantiateAsGameWorld();//TO DO
|
DResourceWorld resource = plugin.getDWorlds().getResourceByName(dGroup.getMapName());
|
||||||
|
if (resource != null) {
|
||||||
|
target = resource.instantiateAsGameWorld();
|
||||||
dGroup.setGameWorld(target);
|
dGroup.setGameWorld(target);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
MessageUtil.sendMessage(player, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage());
|
MessageUtil.sendMessage(player, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage());
|
||||||
@ -197,6 +218,7 @@ public class DPortal extends GlobalProtection {
|
|||||||
|
|
||||||
if (game == null) {
|
if (game == null) {
|
||||||
game = new Game(dGroup, target);
|
game = new Game(dGroup, target);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
game.setWorld(target);
|
game.setWorld(target);
|
||||||
dGroup.setGameWorld(target);
|
dGroup.setGameWorld(target);
|
||||||
@ -225,20 +247,26 @@ public class DPortal extends GlobalProtection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String preString = "protections.portals." + getWorld().getName() + "." + getId();
|
String preString = "protections.portals." + getWorld().getName() + "." + getId();
|
||||||
// Location1
|
|
||||||
configFile.set(preString + ".loc1.x", block1.getX());
|
configFile.set(preString + ".loc1.x", block1.getX());
|
||||||
configFile.set(preString + ".loc1.y", block1.getY());
|
configFile.set(preString + ".loc1.y", block1.getY());
|
||||||
configFile.set(preString + ".loc1.z", block1.getZ());
|
configFile.set(preString + ".loc1.z", block1.getZ());
|
||||||
// Location1
|
|
||||||
configFile.set(preString + ".loc2.x", block2.getX());
|
configFile.set(preString + ".loc2.x", block2.getX());
|
||||||
configFile.set(preString + ".loc2.y", block2.getY());
|
configFile.set(preString + ".loc2.y", block2.getY());
|
||||||
configFile.set(preString + ".loc2.z", block2.getZ());
|
configFile.set(preString + ".loc2.z", block2.getZ());
|
||||||
|
|
||||||
|
configFile.set(preString + ".material", material.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete() {
|
public void delete() {
|
||||||
protections.removeProtection(this);
|
protections.removeProtection(this);
|
||||||
|
|
||||||
|
if (block1 == null || block2 == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int x1 = block1.getX(), y1 = block1.getY(), z1 = block1.getZ();
|
int x1 = block1.getX(), y1 = block1.getY(), z1 = block1.getZ();
|
||||||
int x2 = block2.getX(), y2 = block2.getY(), z2 = block2.getZ();
|
int x2 = block2.getX(), y2 = block2.getY(), z2 = block2.getZ();
|
||||||
int xcount = 0, ycount = 0, zcount = 0;
|
int xcount = 0, ycount = 0, zcount = 0;
|
||||||
@ -269,7 +297,7 @@ public class DPortal extends GlobalProtection {
|
|||||||
do {
|
do {
|
||||||
Material type = getWorld().getBlockAt(xx, yy, zz).getType();
|
Material type = getWorld().getBlockAt(xx, yy, zz).getType();
|
||||||
|
|
||||||
if (type == Material.PORTAL) {
|
if (type == material) {
|
||||||
getWorld().getBlockAt(xx, yy, zz).setType(Material.AIR);
|
getWorld().getBlockAt(xx, yy, zz).setType(Material.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Basically a GroupSign, but to form a game of multiple groups.
|
||||||
|
*
|
||||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class GameSign extends GlobalProtection {
|
public class GameSign extends GlobalProtection {
|
||||||
|
@ -1,11 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* Copyright (C) 2012-2016 Frank Baumann
|
||||||
* To change this template file, choose Tools | Templates
|
*
|
||||||
* and open the template in the editor.
|
* 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.global;
|
package io.github.dre2n.dungeonsxl.global;
|
||||||
|
|
||||||
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -54,6 +68,7 @@ public abstract class GlobalProtection {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Actions */
|
||||||
/**
|
/**
|
||||||
* Delete this protection.
|
* Delete this protection.
|
||||||
*/
|
*/
|
||||||
@ -61,7 +76,6 @@ public abstract class GlobalProtection {
|
|||||||
protections.removeProtection(this);
|
protections.removeProtection(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Abstracts */
|
|
||||||
/**
|
/**
|
||||||
* Save the data to the default file
|
* Save the data to the default file
|
||||||
*/
|
*/
|
||||||
@ -77,6 +91,20 @@ public abstract class GlobalProtection {
|
|||||||
save(YamlConfiguration.loadConfiguration(file));
|
save(YamlConfiguration.loadConfiguration(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean onBreak(DGlobalPlayer dPlayer) {
|
||||||
|
if (dPlayer.isInBreakMode()) {
|
||||||
|
delete();
|
||||||
|
MessageUtil.sendMessage(dPlayer.getPlayer(), plugin.getMessageConfig().getMessage(DMessages.PLAYER_PROTECTED_BLOCK_DELETED));
|
||||||
|
MessageUtil.sendMessage(dPlayer.getPlayer(), plugin.getMessageConfig().getMessage(DMessages.CMD_BREAK_PROTECTED_MODE));
|
||||||
|
dPlayer.setInBreakMode(false);
|
||||||
|
return false;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Abstracts */
|
||||||
/**
|
/**
|
||||||
* @param config
|
* @param config
|
||||||
* the config to save the protection to
|
* the config to save the protection to
|
||||||
|
@ -1,7 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* Copyright (C) 2012-2016 Frank Baumann
|
||||||
* To change this template file, choose Tools | Templates
|
*
|
||||||
* and open the template in the editor.
|
* 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.global;
|
package io.github.dre2n.dungeonsxl.global;
|
||||||
|
|
||||||
@ -10,6 +21,7 @@ import java.io.File;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
@ -225,8 +237,9 @@ public class GlobalProtections {
|
|||||||
if (data.contains(preString)) {
|
if (data.contains(preString)) {
|
||||||
Block block1 = world.getBlockAt(data.getInt(preString + "loc1.x"), data.getInt(preString + "loc1.y"), data.getInt(preString + "loc1.z"));
|
Block block1 = world.getBlockAt(data.getInt(preString + "loc1.x"), data.getInt(preString + "loc1.y"), data.getInt(preString + "loc1.z"));
|
||||||
Block block2 = world.getBlockAt(data.getInt(preString + "loc2.x"), data.getInt(preString + "loc2.y"), data.getInt(preString + "loc2.z"));
|
Block block2 = world.getBlockAt(data.getInt(preString + "loc2.x"), data.getInt(preString + "loc2.y"), data.getInt(preString + "loc2.z"));
|
||||||
DPortal dPortal = new DPortal(id, block1, block2, true);
|
Material material = Material.getMaterial(data.getString(preString + "material"));
|
||||||
dPortal.create();
|
DPortal dPortal = new DPortal(id, block1, block2, material != null ? material : Material.PORTAL, true);
|
||||||
|
dPortal.create(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (data.contains(preString));
|
} while (data.contains(preString));
|
||||||
|
@ -33,6 +33,8 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A sign to form a group and to define its dungeon.
|
||||||
|
*
|
||||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class GroupSign extends GlobalProtection {
|
public class GroupSign extends GlobalProtection {
|
||||||
|
@ -30,6 +30,8 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A sign to leave a group.
|
||||||
|
*
|
||||||
* @author Frank Baumann
|
* @author Frank Baumann
|
||||||
*/
|
*/
|
||||||
public class LeaveSign extends GlobalProtection {
|
public class LeaveSign extends GlobalProtection {
|
||||||
@ -44,14 +46,7 @@ public class LeaveSign extends GlobalProtection {
|
|||||||
setText();
|
setText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setText() {
|
/* Getters and setters */
|
||||||
sign.setLine(0, ChatColor.BLUE + "############");
|
|
||||||
sign.setLine(1, ChatColor.DARK_GREEN + "Leave");
|
|
||||||
sign.setLine(2, "");
|
|
||||||
sign.setLine(3, ChatColor.BLUE + "############");
|
|
||||||
sign.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Block> getBlocks() {
|
public Set<Block> getBlocks() {
|
||||||
if (blocks == null) {
|
if (blocks == null) {
|
||||||
@ -64,6 +59,34 @@ public class LeaveSign extends GlobalProtection {
|
|||||||
return blocks;
|
return blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Actions */
|
||||||
|
public void setText() {
|
||||||
|
sign.setLine(0, ChatColor.BLUE + "############");
|
||||||
|
sign.setLine(1, ChatColor.DARK_GREEN + "Leave");
|
||||||
|
sign.setLine(2, "");
|
||||||
|
sign.setLine(3, ChatColor.BLUE + "############");
|
||||||
|
sign.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPlayerInteract(Player player) {
|
||||||
|
DGamePlayer dplayer = DGamePlayer.getByPlayer(player);
|
||||||
|
|
||||||
|
if (dplayer != null) {
|
||||||
|
dplayer.leave();
|
||||||
|
return;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
DGroup group = DGroup.getByPlayer(player);
|
||||||
|
if (group != null) {
|
||||||
|
group.removePlayer(player);
|
||||||
|
MessageUtil.sendMessage(player, DMessages.PLAYER_LEAVE_GROUP.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(FileConfiguration config) {
|
public void save(FileConfiguration config) {
|
||||||
String preString = "protections.leaveSigns." + sign.getWorld().getName() + "." + getId();
|
String preString = "protections.leaveSigns." + sign.getWorld().getName() + "." + getId();
|
||||||
@ -89,32 +112,4 @@ public class LeaveSign extends GlobalProtection {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SUBJECT TO CHANGE */
|
|
||||||
@Deprecated
|
|
||||||
public static boolean playerInteract(Block block, Player player) {
|
|
||||||
|
|
||||||
LeaveSign leaveSign = getByBlock(block);
|
|
||||||
|
|
||||||
if (leaveSign == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DGamePlayer dplayer = DGamePlayer.getByPlayer(player);
|
|
||||||
|
|
||||||
if (dplayer != null) {
|
|
||||||
dplayer.leave();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
DGroup dgroup = DGroup.getByPlayer(player);
|
|
||||||
if (dgroup != null) {
|
|
||||||
dgroup.removePlayer(player);
|
|
||||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.PLAYER_LEAVE_GROUP));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,6 @@ import io.github.dre2n.commons.util.NumberUtil;
|
|||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
|
||||||
import io.github.dre2n.dungeonsxl.game.GamePlaceableBlock;
|
|
||||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
|
||||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
|
||||||
import io.github.dre2n.dungeonsxl.global.DPortal;
|
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||||
import io.github.dre2n.dungeonsxl.global.GameSign;
|
import io.github.dre2n.dungeonsxl.global.GameSign;
|
||||||
import io.github.dre2n.dungeonsxl.global.GlobalProtection;
|
import io.github.dre2n.dungeonsxl.global.GlobalProtection;
|
||||||
@ -36,9 +32,10 @@ import io.github.dre2n.dungeonsxl.sign.DSign;
|
|||||||
import io.github.dre2n.dungeonsxl.task.RedstoneEventTask;
|
import io.github.dre2n.dungeonsxl.task.RedstoneEventTask;
|
||||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import org.bukkit.Location;
|
import io.github.dre2n.dungeonsxl.world.DInstanceWorld;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -54,7 +51,7 @@ import org.bukkit.event.block.BlockSpreadEvent;
|
|||||||
import org.bukkit.event.block.SignChangeEvent;
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
* @author Frank Baumann, Milan Albrecht, Daniel Saukel, Wooyoung Son
|
||||||
*/
|
*/
|
||||||
public class BlockListener implements Listener {
|
public class BlockListener implements Listener {
|
||||||
|
|
||||||
@ -63,15 +60,33 @@ public class BlockListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPhysics(BlockPhysicsEvent event) {
|
public void onPhysics(BlockPhysicsEvent event) {
|
||||||
if (event.getBlock().getType() != Material.PORTAL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DPortal.getByBlock(event.getBlock()) != null) {
|
if (DPortal.getByBlock(event.getBlock()) != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBreakWithSignOnIt(BlockBreakEvent event){
|
||||||
|
Block block = event.getBlock();
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
Block blockAbove = block.getRelative(BlockFace.UP);
|
||||||
|
//get the above block and return if there is nothing
|
||||||
|
if(blockAbove == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//return if above block is not a sign
|
||||||
|
if(blockAbove.getType() != Material.SIGN_POST && blockAbove.getType() != Material.WALL_SIGN)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//let onBreak() method to handle the sign
|
||||||
|
BlockBreakEvent bbe = new BlockBreakEvent(blockAbove, player);
|
||||||
|
onBreak(bbe);
|
||||||
|
|
||||||
|
//follow the onBreak()
|
||||||
|
event.setCancelled(bbe.isCancelled());
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onBreak(BlockBreakEvent event) {
|
public void onBreak(BlockBreakEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
@ -80,16 +95,9 @@ public class BlockListener implements Listener {
|
|||||||
|
|
||||||
GlobalProtection protection = plugin.getGlobalProtections().getByBlock(event.getBlock());
|
GlobalProtection protection = plugin.getGlobalProtections().getByBlock(event.getBlock());
|
||||||
if (protection != null) {
|
if (protection != null) {
|
||||||
if (dGlobalPlayer.isInBreakMode()) {
|
if (protection.onBreak(dGlobalPlayer)) {
|
||||||
protection.delete();
|
|
||||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.PLAYER_PROTECTED_BLOCK_DELETED));
|
|
||||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.CMD_BREAK_PROTECTED_MODE));
|
|
||||||
dGlobalPlayer.setInBreakMode(false);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,24 +111,7 @@ public class BlockListener implements Listener {
|
|||||||
// Deny DGameWorld block breaking
|
// Deny DGameWorld block breaking
|
||||||
DGameWorld gameWorld = DGameWorld.getByWorld(block.getWorld());
|
DGameWorld gameWorld = DGameWorld.getByWorld(block.getWorld());
|
||||||
if (gameWorld != null) {
|
if (gameWorld != null) {
|
||||||
for (DSign dSign : gameWorld.getDSigns()) {
|
if (gameWorld.onBreak(event)) {
|
||||||
if (dSign.getSign().equals(block)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Game game = gameWorld.getGame();
|
|
||||||
if (game != null) {
|
|
||||||
GameType gameType = game.getType();
|
|
||||||
if (gameType == GameTypeDefault.DEFAULT) {
|
|
||||||
event.setCancelled(!game.getRules().canBuild());
|
|
||||||
|
|
||||||
} else if (!gameType.canBuild()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,28 +127,10 @@ public class BlockListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Game game = gameWorld.getGame();
|
if (gameWorld.onPlace(event.getPlayer(), block, event.getBlockAgainst(), event.getItemInHand())) {
|
||||||
if (game != null) {
|
|
||||||
if (game.getRules().canBuild() || GamePlaceableBlock.canBuildHere(block, block.getFace(event.getBlockAgainst()), event.getItemInHand().getType(), gameWorld)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Workaround for a bug that would allow 3-Block-high jumping
|
|
||||||
Location loc = event.getPlayer().getLocation();
|
|
||||||
if (loc.getY() > block.getY() + 1.0 && loc.getY() <= block.getY() + 1.5) {
|
|
||||||
if (loc.getX() >= block.getX() - 0.3 && loc.getX() <= block.getX() + 1.3) {
|
|
||||||
if (loc.getZ() >= block.getZ() - 0.3 && loc.getZ() <= block.getZ() + 1.3) {
|
|
||||||
loc.setX(block.getX() + 0.5);
|
|
||||||
loc.setY(block.getY());
|
|
||||||
loc.setZ(block.getZ() + 0.5);
|
|
||||||
event.getPlayer().teleport(loc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onSignChange(SignChangeEvent event) {
|
public void onSignChange(SignChangeEvent event) {
|
||||||
@ -246,21 +219,13 @@ public class BlockListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onSpread(BlockSpreadEvent event) {
|
public void onSpread(BlockSpreadEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getSource();
|
||||||
// Block the Spread off Vines
|
|
||||||
if (block.getType() != Material.VINE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check GameWorlds
|
DInstanceWorld instance = plugin.getDWorlds().getInstanceByName(block.getWorld().getName());
|
||||||
DGameWorld gameWorld = DGameWorld.getByWorld(event.getBlock().getWorld());
|
if (instance != null && block.getType() == Material.VINE) {
|
||||||
if (gameWorld != null) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
|
||||||
|
|
||||||
// Check EditWorlds
|
} else if (DPortal.getByBlock(block) != null) {
|
||||||
DEditWorld editWorld = DEditWorld.getByWorld(event.getBlock().getWorld());
|
|
||||||
if (editWorld != null) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,10 @@ public class EntityListener implements Listener {
|
|||||||
DGroup attackerDGroup = null;
|
DGroup attackerDGroup = null;
|
||||||
DGroup attackedDGroup = null;
|
DGroup attackedDGroup = null;
|
||||||
|
|
||||||
if (attackerEntity instanceof LivingEntity && attackedEntity instanceof LivingEntity) {
|
if (!(attackerEntity instanceof LivingEntity) || !(attackedEntity instanceof LivingEntity)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (attackerEntity instanceof Player && attackedEntity instanceof Player) {
|
if (attackerEntity instanceof Player && attackedEntity instanceof Player) {
|
||||||
attackerPlayer = (Player) attackerEntity;
|
attackerPlayer = (Player) attackerEntity;
|
||||||
attackedPlayer = (Player) attackedEntity;
|
attackedPlayer = (Player) attackedEntity;
|
||||||
@ -180,11 +183,13 @@ public class EntityListener implements Listener {
|
|||||||
|
|
||||||
if (!pvp) {
|
if (!pvp) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attackerDGroup != null && attackedDGroup != null) {
|
if (attackerDGroup != null && attackedDGroup != null) {
|
||||||
if (!friendlyFire && attackerDGroup.equals(attackedDGroup)) {
|
if (!friendlyFire && attackerDGroup.equals(attackedDGroup)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,7 +221,6 @@ public class EntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Deny food in Lobby
|
// Deny food in Lobby
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
@ -20,8 +20,6 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
|||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.config.MainConfig;
|
import io.github.dre2n.dungeonsxl.config.MainConfig;
|
||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
|
||||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerDeathEvent;
|
|
||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.global.DPortal;
|
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||||
import io.github.dre2n.dungeonsxl.global.GameSign;
|
import io.github.dre2n.dungeonsxl.global.GameSign;
|
||||||
@ -35,22 +33,21 @@ import io.github.dre2n.dungeonsxl.player.DGroup;
|
|||||||
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPlayers;
|
import io.github.dre2n.dungeonsxl.player.DPlayers;
|
||||||
import io.github.dre2n.dungeonsxl.player.DSavePlayer;
|
|
||||||
import io.github.dre2n.dungeonsxl.reward.DLootInventory;
|
import io.github.dre2n.dungeonsxl.reward.DLootInventory;
|
||||||
import io.github.dre2n.dungeonsxl.reward.RewardChest;
|
|
||||||
import io.github.dre2n.dungeonsxl.sign.OpenDoorSign;
|
|
||||||
import io.github.dre2n.dungeonsxl.task.RespawnTask;
|
import io.github.dre2n.dungeonsxl.task.RespawnTask;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.UseItemTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.UseItemTrigger;
|
||||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.block.LockedDoor;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.block.RewardChest;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -88,55 +85,11 @@ public class PlayerListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onDeath(PlayerDeathEvent event) {
|
public void onDeath(PlayerDeathEvent event) {
|
||||||
Player player = event.getEntity();
|
Player player = event.getEntity();
|
||||||
|
|
||||||
DGameWorld gameWorld = DGameWorld.getByWorld(player.getLocation().getWorld());
|
|
||||||
if (gameWorld == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Game game = Game.getByGameWorld(gameWorld);
|
|
||||||
if (game == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
|
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
|
||||||
if (dPlayer == null) {
|
if (dPlayer == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
dPlayer.onDeath(event);
|
||||||
DPlayerDeathEvent dPlayerDeathEvent = new DPlayerDeathEvent(dPlayer, event, 1);
|
|
||||||
plugin.getServer().getPluginManager().callEvent(dPlayerDeathEvent);
|
|
||||||
|
|
||||||
if (dPlayerDeathEvent.isCancelled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gameWorld.getGame() != null) {
|
|
||||||
if (!gameWorld.getGame().getType().hasLives()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dPlayer.setLives(dPlayer.getLives() - dPlayerDeathEvent.getLostLives());
|
|
||||||
|
|
||||||
if (dPlayer.getLives() != -1) {
|
|
||||||
MessageUtil.sendMessage(player, DMessages.PLAYER_DEATH.getMessage(String.valueOf(dPlayer.getLives())));
|
|
||||||
|
|
||||||
if (game.getRules().getKeepInventoryOnDeath()) {
|
|
||||||
dPlayer.setRespawnInventory(event.getEntity().getInventory().getContents());
|
|
||||||
dPlayer.setRespawnArmor(event.getEntity().getInventory().getArmorContents());
|
|
||||||
// Delete all drops
|
|
||||||
for (ItemStack item : event.getDrops()) {
|
|
||||||
item.setType(Material.AIR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dPlayer.getLives() == 0 && dPlayer.isReady()) {
|
|
||||||
dPlayer.kill();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
@ -144,6 +97,7 @@ public class PlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
DGlobalPlayer dGlobalPlayer = dPlayers.getByPlayer(player);
|
DGlobalPlayer dGlobalPlayer = dPlayers.getByPlayer(player);
|
||||||
Block clickedBlock = event.getClickedBlock();
|
Block clickedBlock = event.getClickedBlock();
|
||||||
|
DGameWorld dGameWorld = DGameWorld.getByWorld(player.getWorld());
|
||||||
|
|
||||||
if (dGlobalPlayer.isInBreakMode()) {
|
if (dGlobalPlayer.isInBreakMode()) {
|
||||||
return;
|
return;
|
||||||
@ -151,7 +105,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
if (clickedBlock != null) {
|
if (clickedBlock != null) {
|
||||||
// Block Enderchests
|
// Block Enderchests
|
||||||
if (DGameWorld.getByWorld(player.getWorld()) != null || DEditWorld.getByWorld(player.getWorld()) != null) {
|
if (dGameWorld != null || DEditWorld.getByWorld(player.getWorld()) != null) {
|
||||||
if (event.getAction() != Action.LEFT_CLICK_BLOCK) {
|
if (event.getAction() != Action.LEFT_CLICK_BLOCK) {
|
||||||
if (clickedBlock.getType() == Material.ENDER_CHEST) {
|
if (clickedBlock.getType() == Material.ENDER_CHEST) {
|
||||||
if (!DPermissions.hasPermission(player, DPermissions.BYPASS)) {
|
if (!DPermissions.hasPermission(player, DPermissions.BYPASS)) {
|
||||||
@ -169,7 +123,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Block Dispensers
|
// Block Dispensers
|
||||||
if (DGameWorld.getByWorld(player.getWorld()) != null) {
|
if (dGameWorld != null) {
|
||||||
if (event.getAction() != Action.LEFT_CLICK_BLOCK) {
|
if (event.getAction() != Action.LEFT_CLICK_BLOCK) {
|
||||||
if (clickedBlock.getType() == Material.DISPENSER) {
|
if (clickedBlock.getType() == Material.DISPENSER) {
|
||||||
if (!DPermissions.hasPermission(player, DPermissions.BYPASS)) {
|
if (!DPermissions.hasPermission(player, DPermissions.BYPASS)) {
|
||||||
@ -178,6 +132,13 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (LockedDoor door : dGameWorld.getLockedDoors()) {
|
||||||
|
if (clickedBlock.equals(door.getBlock()) || clickedBlock.equals(door.getAttachedBlock())) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +160,7 @@ public class PlayerListener implements Listener {
|
|||||||
} else if (dPortal.getBlock2() == null) {
|
} else if (dPortal.getBlock2() == null) {
|
||||||
dPortal.setBlock2(event.getClickedBlock());
|
dPortal.setBlock2(event.getClickedBlock());
|
||||||
dPortal.setActive(true);
|
dPortal.setActive(true);
|
||||||
dPortal.create();
|
dPortal.create(dGlobalPlayer);
|
||||||
MessageUtil.sendMessage(player, DMessages.PLAYER_PORTAL_CREATED.getMessage());
|
MessageUtil.sendMessage(player, DMessages.PLAYER_PORTAL_CREATED.getMessage());
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -266,8 +227,9 @@ public class PlayerListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Leave Sign
|
LeaveSign leaveSign = LeaveSign.getByBlock(clickedBlock);
|
||||||
if (LeaveSign.playerInteract(event.getClickedBlock(), player)) {
|
if (leaveSign != null) {
|
||||||
|
leaveSign.onPlayerInteract(player);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,9 +261,6 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (OpenDoorSign.isProtected(clickedBlock)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -403,7 +362,12 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPortal(PlayerPortalEvent event) {
|
public void onPortal(PlayerPortalEvent event) {
|
||||||
if (DPortal.getByLocation(event.getFrom()) != null) {
|
Block block1 = event.getFrom().getBlock();
|
||||||
|
Block block2 = block1.getRelative(BlockFace.WEST);
|
||||||
|
Block block3 = block1.getRelative(BlockFace.NORTH);
|
||||||
|
Block block4 = block1.getRelative(BlockFace.EAST);
|
||||||
|
Block block5 = block1.getRelative(BlockFace.SOUTH);
|
||||||
|
if (DPortal.getByBlock(block1) != null || DPortal.getByBlock(block2) != null || DPortal.getByBlock(block3) != null || DPortal.getByBlock(block4) != null || DPortal.getByBlock(block5) != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -461,11 +425,11 @@ public class PlayerListener implements Listener {
|
|||||||
((DGamePlayer) dPlayer).leave();
|
((DGamePlayer) dPlayer).leave();
|
||||||
|
|
||||||
} else if (timeUntilKickOfflinePlayer > 0) {
|
} else if (timeUntilKickOfflinePlayer > 0) {
|
||||||
dGroup.sendMessage(DMessages.PLAYER_OFFLINE.getMessage(dPlayer.getPlayer().getName(), String.valueOf(timeUntilKickOfflinePlayer)), player);
|
dGroup.sendMessage(DMessages.PLAYER_OFFLINE.getMessage(dPlayer.getName(), String.valueOf(timeUntilKickOfflinePlayer)), player);
|
||||||
((DGamePlayer) dPlayer).setOfflineTime(System.currentTimeMillis() + timeUntilKickOfflinePlayer * 1000);
|
((DGamePlayer) dPlayer).setOfflineTime(System.currentTimeMillis() + timeUntilKickOfflinePlayer * 1000);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dGroup.sendMessage(DMessages.PLAYER_OFFLINE_NEVER.getMessage(dPlayer.getPlayer().getName()), player);
|
dGroup.sendMessage(DMessages.PLAYER_OFFLINE_NEVER.getMessage(dPlayer.getName()), player);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (dPlayer instanceof DEditPlayer) {
|
} else if (dPlayer instanceof DEditPlayer) {
|
||||||
@ -476,91 +440,25 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onJoin(PlayerJoinEvent event) {
|
public void onJoin(PlayerJoinEvent event) {
|
||||||
plugin.debug.start("PlayerListener#onJoin");
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
if (dPlayers.checkPlayer(player)) {
|
||||||
new DGlobalPlayer(player);
|
return;
|
||||||
|
|
||||||
// Check dPlayers
|
|
||||||
DGamePlayer dPlayer = DGamePlayer.getByName(player.getName());
|
|
||||||
if (dPlayer != null) {
|
|
||||||
DGroup dGroup = DGroup.getByPlayer(dPlayer.getPlayer());
|
|
||||||
if (dGroup != null) {
|
|
||||||
dGroup.getPlayers().remove(dPlayer.getPlayer());
|
|
||||||
dGroup.getPlayers().add(player);
|
|
||||||
}
|
|
||||||
dPlayer.setPlayer(player);
|
|
||||||
|
|
||||||
// Check offlineTime
|
|
||||||
dPlayer.setOfflineTime(0);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
DSavePlayer dSavePlayer = dPlayers.getDSavePlayerByPlayer(player);
|
|
||||||
|
|
||||||
Location target = Bukkit.getServer().getWorlds().get(0).getSpawnLocation();
|
|
||||||
if (dSavePlayer != null) {
|
|
||||||
target = dSavePlayer.getOldLocation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEditWorld.getByWorld(player.getWorld()) != null || DGameWorld.getByWorld(player.getWorld()) != null) {
|
DGlobalPlayer dPlayer = new DGlobalPlayer(player);
|
||||||
player.teleport(target);
|
if (player.hasPlayedBefore()) {
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tutorial Mode
|
|
||||||
if (!plugin.getMainConfig().isTutorialActivated()) {
|
if (!plugin.getMainConfig().isTutorialActivated()) {
|
||||||
plugin.debug.end("PlayerListener#onJoin", true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DGamePlayer.getByPlayer(player) != null) {
|
if (DGamePlayer.getByPlayer(player) != null) {
|
||||||
plugin.debug.end("PlayerListener#onJoin", true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.getPermissionProvider() == null || !plugin.getPermissionProvider().hasGroupSupport()) {
|
dPlayer.startTutorial();
|
||||||
plugin.debug.end("PlayerListener#onJoin", true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((plugin.getMainConfig().getTutorialDungeon() == null || plugin.getMainConfig().getTutorialStartGroup() == null || plugin.getMainConfig().getTutorialEndGroup() == null)) {
|
|
||||||
plugin.debug.end("PlayerListener#onJoin", true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String group : plugin.getPermissionProvider().getPlayerGroups(player)) {
|
|
||||||
if (!plugin.getMainConfig().getTutorialStartGroup().equalsIgnoreCase(group)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
DGroup dGroup = new DGroup(player, plugin.getMainConfig().getTutorialDungeon(), false);
|
|
||||||
|
|
||||||
DGroupCreateEvent createEvent = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.GROUP_SIGN);
|
|
||||||
plugin.getServer().getPluginManager().callEvent(createEvent);
|
|
||||||
|
|
||||||
if (createEvent.isCancelled()) {
|
|
||||||
dGroup = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dGroup == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dGroup.getGameWorld() == null) {
|
|
||||||
dGroup.setGameWorld(plugin.getDWorlds().getResourceByName(DGroup.getByPlayer(player).getMapName()).instantiateAsGameWorld());// TO DO
|
|
||||||
dGroup.getGameWorld().setTutorial(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dGroup.getGameWorld() == null) {
|
|
||||||
MessageUtil.sendMessage(player, DMessages.ERROR_TUTORIAL_NOT_EXIST.getMessage());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
DGamePlayer.create(player, dGroup.getGameWorld());
|
|
||||||
plugin.debug.end("PlayerListener#onJoin", true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
plugin.debug.end("PlayerListener#onJoin", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
@ -711,25 +609,37 @@ public class PlayerListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onMove(PlayerMoveEvent event) {
|
public void onMove(PlayerMoveEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
DGameWorld gameWorld = DGameWorld.getByWorld(player.getWorld());
|
||||||
|
DGamePlayer gamePlayer = DGamePlayer.getByPlayer(player);
|
||||||
|
if (gameWorld != null && gamePlayer != null && gamePlayer.isStealing()) {
|
||||||
|
DGroup group = gamePlayer.getDGroup();
|
||||||
|
Location startLocation = gameWorld.getStartLocation(group);
|
||||||
|
|
||||||
|
if (startLocation.distance(player.getLocation()) < 3) {
|
||||||
|
gamePlayer.captureFlag();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DLootInventory inventory = DLootInventory.getByPlayer(player);
|
DLootInventory inventory = DLootInventory.getByPlayer(player);
|
||||||
|
if (inventory != null && player.getLocation().getBlock().getRelative(0, 1, 0).getType() != Material.PORTAL && player.getLocation().getBlock().getRelative(0, -1, 0).getType() != Material.PORTAL
|
||||||
DPortal dPortal = DPortal.getByLocation(player.getEyeLocation());
|
|
||||||
//TODO: Fix chat spam
|
|
||||||
if (dPortal != null) {
|
|
||||||
dPortal.teleport(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inventory == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player.getLocation().getBlock().getRelative(0, 1, 0).getType() != Material.PORTAL && player.getLocation().getBlock().getRelative(0, -1, 0).getType() != Material.PORTAL
|
|
||||||
&& player.getLocation().getBlock().getRelative(1, 0, 0).getType() != Material.PORTAL && player.getLocation().getBlock().getRelative(-1, 0, 0).getType() != Material.PORTAL
|
&& player.getLocation().getBlock().getRelative(1, 0, 0).getType() != Material.PORTAL && player.getLocation().getBlock().getRelative(-1, 0, 0).getType() != Material.PORTAL
|
||||||
&& player.getLocation().getBlock().getRelative(0, 0, 1).getType() != Material.PORTAL && player.getLocation().getBlock().getRelative(0, 0, -1).getType() != Material.PORTAL) {
|
&& player.getLocation().getBlock().getRelative(0, 0, 1).getType() != Material.PORTAL && player.getLocation().getBlock().getRelative(0, 0, -1).getType() != Material.PORTAL) {
|
||||||
inventory.setInventoryView(player.openInventory(inventory.getInventory()));
|
inventory.setInventoryView(player.openInventory(inventory.getInventory()));
|
||||||
inventory.setTime(System.currentTimeMillis());
|
inventory.setTime(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DPortal dPortal = DPortal.getByLocation(player.getEyeLocation());
|
||||||
|
if (dPortal == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Block blockFrom = event.getFrom().getBlock();
|
||||||
|
Block blockTo = event.getTo().getBlock();
|
||||||
|
if (blockFrom.equals(blockTo)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dPortal.teleport(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A loot table for rewards and mob drops.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class DLootTable {
|
public class DLootTable {
|
||||||
|
@ -22,6 +22,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* DLootTable instance manager.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class DLootTables {
|
public class DLootTables {
|
||||||
|
@ -26,6 +26,8 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* ExternalMobProvider implementation for Citizens.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class CitizensMobProvider implements ExternalMobProvider {
|
public class CitizensMobProvider implements ExternalMobProvider {
|
||||||
|
@ -21,6 +21,8 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A custom external mob provider like defined in the main config file.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class CustomExternalMobProvider implements ExternalMobProvider {
|
public class CustomExternalMobProvider implements ExternalMobProvider {
|
||||||
|
@ -20,6 +20,8 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Officially supported external mob plugins.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public enum ExternalMobPlugin implements ExternalMobProvider {
|
public enum ExternalMobPlugin implements ExternalMobProvider {
|
||||||
|
@ -19,6 +19,8 @@ package io.github.dre2n.dungeonsxl.mob;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Implement this to create custom ExternalMobProviders.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public interface ExternalMobProvider {
|
public interface ExternalMobProvider {
|
||||||
|
@ -25,6 +25,8 @@ import java.util.Set;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* ExternalMobProvider instance manager.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class ExternalMobProviders {
|
public class ExternalMobProviders {
|
||||||
|
@ -29,6 +29,8 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Represents a class and a class script.
|
||||||
|
*
|
||||||
* @author Frank Baumann, Daniel Saukel
|
* @author Frank Baumann, Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class DClass {
|
public class DClass {
|
||||||
|
@ -22,6 +22,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* DClass instance manager.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class DClasses {
|
public class DClasses {
|
||||||
|
@ -19,7 +19,7 @@ package io.github.dre2n.dungeonsxl.player;
|
|||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerUpdateEvent;
|
import io.github.dre2n.dungeonsxl.event.dplayer.instance.DInstancePlayerUpdateEvent;
|
||||||
import io.github.dre2n.dungeonsxl.task.CreateDInstancePlayerTask;
|
import io.github.dre2n.dungeonsxl.task.CreateDInstancePlayerTask;
|
||||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
@ -33,7 +33,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.block.SignChangeEvent;
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a player in an DEditWorld.
|
* Represents a player in a DEditWorld.
|
||||||
*
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
@ -106,7 +106,7 @@ public class DEditPlayer extends DInstancePlayer {
|
|||||||
*/
|
*/
|
||||||
public void escape() {
|
public void escape() {
|
||||||
delete();
|
delete();
|
||||||
getSavePlayer().reset(false);
|
reset(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void poke(Block block) {
|
public void poke(Block block) {
|
||||||
@ -142,7 +142,7 @@ public class DEditPlayer extends DInstancePlayer {
|
|||||||
public void leave() {
|
public void leave() {
|
||||||
delete();
|
delete();
|
||||||
|
|
||||||
getSavePlayer().reset(false);
|
reset(false);
|
||||||
|
|
||||||
DEditWorld editWorld = DEditWorld.getByWorld(getWorld());
|
DEditWorld editWorld = DEditWorld.getByWorld(getWorld());
|
||||||
if (editWorld != null) {
|
if (editWorld != null) {
|
||||||
@ -183,7 +183,7 @@ public class DEditPlayer extends DInstancePlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DPlayerUpdateEvent event = new DPlayerUpdateEvent(this, locationValid, false, false, false, false, false);
|
DInstancePlayerUpdateEvent event = new DInstancePlayerUpdateEvent(this, locationValid, false, false, false, false, false);
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
@ -207,7 +207,7 @@ public class DEditPlayer extends DInstancePlayer {
|
|||||||
|
|
||||||
public static DEditPlayer getByName(String name) {
|
public static DEditPlayer getByName(String name) {
|
||||||
for (DEditPlayer dPlayer : plugin.getDPlayers().getDEditPlayers()) {
|
for (DEditPlayer dPlayer : plugin.getDPlayers().getDEditPlayers()) {
|
||||||
if (dPlayer.getPlayer().getName().equalsIgnoreCase(name)) {
|
if (dPlayer.getName().equalsIgnoreCase(name)) {
|
||||||
return dPlayer;
|
return dPlayer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,13 @@ import io.github.dre2n.dungeonsxl.config.DMessages;
|
|||||||
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
|
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
|
||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishDungeonEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishDungeonEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupRewardEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupRewardEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerFinishEvent;
|
|
||||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
|
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerUpdateEvent;
|
import io.github.dre2n.dungeonsxl.event.dplayer.instance.DInstancePlayerUpdateEvent;
|
||||||
|
import io.github.dre2n.dungeonsxl.event.dplayer.instance.game.DGamePlayerDeathEvent;
|
||||||
|
import io.github.dre2n.dungeonsxl.event.dplayer.instance.game.DGamePlayerFinishEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.requirement.RequirementCheckEvent;
|
import io.github.dre2n.dungeonsxl.event.requirement.RequirementCheckEvent;
|
||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
|
import io.github.dre2n.dungeonsxl.game.GameGoal;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameRules;
|
import io.github.dre2n.dungeonsxl.game.GameRules;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||||
@ -39,6 +41,7 @@ import io.github.dre2n.dungeonsxl.task.CreateDInstancePlayerTask;
|
|||||||
import io.github.dre2n.dungeonsxl.trigger.DistanceTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.DistanceTrigger;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.block.TeamFlag;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -51,6 +54,7 @@ import org.bukkit.entity.Damageable;
|
|||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Wolf;
|
import org.bukkit.entity.Wolf;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
@ -62,6 +66,8 @@ import org.bukkit.potion.PotionEffect;
|
|||||||
public class DGamePlayer extends DInstancePlayer {
|
public class DGamePlayer extends DInstancePlayer {
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
|
private DGroup dGroup;
|
||||||
|
|
||||||
private boolean ready = false;
|
private boolean ready = false;
|
||||||
private boolean finished = false;
|
private boolean finished = false;
|
||||||
|
|
||||||
@ -74,6 +80,9 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
private int initialLives = -1;
|
private int initialLives = -1;
|
||||||
private int lives;
|
private int lives;
|
||||||
|
|
||||||
|
private ItemStack oldHelmet;
|
||||||
|
private DGroup stealing;
|
||||||
|
|
||||||
public DGamePlayer(Player player, DGameWorld world) {
|
public DGamePlayer(Player player, DGameWorld world) {
|
||||||
super(player, world.getWorld());
|
super(player, world.getWorld());
|
||||||
|
|
||||||
@ -129,6 +138,25 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Getters and setters */
|
/* Getters and setters */
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
String name = player.getName();
|
||||||
|
if (getDGroup() != null && dGroup.getDColor() != null) {
|
||||||
|
name = getDGroup().getDColor().getChatColor() + name;
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the DGroup of this player
|
||||||
|
*/
|
||||||
|
public DGroup getDGroup() {
|
||||||
|
if (dGroup == null) {
|
||||||
|
dGroup = DGroup.getByPlayer(player);
|
||||||
|
}
|
||||||
|
return dGroup;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param player
|
* @param player
|
||||||
* the player to set
|
* the player to set
|
||||||
@ -141,8 +169,7 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
* @return if the player is in test mode
|
* @return if the player is in test mode
|
||||||
*/
|
*/
|
||||||
public boolean isInTestMode() {
|
public boolean isInTestMode() {
|
||||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
if (getDGroup() == null) {
|
||||||
if (dGroup == null) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +392,69 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
this.lives = lives;
|
this.lives = lives;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if the player is stealing a flag
|
||||||
|
*/
|
||||||
|
public boolean isStealing() {
|
||||||
|
return stealing != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the group whose flag is stolen
|
||||||
|
*/
|
||||||
|
public DGroup getRobbedGroup() {
|
||||||
|
return stealing;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dGroup
|
||||||
|
* the group whose flag is stolen
|
||||||
|
*/
|
||||||
|
public void setRobbedGroup(DGroup dGroup) {
|
||||||
|
if (dGroup != null) {
|
||||||
|
oldHelmet = player.getInventory().getHelmet();
|
||||||
|
player.getInventory().setHelmet(new ItemStack(Material.WOOL, 1, getDGroup().getDColor().getWoolData()));
|
||||||
|
}
|
||||||
|
|
||||||
|
stealing = dGroup;
|
||||||
|
}
|
||||||
|
|
||||||
/* Actions */
|
/* Actions */
|
||||||
|
public void captureFlag() {
|
||||||
|
if (stealing == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Game game = Game.getByWorld(getWorld());
|
||||||
|
if (game == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
game.sendMessage(DMessages.GROUP_FLAG_CAPTURED.getMessage(getName(), stealing.getName()));
|
||||||
|
|
||||||
|
GameRules rules = game.getRules();
|
||||||
|
|
||||||
|
getDGroup().setScore(getDGroup().getScore() + 1);
|
||||||
|
if (rules.getScoreGoal() == dGroup.getScore()) {
|
||||||
|
dGroup.winGame();
|
||||||
|
}
|
||||||
|
|
||||||
|
stealing.setScore(stealing.getScore() - 1);
|
||||||
|
if (stealing.getScore() == -1) {
|
||||||
|
for (DGamePlayer member : stealing.getDGamePlayers()) {
|
||||||
|
member.kill();
|
||||||
|
}
|
||||||
|
game.sendMessage(DMessages.GROUP_DEFEATED.getMessage(stealing.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
stealing = null;
|
||||||
|
player.getInventory().setHelmet(oldHelmet);
|
||||||
|
|
||||||
|
if (game.getDGroups().size() == 1) {
|
||||||
|
dGroup.winGame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void leave() {
|
public void leave() {
|
||||||
leave(true);
|
leave(true);
|
||||||
@ -376,14 +465,15 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
* if messages should be sent
|
* if messages should be sent
|
||||||
*/
|
*/
|
||||||
public void leave(boolean message) {
|
public void leave(boolean message) {
|
||||||
plugin.debug.start("DGamePlayer#leave");
|
Game game = Game.getByWorld(getWorld());
|
||||||
GameRules rules = Game.getByWorld(getWorld()).getRules();
|
DGameWorld gameWorld = game.getWorld();
|
||||||
|
GameRules rules = game.getRules();
|
||||||
delete();
|
delete();
|
||||||
|
|
||||||
if (finished) {
|
if (finished) {
|
||||||
getSavePlayer().reset(rules.getKeepInventoryOnFinish());
|
reset(rules.getKeepInventoryOnFinish());
|
||||||
} else {
|
} else {
|
||||||
getSavePlayer().reset(rules.getKeepInventoryOnEscape());
|
reset(rules.getKeepInventoryOnEscape());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Permission bridge
|
// Permission bridge
|
||||||
@ -393,24 +483,21 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
if (getDGroup() != null) {
|
||||||
if (dGroup != null) {
|
|
||||||
dGroup.removePlayer(getPlayer(), message);
|
dGroup.removePlayer(getPlayer(), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
DGameWorld gameWorld = DGameWorld.getByWorld(getWorld());
|
|
||||||
Game game = Game.getByGameWorld(gameWorld);
|
|
||||||
if (game != null) {
|
if (game != null) {
|
||||||
if (finished) {
|
if (finished) {
|
||||||
if (game.getType().hasRewards()) {
|
if (game.getType() == GameTypeDefault.CUSTOM || game.getType().hasRewards()) {
|
||||||
for (Reward reward : rules.getRewards()) {
|
for (Reward reward : rules.getRewards()) {
|
||||||
reward.giveTo(getPlayer());
|
reward.giveTo(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
getData().logTimeLastPlayed(dGroup.getDungeon().getName());
|
getData().logTimeLastPlayed(getDGroup().getDungeon().getName());
|
||||||
|
|
||||||
// Tutorial Permissions
|
// Tutorial Permissions
|
||||||
if (gameWorld.isTutorial() && plugin.getPermissionProvider() != null && plugin.getPermissionProvider().hasGroupSupport()) {
|
if (game.isTutorial() && plugin.getPermissionProvider().hasGroupSupport()) {
|
||||||
String endGroup = plugin.getMainConfig().getTutorialEndGroup();
|
String endGroup = plugin.getMainConfig().getTutorialEndGroup();
|
||||||
if (plugin.isGroupEnabled(endGroup)) {
|
if (plugin.isGroupEnabled(endGroup)) {
|
||||||
plugin.getPermissionProvider().playerAddGroup(getPlayer(), endGroup);
|
plugin.getPermissionProvider().playerAddGroup(getPlayer(), endGroup);
|
||||||
@ -425,7 +512,7 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dGroup != null) {
|
if (getDGroup() != null) {
|
||||||
if (!dGroup.isEmpty()) {
|
if (!dGroup.isEmpty()) {
|
||||||
if (dGroup.finishIfMembersFinished()) {
|
if (dGroup.finishIfMembersFinished()) {
|
||||||
return;
|
return;
|
||||||
@ -459,7 +546,6 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
// ...*flies away*
|
// ...*flies away*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plugin.debug.end("DGamePlayer#leave", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void kill() {
|
public void kill() {
|
||||||
@ -467,7 +553,13 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
plugin.getServer().getPluginManager().callEvent(dPlayerKickEvent);
|
plugin.getServer().getPluginManager().callEvent(dPlayerKickEvent);
|
||||||
|
|
||||||
if (!dPlayerKickEvent.isCancelled()) {
|
if (!dPlayerKickEvent.isCancelled()) {
|
||||||
MessageUtil.broadcastMessage(DMessages.PLAYER_DEATH_KICK.getMessage(player.getName()));
|
DGameWorld gameWorld = getDGroup().getGameWorld();
|
||||||
|
if (lives != -1) {
|
||||||
|
gameWorld.sendMessage(DMessages.PLAYER_DEATH_KICK.getMessage(getName()));
|
||||||
|
} else if (getDGroup().getLives() != -1) {
|
||||||
|
gameWorld.sendMessage(DMessages.GROUP_DEATH_KICK.getMessage(getName(), dGroup.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
GameRules rules = Game.getByPlayer(player).getRules();
|
GameRules rules = Game.getByPlayer(player).getRules();
|
||||||
leave();
|
leave();
|
||||||
if (rules.getKeepInventoryOnEscape() && rules.getKeepInventoryOnDeath()) {
|
if (rules.getKeepInventoryOnEscape() && rules.getKeepInventoryOnDeath()) {
|
||||||
@ -578,9 +670,7 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void ready(GameType gameType) {
|
public void ready(GameType gameType) {
|
||||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
if (getDGroup() == null) {
|
||||||
|
|
||||||
if (dGroup == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,15 +698,15 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
respawn();
|
respawn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
game.setStarted(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void respawn() {
|
public void respawn() {
|
||||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
|
||||||
|
|
||||||
Location respawn = checkpoint;
|
Location respawn = checkpoint;
|
||||||
|
|
||||||
if (respawn == null) {
|
if (respawn == null) {
|
||||||
respawn = dGroup.getGameWorld().getStartLocation(dGroup);
|
respawn = getDGroup().getGameWorld().getStartLocation(dGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (respawn == null) {
|
if (respawn == null) {
|
||||||
@ -645,18 +735,14 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
* the name of the next floor
|
* the name of the next floor
|
||||||
*/
|
*/
|
||||||
public void finishFloor(DResourceWorld specifiedFloor) {
|
public void finishFloor(DResourceWorld specifiedFloor) {
|
||||||
plugin.debug.start("DGamePlayer#finishFloor");
|
|
||||||
MessageUtil.sendMessage(getPlayer(), DMessages.PLAYER_FINISHED_DUNGEON.getMessage());
|
MessageUtil.sendMessage(getPlayer(), DMessages.PLAYER_FINISHED_DUNGEON.getMessage());
|
||||||
finished = true;
|
finished = true;
|
||||||
|
|
||||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
if (getDGroup() == null) {
|
||||||
if (dGroup == null) {
|
|
||||||
plugin.debug.end("DGamePlayer#finishFloor", true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dGroup.isPlaying()) {
|
if (!dGroup.isPlaying()) {
|
||||||
plugin.debug.end("DGamePlayer#finishFloor", true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -740,20 +826,16 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
* if messages should be sent
|
* if messages should be sent
|
||||||
*/
|
*/
|
||||||
public void finish(boolean message) {
|
public void finish(boolean message) {
|
||||||
plugin.debug.start("DGamePlayer#finish");
|
|
||||||
if (message) {
|
if (message) {
|
||||||
MessageUtil.sendMessage(getPlayer(), DMessages.PLAYER_FINISHED_DUNGEON.getMessage());
|
MessageUtil.sendMessage(getPlayer(), DMessages.PLAYER_FINISHED_DUNGEON.getMessage());
|
||||||
}
|
}
|
||||||
finished = true;
|
finished = true;
|
||||||
|
|
||||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
if (getDGroup() == null) {
|
||||||
if (dGroup == null) {
|
|
||||||
plugin.debug.end("DGamePlayer#finish", true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dGroup.isPlaying()) {
|
if (!dGroup.isPlaying()) {
|
||||||
plugin.debug.end("DGamePlayer#finish", true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -773,16 +855,14 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DPlayerFinishEvent dPlayerFinishEvent = new DPlayerFinishEvent(this, first, hasToWait);
|
DGamePlayerFinishEvent dPlayerFinishEvent = new DGamePlayerFinishEvent(this, first, hasToWait);
|
||||||
|
|
||||||
if (dPlayerFinishEvent.isCancelled()) {
|
if (dPlayerFinishEvent.isCancelled()) {
|
||||||
finished = false;
|
finished = false;
|
||||||
plugin.debug.end("DGamePlayer#finish", true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasToWait) {
|
if (hasToWait) {
|
||||||
plugin.debug.end("DGamePlayer#finish", true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -823,6 +903,72 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onDeath(PlayerDeathEvent event) {
|
||||||
|
DGameWorld gameWorld = DGameWorld.getByWorld(player.getLocation().getWorld());
|
||||||
|
if (gameWorld == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Game game = Game.getByGameWorld(gameWorld);
|
||||||
|
if (game == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DGamePlayerDeathEvent dPlayerDeathEvent = new DGamePlayerDeathEvent(this, event, 1);
|
||||||
|
plugin.getServer().getPluginManager().callEvent(dPlayerDeathEvent);
|
||||||
|
|
||||||
|
if (dPlayerDeathEvent.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lives != -1) {
|
||||||
|
lives = lives - dPlayerDeathEvent.getLostLives();
|
||||||
|
|
||||||
|
DGamePlayer killer = DGamePlayer.getByPlayer(player.getKiller());
|
||||||
|
if (killer != null) {
|
||||||
|
gameWorld.sendMessage(DMessages.PLAYER_KILLED.getMessage(getName(), killer.getName(), String.valueOf(lives)));
|
||||||
|
} else {
|
||||||
|
gameWorld.sendMessage(DMessages.PLAYER_DEATH.getMessage(getName(), String.valueOf(lives)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (game.getRules().getKeepInventoryOnDeath()) {
|
||||||
|
setRespawnInventory(event.getEntity().getInventory().getContents());
|
||||||
|
setRespawnArmor(event.getEntity().getInventory().getArmorContents());
|
||||||
|
// Delete all drops
|
||||||
|
for (ItemStack item : event.getDrops()) {
|
||||||
|
item.setType(Material.AIR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (getDGroup() != null && dGroup.getLives() != -1) {
|
||||||
|
dGroup.setLives(dGroup.getLives() - 1);
|
||||||
|
MessageUtil.broadcastMessage(DMessages.GROUP_DEATH.getMessage(player.getName(), String.valueOf(lives)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isStealing()) {
|
||||||
|
for (TeamFlag teamFlag : gameWorld.getTeamFlags()) {
|
||||||
|
if (teamFlag.getOwner().equals(stealing)) {
|
||||||
|
teamFlag.reset();
|
||||||
|
gameWorld.sendMessage(DMessages.GROUP_FLAG_LOST.getMessage(player.getName(), stealing.getName()));
|
||||||
|
stealing = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lives == 0 && ready) {
|
||||||
|
kill();
|
||||||
|
}
|
||||||
|
|
||||||
|
GameType gameType = game.getType();
|
||||||
|
if (gameType != null && gameType != GameTypeDefault.CUSTOM) {
|
||||||
|
if (gameType.getGameGoal() == GameGoal.LAST_MAN_STANDING) {
|
||||||
|
if (game.getDGroups().size() == 1) {
|
||||||
|
game.getDGroups().get(0).winGame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(boolean updateSecond) {
|
public void update(boolean updateSecond) {
|
||||||
boolean locationValid = true;
|
boolean locationValid = true;
|
||||||
@ -840,12 +986,10 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
locationValid = false;
|
locationValid = false;
|
||||||
|
|
||||||
if (gameWorld != null) {
|
if (gameWorld != null) {
|
||||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
|
||||||
|
|
||||||
teleportLocation = getCheckpoint();
|
teleportLocation = getCheckpoint();
|
||||||
|
|
||||||
if (teleportLocation == null) {
|
if (teleportLocation == null) {
|
||||||
teleportLocation = dGroup.getGameWorld().getStartLocation(dGroup);
|
teleportLocation = getDGroup().getGameWorld().getStartLocation(getDGroup());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't forget Doge!
|
// Don't forget Doge!
|
||||||
@ -891,7 +1035,7 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
triggerAllInDistance = true;
|
triggerAllInDistance = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPlayerUpdateEvent event = new DPlayerUpdateEvent(this, locationValid, teleportWolf, respawnInventory, offline, kick, triggerAllInDistance);
|
DInstancePlayerUpdateEvent event = new DInstancePlayerUpdateEvent(this, locationValid, teleportWolf, respawnInventory, offline, kick, triggerAllInDistance);
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
@ -935,10 +1079,11 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
|
|
||||||
public static DGamePlayer getByName(String name) {
|
public static DGamePlayer getByName(String name) {
|
||||||
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) {
|
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) {
|
||||||
if (dPlayer.getPlayer().getName().equalsIgnoreCase(name)) {
|
if (dPlayer.getPlayer().getName().equalsIgnoreCase(name) || dPlayer.getName().equalsIgnoreCase(name)) {
|
||||||
return dPlayer;
|
return dPlayer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,12 +16,24 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.player;
|
package io.github.dre2n.dungeonsxl.player;
|
||||||
|
|
||||||
|
import io.github.dre2n.commons.compatibility.CompatibilityHandler;
|
||||||
|
import io.github.dre2n.commons.compatibility.Version;
|
||||||
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
|
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.config.PlayerData;
|
import io.github.dre2n.dungeonsxl.config.PlayerData;
|
||||||
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
||||||
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.global.DPortal;
|
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a player in the non-DXL worlds of the server.
|
* Represents a player in the non-DXL worlds of the server.
|
||||||
@ -43,10 +55,19 @@ public class DGlobalPlayer {
|
|||||||
|
|
||||||
private ItemStack[] respawnInventory;
|
private ItemStack[] respawnInventory;
|
||||||
private ItemStack[] respawnArmor;
|
private ItemStack[] respawnArmor;
|
||||||
|
private List<ItemStack> rewardItems;
|
||||||
|
|
||||||
public DGlobalPlayer(Player player) {
|
public DGlobalPlayer(Player player) {
|
||||||
|
this(player, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DGlobalPlayer(Player player, boolean reset) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
||||||
loadPlayerData(new File(DungeonsXL.PLAYERS, player.getUniqueId().toString() + ".yml"));
|
loadPlayerData(new File(DungeonsXL.PLAYERS, player.getUniqueId().toString() + ".yml"));
|
||||||
|
if (reset && data.wasInGame()) {
|
||||||
|
reset(false);
|
||||||
|
}
|
||||||
|
|
||||||
plugin.getDPlayers().addPlayer(this);
|
plugin.getDPlayers().addPlayer(this);
|
||||||
}
|
}
|
||||||
@ -63,6 +84,14 @@ public class DGlobalPlayer {
|
|||||||
plugin.getDPlayers().addPlayer(this);
|
plugin.getDPlayers().addPlayer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Getters and setters */
|
||||||
|
/**
|
||||||
|
* @return the player's name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return player.getName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the Bukkit player
|
* @return the Bukkit player
|
||||||
*/
|
*/
|
||||||
@ -204,6 +233,28 @@ public class DGlobalPlayer {
|
|||||||
return DPermissions.hasPermission(player, permission);
|
return DPermissions.hasPermission(player, permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the reward items
|
||||||
|
*/
|
||||||
|
public List<ItemStack> getRewardItems() {
|
||||||
|
return rewardItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if the player has reward items left
|
||||||
|
*/
|
||||||
|
public boolean hasRewardItemsLeft() {
|
||||||
|
return rewardItems != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param rewardItems
|
||||||
|
* the reward items to set
|
||||||
|
*/
|
||||||
|
public void setRewardItems(List<ItemStack> rewardItems) {
|
||||||
|
this.rewardItems = rewardItems;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param permission
|
* @param permission
|
||||||
* the permission to check
|
* the permission to check
|
||||||
@ -213,4 +264,95 @@ public class DGlobalPlayer {
|
|||||||
return DPermissions.hasPermission(player, permission);
|
return DPermissions.hasPermission(player, permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Actions */
|
||||||
|
/**
|
||||||
|
* Respawns the player at his old position before he was in a dungeon
|
||||||
|
*/
|
||||||
|
public void reset(boolean keepInventory) {
|
||||||
|
try {
|
||||||
|
if (!keepInventory) {
|
||||||
|
while (data.getOldInventory().size() > 36) {
|
||||||
|
data.getOldInventory().remove(36);
|
||||||
|
}
|
||||||
|
player.getInventory().setContents(data.getOldInventory().toArray(new ItemStack[36]));
|
||||||
|
player.getInventory().setArmorContents(data.getOldArmor().toArray(new ItemStack[4]));
|
||||||
|
if (Version.andHigher(Version.MC1_9).contains(CompatibilityHandler.getInstance().getVersion())) {
|
||||||
|
player.getInventory().setItemInOffHand(data.getOldOffHand());
|
||||||
|
}
|
||||||
|
player.setLevel(data.getOldLevel());
|
||||||
|
player.setExp(data.getOldExp());
|
||||||
|
player.setHealthScale(data.getOldHealthScale());
|
||||||
|
player.setHealth(data.getOldHealth());
|
||||||
|
player.setFoodLevel(data.getOldFoodLevel());
|
||||||
|
player.setGameMode(data.getOldGameMode());
|
||||||
|
player.setFireTicks(data.getOldFireTicks());
|
||||||
|
for (PotionEffect effect : player.getActivePotionEffects()) {
|
||||||
|
player.removePotionEffect(effect.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
player.addPotionEffects(data.getOldPotionEffects());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.getOldLocation().getWorld() != null) {
|
||||||
|
PlayerUtil.secureTeleport(player, data.getOldLocation());
|
||||||
|
} else {
|
||||||
|
PlayerUtil.secureTeleport(player, Bukkit.getWorlds().get(0).getSpawnLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (NullPointerException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
player.setHealth(0);
|
||||||
|
MessageUtil.log(plugin, DMessages.LOG_KILLED_CORRUPTED_PLAYER.getMessage(player.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
data.clearPlayerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the tutorial
|
||||||
|
*/
|
||||||
|
public void startTutorial() {
|
||||||
|
if (plugin.getPermissionProvider() == null || !plugin.getPermissionProvider().hasGroupSupport()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String startGroup = plugin.getMainConfig().getTutorialStartGroup();
|
||||||
|
if ((plugin.getMainConfig().getTutorialDungeon() == null || startGroup == null)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.isGroupEnabled(startGroup)) {
|
||||||
|
plugin.getPermissionProvider().playerAddGroup(player, startGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
DGroup dGroup = new DGroup(player, plugin.getMainConfig().getTutorialDungeon(), false);
|
||||||
|
|
||||||
|
DGroupCreateEvent createEvent = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.GROUP_SIGN);
|
||||||
|
plugin.getServer().getPluginManager().callEvent(createEvent);
|
||||||
|
|
||||||
|
if (createEvent.isCancelled()) {
|
||||||
|
dGroup = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dGroup == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DGameWorld gameWorld = null;
|
||||||
|
|
||||||
|
if (dGroup.getGameWorld() == null) {
|
||||||
|
DResourceWorld resource = plugin.getDWorlds().getResourceByName(dGroup.getMapName());
|
||||||
|
if (resource == null) {
|
||||||
|
MessageUtil.sendMessage(player, DMessages.ERROR_TUTORIAL_NOT_EXIST.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gameWorld = resource.instantiateAsGameWorld();
|
||||||
|
dGroup.setGameWorld(gameWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
new Game(dGroup, gameWorld).setTutorial(true);
|
||||||
|
DGamePlayer.create(player, gameWorld);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,11 @@ import io.github.dre2n.dungeonsxl.event.requirement.RequirementDemandEvent;
|
|||||||
import io.github.dre2n.dungeonsxl.event.reward.RewardAdditionEvent;
|
import io.github.dre2n.dungeonsxl.event.reward.RewardAdditionEvent;
|
||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameRules;
|
import io.github.dre2n.dungeonsxl.game.GameRules;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
|
||||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
|
||||||
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||||
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
||||||
import io.github.dre2n.dungeonsxl.reward.Reward;
|
import io.github.dre2n.dungeonsxl.reward.Reward;
|
||||||
import io.github.dre2n.dungeonsxl.task.TimeIsRunningTask;
|
import io.github.dre2n.dungeonsxl.task.TimeIsRunningTask;
|
||||||
|
import io.github.dre2n.dungeonsxl.util.DColor;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -45,6 +44,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Represents a group of players.
|
||||||
|
*
|
||||||
* @author Frank Baumann, Daniel Saukel
|
* @author Frank Baumann, Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class DGroup {
|
public class DGroup {
|
||||||
@ -66,6 +67,10 @@ public class DGroup {
|
|||||||
private List<Reward> rewards = new ArrayList<>();
|
private List<Reward> rewards = new ArrayList<>();
|
||||||
private BukkitTask timeIsRunningTask;
|
private BukkitTask timeIsRunningTask;
|
||||||
private DResourceWorld nextFloor;
|
private DResourceWorld nextFloor;
|
||||||
|
private DColor color;
|
||||||
|
private int score = 0;
|
||||||
|
private int initialLives = -1;
|
||||||
|
private int lives = -1;
|
||||||
|
|
||||||
public DGroup(Player player) {
|
public DGroup(Player player) {
|
||||||
this("Group_" + plugin.getDGroups().size(), player);
|
this("Group_" + plugin.getDGroups().size(), player);
|
||||||
@ -91,7 +96,6 @@ public class DGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DGroup(String name, Player captain, List<Player> players, String identifier, boolean multiFloor) {
|
public DGroup(String name, Player captain, List<Player> players, String identifier, boolean multiFloor) {
|
||||||
plugin.debug.start("DGroup#init4");
|
|
||||||
plugin.getDGroups().add(this);
|
plugin.getDGroups().add(this);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
@ -122,14 +126,20 @@ public class DGroup {
|
|||||||
|
|
||||||
playing = false;
|
playing = false;
|
||||||
floorCount = 0;
|
floorCount = 0;
|
||||||
plugin.debug.end("DGroup#init4", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters and setters
|
// Getters and setters
|
||||||
/**
|
/**
|
||||||
* @return the name
|
* @return the name; formatted
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
return (color != null ? color.getChatColor().toString() : new String()) + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name; not formatted
|
||||||
|
*/
|
||||||
|
public String getRawName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,6 +570,69 @@ public class DGroup {
|
|||||||
nextFloor = floor;
|
nextFloor = floor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the color that represents this group
|
||||||
|
*/
|
||||||
|
public DColor getDColor() {
|
||||||
|
if (color != null) {
|
||||||
|
return color;
|
||||||
|
} else {
|
||||||
|
return DColor.DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param color the group color to set
|
||||||
|
*/
|
||||||
|
public void setDColor(DColor color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the current score
|
||||||
|
*/
|
||||||
|
public int getScore() {
|
||||||
|
return score;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param score
|
||||||
|
* the score to set
|
||||||
|
*/
|
||||||
|
public void setScore(int score) {
|
||||||
|
this.score = score;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the initial group lives
|
||||||
|
*/
|
||||||
|
public int getInitialLives() {
|
||||||
|
return initialLives;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param initialLives
|
||||||
|
* the initial group lives to set
|
||||||
|
*/
|
||||||
|
public void setInitialLives(int initialLives) {
|
||||||
|
this.initialLives = initialLives;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the group lives
|
||||||
|
*/
|
||||||
|
public int getLives() {
|
||||||
|
return lives;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param lives
|
||||||
|
* the group lives to set
|
||||||
|
*/
|
||||||
|
public void setLives(int lives) {
|
||||||
|
this.lives = lives;
|
||||||
|
}
|
||||||
|
|
||||||
/* Actions */
|
/* Actions */
|
||||||
/**
|
/**
|
||||||
* Remove the group from the List
|
* Remove the group from the List
|
||||||
@ -581,11 +654,13 @@ public class DGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void startGame(Game game) {
|
public void startGame(Game game) {
|
||||||
plugin.debug.start("DGroup#startGame");
|
|
||||||
if (game == null) {
|
if (game == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
game.fetchRules();
|
game.fetchRules();
|
||||||
|
GameRules rules = game.getRules();
|
||||||
|
|
||||||
|
color = plugin.getMainConfig().getGroupColorPriority().get(game.getDGroups().indexOf(this));
|
||||||
|
|
||||||
for (DGroup dGroup : game.getDGroups()) {
|
for (DGroup dGroup : game.getDGroups()) {
|
||||||
if (dGroup == null) {
|
if (dGroup == null) {
|
||||||
@ -605,7 +680,6 @@ public class DGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!ready) {
|
if (!ready) {
|
||||||
plugin.debug.end("DGroup#startGame", true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -614,7 +688,6 @@ public class DGroup {
|
|||||||
plugin.getServer().getPluginManager().callEvent(event);
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
plugin.debug.end("DGroup#startGame", true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,8 +718,6 @@ public class DGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GameRules rules = game.getRules();
|
|
||||||
|
|
||||||
for (Requirement requirement : rules.getRequirements()) {
|
for (Requirement requirement : rules.getRequirements()) {
|
||||||
RequirementDemandEvent requirementDemandEvent = new RequirementDemandEvent(requirement, player);
|
RequirementDemandEvent requirementDemandEvent = new RequirementDemandEvent(requirement, player);
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
@ -658,20 +729,11 @@ public class DGroup {
|
|||||||
requirement.demand(player);
|
requirement.demand(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameType gameType = game.getType();
|
|
||||||
if (gameType == GameTypeDefault.DEFAULT) {
|
|
||||||
player.setGameMode(rules.getGameMode());
|
player.setGameMode(rules.getGameMode());
|
||||||
if (rules.isTimeIsRunning()) {
|
if (rules.isTimeIsRunning()) {
|
||||||
timeIsRunningTask = new TimeIsRunningTask(this, rules.getTimeToFinish()).runTaskTimer(plugin, 20, 20);
|
timeIsRunningTask = new TimeIsRunningTask(this, rules.getTimeToFinish()).runTaskTimer(plugin, 20, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
player.setGameMode(gameType.getGameMode());
|
|
||||||
if (gameType.getShowTime()) {
|
|
||||||
timeIsRunningTask = new TimeIsRunningTask(this, rules.getTimeToFinish()).runTaskTimer(plugin, 20, 20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Permission bridge
|
// Permission bridge
|
||||||
if (plugin.getPermissionProvider() != null) {
|
if (plugin.getPermissionProvider() != null) {
|
||||||
for (String permission : rules.getGamePermissions()) {
|
for (String permission : rules.getGamePermissions()) {
|
||||||
@ -682,7 +744,17 @@ public class DGroup {
|
|||||||
|
|
||||||
GroupSign.updatePerGroup(this);
|
GroupSign.updatePerGroup(this);
|
||||||
nextFloor = null;
|
nextFloor = null;
|
||||||
plugin.debug.end("DGroup#startGame", true);
|
initialLives = rules.getInitialGroupLives();
|
||||||
|
lives = initialLives;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void winGame() {
|
||||||
|
String title = DMessages.GROUP_CONGRATS.getMessage();
|
||||||
|
String subtitle = DMessages.GROUP_CONGRATS_SUB.getMessage(getName());
|
||||||
|
for (DGamePlayer player : getDGamePlayers()) {
|
||||||
|
player.leave(false);
|
||||||
|
MessageUtil.sendTitleMessage(player.getPlayer(), title, subtitle, 20, 20, 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkTime(Game game) {
|
public boolean checkTime(Game game) {
|
||||||
@ -759,7 +831,7 @@ public class DGroup {
|
|||||||
/* Statics */
|
/* Statics */
|
||||||
public static DGroup getByName(String name) {
|
public static DGroup getByName(String name) {
|
||||||
for (DGroup dGroup : plugin.getDGroups()) {
|
for (DGroup dGroup : plugin.getDGroups()) {
|
||||||
if (dGroup.getName().equals(name)) {
|
if (dGroup.getName().equalsIgnoreCase(name) || dGroup.getRawName().equalsIgnoreCase(name)) {
|
||||||
return dGroup;
|
return dGroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,52 +16,27 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.player;
|
package io.github.dre2n.dungeonsxl.player;
|
||||||
|
|
||||||
import io.github.dre2n.commons.compatibility.CompatibilityHandler;
|
|
||||||
import io.github.dre2n.commons.compatibility.Version;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Represents a player in an instance.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public abstract class DInstancePlayer extends DGlobalPlayer {
|
public abstract class DInstancePlayer extends DGlobalPlayer {
|
||||||
|
|
||||||
private DSavePlayer savePlayer;
|
|
||||||
private World world;
|
private World world;
|
||||||
private boolean inDungeonChat = false;
|
private boolean inDungeonChat = false;
|
||||||
|
|
||||||
DInstancePlayer(Player player, World world) {
|
DInstancePlayer(Player player, World world) {
|
||||||
super(player);
|
super(player, false);
|
||||||
|
|
||||||
double health = player.getHealth();
|
|
||||||
if (!Version.andHigher(Version.MC1_9).contains(CompatibilityHandler.getInstance().getVersion())) {
|
|
||||||
savePlayer = new DSavePlayer(player.getName(), player.getUniqueId(), player.getLocation(), player.getInventory().getContents(), player.getInventory().getArmorContents(), null, player.getLevel(),
|
|
||||||
player.getTotalExperience(), (int) health, player.getFoodLevel(), player.getFireTicks(), player.getGameMode(), player.getActivePotionEffects());
|
|
||||||
} else {
|
|
||||||
savePlayer = new DSavePlayer(player.getName(), player.getUniqueId(), player.getLocation(), player.getInventory().getContents(), player.getInventory().getArmorContents(), player.getInventory().getItemInOffHand(), player.getLevel(),
|
|
||||||
player.getTotalExperience(), (int) health, player.getFoodLevel(), player.getFireTicks(), player.getGameMode(), player.getActivePotionEffects());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
getData().savePlayerState(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Getters and setters */
|
/* Getters and setters */
|
||||||
/**
|
|
||||||
* @return the savePlayer
|
|
||||||
*/
|
|
||||||
public DSavePlayer getSavePlayer() {
|
|
||||||
return savePlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param savePlayer
|
|
||||||
* the savePlayer to set
|
|
||||||
*/
|
|
||||||
public void setSavePlayer(DSavePlayer savePlayer) {
|
|
||||||
this.savePlayer = savePlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
* the instance
|
* the instance
|
||||||
@ -104,14 +79,15 @@ public abstract class DInstancePlayer extends DGlobalPlayer {
|
|||||||
* Clear the player's inventory, potion effects etc.
|
* Clear the player's inventory, potion effects etc.
|
||||||
*/
|
*/
|
||||||
public void clearPlayerData() {
|
public void clearPlayerData() {
|
||||||
getPlayer().getInventory().clear();
|
player.getInventory().clear();
|
||||||
getPlayer().getInventory().setArmorContents(null);
|
player.getInventory().setArmorContents(null);
|
||||||
getPlayer().setTotalExperience(0);
|
player.setTotalExperience(0);
|
||||||
getPlayer().setLevel(0);
|
player.setLevel(0);
|
||||||
getPlayer().setHealth(20);
|
player.setHealthScale(20);
|
||||||
getPlayer().setFoodLevel(20);
|
player.setHealth(20);
|
||||||
for (PotionEffect effect : getPlayer().getActivePotionEffects()) {
|
player.setFoodLevel(20);
|
||||||
getPlayer().removePotionEffect(effect.getType());
|
for (PotionEffect effect : player.getActivePotionEffects()) {
|
||||||
|
player.removePotionEffect(effect.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,8 @@ public enum DPermissions {
|
|||||||
PLAY("play", OP),
|
PLAY("play", OP),
|
||||||
PORTAL("portal", OP),
|
PORTAL("portal", OP),
|
||||||
RELOAD("reload", OP),
|
RELOAD("reload", OP),
|
||||||
|
RESOURCE_PACK("resourcepack", OP),
|
||||||
|
REWARDS("rewards", TRUE),
|
||||||
SAVE("save", OP),
|
SAVE("save", OP),
|
||||||
STATUS("status", OP),
|
STATUS("status", OP),
|
||||||
/**
|
/**
|
||||||
|
@ -23,12 +23,13 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* DGlobalPlayer instance manager.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class DPlayers {
|
public class DPlayers {
|
||||||
|
|
||||||
private CopyOnWriteArrayList<DGlobalPlayer> dGlobalPlayers = new CopyOnWriteArrayList<>();
|
private CopyOnWriteArrayList<DGlobalPlayer> dGlobalPlayers = new CopyOnWriteArrayList<>();
|
||||||
private CopyOnWriteArrayList<DSavePlayer> dSavePlayers = new CopyOnWriteArrayList<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the DGlobalPlayer which represents the player
|
* @return the DGlobalPlayer which represents the player
|
||||||
@ -111,42 +112,6 @@ public class DPlayers {
|
|||||||
dGlobalPlayers.remove(player);
|
dGlobalPlayers.remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the DSavePlayer that represents the player
|
|
||||||
*/
|
|
||||||
public DSavePlayer getDSavePlayerByPlayer(Player player) {
|
|
||||||
for (DSavePlayer dSavePlayer : dSavePlayers) {
|
|
||||||
if (dSavePlayer.getName().equals(player.getName())) {
|
|
||||||
return dSavePlayer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the dSavePlayers
|
|
||||||
*/
|
|
||||||
public List<DSavePlayer> getDSavePlayers() {
|
|
||||||
return dSavePlayers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param dSavePlayer
|
|
||||||
* the dSavePlayer to add
|
|
||||||
*/
|
|
||||||
public void addDSavePlayer(DSavePlayer dSavePlayer) {
|
|
||||||
dSavePlayers.add(dSavePlayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param dSavePlayer
|
|
||||||
* the dSavePlayer to remove
|
|
||||||
*/
|
|
||||||
public void removeDSavePlayer(DSavePlayer dSavePlayer) {
|
|
||||||
dSavePlayers.remove(dSavePlayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load all players
|
* Load all players
|
||||||
*/
|
*/
|
||||||
@ -156,4 +121,28 @@ public class DPlayers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if an old DGamePlayer instance of the user exists.
|
||||||
|
* If yes, the old Player of the user is replaced with the new object.
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* the player to check
|
||||||
|
* @return if the player exists
|
||||||
|
*/
|
||||||
|
public boolean checkPlayer(Player player) {
|
||||||
|
DGamePlayer dPlayer = DGamePlayer.getByName(player.getName());
|
||||||
|
if (dPlayer == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DGroup dGroup = DGroup.getByPlayer(dPlayer.getPlayer());
|
||||||
|
if (dGroup != null) {
|
||||||
|
dGroup.removePlayer(dPlayer.getPlayer());
|
||||||
|
dGroup.addPlayer(player);
|
||||||
|
}
|
||||||
|
dPlayer.setPlayer(player);
|
||||||
|
dPlayer.setOfflineTime(0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,399 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.player;
|
|
||||||
|
|
||||||
import io.github.dre2n.commons.compatibility.CompatibilityHandler;
|
|
||||||
import io.github.dre2n.commons.compatibility.Version;
|
|
||||||
import io.github.dre2n.commons.util.EnumUtil;
|
|
||||||
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a player in a GameWorld who went offline.
|
|
||||||
*
|
|
||||||
* @author Frank Baumann, Tobias Schmitz, Milan Albrecht, Daniel Saukel
|
|
||||||
*/
|
|
||||||
public class DSavePlayer {
|
|
||||||
|
|
||||||
static DungeonsXL plugin = DungeonsXL.getInstance();
|
|
||||||
static DPlayers dPlayers = plugin.getDPlayers();
|
|
||||||
|
|
||||||
// Variables
|
|
||||||
private String name;
|
|
||||||
private String uuid;
|
|
||||||
|
|
||||||
private Location oldLocation;
|
|
||||||
private List<ItemStack> oldInventory;
|
|
||||||
private List<ItemStack> oldArmor;
|
|
||||||
private ItemStack oldOffHand;
|
|
||||||
private int oldLvl;
|
|
||||||
private int oldExp;
|
|
||||||
private double oldHealth;
|
|
||||||
private int oldFoodLevel;
|
|
||||||
private int oldFireTicks;
|
|
||||||
private GameMode oldGameMode;
|
|
||||||
private Collection<PotionEffect> oldPotionEffects;
|
|
||||||
|
|
||||||
public DSavePlayer(String name, UUID uuid, Location oldLocation, ArrayList<ItemStack> oldInventory, ArrayList<ItemStack> oldArmor, ItemStack oldOffHand, int oldLvl, int oldExp, double oldHealth, int oldFoodLevel, int oldFireTicks,
|
|
||||||
GameMode oldGameMode, Collection<PotionEffect> oldPotionEffects) {
|
|
||||||
this.name = name;
|
|
||||||
this.uuid = uuid.toString();
|
|
||||||
|
|
||||||
this.oldLocation = oldLocation;
|
|
||||||
this.oldInventory = oldInventory;
|
|
||||||
this.oldArmor = oldArmor;
|
|
||||||
this.oldOffHand = oldOffHand;
|
|
||||||
this.oldExp = oldExp;
|
|
||||||
this.oldHealth = oldHealth;
|
|
||||||
this.oldFoodLevel = oldFoodLevel;
|
|
||||||
this.oldGameMode = oldGameMode;
|
|
||||||
this.oldLvl = oldLvl;
|
|
||||||
this.oldFireTicks = oldFireTicks;
|
|
||||||
this.oldPotionEffects = oldPotionEffects;
|
|
||||||
|
|
||||||
save();
|
|
||||||
dPlayers.addDSavePlayer(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DSavePlayer(String name, UUID uuid, Location oldLocation, ItemStack[] oldInventory, ItemStack[] oldArmor, ItemStack oldOffHand, int oldLvl, int oldExp, double oldHealth, int oldFoodLevel, int oldFireTicks,
|
|
||||||
GameMode oldGameMode, Collection<PotionEffect> oldPotionEffects) {
|
|
||||||
this(name, uuid, oldLocation, new ArrayList<>(Arrays.asList(oldInventory)), new ArrayList<>(Arrays.asList(oldArmor)), oldOffHand, oldLvl, oldExp, oldHealth, oldFoodLevel, oldFireTicks, oldGameMode, oldPotionEffects);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Getters and setters */
|
|
||||||
/**
|
|
||||||
* @return the name
|
|
||||||
*/
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the uuid
|
|
||||||
*/
|
|
||||||
public UUID getUniqueId() {
|
|
||||||
return UUID.fromString(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the old location
|
|
||||||
*/
|
|
||||||
public Location getOldLocation() {
|
|
||||||
return oldLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param location
|
|
||||||
* the location to set
|
|
||||||
*/
|
|
||||||
public void setOldLocation(Location location) {
|
|
||||||
oldLocation = location;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the items in the old inventory
|
|
||||||
*/
|
|
||||||
public List<ItemStack> getOldInventory() {
|
|
||||||
return oldInventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param inventory
|
|
||||||
* the inventory to set
|
|
||||||
*/
|
|
||||||
public void setOldInventory(List<ItemStack> inventory) {
|
|
||||||
oldInventory = inventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the items in the old armor slots
|
|
||||||
*/
|
|
||||||
public List<ItemStack> getOldArmor() {
|
|
||||||
return oldArmor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param inventory
|
|
||||||
* the inventory to set
|
|
||||||
*/
|
|
||||||
public void setOldArmor(List<ItemStack> inventory) {
|
|
||||||
oldArmor = inventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the items in the old off-hand slot
|
|
||||||
*/
|
|
||||||
public ItemStack getOldOffHand() {
|
|
||||||
return oldOffHand;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param offHand
|
|
||||||
* the off hand item to set
|
|
||||||
*/
|
|
||||||
public void setOldOffHand(ItemStack offHand) {
|
|
||||||
oldOffHand = offHand;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the old level
|
|
||||||
*/
|
|
||||||
public int getOldLevel() {
|
|
||||||
return oldLvl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param level
|
|
||||||
* the level to set
|
|
||||||
*/
|
|
||||||
public void setOldLevel(int level) {
|
|
||||||
oldLvl = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the old exp
|
|
||||||
*/
|
|
||||||
public int getOldExp() {
|
|
||||||
return oldExp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param exp
|
|
||||||
* the amount of exp to set
|
|
||||||
*/
|
|
||||||
public void setOldExp(int exp) {
|
|
||||||
oldExp = exp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the old health
|
|
||||||
*/
|
|
||||||
public double getOldHealth() {
|
|
||||||
return oldHealth;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param health
|
|
||||||
* the health to set
|
|
||||||
*/
|
|
||||||
public void setOldHealth(double health) {
|
|
||||||
oldHealth = health;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the old food level
|
|
||||||
*/
|
|
||||||
public int getOldFoodLevel() {
|
|
||||||
return oldFoodLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param foodLevel
|
|
||||||
* the food level to set
|
|
||||||
*/
|
|
||||||
public void setOldFoodLevel(int foodLevel) {
|
|
||||||
oldFoodLevel = foodLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the old fire ticks
|
|
||||||
*/
|
|
||||||
public int getOldFireTicks() {
|
|
||||||
return oldFireTicks;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param fireTicks
|
|
||||||
* the fire ticks to set
|
|
||||||
*/
|
|
||||||
public void setFireTicks(int fireTicks) {
|
|
||||||
oldFireTicks = fireTicks;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the old GameMode
|
|
||||||
*/
|
|
||||||
public GameMode getOldGameMode() {
|
|
||||||
return oldGameMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param gameMode
|
|
||||||
* the GameMode to set
|
|
||||||
*/
|
|
||||||
public void setOldGameMode(GameMode gameMode) {
|
|
||||||
oldGameMode = gameMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the old potion effects
|
|
||||||
*/
|
|
||||||
public Collection<PotionEffect> getOldPotionEffects() {
|
|
||||||
return oldPotionEffects;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param potionEffects
|
|
||||||
* the potion effects to set
|
|
||||||
*/
|
|
||||||
public void setOldPotionEffects(Collection<PotionEffect> potionEffects) {
|
|
||||||
oldPotionEffects = potionEffects;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Actions */
|
|
||||||
public void reset(boolean keepInventory) {
|
|
||||||
Player player = plugin.getServer().getPlayer(name);
|
|
||||||
boolean offline = false;
|
|
||||||
if (player == null) {
|
|
||||||
player = PlayerUtil.getOfflinePlayer(name, UUID.fromString(uuid), oldLocation);
|
|
||||||
offline = true;
|
|
||||||
}
|
|
||||||
if (player == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (!keepInventory) {
|
|
||||||
while (oldInventory.size() > 36) {
|
|
||||||
oldInventory.remove(36);
|
|
||||||
}
|
|
||||||
player.getInventory().setContents(oldInventory.toArray(new ItemStack[36]));
|
|
||||||
player.getInventory().setArmorContents(oldArmor.toArray(new ItemStack[4]));
|
|
||||||
if (Version.andHigher(Version.MC1_9).contains(CompatibilityHandler.getInstance().getVersion())) {
|
|
||||||
player.getInventory().setItemInOffHand(oldOffHand);
|
|
||||||
}
|
|
||||||
player.setTotalExperience(oldExp);
|
|
||||||
player.setLevel(oldLvl);
|
|
||||||
player.setHealth(oldHealth);
|
|
||||||
player.setFoodLevel(oldFoodLevel);
|
|
||||||
player.setGameMode(oldGameMode);
|
|
||||||
player.setFireTicks(oldFireTicks);
|
|
||||||
for (PotionEffect effect : player.getActivePotionEffects()) {
|
|
||||||
player.removePotionEffect(effect.getType());
|
|
||||||
}
|
|
||||||
// Causes NPE if offline
|
|
||||||
if (!offline) {
|
|
||||||
player.addPotionEffects(oldPotionEffects);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
player.saveData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!offline && oldLocation.getWorld() != null) {
|
|
||||||
PlayerUtil.secureTeleport(player, oldLocation);
|
|
||||||
} else {
|
|
||||||
PlayerUtil.secureTeleport(player, Bukkit.getWorlds().get(0).getSpawnLocation());
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (NullPointerException exception) {
|
|
||||||
plugin.getLogger().info("Corrupted playerdata detected and removed!");
|
|
||||||
}
|
|
||||||
|
|
||||||
save();
|
|
||||||
dPlayers.removeDSavePlayer(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Statics */
|
|
||||||
@Deprecated
|
|
||||||
public static void save() {
|
|
||||||
FileConfiguration configFile = new YamlConfiguration();
|
|
||||||
|
|
||||||
for (DSavePlayer savePlayer : dPlayers.getDSavePlayers()) {
|
|
||||||
configFile.set(savePlayer.name + ".uuid", savePlayer.uuid);
|
|
||||||
configFile.set(savePlayer.name + ".oldGameMode", savePlayer.oldGameMode.toString());
|
|
||||||
configFile.set(savePlayer.name + ".oldFireTicks", savePlayer.oldFireTicks);
|
|
||||||
configFile.set(savePlayer.name + ".oldFoodLevel", savePlayer.oldFoodLevel);
|
|
||||||
configFile.set(savePlayer.name + ".oldHealth", savePlayer.oldHealth);
|
|
||||||
configFile.set(savePlayer.name + ".oldExp", savePlayer.oldExp);
|
|
||||||
configFile.set(savePlayer.name + ".oldLvl", savePlayer.oldLvl);
|
|
||||||
configFile.set(savePlayer.name + ".oldArmor", savePlayer.oldArmor);
|
|
||||||
configFile.set(savePlayer.name + ".oldInventory", savePlayer.oldInventory);
|
|
||||||
configFile.set(savePlayer.name + ".oldOffHand", savePlayer.oldOffHand);
|
|
||||||
configFile.set(savePlayer.name + ".oldLocation.x", savePlayer.oldLocation.getX());
|
|
||||||
configFile.set(savePlayer.name + ".oldLocation.y", savePlayer.oldLocation.getY());
|
|
||||||
configFile.set(savePlayer.name + ".oldLocation.z", savePlayer.oldLocation.getZ());
|
|
||||||
configFile.set(savePlayer.name + ".oldLocation.yaw", savePlayer.oldLocation.getYaw());
|
|
||||||
configFile.set(savePlayer.name + ".oldLocation.pitch", savePlayer.oldLocation.getPitch());
|
|
||||||
configFile.set(savePlayer.name + ".oldLocation.world", savePlayer.oldLocation.getWorld().getName());
|
|
||||||
configFile.set(savePlayer.name + ".oldPotionEffects", savePlayer.oldPotionEffects);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
configFile.save(new File(plugin.getDataFolder(), "savePlayers.yml"));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static void load() {
|
|
||||||
FileConfiguration configFile = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "savePlayers.yml"));
|
|
||||||
|
|
||||||
for (String name : configFile.getKeys(false)) {
|
|
||||||
// Load uuid
|
|
||||||
UUID uuid = UUID.fromString(configFile.getString(name + ".uuid"));
|
|
||||||
|
|
||||||
// Load inventory data
|
|
||||||
ArrayList<ItemStack> oldInventory = (ArrayList<ItemStack>) configFile.get(name + ".oldInventory");
|
|
||||||
ArrayList<ItemStack> oldArmor = (ArrayList<ItemStack>) configFile.get(name + ".oldArmor");
|
|
||||||
ItemStack oldOffHand = (ItemStack) configFile.get(name + ".oldOffHand");
|
|
||||||
|
|
||||||
// Load other data
|
|
||||||
int oldLvl = configFile.getInt(name + ".oldLvl");
|
|
||||||
int oldExp = configFile.getInt(name + ".oldExp");
|
|
||||||
int oldHealth = configFile.getInt(name + ".oldHealth");
|
|
||||||
int oldFoodLevel = configFile.getInt(name + ".oldFoodLevel");
|
|
||||||
int oldFireTicks = configFile.getInt(name + ".oldFireTicks");
|
|
||||||
GameMode oldGameMode = GameMode.SURVIVAL;
|
|
||||||
if (EnumUtil.isValidEnum(GameMode.class, configFile.getString(name + ".oldGameMode"))) {
|
|
||||||
oldGameMode = GameMode.valueOf(configFile.getString(name + ".oldGameMode"));
|
|
||||||
}
|
|
||||||
Collection<PotionEffect> oldPotionEffects = (Collection<PotionEffect>) configFile.get(name + ".oldPotionEffects");
|
|
||||||
|
|
||||||
// Location
|
|
||||||
World world = plugin.getServer().getWorld(configFile.getString(name + ".oldLocation.world"));
|
|
||||||
if (world == null) {
|
|
||||||
world = plugin.getServer().getWorlds().get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Location oldLocation = new Location(world, configFile.getDouble(name + ".oldLocation.x"), configFile.getDouble(name + ".oldLocation.y"), configFile.getDouble(name
|
|
||||||
+ ".oldLocation.z"), configFile.getInt(name + ".oldLocation.yaw"), configFile.getInt(name + ".oldLocation.pitch"));
|
|
||||||
|
|
||||||
// Create Player
|
|
||||||
DSavePlayer savePlayer = new DSavePlayer(name, uuid, oldLocation, oldInventory, oldArmor, oldOffHand, oldLvl, oldExp, oldHealth, oldFoodLevel, oldFireTicks, oldGameMode, oldPotionEffects);
|
|
||||||
savePlayer.reset(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -18,8 +18,9 @@ package io.github.dre2n.dungeonsxl.requirement;
|
|||||||
|
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
|
import io.github.dre2n.dungeonsxl.config.PlayerData;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
import io.github.dre2n.dungeonsxl.player.DSavePlayer;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,6 +32,7 @@ public class FeeLevelRequirement extends Requirement {
|
|||||||
|
|
||||||
private int fee;
|
private int fee;
|
||||||
|
|
||||||
|
/* Getters and setters */
|
||||||
/**
|
/**
|
||||||
* @return the fee
|
* @return the fee
|
||||||
*/
|
*/
|
||||||
@ -46,6 +48,17 @@ public class FeeLevelRequirement extends Requirement {
|
|||||||
this.fee = fee;
|
this.fee = fee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RequirementType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Actions */
|
||||||
|
@Override
|
||||||
|
public void setup(ConfigurationSection config) {
|
||||||
|
fee = config.getInt("feeLevel");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check(Player player) {
|
public boolean check(Player player) {
|
||||||
return player.getLevel() >= fee;
|
return player.getLevel() >= fee;
|
||||||
@ -57,15 +70,11 @@ public class FeeLevelRequirement extends Requirement {
|
|||||||
if (dPlayer == null) {
|
if (dPlayer == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DSavePlayer dSavePlayer = dPlayer.getSavePlayer();
|
|
||||||
dSavePlayer.setOldLevel(dSavePlayer.getOldLevel() - fee);
|
PlayerData data = dPlayer.getData();
|
||||||
|
data.setOldLevel(data.getOldLevel() - fee);
|
||||||
|
|
||||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.REQUIREMENT_FEE, fee + " levels"));
|
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.REQUIREMENT_FEE, fee + " levels"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public RequirementType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ package io.github.dre2n.dungeonsxl.requirement;
|
|||||||
|
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,6 +30,7 @@ public class FeeMoneyRequirement extends Requirement {
|
|||||||
|
|
||||||
private double fee;
|
private double fee;
|
||||||
|
|
||||||
|
/* Getters and setters */
|
||||||
/**
|
/**
|
||||||
* @return the fee
|
* @return the fee
|
||||||
*/
|
*/
|
||||||
@ -44,6 +46,17 @@ public class FeeMoneyRequirement extends Requirement {
|
|||||||
this.fee = fee;
|
this.fee = fee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RequirementType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Actions */
|
||||||
|
@Override
|
||||||
|
public void setup(ConfigurationSection config) {
|
||||||
|
fee = config.getDouble("feeMoney");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check(Player player) {
|
public boolean check(Player player) {
|
||||||
if (plugin.getEconomyProvider() == null) {
|
if (plugin.getEconomyProvider() == null) {
|
||||||
@ -63,9 +76,4 @@ public class FeeMoneyRequirement extends Requirement {
|
|||||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.REQUIREMENT_FEE, plugin.getEconomyProvider().format(fee)));
|
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.REQUIREMENT_FEE, plugin.getEconomyProvider().format(fee)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public RequirementType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package io.github.dre2n.dungeonsxl.requirement;
|
package io.github.dre2n.dungeonsxl.requirement;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,6 +60,18 @@ public class GroupSizeRequirement extends Requirement {
|
|||||||
this.maximum = maximum;
|
this.maximum = maximum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RequirementType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Actions */
|
||||||
|
@Override
|
||||||
|
public void setup(ConfigurationSection config) {
|
||||||
|
minimum = config.getInt("groupSize.minimum");
|
||||||
|
maximum = config.getInt("groupSize.maximum");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check(Player player) {
|
public boolean check(Player player) {
|
||||||
DGroup dGroup = DGroup.getByPlayer(player);
|
DGroup dGroup = DGroup.getByPlayer(player);
|
||||||
@ -70,9 +83,4 @@ public class GroupSizeRequirement extends Requirement {
|
|||||||
public void demand(Player player) {
|
public void demand(Player player) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public RequirementType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ package io.github.dre2n.dungeonsxl.requirement;
|
|||||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,6 +53,11 @@ public class PermissionRequirement extends Requirement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Actions */
|
/* Actions */
|
||||||
|
@Override
|
||||||
|
public void setup(ConfigurationSection config) {
|
||||||
|
permissions = config.getStringList("permission");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check(Player player) {
|
public boolean check(Player player) {
|
||||||
for (String permission : permissions) {
|
for (String permission : permissions) {
|
||||||
|
@ -22,9 +22,12 @@ import io.github.dre2n.dungeonsxl.event.requirement.RequirementRegistrationEvent
|
|||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Extend this to create a custom Requirement.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public abstract class Requirement {
|
public abstract class Requirement {
|
||||||
@ -56,6 +59,8 @@ public abstract class Requirement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Abstracts */
|
/* Abstracts */
|
||||||
|
public abstract void setup(ConfigurationSection config);
|
||||||
|
|
||||||
public abstract boolean check(Player player);
|
public abstract boolean check(Player player);
|
||||||
|
|
||||||
public abstract void demand(Player player);
|
public abstract void demand(Player player);
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
package io.github.dre2n.dungeonsxl.requirement;
|
package io.github.dre2n.dungeonsxl.requirement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Implement this to create custom requirement types.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public interface RequirementType {
|
public interface RequirementType {
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
package io.github.dre2n.dungeonsxl.requirement;
|
package io.github.dre2n.dungeonsxl.requirement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Default implementation of RequirementType.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public enum RequirementTypeDefault implements RequirementType {
|
public enum RequirementTypeDefault implements RequirementType {
|
||||||
|
@ -21,6 +21,8 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* RequirementType instance manager.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class RequirementTypes {
|
public class RequirementTypes {
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.reward;
|
package io.github.dre2n.dungeonsxl.reward;
|
||||||
|
|
||||||
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -71,7 +73,14 @@ public class ItemReward extends Reward {
|
|||||||
/* Actions */
|
/* Actions */
|
||||||
@Override
|
@Override
|
||||||
public void giveTo(Player player) {
|
public void giveTo(Player player) {
|
||||||
|
if (items.size() <= 54) {
|
||||||
new DLootInventory(player, getItems());
|
new DLootInventory(player, getItems());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
new DLootInventory(player, items.subList(0, 54).toArray(new ItemStack[54]));
|
||||||
|
plugin.getDPlayers().getByPlayer(player).setRewardItems(items.subList(54, items.size()));
|
||||||
|
MessageUtil.sendMessage(player, DMessages.ERROR_TOO_MANY_REWARDS.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Extend this to create a custom Reward.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public abstract class Reward {
|
public abstract class Reward {
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
package io.github.dre2n.dungeonsxl.reward;
|
package io.github.dre2n.dungeonsxl.reward;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Implement this to create custom reward types.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public interface RewardType {
|
public interface RewardType {
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
package io.github.dre2n.dungeonsxl.reward;
|
package io.github.dre2n.dungeonsxl.reward;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Default implementation of RewardType.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public enum RewardTypeDefault implements RewardType {
|
public enum RewardTypeDefault implements RewardType {
|
||||||
|
@ -21,6 +21,8 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* RewardType instance manager.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class RewardTypes {
|
public class RewardTypes {
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* 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.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.commons.util.BlockUtil;
|
||||||
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.block.TeamBed;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class BedSign extends DSign {
|
||||||
|
|
||||||
|
private DSignType type = DSignTypeDefault.BED;
|
||||||
|
|
||||||
|
private int team;
|
||||||
|
|
||||||
|
public BedSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||||
|
super(sign, lines, gameWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Getters and setters */
|
||||||
|
@Override
|
||||||
|
public DSignType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Actions */
|
||||||
|
@Override
|
||||||
|
public boolean check() {
|
||||||
|
return NumberUtil.parseInt(lines[1], -1) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInit() {
|
||||||
|
this.team = NumberUtil.parseInt(lines[1]);
|
||||||
|
Block block = BlockUtil.getAttachedBlock(getSign().getBlock());
|
||||||
|
|
||||||
|
if (block.getType() == Material.BED_BLOCK) {
|
||||||
|
if (getGame().getDGroups().size() > team) {
|
||||||
|
getGameWorld().addGameBlock(new TeamBed(block, getGame().getDGroups().get(team)));
|
||||||
|
}
|
||||||
|
getSign().getBlock().setType(Material.AIR);
|
||||||
|
} else {
|
||||||
|
markAsErroneous();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* 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.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
|
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
|
import org.black_ixx.bossshop.BossShop;
|
||||||
|
import org.black_ixx.bossshop.core.BSShop;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class BossShopSign extends DSign {
|
||||||
|
|
||||||
|
BossShop bossShop = (BossShop) Bukkit.getPluginManager().getPlugin("BossShop");
|
||||||
|
|
||||||
|
private DSignType type = DSignTypeDefault.BOSS_SHOP;
|
||||||
|
|
||||||
|
private String shopName;
|
||||||
|
|
||||||
|
public BossShopSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||||
|
super(sign, lines, gameWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Getters and setters*/
|
||||||
|
/**
|
||||||
|
* @return the name of the shop
|
||||||
|
*/
|
||||||
|
public String getShopName() {
|
||||||
|
return shopName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* the name of the shop
|
||||||
|
*/
|
||||||
|
public void setShopName(String name) {
|
||||||
|
shopName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Actions */
|
||||||
|
@Override
|
||||||
|
public boolean check() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInit() {
|
||||||
|
if (bossShop == null || bossShop.getAPI().getShop(lines[1]) == null) {
|
||||||
|
markAsErroneous();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
shopName = lines[1];
|
||||||
|
|
||||||
|
if (!getTriggers().isEmpty()) {
|
||||||
|
getSign().getBlock().setType(Material.AIR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGameWorld());
|
||||||
|
if (trigger != null) {
|
||||||
|
trigger.addListener(this);
|
||||||
|
addTrigger(trigger);
|
||||||
|
}
|
||||||
|
|
||||||
|
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
|
||||||
|
getSign().setLine(1, ChatColor.GREEN + lines[1]);
|
||||||
|
getSign().setLine(2, ChatColor.GREEN + lines[2]);
|
||||||
|
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
|
||||||
|
getSign().update();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPlayerTrigger(Player player) {
|
||||||
|
openShop(player, lines[1]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DSignType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openShop(Player player, String shopName) {
|
||||||
|
BSShop shop = bossShop.getAPI().getShop(shopName);
|
||||||
|
if (shop != null) {
|
||||||
|
bossShop.getAPI().openShop(player, shop);
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendMessage(player, DMessages.ERROR_NO_SUCH_SHOP.getMessage(shopName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -18,8 +18,8 @@ package io.github.dre2n.dungeonsxl.sign;
|
|||||||
|
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
import io.github.dre2n.dungeonsxl.loottable.DLootTable;
|
import io.github.dre2n.dungeonsxl.loottable.DLootTable;
|
||||||
import io.github.dre2n.dungeonsxl.reward.RewardChest;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.block.RewardChest;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -181,7 +181,7 @@ public class ChestSign extends DSign {
|
|||||||
itemReward = list.toArray(new ItemStack[list.size()]);
|
itemReward = list.toArray(new ItemStack[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
new RewardChest(chest, getGameWorld(), moneyReward, levelReward, itemReward);
|
getGameWorld().addGameBlock(new RewardChest(chest, moneyReward, levelReward, itemReward));
|
||||||
getSign().getBlock().setType(Material.AIR);
|
getSign().getBlock().setType(Material.AIR);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -59,13 +59,17 @@ public class ClassesSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
|
if (dClass != null) {
|
||||||
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
|
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
|
||||||
getSign().setLine(1, ChatColor.DARK_GREEN + dClass.getName());
|
getSign().setLine(1, ChatColor.DARK_GREEN + dClass.getName());
|
||||||
getSign().setLine(2, "");
|
getSign().setLine(2, "");
|
||||||
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
|
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
|
||||||
getSign().update();
|
getSign().update();
|
||||||
|
|
||||||
getGameWorld().getClassesSigns().add(getSign());
|
getGameWorld().getClassesSigns().add(getSign());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
markAsErroneous();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,6 +32,8 @@ import org.bukkit.block.Sign;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Extend this to create a custom DSign.
|
||||||
|
*
|
||||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public abstract class DSign {
|
public abstract class DSign {
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Implement this to create custom sign types.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public interface DSignType {
|
public interface DSignType {
|
||||||
@ -32,10 +34,15 @@ public interface DSignType {
|
|||||||
public String getBuildPermission();
|
public String getBuildPermission();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the onDungeonInit
|
* @return if the sign gets initialized when the dungeon is loaded instead of when the game starts
|
||||||
*/
|
*/
|
||||||
public boolean isOnDungeonInit();
|
public boolean isOnDungeonInit();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if the sign block should be destroyable after the initialization
|
||||||
|
*/
|
||||||
|
public boolean isProtected();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the handler
|
* @return the handler
|
||||||
*/
|
*/
|
||||||
|
@ -19,49 +19,58 @@ package io.github.dre2n.dungeonsxl.sign;
|
|||||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Default implementation of DSignType.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public enum DSignTypeDefault implements DSignType {
|
public enum DSignTypeDefault implements DSignType {
|
||||||
|
|
||||||
BLOCK("Block", "block", false, BlockSign.class),
|
BED("Bed", "bed", false, false, BedSign.class),
|
||||||
CHECKPOINT("Checkpoint", "checkpoint", false, CheckpointSign.class),
|
BLOCK("Block", "block", false, true, BlockSign.class),
|
||||||
CHEST("Chest", "chest", false, ChestSign.class),
|
BOSS_SHOP("BossShop", "bossshop", false, true, BossShopSign.class),
|
||||||
CHUNK_UPDATER("ChunkUpdater", "chunkupdater", true, ChunkUpdaterSign.class),
|
CHECKPOINT("Checkpoint", "checkpoint", false, false, CheckpointSign.class),
|
||||||
CLASSES("Classes", "classes", true, ClassesSign.class),
|
CHEST("Chest", "chest", false, false, ChestSign.class),
|
||||||
COMMAND("CMD", "cmd", false, CommandSign.class),
|
CHUNK_UPDATER("ChunkUpdater", "chunkupdater", true, false, ChunkUpdaterSign.class),
|
||||||
DROP("Drop", "drop", false, DropSign.class),
|
CLASSES("Classes", "classes", true, true, ClassesSign.class),
|
||||||
END("End", "end", false, EndSign.class),
|
COMMAND("CMD", "cmd", false, false, CommandSign.class),
|
||||||
EXTERNAL_MOB("ExternalMob", "mob", false, ExternalMobSign.class),
|
DROP("Drop", "drop", false, false, DropSign.class),
|
||||||
FLOOR("Floor", "floor", false, FloorSign.class),
|
END("End", "end", false, true, EndSign.class),
|
||||||
HOLOGRAM("Hologram", "hologram", true, HologramSign.class),
|
EXTERNAL_MOB("ExternalMob", "mob", false, false, ExternalMobSign.class),
|
||||||
INTERACT("Interact", "interact", true, InteractSign.class),
|
FLAG("Flag", "flag", false, false, FlagSign.class),
|
||||||
LEAVE("Leave", "leave", true, LeaveSign.class),
|
FLOOR("Floor", "floor", false, true, FloorSign.class),
|
||||||
LIVES_MODIFIER("Lives", "lives", false, LivesModifierSign.class),
|
HOLOGRAM("Hologram", "hologram", true, false, HologramSign.class),
|
||||||
LOBBY("Lobby", "lobby", true, LobbySign.class),
|
INTERACT("Interact", "interact", true, true, InteractSign.class),
|
||||||
MOB("Mob", "mob", false, DMobSign.class),
|
LEAVE("Leave", "leave", true, true, LeaveSign.class),
|
||||||
MESSAGE("MSG", "msg", false, MessageSign.class),
|
LIVES_MODIFIER("Lives", "lives", false, false, LivesModifierSign.class),
|
||||||
|
LOBBY("Lobby", "lobby", true, false, LobbySign.class),
|
||||||
|
MOB("Mob", "mob", false, false, DMobSign.class),
|
||||||
|
MESSAGE("MSG", "msg", false, false, MessageSign.class),
|
||||||
@Deprecated
|
@Deprecated
|
||||||
MYTHIC_MOBS("MythicMobs", "mob", false, ExternalMobSign.class),
|
MYTHIC_MOBS("MythicMobs", "mob", false, false, ExternalMobSign.class),
|
||||||
OPEN_DOOR("Door", "door", false, OpenDoorSign.class),
|
OPEN_DOOR("Door", "door", false, false, OpenDoorSign.class),
|
||||||
PLACE("Place", "place", false, PlaceSign.class),
|
PLACE("Place", "place", false, false, PlaceSign.class),
|
||||||
READY("Ready", "ready", true, ReadySign.class),
|
PROTECTION("Protection", "protection", false, false, ProtectionSign.class),
|
||||||
REDSTONE("Redstone", "redstone", false, RedstoneSign.class),
|
READY("Ready", "ready", true, true, ReadySign.class),
|
||||||
SCRIPT("Script", "script", false, ScriptSign.class),
|
REDSTONE("Redstone", "redstone", false, false, RedstoneSign.class),
|
||||||
SOUND_MESSAGE("SoundMSG", "soundmsg", false, SoundMessageSign.class),
|
RESOURCE_PACK("ResourcePack", "resourcepack", true, true, ResourcePackSign.class),
|
||||||
START("Start", "start", true, StartSign.class),
|
SCRIPT("Script", "script", false, false, ScriptSign.class),
|
||||||
TELEPORT("Teleport", "teleport", false, TeleportSign.class),
|
SOUND_MESSAGE("SoundMSG", "soundmsg", false, false, SoundMessageSign.class),
|
||||||
TRIGGER("Trigger", "trigger", true, TriggerSign.class),
|
START("Start", "start", true, false, StartSign.class),
|
||||||
WAVE("Wave", "wave", false, WaveSign.class);
|
TELEPORT("Teleport", "teleport", false, false, TeleportSign.class),
|
||||||
|
TRIGGER("Trigger", "trigger", true, false, TriggerSign.class),
|
||||||
|
WAVE("Wave", "wave", false, false, WaveSign.class);
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private String buildPermission;
|
private String buildPermission;
|
||||||
private boolean onDungeonInit;
|
private boolean onDungeonInit;
|
||||||
|
private boolean isProtected;
|
||||||
private Class<? extends DSign> handler;
|
private Class<? extends DSign> handler;
|
||||||
|
|
||||||
DSignTypeDefault(String name, String buildPermission, boolean onDungeonInit, Class<? extends DSign> handler) {
|
DSignTypeDefault(String name, String buildPermission, boolean onDungeonInit, boolean isProtected, Class<? extends DSign> handler) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.buildPermission = buildPermission;
|
this.buildPermission = buildPermission;
|
||||||
this.onDungeonInit = onDungeonInit;
|
this.onDungeonInit = onDungeonInit;
|
||||||
|
this.isProtected = isProtected;
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,6 +89,11 @@ public enum DSignTypeDefault implements DSignType {
|
|||||||
return onDungeonInit;
|
return onDungeonInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isProtected() {
|
||||||
|
return isProtected;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends DSign> getHandler() {
|
public Class<? extends DSign> getHandler() {
|
||||||
return handler;
|
return handler;
|
||||||
|
@ -21,6 +21,8 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* DSignType instance manager.
|
||||||
|
*
|
||||||
* @author Daniel Saukel
|
* @author Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class DSignTypes {
|
public class DSignTypes {
|
||||||
|
@ -229,6 +229,11 @@ public class ExternalMobSign extends DSign implements MobSign {
|
|||||||
} else {
|
} else {
|
||||||
provider = ExternalMobPlugin.MYTHIC_MOBS;
|
provider = ExternalMobPlugin.MYTHIC_MOBS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (provider == null) {
|
||||||
|
markAsErroneous();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* 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.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.block.TeamFlag;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class FlagSign extends DSign {
|
||||||
|
|
||||||
|
private DSignType type = DSignTypeDefault.FLAG;
|
||||||
|
|
||||||
|
private int team;
|
||||||
|
|
||||||
|
public FlagSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||||
|
super(sign, lines, gameWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Getters and setters */
|
||||||
|
@Override
|
||||||
|
public DSignType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Actions */
|
||||||
|
@Override
|
||||||
|
public boolean check() {
|
||||||
|
return NumberUtil.parseInt(lines[1], -1) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInit() {
|
||||||
|
this.team = NumberUtil.parseInt(lines[1]);
|
||||||
|
if (getGame().getDGroups().size() > team) {
|
||||||
|
getGameWorld().addGameBlock(new TeamFlag(getSign().getBlock(), getGame().getDGroups().get(team)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEscapeEvent;
|
import io.github.dre2n.dungeonsxl.event.dplayer.instance.game.DGamePlayerEscapeEvent;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
@ -64,7 +64,7 @@ public class LeaveSign extends DSign {
|
|||||||
public boolean onPlayerTrigger(Player player) {
|
public boolean onPlayerTrigger(Player player) {
|
||||||
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
|
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
|
||||||
if (dPlayer != null) {
|
if (dPlayer != null) {
|
||||||
DPlayerEscapeEvent event = new DPlayerEscapeEvent(dPlayer);
|
DGamePlayerEscapeEvent event = new DGamePlayerEscapeEvent(dPlayer);
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
@ -80,7 +80,7 @@ public class LeaveSign extends DSign {
|
|||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) {
|
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) {
|
||||||
DPlayerEscapeEvent event = new DPlayerEscapeEvent(dPlayer);
|
DGamePlayerEscapeEvent event = new DGamePlayerEscapeEvent(dPlayer);
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
|
@ -93,9 +93,7 @@ public class LivesModifierSign extends DSign {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case GROUP:
|
case GROUP:
|
||||||
for (DGamePlayer dPlayer : DGroup.getByPlayer(player).getDGamePlayers()) {
|
modifyLives(DGroup.getByPlayer(player));
|
||||||
modifyLives(dPlayer);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PLAYER:
|
case PLAYER:
|
||||||
@ -119,6 +117,16 @@ public class LivesModifierSign extends DSign {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void modifyLives(DGroup dGroup) {
|
||||||
|
dGroup.setLives(dGroup.getLives() + lives);
|
||||||
|
if (lives > 0) {
|
||||||
|
dGroup.sendMessage(DMessages.GROUP_LIVES_ADDED.getMessage(String.valueOf(lives)));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
dGroup.sendMessage(DMessages.GROUP_LIVES_REMOVED.getMessage(String.valueOf(-1 * lives)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DSignType getType() {
|
public DSignType getType() {
|
||||||
return type;
|
return type;
|
||||||
|
@ -18,6 +18,7 @@ package io.github.dre2n.dungeonsxl.sign;
|
|||||||
|
|
||||||
import io.github.dre2n.commons.util.BlockUtil;
|
import io.github.dre2n.commons.util.BlockUtil;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.block.LockedDoor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
@ -31,7 +32,8 @@ public class OpenDoorSign extends DSign {
|
|||||||
|
|
||||||
private DSignType type = DSignTypeDefault.OPEN_DOOR;
|
private DSignType type = DSignTypeDefault.OPEN_DOOR;
|
||||||
|
|
||||||
private Block block;
|
private LockedDoor door;
|
||||||
|
private boolean active = true;
|
||||||
|
|
||||||
public OpenDoorSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
public OpenDoorSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||||
super(sign, lines, gameWorld);
|
super(sign, lines, gameWorld);
|
||||||
@ -41,16 +43,31 @@ public class OpenDoorSign extends DSign {
|
|||||||
/**
|
/**
|
||||||
* @return the door to open;
|
* @return the door to open;
|
||||||
*/
|
*/
|
||||||
public Block getBlock() {
|
public LockedDoor getDoor() {
|
||||||
return block;
|
return door;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param block
|
* @param door
|
||||||
* the door to open
|
* the door to open
|
||||||
*/
|
*/
|
||||||
public void setBlock(Block block) {
|
public void setDoor(LockedDoor door) {
|
||||||
this.block = block;
|
this.door = door;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if the sign is active
|
||||||
|
*/
|
||||||
|
public boolean isActive() {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param active
|
||||||
|
* toggle the sign active
|
||||||
|
*/
|
||||||
|
public void setActive(boolean active) {
|
||||||
|
this.active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -69,44 +86,25 @@ public class OpenDoorSign extends DSign {
|
|||||||
Block block = BlockUtil.getAttachedBlock(getSign().getBlock());
|
Block block = BlockUtil.getAttachedBlock(getSign().getBlock());
|
||||||
if (block.getState().getData() instanceof Door) {
|
if (block.getState().getData() instanceof Door) {
|
||||||
if (block.getRelative(BlockFace.DOWN).getType() == block.getType()) {
|
if (block.getRelative(BlockFace.DOWN).getType() == block.getType()) {
|
||||||
this.block = block.getRelative(BlockFace.DOWN);
|
door = new LockedDoor(block.getRelative(BlockFace.DOWN));
|
||||||
} else {
|
} else {
|
||||||
this.block = block;
|
door = new LockedDoor(block);
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
getGameWorld().addGameBlock(door);
|
||||||
|
|
||||||
getSign().getBlock().setType(Material.AIR);
|
getSign().getBlock().setType(Material.AIR);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
markAsErroneous();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
if (block != null) {
|
if (door != null && active) {
|
||||||
((Door) block.getState().getData()).setOpen(true);
|
door.open();
|
||||||
block.getState().update(true);
|
active = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Statics */
|
|
||||||
/**
|
|
||||||
* @param block
|
|
||||||
* the block to check
|
|
||||||
* @return
|
|
||||||
* true if the block is openable only with a sign
|
|
||||||
*/
|
|
||||||
public static boolean isProtected(Block block) {
|
|
||||||
DGameWorld gameWorld = DGameWorld.getByWorld(block.getWorld());
|
|
||||||
if (gameWorld != null) {
|
|
||||||
for (DSign dSign : gameWorld.getDSigns(DSignTypeDefault.OPEN_DOOR)) {
|
|
||||||
Block signBlock1 = ((OpenDoorSign) dSign).getBlock();
|
|
||||||
Block signBlock2 = signBlock1.getRelative(BlockFace.UP);
|
|
||||||
if (block.equals(signBlock1) || block.equals(signBlock2)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user