mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Merge branch '3.4.5' of https://github.com/IntellectualSites/PlotSquared into 3.5.0
This commit is contained in:
commit
85d6e42462
@ -1,5 +1,7 @@
|
||||
package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
@ -14,14 +16,14 @@ public class EntitySpawnListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void creatureSpawnEvent(EntitySpawnEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
Location location = BukkitUtil.getLocation(entity.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlotAbs(location);
|
||||
switch (entity.getType()) {
|
||||
case ENDER_CRYSTAL:
|
||||
Location location = BukkitUtil.getLocation(entity.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlotAbs(location);
|
||||
if (plot == null) {
|
||||
if (!area.MOB_SPAWNING) {
|
||||
event.setCancelled(true);
|
||||
@ -32,5 +34,8 @@ public class EntitySpawnListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -534,6 +534,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
case PAINTING:
|
||||
case ARMOR_STAND:
|
||||
count[5]++;
|
||||
break;
|
||||
// misc
|
||||
case MINECART:
|
||||
case MINECART_CHEST:
|
||||
|
@ -164,7 +164,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
ByteSource is = com.google.common.io.Files.asByteSource(file);
|
||||
NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
||||
if (!compound.containsKey("bukkit")) {
|
||||
PS.debug("ERROR: Player data does not contain the the key \"bukkit\"");
|
||||
PS.debug("ERROR: Player data (" + uuid.toString() + ".dat) does not contain the the key \"bukkit\"");
|
||||
} else {
|
||||
NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
||||
String name = (String) bukkit.get("lastKnownName");
|
||||
|
@ -166,6 +166,9 @@ public class FlagCmd extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(flag == Flags.TIME) {
|
||||
player.setTime(Long.MAX_VALUE);
|
||||
}
|
||||
MainUtil.sendMessage(player, C.FLAG_REMOVED);
|
||||
return true;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
*/
|
||||
@CommandDeclaration(
|
||||
command = "middle",
|
||||
aliases = {"center"},
|
||||
aliases = {"center", "centre"},
|
||||
description = "Teleports you to the center of the plot",
|
||||
usage = "/plot middle",
|
||||
category = CommandCategory.TELEPORT,
|
||||
|
@ -670,7 +670,7 @@ public enum C {
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
if (args.length > 0) {
|
||||
for (int i = args.length - 1; i >= 0; i--) {
|
||||
String arg = args[i].toString();
|
||||
String arg = "" + args[i];
|
||||
if (arg == null || arg.isEmpty()) {
|
||||
map.put("%s" + i, "");
|
||||
} else {
|
||||
|
@ -1816,14 +1816,7 @@ public class SQLManager implements AbstractDB {
|
||||
String[] split = element.split(":");
|
||||
try {
|
||||
String flag_str = split[1].replaceAll("¯", ":").replaceAll("\u00B4", ",");
|
||||
Flag<?> flag = FlagManager.getFlag(split[0],true);
|
||||
if (flag == null) {
|
||||
flag = new StringFlag(split[0]) {
|
||||
@Override public String getValueDescription() {
|
||||
return "Generic Filler Flag";
|
||||
}
|
||||
};
|
||||
}
|
||||
Flag<?> flag = FlagManager.getOrCreateFlag(split[0]);
|
||||
flags.put(flag, flag.parseValue(flag_str));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -1832,7 +1825,7 @@ public class SQLManager implements AbstractDB {
|
||||
} else {
|
||||
element = element.replaceAll("\u00AF", ":").replaceAll("\u00B4", ",");
|
||||
if (StringMan.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) {
|
||||
Flag flag = FlagManager.getFlag(element,true);
|
||||
Flag flag = FlagManager.getOrCreateFlag(element);
|
||||
if (flag == null) {
|
||||
flag = new StringFlag(element) {
|
||||
@Override public String getValueDescription() {
|
||||
@ -2634,7 +2627,7 @@ public class SQLManager implements AbstractDB {
|
||||
if (element.contains(":")) {
|
||||
String[] split = element.split(":");
|
||||
String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("<EFBFBD>", ",");
|
||||
Flag flag = FlagManager.getFlag(split[0],true);
|
||||
Flag flag = FlagManager.getOrCreateFlag(split[0]);
|
||||
if (flag == null) {
|
||||
flag = new StringFlag(split[0]) {
|
||||
@Override public String getValueDescription() {
|
||||
@ -2644,7 +2637,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
flags.put(flag, flag.parseValue(flag_str));
|
||||
} else {
|
||||
Flag flag = FlagManager.getFlag(element,true);
|
||||
Flag flag = FlagManager.getOrCreateFlag(element);
|
||||
if (flag == null) {
|
||||
flag = new StringFlag(element) {
|
||||
@Override public String getValueDescription() {
|
||||
|
@ -9,11 +9,7 @@ public class BooleanFlag extends Flag<Boolean> {
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
if (((boolean) value)) {
|
||||
return "true";
|
||||
} else {
|
||||
return "false";
|
||||
}
|
||||
return value + "";
|
||||
}
|
||||
|
||||
@Override public Boolean parseValue(String value) {
|
||||
|
@ -112,12 +112,17 @@ public class FlagManager {
|
||||
StringBuilder flag_string = new StringBuilder();
|
||||
int i = 0;
|
||||
for (Map.Entry<Flag<?>, Object> entry : flags.entrySet()) {
|
||||
Flag flag = entry.getKey();
|
||||
if (i != 0) {
|
||||
flag_string.append(',');
|
||||
try {
|
||||
Flag flag = entry.getKey();
|
||||
if (i != 0) {
|
||||
flag_string.append(',');
|
||||
}
|
||||
flag_string.append(flag.getName() + ':' + flag.valueToString(entry.getValue()).replaceAll(":", "¯").replaceAll(",", "´"));
|
||||
i++;
|
||||
} catch (Exception e) {
|
||||
PS.debug("Failed to parse flag: " + entry.getKey() + "->" + entry.getValue());
|
||||
e.printStackTrace();
|
||||
}
|
||||
flag_string.append(flag.getName() + ':' + flag.valueToString(entry.getValue()).replaceAll(":", "¯").replaceAll(",", "´"));
|
||||
i++;
|
||||
}
|
||||
return flag_string.toString();
|
||||
}
|
||||
@ -317,6 +322,19 @@ public class FlagManager {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public static Flag<?> getOrCreateFlag(String string) {
|
||||
Flag<?> flag = Flags.getFlag(string);
|
||||
if (flag == null) {
|
||||
flag = new StringFlag(string) {
|
||||
@Override public String getValueDescription() {
|
||||
return "Generic Filler Flag";
|
||||
}
|
||||
};
|
||||
flag.register();
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
public static Map<Flag<?>, Object> parseFlags(List<String> flagStrings) {
|
||||
HashMap<Flag<?>, Object> map = new HashMap<>();
|
||||
|
@ -152,35 +152,25 @@ public final class Flags {
|
||||
|
||||
public static void registerFlag(final Flag<?> flag) {
|
||||
final Flag<?> duplicate = flags.put(flag.getName(), flag);
|
||||
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
||||
@Override public void run(PlotArea value) {
|
||||
if (duplicate != null) {
|
||||
if (duplicate != null) {
|
||||
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
||||
@Override public void run(PlotArea value) {
|
||||
Object remove;
|
||||
if (value.DEFAULT_FLAGS.containsKey(duplicate)) {
|
||||
remove = value.DEFAULT_FLAGS.remove(duplicate);
|
||||
if (!(remove instanceof String)) {
|
||||
//error message? maybe?
|
||||
return;
|
||||
}
|
||||
value.DEFAULT_FLAGS.put(flag,flag.parseValue((String) remove));
|
||||
value.DEFAULT_FLAGS.put(flag,flag.parseValue("" + remove));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
PS.get().foreachPlotRaw(new RunnableVal<Plot>() {
|
||||
@Override public void run(Plot value) {
|
||||
if (duplicate != null) {
|
||||
});
|
||||
PS.get().foreachPlotRaw(new RunnableVal<Plot>() {
|
||||
@Override public void run(Plot value) {
|
||||
Object remove = null;
|
||||
if (value.getFlags().containsKey(duplicate)) {
|
||||
remove = value.getFlags().remove(duplicate);
|
||||
}
|
||||
if (!(remove instanceof String)) {
|
||||
//error message? maybe?
|
||||
return;
|
||||
}
|
||||
value.getFlags().put(flag,flag.parseValue((String) remove));
|
||||
value.getFlags().put(flag,flag.parseValue("" + remove));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +238,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(), false)) {
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -333,7 +333,11 @@ public abstract class Command {
|
||||
if (!cmd.checkArgs(player, newArgs) || !cmd.canExecute(player, true)) {
|
||||
return;
|
||||
}
|
||||
cmd.execute(player, newArgs, confirm, whenDone);
|
||||
try {
|
||||
cmd.execute(player, newArgs, confirm, whenDone);
|
||||
} catch (CommandException e) {
|
||||
e.perform(player);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkArgs(PlotPlayer player, String[] args) {
|
||||
|
@ -209,7 +209,7 @@ public class PlotListener {
|
||||
PlotGameMode gameMode = player.getGameMode();
|
||||
if (gameMode == PlotGameMode.SURVIVAL || gameMode == PlotGameMode.ADVENTURE) {
|
||||
player.setFlight(false);
|
||||
} else if (player.getFlight() != true) {
|
||||
} else if (!player.getFlight()) {
|
||||
player.setFlight(true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user