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