Don't send duplicate messages

This commit is contained in:
Jesse Boyd 2016-06-16 10:31:25 +10:00
parent 472aadcd01
commit b2997b7c7b
8 changed files with 47 additions and 22 deletions

View File

@ -5,6 +5,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.PlotGameMode;
import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.util.BukkitUtil;
import org.bukkit.Effect;
@ -66,7 +67,10 @@ public class BukkitPlayer extends PlotPlayer {
@Override
public void sendMessage(String message) {
this.player.sendMessage(message);
if (!StringMan.isEqual(this.<String>getMeta("lastMessage"), message)) {
setMeta("lastMessage", message);
this.player.sendMessage(message);
}
}
@Override

View File

@ -14,6 +14,7 @@ import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
import com.plotsquared.bukkit.object.schematic.StateWrapper;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
@ -303,7 +304,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
}
@Override
public void restoreTile(String world, CompoundTag ct, int x, int y, int z) {
new StateWrapper(ct).restoreTag(world, x, y, z);
public boolean restoreTile(LocalBlockQueue queue, CompoundTag ct, int x, int y, int z) {
return new StateWrapper(ct).restoreTag(queue.getWorld(), x, y, z);
}
}

View File

@ -9,6 +9,8 @@ import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue;
import java.util.HashMap;
import java.util.Map.Entry;
@ -223,13 +225,17 @@ public class HybridGen extends IndependentPlotGenerator {
}
rz[i] = v;
}
LocalBlockQueue queue = null;
for (short x = 0; x < 16; x++) {
for (short z = 0; z < 16; z++) {
int pair = MathMan.pair(rx[x], rz[z]);
HashMap<Integer, CompoundTag> map = hpw.G_SCH_STATE.get(pair);
if (map != null) {
for (Entry<Integer, CompoundTag> entry : map.entrySet()) {
SchematicHandler.manager.restoreTile(hpw.worldname, entry.getValue(), p1x + x, entry.getKey(), p1z + z);
if (queue == null) {
queue = GlobalBlockQueue.IMP.getNewQueue(hpw.worldname, false);
}
SchematicHandler.manager.restoreTile(queue, entry.getValue(), p1x + x, entry.getKey(), p1z + z);
}
}
}

View File

@ -137,7 +137,7 @@ public abstract class EventUtil {
return true;
}
}
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
return true;
}
return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_BREAK.s()));
@ -149,8 +149,7 @@ public abstract class EventUtil {
return true;
}
if (plot.hasOwner()) {
return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms) || !(!notifyPerms || MainUtil
.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_HANGING_BREAK.s()));
return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false) || !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_HANGING_BREAK.s()));
}
return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
case BREAK_MISC:
@ -161,7 +160,7 @@ public abstract class EventUtil {
return true;
}
if (plot.hasOwner()) {
return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms) || !(!notifyPerms || MainUtil
return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false) || !(!notifyPerms || MainUtil
.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_MISC_BREAK.s()));
}
return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
@ -173,7 +172,7 @@ public abstract class EventUtil {
return true;
}
if (plot.hasOwner()) {
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
return true;
}
return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_VEHICLE_BREAK.s()));
@ -194,7 +193,7 @@ public abstract class EventUtil {
value = null;
}
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms) || !(!notifyPerms || MainUtil
return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false) || !(!notifyPerms || MainUtil
.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s()));
}
return true;
@ -214,7 +213,7 @@ public abstract class EventUtil {
value = null;
}
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_BUILD_OTHER.s(), notifyPerms)) {
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_BUILD_OTHER.s(), false)) {
return true;
}
return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_PLACE.s()));
@ -264,7 +263,7 @@ public abstract class EventUtil {
value = null;
}
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
return true;
}
return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_HANGING_INTERACT.s()));
@ -289,7 +288,7 @@ public abstract class EventUtil {
value = null;
}
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
return true;
}
return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_MISC_INTERACT.s()));
@ -314,7 +313,7 @@ public abstract class EventUtil {
value = null;
}
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
return true;
}
return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_VEHICLE_USE.s()));
@ -339,7 +338,7 @@ public abstract class EventUtil {
value = null;
}
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
return true;
}
return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_MOB_PLACE.s() + '/' + C.FLAG_PLACE.s()));
@ -366,7 +365,7 @@ public abstract class EventUtil {
value = null;
}
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
return true;
}
return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_MISC_PLACE.s() + '/' + C.FLAG_PLACE.s()));
@ -392,7 +391,7 @@ public abstract class EventUtil {
value = null;
}
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
return true;
}
return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_VEHICLE_PLACE.s() + '/' + C.FLAG_PLACE.s()));

View File

@ -334,15 +334,15 @@ public abstract class SchematicHandler {
if (!chunks.isEmpty()) {
this.run();
} else {
queue.flush();
for (Map.Entry<BlockLoc, CompoundTag> entry : schematic.getTiles().entrySet()) {
BlockLoc loc = entry.getKey();
restoreTile(plot.getArea().worldname, entry.getValue(), p1x + xOffset + loc.x, loc.y + y_offset_actual, p1z + zOffset + loc.z);
restoreTile(queue, entry.getValue(), p1x + xOffset + loc.x, loc.y + y_offset_actual, p1z + zOffset + loc.z);
}
if (whenDone != null) {
whenDone.value = true;
whenDone.run();
}
queue.flush();
}
}
});
@ -426,7 +426,7 @@ public abstract class SchematicHandler {
return schem;
}
public abstract void restoreTile(String world, CompoundTag tag, int x, int y, int z);
public abstract boolean restoreTile(LocalBlockQueue queue, CompoundTag tag, int x, int y, int z);
/**
* Get a schematic

View File

@ -57,7 +57,11 @@ public class GlobalBlockQueue {
}
};
public void GlobalBlockQueueProvider(QueueProvider provider) {
public QueueProvider getProvider() {
return provider;
}
public void setProvider(QueueProvider provider) {
this.provider = provider;
}

View File

@ -1,10 +1,12 @@
package com.intellectualcrafters.plot.util.block;
import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
@ -44,6 +46,11 @@ public abstract class LocalBlockQueue {
return setBlock(x, y, z, block.id, block.data);
}
public boolean setTile(int x, int y, int z, CompoundTag tag) {
SchematicHandler.manager.restoreTile(this, tag, x, y, z);
return true;
}
public abstract PlotBlock getBlock(int x, int y, int z);
public abstract boolean setBiome(int x, int z, String biome);

View File

@ -6,6 +6,7 @@ import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.PlotGameMode;
import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.sponge.util.SpongeUtil;
import org.spongepowered.api.Sponge;
@ -73,7 +74,10 @@ public class SpongePlayer extends PlotPlayer {
@Override
public void sendMessage(String message) {
this.player.sendMessage(ChatTypes.CHAT, TextSerializers.LEGACY_FORMATTING_CODE.deserialize(message));
if (!StringMan.isEqual(this.<String>getMeta("lastMessage"), message)) {
setMeta("lastMessage", message);
this.player.sendMessage(ChatTypes.CHAT, TextSerializers.LEGACY_FORMATTING_CODE.deserialize(message));
}
}
@Override