mirror of
https://e.coding.net/circlecloud/Residence.git
synced 2025-11-24 21:46:16 +00:00
@@ -27,27 +27,50 @@ public class ResidenceBugFix implements Listener {
|
||||
plugin.getLogger().info("防刷生物补丁已加载...");
|
||||
}
|
||||
|
||||
public boolean checkPerm(final ClaimedResidence res, final Player p) {
|
||||
final FlagPermissions perms = res.getPermissions();
|
||||
final String world = p.getWorld().getName();
|
||||
return perms.playerHas(p.getName(), world, "place", perms.playerHas(p.getName(), world, "build", false));
|
||||
}
|
||||
|
||||
public Block getPlaceBlock(final PlayerInteractEvent e) {
|
||||
final Player p = e.getPlayer();
|
||||
final ItemStack it = p.getItemInHand();
|
||||
if (it == null || it.getType() == Material.AIR) {
|
||||
return null;
|
||||
}
|
||||
final Block b = e.getClickedBlock();
|
||||
final BlockFace bf = e.getBlockFace();
|
||||
if (bf == null) {
|
||||
return null;
|
||||
}
|
||||
return b.getRelative(bf, 1);
|
||||
}
|
||||
|
||||
public Block getPlaceBlockDown(final PlayerInteractEvent e) {
|
||||
final Block b = this.getPlaceBlock(e);
|
||||
return b.getRelative(BlockFace.DOWN);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(final PlayerInteractEvent e) {
|
||||
if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.PHYSICAL) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final Player p = e.getPlayer();
|
||||
final ItemStack it = p.getItemInHand();
|
||||
if (it == null || it.getType() == Material.AIR) {
|
||||
final Block b = this.getPlaceBlockDown(e);
|
||||
if (b == null) {
|
||||
return;
|
||||
}
|
||||
final Block b = e.getClickedBlock();
|
||||
final Player p = e.getPlayer();
|
||||
final ItemStack it = p.getItemInHand();
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(b.getLocation());
|
||||
if (res == null) {
|
||||
return;
|
||||
}
|
||||
if ((it.getType() == Material.PUMPKIN && (b.getType() == Material.SNOW_BLOCK || b.getType() == Material.IRON_BLOCK))
|
||||
|| (it.getType() == Material.SKULL_ITEM && b.getType() == Material.SOUL_SAND)) {
|
||||
final FlagPermissions perms = res.getPermissions();
|
||||
final String world = p.getWorld().getName();
|
||||
if (!perms.playerHas(p.getName(), world, "place", perms.playerHas(p.getName(), world, "build", false))) {
|
||||
if (checkPerm(res, p)) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission") + ChatColor.DARK_RED + " 当前区域不允许放置!");
|
||||
}
|
||||
@@ -69,7 +92,7 @@ public class ResidenceBugFix implements Listener {
|
||||
}
|
||||
final Block b = e.getClickedBlock();
|
||||
final BlockFace bf = e.getBlockFace();
|
||||
if (bf == null) {
|
||||
if (bf == null || bf != BlockFace.UP) {
|
||||
return;
|
||||
}
|
||||
final Block b1 = b.getRelative(bf, 1);
|
||||
@@ -78,10 +101,8 @@ public class ResidenceBugFix implements Listener {
|
||||
if (res == null) {
|
||||
return;
|
||||
}
|
||||
final FlagPermissions perms = res.getPermissions();
|
||||
final String world = p.getWorld().getName();
|
||||
if (b1.getType() != Material.AIR && b2.getType() == Material.AIR) {
|
||||
if (!perms.playerHas(p.getName(), world, "place", perms.playerHas(p.getName(), world, "build", false))) {
|
||||
if (checkPerm(res, p)) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission") + ChatColor.DARK_RED + " 当前区域不允许此操作!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user