mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Various
sponge changes / documentation / cleanup / event tweak
This commit is contained in:
parent
edc43bd53b
commit
a8fd1b49ca
@ -53,14 +53,18 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PlotSquared API
|
* PlotSquared API<br>
|
||||||
*
|
* <br>
|
||||||
|
* @version API 3.3.1
|
||||||
|
* <br>
|
||||||
* @version API 2.0
|
* Useful classes:<br>
|
||||||
*
|
* @see BukkitUtil
|
||||||
|
* @see PlotPlayer
|
||||||
|
* @see Plot
|
||||||
|
* @see com.intellectualcrafters.plot.object.Location
|
||||||
|
* @see PlotArea
|
||||||
|
* @see PS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PlotAPI {
|
public class PlotAPI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,13 +5,38 @@ import com.intellectualcrafters.plot.config.C;
|
|||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.object.*;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.util.*;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotArea;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotHandler;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotInventory;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||||
|
import com.intellectualcrafters.plot.util.EventUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.MathMan;
|
||||||
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
|
import com.intellectualcrafters.plot.util.RegExUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.plotsquared.bukkit.BukkitMain;
|
import com.plotsquared.bukkit.BukkitMain;
|
||||||
import com.plotsquared.bukkit.object.BukkitLazyBlock;
|
import com.plotsquared.bukkit.object.BukkitLazyBlock;
|
||||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.listener.PlayerBlockEventType;
|
import com.plotsquared.listener.PlayerBlockEventType;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -20,17 +45,64 @@ import org.bukkit.block.Block;
|
|||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.Animals;
|
||||||
|
import org.bukkit.entity.Arrow;
|
||||||
|
import org.bukkit.entity.Creature;
|
||||||
|
import org.bukkit.entity.EnderDragon;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Hanging;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Monster;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Projectile;
|
||||||
|
import org.bukkit.entity.TNTPrimed;
|
||||||
|
import org.bukkit.entity.Tameable;
|
||||||
|
import org.bukkit.entity.ThrownPotion;
|
||||||
|
import org.bukkit.entity.Vehicle;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.*;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.entity.*;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockDamageEvent;
|
||||||
|
import org.bukkit.event.block.BlockDispenseEvent;
|
||||||
|
import org.bukkit.event.block.BlockFadeEvent;
|
||||||
|
import org.bukkit.event.block.BlockFormEvent;
|
||||||
|
import org.bukkit.event.block.BlockFromToEvent;
|
||||||
|
import org.bukkit.event.block.BlockGrowEvent;
|
||||||
|
import org.bukkit.event.block.BlockIgniteEvent;
|
||||||
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
|
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||||
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||||
|
import org.bukkit.event.block.BlockSpreadEvent;
|
||||||
|
import org.bukkit.event.block.EntityBlockFormEvent;
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||||
|
import org.bukkit.event.entity.PotionSplashEvent;
|
||||||
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||||
|
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||||
|
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleCreateEvent;
|
import org.bukkit.event.vehicle.VehicleCreateEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||||
import org.bukkit.event.world.StructureGrowEvent;
|
import org.bukkit.event.world.StructureGrowEvent;
|
||||||
@ -43,10 +115,6 @@ import org.bukkit.projectiles.BlockProjectileSource;
|
|||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Player Events involving plots
|
* Player Events involving plots
|
||||||
*
|
*
|
||||||
@ -1009,7 +1077,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
|||||||
}
|
}
|
||||||
lb = new BukkitLazyBlock(blockId, block);
|
lb = new BukkitLazyBlock(blockId, block);
|
||||||
final ItemStack hand = player.getItemInHand();
|
final ItemStack hand = player.getItemInHand();
|
||||||
if (eventType != null && !player.isSneaking()) {
|
if (eventType != null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Material type = (hand == null) ? null : hand.getType();
|
Material type = (hand == null) ? null : hand.getType();
|
||||||
|
@ -58,7 +58,7 @@ public class Auto extends SubCommand {
|
|||||||
return new PlotId(id.x + 1, id.y);
|
return new PlotId(id.x + 1, id.y);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (id.x.equals(id.y) && (id.x > 0)) {
|
if (id.x == id.y && (id.x > 0)) {
|
||||||
return new PlotId(id.x, id.y + step);
|
return new PlotId(id.x, id.y + step);
|
||||||
}
|
}
|
||||||
if (id.x == absX) {
|
if (id.x == absX) {
|
||||||
@ -159,6 +159,7 @@ public class Auto extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO handle type 2 the same as normal worlds!
|
||||||
if (plotarea.TYPE == 2) {
|
if (plotarea.TYPE == 2) {
|
||||||
final PlotId bot = plotarea.getMin();
|
final PlotId bot = plotarea.getMin();
|
||||||
final PlotId top = plotarea.getMax();
|
final PlotId top = plotarea.getMax();
|
||||||
@ -180,34 +181,26 @@ public class Auto extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NO_FREE_PLOTS);
|
MainUtil.sendMessage(plr, C.NO_FREE_PLOTS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
plotarea.setMeta("lastPlot", new PlotId(0, 0));
|
||||||
boolean br = false;
|
boolean br = false;
|
||||||
if ((size_x == 1) && (size_z == 1)) {
|
while (true) {
|
||||||
while (!br) {
|
final PlotId start = getNextPlotId(getLastPlotId(plotarea), 1);
|
||||||
Plot plot = plotarea.getPlotAbs(getLastPlotId(plotarea));
|
final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1);
|
||||||
if (plot.canClaim(plr)) {
|
plotarea.setMeta("lastPlot", start);
|
||||||
plot.claim(plr, true, null);
|
if (plotarea.canClaim(plr, start, end)) {
|
||||||
br = true;
|
for (int i = start.x; i <= end.x; i++) {
|
||||||
}
|
for (int j = start.y; j <= end.y; j++) {
|
||||||
plotarea.setMeta("lastPlot", getNextPlotId(plot.getId(), 1));
|
Plot plot = plotarea.getPlotAbs(new PlotId(i, j));
|
||||||
}
|
final boolean teleport = ((i == end.x) && (j == end.y));
|
||||||
} else {
|
plot.claim(plr, teleport, null);
|
||||||
while (!br) {
|
|
||||||
final PlotId start = getNextPlotId(getLastPlotId(plotarea), 1);
|
|
||||||
final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1);
|
|
||||||
plotarea.setMeta("lastPlot", start);
|
|
||||||
if (plotarea.canClaim(plr, start, end)) {
|
|
||||||
for (int i = start.x; i <= end.x; i++) {
|
|
||||||
for (int j = start.y; j <= end.y; j++) {
|
|
||||||
Plot plot = plotarea.getPlotAbs(new PlotId(i, j));
|
|
||||||
final boolean teleport = ((i == end.x) && (j == end.y));
|
|
||||||
plot.claim(plr, teleport, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if ((size_x != 1) || (size_z != 1)) {
|
||||||
if (!plotarea.mergePlots(MainUtil.getPlotSelectionIds(start, end), Settings.MERGE_REMOVES_ROADS, true)) {
|
if (!plotarea.mergePlots(MainUtil.getPlotSelectionIds(start, end), Settings.MERGE_REMOVES_ROADS, true)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
br = true;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plotarea.setMeta("lastPlot", new PlotId(0, 0));
|
plotarea.setMeta("lastPlot", new PlotId(0, 0));
|
||||||
|
@ -68,7 +68,7 @@ public class Buy extends SubCommand {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
plot = loc.getPlotAbs();
|
plot = loc.getPlotAbs();
|
||||||
plots = plot.getConnectedPlots();
|
plots = plot != null ? plot.getConnectedPlots() : null;
|
||||||
}
|
}
|
||||||
if (plots == null) {
|
if (plots == null) {
|
||||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
|
@ -8,6 +8,11 @@ import com.intellectualcrafters.plot.object.PseudoRandom;
|
|||||||
import com.intellectualcrafters.plot.object.SetupObject;
|
import com.intellectualcrafters.plot.object.SetupObject;
|
||||||
import com.intellectualcrafters.plot.util.PlotChunk;
|
import com.intellectualcrafters.plot.util.PlotChunk;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class allows for implementation independent world generation<br>
|
||||||
|
* - Sponge/Bukkit API<br><br>
|
||||||
|
* Use the specify method to get the generator for that platform.
|
||||||
|
*/
|
||||||
public abstract class IndependentPlotGenerator {
|
public abstract class IndependentPlotGenerator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,7 +45,12 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plot class
|
* The plot class<br>
|
||||||
|
* [IMPORTANT]
|
||||||
|
* - Unclaimed plots will not have persistent information.
|
||||||
|
* - Any information set/modified in an unclaimed object may not be reflected in other instances
|
||||||
|
* - Using the `new` operator will create an unclaimed plot instance
|
||||||
|
* - Use the methods from the PlotArea/PS/Location etc to get existing plots
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class Plot {
|
public class Plot {
|
||||||
@ -212,6 +217,12 @@ public class Plot {
|
|||||||
this.temp = temp;
|
this.temp = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a plot from a string e.g. [area];[id]
|
||||||
|
* @param defaultArea If no area is specified
|
||||||
|
* @param string plot id/area + id
|
||||||
|
* @return New or existing plot object
|
||||||
|
*/
|
||||||
public static Plot fromString(final PlotArea defaultArea, final String string) {
|
public static Plot fromString(final PlotArea defaultArea, final String string) {
|
||||||
final String[] split = string.split(";|,");
|
final String[] split = string.split(";|,");
|
||||||
if (split.length == 2) {
|
if (split.length == 2) {
|
||||||
@ -431,6 +442,12 @@ public class Plot {
|
|||||||
return this.area;
|
return this.area;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign this plot to a plot area.<br>
|
||||||
|
* (Mostly used during startup when worlds are being created)<br>
|
||||||
|
* Note: Using this when it doesn't make sense will result in strange behavior
|
||||||
|
* @param area
|
||||||
|
*/
|
||||||
public void setArea(final PlotArea area) {
|
public void setArea(final PlotArea area) {
|
||||||
if (this.getArea() == area) {
|
if (this.getArea() == area) {
|
||||||
return;
|
return;
|
||||||
@ -497,7 +514,7 @@ public class Plot {
|
|||||||
this.origin = this;
|
this.origin = this;
|
||||||
PlotId min = this.id;
|
PlotId min = this.id;
|
||||||
for (final Plot plot : this.getConnectedPlots()) {
|
for (final Plot plot : this.getConnectedPlots()) {
|
||||||
if ((plot.id.y < min.y) || (plot.id.y.equals(min.y) && (plot.id.x < min.x))) {
|
if ((plot.id.y < min.y) || (plot.id.y == min.y && plot.id.x < min.x)) {
|
||||||
this.origin = plot;
|
this.origin = plot;
|
||||||
min = plot.id;
|
min = plot.id;
|
||||||
}
|
}
|
||||||
@ -1023,6 +1040,11 @@ public class Plot {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrement the number of tracked tasks this plot is running<br>
|
||||||
|
* - Used to track/limit the number of things a player can do on the plot at once
|
||||||
|
* @return previous number of tasks (int)
|
||||||
|
*/
|
||||||
public int removeRunning() {
|
public int removeRunning() {
|
||||||
final int value = this.getRunning();
|
final int value = this.getRunning();
|
||||||
if (value < 2) {
|
if (value < 2) {
|
||||||
@ -1037,11 +1059,21 @@ public class Plot {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of tracked running tasks for this plot<br>
|
||||||
|
* - Used to track/limit the number of things a player can do on the plot at once
|
||||||
|
* @return number of tasks (int)
|
||||||
|
*/
|
||||||
public int getRunning() {
|
public int getRunning() {
|
||||||
final Integer value = (Integer) this.getMeta("running");
|
final Integer value = (Integer) this.getMeta("running");
|
||||||
return value == null ? 0 : value;
|
return value == null ? 0 : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unclaim the plot (does not modify terrain)<br>
|
||||||
|
* - Changes made to this plot will not be reflected in unclaimed plot objects<br>
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean unclaim() {
|
public boolean unclaim() {
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -1776,8 +1808,10 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the plot hashcode
|
* Get the plot hashcode<br>
|
||||||
*
|
* Note: The hashcode is unique if:<br>
|
||||||
|
* - Plots are in the same world<br>
|
||||||
|
* - The x,z coordinates are between Short.MIN_VALUE and Short.MAX_VALUE<br>
|
||||||
* @return integer.
|
* @return integer.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -1853,7 +1887,7 @@ public class Plot {
|
|||||||
if (value) {
|
if (value) {
|
||||||
final Plot other = this.getRelative(direction).getBasePlot(false);
|
final Plot other = this.getRelative(direction).getBasePlot(false);
|
||||||
if (!other.equals(this.getBasePlot(false))) {
|
if (!other.equals(this.getBasePlot(false))) {
|
||||||
final Plot base = (other.id.y < this.id.y) || (other.id.y.equals(this.id.y) && (other.id.x < this.id.x)) ? other : this.origin;
|
final Plot base = (other.id.y < this.id.y) || (other.id.y == this.id.y && (other.id.x < this.id.x)) ? other : this.origin;
|
||||||
this.origin.origin = base;
|
this.origin.origin = base;
|
||||||
other.origin = base;
|
other.origin = base;
|
||||||
this.origin = base;
|
this.origin = base;
|
||||||
@ -1920,6 +1954,11 @@ public class Plot {
|
|||||||
return this.settings.getPosition();
|
return this.settings.getPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a plot can be claimed
|
||||||
|
* @param player
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean canClaim(final PlotPlayer player) {
|
public boolean canClaim(final PlotPlayer player) {
|
||||||
if (Settings.ENABLE_CLUSTERS) {
|
if (Settings.ENABLE_CLUSTERS) {
|
||||||
final PlotCluster cluster = this.getCluster();
|
final PlotCluster cluster = this.getCluster();
|
||||||
@ -1929,9 +1968,14 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.guessOwner() == null;
|
return this.guessOwner() == null && !isMerged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Guess the owner of a plot either by the value in memory, or the sign data<br>
|
||||||
|
* Note: Recovering from sign information is useful if e.g. PlotMe conversion wasn't successful
|
||||||
|
* @return UUID
|
||||||
|
*/
|
||||||
public UUID guessOwner() {
|
public UUID guessOwner() {
|
||||||
if (this.hasOwner()) {
|
if (this.hasOwner()) {
|
||||||
return this.owner;
|
return this.owner;
|
||||||
@ -2138,6 +2182,9 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the SE road (only effects terrain)
|
||||||
|
*/
|
||||||
public void removeRoadSouthEast() {
|
public void removeRoadSouthEast() {
|
||||||
if ((this.area.TYPE != 0) && (this.area.TERRAIN > 1)) {
|
if ((this.area.TYPE != 0) && (this.area.TERRAIN > 1)) {
|
||||||
if (this.area.TERRAIN == 3) {
|
if (this.area.TERRAIN == 3) {
|
||||||
@ -2154,10 +2201,27 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the plot in a relative location<br>
|
||||||
|
* Note: May be null if the partial plot area does not include the relative location
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @return Plot
|
||||||
|
*/
|
||||||
public Plot getRelative(final int x, final int y) {
|
public Plot getRelative(final int x, final int y) {
|
||||||
return this.area.getPlotAbs(this.id.getRelative(x, y));
|
return this.area.getPlotAbs(this.id.getRelative(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the plot in a relative direction<br>
|
||||||
|
* 0 = north<br>
|
||||||
|
* 1 = east<br>
|
||||||
|
* 2 = south<br>
|
||||||
|
* 3 = west<br>
|
||||||
|
* Note: May be null if the partial plot area does not include the relative location
|
||||||
|
* @param direction
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public Plot getRelative(final int direction) {
|
public Plot getRelative(final int direction) {
|
||||||
return this.area.getPlotAbs(this.id.getRelative(direction));
|
return this.area.getPlotAbs(this.id.getRelative(direction));
|
||||||
}
|
}
|
||||||
@ -2428,6 +2492,10 @@ public class Plot {
|
|||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do the plot entry tasks for each player in the plot<br>
|
||||||
|
* - Usually called when the plot state changes (unclaimed/claimed/flag change etc)
|
||||||
|
*/
|
||||||
public void reEnter() {
|
public void reEnter() {
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
TaskManager.runTaskLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -2564,7 +2632,7 @@ public class Plot {
|
|||||||
*/
|
*/
|
||||||
public void mergePlot(Plot lesserPlot, final boolean removeRoads) {
|
public void mergePlot(Plot lesserPlot, final boolean removeRoads) {
|
||||||
Plot greaterPlot = this;
|
Plot greaterPlot = this;
|
||||||
if (lesserPlot.getId().x.equals(greaterPlot.getId().x)) {
|
if (lesserPlot.getId().x == greaterPlot.getId().x) {
|
||||||
if (lesserPlot.getId().y > greaterPlot.getId().y) {
|
if (lesserPlot.getId().y > greaterPlot.getId().y) {
|
||||||
final Plot tmp = lesserPlot;
|
final Plot tmp = lesserPlot;
|
||||||
lesserPlot = greaterPlot;
|
lesserPlot = greaterPlot;
|
||||||
|
@ -98,6 +98,12 @@ public abstract class PlotArea {
|
|||||||
this.worldhash = worldname.hashCode();
|
this.worldhash = worldname.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new PlotArea object with no functionality/information<br>
|
||||||
|
* - Mainly used during startup before worlds are created as a temporary object
|
||||||
|
* @param world
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static PlotArea createGeneric(String world) {
|
public static PlotArea createGeneric(String world) {
|
||||||
return new PlotArea(world, null, null, null, null) {
|
return new PlotArea(world, null, null, null, null) {
|
||||||
@Override
|
@Override
|
||||||
@ -108,8 +114,9 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the region for this PlotArea
|
* Returns the region for this PlotArea or a RegionWrapper encompassing the whole world if none exists
|
||||||
* @return
|
* @NotNull
|
||||||
|
* @return RegionWrapper
|
||||||
*/
|
*/
|
||||||
public RegionWrapper getRegion() {
|
public RegionWrapper getRegion() {
|
||||||
region = getRegionAbs();
|
region = getRegionAbs();
|
||||||
@ -119,6 +126,11 @@ public abstract class PlotArea {
|
|||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the region for this PlotArea
|
||||||
|
* @Nullable
|
||||||
|
* @return RegionWrapper or null if no applicable region
|
||||||
|
*/
|
||||||
public RegionWrapper getRegionAbs() {
|
public RegionWrapper getRegionAbs() {
|
||||||
if (region == null) {
|
if (region == null) {
|
||||||
if (min != null) {
|
if (min != null) {
|
||||||
@ -146,6 +158,11 @@ public abstract class PlotArea {
|
|||||||
return max == null ? new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE) : max;
|
return max == null ? new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE) : max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the implementation independent generator for this area
|
||||||
|
* @Nullable
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public IndependentPlotGenerator getGenerator() {
|
public IndependentPlotGenerator getGenerator() {
|
||||||
return generator;
|
return generator;
|
||||||
}
|
}
|
||||||
@ -169,6 +186,11 @@ public abstract class PlotArea {
|
|||||||
return clusters == null ? new HashSet<PlotCluster>() : clusters.getAll();
|
return clusters == null ? new HashSet<PlotCluster>() : clusters.getAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a PlotArea is compatible (move/copy etc)
|
||||||
|
* @param plotarea
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean isCompatible(PlotArea plotarea) {
|
public boolean isCompatible(PlotArea plotarea) {
|
||||||
final ConfigurationSection section = PS.get().config.getConfigurationSection("worlds");
|
final ConfigurationSection section = PS.get().config.getConfigurationSection("worlds");
|
||||||
for (final ConfigurationNode setting : plotarea.getSettingNodes()) {
|
for (final ConfigurationNode setting : plotarea.getSettingNodes()) {
|
||||||
@ -359,6 +381,11 @@ public abstract class PlotArea {
|
|||||||
*/
|
*/
|
||||||
public abstract ConfigurationNode[] getSettingNodes();
|
public abstract ConfigurationNode[] getSettingNodes();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Plot at a location
|
||||||
|
* @param loc
|
||||||
|
* @return Plot
|
||||||
|
*/
|
||||||
public Plot getPlotAbs(Location loc) {
|
public Plot getPlotAbs(Location loc) {
|
||||||
PlotId pid = manager.getPlotId(this, loc.getX(), loc.getY(), loc.getZ());
|
PlotId pid = manager.getPlotId(this, loc.getX(), loc.getY(), loc.getZ());
|
||||||
if (pid == null) {
|
if (pid == null) {
|
||||||
@ -367,6 +394,11 @@ public abstract class PlotArea {
|
|||||||
return getPlotAbs(pid);
|
return getPlotAbs(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the base plot at a location
|
||||||
|
* @param loc
|
||||||
|
* @return base Plot
|
||||||
|
*/
|
||||||
public Plot getPlot(Location loc) {
|
public Plot getPlot(Location loc) {
|
||||||
PlotId pid = manager.getPlotId(this, loc.getX(), loc.getY(), loc.getZ());
|
PlotId pid = manager.getPlotId(this, loc.getX(), loc.getY(), loc.getZ());
|
||||||
if (pid == null) {
|
if (pid == null) {
|
||||||
@ -375,6 +407,11 @@ public abstract class PlotArea {
|
|||||||
return getPlot(pid);
|
return getPlot(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the base owned plot at a location
|
||||||
|
* @param loc
|
||||||
|
* @return base Plot or null
|
||||||
|
*/
|
||||||
public Plot getOwnedPlot(Location loc) {
|
public Plot getOwnedPlot(Location loc) {
|
||||||
PlotId pid = manager.getPlotId(this, loc.getX(), loc.getY(), loc.getZ());
|
PlotId pid = manager.getPlotId(this, loc.getX(), loc.getY(), loc.getZ());
|
||||||
if (pid == null) {
|
if (pid == null) {
|
||||||
@ -384,6 +421,11 @@ public abstract class PlotArea {
|
|||||||
return plot == null ? null : plot.getBasePlot(false);
|
return plot == null ? null : plot.getBasePlot(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the owned plot at a location
|
||||||
|
* @param loc
|
||||||
|
* @return Plot or null
|
||||||
|
*/
|
||||||
public Plot getOwnedPlotAbs(Location loc) {
|
public Plot getOwnedPlotAbs(Location loc) {
|
||||||
PlotId pid = manager.getPlotId(this, loc.getX(), loc.getY(), loc.getZ());
|
PlotId pid = manager.getPlotId(this, loc.getX(), loc.getY(), loc.getZ());
|
||||||
if (pid == null) {
|
if (pid == null) {
|
||||||
@ -392,6 +434,11 @@ public abstract class PlotArea {
|
|||||||
return plots.get(pid);
|
return plots.get(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the owned Plot at a PlotId
|
||||||
|
* @param id
|
||||||
|
* @return Plot or null
|
||||||
|
*/
|
||||||
public Plot getOwnedPlotAbs(PlotId id) {
|
public Plot getOwnedPlotAbs(PlotId id) {
|
||||||
return plots.get(id);
|
return plots.get(id);
|
||||||
}
|
}
|
||||||
@ -688,7 +735,7 @@ public abstract class PlotArea {
|
|||||||
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++) {
|
||||||
final PlotId id = new PlotId(x, y);
|
final PlotId id = new PlotId(x, y);
|
||||||
final Plot plot = getPlot(id);
|
final Plot plot = getPlotAbs(id);
|
||||||
if (!plot.canClaim(player)) {
|
if (!plot.canClaim(player)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,11 @@ public class PlotId {
|
|||||||
/**
|
/**
|
||||||
* x value
|
* x value
|
||||||
*/
|
*/
|
||||||
public Integer x;
|
public int x;
|
||||||
/**
|
/**
|
||||||
* y value
|
* y value
|
||||||
*/
|
*/
|
||||||
public Integer y;
|
public int y;
|
||||||
private int hash;
|
private int hash;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,10 +68,25 @@ public class PlotId {
|
|||||||
return new PlotId(x, y);
|
return new PlotId(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the PlotId from the HashCode<br>
|
||||||
|
* Note: Only accurate for small x,z values (short)
|
||||||
|
* @param hash
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static PlotId unpair(int hash) {
|
public static PlotId unpair(int hash) {
|
||||||
return new PlotId(hash >> 16, hash & 0xFFFF);
|
return new PlotId(hash >> 16, hash & 0xFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the PlotId in a relative direction
|
||||||
|
* 0 = north<br>
|
||||||
|
* 1 = east<br>
|
||||||
|
* 2 = south<br>
|
||||||
|
* 3 = west<br>
|
||||||
|
* @param direction
|
||||||
|
* @return PlotId
|
||||||
|
*/
|
||||||
public PlotId getRelative(final int direction) {
|
public PlotId getRelative(final int direction) {
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -86,6 +101,12 @@ public class PlotId {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the PlotId in a relative location
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @return PlotId
|
||||||
|
*/
|
||||||
public PlotId getRelative(int x, int y) {
|
public PlotId getRelative(int x, int y) {
|
||||||
return new PlotId(this.x + x, this.y + y);
|
return new PlotId(this.x + x, this.y + y);
|
||||||
}
|
}
|
||||||
@ -98,18 +119,31 @@ public class PlotId {
|
|||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this.hashCode() != obj.hashCode()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (getClass() != obj.getClass()) {
|
if (getClass() != obj.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final PlotId other = (PlotId) obj;
|
final PlotId other = (PlotId) obj;
|
||||||
return ((x.equals(other.x)) && (y.equals(other.y)));
|
return x == other.x && y == other.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e.g.
|
||||||
|
* 5;-6
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return x + ";" + y;
|
return x + ";" + y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The PlotId object caches the hashcode for faster mapping/fetching/sorting<br>
|
||||||
|
* - Recalculation is required if the x/y values change
|
||||||
|
* TODO maybe make x/y values private and add this to the mutators
|
||||||
|
*/
|
||||||
public void recalculateHash() {
|
public void recalculateHash() {
|
||||||
hash = 0;
|
hash = 0;
|
||||||
hashCode();
|
hashCode();
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
package com.intellectualcrafters.plot.util;
|
package com.intellectualcrafters.plot.util;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
|
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The PlotChunk class is primarily used for world generation and mass block placement.<br>
|
||||||
|
* - With mass block placement, it is associated with a queue<br>
|
||||||
|
* - World Generation has no queue, so don't use those methods in that case
|
||||||
|
* @param <T>
|
||||||
|
*/
|
||||||
public abstract class PlotChunk<T> implements Cloneable {
|
public abstract class PlotChunk<T> implements Cloneable {
|
||||||
private ChunkWrapper chunk;
|
private ChunkWrapper chunk;
|
||||||
private T objChunk;
|
private T objChunk;
|
||||||
@ -31,6 +38,10 @@ public abstract class PlotChunk<T> implements Cloneable {
|
|||||||
return chunk.z;
|
return chunk.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds this PlotChunk to the SetQueue for later block placement<br>
|
||||||
|
* - Will cause issues if not the right type for the implementation
|
||||||
|
*/
|
||||||
public void addToQueue() {
|
public void addToQueue() {
|
||||||
if (chunk == null) {
|
if (chunk == null) {
|
||||||
throw new IllegalArgumentException("Chunk location cannot be null!");
|
throw new IllegalArgumentException("Chunk location cannot be null!");
|
||||||
@ -38,36 +49,142 @@ public abstract class PlotChunk<T> implements Cloneable {
|
|||||||
((PlotQueue<T>) SetQueue.IMP.queue).setChunk(this);
|
((PlotQueue<T>) SetQueue.IMP.queue).setChunk(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force the queue to finish processing this chunk
|
||||||
|
* @param fixLighting
|
||||||
|
*/
|
||||||
public void flush(boolean fixLighting) {
|
public void flush(boolean fixLighting) {
|
||||||
((PlotQueue<T>) SetQueue.IMP.queue).next(getChunkWrapper(), fixLighting);
|
((PlotQueue<T>) SetQueue.IMP.queue).next(getChunkWrapper(), fixLighting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force the queue to fix lighting for this chunk
|
||||||
|
*/
|
||||||
public void fixLighting() {
|
public void fixLighting() {
|
||||||
((PlotQueue<T>) SetQueue.IMP.queue).fixLighting(this, true);
|
((PlotQueue<T>) SetQueue.IMP.queue).fixLighting(this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill this chunk with a block
|
||||||
|
* @param id
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
public void fill(int id, byte data) {
|
public void fill(int id, byte data) {
|
||||||
for (int x = 0; x < 16; x++) {
|
fillCuboid(0, 15, 0, 255, 0, 15, id, data);
|
||||||
for (int y = 0; y < 256; y++) {
|
}
|
||||||
for (int z = 0; z < 16; z++) {
|
|
||||||
|
/**
|
||||||
|
* Fill this chunk with blocks (random)
|
||||||
|
* @param blocks
|
||||||
|
*/
|
||||||
|
public void fill(PlotBlock[] blocks) {
|
||||||
|
fillCuboid(0, 15, 0, 255, 0, 15, blocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill a cuboid in this chunk with a block
|
||||||
|
* @param x1
|
||||||
|
* @param x2
|
||||||
|
* @param y1
|
||||||
|
* @param y2
|
||||||
|
* @param z1
|
||||||
|
* @param z2
|
||||||
|
* @param id
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
public void fillCuboid(int x1, int x2, int y1, int y2, int z1, int z2, int id, byte data) {
|
||||||
|
for (int x = x1; x <= x2; x++) {
|
||||||
|
for (int y = y1; y <= y2; y++) {
|
||||||
|
for (int z = z1; z <= z2; z++) {
|
||||||
setBlock(x, y, z, id, data);
|
setBlock(x, y, z, id, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill a cuboid in this chunk with blocks
|
||||||
|
* @param x1
|
||||||
|
* @param x2
|
||||||
|
* @param y1
|
||||||
|
* @param y2
|
||||||
|
* @param z1
|
||||||
|
* @param z2
|
||||||
|
* @param blocks
|
||||||
|
*/
|
||||||
|
public void fillCuboid(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks) {
|
||||||
|
if (blocks.length == 1) {
|
||||||
|
fillCuboid(x1, x2, y1, y2, z1, z2, blocks[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (chunk != null) {
|
||||||
|
PseudoRandom.random.state = (chunk.x << 16) | (chunk.z & 0xFFFF);
|
||||||
|
}
|
||||||
|
for (int x = x1; x <= x2; x++) {
|
||||||
|
for (int y = y1; y <= y2; y++) {
|
||||||
|
for (int z = z1; z <= z2; z++) {
|
||||||
|
setBlock(x, y, z, blocks[PseudoRandom.random.random(blocks.length)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill a cuboid in this chunk with a block
|
||||||
|
* @param x1
|
||||||
|
* @param x2
|
||||||
|
* @param y1
|
||||||
|
* @param y2
|
||||||
|
* @param z1
|
||||||
|
* @param z2
|
||||||
|
* @param block
|
||||||
|
*/
|
||||||
|
public void fillCuboid(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock block) {
|
||||||
|
fillCuboid(x1, x2, y1, y2, z1, z2, block.id, block.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the implementation specific chunk
|
||||||
|
* @Nullable If no location is tied to this container
|
||||||
|
* @return Chunk
|
||||||
|
*/
|
||||||
public T getChunk() {
|
public T getChunk() {
|
||||||
return objChunk != null ? objChunk : getChunkAbs();
|
return objChunk != null ? objChunk : getChunkAbs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the implementation specific chunk (no caching)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public abstract T getChunkAbs();
|
public abstract T getChunkAbs();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a block in this container
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @param z
|
||||||
|
* @param id
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
public abstract void setBlock(final int x, final int y, final int z, final int id, final byte data);
|
public abstract void setBlock(final int x, final int y, final int z, final int id, final byte data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a block in this container
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @param z
|
||||||
|
* @param block
|
||||||
|
*/
|
||||||
public void setBlock(int x, int y, int z, PlotBlock block) {
|
public void setBlock(int x, int y, int z, PlotBlock block) {
|
||||||
setBlock(x, y, z, block.id, block.data);
|
setBlock(x, y, z, block.id, block.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a biome in this container
|
||||||
|
* @param x
|
||||||
|
* @param z
|
||||||
|
* @param biome
|
||||||
|
*/
|
||||||
public abstract void setBiome(int x, int z, int biome);
|
public abstract void setBiome(int x, int z, int biome);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -88,8 +205,18 @@ public abstract class PlotChunk<T> implements Cloneable {
|
|||||||
return getChunkWrapper().toString();
|
return getChunkWrapper().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to clone this PlotChunk object<br>
|
||||||
|
* - Depending on the implementation, this may not work
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public abstract PlotChunk clone();
|
public abstract PlotChunk clone();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt a shallow clone i.e. block mappings share the same reference<br>
|
||||||
|
* - Depending on the implementation, this may not work
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public abstract PlotChunk shallowClone();
|
public abstract PlotChunk shallowClone();
|
||||||
}
|
}
|
||||||
|
@ -1,64 +1,64 @@
|
|||||||
package com.intellectualcrafters.plot;
|
//package com.intellectualcrafters.plot;
|
||||||
|
//
|
||||||
import static com.intellectualcrafters.plot.PS.log;
|
//import static com.intellectualcrafters.plot.PS.log;
|
||||||
|
//
|
||||||
import com.google.gson.Gson;
|
//import com.google.gson.Gson;
|
||||||
import com.google.gson.annotations.SerializedName;
|
//import com.google.gson.annotations.SerializedName;
|
||||||
|
//
|
||||||
import java.io.BufferedReader;
|
//import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
//import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
//import java.net.URL;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
|
//
|
||||||
public class UpdaterTest {
|
//public class UpdaterTest {
|
||||||
|
//
|
||||||
@org.junit.Test
|
// @org.junit.Test
|
||||||
public void getUpdate() throws Exception {
|
// public void getUpdate() throws Exception {
|
||||||
String str = null;
|
// String str = null;
|
||||||
BufferedReader reader = null;
|
// BufferedReader reader = null;
|
||||||
try {
|
// try {
|
||||||
URL url = new URL("https://api.github.com/repos/IntellectualSites/PlotSquared/releases/latest");
|
// URL url = new URL("https://api.github.com/repos/IntellectualSites/PlotSquared/releases/latest");
|
||||||
reader = new BufferedReader(new InputStreamReader(url.openStream()));
|
// reader = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||||
StringBuilder buffer = new StringBuilder();
|
// StringBuilder buffer = new StringBuilder();
|
||||||
int read;
|
// int read;
|
||||||
char[] chars = new char[1024];
|
// char[] chars = new char[1024];
|
||||||
while ((read = reader.read(chars)) != -1) {
|
// while ((read = reader.read(chars)) != -1) {
|
||||||
buffer.append(chars, 0, read);
|
// buffer.append(chars, 0, read);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
str = buffer.toString();
|
// str = buffer.toString();
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
log("&dCould not check for updates (0)");
|
// log("&dCould not check for updates (0)");
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
} finally {
|
// } finally {
|
||||||
try {
|
// try {
|
||||||
if (reader != null) {
|
// if (reader != null) {
|
||||||
reader.close();
|
// reader.close();
|
||||||
}
|
// }
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (str == null) {
|
// if (str == null) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
Gson gson = new Gson();
|
// Gson gson = new Gson();
|
||||||
Release release = gson.fromJson(str, Release.class);
|
// Release release = gson.fromJson(str, Release.class);
|
||||||
System.out.println(release.name);
|
// System.out.println(release.name);
|
||||||
for (Release.Assets asset : release.assets) {
|
// for (Release.Assets asset : release.assets) {
|
||||||
System.out.println(asset.name);
|
// System.out.println(asset.name);
|
||||||
System.out.println(asset.downloadUrl);
|
// System.out.println(asset.downloadUrl);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
private static class Release {
|
// private static class Release {
|
||||||
String name;
|
// String name;
|
||||||
List<Assets> assets;
|
// List<Assets> assets;
|
||||||
private static class Assets {
|
// private static class Assets {
|
||||||
String name;
|
// String name;
|
||||||
@SerializedName("browser_download_url") String downloadUrl;
|
// @SerializedName("browser_download_url") String downloadUrl;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
@ -44,13 +44,16 @@ import org.spongepowered.api.world.gen.WorldGenerator;
|
|||||||
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
|
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by robin on 01/11/2014
|
* Created by robin on 01/11/2014
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Plugin(id = "PlotSquared", name = "PlotSquared", version = "3.3.1", dependencies = "before:WorldEdit")
|
@Plugin(id = "com.plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.", url = "https://github.com/IntellectualSites/PlotSquared", version = "3.3.1")
|
||||||
public class SpongeMain implements IPlotMain {
|
public class SpongeMain implements IPlotMain {
|
||||||
public static SpongeMain THIS;
|
public static SpongeMain THIS;
|
||||||
|
|
||||||
@ -86,33 +89,6 @@ public class SpongeMain implements IPlotMain {
|
|||||||
return THIS;
|
return THIS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
public String getId() {
|
|
||||||
return "PlotSquared";
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
public Optional<Object> getInstance() {
|
|
||||||
return Optional.<Object> of(THIS);
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
public String getName() {
|
|
||||||
return "PlotSquared";
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
public String getVersion() {
|
|
||||||
final int[] version = PS.get().getVersion();
|
|
||||||
String result = "";
|
|
||||||
String prefix = "";
|
|
||||||
for (final int i : version) {
|
|
||||||
result += prefix + i;
|
|
||||||
prefix = ".";
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void init(final GameInitializationEvent event) {
|
public void init(final GameInitializationEvent event) {
|
||||||
log("PlotSquared: Game init");
|
log("PlotSquared: Game init");
|
||||||
@ -163,8 +139,8 @@ public class SpongeMain implements IPlotMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getPluginVersion() {
|
public int[] getPluginVersion() {
|
||||||
final PluginContainer plugin = game.getPluginManager().getPlugin("PlotSquared").get();
|
PluginContainer plugin = game.getPluginManager().fromInstance(this).get();
|
||||||
final String version = plugin.getVersion();
|
String version = plugin.getVersion().get();
|
||||||
log("Checking plugin version: PlotSquared: ");
|
log("Checking plugin version: PlotSquared: ");
|
||||||
final String[] split = version.split("\\.");
|
final String[] split = version.split("\\.");
|
||||||
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 };
|
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 };
|
||||||
|
@ -120,7 +120,6 @@ public class MainListener {
|
|||||||
final String sender = player.getName();
|
final String sender = player.getName();
|
||||||
final PlotId id = plot.getId();
|
final PlotId id = plot.getId();
|
||||||
final String newMessage = StringMan.replaceAll(C.PLOT_CHAT_FORMAT.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
|
final String newMessage = StringMan.replaceAll(C.PLOT_CHAT_FORMAT.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
|
||||||
final Text forcedMessage = event.getMessage();
|
|
||||||
// String forcedMessage = StringMan.replaceAll(C.PLOT_CHAT_FORCED.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
|
// String forcedMessage = StringMan.replaceAll(C.PLOT_CHAT_FORCED.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
|
||||||
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
||||||
PlotPlayer user = entry.getValue();
|
PlotPlayer user = entry.getValue();
|
||||||
@ -128,7 +127,7 @@ public class MainListener {
|
|||||||
if (plot.equals(user.getLocation().getPlot())) {
|
if (plot.equals(user.getLocation().getPlot())) {
|
||||||
toSend = newMessage;
|
toSend = newMessage;
|
||||||
} else if (Permissions.hasPermission(user, C.PERMISSION_COMMANDS_CHAT)) {
|
} else if (Permissions.hasPermission(user, C.PERMISSION_COMMANDS_CHAT)) {
|
||||||
((SpongePlayer) user).player.sendMessage(forcedMessage);
|
((SpongePlayer) user).player.sendMessage(message);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
@ -146,7 +145,7 @@ public class MainListener {
|
|||||||
}
|
}
|
||||||
((SpongePlayer) user).player.sendMessage(Text.join(components));
|
((SpongePlayer) user).player.sendMessage(Text.join(components));
|
||||||
}
|
}
|
||||||
event.clearMessage();
|
event.setMessage(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
|
@ -131,7 +131,7 @@ public class SpongePlayer extends PlotPlayer {
|
|||||||
@Override
|
@Override
|
||||||
public void setCompassTarget(final Location loc) {
|
public void setCompassTarget(final Location loc) {
|
||||||
final TargetedLocationData target = player.getOrCreate(TargetedLocationData.class).get();
|
final TargetedLocationData target = player.getOrCreate(TargetedLocationData.class).get();
|
||||||
target.set(Keys.TARGETED_LOCATION, SpongeUtil.getLocation(loc));
|
target.set(Keys.TARGETED_LOCATION, SpongeUtil.getLocation(loc).getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
package com.plotsquared.sponge.util;
|
package com.plotsquared.sponge.util;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import org.spongepowered.api.Sponge;
|
|
||||||
import org.spongepowered.api.event.Listener;
|
|
||||||
import org.spongepowered.api.event.cause.Cause;
|
|
||||||
import org.spongepowered.api.event.service.ChangeServiceProviderEvent;
|
|
||||||
import org.spongepowered.api.service.economy.EconomyService;
|
|
||||||
import org.spongepowered.api.service.economy.account.UniqueAccount;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.EconHandler;
|
import com.intellectualcrafters.plot.util.EconHandler;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.plotsquared.sponge.object.SpongePlayer;
|
import com.plotsquared.sponge.object.SpongePlayer;
|
||||||
|
import org.spongepowered.api.Sponge;
|
||||||
|
import org.spongepowered.api.event.Listener;
|
||||||
|
import org.spongepowered.api.event.service.ChangeServiceProviderEvent;
|
||||||
|
import org.spongepowered.api.service.economy.EconomyService;
|
||||||
|
import org.spongepowered.api.service.economy.account.UniqueAccount;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class SpongeEconHandler extends EconHandler {
|
public class SpongeEconHandler extends EconHandler {
|
||||||
private EconomyService econ;
|
private EconomyService econ;
|
||||||
@ -35,11 +33,11 @@ public class SpongeEconHandler extends EconHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void withdrawMoney(PlotPlayer player, double amount) {
|
public void withdrawMoney(PlotPlayer player, double amount) {
|
||||||
if (econ != null) {
|
if (econ != null) {
|
||||||
Optional<UniqueAccount> accOpt = econ.getAccount(player.getUUID());
|
Optional<UniqueAccount> accOpt = econ.getOrCreateAccount(player.getUUID());
|
||||||
if (accOpt.isPresent()) {
|
if (accOpt.isPresent()) {
|
||||||
UniqueAccount acc = accOpt.get();
|
UniqueAccount acc = accOpt.get();
|
||||||
|
|
||||||
acc.withdraw(econ.getDefaultCurrency(), new BigDecimal(amount), Cause.of("PlotSquared"));
|
acc.withdraw(econ.getDefaultCurrency(), new BigDecimal(amount), SpongeUtil.CAUSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,10 +45,10 @@ public class SpongeEconHandler extends EconHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void depositMoney(PlotPlayer player, double amount) {
|
public void depositMoney(PlotPlayer player, double amount) {
|
||||||
if (econ != null) {
|
if (econ != null) {
|
||||||
Optional<UniqueAccount> accOpt = econ.getAccount(player.getUUID());
|
Optional<UniqueAccount> accOpt = econ.getOrCreateAccount(player.getUUID());
|
||||||
if (accOpt.isPresent()) {
|
if (accOpt.isPresent()) {
|
||||||
UniqueAccount acc = accOpt.get();
|
UniqueAccount acc = accOpt.get();
|
||||||
acc.deposit(econ.getDefaultCurrency(), new BigDecimal(amount), Cause.of("PlotSquared"));
|
acc.deposit(econ.getDefaultCurrency(), new BigDecimal(amount), SpongeUtil.CAUSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,10 +56,10 @@ public class SpongeEconHandler extends EconHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void depositMoney(OfflinePlotPlayer player, double amount) {
|
public void depositMoney(OfflinePlotPlayer player, double amount) {
|
||||||
if (econ != null) {
|
if (econ != null) {
|
||||||
Optional<UniqueAccount> accOpt = econ.getAccount(player.getUUID());
|
Optional<UniqueAccount> accOpt = econ.getOrCreateAccount(player.getUUID());
|
||||||
if (accOpt.isPresent()) {
|
if (accOpt.isPresent()) {
|
||||||
UniqueAccount acc = accOpt.get();
|
UniqueAccount acc = accOpt.get();
|
||||||
acc.deposit(econ.getDefaultCurrency(), new BigDecimal(amount), Cause.of("PlotSquared"));
|
acc.deposit(econ.getDefaultCurrency(), new BigDecimal(amount), SpongeUtil.CAUSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,7 +83,7 @@ public class SpongeEconHandler extends EconHandler {
|
|||||||
@Override
|
@Override
|
||||||
public double getBalance(PlotPlayer player) {
|
public double getBalance(PlotPlayer player) {
|
||||||
if (econ != null) {
|
if (econ != null) {
|
||||||
Optional<UniqueAccount> accOpt = econ.getAccount(player.getUUID());
|
Optional<UniqueAccount> accOpt = econ.getOrCreateAccount(player.getUUID());
|
||||||
if (accOpt.isPresent()) {
|
if (accOpt.isPresent()) {
|
||||||
UniqueAccount acc = accOpt.get();
|
UniqueAccount acc = accOpt.get();
|
||||||
BigDecimal balance = acc.getBalance(econ.getDefaultCurrency());
|
BigDecimal balance = acc.getBalance(econ.getDefaultCurrency());
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
package com.plotsquared.sponge.util;
|
package com.plotsquared.sponge.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.intellectualcrafters.plot.object.PlotInventory;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotItemStack;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.util.InventoryUtil;
|
||||||
|
import com.plotsquared.sponge.SpongeMain;
|
||||||
|
import com.plotsquared.sponge.object.SpongePlayer;
|
||||||
import org.spongepowered.api.entity.living.player.Player;
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
import org.spongepowered.api.item.ItemType;
|
import org.spongepowered.api.item.ItemType;
|
||||||
import org.spongepowered.api.item.ItemTypes;
|
import org.spongepowered.api.item.ItemTypes;
|
||||||
@ -11,12 +15,7 @@ import org.spongepowered.api.item.inventory.custom.CustomInventory;
|
|||||||
import org.spongepowered.api.item.inventory.property.SlotIndex;
|
import org.spongepowered.api.item.inventory.property.SlotIndex;
|
||||||
import org.spongepowered.api.item.inventory.type.CarriedInventory;
|
import org.spongepowered.api.item.inventory.type.CarriedInventory;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.PlotInventory;
|
import java.util.ArrayList;
|
||||||
import com.intellectualcrafters.plot.object.PlotItemStack;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
|
||||||
import com.intellectualcrafters.plot.util.InventoryUtil;
|
|
||||||
import com.plotsquared.sponge.SpongeMain;
|
|
||||||
import com.plotsquared.sponge.object.SpongePlayer;
|
|
||||||
|
|
||||||
public class SpongeInventoryUtil extends InventoryUtil {
|
public class SpongeInventoryUtil extends InventoryUtil {
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ public class SpongeInventoryUtil extends InventoryUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
inv.player.setMeta("inventory", inv);
|
inv.player.setMeta("inventory", inv);
|
||||||
player.openInventory(inventory);
|
player.openInventory(inventory, SpongeUtil.CAUSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItem(final PlotItemStack item) {
|
public ItemStack getItem(final PlotItemStack item) {
|
||||||
@ -56,7 +55,7 @@ public class SpongeInventoryUtil extends InventoryUtil {
|
|||||||
}
|
}
|
||||||
inv.player.deleteMeta("inventory");
|
inv.player.deleteMeta("inventory");
|
||||||
final SpongePlayer sp = (SpongePlayer) inv.player;
|
final SpongePlayer sp = (SpongePlayer) inv.player;
|
||||||
sp.player.closeInventory();
|
sp.player.closeInventory(SpongeUtil.CAUSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,6 +28,8 @@ package com.plotsquared.sponge.util;
|
|||||||
* either expressed or implied, of anybody else.
|
* either expressed or implied, of anybody else.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.intellectualcrafters.plot.PS;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -42,18 +44,13 @@ import java.net.URLEncoder;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
|
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
|
||||||
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
|
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
|
||||||
import ninja.leaping.configurate.loader.ConfigurationLoader;
|
import ninja.leaping.configurate.loader.ConfigurationLoader;
|
||||||
|
|
||||||
import org.spongepowered.api.Game;
|
import org.spongepowered.api.Game;
|
||||||
import org.spongepowered.api.plugin.PluginContainer;
|
import org.spongepowered.api.plugin.PluginContainer;
|
||||||
import org.spongepowered.api.scheduler.Task;
|
import org.spongepowered.api.scheduler.Task;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
|
||||||
|
|
||||||
public class SpongeMetrics {
|
public class SpongeMetrics {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -404,7 +401,7 @@ public class SpongeMetrics {
|
|||||||
// Server software specific section
|
// Server software specific section
|
||||||
final String pluginName = plugin.getName();
|
final String pluginName = plugin.getName();
|
||||||
final boolean onlineMode = game.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
final boolean onlineMode = game.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
||||||
final String pluginVersion = plugin.getVersion();
|
final String pluginVersion = plugin.getVersion().get();
|
||||||
// TODO no visible way to get MC version at the moment
|
// TODO no visible way to get MC version at the moment
|
||||||
// TODO added by game.getPlatform().getMinecraftVersion() -- impl in 2.1
|
// TODO added by game.getPlatform().getMinecraftVersion() -- impl in 2.1
|
||||||
final String serverVersion = String.format("%s %s", "Sponge", game.getPlatform().getMinecraftVersion());
|
final String serverVersion = String.format("%s %s", "Sponge", game.getPlatform().getMinecraftVersion());
|
||||||
|
@ -32,6 +32,7 @@ import org.spongepowered.api.data.value.mutable.ListValue;
|
|||||||
import org.spongepowered.api.entity.Entity;
|
import org.spongepowered.api.entity.Entity;
|
||||||
import org.spongepowered.api.entity.living.player.Player;
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
import org.spongepowered.api.event.cause.Cause;
|
import org.spongepowered.api.event.cause.Cause;
|
||||||
|
import org.spongepowered.api.event.cause.NamedCause;
|
||||||
import org.spongepowered.api.text.Text;
|
import org.spongepowered.api.text.Text;
|
||||||
import org.spongepowered.api.text.serializer.TextSerializers;
|
import org.spongepowered.api.text.serializer.TextSerializers;
|
||||||
import org.spongepowered.api.text.translation.Translation;
|
import org.spongepowered.api.text.translation.Translation;
|
||||||
@ -50,6 +51,8 @@ import java.util.Optional;
|
|||||||
|
|
||||||
public class SpongeUtil extends WorldUtil {
|
public class SpongeUtil extends WorldUtil {
|
||||||
|
|
||||||
|
public static Cause CAUSE = Cause.of(NamedCause.source("PlotSquared"));
|
||||||
|
|
||||||
public static Location getLocation(final Entity player) {
|
public static Location getLocation(final Entity player) {
|
||||||
final String world = player.getWorld().getName();
|
final String world = player.getWorld().getName();
|
||||||
final org.spongepowered.api.world.Location loc = player.getLocation();
|
final org.spongepowered.api.world.Location loc = player.getLocation();
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
package com.plotsquared.sponge.uuid;
|
package com.plotsquared.sponge.uuid;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.spongepowered.api.entity.living.player.Player;
|
|
||||||
import org.spongepowered.api.profile.GameProfile;
|
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||||
import com.plotsquared.sponge.SpongeMain;
|
import com.plotsquared.sponge.SpongeMain;
|
||||||
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
|
import org.spongepowered.api.profile.GameProfile;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
||||||
|
|
||||||
@ -36,7 +35,7 @@ public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
|||||||
try {
|
try {
|
||||||
final GameProfile profile = SpongeMain.THIS.getResolver().get(uuid).get();
|
final GameProfile profile = SpongeMain.THIS.getResolver().get(uuid).get();
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
name = profile.getName();
|
name = profile.getName().orElse(null);
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -44,9 +43,12 @@ public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
|||||||
}
|
}
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
for (final GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) {
|
for (final GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) {
|
||||||
if (getUUID(profile.getName()).equals(uuid)) {
|
String tmp = profile.getName().orElse(null);
|
||||||
name = profile.getName();
|
if (tmp != null) {
|
||||||
break;
|
if (getUUID(name).equals(uuid)) {
|
||||||
|
name = tmp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.plotsquared.sponge.uuid;
|
package com.plotsquared.sponge.uuid;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
@ -9,6 +7,8 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
|||||||
import com.plotsquared.sponge.SpongeMain;
|
import com.plotsquared.sponge.SpongeMain;
|
||||||
import com.plotsquared.sponge.object.SpongePlayer;
|
import com.plotsquared.sponge.object.SpongePlayer;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class SpongeOnlineUUIDWrapper extends UUIDWrapper {
|
public class SpongeOnlineUUIDWrapper extends UUIDWrapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -35,7 +35,7 @@ public class SpongeOnlineUUIDWrapper extends UUIDWrapper {
|
|||||||
public OfflinePlotPlayer getOfflinePlayer(final UUID uuid) {
|
public OfflinePlotPlayer getOfflinePlayer(final UUID uuid) {
|
||||||
String name;
|
String name;
|
||||||
try {
|
try {
|
||||||
name = SpongeMain.THIS.getResolver().get(uuid, true).get().getName();
|
name = SpongeMain.THIS.getResolver().get(uuid, true).get().getName().orElse(null);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
name = null;
|
name = null;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package com.plotsquared.sponge.uuid;
|
package com.plotsquared.sponge.uuid;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.spongepowered.api.profile.GameProfile;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||||
@ -11,6 +7,9 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
|||||||
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
||||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||||
import com.plotsquared.sponge.SpongeMain;
|
import com.plotsquared.sponge.SpongeMain;
|
||||||
|
import org.spongepowered.api.profile.GameProfile;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class SpongeUUIDHandler extends UUIDHandlerImplementation {
|
public class SpongeUUIDHandler extends UUIDHandlerImplementation {
|
||||||
|
|
||||||
@ -29,7 +28,10 @@ public class SpongeUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
public boolean cache(final Runnable whenDone) {
|
public boolean cache(final Runnable whenDone) {
|
||||||
add(new StringWrapper("*"), DBFunc.everyone);
|
add(new StringWrapper("*"), DBFunc.everyone);
|
||||||
for (final GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) {
|
for (final GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) {
|
||||||
add(new StringWrapper(profile.getName()), profile.getUniqueId());
|
String name = profile.getName().orElse(null);
|
||||||
|
if (name != null) {
|
||||||
|
add(new StringWrapper(name), profile.getUniqueId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user