mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-02 17:00:19 +01:00
Don't reload if players are in a game; resolves #185
This commit is contained in:
parent
151a8be490
commit
4133e20471
@ -68,7 +68,7 @@ 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_.
|
||||
|
||||
#### BRCommons
|
||||
[BRCommons](https://github.com/DRE2N/BRCommons) is a util library for common tasks. DungeonsXL contains BRCommons 1.0.3.
|
||||
[BRCommons](https://github.com/DRE2N/BRCommons) is a util library for common tasks. DungeonsXL contains BRCommons 1.0.4.
|
||||
|
||||
#### 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.3.
|
||||
|
@ -19,13 +19,19 @@ package io.github.dre2n.dungeonsxl.command;
|
||||
import io.github.dre2n.commons.command.BRCommand;
|
||||
import io.github.dre2n.commons.compatibility.CompatibilityHandler;
|
||||
import io.github.dre2n.commons.compatibility.Internals;
|
||||
import io.github.dre2n.commons.util.messageutil.DefaultFontInfo;
|
||||
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.event.DataReloadEvent;
|
||||
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import java.util.List;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
/**
|
||||
@ -38,7 +44,7 @@ public class ReloadCommand extends BRCommand {
|
||||
public ReloadCommand() {
|
||||
setCommand("reload");
|
||||
setMinArgs(0);
|
||||
setMaxArgs(0);
|
||||
setMaxArgs(1);
|
||||
setHelp(DMessages.HELP_CMD_RELOAD.getMessage());
|
||||
setPermission(DPermissions.RELOAD.getNode());
|
||||
setPlayerCommand(true);
|
||||
@ -47,6 +53,17 @@ public class ReloadCommand extends BRCommand {
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
List<DInstancePlayer> dPlayers = plugin.getDPlayers().getDInstancePlayers();
|
||||
if (!dPlayers.isEmpty() && args.length == 1 && CompatibilityHandler.getInstance().isSpigot() && sender instanceof Player) {
|
||||
MessageUtil.sendMessage(sender, DMessages.CMD_RELOAD_PLAYERS.getMessage());
|
||||
ClickEvent onClick = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/dungeonsxl reload -force");
|
||||
String message = DefaultFontInfo.center("&a[ OK ]");
|
||||
TextComponent text = new TextComponent(message);
|
||||
text.setClickEvent(onClick);
|
||||
((Player) sender).spigot().sendMessage(text);
|
||||
return;
|
||||
}
|
||||
|
||||
PluginManager plugins = Bukkit.getPluginManager();
|
||||
|
||||
DataReloadEvent event = new DataReloadEvent();
|
||||
@ -55,6 +72,10 @@ public class ReloadCommand extends BRCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
for (DInstancePlayer dPlayer : dPlayers) {
|
||||
dPlayer.leave();
|
||||
}
|
||||
|
||||
int maps = DungeonsXL.MAPS.listFiles().length;
|
||||
int dungeons = DungeonsXL.DUNGEONS.listFiles().length;
|
||||
int loaded = plugin.getDWorlds().getEditWorlds().size() + plugin.getDWorlds().getGameWorlds().size();
|
||||
|
@ -55,6 +55,7 @@ public enum DMessages implements Messages {
|
||||
CMD_MSG_ADDED("Cmd_Msg_Added", "&6New Messages (&4&v1&6) added!"),
|
||||
CMD_MSG_UPDATED("Cmd_Msg_Updated", "&6Messages (&4&v1&6) updated!"),
|
||||
CMD_RELOAD_DONE("Cmd_Reload_Done", "&7Successfully reloaded DungeonsXL."),
|
||||
CMD_RELOAD_PLAYERS("Cmd_Reload_Players", "&4Warning: If you reload the plugin, all players will get kicked out of their game."),
|
||||
CMD_RENAME_SUCCESS("Cmd_Rename_Success", "&6Successfully renamed the map &4&v1&6 to &4&v2&6."),
|
||||
CMD_SAVE_SUCCESS("Cmd_Save_Success", "&6Map saved!"),
|
||||
CMD_UNINVITE_SUCCESS("Cmd_Uninvite_Success", "&4&v1&6's permission to edit the map &4&v2&6 has been removed successfully."),
|
||||
|
Loading…
Reference in New Issue
Block a user