From 0c1b75d2222e935dd726d0f87eef2572edbd8b5d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 16 Jun 2020 01:39:26 +0200 Subject: [PATCH 01/33] 1.8.8 compatibility (almost) --- .../challenge/challenge/Challenge.java | 2 +- .../challenge/ChallengeCategory.java | 4 +- .../skyblock/island/IslandManager.java | 1 - .../com/songoda/skyblock/listeners/Block.java | 40 ++++++++------ .../songoda/skyblock/listeners/Interact.java | 8 ++- .../songoda/skyblock/menus/Leaderboard.java | 2 +- .../skyblock/tasks/MobNetherWaterTask.java | 53 +++++++++++-------- .../skyblock/utils/world/LocationUtil.java | 42 +++++++-------- .../skyblock/utils/world/LocationUtil113.java | 13 +++++ .../utils/world/entity/EntityUtil.java | 6 ++- 10 files changed, 102 insertions(+), 69 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/utils/world/LocationUtil113.java diff --git a/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java b/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java index eb1a3604..d7deaf71 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java @@ -160,7 +160,7 @@ public class Challenge { ItemStack is = (ItemStack) obj; //p.getInventory().removeItem(new ItemStack(is.getType(), is.getAmount())); int toRemove = is.getAmount(); - for(ItemStack jis : p.getInventory().getStorageContents()) { + for(ItemStack jis : p.getInventory().getContents()) { if(jis != null && jis.isSimilar(is)) { if(jis.getAmount() <= toRemove) { toRemove -= jis.getAmount(); diff --git a/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java b/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java index ddc31195..3e48ffb6 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java @@ -61,8 +61,8 @@ public class ChallengeCategory { Challenge c = new Challenge(this, id, name, maxTimes, showInChat, require, reward, ic); challenges.put(id, c); } catch (IllegalArgumentException ex) { - throw new IllegalArgumentException("Exception at category " + this.name + "(" + this.id - + ") at challenge " + name + "(" + id + "): " + ex.getMessage()); + throw new IllegalArgumentException("Exception at category " + this.name.replace("&", "") + "(" + this.id + + ") at challenge " + name.replace("&", "") + "(" + id + "): " + ex.getMessage()); } } Bukkit.getConsoleSender().sendMessage("[FabledSkyBlock] " + ChatColor.GREEN + "Category " + name + ChatColor.GREEN diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index f25eb3b8..58c342a4 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -47,7 +47,6 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; -import org.bukkit.plugin.IllegalPluginAccessException; import java.io.File; import java.io.IOException; diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index 3e084222..9a33b4b9 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -25,9 +25,8 @@ import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.block.CreatureSpawner; import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.*; import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -323,22 +322,29 @@ public class Block implements Listener { if(configLoad.getBoolean("Island.Nether.WaterDoNotFlowNearNetherMobs", false) && worldManager.getIslandWorld(block.getWorld()).equals(IslandWorld.Nether)){ Collection entities = block.getWorld().getNearbyEntities(block.getLocation(), 1d, 1d, 1d); if(entities.size() > 0){ - EntityCycle: for(Entity ent : entities){ - switch(ent.getType()){ - case PIG_ZOMBIE: - case BLAZE: - case MAGMA_CUBE: - case WITHER_SKELETON: - case WITHER: - case GHAST: - if(block.getRelative(event.getFace().getOppositeFace()).getType().equals(Material.WATER)){ - event.setCancelled(true); + for(Entity ent : entities){ + boolean witherSkeleton; + if (NMSUtil.getVersionNumber() > 10) { + witherSkeleton = ent.getType().equals(EntityType.WITHER_SKELETON); + } else { + witherSkeleton = ent instanceof Skeleton && ((Skeleton) ent).getSkeletonType().equals(Skeleton.SkeletonType.WITHER); + } + if (ent.getType().equals(EntityType.PIG_ZOMBIE) || + ent.getType().equals(EntityType.BLAZE) || + ent.getType().equals(EntityType.MAGMA_CUBE) || + ent.getType().equals(EntityType.WITHER) || + ent.getType().equals(EntityType.GHAST) || + witherSkeleton) { + if(block.getRelative(event.getFace().getOppositeFace()).getType().equals(Material.WATER)){ + event.setCancelled(true); + if(NMSUtil.getVersionNumber() > 8){ event.getToBlock().getWorld().playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f); - event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1); + } else { + // TODO Find a sound for 1.8 } - break EntityCycle; // TODO No spaghetti code - default: - break; + event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1); + } + break; } } } @@ -638,7 +644,7 @@ public class Block implements Listener { // PortalCreateEvent.getBlocks() changed from ArrayList to // ArrayList in 1.14.1 if (NMSUtil.getVersionNumber() > 13) { - List blocks = event.getBlocks(); + List blocks = event.getBlocks(); // TODO 1.8 if (event.getBlocks().isEmpty()) return; Island island = islandManager.getIslandAtLocation(event.getBlocks().get(0).getLocation()); diff --git a/src/main/java/com/songoda/skyblock/listeners/Interact.java b/src/main/java/com/songoda/skyblock/listeners/Interact.java index b13b2185..f2489589 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Interact.java +++ b/src/main/java/com/songoda/skyblock/listeners/Interact.java @@ -18,6 +18,7 @@ import com.songoda.skyblock.stackable.Stackable; import com.songoda.skyblock.stackable.StackableManager; import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.structure.StructureUtil; +import com.songoda.skyblock.utils.version.NMSUtil; import com.songoda.skyblock.utils.world.LocationUtil; import com.songoda.skyblock.world.WorldManager; import org.apache.commons.lang.WordUtils; @@ -121,7 +122,12 @@ public class Interact implements Listener { if(configLoad.getBoolean("Island.Nether.AllowNetherWater", false)){ event.setCancelled(true); block.setType(Material.WATER, true); - block.getWorld().playSound(block.getLocation(), Sound.ITEM_BUCKET_EMPTY, 1f, 1f); + if(NMSUtil.getVersionNumber() > 8){ + block.getWorld().playSound(block.getLocation(), Sound.ITEM_BUCKET_EMPTY, 1f, 1f); + } else { + //block.getWorld().playSound(block.getLocation(), Sound.SPLASH, 1f, 1f); + // TODO Find a sound for 1.8 + } if(!event.getPlayer().getGameMode().equals(GameMode.CREATIVE)){ event.getItem().setType(Material.BUCKET); } diff --git a/src/main/java/com/songoda/skyblock/menus/Leaderboard.java b/src/main/java/com/songoda/skyblock/menus/Leaderboard.java index 892521f7..05f969a2 100644 --- a/src/main/java/com/songoda/skyblock/menus/Leaderboard.java +++ b/src/main/java/com/songoda/skyblock/menus/Leaderboard.java @@ -123,7 +123,7 @@ public class Leaderboard { 2); } else { nInv.addItem( - nInv.createItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), "", null, null, null, null), 2); + nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), "", null, null, null, null), 2); } nInv.addItem( nInv.createItem(new ItemStack(Material.EMERALD), configLoad diff --git a/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java b/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java index 5ae7bd69..2dd109eb 100644 --- a/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java +++ b/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java @@ -11,6 +11,7 @@ import com.songoda.skyblock.leaderboard.Leaderboard; import com.songoda.skyblock.leaderboard.LeaderboardManager; import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.player.OfflinePlayer; +import com.songoda.skyblock.utils.version.NMSUtil; import com.songoda.skyblock.utils.world.LocationUtil; import com.songoda.skyblock.visit.Visit; import org.bukkit.*; @@ -18,7 +19,9 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; import org.bukkit.scheduler.BukkitRunnable; import java.io.File; @@ -51,28 +54,22 @@ public class MobNetherWaterTask extends BukkitRunnable { .getFileConfiguration().getBoolean("Island.Nether.WaterDisappearWithNetherMobs", false)){ for(World world : Bukkit.getServer().getWorlds()){ if(plugin.getWorldManager().isIslandWorld(world) && plugin.getWorldManager().getIslandWorld(world).equals(IslandWorld.Nether)){ - for(Entity ent : world.getEntities()){ - switch(ent.getType()){ - case PIG_ZOMBIE: - case BLAZE: - case MAGMA_CUBE: - case WITHER_SKELETON: - case WITHER: - case GHAST: - Block block = ent.getLocation().getBlock(); - if(block.getType().equals(Material.WATER)){ - block.setType(Material.AIR, true); - world.playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f); - world.playEffect(block.getLocation(), Effect.SMOKE, 1); - } - block = block.getRelative(BlockFace.UP); - if(block.getType().equals(Material.WATER)){ - block.setType(Material.AIR, true); - world.playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f); - world.playEffect(block.getLocation(), Effect.SMOKE, 1); - } - default: - break; + for(Entity ent : world.getEntities()) { + boolean witherSkeleton; + if (NMSUtil.getVersionNumber() > 10) { + witherSkeleton = ent.getType().equals(EntityType.WITHER_SKELETON); + } else { + witherSkeleton = ent instanceof Skeleton && ((Skeleton) ent).getSkeletonType().equals(Skeleton.SkeletonType.WITHER); + } + if (ent.getType().equals(EntityType.PIG_ZOMBIE) || + ent.getType().equals(EntityType.BLAZE) || + ent.getType().equals(EntityType.MAGMA_CUBE) || + ent.getType().equals(EntityType.WITHER) || + ent.getType().equals(EntityType.GHAST) || + witherSkeleton) { + Block block = ent.getLocation().getBlock(); + removeWater(world, block); + removeWater(world, block.getRelative(BlockFace.UP)); } } } @@ -80,6 +77,18 @@ public class MobNetherWaterTask extends BukkitRunnable { } } + private void removeWater(World world, Block block) { + if (block.getType().equals(Material.WATER)) { + block.setType(Material.AIR, true); + if(NMSUtil.getVersionNumber() > 8){ + world.playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f); + } else { + // TODO Find a sound for 1.8 + } + world.playEffect(block.getLocation(), Effect.SMOKE, 1); + } + } + public void onDisable() { } diff --git a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java index 722233ad..04a3fc7f 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java @@ -9,13 +9,13 @@ import com.songoda.skyblock.island.IslandEnvironment; import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.utils.math.VectorUtil; +import com.songoda.skyblock.utils.version.NMSUtil; import com.songoda.skyblock.utils.world.block.BlockDegreesType; import com.songoda.skyblock.world.WorldManager; import org.bukkit.*; import org.bukkit.World.Environment; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.block.data.Waterlogged; import org.bukkit.entity.Player; import java.io.File; @@ -32,10 +32,8 @@ public final class LocationUtil { Location tempLoc = LocationUtil.getDefinitiveLocation(loc); if(tempLoc.getBlock().getType().equals(Material.WATER)){ tempLoc.getBlock().setType(Material.AIR); - } else if(tempLoc.getBlock().getBlockData() instanceof Waterlogged){ - Waterlogged blockData = (Waterlogged) tempLoc.getBlock().getBlockData(); - blockData.setWaterlogged(false); - tempLoc.getBlock().setBlockData(blockData); + } else if(NMSUtil.getVersionNumber() > 13){ + LocationUtil113.removeWaterLoggedFromLocation(tempLoc); } } } @@ -66,7 +64,8 @@ public final class LocationUtil { Location locWorking = loc.clone(); for(int i=locWorking.getBlockY(); i>=0; i--){ if(!locWorking.getBlock().isEmpty()){ - if(locWorking.getBlock().getType().equals(Material.WATER) || locWorking.getBlock().getBlockData() instanceof Waterlogged){ + if(locWorking.getBlock().getType().equals(Material.WATER) || + (NMSUtil.getVersionNumber() > 13 && locWorking.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){ loc = locWorking; } break; @@ -79,39 +78,38 @@ public final class LocationUtil { boolean safe = false; if(!locChecked.getBlock().isEmpty() && !locChecked.getBlock().isLiquid() && - !locChecked.getBlock().isPassable() && locChecked.getBlock().getType().isSolid() && locChecked.getBlock().getType().isBlock() && - locChecked.add(0d,1d,0d).getBlock().getType().isAir() && - locChecked.add(0d,2d,0d).getBlock().getType().isAir() && - !(locChecked.getBlock().getBlockData() instanceof Waterlogged)){ + locChecked.add(0d,1d,0d).getBlock().getType().equals(Material.AIR) && + locChecked.add(0d,2d,0d).getBlock().getType().equals(Material.AIR) && + !(NMSUtil.getVersionNumber() <= 13 || locChecked.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){ safe = true; switch(locChecked.getBlock().getType()){ - case ACACIA_BUTTON: - case ACACIA_DOOR: + case ACACIA_DOOR: // <= 1.8.8 case ACACIA_FENCE_GATE: - case ACACIA_TRAPDOOR: case BIRCH_DOOR: case BIRCH_FENCE_GATE: - case BIRCH_TRAPDOOR: case CACTUS: case CAKE: - case CAMPFIRE: - case COBWEB: case DARK_OAK_DOOR: case DARK_OAK_FENCE_GATE: - case DARK_OAK_TRAPDOOR: case IRON_TRAPDOOR: case JUNGLE_DOOR: case JUNGLE_FENCE_GATE: - case JUNGLE_TRAPDOOR: case LADDER: - case MAGMA_BLOCK: - case NETHER_PORTAL: - case OAK_DOOR: - case OAK_FENCE_GATE: case SPRUCE_DOOR: case SPRUCE_FENCE_GATE: + case ACACIA_BUTTON: // TODO check server version + case ACACIA_TRAPDOOR: // TODO check server version + case BIRCH_TRAPDOOR: // TODO check server version + case CAMPFIRE: // TODO check server version + case COBWEB: // TODO check server version + case DARK_OAK_TRAPDOOR: // TODO check server version + case JUNGLE_TRAPDOOR: // TODO check server version + case MAGMA_BLOCK: // TODO check server version + case NETHER_PORTAL: // TODO check server version + case OAK_DOOR: // TODO check server version + case OAK_FENCE_GATE: // TODO check server version safe = false; break; } diff --git a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil113.java b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil113.java new file mode 100644 index 00000000..d86dd7f1 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil113.java @@ -0,0 +1,13 @@ +package com.songoda.skyblock.utils.world; + +import org.bukkit.Location; + +public class LocationUtil113 { + public static void removeWaterLoggedFromLocation(Location loc){ + if(loc.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged){ + org.bukkit.block.data.Waterlogged blockData = (org.bukkit.block.data.Waterlogged) loc.getBlock().getBlockData(); + blockData.setWaterlogged(false); + loc.getBlock().setBlockData(blockData); + } + } +} diff --git a/src/main/java/com/songoda/skyblock/utils/world/entity/EntityUtil.java b/src/main/java/com/songoda/skyblock/utils/world/entity/EntityUtil.java index e13d7a78..ea550a4f 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/entity/EntityUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/entity/EntityUtil.java @@ -498,7 +498,10 @@ public final class EntityUtil { } public static boolean isMonster(EntityType type) { - switch (type) { + if (NMSUtil.getVersionNumber() > 10) { + if(type.equals(EntityType.WITHER_SKELETON)) return true; // TODO In < 11 we have SkeletonType.Wither + } + switch (type) { // TODO Check server versions case BAT: case BLAZE: case CAVE_SPIDER: @@ -525,7 +528,6 @@ public final class EntityUtil { case VINDICATOR: case WITCH: case WITHER: - case WITHER_SKELETON: case ZOMBIE: case ZOMBIE_VILLAGER: return true; From fa5f34a8899f39da8d44413a4568cec6e3f9d2da Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 16 Jun 2020 04:17:49 +0200 Subject: [PATCH 02/33] Hotfix for island disappeared bug --- src/main/java/com/songoda/skyblock/listeners/Move.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java index 0fb33b34..cf8929bd 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Move.java +++ b/src/main/java/com/songoda/skyblock/listeners/Move.java @@ -242,9 +242,11 @@ public class Move implements Listener { e.setCancelled(true); - skyblock.getMessageManager().sendMessage(player, - skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message")); - skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); - + Bukkit.getScheduler().runTaskLater(skyblock, () -> { + if (e.getTo() != null && worldManager.isIslandWorld(e.getTo().getWorld()) && skyblock.getIslandManager().getIslandAtLocation(e.getTo()) == null) + skyblock.getMessageManager().sendMessage(player, + skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message")); + skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); + }, 10L); // 2 ticks are good, 10 because we don't know the cause yet } } From 781b7167833b507837fae1339bf6a135e5052b7d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 16 Jun 2020 05:07:30 +0200 Subject: [PATCH 03/33] Use block instead of material in CompatibleMaterial --- src/main/java/com/songoda/skyblock/listeners/Block.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index 9a33b4b9..f5dab715 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -73,9 +73,9 @@ public class Block implements Listener { } if (stackableManager != null && stackableManager.isStacked(blockLocation)) { - Stackable stackable = stackableManager.getStack(block.getLocation(), CompatibleMaterial.getBlockMaterial(block.getType())); + Stackable stackable = stackableManager.getStack(block.getLocation(), CompatibleMaterial.getMaterial(block)); if (stackable != null) { - CompatibleMaterial material = CompatibleMaterial.getBlockMaterial(block.getType()); + CompatibleMaterial material = CompatibleMaterial.getMaterial(block); byte data = block.getData(); int droppedAmount = 0; From c27a8b03ad47f20ec9f539914da61439705402ce Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 16 Jun 2020 19:42:25 +0200 Subject: [PATCH 04/33] Some comments --- src/main/java/com/songoda/skyblock/listeners/Block.java | 1 + src/main/resources/config.yml | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index f5dab715..54c34958 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -728,6 +728,7 @@ public class Block implements Listener { // placed. // This shouldn't cause any issues besides the task number being increased // insanely fast. + // TODO Do this only in 1.8.8 Bukkit.getScheduler().runTask(skyblock, () -> { org.bukkit.block.Block block = location.getBlock(); CompatibleMaterial material = CompatibleMaterial.getMaterial(block); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e68afb67..ca6c6fa2 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -337,11 +337,16 @@ Island: # Should slime split bypass limits.yml AllowSlimeSplit: true Nether: + # Allow placing water in the Nether AllowNetherWater: false + # Water disappear when a nether mob walks into it WaterDisappearWithNetherMobs: false + # Block water from flowing near nether mobs EXPERIMENTAL! WaterDoNotFlowNearNetherMobs: false + # Make blaze immune from water in the Nether BlazeImmuneToWaterInNether: false Restrict: + # Blocks that can be placed only if the island has nether unlocked NetherBlocks: NETHERRACK: true SOUL_SAND: true @@ -364,6 +369,7 @@ Island: NETHER_WART_BLOCK: true WITHER_SKELETON_SKULL: true WITHER_ROSE: true + # Blocks that can be placed only if the island has The End unlocked EndBlocks: END_STONE: true END_STONE_BRICKS: true From b181babdd4172594e81070c58f59d6dc4d6aa81c Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 16 Jun 2020 21:05:01 +0200 Subject: [PATCH 05/33] Fix for permission check We should have both true, because overridingCheck() is usually true also when we don't have permission --- .../java/com/songoda/skyblock/permission/PermissionManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index 4eee2198..fa4c0ac0 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -152,7 +152,7 @@ public class PermissionManager { BasicPermission permission = wrapper.getPermission(); - if (permission.overridingCheck() || hasPermission(player, island, permission)) + if (permission.overridingCheck() && hasPermission(player, island, permission)) continue; try { From 1fe0777645c4b084db442011a0a26ed2f502d9a3 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 16 Jun 2020 21:43:42 +0200 Subject: [PATCH 06/33] Now config.yml hunger totally disables hunger permission --- src/main/java/com/songoda/skyblock/SkyBlock.java | 2 +- .../songoda/skyblock/permission/BasicPermission.java | 9 --------- .../skyblock/permission/PermissionManager.java | 11 ++++++++--- .../permissions/listening/HungerPermission.java | 6 ------ 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 2c4335ad..3d2771f4 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -111,8 +111,8 @@ public class SkyBlock extends SongodaPlugin { // Load Holograms com.songoda.core.hooks.HologramManager.load(this); - permissionManager = new PermissionManager(this); fileManager = new FileManager(this); + permissionManager = new PermissionManager(this); localizationManager = new LocalizationManager(); worldManager = new WorldManager(this); userCacheManager = new UserCacheManager(this); diff --git a/src/main/java/com/songoda/skyblock/permission/BasicPermission.java b/src/main/java/com/songoda/skyblock/permission/BasicPermission.java index f8284349..8ecf2cb3 100644 --- a/src/main/java/com/songoda/skyblock/permission/BasicPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/BasicPermission.java @@ -60,15 +60,6 @@ public abstract class BasicPermission { return is; } - /** - * Use this to check additional perms. - * - * @return - */ - public boolean overridingCheck() { - return true; - } - public String getName() { return name; } diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index fa4c0ac0..4038b7fe 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -11,6 +11,7 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import java.io.File; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.*; @@ -27,7 +28,7 @@ public class PermissionManager { this.plugin = plugin; // Load default permissions. - registerPermissions( + registerPermissions( // TODO Reload them with /is admin reload - Fabrimat //Listening new StoragePermission(plugin), new DragonEggUsePermission(plugin), @@ -77,7 +78,6 @@ public class PermissionManager { new MobGriefingPermission(plugin), new ExperienceOrbPickupPermission(plugin), new NaturalMobSpawningPermission(), - new HungerPermission(plugin), new PortalPermission(plugin), new ItemPickupPermission(), new ItemDropPermission(), @@ -100,6 +100,11 @@ public class PermissionManager { new MainSpawnPermission(), new VisitorSpawnPermission()); + if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")){ + registerPermission(new HungerPermission(plugin)); + } + registeredHandlers = registeredHandlers.stream().sorted(Comparator.comparingInt(h -> { final PermissionHandler permissionHandler = h.getHandler().getAnnotation(PermissionHandler.class); return permissionHandler.priority().ordinal(); @@ -152,7 +157,7 @@ public class PermissionManager { BasicPermission permission = wrapper.getPermission(); - if (permission.overridingCheck() && hasPermission(player, island, permission)) + if (hasPermission(player, island, permission)) continue; try { diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/HungerPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/HungerPermission.java index abed5a99..9d7bc164 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/HungerPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/HungerPermission.java @@ -21,12 +21,6 @@ public class HungerPermission extends ListeningPermission { this.messageManager = plugin.getMessageManager(); } - @Override - public boolean overridingCheck() { - return plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) - .getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable"); - } - @PermissionHandler public void onFoodLevelChange(FoodLevelChangeEvent event) { event.setCancelled(true); From 8514c0233eeaa99c5ead1448552e46fd6dc6eba2 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 16 Jun 2020 21:54:21 +0200 Subject: [PATCH 07/33] Use CompatibleSound for sound in 1.8.8 --- src/main/java/com/songoda/skyblock/listeners/Block.java | 6 +----- src/main/java/com/songoda/skyblock/listeners/Interact.java | 7 +------ .../com/songoda/skyblock/tasks/MobNetherWaterTask.java | 7 ++----- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index 54c34958..d1cfe72e 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -337,11 +337,7 @@ public class Block implements Listener { witherSkeleton) { if(block.getRelative(event.getFace().getOppositeFace()).getType().equals(Material.WATER)){ event.setCancelled(true); - if(NMSUtil.getVersionNumber() > 8){ - event.getToBlock().getWorld().playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f); - } else { - // TODO Find a sound for 1.8 - } + event.getToBlock().getWorld().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1f, 1f); event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1); } break; diff --git a/src/main/java/com/songoda/skyblock/listeners/Interact.java b/src/main/java/com/songoda/skyblock/listeners/Interact.java index f2489589..0e053b5b 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Interact.java +++ b/src/main/java/com/songoda/skyblock/listeners/Interact.java @@ -122,12 +122,7 @@ public class Interact implements Listener { if(configLoad.getBoolean("Island.Nether.AllowNetherWater", false)){ event.setCancelled(true); block.setType(Material.WATER, true); - if(NMSUtil.getVersionNumber() > 8){ - block.getWorld().playSound(block.getLocation(), Sound.ITEM_BUCKET_EMPTY, 1f, 1f); - } else { - //block.getWorld().playSound(block.getLocation(), Sound.SPLASH, 1f, 1f); - // TODO Find a sound for 1.8 - } + block.getWorld().playSound(block.getLocation(), CompatibleSound.ITEM_BUCKET_EMPTY.getSound(), 1f, 1f); if(!event.getPlayer().getGameMode().equals(GameMode.CREATIVE)){ event.getItem().setType(Material.BUCKET); } diff --git a/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java b/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java index 2dd109eb..ac22f427 100644 --- a/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java +++ b/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.tasks; +import com.songoda.core.compatibility.CompatibleSound; import com.songoda.core.utils.TextUtils; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; @@ -80,11 +81,7 @@ public class MobNetherWaterTask extends BukkitRunnable { private void removeWater(World world, Block block) { if (block.getType().equals(Material.WATER)) { block.setType(Material.AIR, true); - if(NMSUtil.getVersionNumber() > 8){ - world.playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f); - } else { - // TODO Find a sound for 1.8 - } + block.getWorld().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1f, 1f); world.playEffect(block.getLocation(), Effect.SMOKE, 1); } } From a186206d0098e0b8c8b5d88daf38367bc5fb585d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 01:58:57 +0200 Subject: [PATCH 08/33] Changed Explosion setting to Island and fixed explosion and mobgrief settings --- .../songoda/skyblock/listeners/Entity.java | 34 +++++++-- .../listening/ExplosionsPermission.java | 72 ++++++++++++++----- .../listening/MobGriefingPermission.java | 62 ++++++++++++---- 3 files changed, 131 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Entity.java b/src/main/java/com/songoda/skyblock/listeners/Entity.java index 14d8e7b0..6d1d768f 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Entity.java +++ b/src/main/java/com/songoda/skyblock/listeners/Entity.java @@ -27,6 +27,8 @@ import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.hanging.HangingPlaceEvent; import org.bukkit.event.player.PlayerArmorStandManipulateEvent; import org.bukkit.event.player.PlayerShearEntityEvent; +import org.bukkit.event.vehicle.VehicleDamageEvent; +import org.bukkit.event.vehicle.VehicleDestroyEvent; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; @@ -109,7 +111,7 @@ public class Entity implements Listener { skyblock.getPermissionManager() .processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation())); - } else if (event.getDamager() instanceof TNTPrimed) { + } else { // Make it work with all the entities, not just TNT org.bukkit.entity.Entity entity = event.getEntity(); // Check permissions. @@ -217,6 +219,7 @@ public class Entity implements Listener { @EventHandler public void onHangingBreak(HangingBreakEvent event) { Hanging hanging = event.getEntity(); + if (!skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) return; IslandManager islandManager = skyblock.getIslandManager(); @@ -229,14 +232,15 @@ public class Entity implements Listener { public void onHangingBreak(HangingBreakByEntityEvent event) { Hanging hanging = event.getEntity(); - if (!(event.getRemover() instanceof Player)) - return; - if (!skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) return; IslandManager islandManager = skyblock.getIslandManager(); + Player p = null; + if(event.getRemover() instanceof Player){ + p = (Player) event.getRemover(); + } // Check permissions. - skyblock.getPermissionManager().processPermission(event, (Player) event.getRemover(), + skyblock.getPermissionManager().processPermission(event, p, islandManager.getIslandAtLocation(hanging.getLocation())); } @@ -322,9 +326,11 @@ public class Entity implements Listener { event.setCancelled(true); return; } + // Check permissions. skyblock.getPermissionManager().processPermission(event, null, island); + if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Block.Level.Enable")) return; @@ -373,10 +379,10 @@ public class Entity implements Listener { if (skyblock.getWorldManager().isIslandWorld(entity.getWorld())) { // Check permissions. Island island = islandManager.getIslandAtLocation(entity.getLocation()); + skyblock.getPermissionManager().processPermission(event, null, island); if (!event.isCancelled()) { - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Block.Level.Enable")) { for (org.bukkit.block.Block blockList : event.blockList()) { @@ -563,6 +569,22 @@ public class Entity implements Listener { event.setCancelled(true); // For other plugin API reasons. } + @EventHandler + public void onDamageVehicle(VehicleDamageEvent event) { + if (!(event.getAttacker() instanceof Player)) { + IslandManager islandManager = skyblock.getIslandManager(); + skyblock.getPermissionManager().processPermission(event, null, islandManager.getIslandAtLocation(event.getVehicle().getLocation())); + } + } + + @EventHandler + public void onDestroyVehicle(VehicleDestroyEvent event) { + if (!(event.getAttacker() instanceof Player)) { + IslandManager islandManager = skyblock.getIslandManager(); + skyblock.getPermissionManager().processPermission(event, null, islandManager.getIslandAtLocation(event.getVehicle().getLocation())); + } + } + private static SpawnReason getSpawnReason(String reason) { try { return SpawnReason.valueOf(reason); diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ExplosionsPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ExplosionsPermission.java index 0063e60a..210c91f2 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ExplosionsPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ExplosionsPermission.java @@ -1,53 +1,89 @@ package com.songoda.skyblock.permission.permissions.listening; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; +import org.bukkit.Bukkit; +import org.bukkit.entity.Creeper; import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.entity.minecart.ExplosiveMinecart; +import org.bukkit.event.block.BlockExplodeEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.vehicle.VehicleDamageEvent; +import org.bukkit.event.vehicle.VehicleDestroyEvent; public class ExplosionsPermission extends ListeningPermission { private SkyBlock plugin; public ExplosionsPermission(SkyBlock plugin) { - super("Explosions", CompatibleMaterial.GUNPOWDER, PermissionType.GENERIC); + super("Explosions", CompatibleMaterial.GUNPOWDER, PermissionType.ISLAND); this.plugin = plugin; } @PermissionHandler - public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { - Entity entity = event.getEntity(); + public void onBlockExplode(BlockExplodeEvent event) { + event.setCancelled(true); + } - if (event.getDamager() instanceof TNTPrimed) + @PermissionHandler + public void onEntityExplode(EntityExplodeEvent event) { + event.setCancelled(true); + } + + @PermissionHandler + public void onVehicleDamage(VehicleDamageEvent event) { + if (event.getAttacker() instanceof TNTPrimed + || event.getAttacker() instanceof ExplosiveMinecart + || event.getAttacker() instanceof Creeper) event.setCancelled(true); - if (entity.getType() == EntityType.PLAYER - && event.getDamager() instanceof TNTPrimed) + } + + @PermissionHandler + public void onVehicleDestroy(VehicleDestroyEvent event) { + if (event.getAttacker() instanceof TNTPrimed + || event.getAttacker() instanceof ExplosiveMinecart + || event.getAttacker() instanceof Creeper) + event.setCancelled(true); + } + + @PermissionHandler + public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { + if (event.getCause().equals(EntityDamageEvent.DamageCause.ENTITY_EXPLOSION) + || event.getCause().equals(EntityDamageEvent.DamageCause.BLOCK_EXPLOSION) + || event.getDamager() instanceof TNTPrimed + || event.getDamager() instanceof ExplosiveMinecart + || event.getDamager() instanceof Creeper) event.setCancelled(true); } @PermissionHandler public void onHangingBreak(HangingBreakEvent event) { - if (event.getCause() != HangingBreakEvent.RemoveCause.EXPLOSION) - return; - - event.setCancelled(true); + if (event.getCause().equals(HangingBreakEvent.RemoveCause.EXPLOSION)) { + event.setCancelled(true); + } } @PermissionHandler - public void onBlockInteract(PlayerInteractEvent event) { - if (CompatibleMaterial.getMaterial(event.getPlayer().getItemInHand()) != CompatibleMaterial.FLINT_AND_STEEL) - return; + public void onHangingBreak(HangingBreakByEntityEvent event) { + if(event.getCause().equals(HangingBreakEvent.RemoveCause.EXPLOSION)){ + event.setCancelled(true); + } + } - CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock()); - if (material == CompatibleMaterial.TNT) + @PermissionHandler + public void onTNTInteract(PlayerInteractEvent event) { + if(event.getItem().getType().equals(CompatibleMaterial.FLINT_AND_STEEL.getMaterial()) + && event.getClickedBlock().getType().equals(CompatibleMaterial.TNT.getBlockMaterial())){ cancelAndMessage(event, event.getPlayer(), plugin, plugin.getMessageManager()); + } } } diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java index d411e012..f5a5e1bf 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java @@ -2,43 +2,79 @@ package com.songoda.skyblock.permission.permissions.listening; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; -import org.bukkit.entity.*; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.entity.minecart.ExplosiveMinecart; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.vehicle.VehicleDamageEvent; import org.bukkit.event.vehicle.VehicleDestroyEvent; public class MobGriefingPermission extends ListeningPermission { private final SkyBlock plugin; - private final MessageManager messageManager; public MobGriefingPermission(SkyBlock plugin) { super("MobGriefing", CompatibleMaterial.IRON_SHOVEL, PermissionType.ISLAND); this.plugin = plugin; - this.messageManager = plugin.getMessageManager(); + } + + @PermissionHandler + public void onEntityExplode(EntityExplodeEvent event) { + if (!(event.getEntity() instanceof Player) + && (!(event.getEntity() instanceof org.bukkit.entity.Projectile) + || !(((org.bukkit.entity.Projectile) event.getEntity()).getShooter() instanceof Player)) + && !(event.getEntity() instanceof TNTPrimed) + && !(event.getEntity() instanceof ExplosiveMinecart)) { + event.setCancelled(true); + } } @PermissionHandler public void onVehicleDamage(VehicleDamageEvent event) { - - - Player player = (Player) event.getAttacker(); - cancelAndMessage(event, player, plugin, messageManager); + if (!(event.getAttacker() instanceof Player) + && (!(event.getAttacker() instanceof org.bukkit.entity.Projectile) + || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) + && !(event.getAttacker() instanceof TNTPrimed) + && !(event.getAttacker() instanceof ExplosiveMinecart)) { + event.setCancelled(true); + } } @PermissionHandler public void onVehicleDestroy(VehicleDestroyEvent event) { - - - Player player = (Player) event.getAttacker(); - cancelAndMessage(event, player, plugin, messageManager); + if (!(event.getAttacker() instanceof Player) + && (!(event.getAttacker() instanceof org.bukkit.entity.Projectile) + || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) + && !(event.getAttacker() instanceof TNTPrimed) + && !(event.getAttacker() instanceof ExplosiveMinecart)) { + event.setCancelled(true); + } } @PermissionHandler + public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { + if (!(event.getDamager() instanceof Player) + && (!(event.getDamager() instanceof org.bukkit.entity.Projectile) + || !(((org.bukkit.entity.Projectile) event.getDamager()).getShooter() instanceof Player)) + && !(event.getDamager() instanceof TNTPrimed) + && !(event.getDamager() instanceof ExplosiveMinecart)) { + event.setCancelled(true); + } + } + + @PermissionHandler + public void onHangingBreak(HangingBreakByEntityEvent event) { + if(!(event.getRemover() instanceof Player)){ + event.setCancelled(true); + } + } + + /*@PermissionHandler // TODO ? - Fabrimat public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { Entity entity = event.getEntity(); EntityType type = event.getEntityType(); @@ -53,6 +89,6 @@ public class MobGriefingPermission extends ListeningPermission { else return; cancelAndMessage(event, player, plugin, messageManager); - } + }*/ } From 908bc3d276e12e49a9fbde423d0858821b3a2412 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 02:00:06 +0200 Subject: [PATCH 09/33] LaborPatch 0.0.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 914a3eb3..18ca4379 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.2.16-LaborPatch-0.0.3 + 2.2.16-LaborPatch-0.0.4 jar clean install From ab0b6c664126367cf14a79edf4c5ddaa44cda368 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 04:28:36 +0200 Subject: [PATCH 10/33] Fixed unloadEvent called async --- src/main/java/com/songoda/skyblock/island/IslandManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 58c342a4..1d2ab86c 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -895,7 +895,9 @@ public class IslandManager { islandStorage.remove(island.getOwnerUUID()); - Bukkit.getServer().getPluginManager().callEvent(new IslandUnloadEvent(island.getAPIWrapper())); + Bukkit.getScheduler().runTask(skyblock, () -> { + Bukkit.getServer().getPluginManager().callEvent(new IslandUnloadEvent(island.getAPIWrapper())); + }); } public void prepareIsland(Island island, IslandWorld world) { From d0e194518335e16ff30d67366aa1cad1f8534b1e Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 04:29:07 +0200 Subject: [PATCH 11/33] Hotfix for a nullPointerException in getString() --- .../songoda/skyblock/command/commands/island/AcceptCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java index 9a74c1fd..11b4c2c7 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java @@ -170,7 +170,7 @@ public class AcceptCommand extends SubCommand { if (scoreboardManager != null) { Scoreboard scoreboard = scoreboardManager.getScoreboard(player); scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Scoreboard.Island.Team.Displayname"))); + configLoad.getString("Scoreboard.Island.Team.Displayname", ""))); if (islandManager.getVisitorsAtIsland(island).size() == 0) { scoreboard.setDisplayList( From 9610943e1b285a332879b387999f5a11a3e1456c Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 04:29:20 +0200 Subject: [PATCH 12/33] Kick and ban bypass --- .../skyblock/command/commands/island/BanCommand.java | 3 +++ .../skyblock/command/commands/island/KickCommand.java | 9 +++++---- src/main/resources/language.yml | 4 ++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/BanCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/BanCommand.java index 0ff09f8e..b27df88d 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/BanCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/BanCommand.java @@ -63,6 +63,9 @@ public class BanCommand extends SubCommand { if (targetPlayerUUID == null) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Found.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + } else if((targetPlayer.hasPermission("fabledskyblock.bypass.ban") || targetPlayer.isOp())){ + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Exempt")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else if (targetPlayerUUID.equals(player.getUniqueId())) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Yourself.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/KickCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/KickCommand.java index 53976a39..cc83190a 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/KickCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/KickCommand.java @@ -73,9 +73,8 @@ public class KickCommand extends SubCommand { } assert targetPlayer != null; - if(targetPlayer.hasPermission("fabledskyblock.bypass.kick") && islandVisitors.contains(targetPlayer.getUniqueId())){ - // messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Exempt")); // TODO - messageManager.sendMessage(player, "&cNon puoi cacciare questo utente!"); + if((targetPlayer.hasPermission("fabledskyblock.bypass.kick") || targetPlayer.isOp()) && islandVisitors.contains(targetPlayer.getUniqueId())){ + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Exempt")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else if (targetPlayerUUID.equals(player.getUniqueId())) { messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Yourself.Message")); @@ -143,7 +142,9 @@ public class KickCommand extends SubCommand { languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Target.Message").replace("%player", player.getName())); soundManager.playSound(targetPlayer, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F); - if (islandManager.isPlayerAtIsland(island, targetPlayer)) { + if (islandManager.isPlayerAtIsland(island, targetPlayer) + && !targetPlayer.hasPermission("fabledskyblock.bypass.kick") + && !targetPlayer.isOp()) { LocationUtil.teleportPlayerToSpawn(targetPlayer); } diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index d4f45456..58f0d6a9 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -433,6 +433,8 @@ Command: Permission: Message: '&bSkyBlock &8| &cError&8: &eYou do not have the right to delete your Island.' Kick: + Bypass: + Message: '&bSkyBlock &8| &cError&8: &cYou can''t kick this user!' Invalid: Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island kick ' Role: @@ -766,6 +768,8 @@ Command: Message: '&bSkyBlock &8| &aInfo&8: &eYou have banned the player &c%player &efrom the Island.' Target: Message: '&bSkyBlock &8| &aInfo&8: &eYou have been banned from the Island.' + Bypass: + Message: '&bSkyBlock &8| &cError&8: &cYou can''t ban this user!' Already: Message: '&bSkyBlock &8| &cError&8: &eThat player is already banned from the Island.' Owner: From 652a53010cc73a63f9e27913320cdb2ebb2fa2f2 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 04:29:49 +0200 Subject: [PATCH 13/33] Fix for bank that couldnt be opened from the members --- src/main/java/com/songoda/skyblock/bank/BankManager.java | 4 ++-- src/main/java/com/songoda/skyblock/menus/Bank.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/bank/BankManager.java b/src/main/java/com/songoda/skyblock/bank/BankManager.java index 2233bef2..95693e7a 100644 --- a/src/main/java/com/songoda/skyblock/bank/BankManager.java +++ b/src/main/java/com/songoda/skyblock/bank/BankManager.java @@ -67,11 +67,11 @@ public class BankManager { public List getBalanceLore(Player player) { List result = new ArrayList<>(); result.add("Some error occurred while loading your balance!"); - Island island = SkyBlock.getInstance().getIslandManager().getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId())); + Island island = SkyBlock.getInstance().getIslandManager().getIsland(player); result.add("If this is null then its a easy to fix bug: "+island.toString()); if (island != null) { result.clear(); - result.add(player.getDisplayName()+"'s balance is "+EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(player.getUniqueId())))); + result.add(player.getDisplayName()+"'s balance is "+EconomyManager.formatEconomy(EconomyManager.getBalance(player))); result.add(player.getDisplayName()+"'s island has "+EconomyManager.formatEconomy(island.getBankBalance())); } return result; diff --git a/src/main/java/com/songoda/skyblock/menus/Bank.java b/src/main/java/com/songoda/skyblock/menus/Bank.java index a85d37ce..e21461cb 100644 --- a/src/main/java/com/songoda/skyblock/menus/Bank.java +++ b/src/main/java/com/songoda/skyblock/menus/Bank.java @@ -141,7 +141,7 @@ public class Bank { public void open(Player player) { Island island; - island = islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId())); + island = islandManager.getIsland(player); SkyBlock skyblock = SkyBlock.getInstance(); From 1055f755d8386dbabd333ab2060daa207af34f5d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 15:10:33 +0200 Subject: [PATCH 14/33] Working hotfix for 1.8 island disappear --- .../com/songoda/skyblock/listeners/Move.java | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java index cf8929bd..0909bee8 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Move.java +++ b/src/main/java/com/songoda/skyblock/listeners/Move.java @@ -230,23 +230,20 @@ public class Move implements Listener { } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onTeleport(PlayerTeleportEvent e) { - + public void onTeleport(PlayerTeleportEvent e) { // TODO We should wait for the player island to be loaded in 1.8.8 - Fabrimat final Player player = e.getPlayer(); final WorldManager worldManager = skyblock.getWorldManager(); - - if (e.getTo() == null || - !worldManager.isIslandWorld(e.getTo().getWorld()) || - skyblock.getIslandManager().getIslandAtLocation(e.getTo()) != null) - return; - - e.setCancelled(true); - - Bukkit.getScheduler().runTaskLater(skyblock, () -> { - if (e.getTo() != null && worldManager.isIslandWorld(e.getTo().getWorld()) && skyblock.getIslandManager().getIslandAtLocation(e.getTo()) == null) - skyblock.getMessageManager().sendMessage(player, - skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message")); - skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); - }, 10L); // 2 ticks are good, 10 because we don't know the cause yet + if(e.getTo() != null && e.getTo().getWorld() != null){ + e.getTo().getWorld().loadChunk(e.getTo().getChunk()); + if(worldManager.isIslandWorld(e.getTo().getWorld()) && e.getTo().distance(e.getFrom()) > 1.0d){ // We should not care of self block tp + if(skyblock.getIslandManager().getIslandAtLocation(e.getTo()) == null){ + e.setCancelled(true); + skyblock.getMessageManager().sendMessage(player, + skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + .getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message")); + skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); + } + } + } } } From 466b5ae8c6054187d138595856d0da225b019b38 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 15:10:56 +0200 Subject: [PATCH 15/33] Fix for NullPointer in permissions --- .../com/songoda/skyblock/permission/ListeningPermission.java | 2 +- src/main/resources/language.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java b/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java index 5da4b583..f7029d1c 100644 --- a/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java @@ -83,7 +83,7 @@ public abstract class ListeningPermission extends BasicPermission { protected void noPermsMessage(Player player, SkyBlock plugin, MessageManager messageManager) { messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) - .getFileConfiguration().getString("Island.Settings.Permission.Message")); + .getFileConfiguration().getString("Island.Permission.Message")); CompatibleSound.ENTITY_VILLAGER_NO.play(player); } diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 58f0d6a9..3f28b5c5 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -8,6 +8,8 @@ ClassLocalization: Owner: 'Owner' Command: Island: + Permission: + Message: '&bSkyBlock &8| &cError&8: &eYou don''t have the permission to to this.' Bans: Owner: Message: '&bSkyBlock &8| &cError&8: &eYou are not an Island Owner.' From d63b232453748ac1f9a7a4d306eed38648ed4bd6 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 15:11:17 +0200 Subject: [PATCH 16/33] Removed useless = null --- .../skyblock/command/commands/island/TeleportCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/TeleportCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/TeleportCommand.java index 89479fc1..727d37d1 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/TeleportCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/TeleportCommand.java @@ -40,7 +40,7 @@ public class TeleportCommand extends SubCommand { if (args.length == 1) { Player targetPlayer = Bukkit.getServer().getPlayer(args[0]); - UUID islandOwnerUUID = null; + UUID islandOwnerUUID; String targetPlayerName; if (targetPlayer == null) { From 30857c8a1246d4b97fafa342671fd79c20de4372 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 15:11:47 +0200 Subject: [PATCH 17/33] Updated Safe Location to 1.8.8 --- .../skyblock/utils/world/LocationUtil.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java index 04a3fc7f..cf961fd2 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java @@ -64,7 +64,7 @@ public final class LocationUtil { Location locWorking = loc.clone(); for(int i=locWorking.getBlockY(); i>=0; i--){ if(!locWorking.getBlock().isEmpty()){ - if(locWorking.getBlock().getType().equals(Material.WATER) || + if(locWorking.getBlock().getType().equals(CompatibleMaterial.WATER.getMaterial()) || (NMSUtil.getVersionNumber() > 13 && locWorking.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){ loc = locWorking; } @@ -80,11 +80,11 @@ public final class LocationUtil { !locChecked.getBlock().isLiquid() && locChecked.getBlock().getType().isSolid() && locChecked.getBlock().getType().isBlock() && - locChecked.add(0d,1d,0d).getBlock().getType().equals(Material.AIR) && - locChecked.add(0d,2d,0d).getBlock().getType().equals(Material.AIR) && - !(NMSUtil.getVersionNumber() <= 13 || locChecked.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){ + locChecked.add(0d,1d,0d).getBlock().getType().equals(CompatibleMaterial.AIR.getMaterial()) && + locChecked.add(0d,2d,0d).getBlock().getType().equals(CompatibleMaterial.AIR.getMaterial()) && + !(NMSUtil.getVersionNumber() >= 13 && locChecked.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){ safe = true; - switch(locChecked.getBlock().getType()){ + switch(CompatibleMaterial.getMaterial(locChecked.getBlock())){ case ACACIA_DOOR: // <= 1.8.8 case ACACIA_FENCE_GATE: case BIRCH_DOOR: @@ -99,17 +99,17 @@ public final class LocationUtil { case LADDER: case SPRUCE_DOOR: case SPRUCE_FENCE_GATE: - case ACACIA_BUTTON: // TODO check server version - case ACACIA_TRAPDOOR: // TODO check server version - case BIRCH_TRAPDOOR: // TODO check server version - case CAMPFIRE: // TODO check server version - case COBWEB: // TODO check server version - case DARK_OAK_TRAPDOOR: // TODO check server version - case JUNGLE_TRAPDOOR: // TODO check server version - case MAGMA_BLOCK: // TODO check server version - case NETHER_PORTAL: // TODO check server version - case OAK_DOOR: // TODO check server version - case OAK_FENCE_GATE: // TODO check server version + case ACACIA_BUTTON: + case ACACIA_TRAPDOOR: + case BIRCH_TRAPDOOR: + case CAMPFIRE: + case COBWEB: + case DARK_OAK_TRAPDOOR: + case JUNGLE_TRAPDOOR: + case MAGMA_BLOCK: + case NETHER_PORTAL: + case OAK_DOOR: + case OAK_FENCE_GATE: safe = false; break; } From 08b3cbdb33ee7084d3f347347e36682e3197290d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 15:12:02 +0200 Subject: [PATCH 18/33] Removed RequireNonNull --- src/main/java/com/songoda/skyblock/island/IslandManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 1d2ab86c..0db97ead 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -1085,8 +1085,8 @@ public class IslandManager { } } else { player.sendMessage(ChatColor.translateAlternateColorCodes('&', - Objects.requireNonNull(skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) - .getFileConfiguration().getString("Island.Teleport.Unsafe.Message")))); + skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + .getFileConfiguration().getString("Island.Teleport.Unsafe.Message"))); } } else { if (scoreboardManager != null) { From 2eb0864c0f79d5f8454febbce787bad2906e3196 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 15:24:36 +0200 Subject: [PATCH 19/33] Fixed NullPointer in admin level menu --- .../songoda/skyblock/menus/admin/Levelling.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java b/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java index faae29c9..9da25588 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java @@ -178,6 +178,7 @@ public class Levelling implements Listener { } if (inventoryName.equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Levelling.Title")))) { + event.setCancelled(true); PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); if (!(player.hasPermission("fabledskyblock.admin.level") || player.hasPermission("fabledskyblock.admin.*") @@ -185,7 +186,6 @@ public class Levelling implements Listener { messageManager.sendMessage(player, configLoad.getString("Island.Admin.Levelling.Permission.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - event.setCancelled(true); return; } @@ -193,7 +193,6 @@ public class Levelling implements Listener { && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Levelling.Item.Barrier.Displayname"))))) { - event.setCancelled(true); soundManager.playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F); return; @@ -201,7 +200,6 @@ public class Levelling implements Listener { && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Levelling.Item.Exit.Displayname"))))) { - event.setCancelled(true); soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1.0F, 1.0F); player.closeInventory(); @@ -209,7 +207,6 @@ public class Levelling implements Listener { } else if ((event.getCurrentItem().getType() == CompatibleMaterial.OAK_SIGN.getMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Levelling.Item.Information.Displayname"))))) { - event.setCancelled(true); soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { @@ -271,7 +268,6 @@ public class Levelling implements Listener { } else if ((event.getCurrentItem().getType() == Material.BARRIER) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Levelling.Item.Nothing.Displayname"))))) { - event.setCancelled(true); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); return; @@ -279,7 +275,6 @@ public class Levelling implements Listener { && (is.hasItemMeta())) { if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Levelling.Item.Previous.Displayname")))) { - event.setCancelled(true); player.closeInventory(); playerData.setPage(playerData.getPage() - 1); @@ -290,7 +285,6 @@ public class Levelling implements Listener { return; } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Levelling.Item.Next.Displayname")))) { - event.setCancelled(true); player.closeInventory(); playerData.setPage(playerData.getPage() + 1); @@ -306,9 +300,9 @@ public class Levelling implements Listener { for (LevellingMaterial materialList : levellingManager.getWorthsAsLevelingMaterials()) { CompatibleMaterial materials = materialList.getMaterials(); - if (event.getCurrentItem().getType() == CompatibleMaterial.getMaterial(materials.getMaterial()).getMaterial() + if (CompatibleMaterial.getMaterial(materials.getMaterial()) != null + && event.getCurrentItem().getType().equals(CompatibleMaterial.getMaterial(materials.getMaterial()).getMaterial()) && ChatColor.stripColor(is.getItemMeta().getDisplayName()).equals(materials.name())) { - event.setCancelled(true); if (event.getClick() == ClickType.LEFT) { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); @@ -411,8 +405,6 @@ public class Levelling implements Listener { } } - event.setCancelled(true); - CompatibleMaterial materials = CompatibleMaterial.getMaterial(event.getCurrentItem().getType()); if (NMSUtil.getVersionNumber() < 13) { From 3467b0d5bb375f28ed064eff57f20c45cbf5e02c Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 15:49:35 +0200 Subject: [PATCH 20/33] Reworked menu pages logic, now every menu has its own page --- .../java/com/songoda/skyblock/menus/Bans.java | 6 ++--- .../java/com/songoda/skyblock/menus/Coop.java | 6 ++--- .../songoda/skyblock/menus/Information.java | 12 ++++----- .../com/songoda/skyblock/menus/Levelling.java | 6 ++--- .../com/songoda/skyblock/menus/Members.java | 6 ++--- .../com/songoda/skyblock/menus/MenuType.java | 14 +++++++++++ .../com/songoda/skyblock/menus/Visit.java | 6 ++--- .../com/songoda/skyblock/menus/Visitors.java | 6 ++--- .../songoda/skyblock/menus/admin/Creator.java | 3 ++- .../skyblock/menus/admin/Generator.java | 7 +++--- .../skyblock/menus/admin/Levelling.java | 7 +++--- .../songoda/skyblock/playerdata/MenuPage.java | 25 +++++++++++++++++++ .../skyblock/playerdata/PlayerData.java | 25 ++++++++++++++----- 13 files changed, 92 insertions(+), 37 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/menus/MenuType.java create mode 100644 src/main/java/com/songoda/skyblock/playerdata/MenuPage.java diff --git a/src/main/java/com/songoda/skyblock/menus/Bans.java b/src/main/java/com/songoda/skyblock/menus/Bans.java index 03df6a45..e82d1019 100644 --- a/src/main/java/com/songoda/skyblock/menus/Bans.java +++ b/src/main/java/com/songoda/skyblock/menus/Bans.java @@ -128,13 +128,13 @@ public class Bans { } else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) { if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Item.Previous.Displayname")))) { - playerData1.setPage(playerData1.getPage() - 1); + playerData1.setPage(MenuType.BANS, playerData1.getPage(MenuType.BANS) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes( '&', configLoad.getString("Menu.Bans.Item.Next.Displayname")))) { - playerData1.setPage(playerData1.getPage() + 1); + playerData1.setPage(MenuType.BANS, playerData1.getPage(MenuType.BANS) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); @@ -173,7 +173,7 @@ public class Bans { configLoad.getString("Menu.Bans.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17); - int playerMenuPage = playerData.getPage(), nextEndIndex = islandBans.size() - playerMenuPage * 36; + int playerMenuPage = playerData.getPage(MenuType.BANS), nextEndIndex = islandBans.size() - playerMenuPage * 36; if (playerMenuPage != 1) { nInv.addItem(nInv.createItem(SkullUtil.create( diff --git a/src/main/java/com/songoda/skyblock/menus/Coop.java b/src/main/java/com/songoda/skyblock/menus/Coop.java index 488818a1..732d2879 100644 --- a/src/main/java/com/songoda/skyblock/menus/Coop.java +++ b/src/main/java/com/songoda/skyblock/menus/Coop.java @@ -151,13 +151,13 @@ public class Coop { } else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) { if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Coop.Item.Previous.Displayname")))) { - playerData.setPage(playerData.getPage() - 1); + playerData.setPage(MenuType.COOP, playerData.getPage(MenuType.COOP) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes( '&', configLoad.getString("Menu.Coop.Item.Next.Displayname")))) { - playerData.setPage(playerData.getPage() + 1); + playerData.setPage(MenuType.COOP, playerData.getPage(MenuType.COOP) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); @@ -194,7 +194,7 @@ public class Coop { Map coopPlayers = island.getCoopPlayers(); - int playerMenuPage = playerData.getPage(), nextEndIndex = coopPlayers.size() - playerMenuPage * 36; + int playerMenuPage = playerData.getPage(MenuType.COOP), nextEndIndex = coopPlayers.size() - playerMenuPage * 36; nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), configLoad.getString("Menu.Coop.Item.Exit.Displayname"), null, null, null, null), 0, 8); diff --git a/src/main/java/com/songoda/skyblock/menus/Information.java b/src/main/java/com/songoda/skyblock/menus/Information.java index 50044f23..d28067f3 100644 --- a/src/main/java/com/songoda/skyblock/menus/Information.java +++ b/src/main/java/com/songoda/skyblock/menus/Information.java @@ -303,7 +303,7 @@ public class Information { if (is.getItemMeta().getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString( "Menu.Information.Members.Item.Previous.Displayname")))) { - playerData1.setPage(playerData1.getPage() - 1); + playerData1.setPage(MenuType.INFORMATION, playerData1.getPage(MenuType.INFORMATION) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, @@ -311,7 +311,7 @@ public class Information { } else if (is.getItemMeta().getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad .getString("Menu.Information.Members.Item.Next.Displayname")))) { - playerData1.setPage(playerData1.getPage() + 1); + playerData1.setPage(MenuType.INFORMATION, playerData1.getPage(MenuType.INFORMATION) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, @@ -358,7 +358,7 @@ public class Information { configLoad.getString("Menu.Information.Members.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17); - int playerMenuPage = playerData.getPage(), + int playerMenuPage = playerData.getPage(MenuType.INFORMATION), nextEndIndex = displayedMembers.size() - playerMenuPage * 36; if (playerMenuPage != 1) { @@ -464,7 +464,7 @@ public class Information { if (is.getItemMeta().getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString( "Menu.Information.Visitors.Item.Previous.Displayname")))) { - playerData12.setPage(playerData12.getPage() - 1); + playerData12.setPage(MenuType.INFORMATION, playerData12.getPage(MenuType.INFORMATION) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, @@ -472,7 +472,7 @@ public class Information { } else if (is.getItemMeta().getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad .getString("Menu.Information.Visitors.Item.Next.Displayname")))) { - playerData12.setPage(playerData12.getPage() + 1); + playerData12.setPage(MenuType.INFORMATION, playerData12.getPage(MenuType.INFORMATION) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, @@ -503,7 +503,7 @@ public class Information { configLoad.getString("Menu.Information.Visitors.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17); - int playerMenuPage = playerData.getPage(), + int playerMenuPage = playerData.getPage(MenuType.INFORMATION), nextEndIndex = displayedVisitors.size() - playerMenuPage * 36; if (playerMenuPage != 1) { diff --git a/src/main/java/com/songoda/skyblock/menus/Levelling.java b/src/main/java/com/songoda/skyblock/menus/Levelling.java index 23161957..b01250e3 100644 --- a/src/main/java/com/songoda/skyblock/menus/Levelling.java +++ b/src/main/java/com/songoda/skyblock/menus/Levelling.java @@ -146,12 +146,12 @@ public class Levelling { PlayerData playerData1 = skyblock.getPlayerDataManager().getPlayerData(player); if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Previous.Displayname")))) { - playerData1.setPage(playerData1.getPage() - 1); + playerData1.setPage(MenuType.LEVELLING, playerData1.getPage(MenuType.LEVELLING) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Next.Displayname")))) { - playerData1.setPage(playerData1.getPage() + 1); + playerData1.setPage(MenuType.LEVELLING, playerData1.getPage(MenuType.LEVELLING) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); @@ -208,7 +208,7 @@ public class Levelling { } } - int playerMenuPage = playerData.getPage(), nextEndIndex = islandMaterials.size() - playerMenuPage * 36; + int playerMenuPage = playerData.getPage(MenuType.LEVELLING), nextEndIndex = islandMaterials.size() - playerMenuPage * 36; nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), configLoad.getString("Menu.Levelling.Item.Exit.Displayname"), null, null, null, null), 0, 8); nInv.addItem(nInv.createItem(CompatibleMaterial.FIREWORK_STAR.getItem(), configLoad.getString("Menu.Levelling.Item.Rescan.Displayname"), configLoad.getStringList("Menu.Levelling.Item.Rescan.Lore"), null, null, diff --git a/src/main/java/com/songoda/skyblock/menus/Members.java b/src/main/java/com/songoda/skyblock/menus/Members.java index db6de9e4..5e92ee3f 100644 --- a/src/main/java/com/songoda/skyblock/menus/Members.java +++ b/src/main/java/com/songoda/skyblock/menus/Members.java @@ -130,14 +130,14 @@ public class Members { } else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) { if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Item.Previous.Displayname")))) { - playerData.setPage(playerData.getPage() - 1); + playerData.setPage(MenuType.MEMBERS, playerData.getPage(MenuType.MEMBERS) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L); } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes( '&', configLoad.getString("Menu.Members.Item.Next.Displayname")))) { - playerData.setPage(playerData.getPage() + 1); + playerData.setPage(MenuType.MEMBERS, playerData.getPage(MenuType.MEMBERS) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(), @@ -319,7 +319,7 @@ public class Members { } } - int playerMenuPage = playerData.getPage(), nextEndIndex = displayedMembers.size() - playerMenuPage * 36; + int playerMenuPage = playerData.getPage(MenuType.MEMBERS), nextEndIndex = displayedMembers.size() - playerMenuPage * 36; nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), configLoad.getString("Menu.Members.Item.Exit.Displayname"), null, null, null, null), 0, 8); diff --git a/src/main/java/com/songoda/skyblock/menus/MenuType.java b/src/main/java/com/songoda/skyblock/menus/MenuType.java new file mode 100644 index 00000000..730e7b1c --- /dev/null +++ b/src/main/java/com/songoda/skyblock/menus/MenuType.java @@ -0,0 +1,14 @@ +package com.songoda.skyblock.menus; + +public enum MenuType { + ADMIN_LEVELLING, + ADMIN_CREATOR, + ADMIN_GENERATOR, + INFORMATION, + COOP, + LEVELLING, + MEMBERS, + BANS, + VISIT, + VISITORS +} diff --git a/src/main/java/com/songoda/skyblock/menus/Visit.java b/src/main/java/com/songoda/skyblock/menus/Visit.java index 41ebd2ee..c8b30301 100644 --- a/src/main/java/com/songoda/skyblock/menus/Visit.java +++ b/src/main/java/com/songoda/skyblock/menus/Visit.java @@ -120,13 +120,13 @@ public class Visit { } else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) { if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Item.Previous.Displayname")))) { - playerData.setPage(playerData.getPage() - 1); + playerData.setPage(MenuType.VISIT, playerData.getPage(MenuType.VISIT) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L); } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Item.Next.Displayname")))) { - playerData.setPage(playerData.getPage() + 1); + playerData.setPage(MenuType.VISIT, playerData.getPage(MenuType.VISIT) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L); @@ -330,7 +330,7 @@ public class Visit { }); } - int playerMenuPage = playerDataManager.getPlayerData(player).getPage(), + int playerMenuPage = playerDataManager.getPlayerData(player).getPage(MenuType.VISIT), nextEndIndex = visitIslands.size() - playerMenuPage * 36, totalIslands = visitManager.getIslands().size(); diff --git a/src/main/java/com/songoda/skyblock/menus/Visitors.java b/src/main/java/com/songoda/skyblock/menus/Visitors.java index 5e0ffc0d..135734e7 100644 --- a/src/main/java/com/songoda/skyblock/menus/Visitors.java +++ b/src/main/java/com/songoda/skyblock/menus/Visitors.java @@ -95,13 +95,13 @@ public class Visitors { } else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) { if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Item.Previous.Displayname")))) { - playerData.setPage(playerData.getPage() - 1); + playerData.setPage(MenuType.VISITORS, playerData.getPage(MenuType.VISITORS) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes( '&', configLoad.getString("Menu.Visitors.Item.Next.Displayname")))) { - playerData.setPage(playerData.getPage() + 1); + playerData.setPage(MenuType.VISITORS, playerData.getPage(MenuType.VISITORS) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); @@ -188,7 +188,7 @@ public class Visitors { islandVisitors.add(sortedIslandVisitors.get(sortedIslandVisitorList)); } - int playerMenuPage = playerData.getPage(), nextEndIndex = sortedIslandVisitors.size() - playerMenuPage * 36; + int playerMenuPage = playerData.getPage(MenuType.VISITORS), nextEndIndex = sortedIslandVisitors.size() - playerMenuPage * 36; if (playerMenuPage != 1) { nInv.addItem(nInv.createItem(SkullUtil.create( diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Creator.java b/src/main/java/com/songoda/skyblock/menus/admin/Creator.java index ea06377c..93c456c3 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Creator.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Creator.java @@ -5,6 +5,7 @@ import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; +import com.songoda.skyblock.menus.MenuType; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.playerdata.PlayerData; @@ -75,7 +76,7 @@ public class Creator implements Listener { configLoad.getString("Menu.Admin.Creator.Browse.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17); - int playerMenuPage = playerData.getPage(), nextEndIndex = structures.size() - playerMenuPage * 36; + int playerMenuPage = playerData.getPage(MenuType.ADMIN_CREATOR), nextEndIndex = structures.size() - playerMenuPage * 36; if (playerMenuPage != 1) { nInv.addItem(nInv.createItem(SkullUtil.create( diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Generator.java b/src/main/java/com/songoda/skyblock/menus/admin/Generator.java index 7eb193c3..f8d8841d 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Generator.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Generator.java @@ -8,6 +8,7 @@ import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.generator.GeneratorManager; import com.songoda.skyblock.generator.GeneratorMaterial; import com.songoda.skyblock.island.IslandWorld; +import com.songoda.skyblock.menus.MenuType; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.playerdata.PlayerData; @@ -75,7 +76,7 @@ public class Generator implements Listener { configLoad.getString("Menu.Admin.Generator.Browse.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17); - int playerMenuPage = playerData.getPage(), nextEndIndex = generators.size() - playerMenuPage * 36; + int playerMenuPage = playerData.getPage(MenuType.ADMIN_GENERATOR), nextEndIndex = generators.size() - playerMenuPage * 36; if (playerMenuPage != 1) { nInv.addItem(nInv.createItem(SkullUtil.create( @@ -394,7 +395,7 @@ public class Generator implements Listener { && (is.hasItemMeta())) { if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Generator.Browse.Item.Previous.Displayname")))) { - playerData.setPage(playerData.getPage() - 1); + playerData.setPage(MenuType.ADMIN_GENERATOR, playerData.getPage(MenuType.ADMIN_GENERATOR) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); player.closeInventory(); @@ -404,7 +405,7 @@ public class Generator implements Listener { return; } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Generator.Browse.Item.Next.Displayname")))) { - playerData.setPage(playerData.getPage() + 1); + playerData.setPage(MenuType.ADMIN_GENERATOR, playerData.getPage(MenuType.ADMIN_GENERATOR) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); player.closeInventory(); diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java b/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java index 9da25588..dd69ea4c 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java @@ -7,6 +7,7 @@ import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.levelling.rework.IslandLevelManager; import com.songoda.skyblock.levelling.rework.LevellingMaterial; +import com.songoda.skyblock.menus.MenuType; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.playerdata.PlayerData; @@ -96,7 +97,7 @@ public class Levelling implements Listener { configLoad.getString("Menu.Admin.Levelling.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17); - int playerMenuPage = playerData.getPage(), nextEndIndex = levellingMaterials.size() - playerMenuPage * 36; + int playerMenuPage = playerData.getPage(MenuType.ADMIN_LEVELLING), nextEndIndex = levellingMaterials.size() - playerMenuPage * 36; if (playerMenuPage != 1) { nInv.addItem(nInv.createItem(SkullUtil.create( @@ -277,7 +278,7 @@ public class Levelling implements Listener { configLoad.getString("Menu.Admin.Levelling.Item.Previous.Displayname")))) { player.closeInventory(); - playerData.setPage(playerData.getPage() - 1); + playerData.setPage(MenuType.ADMIN_LEVELLING, playerData.getPage(MenuType.ADMIN_LEVELLING) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); @@ -287,7 +288,7 @@ public class Levelling implements Listener { configLoad.getString("Menu.Admin.Levelling.Item.Next.Displayname")))) { player.closeInventory(); - playerData.setPage(playerData.getPage() + 1); + playerData.setPage(MenuType.ADMIN_LEVELLING, playerData.getPage(MenuType.ADMIN_LEVELLING) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); diff --git a/src/main/java/com/songoda/skyblock/playerdata/MenuPage.java b/src/main/java/com/songoda/skyblock/playerdata/MenuPage.java new file mode 100644 index 00000000..a76b4fa2 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/playerdata/MenuPage.java @@ -0,0 +1,25 @@ +package com.songoda.skyblock.playerdata; + +import com.songoda.skyblock.menus.MenuType; + +public class MenuPage { + MenuType type; + int page; + + public MenuPage(MenuType type, int page){ + this.type = type; + this.page = page; + } + + public void setPage(int page){ + this.page = page; + } + + public MenuType getType(){ + return type; + } + + public int getPage(){ + return page; + } +} diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java index 48bd289b..d3401ac8 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java @@ -6,6 +6,7 @@ import com.songoda.skyblock.bank.Transaction; import com.songoda.skyblock.bank.Type; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.confirmation.Confirmation; +import com.songoda.skyblock.menus.MenuType; import com.songoda.skyblock.utils.structure.Area; import org.bukkit.Bukkit; @@ -22,7 +23,7 @@ public class PlayerData { private UUID islandOwnerUUID; private UUID ownershipUUID; - private int page; + private List pages; private int playTime; private int visitTime; private int confirmationTime; @@ -45,7 +46,8 @@ public class PlayerData { uuid = player.getUniqueId(); islandOwnerUUID = null; - page = 1; + pages = new ArrayList<>(); + confirmationTime = 0; playTime = getConfig().getFileConfiguration().getInt("Statistics.Island.Playtime"); @@ -67,12 +69,23 @@ public class PlayerData { } } - public int getPage() { - return page; + public int getPage(MenuType type) { + for(MenuPage menu : pages){ + if(menu.getType().equals(type)){ + return menu.getPage(); + } + } + return 1; } - public void setPage(int page) { - this.page = page; + public void setPage(MenuType type, int page) { + for(MenuPage menu : pages){ + if(menu.getType().equals(type)){ + menu.setPage(page); + return; + } + } + pages.add(new MenuPage(type, page)); } public Object getType() { From 1534c354d4debc7f377acc8ad36bb3e88d3b3641 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 15:50:08 +0200 Subject: [PATCH 21/33] LaborPatch 0.0.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 18ca4379..d359add2 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.2.16-LaborPatch-0.0.4 + 2.2.16-LaborPatch-0.0.5 jar clean install From 367c27784bc423c1ecc04e7b92c77ddc4c93f5d7 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 16:53:43 +0200 Subject: [PATCH 22/33] Definetly fixed NullPointer in permission checking --- .../songoda/skyblock/permission/ListeningPermission.java | 6 +++++- src/main/resources/language.yml | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java b/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java index f7029d1c..e9b1e03b 100644 --- a/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java @@ -81,9 +81,13 @@ public abstract class ListeningPermission extends BasicPermission { public void onBlockIgnite(BlockIgniteEvent event) {} protected void noPermsMessage(Player player, SkyBlock plugin, MessageManager messageManager) { + if(messageManager == null){ // TODO Check why this is null - Fabrimat + messageManager = SkyBlock.getInstance().getMessageManager(); + } + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) - .getFileConfiguration().getString("Island.Permission.Message")); + .getFileConfiguration().getString("Island.Settings.Permission.Message")); CompatibleSound.ENTITY_VILLAGER_NO.play(player); } diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 3f28b5c5..58f0d6a9 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -8,8 +8,6 @@ ClassLocalization: Owner: 'Owner' Command: Island: - Permission: - Message: '&bSkyBlock &8| &cError&8: &eYou don''t have the permission to to this.' Bans: Owner: Message: '&bSkyBlock &8| &cError&8: &eYou are not an Island Owner.' From 4eeef50853b2e877eb58cfc7d0d3eda82fb4311e Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 16:54:14 +0200 Subject: [PATCH 23/33] Fixed stackables bypassing island settings --- src/main/java/com/songoda/skyblock/listeners/Block.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index d1cfe72e..cb737dd9 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -68,7 +68,7 @@ public class Block implements Listener { } // Check permissions. - if (!skyblock.getPermissionManager().processPermission(event, player, island)) { + if (!skyblock.getPermissionManager().processPermission(event, player, island) || event.isCancelled()) { return; } From b1528c30a256ba66d39afbb03245fe94fd7fe915 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 19:23:15 +0200 Subject: [PATCH 24/33] Fix for distance between different worlds --- src/main/java/com/songoda/skyblock/listeners/Move.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java index 0909bee8..a8360f01 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Move.java +++ b/src/main/java/com/songoda/skyblock/listeners/Move.java @@ -235,7 +235,8 @@ public class Move implements Listener { final WorldManager worldManager = skyblock.getWorldManager(); if(e.getTo() != null && e.getTo().getWorld() != null){ e.getTo().getWorld().loadChunk(e.getTo().getChunk()); - if(worldManager.isIslandWorld(e.getTo().getWorld()) && e.getTo().distance(e.getFrom()) > 1.0d){ // We should not care of self block tp + if(worldManager.isIslandWorld(e.getTo().getWorld()) + && (!e.getTo().getWorld().equals(e.getFrom().getWorld()) || e.getTo().distance(e.getFrom()) > 1.0d)){ // We should not care of self block tp if(skyblock.getIslandManager().getIslandAtLocation(e.getTo()) == null){ e.setCancelled(true); skyblock.getMessageManager().sendMessage(player, From 6f2adfad702a80b22eda4d42340f4740cad8ee37 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 20:33:01 +0200 Subject: [PATCH 25/33] Fixed damage and portal settings --- .../songoda/skyblock/listeners/Entity.java | 2 +- .../songoda/skyblock/listeners/Portal.java | 5 +-- .../permission/PermissionManager.java | 30 +++++++++++----- .../listening/DamagePermission.java | 14 ++++---- .../listening/PortalPermission.java | 36 ++++++++++++------- 5 files changed, 56 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Entity.java b/src/main/java/com/songoda/skyblock/listeners/Entity.java index 6d1d768f..ad47df64 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Entity.java +++ b/src/main/java/com/songoda/skyblock/listeners/Entity.java @@ -109,7 +109,7 @@ public class Entity implements Listener { // Check permissions. skyblock.getPermissionManager() - .processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation())); + .processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation()), true); } else { // Make it work with all the entities, not just TNT org.bukkit.entity.Entity entity = event.getEntity(); diff --git a/src/main/java/com/songoda/skyblock/listeners/Portal.java b/src/main/java/com/songoda/skyblock/listeners/Portal.java index 2dc5a66d..145852a3 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Portal.java +++ b/src/main/java/com/songoda/skyblock/listeners/Portal.java @@ -81,9 +81,10 @@ public class Portal implements Listener { Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); + PlayerEnterPortalEvent playerEnterPortalEvent = new PlayerEnterPortalEvent(player, player.getLocation()); // TODO Why?? - Fabrimat // Check permissions. - if (!skyblock.getPermissionManager().processPermission(new PlayerEnterPortalEvent(player, player.getLocation()), - player, island)) + if (!skyblock.getPermissionManager().processPermission(playerEnterPortalEvent, + player, island) || playerEnterPortalEvent.isCancelled()) return; IslandEnvironment spawnEnvironment; diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index 4038b7fe..1d1b1a11 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -146,6 +146,10 @@ public class PermissionManager { } public boolean processPermission(Cancellable cancellable, Player player, Island island) { + return processPermission(cancellable, player, island, false); + } + + public boolean processPermission(Cancellable cancellable, Player player, Island island, boolean reversePermission) { if (island == null) return true; for (HandlerWrapper wrapper : registeredHandlers) { @@ -157,7 +161,7 @@ public class PermissionManager { BasicPermission permission = wrapper.getPermission(); - if (hasPermission(player, island, permission)) + if (hasPermission(player, island, permission, reversePermission)) continue; try { @@ -169,20 +173,28 @@ public class PermissionManager { return true; } - public boolean hasPermission(Player player, Island island, BasicPermission permission) { + public boolean hasPermission(Player player, Island island, BasicPermission permission, boolean reversePermission){ if (player == null) return island.hasPermission(IslandRole.Owner, permission); if (player.hasPermission("fabledskyblock.bypass." + permission.getName().toLowerCase())) - return true; + return !reversePermission; - if (island.hasPermission(island.getRole(player), permission)) - return true; + switch(island.getRole(player)){ + case Owner: + case Operator: + case Member: + return island.hasPermission(IslandRole.Member, permission); + case Coop: + return island.hasPermission(IslandRole.Coop, permission); + case Visitor: + return island.hasPermission(IslandRole.Visitor, permission); + } + return false; + } - if (island.isCoopPlayer(player.getUniqueId()) && island.hasPermission(IslandRole.Coop, permission)) - return true; - - return island.hasPermission(IslandRole.Visitor, permission); + public boolean hasPermission(Player player, Island island, BasicPermission permission) { + return this.hasPermission(player, island, permission, false); } public boolean hasPermission(Location location, String permission, IslandRole islandRole) { diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java index 9673cd72..baed4a95 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java @@ -7,6 +7,7 @@ import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; import com.songoda.skyblock.utils.version.NMSUtil; +import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -52,10 +53,10 @@ public class DamagePermission extends ListeningPermission { FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - if (configLoad.getBoolean("Island.Settings.Damage.Enable")) - event.setCancelled(true); - else if (!configLoad.getBoolean("Island.Damage.Enable")) + if (configLoad.getBoolean("Island.Settings.Damage.Enable", false) + || !configLoad.getBoolean("Island.Damage.Enable", false)) { event.setCancelled(true); + } } @PermissionHandler @@ -66,10 +67,9 @@ public class DamagePermission extends ListeningPermission { FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - - if (configLoad.getBoolean("Island.Settings.Damage.Enable")) { - event.setCancelled(true); - } else if (!configLoad.getBoolean("Island.Damage.Enable")) { + + if (configLoad.getBoolean("Island.Settings.Damage.Enable", false) + || !configLoad.getBoolean("Island.Damage.Enable", false)) { event.setCancelled(true); } } diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java index 654dec3f..3ebaaf7d 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java @@ -3,12 +3,15 @@ package com.songoda.skyblock.permission.permissions.listening; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.island.*; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent; import com.songoda.skyblock.utils.world.LocationUtil; +import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerTeleportEvent; @@ -26,18 +29,11 @@ public class PortalPermission extends ListeningPermission { @PermissionHandler public void onPortalEnter(PlayerEnterPortalEvent event) { - Player player = (Player) event.getEntity(); + if(event.getEntity() instanceof Player){ + Player player = (Player) event.getEntity(); - cancelAndMessage(event, player, plugin, messageManager); - } - - @PermissionHandler - public void onMove(PlayerMoveEvent event) { - CompatibleMaterial toMaterial = CompatibleMaterial.getMaterial(event.getTo().getBlock().getType()); - - if (toMaterial == CompatibleMaterial.NETHER_BRICK || toMaterial == CompatibleMaterial.END_PORTAL) { - event.setTo(LocationUtil.getRandomLocation(event.getFrom().getWorld(), 5000, 5000, true, true)); - cancelAndMessage(event, event.getPlayer(), plugin, messageManager); + cancelAndMessage(event, player, plugin, messageManager); + player.teleport(getToLocation(event.getLocation(), player)); } } @@ -47,8 +43,24 @@ public class PortalPermission extends ListeningPermission { || event.getCause() == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL || event.getCause() == PlayerTeleportEvent.TeleportCause.END_PORTAL || ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9) && - event.getCause() == PlayerTeleportEvent.TeleportCause.END_GATEWAY) + event.getCause() == PlayerTeleportEvent.TeleportCause.END_GATEWAY){ + event.getPlayer().teleport(getToLocation(event.getFrom(), event.getPlayer())); + cancelAndMessage(event, event.getPlayer(), plugin, messageManager); + } + } + + private Location getToLocation(Location from, Player player) { + IslandManager islandManager = plugin.getIslandManager(); + Island island = islandManager.getIslandAtLocation(from); + Location to = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main); + if(island.hasRole(IslandRole.Visitor, player.getUniqueId())){ + to = LocationUtil.getSafeLocation(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor)); + if(to == null){ + to = LocationUtil.getSpawnLocation(); + } + } + return to; } } From 808c3c06dabf2f9d78d01693a986e1f2b81143aa Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 20:50:07 +0200 Subject: [PATCH 26/33] Added option to have same Members, operators and owner settings --- .../skyblock/permission/PermissionManager.java | 11 +++++++++++ .../permissions/listening/DamagePermission.java | 2 +- src/main/resources/config.yml | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index 1d1b1a11..4e4bd347 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -1,6 +1,7 @@ package com.songoda.skyblock.permission; import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandRole; import com.songoda.skyblock.permission.event.Stoppable; @@ -8,6 +9,7 @@ import com.songoda.skyblock.permission.permissions.basic.*; import com.songoda.skyblock.permission.permissions.listening.*; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; @@ -180,9 +182,18 @@ public class PermissionManager { if (player.hasPermission("fabledskyblock.bypass." + permission.getName().toLowerCase())) return !reversePermission; + FileManager.Config config = SkyBlock.getInstance().getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + switch(island.getRole(player)){ case Owner: + if(configLoad.getBoolean("Island.Settings.OwnersAndOperatorsAsMembers", false)){ + return island.hasPermission(IslandRole.Owner, permission); + } case Operator: + if(configLoad.getBoolean("Island.Settings.OwnersAndOperatorsAsMembers", false)){ + return island.hasPermission(IslandRole.Operator, permission); + } case Member: return island.hasPermission(IslandRole.Member, permission); case Coop: diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java index baed4a95..e91520a5 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java @@ -67,7 +67,7 @@ public class DamagePermission extends ListeningPermission { FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - + if (configLoad.getBoolean("Island.Settings.Damage.Enable", false) || !configLoad.getBoolean("Island.Damage.Enable", false)) { event.setCancelled(true); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ca6c6fa2..e4baadf3 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -90,7 +90,7 @@ Island: Height: 60 Member: # Max amount of players allowed to be in a team. - Capacity: 12 + Capacity: 12 # TODO Remove Chat: # If island chat should be output to console OutputToConsole: true @@ -299,6 +299,8 @@ Island: Enable: true Hunger: Enable: false + # If owners and operators should have same permission of members + OwnersAndOperatorsAsMembers: false Portal: # When disabled, when a player enters a portal, they will teleport to the nether or # end world rather than the island world. From 32b8f661ca13b40aa8e7753ef9e7afbfd9906c5f Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 21:35:53 +0200 Subject: [PATCH 27/33] Config comments update --- src/main/resources/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e4baadf3..1803329e 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -36,7 +36,7 @@ Island: Time: 60 # [!] How many seconds to wait before teleporting to a newly created island TeleportTimeout: 1 - # The distance between the islands + # The distance between the islands EXPERIMENTAL! Distance: 1200 Deletion: # [!] You are adviced to keep these options both enabled to prevent any issues. @@ -90,7 +90,7 @@ Island: Height: 60 Member: # Max amount of players allowed to be in a team. - Capacity: 12 # TODO Remove + Capacity: 12 Chat: # If island chat should be output to console OutputToConsole: true From c58c60a80524804c72dc372d84e66a0be3adcae7 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 22:17:18 +0200 Subject: [PATCH 28/33] Fix for permission setting for owners and ops --- .../com/songoda/skyblock/permission/PermissionManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index 4e4bd347..616e14d4 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -187,11 +187,11 @@ public class PermissionManager { switch(island.getRole(player)){ case Owner: - if(configLoad.getBoolean("Island.Settings.OwnersAndOperatorsAsMembers", false)){ + if(!configLoad.getBoolean("Island.Settings.OwnersAndOperatorsAsMembers", false)){ return island.hasPermission(IslandRole.Owner, permission); } case Operator: - if(configLoad.getBoolean("Island.Settings.OwnersAndOperatorsAsMembers", false)){ + if(!configLoad.getBoolean("Island.Settings.OwnersAndOperatorsAsMembers", false)){ return island.hasPermission(IslandRole.Operator, permission); } case Member: From 586874e20e1a17e71cdacb1942e24c4cf0028b28 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 22:17:28 +0200 Subject: [PATCH 29/33] Added comment in config --- src/main/resources/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 1803329e..e02f6afb 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -300,6 +300,7 @@ Island: Hunger: Enable: false # If owners and operators should have same permission of members + # It should be left to false as it could be changed soon OwnersAndOperatorsAsMembers: false Portal: # When disabled, when a player enters a portal, they will teleport to the nether or From b83544df9d44126972c277ef0efa30b3fd2dc952 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 22:23:07 +0200 Subject: [PATCH 30/33] LaborPatch 0.0.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d359add2..6471f5b3 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.2.16-LaborPatch-0.0.5 + 2.2.16-LaborPatch-0.0.6 jar clean install From e6cd8558c993c79b860ab17bc1fdc14a0cb2d8de Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 22:27:47 +0200 Subject: [PATCH 31/33] [ci skip] Updated readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1aeb70c4..edbb5f76 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ Forked from [FabledSkyBlock](https://gitlab.com/Songoda/fabledskyblock) This fork contains bug fixes, features and improvements: - Added option to check location security when using `/is visit` - Added option to remove water from Island Spawn -- Added an option to toggle fall damage in certain conditions like when using `/is home` +- Added option to have Members, Operators and Owners all responding to Members settings as a temporary fix to Operators and Owners settings not being editable via GUI +- Added option to toggle fall damage in certain conditions like when using `/is home` - Added per-world generator (editable only from generators.yml, GUI not supported yet) - Added a "subtract" value to levels in order to have all the new islands to level 0 - Added option to set default WorldBorder status From cb3e16031e966b4c95feaa33bd6ff652d1cb8b94 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 18 Jun 2020 00:51:32 +0200 Subject: [PATCH 32/33] Reworked portal setting handle --- .../com/songoda/skyblock/listeners/Move.java | 11 +++++++--- .../listening/PortalPermission.java | 20 +++++++++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java index a8360f01..e3ef3789 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Move.java +++ b/src/main/java/com/songoda/skyblock/listeners/Move.java @@ -169,12 +169,17 @@ public class Move implements Listener { } // Load the island they are now on if one exists - if (player.hasPermission("fabledskyblock.bypass")) { - Island loadedIsland = islandManager.loadIslandAtLocation(player.getLocation()); - if (loadedIsland != null) { + Island loadedIsland = islandManager.loadIslandAtLocation(player.getLocation()); + if (loadedIsland != null) { + if (player.hasPermission("fabledskyblock.bypass")) { playerData.setIsland(loadedIsland.getOwnerUUID()); return; } + + if(loadedIsland.isOpen()){ + loadedIsland.getVisit().addVisitor(player.getUniqueId()); + return; + } } LocationUtil.teleportPlayerToSpawn(player); diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java index 3ebaaf7d..f339ab3a 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java @@ -12,6 +12,7 @@ import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent; import com.songoda.skyblock.utils.world.LocationUtil; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerTeleportEvent; @@ -33,18 +34,25 @@ public class PortalPermission extends ListeningPermission { Player player = (Player) event.getEntity(); cancelAndMessage(event, player, plugin, messageManager); - player.teleport(getToLocation(event.getLocation(), player)); + Bukkit.getScheduler().runTask(plugin, () -> { + player.teleport(getToLocation(event.getLocation(), player)); + }); } } @PermissionHandler public void onTeleport(PlayerTeleportEvent event) { - if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL - || event.getCause() == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL - || event.getCause() == PlayerTeleportEvent.TeleportCause.END_PORTAL - || ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9) && - event.getCause() == PlayerTeleportEvent.TeleportCause.END_GATEWAY){ + if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.ENDER_PEARL) + || event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL) + || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL) + || (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9) + && event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_GATEWAY))){ event.getPlayer().teleport(getToLocation(event.getFrom(), event.getPlayer())); + Location to = getToLocation(event.getFrom(), event.getPlayer()); + Bukkit.getScheduler().runTask(plugin, () -> { + event.getPlayer().teleport(to); + }); + event.setTo(to); cancelAndMessage(event, event.getPlayer(), plugin, messageManager); } From e5ccded437406de41860d62c541d375472f43b1d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 18 Jun 2020 00:58:23 +0200 Subject: [PATCH 33/33] Updated readme --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index edbb5f76..4ffbd242 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This fork contains bug fixes, features and improvements: - Added a "subtract" value to levels in order to have all the new islands to level 0 - Added option to set default WorldBorder status - Added permissions for WorldBorder colors -- Added permission to bypass `/is kick` +- Added permissions to bypass kick and ban - Added water in Nether mechanics! - Added option to let slime splitting bypass limits.yml - Added option to define distance between islands @@ -20,8 +20,17 @@ This fork contains bug fixes, features and improvements: - Fixed bugs in Challenges that didn't remove all the items - Fixed WorldBorder size not reflecting real island size - Fixed bugs in island settings that prevented the from loading correctly +- Fixed mob grief setting +- Fixed explosion setting +- Fixed damage setting +- Fixed use portal setting +- Fixed bank that couldn't be opened from Members +- Fixed message telling that island disappeared on login +- Fixed GUI menus that had used the same page variable +- Fixed stackable bypassing break setting - Now you can use `/is chat ` to send messages to island chat - Now Challenges can be per-island too +- Now hunger setting works as intended - Hide options in control panel if missing the permission - Hide vanished players from visitors list - Hide bank from leaderboard if disabled