Skip to content

Commit

Permalink
Fixed the ability to unleash entities even without the required privi…
Browse files Browse the repository at this point in the history
…lege (#990)
  • Loading branch information
OmerBenGera committed Mar 11, 2022
1 parent 91a7e84 commit a4886aa
Showing 1 changed file with 5 additions and 8 deletions.
@@ -1,16 +1,16 @@
package com.bgsoftware.superiorskyblock.listeners;

import com.bgsoftware.common.reflection.ReflectMethod;
import com.bgsoftware.superiorskyblock.lang.Message;
import com.bgsoftware.superiorskyblock.SuperiorSkyblockPlugin;
import com.bgsoftware.superiorskyblock.api.island.Island;
import com.bgsoftware.superiorskyblock.api.island.IslandPrivilege;
import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer;
import com.bgsoftware.superiorskyblock.island.permissions.IslandPrivileges;
import com.bgsoftware.superiorskyblock.lang.Message;
import com.bgsoftware.superiorskyblock.lang.PlayerLocales;
import com.bgsoftware.superiorskyblock.utils.ServerVersion;
import com.bgsoftware.superiorskyblock.utils.debug.PluginDebugger;
import com.bgsoftware.superiorskyblock.utils.entities.EntityUtils;
import com.bgsoftware.superiorskyblock.island.permissions.IslandPrivileges;
import com.bgsoftware.superiorskyblock.utils.items.ItemUtils;
import com.bgsoftware.superiorskyblock.utils.legacy.Materials;
import com.bgsoftware.superiorskyblock.utils.logic.ProtectionLogic;
Expand All @@ -28,7 +28,6 @@
import org.bukkit.entity.Fish;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.LeashHitch;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Painting;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -65,6 +64,7 @@
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerShearEntityEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerUnleashEntityEvent;
import org.bukkit.event.vehicle.VehicleDamageEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.inventory.Inventory;
Expand Down Expand Up @@ -395,12 +395,9 @@ public void onPlayerLeash(PlayerLeashEntityEvent e) {
}

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onUnleashEntity(PlayerInteractAtEntityEvent e) {
if (!(e.getRightClicked() instanceof LeashHitch))
return;

public void onPlayerUnleash(PlayerUnleashEntityEvent e) {
SuperiorPlayer superiorPlayer = plugin.getPlayers().getSuperiorPlayer(e.getPlayer());
Island island = plugin.getGrid().getIslandAt(e.getRightClicked().getLocation());
Island island = plugin.getGrid().getIslandAt(e.getEntity().getLocation());

if (island != null && !island.hasPermission(superiorPlayer, IslandPrivileges.LEASH)) {
e.setCancelled(true);
Expand Down

0 comments on commit a4886aa

Please sign in to comment.