mirror of
https://e.coding.net/circlecloud/Residence.git
synced 2024-10-31 22:38:48 +00:00
fix sugercans bug...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
a962b6f44d
commit
4e2d35f448
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>cn.citycraft</groupId>
|
||||
<artifactId>Residence</artifactId>
|
||||
<version>2.8.0.4</version>
|
||||
<version>2.8.0.5</version>
|
||||
<name>Residence</name>
|
||||
<description>重制版本的领地插件 - 喵♂呜</description>
|
||||
<build>
|
||||
|
@ -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 + " 当前区域不允许此操作!");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user