mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 10:14:42 +02:00
Fix merging
This commit is contained in:
@ -54,8 +54,8 @@ import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
@ -132,8 +132,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
// Check for updates
|
||||
if (PlotSquared.get().getUpdateUtility() != null) {
|
||||
final UpdateUtility updateUtility = PlotSquared.get().getUpdateUtility();
|
||||
updateUtility
|
||||
.checkForUpdate(this.getPluginVersionString(), ((updateDescription, throwable) -> {
|
||||
updateUtility.checkForUpdate(PlotSquared.get().getVersion().versionString(),
|
||||
((updateDescription, throwable) -> {
|
||||
Bukkit.getScheduler().runTask(BukkitMain.this, () -> {
|
||||
getLogger().info("-------- PlotSquared Update Check --------");
|
||||
if (throwable != null) {
|
||||
@ -289,9 +289,11 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
@Override public void registerCommands() {
|
||||
final BukkitCommand bukkitCommand = new BukkitCommand();
|
||||
final PluginCommand plotCommand = getCommand("plots");
|
||||
plotCommand.setExecutor(bukkitCommand);
|
||||
plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot"));
|
||||
plotCommand.setTabCompleter(bukkitCommand);
|
||||
if (plotCommand != null) {
|
||||
plotCommand.setExecutor(bukkitCommand);
|
||||
plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot"));
|
||||
plotCommand.setTabCompleter(bukkitCommand);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public File getDirectory() {
|
||||
@ -598,14 +600,15 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
}
|
||||
|
||||
@Override public QueueProvider initBlockQueue() {
|
||||
try {
|
||||
new SendChunk();
|
||||
MainUtil.canSendChunk = true;
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) {
|
||||
PlotSquared.debug(
|
||||
SendChunk.class + " does not support " + StringMan.getString(getServerVersion()));
|
||||
MainUtil.canSendChunk = false;
|
||||
}
|
||||
//TODO Figure out why this code is still here yet isn't being called anywhere.
|
||||
// try {
|
||||
// new SendChunk();
|
||||
// MainUtil.canSendChunk = true;
|
||||
// } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) {
|
||||
// PlotSquared.debug(
|
||||
// SendChunk.class + " does not support " + StringMan.getString(getServerVersion()));
|
||||
// MainUtil.canSendChunk = false;
|
||||
// }
|
||||
return QueueProvider.of(BukkitLocalQueue.class, BukkitLocalQueue.class);
|
||||
}
|
||||
|
||||
@ -800,4 +803,5 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
@Override public LegacyMappings getLegacyMappings() {
|
||||
return this.legacyMappings;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ import lombok.Setter;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -30,8 +30,8 @@ public final class PlotAutoMergeEvent extends PlotEvent implements Cancellable {
|
||||
* @param plot Plot that was merged
|
||||
* @param plots A list of plots involved in the event
|
||||
*/
|
||||
public PlotAutoMergeEvent(@Nonnull final World world, @Nonnull final Plot plot,
|
||||
@Nonnull final List<PlotId> plots) {
|
||||
public PlotAutoMergeEvent(@NotNull final World world, @NotNull final Plot plot,
|
||||
@NotNull final List<PlotId> plots) {
|
||||
super(plot);
|
||||
this.world = world;
|
||||
this.plots = plots;
|
||||
|
@ -6,8 +6,7 @@ import lombok.Setter;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Event called when several plots are merged
|
||||
@ -29,8 +28,8 @@ public final class PlotMergeEvent extends PlotEvent implements Cancellable {
|
||||
* @param dir The direction of the merge
|
||||
* @param max Max merge size
|
||||
*/
|
||||
public PlotMergeEvent(@Nonnull final World world, @Nonnull final Plot plot,
|
||||
@Nonnull final int dir, @Nonnull final int max) {
|
||||
public PlotMergeEvent(@NotNull final World world, @NotNull final Plot plot,
|
||||
@NotNull final int dir, @NotNull final int max) {
|
||||
super(plot);
|
||||
this.world = world;
|
||||
this.dir = dir;
|
||||
|
@ -8,8 +8,8 @@ import org.bukkit.World;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -31,8 +31,8 @@ public final class PlotUnlinkEvent extends Event implements Cancellable {
|
||||
* @param world World in which the event occurred
|
||||
* @param plots Plots that are involved in the event
|
||||
*/
|
||||
public PlotUnlinkEvent(@Nonnull final World world, @Nonnull final PlotArea area,
|
||||
@Nonnull final List<PlotId> plots) {
|
||||
public PlotUnlinkEvent(@NotNull final World world, @NotNull final PlotArea area,
|
||||
@NotNull final List<PlotId> plots) {
|
||||
this.plots = plots;
|
||||
this.world = world;
|
||||
this.area = area;
|
||||
|
@ -85,10 +85,10 @@ import java.util.regex.Pattern;
|
||||
int distance = Bukkit.getViewDistance() * 16;
|
||||
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
||||
PlotPlayer player = entry.getValue();
|
||||
Location loc = player.getLocation();
|
||||
if (loc.getWorld().equals(world)) {
|
||||
if (16 * Math.abs(loc.getX() - x) / 16 > distance
|
||||
|| 16 * Math.abs(loc.getZ() - z) / 16 > distance) {
|
||||
Location location = player.getLocation();
|
||||
if (location.getWorld().equals(world)) {
|
||||
if (16 * Math.abs(location.getX() - x) / 16 > distance
|
||||
|| 16 * Math.abs(location.getZ() - z) / 16 > distance) {
|
||||
continue;
|
||||
}
|
||||
((BukkitPlayer) player).player.sendBlockChange(bloc, data);
|
||||
@ -314,12 +314,12 @@ import java.util.regex.Pattern;
|
||||
case POWERED_RAIL:
|
||||
return;
|
||||
default:*/
|
||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
PlotArea area = loc.getPlotArea();
|
||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = loc.getOwnedPlot();
|
||||
Plot plot = location.getOwnedPlot();
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
@ -369,12 +369,11 @@ import java.util.regex.Pattern;
|
||||
switch (event.getChangedType()) {
|
||||
case COMPARATOR: {
|
||||
Block block = event.getBlock();
|
||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
PlotArea area = loc.getPlotArea();
|
||||
if (area == null) {
|
||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||
if (location.isPlotArea()) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlotAbs(loc);
|
||||
Plot plot = location.getOwnedPlotAbs();
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
@ -391,12 +390,12 @@ import java.util.regex.Pattern;
|
||||
case TURTLE_HELMET:
|
||||
case TURTLE_SPAWN_EGG: {
|
||||
Block block = event.getBlock();
|
||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
PlotArea area = loc.getPlotArea();
|
||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlotAbs(loc);
|
||||
Plot plot = area.getOwnedPlotAbs(location);
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
@ -413,30 +412,30 @@ import java.util.regex.Pattern;
|
||||
case STICKY_PISTON:
|
||||
org.bukkit.block.data.Directional piston =
|
||||
(org.bukkit.block.data.Directional) block.getBlockData();
|
||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
PlotArea area = loc.getPlotArea();
|
||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlotAbs(loc);
|
||||
Plot plot = area.getOwnedPlotAbs(location);
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
switch (piston.getFacing()) {
|
||||
case EAST:
|
||||
loc.setX(loc.getX() + 1);
|
||||
location.setX(location.getX() + 1);
|
||||
break;
|
||||
case SOUTH:
|
||||
loc.setX(loc.getX() - 1);
|
||||
location.setX(location.getX() - 1);
|
||||
break;
|
||||
case WEST:
|
||||
loc.setZ(loc.getZ() + 1);
|
||||
location.setZ(location.getZ() + 1);
|
||||
break;
|
||||
case NORTH:
|
||||
loc.setZ(loc.getZ() - 1);
|
||||
location.setZ(location.getZ() - 1);
|
||||
break;
|
||||
}
|
||||
Plot newPlot = area.getOwnedPlotAbs(loc);
|
||||
Plot newPlot = area.getOwnedPlotAbs(location);
|
||||
if (!plot.equals(newPlot)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -470,15 +469,15 @@ import java.util.regex.Pattern;
|
||||
|
||||
@EventHandler public boolean onProjectileHit(ProjectileHitEvent event) {
|
||||
Projectile entity = event.getEntity();
|
||||
Location loc = BukkitUtil.getLocation(entity);
|
||||
if (!PlotSquared.get().hasPlotArea(loc.getWorld())) {
|
||||
Location location = BukkitUtil.getLocation(entity);
|
||||
if (!PlotSquared.get().hasPlotArea(location.getWorld())) {
|
||||
return true;
|
||||
}
|
||||
PlotArea area = loc.getPlotArea();
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return true;
|
||||
}
|
||||
Plot plot = area.getPlot(loc);
|
||||
Plot plot = area.getPlot(location);
|
||||
ProjectileSource shooter = entity.getShooter();
|
||||
if (shooter instanceof Player) {
|
||||
PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter);
|
||||
@ -523,22 +522,22 @@ import java.util.regex.Pattern;
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Location loc = pp.getLocation();
|
||||
PlotArea area = loc.getPlotArea();
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
Location location = plotPlayer.getLocation();
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
String[] parts = msg.split(" ");
|
||||
Plot plot = pp.getCurrentPlot();
|
||||
Plot plot = plotPlayer.getCurrentPlot();
|
||||
// Check WorldEdit
|
||||
switch (parts[0].toLowerCase()) {
|
||||
case "up":
|
||||
case "/up":
|
||||
case "worldedit:up":
|
||||
case "worldedit:/up":
|
||||
if (plot == null || (!plot.isAdded(pp.getUUID()) && !Permissions
|
||||
.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER, true))) {
|
||||
if (plot == null || (!plot.isAdded(plotPlayer.getUUID()) && !Permissions
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER, true))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -548,7 +547,7 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
Optional<List<String>> flag = plot.getFlag(Flags.BLOCKED_CMDS);
|
||||
if (flag.isPresent() && !Permissions
|
||||
.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
|
||||
List<String> blocked_cmds = flag.get();
|
||||
String part = parts[0];
|
||||
if (parts[0].contains(":")) {
|
||||
@ -592,13 +591,13 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
if (pattern.matcher(msg).matches()) {
|
||||
String perm;
|
||||
if (plot.isAdded(pp.getUUID())) {
|
||||
if (plot.isAdded(plotPlayer.getUUID())) {
|
||||
perm = "plots.admin.command.blocked-cmds.shared";
|
||||
} else {
|
||||
perm = "plots.admin.command.blocked-cmds.other";
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, perm)) {
|
||||
MainUtil.sendMessage(pp, Captions.COMMAND_BLOCKED);
|
||||
if (!Permissions.hasPermission(plotPlayer, perm)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.COMMAND_BLOCKED);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
@ -619,10 +618,10 @@ import java.util.regex.Pattern;
|
||||
UUID uuid = pp.getUUID();
|
||||
UUIDHandler.add(sw, uuid);
|
||||
|
||||
Location loc = pp.getLocation();
|
||||
PlotArea area = loc.getPlotArea();
|
||||
Location location = pp.getLocation();
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area != null) {
|
||||
Plot plot = area.getPlot(loc);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot != null) {
|
||||
plotEntry(pp, plot);
|
||||
}
|
||||
@ -641,7 +640,7 @@ import java.util.regex.Pattern;
|
||||
&& PlotSquared.get().getUpdateUtility() != null) {
|
||||
final UpdateUtility updateUtility = PlotSquared.get().getUpdateUtility();
|
||||
final BukkitMain bukkitMain = BukkitMain.getPlugin(BukkitMain.class);
|
||||
updateUtility.checkForUpdate(bukkitMain.getPluginVersionString(),
|
||||
updateUtility.checkForUpdate(PlotSquared.get().getVersion().versionString(),
|
||||
((updateDescription, throwable) -> {
|
||||
if (throwable != null) {
|
||||
bukkitMain.getLogger().severe(String
|
||||
@ -688,27 +687,27 @@ import java.util.regex.Pattern;
|
||||
org.bukkit.Location to = event.getTo();
|
||||
if (to != null) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = PlotPlayer.wrap(player);
|
||||
Location loc = BukkitUtil.getLocation(to);
|
||||
PlotArea area = loc.getPlotArea();
|
||||
PlotPlayer plotPlayer = PlotPlayer.wrap(player);
|
||||
Location location = BukkitUtil.getLocation(to);
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getPlot(loc);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot != null) {
|
||||
final boolean result = Flags.DENY_TELEPORT.allowsTeleport(pp, plot);
|
||||
final boolean result = Flags.DENY_TELEPORT.allowsTeleport(plotPlayer, plot);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||
event.setCancelled(true);
|
||||
if (lastLoc != null) {
|
||||
pp.setMeta(PlotPlayer.META_LOCATION, lastLoc);
|
||||
plotPlayer.setMeta(PlotPlayer.META_LOCATION, lastLoc);
|
||||
}
|
||||
if (lastPlot != null) {
|
||||
pp.setMeta(PlotPlayer.META_LAST_PLOT, lastPlot);
|
||||
plotPlayer.setMeta(PlotPlayer.META_LAST_PLOT, lastPlot);
|
||||
}
|
||||
} else {
|
||||
plotEntry(pp, plot);
|
||||
plotEntry(plotPlayer, plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -809,14 +808,14 @@ import java.util.regex.Pattern;
|
||||
// Cancel teleport
|
||||
TaskManager.TELEPORT_QUEUE.remove(pp.getName());
|
||||
// Set last location
|
||||
Location loc = BukkitUtil.getLocation(to);
|
||||
pp.setMeta(PlotPlayer.META_LOCATION, loc);
|
||||
PlotArea area = loc.getPlotArea();
|
||||
Location location = BukkitUtil.getLocation(to);
|
||||
pp.setMeta(PlotPlayer.META_LOCATION, location);
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
pp.deleteMeta(PlotPlayer.META_LAST_PLOT);
|
||||
return;
|
||||
}
|
||||
Plot now = area.getPlot(loc);
|
||||
Plot now = area.getPlot(location);
|
||||
Plot lastPlot = pp.getMeta(PlotPlayer.META_LAST_PLOT);
|
||||
if (now == null) {
|
||||
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport && !pp
|
||||
@ -869,14 +868,14 @@ import java.util.regex.Pattern;
|
||||
// Cancel teleport
|
||||
TaskManager.TELEPORT_QUEUE.remove(pp.getName());
|
||||
// Set last location
|
||||
Location loc = BukkitUtil.getLocation(to);
|
||||
pp.setMeta(PlotPlayer.META_LOCATION, loc);
|
||||
PlotArea area = loc.getPlotArea();
|
||||
Location location = BukkitUtil.getLocation(to);
|
||||
pp.setMeta(PlotPlayer.META_LOCATION, location);
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
pp.deleteMeta(PlotPlayer.META_LAST_PLOT);
|
||||
return;
|
||||
}
|
||||
Plot now = area.getPlot(loc);
|
||||
Plot now = area.getPlot(location);
|
||||
Plot lastPlot = pp.getMeta(PlotPlayer.META_LAST_PLOT);
|
||||
if (now == null) {
|
||||
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport && !pp
|
||||
@ -1123,10 +1122,10 @@ import java.util.regex.Pattern;
|
||||
if (Settings.Enabled_Components.PERMISSION_CACHE) {
|
||||
pp.deleteMeta("perm");
|
||||
}
|
||||
Location loc = pp.getLocation();
|
||||
PlotArea area = loc.getPlotArea();
|
||||
if (loc.isPlotArea()) {
|
||||
plot = loc.getPlot();
|
||||
Location location = pp.getLocation();
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (location.isPlotArea()) {
|
||||
plot = location.getPlot();
|
||||
if (plot != null) {
|
||||
plotEntry(pp, plot);
|
||||
}
|
||||
@ -2269,17 +2268,17 @@ import java.util.regex.Pattern;
|
||||
Entity ignitingEntity = event.getIgnitingEntity();
|
||||
Block block = event.getBlock();
|
||||
BlockIgniteEvent.IgniteCause igniteCause = event.getCause();
|
||||
Location loc;
|
||||
Location location1;
|
||||
if (block != null) {
|
||||
loc = BukkitUtil.getLocation(block.getLocation());
|
||||
location1 = BukkitUtil.getLocation(block.getLocation());
|
||||
} else if (ignitingEntity != null) {
|
||||
loc = BukkitUtil.getLocation(ignitingEntity);
|
||||
location1 = BukkitUtil.getLocation(ignitingEntity);
|
||||
} else if (player != null) {
|
||||
loc = BukkitUtil.getLocation(player);
|
||||
location1 = BukkitUtil.getLocation(player);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
PlotArea area = loc.getPlotArea();
|
||||
PlotArea area = location1.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
@ -2288,7 +2287,7 @@ import java.util.regex.Pattern;
|
||||
return;
|
||||
}
|
||||
|
||||
Plot plot = area.getOwnedPlotAbs(loc);
|
||||
Plot plot = area.getOwnedPlotAbs(location1);
|
||||
if (player != null) {
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
if (plot == null) {
|
||||
|
@ -30,8 +30,8 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
|
||||
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle").getRealMethod();
|
||||
try {
|
||||
this.mustSave = classChunk.getField("mustSave").getRealField();
|
||||
} catch (Throwable ignore) {
|
||||
ignore.printStackTrace();
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -56,7 +55,7 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
super.populatePersistentMetaMap();
|
||||
}
|
||||
|
||||
@Override public Location getLocation() {
|
||||
@NotNull @Override public Location getLocation() {
|
||||
final Location location = super.getLocation();
|
||||
return location == null ? BukkitUtil.getLocation(this.player) : location;
|
||||
}
|
||||
@ -72,8 +71,8 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
return this.player.getLastPlayed();
|
||||
}
|
||||
|
||||
@Override public boolean canTeleport(@NotNull final Location loc) {
|
||||
final org.bukkit.Location to = BukkitUtil.getLocation(loc);
|
||||
@Override public boolean canTeleport(@NotNull final Location location) {
|
||||
final org.bukkit.Location to = BukkitUtil.getLocation(location);
|
||||
final org.bukkit.Location from = player.getLocation();
|
||||
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to);
|
||||
callEvent(event);
|
||||
@ -184,7 +183,7 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void teleport(@Nonnull final Location location) {
|
||||
@Override public void teleport(@NotNull final Location location) {
|
||||
if (Math.abs(location.getX()) >= 30000000 || Math.abs(location.getZ()) >= 30000000) {
|
||||
return;
|
||||
}
|
||||
@ -229,7 +228,7 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull @Override public PlotGameMode getGameMode() {
|
||||
@NotNull @Override public PlotGameMode getGameMode() {
|
||||
switch (this.player.getGameMode()) {
|
||||
case ADVENTURE:
|
||||
return PlotGameMode.ADVENTURE;
|
||||
|
@ -351,8 +351,8 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
int bz = min.getZ();
|
||||
for (int x1 = 0; x1 < 16; x1++) {
|
||||
for (int z1 = 0; z1 < 16; z1++) {
|
||||
PlotLoc loc = new PlotLoc(bx + x1, bz + z1);
|
||||
BaseBlock[] ids = map.allBlocks.get(loc);
|
||||
PlotLoc plotLoc = new PlotLoc(bx + x1, bz + z1);
|
||||
BaseBlock[] ids = map.allBlocks.get(plotLoc);
|
||||
if (ids != null) {
|
||||
for (int y = 0; y < Math.min(128, ids.length); y++) {
|
||||
BaseBlock id = ids[y];
|
||||
@ -387,17 +387,18 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean loadChunk(String world, ChunkLoc loc, boolean force) {
|
||||
return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force);
|
||||
@Override public boolean loadChunk(String world, ChunkLoc chunkLoc, boolean force) {
|
||||
return BukkitUtil.getWorld(world).getChunkAt(chunkLoc.x, chunkLoc.z).load(force);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") @Override
|
||||
public void unloadChunk(final String world, final ChunkLoc loc, final boolean save,
|
||||
@Override
|
||||
public void unloadChunk(final String world, final ChunkLoc chunkLoc, final boolean save,
|
||||
final boolean safe) {
|
||||
if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
|
||||
TaskManager.runTask(() -> BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save));
|
||||
TaskManager.runTask(
|
||||
() -> BukkitUtil.getWorld(world).unloadChunk(chunkLoc.x, chunkLoc.z, save));
|
||||
} else {
|
||||
BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save);
|
||||
BukkitUtil.getWorld(world).unloadChunk(chunkLoc.x, chunkLoc.z, save);
|
||||
}
|
||||
}
|
||||
|
||||
@ -614,9 +615,9 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
|
||||
void saveEntitiesOut(Chunk chunk, RegionWrapper region) {
|
||||
for (Entity entity : chunk.getEntities()) {
|
||||
Location loc = BukkitUtil.getLocation(entity);
|
||||
int x = loc.getX();
|
||||
int z = loc.getZ();
|
||||
Location location = BukkitUtil.getLocation(entity);
|
||||
int x = location.getX();
|
||||
int z = location.getZ();
|
||||
if (isIn(region, x, z)) {
|
||||
continue;
|
||||
}
|
||||
@ -636,9 +637,9 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
void saveEntitiesIn(Chunk chunk, RegionWrapper region, int offsetX, int offsetZ,
|
||||
boolean delete) {
|
||||
for (Entity entity : chunk.getEntities()) {
|
||||
Location loc = BukkitUtil.getLocation(entity);
|
||||
int x = loc.getX();
|
||||
int z = loc.getZ();
|
||||
Location location = BukkitUtil.getLocation(entity);
|
||||
int x = location.getX();
|
||||
int z = location.getZ();
|
||||
if (!isIn(region, x, z)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1,22 +1,6 @@
|
||||
package com.github.intellectualsites.plotsquared.bukkit.util;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerClaimPlotEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerEnterPlotEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerLeavePlotEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerPlotDeniedEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerPlotHelperEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerPlotTrustedEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerTeleportToPlotEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlotAutoMergeEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlotChangeOwnerEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlotClearEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlotComponentSetEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlotDeleteEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlotFlagAddEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlotFlagRemoveEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlotMergeEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlotRateEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlotUnlinkEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.*;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
@ -30,9 +14,9 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -41,91 +25,93 @@ import java.util.UUID;
|
||||
*/
|
||||
public final class BukkitEventUtil extends EventUtil {
|
||||
|
||||
@Nullable public Player getPlayer(final PlotPlayer player) {
|
||||
if (player instanceof BukkitPlayer) {
|
||||
return ((BukkitPlayer) player).player;
|
||||
@Nullable public Player getPlayer(final PlotPlayer player) {
|
||||
if (player instanceof BukkitPlayer) {
|
||||
return ((BukkitPlayer) player).player;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean callEvent(@Nonnull final Event event) {
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
return !(event instanceof Cancellable) || !((Cancellable) event).isCancelled();
|
||||
}
|
||||
|
||||
@Override public boolean callClaim(PlotPlayer player, Plot plot, boolean auto) {
|
||||
return callEvent(new PlayerClaimPlotEvent(getPlayer(player), plot, auto));
|
||||
}
|
||||
|
||||
@Override public boolean callTeleport(PlotPlayer player, Location from, Plot plot) {
|
||||
return callEvent(new PlayerTeleportToPlotEvent(getPlayer(player), from, plot));
|
||||
}
|
||||
|
||||
@Override public boolean callComponentSet(Plot plot, String component) {
|
||||
return callEvent(new PlotComponentSetEvent(plot, component));
|
||||
}
|
||||
|
||||
@Override public boolean callClear(Plot plot) {
|
||||
return callEvent(new PlotClearEvent(plot));
|
||||
}
|
||||
|
||||
@Override public boolean callDelete(Plot plot) {
|
||||
return callEvent(new PlotDeleteEvent(plot));
|
||||
}
|
||||
|
||||
@Override public boolean callFlagAdd(Flag flag, Plot plot) {
|
||||
return callEvent(new PlotFlagAddEvent(flag, plot));
|
||||
}
|
||||
|
||||
@Override public boolean callFlagRemove(Flag<?> flag, Plot plot, Object value) {
|
||||
return callEvent(new PlotFlagRemoveEvent(flag, plot));
|
||||
}
|
||||
|
||||
@Override public boolean callMerge(Plot plot, int dir, int max) {
|
||||
return callEvent(new PlotMergeEvent(BukkitUtil.getWorld(plot.getWorldName()), plot, dir, max));
|
||||
}
|
||||
|
||||
@Override public boolean callAutoMerge(Plot plot, List<PlotId> plots) {
|
||||
return callEvent(new PlotAutoMergeEvent(BukkitUtil.getWorld(plot.getWorldName()), plot, plots));
|
||||
}
|
||||
|
||||
@Override public boolean callUnlink(PlotArea area, List<PlotId> plots) {
|
||||
return callEvent(new PlotUnlinkEvent(BukkitUtil.getWorld(area.worldname), area, plots));
|
||||
}
|
||||
|
||||
@Override public void callEntry(PlotPlayer player, Plot plot) {
|
||||
callEvent(new PlayerEnterPlotEvent(getPlayer(player), plot));
|
||||
}
|
||||
|
||||
@Override public void callLeave(PlotPlayer player, Plot plot) {
|
||||
callEvent(new PlayerLeavePlotEvent(getPlayer(player), plot));
|
||||
}
|
||||
|
||||
@Override public void callDenied(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||
callEvent(new PlayerPlotDeniedEvent(getPlayer(initiator), plot, player, added));
|
||||
}
|
||||
|
||||
@Override public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||
callEvent(new PlayerPlotTrustedEvent(getPlayer(initiator), plot, player, added));
|
||||
}
|
||||
|
||||
@Override public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||
callEvent(new PlayerPlotHelperEvent(getPlayer(initiator), plot, player, added));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean callOwnerChange(PlotPlayer initiator, Plot plot, UUID oldOwner, UUID newOwner,
|
||||
boolean hasOldOwner) {
|
||||
return callEvent(
|
||||
new PlotChangeOwnerEvent(getPlayer(initiator), plot, oldOwner, newOwner, hasOldOwner));
|
||||
}
|
||||
|
||||
@Override @Nullable public Rating callRating(PlotPlayer player, Plot plot, Rating rating) {
|
||||
PlotRateEvent event = new PlotRateEvent(player, rating, plot);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return null;
|
||||
private boolean callEvent(@NotNull final Event event) {
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
return !(event instanceof Cancellable) || !((Cancellable) event).isCancelled();
|
||||
}
|
||||
|
||||
@Override public boolean callClaim(PlotPlayer player, Plot plot, boolean auto) {
|
||||
return callEvent(new PlayerClaimPlotEvent(getPlayer(player), plot, auto));
|
||||
}
|
||||
|
||||
@Override public boolean callTeleport(PlotPlayer player, Location from, Plot plot) {
|
||||
return callEvent(new PlayerTeleportToPlotEvent(getPlayer(player), from, plot));
|
||||
}
|
||||
|
||||
@Override public boolean callComponentSet(Plot plot, String component) {
|
||||
return callEvent(new PlotComponentSetEvent(plot, component));
|
||||
}
|
||||
|
||||
@Override public boolean callClear(Plot plot) {
|
||||
return callEvent(new PlotClearEvent(plot));
|
||||
}
|
||||
|
||||
@Override public boolean callDelete(Plot plot) {
|
||||
return callEvent(new PlotDeleteEvent(plot));
|
||||
}
|
||||
|
||||
@Override public boolean callFlagAdd(Flag flag, Plot plot) {
|
||||
return callEvent(new PlotFlagAddEvent(flag, plot));
|
||||
}
|
||||
|
||||
@Override public boolean callFlagRemove(Flag<?> flag, Plot plot, Object value) {
|
||||
return callEvent(new PlotFlagRemoveEvent(flag, plot));
|
||||
}
|
||||
|
||||
@Override public boolean callMerge(Plot plot, int dir, int max) {
|
||||
return callEvent(
|
||||
new PlotMergeEvent(BukkitUtil.getWorld(plot.getWorldName()), plot, dir, max));
|
||||
}
|
||||
|
||||
@Override public boolean callAutoMerge(Plot plot, List<PlotId> plots) {
|
||||
return callEvent(
|
||||
new PlotAutoMergeEvent(BukkitUtil.getWorld(plot.getWorldName()), plot, plots));
|
||||
}
|
||||
|
||||
@Override public boolean callUnlink(PlotArea area, List<PlotId> plots) {
|
||||
return callEvent(new PlotUnlinkEvent(BukkitUtil.getWorld(area.worldname), area, plots));
|
||||
}
|
||||
|
||||
@Override public void callEntry(PlotPlayer player, Plot plot) {
|
||||
callEvent(new PlayerEnterPlotEvent(getPlayer(player), plot));
|
||||
}
|
||||
|
||||
@Override public void callLeave(PlotPlayer player, Plot plot) {
|
||||
callEvent(new PlayerLeavePlotEvent(getPlayer(player), plot));
|
||||
}
|
||||
|
||||
@Override public void callDenied(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||
callEvent(new PlayerPlotDeniedEvent(getPlayer(initiator), plot, player, added));
|
||||
}
|
||||
|
||||
@Override public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||
callEvent(new PlayerPlotTrustedEvent(getPlayer(initiator), plot, player, added));
|
||||
}
|
||||
|
||||
@Override public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||
callEvent(new PlayerPlotHelperEvent(getPlayer(initiator), plot, player, added));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean callOwnerChange(PlotPlayer initiator, Plot plot, UUID oldOwner, UUID newOwner,
|
||||
boolean hasOldOwner) {
|
||||
return callEvent(
|
||||
new PlotChangeOwnerEvent(getPlayer(initiator), plot, oldOwner, newOwner, hasOldOwner));
|
||||
}
|
||||
|
||||
@Override @Nullable public Rating callRating(PlotPlayer player, Plot plot, Rating rating) {
|
||||
PlotRateEvent event = new PlotRateEvent(player, rating, plot);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return null;
|
||||
}
|
||||
return event.getRating();
|
||||
}
|
||||
return event.getRating();
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +27,9 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@ -242,7 +243,7 @@ import java.util.Set;
|
||||
location.getBlockZ());
|
||||
}
|
||||
|
||||
public static Location getLocationFull(@NonNull final Entity entity) {
|
||||
@NotNull public static Location getLocationFull(@NonNull final Entity entity) {
|
||||
final org.bukkit.Location location = entity.getLocation();
|
||||
return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()),
|
||||
MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(),
|
||||
|
@ -42,7 +42,6 @@ public class SendChunk {
|
||||
* Constructor.
|
||||
*/
|
||||
public SendChunk() throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException {
|
||||
RefConstructor tempMapChunk;
|
||||
RefClass classCraftPlayer = getRefClass("{cb}.entity.CraftPlayer");
|
||||
this.methodGetHandlePlayer = classCraftPlayer.getMethod("getHandle");
|
||||
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||
@ -50,8 +49,7 @@ public class SendChunk {
|
||||
RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
this.methodInitLighting = classChunk.getMethod("initLighting");
|
||||
RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
|
||||
tempMapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), int.class);
|
||||
this.mapChunk = tempMapChunk;
|
||||
this.mapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), int.class);
|
||||
RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer");
|
||||
this.connection = classEntityPlayer.getField("playerConnection");
|
||||
RefClass classPacket = getRefClass("{nms}.Packet");
|
||||
|
@ -31,13 +31,13 @@ import java.util.ArrayDeque;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
|
||||
final int MAX_REQUESTS = 500;
|
||||
private final String PROFILE_URL =
|
||||
"https://sessionserver.mojang.com/session/minecraft/profile/";
|
||||
private final int INTERVAL = 12000;
|
||||
private final JSONParser jsonParser = new JSONParser();
|
||||
private final SQLite sqlite;
|
||||
|
||||
@ -133,7 +133,10 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
"Invalid response from Mojang: Some UUIDs will be cached later. (`unknown` until then or player joins)");
|
||||
}
|
||||
try {
|
||||
Thread.sleep(INTERVAL * 50);
|
||||
//Mojang allows requests every 10 minutes according to https://wiki.vg/Mojang_API
|
||||
//15 Minutes is chosen here since system timers are not always precise
|
||||
//and it should provide enough time where Mojang won't block requests.
|
||||
TimeUnit.MINUTES.sleep(15);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
break;
|
||||
@ -142,7 +145,6 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
if (whenDone != null) {
|
||||
whenDone.run();
|
||||
}
|
||||
return;
|
||||
});
|
||||
});
|
||||
} catch (SQLException e) {
|
||||
|
Reference in New Issue
Block a user