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

@ -199,8 +199,7 @@ public final class NukkitMain extends PluginBase implements Listener, IPlotMain
if (entity instanceof Player) {
continue;
}
Location location =
NukkitUtil.getLocation(entity.getLocation());
Location location = NukkitUtil.getLocation(entity.getLocation());
Plot plot = location.getPlot();
if (plot == null) {
if (location.isPlotArea()) {

View File

@ -0,0 +1,107 @@
package com.github.intellectualsites.plotsquared.nukkit.events;
import cn.nukkit.Player;
import cn.nukkit.event.Cancellable;
import cn.nukkit.event.HandlerList;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import java.util.UUID;
public class PlotChangeOwnerEvent extends PlotEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Plot plot;
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.plot = plot;
this.initiator = initiator;
this.newOwner = newOwner;
this.hasOldOwner = hasOldOwner;
this.oldOwner = oldOwner;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* 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
*
* @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;
}
public HandlerList getHandlers() {
return handlers;
}
@Override public boolean isCancelled() {
return this.cancelled;
}
@Override public void setCancelled(boolean b) {
this.cancelled = b;
}
}

View File

@ -1,15 +1,17 @@
package com.github.intellectualsites.plotsquared.nukkit.events;
import cn.nukkit.event.Cancellable;
import cn.nukkit.event.HandlerList;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.Rating;
public class PlotRateEvent extends PlotEvent {
public class PlotRateEvent extends PlotEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final PlotPlayer rater;
private Rating rating;
private boolean cancelled = false;
public PlotRateEvent(PlotPlayer rater, Rating rating, Plot plot) {
super(plot);
@ -33,4 +35,11 @@ public class PlotRateEvent extends PlotEvent {
this.rating = rating;
}
@Override public boolean isCancelled() {
return this.cancelled;
}
@Override public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@ -61,7 +61,8 @@ public class NukkitPlotGenerator extends Generator implements GeneratorWrapper<G
@Override
public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
return PlotSquared.get().IMP.getDefaultGenerator().getNewPlotArea(world, id, min, max);
return PlotSquared.get().IMP.getDefaultGenerator()
.getNewPlotArea(world, id, min, max);
}
@Override

View File

@ -612,8 +612,10 @@ public class PlayerEvents extends PlotListener implements Listener {
}
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onChat(PlayerChatEvent event) {
@EventHandler(priority = EventPriority.LOW) public void onChat(PlayerChatEvent event) {
if (event.isCancelled())
return;
PlotPlayer plotPlayer = NukkitUtil.getPlayer(event.getPlayer());
Location location = plotPlayer.getLocation();
PlotArea area = location.getPlotArea();

View File

@ -10,6 +10,7 @@ import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.UUID;
@ -89,13 +90,23 @@ public class NukkitEventUtil extends EventUtil {
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 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);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return null;
}
return event.getRating();
}

View File

@ -53,7 +53,8 @@ public class NukkitSetupUtils extends SetupUtils {
if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath);
}
ConfigurationSection worldSection = PlotSquared.get().worlds.getConfigurationSection(worldPath);
ConfigurationSection worldSection =
PlotSquared.get().worlds.getConfigurationSection(worldPath);
switch (type) {
case 2: {
if (object.id != null) {
@ -99,8 +100,10 @@ public class NukkitSetupUtils 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

@ -12,6 +12,7 @@ public class NukkitTaskManager extends TaskManager {
private final NukkitMain plugin;
private AtomicInteger index = new AtomicInteger(0);
private HashMap<Integer, Integer> tasks = new HashMap<>();
public NukkitTaskManager(NukkitMain bukkitMain) {
this.plugin = bukkitMain;
}

View File

@ -14,7 +14,8 @@ public class NukkitHybridGen extends NukkitPlotGenerator {
private static Map<String, Object> defaultSettings(Map<String, Object> existing) {
if (!existing.containsKey("world")) {
Map<Integer, Level> levels = ((NukkitMain) PlotSquared.get().IMP).getServer().getLevels();
Map<Integer, Level> levels =
((NukkitMain) PlotSquared.get().IMP).getServer().getLevels();
int max = -1;
for (Map.Entry<Integer, Level> entry : levels.entrySet()) {
int id = entry.getKey();