diff --git a/pom.xml b/pom.xml index 4a4b28618..9e4e70605 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 3.2.13 + 3.2.14 PlotSquared jar diff --git a/src/main/java/com/intellectualcrafters/plot/config/C.java b/src/main/java/com/intellectualcrafters/plot/config/C.java index 766e9ca35..80bd8830a 100644 --- a/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -46,16 +46,25 @@ public enum C { * Static flags */ FLAG_USE("use", "static.flags"), + FLAG_BREAK("break", "static.flags"), FLAG_PLACE("place", "static.flags"), FLAG_PVP("pvp", "static.flags"), FLAG_HANGING_PLACE("hanging-place", "static.flags"), FLAG_HANGING_BREAK("hanging-break", "static.flags"), + FLAG_HANGING_INTERACT("hanging-interact", "static.flags"), + FLAG_MISC_INTERACT("misc-interact", "static.flags"), + FLAG_MISC_BREAK("misc-break", "static.flags"), + FLAG_MISC_PLACE("misc-place", "static.flags"), + FLAG_VEHICLE_BREAK("vehicle-break", "static.flags"), FLAG_HOSTILE_INTERACT("hostile-interact", "static.flags"), + FLAG_DEVICE_INTERACT("device-interact", "static.flags"), FLAG_ANIMAL_INTERACT("animal-interact", "static.flags"), FLAG_VEHICLE_USE("vehicle-use", "static.flags"), + FLAG_VEHICLE_PLACE("vehicle-place", "static.flags"), FLAG_PLAYER_INTERACT("player-interact", "static.flags"), FLAG_TAMED_INTERACT("tamed-interact", "static.flags"), FLAG_DISABLE_PHYSICS("disable-physics", "static.flags"), + FLAG_MOB_PLACE("mob-place", "static.flags"), /* * Static permission */ @@ -548,6 +557,7 @@ public enum C { FLAG_NOT_ADDED("$2The flag could not be added", "Flag"), FLAG_REMOVED("$4Successfully removed flag", "Flag"), FLAG_ADDED("$4Successfully added flag", "Flag"), + FLAG_TUTORIAL_USAGE("$1Have an admin set the flag: $2%s", "Commands"), /* * Trusted */ diff --git a/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java b/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java index 73d562f19..54d5e551a 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java +++ b/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java @@ -61,7 +61,7 @@ public abstract class EventUtil { public abstract void callMember(final PlotPlayer initiator, final Plot plot, final UUID player, final boolean added); - public boolean checkPlayerBlockEvent(final PlotPlayer pp, final PlayerBlockEventType type, final Location loc, final LazyBlock block, final boolean notifyPerms) { + public boolean checkPlayerBlockEvent(final PlotPlayer pp, final PlayerBlockEventType type, final Location loc, final LazyBlock block, boolean notifyPerms) { final Plot plot = MainUtil.getPlotAbs(loc); final UUID uuid = pp.getUUID(); if (plot == null) { @@ -100,7 +100,10 @@ public abstract class EventUtil { return true; } } - return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); + if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { + return true; + } + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_BREAK.s())); } case BREAK_HANGING: if (plot == null) { @@ -110,7 +113,10 @@ public abstract class EventUtil { return true; } if (plot.hasOwner()) { - return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); + if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { + return true; + } + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_HANGING_BREAK.s())); } return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); case BREAK_MISC: @@ -121,7 +127,10 @@ public abstract class EventUtil { return true; } if (plot.hasOwner()) { - return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); + if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { + return true; + } + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_MISC_BREAK.s())); } return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); case BREAK_VEHICLE: @@ -132,7 +141,10 @@ public abstract class EventUtil { return true; } if (plot.hasOwner()) { - return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); + if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { + return true; + } + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_VEHICLE_BREAK.s())); } return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); case INTERACT_BLOCK: { @@ -145,7 +157,10 @@ public abstract class EventUtil { final Flag flag = FlagManager.getPlotFlagRaw(plot, "use"); final HashSet value = flag == null ? null : (HashSet) flag.getValue(); if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { - return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); + if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { + return true; + } + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s())); } return true; } @@ -159,7 +174,10 @@ public abstract class EventUtil { final Flag flag = FlagManager.getPlotFlagRaw(plot, "place"); final HashSet value = flag == null ? null : (HashSet) flag.getValue(); if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { - return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER.s(), notifyPerms); + if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER.s(), notifyPerms)) { + return true; + } + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_PLACE.s())); } return true; } @@ -176,7 +194,12 @@ public abstract class EventUtil { final Flag flag = FlagManager.getPlotFlagRaw(plot, "use"); final HashSet value = flag == null ? null : (HashSet) flag.getValue(); if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { - return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); + long time = System.currentTimeMillis(); + notifyPerms = notifyPerms && (31 * (time / 31) == time); + if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { + return true; + } + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_DEVICE_INTERACT.s())); } return true; } @@ -193,7 +216,10 @@ public abstract class EventUtil { final Flag flag = FlagManager.getPlotFlagRaw(plot, "use"); final HashSet value = flag == null ? null : (HashSet) flag.getValue(); if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { - return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); + if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { + return true; + } + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_HANGING_INTERACT.s())); } return true; } @@ -210,7 +236,10 @@ public abstract class EventUtil { final Flag flag = FlagManager.getPlotFlagRaw(plot, "use"); final HashSet value = flag == null ? null : (HashSet) flag.getValue(); if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { - return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); + if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { + return true; + } + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_MISC_INTERACT.s())); } return true; } @@ -227,7 +256,10 @@ public abstract class EventUtil { final Flag flag = FlagManager.getPlotFlagRaw(plot, "use"); final HashSet value = flag == null ? null : (HashSet) flag.getValue(); if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { - return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); + if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { + return true; + } + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_VEHICLE_USE.s())); } return true; } @@ -245,7 +277,10 @@ public abstract class EventUtil { final Flag flag = FlagManager.getPlotFlagRaw(plot, "place"); final HashSet value = flag == null ? null : (HashSet) flag.getValue(); if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { - return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); + if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { + return true; + } + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_MOB_PLACE.s() + "/" + C.FLAG_PLACE.s())); } return true; } @@ -281,7 +316,10 @@ public abstract class EventUtil { final Flag flag = FlagManager.getPlotFlagRaw(plot, "place"); final HashSet value = flag == null ? null : (HashSet) flag.getValue(); if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { - return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); + if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { + return true; + } + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_MISC_PLACE.s() + "/" + C.FLAG_PLACE.s())); } return true; } @@ -299,7 +337,10 @@ public abstract class EventUtil { final Flag flag = FlagManager.getPlotFlagRaw(plot, "place"); final HashSet value = flag == null ? null : (HashSet) flag.getValue(); if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { - return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); + if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { + return true; + } + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_VEHICLE_PLACE.s() + "/" + C.FLAG_PLACE.s())); } return true; } diff --git a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index 8cfa13391..19f06b3ac 100644 --- a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -1135,9 +1135,15 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen if ((eventType != null) && !player.isSneaking()) { break; } - if ((hand == null) || (hand.getType() == Material.AIR) || hand.getType().isBlock()) { + Material type = hand == null ? null : hand.getType(); + int id = type == null ? 0 : type.getId(); + if (id == 0) { eventType = PlayerBlockEventType.INTERACT_BLOCK; - lb = new BukkitLazyBlock(block); + lb = new BukkitLazyBlock(id, block); + break; + } else if (id < 198) { + eventType = PlayerBlockEventType.PLACE_BLOCK; + lb = new BukkitLazyBlock(id, block); break; } lb = new BukkitLazyBlock(new PlotBlock((short) hand.getTypeId(), (byte) hand.getDurability())); diff --git a/target/PlotSquared-Bukkit.jar b/target/PlotSquared-Bukkit.jar index e62751a0d..9089c6580 100644 Binary files a/target/PlotSquared-Bukkit.jar and b/target/PlotSquared-Bukkit.jar differ