mirror of
https://github.com/songoda/EpicFurnaces.git
synced 2025-02-10 00:21:59 +01:00
Added epicfurnaces.limit.<limit> permission.
This commit is contained in:
parent
63e9b68f74
commit
75937527cb
@ -1,5 +1,6 @@
|
||||
package com.songoda.epicfurnaces.listeners;
|
||||
|
||||
import com.songoda.core.utils.PlayerUtils;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.furnace.Furnace;
|
||||
import com.songoda.epicfurnaces.furnace.FurnaceBuilder;
|
||||
@ -8,6 +9,7 @@ import com.songoda.epicfurnaces.utils.GameArea;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -57,11 +59,28 @@ public class BlockListeners implements Listener {
|
||||
return;
|
||||
|
||||
ItemStack item = event.getItemInHand();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!plugin.isLeveledFurnace(item) && Settings.ALLOW_NORMAL_FURNACES.getBoolean()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Settings.USE_LIMIT_PERMISSION.getBoolean()) {
|
||||
int amount = 0;
|
||||
for (Furnace furnace : plugin.getFurnaceManager().getFurnaces().values()) {
|
||||
if (furnace.getPlacedBy() == null || !furnace.getPlacedBy().equals(player.getUniqueId())) continue;
|
||||
amount++;
|
||||
}
|
||||
int limit = PlayerUtils.getNumberFromPermission(player, "epicfurnaces.limit", -1);
|
||||
|
||||
if (limit != -1 && amount >= limit) {
|
||||
event.setCancelled(true);
|
||||
plugin.getLocale().getMessage("event.limit.hit")
|
||||
.processPlaceholder("limit", limit).sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Location location = event.getBlock().getLocation();
|
||||
|
||||
Furnace furnace = event.getItemInHand().getItemMeta().hasDisplayName() && plugin.getFurnaceLevel(item) != 1
|
||||
|
@ -54,6 +54,11 @@ public class Settings {
|
||||
"Should normal furnaces not be converted into",
|
||||
"Epic Furnaces?");
|
||||
|
||||
public static final ConfigSetting USE_LIMIT_PERMISSION = new ConfigSetting(config, "Main.Use Limit Permission", true,
|
||||
"Should we use the epicfurnaces.limit.<amount>",
|
||||
"permission? This will limit the amount of Epic Furnaces",
|
||||
"a player can place.");
|
||||
|
||||
public static final ConfigSetting PARTICLE_TYPE = new ConfigSetting(config, "Main.Upgrade Particle Type", "SPELL_WITCH",
|
||||
"The type of particle shown when a furnace is upgraded.");
|
||||
|
||||
|
@ -76,3 +76,5 @@ event:
|
||||
playeralreadyadded: '&cThis player has already been added to this furnace.'
|
||||
playeradded: '&aPlayer successfully added!'
|
||||
invalidplayer: '&cInvalid player. Are they online?'
|
||||
limit:
|
||||
hit: '&7You can only have &6%limit% &7furnaces at a single time.'
|
Loading…
Reference in New Issue
Block a user