mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-09-03 02:20:55 +02:00
Misc island permission bug fixes, portal event bug fix
This commit is contained in:
parent
4214c60fe3
commit
95e3eab883
|
@ -824,14 +824,6 @@ public class Island {
|
||||||
return unlocked;
|
return unlocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLocationWithinIsland(IslandWorld world, Location location) {
|
|
||||||
Location islandLocation = this.getLocation(world, IslandEnvironment.Island).clone().add(0.5, 0, 0.5);
|
|
||||||
double size = this.getRadius();
|
|
||||||
size += size % 2 == 0 ? 1 : 0;
|
|
||||||
|
|
||||||
return LocationUtil.isLocationAtLocationRadius(location, islandLocation, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
public me.goodandevil.skyblock.api.island.Island getAPIWrapper() {
|
public me.goodandevil.skyblock.api.island.Island getAPIWrapper() {
|
||||||
return apiWrapper;
|
return apiWrapper;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1342,6 +1342,10 @@ public class IslandManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLocationAtIsland(Island island, org.bukkit.Location location, IslandWorld world) {
|
public boolean isLocationAtIsland(Island island, org.bukkit.Location location, IslandWorld world) {
|
||||||
return LocationUtil.isLocationAtLocationRadius(location, island.getLocation(world, IslandEnvironment.Island), island.getRadius());
|
Location islandLocation = island.getLocation(world, IslandEnvironment.Island).clone().add(0.5, 0, 0.5);
|
||||||
|
double size = island.getRadius();
|
||||||
|
size += size % 2 == 0 ? 1 : 0;
|
||||||
|
|
||||||
|
return LocationUtil.isLocationAtLocationRadius(location, islandLocation, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
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.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
@ -187,7 +188,7 @@ public class Block implements Listener {
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
if (configLoad.getBoolean("Island.WorldBorder.Block") && block.getType() == Material.DISPENSER) {
|
if (configLoad.getBoolean("Island.WorldBorder.Block") && block.getType() == Material.DISPENSER) {
|
||||||
if (!island.isLocationWithinIsland(world, block.getLocation())) {
|
if (!islandManager.isLocationAtIsland(island, block.getLocation(), world)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,7 +269,7 @@ public class Block implements Listener {
|
||||||
org.bukkit.block.Block block = event.getToBlock();
|
org.bukkit.block.Block block = event.getToBlock();
|
||||||
|
|
||||||
// Protect outside of border
|
// Protect outside of border
|
||||||
if (!island.isLocationWithinIsland(world, block.getLocation())) {
|
if (!islandManager.isLocationAtIsland(island, block.getLocation(), world)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -291,7 +292,7 @@ public class Block implements Listener {
|
||||||
island.hasRole(IslandRole.Member, p.getUniqueId()) ||
|
island.hasRole(IslandRole.Member, p.getUniqueId()) ||
|
||||||
island.hasRole(IslandRole.Coop, p.getUniqueId()) ||
|
island.hasRole(IslandRole.Coop, p.getUniqueId()) ||
|
||||||
island.hasRole(IslandRole.Operator, p.getUniqueId());
|
island.hasRole(IslandRole.Operator, p.getUniqueId());
|
||||||
if (isMember && island.isLocationWithinIsland(world, p.getLocation())) {
|
if (isMember && islandManager.isLocationAtIsland(island, p.getLocation(), world)) {
|
||||||
possiblePlayers.add(p);
|
possiblePlayers.add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -334,7 +335,7 @@ public class Block implements Listener {
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
for (org.bukkit.block.Block block : event.getBlocks()) {
|
for (org.bukkit.block.Block block : event.getBlocks()) {
|
||||||
if (!island.isLocationWithinIsland(world, block.getLocation())) {
|
if (!islandManager.isLocationAtIsland(island, block.getLocation(), world)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -390,7 +391,7 @@ public class Block implements Listener {
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
for (org.bukkit.block.Block block : event.getBlocks()) {
|
for (org.bukkit.block.Block block : event.getBlocks()) {
|
||||||
if (!island.isLocationWithinIsland(world, block.getLocation())) {
|
if (!islandManager.isLocationAtIsland(island, block.getLocation(), world)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -466,7 +467,7 @@ public class Block implements Listener {
|
||||||
island.hasRole(IslandRole.Member, player.getUniqueId()) ||
|
island.hasRole(IslandRole.Member, player.getUniqueId()) ||
|
||||||
island.hasRole(IslandRole.Coop, player.getUniqueId()) ||
|
island.hasRole(IslandRole.Coop, player.getUniqueId()) ||
|
||||||
island.hasRole(IslandRole.Operator, player.getUniqueId());
|
island.hasRole(IslandRole.Operator, player.getUniqueId());
|
||||||
if (isMember && island.isLocationWithinIsland(world, player.getLocation())) {
|
if (isMember && islandManager.isLocationAtIsland(island, player.getLocation(), world)) {
|
||||||
possiblePlayers.add(player);
|
possiblePlayers.add(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -639,37 +640,26 @@ public class Block implements Listener {
|
||||||
IslandWorld world = worldManager.getIslandWorld(event.getBlocks().get(0).getWorld());
|
IslandWorld world = worldManager.getIslandWorld(event.getBlocks().get(0).getWorld());
|
||||||
Location islandLocation = island.getLocation(world, IslandEnvironment.Main);
|
Location islandLocation = island.getLocation(world, IslandEnvironment.Main);
|
||||||
|
|
||||||
for (org.bukkit.block.Block block : event.getBlocks()) {
|
// PortalCreateEvent.getBlocks() changed from ArrayList<Block> to ArrayList<BlockState> in 1.14.1... why...
|
||||||
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), islandLocation)) {
|
if (NMSUtil.getVersionNumber() > 13) {
|
||||||
event.setCancelled(true);
|
for (BlockState block : event.getBlocks()) {
|
||||||
return;
|
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), islandLocation)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
}
|
try {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@EventHandler
|
ArrayList<org.bukkit.block.Block> blocks = (ArrayList<org.bukkit.block.Block>) event.getClass().getMethod("getBlocks").invoke(event);
|
||||||
public void onEntityCreatePortal(EntityCreatePortalEvent event) {
|
for (org.bukkit.block.Block block : blocks) {
|
||||||
WorldManager worldManager = skyblock.getWorldManager();
|
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), islandLocation)) {
|
||||||
IslandManager islandManager = skyblock.getIslandManager();
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection"))
|
}
|
||||||
return;
|
}
|
||||||
|
} catch (ReflectiveOperationException ex) {
|
||||||
if (event.getBlocks().isEmpty())
|
ex.printStackTrace();
|
||||||
return;
|
|
||||||
|
|
||||||
Island island = islandManager.getIslandAtLocation(event.getBlocks().get(0).getLocation());
|
|
||||||
if (island == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Check spawn block protection
|
|
||||||
IslandWorld world = worldManager.getIslandWorld(event.getBlocks().get(0).getWorld());
|
|
||||||
Location islandLocation = island.getLocation(world, IslandEnvironment.Main);
|
|
||||||
|
|
||||||
for (org.bukkit.block.BlockState block : event.getBlocks()) {
|
|
||||||
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), islandLocation)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class Entity implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix a bug in spigot where arrows with flame still apply flame even if the event is cancelled
|
// Fix a bug in minecraft where arrows with flame still apply fire ticks even if the shot entity isn't damaged
|
||||||
if (preventFireTicks.contains(player.getUniqueId()) && event.getCause() == DamageCause.FIRE_TICK) {
|
if (preventFireTicks.contains(player.getUniqueId()) && event.getCause() == DamageCause.FIRE_TICK) {
|
||||||
player.setFireTicks(0);
|
player.setFireTicks(0);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -157,8 +157,7 @@ public class Entity implements Listener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getDamager() instanceof Projectile
|
if (event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player) {
|
||||||
&& ((Projectile) event.getDamager()).getShooter() instanceof Player) {
|
|
||||||
Player player = (Player) ((Projectile) event.getDamager()).getShooter();
|
Player player = (Player) ((Projectile) event.getDamager()).getShooter();
|
||||||
org.bukkit.entity.Entity entity = event.getEntity();
|
org.bukkit.entity.Entity entity = event.getEntity();
|
||||||
|
|
||||||
|
@ -167,6 +166,11 @@ public class Entity 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();
|
||||||
|
|
||||||
|
if (entity.getType() == EntityType.ITEM_FRAME && !islandManager.hasPermission(player, entity.getLocation(), "HangingDestroy")) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (configLoad.getBoolean("Island.Settings.PvP.Enable")) {
|
if (configLoad.getBoolean("Island.Settings.PvP.Enable")) {
|
||||||
if (!islandManager.hasSetting(entity.getLocation(), IslandRole.Owner, "PvP")) {
|
if (!islandManager.hasSetting(entity.getLocation(), IslandRole.Owner, "PvP")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -214,7 +218,7 @@ public class Entity implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix a bug in spigot where arrows with flame still apply flame even if the event is cancelled
|
// Fix a bug in minecraft where arrows with flame still apply fire ticks even if the shot entity isn't damaged
|
||||||
if (event.isCancelled() && event.getEntity() != null && event.getDamager() instanceof Arrow && ((Arrow)event.getDamager()).getShooter() instanceof Player) {
|
if (event.isCancelled() && event.getEntity() != null && event.getDamager() instanceof Arrow && ((Arrow)event.getDamager()).getShooter() instanceof Player) {
|
||||||
Arrow arrow = (Arrow) event.getDamager();
|
Arrow arrow = (Arrow) event.getDamager();
|
||||||
if (arrow.getFireTicks() != 0) {
|
if (arrow.getFireTicks() != 0) {
|
||||||
|
|
|
@ -258,7 +258,8 @@ public class Interact implements Listener {
|
||||||
|| block.getType() == Materials.BIRCH_BUTTON.parseMaterial()
|
|| block.getType() == Materials.BIRCH_BUTTON.parseMaterial()
|
||||||
|| block.getType() == Materials.JUNGLE_BUTTON.parseMaterial()
|
|| block.getType() == Materials.JUNGLE_BUTTON.parseMaterial()
|
||||||
|| block.getType() == Materials.ACACIA_BUTTON.parseMaterial()
|
|| block.getType() == Materials.ACACIA_BUTTON.parseMaterial()
|
||||||
|| block.getType() == Materials.DARK_OAK_BUTTON.parseMaterial()) {
|
|| block.getType() == Materials.DARK_OAK_BUTTON.parseMaterial()
|
||||||
|
|| block.getType() == Materials.LEVER.parseMaterial()) {
|
||||||
if (!islandManager.hasPermission(player, block.getLocation(), "LeverButton")) {
|
if (!islandManager.hasPermission(player, block.getLocation(), "LeverButton")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
@ -468,6 +469,7 @@ public class Interact implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
} else if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
|
// Note: Cast is necessary as it is ambiguous without it in 1.8
|
||||||
if (player.getTargetBlock((Set<Material>) null, 5).getType() == Material.FIRE) {
|
if (player.getTargetBlock((Set<Material>) null, 5).getType() == Material.FIRE) {
|
||||||
if (!islandManager.hasPermission(player, block.getLocation(), "Fire")) {
|
if (!islandManager.hasPermission(player, block.getLocation(), "Fire")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -479,7 +481,9 @@ public class Interact implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (event.getAction() == Action.PHYSICAL) {
|
} else if (event.getAction() == Action.PHYSICAL) {
|
||||||
if (block.getType() == Materials.FARMLAND.parseMaterial()) {
|
if (block.getType() == Materials.TURTLE_EGG.parseMaterial()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
} else if (block.getType() == Materials.FARMLAND.parseMaterial()) {
|
||||||
if (!islandManager.hasPermission(player, block.getLocation(), "Crop")) {
|
if (!islandManager.hasPermission(player, block.getLocation(), "Crop")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user