more stuff

This commit is contained in:
boy0001 2015-02-20 22:37:34 +11:00
parent 081da35024
commit 4aeb5f459f
3 changed files with 51 additions and 34 deletions

View File

@ -10,6 +10,7 @@ import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent;
import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.events.PlotDeleteEvent;
import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.generator.HybridGen;
import com.intellectualcrafters.plot.listeners.*; import com.intellectualcrafters.plot.listeners.*;
import com.intellectualcrafters.plot.object.BukkitPlayer;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
@ -19,7 +20,9 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.bukkit.*; import com.intellectualcrafters.plot.util.bukkit.*;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Chunk; import org.bukkit.Chunk;
@ -76,7 +79,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
if (Settings.USE_PLOTME_ALIAS) { if (Settings.USE_PLOTME_ALIAS) {
player.performCommand(message.replace("/plotme", "plots")); player.performCommand(message.replace("/plotme", "plots"));
} else { } else {
BukkitPlayerFunctions.sendMessage(player, C.NOT_USING_PLOTME); MainUtil.sendMessage(new BukkitPlayer(player), C.NOT_USING_PLOTME);
} }
event.setCancelled(true); event.setCancelled(true);
} }

View File

@ -1,28 +1,29 @@
package com.intellectualcrafters.plot.generator; package com.intellectualcrafters.plot.generator;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
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.block.Block; import org.bukkit.block.Block;
import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.AChunkManager;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.ChunkManager;
import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.MainUtil;
/** /**
* A plot manager with a square grid layout, with square shaped plots * A plot manager with a square grid layout, with square shaped plots
*/ */
public abstract class SquarePlotManager extends GridPlotManager { public abstract class SquarePlotManager extends GridPlotManager {
@Override @Override
public boolean clearPlot(final World world, final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whendone) { public boolean clearPlot(final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whenDone) {
final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1); final Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id); final Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id);
ChunkManager.regenerateRegion(pos1, pos2, whendone); AChunkManager.manager.regenerateRegion(pos1, pos2, whenDone);
return true; return true;
} }
@ -33,15 +34,12 @@ public abstract class SquarePlotManager extends GridPlotManager {
final int pz = plotid.y; final int pz = plotid.y;
final int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; final int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
final int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; final int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
return new Location(Bukkit.getWorld(plotworld.worldname), x, 256, z); return new Location(plotworld.worldname, x, 256, z);
} }
@Override @Override
public PlotId getPlotIdAbs(final PlotWorld plotworld, final Location loc) { public PlotId getPlotIdAbs(final PlotWorld plotworld, int x, int y, int z) {
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
// get x,z loc
int x = loc.getBlockX();
int z = loc.getBlockZ();
// get plot size // get plot size
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH; final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
// get size of path on bottom part, and top part of plot // get size of path on bottom part, and top part of plot
@ -78,10 +76,8 @@ public abstract class SquarePlotManager extends GridPlotManager {
} }
@Override @Override
public PlotId getPlotId(final PlotWorld plotworld, final Location loc) { public PlotId getPlotId(final PlotWorld plotworld, int x, int y, int z) {
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
int x = loc.getBlockX();
int z = loc.getBlockZ();
if (plotworld == null) { if (plotworld == null) {
return null; return null;
} }
@ -109,47 +105,49 @@ public abstract class SquarePlotManager extends GridPlotManager {
final boolean eastWest = (rx <= pathWidthLower) || (rx > end); final boolean eastWest = (rx <= pathWidthLower) || (rx > end);
if (northSouth && eastWest) { if (northSouth && eastWest) {
// This means you are in the intersection // This means you are in the intersection
final PlotId id = BukkitPlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, dpw.ROAD_WIDTH)); Location loc = new Location(plotworld.worldname, x + dpw.ROAD_WIDTH, y, z + dpw.ROAD_WIDTH);
final Plot plot = PlotSquared.getPlots(loc.getWorld()).get(id); final PlotId id = MainUtil.getPlotAbs(loc);
final Plot plot = PlotSquared.getPlots(plotworld.worldname).get(id);
if (plot == null) { if (plot == null) {
return null; return null;
} }
if ((plot.settings.getMerged(0) && plot.settings.getMerged(3))) { if ((plot.settings.getMerged(0) && plot.settings.getMerged(3))) {
return BukkitPlayerFunctions.getBottomPlot(loc.getWorld(), plot).id; return MainUtil.getBottomPlot(plot).id;
} }
return null; return null;
} }
if (northSouth) { if (northSouth) {
// You are on a road running West to East (yeah, I named the var // You are on a road running West to East (yeah, I named the var poorly)
// poorly) Location loc = new Location(plotworld.worldname, x, y, z + dpw.ROAD_WIDTH);
final PlotId id = BukkitPlayerFunctions.getPlotAbs(loc.add(0, 0, dpw.ROAD_WIDTH)); final PlotId id = MainUtil.getPlotAbs(loc);
final Plot plot = PlotSquared.getPlots(loc.getWorld()).get(id); final Plot plot = PlotSquared.getPlots(plotworld.worldname).get(id);
if (plot == null) { if (plot == null) {
return null; return null;
} }
if (plot.settings.getMerged(0)) { if (plot.settings.getMerged(0)) {
return BukkitPlayerFunctions.getBottomPlot(loc.getWorld(), plot).id; return MainUtil.getBottomPlot(plot).id;
} }
return null; return null;
} }
if (eastWest) { if (eastWest) {
// This is the road separating an Eastern and Western plot // This is the road separating an Eastern and Western plot
final PlotId id = BukkitPlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, 0)); Location loc = new Location(plotworld.worldname, x + dpw.ROAD_WIDTH, y, z);
final Plot plot = PlotSquared.getPlots(loc.getWorld()).get(id); final PlotId id = MainUtil.getPlotAbs(loc);
final Plot plot = PlotSquared.getPlots(plotworld.worldname).get(id);
if (plot == null) { if (plot == null) {
return null; return null;
} }
if (plot.settings.getMerged(3)) { if (plot.settings.getMerged(3)) {
return BukkitPlayerFunctions.getBottomPlot(loc.getWorld(), plot).id; return MainUtil.getBottomPlot(plot).id;
} }
return null; return null;
} }
final PlotId id = new PlotId(dx + 1, dz + 1); final PlotId id = new PlotId(dx + 1, dz + 1);
final Plot plot = PlotSquared.getPlots(loc.getWorld()).get(id); final Plot plot = PlotSquared.getPlots(plotworld.worldname).get(id);
if (plot == null) { if (plot == null) {
return id; return id;
} }
return BukkitPlayerFunctions.getBottomPlot(loc.getWorld(), plot).id; return MainUtil.getBottomPlot(plot).id;
} }
/** /**
@ -162,20 +160,23 @@ public abstract class SquarePlotManager extends GridPlotManager {
final int pz = plotid.y; final int pz = plotid.y;
final int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; final int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
final int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; final int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
return new Location(Bukkit.getWorld(plotworld.worldname), x, 1, z); return new Location(plotworld.worldname, x, 1, z);
} }
/** /**
* Set a plot biome * Set a plot biome
*/ */
@Override @Override
public boolean setBiome(final World world, final Plot plot, final Biome biome) { public boolean setBiome(final String world, final Plot plot, final Biome biome) {
final int bottomX = MainUtil.getPlotBottomLoc(world, plot.id).getBlockX() - 1; final int bottomX = MainUtil.getPlotBottomLoc(world, plot.id).getX() - 1;
final int topX = MainUtil.getPlotTopLoc(world, plot.id).getBlockX() + 1; final int topX = MainUtil.getPlotTopLoc(world, plot.id).getX() + 1;
final int bottomZ = MainUtil.getPlotBottomLoc(world, plot.id).getBlockZ() - 1; final int bottomZ = MainUtil.getPlotBottomLoc(world, plot.id).getZ() - 1;
final int topZ = MainUtil.getPlotTopLoc(world, plot.id).getBlockZ() + 1; final int topZ = MainUtil.getPlotTopLoc(world, plot.id).getZ() + 1;
final Block block = world.getBlockAt(MainUtil.getPlotBottomLoc(world, plot.id).add(1, 1, 1)); final Block block = world.getBlockAt(MainUtil.getPlotBottomLoc(world, plot.id).add(1, 1, 1));
final Biome current = block.getBiome(); final Biome current = block.getBiome();
if (biome.equals(current)) { if (biome.equals(current)) {
return false; return false;
} }

View File

@ -48,6 +48,19 @@ import java.util.UUID;
* Functions involving players, plots and locations. * Functions involving players, plots and locations.
*/ */
public class BukkitPlayerFunctions { public class BukkitPlayerFunctions {
/*
* =========== NOTICE ================
* - We will try to move as many functions as we can out of this class and into the MainUtil class
*/
/** /**
* Clear a plot. Use null player if no player is present * Clear a plot. Use null player if no player is present
* @param player * @param player