Merge remote-tracking branch 'origin/master'

This commit is contained in:
Sauilitired 2014-10-25 14:46:21 +02:00
commit 3e7a52f263
39 changed files with 504 additions and 440 deletions

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
/**

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
/**

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
import java.util.Collections;

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
import java.util.HashMap;

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
/**

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
/**

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
/**

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
import static com.google.common.base.Preconditions.checkNotNull;

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
/**

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
import javax.annotation.Nullable;

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
import java.util.ArrayList;

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
/**

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
import java.nio.charset.Charset;

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
import java.io.Closeable;

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
import java.io.Closeable;

View File

@ -1,30 +1,7 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
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 extends Tag> T getChildTag(Map<String, Tag> items, String key, Class<T> expected) throws InvalidFormatException {
public static <T extends Tag> T getChildTag(Map<String, Tag> items, String key, Class<T> 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);
}

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
/**

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
import static com.google.common.base.Preconditions.checkNotNull;

View File

@ -1,22 +1,3 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.intellectualcrafters.jnbt;
/**

View File

@ -68,7 +68,7 @@ public enum C {
/*
* Schematic Stuff
*/
SCHEMATIC_MISSING_ARG("&cYou need to specify an argument. Possible values: &6test <name>"),
SCHEMATIC_MISSING_ARG("&cYou need to specify an argument. Possible values: &6test <name>&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 <world> X;Y"),
/*

View File

@ -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 {
@ -148,11 +149,28 @@ public class Configuration {
}
};
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<PlotBlock> parsedvalues = new ArrayList<PlotBlock>();
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<min) {
min = value;
}
}
else {
counts[i] = 1;
if (1<min) {
min = 1;
}
}
if (blocks[i].contains(":")) {
String[] split = blocks[i].split(":");
values[i] = new PlotBlock(Short.parseShort(split[0]), Byte.parseByte(split[1]));
@ -182,7 +220,15 @@ public class Configuration {
values[i] = new PlotBlock(Short.parseShort(blocks[i]), (byte) 0);
}
}
return values;
int gcd = gcd(counts);
for (int i = 0; i < counts.length; i++) {
int num = counts[i];
for (int j = 0; j<num/gcd; j++) {
parsedvalues.add(values[i]);
}
}
return parsedvalues.toArray(new PlotBlock[0]);
}
@Override

View File

@ -21,14 +21,17 @@ public class Flag {
* if you provide inadequate inputs
*/
public Flag(AbstractFlag key, String value) {
if (!StringUtils.isAlphanumericSpace(ChatColor.stripColor(value))) {
if (!StringUtils.isAlphanumericSpace(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', value)))) {
throw new IllegalArgumentException("Flag must be alphanumerical");
}
if (value.length() > 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());
}
}
/**

View File

@ -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;
}
/**

View File

@ -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

View File

@ -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");

View File

@ -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;

View File

@ -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;

View File

@ -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";
}
/**

View File

@ -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,28 +108,89 @@ 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<UUID> l) {
if ((l == null) || (l.size() < 1)) {
return " none";

View File

@ -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 <world>");
return false;
}
HashMap<PlotId, Plot> plotmap = PlotMain.getPlots(args[1]);
if (plotmap==null || plotmap.size()==0) {
PlayerFunctions.sendMessage(plr, "&cInvalid world. Use &7/plots sch exportall <world>");
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 <world> <id>");
return false;
}
p2 = PlotMain.getPlots(world).get(i);
}
catch (Exception e) {
PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
return false;
}
}
else {
PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
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;

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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
*/

View File

@ -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<Flag> flags = new ArrayList<Flag>();
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<UUID> helpers = plotHelpers(id);
ArrayList<UUID> trusted = plotTrusted(id);
ArrayList<UUID> 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);
}
@ -557,6 +569,33 @@ public class SQLManager extends AbstractDB {
});
}
public void setFlags(final String world, final int id, final Flag[] flags) {
ArrayList<Flag> newflags = new ArrayList<Flag>();
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
* @param alias

View File

@ -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);
}

View File

@ -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;
@ -46,6 +49,21 @@ public class PlotListener {
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()));
PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getBlockX(), 64, l2.getBlockZ()));

View File

@ -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);
}

View File

@ -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.