mirror of
https://e.coding.net/circlecloud/Residence.git
synced 2025-11-24 21:46:16 +00:00
2
pom.xml
2
pom.xml
@@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>cn.citycraft</groupId>
|
<groupId>cn.citycraft</groupId>
|
||||||
<artifactId>Residence</artifactId>
|
<artifactId>Residence</artifactId>
|
||||||
<version>2.8.0.4</version>
|
<version>2.8.0.5</version>
|
||||||
<name>Residence</name>
|
<name>Residence</name>
|
||||||
<description>重制版本的领地插件 - 喵♂呜</description>
|
<description>重制版本的领地插件 - 喵♂呜</description>
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -27,27 +27,50 @@ public class ResidenceBugFix implements Listener {
|
|||||||
plugin.getLogger().info("防刷生物补丁已加载...");
|
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
|
@EventHandler
|
||||||
public void onBlockPlace(final PlayerInteractEvent e) {
|
public void onBlockPlace(final PlayerInteractEvent e) {
|
||||||
if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.PHYSICAL) {
|
if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.PHYSICAL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final Player p = e.getPlayer();
|
final Block b = this.getPlaceBlockDown(e);
|
||||||
final ItemStack it = p.getItemInHand();
|
if (b == null) {
|
||||||
if (it == null || it.getType() == Material.AIR) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Block b = e.getClickedBlock();
|
final Player p = e.getPlayer();
|
||||||
|
final ItemStack it = p.getItemInHand();
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(b.getLocation());
|
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(b.getLocation());
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((it.getType() == Material.PUMPKIN && (b.getType() == Material.SNOW_BLOCK || b.getType() == Material.IRON_BLOCK))
|
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)) {
|
|| (it.getType() == Material.SKULL_ITEM && b.getType() == Material.SOUL_SAND)) {
|
||||||
final FlagPermissions perms = res.getPermissions();
|
if (checkPerm(res, p)) {
|
||||||
final String world = p.getWorld().getName();
|
|
||||||
if (!perms.playerHas(p.getName(), world, "place", perms.playerHas(p.getName(), world, "build", false))) {
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
p.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission") + ChatColor.DARK_RED + " 当前区域不允许放置!");
|
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 Block b = e.getClickedBlock();
|
||||||
final BlockFace bf = e.getBlockFace();
|
final BlockFace bf = e.getBlockFace();
|
||||||
if (bf == null) {
|
if (bf == null || bf != BlockFace.UP) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Block b1 = b.getRelative(bf, 1);
|
final Block b1 = b.getRelative(bf, 1);
|
||||||
@@ -78,10 +101,8 @@ public class ResidenceBugFix implements Listener {
|
|||||||
if (res == null) {
|
if (res == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final FlagPermissions perms = res.getPermissions();
|
|
||||||
final String world = p.getWorld().getName();
|
|
||||||
if (b1.getType() != Material.AIR && b2.getType() == Material.AIR) {
|
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);
|
e.setCancelled(true);
|
||||||
p.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission") + ChatColor.DARK_RED + " 当前区域不允许此操作!");
|
p.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission") + ChatColor.DARK_RED + " 当前区域不允许此操作!");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user