mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 21:48:43 +01:00
#61: Use GameRules instead of WorldConfig
This commit is contained in:
parent
ffde4f6c8b
commit
231372956d
@ -35,6 +35,7 @@ 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 java.util.Set;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@ -348,7 +349,7 @@ public class Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int delay = world.getConfig().getTimeToNextWave();
|
int delay = rules.getTimeToNextWave();
|
||||||
sendMessage(plugin.getMessageConfig().getMessage(DMessages.GROUP_WAVE_FINISHED, String.valueOf(waveCount), String.valueOf(delay)));
|
sendMessage(plugin.getMessageConfig().getMessage(DMessages.GROUP_WAVE_FINISHED, String.valueOf(waveCount), String.valueOf(delay)));
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@ -410,4 +411,13 @@ public class Game {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Game getByWorld(World world) {
|
||||||
|
GameWorld gameWorld = GameWorld.getByWorld(world);
|
||||||
|
if (gameWorld != null) {
|
||||||
|
return getByGameWorld(gameWorld);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ 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.GamePlaceableBlock;
|
||||||
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;
|
||||||
@ -107,10 +108,11 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gameWorld.getGame() != null) {
|
Game game = gameWorld.getGame();
|
||||||
GameType gameType = gameWorld.getGame().getType();
|
if (game != null) {
|
||||||
if (gameType == GameTypeDefault.DEFAULT && gameWorld.getConfig() != null) {
|
GameType gameType = game.getType();
|
||||||
event.setCancelled(!gameWorld.getConfig().canBuild());
|
if (gameType == GameTypeDefault.DEFAULT) {
|
||||||
|
event.setCancelled(!game.getRules().canBuild());
|
||||||
|
|
||||||
} else if (!gameType.canBuild()) {
|
} else if (!gameType.canBuild()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -132,8 +134,11 @@ public class BlockListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gameWorld.getConfig().canBuild() || GamePlaceableBlock.canBuildHere(block, block.getFace(event.getBlockAgainst()), event.getItemInHand().getType(), gameWorld)) {
|
Game game = gameWorld.getGame();
|
||||||
return;
|
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
|
// Workaround for a bug that would allow 3-Block-high jumping
|
||||||
|
@ -17,10 +17,7 @@
|
|||||||
package io.github.dre2n.dungeonsxl.listener;
|
package io.github.dre2n.dungeonsxl.listener;
|
||||||
|
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
|
||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
|
||||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
|
||||||
import io.github.dre2n.dungeonsxl.mob.DMob;
|
import io.github.dre2n.dungeonsxl.mob.DMob;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
@ -158,16 +155,8 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldConfig config = gameWorld.getConfig();
|
boolean pvp = game.getRules().isPlayerVersusPlayer();
|
||||||
GameType type = game.getType();
|
boolean friendlyFire = game.getRules().isFriendlyFire();
|
||||||
|
|
||||||
boolean pvp = config.isPlayerVersusPlayer();
|
|
||||||
boolean friendlyFire = config.isFriendlyFire();
|
|
||||||
|
|
||||||
if (type != GameTypeDefault.DEFAULT) {
|
|
||||||
pvp = type.isPlayerVersusPlayer();
|
|
||||||
friendlyFire = type.isFriendlyFire();
|
|
||||||
}
|
|
||||||
|
|
||||||
Entity attackerEntity = event.getDamager();
|
Entity attackerEntity = event.getDamager();
|
||||||
Entity attackedEntity = event.getEntity();
|
Entity attackedEntity = event.getEntity();
|
||||||
|
@ -19,10 +19,10 @@ package io.github.dre2n.dungeonsxl.listener;
|
|||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
|
||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerDeathEvent;
|
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerDeathEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
|
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
|
||||||
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.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;
|
||||||
@ -84,15 +84,18 @@ 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();
|
||||||
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
|
|
||||||
|
|
||||||
GameWorld gameWorld = GameWorld.getByWorld(player.getLocation().getWorld());
|
GameWorld gameWorld = GameWorld.getByWorld(player.getLocation().getWorld());
|
||||||
if (gameWorld == null) {
|
if (gameWorld == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldConfig dConfig = gameWorld.getConfig();
|
Game game = Game.getByGameWorld(gameWorld);
|
||||||
|
if (game == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
|
||||||
if (dPlayer == null) {
|
if (dPlayer == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -117,14 +120,12 @@ public class PlayerListener implements Listener {
|
|||||||
if (dPlayer.getLives() != -1) {
|
if (dPlayer.getLives() != -1) {
|
||||||
MessageUtil.sendMessage(player, DMessages.PLAYER_DEATH.getMessage(String.valueOf(dPlayer.getLives())));
|
MessageUtil.sendMessage(player, DMessages.PLAYER_DEATH.getMessage(String.valueOf(dPlayer.getLives())));
|
||||||
|
|
||||||
if (dConfig != null) {
|
if (game.getRules().getKeepInventoryOnDeath()) {
|
||||||
if (dConfig.getKeepInventoryOnDeath()) {
|
dPlayer.setRespawnInventory(event.getEntity().getInventory().getContents());
|
||||||
dPlayer.setRespawnInventory(event.getEntity().getInventory().getContents());
|
dPlayer.setRespawnArmor(event.getEntity().getInventory().getArmorContents());
|
||||||
dPlayer.setRespawnArmor(event.getEntity().getInventory().getArmorContents());
|
// Delete all drops
|
||||||
// Delete all drops
|
for (ItemStack item : event.getDrops()) {
|
||||||
for (ItemStack item : event.getDrops()) {
|
item.setType(Material.AIR);
|
||||||
item.setType(Material.AIR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,7 +137,7 @@ public class PlayerListener implements Listener {
|
|||||||
if (!dPlayerKickEvent.isCancelled()) {
|
if (!dPlayerKickEvent.isCancelled()) {
|
||||||
MessageUtil.broadcastMessage(DMessages.PLAYER_DEATH_KICK.getMessage(player.getName()));
|
MessageUtil.broadcastMessage(DMessages.PLAYER_DEATH_KICK.getMessage(player.getName()));
|
||||||
dPlayer.leave();
|
dPlayer.leave();
|
||||||
if (gameWorld.getConfig().getKeepInventoryOnEscape()) {
|
if (game.getRules().getKeepInventoryOnEscape()) {
|
||||||
dPlayer.applyRespawnInventory();
|
dPlayer.applyRespawnInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -347,9 +348,9 @@ public class PlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameWorld gameWorld = GameWorld.getByWorld(gamePlayer.getWorld());
|
Game game = Game.getByWorld(gamePlayer.getWorld());
|
||||||
|
|
||||||
for (Material material : gameWorld.getConfig().getSecureObjects()) {
|
for (Material material : game.getRules().getSecureObjects()) {
|
||||||
if (material == event.getItemDrop().getItemStack().getType()) {
|
if (material == event.getItemDrop().getItemStack().getType()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
MessageUtil.sendMessage(player, DMessages.ERROR_DROP.getMessage());
|
MessageUtil.sendMessage(player, DMessages.ERROR_DROP.getMessage());
|
||||||
@ -471,9 +472,9 @@ public class PlayerListener implements Listener {
|
|||||||
DGroup dGroup = DGroup.getByPlayer(player);
|
DGroup dGroup = DGroup.getByPlayer(player);
|
||||||
|
|
||||||
// Check GameWorld
|
// Check GameWorld
|
||||||
GameWorld gameWorld = GameWorld.getByWorld(player.getWorld());
|
Game game = Game.getByWorld(player.getWorld());
|
||||||
if (gameWorld != null) {
|
if (game != null) {
|
||||||
int timeUntilKickOfflinePlayer = gameWorld.getConfig().getTimeUntilKickOfflinePlayer();
|
int timeUntilKickOfflinePlayer = game.getRules().getTimeUntilKickOfflinePlayer();
|
||||||
|
|
||||||
if (timeUntilKickOfflinePlayer == 0) {
|
if (timeUntilKickOfflinePlayer == 0) {
|
||||||
dPlayer.leave();
|
dPlayer.leave();
|
||||||
@ -587,7 +588,7 @@ public class PlayerListener implements Listener {
|
|||||||
String command = event.getMessage().toLowerCase();
|
String command = event.getMessage().toLowerCase();
|
||||||
ArrayList<String> commandWhitelist = new ArrayList<>();
|
ArrayList<String> commandWhitelist = new ArrayList<>();
|
||||||
|
|
||||||
GameWorld gameWorld = GameWorld.getByWorld(dPlayer.getWorld());
|
Game game = Game.getByWorld(dPlayer.getWorld());
|
||||||
|
|
||||||
if (dPlayer instanceof DEditPlayer) {
|
if (dPlayer instanceof DEditPlayer) {
|
||||||
if (DPermissions.hasPermission(event.getPlayer(), DPermissions.CMD_EDIT)) {
|
if (DPermissions.hasPermission(event.getPlayer(), DPermissions.CMD_EDIT)) {
|
||||||
@ -597,9 +598,9 @@ public class PlayerListener implements Listener {
|
|||||||
commandWhitelist.addAll(plugin.getMainConfig().getEditCommandWhitelist());
|
commandWhitelist.addAll(plugin.getMainConfig().getEditCommandWhitelist());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (gameWorld != null) {
|
} else if (game != null) {
|
||||||
if (gameWorld.getConfig() != null) {
|
if (game.getRules() != null) {
|
||||||
commandWhitelist.addAll(gameWorld.getConfig().getGameCommandWhitelist());
|
commandWhitelist.addAll(game.getRules().getGameCommandWhitelist());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
|||||||
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
|
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
|
||||||
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
|
||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishDungeonEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishDungeonEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishFloorEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishFloorEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupRewardEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupRewardEvent;
|
||||||
@ -29,6 +28,7 @@ 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.DPlayerUpdateEvent;
|
||||||
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.GameType;
|
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.mob.DMob;
|
import io.github.dre2n.dungeonsxl.mob.DMob;
|
||||||
@ -83,18 +83,18 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
public DGamePlayer(Player player, World world) {
|
public DGamePlayer(Player player, World world) {
|
||||||
super(player, world);
|
super(player, world);
|
||||||
|
|
||||||
WorldConfig worldConfig = GameWorld.getByWorld(world).getConfig();
|
GameRules rules = Game.getByWorld(world).getRules();
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
|
||||||
if (!worldConfig.getKeepInventoryOnEnter()) {
|
if (!rules.getKeepInventoryOnEnter()) {
|
||||||
clearPlayerData();
|
clearPlayerData();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (worldConfig.isLobbyDisabled()) {
|
if (rules.isLobbyDisabled()) {
|
||||||
ready();
|
ready();
|
||||||
}
|
}
|
||||||
|
|
||||||
initialLives = worldConfig.getInitialLives();
|
initialLives = rules.getInitialLives();
|
||||||
lives = initialLives;
|
lives = initialLives;
|
||||||
|
|
||||||
Location teleport = GameWorld.getByWorld(world).getLobbyLocation();
|
Location teleport = GameWorld.getByWorld(world).getLobbyLocation();
|
||||||
@ -183,12 +183,12 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
* the dClass to set
|
* the dClass to set
|
||||||
*/
|
*/
|
||||||
public void setDClass(String className) {
|
public void setDClass(String className) {
|
||||||
GameWorld gameWorld = GameWorld.getByWorld(getPlayer().getWorld());
|
Game game = Game.getByWorld(getPlayer().getWorld());
|
||||||
if (gameWorld == null) {
|
if (game == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DClass dClass = gameWorld.getConfig().getClass(className);
|
DClass dClass = game.getRules().getClass(className);
|
||||||
if (dClass != null) {
|
if (dClass != null) {
|
||||||
if (this.dClass != dClass) {
|
if (this.dClass != dClass) {
|
||||||
this.dClass = dClass;
|
this.dClass = dClass;
|
||||||
@ -359,11 +359,11 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
public void leave() {
|
public void leave() {
|
||||||
delete();
|
delete();
|
||||||
|
|
||||||
WorldConfig dConfig = GameWorld.getByWorld(getWorld()).getConfig();
|
GameRules rules = Game.getByWorld(getWorld()).getRules();
|
||||||
if (finished) {
|
if (finished) {
|
||||||
getSavePlayer().reset(dConfig.getKeepInventoryOnFinish());
|
getSavePlayer().reset(rules.getKeepInventoryOnFinish());
|
||||||
} else {
|
} else {
|
||||||
getSavePlayer().reset(dConfig.getKeepInventoryOnEscape());
|
getSavePlayer().reset(rules.getKeepInventoryOnEscape());
|
||||||
}
|
}
|
||||||
|
|
||||||
GameWorld gameWorld = GameWorld.getByWorld(getWorld());
|
GameWorld gameWorld = GameWorld.getByWorld(getWorld());
|
||||||
@ -371,7 +371,7 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
|
|
||||||
// Permission bridge
|
// Permission bridge
|
||||||
if (plugin.getPermissionProvider() != null) {
|
if (plugin.getPermissionProvider() != null) {
|
||||||
for (String permission : gameWorld.getConfig().getGamePermissions()) {
|
for (String permission : rules.getGamePermissions()) {
|
||||||
plugin.getPermissionProvider().playerRemoveTransient(getWorld().getName(), player, permission);
|
plugin.getPermissionProvider().playerRemoveTransient(getWorld().getName(), player, permission);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -385,7 +385,7 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
if (game != null) {
|
if (game != null) {
|
||||||
if (finished) {
|
if (finished) {
|
||||||
if (game.getType().hasRewards()) {
|
if (game.getType().hasRewards()) {
|
||||||
for (Reward reward : gameWorld.getConfig().getRewards()) {
|
for (Reward reward : rules.getRewards()) {
|
||||||
reward.giveTo(getPlayer());
|
reward.giveTo(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,7 +515,7 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Respawn Items
|
// Respawn Items
|
||||||
if (GameWorld.getByWorld(getWorld()).getConfig().getKeepInventoryOnDeath()) {
|
if (Game.getByWorld(getWorld()).getRules().getKeepInventoryOnDeath()) {
|
||||||
applyRespawnInventory();
|
applyRespawnInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package io.github.dre2n.dungeonsxl.player;
|
|||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
|
||||||
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupDisbandEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupDisbandEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupStartFloorEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupStartFloorEvent;
|
||||||
@ -27,6 +26,7 @@ import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerJoinDGroupEvent;
|
|||||||
import io.github.dre2n.dungeonsxl.event.requirement.RequirementDemandEvent;
|
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.GameType;
|
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||||
@ -521,9 +521,9 @@ public class DGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldConfig config = gameWorld.getConfig();
|
GameRules rules = gameWorld.getGame().getRules();
|
||||||
if (config != null) {
|
if (rules != null) {
|
||||||
for (Requirement requirement : config.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);
|
||||||
|
|
||||||
@ -536,22 +536,22 @@ public class DGroup {
|
|||||||
|
|
||||||
GameType gameType = game.getType();
|
GameType gameType = game.getType();
|
||||||
if (gameType == GameTypeDefault.DEFAULT) {
|
if (gameType == GameTypeDefault.DEFAULT) {
|
||||||
player.setGameMode(config.getGameMode());
|
player.setGameMode(rules.getGameMode());
|
||||||
if (config.isTimeIsRunning()) {
|
if (rules.isTimeIsRunning()) {
|
||||||
timeIsRunningTask = new TimeIsRunningTask(this, config.getTimeToFinish()).runTaskTimer(plugin, 20, 20);
|
timeIsRunningTask = new TimeIsRunningTask(this, rules.getTimeToFinish()).runTaskTimer(plugin, 20, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
player.setGameMode(gameType.getGameMode());
|
player.setGameMode(gameType.getGameMode());
|
||||||
if (gameType.getShowTime()) {
|
if (gameType.getShowTime()) {
|
||||||
timeIsRunningTask = new TimeIsRunningTask(this, config.getTimeToFinish()).runTaskTimer(plugin, 20, 20);
|
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 : gameWorld.getConfig().getGamePermissions()) {
|
for (String permission : rules.getGamePermissions()) {
|
||||||
plugin.getPermissionProvider().playerRemoveTransient(gameWorld.getWorld().getName(), player, permission);
|
plugin.getPermissionProvider().playerRemoveTransient(gameWorld.getWorld().getName(), player, permission);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class ClassesSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
if (getGameWorld().getConfig().isLobbyDisabled()) {
|
if (getGame().getRules().isLobbyDisabled()) {
|
||||||
getSign().getBlock().setType(Material.AIR);
|
getSign().getBlock().setType(Material.AIR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ public class ClassesSign extends DSign {
|
|||||||
int directionZ = direction[1];
|
int directionZ = direction[1];
|
||||||
|
|
||||||
int xx = 0, zz = 0;
|
int xx = 0, zz = 0;
|
||||||
for (DClass dclass : getGameWorld().getConfig().getClasses()) {
|
for (DClass dclass : getGame().getRules().getClasses()) {
|
||||||
|
|
||||||
// Check existing signs
|
// Check existing signs
|
||||||
boolean isContinued = true;
|
boolean isContinued = true;
|
||||||
|
@ -54,7 +54,7 @@ public class MessageSign extends DSign {
|
|||||||
String lines[] = getSign().getLines();
|
String lines[] = getSign().getLines();
|
||||||
|
|
||||||
if (!lines[1].isEmpty()) {
|
if (!lines[1].isEmpty()) {
|
||||||
String msg = getGameWorld().getConfig().getMsg(NumberUtil.parseInt(lines[1]), true);
|
String msg = getGame().getRules().getMsg(NumberUtil.parseInt(lines[1]), true);
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
getSign().getBlock().setType(Material.AIR);
|
getSign().getBlock().setType(Material.AIR);
|
||||||
|
@ -53,7 +53,7 @@ public class SoundMessageSign extends DSign {
|
|||||||
String lines[] = getSign().getLines();
|
String lines[] = getSign().getLines();
|
||||||
|
|
||||||
if (!lines[1].isEmpty()) {
|
if (!lines[1].isEmpty()) {
|
||||||
String msg = getGameWorld().getConfig().getMsg(NumberUtil.parseInt(lines[1]), true);
|
String msg = getGame().getRules().getMsg(NumberUtil.parseInt(lines[1]), true);
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
getSign().getBlock().setType(Material.AIR);
|
getSign().getBlock().setType(Material.AIR);
|
||||||
|
@ -71,7 +71,7 @@ public class MobSpawnTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check custom mobs
|
// Check custom mobs
|
||||||
DMobType mobType = DMobType.getByName(sign.getMob(), gameWorld.getConfig().getMobTypes());
|
DMobType mobType = DMobType.getByName(sign.getMob(), gameWorld.getGame().getRules().getMobTypes());
|
||||||
|
|
||||||
if (mobType != null) {
|
if (mobType != null) {
|
||||||
mobType.spawn(GameWorld.getByWorld(world), spawnLoc);
|
mobType.spawn(GameWorld.getByWorld(world), spawnLoc);
|
||||||
|
@ -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.event.dplayer.DPlayerKickEvent;
|
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
|
||||||
|
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 org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -72,7 +73,7 @@ public class TimeIsRunningTask extends BukkitRunnable {
|
|||||||
if (!dPlayerKickEvent.isCancelled()) {
|
if (!dPlayerKickEvent.isCancelled()) {
|
||||||
MessageUtil.broadcastMessage(DMessages.PLAYER_TIME_KICK.getMessage(player.getName()));
|
MessageUtil.broadcastMessage(DMessages.PLAYER_TIME_KICK.getMessage(player.getName()));
|
||||||
dPlayer.leave();
|
dPlayer.leave();
|
||||||
if (dGroup.getGameWorld().getConfig().getKeepInventoryOnEscape()) {
|
if (Game.getByDGroup(dGroup).getRules().getKeepInventoryOnEscape()) {
|
||||||
dPlayer.applyRespawnInventory();
|
dPlayer.applyRespawnInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user