mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
53e4b728a6
@ -0,0 +1,56 @@
|
||||
package com.plotsquared.bukkit.events;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when a plot component is set
|
||||
*
|
||||
*/
|
||||
public class PlotComponentSetEvent extends PlotEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final String component;
|
||||
|
||||
public PlotComponentSetEvent(Plot plot, String component) {
|
||||
super(plot);
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
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().getArea().worldname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the component which was set
|
||||
*
|
||||
* @return Component name
|
||||
*/
|
||||
public String getComponent() {
|
||||
return this.component;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -109,7 +109,6 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.projectiles.BlockProjectileSource;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
@ -18,6 +18,7 @@ import com.plotsquared.bukkit.events.PlayerPlotHelperEvent;
|
||||
import com.plotsquared.bukkit.events.PlayerPlotTrustedEvent;
|
||||
import com.plotsquared.bukkit.events.PlayerTeleportToPlotEvent;
|
||||
import com.plotsquared.bukkit.events.PlotClearEvent;
|
||||
import com.plotsquared.bukkit.events.PlotComponentSetEvent;
|
||||
import com.plotsquared.bukkit.events.PlotDeleteEvent;
|
||||
import com.plotsquared.bukkit.events.PlotFlagAddEvent;
|
||||
import com.plotsquared.bukkit.events.PlotFlagRemoveEvent;
|
||||
@ -57,6 +58,11 @@ public class BukkitEventUtil extends EventUtil {
|
||||
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));
|
||||
|
@ -539,7 +539,6 @@ public class MemorySection implements ConfigurationSection {
|
||||
List<?> list = getList(path);
|
||||
|
||||
if (list == null) {
|
||||
PS.get().log(path + " is null");
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class Set extends SubCommand {
|
||||
}
|
||||
plot.addRunning();
|
||||
for (Plot current : plot.getConnectedPlots()) {
|
||||
manager.setComponent(plotworld, current.getId(), component, blocks);
|
||||
current.setComponent(component, blocks);
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.GENERATING_COMPONENT);
|
||||
SetQueue.IMP.addTask(new Runnable() {
|
||||
|
@ -9,7 +9,6 @@ import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
|
@ -18,11 +18,11 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.PathIterator;
|
||||
@ -2600,6 +2600,9 @@ public class Plot {
|
||||
* @return
|
||||
*/
|
||||
public boolean setComponent(String component, PlotBlock[] blocks) {
|
||||
if (StringMan.isEqualToAny(component, getManager().getPlotComponents(this.area, this.getId()))) {
|
||||
EventUtil.manager.callComponentSet(this, component);
|
||||
}
|
||||
return this.getManager().setComponent(this.area, this.getId(), component, blocks);
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,8 @@ public abstract class EventUtil {
|
||||
|
||||
public abstract boolean callTeleport(PlotPlayer player, Location from, Plot plot);
|
||||
|
||||
public abstract boolean callComponentSet(Plot plot, String component);
|
||||
|
||||
public abstract boolean callClear(Plot plot);
|
||||
|
||||
public abstract void callDelete(Plot plot);
|
||||
|
@ -26,6 +26,8 @@ public class EventUtilTest extends EventUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean callComponentSet(Plot plot, String component) { return false; }
|
||||
|
||||
@Override public boolean callClear(Plot plot) {
|
||||
return false;
|
||||
}
|
||||
|
@ -52,6 +52,12 @@ import com.plotsquared.sponge.util.block.SlowQueue;
|
||||
import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper;
|
||||
import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper;
|
||||
import com.plotsquared.sponge.uuid.SpongeUUIDHandler;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.api.Game;
|
||||
import org.spongepowered.api.Server;
|
||||
@ -60,8 +66,6 @@ import org.spongepowered.api.config.ConfigDir;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
|
||||
import org.spongepowered.api.event.game.state.GameInitializationEvent;
|
||||
import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
|
||||
import org.spongepowered.api.plugin.Plugin;
|
||||
import org.spongepowered.api.plugin.PluginContainer;
|
||||
import org.spongepowered.api.profile.GameProfileManager;
|
||||
@ -70,14 +74,7 @@ import org.spongepowered.api.world.World;
|
||||
import org.spongepowered.api.world.gen.GenerationPopulator;
|
||||
import org.spongepowered.api.world.gen.WorldGenerator;
|
||||
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Plugin(id = "plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.",
|
||||
url = "https://github.com/IntellectualSites/PlotSquared", version = "3.3.3")
|
||||
@ -126,19 +123,8 @@ public class SpongeMain implements IPlotMain {
|
||||
return THIS;
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void init(GameInitializationEvent event) {
|
||||
PS.log("PlotSquared: Game init");
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onInit(GamePreInitializationEvent event) {
|
||||
PS.log("PlotSquared: Game pre init");
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onServerAboutToStart(GameAboutToStartServerEvent event) {
|
||||
PS.log("PlotSquared: Server init");
|
||||
THIS = this;
|
||||
new PS(this, "Sponge");
|
||||
this.server = this.game.getServer();
|
||||
|
@ -0,0 +1,55 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import org.spongepowered.api.event.cause.Cause;
|
||||
import org.spongepowered.api.event.impl.AbstractEvent;
|
||||
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
|
||||
public class PlotComponentSetEvent extends AbstractEvent {
|
||||
private final Plot plot;
|
||||
private final String component;
|
||||
|
||||
/**
|
||||
* PlotDeleteEvent: Called when a plot component is set
|
||||
*
|
||||
* @param plot The plot
|
||||
* @param component The component which was set
|
||||
*/
|
||||
public PlotComponentSetEvent(Plot plot, String component) {
|
||||
this.plot = plot;
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotId
|
||||
*
|
||||
* @return PlotId
|
||||
*/
|
||||
public PlotId getPlotId() {
|
||||
return this.plot.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the world name
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getWorld() {
|
||||
return this.plot.getArea().worldname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the component which was set
|
||||
*
|
||||
* @return Component name
|
||||
*/
|
||||
public String getComponent() {
|
||||
return this.component;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cause getCause() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ import com.plotsquared.sponge.events.PlayerPlotHelperEvent;
|
||||
import com.plotsquared.sponge.events.PlayerPlotTrustedEvent;
|
||||
import com.plotsquared.sponge.events.PlayerTeleportToPlotEvent;
|
||||
import com.plotsquared.sponge.events.PlotClearEvent;
|
||||
import com.plotsquared.sponge.events.PlotComponentSetEvent;
|
||||
import com.plotsquared.sponge.events.PlotDeleteEvent;
|
||||
import com.plotsquared.sponge.events.PlotFlagAddEvent;
|
||||
import com.plotsquared.sponge.events.PlotFlagRemoveEvent;
|
||||
@ -53,6 +54,11 @@ public class SpongeEventUtil extends EventUtil {
|
||||
return callEvent(new PlayerTeleportToPlotEvent(SpongeUtil.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));
|
||||
|
Loading…
Reference in New Issue
Block a user