mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-22 18:26:08 +01:00
Stackables permission, block limits fixes, wildstacker level support
This commit is contained in:
parent
9191f99f2d
commit
807cd45b60
@ -9,6 +9,7 @@ import me.goodandevil.skyblock.hologram.HologramManager;
|
||||
import me.goodandevil.skyblock.hologram.HologramType;
|
||||
import me.goodandevil.skyblock.leaderboard.LeaderboardManager;
|
||||
import me.goodandevil.skyblock.levelling.LevellingManager;
|
||||
import me.goodandevil.skyblock.limit.LimitManager;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.scoreboard.ScoreboardManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
@ -39,13 +40,14 @@ public class ReloadCommand extends SubCommand {
|
||||
HologramManager hologramManager = skyblock.getHologramManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
LimitManager limitManager = skyblock.getLimitManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
messageManager.sendMessage(sender, "&cPlease note that this command is not supported and may " +
|
||||
"cause issues that could put the plugin in an unstable state. " +
|
||||
"If you encounter any issues please stop your server, edit the configuration files, " +
|
||||
"and then start your server again. This command does NOT reload all the plugin files, only " +
|
||||
"the config.yml, language.yml, generators.yml, and levelling.yml.");
|
||||
"the config.yml, language.yml, generators.yml, levelling.yml, and limits.yml.");
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
@ -94,6 +96,8 @@ public class ReloadCommand extends SubCommand {
|
||||
|
||||
hologramManager.resetHologram();
|
||||
|
||||
limitManager.reload();
|
||||
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Reload.Reloaded.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
@ -1226,18 +1226,18 @@ public class IslandManager {
|
||||
if (isFlyUpgradeEnabled) {
|
||||
boolean upgradeEnabled = island != null && island.isUpgrade(Upgrade.Type.Fly);
|
||||
setPlayerFlying = upgradeEnabled;
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
|
||||
player.setAllowFlight(upgradeEnabled);
|
||||
});
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> player.setAllowFlight(upgradeEnabled));
|
||||
}
|
||||
|
||||
boolean hasFlyPermission = player.hasPermission("fabledskyblock.fly") || player.hasPermission("fabledskyblock.*");
|
||||
if (hasFlyPermission && island != null && !setPlayerFlying) {
|
||||
if (island == null || setPlayerFlying)
|
||||
return;
|
||||
|
||||
boolean hasGlobalFlyPermission = player.hasPermission("fabledskyblock.*") || player.hasPermission("fabledskyblock.fly.*");
|
||||
boolean hasOwnIslandFlyPermission = player.hasPermission("fabledskyblock.fly") && island.getRole(player) != null && island.getRole(player) != IslandRole.Visitor;
|
||||
if (hasGlobalFlyPermission || hasOwnIslandFlyPermission) {
|
||||
WorldManager worldManager = skyblock.getWorldManager();
|
||||
boolean canFlyInWorld = worldManager.isIslandWorld(player.getWorld());
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
|
||||
player.setAllowFlight(canFlyInWorld);
|
||||
});
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> player.setAllowFlight(canFlyInWorld));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class Chunk {
|
||||
}
|
||||
|
||||
public void prepareNextChunkSnapshots() {
|
||||
boolean isWildStackerEnabled = Bukkit.getPluginManager().isPluginEnabled("WildStacker") && false; // TODO: Disabled for now until we figure out why it isn't working properly
|
||||
boolean isWildStackerEnabled = Bukkit.getPluginManager().isPluginEnabled("WildStacker");
|
||||
|
||||
Bukkit.getScheduler().runTask(this.skyblock, () -> {
|
||||
this.chunkSnapshots.clear();
|
||||
|
@ -41,6 +41,7 @@ public class LevellingManager {
|
||||
|
||||
private final SkyBlock skyblock;
|
||||
|
||||
private Set<Island> activeIslandScans = new HashSet<>();
|
||||
private List<LevellingMaterial> materialStorage = new ArrayList<>();
|
||||
|
||||
private Method getBlockTypeMethod = null;
|
||||
@ -67,6 +68,8 @@ public class LevellingManager {
|
||||
return;
|
||||
}
|
||||
|
||||
this.activeIslandScans.add(island);
|
||||
|
||||
Chunk chunk = new Chunk(skyblock, island);
|
||||
chunk.prepareInitial();
|
||||
|
||||
@ -180,7 +183,7 @@ public class LevellingManager {
|
||||
if (snapshot.isStackedSpawner(location)) {
|
||||
Map.Entry<Integer, EntityType> spawnerData = snapshot.getStackedSpawner(location);
|
||||
amount = spawnerData.getKey();
|
||||
blockData = 0;
|
||||
spawnerType = spawnerData.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
@ -304,6 +307,8 @@ public class LevellingManager {
|
||||
me.goodandevil.skyblock.menus.Levelling.getInstance().open(player);
|
||||
}
|
||||
}
|
||||
|
||||
this.activeIslandScans.remove(island);
|
||||
}
|
||||
|
||||
public void registerMaterials() {
|
||||
@ -321,12 +326,16 @@ public class LevellingManager {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: The material '" + materialKey
|
||||
+ "' is not a Material type. Make sure the material name is a 1.13 material name. Please correct this in the 'levelling.yml' file.");
|
||||
+ "' is not a Material type. Make sure the material name is a 1.14 material name. Please correct this in the 'levelling.yml' file.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isIslandLevelBeingScanned(Island island) {
|
||||
return this.activeIslandScans.contains(island);
|
||||
}
|
||||
|
||||
public void unregisterMaterials() {
|
||||
materialStorage.clear();
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import me.goodandevil.skyblock.SkyBlock;
|
||||
import me.goodandevil.skyblock.island.Island;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -26,6 +27,12 @@ public class LimitManager {
|
||||
this.skyblock = skyblock;
|
||||
this.blockLimits = new HashMap<>();
|
||||
|
||||
this.reload();
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
this.blockLimits.clear();
|
||||
|
||||
FileConfiguration limitsConfig = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "limits.yml")).getFileConfiguration();
|
||||
ConfigurationSection blockLimitSection = limitsConfig.getConfigurationSection("block");
|
||||
|
||||
@ -51,22 +58,14 @@ public class LimitManager {
|
||||
return -1;
|
||||
|
||||
long limit = -1;
|
||||
Materials material;
|
||||
if (block.getType() == Materials.SPAWNER.parseMaterial()) {
|
||||
material = Materials.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType());
|
||||
if (this.blockLimits.containsKey(Materials.SPAWNER))
|
||||
limit = Math.max(limit, this.blockLimits.get(Materials.SPAWNER));
|
||||
} else {
|
||||
material = Materials.getMaterials(block.getType(), block.getData());
|
||||
}
|
||||
Materials material = Materials.getMaterials(block.getType(), block.getData());
|
||||
|
||||
if (this.blockLimits.containsKey(material))
|
||||
limit = Math.max(limit, this.blockLimits.get(material));
|
||||
|
||||
Set<PermissionAttachmentInfo> permissions = player.getEffectivePermissions()
|
||||
.stream()
|
||||
.filter(x -> x.getPermission().toLowerCase().startsWith("fabledskyblock.limit.block." + material.name().toLowerCase())
|
||||
|| (block.getType() == Materials.SPAWNER.parseMaterial() && x.getPermission().toLowerCase().startsWith("fabledskyblock.limit.block.spawner")))
|
||||
.filter(x -> x.getPermission().toLowerCase().startsWith("fabledskyblock.limit.block." + material.name().toLowerCase()))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
for (PermissionAttachmentInfo permission : permissions) {
|
||||
@ -97,7 +96,12 @@ public class LimitManager {
|
||||
return false;
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(block.getLocation());
|
||||
long totalPlaced = island.getLevel().getMaterialAmount(Materials.getMaterials(block.getType(), block.getData()).name());
|
||||
long totalPlaced;
|
||||
if (block.getType() == Materials.SPAWNER.parseMaterial()) {
|
||||
totalPlaced = island.getLevel().getMaterials().entrySet().stream().filter(x -> x.getKey().contains("SPAWNER")).mapToLong(Map.Entry::getValue).sum();
|
||||
} else {
|
||||
totalPlaced = island.getLevel().getMaterialAmount(Materials.getMaterials(block.getType(), block.getData()).name());
|
||||
}
|
||||
|
||||
return limit < totalPlaced + 1;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.generator.Generator;
|
||||
import me.goodandevil.skyblock.generator.GeneratorManager;
|
||||
import me.goodandevil.skyblock.island.*;
|
||||
import me.goodandevil.skyblock.levelling.LevellingManager;
|
||||
import me.goodandevil.skyblock.limit.LimitManager;
|
||||
import me.goodandevil.skyblock.stackable.Stackable;
|
||||
import me.goodandevil.skyblock.stackable.StackableManager;
|
||||
@ -170,6 +171,7 @@ public class Block implements Listener {
|
||||
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
WorldManager worldManager = skyblock.getWorldManager();
|
||||
LevellingManager levellingManager = skyblock.getLevellingManager();
|
||||
if (!worldManager.isIslandWorld(block.getWorld())) return;
|
||||
|
||||
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
|
||||
@ -180,6 +182,14 @@ public class Block implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (levellingManager.isIslandLevelBeingScanned(island)) {
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Place")) {
|
||||
event.setCancelled(true);
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
@ -226,12 +236,7 @@ public class Block implements Listener {
|
||||
|
||||
LimitManager limitManager = skyblock.getLimitManager();
|
||||
if (limitManager.isBlockLimitExceeded(player, block)) {
|
||||
Materials material;
|
||||
if (block.getType() == Materials.SPAWNER.parseMaterial()) {
|
||||
material = Materials.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType());
|
||||
} else {
|
||||
material = Materials.getMaterials(block.getType(), block.getData());
|
||||
}
|
||||
Materials material = Materials.getMaterials(block.getType(), block.getData());
|
||||
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
|
@ -3,6 +3,7 @@ package me.goodandevil.skyblock.listeners;
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
import me.goodandevil.skyblock.levelling.LevellingManager;
|
||||
import me.goodandevil.skyblock.limit.LimitManager;
|
||||
import me.goodandevil.skyblock.utils.NumberUtil;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
@ -68,6 +69,13 @@ public class Interact implements Listener {
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
StackableManager stackableManager = skyblock.getStackableManager();
|
||||
LevellingManager levellingManager = skyblock.getLevellingManager();
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(player.getLocation());
|
||||
if (island == null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
if (block.getType() == Material.DRAGON_EGG) {
|
||||
@ -123,19 +131,23 @@ public class Interact implements Listener {
|
||||
if (stackableManager != null
|
||||
&& stackableManager.getStackableMaterials().contains(event.getMaterial())
|
||||
&& event.getClickedBlock().getType() == event.getMaterial()
|
||||
&& !player.isSneaking() && islandManager.hasPermission(player, block.getLocation(), "Place")) {
|
||||
&& !player.isSneaking() && islandManager.hasPermission(player, block.getLocation(), "Place")
|
||||
&& (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Stackable.RequirePermission") || player.hasPermission("fabledskyblock.stackable"))) {
|
||||
if (NMSUtil.getVersionNumber() > 8) {
|
||||
if (event.getHand() == EquipmentSlot.OFF_HAND) return;
|
||||
}
|
||||
|
||||
if (levellingManager.isIslandLevelBeingScanned(island)) {
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
LimitManager limitManager = skyblock.getLimitManager();
|
||||
if (limitManager.isBlockLimitExceeded(player, block)) {
|
||||
Materials material;
|
||||
if (block.getType() == Materials.SPAWNER.parseMaterial()) {
|
||||
material = Materials.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType());
|
||||
} else {
|
||||
material = Materials.getMaterials(block.getType(), block.getData());
|
||||
}
|
||||
Materials material = Materials.getMaterials(block.getType(), block.getData());
|
||||
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
@ -162,8 +174,6 @@ public class Interact implements Listener {
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
if (!configLoad.getBoolean("Island.Block.Level.Enable")) return;
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(block.getLocation());
|
||||
|
||||
Materials materials = Materials.getMaterials(block.getType(), block.getData());
|
||||
|
||||
if (materials == null) return;
|
||||
|
@ -14,9 +14,9 @@ Island:
|
||||
# The size of an Island when created.
|
||||
# [!] Do not go over the maximum.
|
||||
# [!] Even numbers WILL create world border issues.
|
||||
Minimum: 101
|
||||
Minimum: 100
|
||||
# The maximum size of an Island based on the permission node 'skyblock.size.<size>'.
|
||||
Maximum: 201
|
||||
Maximum: 200
|
||||
Creation:
|
||||
# Rather than opening the 'Island Creator' menu. Create an island
|
||||
# as soon as a player performs the '/island' or '/island create'
|
||||
@ -38,7 +38,7 @@ Island:
|
||||
# Delete the Island world when changing the liquid option.
|
||||
# If lava disabled, the world will be a water world.
|
||||
# -1 to disable Nether and End unlock prices.
|
||||
# Valid Enrivonments: NORMAL, NETHER, THE_END
|
||||
# Valid Environments: NORMAL, NETHER, THE_END
|
||||
Normal:
|
||||
Name: "island_normal_world"
|
||||
IslandSpawnHeight: 72
|
||||
@ -285,3 +285,5 @@ Island:
|
||||
Enable: true
|
||||
Stackable:
|
||||
Enable: true
|
||||
# fabledskyblock.stackables
|
||||
RequirePermission: false
|
||||
|
@ -82,6 +82,8 @@ Command:
|
||||
Message: '&eScanning Island level: &b%percent%'
|
||||
NotOnIsland:
|
||||
Message: '&bSkyBlock &8| &cError&8: &eYou cannot initiate an Island level scan without being on your Island.'
|
||||
BlockPlacing:
|
||||
Message: '&bSkyBlock &8 | &cError:&8: &eYou cannot place blocks during an Island level scan. Please wait for the scan to finish.'
|
||||
Cooldown:
|
||||
Word:
|
||||
Minute: minute(s)
|
||||
@ -2062,7 +2064,9 @@ Menu:
|
||||
- ''
|
||||
- '&cWarning: You must wait a'
|
||||
- '&chour after a rescan to'
|
||||
- '&cperform another one!'
|
||||
- '&cperform another one! You'
|
||||
- '&cwill also not be able to'
|
||||
- '&cplace blocks during the scan!'
|
||||
Displayname: '&aRescan Island Materials'
|
||||
Material:
|
||||
Displayname: '&7%material &8(&e+%points Points&8)'
|
||||
|
Loading…
Reference in New Issue
Block a user