fixes #763
This commit is contained in:
Jesse Boyd
2015-11-29 19:21:32 +11:00
parent c2b781da98
commit 9118f111e4
17 changed files with 100 additions and 92 deletions

View File

@ -63,12 +63,11 @@ public abstract class EventUtil {
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) {
if (!MainUtil.isPlotAreaAbs(loc)) {
return true;
}
} else if (plot.isAdded(uuid)) {
} else if (plot.isAdded(pp.getUUID())) {
return true;
}
switch (type) {
@ -83,7 +82,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
}
if (!plot.hasOwner()) {
if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
final Flag use = FlagManager.getPlotFlagRaw(plot, "use");
@ -151,7 +150,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
}
if (!plot.hasOwner()) {
if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
@ -168,7 +167,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD.s(), notifyPerms);
}
if (!plot.hasOwner()) {
if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED.s(), notifyPerms);
}
final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
@ -185,7 +184,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), false);
}
if (!plot.hasOwner()) {
if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), false);
}
if (FlagManager.isPlotFlagTrue(plot, "device-interact")) {
@ -194,12 +193,10 @@ public abstract class EventUtil {
final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
long time = System.currentTimeMillis();
notifyPerms = notifyPerms && (31 * (time / 31) == time);
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
return true;
}
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_DEVICE_INTERACT.s()));
return !(!false || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_DEVICE_INTERACT.s()));
}
return true;
}
@ -207,7 +204,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
}
if (!plot.hasOwner()) {
if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
if (FlagManager.isPlotFlagTrue(plot, "hanging-interact")) {
@ -227,7 +224,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
}
if (!plot.hasOwner()) {
if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
if (FlagManager.isPlotFlagTrue(plot, "misc-interact")) {
@ -247,7 +244,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
}
if (!plot.hasOwner()) {
if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
if (FlagManager.isPlotFlagTrue(plot, "vehicle-use")) {
@ -267,7 +264,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
}
if (!plot.hasOwner()) {
if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
@ -288,7 +285,7 @@ public abstract class EventUtil {
// if (plot == null) {
// return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
// }
// if (!plot.hasOwner()) {
// if (plot.owner == null) {
// return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
// }
//
@ -306,7 +303,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
}
if (!plot.hasOwner()) {
if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
@ -327,7 +324,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
}
if (!plot.hasOwner()) {
if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}

View File

@ -2177,18 +2177,7 @@ public class MainUtil {
*
* @return boolean success
*/
public static boolean sendMessage(final PlotPlayer plr, final C c, final String... args) {
if (c.s().length() > 1) {
String msg = c.s();
if ((args != null) && (args.length > 0)) {
msg = C.format(c, args);
}
if (plr == null) {
ConsolePlayer.getConsole().sendMessage(msg);
} else {
sendMessage(plr, msg, c.usePrefix());
}
}
public static boolean sendMessage(final PlotPlayer plr, final C c, final String... args) {
return sendMessage(plr, c, (Object[]) args);
}
@ -2200,17 +2189,23 @@ public class MainUtil {
*
* @return boolean success
*/
public static boolean sendMessage(final PlotPlayer plr, final C c, final Object... args) {
if (c.s().length() > 1) {
String msg = c.s();
if ((args != null) && (args.length > 0)) {
msg = C.format(c, args);
}
if (plr == null) {
ConsolePlayer.getConsole().sendMessage(msg);
} else {
sendMessage(plr, msg, c.usePrefix());
public static boolean sendMessage(final PlotPlayer plr, final C c, final Object... args) {
if (c.s().length() == 0) {
return true;
}
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
String msg = c.s();
if (args.length != 0) {
msg = c.format(c, args);
}
if (plr != null) {
plr.sendMessage((c.usePrefix() ? C.PREFIX.s() + msg : msg));
} else {
ConsolePlayer.getConsole().sendMessage((c.usePrefix() ? C.PREFIX.s() : "") + msg);
}
}
});
return true;
}

View File

@ -1,6 +1,9 @@
package com.intellectualcrafters.plot.util;
import java.util.HashMap;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.general.commands.CommandCaller;
@ -10,7 +13,22 @@ public class Permissions {
}
public static boolean hasPermission(final PlotPlayer player, final String perm) {
return hasPermission((CommandCaller) player, perm);
if (!Settings.PERMISSION_CACHING) {
return hasPermission((CommandCaller) player, perm);
}
HashMap<String, Boolean> map = (HashMap<String, Boolean>) player.getMeta("perm");
if (map != null) {
Boolean result = map.get(perm);
if (result != null) {
return result;
}
} else {
map = new HashMap<>();
player.setMeta("perm", map);
}
boolean result = hasPermission((CommandCaller) player, perm);
map.put(perm, result);
return result;
}
public static boolean hasPermission(final CommandCaller player, String perm) {

View File

@ -116,11 +116,11 @@ public abstract class UUIDHandlerImplementation {
offline = null;
}
}
if (offline != null) {
if (offline != null && !offline.equals(uuid)) {
unknown.remove(offline);
final Set<Plot> plots = PS.get().getPlots(offline);
if (plots.size() > 0) {
for (final Plot plot : PS.get().getPlots(offline)) {
for (final Plot plot : plots) {
plot.owner = uuid;
}
DBFunc.replaceUUID(offline, uuid);
@ -136,7 +136,7 @@ public abstract class UUIDHandlerImplementation {
if (!offline.equals(uuid)) {
final Set<Plot> plots = PS.get().getPlots(offline);
if (plots.size() > 0) {
for (final Plot plot : PS.get().getPlots(offline)) {
for (final Plot plot : plots) {
plot.owner = uuid;
}
DBFunc.replaceUUID(offline, uuid);