mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2025-01-08 09:17:46 +01:00
parent
6dd6133978
commit
6e0d4ef9b8
@ -243,7 +243,7 @@ public class DungeonsXL extends BRPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
// Getters & loaders
|
||||
/* Getters and loaders */
|
||||
/**
|
||||
* @return the plugin instance
|
||||
*/
|
||||
|
@ -22,8 +22,8 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
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.player.DGamePlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -48,7 +48,13 @@ public class LeaveCommand extends BRCommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
|
||||
|
||||
if (!(plugin.getDPlayers().getByPlayer(player) instanceof DInstancePlayer)) {
|
||||
MessageUtil.sendMessage(player, DMessages.ERROR_NOT_IN_DUNGEON.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
DInstancePlayer dPlayer = (DInstancePlayer) plugin.getDPlayers().getByPlayer(player);
|
||||
|
||||
if (GameWorld.getByWorld(player.getWorld()) != null) {
|
||||
if (GameWorld.getByWorld(player.getWorld()).isTutorial()) {
|
||||
@ -77,10 +83,7 @@ public class LeaveCommand extends BRCommand {
|
||||
if (dGroup != null) {
|
||||
dGroup.removePlayer(player);
|
||||
MessageUtil.sendMessage(player, DMessages.CMD_LEAVE_SUCCESS.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
MessageUtil.sendMessage(player, DMessages.ERROR_NOT_IN_DUNGEON.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
*/
|
||||
public class MainConfig extends BRConfig {
|
||||
|
||||
public static final int CONFIG_VERSION = 5;
|
||||
public static final int CONFIG_VERSION = 6;
|
||||
|
||||
private String language = "en";
|
||||
private boolean enableEconomy = false;
|
||||
@ -44,13 +44,16 @@ public class MainConfig extends BRConfig {
|
||||
private boolean sendFloorTitle = true;
|
||||
private Map<String, Object> externalMobProviders = new HashMap<>();
|
||||
|
||||
/* Secure Mode*/
|
||||
/* Secure Mode */
|
||||
private boolean secureModeEnabled = false;
|
||||
private double secureModeCheckInterval = 5;
|
||||
private boolean openInventories = false;
|
||||
private boolean dropItems = false;
|
||||
private List<String> editCommandWhitelist = new ArrayList<>();
|
||||
|
||||
/* Permissions bridge */
|
||||
private List<String> editPermissions = new ArrayList<>();
|
||||
|
||||
/* Default Dungeon Settings */
|
||||
private WorldConfig defaultWorldConfig;
|
||||
|
||||
@ -154,6 +157,13 @@ public class MainConfig extends BRConfig {
|
||||
return editCommandWhitelist;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the edit mode permissions
|
||||
*/
|
||||
public List<String> getEditPermissions() {
|
||||
return editPermissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the defaultWorldConfig
|
||||
*/
|
||||
@ -216,6 +226,10 @@ public class MainConfig extends BRConfig {
|
||||
config.set("secureMode.editCommandWhitelist", editCommandWhitelist);
|
||||
}
|
||||
|
||||
if (!config.contains("editPermissions")) {
|
||||
config.set("editPermissions", editPermissions);
|
||||
}
|
||||
|
||||
/* Default Dungeon Config */
|
||||
if (!config.contains("default")) {
|
||||
config.createSection("default");
|
||||
@ -279,6 +293,10 @@ public class MainConfig extends BRConfig {
|
||||
editCommandWhitelist = config.getStringList("secureMode.editCommandWhitelist");
|
||||
}
|
||||
|
||||
if (config.contains("editPermissions")) {
|
||||
editPermissions = config.getStringList("editPermissions");
|
||||
}
|
||||
|
||||
/* Default Dungeon Config */
|
||||
ConfigurationSection configSection = config.getConfigurationSection("default");
|
||||
if (configSection != null) {
|
||||
|
@ -96,6 +96,7 @@ public class WorldConfig {
|
||||
private Set<DMobType> mobTypes = new HashSet<>();
|
||||
|
||||
private List<String> gameCommandWhitelist = new ArrayList<>();
|
||||
private List<String> gamePermissions = new ArrayList<>();
|
||||
|
||||
public WorldConfig() {
|
||||
}
|
||||
@ -359,6 +360,12 @@ public class WorldConfig {
|
||||
gameCommandWhitelist = plugin.getDefaultConfig().gameCommandWhitelist;
|
||||
}
|
||||
|
||||
if (configFile.contains("gamePermissions")) {
|
||||
gamePermissions = configFile.getStringList("gamePermissions");
|
||||
} else {
|
||||
gamePermissions = plugin.getDefaultConfig().gamePermissions;
|
||||
}
|
||||
|
||||
if (configFile.contains("forcedGameType")) {
|
||||
GameType gameType = plugin.getGameTypes().getByName(configFile.getString("forcedGameType"));
|
||||
if (gameType != null) {
|
||||
@ -667,6 +674,13 @@ public class WorldConfig {
|
||||
return gameCommandWhitelist;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the gamePermissions
|
||||
*/
|
||||
public List<String> getGamePermissions() {
|
||||
return gamePermissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the forcedGameType
|
||||
*/
|
||||
|
@ -57,6 +57,13 @@ public class DEditPlayer extends DInstancePlayer {
|
||||
} else {
|
||||
PlayerUtil.secureTeleport(player, teleport);
|
||||
}
|
||||
|
||||
// Permission bridge
|
||||
if (plugin.getPermissionProvider() != null) {
|
||||
for (String permission : plugin.getMainConfig().getEditPermissions()) {
|
||||
plugin.getPermissionProvider().playerAddTransient(world.getName(), player, permission);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
@ -76,6 +83,18 @@ public class DEditPlayer extends DInstancePlayer {
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
@Override
|
||||
public void delete() {
|
||||
// Permission bridge
|
||||
if (plugin.getPermissionProvider() != null) {
|
||||
for (String permission : plugin.getMainConfig().getEditPermissions()) {
|
||||
plugin.getPermissionProvider().playerRemoveTransient(getWorld().getName(), player, permission);
|
||||
}
|
||||
}
|
||||
|
||||
super.delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape the EditWorld without saving.
|
||||
*/
|
||||
@ -115,6 +134,8 @@ public class DEditPlayer extends DInstancePlayer {
|
||||
|
||||
@Override
|
||||
public void leave() {
|
||||
delete();
|
||||
|
||||
getSavePlayer().reset(false);
|
||||
|
||||
EditWorld editWorld = EditWorld.getByWorld(getWorld());
|
||||
@ -141,14 +162,13 @@ public class DEditPlayer extends DInstancePlayer {
|
||||
public void update(boolean updateSecond) {
|
||||
boolean locationValid = true;
|
||||
Location teleportLocation = player.getLocation();
|
||||
boolean teleportWolf = false;
|
||||
boolean respawnInventory = false;
|
||||
boolean offline = false;
|
||||
boolean kick = false;
|
||||
boolean triggerAllInDistance = false;
|
||||
|
||||
EditWorld editWorld = EditWorld.getByWorld(getWorld());
|
||||
|
||||
if (!getPlayer().getWorld().equals(getWorld())) {
|
||||
locationValid = false;
|
||||
}
|
||||
|
||||
if (editWorld != null) {
|
||||
if (editWorld.getLobbyLocation() == null) {
|
||||
teleportLocation = editWorld.getWorld().getSpawnLocation();
|
||||
@ -157,8 +177,16 @@ public class DEditPlayer extends DInstancePlayer {
|
||||
}
|
||||
}
|
||||
|
||||
DPlayerUpdateEvent event = new DPlayerUpdateEvent(this, locationValid, teleportWolf, respawnInventory, offline, kick, triggerAllInDistance);
|
||||
DPlayerUpdateEvent event = new DPlayerUpdateEvent(this, locationValid, false, false, false, false, false);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!locationValid) {
|
||||
PlayerUtil.secureTeleport(getPlayer(), teleportLocation);
|
||||
}
|
||||
}
|
||||
|
||||
/* Statics */
|
||||
|
@ -369,6 +369,13 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
GameWorld gameWorld = GameWorld.getByWorld(getWorld());
|
||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
||||
|
||||
// Permission bridge
|
||||
if (plugin.getPermissionProvider() != null) {
|
||||
for (String permission : gameWorld.getConfig().getGamePermissions()) {
|
||||
plugin.getPermissionProvider().playerRemoveTransient(getWorld().getName(), player, permission);
|
||||
}
|
||||
}
|
||||
|
||||
Game game = Game.getByGameWorld(gameWorld);
|
||||
if (dGroup != null) {
|
||||
dGroup.removePlayer(getPlayer());
|
||||
|
@ -548,6 +548,13 @@ public class DGroup {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Permission bridge
|
||||
if (plugin.getPermissionProvider() != null) {
|
||||
for (String permission : gameWorld.getConfig().getGamePermissions()) {
|
||||
plugin.getPermissionProvider().playerRemoveTransient(gameWorld.getWorld().getName(), player, permission);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GroupSign.updatePerGroup(this);
|
||||
|
Loading…
Reference in New Issue
Block a user