From db0f6ee37fbacbb775c069fd97505aa7397ec75d Mon Sep 17 00:00:00 2001 From: rlf Date: Fri, 13 Jul 2018 12:37:03 +0200 Subject: [PATCH] Fixed issue #1009 and made it more configurable. It now uses the output from `/is info` to count items. Might be memory intensive, so perhaps it should be disabled per default. --- .../ultimateskyblock/api}/async/Callback.java | 3 +- .../event/CancellableAsyncPlayerEvent.java | 34 ++++++ .../api/event/IslandInfoEvent.java | 38 +++++++ .../api/event/uSkyBlockScoreChangedEvent.java | 9 +- .../command/admin/PurgeCommand.java | 2 - .../command/island/BiomeCommand.java | 1 - .../command/island/InfoCommand.java | 16 +-- .../command/island/LevelCommand.java | 8 +- .../event/InternalEvents.java | 15 +++ .../ultimateskyblock/event/PlayerEvents.java | 78 +++++++++---- .../island/BlockLimitLogic.java | 105 ++++++++++++++++++ .../ultimateskyblock/island/IslandInfo.java | 1 + .../ultimateskyblock/island/IslandLogic.java | 2 +- .../island/{ => level}/AweLevelLogic.java | 13 ++- .../{ => level}/BlockScoreComparator.java | 2 +- .../island/{ => level}/BlockScoreImpl.java | 2 +- .../{ => level}/ChunkSnapshotLevelLogic.java | 4 +- .../island/{ => level}/CommonLevelLogic.java | 2 +- .../island/{ => level}/IslandScore.java | 3 +- .../island/{ => level}/LevelLogic.java | 4 +- .../island/task/ChunkSnapShotTask.java | 2 +- .../island/task/RecalculateTopTen.java | 7 +- .../player/PatienceTester.java | 36 ++++++ .../talabrek/ultimateskyblock/uSkyBlock.java | 54 +++++---- .../ultimateskyblock/util/LocationUtil.java | 2 +- uSkyBlock-Core/src/main/po/cs.po | 33 +++++- uSkyBlock-Core/src/main/po/da.po | 33 +++++- uSkyBlock-Core/src/main/po/de.po | 33 +++++- uSkyBlock-Core/src/main/po/en_GB.po | 33 +++++- uSkyBlock-Core/src/main/po/es.po | 33 +++++- uSkyBlock-Core/src/main/po/fr.po | 33 +++++- uSkyBlock-Core/src/main/po/it.po | 33 +++++- uSkyBlock-Core/src/main/po/keys.pot | 33 +++++- uSkyBlock-Core/src/main/po/ko.po | 33 +++++- uSkyBlock-Core/src/main/po/nl.po | 33 +++++- uSkyBlock-Core/src/main/po/pt_BR.po | 33 +++++- uSkyBlock-Core/src/main/po/ru.po | 33 +++++- uSkyBlock-Core/src/main/po/sv.po | 33 +++++- uSkyBlock-Core/src/main/po/vi_VN.po | 33 +++++- uSkyBlock-Core/src/main/po/xx_PIRATE.po | 33 +++++- uSkyBlock-Core/src/main/po/xx_lol_US.po | 33 +++++- uSkyBlock-Core/src/main/po/zh_CN.po | 33 +++++- uSkyBlock-Core/src/main/resources/config.yml | 20 ++-- 43 files changed, 919 insertions(+), 105 deletions(-) rename {uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock => uSkyBlock-API/src/main/java/us/talabrek/ultimateskyblock/api}/async/Callback.java (79%) create mode 100644 uSkyBlock-API/src/main/java/us/talabrek/ultimateskyblock/api/event/CancellableAsyncPlayerEvent.java create mode 100644 uSkyBlock-API/src/main/java/us/talabrek/ultimateskyblock/api/event/IslandInfoEvent.java create mode 100644 uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/BlockLimitLogic.java rename uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/{ => level}/AweLevelLogic.java (88%) rename uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/{ => level}/BlockScoreComparator.java (92%) rename uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/{ => level}/BlockScoreImpl.java (96%) rename uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/{ => level}/ChunkSnapshotLevelLogic.java (98%) rename uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/{ => level}/CommonLevelLogic.java (99%) rename uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/{ => level}/IslandScore.java (96%) rename uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/{ => level}/LevelLogic.java (55%) create mode 100644 uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/player/PatienceTester.java diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/async/Callback.java b/uSkyBlock-API/src/main/java/us/talabrek/ultimateskyblock/api/async/Callback.java similarity index 79% rename from uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/async/Callback.java rename to uSkyBlock-API/src/main/java/us/talabrek/ultimateskyblock/api/async/Callback.java index 284ed254c..189f907f5 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/async/Callback.java +++ b/uSkyBlock-API/src/main/java/us/talabrek/ultimateskyblock/api/async/Callback.java @@ -1,7 +1,8 @@ -package us.talabrek.ultimateskyblock.async; +package us.talabrek.ultimateskyblock.api.async; /** * Runnable with state. + * @since v2.7.3 */ public abstract class Callback implements Runnable { private volatile T state; diff --git a/uSkyBlock-API/src/main/java/us/talabrek/ultimateskyblock/api/event/CancellableAsyncPlayerEvent.java b/uSkyBlock-API/src/main/java/us/talabrek/ultimateskyblock/api/event/CancellableAsyncPlayerEvent.java new file mode 100644 index 000000000..05a984bfb --- /dev/null +++ b/uSkyBlock-API/src/main/java/us/talabrek/ultimateskyblock/api/event/CancellableAsyncPlayerEvent.java @@ -0,0 +1,34 @@ +package us.talabrek.ultimateskyblock.api.event; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.player.PlayerEvent; + +/** + * Common event for PlayerEvents that can be cancelled (async). + * @since 2.7.3 + */ +public abstract class CancellableAsyncPlayerEvent extends Event implements Cancellable { + private boolean cancelled = false; + private Player player; + + public CancellableAsyncPlayerEvent(Player player) { + super(true); + this.player = player; + } + + public Player getPlayer() { + return player; + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } +} diff --git a/uSkyBlock-API/src/main/java/us/talabrek/ultimateskyblock/api/event/IslandInfoEvent.java b/uSkyBlock-API/src/main/java/us/talabrek/ultimateskyblock/api/event/IslandInfoEvent.java new file mode 100644 index 000000000..fbff4cd74 --- /dev/null +++ b/uSkyBlock-API/src/main/java/us/talabrek/ultimateskyblock/api/event/IslandInfoEvent.java @@ -0,0 +1,38 @@ +package us.talabrek.ultimateskyblock.api.event; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import us.talabrek.ultimateskyblock.api.async.Callback; +import us.talabrek.ultimateskyblock.api.model.IslandScore; + +/** + * @since v2.7.3 + */ +public class IslandInfoEvent extends CancellableAsyncPlayerEvent { + private static final HandlerList handlers = new HandlerList(); + private final Location islandLocation; + private final Callback callback; + + public IslandInfoEvent(Player who, Location islandLocation, Callback callback) { + super(who); + this.islandLocation = islandLocation; + this.callback = callback; + } + + public Location getIslandLocation() { + return islandLocation; + } + + public Callback getCallback() { + return callback; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/uSkyBlock-API/src/main/java/us/talabrek/ultimateskyblock/api/event/uSkyBlockScoreChangedEvent.java b/uSkyBlock-API/src/main/java/us/talabrek/ultimateskyblock/api/event/uSkyBlockScoreChangedEvent.java index 7275d819a..2ec9e464d 100644 --- a/uSkyBlock-API/src/main/java/us/talabrek/ultimateskyblock/api/event/uSkyBlockScoreChangedEvent.java +++ b/uSkyBlock-API/src/main/java/us/talabrek/ultimateskyblock/api/event/uSkyBlockScoreChangedEvent.java @@ -1,5 +1,6 @@ package us.talabrek.ultimateskyblock.api.event; +import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import us.talabrek.ultimateskyblock.api.model.IslandScore; @@ -12,10 +13,12 @@ public class uSkyBlockScoreChangedEvent extends uSkyBlockEvent { private static final HandlerList handlers = new HandlerList(); private final IslandScore score; + private final Location islandLocation; - public uSkyBlockScoreChangedEvent(Player player, uSkyBlockAPI api, IslandScore score) { + public uSkyBlockScoreChangedEvent(Player player, uSkyBlockAPI api, IslandScore score, Location islandLocation) { super(player, api, Cause.SCORE_CHANGED); this.score = score; + this.islandLocation = islandLocation; } /** @@ -26,6 +29,10 @@ public IslandScore getScore() { return score; } + public Location getIslandLocation() { + return islandLocation; + } + @Override public HandlerList getHandlers() { return handlers; diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/command/admin/PurgeCommand.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/command/admin/PurgeCommand.java index d93d47cd8..ac6c958da 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/command/admin/PurgeCommand.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/command/admin/PurgeCommand.java @@ -1,10 +1,8 @@ package us.talabrek.ultimateskyblock.command.admin; import dk.lockfuglsang.minecraft.command.AbstractCommand; -import dk.lockfuglsang.minecraft.po.I18nUtil; import org.bukkit.command.CommandSender; import org.bukkit.scheduler.BukkitRunnable; -import us.talabrek.ultimateskyblock.async.Callback; import us.talabrek.ultimateskyblock.command.admin.task.PurgeScanTask; import us.talabrek.ultimateskyblock.command.admin.task.PurgeTask; import us.talabrek.ultimateskyblock.uSkyBlock; diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/command/island/BiomeCommand.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/command/island/BiomeCommand.java index 8137baac2..7670bb423 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/command/island/BiomeCommand.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/command/island/BiomeCommand.java @@ -6,7 +6,6 @@ import org.bukkit.block.Biome; import org.bukkit.entity.Player; import us.talabrek.ultimateskyblock.Settings; -import us.talabrek.ultimateskyblock.async.Callback; import us.talabrek.ultimateskyblock.handler.WorldGuardHandler; import us.talabrek.ultimateskyblock.island.IslandInfo; import us.talabrek.ultimateskyblock.island.task.SetBiomeTask; diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/command/island/InfoCommand.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/command/island/InfoCommand.java index e5658a5dd..324a91782 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/command/island/InfoCommand.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/command/island/InfoCommand.java @@ -1,13 +1,12 @@ package us.talabrek.ultimateskyblock.command.island; import org.bukkit.entity.Player; -import org.bukkit.metadata.FixedMetadataValue; import us.talabrek.ultimateskyblock.Settings; +import us.talabrek.ultimateskyblock.api.async.Callback; import us.talabrek.ultimateskyblock.api.model.BlockScore; -import us.talabrek.ultimateskyblock.async.Callback; import us.talabrek.ultimateskyblock.handler.VaultHandler; import us.talabrek.ultimateskyblock.island.IslandInfo; -import us.talabrek.ultimateskyblock.island.IslandScore; +import us.talabrek.ultimateskyblock.player.PatienceTester; import us.talabrek.ultimateskyblock.player.PlayerInfo; import us.talabrek.ultimateskyblock.uSkyBlock; import us.talabrek.ultimateskyblock.util.LogUtil; @@ -30,6 +29,9 @@ protected boolean doExecute(String alias, Player player, PlayerInfo pi, IslandIn player.sendMessage(tr("\u00a74Island level has been disabled, contact an administrator.")); return true; } + if (PatienceTester.isRunning(player, "usb.island.info.active")) { + return true; + } if (player.hasMetadata("usb.island.info.active")) { player.sendMessage(tr("\u00a74Hold your horses! \u00a7eYou have to be patient...")); return true; @@ -63,7 +65,7 @@ public boolean getIslandInfo(final Player player, final String islandPlayer, fin return false; } final PlayerInfo playerInfo = islandPlayer.equals(player.getName()) ? plugin.getPlayerInfo(player) : plugin.getPlayerInfo(islandPlayer); - final Callback showInfo = new Callback() { + final Callback showInfo = new Callback() { @Override public void run() { if (player.isOnline()) { @@ -79,19 +81,19 @@ public void run() { if (cmd.equalsIgnoreCase("info") && getState() != null) { player.sendMessage(tr("Score Count Block")); for (BlockScore score : getState().getTop((currentPage - 1) * 10, 10)) { - player.sendMessage(score.getState().getColor() + String.format("%05.2f %d %s", + player.sendMessage(score.getState().getColor() + tr("{0,number,#####.##} {1,number,#} {2}", score.getScore(), score.getCount(), VaultHandler.getItemName(score.getBlock()))); } player.sendMessage(tr("\u00a7aIsland level is {0,number,###.##}", getState().getScore())); } } - player.removeMetadata("usb.island.info.active", plugin); + PatienceTester.stopRunning(player, "usb.island.info.active"); } }; plugin.sync(() -> { try { - player.setMetadata("usb.island.info.active", new FixedMetadataValue(plugin, Boolean.TRUE)); + PatienceTester.startRunning(player, "usb.island.info.active"); plugin.calculateScoreAsync(player, playerInfo.locationForParty(), showInfo); } catch (Exception e) { LogUtil.log(Level.SEVERE, "Error while calculating Island Level", e); diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/command/island/LevelCommand.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/command/island/LevelCommand.java index 0c9a97b9d..5c01762fa 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/command/island/LevelCommand.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/command/island/LevelCommand.java @@ -1,19 +1,17 @@ package us.talabrek.ultimateskyblock.command.island; -import dk.lockfuglsang.minecraft.po.I18nUtil; import org.bukkit.entity.Player; import us.talabrek.ultimateskyblock.Settings; import us.talabrek.ultimateskyblock.api.IslandRank; -import us.talabrek.ultimateskyblock.async.Callback; +import us.talabrek.ultimateskyblock.api.async.Callback; import us.talabrek.ultimateskyblock.island.IslandInfo; -import us.talabrek.ultimateskyblock.island.IslandScore; +import us.talabrek.ultimateskyblock.island.level.IslandScore; import us.talabrek.ultimateskyblock.player.PlayerInfo; import us.talabrek.ultimateskyblock.uSkyBlock; import java.util.Map; import static dk.lockfuglsang.minecraft.perm.PermissionUtil.hasPermission; -import static dk.lockfuglsang.minecraft.po.I18nUtil.*; import static dk.lockfuglsang.minecraft.po.I18nUtil.tr; public class LevelCommand extends RequireIslandCommand { @@ -81,7 +79,7 @@ public void run() { plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @Override public void run() { - plugin.calculateScoreAsync(player, info.locationForParty(), new Callback() { + plugin.calculateScoreAsync(player, info.locationForParty(), new Callback() { @Override public void run() { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, showInfo, 10L); diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/event/InternalEvents.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/event/InternalEvents.java index 374b90b58..2009f6a46 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/event/InternalEvents.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/event/InternalEvents.java @@ -4,11 +4,16 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import us.talabrek.ultimateskyblock.api.event.CreateIslandEvent; +import us.talabrek.ultimateskyblock.api.event.IslandInfoEvent; import us.talabrek.ultimateskyblock.api.event.MemberJoinedEvent; import us.talabrek.ultimateskyblock.api.event.MemberLeftEvent; import us.talabrek.ultimateskyblock.api.event.RestartIslandEvent; +import us.talabrek.ultimateskyblock.api.event.uSkyBlockScoreChangedEvent; +import us.talabrek.ultimateskyblock.api.async.Callback; +import us.talabrek.ultimateskyblock.island.level.IslandScore; import us.talabrek.ultimateskyblock.player.PlayerInfo; import us.talabrek.ultimateskyblock.uSkyBlock; +import us.talabrek.ultimateskyblock.util.LocationUtil; /** * Main event-handler for internal uSkyBlock events @@ -45,4 +50,14 @@ public void onMemberLeft(MemberLeftEvent e) { PlayerInfo playerInfo = (PlayerInfo) e.getPlayerInfo(); playerInfo.execCommands(plugin.getConfig().getStringList("options.party.leave-commands")); } + + @EventHandler + public void onScoreChanged(uSkyBlockScoreChangedEvent e) { + plugin.getBlockLimitLogic().updateBlockCount(e.getIslandLocation(), (IslandScore) e.getScore()); + } + + @EventHandler + public void onInfoEvent(IslandInfoEvent e) { + plugin.calculateScoreAsync(e.getPlayer(), LocationUtil.getIslandName(e.getIslandLocation()), e.getCallback()); + } } diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/event/PlayerEvents.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/event/PlayerEvents.java index 39b7f22d3..633e69205 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/event/PlayerEvents.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/event/PlayerEvents.java @@ -1,9 +1,9 @@ package us.talabrek.ultimateskyblock.event; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.EnderPearl; import org.bukkit.entity.Monster; import org.bukkit.entity.Player; @@ -25,8 +25,14 @@ import org.bukkit.inventory.PlayerInventory; import org.bukkit.projectiles.ProjectileSource; import us.talabrek.ultimateskyblock.Settings; +import us.talabrek.ultimateskyblock.api.async.Callback; +import us.talabrek.ultimateskyblock.api.event.IslandInfoEvent; +import us.talabrek.ultimateskyblock.api.model.IslandScore; +import us.talabrek.ultimateskyblock.handler.VaultHandler; import us.talabrek.ultimateskyblock.handler.WorldGuardHandler; +import us.talabrek.ultimateskyblock.island.BlockLimitLogic; import us.talabrek.ultimateskyblock.island.IslandInfo; +import us.talabrek.ultimateskyblock.player.PatienceTester; import us.talabrek.ultimateskyblock.player.Perk; import us.talabrek.ultimateskyblock.player.PlayerInfo; import us.talabrek.ultimateskyblock.uSkyBlock; @@ -38,7 +44,6 @@ import java.util.Set; import java.util.UUID; import java.util.WeakHashMap; -import org.bukkit.ChatColor; import static dk.lockfuglsang.minecraft.perm.PermissionUtil.hasPermission; import static dk.lockfuglsang.minecraft.po.I18nUtil.tr; @@ -56,15 +61,16 @@ public class PlayerEvents implements Listener { private final boolean visitorMonsterProtected; private final boolean protectLava; private final Map obsidianClick = new WeakHashMap<>(); - private final int hopperlimit; + private final boolean blockLimitsEnabled; public PlayerEvents(uSkyBlock plugin) { this.plugin = plugin; - visitorFallProtected = plugin.getConfig().getBoolean("options.protection.visitors.fall", true); - visitorFireProtected = plugin.getConfig().getBoolean("options.protection.visitors.fire-damage", true); - visitorMonsterProtected = plugin.getConfig().getBoolean("options.protection.visitors.monster-damage", false); - protectLava = plugin.getConfig().getBoolean("options.protection.protect-lava", true); - hopperlimit = plugin.getConfig().getInt("options.island.hopperlimit", 10); + FileConfiguration config = plugin.getConfig(); + visitorFallProtected = config.getBoolean("options.protection.visitors.fall", true); + visitorFireProtected = config.getBoolean("options.protection.visitors.fire-damage", true); + visitorMonsterProtected = config.getBoolean("options.protection.visitors.monster-damage", false); + protectLava = config.getBoolean("options.protection.protect-lava", true); + blockLimitsEnabled = config.getBoolean("options.island.block-limits.enabled", false); } @EventHandler(priority = EventPriority.NORMAL) @@ -264,28 +270,52 @@ public void onLeafBreak(BlockBreakEvent event) { } @EventHandler - public void onHopperPlace(BlockPlaceEvent event) + public void onBlockPlaceEvent(BlockPlaceEvent event) { - if (Material.HOPPER.equals(event.getBlock().getType())) - { - IslandInfo isInfo = plugin.getIslandInfo(event.getBlock().getLocation()); - if(isInfo.getHopperCount() > hopperlimit) - { - event.setCancelled(true); - event.getPlayer().sendMessage(tr("\u00a74You've hit the hopper limit! You can't have more hoppers!")); - } - else - { - isInfo.setHopperCount(isInfo.getHopperCount() + 1); + final Player player = event.getPlayer(); + if (!blockLimitsEnabled || player == null || !plugin.isSkyWorld(player.getWorld()) || event.isCancelled()) { + return; // Skip + } + + IslandInfo islandInfo = plugin.getIslandInfo(event.getBlock().getLocation()); + if (islandInfo == null) { + return; + } + Material type = event.getBlock().getType(); + BlockLimitLogic.CanPlace canPlace = plugin.getBlockLimitLogic().canPlace(type, islandInfo.getIslandLocation()); + if (canPlace == BlockLimitLogic.CanPlace.UNCERTAIN) { + event.setCancelled(true); + final String key = "usb.block-limits"; + if (!PatienceTester.isRunning(player, key)) { + PatienceTester.startRunning(player, key); + player.sendMessage(tr("\u00a74{0} is limited. \u00a7eScanning your island to see if you are allowed to place more, please be patient", VaultHandler.getItemName(new ItemStack(type)))); + plugin.fireAsyncEvent(new IslandInfoEvent(player, islandInfo.getIslandLocation(), new Callback() { + @Override + public void run() { + player.sendMessage(tr("\u00a7e... Scanning complete, you can try again")); + PatienceTester.stopRunning(player, key); + } + })); } + return; + } + if (canPlace == BlockLimitLogic.CanPlace.NO) { + event.setCancelled(true); + player.sendMessage(tr("\u00a74You''ve hit the {0} limit!\u00a7e You can''t have more of that type on your island!\u00a79 Max: {1,number}", VaultHandler.getItemName(new ItemStack(type)), plugin.getBlockLimitLogic().getLimit(type))); + return; } + plugin.getBlockLimitLogic().incBlockCount(islandInfo.getIslandLocation(), type); } @EventHandler public void onHopperDestroy(BlockBreakEvent event){ - if (Material.HOPPER.equals(event.getBlock().getType())){ - IslandInfo isInfo = plugin.getIslandInfo(event.getBlock().getLocation()); - isInfo.setHopperCount(isInfo.getHopperCount() - 1); - } + if (!blockLimitsEnabled || event.getPlayer() == null || !plugin.isSkyWorld(event.getPlayer().getWorld()) || event.isCancelled()) { + return; // Skip + } + IslandInfo islandInfo = plugin.getIslandInfo(event.getBlock().getLocation()); + if (islandInfo == null) { + return; + } + plugin.getBlockLimitLogic().decBlockCount(islandInfo.getIslandLocation(), event.getBlock().getType()); } } diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/BlockLimitLogic.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/BlockLimitLogic.java new file mode 100644 index 000000000..1cd644fe9 --- /dev/null +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/BlockLimitLogic.java @@ -0,0 +1,105 @@ +package us.talabrek.ultimateskyblock.island; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.FileConfiguration; +import us.talabrek.ultimateskyblock.api.model.BlockScore; +import us.talabrek.ultimateskyblock.island.level.IslandScore; +import us.talabrek.ultimateskyblock.uSkyBlock; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Logger; + +public class BlockLimitLogic { + public enum CanPlace { YES, UNCERTAIN, NO}; + + private static final Logger log = Logger.getLogger(BlockLimitLogic.class.getName()); + private uSkyBlock plugin; + private Map blockLimits = new HashMap<>(); + // TODO: Rasmus - 13-07-2018: Persist this somehow - and use a guavacache + private Map> blockCounts = new HashMap<>(); + + private final boolean limitsEnabled; + + public BlockLimitLogic(uSkyBlock plugin) { + this.plugin = plugin; + FileConfiguration config = plugin.getConfig(); + limitsEnabled = config.getBoolean("options.island.block-limits.enabled", false); + if (limitsEnabled) { + ConfigurationSection section = config.getConfigurationSection("options.island.block-limits"); + Set keys = section.getKeys(false); + keys.remove("enabled"); + for (String key : keys) { + Material material = Material.getMaterial(key.toUpperCase()); + int limit = section.getInt(key, -1); + if (material != null && limit >= 0) { + blockLimits.put(material, limit); + } else { + log.warning("Unknown material " + key + " supplied for block-limit, or value not an integer"); + } + } + } + } + + public int getLimit(Material type) { + return blockLimits.getOrDefault(type, Integer.MAX_VALUE); + } + + public void updateBlockCount(Location islandLocation, IslandScore score) { + if (!limitsEnabled) { + return; + } + Map countMap = asBlockCount(score); + blockCounts.put(islandLocation, countMap); + } + + private Map asBlockCount(IslandScore score) { + Map countMap = new ConcurrentHashMap<>(); + for (BlockScore blockScore : score.getTop()) { + Material type = blockScore.getBlock().getType(); + if (blockLimits.containsKey(type)) { + int initalValue = countMap.getOrDefault(type, 0); + initalValue += blockScore.getCount(); + countMap.put(type, initalValue); + } + } + return countMap; + } + + public CanPlace canPlace(Material type, Location islandLocation) { + if (!limitsEnabled || !blockLimits.containsKey(type)) { + return CanPlace.YES; + } + Map islandCount = blockCounts.getOrDefault(islandLocation, null); + if (islandCount == null) { + return CanPlace.UNCERTAIN; + } + int blockCount = islandCount.getOrDefault(type, 0); + int limit = blockLimits.getOrDefault(type, Integer.MAX_VALUE); + return blockCount < limit ? CanPlace.YES : CanPlace.NO; + } + + public void incBlockCount(Location islandLocation, Material type) { + if (!limitsEnabled || !blockLimits.containsKey(type)) { + return; + } + Map islandCount = blockCounts.getOrDefault(islandLocation, new ConcurrentHashMap<>()); + int blockCount = islandCount.getOrDefault(type, 0); + islandCount.put(type, blockCount+1); + blockCounts.put(islandLocation, islandCount); + } + + public void decBlockCount(Location islandLocation, Material type) { + if (!limitsEnabled || !blockLimits.containsKey(type)) { + return; + } + Map islandCount = blockCounts.getOrDefault(islandLocation, new ConcurrentHashMap<>()); + int blockCount = islandCount.getOrDefault(type, 0); + islandCount.put(type, blockCount-1); + blockCounts.put(islandLocation, islandCount); + } +} diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/IslandInfo.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/IslandInfo.java index 0d92e7f84..94a5c1624 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/IslandInfo.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/IslandInfo.java @@ -8,6 +8,7 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import us.talabrek.ultimateskyblock.Settings; +import us.talabrek.ultimateskyblock.api.model.IslandScore; import us.talabrek.ultimateskyblock.handler.WorldGuardHandler; import us.talabrek.ultimateskyblock.player.Perk; import us.talabrek.ultimateskyblock.player.PlayerInfo; diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/IslandLogic.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/IslandLogic.java index faecd2903..9e97ff312 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/IslandLogic.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/IslandLogic.java @@ -23,12 +23,12 @@ import us.talabrek.ultimateskyblock.handler.WorldEditHandler; import us.talabrek.ultimateskyblock.handler.WorldGuardHandler; import us.talabrek.ultimateskyblock.handler.task.WorldEditClearFlatlandTask; +import us.talabrek.ultimateskyblock.island.level.IslandScore; import us.talabrek.ultimateskyblock.player.PlayerInfo; import us.talabrek.ultimateskyblock.uSkyBlock; import us.talabrek.ultimateskyblock.util.IslandUtil; import us.talabrek.ultimateskyblock.util.LocationUtil; import us.talabrek.ultimateskyblock.util.PlayerUtil; -import dk.lockfuglsang.minecraft.util.TimeUtil; import java.io.File; import java.util.ArrayList; diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/AweLevelLogic.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/AweLevelLogic.java similarity index 88% rename from uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/AweLevelLogic.java rename to uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/AweLevelLogic.java index 04c4636bf..b7a5e2af2 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/AweLevelLogic.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/AweLevelLogic.java @@ -1,4 +1,4 @@ -package us.talabrek.ultimateskyblock.island; +package us.talabrek.ultimateskyblock.island.level; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.blocks.BaseBlock; @@ -7,22 +7,30 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion; import org.bukkit.Location; import org.bukkit.configuration.file.FileConfiguration; -import us.talabrek.ultimateskyblock.async.Callback; +import us.talabrek.ultimateskyblock.api.async.Callback; import us.talabrek.ultimateskyblock.handler.AsyncWorldEditHandler; import us.talabrek.ultimateskyblock.handler.WorldEditHandler; import us.talabrek.ultimateskyblock.handler.WorldGuardHandler; import us.talabrek.ultimateskyblock.uSkyBlock; +import java.util.HashSet; import java.util.List; +import java.util.Set; public class AweLevelLogic extends CommonLevelLogic { + private Set running = new HashSet<>(); + public AweLevelLogic(uSkyBlock plugin, FileConfiguration config) { super(plugin, config); } @Override public void calculateScoreAsync(Location l, Callback callback) { + if (running.contains(l)) { + return; + } + running.add(l); plugin.async(() -> { ProtectedRegion region = WorldGuardHandler.getIslandRegionAt(l); if (region == null) { @@ -45,6 +53,7 @@ public void calculateScoreAsync(Location l, Callback callback) { callback.setState(islandScore); plugin.sync(callback); + running.remove(l); }); } } diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/BlockScoreComparator.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/BlockScoreComparator.java similarity index 92% rename from uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/BlockScoreComparator.java rename to uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/BlockScoreComparator.java index b4c6d5bfd..6abd61d8d 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/BlockScoreComparator.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/BlockScoreComparator.java @@ -1,4 +1,4 @@ -package us.talabrek.ultimateskyblock.island; +package us.talabrek.ultimateskyblock.island.level; import us.talabrek.ultimateskyblock.api.model.BlockScore; import us.talabrek.ultimateskyblock.handler.VaultHandler; diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/BlockScoreImpl.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/BlockScoreImpl.java similarity index 96% rename from uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/BlockScoreImpl.java rename to uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/BlockScoreImpl.java index b9b33eeb7..a6a16f501 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/BlockScoreImpl.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/BlockScoreImpl.java @@ -1,4 +1,4 @@ -package us.talabrek.ultimateskyblock.island; +package us.talabrek.ultimateskyblock.island.level; import org.bukkit.inventory.ItemStack; import us.talabrek.ultimateskyblock.handler.VaultHandler; diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/ChunkSnapshotLevelLogic.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/ChunkSnapshotLevelLogic.java similarity index 98% rename from uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/ChunkSnapshotLevelLogic.java rename to uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/ChunkSnapshotLevelLogic.java index 60ed4212f..647eb435d 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/ChunkSnapshotLevelLogic.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/ChunkSnapshotLevelLogic.java @@ -1,11 +1,11 @@ -package us.talabrek.ultimateskyblock.island; +package us.talabrek.ultimateskyblock.island.level; import com.sk89q.worldguard.protection.regions.ProtectedRegion; import org.bukkit.ChunkSnapshot; import org.bukkit.Location; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.scheduler.BukkitRunnable; -import us.talabrek.ultimateskyblock.async.Callback; +import us.talabrek.ultimateskyblock.api.async.Callback; import us.talabrek.ultimateskyblock.handler.WorldGuardHandler; import us.talabrek.ultimateskyblock.island.task.ChunkSnapShotTask; import us.talabrek.ultimateskyblock.uSkyBlock; diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/CommonLevelLogic.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/CommonLevelLogic.java similarity index 99% rename from uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/CommonLevelLogic.java rename to uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/CommonLevelLogic.java index 295b3578f..a23ccec02 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/CommonLevelLogic.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/CommonLevelLogic.java @@ -1,4 +1,4 @@ -package us.talabrek.ultimateskyblock.island; +package us.talabrek.ultimateskyblock.island.level; import org.bukkit.Location; import org.bukkit.configuration.ConfigurationSection; diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/IslandScore.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/IslandScore.java similarity index 96% rename from uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/IslandScore.java rename to uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/IslandScore.java index 74ac96775..486aa5476 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/IslandScore.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/IslandScore.java @@ -1,7 +1,6 @@ -package us.talabrek.ultimateskyblock.island; +package us.talabrek.ultimateskyblock.island.level; import us.talabrek.ultimateskyblock.api.model.BlockScore; -import us.talabrek.ultimateskyblock.player.IslandPerk; import java.util.ArrayList; import java.util.Collections; diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/LevelLogic.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/LevelLogic.java similarity index 55% rename from uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/LevelLogic.java rename to uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/LevelLogic.java index 0de5e57d3..ec4265e16 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/LevelLogic.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/level/LevelLogic.java @@ -1,7 +1,7 @@ -package us.talabrek.ultimateskyblock.island; +package us.talabrek.ultimateskyblock.island.level; import org.bukkit.Location; -import us.talabrek.ultimateskyblock.async.Callback; +import us.talabrek.ultimateskyblock.api.async.Callback; public interface LevelLogic { void calculateScoreAsync(Location l, Callback callback); diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/task/ChunkSnapShotTask.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/task/ChunkSnapShotTask.java index d6de51df9..4dbbc35de 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/task/ChunkSnapShotTask.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/task/ChunkSnapShotTask.java @@ -6,7 +6,7 @@ import org.bukkit.Chunk; import org.bukkit.ChunkSnapshot; import org.bukkit.Location; -import us.talabrek.ultimateskyblock.async.Callback; +import us.talabrek.ultimateskyblock.api.async.Callback; import us.talabrek.ultimateskyblock.async.IncrementalRunnable; import us.talabrek.ultimateskyblock.handler.WorldEditHandler; import us.talabrek.ultimateskyblock.uSkyBlock; diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/task/RecalculateTopTen.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/task/RecalculateTopTen.java index c08d4e3ce..08eb208ea 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/task/RecalculateTopTen.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/island/task/RecalculateTopTen.java @@ -2,8 +2,7 @@ import org.bukkit.scheduler.BukkitRunnable; import us.talabrek.ultimateskyblock.api.event.uSkyBlockEvent; -import us.talabrek.ultimateskyblock.async.Callback; -import us.talabrek.ultimateskyblock.island.IslandScore; +import us.talabrek.ultimateskyblock.api.async.Callback; import us.talabrek.ultimateskyblock.uSkyBlock; import java.util.ArrayList; @@ -25,7 +24,7 @@ public RecalculateTopTen(uSkyBlock plugin, Set locations) { public void run() { if (!locations.isEmpty()) { String islandName = locations.remove(0); - plugin.calculateScoreAsync(null, islandName, new Callback() { + plugin.calculateScoreAsync(null, islandName, new Callback() { @Override public void run() { // We use the deprecated on purpose (the other would fail). @@ -33,7 +32,7 @@ public void run() { } }); } else { - plugin.fireChangeEvent(new uSkyBlockEvent(null, plugin.getAPI(), uSkyBlockEvent.Cause.RANK_UPDATED)); + plugin.fireAsyncEvent(new uSkyBlockEvent(null, plugin.getAPI(), uSkyBlockEvent.Cause.RANK_UPDATED)); } } } diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/player/PatienceTester.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/player/PatienceTester.java new file mode 100644 index 000000000..fb39d9856 --- /dev/null +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/player/PatienceTester.java @@ -0,0 +1,36 @@ +package us.talabrek.ultimateskyblock.player; + +import org.bukkit.entity.Player; +import org.bukkit.metadata.FixedMetadataValue; +import us.talabrek.ultimateskyblock.uSkyBlock; + +import static dk.lockfuglsang.minecraft.po.I18nUtil.tr; + +public class PatienceTester { + public static boolean isRunning(Player player, String key) { + if (player.hasMetadata(key)) { + player.sendMessage(getMessage()); + return true; + } + return false; + } + + private static String getMessage() { + String[] messages = new String[] { + tr("\u00a79Hold your horses! You have to be patient..."), + tr("\u00a79Not really patient, are you?"), + tr("\u00a79Be patient, young padawan"), + tr("\u00a79Patience you MUST have, young padawan"), + tr("\u00a79The two most powerful warriors are patience and time."), + }; + return messages[(int)Math.floor(Math.random() * messages.length)]; + } + + public static void startRunning(Player player, String key) { + player.setMetadata(key, new FixedMetadataValue(uSkyBlock.getInstance(), Boolean.TRUE)); + } + + public static void stopRunning(Player player, String key) { + player.removeMetadata(key, uSkyBlock.getInstance()); + } +} diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/uSkyBlock.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/uSkyBlock.java index c0ee4917c..49079e342 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/uSkyBlock.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/uSkyBlock.java @@ -23,6 +23,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Monster; import org.bukkit.entity.Player; +import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.generator.ChunkGenerator; import org.bukkit.inventory.ItemStack; @@ -37,8 +38,9 @@ import us.talabrek.ultimateskyblock.api.event.MemberJoinedEvent; import us.talabrek.ultimateskyblock.api.event.MemberLeftEvent; import us.talabrek.ultimateskyblock.api.event.uSkyBlockEvent; +import us.talabrek.ultimateskyblock.api.event.uSkyBlockScoreChangedEvent; import us.talabrek.ultimateskyblock.api.uSkyBlockAPI; -import us.talabrek.ultimateskyblock.async.Callback; +import us.talabrek.ultimateskyblock.api.async.Callback; import us.talabrek.ultimateskyblock.challenge.ChallengeLogic; import us.talabrek.ultimateskyblock.chat.ChatEvents; import us.talabrek.ultimateskyblock.chat.ChatLogic; @@ -69,14 +71,15 @@ import us.talabrek.ultimateskyblock.handler.WorldGuardHandler; import us.talabrek.ultimateskyblock.handler.placeholder.PlaceholderHandler; import us.talabrek.ultimateskyblock.imports.impl.USBImporterExecutor; -import us.talabrek.ultimateskyblock.island.AweLevelLogic; +import us.talabrek.ultimateskyblock.island.BlockLimitLogic; +import us.talabrek.ultimateskyblock.island.level.AweLevelLogic; import us.talabrek.ultimateskyblock.island.IslandGenerator; import us.talabrek.ultimateskyblock.island.IslandInfo; import us.talabrek.ultimateskyblock.island.IslandLocatorLogic; import us.talabrek.ultimateskyblock.island.IslandLogic; -import us.talabrek.ultimateskyblock.island.IslandScore; -import us.talabrek.ultimateskyblock.island.ChunkSnapshotLevelLogic; -import us.talabrek.ultimateskyblock.island.LevelLogic; +import us.talabrek.ultimateskyblock.island.level.IslandScore; +import us.talabrek.ultimateskyblock.island.level.ChunkSnapshotLevelLogic; +import us.talabrek.ultimateskyblock.island.level.LevelLogic; import us.talabrek.ultimateskyblock.island.LimitLogic; import us.talabrek.ultimateskyblock.island.OrphanLogic; import us.talabrek.ultimateskyblock.island.task.CreateIslandTask; @@ -159,6 +162,7 @@ public class uSkyBlock extends JavaPlugin implements uSkyBlockAPI, CommandManage public File directoryIslands; private BukkitTask autoRecalculateTask; + static { uSkyBlock.skyBlockWorld = null; } @@ -173,6 +177,7 @@ public class uSkyBlock extends JavaPlugin implements uSkyBlockAPI, CommandManage private ChatLogic chatLogic; private volatile boolean maintenanceMode = false; + private BlockLimitLogic blockLimitLogic; public uSkyBlock() { } @@ -252,7 +257,7 @@ public void run() { public synchronized boolean isRequirementsMet(CommandSender sender, Command command, String... args) { if (maintenanceMode && !( (command instanceof AdminCommand && args != null && args.length > 0 && args[0].equals("maintenance")) || - command instanceof SetMaintenanceCommand)) { + command instanceof SetMaintenanceCommand)) { sender.sendMessage(tr("\u00a7cMAINTENANCE:\u00a7e uSkyBlock is currently in maintenance mode")); return false; } @@ -269,7 +274,7 @@ public synchronized boolean isRequirementsMet(CommandSender sender, Command comm missingRequirements += tr("\u00a7buSkyBlock\u00a7e depends on \u00a79{0}\u00a7e >= \u00a7av{1}\u00a7e but only \u00a7cv{2}\u00a7e was found!\n", pluginReq[0], pluginReq[1], desc.getVersion()); } } else { - missingRequirements += tr("\u00a7buSkyBlock\u00a7e depends on \u00a79{0}\u00a7e >= \u00a7av{1}", pluginReq[0], pluginReq[1]); + missingRequirements += tr("\u00a7buSkyBlock\u00a7e depends on \u00a79{0}\u00a7e >= \u00a7av{1}", pluginReq[0], pluginReq[1]); } } } @@ -337,8 +342,7 @@ public World getWorld() { ChunkGenerator skyGenerator = getGenerator(); ChunkGenerator worldGenerator = skyBlockWorld != null ? skyBlockWorld.getGenerator() : null; if (skyBlockWorld == null || skyBlockWorld.canGenerateStructures() || - worldGenerator == null || !worldGenerator.getClass().getName().equals(skyGenerator.getClass().getName())) - { + worldGenerator == null || !worldGenerator.getClass().getName().equals(skyGenerator.getClass().getName())) { uSkyBlock.skyBlockWorld = WorldCreator .name(Settings.general_worldName) .type(WorldType.NORMAL) @@ -1019,6 +1023,7 @@ private void reloadConfigs() { islandLocatorLogic = new IslandLocatorLogic(this); islandLogic = new IslandLogic(this, directoryIslands, orphanLogic); limitLogic = new LimitLogic(this); + blockLimitLogic = new BlockLimitLogic(this); notifier = new PlayerNotifier(getConfig()); playerLogic = new PlayerLogic(this); if (autoRecalculateTask != null) { @@ -1075,6 +1080,10 @@ public OrphanLogic getOrphanLogic() { return orphanLogic; } + public BlockLimitLogic getBlockLimitLogic() { + return blockLimitLogic; + } + /** * @param player The player executing the command * @param command The command to execute @@ -1228,16 +1237,12 @@ public IslandRank getIslandRank(Location location) { public void fireChangeEvent(CommandSender sender, uSkyBlockEvent.Cause cause) { Player player = (sender instanceof Player) ? (Player) sender : null; final uSkyBlockEvent event = new uSkyBlockEvent(player, this, cause); - fireChangeEvent(event); + fireAsyncEvent(event); } - public void fireChangeEvent(final uSkyBlockEvent event) { - getServer().getScheduler().runTaskAsynchronously(this, new Runnable() { - @Override - public void run() { - getServer().getPluginManager().callEvent(event); - } - } + public void fireAsyncEvent(final Event event) { + getServer().getScheduler().runTaskAsynchronously(this, + () -> getServer().getPluginManager().callEvent(event) ); } @@ -1284,11 +1289,11 @@ public PlayerDB getPlayerDB() { private IslandScore adjustScore(IslandScore score, IslandInfo islandInfo) { IslandPerk islandPerk = perkLogic.getIslandPerk(islandInfo.getSchematicName()); double blockScore = score.getScore(); - blockScore = blockScore*islandPerk.getScoreMultiply()*islandInfo.getScoreMultiplier() + islandPerk.getScoreOffset()+islandInfo.getScoreOffset(); + blockScore = blockScore * islandPerk.getScoreMultiply() * islandInfo.getScoreMultiplier() + islandPerk.getScoreOffset() + islandInfo.getScoreOffset(); return new IslandScore(blockScore, score.getTop()); } - public void calculateScoreAsync(final Player player, String islandName, final Callback callback) { + public void calculateScoreAsync(final Player player, String islandName, final Callback callback) { final IslandInfo islandInfo = getIslandInfo(islandName); getLevelLogic().calculateScoreAsync(islandInfo.getIslandLocation(), new Callback() { @Override @@ -1297,7 +1302,7 @@ public void run() { callback.setState(score); islandInfo.setLevel(score.getScore()); getIslandLogic().updateRank(islandInfo, score); - fireChangeEvent(new uSkyBlockEvent(player, getInstance(), uSkyBlockEvent.Cause.SCORE_CHANGED)); + fireAsyncEvent(new uSkyBlockScoreChangedEvent(player, getInstance(), score, islandInfo.getIslandLocation())); callback.run(); } }); @@ -1334,6 +1339,7 @@ public boolean isMaintenanceMode() { /** * CAUTION! If anyone calls this with true, they MUST ensure it is later called with false, * or the plugin will effectively be in a locked state. + * * @param maintenanceMode whether or not to enable maintenance-mode. */ public void setMaintenanceMode(boolean maintenanceMode) { @@ -1393,10 +1399,14 @@ public void execCommands(Player player, List cmdList) { } public void fireMemberJoinedEvent(IslandInfo islandInfo, PlayerInfo playerInfo) { - async(() -> { getServer().getPluginManager().callEvent(new MemberJoinedEvent(islandInfo, playerInfo)); }); + async(() -> { + getServer().getPluginManager().callEvent(new MemberJoinedEvent(islandInfo, playerInfo)); + }); } public void fireMemberLeftEvent(IslandInfo islandInfo, PlayerInfo member) { - async(() -> { getServer().getPluginManager().callEvent(new MemberLeftEvent(islandInfo, member)); }); + async(() -> { + getServer().getPluginManager().callEvent(new MemberLeftEvent(islandInfo, member)); + }); } } diff --git a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/util/LocationUtil.java b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/util/LocationUtil.java index fbb207474..6615a2103 100644 --- a/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/util/LocationUtil.java +++ b/uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/util/LocationUtil.java @@ -12,7 +12,7 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; import us.talabrek.ultimateskyblock.Settings; -import us.talabrek.ultimateskyblock.async.Callback; +import us.talabrek.ultimateskyblock.api.async.Callback; import java.util.logging.Level; import java.util.regex.Matcher; diff --git a/uSkyBlock-Core/src/main/po/cs.po b/uSkyBlock-Core/src/main/po/cs.po index 64f65242a..987ed1a66 100644 --- a/uSkyBlock-Core/src/main/po/cs.po +++ b/uSkyBlock-Core/src/main/po/cs.po @@ -1207,6 +1207,9 @@ msgstr "" msgid "§4Island level has been disabled, contact an administrator." msgstr "§4Uroven ostrova není povolena, kontaktuj admina." +msgid "§4Hold your horses! §eYou have to be patient..." +msgstr "" + msgid "§eYou must be on your island to use this command." msgstr "§eMusis byt na svem ostrove aby si mohl pouzit tento prikaz." @@ -1226,6 +1229,10 @@ msgstr "§eBloku na {0}s ostrove (page {1,number} of {2,number}):" msgid "Score Count Block" msgstr "Skore poctu bloku" +#, java-format +msgid "{0,number,#####.##} {1,number,#} {2}" +msgstr "" + #, java-format msgid "§aIsland level is {0,number,###.##}" msgstr "§aLevel ostrova je: {0,number,###.##}" @@ -1666,7 +1673,19 @@ msgstr "§4Hrac ti zakazal teleportovat se na jeho ostrov." msgid "§4That island is §clocked.§e No teleporting to the island." msgstr "§4Tento ostrov je §clocked.§e Zadne teleportovani na ostrov nejde." -msgid "§4You've hit the hopper limit! You can't have more hoppers!" +#, java-format +msgid "" +"§4{0} is limited. §eScanning your island to see if you are allowed to place " +"more, please be patient" +msgstr "" + +msgid "§e... Scanning complete, you can try again" +msgstr "" + +#, java-format +msgid "" +"§4You''ve hit the {0} limit!§e You can''t have more of that type on your " +"island!§9 Max: {1,number}" msgstr "" msgid "§cYou have reached your spawn-limit for your island." @@ -2684,6 +2703,18 @@ msgstr "§9Textovy editor" msgid "Too many requests for Mojangs API ({0} within {1}), sleeping {2}" msgstr "Prilis mnoho pozadavku pro Mojang API ({0} within {1}), sleeping {2}" +msgid "§9Not really patient, are you?" +msgstr "" + +msgid "§9Be patient, young padawan" +msgstr "" + +msgid "§9Patience you MUST have, young padawan" +msgstr "" + +msgid "§9The two most powerful warriors are patience and time." +msgstr "" + msgid "§eSending you to spawn." msgstr "§ePosilam te na spawn." diff --git a/uSkyBlock-Core/src/main/po/da.po b/uSkyBlock-Core/src/main/po/da.po index bed5142fd..e424e97c5 100644 --- a/uSkyBlock-Core/src/main/po/da.po +++ b/uSkyBlock-Core/src/main/po/da.po @@ -1210,6 +1210,9 @@ msgstr "tillader brugere at se andre øers informationer" msgid "§4Island level has been disabled, contact an administrator." msgstr "§4Ø levels er blevet deaktiveret, kontakt en administrator." +msgid "§4Hold your horses! §eYou have to be patient..." +msgstr "" + msgid "§eYou must be on your island to use this command." msgstr "§eDu skal være på en ø, for at bruge denne kommando." @@ -1229,6 +1232,10 @@ msgstr "§eBlokke på {0}s ø (side {1,number} af {2,number}):" msgid "Score Count Block" msgstr "Score Antal Blok" +#, java-format +msgid "{0,number,#####.##} {1,number,#} {2}" +msgstr "" + #, java-format msgid "§aIsland level is {0,number,###.##}" msgstr "§eØen niveau er {0,number,###.##}" @@ -1666,7 +1673,19 @@ msgstr "§Den spiller har udelukket dig fra sin ø." msgid "§4That island is §clocked.§e No teleporting to the island." msgstr "§Den ø er låst.§e Ikke muligt at teleportere til den." -msgid "§4You've hit the hopper limit! You can't have more hoppers!" +#, java-format +msgid "" +"§4{0} is limited. §eScanning your island to see if you are allowed to place " +"more, please be patient" +msgstr "" + +msgid "§e... Scanning complete, you can try again" +msgstr "" + +#, java-format +msgid "" +"§4You''ve hit the {0} limit!§e You can''t have more of that type on your " +"island!§9 Max: {1,number}" msgstr "" msgid "§cYou have reached your spawn-limit for your island." @@ -2695,6 +2714,18 @@ msgstr "§9Tekst Editor" msgid "Too many requests for Mojangs API ({0} within {1}), sleeping {2}" msgstr "For mange forespørgsler til Mojang ({0} inden for {1}), venter {2}" +msgid "§9Not really patient, are you?" +msgstr "" + +msgid "§9Be patient, young padawan" +msgstr "" + +msgid "§9Patience you MUST have, young padawan" +msgstr "" + +msgid "§9The two most powerful warriors are patience and time." +msgstr "" + msgid "§eSending you to spawn." msgstr "§aTeleporterer dig til spawn." diff --git a/uSkyBlock-Core/src/main/po/de.po b/uSkyBlock-Core/src/main/po/de.po index 97befee11..55ab9c97e 100644 --- a/uSkyBlock-Core/src/main/po/de.po +++ b/uSkyBlock-Core/src/main/po/de.po @@ -1236,6 +1236,9 @@ msgstr "erlaubt den Spieler Infos von anderen Insel anzugucken" msgid "§4Island level has been disabled, contact an administrator." msgstr "§4Insel Level wurde deaktiviert, kontaktiere einen Administrator." +msgid "§4Hold your horses! §eYou have to be patient..." +msgstr "" + msgid "§eYou must be on your island to use this command." msgstr "§eDu musst auf deiner Insel sein um den Befehl nutzen zu können." @@ -1255,6 +1258,10 @@ msgstr "§eBlöcke von {0}s Insel (Seite {1,number} von {2,number}):" msgid "Score Count Block" msgstr "Werte der Blöcke und deren Anzahl" +#, java-format +msgid "{0,number,#####.##} {1,number,#} {2}" +msgstr "" + #, java-format msgid "§aIsland level is {0,number,###.##}" msgstr "§aDein Insel Level: {0,number,###.##}" @@ -1704,7 +1711,19 @@ msgstr "" msgid "§4That island is §clocked.§e No teleporting to the island." msgstr "§4Diese Insel ist gesperrt. Kein Teleport zu dieser Insel" -msgid "§4You've hit the hopper limit! You can't have more hoppers!" +#, java-format +msgid "" +"§4{0} is limited. §eScanning your island to see if you are allowed to place " +"more, please be patient" +msgstr "" + +msgid "§e... Scanning complete, you can try again" +msgstr "" + +#, java-format +msgid "" +"§4You''ve hit the {0} limit!§e You can''t have more of that type on your " +"island!§9 Max: {1,number}" msgstr "" msgid "§cYou have reached your spawn-limit for your island." @@ -2722,6 +2741,18 @@ msgstr "§9Text Editor" msgid "Too many requests for Mojangs API ({0} within {1}), sleeping {2}" msgstr "Zu viele Anfragen an die Mojang API ({0} innerhalb von {1}), warte {2}" +msgid "§9Not really patient, are you?" +msgstr "" + +msgid "§9Be patient, young padawan" +msgstr "" + +msgid "§9Patience you MUST have, young padawan" +msgstr "" + +msgid "§9The two most powerful warriors are patience and time." +msgstr "" + msgid "§eSending you to spawn." msgstr "§eDu wirst zum Spawn gesendet" diff --git a/uSkyBlock-Core/src/main/po/en_GB.po b/uSkyBlock-Core/src/main/po/en_GB.po index f4e9f2158..421d04267 100644 --- a/uSkyBlock-Core/src/main/po/en_GB.po +++ b/uSkyBlock-Core/src/main/po/en_GB.po @@ -1217,6 +1217,9 @@ msgstr "§9* §7allows user to see others island info" msgid "§4Island level has been disabled, contact an administrator." msgstr "§4* §7Island level has been disabled, contact an administrator." +msgid "§4Hold your horses! §eYou have to be patient..." +msgstr "" + msgid "§eYou must be on your island to use this command." msgstr "§4* §7You must be on your island to use this command." @@ -1236,6 +1239,10 @@ msgstr "§eBlocks on {0}s Island (page {1,number} of {2,number}):" msgid "Score Count Block" msgstr "Score Count Block" +#, java-format +msgid "{0,number,#####.##} {1,number,#} {2}" +msgstr "" + #, java-format msgid "§aIsland level is {0,number,###.##}" msgstr "§9- §7Island level is §a{0,number,###.##}" @@ -1681,7 +1688,19 @@ msgstr "" msgid "§4That island is §clocked.§e No teleporting to the island." msgstr "§4* §7That island is §4locked.§7 No teleporting to the island." -msgid "§4You've hit the hopper limit! You can't have more hoppers!" +#, java-format +msgid "" +"§4{0} is limited. §eScanning your island to see if you are allowed to place " +"more, please be patient" +msgstr "" + +msgid "§e... Scanning complete, you can try again" +msgstr "" + +#, java-format +msgid "" +"§4You''ve hit the {0} limit!§e You can''t have more of that type on your " +"island!§9 Max: {1,number}" msgstr "" msgid "§cYou have reached your spawn-limit for your island." @@ -2727,6 +2746,18 @@ msgstr "§9Text Editor" msgid "Too many requests for Mojangs API ({0} within {1}), sleeping {2}" msgstr "§4* §7Too many requests for Mojangs API ({0} within {1}), sleeping {2}" +msgid "§9Not really patient, are you?" +msgstr "" + +msgid "§9Be patient, young padawan" +msgstr "" + +msgid "§9Patience you MUST have, young padawan" +msgstr "" + +msgid "§9The two most powerful warriors are patience and time." +msgstr "" + msgid "§eSending you to spawn." msgstr "§9* §7Sending you to spawn." diff --git a/uSkyBlock-Core/src/main/po/es.po b/uSkyBlock-Core/src/main/po/es.po index 75fb9095d..5c62f1cae 100644 --- a/uSkyBlock-Core/src/main/po/es.po +++ b/uSkyBlock-Core/src/main/po/es.po @@ -1207,6 +1207,9 @@ msgstr "" msgid "§4Island level has been disabled, contact an administrator." msgstr "§4El nivel de isla ha sido deshabilitado, contacta un administrador." +msgid "§4Hold your horses! §eYou have to be patient..." +msgstr "" + msgid "§eYou must be on your island to use this command." msgstr "§eTienes que estar en tu isla para usar este comando." @@ -1226,6 +1229,10 @@ msgstr "§eBloques en la isla de {0} (página {1,number} de {2,number}):" msgid "Score Count Block" msgstr "Recuento de Puntuación de Bloques" +#, java-format +msgid "{0,number,#####.##} {1,number,#} {2}" +msgstr "" + #, java-format msgid "§aIsland level is {0,number,###.##}" msgstr "§aEl nivel de tu isla es {0,number,###.##}" @@ -1676,7 +1683,19 @@ msgstr "§4Ese jugador te prohibió teletransportarte a su isla." msgid "§4That island is §clocked.§e No teleporting to the island." msgstr "§4Esa isla está §cbloqueada§4.§e No hay teletransportes a la isla." -msgid "§4You've hit the hopper limit! You can't have more hoppers!" +#, java-format +msgid "" +"§4{0} is limited. §eScanning your island to see if you are allowed to place " +"more, please be patient" +msgstr "" + +msgid "§e... Scanning complete, you can try again" +msgstr "" + +#, java-format +msgid "" +"§4You''ve hit the {0} limit!§e You can''t have more of that type on your " +"island!§9 Max: {1,number}" msgstr "" msgid "§cYou have reached your spawn-limit for your island." @@ -2695,6 +2714,18 @@ msgstr "§9Editor de Texto" msgid "Too many requests for Mojangs API ({0} within {1}), sleeping {2}" msgstr "" +msgid "§9Not really patient, are you?" +msgstr "" + +msgid "§9Be patient, young padawan" +msgstr "" + +msgid "§9Patience you MUST have, young padawan" +msgstr "" + +msgid "§9The two most powerful warriors are patience and time." +msgstr "" + msgid "§eSending you to spawn." msgstr "§eEnviándote al spawn." diff --git a/uSkyBlock-Core/src/main/po/fr.po b/uSkyBlock-Core/src/main/po/fr.po index 4a929a02e..731cd6fc3 100644 --- a/uSkyBlock-Core/src/main/po/fr.po +++ b/uSkyBlock-Core/src/main/po/fr.po @@ -1218,6 +1218,9 @@ msgstr "" msgid "§4Island level has been disabled, contact an administrator." msgstr "§4Le niveaus des îles ont été désactivé, contacté un administrateur." +msgid "§4Hold your horses! §eYou have to be patient..." +msgstr "" + msgid "§eYou must be on your island to use this command." msgstr "§eVous devez être sur votre île pour utiliser cette commande." @@ -1237,6 +1240,10 @@ msgstr "§eBlocks sur l''île de {0} (page {1,number} of {2,number}):" msgid "Score Count Block" msgstr "Nombre de blocks" +#, java-format +msgid "{0,number,#####.##} {1,number,#} {2}" +msgstr "" + #, java-format msgid "§aIsland level is {0,number,###.##}" msgstr "§aLe niveau de votre île est {0,number,###.##}" @@ -1683,7 +1690,19 @@ msgstr "§4Ce joueur vous a interdit de se téléporter à son île." msgid "§4That island is §clocked.§e No teleporting to the island." msgstr "§4Cette île est §cvérrouillé.§e Impossible de s'y téléporter." -msgid "§4You've hit the hopper limit! You can't have more hoppers!" +#, java-format +msgid "" +"§4{0} is limited. §eScanning your island to see if you are allowed to place " +"more, please be patient" +msgstr "" + +msgid "§e... Scanning complete, you can try again" +msgstr "" + +#, java-format +msgid "" +"§4You''ve hit the {0} limit!§e You can''t have more of that type on your " +"island!§9 Max: {1,number}" msgstr "" msgid "§cYou have reached your spawn-limit for your island." @@ -2689,6 +2708,18 @@ msgstr "§9Editeur de texte" msgid "Too many requests for Mojangs API ({0} within {1}), sleeping {2}" msgstr "Trop de requêtes pour Mojang API ({0} within {1}), sleeping {2}" +msgid "§9Not really patient, are you?" +msgstr "" + +msgid "§9Be patient, young padawan" +msgstr "" + +msgid "§9Patience you MUST have, young padawan" +msgstr "" + +msgid "§9The two most powerful warriors are patience and time." +msgstr "" + msgid "§eSending you to spawn." msgstr "§aTéléportation au spawn" diff --git a/uSkyBlock-Core/src/main/po/it.po b/uSkyBlock-Core/src/main/po/it.po index 7188c24e7..05af450bb 100644 --- a/uSkyBlock-Core/src/main/po/it.po +++ b/uSkyBlock-Core/src/main/po/it.po @@ -1230,6 +1230,9 @@ msgid "§4Island level has been disabled, contact an administrator." msgstr "" "§4* §7Il livello delle isole è disabilito, contatta una amministratore." +msgid "§4Hold your horses! §eYou have to be patient..." +msgstr "" + msgid "§eYou must be on your island to use this command." msgstr "§4* §7Devi essere sulla tua isola per usare questo comando." @@ -1249,6 +1252,10 @@ msgstr "§eBlocchi nell''isola di {0} (pagina {1,number} di {2,number}):" msgid "Score Count Block" msgstr "Blocco Conto Punteggi" +#, java-format +msgid "{0,number,#####.##} {1,number,#} {2}" +msgstr "" + #, java-format msgid "§aIsland level is {0,number,###.##}" msgstr "§9* §7Il livello dell''isola è §a{0,number,###.##}" @@ -1702,7 +1709,19 @@ msgstr "" msgid "§4That island is §clocked.§e No teleporting to the island." msgstr "§4* §7Quell''isola è §4bloccata.§7 Nessun teletrasporto all''isola." -msgid "§4You've hit the hopper limit! You can't have more hoppers!" +#, java-format +msgid "" +"§4{0} is limited. §eScanning your island to see if you are allowed to place " +"more, please be patient" +msgstr "" + +msgid "§e... Scanning complete, you can try again" +msgstr "" + +#, java-format +msgid "" +"§4You''ve hit the {0} limit!§e You can''t have more of that type on your " +"island!§9 Max: {1,number}" msgstr "" msgid "§cYou have reached your spawn-limit for your island." @@ -2753,6 +2772,18 @@ msgstr "§9Editor Testuale" msgid "Too many requests for Mojangs API ({0} within {1}), sleeping {2}" msgstr "§4* §7Troppe richieste alle API Mojang ({0} entro {1}), dormendo {2}" +msgid "§9Not really patient, are you?" +msgstr "" + +msgid "§9Be patient, young padawan" +msgstr "" + +msgid "§9Patience you MUST have, young padawan" +msgstr "" + +msgid "§9The two most powerful warriors are patience and time." +msgstr "" + msgid "§eSending you to spawn." msgstr "§9* §7Inviandoti allo spawn." diff --git a/uSkyBlock-Core/src/main/po/keys.pot b/uSkyBlock-Core/src/main/po/keys.pot index 4bd166913..d196da654 100644 --- a/uSkyBlock-Core/src/main/po/keys.pot +++ b/uSkyBlock-Core/src/main/po/keys.pot @@ -1177,6 +1177,9 @@ msgstr "" msgid "§4Island level has been disabled, contact an administrator." msgstr "" +msgid "§4Hold your horses! §eYou have to be patient..." +msgstr "" + msgid "§eYou must be on your island to use this command." msgstr "" @@ -1196,6 +1199,10 @@ msgstr "" msgid "Score Count Block" msgstr "" +#, java-format +msgid "{0,number,#####.##} {1,number,#} {2}" +msgstr "" + #, java-format msgid "§aIsland level is {0,number,###.##}" msgstr "" @@ -1615,7 +1622,19 @@ msgstr "" msgid "§4That island is §clocked.§e No teleporting to the island." msgstr "" -msgid "§4You've hit the hopper limit! You can't have more hoppers!" +#, java-format +msgid "" +"§4{0} is limited. §eScanning your island to see if you are allowed to place " +"more, please be patient" +msgstr "" + +msgid "§e... Scanning complete, you can try again" +msgstr "" + +#, java-format +msgid "" +"§4You''ve hit the {0} limit!§e You can''t have more of that type on your " +"island!§9 Max: {1,number}" msgstr "" msgid "§cYou have reached your spawn-limit for your island." @@ -2476,6 +2495,18 @@ msgstr "" msgid "Too many requests for Mojangs API ({0} within {1}), sleeping {2}" msgstr "" +msgid "§9Not really patient, are you?" +msgstr "" + +msgid "§9Be patient, young padawan" +msgstr "" + +msgid "§9Patience you MUST have, young padawan" +msgstr "" + +msgid "§9The two most powerful warriors are patience and time." +msgstr "" + msgid "§eSending you to spawn." msgstr "" diff --git a/uSkyBlock-Core/src/main/po/ko.po b/uSkyBlock-Core/src/main/po/ko.po index 5f1ead1d3..b8b38c8c6 100644 --- a/uSkyBlock-Core/src/main/po/ko.po +++ b/uSkyBlock-Core/src/main/po/ko.po @@ -1210,6 +1210,9 @@ msgstr "해당 유저가 다른 섬 정보를 보는것을 허용합니다." msgid "§4Island level has been disabled, contact an administrator." msgstr "§4섬 레벨이 작동하지 않습니다, 관리자에게 문의하세요." +msgid "§4Hold your horses! §eYou have to be patient..." +msgstr "" + msgid "§eYou must be on your island to use this command." msgstr "§e이 커맨드를 쓰려면 자신의 섬에 있어야 합니다." @@ -1229,6 +1232,10 @@ msgstr "§e{0}의 섬의 블록들(page {1,number} of {2,number}):" msgid "Score Count Block" msgstr "점수 카운트 블록" +#, java-format +msgid "{0,number,#####.##} {1,number,#} {2}" +msgstr "" + #, java-format msgid "§aIsland level is {0,number,###.##}" msgstr "§a섬의 레벨은 {0,number,###.##}입니다" @@ -1670,7 +1677,19 @@ msgstr "§4그 플레이어가 그들의 섬으로 당신이 텔레포트하는 msgid "§4That island is §clocked.§e No teleporting to the island." msgstr "§4그 섬은 §c잠겼습니다.§e 그 섬으로 텔레포트 할 수 없습니다." -msgid "§4You've hit the hopper limit! You can't have more hoppers!" +#, java-format +msgid "" +"§4{0} is limited. §eScanning your island to see if you are allowed to place " +"more, please be patient" +msgstr "" + +msgid "§e... Scanning complete, you can try again" +msgstr "" + +#, java-format +msgid "" +"§4You''ve hit the {0} limit!§e You can''t have more of that type on your " +"island!§9 Max: {1,number}" msgstr "" msgid "§cYou have reached your spawn-limit for your island." @@ -2700,6 +2719,18 @@ msgstr "§9텍스트 에디터" msgid "Too many requests for Mojangs API ({0} within {1}), sleeping {2}" msgstr "너무 많은 Mojangs API 호출 입니다 ({0} within {1}), sleeping {2}" +msgid "§9Not really patient, are you?" +msgstr "" + +msgid "§9Be patient, young padawan" +msgstr "" + +msgid "§9Patience you MUST have, young padawan" +msgstr "" + +msgid "§9The two most powerful warriors are patience and time." +msgstr "" + msgid "§eSending you to spawn." msgstr "§e스폰으로 이동 중 입니다." diff --git a/uSkyBlock-Core/src/main/po/nl.po b/uSkyBlock-Core/src/main/po/nl.po index f0c6dce7d..dcf3bada9 100644 --- a/uSkyBlock-Core/src/main/po/nl.po +++ b/uSkyBlock-Core/src/main/po/nl.po @@ -1226,6 +1226,9 @@ msgstr "Laat de gebruiker anderen eiland info zien" msgid "§4Island level has been disabled, contact an administrator." msgstr "§4Eiland niveau is uitgeschakeld, neem contact op met een beheerder." +msgid "§4Hold your horses! §eYou have to be patient..." +msgstr "" + msgid "§eYou must be on your island to use this command." msgstr "§eJe moet op je eiland zijn om dit commando te kunnen uitvoeren" @@ -1245,6 +1248,10 @@ msgstr "§eBlokken op {0}s Eiland (pagina {1,number} of {2,number}):" msgid "Score Count Block" msgstr "Score van het aantal blokken" +#, java-format +msgid "{0,number,#####.##} {1,number,#} {2}" +msgstr "" + #, java-format msgid "§aIsland level is {0,number,###.##}" msgstr "§aEiland niveau is {0,number,###.##}" @@ -1690,7 +1697,19 @@ msgstr "§4Die speler heeft je verboden om naar zijn eiland te warpen." msgid "§4That island is §clocked.§e No teleporting to the island." msgstr "§4Dat eiland is §cgesloten.§e Er is geen teleport mogelijk." -msgid "§4You've hit the hopper limit! You can't have more hoppers!" +#, java-format +msgid "" +"§4{0} is limited. §eScanning your island to see if you are allowed to place " +"more, please be patient" +msgstr "" + +msgid "§e... Scanning complete, you can try again" +msgstr "" + +#, java-format +msgid "" +"§4You''ve hit the {0} limit!§e You can''t have more of that type on your " +"island!§9 Max: {1,number}" msgstr "" msgid "§cYou have reached your spawn-limit for your island." @@ -2742,6 +2761,18 @@ msgstr "§9Text Editor" msgid "Too many requests for Mojangs API ({0} within {1}), sleeping {2}" msgstr "Te veel verzoeken naar Mojangs API ({0} binnen {1}), pause {2}" +msgid "§9Not really patient, are you?" +msgstr "" + +msgid "§9Be patient, young padawan" +msgstr "" + +msgid "§9Patience you MUST have, young padawan" +msgstr "" + +msgid "§9The two most powerful warriors are patience and time." +msgstr "" + msgid "§eSending you to spawn." msgstr "§eJe wordt naar spawn gestuurd." diff --git a/uSkyBlock-Core/src/main/po/pt_BR.po b/uSkyBlock-Core/src/main/po/pt_BR.po index b5024424e..a9a54684a 100644 --- a/uSkyBlock-Core/src/main/po/pt_BR.po +++ b/uSkyBlock-Core/src/main/po/pt_BR.po @@ -1202,6 +1202,9 @@ msgid "§4Island level has been disabled, contact an administrator." msgstr "" "§4Nível de ilha está desativado, entre em contato com um administrador." +msgid "§4Hold your horses! §eYou have to be patient..." +msgstr "" + msgid "§eYou must be on your island to use this command." msgstr "§eVocê precisa estar na sua ilha para usar esse comando." @@ -1221,6 +1224,10 @@ msgstr "§eBlocos na ilha de {0} (pagina {1,number} de {2,number}):" msgid "Score Count Block" msgstr "Pontos por bloco" +#, java-format +msgid "{0,number,#####.##} {1,number,#} {2}" +msgstr "" + #, java-format msgid "§aIsland level is {0,number,###.##}" msgstr "§aNível: {0,number,###.##}" @@ -1663,7 +1670,19 @@ msgstr "§4Esse jogador proibiu você de teletransportar até a ilha dele." msgid "§4That island is §clocked.§e No teleporting to the island." msgstr "§4Essa ilha está §ctrancada.§e Sem teletransportes para essa ilha." -msgid "§4You've hit the hopper limit! You can't have more hoppers!" +#, java-format +msgid "" +"§4{0} is limited. §eScanning your island to see if you are allowed to place " +"more, please be patient" +msgstr "" + +msgid "§e... Scanning complete, you can try again" +msgstr "" + +#, java-format +msgid "" +"§4You''ve hit the {0} limit!§e You can''t have more of that type on your " +"island!§9 Max: {1,number}" msgstr "" msgid "§cYou have reached your spawn-limit for your island." @@ -2675,6 +2694,18 @@ msgstr "§9Editor de texto" msgid "Too many requests for Mojangs API ({0} within {1}), sleeping {2}" msgstr "" +msgid "§9Not really patient, are you?" +msgstr "" + +msgid "§9Be patient, young padawan" +msgstr "" + +msgid "§9Patience you MUST have, young padawan" +msgstr "" + +msgid "§9The two most powerful warriors are patience and time." +msgstr "" + msgid "§eSending you to spawn." msgstr "§eEnviando você para o spawn." diff --git a/uSkyBlock-Core/src/main/po/ru.po b/uSkyBlock-Core/src/main/po/ru.po index f898c41ca..fdd429297 100644 --- a/uSkyBlock-Core/src/main/po/ru.po +++ b/uSkyBlock-Core/src/main/po/ru.po @@ -1211,6 +1211,9 @@ msgstr "" msgid "§4Island level has been disabled, contact an administrator." msgstr "§4Уровень острова отключен, свяжитесь с администратором." +msgid "§4Hold your horses! §eYou have to be patient..." +msgstr "" + msgid "§eYou must be on your island to use this command." msgstr "§eДля выполнения этой команды нужно быть на своем острове." @@ -1230,6 +1233,10 @@ msgstr "§eБлоки на острове игрока {0} (страница {1, msgid "Score Count Block" msgstr "Score Count Block" +#, java-format +msgid "{0,number,#####.##} {1,number,#} {2}" +msgstr "" + #, java-format msgid "§aIsland level is {0,number,###.##}" msgstr "§aУровень острова {0,number,###.##}" @@ -1671,7 +1678,19 @@ msgstr "§4Этот игрок запретил вам телепортиров msgid "§4That island is §clocked.§e No teleporting to the island." msgstr "§4Этот остров §clocked.§e Нет телепортации на остров." -msgid "§4You've hit the hopper limit! You can't have more hoppers!" +#, java-format +msgid "" +"§4{0} is limited. §eScanning your island to see if you are allowed to place " +"more, please be patient" +msgstr "" + +msgid "§e... Scanning complete, you can try again" +msgstr "" + +#, java-format +msgid "" +"§4You''ve hit the {0} limit!§e You can''t have more of that type on your " +"island!§9 Max: {1,number}" msgstr "" msgid "§cYou have reached your spawn-limit for your island." @@ -2676,6 +2695,18 @@ msgstr "§9Текстовый редактор" msgid "Too many requests for Mojangs API ({0} within {1}), sleeping {2}" msgstr "" +msgid "§9Not really patient, are you?" +msgstr "" + +msgid "§9Be patient, young padawan" +msgstr "" + +msgid "§9Patience you MUST have, young padawan" +msgstr "" + +msgid "§9The two most powerful warriors are patience and time." +msgstr "" + msgid "§eSending you to spawn." msgstr "§eОтправка вам на нерест." diff --git a/uSkyBlock-Core/src/main/po/sv.po b/uSkyBlock-Core/src/main/po/sv.po index 8b828b0ce..acd8ce4a0 100644 --- a/uSkyBlock-Core/src/main/po/sv.po +++ b/uSkyBlock-Core/src/main/po/sv.po @@ -1214,6 +1214,9 @@ msgstr "tillåter spelaren att se andra öars info" msgid "§4Island level has been disabled, contact an administrator." msgstr "§cSkyblock level är inaktiverat. Vänligen kontakta en administratör." +msgid "§4Hold your horses! §eYou have to be patient..." +msgstr "" + msgid "§eYou must be on your island to use this command." msgstr "§eDu måste vara på din ö för att använda detta kommando." @@ -1233,6 +1236,10 @@ msgstr "§eBlock på {0}s ö (sida {1,number} av {2,number}):" msgid "Score Count Block" msgstr "Poäng Antal Blocktyp" +#, java-format +msgid "{0,number,#####.##} {1,number,#} {2}" +msgstr "" + #, java-format msgid "§aIsland level is {0,number,###.##}" msgstr "§aSkyblock level är {0,number,###.##}" @@ -1664,7 +1671,19 @@ msgstr "§cDen spelaren har förbjudit dig från att warpa till sin ö." msgid "§4That island is §clocked.§e No teleporting to the island." msgstr "§cDen ön är §clåst§e. Du får inte teleportera till ön." -msgid "§4You've hit the hopper limit! You can't have more hoppers!" +#, java-format +msgid "" +"§4{0} is limited. §eScanning your island to see if you are allowed to place " +"more, please be patient" +msgstr "" + +msgid "§e... Scanning complete, you can try again" +msgstr "" + +#, java-format +msgid "" +"§4You''ve hit the {0} limit!§e You can''t have more of that type on your " +"island!§9 Max: {1,number}" msgstr "" msgid "§cYou have reached your spawn-limit for your island." @@ -2678,6 +2697,18 @@ msgstr "§9Textredigerare" msgid "Too many requests for Mojangs API ({0} within {1}), sleeping {2}" msgstr "För många förfrågningar till Mojangs API ({0} inom {1}), väntar {2}" +msgid "§9Not really patient, are you?" +msgstr "" + +msgid "§9Be patient, young padawan" +msgstr "" + +msgid "§9Patience you MUST have, young padawan" +msgstr "" + +msgid "§9The two most powerful warriors are patience and time." +msgstr "" + msgid "§eSending you to spawn." msgstr "§eSkickar dig till spawn." diff --git a/uSkyBlock-Core/src/main/po/vi_VN.po b/uSkyBlock-Core/src/main/po/vi_VN.po index d5535ef7d..37071cedd 100644 --- a/uSkyBlock-Core/src/main/po/vi_VN.po +++ b/uSkyBlock-Core/src/main/po/vi_VN.po @@ -1196,6 +1196,9 @@ msgstr "" msgid "§4Island level has been disabled, contact an administrator." msgstr "§4Cấp đảo bị vô hiệu hoá, liên lạc với quản trị viên." +msgid "§4Hold your horses! §eYou have to be patient..." +msgstr "" + msgid "§eYou must be on your island to use this command." msgstr "§eBạn phải có đảo để dùng lệnh" @@ -1215,6 +1218,10 @@ msgstr "§eKhối trên đảo của {0} (trang {1,number} của {2,number}):" msgid "Score Count Block" msgstr "Điểm theo khối" +#, java-format +msgid "{0,number,#####.##} {1,number,#} {2}" +msgstr "" + #, java-format msgid "§aIsland level is {0,number,###.##}" msgstr "§aCấp đảo là {0,number,###.##}" @@ -1644,7 +1651,19 @@ msgstr "" msgid "§4That island is §clocked.§e No teleporting to the island." msgstr "§Đảo đã §ckhoá. §eKhông thể dịch chuyển vào." -msgid "§4You've hit the hopper limit! You can't have more hoppers!" +#, java-format +msgid "" +"§4{0} is limited. §eScanning your island to see if you are allowed to place " +"more, please be patient" +msgstr "" + +msgid "§e... Scanning complete, you can try again" +msgstr "" + +#, java-format +msgid "" +"§4You''ve hit the {0} limit!§e You can''t have more of that type on your " +"island!§9 Max: {1,number}" msgstr "" msgid "§cYou have reached your spawn-limit for your island." @@ -2609,6 +2628,18 @@ msgstr "§9Trình soạn thảo" msgid "Too many requests for Mojangs API ({0} within {1}), sleeping {2}" msgstr "" +msgid "§9Not really patient, are you?" +msgstr "" + +msgid "§9Be patient, young padawan" +msgstr "" + +msgid "§9Patience you MUST have, young padawan" +msgstr "" + +msgid "§9The two most powerful warriors are patience and time." +msgstr "" + msgid "§eSending you to spawn." msgstr "§eHồi chuyển về khu vực chug" diff --git a/uSkyBlock-Core/src/main/po/xx_PIRATE.po b/uSkyBlock-Core/src/main/po/xx_PIRATE.po index 8a5be8b07..68deb6c04 100644 --- a/uSkyBlock-Core/src/main/po/xx_PIRATE.po +++ b/uSkyBlock-Core/src/main/po/xx_PIRATE.po @@ -1207,6 +1207,9 @@ msgstr "allows user to see others hideout info" msgid "§4Island level has been disabled, contact an administrator." msgstr "§4Island level has been disabled, contact an administrator." +msgid "§4Hold your horses! §eYou have to be patient..." +msgstr "" + msgid "§eYou must be on your island to use this command." msgstr "§eYe must be in yer hideout to use this command." @@ -1226,6 +1229,10 @@ msgstr "§eBlocks on {0}s Island (page {1,number} of {2,number}):" msgid "Score Count Block" msgstr "Score Count Block" +#, java-format +msgid "{0,number,#####.##} {1,number,#} {2}" +msgstr "" + #, java-format msgid "§aIsland level is {0,number,###.##}" msgstr "§aIsland level be {0,number,###.##}" @@ -1660,7 +1667,19 @@ msgstr "§4That pirate has forbidden ye from teleportin' to their hideout." msgid "§4That island is §clocked.§e No teleporting to the island." msgstr "§4That hideout be §clocked.§e Nay teleportin' to the hideout." -msgid "§4You've hit the hopper limit! You can't have more hoppers!" +#, java-format +msgid "" +"§4{0} is limited. §eScanning your island to see if you are allowed to place " +"more, please be patient" +msgstr "" + +msgid "§e... Scanning complete, you can try again" +msgstr "" + +#, java-format +msgid "" +"§4You''ve hit the {0} limit!§e You can''t have more of that type on your " +"island!§9 Max: {1,number}" msgstr "" msgid "§cYou have reached your spawn-limit for your island." @@ -2703,6 +2722,18 @@ msgstr "§9Text Editor" msgid "Too many requests for Mojangs API ({0} within {1}), sleeping {2}" msgstr "Too many requests for Mojangs API ({0} within {1}), sleepin'' {2}" +msgid "§9Not really patient, are you?" +msgstr "" + +msgid "§9Be patient, young padawan" +msgstr "" + +msgid "§9Patience you MUST have, young padawan" +msgstr "" + +msgid "§9The two most powerful warriors are patience and time." +msgstr "" + msgid "§eSending you to spawn." msgstr "§eSendin' ye to spawn." diff --git a/uSkyBlock-Core/src/main/po/xx_lol_US.po b/uSkyBlock-Core/src/main/po/xx_lol_US.po index 4812fe11c..50c763fc3 100644 --- a/uSkyBlock-Core/src/main/po/xx_lol_US.po +++ b/uSkyBlock-Core/src/main/po/xx_lol_US.po @@ -1208,6 +1208,9 @@ msgstr "allows user to see others cathouz info" msgid "§4Island level has been disabled, contact an administrator." msgstr "§4Island level haz been disabled, contact an administrator." +msgid "§4Hold your horses! §eYou have to be patient..." +msgstr "" + msgid "§eYou must be on your island to use this command." msgstr "§eYou must be on yoor cathouz to use this command." @@ -1227,6 +1230,10 @@ msgstr "§eBloks on {0}s Island (page {1,number} of {2,number}):" msgid "Score Count Block" msgstr "Score Count Blok" +#, java-format +msgid "{0,number,#####.##} {1,number,#} {2}" +msgstr "" + #, java-format msgid "§aIsland level is {0,number,###.##}" msgstr "§aIsland level iz {0,number,###.##}" @@ -1664,7 +1671,19 @@ msgstr "§4That kitteh haz forbidden you from teleporting to their cathouz." msgid "§4That island is §clocked.§e No teleporting to the island." msgstr "§4That cathouz iz §clocked.§e Noe teleporting to teh cathouz." -msgid "§4You've hit the hopper limit! You can't have more hoppers!" +#, java-format +msgid "" +"§4{0} is limited. §eScanning your island to see if you are allowed to place " +"more, please be patient" +msgstr "" + +msgid "§e... Scanning complete, you can try again" +msgstr "" + +#, java-format +msgid "" +"§4You''ve hit the {0} limit!§e You can''t have more of that type on your " +"island!§9 Max: {1,number}" msgstr "" msgid "§cYou have reached your spawn-limit for your island." @@ -2708,6 +2727,18 @@ msgstr "§9Text Editor" msgid "Too many requests for Mojangs API ({0} within {1}), sleeping {2}" msgstr "Too many requests for Mojangs API ({0} wiffin {1}), sleeping {2}" +msgid "§9Not really patient, are you?" +msgstr "" + +msgid "§9Be patient, young padawan" +msgstr "" + +msgid "§9Patience you MUST have, young padawan" +msgstr "" + +msgid "§9The two most powerful warriors are patience and time." +msgstr "" + msgid "§eSending you to spawn." msgstr "§eSending you to spawn." diff --git a/uSkyBlock-Core/src/main/po/zh_CN.po b/uSkyBlock-Core/src/main/po/zh_CN.po index 6dbabee14..d3360c214 100644 --- a/uSkyBlock-Core/src/main/po/zh_CN.po +++ b/uSkyBlock-Core/src/main/po/zh_CN.po @@ -1186,6 +1186,9 @@ msgstr "" msgid "§4Island level has been disabled, contact an administrator." msgstr "§4岛屿等级系统未启用,请联系管理员." +msgid "§4Hold your horses! §eYou have to be patient..." +msgstr "" + msgid "§eYou must be on your island to use this command." msgstr "§e你必须在你的岛屿上来使用这个指令." @@ -1205,6 +1208,10 @@ msgstr "eBlocks on {0}s Island (page {1,number} of {2,number}):" msgid "Score Count Block" msgstr "计分方块" +#, java-format +msgid "{0,number,#####.##} {1,number,#} {2}" +msgstr "" + #, java-format msgid "§aIsland level is {0,number,###.##}" msgstr "§a岛屿等级: {0,number,###.##}" @@ -1630,7 +1637,19 @@ msgstr "§4玩家禁止你传送到他们的岛屿上." msgid "§4That island is §clocked.§e No teleporting to the island." msgstr "" -msgid "§4You've hit the hopper limit! You can't have more hoppers!" +#, java-format +msgid "" +"§4{0} is limited. §eScanning your island to see if you are allowed to place " +"more, please be patient" +msgstr "" + +msgid "§e... Scanning complete, you can try again" +msgstr "" + +#, java-format +msgid "" +"§4You''ve hit the {0} limit!§e You can''t have more of that type on your " +"island!§9 Max: {1,number}" msgstr "" msgid "§cYou have reached your spawn-limit for your island." @@ -2517,6 +2536,18 @@ msgstr "" msgid "Too many requests for Mojangs API ({0} within {1}), sleeping {2}" msgstr "" +msgid "§9Not really patient, are you?" +msgstr "" + +msgid "§9Be patient, young padawan" +msgstr "" + +msgid "§9Patience you MUST have, young padawan" +msgstr "" + +msgid "§9The two most powerful warriors are patience and time." +msgstr "" + msgid "§eSending you to spawn." msgstr "" diff --git a/uSkyBlock-Core/src/main/resources/config.yml b/uSkyBlock-Core/src/main/resources/config.yml index eeae5bb1b..aa9c6e19f 100644 --- a/uSkyBlock-Core/src/main/resources/config.yml +++ b/uSkyBlock-Core/src/main/resources/config.yml @@ -88,12 +88,6 @@ options: # How many entries to remember in the island-log log-size: 10 - # How many hoppers are allowed to be placed down on an island - hopperlimit: 50 - - # How many mob spawners are allowed to be placed on an island - spawnerlimit: 10 - # Limits the spawning spawn-limits: # [true/false] if true, the limits below will limit spawning @@ -111,6 +105,16 @@ options: # how many snowmen and iron-golems can be spawned on an island golems: 5 + block-limits: + # [true/false] if true, the limits below will limit block placement + enabled: true + + # How many hoppers are allowed to be placed down on an island + hopper: 50 + + # How many mob spawners are allowed to be placed on an island + mob_spawner: 10 + # [permission] The name of the permissions to check if extra items are added to the chest, you can change these or add more # Only checked if 'addExtraItems' is set to true. # [permission:item list] The list of extra items to add to the chest, will only be added if the player has the permission. ITEM_ID:HOW_MANY @@ -438,7 +442,7 @@ placeholder: servercommandplaceholder: false # DO NOT TOUCH THE FIELDS BELOW -version: 62 +version: 64 force-replace: options.party.invite-timeout: 100 options.island.islandTeleportDelay: 5 @@ -447,3 +451,5 @@ force-replace: move-nodes: options.restart.confirmation: confirmation.is restart options.party.leave.confirmation: confirmation.is leave + options.island.hopperlimit: options.island.block-limits.hopper + options.island.spawnerlimit: options.island.block-limits.mob_spawner \ No newline at end of file