Merge branch 'master' into breaking

# Conflicts:
#	Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/events/PlotRateEvent.java
#	Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEventUtil.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Delete.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Kick.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Load.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Music.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Owner.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Rate.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Reload.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/SchematicCmd.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/GameModeFlag.java
#	Core/src/main/java/com/intellectualcrafters/plot/commands/Clear.java
#	Core/src/main/java/com/intellectualcrafters/plot/commands/PluginCmd.java
#	Core/src/main/java/com/intellectualcrafters/plot/commands/Relight.java
#	Core/src/main/java/com/intellectualcrafters/plot/commands/SetHome.java
#	Core/src/main/java/com/intellectualcrafters/plot/config/C.java
#	Core/src/main/java/com/intellectualcrafters/plot/config/Configuration.java
#	Core/src/main/java/com/intellectualcrafters/plot/config/Settings.java
#	Core/src/test/java/com/github/intellectualsites/plotsquared/plot/util/EventUtilTest.java
#	Nukkit/src/main/java/com/plotsquared/nukkit/util/NukkitEventUtil.java
#	README.md
#	Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/events/PlotRateEvent.java
#	Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/util/SpongeSchematicHandler.java
#	Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/util/block/SpongeLocalQueue.java
#	Sponge/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java
This commit is contained in:
dordsor21
2018-11-14 14:44:07 +00:00
120 changed files with 1644 additions and 1216 deletions

View File

@ -0,0 +1,96 @@
package com.github.intellectualsites.plotsquared.sponge.events;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Cancellable;
import java.util.UUID;
public class PlotChangeOwnerEvent extends PlotEvent implements Cancellable {
private final Player initiator;
private final UUID newOwner;
private final UUID oldOwner;
private final boolean hasOldOwner;
private boolean cancelled;
/**
* PlotChangeOwnerEvent: Called when a plot's owner is change.
*
* @param newOwner The new owner of the plot
* @param oldOwner The old owner of the plot
* @param plot The plot having its owner changed
*/
public PlotChangeOwnerEvent(Player initiator, Plot plot, UUID oldOwner, UUID newOwner,
boolean hasOldOwner) {
super(plot);
this.initiator = initiator;
this.newOwner = newOwner;
this.oldOwner = oldOwner;
this.hasOldOwner = hasOldOwner;
}
/**
* Get the PlotId.
*
* @return PlotId
*/
public PlotId getPlotId() {
return getPlot().getId();
}
/**
* Get the world name.
*
* @return String
*/
public String getWorld() {
return getPlot().getWorldName();
}
/**
* Get the change-owner initator
*
* @return Player
*/
public Player getInitiator() {
return this.initiator;
}
/**
* Get the old owner of the plot. Null if not exists.
*
* @return UUID
*/
public UUID getOldOwner() {
return this.oldOwner;
}
/**
* Get the new owner of the plot
*
* @return UUID
*/
public UUID getNewOwner() {
return this.newOwner;
}
/**
* Get if the plot had an old owner
*
* @return boolean
*/
public boolean hasOldOwner() {
return this.hasOldOwner;
}
@Override public boolean isCancelled() {
return this.cancelled;
}
@Override public void setCancelled(boolean b) {
this.cancelled = b;
}
}

View File

@ -3,10 +3,13 @@ package com.github.intellectualsites.plotsquared.sponge.events;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.Rating;
import org.spongepowered.api.event.Cancellable;
public class PlotRateEvent extends PlotEvent implements Cancellable {
public class PlotRateEvent extends PlotEvent {
private final PlotPlayer rater;
private Rating rating;
private boolean cancelled = false;
public PlotRateEvent(final PlotPlayer rater, final Rating rating, final Plot plot) {
super(plot);
@ -22,7 +25,11 @@ public class PlotRateEvent extends PlotEvent {
return rating;
}
public void setRating(final Rating rating) {
this.rating = rating;
@Override public boolean isCancelled() {
return this.cancelled;
}
@Override public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
}

View File

@ -41,7 +41,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Predicate;
@SuppressWarnings("Guava") public class MainListener {
/*
* TODO:
* - Anything marked with a TODO below
@ -69,6 +69,9 @@ import java.util.function.Predicate;
@Listener public void onChat(MessageEvent event) {
// TODO
if (event.isMessageCancelled())
return;
Player player = SpongeUtil.getCause(event.getCause(), Player.class);
if (player == null) {
return;

View File

@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.sponge.events.*;
import org.spongepowered.api.event.Event;
import org.spongepowered.api.event.EventManager;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.UUID;
@ -79,13 +80,24 @@ public class SpongeEventUtil extends EventUtil {
callEvent(new PlayerPlotHelperEvent(SpongeUtil.getPlayer(initiator), plot, player, added));
}
@Override
public boolean callOwnerChange(PlotPlayer initiator, Plot plot, UUID oldOwner, UUID newOwner,
boolean hasOldOwner) {
return callEvent(
new PlotChangeOwnerEvent(SpongeUtil.getPlayer(initiator), plot, oldOwner, newOwner,
hasOldOwner));
}
@Override public boolean callFlagRemove(Flag flag, Object object, PlotCluster cluster) {
return callEvent(new ClusterFlagRemoveEvent(flag, cluster));
}
@Override public Rating callRating(PlotPlayer player, Plot plot, Rating rating) {
@Override @Nullable public Rating callRating(PlotPlayer player, Plot plot, Rating rating) {
PlotRateEvent event = new PlotRateEvent(player, rating, plot);
this.events.post(event);
if (event.isCancelled()) {
return null;
}
return event.getRating();
}

View File

@ -109,12 +109,12 @@ public class SpongeSchematicHandler extends SchematicHandler {
ChunkLoc chunk = chunks.remove(0);
int X = chunk.x;
int Z = chunk.z;
int xxb = X << 4;
int zzb = Z << 4;
if (!worldObj.getChunk(xxb, 1, zzb).isPresent() && !worldObj
.loadChunk(xxb, 1, zzb, false).isPresent()) {
if (!worldObj.getChunk(X, 0, Z).isPresent() && !worldObj
.loadChunk(X, 0, Z, false).isPresent()) {
continue;
}
int xxb = X << 4;
int zzb = Z << 4;
int xxt = xxb + 15;
int zzt = zzb + 15;
@ -134,10 +134,10 @@ public class SpongeSchematicHandler extends SchematicHandler {
int ry = y - sy;
int i1 = ry * width * length;
for (int z = zzb; z <= zzt; z++) {
int rz = z - p1z;
int rz = z - bz;
int i2 = i1 + rz * width;
for (int x = xxb; x <= xxt; x++) {
int rx = x - p1x;
int rx = x - bx;
int index = i2 + rx;
BlockState state = worldObj.getBlock(x, y, z);

View File

@ -129,8 +129,10 @@ public class SpongeSetupUtils extends SetupUtils {
worldSection.set(step.getConstant(), step.getValue());
}
PlotSquared.get().worlds.set("worlds." + world + ".generator.type", object.type);
PlotSquared.get().worlds.set("worlds." + world + ".generator.terrain", object.terrain);
PlotSquared.get().worlds.set("worlds." + world + ".generator.plugin", object.plotManager);
PlotSquared.get().worlds
.set("worlds." + world + ".generator.terrain", object.terrain);
PlotSquared.get().worlds
.set("worlds." + world + ".generator.plugin", object.plotManager);
if (object.setupGenerator != null && !object.setupGenerator
.equals(object.plotManager)) {
PlotSquared.get().worlds

View File

@ -267,6 +267,7 @@ public class SpongeLocalQueue extends BasicLocalBlockQueue<char[]> {
public void setBlocks(LocalChunk<char[]> lc) {
World worldObj = getSpongeWorld();
net.minecraft.world.World nmsWorld = ((net.minecraft.world.World) worldObj);
org.spongepowered.api.world.Chunk spongeChunk =
(org.spongepowered.api.world.Chunk) getChunk(worldObj, lc.getX(), lc.getZ());
Chunk nmsChunk = (Chunk) spongeChunk;
@ -276,7 +277,13 @@ public class SpongeLocalQueue extends BasicLocalBlockQueue<char[]> {
if (array == null) {
continue;
}
ExtendedBlockStorage section = nmsChunk.getBlockStorageArray()[layer];
ExtendedBlockStorage[] sections = nmsChunk.getBlockStorageArray();
ExtendedBlockStorage section = sections[layer];
if (section == null) {
section = sections[layer] =
new ExtendedBlockStorage(layer << 4, nmsWorld.provider.hasSkyLight());
}
short[] cacheX = MainUtil.x_loc[0];
short[] cacheY = MainUtil.y_loc[0];
short[] cacheZ = MainUtil.z_loc[0];