mirror of
https://github.com/songoda/EpicFurnaces.git
synced 2025-02-12 17:41:22 +01:00
Only allow remote in loaded chunks.
This commit is contained in:
parent
15059ad7c6
commit
b529b19678
@ -25,6 +25,7 @@ public class CommandRemote extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
Player player = ((Player) sender);
|
||||
if (!Settings.REMOTE.getBoolean() || !sender.hasPermission("EpicFurnaces.Remote")) {
|
||||
plugin.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
@ -40,21 +41,17 @@ public class CommandRemote extends AbstractCommand {
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (!furnace.isInLoadedChunk()) {
|
||||
plugin.getLocale().getMessage("event.remote.notloaded").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
for (UUID uuid : furnace.getAccessList()) {
|
||||
if (!uuid.equals(((Player) sender).getUniqueId())) continue;
|
||||
Block b = furnace.getLocation().getBlock();
|
||||
b.getChunk().load();
|
||||
Block b = furnace.getLocation().getBlock();
|
||||
org.bukkit.block.Furnace furnaceBlock = (org.bukkit.block.Furnace) b.getState();
|
||||
Inventory inventory = furnaceBlock.getInventory();
|
||||
((Player) sender).openInventory(inventory);
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
if (inventory.getViewers().size() == 0) {
|
||||
b.getChunk().unload();
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 5L, 5L);
|
||||
player.openInventory(inventory);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
plugin.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(sender);
|
||||
|
@ -64,5 +64,6 @@ event:
|
||||
remote:
|
||||
enter: '&7Enter a unique nickname for the furnace.'
|
||||
notfound: '&cRemote furnace not found.'
|
||||
notloaded: '&cThat furnace isn't in a loaded chunk...'
|
||||
nicknamesuccess: '&aNickname set successfully.'
|
||||
nicknameinuse: '&cThat nickname is already in use.'
|
||||
|
Loading…
Reference in New Issue
Block a user