Major Restructure

This commit is contained in:
Sauilitired 2014-11-16 10:48:18 +01:00
parent 38c7edbddd
commit 23d88763d1
111 changed files with 1371 additions and 998 deletions

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.bukkit:bukkit:1.7.9-R0.2" level="project" />
<orderEntry type="library" name="Maven: net.milkbowl.vault:Vault:1.3.2" level="project" />
<orderEntry type="library" name="Maven: com.sk89q:worldedit:6.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.schlichtherle:truezip:6.8.3" level="project" />
<orderEntry type="library" name="Maven: rhino:js:1.7R2" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:10.0.1" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
<orderEntry type="library" name="Maven: me.confuser:BarAPI:2.0" level="project" />
<orderEntry type="library" name="Maven: com.sk89q:worldguard:5.9" level="project" />
<orderEntry type="module-library">
<library name="Maven: com.worldcretornica:PlotMe:0.13d-SNAPSHOT">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/plotme-0.13f.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="Maven: junit:junit:4.11" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>

View File

@ -21,16 +21,23 @@
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
import com.intellectualcrafters.plot.Logger.LogLevel;
import com.intellectualcrafters.plot.commands.Auto; import com.intellectualcrafters.plot.commands.Auto;
import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.ConfigurationNode;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.*; import com.intellectualcrafters.plot.database.*;
import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent; import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent;
import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.events.PlotDeleteEvent;
import com.intellectualcrafters.plot.flag.AbstractFlag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.generator.DefaultPlotManager; import com.intellectualcrafters.plot.generator.DefaultPlotManager;
import com.intellectualcrafters.plot.generator.DefaultPlotWorld; import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
import com.intellectualcrafters.plot.generator.WorldGenerator; import com.intellectualcrafters.plot.generator.WorldGenerator;
import com.intellectualcrafters.plot.listeners.*; import com.intellectualcrafters.plot.listeners.*;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.util.Logger.LogLevel;
import com.intellectualcrafters.plot.uuid.PlotUUIDSaver; import com.intellectualcrafters.plot.uuid.PlotUUIDSaver;
import com.intellectualcrafters.plot.uuid.UUIDSaver; import com.intellectualcrafters.plot.uuid.UUIDSaver;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
@ -1285,15 +1292,15 @@ public class PlotMain extends JavaPlugin {
return plots; return plots;
} }
public static void setAllPlotsRaw(final LinkedHashMap<String, HashMap<PlotId, Plot>> plots) {
PlotMain.plots = plots;
}
public static void setAllPlotsRaw(final HashMap<String, HashMap<PlotId, Plot>> plots) { public static void setAllPlotsRaw(final HashMap<String, HashMap<PlotId, Plot>> plots) {
PlotMain.plots = new LinkedHashMap<>(plots); PlotMain.plots = new LinkedHashMap<>(plots);
// PlotMain.plots.putAll(plots); // PlotMain.plots.putAll(plots);
} }
public static void setAllPlotsRaw(final LinkedHashMap<String, HashMap<PlotId, Plot>> plots) {
PlotMain.plots = plots;
}
/** /**
* !!WorldGeneration!! * !!WorldGeneration!!
*/ */

View File

@ -21,9 +21,19 @@
package com.intellectualcrafters.plot.api; package com.intellectualcrafters.plot.api;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.commands.SubCommand; import com.intellectualcrafters.plot.commands.SubCommand;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.flag.AbstractFlag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.SchematicHandler;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -108,8 +118,8 @@ public class PlotAPI {
* @param plotWorld Plot World Object * @param plotWorld Plot World Object
* @param manager World Manager * @param manager World Manager
* @see com.intellectualcrafters.plot.PlotMain#addPlotWorld(String, * @see com.intellectualcrafters.plot.PlotMain#addPlotWorld(String,
* com.intellectualcrafters.plot.PlotWorld, * com.intellectualcrafters.plot.object.PlotWorld,
* com.intellectualcrafters.plot.PlotManager) * com.intellectualcrafters.plot.object.PlotManager)
*/ */
public void addPlotWorld(final String world, final PlotWorld plotWorld, final PlotManager manager) { public void addPlotWorld(final String world, final PlotWorld plotWorld, final PlotManager manager) {
PlotMain.addPlotWorld(world, plotWorld, manager); PlotMain.addPlotWorld(world, plotWorld, manager);

View File

@ -21,22 +21,57 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class Auto extends SubCommand { public class Auto extends SubCommand {
public static PlotId lastPlot = new PlotId(0, 0);
public Auto() { public Auto() {
super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING, true); super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING, true);
} }
public static PlotId lastPlot = new PlotId(0, 0); public static PlotId getNextPlot(final PlotId id, final int step) {
final int absX = Math.abs(id.x);
final int absY = Math.abs(id.y);
if (absX > absY) {
if (id.x > 0) {
return new PlotId(id.x, id.y + 1);
} else {
return new PlotId(id.x, id.y - 1);
}
} else if (absY > absX) {
if (id.y > 0) {
return new PlotId(id.x - 1, id.y);
} else {
return new PlotId(id.x + 1, id.y);
}
} else {
if (id.x.equals(id.y) && (id.x > 0)) {
return new PlotId(id.x, id.y + step);
}
if (id.x == absX) {
return new PlotId(id.x, id.y + 1);
}
if (id.y == absY) {
return new PlotId(id.x, id.y - 1);
}
return new PlotId(id.x + 1, id.y);
}
}
// TODO auto claim a mega plot with schematic // TODO auto claim a mega plot with schematic
@Override @Override
@ -131,10 +166,10 @@ public class Auto extends SubCommand {
Auto.lastPlot = getNextPlot(Auto.lastPlot, 1); Auto.lastPlot = getNextPlot(Auto.lastPlot, 1);
} }
} else { } else {
// Why does this need fixing, it should work fine for auto claiming mega plots // Why does this need fixing, it should work fine for auto claiming mega plots
while (!br) { while (!br) {
final PlotId start = getNextPlot(Auto.lastPlot, 1); final PlotId start = getNextPlot(Auto.lastPlot, 1);
@ -172,35 +207,6 @@ public class Auto extends SubCommand {
return true; return true;
} }
public static PlotId getNextPlot(final PlotId id, final int step) {
final int absX = Math.abs(id.x);
final int absY = Math.abs(id.y);
if (absX > absY) {
if (id.x > 0) {
return new PlotId(id.x, id.y + 1);
} else {
return new PlotId(id.x, id.y - 1);
}
} else if (absY > absX) {
if (id.y > 0) {
return new PlotId(id.x - 1, id.y);
} else {
return new PlotId(id.x + 1, id.y);
}
} else {
if (id.x.equals(id.y) && (id.x > 0)) {
return new PlotId(id.x, id.y + step);
}
if (id.x == absX) {
return new PlotId(id.x, id.y + 1);
}
if (id.y == absY) {
return new PlotId(id.x, id.y - 1);
}
return new PlotId(id.x + 1, id.y);
}
}
public boolean isUnowned(final World world, final PlotId pos1, final PlotId pos2) { public boolean isUnowned(final World world, final PlotId pos1, final PlotId pos2) {
for (int x = pos1.x; x <= pos2.x; x++) { for (int x = pos1.x; x <= pos2.x; x++) {
for (int y = pos1.y; y <= pos2.y; y++) { for (int y = pos1.y; y <= pos2.y; y++) {

View File

@ -1,8 +1,8 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.PlayerFunctions; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** /**

View File

@ -21,13 +21,20 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.generator.DefaultPlotWorld; import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SetBlockFast;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -40,48 +47,6 @@ public class Claim extends SubCommand {
super(Command.CLAIM, "Claim the current plot you're standing on.", "claim", CommandCategory.CLAIMING, true); super(Command.CLAIM, "Claim the current plot you're standing on.", "claim", CommandCategory.CLAIMING, true);
} }
@Override
public boolean execute(final Player plr, final String... args) {
String schematic = "";
if (args.length >= 1) {
schematic = args[0];
}
if (!PlayerFunctions.isInPlot(plr)) {
return sendMessage(plr, C.NOT_IN_PLOT);
}
if (PlayerFunctions.getPlayerPlotCount(plr.getWorld(), plr) >= PlayerFunctions.getAllowedPlots(plr)) {
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
}
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (plot.hasOwner()) {
return sendMessage(plr, C.PLOT_IS_CLAIMED);
}
final PlotWorld world = PlotMain.getWorldSettings(plot.getWorld());
if (PlotMain.useEconomy && world.USE_ECONOMY) {
final double cost = world.PLOT_PRICE;
if (cost > 0d) {
final Economy economy = PlotMain.economy;
if (economy.getBalance(plr) < cost) {
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
}
economy.withdrawPlayer(plr, cost);
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
}
}
if (!schematic.equals("")) {
if (world.SCHEMATIC_CLAIM_SPECIFY) {
if (!world.SCHEMATICS.contains(schematic.toLowerCase())) {
return sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
}
if (!PlotMain.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin")) {
return sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
}
}
}
return !claimPlot(plr, plot, false, schematic) || sendMessage(plr, C.PLOT_NOT_CLAIMED);
}
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport) { public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport) {
return claimPlot(player, plot, teleport, ""); return claimPlot(player, plot, teleport, "");
} }
@ -129,4 +94,46 @@ public class Claim extends SubCommand {
} }
return event.isCancelled(); return event.isCancelled();
} }
@Override
public boolean execute(final Player plr, final String... args) {
String schematic = "";
if (args.length >= 1) {
schematic = args[0];
}
if (!PlayerFunctions.isInPlot(plr)) {
return sendMessage(plr, C.NOT_IN_PLOT);
}
if (PlayerFunctions.getPlayerPlotCount(plr.getWorld(), plr) >= PlayerFunctions.getAllowedPlots(plr)) {
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
}
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (plot.hasOwner()) {
return sendMessage(plr, C.PLOT_IS_CLAIMED);
}
final PlotWorld world = PlotMain.getWorldSettings(plot.getWorld());
if (PlotMain.useEconomy && world.USE_ECONOMY) {
final double cost = world.PLOT_PRICE;
if (cost > 0d) {
final Economy economy = PlotMain.economy;
if (economy.getBalance(plr) < cost) {
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
}
economy.withdrawPlayer(plr, cost);
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
}
}
if (!schematic.equals("")) {
if (world.SCHEMATIC_CLAIM_SPECIFY) {
if (!world.SCHEMATICS.contains(schematic.toLowerCase())) {
return sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
}
if (!PlotMain.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin")) {
return sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
}
}
}
return !claimPlot(plr, plot, false, schematic) || sendMessage(plr, C.PLOT_NOT_CLAIMED);
}
} }

View File

@ -21,7 +21,12 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -21,13 +21,13 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.PlayerFunctions; import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.PlotId; import com.intellectualcrafters.plot.object.PlotSelection;
import com.intellectualcrafters.plot.PlotSelection; import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import static com.intellectualcrafters.plot.PlotSelection.currentSelection; import static com.intellectualcrafters.plot.object.PlotSelection.currentSelection;
public class Clipboard extends SubCommand { public class Clipboard extends SubCommand {

View File

@ -21,8 +21,12 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotComment;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -21,7 +21,12 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotSelection;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class Copy extends SubCommand { public class Copy extends SubCommand {

View File

@ -1,8 +1,8 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.PlayerFunctions; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** /**

View File

@ -1,11 +1,11 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.StringComparsion;
import com.intellectualcrafters.plot.database.MySQL; import com.intellectualcrafters.plot.database.MySQL;
import com.intellectualcrafters.plot.database.SQLManager; import com.intellectualcrafters.plot.database.SQLManager;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.StringComparison;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -76,7 +76,7 @@ public class Database extends SubCommand {
if (args.length < 1) { if (args.length < 1) {
return sendMessage(plr, "/plot database [sqlite/mysql]"); return sendMessage(plr, "/plot database [sqlite/mysql]");
} }
String type = new StringComparsion(args[0], new String[]{"mysql", "sqlite"}).getBestMatch().toLowerCase(); String type = new StringComparison(args[0], new String[]{"mysql", "sqlite"}).getBestMatch().toLowerCase();
switch (type) { switch (type) {
case "mysql": case "mysql":
if (args.length < 6) { if (args.length < 6) {

View File

@ -21,7 +21,12 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.util.Lag;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.RUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -22,9 +22,15 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.google.common.collect.BiMap; import com.google.common.collect.BiMap;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
@ -45,6 +51,26 @@ public class DebugClaimTest extends SubCommand {
super(Command.DEBUGCLAIMTEST, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. Execution time may vary", "debugclaimtest", CommandCategory.DEBUG, false); super(Command.DEBUGCLAIMTEST, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. Execution time may vary", "debugclaimtest", CommandCategory.DEBUG, false);
} }
@SuppressWarnings("unused")
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport) {
return claimPlot(player, plot, teleport, "");
}
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, @SuppressWarnings("unused") final String schematic) {
final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
PlotHelper.createPlot(player, plot);
PlotHelper.setSign(player, plot);
PlayerFunctions.sendMessage(player, C.CLAIMED);
if (teleport) {
PlotMain.teleportPlayer(player, player.getLocation(), plot);
}
plot.settings.setFlags(FlagManager.parseFlags(PlotMain.getWorldSettings(player.getWorld()).DEFAULT_FLAGS));
}
return event.isCancelled();
}
@Override @Override
public boolean execute(final Player plr, final String... args) { public boolean execute(final Player plr, final String... args) {
if (plr == null) { if (plr == null) {
@ -150,24 +176,4 @@ public class DebugClaimTest extends SubCommand {
} }
return true; return true;
} }
@SuppressWarnings("unused")
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport) {
return claimPlot(player, plot, teleport, "");
}
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, @SuppressWarnings("unused") final String schematic) {
final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
PlotHelper.createPlot(player, plot);
PlotHelper.setSign(player, plot);
PlayerFunctions.sendMessage(player, C.CLAIMED);
if (teleport) {
PlotMain.teleportPlayer(player, player.getLocation(), plot);
}
plot.settings.setFlags(FlagManager.parseFlags(PlotMain.getWorldSettings(player.getWorld()).DEFAULT_FLAGS));
}
return event.isCancelled();
}
} }

View File

@ -21,9 +21,9 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.lang.reflect.Field; import java.lang.reflect.Field;

View File

@ -21,10 +21,10 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -21,8 +21,12 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -21,12 +21,12 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.UUIDHandler;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent; import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -21,12 +21,12 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.UUIDHandler;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent; import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -21,10 +21,10 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** /**

View File

@ -21,8 +21,12 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotComment;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -21,8 +21,15 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -21,10 +21,10 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -21,10 +21,10 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.StringComparsion; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.StringComparison;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -225,7 +225,7 @@ public class MainCommand implements CommandExecutor, TabCompleter {
} }
/* Let's try to get a proper usage string */ /* Let's try to get a proper usage string */
String command = new StringComparsion(args[0], commands).getBestMatch(); String command = new StringComparison(args[0], commands).getBestMatch();
return PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command); return PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command);
//PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, new StringComparsion(args[0], commands).getBestMatch()); //PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, new StringComparsion(args[0], commands).getBestMatch());
} }

View File

@ -21,8 +21,15 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.events.PlotMergeEvent; import com.intellectualcrafters.plot.events.PlotMergeEvent;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.SetBlockFast;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@ -21,10 +21,10 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.listeners.PlotPlusListener;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -1,8 +1,8 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.PlayerFunctions; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** /**

View File

@ -21,7 +21,12 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotSelection;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class Paste extends SubCommand { public class Paste extends SubCommand {

View File

@ -21,11 +21,11 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@SuppressWarnings({"unused", "deprecated", "javadoc"}) @SuppressWarnings({"unused", "deprecated", "javadoc"})

View File

@ -21,10 +21,10 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@SuppressWarnings({"unused", "deprecated", "javadoc"}) @SuppressWarnings({"unused", "deprecated", "javadoc"})

View File

@ -21,10 +21,10 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class Reload extends SubCommand { public class Reload extends SubCommand {

View File

@ -22,9 +22,14 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.jnbt.CompoundTag; import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.SchematicHandler.DataCollection; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.SchematicHandler.Dimension; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.util.SchematicHandler.DataCollection;
import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;

View File

@ -21,11 +21,22 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlotFlagAddEvent; import com.intellectualcrafters.plot.events.PlotFlagAddEvent;
import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent; import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent;
import com.intellectualcrafters.plot.flag.AbstractFlag;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.listeners.PlotListener;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotHomePosition;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.StringComparison;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -225,7 +236,7 @@ public class Set extends SubCommand {
return true; return true;
} }
final Biome biome = Biome.valueOf(new StringComparsion(args[1], Biome.values()).getBestMatch()); final Biome biome = Biome.valueOf(new StringComparison(args[1], Biome.values()).getBestMatch());
/* /*
* for (Biome b : Biome.values()) { * for (Biome b : Biome.values()) {
* if (b.toString().equalsIgnoreCase(args[1])) { * if (b.toString().equalsIgnoreCase(args[1])) {
@ -443,7 +454,7 @@ public class Set extends SubCommand {
} }
private Material getMaterial(final String input, final List<Material> blocks) { private Material getMaterial(final String input, final List<Material> blocks) {
return Material.valueOf(new StringComparsion(input, blocks.toArray()).getBestMatch()); return Material.valueOf(new StringComparison(input, blocks.toArray()).getBestMatch());
} }
private String getBlockList(final List<Material> blocks) { private String getBlockList(final List<Material> blocks) {

View File

@ -21,8 +21,12 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.UUID; import java.util.UUID;

View File

@ -21,8 +21,13 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.ConfigurationNode;
import com.intellectualcrafters.plot.generator.DefaultPlotWorld; import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
import com.intellectualcrafters.plot.object.PlotGenerator;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;

View File

@ -21,8 +21,8 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.PlayerFunctions; import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** /**

View File

@ -21,7 +21,14 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotSelection;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.SetBlockFast;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -21,7 +21,12 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;

View File

@ -21,12 +21,12 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.UUIDHandler;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent; import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -1,8 +1,8 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.PlayerFunctions; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** /**

View File

@ -21,9 +21,17 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlotUnlinkEvent; import com.intellectualcrafters.plot.events.PlotUnlinkEvent;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.SetBlockFast;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -21,10 +21,10 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.UUIDHandler; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -21,7 +21,13 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -146,7 +152,7 @@ public class list extends SubCommand {
return true; return true;
} else { } else {
// execute(plr); // execute(plr);
sendMessage(plr, C.DID_YOU_MEAN, new StringComparsion(args[0], new String[]{"mine", "shared", "world", "all"}).getBestMatch()); sendMessage(plr, C.DID_YOU_MEAN, new StringComparison(args[0], new String[]{"mine", "shared", "world", "all"}).getBestMatch());
return false; return false;
} }
} }

View File

@ -21,8 +21,8 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;

View File

@ -19,8 +19,9 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.config;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualsites.translation.*; import com.intellectualsites.translation.*;
import com.intellectualsites.translation.bukkit.BukkitTranslation; import com.intellectualsites.translation.bukkit.BukkitTranslation;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -419,7 +420,7 @@ public enum C {
if (manager == null) { if (manager == null) {
manager = new TranslationManager(); manager = new TranslationManager();
} }
// FIXME: generating a blank file // FIXME: generating a blank file
// FIXME: translations aren't customizable // FIXME: translations aren't customizable
// FIXME: Some messages still have the %arg stuff in them // FIXME: Some messages still have the %arg stuff in them

View File

@ -19,8 +19,9 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.config;
import com.intellectualcrafters.plot.object.PlotBlock;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -19,9 +19,9 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.config;
import com.intellectualcrafters.plot.Configuration.SettingValue; import com.intellectualcrafters.plot.config.Configuration.SettingValue;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import java.util.Arrays; import java.util.Arrays;

View File

@ -19,7 +19,7 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.config;
/** /**
* Updater and DB settings * Updater and DB settings

View File

@ -21,10 +21,10 @@
package com.intellectualcrafters.plot.database; package com.intellectualcrafters.plot.database;
import com.intellectualcrafters.plot.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.PlotComment; import com.intellectualcrafters.plot.object.PlotComment;
import com.intellectualcrafters.plot.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import java.sql.SQLException; import java.sql.SQLException;
@ -40,6 +40,11 @@ public abstract class AbstractDB {
// TODO MongoDB @Brandon // TODO MongoDB @Brandon
/**
*
*/
public UUID everyone = UUID.fromString("1-1-3-3-7");
/** /**
* Set Plot owner * Set Plot owner
* *
@ -119,11 +124,6 @@ public abstract class AbstractDB {
*/ */
public abstract HashMap<String, Object> getSettings(final int id); public abstract HashMap<String, Object> getSettings(final int id);
/**
*
*/
public UUID everyone = UUID.fromString("1-1-3-3-7");
/** /**
* @param plot * @param plot
* @param player * @param player

View File

@ -21,10 +21,10 @@
package com.intellectualcrafters.plot.database; package com.intellectualcrafters.plot.database;
import com.intellectualcrafters.plot.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.PlotComment; import com.intellectualcrafters.plot.object.PlotComment;
import com.intellectualcrafters.plot.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -22,10 +22,10 @@
package com.intellectualcrafters.plot.database; package com.intellectualcrafters.plot.database;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import com.intellectualcrafters.plot.PlotHomePosition;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.generator.WorldGenerator; import com.intellectualcrafters.plot.generator.WorldGenerator;
import com.intellectualcrafters.plot.object.PlotHomePosition;
import com.intellectualcrafters.plot.object.PlotId;
import com.worldcretornica.plotme.PlayerList; import com.worldcretornica.plotme.PlayerList;
import com.worldcretornica.plotme.Plot; import com.worldcretornica.plotme.Plot;
import com.worldcretornica.plotme.PlotManager; import com.worldcretornica.plotme.PlotManager;
@ -73,7 +73,7 @@ public class PlotMeConverter {
public void run() { public void run() {
sendMessage("&7Conversion has started"); sendMessage("&7Conversion has started");
sendMessage("7Caching playerdata..."); sendMessage("7Caching playerdata...");
final ArrayList<com.intellectualcrafters.plot.Plot> createdPlots = final ArrayList<com.intellectualcrafters.plot.object.Plot> createdPlots =
new ArrayList<>(); new ArrayList<>();
// Online Mode // Online Mode
final boolean online = final boolean online =
@ -193,14 +193,14 @@ public class PlotMeConverter {
e.printStackTrace(); e.printStackTrace();
} }
final PlotId id = new PlotId(Integer.parseInt(plot.id.split(";")[0]), Integer.parseInt(plot.id.split(";")[1])); final PlotId id = new PlotId(Integer.parseInt(plot.id.split(";")[0]), Integer.parseInt(plot.id.split(";")[1]));
com.intellectualcrafters.plot.Plot pl; com.intellectualcrafters.plot.object.Plot pl;
if (online) { if (online) {
pl = new com.intellectualcrafters.plot.Plot(id, plot.getOwnerId(), plot.getBiome(), psAdded, psTrusted, psDenied, pl = new com.intellectualcrafters.plot.object.Plot(id, plot.getOwnerId(), plot.getBiome(), psAdded, psTrusted, psDenied,
"", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[]{false, false, false, false}); "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[]{false, false, false, false});
} else { } else {
final String owner = plot.getOwner(); final String owner = plot.getOwner();
pl = new com.intellectualcrafters.plot.Plot(id, UUID.nameUUIDFromBytes(("OfflinePlayer:" + owner).getBytes(Charsets.UTF_8)), plot.getBiome(), psAdded, psTrusted, psDenied, pl = new com.intellectualcrafters.plot.object.Plot(id, UUID.nameUUIDFromBytes(("OfflinePlayer:" + owner).getBytes(Charsets.UTF_8)), plot.getBiome(), psAdded, psTrusted, psDenied,
"", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[]{false, false, false, false}); "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[]{false, false, false, false});
} }

View File

@ -21,8 +21,15 @@
package com.intellectualcrafters.plot.database; package com.intellectualcrafters.plot.database;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.Logger.LogLevel; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotComment;
import com.intellectualcrafters.plot.object.PlotHomePosition;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.Logger;
import com.intellectualcrafters.plot.util.Logger.LogLevel;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -529,10 +536,6 @@ public class SQLManager extends AbstractDB {
} }
} }
} }
if (biome == null) {
biome = Biome.FOREST;
}
plot.settings.setBiome(biome);
final String alias = r.getString("alias"); final String alias = r.getString("alias");
if (alias != null) { if (alias != null) {

View File

@ -21,7 +21,7 @@
package com.intellectualcrafters.plot.database.sqlobjects; package com.intellectualcrafters.plot.database.sqlobjects;
import com.intellectualcrafters.plot.Settings; import com.intellectualcrafters.plot.config.Settings;
/** /**
* Created by Citymonstret on 2014-10-28. * Created by Citymonstret on 2014-10-28.

View File

@ -21,7 +21,7 @@
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.object.Plot;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -32,9 +32,8 @@ import org.bukkit.event.player.PlayerEvent;
*/ */
public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable { public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable {
private static HandlerList handlers = new HandlerList(); private static HandlerList handlers = new HandlerList();
private boolean cancelled;
private final Plot plot; private final Plot plot;
private boolean cancelled;
/** /**
* PlayerClaimPlotEvent: Called when a plot is claimed * PlayerClaimPlotEvent: Called when a plot is claimed
@ -47,6 +46,10 @@ public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable {
this.plot = plot; this.plot = plot;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* Get the plot involved * Get the plot involved
* *
@ -56,10 +59,6 @@ public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable {
return this.plot; return this.plot;
} }
public static HandlerList getHandlerList() {
return handlers;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;

View File

@ -21,7 +21,7 @@
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.object.Plot;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
@ -46,6 +46,10 @@ public class PlayerEnterPlotEvent extends PlayerEvent {
this.plot = plot; this.plot = plot;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* Get the plot involved * Get the plot involved
* *
@ -55,10 +59,6 @@ public class PlayerEnterPlotEvent extends PlayerEvent {
return this.plot; return this.plot;
} }
public static HandlerList getHandlerList() {
return handlers;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;

View File

@ -21,7 +21,7 @@
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.object.Plot;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
@ -45,6 +45,10 @@ public class PlayerLeavePlotEvent extends PlayerEvent {
this.plot = plot; this.plot = plot;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* Get the plot involved * Get the plot involved
* *
@ -54,10 +58,6 @@ public class PlayerLeavePlotEvent extends PlayerEvent {
return this.plot; return this.plot;
} }
public static HandlerList getHandlerList() {
return handlers;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;

View File

@ -21,7 +21,7 @@
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.object.Plot;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -55,6 +55,10 @@ public class PlayerPlotDeniedEvent extends Event {
this.player = player; this.player = player;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* If a user was added * If a user was added
* *
@ -91,10 +95,6 @@ public class PlayerPlotDeniedEvent extends Event {
return this.initiator; return this.initiator;
} }
public static HandlerList getHandlerList() {
return handlers;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;

View File

@ -21,7 +21,7 @@
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.object.Plot;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -54,6 +54,10 @@ public class PlayerPlotHelperEvent extends Event {
this.player = player; this.player = player;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* If a player was added * If a player was added
* *
@ -90,10 +94,6 @@ public class PlayerPlotHelperEvent extends Event {
return this.initiator; return this.initiator;
} }
public static HandlerList getHandlerList() {
return handlers;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;

View File

@ -21,7 +21,7 @@
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.object.Plot;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -54,6 +54,10 @@ public class PlayerPlotTrustedEvent extends Event {
this.player = player; this.player = player;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* If a player was added * If a player was added
* *
@ -90,10 +94,6 @@ public class PlayerPlotTrustedEvent extends Event {
return this.initiator; return this.initiator;
} }
public static HandlerList getHandlerList() {
return handlers;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;

View File

@ -21,7 +21,7 @@
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.object.Plot;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
@ -52,6 +52,10 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl
this.plot = plot; this.plot = plot;
} }
public static HandlerList getHandlerList() {
return handlers;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
@ -75,10 +79,6 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl
return this.plot; return this.plot;
} }
public static HandlerList getHandlerList() {
return handlers;
}
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return this.cancelled; return this.cancelled;

View File

@ -21,7 +21,7 @@
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;
import com.intellectualcrafters.plot.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -31,10 +31,9 @@ import org.bukkit.event.HandlerList;
*/ */
public class PlotClearEvent extends Event implements Cancellable { public class PlotClearEvent extends Event implements Cancellable {
private static HandlerList handlers = new HandlerList(); private static HandlerList handlers = new HandlerList();
private boolean cancelled;
private final PlotId id; private final PlotId id;
private final String world; private final String world;
private boolean cancelled;
/** /**
* PlotDeleteEvent: Called when a plot is cleared * PlotDeleteEvent: Called when a plot is cleared
@ -47,6 +46,10 @@ public class PlotClearEvent extends Event implements Cancellable {
this.world = world; this.world = world;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* Get the PlotId * Get the PlotId
* *
@ -65,10 +68,6 @@ public class PlotClearEvent extends Event implements Cancellable {
return this.world; return this.world;
} }
public static HandlerList getHandlerList() {
return handlers;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;

View File

@ -21,7 +21,7 @@
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;
import com.intellectualcrafters.plot.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -31,10 +31,9 @@ import org.bukkit.event.HandlerList;
*/ */
public class PlotDeleteEvent extends Event implements Cancellable { public class PlotDeleteEvent extends Event implements Cancellable {
private static HandlerList handlers = new HandlerList(); private static HandlerList handlers = new HandlerList();
private boolean cancelled;
private final PlotId id; private final PlotId id;
private final String world; private final String world;
private boolean cancelled;
/** /**
* PlotDeleteEvent: Called when a plot is deleted * PlotDeleteEvent: Called when a plot is deleted
@ -47,6 +46,10 @@ public class PlotDeleteEvent extends Event implements Cancellable {
this.world = world; this.world = world;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* Get the PlotId * Get the PlotId
* *
@ -65,10 +68,6 @@ public class PlotDeleteEvent extends Event implements Cancellable {
return this.world; return this.world;
} }
public static HandlerList getHandlerList() {
return handlers;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;

View File

@ -21,8 +21,8 @@
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;
import com.intellectualcrafters.plot.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.object.Plot;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -32,10 +32,9 @@ import org.bukkit.event.HandlerList;
*/ */
public class PlotFlagAddEvent extends Event implements Cancellable { public class PlotFlagAddEvent extends Event implements Cancellable {
private static HandlerList handlers = new HandlerList(); private static HandlerList handlers = new HandlerList();
private boolean cancelled;
private final Plot plot; private final Plot plot;
private final Flag flag; private final Flag flag;
private boolean cancelled;
/** /**
* PlotFlagAddEvent: Called when a Flag is added to a plot * PlotFlagAddEvent: Called when a Flag is added to a plot
@ -48,6 +47,10 @@ public class PlotFlagAddEvent extends Event implements Cancellable {
this.flag = flag; this.flag = flag;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* Get the plot involved * Get the plot involved
* *
@ -66,10 +69,6 @@ public class PlotFlagAddEvent extends Event implements Cancellable {
return this.flag; return this.flag;
} }
public static HandlerList getHandlerList() {
return handlers;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;

View File

@ -21,8 +21,8 @@
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;
import com.intellectualcrafters.plot.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.object.Plot;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -32,10 +32,9 @@ import org.bukkit.event.HandlerList;
*/ */
public class PlotFlagRemoveEvent extends Event implements Cancellable { public class PlotFlagRemoveEvent extends Event implements Cancellable {
private static HandlerList handlers = new HandlerList(); private static HandlerList handlers = new HandlerList();
private boolean cancelled;
private final Plot plot; private final Plot plot;
private final Flag flag; private final Flag flag;
private boolean cancelled;
/** /**
* PlotFlagRemoveEvent: Called when a flag is removed from a plot * PlotFlagRemoveEvent: Called when a flag is removed from a plot
@ -48,6 +47,10 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable {
this.flag = flag; this.flag = flag;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* Get the plot involved * Get the plot involved
* *
@ -66,10 +69,6 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable {
return this.flag; return this.flag;
} }
public static HandlerList getHandlerList() {
return handlers;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;

View File

@ -21,8 +21,8 @@
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
@ -35,9 +35,8 @@ import java.util.ArrayList;
*/ */
public class PlotMergeEvent extends Event implements Cancellable { public class PlotMergeEvent extends Event implements Cancellable {
private static HandlerList handlers = new HandlerList(); private static HandlerList handlers = new HandlerList();
private boolean cancelled;
private final ArrayList<PlotId> plots; private final ArrayList<PlotId> plots;
private boolean cancelled;
private Plot plot; private Plot plot;
private World world; private World world;
@ -51,6 +50,10 @@ public class PlotMergeEvent extends Event implements Cancellable {
this.plots = plots; this.plots = plots;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* Get the plots being added; * Get the plots being added;
* *
@ -73,10 +76,6 @@ public class PlotMergeEvent extends Event implements Cancellable {
return this.world; return this.world;
} }
public static HandlerList getHandlerList() {
return handlers;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;

View File

@ -21,7 +21,7 @@
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;
import com.intellectualcrafters.plot.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
@ -34,10 +34,9 @@ import java.util.ArrayList;
*/ */
public class PlotUnlinkEvent extends Event implements Cancellable { public class PlotUnlinkEvent extends Event implements Cancellable {
private static HandlerList handlers = new HandlerList(); private static HandlerList handlers = new HandlerList();
private boolean cancelled;
private final ArrayList<PlotId> plots; private final ArrayList<PlotId> plots;
private final World world; private final World world;
private boolean cancelled;
/** /**
* Called when a mega-plot is unlinked. * Called when a mega-plot is unlinked.
@ -50,6 +49,10 @@ public class PlotUnlinkEvent extends Event implements Cancellable {
this.world = world; this.world = world;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* Get the plots involved * Get the plots involved
* *
@ -63,10 +66,6 @@ public class PlotUnlinkEvent extends Event implements Cancellable {
return this.world; return this.world;
} }
public static HandlerList getHandlerList() {
return handlers;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;

View File

@ -19,7 +19,7 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.flag;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;

View File

@ -19,7 +19,7 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.flag;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;

View File

@ -19,8 +19,9 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.flag;
import com.intellectualcrafters.plot.object.Plot;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -21,7 +21,10 @@
package com.intellectualcrafters.plot.generator; package com.intellectualcrafters.plot.generator;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -487,7 +490,6 @@ public class DefaultPlotManager extends PlotManager {
} }
} }
plot.settings.setBiome(biome);
PlotMain.updatePlot(plot); PlotMain.updatePlot(plot);
PlotHelper.refreshPlotChunks(world, plot); PlotHelper.refreshPlotChunks(world, plot);

View File

@ -21,7 +21,11 @@
package com.intellectualcrafters.plot.generator; package com.intellectualcrafters.plot.generator;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.Configuration;
import com.intellectualcrafters.plot.config.ConfigurationNode;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotWorld;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;

View File

@ -21,22 +21,19 @@
package com.intellectualcrafters.plot.generator; package com.intellectualcrafters.plot.generator;
import java.util.Arrays; import com.intellectualcrafters.plot.PlotMain;
import java.util.List; import com.intellectualcrafters.plot.object.PlotBlock;
import java.util.Random; import com.intellectualcrafters.plot.object.PlotGenerator;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotWorld;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
import com.intellectualcrafters.plot.PlotBlock; import java.util.Arrays;
import com.intellectualcrafters.plot.PlotGenerator; import java.util.List;
import com.intellectualcrafters.plot.PlotMain; import java.util.Random;
import com.intellectualcrafters.plot.PlotManager;
import com.intellectualcrafters.plot.PlotWorld;
/** /**
* @author Citymonstret The default generator is very messy, as we have decided * @author Citymonstret The default generator is very messy, as we have decided
@ -47,20 +44,10 @@ import com.intellectualcrafters.plot.PlotWorld;
* @auther Empire92 * @auther Empire92
*/ */
public class WorldGenerator extends PlotGenerator { public class WorldGenerator extends PlotGenerator {
/**
* result object is returned for each generated chunk, do stuff to it
*/
short[][] result;
/**
* plotworld object
*/
DefaultPlotWorld plotworld = null;
/** /**
* Set to static to re-use the same managet for all Default World Generators * Set to static to re-use the same managet for all Default World Generators
*/ */
private static PlotManager manager = null; private static PlotManager manager = null;
/** /**
* Some generator specific variables (implementation dependent) * Some generator specific variables (implementation dependent)
*/ */
@ -77,6 +64,48 @@ public class WorldGenerator extends PlotGenerator {
final int plotheight; final int plotheight;
final PlotBlock[] plotfloors; final PlotBlock[] plotfloors;
final PlotBlock[] filling; final PlotBlock[] filling;
/**
* result object is returned for each generated chunk, do stuff to it
*/
short[][] result;
/**
* plotworld object
*/
DefaultPlotWorld plotworld = null;
/**
* Faster sudo-random number generator than java.util.random
*/
private long state;
/**
* Initialize variables, and create plotworld object used in calculations
*/
public WorldGenerator(final String world) {
super(world);
if (this.plotworld == null) {
this.plotworld = (DefaultPlotWorld) PlotMain.getWorldSettings(world);
}
this.plotsize = this.plotworld.PLOT_WIDTH;
this.pathsize = this.plotworld.ROAD_WIDTH;
this.floor1 = this.plotworld.ROAD_BLOCK;
this.floor2 = this.plotworld.ROAD_STRIPES;
this.wallfilling = this.plotworld.WALL_FILLING;
this.size = this.pathsize + this.plotsize;
this.wall = this.plotworld.WALL_BLOCK;
this.plotfloors = this.plotworld.TOP_BLOCK;
this.filling = this.plotworld.MAIN_BLOCK;
this.wallheight = this.plotworld.WALL_HEIGHT;
this.roadheight = this.plotworld.ROAD_HEIGHT;
this.plotheight = this.plotworld.PLOT_HEIGHT;
this.biome = this.plotworld.PLOT_BIOME;
}
/** /**
* Return the plot manager for this type of generator, or create one For * Return the plot manager for this type of generator, or create one For
@ -109,11 +138,6 @@ public class WorldGenerator extends PlotGenerator {
return this.plotworld; return this.plotworld;
} }
/**
* Faster sudo-random number generator than java.util.random
*/
private long state;
public final long nextLong() { public final long nextLong() {
final long a = this.state; final long a = this.state;
this.state = xorShift64(a); this.state = xorShift64(a);
@ -172,36 +196,6 @@ public class WorldGenerator extends PlotGenerator {
result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid; result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid;
} }
/**
* Initialize variables, and create plotworld object used in calculations
*/
public WorldGenerator(final String world) {
super(world);
if (this.plotworld == null) {
this.plotworld = (DefaultPlotWorld) PlotMain.getWorldSettings(world);
}
this.plotsize = this.plotworld.PLOT_WIDTH;
this.pathsize = this.plotworld.ROAD_WIDTH;
this.floor1 = this.plotworld.ROAD_BLOCK;
this.floor2 = this.plotworld.ROAD_STRIPES;
this.wallfilling = this.plotworld.WALL_FILLING;
this.size = this.pathsize + this.plotsize;
this.wall = this.plotworld.WALL_BLOCK;
this.plotfloors = this.plotworld.TOP_BLOCK;
this.filling = this.plotworld.MAIN_BLOCK;
this.wallheight = this.plotworld.WALL_HEIGHT;
this.roadheight = this.plotworld.ROAD_HEIGHT;
this.plotheight = this.plotworld.PLOT_HEIGHT;
this.biome = this.plotworld.PLOT_BIOME;
}
/** /**
* Return the block populator * Return the block populator
*/ */

View File

@ -21,8 +21,8 @@
package com.intellectualcrafters.plot.generator; package com.intellectualcrafters.plot.generator;
import com.intellectualcrafters.plot.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.PlotWorld; import com.intellectualcrafters.plot.object.PlotWorld;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
@ -41,9 +41,53 @@ public class XPopulator extends BlockPopulator {
* information about how a BlockPopulator works. * information about how a BlockPopulator works.
*/ */
private final DefaultPlotWorld plotworld;
int plotsize;
int pathsize;
PlotBlock wall;
PlotBlock wallfilling;
PlotBlock floor1;
PlotBlock floor2;
int size;
Biome biome;
int roadheight;
int wallheight;
int plotheight;
PlotBlock[] plotfloors;
PlotBlock[] filling;
private int X; private int X;
private int Z; private int Z;
private long state; private long state;
private double pathWidthLower;
public XPopulator(final PlotWorld pw) {
this.plotworld = (DefaultPlotWorld) pw;
// save configuration
this.plotsize = this.plotworld.PLOT_WIDTH;
this.pathsize = this.plotworld.ROAD_WIDTH;
this.floor1 = this.plotworld.ROAD_BLOCK;
this.floor2 = this.plotworld.ROAD_STRIPES;
this.wallfilling = this.plotworld.WALL_FILLING;
this.size = this.pathsize + this.plotsize;
this.wall = this.plotworld.WALL_BLOCK;
this.plotfloors = this.plotworld.TOP_BLOCK;
this.filling = this.plotworld.MAIN_BLOCK;
this.wallheight = this.plotworld.WALL_HEIGHT;
this.roadheight = this.plotworld.ROAD_HEIGHT;
this.plotheight = this.plotworld.PLOT_HEIGHT;
if ((this.pathsize % 2) == 0) {
this.pathWidthLower = Math.floor(this.pathsize / 2) - 1;
} else {
this.pathWidthLower = Math.floor(this.pathsize / 2);
}
}
public final long nextLong() { public final long nextLong() {
final long a = this.state; final long a = this.state;
@ -102,52 +146,6 @@ public class XPopulator extends BlockPopulator {
return new short[]{Short.parseShort(block), 0}; return new short[]{Short.parseShort(block), 0};
} }
int plotsize;
int pathsize;
PlotBlock wall;
PlotBlock wallfilling;
PlotBlock floor1;
PlotBlock floor2;
int size;
Biome biome;
int roadheight;
int wallheight;
int plotheight;
PlotBlock[] plotfloors;
PlotBlock[] filling;
private double pathWidthLower;
private final DefaultPlotWorld plotworld;
public XPopulator(final PlotWorld pw) {
this.plotworld = (DefaultPlotWorld) pw;
// save configuration
this.plotsize = this.plotworld.PLOT_WIDTH;
this.pathsize = this.plotworld.ROAD_WIDTH;
this.floor1 = this.plotworld.ROAD_BLOCK;
this.floor2 = this.plotworld.ROAD_STRIPES;
this.wallfilling = this.plotworld.WALL_FILLING;
this.size = this.pathsize + this.plotsize;
this.wall = this.plotworld.WALL_BLOCK;
this.plotfloors = this.plotworld.TOP_BLOCK;
this.filling = this.plotworld.MAIN_BLOCK;
this.wallheight = this.plotworld.WALL_HEIGHT;
this.roadheight = this.plotworld.ROAD_HEIGHT;
this.plotheight = this.plotworld.PLOT_HEIGHT;
if ((this.pathsize % 2) == 0) {
this.pathWidthLower = Math.floor(this.pathsize / 2) - 1;
} else {
this.pathWidthLower = Math.floor(this.pathsize / 2);
}
}
@Override @Override
public void populate(final World w, final Random r, final Chunk c) { public void populate(final World w, final Random r, final Chunk c) {
int cx = c.getX(), cz = c.getZ(); int cx = c.getX(), cz = c.getZ();

View File

@ -1,17 +1,12 @@
package com.intellectualcrafters.plot.listeners; package com.intellectualcrafters.plot.listeners;
import java.util.HashMap; import com.intellectualcrafters.plot.PlotMain;
import java.util.HashSet; import com.intellectualcrafters.plot.config.C;
import java.util.Iterator; import com.intellectualcrafters.plot.config.Settings;
import java.util.Map.Entry; import com.intellectualcrafters.plot.object.Plot;
import java.util.Set; import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import org.bukkit.Bukkit; import org.bukkit.*;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -21,71 +16,30 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import com.intellectualcrafters.plot.C; import java.util.HashMap;
import com.intellectualcrafters.plot.PlayerFunctions; import java.util.HashSet;
import com.intellectualcrafters.plot.Plot; import java.util.Iterator;
import com.intellectualcrafters.plot.PlotHelper; import java.util.Map.Entry;
import com.intellectualcrafters.plot.PlotMain; import java.util.Set;
import com.intellectualcrafters.plot.Settings;
public class EntityListener implements Listener { public class EntityListener implements Listener {
public static HashMap<String, HashMap<Plot, HashSet<Integer>>> entityMap = new HashMap<String, HashMap<Plot, HashSet<Integer>>>(); public static HashMap<String, HashMap<Plot, HashSet<Integer>>> entityMap = new HashMap<String, HashMap<Plot, HashSet<Integer>>>();
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onPlayerInteract(final PlayerInteractEvent e) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
final Player p = e.getPlayer();
World w = p.getWorld();
String n = w.getName();
if (e.getMaterial() == Material.MONSTER_EGG || e.getMaterial() == Material.MONSTER_EGGS) {
if (entityMap.containsKey(n)) {
Location l = e.getClickedBlock().getLocation();
Plot plot = PlotHelper.getCurrentPlot(l);
if (plot!=null && plot.hasRights(p)) {
int mobs;
if (entityMap.get(n).containsKey(plot)) {
mobs = entityMap.get(n).get(plot).size();
}
else {
mobs = 0;
}
if (!(PlotMain.hasPermissionRange(p, "plots.mobcap", Settings.MOB_CAP)>mobs)) {
PlayerFunctions.sendMessage(p, C.NO_PLOTS, "plots.mobcap."+(mobs+1));
}
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public static void onCreatureSpawn(CreatureSpawnEvent e) {
Location l = e.getLocation();
String w = l.getWorld().getName();
if (PlotMain.isPlotWorld(w)) {
Plot plot = PlotHelper.getCurrentPlot(l);
if (plot!=null && plot.hasOwner()) {
addEntity(e.getEntity(), plot);
}
}
}
public EntityListener() { public EntityListener() {
BukkitScheduler scheduler = Bukkit.getServer().getScheduler(); BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
scheduler.scheduleSyncRepeatingTask(PlotMain.getMain(), new Runnable() { scheduler.scheduleSyncRepeatingTask(PlotMain.getMain(), new Runnable() {
@Override @Override
public void run() { public void run() {
Iterator<Entry<String, HashMap<Plot, HashSet<Integer>>>> worldIt = entityMap.entrySet().iterator(); Iterator<Entry<String, HashMap<Plot, HashSet<Integer>>>> worldIt = entityMap.entrySet().iterator();
Set<Plot> plots = PlotMain.getPlots(); Set<Plot> plots = PlotMain.getPlots();
while (worldIt.hasNext()) { while (worldIt.hasNext()) {
Entry<String, HashMap<Plot, HashSet<Integer>>> entry = worldIt.next(); Entry<String, HashMap<Plot, HashSet<Integer>>> entry = worldIt.next();
String worldname = entry.getKey(); String worldname = entry.getKey();
@ -97,7 +51,7 @@ public class EntityListener implements Listener {
if (world == null || entry.getValue().size() == 0) { if (world == null || entry.getValue().size() == 0) {
worldIt.remove(); worldIt.remove();
continue; continue;
} }
Iterator<Entry<Plot, HashSet<Integer>>> it = entry.getValue().entrySet().iterator(); Iterator<Entry<Plot, HashSet<Integer>>> it = entry.getValue().entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Entry<Plot, HashSet<Integer>> plotEntry = it.next(); Entry<Plot, HashSet<Integer>> plotEntry = it.next();
@ -106,9 +60,9 @@ public class EntityListener implements Listener {
it.remove(); it.remove();
continue; continue;
} }
boolean loaded = false; boolean loaded = false;
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id);
try { try {
@ -122,8 +76,7 @@ public class EntityListener implements Listener {
} }
} }
} }
} } catch (Exception e) {
catch (Exception e) {
it.remove(); it.remove();
continue; continue;
} }
@ -135,7 +88,45 @@ public class EntityListener implements Listener {
} }
}, 24000L, 48000L); }, 24000L, 48000L);
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onPlayerInteract(final PlayerInteractEvent e) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
final Player p = e.getPlayer();
World w = p.getWorld();
String n = w.getName();
if (e.getMaterial() == Material.MONSTER_EGG || e.getMaterial() == Material.MONSTER_EGGS) {
if (entityMap.containsKey(n)) {
Location l = e.getClickedBlock().getLocation();
Plot plot = PlotHelper.getCurrentPlot(l);
if (plot != null && plot.hasRights(p)) {
int mobs;
if (entityMap.get(n).containsKey(plot)) {
mobs = entityMap.get(n).get(plot).size();
} else {
mobs = 0;
}
if (!(PlotMain.hasPermissionRange(p, "plots.mobcap", Settings.MOB_CAP) > mobs)) {
PlayerFunctions.sendMessage(p, C.NO_PLOTS, "plots.mobcap." + (mobs + 1));
}
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public static void onCreatureSpawn(CreatureSpawnEvent e) {
Location l = e.getLocation();
String w = l.getWorld().getName();
if (PlotMain.isPlotWorld(w)) {
Plot plot = PlotHelper.getCurrentPlot(l);
if (plot != null && plot.hasOwner()) {
addEntity(e.getEntity(), plot);
}
}
}
@EventHandler @EventHandler
public static void onChunkLoad(final ChunkLoadEvent e) { public static void onChunkLoad(final ChunkLoadEvent e) {
if (PlotMain.isPlotWorld(e.getWorld())) { if (PlotMain.isPlotWorld(e.getWorld())) {
@ -143,7 +134,7 @@ public class EntityListener implements Listener {
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {
if (!(entity instanceof Player)) { if (!(entity instanceof Player)) {
Plot plot = PlotHelper.getCurrentPlot(entity.getLocation()); Plot plot = PlotHelper.getCurrentPlot(entity.getLocation());
if (plot!=null) { if (plot != null) {
if (plot.hasOwner()) { if (plot.hasOwner()) {
addEntity(entity, plot); addEntity(entity, plot);
} }
@ -153,7 +144,7 @@ public class EntityListener implements Listener {
} }
} }
} }
public static void addEntity(Entity entity, Plot plot) { public static void addEntity(Entity entity, Plot plot) {
if (!entityMap.containsKey(plot.world)) { if (!entityMap.containsKey(plot.world)) {
entityMap.put(plot.world, new HashMap<Plot, HashSet<Integer>>()); entityMap.put(plot.world, new HashMap<Plot, HashSet<Integer>>());
@ -164,7 +155,7 @@ public class EntityListener implements Listener {
} }
section.get(plot).add(entity.getEntityId()); section.get(plot).add(entity.getEntityId());
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public static void onEntityDeath(EntityDeathEvent e) { public static void onEntityDeath(EntityDeathEvent e) {
Entity entity = e.getEntity(); Entity entity = e.getEntity();
@ -173,12 +164,11 @@ public class EntityListener implements Listener {
if (entityMap.containsKey(w)) { if (entityMap.containsKey(w)) {
int id = entity.getEntityId(); int id = entity.getEntityId();
Plot plot = PlotHelper.getCurrentPlot(entity.getLocation()); Plot plot = PlotHelper.getCurrentPlot(entity.getLocation());
if (plot!=null) { if (plot != null) {
if (entityMap.get(w).containsKey(plot)) { if (entityMap.get(w).containsKey(plot)) {
entityMap.get(w).get(plot).remove(id); entityMap.get(w).get(plot).remove(id);
} }
} } else {
else {
Iterator<Entry<Plot, HashSet<Integer>>> it = entityMap.get(w).entrySet().iterator(); Iterator<Entry<Plot, HashSet<Integer>>> it = entityMap.get(w).entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Entry<Plot, HashSet<Integer>> n = it.next(); Entry<Plot, HashSet<Integer>> n = it.next();
@ -187,7 +177,7 @@ public class EntityListener implements Listener {
} }
} }
} }
@EventHandler @EventHandler
public static void onChunkDespawn(final ChunkUnloadEvent e) { public static void onChunkDespawn(final ChunkUnloadEvent e) {
String w = e.getWorld().getName(); String w = e.getWorld().getName();
@ -196,13 +186,12 @@ public class EntityListener implements Listener {
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {
if (!(entity instanceof Player)) { if (!(entity instanceof Player)) {
Plot plot = PlotHelper.getCurrentPlot(entity.getLocation()); Plot plot = PlotHelper.getCurrentPlot(entity.getLocation());
if (plot!=null) { if (plot != null) {
if (plot.hasOwner()) { if (plot.hasOwner()) {
if (entityMap.get(w).containsKey(plot)) { if (entityMap.get(w).containsKey(plot)) {
if (entityMap.get(w).get(plot).size()==1) { if (entityMap.get(w).get(plot).size() == 1) {
entityMap.get(w).remove(plot); entityMap.get(w).remove(plot);
} } else {
else {
entityMap.get(w).get(plot).remove(entity.getEntityId()); entityMap.get(w).get(plot).remove(entity.getEntityId());
} }
} }

View File

@ -21,8 +21,8 @@
package com.intellectualcrafters.plot.listeners; package com.intellectualcrafters.plot.listeners;
import com.intellectualcrafters.plot.PlayerFunctions; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -21,9 +21,13 @@
package com.intellectualcrafters.plot.listeners; package com.intellectualcrafters.plot.listeners;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.commands.Setup; import com.intellectualcrafters.plot.commands.Setup;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -79,7 +83,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
final Location f = event.getFrom(); final Location f = event.getFrom();
final Location t = event.getTo(); final Location t = event.getTo();
final Location q = new Location(t.getWorld(), t.getBlockX(), 64, t.getZ()); final Location q = new Location(t.getWorld(), t.getBlockX(), 64, t.getZ());
if ((f.getBlockX() != q.getBlockX()) || (f.getBlockZ() != q.getBlockZ())) { if ((f.getBlockX() != q.getBlockX()) || (f.getBlockZ() != q.getBlockZ())) {
if (!isPlotWorld(player.getWorld())) { if (!isPlotWorld(player.getWorld())) {
return; return;
@ -421,20 +425,17 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onBlockIgnite(final BlockIgniteEvent e) { public static void onBlockIgnite(final BlockIgniteEvent e) {
final World world; final World world;
if (e.getBlock() != null) { if (e.getBlock() != null) {
world = e.getBlock().getWorld(); world = e.getBlock().getWorld();
} } else if (e.getIgnitingEntity() != null) {
else if (e.getIgnitingEntity() != null) {
world = e.getIgnitingEntity().getWorld(); world = e.getIgnitingEntity().getWorld();
} } else if (e.getPlayer() != null) {
else if (e.getPlayer() != null) {
world = e.getPlayer().getWorld(); world = e.getPlayer().getWorld();
} } else {
else {
return; return;
} }
if (!isPlotWorld(world)) { if (!isPlotWorld(world)) {
return; return;
} }

View File

@ -21,9 +21,15 @@
package com.intellectualcrafters.plot.listeners; package com.intellectualcrafters.plot.listeners;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent; import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent;
import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -211,7 +217,6 @@ public class PlotListener {
final PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(player, plot); final PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(player, plot);
Bukkit.getPluginManager().callEvent(callEvent); Bukkit.getPluginManager().callEvent(callEvent);
} }
PlayerFunctions.sendMessage(player, plot.settings.getJoinMessage());
} }
} }
@ -232,7 +237,6 @@ public class PlotListener {
if (plot.settings.getFlag("weather") != null) { if (plot.settings.getFlag("weather") != null) {
player.resetPlayerWeather(); player.resetPlayerWeather();
} }
PlayerFunctions.sendMessage(player, plot.settings.getLeaveMessage());
} }
public static boolean getFlagValue(final String value) { public static boolean getFlagValue(final String value) {

View File

@ -21,11 +21,11 @@
package com.intellectualcrafters.plot.listeners; package com.intellectualcrafters.plot.listeners;
import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent; import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent;
import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -21,9 +21,14 @@
package com.intellectualcrafters.plot.listeners; package com.intellectualcrafters.plot.listeners;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.events.PlotDeleteEvent;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.PWE;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;

View File

@ -21,11 +21,15 @@
package com.intellectualcrafters.plot.listeners; package com.intellectualcrafters.plot.listeners;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.events.PlotDeleteEvent;
import com.intellectualcrafters.plot.events.PlotMergeEvent; import com.intellectualcrafters.plot.events.PlotMergeEvent;
import com.intellectualcrafters.plot.events.PlotUnlinkEvent; import com.intellectualcrafters.plot.events.PlotUnlinkEvent;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldguard.domains.DefaultDomain; import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.flags.DefaultFlag; import com.sk89q.worldguard.protection.flags.DefaultFlag;

View File

@ -19,7 +19,7 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.object;
/** /**
* Wrapper class for blocks, using * Wrapper class for blocks, using

View File

@ -19,9 +19,12 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.object;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.util.PlotHelper;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
@ -92,7 +95,6 @@ public class Plot implements Cloneable {
public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList<UUID> helpers, final ArrayList<UUID> denied, final String world) { public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList<UUID> helpers, final ArrayList<UUID> denied, final String world) {
this.id = id; this.id = id;
this.settings = new PlotSettings(this); this.settings = new PlotSettings(this);
this.settings.setBiome(plotBiome);
this.owner = owner; this.owner = owner;
this.deny_entry = this.owner == null; this.deny_entry = this.owner == null;
this.helpers = helpers; this.helpers = helpers;
@ -118,7 +120,6 @@ public class Plot implements Cloneable {
public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList<UUID> helpers, final ArrayList<UUID> trusted, final ArrayList<UUID> denied, final String alias, final PlotHomePosition position, final Flag[] flags, final String world, final boolean[] merged) { public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList<UUID> helpers, final ArrayList<UUID> trusted, final ArrayList<UUID> denied, final String alias, final PlotHomePosition position, final Flag[] flags, final String world, final boolean[] merged) {
this.id = id; this.id = id;
this.settings = new PlotSettings(this); this.settings = new PlotSettings(this);
this.settings.setBiome(plotBiome);
this.owner = owner; this.owner = owner;
this.deny_entry = this.owner != null; this.deny_entry = this.owner != null;
this.trusted = trusted; this.trusted = trusted;

View File

@ -19,7 +19,7 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.object;
public class PlotBlock { public class PlotBlock {
public short id; public short id;

View File

@ -19,7 +19,7 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.object;
public class PlotComment { public class PlotComment {
public final String comment; public final String comment;

View File

@ -19,8 +19,9 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.object;
import com.intellectualcrafters.plot.PlotMain;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
public abstract class PlotGenerator extends ChunkGenerator { public abstract class PlotGenerator extends ChunkGenerator {

View File

@ -19,7 +19,7 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.object;
/** /**
* Created by Citymonstret on 2014-08-05. * Created by Citymonstret on 2014-08-05.

View File

@ -19,30 +19,10 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.object;
public class PlotId { public class PlotId {
/**
* Get a Plot Id based on a string
*
* @param string to create id from
* @return null if the string is invalid
*/
public static PlotId fromString(final String string) {
int x, y;
String[] parts = string.split(";");
if (parts.length < 2)
return null;
try {
x = Integer.parseInt(parts[0]);
y = Integer.parseInt(parts[1]);
} catch (Exception e) {
return null;
}
return new PlotId(x, y);
}
/** /**
* x value * x value
*/ */
@ -63,6 +43,26 @@ public class PlotId {
this.y = y; this.y = y;
} }
/**
* Get a Plot Id based on a string
*
* @param string to create id from
* @return null if the string is invalid
*/
public static PlotId fromString(final String string) {
int x, y;
String[] parts = string.split(";");
if (parts.length < 2)
return null;
try {
x = Integer.parseInt(parts[0]);
y = Integer.parseInt(parts[1]);
} catch (Exception e) {
return null;
}
return new PlotId(x, y);
}
@Override @Override
public boolean equals(final Object obj) { public boolean equals(final Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -19,7 +19,7 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.object;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -27,6 +27,7 @@ import org.bukkit.block.Biome;
import java.util.ArrayList; import java.util.ArrayList;
@SuppressWarnings("unused")
public abstract class PlotManager { public abstract class PlotManager {
/* /*

View File

@ -19,8 +19,10 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.object;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.SetBlockFast;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;

View File

@ -19,8 +19,10 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.object;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.util.PlotHelper;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import java.util.ArrayList; import java.util.ArrayList;
@ -32,6 +34,7 @@ import java.util.Set;
* plot settings * plot settings
* *
* @author Citymonstret * @author Citymonstret
* @author Empire92
*/ */
public class PlotSettings { public class PlotSettings {
/** /**
@ -43,23 +46,26 @@ public class PlotSettings {
*/ */
private String alias; private String alias;
/** /**
* plot biome * Comments
*/ */
private Biome biome;
private ArrayList<PlotComment> comments = null; private ArrayList<PlotComment> comments = null;
/** /**
* * Flags
*/ */
private Set<Flag> flags; private Set<Flag> flags;
/**
* Home Position
*/
private PlotHomePosition position; private PlotHomePosition position;
/**
* Plot
*/
private Plot plot; private Plot plot;
/** /**
* Constructor * Constructor
* *
* @param plot * @param plot object
*/ */
public PlotSettings(final Plot plot) { public PlotSettings(final Plot plot) {
this.alias = ""; this.alias = "";
@ -73,8 +79,8 @@ public class PlotSettings {
* 2 = South<br> * 2 = South<br>
* 3 = West<br> * 3 = West<br>
* *
* @param direction * @param direction Direction to check
* @return boolean * @return boolean merged
*/ */
public boolean getMerged(final int direction) { public boolean getMerged(final int direction) {
return this.merged[direction]; return this.merged[direction];
@ -107,14 +113,7 @@ public class PlotSettings {
} }
/** /**
* @param b * @param flag to add
*/
public void setBiome(final Biome b) {
this.biome = b;
}
/**
* @param flag
*/ */
public void addFlag(final Flag flag) { public void addFlag(final Flag flag) {
final Flag hasFlag = getFlag(flag.getKey()); final Flag hasFlag = getFlag(flag.getKey());
@ -125,7 +124,9 @@ public class PlotSettings {
} }
/** /**
* @return * Get all flags applied for the plot
*
* @return flags
*/ */
public Set<Flag> getFlags() { public Set<Flag> getFlags() {
return this.flags; return this.flags;
@ -164,22 +165,37 @@ public class PlotSettings {
} }
/** /**
* @param alias * Set the plot alias
*
* @param alias alias to be used
*/ */
public void setAlias(final String alias) { public void setAlias(final String alias) {
this.alias = alias; this.alias = alias;
} }
public String getJoinMessage() { public String getJoinMessage() {
Flag greeting = getFlag("greeting");
if (greeting != null) {
return greeting.getValue();
}
return ""; return "";
} }
/**
* Get the "farewell" flag value
*
* @return Farewell flag
*/
public String getLeaveMessage() { public String getLeaveMessage() {
Flag farewell = getFlag("farewell");
if (farewell != null) {
return farewell.getValue();
}
return ""; return "";
} }
public ArrayList<PlotComment> getComments(final int tier) { public ArrayList<PlotComment> getComments(final int tier) {
final ArrayList<PlotComment> c = new ArrayList<PlotComment>(); final ArrayList<PlotComment> c = new ArrayList<>();
for (final PlotComment comment : this.comments) { for (final PlotComment comment : this.comments) {
if (comment.tier == tier) { if (comment.tier == tier) {
c.add(comment); c.add(comment);
@ -206,7 +222,7 @@ public class PlotSettings {
public void addComment(final PlotComment comment) { public void addComment(final PlotComment comment) {
if (this.comments == null) { if (this.comments == null) {
this.comments = new ArrayList<PlotComment>(); this.comments = new ArrayList<>();
} }
this.comments.add(comment); this.comments.add(comment);
} }

View File

@ -19,8 +19,10 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.object;
import com.intellectualcrafters.plot.config.Configuration;
import com.intellectualcrafters.plot.config.ConfigurationNode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -172,7 +174,47 @@ public abstract class PlotWorld {
} }
} }
public String worldname; /**
* Saving core plotworld settings
*
* @param config
*/
public void saveConfiguration(final ConfigurationSection config) {
final HashMap<String, Object> options = new HashMap<String, Object>();
options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT);
options.put("plot.auto_merge", PlotWorld.AUTO_MERGE_DEFAULT);
options.put("plot.biome", PlotWorld.PLOT_BIOME_DEFAULT.toString());
options.put("schematic.on_claim", PlotWorld.SCHEMATIC_ON_CLAIM_DEFAULT);
options.put("schematic.file", PlotWorld.SCHEMATIC_FILE_DEFAULT);
options.put("schematic.specify_on_claim", PlotWorld.SCHEMATIC_CLAIM_SPECIFY_DEFAULT);
options.put("schematic.schematics", PlotWorld.SCHEMATICS_DEFAULT);
options.put("economy.use", PlotWorld.USE_ECONOMY_DEFAULT);
options.put("economy.prices.claim", PlotWorld.PLOT_PRICE_DEFAULT);
options.put("economy.prices.merge", PlotWorld.MERGE_PRICE_DEFAULT);
options.put("economy.prices.sell", PlotWorld.SELL_PRICE_DEFAULT);
options.put("chat.enabled", PlotWorld.PLOT_CHAT_DEFAULT);
options.put("flags.default", PlotWorld.DEFAULT_FLAGS_DEFAULT);
options.put("event.pvp", PlotWorld.PVP_DEFAULT);
options.put("event.pve", PlotWorld.PVE_DEFAULT);
options.put("event.spawn.egg", PlotWorld.SPAWN_EGGS_DEFAULT);
options.put("event.spawn.custom", PlotWorld.SPAWN_CUSTOM_DEFAULT);
options.put("event.spawn.breeding", PlotWorld.SPAWN_BREEDING_DEFAULT);
final ConfigurationNode[] settings = getSettingNodes();
/*
* Saving generator specific settings
*/
for (final ConfigurationNode setting : settings) {
options.put(setting.getConstant(), setting.getType().parseObject(setting.getValue()));
}
for (final String option : options.keySet()) {
if (!config.contains(option)) {
config.set(option, options.get(option));
}
}
} public String worldname;
/** /**
* Used for the <b>/plot setup</b> command Return null if you do not want to * Used for the <b>/plot setup</b> command Return null if you do not want to

View File

@ -19,7 +19,7 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.object;
/** /**
* @author Empire92 * @author Empire92

View File

@ -19,7 +19,7 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.object;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -38,6 +38,11 @@ import java.util.Map;
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class Title { public class Title {
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES;
static {
CORRESPONDING_TYPES = new HashMap<>();
}
/* Title packet */ /* Title packet */
private Class<?> packetTitle; private Class<?> packetTitle;
/* Title packet actions ENUM */ /* Title packet actions ENUM */
@ -56,12 +61,6 @@ public class Title {
private int fadeOutTime = -1; private int fadeOutTime = -1;
private boolean ticks = false; private boolean ticks = false;
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES;
static {
CORRESPONDING_TYPES = new HashMap<>();
}
/** /**
* Create a new 1.8 title * Create a new 1.8 title
* *
@ -102,6 +101,18 @@ public class Title {
loadClasses(); loadClasses();
} }
private static boolean equalsTypeArray(final Class<?>[] a, final Class<?>[] o) {
if (a.length != o.length) {
return false;
}
for (int i = 0; i < a.length; i++) {
if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i])) {
return false;
}
}
return true;
}
/** /**
* Load spigot and NMS classes * Load spigot and NMS classes
*/ */
@ -325,18 +336,6 @@ public class Title {
return types; return types;
} }
private static boolean equalsTypeArray(final Class<?>[] a, final Class<?>[] o) {
if (a.length != o.length) {
return false;
}
for (int i = 0; i < a.length; i++) {
if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i])) {
return false;
}
}
return true;
}
private Object getHandle(final Object obj) { private Object getHandle(final Object obj) {
try { try {
return getMethod("getHandle", obj.getClass()).invoke(obj); return getMethod("getHandle", obj.getClass()).invoke(obj);

View File

@ -19,7 +19,7 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.util;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -19,7 +19,7 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.util;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -19,7 +19,7 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.util;
/** /**
* TPS and Lag Checker. * TPS and Lag Checker.
@ -78,12 +78,6 @@ public class Lag implements Runnable {
return System.currentTimeMillis() - t; return System.currentTimeMillis() - t;
} }
@Override
public void run() {
T[TC % T.length] = System.currentTimeMillis();
TC++;
}
/** /**
* Get lag percentage * Get lag percentage
* *
@ -101,4 +95,10 @@ public class Lag implements Runnable {
public static double getFullPercentage() { public static double getFullPercentage() {
return getTPS() * 5.0D; return getTPS() * 5.0D;
} }
@Override
public void run() {
T[TC % T.length] = System.currentTimeMillis();
TC++;
}
} }

View File

@ -19,7 +19,10 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.util;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -50,22 +53,6 @@ public class Logger {
} }
} }
public enum LogLevel {
GENERAL("General"),
WARNING("Warning"),
DANGER("Danger");
private final String name;
LogLevel(final String name) {
this.name = name;
}
@Override
public String toString() {
return this.name;
}
}
public static void write() throws IOException { public static void write() throws IOException {
final FileWriter writer = new FileWriter(log); final FileWriter writer = new FileWriter(log);
for (final String string : entries) { for (final String string : entries) {
@ -81,4 +68,20 @@ public class Logger {
private static void append(final String string) { private static void append(final String string) {
entries.add("[" + new Date().toString() + "]" + string); entries.add("[" + new Date().toString() + "]" + string);
} }
public enum LogLevel {
GENERAL("General"),
WARNING("Warning"),
DANGER("Danger");
private final String name;
LogLevel(final String name) {
this.name = name;
}
@Override
public String toString() {
return this.name;
}
}
} }

View File

@ -19,7 +19,7 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.util;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.InvalidConfigurationException;
@ -111,6 +111,114 @@ public class Metrics {
this.debug = this.configuration.getBoolean("debug", false); this.debug = this.configuration.getBoolean("debug", false);
} }
/**
* GZip compress a string of bytes
*
* @param input
* @return
*/
public static byte[] gzip(final String input) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gzos = null;
try {
gzos = new GZIPOutputStream(baos);
gzos.write(input.getBytes("UTF-8"));
} catch (final IOException e) {
e.printStackTrace();
} finally {
if (gzos != null) {
try {
gzos.close();
} catch (final IOException ignore) {
}
}
}
return baos.toByteArray();
}
/**
* Appends a json encoded key/value pair to the given string builder.
*
* @param json
* @param key
* @param value
* @throws UnsupportedEncodingException
*/
private static void appendJSONPair(final StringBuilder json, final String key, final String value) throws UnsupportedEncodingException {
boolean isValueNumeric = false;
try {
if (value.equals("0") || !value.endsWith("0")) {
Double.parseDouble(value);
isValueNumeric = true;
}
} catch (final NumberFormatException e) {
isValueNumeric = false;
}
if (json.charAt(json.length() - 1) != '{') {
json.append(',');
}
json.append(escapeJSON(key));
json.append(':');
if (isValueNumeric) {
json.append(value);
} else {
json.append(escapeJSON(value));
}
}
/**
* Escape a string to create a valid JSON string
*
* @param text
* @return
*/
private static String escapeJSON(final String text) {
final StringBuilder builder = new StringBuilder();
builder.append('"');
for (int index = 0; index < text.length(); index++) {
final char chr = text.charAt(index);
switch (chr) {
case '"':
case '\\':
builder.append('\\');
builder.append(chr);
break;
case '\b':
builder.append("\\b");
break;
case '\t':
builder.append("\\t");
break;
case '\n':
builder.append("\\n");
break;
case '\r':
builder.append("\\r");
break;
default:
if (chr < ' ') {
final String t = "000" + Integer.toHexString(chr);
builder.append("\\u" + t.substring(t.length() - 4));
} else {
builder.append(chr);
}
break;
}
}
builder.append('"');
return builder.toString();
}
/**
* Encode text as UTF-8
*
* @param text the text to encode
* @return the encoded text, as UTF-8
*/
private static String urlEncode(final String text) throws UnsupportedEncodingException {
return URLEncoder.encode(text, "UTF-8");
}
/** /**
* Construct and create a Graph that can be used to separate specific * Construct and create a Graph that can be used to separate specific
* plotters to their own graphs on the metrics website. Plotters can be * plotters to their own graphs on the metrics website. Plotters can be
@ -445,31 +553,6 @@ public class Metrics {
} }
} }
/**
* GZip compress a string of bytes
*
* @param input
* @return
*/
public static byte[] gzip(final String input) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gzos = null;
try {
gzos = new GZIPOutputStream(baos);
gzos.write(input.getBytes("UTF-8"));
} catch (final IOException e) {
e.printStackTrace();
} finally {
if (gzos != null) {
try {
gzos.close();
} catch (final IOException ignore) {
}
}
}
return baos.toByteArray();
}
/** /**
* Check if mineshafter is present. If it is, we need to bypass it to send * Check if mineshafter is present. If it is, we need to bypass it to send
* POST requests * POST requests
@ -485,89 +568,6 @@ public class Metrics {
} }
} }
/**
* Appends a json encoded key/value pair to the given string builder.
*
* @param json
* @param key
* @param value
* @throws UnsupportedEncodingException
*/
private static void appendJSONPair(final StringBuilder json, final String key, final String value) throws UnsupportedEncodingException {
boolean isValueNumeric = false;
try {
if (value.equals("0") || !value.endsWith("0")) {
Double.parseDouble(value);
isValueNumeric = true;
}
} catch (final NumberFormatException e) {
isValueNumeric = false;
}
if (json.charAt(json.length() - 1) != '{') {
json.append(',');
}
json.append(escapeJSON(key));
json.append(':');
if (isValueNumeric) {
json.append(value);
} else {
json.append(escapeJSON(value));
}
}
/**
* Escape a string to create a valid JSON string
*
* @param text
* @return
*/
private static String escapeJSON(final String text) {
final StringBuilder builder = new StringBuilder();
builder.append('"');
for (int index = 0; index < text.length(); index++) {
final char chr = text.charAt(index);
switch (chr) {
case '"':
case '\\':
builder.append('\\');
builder.append(chr);
break;
case '\b':
builder.append("\\b");
break;
case '\t':
builder.append("\\t");
break;
case '\n':
builder.append("\\n");
break;
case '\r':
builder.append("\\r");
break;
default:
if (chr < ' ') {
final String t = "000" + Integer.toHexString(chr);
builder.append("\\u" + t.substring(t.length() - 4));
} else {
builder.append(chr);
}
break;
}
}
builder.append('"');
return builder.toString();
}
/**
* Encode text as UTF-8
*
* @param text the text to encode
* @return the encoded text, as UTF-8
*/
private static String urlEncode(final String text) throws UnsupportedEncodingException {
return URLEncoder.encode(text, "UTF-8");
}
/** /**
* Represents a custom graph on the website * Represents a custom graph on the website
*/ */

View File

@ -19,9 +19,12 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.util;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;

View File

@ -19,8 +19,15 @@
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot.util;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotWorld;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -292,7 +299,7 @@ public class PlayerFunctions {
* *
* @param plr Player to recieve message * @param plr Player to recieve message
* @param c Caption to send * @param c Caption to send
* @return * @return
*/ */
public static boolean sendMessage(final Player plr, final C c, final String... args) { public static boolean sendMessage(final Player plr, final C c, final String... args) {
if (c.s().length() > 1) { if (c.s().length() > 1) {

Some files were not shown because too many files have changed in this diff Show More