Merge remote-tracking branch 'origin/master' into development

This commit is contained in:
Brianna 2020-06-17 18:22:23 -05:00
commit 98299efc53
45 changed files with 477 additions and 242 deletions

View File

@ -5,12 +5,13 @@ Forked from [FabledSkyBlock](https://gitlab.com/Songoda/fabledskyblock)
This fork contains bug fixes, features and improvements: This fork contains bug fixes, features and improvements:
- Added option to check location security when using `/is visit` - Added option to check location security when using `/is visit`
- Added option to remove water from Island Spawn - 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 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 a "subtract" value to levels in order to have all the new islands to level 0
- Added option to set default WorldBorder status - Added option to set default WorldBorder status
- Added permissions for WorldBorder colors - Added permissions for WorldBorder colors
- Added permission to bypass `/is kick` - Added permissions to bypass kick and ban
- Added water in Nether mechanics! - Added water in Nether mechanics!
- Added option to let slime splitting bypass limits.yml - Added option to let slime splitting bypass limits.yml
- Added option to define distance between islands - Added option to define distance between islands
@ -19,8 +20,17 @@ This fork contains bug fixes, features and improvements:
- Fixed bugs in Challenges that didn't remove all the items - Fixed bugs in Challenges that didn't remove all the items
- Fixed WorldBorder size not reflecting real island size - Fixed WorldBorder size not reflecting real island size
- Fixed bugs in island settings that prevented the from loading correctly - 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 <message>` to send messages to island chat - Now you can use `/is chat <message>` to send messages to island chat
- Now Challenges can be per-island too - Now Challenges can be per-island too
- Now hunger setting works as intended
- Hide options in control panel if missing the permission - Hide options in control panel if missing the permission
- Hide vanished players from visitors list - Hide vanished players from visitors list
- Hide bank from leaderboard if disabled - Hide bank from leaderboard if disabled

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>skyblock</artifactId> <artifactId>skyblock</artifactId>
<version>2.2.16-LaborPatch-0.0.3</version> <version>2.2.16-LaborPatch-0.0.6</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>
<defaultGoal>clean install</defaultGoal> <defaultGoal>clean install</defaultGoal>

View File

@ -111,8 +111,8 @@ public class SkyBlock extends SongodaPlugin {
// Load Holograms // Load Holograms
com.songoda.core.hooks.HologramManager.load(this); com.songoda.core.hooks.HologramManager.load(this);
permissionManager = new PermissionManager(this);
fileManager = new FileManager(this); fileManager = new FileManager(this);
permissionManager = new PermissionManager(this);
localizationManager = new LocalizationManager(); localizationManager = new LocalizationManager();
worldManager = new WorldManager(this); worldManager = new WorldManager(this);
userCacheManager = new UserCacheManager(this); userCacheManager = new UserCacheManager(this);

View File

@ -67,11 +67,11 @@ public class BankManager {
public List<String> getBalanceLore(Player player) { public List<String> getBalanceLore(Player player) {
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
result.add("Some error occurred while loading your balance!"); 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()); result.add("If this is null then its a easy to fix bug: "+island.toString());
if (island != null) { if (island != null) {
result.clear(); 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())); result.add(player.getDisplayName()+"'s island has "+EconomyManager.formatEconomy(island.getBankBalance()));
} }
return result; return result;

View File

@ -160,7 +160,7 @@ public class Challenge {
ItemStack is = (ItemStack) obj; ItemStack is = (ItemStack) obj;
//p.getInventory().removeItem(new ItemStack(is.getType(), is.getAmount())); //p.getInventory().removeItem(new ItemStack(is.getType(), is.getAmount()));
int toRemove = 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 != null && jis.isSimilar(is)) {
if(jis.getAmount() <= toRemove) { if(jis.getAmount() <= toRemove) {
toRemove -= jis.getAmount(); toRemove -= jis.getAmount();

View File

@ -61,8 +61,8 @@ public class ChallengeCategory {
Challenge c = new Challenge(this, id, name, maxTimes, showInChat, require, reward, ic); Challenge c = new Challenge(this, id, name, maxTimes, showInChat, require, reward, ic);
challenges.put(id, c); challenges.put(id, c);
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
throw new IllegalArgumentException("Exception at category " + this.name + "(" + this.id throw new IllegalArgumentException("Exception at category " + this.name.replace("&", "") + "(" + this.id
+ ") at challenge " + name + "(" + id + "): " + ex.getMessage()); + ") at challenge " + name.replace("&", "") + "(" + id + "): " + ex.getMessage());
} }
} }
Bukkit.getConsoleSender().sendMessage("[FabledSkyBlock] " + ChatColor.GREEN + "Category " + name + ChatColor.GREEN Bukkit.getConsoleSender().sendMessage("[FabledSkyBlock] " + ChatColor.GREEN + "Category " + name + ChatColor.GREEN

View File

@ -170,7 +170,7 @@ public class AcceptCommand extends SubCommand {
if (scoreboardManager != null) { if (scoreboardManager != null) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(player); Scoreboard scoreboard = scoreboardManager.getScoreboard(player);
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Scoreboard.Island.Team.Displayname"))); configLoad.getString("Scoreboard.Island.Team.Displayname", "")));
if (islandManager.getVisitorsAtIsland(island).size() == 0) { if (islandManager.getVisitorsAtIsland(island).size() == 0) {
scoreboard.setDisplayList( scoreboard.setDisplayList(

View File

@ -63,6 +63,9 @@ public class BanCommand extends SubCommand {
if (targetPlayerUUID == null) { if (targetPlayerUUID == null) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Found.Message")); messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Found.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); 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())) { } else if (targetPlayerUUID.equals(player.getUniqueId())) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Yourself.Message")); messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Yourself.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);

View File

@ -73,9 +73,8 @@ public class KickCommand extends SubCommand {
} }
assert targetPlayer != null; assert targetPlayer != null;
if(targetPlayer.hasPermission("fabledskyblock.bypass.kick") && islandVisitors.contains(targetPlayer.getUniqueId())){ if((targetPlayer.hasPermission("fabledskyblock.bypass.kick") || targetPlayer.isOp()) && islandVisitors.contains(targetPlayer.getUniqueId())){
// messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Exempt")); // TODO messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Exempt"));
messageManager.sendMessage(player, "&cNon puoi cacciare questo utente!");
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else if (targetPlayerUUID.equals(player.getUniqueId())) { } else if (targetPlayerUUID.equals(player.getUniqueId())) {
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Yourself.Message")); 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())); 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); 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); LocationUtil.teleportPlayerToSpawn(targetPlayer);
} }

View File

@ -40,7 +40,7 @@ public class TeleportCommand extends SubCommand {
if (args.length == 1) { if (args.length == 1) {
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]); Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
UUID islandOwnerUUID = null; UUID islandOwnerUUID;
String targetPlayerName; String targetPlayerName;
if (targetPlayer == null) { if (targetPlayer == null) {

View File

@ -47,7 +47,6 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.IllegalPluginAccessException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -896,7 +895,9 @@ public class IslandManager {
islandStorage.remove(island.getOwnerUUID()); islandStorage.remove(island.getOwnerUUID());
Bukkit.getScheduler().runTask(skyblock, () -> {
Bukkit.getServer().getPluginManager().callEvent(new IslandUnloadEvent(island.getAPIWrapper())); Bukkit.getServer().getPluginManager().callEvent(new IslandUnloadEvent(island.getAPIWrapper()));
});
} }
public void prepareIsland(Island island, IslandWorld world) { public void prepareIsland(Island island, IslandWorld world) {
@ -1084,8 +1085,8 @@ public class IslandManager {
} }
} else { } else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', player.sendMessage(ChatColor.translateAlternateColorCodes('&',
Objects.requireNonNull(skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Teleport.Unsafe.Message")))); .getFileConfiguration().getString("Island.Teleport.Unsafe.Message")));
} }
} else { } else {
if (scoreboardManager != null) { if (scoreboardManager != null) {

View File

@ -25,9 +25,8 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.*;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -69,14 +68,14 @@ public class Block implements Listener {
} }
// Check permissions. // Check permissions.
if (!skyblock.getPermissionManager().processPermission(event, player, island)) { if (!skyblock.getPermissionManager().processPermission(event, player, island) || event.isCancelled()) {
return; return;
} }
if (stackableManager != null && stackableManager.isStacked(blockLocation)) { 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) { if (stackable != null) {
CompatibleMaterial material = CompatibleMaterial.getBlockMaterial(block.getType()); CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
byte data = block.getData(); byte data = block.getData();
int droppedAmount = 0; int droppedAmount = 0;
@ -323,21 +322,24 @@ public class Block implements Listener {
if(configLoad.getBoolean("Island.Nether.WaterDoNotFlowNearNetherMobs", false) && worldManager.getIslandWorld(block.getWorld()).equals(IslandWorld.Nether)){ if(configLoad.getBoolean("Island.Nether.WaterDoNotFlowNearNetherMobs", false) && worldManager.getIslandWorld(block.getWorld()).equals(IslandWorld.Nether)){
Collection<Entity> entities = block.getWorld().getNearbyEntities(block.getLocation(), 1d, 1d, 1d); Collection<Entity> entities = block.getWorld().getNearbyEntities(block.getLocation(), 1d, 1d, 1d);
if(entities.size() > 0){ if(entities.size() > 0){
EntityCycle: for(Entity ent : entities){ for(Entity ent : entities){
switch(ent.getType()){ boolean witherSkeleton;
case PIG_ZOMBIE: if (NMSUtil.getVersionNumber() > 10) {
case BLAZE: witherSkeleton = ent.getType().equals(EntityType.WITHER_SKELETON);
case MAGMA_CUBE: } else {
case WITHER_SKELETON: witherSkeleton = ent instanceof Skeleton && ((Skeleton) ent).getSkeletonType().equals(Skeleton.SkeletonType.WITHER);
case WITHER: }
case GHAST: 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)){ if(block.getRelative(event.getFace().getOppositeFace()).getType().equals(Material.WATER)){
event.setCancelled(true); event.setCancelled(true);
event.getToBlock().getWorld().playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f); event.getToBlock().getWorld().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1f, 1f);
event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1); event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1);
} }
break EntityCycle; // TODO No spaghetti code
default:
break; break;
} }
} }
@ -638,7 +640,7 @@ public class Block implements Listener {
// PortalCreateEvent.getBlocks() changed from ArrayList<Block> to // PortalCreateEvent.getBlocks() changed from ArrayList<Block> to
// ArrayList<BlockState> in 1.14.1 // ArrayList<BlockState> in 1.14.1
if (NMSUtil.getVersionNumber() > 13) { if (NMSUtil.getVersionNumber() > 13) {
List<BlockState> blocks = event.getBlocks(); List<BlockState> blocks = event.getBlocks(); // TODO 1.8
if (event.getBlocks().isEmpty()) return; if (event.getBlocks().isEmpty()) return;
Island island = islandManager.getIslandAtLocation(event.getBlocks().get(0).getLocation()); Island island = islandManager.getIslandAtLocation(event.getBlocks().get(0).getLocation());
@ -722,6 +724,7 @@ public class Block implements Listener {
// placed. // placed.
// This shouldn't cause any issues besides the task number being increased // This shouldn't cause any issues besides the task number being increased
// insanely fast. // insanely fast.
// TODO Do this only in 1.8.8
Bukkit.getScheduler().runTask(skyblock, () -> { Bukkit.getScheduler().runTask(skyblock, () -> {
org.bukkit.block.Block block = location.getBlock(); org.bukkit.block.Block block = location.getBlock();
CompatibleMaterial material = CompatibleMaterial.getMaterial(block); CompatibleMaterial material = CompatibleMaterial.getMaterial(block);

View File

@ -27,6 +27,8 @@ import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.hanging.HangingPlaceEvent; import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent; import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import org.bukkit.event.player.PlayerShearEntityEvent; 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.EntityEquipment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@ -107,9 +109,9 @@ public class Entity implements Listener {
// Check permissions. // Check permissions.
skyblock.getPermissionManager() skyblock.getPermissionManager()
.processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation())); .processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation()), true);
} else if (event.getDamager() instanceof TNTPrimed) { } else { // Make it work with all the entities, not just TNT
org.bukkit.entity.Entity entity = event.getEntity(); org.bukkit.entity.Entity entity = event.getEntity();
// Check permissions. // Check permissions.
@ -217,6 +219,7 @@ public class Entity implements Listener {
@EventHandler @EventHandler
public void onHangingBreak(HangingBreakEvent event) { public void onHangingBreak(HangingBreakEvent event) {
Hanging hanging = event.getEntity(); Hanging hanging = event.getEntity();
if (!skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) return; if (!skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) return;
IslandManager islandManager = skyblock.getIslandManager(); IslandManager islandManager = skyblock.getIslandManager();
@ -229,14 +232,15 @@ public class Entity implements Listener {
public void onHangingBreak(HangingBreakByEntityEvent event) { public void onHangingBreak(HangingBreakByEntityEvent event) {
Hanging hanging = event.getEntity(); Hanging hanging = event.getEntity();
if (!(event.getRemover() instanceof Player))
return;
if (!skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) return; if (!skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) return;
IslandManager islandManager = skyblock.getIslandManager(); IslandManager islandManager = skyblock.getIslandManager();
Player p = null;
if(event.getRemover() instanceof Player){
p = (Player) event.getRemover();
}
// Check permissions. // Check permissions.
skyblock.getPermissionManager().processPermission(event, (Player) event.getRemover(), skyblock.getPermissionManager().processPermission(event, p,
islandManager.getIslandAtLocation(hanging.getLocation())); islandManager.getIslandAtLocation(hanging.getLocation()));
} }
@ -322,9 +326,11 @@ public class Entity implements Listener {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
// Check permissions. // Check permissions.
skyblock.getPermissionManager().processPermission(event, null, island); skyblock.getPermissionManager().processPermission(event, null, island);
if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Block.Level.Enable")) .getBoolean("Island.Block.Level.Enable"))
return; return;
@ -373,10 +379,10 @@ public class Entity implements Listener {
if (skyblock.getWorldManager().isIslandWorld(entity.getWorld())) { if (skyblock.getWorldManager().isIslandWorld(entity.getWorld())) {
// Check permissions. // Check permissions.
Island island = islandManager.getIslandAtLocation(entity.getLocation()); Island island = islandManager.getIslandAtLocation(entity.getLocation());
skyblock.getPermissionManager().processPermission(event, null, island); skyblock.getPermissionManager().processPermission(event, null, island);
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Block.Level.Enable")) { .getBoolean("Island.Block.Level.Enable")) {
for (org.bukkit.block.Block blockList : event.blockList()) { 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. 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) { private static SpawnReason getSpawnReason(String reason) {
try { try {
return SpawnReason.valueOf(reason); return SpawnReason.valueOf(reason);

View File

@ -18,6 +18,7 @@ import com.songoda.skyblock.stackable.Stackable;
import com.songoda.skyblock.stackable.StackableManager; import com.songoda.skyblock.stackable.StackableManager;
import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.NumberUtil;
import com.songoda.skyblock.utils.structure.StructureUtil; 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.utils.world.LocationUtil;
import com.songoda.skyblock.world.WorldManager; import com.songoda.skyblock.world.WorldManager;
import org.apache.commons.lang.WordUtils; import org.apache.commons.lang.WordUtils;
@ -121,7 +122,7 @@ public class Interact implements Listener {
if(configLoad.getBoolean("Island.Nether.AllowNetherWater", false)){ if(configLoad.getBoolean("Island.Nether.AllowNetherWater", false)){
event.setCancelled(true); event.setCancelled(true);
block.setType(Material.WATER, true); block.setType(Material.WATER, true);
block.getWorld().playSound(block.getLocation(), Sound.ITEM_BUCKET_EMPTY, 1f, 1f); block.getWorld().playSound(block.getLocation(), CompatibleSound.ITEM_BUCKET_EMPTY.getSound(), 1f, 1f);
if(!event.getPlayer().getGameMode().equals(GameMode.CREATIVE)){ if(!event.getPlayer().getGameMode().equals(GameMode.CREATIVE)){
event.getItem().setType(Material.BUCKET); event.getItem().setType(Material.BUCKET);
} }

View File

@ -169,12 +169,17 @@ public class Move implements Listener {
} }
// Load the island they are now on if one exists // Load the island they are now on if one exists
if (player.hasPermission("fabledskyblock.bypass")) {
Island loadedIsland = islandManager.loadIslandAtLocation(player.getLocation()); Island loadedIsland = islandManager.loadIslandAtLocation(player.getLocation());
if (loadedIsland != null) { if (loadedIsland != null) {
if (player.hasPermission("fabledskyblock.bypass")) {
playerData.setIsland(loadedIsland.getOwnerUUID()); playerData.setIsland(loadedIsland.getOwnerUUID());
return; return;
} }
if(loadedIsland.isOpen()){
loadedIsland.getVisit().addVisitor(player.getUniqueId());
return;
}
} }
LocationUtil.teleportPlayerToSpawn(player); LocationUtil.teleportPlayerToSpawn(player);
@ -230,21 +235,21 @@ public class Move implements Listener {
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @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 Player player = e.getPlayer();
final WorldManager worldManager = skyblock.getWorldManager(); final WorldManager worldManager = skyblock.getWorldManager();
if(e.getTo() != null && e.getTo().getWorld() != null){
if (e.getTo() == null || e.getTo().getWorld().loadChunk(e.getTo().getChunk());
!worldManager.isIslandWorld(e.getTo().getWorld()) || if(worldManager.isIslandWorld(e.getTo().getWorld())
skyblock.getIslandManager().getIslandAtLocation(e.getTo()) != null) && (!e.getTo().getWorld().equals(e.getFrom().getWorld()) || e.getTo().distance(e.getFrom()) > 1.0d)){ // We should not care of self block tp
return; if(skyblock.getIslandManager().getIslandAtLocation(e.getTo()) == null){
e.setCancelled(true); e.setCancelled(true);
skyblock.getMessageManager().sendMessage(player, skyblock.getMessageManager().sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message")); 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); skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
}
}
}
} }
} }

View File

@ -81,9 +81,10 @@ public class Portal implements Listener {
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration(); FileConfiguration configLoad = config.getFileConfiguration();
PlayerEnterPortalEvent playerEnterPortalEvent = new PlayerEnterPortalEvent(player, player.getLocation()); // TODO Why?? - Fabrimat
// Check permissions. // Check permissions.
if (!skyblock.getPermissionManager().processPermission(new PlayerEnterPortalEvent(player, player.getLocation()), if (!skyblock.getPermissionManager().processPermission(playerEnterPortalEvent,
player, island)) player, island) || playerEnterPortalEvent.isCancelled())
return; return;
IslandEnvironment spawnEnvironment; IslandEnvironment spawnEnvironment;

View File

@ -141,7 +141,7 @@ public class Bank {
public void open(Player player) { public void open(Player player) {
Island island; Island island;
island = islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId())); island = islandManager.getIsland(player);
SkyBlock skyblock = SkyBlock.getInstance(); SkyBlock skyblock = SkyBlock.getInstance();

View File

@ -128,13 +128,13 @@ public class Bans {
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) { } else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Bans.Item.Previous.Displayname")))) { 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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes( } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes(
'&', configLoad.getString("Menu.Bans.Item.Next.Displayname")))) { '&', 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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); 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), configLoad.getString("Menu.Bans.Item.Barrier.Displayname"), null, null, null, null),
9, 10, 11, 12, 13, 14, 15, 16, 17); 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) { if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create( nInv.addItem(nInv.createItem(SkullUtil.create(

View File

@ -151,13 +151,13 @@ public class Coop {
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) { } else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Coop.Item.Previous.Displayname")))) { 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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes( } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes(
'&', configLoad.getString("Menu.Coop.Item.Next.Displayname")))) { '&', 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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
@ -194,7 +194,7 @@ public class Coop {
Map<UUID, IslandCoop> coopPlayers = island.getCoopPlayers(); Map<UUID, IslandCoop> 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(), nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(),
configLoad.getString("Menu.Coop.Item.Exit.Displayname"), null, null, null, null), 0, 8); configLoad.getString("Menu.Coop.Item.Exit.Displayname"), null, null, null, null), 0, 8);

View File

@ -303,7 +303,7 @@ public class Information {
if (is.getItemMeta().getDisplayName() if (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString( .equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString(
"Menu.Information.Members.Item.Previous.Displayname")))) { "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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, Bukkit.getServer().getScheduler().runTaskLater(skyblock,
@ -311,7 +311,7 @@ public class Information {
} else if (is.getItemMeta().getDisplayName() } else if (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&', configLoad .equals(ChatColor.translateAlternateColorCodes('&', configLoad
.getString("Menu.Information.Members.Item.Next.Displayname")))) { .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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, Bukkit.getServer().getScheduler().runTaskLater(skyblock,
@ -358,7 +358,7 @@ public class Information {
configLoad.getString("Menu.Information.Members.Item.Barrier.Displayname"), null, null, null, configLoad.getString("Menu.Information.Members.Item.Barrier.Displayname"), null, null, null,
null), 9, 10, 11, 12, 13, 14, 15, 16, 17); 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; nextEndIndex = displayedMembers.size() - playerMenuPage * 36;
if (playerMenuPage != 1) { if (playerMenuPage != 1) {
@ -464,7 +464,7 @@ public class Information {
if (is.getItemMeta().getDisplayName() if (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString( .equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString(
"Menu.Information.Visitors.Item.Previous.Displayname")))) { "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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, Bukkit.getServer().getScheduler().runTaskLater(skyblock,
@ -472,7 +472,7 @@ public class Information {
} else if (is.getItemMeta().getDisplayName() } else if (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&', configLoad .equals(ChatColor.translateAlternateColorCodes('&', configLoad
.getString("Menu.Information.Visitors.Item.Next.Displayname")))) { .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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, Bukkit.getServer().getScheduler().runTaskLater(skyblock,
@ -503,7 +503,7 @@ public class Information {
configLoad.getString("Menu.Information.Visitors.Item.Barrier.Displayname"), null, null, configLoad.getString("Menu.Information.Visitors.Item.Barrier.Displayname"), null, null,
null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17); 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; nextEndIndex = displayedVisitors.size() - playerMenuPage * 36;
if (playerMenuPage != 1) { if (playerMenuPage != 1) {

View File

@ -123,7 +123,7 @@ public class Leaderboard {
2); 2);
} else { } else {
nInv.addItem( 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.addItem(
nInv.createItem(new ItemStack(Material.EMERALD), configLoad nInv.createItem(new ItemStack(Material.EMERALD), configLoad

View File

@ -146,12 +146,12 @@ public class Levelling {
PlayerData playerData1 = skyblock.getPlayerDataManager().getPlayerData(player); PlayerData playerData1 = skyblock.getPlayerDataManager().getPlayerData(player);
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Previous.Displayname")))) { 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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Next.Displayname")))) { } 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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); 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.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, nInv.addItem(nInv.createItem(CompatibleMaterial.FIREWORK_STAR.getItem(), configLoad.getString("Menu.Levelling.Item.Rescan.Displayname"), configLoad.getStringList("Menu.Levelling.Item.Rescan.Lore"), null, null,

View File

@ -130,14 +130,14 @@ public class Members {
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) { } else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Members.Item.Previous.Displayname")))) { 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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(), Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(),
(Sort) playerData.getSort()), 1L); (Sort) playerData.getSort()), 1L);
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes( } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes(
'&', configLoad.getString("Menu.Members.Item.Next.Displayname")))) { '&', 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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(), 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(), nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(),
configLoad.getString("Menu.Members.Item.Exit.Displayname"), null, null, null, null), 0, 8); configLoad.getString("Menu.Members.Item.Exit.Displayname"), null, null, null, null), 0, 8);

View File

@ -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
}

View File

@ -120,13 +120,13 @@ public class Visit {
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) { } else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Visit.Item.Previous.Displayname")))) { 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); 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); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L);
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Visit.Item.Next.Displayname")))) { 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); 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); 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, nextEndIndex = visitIslands.size() - playerMenuPage * 36,
totalIslands = visitManager.getIslands().size(); totalIslands = visitManager.getIslands().size();

View File

@ -95,13 +95,13 @@ public class Visitors {
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) { } else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Visitors.Item.Previous.Displayname")))) { 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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes( } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes(
'&', configLoad.getString("Menu.Visitors.Item.Next.Displayname")))) { '&', 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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
@ -188,7 +188,7 @@ public class Visitors {
islandVisitors.add(sortedIslandVisitors.get(sortedIslandVisitorList)); 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) { if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create( nInv.addItem(nInv.createItem(SkullUtil.create(

View File

@ -5,6 +5,7 @@ import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.menus.MenuType;
import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.placeholder.Placeholder;
import com.songoda.skyblock.playerdata.PlayerData; 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), configLoad.getString("Menu.Admin.Creator.Browse.Item.Barrier.Displayname"), null, null, null, null),
9, 10, 11, 12, 13, 14, 15, 16, 17); 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) { if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create( nInv.addItem(nInv.createItem(SkullUtil.create(

View File

@ -8,6 +8,7 @@ import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.generator.GeneratorManager; import com.songoda.skyblock.generator.GeneratorManager;
import com.songoda.skyblock.generator.GeneratorMaterial; import com.songoda.skyblock.generator.GeneratorMaterial;
import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.menus.MenuType;
import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.placeholder.Placeholder;
import com.songoda.skyblock.playerdata.PlayerData; 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, configLoad.getString("Menu.Admin.Generator.Browse.Item.Barrier.Displayname"), null, null, null,
null), 9, 10, 11, 12, 13, 14, 15, 16, 17); 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) { if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create( nInv.addItem(nInv.createItem(SkullUtil.create(
@ -394,7 +395,7 @@ public class Generator implements Listener {
&& (is.hasItemMeta())) { && (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Generator.Browse.Item.Previous.Displayname")))) { 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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
player.closeInventory(); player.closeInventory();
@ -404,7 +405,7 @@ public class Generator implements Listener {
return; return;
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Generator.Browse.Item.Next.Displayname")))) { 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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
player.closeInventory(); player.closeInventory();

View File

@ -7,6 +7,7 @@ import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.levelling.rework.IslandLevelManager; import com.songoda.skyblock.levelling.rework.IslandLevelManager;
import com.songoda.skyblock.levelling.rework.LevellingMaterial; import com.songoda.skyblock.levelling.rework.LevellingMaterial;
import com.songoda.skyblock.menus.MenuType;
import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.placeholder.Placeholder;
import com.songoda.skyblock.playerdata.PlayerData; 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), configLoad.getString("Menu.Admin.Levelling.Item.Barrier.Displayname"), null, null, null, null),
9, 10, 11, 12, 13, 14, 15, 16, 17); 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) { if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create( nInv.addItem(nInv.createItem(SkullUtil.create(
@ -178,6 +179,7 @@ public class Levelling implements Listener {
} }
if (inventoryName.equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Levelling.Title")))) { if (inventoryName.equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Levelling.Title")))) {
event.setCancelled(true);
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
if (!(player.hasPermission("fabledskyblock.admin.level") || player.hasPermission("fabledskyblock.admin.*") if (!(player.hasPermission("fabledskyblock.admin.level") || player.hasPermission("fabledskyblock.admin.*")
@ -185,7 +187,6 @@ public class Levelling implements Listener {
messageManager.sendMessage(player, messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Levelling.Permission.Message")); configLoad.getString("Island.Admin.Levelling.Permission.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
event.setCancelled(true);
return; return;
} }
@ -193,7 +194,6 @@ public class Levelling implements Listener {
&& (is.hasItemMeta()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Levelling.Item.Barrier.Displayname"))))) { configLoad.getString("Menu.Admin.Levelling.Item.Barrier.Displayname"))))) {
event.setCancelled(true);
soundManager.playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F);
return; return;
@ -201,7 +201,6 @@ public class Levelling implements Listener {
&& (is.hasItemMeta()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Levelling.Item.Exit.Displayname"))))) { configLoad.getString("Menu.Admin.Levelling.Item.Exit.Displayname"))))) {
event.setCancelled(true);
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1.0F, 1.0F);
player.closeInventory(); player.closeInventory();
@ -209,7 +208,6 @@ public class Levelling implements Listener {
} else if ((event.getCurrentItem().getType() == CompatibleMaterial.OAK_SIGN.getMaterial()) && (is.hasItemMeta()) } else if ((event.getCurrentItem().getType() == CompatibleMaterial.OAK_SIGN.getMaterial()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Levelling.Item.Information.Displayname"))))) { 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); soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
@ -271,7 +269,6 @@ public class Levelling implements Listener {
} else if ((event.getCurrentItem().getType() == Material.BARRIER) && (is.hasItemMeta()) } else if ((event.getCurrentItem().getType() == Material.BARRIER) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Levelling.Item.Nothing.Displayname"))))) { configLoad.getString("Menu.Admin.Levelling.Item.Nothing.Displayname"))))) {
event.setCancelled(true);
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return; return;
@ -279,10 +276,9 @@ public class Levelling implements Listener {
&& (is.hasItemMeta())) { && (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Levelling.Item.Previous.Displayname")))) { configLoad.getString("Menu.Admin.Levelling.Item.Previous.Displayname")))) {
event.setCancelled(true);
player.closeInventory(); 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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
@ -290,10 +286,9 @@ public class Levelling implements Listener {
return; return;
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Levelling.Item.Next.Displayname")))) { configLoad.getString("Menu.Admin.Levelling.Item.Next.Displayname")))) {
event.setCancelled(true);
player.closeInventory(); 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); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
@ -306,9 +301,9 @@ public class Levelling implements Listener {
for (LevellingMaterial materialList : levellingManager.getWorthsAsLevelingMaterials()) { for (LevellingMaterial materialList : levellingManager.getWorthsAsLevelingMaterials()) {
CompatibleMaterial materials = materialList.getMaterials(); 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())) { && ChatColor.stripColor(is.getItemMeta().getDisplayName()).equals(materials.name())) {
event.setCancelled(true);
if (event.getClick() == ClickType.LEFT) { if (event.getClick() == ClickType.LEFT) {
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
@ -411,8 +406,6 @@ public class Levelling implements Listener {
} }
} }
event.setCancelled(true);
CompatibleMaterial materials = CompatibleMaterial.getMaterial(event.getCurrentItem().getType()); CompatibleMaterial materials = CompatibleMaterial.getMaterial(event.getCurrentItem().getType());
if (NMSUtil.getVersionNumber() < 13) { if (NMSUtil.getVersionNumber() < 13) {

View File

@ -60,15 +60,6 @@ public abstract class BasicPermission {
return is; return is;
} }
/**
* Use this to check additional perms.
*
* @return
*/
public boolean overridingCheck() {
return true;
}
public String getName() { public String getName() {
return name; return name;
} }

View File

@ -81,6 +81,10 @@ public abstract class ListeningPermission extends BasicPermission {
public void onBlockIgnite(BlockIgniteEvent event) {} public void onBlockIgnite(BlockIgniteEvent event) {}
protected void noPermsMessage(Player player, SkyBlock plugin, MessageManager messageManager) { 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, messageManager.sendMessage(player,
plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Settings.Permission.Message")); .getFileConfiguration().getString("Island.Settings.Permission.Message"));

View File

@ -1,6 +1,7 @@
package com.songoda.skyblock.permission; package com.songoda.skyblock.permission;
import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandRole; import com.songoda.skyblock.island.IslandRole;
import com.songoda.skyblock.permission.event.Stoppable; import com.songoda.skyblock.permission.event.Stoppable;
@ -8,9 +9,11 @@ import com.songoda.skyblock.permission.permissions.basic.*;
import com.songoda.skyblock.permission.permissions.listening.*; import com.songoda.skyblock.permission.permissions.listening.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import java.io.File;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.*; import java.util.*;
@ -27,7 +30,7 @@ public class PermissionManager {
this.plugin = plugin; this.plugin = plugin;
// Load default permissions. // Load default permissions.
registerPermissions( registerPermissions( // TODO Reload them with /is admin reload - Fabrimat
//Listening //Listening
new StoragePermission(plugin), new StoragePermission(plugin),
new DragonEggUsePermission(plugin), new DragonEggUsePermission(plugin),
@ -77,7 +80,6 @@ public class PermissionManager {
new MobGriefingPermission(plugin), new MobGriefingPermission(plugin),
new ExperienceOrbPickupPermission(plugin), new ExperienceOrbPickupPermission(plugin),
new NaturalMobSpawningPermission(), new NaturalMobSpawningPermission(),
new HungerPermission(plugin),
new PortalPermission(plugin), new PortalPermission(plugin),
new ItemPickupPermission(), new ItemPickupPermission(),
new ItemDropPermission(), new ItemDropPermission(),
@ -100,6 +102,11 @@ public class PermissionManager {
new MainSpawnPermission(), new MainSpawnPermission(),
new VisitorSpawnPermission()); 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 -> { registeredHandlers = registeredHandlers.stream().sorted(Comparator.comparingInt(h -> {
final PermissionHandler permissionHandler = h.getHandler().getAnnotation(PermissionHandler.class); final PermissionHandler permissionHandler = h.getHandler().getAnnotation(PermissionHandler.class);
return permissionHandler.priority().ordinal(); return permissionHandler.priority().ordinal();
@ -141,6 +148,10 @@ public class PermissionManager {
} }
public boolean processPermission(Cancellable cancellable, Player player, Island island) { 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; if (island == null) return true;
for (HandlerWrapper wrapper : registeredHandlers) { for (HandlerWrapper wrapper : registeredHandlers) {
@ -152,7 +163,7 @@ public class PermissionManager {
BasicPermission permission = wrapper.getPermission(); BasicPermission permission = wrapper.getPermission();
if (permission.overridingCheck() || hasPermission(player, island, permission)) if (hasPermission(player, island, permission, reversePermission))
continue; continue;
try { try {
@ -164,21 +175,38 @@ public class PermissionManager {
return true; 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) if (player == null)
return island.hasPermission(IslandRole.Owner, permission); return island.hasPermission(IslandRole.Owner, permission);
if (player.hasPermission("fabledskyblock.bypass." + permission.getName().toLowerCase())) if (player.hasPermission("fabledskyblock.bypass." + permission.getName().toLowerCase()))
return true; return !reversePermission;
if (island.hasPermission(island.getRole(player), permission)) FileManager.Config config = SkyBlock.getInstance().getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
return true; FileConfiguration configLoad = config.getFileConfiguration();
if (island.isCoopPlayer(player.getUniqueId()) && island.hasPermission(IslandRole.Coop, permission))
return true;
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:
return island.hasPermission(IslandRole.Coop, permission);
case Visitor:
return island.hasPermission(IslandRole.Visitor, permission); return island.hasPermission(IslandRole.Visitor, permission);
} }
return false;
}
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) { public boolean hasPermission(Location location, String permission, IslandRole islandRole) {
if (location == null) if (location == null)

View File

@ -7,6 +7,7 @@ import com.songoda.skyblock.permission.ListeningPermission;
import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionHandler;
import com.songoda.skyblock.permission.PermissionType; import com.songoda.skyblock.permission.PermissionType;
import com.songoda.skyblock.utils.version.NMSUtil; import com.songoda.skyblock.utils.version.NMSUtil;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -52,11 +53,11 @@ public class DamagePermission extends ListeningPermission {
FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration(); FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Settings.Damage.Enable")) if (configLoad.getBoolean("Island.Settings.Damage.Enable", false)
event.setCancelled(true); || !configLoad.getBoolean("Island.Damage.Enable", false)) {
else if (!configLoad.getBoolean("Island.Damage.Enable"))
event.setCancelled(true); event.setCancelled(true);
} }
}
@PermissionHandler @PermissionHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
@ -67,9 +68,8 @@ public class DamagePermission extends ListeningPermission {
FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration(); FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Settings.Damage.Enable")) { if (configLoad.getBoolean("Island.Settings.Damage.Enable", false)
event.setCancelled(true); || !configLoad.getBoolean("Island.Damage.Enable", false)) {
} else if (!configLoad.getBoolean("Island.Damage.Enable")) {
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -1,53 +1,89 @@
package com.songoda.skyblock.permission.permissions.listening; package com.songoda.skyblock.permission.permissions.listening;
import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.ListeningPermission;
import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionHandler;
import com.songoda.skyblock.permission.PermissionType; import com.songoda.skyblock.permission.PermissionType;
import org.bukkit.entity.Entity; import org.bukkit.Bukkit;
import org.bukkit.entity.EntityType; import org.bukkit.entity.Creeper;
import org.bukkit.entity.TNTPrimed; 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.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.hanging.HangingBreakEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.vehicle.VehicleDamageEvent;
import org.bukkit.event.vehicle.VehicleDestroyEvent;
public class ExplosionsPermission extends ListeningPermission { public class ExplosionsPermission extends ListeningPermission {
private SkyBlock plugin; private SkyBlock plugin;
public ExplosionsPermission(SkyBlock plugin) { public ExplosionsPermission(SkyBlock plugin) {
super("Explosions", CompatibleMaterial.GUNPOWDER, PermissionType.GENERIC); super("Explosions", CompatibleMaterial.GUNPOWDER, PermissionType.ISLAND);
this.plugin = plugin; this.plugin = plugin;
} }
@PermissionHandler @PermissionHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { public void onBlockExplode(BlockExplodeEvent event) {
Entity entity = event.getEntity();
if (event.getDamager() instanceof TNTPrimed)
event.setCancelled(true); event.setCancelled(true);
if (entity.getType() == EntityType.PLAYER }
&& 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);
}
@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); event.setCancelled(true);
} }
@PermissionHandler @PermissionHandler
public void onHangingBreak(HangingBreakEvent event) { public void onHangingBreak(HangingBreakEvent event) {
if (event.getCause() != HangingBreakEvent.RemoveCause.EXPLOSION) if (event.getCause().equals(HangingBreakEvent.RemoveCause.EXPLOSION)) {
return;
event.setCancelled(true); event.setCancelled(true);
} }
}
@PermissionHandler @PermissionHandler
public void onBlockInteract(PlayerInteractEvent event) { public void onHangingBreak(HangingBreakByEntityEvent event) {
if (CompatibleMaterial.getMaterial(event.getPlayer().getItemInHand()) != CompatibleMaterial.FLINT_AND_STEEL) if(event.getCause().equals(HangingBreakEvent.RemoveCause.EXPLOSION)){
return; event.setCancelled(true);
}
}
CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock()); @PermissionHandler
if (material == CompatibleMaterial.TNT) 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()); cancelAndMessage(event, event.getPlayer(), plugin, plugin.getMessageManager());
} }
} }
}

View File

@ -21,12 +21,6 @@ public class HungerPermission extends ListeningPermission {
this.messageManager = plugin.getMessageManager(); 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 @PermissionHandler
public void onFoodLevelChange(FoodLevelChangeEvent event) { public void onFoodLevelChange(FoodLevelChangeEvent event) {
event.setCancelled(true); event.setCancelled(true);

View File

@ -2,43 +2,79 @@ package com.songoda.skyblock.permission.permissions.listening;
import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.ListeningPermission;
import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionHandler;
import com.songoda.skyblock.permission.PermissionType; 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.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.vehicle.VehicleDamageEvent; import org.bukkit.event.vehicle.VehicleDamageEvent;
import org.bukkit.event.vehicle.VehicleDestroyEvent; import org.bukkit.event.vehicle.VehicleDestroyEvent;
public class MobGriefingPermission extends ListeningPermission { public class MobGriefingPermission extends ListeningPermission {
private final SkyBlock plugin; private final SkyBlock plugin;
private final MessageManager messageManager;
public MobGriefingPermission(SkyBlock plugin) { public MobGriefingPermission(SkyBlock plugin) {
super("MobGriefing", CompatibleMaterial.IRON_SHOVEL, PermissionType.ISLAND); super("MobGriefing", CompatibleMaterial.IRON_SHOVEL, PermissionType.ISLAND);
this.plugin = plugin; 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 @PermissionHandler
public void onVehicleDamage(VehicleDamageEvent event) { public void onVehicleDamage(VehicleDamageEvent event) {
if (!(event.getAttacker() instanceof Player)
&& (!(event.getAttacker() instanceof org.bukkit.entity.Projectile)
Player player = (Player) event.getAttacker(); || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player))
cancelAndMessage(event, player, plugin, messageManager); && !(event.getAttacker() instanceof TNTPrimed)
&& !(event.getAttacker() instanceof ExplosiveMinecart)) {
event.setCancelled(true);
}
} }
@PermissionHandler @PermissionHandler
public void onVehicleDestroy(VehicleDestroyEvent event) { public void onVehicleDestroy(VehicleDestroyEvent event) {
if (!(event.getAttacker() instanceof Player)
&& (!(event.getAttacker() instanceof org.bukkit.entity.Projectile)
Player player = (Player) event.getAttacker(); || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player))
cancelAndMessage(event, player, plugin, messageManager); && !(event.getAttacker() instanceof TNTPrimed)
&& !(event.getAttacker() instanceof ExplosiveMinecart)) {
event.setCancelled(true);
}
} }
@PermissionHandler @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) { public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
EntityType type = event.getEntityType(); EntityType type = event.getEntityType();
@ -53,6 +89,6 @@ public class MobGriefingPermission extends ListeningPermission {
else return; else return;
cancelAndMessage(event, player, plugin, messageManager); cancelAndMessage(event, player, plugin, messageManager);
} }*/
} }

View File

@ -3,12 +3,16 @@ package com.songoda.skyblock.permission.permissions.listening;
import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.compatibility.ServerVersion;
import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.island.*;
import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.ListeningPermission;
import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionHandler;
import com.songoda.skyblock.permission.PermissionType; import com.songoda.skyblock.permission.PermissionType;
import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent; import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent;
import com.songoda.skyblock.utils.world.LocationUtil; 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.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
@ -26,29 +30,45 @@ public class PortalPermission extends ListeningPermission {
@PermissionHandler @PermissionHandler
public void onPortalEnter(PlayerEnterPortalEvent event) { public void onPortalEnter(PlayerEnterPortalEvent event) {
if(event.getEntity() instanceof Player){
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
cancelAndMessage(event, player, plugin, messageManager); cancelAndMessage(event, player, plugin, messageManager);
} Bukkit.getScheduler().runTask(plugin, () -> {
player.teleport(getToLocation(event.getLocation(), player));
@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);
} }
} }
@PermissionHandler @PermissionHandler
public void onTeleport(PlayerTeleportEvent event) { public void onTeleport(PlayerTeleportEvent event) {
if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.ENDER_PEARL)
|| event.getCause() == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL || event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL)
|| event.getCause() == PlayerTeleportEvent.TeleportCause.END_PORTAL || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)
|| ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9) && || (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)
event.getCause() == PlayerTeleportEvent.TeleportCause.END_GATEWAY) && 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); 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;
}
}

View File

@ -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;
}
}

View File

@ -6,6 +6,7 @@ import com.songoda.skyblock.bank.Transaction;
import com.songoda.skyblock.bank.Type; import com.songoda.skyblock.bank.Type;
import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.confirmation.Confirmation; import com.songoda.skyblock.confirmation.Confirmation;
import com.songoda.skyblock.menus.MenuType;
import com.songoda.skyblock.utils.structure.Area; import com.songoda.skyblock.utils.structure.Area;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -22,7 +23,7 @@ public class PlayerData {
private UUID islandOwnerUUID; private UUID islandOwnerUUID;
private UUID ownershipUUID; private UUID ownershipUUID;
private int page; private List<MenuPage> pages;
private int playTime; private int playTime;
private int visitTime; private int visitTime;
private int confirmationTime; private int confirmationTime;
@ -45,7 +46,8 @@ public class PlayerData {
uuid = player.getUniqueId(); uuid = player.getUniqueId();
islandOwnerUUID = null; islandOwnerUUID = null;
page = 1; pages = new ArrayList<>();
confirmationTime = 0; confirmationTime = 0;
playTime = getConfig().getFileConfiguration().getInt("Statistics.Island.Playtime"); playTime = getConfig().getFileConfiguration().getInt("Statistics.Island.Playtime");
@ -67,12 +69,23 @@ public class PlayerData {
} }
} }
public int getPage() { public int getPage(MenuType type) {
return page; for(MenuPage menu : pages){
if(menu.getType().equals(type)){
return menu.getPage();
}
}
return 1;
} }
public void setPage(int page) { public void setPage(MenuType type, int page) {
this.page = page; for(MenuPage menu : pages){
if(menu.getType().equals(type)){
menu.setPage(page);
return;
}
}
pages.add(new MenuPage(type, page));
} }
public Object getType() { public Object getType() {

View File

@ -1,5 +1,6 @@
package com.songoda.skyblock.tasks; package com.songoda.skyblock.tasks;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.utils.TextUtils; import com.songoda.core.utils.TextUtils;
import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager;
@ -11,6 +12,7 @@ import com.songoda.skyblock.leaderboard.Leaderboard;
import com.songoda.skyblock.leaderboard.LeaderboardManager; import com.songoda.skyblock.leaderboard.LeaderboardManager;
import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.NumberUtil;
import com.songoda.skyblock.utils.player.OfflinePlayer; 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.utils.world.LocationUtil;
import com.songoda.skyblock.visit.Visit; import com.songoda.skyblock.visit.Visit;
import org.bukkit.*; import org.bukkit.*;
@ -18,7 +20,9 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.io.File; import java.io.File;
@ -52,32 +56,34 @@ public class MobNetherWaterTask extends BukkitRunnable {
for(World world : Bukkit.getServer().getWorlds()){ for(World world : Bukkit.getServer().getWorlds()){
if(plugin.getWorldManager().isIslandWorld(world) && plugin.getWorldManager().getIslandWorld(world).equals(IslandWorld.Nether)){ if(plugin.getWorldManager().isIslandWorld(world) && plugin.getWorldManager().getIslandWorld(world).equals(IslandWorld.Nether)){
for(Entity ent : world.getEntities()) { for(Entity ent : world.getEntities()) {
switch(ent.getType()){ boolean witherSkeleton;
case PIG_ZOMBIE: if (NMSUtil.getVersionNumber() > 10) {
case BLAZE: witherSkeleton = ent.getType().equals(EntityType.WITHER_SKELETON);
case MAGMA_CUBE: } else {
case WITHER_SKELETON: witherSkeleton = ent instanceof Skeleton && ((Skeleton) ent).getSkeletonType().equals(Skeleton.SkeletonType.WITHER);
case WITHER: }
case GHAST: 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(); Block block = ent.getLocation().getBlock();
removeWater(world, block);
removeWater(world, block.getRelative(BlockFace.UP));
}
}
}
}
}
}
private void removeWater(World world, Block block) {
if (block.getType().equals(Material.WATER)) { if (block.getType().equals(Material.WATER)) {
block.setType(Material.AIR, true); block.setType(Material.AIR, true);
world.playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f); block.getWorld().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1f, 1f);
world.playEffect(block.getLocation(), Effect.SMOKE, 1); 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;
}
}
}
}
}
} }
public void onDisable() { public void onDisable() {

View File

@ -9,13 +9,13 @@ import com.songoda.skyblock.island.IslandEnvironment;
import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.utils.math.VectorUtil; 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.utils.world.block.BlockDegreesType;
import com.songoda.skyblock.world.WorldManager; import com.songoda.skyblock.world.WorldManager;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.io.File; import java.io.File;
@ -32,10 +32,8 @@ public final class LocationUtil {
Location tempLoc = LocationUtil.getDefinitiveLocation(loc); Location tempLoc = LocationUtil.getDefinitiveLocation(loc);
if(tempLoc.getBlock().getType().equals(Material.WATER)){ if(tempLoc.getBlock().getType().equals(Material.WATER)){
tempLoc.getBlock().setType(Material.AIR); tempLoc.getBlock().setType(Material.AIR);
} else if(tempLoc.getBlock().getBlockData() instanceof Waterlogged){ } else if(NMSUtil.getVersionNumber() > 13){
Waterlogged blockData = (Waterlogged) tempLoc.getBlock().getBlockData(); LocationUtil113.removeWaterLoggedFromLocation(tempLoc);
blockData.setWaterlogged(false);
tempLoc.getBlock().setBlockData(blockData);
} }
} }
} }
@ -66,7 +64,8 @@ public final class LocationUtil {
Location locWorking = loc.clone(); Location locWorking = loc.clone();
for(int i=locWorking.getBlockY(); i>=0; i--){ for(int i=locWorking.getBlockY(); i>=0; i--){
if(!locWorking.getBlock().isEmpty()){ if(!locWorking.getBlock().isEmpty()){
if(locWorking.getBlock().getType().equals(Material.WATER) || locWorking.getBlock().getBlockData() instanceof Waterlogged){ if(locWorking.getBlock().getType().equals(CompatibleMaterial.WATER.getMaterial()) ||
(NMSUtil.getVersionNumber() > 13 && locWorking.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){
loc = locWorking; loc = locWorking;
} }
break; break;
@ -79,39 +78,38 @@ public final class LocationUtil {
boolean safe = false; boolean safe = false;
if(!locChecked.getBlock().isEmpty() && if(!locChecked.getBlock().isEmpty() &&
!locChecked.getBlock().isLiquid() && !locChecked.getBlock().isLiquid() &&
!locChecked.getBlock().isPassable() &&
locChecked.getBlock().getType().isSolid() && locChecked.getBlock().getType().isSolid() &&
locChecked.getBlock().getType().isBlock() && locChecked.getBlock().getType().isBlock() &&
locChecked.add(0d,1d,0d).getBlock().getType().isAir() && locChecked.add(0d,1d,0d).getBlock().getType().equals(CompatibleMaterial.AIR.getMaterial()) &&
locChecked.add(0d,2d,0d).getBlock().getType().isAir() && locChecked.add(0d,2d,0d).getBlock().getType().equals(CompatibleMaterial.AIR.getMaterial()) &&
!(locChecked.getBlock().getBlockData() instanceof Waterlogged)){ !(NMSUtil.getVersionNumber() >= 13 && locChecked.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){
safe = true; safe = true;
switch(locChecked.getBlock().getType()){ switch(CompatibleMaterial.getMaterial(locChecked.getBlock())){
case ACACIA_BUTTON: case ACACIA_DOOR: // <= 1.8.8
case ACACIA_DOOR:
case ACACIA_FENCE_GATE: case ACACIA_FENCE_GATE:
case ACACIA_TRAPDOOR:
case BIRCH_DOOR: case BIRCH_DOOR:
case BIRCH_FENCE_GATE: case BIRCH_FENCE_GATE:
case BIRCH_TRAPDOOR:
case CACTUS: case CACTUS:
case CAKE: case CAKE:
case CAMPFIRE:
case COBWEB:
case DARK_OAK_DOOR: case DARK_OAK_DOOR:
case DARK_OAK_FENCE_GATE: case DARK_OAK_FENCE_GATE:
case DARK_OAK_TRAPDOOR:
case IRON_TRAPDOOR: case IRON_TRAPDOOR:
case JUNGLE_DOOR: case JUNGLE_DOOR:
case JUNGLE_FENCE_GATE: case JUNGLE_FENCE_GATE:
case JUNGLE_TRAPDOOR:
case LADDER: case LADDER:
case SPRUCE_DOOR:
case SPRUCE_FENCE_GATE:
case ACACIA_BUTTON:
case ACACIA_TRAPDOOR:
case BIRCH_TRAPDOOR:
case CAMPFIRE:
case COBWEB:
case DARK_OAK_TRAPDOOR:
case JUNGLE_TRAPDOOR:
case MAGMA_BLOCK: case MAGMA_BLOCK:
case NETHER_PORTAL: case NETHER_PORTAL:
case OAK_DOOR: case OAK_DOOR:
case OAK_FENCE_GATE: case OAK_FENCE_GATE:
case SPRUCE_DOOR:
case SPRUCE_FENCE_GATE:
safe = false; safe = false;
break; break;
} }

View File

@ -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);
}
}
}

View File

@ -498,7 +498,10 @@ public final class EntityUtil {
} }
public static boolean isMonster(EntityType type) { 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 BAT:
case BLAZE: case BLAZE:
case CAVE_SPIDER: case CAVE_SPIDER:
@ -525,7 +528,6 @@ public final class EntityUtil {
case VINDICATOR: case VINDICATOR:
case WITCH: case WITCH:
case WITHER: case WITHER:
case WITHER_SKELETON:
case ZOMBIE: case ZOMBIE:
case ZOMBIE_VILLAGER: case ZOMBIE_VILLAGER:
return true; return true;

View File

@ -36,7 +36,7 @@ Island:
Time: 60 Time: 60
# [!] How many seconds to wait before teleporting to a newly created island # [!] How many seconds to wait before teleporting to a newly created island
TeleportTimeout: 1 TeleportTimeout: 1
# The distance between the islands # The distance between the islands EXPERIMENTAL!
Distance: 1200 Distance: 1200
Deletion: Deletion:
# [!] You are adviced to keep these options both enabled to prevent any issues. # [!] You are adviced to keep these options both enabled to prevent any issues.
@ -299,6 +299,9 @@ Island:
Enable: true Enable: true
Hunger: Hunger:
Enable: false 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: Portal:
# When disabled, when a player enters a portal, they will teleport to the nether or # When disabled, when a player enters a portal, they will teleport to the nether or
# end world rather than the island world. # end world rather than the island world.
@ -337,11 +340,16 @@ Island:
# Should slime split bypass limits.yml # Should slime split bypass limits.yml
AllowSlimeSplit: true AllowSlimeSplit: true
Nether: Nether:
# Allow placing water in the Nether
AllowNetherWater: false AllowNetherWater: false
# Water disappear when a nether mob walks into it
WaterDisappearWithNetherMobs: false WaterDisappearWithNetherMobs: false
# Block water from flowing near nether mobs EXPERIMENTAL!
WaterDoNotFlowNearNetherMobs: false WaterDoNotFlowNearNetherMobs: false
# Make blaze immune from water in the Nether
BlazeImmuneToWaterInNether: false BlazeImmuneToWaterInNether: false
Restrict: Restrict:
# Blocks that can be placed only if the island has nether unlocked
NetherBlocks: NetherBlocks:
NETHERRACK: true NETHERRACK: true
SOUL_SAND: true SOUL_SAND: true
@ -364,6 +372,7 @@ Island:
NETHER_WART_BLOCK: true NETHER_WART_BLOCK: true
WITHER_SKELETON_SKULL: true WITHER_SKELETON_SKULL: true
WITHER_ROSE: true WITHER_ROSE: true
# Blocks that can be placed only if the island has The End unlocked
EndBlocks: EndBlocks:
END_STONE: true END_STONE: true
END_STONE_BRICKS: true END_STONE_BRICKS: true

View File

@ -433,6 +433,8 @@ Command:
Permission: Permission:
Message: '&bSkyBlock &8| &cError&8: &eYou do not have the right to delete your Island.' Message: '&bSkyBlock &8| &cError&8: &eYou do not have the right to delete your Island.'
Kick: Kick:
Bypass:
Message: '&bSkyBlock &8| &cError&8: &cYou can''t kick this user!'
Invalid: Invalid:
Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island kick <player>' Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island kick <player>'
Role: Role:
@ -766,6 +768,8 @@ Command:
Message: '&bSkyBlock &8| &aInfo&8: &eYou have banned the player &c%player &efrom the Island.' Message: '&bSkyBlock &8| &aInfo&8: &eYou have banned the player &c%player &efrom the Island.'
Target: Target:
Message: '&bSkyBlock &8| &aInfo&8: &eYou have been banned from the Island.' 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: Already:
Message: '&bSkyBlock &8| &cError&8: &eThat player is already banned from the Island.' Message: '&bSkyBlock &8| &cError&8: &eThat player is already banned from the Island.'
Owner: Owner: