mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-07 11:10:04 +01:00
Fixed entities being placed outside of the border
This commit is contained in:
parent
43d31880ec
commit
1e1da915fe
@ -5,6 +5,7 @@ import com.songoda.skyblock.config.FileManager;
|
|||||||
import com.songoda.skyblock.island.Island;
|
import com.songoda.skyblock.island.Island;
|
||||||
import com.songoda.skyblock.island.IslandLevel;
|
import com.songoda.skyblock.island.IslandLevel;
|
||||||
import com.songoda.skyblock.island.IslandManager;
|
import com.songoda.skyblock.island.IslandManager;
|
||||||
|
import com.songoda.skyblock.island.IslandWorld;
|
||||||
import com.songoda.skyblock.levelling.LevellingManager;
|
import com.songoda.skyblock.levelling.LevellingManager;
|
||||||
import com.songoda.skyblock.limit.LimitManager;
|
import com.songoda.skyblock.limit.LimitManager;
|
||||||
import com.songoda.skyblock.message.MessageManager;
|
import com.songoda.skyblock.message.MessageManager;
|
||||||
@ -17,6 +18,8 @@ import com.songoda.skyblock.utils.structure.StructureUtil;
|
|||||||
import com.songoda.skyblock.utils.version.Materials;
|
import com.songoda.skyblock.utils.version.Materials;
|
||||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||||
import com.songoda.skyblock.utils.version.Sounds;
|
import com.songoda.skyblock.utils.version.Sounds;
|
||||||
|
import com.songoda.skyblock.world.WorldManager;
|
||||||
|
|
||||||
import org.apache.commons.lang3.text.WordUtils;
|
import org.apache.commons.lang3.text.WordUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -198,6 +201,15 @@ public class Interact implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the clicked block is outside of the border.
|
||||||
|
WorldManager worldManager = skyblock.getWorldManager();
|
||||||
|
org.bukkit.block.Block clickedBlock = event.getClickedBlock();
|
||||||
|
IslandWorld world = worldManager.getIslandWorld(clickedBlock.getWorld());
|
||||||
|
if (!islandManager.isLocationAtIsland(island, clickedBlock.getLocation(), world)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (event.getItem() != null && event.getItem().getType() == Materials.BONE_MEAL.parseMaterial() && !islandManager.hasPermission(player, block.getLocation(), "Place")) {
|
if (event.getItem() != null && event.getItem().getType() == Materials.BONE_MEAL.parseMaterial() && !islandManager.hasPermission(player, block.getLocation(), "Place")) {
|
||||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -597,7 +609,8 @@ public class Interact implements Listener {
|
|||||||
|
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
} else if (event.getItem().getType() == Material.ARMOR_STAND) {
|
} else if (event.getItem().getType() == Material.ARMOR_STAND || event.getItem().getType().name().contains("BOAT")
|
||||||
|
|| event.getItem().getType().name().contains("MINECART")) {
|
||||||
if (!islandManager.hasPermission(player, block.getLocation(), "EntityPlacement")) {
|
if (!islandManager.hasPermission(player, block.getLocation(), "EntityPlacement")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@ -22,37 +23,36 @@ public class Projectile implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onProjectileLaunch(ProjectileLaunchEvent event) {
|
public void onProjectileLaunch(ProjectileLaunchEvent event) {
|
||||||
if (!(event.getEntity().getShooter() instanceof Player)) {
|
org.bukkit.entity.Projectile projectile = event.getEntity();
|
||||||
|
ProjectileSource shooter = projectile.getShooter();
|
||||||
|
if (!(shooter instanceof Player))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
Player player = (Player) event.getEntity().getShooter();
|
|
||||||
|
|
||||||
MessageManager messageManager = skyblock.getMessageManager();
|
MessageManager messageManager = skyblock.getMessageManager();
|
||||||
SoundManager soundManager = skyblock.getSoundManager();
|
SoundManager soundManager = skyblock.getSoundManager();
|
||||||
|
Player player = (Player) shooter;
|
||||||
|
|
||||||
if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) {
|
if (!skyblock.getWorldManager().isIslandWorld(player.getWorld()))
|
||||||
if (event.getEntity() instanceof FishHook) {
|
return;
|
||||||
|
|
||||||
|
if (projectile instanceof FishHook) {
|
||||||
if (!skyblock.getIslandManager().hasPermission(player, "Fishing")) {
|
if (!skyblock.getIslandManager().hasPermission(player, "Fishing")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
messageManager.sendMessage(player,
|
messageManager.sendMessage(player,
|
||||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skyblock.getIslandManager().hasPermission(player, "Projectile")) {
|
if (!skyblock.getIslandManager().hasPermission(player, "Projectile")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
messageManager.sendMessage(player,
|
messageManager.sendMessage(player,
|
||||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user