diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/ByteArrayTag.java b/PlotSquared/src/com/intellectualcrafters/jnbt/ByteArrayTag.java index c6efbd9cb..4d0d89322 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/ByteArrayTag.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/ByteArrayTag.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; /** diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/ByteTag.java b/PlotSquared/src/com/intellectualcrafters/jnbt/ByteTag.java index 65e86ec84..46e247e63 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/ByteTag.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/ByteTag.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; /** diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/CompoundTag.java b/PlotSquared/src/com/intellectualcrafters/jnbt/CompoundTag.java index 13dad7121..2052d65b3 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/CompoundTag.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/CompoundTag.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; import java.util.Collections; diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/CompoundTagBuilder.java b/PlotSquared/src/com/intellectualcrafters/jnbt/CompoundTagBuilder.java index 8f1edf183..bdca78428 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/CompoundTagBuilder.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/CompoundTagBuilder.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; import java.util.HashMap; diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/DoubleTag.java b/PlotSquared/src/com/intellectualcrafters/jnbt/DoubleTag.java index e3c9028d6..b660eb681 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/DoubleTag.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/DoubleTag.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; /** diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/EndTag.java b/PlotSquared/src/com/intellectualcrafters/jnbt/EndTag.java index f4a6b49e4..408206b1b 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/EndTag.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/EndTag.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; /** diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/FloatTag.java b/PlotSquared/src/com/intellectualcrafters/jnbt/FloatTag.java index 9d75964c0..ad333dad1 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/FloatTag.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/FloatTag.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; /** diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/IntArrayTag.java b/PlotSquared/src/com/intellectualcrafters/jnbt/IntArrayTag.java index 3359b393a..4c80b1cf7 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/IntArrayTag.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/IntArrayTag.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/IntTag.java b/PlotSquared/src/com/intellectualcrafters/jnbt/IntTag.java index d272cfa15..bea176238 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/IntTag.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/IntTag.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; /** diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/ListTag.java b/PlotSquared/src/com/intellectualcrafters/jnbt/ListTag.java index 8d36aea43..bea5d8158 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/ListTag.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/ListTag.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; import javax.annotation.Nullable; diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/ListTagBuilder.java b/PlotSquared/src/com/intellectualcrafters/jnbt/ListTagBuilder.java index 711e5629e..758bc52eb 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/ListTagBuilder.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/ListTagBuilder.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; import java.util.ArrayList; diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/LongTag.java b/PlotSquared/src/com/intellectualcrafters/jnbt/LongTag.java index 839b0f0cf..19ab6b44f 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/LongTag.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/LongTag.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; /** diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/NBTConstants.java b/PlotSquared/src/com/intellectualcrafters/jnbt/NBTConstants.java index d8b5544f9..f1bef6d4f 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/NBTConstants.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/NBTConstants.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; import java.nio.charset.Charset; diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/NBTInputStream.java b/PlotSquared/src/com/intellectualcrafters/jnbt/NBTInputStream.java index a412a4d74..fc6609f35 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/NBTInputStream.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/NBTInputStream.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; import java.io.Closeable; diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/NBTOutputStream.java b/PlotSquared/src/com/intellectualcrafters/jnbt/NBTOutputStream.java index c982d7817..dc915bcf4 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/NBTOutputStream.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/NBTOutputStream.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; import java.io.Closeable; diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/NBTUtils.java b/PlotSquared/src/com/intellectualcrafters/jnbt/NBTUtils.java index 19a62bfb6..611f109df 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/NBTUtils.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/NBTUtils.java @@ -1,30 +1,7 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; import java.util.Map; -import com.sun.media.sound.InvalidFormatException; - -import static com.google.common.base.Preconditions.checkNotNull; - /** * A class which contains NBT-related utility methods. * @@ -160,13 +137,13 @@ public final class NBTUtils { * @return child tag * @throws InvalidFormatException */ - public static T getChildTag(Map items, String key, Class expected) throws InvalidFormatException { + public static T getChildTag(Map items, String key, Class expected) throws IllegalArgumentException { if (!items.containsKey(key)) { - throw new InvalidFormatException("Missing a \"" + key + "\" tag"); + throw new IllegalArgumentException("Missing a \"" + key + "\" tag"); } Tag tag = items.get(key); if (!expected.isInstance(tag)) { - throw new InvalidFormatException(key + " tag is not of tag type " + expected.getName()); + throw new IllegalArgumentException(key + " tag is not of tag type " + expected.getName()); } return expected.cast(tag); } diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/ShortTag.java b/PlotSquared/src/com/intellectualcrafters/jnbt/ShortTag.java index c48e4198b..e488968d1 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/ShortTag.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/ShortTag.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; /** diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/StringTag.java b/PlotSquared/src/com/intellectualcrafters/jnbt/StringTag.java index 1e5c06a98..6a66458eb 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/StringTag.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/StringTag.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/PlotSquared/src/com/intellectualcrafters/jnbt/Tag.java b/PlotSquared/src/com/intellectualcrafters/jnbt/Tag.java index a1ea70e83..2fab21bd2 100644 --- a/PlotSquared/src/com/intellectualcrafters/jnbt/Tag.java +++ b/PlotSquared/src/com/intellectualcrafters/jnbt/Tag.java @@ -1,22 +1,3 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - package com.intellectualcrafters.jnbt; /** diff --git a/PlotSquared/src/com/intellectualcrafters/plot/C.java b/PlotSquared/src/com/intellectualcrafters/plot/C.java index 41be88e8b..e02ee649e 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/C.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/C.java @@ -68,7 +68,7 @@ public enum C { /* * Schematic Stuff */ - SCHEMATIC_MISSING_ARG("&cYou need to specify an argument. Possible values: &6test "), + SCHEMATIC_MISSING_ARG("&cYou need to specify an argument. Possible values: &6test &7 , &6save&7 , &6paste &7, &6exportall"), SCHEMATIC_INVALID("&cThat is not a valid schematic. Reason: &c%s"), SCHEMATIC_VALID("&cThat is a valid schematic"), SCHEMATIC_PASTE_FAILED("&cFailed to paste the schematic"), @@ -207,7 +207,19 @@ public enum C { * Info */ PLOT_INFO_UNCLAIMED("&cPlot &6%s&c is not yet claimed"), - PLOT_INFO("ID: &6%id%&c, Alias: &6%alias%&c, Owner: &6%owner%&c, Biome: &6%biome%&c, Helpers:&6%helpers%&c, Trusted:&6%trusted%&c, Denied:&6%denied%&c, Rating: &6%rating%&c, Flags: &6%flags%"), + PLOT_INFO("&6ID&7: &a%id%&7\n&6Alias&7: &a%alias%\n&6Owner&7: &a%owner%\n&6Description&7: &a%desc%\n&6Rating&7: &a%rating%&7/&a10\n&6Can build&7: &a%build%"), + + PLOT_INFO_HELPERS("&6Helpers&7: %helpers%"), + PLOT_INFO_TRUSTED("&6Trusted&7: %trusted%"), + PLOT_INFO_DENIED("&6DENIED&7: %denied%"), + PLOT_INFO_FLAGS("&6Flags&7: %flags%"), + PLOT_INFO_BIOME("&6Biome&7: %biome%"), + PLOT_INFO_RATING("&6Rating&7: %rating%"), + PLOT_INFO_OWNER("&6Owner&7: %owner%"), + PLOT_INFO_ID("&6ID&7: %id%"), + PLOT_INFO_ALIAS("&6Alias&7: %alias%"), + PLOT_INFO_SIZE("&6Size&7: %size%"), + PLOT_USER_LIST(" &6%user%&c,"), INFO_SYNTAX_CONSOLE("/plot info X;Y"), /* diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Configuration.java b/PlotSquared/src/com/intellectualcrafters/plot/Configuration.java index 2bbb26e7a..53b9c4482 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Configuration.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Configuration.java @@ -3,6 +3,7 @@ package com.intellectualcrafters.plot; import java.util.ArrayList; import java.util.List; +import org.bukkit.Bukkit; import org.bukkit.block.Biome; public class Configuration { @@ -147,12 +148,29 @@ public class Configuration { return ((PlotBlock) object).id + ":" + ((PlotBlock) object).data; } }; + + public static int gcd(int a, int b) { + if (b==0) return a; + return gcd(b,a%b); + } + private static int gcd(int[] a) + { + int result = a[0]; + for(int i = 1; i < a.length; i++) + result = gcd(result, a[i]); + return result; + } public static final SettingValue BLOCKLIST = new SettingValue("BLOCKLIST") { @Override public boolean validateValue(String string) { try { for (String block : string.split(",")) { + if (block.contains("%")) { + String[] split = block.split("%"); + Integer.parseInt(split[0]); + block = split[1]; + } if (block.contains(":")) { String[] split = block.split(":"); Short.parseShort(split[0]); @@ -172,8 +190,28 @@ public class Configuration { @Override public Object parseString(String string) { String[] blocks = string.split(","); + ArrayList parsedvalues = new ArrayList(); + + PlotBlock[] values = new PlotBlock[blocks.length]; + int[] counts = new int[blocks.length]; + int min = 100; for (int i = 0; i < blocks.length; i++) { + if (blocks[i].contains("%")) { + String[] split = blocks[i].split("%"); + blocks[i] = split[1]; + int value = Integer.parseInt(split[0]); + counts[i] = value; + if (value 48) { throw new IllegalArgumentException("Value must be <= 48 characters"); } this.key = key; - this.value = value; + this.value = key.parseValue(value); + if (this.value==null) { + throw new IllegalArgumentException(key.getValueDesc()); + } } /** diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlayerFunctions.java b/PlotSquared/src/com/intellectualcrafters/plot/PlayerFunctions.java index ce0e10ed7..97bec2db9 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlayerFunctions.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlayerFunctions.java @@ -182,7 +182,14 @@ public class PlayerFunctions { * @return */ public static int getPlayerPlotCount(World world, Player plr) { - return getPlayerPlots(world, plr).size(); + UUID uuid = plr.getUniqueId(); + int count = 0; + for (Plot plot: PlotMain.getPlots(world).values()) { + if (plot.hasOwner() && plot.owner.equals(uuid) && plot.countsTowardsMax) { + count++; + } + } + return count; } /** diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Plot.java b/PlotSquared/src/com/intellectualcrafters/plot/Plot.java index ddcf159f0..f4a5af227 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Plot.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Plot.java @@ -65,6 +65,7 @@ public class Plot implements Cloneable { * Has the plot changed since the last save cycle? */ public boolean hasChanged = false; + public boolean countsTowardsMax = true ; /** * Primary constructor diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java index 18636934c..12e53a0ce 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java @@ -1078,6 +1078,7 @@ public class PlotMain extends JavaPlugin { options.put("kill_road_mobs", Settings.KILL_ROAD_MOBS_DEFAULT); options.put("mob_pathfinding", Settings.MOB_PATHFINDING_DEFAULT); options.put("web.enabled", Web.ENABLED); + options.put("web.directory", "/var/www"); options.put("web.port", Web.PORT); options.put("metrics", true); options.put("debug", true); @@ -1097,6 +1098,7 @@ public class PlotMain extends JavaPlugin { } Web.ENABLED = config.getBoolean("web.enabled"); Web.PORT = config.getInt("web.port"); + Web.PATH = config.getString("web.directory"); Settings.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs"); Settings.WORLDGUARD = config.getBoolean("worldguard.enabled"); Settings.MOB_PATHFINDING = config.getBoolean("mob_pathfinding"); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotSettings.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotSettings.java index 6fdd88f9d..d61617a92 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotSettings.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotSettings.java @@ -10,6 +10,8 @@ package com.intellectualcrafters.plot; import org.bukkit.block.Biome; +import com.intellectualcrafters.plot.database.DBFunc; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/SchematicHandler.java b/PlotSquared/src/com/intellectualcrafters/plot/SchematicHandler.java index 3fa4a1e5a..2280d0e8d 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/SchematicHandler.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/SchematicHandler.java @@ -23,7 +23,7 @@ import java.util.zip.GZIPInputStream; */ public class SchematicHandler { - public boolean paste(Location location, Schematic schematic, Plot plot) { + public static boolean paste(Location location, Schematic schematic, Plot plot) { if (schematic == null) { PlotMain.sendConsoleSenderMessage("Schematic == null :|"); return false; @@ -71,7 +71,7 @@ public class SchematicHandler { return true; } - public Schematic getSchematic(String name) { + public static Schematic getSchematic(String name) { { File parent = new File(JavaPlugin.getPlugin(PlotMain.class).getDataFolder() + File.separator + "schematics"); @@ -163,7 +163,7 @@ public class SchematicHandler { } } - public class Dimension { + public static class Dimension { private int x; private int y; private int z; @@ -193,7 +193,7 @@ public class SchematicHandler { * @param path * @return */ - public boolean save(CompoundTag tag, String path) { + public static boolean save(CompoundTag tag, String path) { if (tag==null) { PlotMain.sendConsoleSenderMessage("&cCannot save empty tag"); @@ -219,18 +219,21 @@ public class SchematicHandler { * @param plot * @return */ - public CompoundTag getCompoundTag(World world, Plot plot) { + public static CompoundTag getCompoundTag(World world, PlotId id) { - if (!PlotMain.getPlots(world).containsKey(plot.id)) { + if (!PlotMain.getPlots(world).containsKey(id)) { return null; // Plot is empty } // loading chunks - final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); - final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); - for (int i = (pos1.getBlockX() / 16) * 16; i < (16 + ((pos2.getBlockX() / 16) * 16)); i += 16) { - for (int j = (pos1.getBlockZ() / 16) * 16; j < (16 + ((pos2.getBlockZ() / 16) * 16)); j += 16) { + final Location pos1 = PlotHelper.getPlotBottomLoc(world, id).add(1, 0, 1); + final Location pos2 = PlotHelper.getPlotTopLoc(world, id); + int i = 0; + int j = 0; + try { + for (i = (pos1.getBlockX() / 16) * 16; i < (16 + ((pos2.getBlockX() / 16) * 16)); i += 16) { + for (j = (pos1.getBlockZ() / 16) * 16; j < (16 + ((pos2.getBlockZ() / 16) * 16)); j += 16) { Chunk chunk = world.getChunkAt(i, j); boolean result = chunk.load(false); if (!result) { @@ -241,6 +244,11 @@ public class SchematicHandler { } } } + } + catch (Exception e) { + PlotMain.sendConsoleSenderMessage("&7 - Cannot save: corrupt chunk at "+(i/16)+", "+(j/16)); + return null; + } int width = pos2.getBlockX()-pos1.getBlockX(); int height = 256; int length = pos2.getBlockZ()-pos1.getBlockZ(); @@ -268,19 +276,19 @@ public class SchematicHandler { Block block = world.getBlockAt(new Location(world, pos1.getBlockX() + x, 0 + y, pos1.getBlockZ() + z)); - int id = block.getTypeId(); + int id2 = block.getTypeId(); - if (id > 255) { + if (id2 > 255) { if (addBlocks == null) { addBlocks = new byte[(blocks.length >> 1) + 1]; } addBlocks[index >> 1] = (byte) (((index & 1) == 0) ? - addBlocks[index >> 1] & 0xF0 | (id >> 8) & 0xF - : addBlocks[index >> 1] & 0xF | ((id >> 8) & 0xF) << 4); + addBlocks[index >> 1] & 0xF0 | (id2 >> 8) & 0xF + : addBlocks[index >> 1] & 0xF | ((id2 >> 8) & 0xF) << 4); } - blocks[index] = (byte) id; + blocks[index] = (byte) id2; blockData[index] = (byte) block.getData(); @@ -300,7 +308,7 @@ public class SchematicHandler { return schematicTag; } - public class DataCollection { + public static class DataCollection { private short block; private byte data; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Settings.java b/PlotSquared/src/com/intellectualcrafters/plot/Settings.java index dd302a1c7..29ff27347 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Settings.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Settings.java @@ -73,6 +73,7 @@ public class Settings { public static class Web { public static boolean ENABLED = false; public static int PORT = 9000; + public static String PATH = "/var/www"; } /** diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Info.java index caf3f5189..fb3189988 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Info.java @@ -10,7 +10,9 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.database.DBFunc; + import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.time.DateUtils; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; @@ -31,9 +33,10 @@ public class Info extends SubCommand { @Override public boolean execute(Player player, String... args) { - + World world; Plot plot; if (player!=null) { + world = player.getWorld(); if (!PlayerFunctions.isInPlot(player)) { PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); return false; @@ -41,7 +44,7 @@ public class Info extends SubCommand { plot = PlayerFunctions.getCurrentPlot(player); } else { - if (args.length!=2) { + if (args.length<2) { PlayerFunctions.sendMessage(player, C.INFO_SYNTAX_CONSOLE); return false; } @@ -56,6 +59,14 @@ public class Info extends SubCommand { plot = PlotHelper.getPlot(Bukkit.getWorld(plotworld.worldname), id); if (plot==null) { PlayerFunctions.sendMessage(player, C.NOT_VALID_PLOT_ID); + return false; + } + world = Bukkit.getWorld(args[0]); + if (args.length==3) { + args = new String[] {args[2]}; + } + else { + args = new String[0]; } } catch (Exception e) { @@ -86,12 +97,10 @@ public class Info extends SubCommand { // Unclaimed? if (!hasOwner && !containsEveryone && !trustedEveryone) { - PlayerFunctions.sendMessage(player, C.PLOT_INFO_UNCLAIMED, plot.id.x + ";" + plot.id.y); + PlayerFunctions.sendMessage(player, C.PLOT_INFO_UNCLAIMED, (plot.id.x + ";" + plot.id.y)); return true; } - new StringBuilder(); - String owner = "none"; if (plot.owner != null) { owner = Bukkit.getOfflinePlayer(plot.owner).getName(); @@ -99,27 +108,88 @@ public class Info extends SubCommand { if (owner == null) { owner = plot.owner.toString(); } - String info = C.PLOT_INFO.s(); - info = info.replaceAll("%alias%", plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none"); - info = info.replaceAll("%id%", plot.id.toString()); - info = info.replaceAll("%biome%", getBiomeAt(plot).toString()); - info = info.replaceAll("%owner%", owner); - info = info.replaceAll("%helpers%", getPlayerList(plot.helpers)); - info = info.replaceAll("%trusted%", getPlayerList(plot.trusted)); - info = info.replaceAll("%denied%", getPlayerList(plot.denied)); - info = info.replaceAll("%rating%", "" + DBFunc.getRatings(plot)); - info = - info.replaceAll("%flags%", StringUtils.join(plot.settings.getFlags(), "").length() > 0 - ? StringUtils.join(plot.settings.getFlags(), ",") : "none"); - // PlayerFunctions.sendMessage(player, - // PlayerFunctions.getTopPlot(player.getWorld(), plot).id.toString()); - // PlayerFunctions.sendMessage(player, - // PlayerFunctions.getBottomPlot(player.getWorld(), - // plot).id.toString()); + + if (args.length==1) { + info = getCaption(args[0].toLowerCase()); + if (info==null) { + PlayerFunctions.sendMessage(player, "&6Categories&7: &ahelpers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating"); + return false; + } + } + + info = format(info, world, plot, player); + PlayerFunctions.sendMessage(player, info); return true; } + + private String getCaption(String string) { + switch (string) { + case "helpers": + return C.PLOT_INFO_HELPERS.s(); + case "alias": + return C.PLOT_INFO_ALIAS.s(); + case "biome": + return C.PLOT_INFO_BIOME.s(); + case "denied": + return C.PLOT_INFO_DENIED.s(); + case "flags": + return C.PLOT_INFO_FLAGS.s(); + case "id": + return C.PLOT_INFO_ID.s(); + case "size": + return C.PLOT_INFO_SIZE.s(); + case "trusted": + return C.PLOT_INFO_TRUSTED.s(); + case "owner": + return C.PLOT_INFO_OWNER.s(); + case "rating": + return C.PLOT_INFO_RATING.s(); + default: + return null; + } + } + + private String format(String info, World world, Plot plot, Player player) { + + PlotId id = plot.id; + PlotId id2 = PlayerFunctions.getTopPlot(world, plot).id; + int num = PlayerFunctions.getPlotSelectionIds(world, id, id2).size(); + String alias = plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none"; + String biome = getBiomeAt(plot).toString(); + String helpers = getPlayerList(plot.helpers); + String trusted = getPlayerList(plot.trusted); + String denied = getPlayerList(plot.denied); + String rating = String.format("%.1f", DBFunc.getRatings(plot)); + String flags = "&3"+ (StringUtils.join(plot.settings.getFlags(), "").length() > 0 ? StringUtils.join(plot.settings.getFlags(), "&7, &3") : "none"); + boolean build = player==null ? true : plot.hasRights(player); + + String owner = "none"; + if (plot.owner != null) { + owner = Bukkit.getOfflinePlayer(plot.owner).getName(); + } + if (owner == null) { + owner = plot.owner.toString(); + } + + info = info.replaceAll("%alias%", alias); + info = info.replaceAll("%id%", id.toString()); + info = info.replaceAll("%id2%", id2.toString()); + info = info.replaceAll("%num%", num+""); + info = info.replaceAll("%biome%", biome); + info = info.replaceAll("%owner%", owner); + info = info.replaceAll("%helpers%", helpers); + info = info.replaceAll("%trusted%", trusted); + info = info.replaceAll("%denied%", denied); + info = info.replaceAll("%rating%", rating); + info = info.replaceAll("%flags%", flags); + info = info.replaceAll("%build%", build+""); + info = info.replaceAll("%desc%", "No description set."); + + + return info; + } private String getPlayerList(ArrayList l) { if ((l == null) || (l.size() < 1)) { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Schematic.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Schematic.java index f5b64e951..981dbb663 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Schematic.java @@ -1,32 +1,62 @@ package com.intellectualcrafters.plot.commands; -import org.bukkit.entity.Player; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +import com.intellectualcrafters.jnbt.CompoundTag; import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.PlayerFunctions; import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.PlotHelper; +import com.intellectualcrafters.plot.PlotId; +import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.SchematicHandler; +import com.intellectualcrafters.plot.Settings; +import com.intellectualcrafters.plot.UUIDHandler; +import com.intellectualcrafters.plot.database.DBFunc; +import com.sun.org.apache.xerces.internal.impl.xs.identity.ValueStore; public class Schematic extends SubCommand { public Schematic() { - super("schematic", "plots.admin", "Schematic Command", "schematic {arg}", "sch", CommandCategory.ACTIONS, true); + super("schematic", "plots.admin", "Schematic Command", "schematic {arg}", "sch", CommandCategory.ACTIONS, false); // TODO command to fetch schematic from worldedit directory } - + + private int counter = 0; + private boolean running = false; + private Plot[] plots; + private int task; + + + + @Override - public boolean execute(Player plr, String... args) { + public boolean execute(final Player plr, String... args) { if (args.length < 1) { sendMessage(plr, C.SCHEMATIC_MISSING_ARG); return true; } - String arg = args[0]; + String arg = args[0].toLowerCase(); String file; SchematicHandler.Schematic schematic; switch (arg) { case "paste": + if (plr==null) { + PlotMain.sendConsoleSenderMessage(C.IS_CONSOLE); + return false; + } + if (!PlotMain.hasPermission(plr, "plots.schematic.save")) { + PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.paste"); + return false; + } if (args.length < 2) { sendMessage(plr, C.SCHEMATIC_MISSING_ARG); break; @@ -36,8 +66,8 @@ public class Schematic extends SubCommand { break; } file = args[1]; - schematic = new SchematicHandler().getSchematic(file); - boolean s = new SchematicHandler().paste(plr.getLocation(), schematic, PlayerFunctions.getCurrentPlot(plr)); + schematic = SchematicHandler.getSchematic(file); + boolean s = SchematicHandler.paste(plr.getLocation(), schematic, PlayerFunctions.getCurrentPlot(plr)); if (s) { sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS); } @@ -46,12 +76,20 @@ public class Schematic extends SubCommand { } break; case "test": + if (plr==null) { + PlotMain.sendConsoleSenderMessage(C.IS_CONSOLE); + return false; + } + if (!PlotMain.hasPermission(plr, "plots.schematic.save")) { + PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.test"); + return false; + } if (args.length < 2) { sendMessage(plr, C.SCHEMATIC_MISSING_ARG); break; } file = args[1]; - schematic = new SchematicHandler().getSchematic(file); + schematic = SchematicHandler.getSchematic(file); if (schematic == null) { sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent"); break; @@ -69,6 +107,167 @@ public class Schematic extends SubCommand { } sendMessage(plr, C.SCHEMATIC_VALID); break; + case "saveall": + case "exportall": + if (plr!=null) { + PlayerFunctions.sendMessage(plr, C.NOT_CONSOLE); + return false; + } + if (args.length!=2) { + PlayerFunctions.sendMessage(plr, "&cNeed world arg. Use &7/plots sch exportall "); + return false; + } + HashMap plotmap = PlotMain.getPlots(args[1]); + if (plotmap==null || plotmap.size()==0) { + PlayerFunctions.sendMessage(plr, "&cInvalid world. Use &7/plots sch exportall "); + return false; + } + if (running) { + PlayerFunctions.sendMessage(plr, "&cTask is already running."); + return false; + } + + PlotMain.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while."); + PlotMain.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &7Found &c"+plotmap.size()+"&7 plots..."); + final World worldObj = Bukkit.getWorld(args[1]); + final String worldname = Bukkit.getWorld(args[1]).getName(); + + final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"); + + + this.plots = plotmap.values().toArray(new Plot[0]); + this.running = true; + this.counter = 0; + + task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { + @Override + public void run() { + if (counter>=plots.length) { + PlotMain.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &aFinished!"); + running = false; + Bukkit.getScheduler().cancelTask(task); + return; + } + final Plot plot = plots[counter]; + final CompoundTag sch = SchematicHandler.getCompoundTag(worldObj, plot.id); + String o = UUIDHandler.getName(plot.owner); + final String owner = o==null ? "unknown" : o ; + if (sch==null) { + PlayerFunctions.sendMessage(plr, "&7 - Skipped plot &c"+plot.id); + } + else { + Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"), new Runnable() { + @Override + public void run() { + counter++; + PlayerFunctions.sendMessage(plr, "&6ID: "+plot.id); + boolean result = SchematicHandler.save(sch, Settings.Web.PATH+"/"+plot.id.x+","+plot.id.y+","+worldname+","+owner+".schematic"); + + if (!result) { + PlayerFunctions.sendMessage(plr, "&7 - Failed to save &c"+plot.id); + } + else { + PlayerFunctions.sendMessage(plr, "&7 - &aExport success: "+plot.id); + } + } + }); + } + counter++; + } + }, 20, 20); + break; + case "export": + case "save": + if (!PlotMain.hasPermission(plr, "plots.schematic.save")) { + PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save"); + return false; + } + if (running) { + PlayerFunctions.sendMessage(plr, "&cTask is already running."); + return false; + } + final String world; + final Plot p2; + if (plr!=null) { + if(!PlayerFunctions.isInPlot(plr)) { + sendMessage(plr, C.NOT_IN_PLOT); + return false; + } + Plot myplot = PlayerFunctions.getCurrentPlot(plr); + if(!myplot.hasRights(plr)) { + sendMessage(plr, C.NO_PLOT_PERMS); + return false; + } + p2 = myplot; + world = plr.getWorld().getName(); + } + else { + if (args.length==3) { + try { + world = args[0]; + String[] split = args[2].split(";"); + PlotId i = new PlotId(Integer.parseInt(split[0]),Integer.parseInt(split[1])); + if (PlotMain.getPlots(world)==null || PlotMain.getPlots(world).get(i) == null) { + PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save "); + return false; + } + p2 = PlotMain.getPlots(world).get(i); + } + catch (Exception e) { + PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save "); + return false; + } + } + else { + PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save "); + return false; + } + } + + final Plugin plugin2 = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"); + + + this.plots = new Plot[] {p2} ; + this.running = true; + this.counter = 0; + + task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin2, new Runnable() { + @Override + public void run() { + if (counter>=plots.length) { + PlotMain.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &aFinished!"); + running = false; + Bukkit.getScheduler().cancelTask(task); + return; + } + final Plot plot = plots[counter]; + final CompoundTag sch = SchematicHandler.getCompoundTag(Bukkit.getWorld(world), plot.id); + String o = UUIDHandler.getName(plot.owner); + final String owner = o==null ? "unknown" : o ; + if (sch==null) { + PlayerFunctions.sendMessage(plr, "&7 - Skipped plot &c"+plot.id); + } + else { + Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"), new Runnable() { + @Override + public void run() { + counter++; + PlayerFunctions.sendMessage(plr, "&6ID: "+plot.id); + boolean result = SchematicHandler.save(sch, Settings.Web.PATH+"/"+plot.id.x+","+plot.id.y+","+world+","+owner+".schematic"); + + if (!result) { + PlayerFunctions.sendMessage(plr, "&7 - Failed to save &c"+plot.id); + } + else { + PlayerFunctions.sendMessage(plr, "&7 - &aExport success: "+plot.id); + } + } + }); + } + counter++; + } + }, 20, 60); + break; default: sendMessage(plr, C.SCHEMATIC_MISSING_ARG); break; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java index 5204dd414..e5eac2f8c 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java @@ -91,13 +91,13 @@ public class Set extends SubCommand { return false; } - AbstractFlag af = new AbstractFlag(""); + AbstractFlag af; try { - af = new AbstractFlag(args[1].toLowerCase()); + af = FlagManager.getFlag(args[1].toLowerCase()); } catch (Exception e) { - + af = new AbstractFlag(args[1].toLowerCase()); } if (!FlagManager.getFlags().contains(af) && ((PlotMain.worldGuardListener == null) || !PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase()))) { @@ -141,7 +141,6 @@ public class Set extends SubCommand { try { String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); value = af.parseValue(value); - if (value==null) { PlayerFunctions.sendMessage(plr, af.getValueDesc()); return false; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/SetOwner.java index dd25ee01b..6b08e9f7c 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/SetOwner.java @@ -51,6 +51,11 @@ public class SetOwner extends SubCommand { PlotMain.updatePlot(plot); DBFunc.setOwner(plot, plot.owner); PlayerFunctions.sendMessage(plr, C.SET_OWNER); + + if (PlotMain.worldGuardListener!=null) { + PlotMain.worldGuardListener.changeOwner(plr, plot.owner, plr.getWorld(), plot); + } + return true; } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/list.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/list.java index f60431414..df09855e6 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/list.java @@ -72,7 +72,7 @@ public class list extends SubCommand { + "\n"); } } - string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", PlotMain.getPlots().size() + string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There are").replaceAll("%num%", PlotMain.getPlots().size() + "").replaceAll("%plot%", PlotMain.getPlots().size() == 1 ? "plot" : "plots")); PlayerFunctions.sendMessage(plr, string.toString()); return true; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java index 00bbe70da..9e06bd96e 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java @@ -8,15 +8,15 @@ package com.intellectualcrafters.plot.database; -import com.intellectualcrafters.plot.Flag; -import com.intellectualcrafters.plot.Plot; -import com.intellectualcrafters.plot.PlotId; -import org.bukkit.OfflinePlayer; - import java.util.ArrayList; import java.util.HashMap; import java.util.UUID; +import org.bukkit.OfflinePlayer; +import com.intellectualcrafters.plot.Flag; +import com.intellectualcrafters.plot.Plot; +import com.intellectualcrafters.plot.PlotId; + /** * @author Citymonstret */ diff --git a/PlotSquared/src/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/com/intellectualcrafters/plot/database/SQLManager.java index b813adf8e..04eeebe79 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/database/SQLManager.java @@ -22,6 +22,7 @@ import java.util.HashSet; import java.util.Set; import java.util.UUID; +import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.block.Biome; @@ -431,16 +432,28 @@ public class SQLManager extends AbstractDB { else { flags_string = ((String) settings.get("flags")).split(","); } - Flag[] flags = new Flag[flags_string.length]; - for (int i = 0; i < flags.length; i++) { + ArrayList flags = new ArrayList(); + boolean exception = false; + for (int i = 0; i < flags_string.length; i++) { if (flags_string[i].contains(":")) { String[] split = flags_string[i].split(":"); - flags[i] = new Flag(FlagManager.getFlag(split[0], true), split[1]); + try { + flags.add(new Flag(FlagManager.getFlag(split[0], true), split[1])); + } + catch (Exception e) { + exception = true; + // invalid flag... ignoring it for now. + } } else { - flags[i] = new Flag(FlagManager.getFlag(flags_string[i], true), ""); + flags.add(new Flag(FlagManager.getFlag(flags_string[i], true), "")); } } + + if (exception) { + setFlags(worldname, id, flags.toArray(new Flag[0])); + } + ArrayList helpers = plotHelpers(id); ArrayList trusted = plotTrusted(id); ArrayList denied = plotDenied(id); @@ -468,8 +481,7 @@ public class SQLManager extends AbstractDB { for (int i = 0; i < 4; i++) { merged[3 - i] = (merged_int & (1 << i)) != 0; } - p = - new Plot(plot_id, owner, plotBiome, helpers, trusted, denied, alias, position, flags, worldname, merged); + p = new Plot(plot_id, owner, plotBiome, helpers, trusted, denied, alias, position, flags.toArray(new Flag[0]), worldname, merged); if (plots.containsKey(worldname)) { plots.get(worldname).put((plot_id), p); } @@ -556,6 +568,33 @@ public class SQLManager extends AbstractDB { } }); } + + public void setFlags(final String world, final int id, final Flag[] flags) { + ArrayList newflags = new ArrayList(); + for (Flag flag : flags) { + if (flag!=null && flag.getKey()!=null && !flag.getKey().equals("")) { + newflags.add(flag); + } + } + final String flag_string = StringUtils.join(newflags,","); + runTask(new Runnable() { + @Override + public void run() { + try { + PreparedStatement stmt = + connection.prepareStatement("UPDATE `plot_settings` SET `flags` = ? WHERE `plot_plot_id` = ?"); + stmt.setString(1, flag_string); + stmt.setInt(2, id); + stmt.execute(); + stmt.close(); + } + catch (SQLException e) { + e.printStackTrace(); + Logger.add(LogLevel.WARNING, "Could not set flag for plot " + id); + } + } + }); + } /** * @param plot diff --git a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 8bbcf8ce2..d68f210a0 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -451,7 +451,6 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (event.getEntity() instanceof Player) { return; } - System.out.print(event.getEntityType().getName()); if (!isInPlot(event.getLocation())) { event.setCancelled(true); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlotListener.java b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlotListener.java index d6a45f709..71de3e21c 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -3,9 +3,12 @@ package com.intellectualcrafters.plot.listeners; import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent; import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; + import org.bukkit.*; import org.bukkit.block.Biome; +import org.bukkit.block.Block; import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; import java.util.ArrayList; import java.util.Arrays; @@ -45,6 +48,21 @@ public class PlotListener { public static UUID getUUID(String name) { return UUIDHandler.getUUID(name); } + + // unused + public static void blockChange(Block block, Cancellable event) { + Location loc = block.getLocation(); + String world = loc.getWorld().getName(); + PlotManager manager = PlotMain.getPlotManager(world); + if (manager!=null) { + PlotWorld plotworld = PlotMain.getWorldSettings(world); + PlotId id = manager.getPlotId(plotworld, loc); + if (id==null) { + event.setCancelled(true); + } + } + return; + } public static boolean enteredPlot(Location l1, Location l2) { PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getBlockX(), 64, l1.getBlockZ())); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldGuardListener.java b/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldGuardListener.java index aa6f4221b..7c49688f2 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldGuardListener.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldGuardListener.java @@ -2,6 +2,7 @@ package com.intellectualcrafters.plot.listeners; import java.util.ArrayList; import java.util.Map; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -15,6 +16,7 @@ import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.PlotHelper; import com.intellectualcrafters.plot.PlotId; import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.UUIDHandler; import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.events.PlotMergeEvent; @@ -41,6 +43,22 @@ public class WorldGuardListener implements Listener { this.flags.add(flag); } } + public void changeOwner(Player requester, UUID owner, World world, Plot plot) { + boolean op = requester.isOp(); + requester.setOp(true); + try { + RegionManager manager = PlotMain.worldGuard.getRegionManager(world); + manager.getRegion(plot.id.x + "-" + plot.id.y); + requester.performCommand("region setowner " + (plot.id.x + "-" + plot.id.y) + " " + UUIDHandler.getName(owner)); + requester.performCommand("region removeowner " + (plot.id.x + "-" + plot.id.y) + " " + UUIDHandler.getName(plot.getOwner())); + } + catch (Exception e) { + requester.setOp(op); + } + finally { + requester.setOp(op); + } + } public void removeFlag(Player requester, World world, Plot plot, String key) { boolean op = requester.isOp(); @@ -48,7 +66,7 @@ public class WorldGuardListener implements Listener { try { RegionManager manager = PlotMain.worldGuard.getRegionManager(world); manager.getRegion(plot.id.x + "-" + plot.id.y); - for (Flag flag : this.flags) { + for (Flag flag : this.flags) { if (flag.getName().equalsIgnoreCase(key)) { requester.performCommand("region flag " + (plot.id.x + "-" + plot.id.y) + " " + key); } @@ -68,7 +86,7 @@ public class WorldGuardListener implements Listener { try { RegionManager manager = PlotMain.worldGuard.getRegionManager(world); manager.getRegion(plot.id.x + "-" + plot.id.y); - for (Flag flag : this.flags) { + for (Flag flag : this.flags) { if (flag.getName().equalsIgnoreCase(key)) { requester.performCommand("region flag " + (plot.id.x + "-" + plot.id.y) + " " + key + " " + value); } diff --git a/PlotSquared/src/plugin.yml b/PlotSquared/src/plugin.yml index 1a27cbd72..ed8bc74e6 100644 --- a/PlotSquared/src/plugin.yml +++ b/PlotSquared/src/plugin.yml @@ -1,6 +1,6 @@ name: PlotSquared main: com.intellectualcrafters.plot.PlotMain -version: 2.1.1 +version: 2.1.2 load: STARTUP description: > Easy, yet powerful Plot World generation and management.