mirror of
https://github.com/YouHaveTrouble/YardWatch.git
synced 2026-05-11 22:16:58 +00:00
Improve FUUID support: (#7)
Don't waste time if not in an enabled world. Fixes test for protection that would always return true. Fixes block use test to use more proper method.
This commit is contained in:
@@ -35,12 +35,13 @@ public class FactionsUUIDProtection implements Protection {
|
|||||||
if (!FactionsPlugin.getInstance().worldUtil().isEnabled(location.getWorld())) return false;
|
if (!FactionsPlugin.getInstance().worldUtil().isEnabled(location.getWorld())) return false;
|
||||||
FLocation fLocation = new FLocation(location);
|
FLocation fLocation = new FLocation(location);
|
||||||
Faction faction = Board.getInstance().getFactionAt(fLocation);
|
Faction faction = Board.getInstance().getFactionAt(fLocation);
|
||||||
return faction != null;
|
return !faction.isWilderness();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBreakBlock(Player player, BlockState blockState) {
|
public boolean canBreakBlock(Player player, BlockState blockState) {
|
||||||
if (!isEnabled()) return true;
|
if (!isEnabled()) return true;
|
||||||
|
if (!FactionsPlugin.getInstance().worldUtil().isEnabled(blockState.getWorld())) return true;
|
||||||
return FactionsBlockListener.playerCanBuildDestroyBlock(
|
return FactionsBlockListener.playerCanBuildDestroyBlock(
|
||||||
player,
|
player,
|
||||||
blockState.getLocation(),
|
blockState.getLocation(),
|
||||||
@@ -52,6 +53,7 @@ public class FactionsUUIDProtection implements Protection {
|
|||||||
@Override
|
@Override
|
||||||
public boolean canPlaceBlock(Player player, Location location) {
|
public boolean canPlaceBlock(Player player, Location location) {
|
||||||
if (!isEnabled()) return true;
|
if (!isEnabled()) return true;
|
||||||
|
if (!FactionsPlugin.getInstance().worldUtil().isEnabled(location.getWorld())) return true;
|
||||||
return FactionsBlockListener.playerCanBuildDestroyBlock(
|
return FactionsBlockListener.playerCanBuildDestroyBlock(
|
||||||
player,
|
player,
|
||||||
location,
|
location,
|
||||||
@@ -63,18 +65,26 @@ public class FactionsUUIDProtection implements Protection {
|
|||||||
@Override
|
@Override
|
||||||
public boolean canInteract(Player player, BlockState blockState) {
|
public boolean canInteract(Player player, BlockState blockState) {
|
||||||
if (!isEnabled()) return true;
|
if (!isEnabled()) return true;
|
||||||
return FactionsPlayerListener.canInteractHere(player, blockState.getLocation());
|
if (!FactionsPlugin.getInstance().worldUtil().isEnabled(blockState.getWorld())) return true;
|
||||||
|
return FactionsPlayerListener.canUseBlock(
|
||||||
|
player,
|
||||||
|
blockState.getType(),
|
||||||
|
blockState.getLocation(),
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteract(Player player, Entity target) {
|
public boolean canInteract(Player player, Entity target) {
|
||||||
if (!isEnabled()) return true;
|
if (!isEnabled()) return true;
|
||||||
|
if (!FactionsPlugin.getInstance().worldUtil().isEnabled(target)) return true;
|
||||||
return FactionsEntityListener.canInteractHere(player, target.getLocation());
|
return FactionsEntityListener.canInteractHere(player, target.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canDamage(Entity damager, Entity target) {
|
public boolean canDamage(Entity damager, Entity target) {
|
||||||
if (!isEnabled()) return true;
|
if (!isEnabled()) return true;
|
||||||
|
if (!FactionsPlugin.getInstance().worldUtil().isEnabled(target)) return true;
|
||||||
return FactionsEntityListener.canDamage(damager, target, false);
|
return FactionsEntityListener.canDamage(damager, target, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user