mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Features/v5/event results (#2706)
* Begin events rewrite using Guava EventBus: - moved events to within core - removed BukkitEventUtil - EventUtil in core is now the implementation - Refactor any event calls TODO: - Test :) - Implement changes to PlotSquared's own listeners - Other * Correct code style for annotations and refactor EventUtil to EventDispatcher * Make getEventResultRaw default method and remove empty PlotEventListener file * not raw map * Remove PlotPlusListener * Add listener registration to PlotAPI. Add documentation and refactor Result enum * Add reason for the Event Result. Change how the claim event is called TODO: better auto event somehow. Possible re-write of auto required..? * Implement changes to events properly Add PlayerAutoPlotEvent Add PlotDoneEvent Add schematic variable to Claim event and allow it to be changed Add reason for plot unlink to unlink event Add pattern to component set event and allow it to be changed Allow component of component set event to be changed Add player to plot merge event * Fix compile * Correct formating * Various cleanup - Correct formatting in places - Add feedback to Desc command cancellation - Correct use of flag API - Add FlagRemove event to flagcommand where required * Replace reason with caption * Switch colours in Event Deny caption Co-authored-by: dordsor21 <dordsor21@gmail.com>
This commit is contained in:
parent
4bcd926543
commit
d9f9d7dc34
@ -4,7 +4,6 @@ import com.github.intellectualsites.plotsquared.bukkit.generator.BukkitPlotGener
|
|||||||
import com.github.intellectualsites.plotsquared.bukkit.listeners.ChunkListener;
|
import com.github.intellectualsites.plotsquared.bukkit.listeners.ChunkListener;
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.listeners.EntitySpawnListener;
|
import com.github.intellectualsites.plotsquared.bukkit.listeners.EntitySpawnListener;
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.listeners.PlayerEvents;
|
import com.github.intellectualsites.plotsquared.bukkit.listeners.PlayerEvents;
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.listeners.PlotPlusListener;
|
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.listeners.SingleWorldListener;
|
import com.github.intellectualsites.plotsquared.bukkit.listeners.SingleWorldListener;
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.listeners.WorldEvents;
|
import com.github.intellectualsites.plotsquared.bukkit.listeners.WorldEvents;
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.placeholders.PlaceholderFormatter;
|
import com.github.intellectualsites.plotsquared.bukkit.placeholders.PlaceholderFormatter;
|
||||||
@ -13,7 +12,6 @@ import com.github.intellectualsites.plotsquared.bukkit.util.BukkitChatManager;
|
|||||||
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitChunkManager;
|
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitChunkManager;
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitCommand;
|
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitCommand;
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitEconHandler;
|
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitEconHandler;
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitEventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitHybridUtils;
|
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitHybridUtils;
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitInventoryUtil;
|
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitInventoryUtil;
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitSchematicHandler;
|
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitSchematicHandler;
|
||||||
@ -588,11 +586,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this);
|
getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void registerPlotPlusEvents() {
|
|
||||||
PlotPlusListener.startRunnable(this);
|
|
||||||
getServer().getPluginManager().registerEvents(new PlotPlusListener(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void registerForceFieldEvents() {
|
@Override public void registerForceFieldEvents() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -672,10 +665,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
return new BukkitChunkManager();
|
return new BukkitChunkManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public EventUtil initEventUtil() {
|
|
||||||
return new BukkitEventUtil();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void unregister(@NonNull final PlotPlayer player) {
|
@Override public void unregister(@NonNull final PlotPlayer player) {
|
||||||
BukkitUtil.removePlayer(player.getName());
|
BukkitUtil.removePlayer(player.getName());
|
||||||
}
|
}
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
|
||||||
|
|
||||||
public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable {
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
private final Plot plot;
|
|
||||||
private final boolean auto;
|
|
||||||
private boolean cancelled;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PlayerClaimPlotEvent: Called when a plot is claimed.
|
|
||||||
*
|
|
||||||
* @param player Player that claimed the plot
|
|
||||||
* @param plot Plot that was claimed
|
|
||||||
*/
|
|
||||||
public PlayerClaimPlotEvent(Player player, Plot plot, boolean auto) {
|
|
||||||
super(player);
|
|
||||||
this.plot = plot;
|
|
||||||
this.auto = auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the plot involved
|
|
||||||
*
|
|
||||||
* @return Plot
|
|
||||||
*/
|
|
||||||
public Plot getPlot() {
|
|
||||||
return this.plot;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return true if it was an automated claim, else false
|
|
||||||
*/
|
|
||||||
public boolean wasAuto() {
|
|
||||||
return this.auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean isCancelled() {
|
|
||||||
return this.cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void setCancelled(boolean b) {
|
|
||||||
this.cancelled = b;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
|
||||||
|
|
||||||
public class PlayerEnterPlotEvent extends PlayerEvent {
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
private final Plot plot;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a player leaves a plot.
|
|
||||||
*
|
|
||||||
* @param player Player that entered the plot
|
|
||||||
* @param plot Plot that was entered
|
|
||||||
*/
|
|
||||||
public PlayerEnterPlotEvent(Player player, Plot plot) {
|
|
||||||
super(player);
|
|
||||||
this.plot = plot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the plot involved.
|
|
||||||
*
|
|
||||||
* @return Plot
|
|
||||||
*/
|
|
||||||
public Plot getPlot() {
|
|
||||||
return this.plot;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class PlayerLeavePlotEvent extends PlayerEvent {
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
private final Plot plot;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PlayerLeavePlotEvent: Called when a player leaves a plot
|
|
||||||
*
|
|
||||||
* @param player Player that left the plot
|
|
||||||
* @param plot Plot that was left
|
|
||||||
*/
|
|
||||||
public PlayerLeavePlotEvent(Player player, Plot plot) {
|
|
||||||
super(player);
|
|
||||||
this.plot = plot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the plot involved
|
|
||||||
*
|
|
||||||
* @return Plot
|
|
||||||
*/
|
|
||||||
public Plot getPlot() {
|
|
||||||
return this.plot;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a player teleports to a plot
|
|
||||||
*/
|
|
||||||
public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellable {
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
private final Location from;
|
|
||||||
private final Plot plot;
|
|
||||||
private boolean cancelled;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PlayerTeleportToPlotEvent: Called when a player teleports to a plot
|
|
||||||
*
|
|
||||||
* @param player That was teleported
|
|
||||||
* @param from Start location
|
|
||||||
* @param plot Plot to which the player was teleported
|
|
||||||
*/
|
|
||||||
public PlayerTeleportToPlotEvent(Player player, Location from, Plot plot) {
|
|
||||||
super(player);
|
|
||||||
this.from = from;
|
|
||||||
this.plot = plot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the from location
|
|
||||||
*
|
|
||||||
* @return Location
|
|
||||||
*/
|
|
||||||
public Location getFrom() {
|
|
||||||
return this.from;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the plot involved
|
|
||||||
*
|
|
||||||
* @return Plot
|
|
||||||
*/
|
|
||||||
public Plot getPlot() {
|
|
||||||
return this.plot;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean isCancelled() {
|
|
||||||
return this.cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void setCancelled(boolean cancelled) {
|
|
||||||
this.cancelled = cancelled;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|
||||||
import com.github.intellectualsites.plotsquared.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().getWorldName();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the component which was set
|
|
||||||
*
|
|
||||||
* @return Component name
|
|
||||||
*/
|
|
||||||
public String getComponent() {
|
|
||||||
return this.component;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
|
|
||||||
public abstract class PlotEvent extends Event {
|
|
||||||
|
|
||||||
private final Plot plot;
|
|
||||||
|
|
||||||
public PlotEvent(Plot plot) {
|
|
||||||
this.plot = plot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final Plot getPlot() {
|
|
||||||
return this.plot;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a Flag is added to a plot.
|
|
||||||
*/
|
|
||||||
public class PlotFlagAddEvent extends PlotFlagEvent implements Cancellable {
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
private boolean cancelled;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PlotFlagAddEvent: Called when a Flag is added to a plot.
|
|
||||||
*
|
|
||||||
* @param flag Flag that was added
|
|
||||||
* @param plot Plot to which the flag was added
|
|
||||||
*/
|
|
||||||
public PlotFlagAddEvent(PlotFlag<?, ?> flag, Plot plot) {
|
|
||||||
super(plot, flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public final boolean isCancelled() {
|
|
||||||
return this.cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public final void setCancelled(boolean cancelled) {
|
|
||||||
this.cancelled = cancelled;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a flag is removed from a plot
|
|
||||||
*/
|
|
||||||
public class PlotFlagRemoveEvent extends PlotFlagEvent implements Cancellable {
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
private boolean cancelled;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PlotFlagRemoveEvent: Called when a flag is removed from a plot
|
|
||||||
*
|
|
||||||
* @param flag Flag that was removed
|
|
||||||
* @param plot Plot from which the flag was removed
|
|
||||||
*/
|
|
||||||
public PlotFlagRemoveEvent(PlotFlag<?, ?> flag, Plot plot) {
|
|
||||||
super(plot, flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public final boolean isCancelled() {
|
|
||||||
return this.cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public final void setCancelled(boolean cancelled) {
|
|
||||||
this.cancelled = cancelled;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Event called when several plots are merged
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public final class PlotMergeEvent extends PlotEvent implements Cancellable {
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
@Getter private final int dir;
|
|
||||||
@Getter private final int max;
|
|
||||||
@Getter private final World world;
|
|
||||||
@Getter @Setter private boolean cancelled;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PlotMergeEvent: Called when plots are merged
|
|
||||||
*
|
|
||||||
* @param world World in which the event occurred
|
|
||||||
* @param plot Plot that was merged
|
|
||||||
* @param dir The direction of the merge
|
|
||||||
* @param max Max merge size
|
|
||||||
*/
|
|
||||||
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;
|
|
||||||
this.max = max;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.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.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
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);
|
|
||||||
this.rater = rater;
|
|
||||||
this.rating = rating;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlotPlayer getRater() {
|
|
||||||
return this.rater;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Rating getRating() {
|
|
||||||
return this.rating;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRating(Rating rating) {
|
|
||||||
this.rating = rating;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean isCancelled() {
|
|
||||||
return this.cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void setCancelled(boolean cancelled) {
|
|
||||||
this.cancelled = cancelled;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
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 java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Event called when several merged plots are unlinked
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public final class PlotUnlinkEvent extends Event implements Cancellable {
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
private final List<PlotId> plots;
|
|
||||||
@Getter private final World world;
|
|
||||||
@Getter private final PlotArea area;
|
|
||||||
@Getter @Setter private boolean cancelled;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a mega-plot is unlinked.
|
|
||||||
*
|
|
||||||
* @param world World in which the event occurred
|
|
||||||
* @param plots Plots that are involved in the event
|
|
||||||
*/
|
|
||||||
public PlotUnlinkEvent(@NotNull final World world, @NotNull final PlotArea area,
|
|
||||||
@NotNull final List<PlotId> plots) {
|
|
||||||
this.plots = plots;
|
|
||||||
this.world = world;
|
|
||||||
this.area = area;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the plots involved.
|
|
||||||
*
|
|
||||||
* @return Unmodifiable list containing {@link PlotId PlotIds} of the plots involved
|
|
||||||
*/
|
|
||||||
public List<PlotId> getPlots() {
|
|
||||||
return Collections.unmodifiableList(this.plots);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,51 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalAttackFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalCapFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalInteractFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockBurnFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockIgnitionFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockedCmdsFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BreakFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyTeleportFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DisablePhysicsFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.EntityCapFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.ExplosionFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.GrassGrowFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HangingBreakFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HangingPlaceFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HostileAttackFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HostileCapFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HostileInteractFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.IceFormFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.IceMeltFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.KelpGrowFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.LiquidFlowFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscBreakFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscCapFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscInteractFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobCapFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobPlaceFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MycelGrowFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PlaceFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PlayerInteractFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PveFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PvpFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.RedstoneFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.SnowFormFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.SnowMeltFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.SoilDryFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TamedAttackFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TamedInteractFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UntrustedVisitFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UseFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleBreakFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleCapFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleUseFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VillagerInteractFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VineGrowFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.types.BlockTypeWrapper;
|
import com.github.intellectualsites.plotsquared.plot.flags.types.BlockTypeWrapper;
|
||||||
import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType;
|
import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType;
|
||||||
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
|
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
|
||||||
@ -66,7 +22,6 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
|
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EntityUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.EntityUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
@ -76,11 +31,7 @@ import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
|||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.*;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.FluidCollisionMode;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
@ -130,36 +81,12 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||||
import org.bukkit.event.block.BlockSpreadEvent;
|
import org.bukkit.event.block.BlockSpreadEvent;
|
||||||
import org.bukkit.event.block.EntityBlockFormEvent;
|
import org.bukkit.event.block.EntityBlockFormEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.*;
|
||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
|
||||||
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
|
||||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
|
||||||
import org.bukkit.event.entity.LingeringPotionSplashEvent;
|
|
||||||
import org.bukkit.event.entity.PotionSplashEvent;
|
|
||||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
|
||||||
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.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.*;
|
||||||
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.PlayerEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
|
||||||
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.PlayerRespawnEvent;
|
|
||||||
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.vehicle.VehicleEntityCollisionEvent;
|
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
|
||||||
@ -196,7 +123,8 @@ import java.util.regex.Pattern;
|
|||||||
/**
|
/**
|
||||||
* Player Events involving plots.
|
* Player Events involving plots.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused") public class PlayerEvents extends PlotListener implements Listener {
|
@SuppressWarnings("unused")
|
||||||
|
public class PlayerEvents extends PlotListener implements Listener {
|
||||||
|
|
||||||
private boolean pistonBlocks = true;
|
private boolean pistonBlocks = true;
|
||||||
private float lastRadius;
|
private float lastRadius;
|
||||||
@ -237,8 +165,8 @@ import java.util.regex.Pattern;
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkEntity(Entity entity, Plot plot) {
|
public static boolean checkEntity(Entity entity, Plot plot) {
|
||||||
if (plot == null || !plot.hasOwner() || plot.getFlags().isEmpty() && plot
|
if (plot == null || !plot.hasOwner() || plot.getFlags().isEmpty() && plot.getArea()
|
||||||
.getArea().getFlagContainer().getFlagMap().isEmpty()) {
|
.getFlagContainer().getFlagMap().isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (entity.getType()) {
|
switch (entity.getType()) {
|
||||||
@ -277,8 +205,7 @@ import java.util.regex.Pattern;
|
|||||||
case ARMOR_STAND:
|
case ARMOR_STAND:
|
||||||
case ITEM_FRAME:
|
case ITEM_FRAME:
|
||||||
case PAINTING:
|
case PAINTING:
|
||||||
return EntityUtil.checkEntity(plot,
|
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
|
||||||
MiscCapFlag.MISC_CAP_UNLIMITED);
|
MiscCapFlag.MISC_CAP_UNLIMITED);
|
||||||
// misc
|
// misc
|
||||||
case BOAT:
|
case BOAT:
|
||||||
@ -289,8 +216,7 @@ import java.util.regex.Pattern;
|
|||||||
case MINECART_HOPPER:
|
case MINECART_HOPPER:
|
||||||
case MINECART_MOB_SPAWNER:
|
case MINECART_MOB_SPAWNER:
|
||||||
case MINECART_TNT:
|
case MINECART_TNT:
|
||||||
return EntityUtil.checkEntity(plot,
|
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
|
||||||
VehicleCapFlag.VEHICLE_CAP_UNLIMITED);
|
VehicleCapFlag.VEHICLE_CAP_UNLIMITED);
|
||||||
case BAT:
|
case BAT:
|
||||||
case CHICKEN:
|
case CHICKEN:
|
||||||
@ -324,10 +250,8 @@ import java.util.regex.Pattern;
|
|||||||
case WOLF:
|
case WOLF:
|
||||||
case ZOMBIE_HORSE:
|
case ZOMBIE_HORSE:
|
||||||
// animal
|
// animal
|
||||||
return EntityUtil.checkEntity(plot,
|
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
MobCapFlag.MOB_CAP_UNLIMITED, AnimalCapFlag.ANIMAL_CAP_UNLIMITED);
|
||||||
MobCapFlag.MOB_CAP_UNLIMITED,
|
|
||||||
AnimalCapFlag.ANIMAL_CAP_UNLIMITED);
|
|
||||||
case BLAZE:
|
case BLAZE:
|
||||||
case CAVE_SPIDER:
|
case CAVE_SPIDER:
|
||||||
case CREEPER:
|
case CREEPER:
|
||||||
@ -361,37 +285,27 @@ import java.util.regex.Pattern;
|
|||||||
case PHANTOM:
|
case PHANTOM:
|
||||||
case RAVAGER:
|
case RAVAGER:
|
||||||
// monster
|
// monster
|
||||||
return EntityUtil
|
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||||
.checkEntity(plot,
|
MobCapFlag.MOB_CAP_UNLIMITED, HostileCapFlag.HOSTILE_CAP_UNLIMITED);
|
||||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
|
||||||
MobCapFlag.MOB_CAP_UNLIMITED,
|
|
||||||
HostileCapFlag.HOSTILE_CAP_UNLIMITED);
|
|
||||||
default:
|
default:
|
||||||
if (entity instanceof LivingEntity) {
|
if (entity instanceof LivingEntity) {
|
||||||
if (entity instanceof Animals || entity instanceof WaterMob) {
|
if (entity instanceof Animals || entity instanceof WaterMob) {
|
||||||
return EntityUtil.checkEntity(plot,
|
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
MobCapFlag.MOB_CAP_UNLIMITED, AnimalCapFlag.ANIMAL_CAP_UNLIMITED);
|
||||||
MobCapFlag.MOB_CAP_UNLIMITED,
|
|
||||||
AnimalCapFlag.ANIMAL_CAP_UNLIMITED);
|
|
||||||
} else if (entity instanceof Monster) {
|
} else if (entity instanceof Monster) {
|
||||||
return EntityUtil.checkEntity(plot,
|
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
MobCapFlag.MOB_CAP_UNLIMITED, HostileCapFlag.HOSTILE_CAP_UNLIMITED);
|
||||||
MobCapFlag.MOB_CAP_UNLIMITED,
|
|
||||||
HostileCapFlag.HOSTILE_CAP_UNLIMITED);
|
|
||||||
} else {
|
} else {
|
||||||
return EntityUtil.checkEntity(plot,
|
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
|
||||||
MobCapFlag.MOB_CAP_UNLIMITED);
|
MobCapFlag.MOB_CAP_UNLIMITED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entity instanceof Vehicle) {
|
if (entity instanceof Vehicle) {
|
||||||
return EntityUtil.checkEntity(plot,
|
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
|
||||||
VehicleCapFlag.VEHICLE_CAP_UNLIMITED);
|
VehicleCapFlag.VEHICLE_CAP_UNLIMITED);
|
||||||
}
|
}
|
||||||
if (entity instanceof Hanging) {
|
if (entity instanceof Hanging) {
|
||||||
return EntityUtil.checkEntity(plot,
|
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
|
||||||
MiscCapFlag.MISC_CAP_UNLIMITED);
|
MiscCapFlag.MISC_CAP_UNLIMITED);
|
||||||
}
|
}
|
||||||
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED);
|
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED);
|
||||||
@ -793,26 +707,38 @@ import java.util.regex.Pattern;
|
|||||||
if (!player.hasPlayedBefore() && player.isOnline()) {
|
if (!player.hasPlayedBefore() && player.isOnline()) {
|
||||||
player.saveData();
|
player.saveData();
|
||||||
}
|
}
|
||||||
EventUtil.manager.doJoinTask(pp);
|
PlotSquared.get().getEventDispatcher().doJoinTask(pp);
|
||||||
}, 20);
|
}, 20);
|
||||||
|
|
||||||
if (pp.hasPermission(Captions.PERMISSION_ADMIN_UPDATE_NOTIFICATION.getTranslated())
|
if (pp.hasPermission(Captions.PERMISSION_ADMIN_UPDATE_NOTIFICATION.getTranslated())
|
||||||
&& Settings.Enabled_Components.UPDATE_NOTIFICATIONS) {
|
&& Settings.Enabled_Components.UPDATE_NOTIFICATIONS) {
|
||||||
try {
|
try {
|
||||||
HttpsURLConnection connection = (HttpsURLConnection) new URL("https://api.spigotmc.org/legacy/update.php?resource=1177").openConnection();
|
HttpsURLConnection connection = (HttpsURLConnection) new URL(
|
||||||
|
"https://api.spigotmc.org/legacy/update.php?resource=1177").openConnection();
|
||||||
connection.setRequestMethod("GET");
|
connection.setRequestMethod("GET");
|
||||||
spigotVersion = (new BufferedReader(new InputStreamReader(connection.getInputStream()))).readLine();
|
spigotVersion =
|
||||||
|
(new BufferedReader(new InputStreamReader(connection.getInputStream())))
|
||||||
|
.readLine();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
new PlotMessage(Captions.PREFIX + "Unable to check for updates, check console for further information.").color("$13");
|
new PlotMessage(Captions.PREFIX
|
||||||
|
+ "Unable to check for updates, check console for further information.")
|
||||||
|
.color("$13");
|
||||||
PlotSquared.log(Captions.PREFIX + "&cUnable to check for updates because: " + e);
|
PlotSquared.log(Captions.PREFIX + "&cUnable to check for updates because: " + e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!UpdateUtility.internalVersion.equals(UpdateUtility.spigotVersion)) {
|
if (!UpdateUtility.internalVersion.equals(UpdateUtility.spigotVersion)) {
|
||||||
new PlotMessage("-----------------------------------").send(pp);
|
new PlotMessage("-----------------------------------").send(pp);
|
||||||
new PlotMessage(Captions.PREFIX + "There appears to be a PlotSquared update available!").color("$1").tooltip("https://www.spigotmc.org/resources/1177/updates").send(pp);
|
new PlotMessage(
|
||||||
new PlotMessage(Captions.PREFIX + "The latest version is " + spigotVersion).color("$1").tooltip("https://www.spigotmc.org/resources/1177/updates").send(pp);
|
Captions.PREFIX + "There appears to be a PlotSquared update available!")
|
||||||
new PlotMessage(Captions.PREFIX + "https://www.spigotmc.org/resources/1177/updates").color("$1").tooltip("https://www.spigotmc.org/resources/1177/updates").send(pp);
|
.color("$1").tooltip("https://www.spigotmc.org/resources/1177/updates")
|
||||||
|
.send(pp);
|
||||||
|
new PlotMessage(Captions.PREFIX + "The latest version is " + spigotVersion)
|
||||||
|
.color("$1").tooltip("https://www.spigotmc.org/resources/1177/updates")
|
||||||
|
.send(pp);
|
||||||
|
new PlotMessage(Captions.PREFIX + "https://www.spigotmc.org/resources/1177/updates")
|
||||||
|
.color("$1").tooltip("https://www.spigotmc.org/resources/1177/updates")
|
||||||
|
.send(pp);
|
||||||
new PlotMessage("-----------------------------------").send(pp);
|
new PlotMessage("-----------------------------------").send(pp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -822,7 +748,7 @@ import java.util.regex.Pattern;
|
|||||||
public void playerRespawn(PlayerRespawnEvent event) {
|
public void playerRespawn(PlayerRespawnEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
EventUtil.manager.doRespawnTask(pp);
|
PlotSquared.get().getEventDispatcher().doRespawnTask(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@ -850,7 +776,8 @@ import java.util.regex.Pattern;
|
|||||||
// to is identical to the plot's home location, and untrusted-visit is true
|
// to is identical to the plot's home location, and untrusted-visit is true
|
||||||
// i.e. untrusted-visit can override deny-teleport
|
// i.e. untrusted-visit can override deny-teleport
|
||||||
// this is acceptable, because otherwise it wouldn't make sense to have both flags set
|
// this is acceptable, because otherwise it wouldn't make sense to have both flags set
|
||||||
if (!result && !(plot.getFlag(UntrustedVisitFlag.class) && plot.getHome().equals(BukkitUtil.getLocationFull(to)))) {
|
if (!result && !(plot.getFlag(UntrustedVisitFlag.class) && plot.getHome()
|
||||||
|
.equals(BukkitUtil.getLocationFull(to)))) {
|
||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||||
Captions.PERMISSION_ADMIN_ENTRY_DENIED);
|
Captions.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -1109,8 +1036,8 @@ import java.util.regex.Pattern;
|
|||||||
}
|
}
|
||||||
if (!spies.isEmpty()) {
|
if (!spies.isEmpty()) {
|
||||||
String spyMessage = Captions.PLOT_CHAT_SPY_FORMAT.getTranslated()
|
String spyMessage = Captions.PLOT_CHAT_SPY_FORMAT.getTranslated()
|
||||||
.replace("%plot_id%", id.x + ";" + id.y)
|
.replace("%plot_id%", id.x + ";" + id.y).replace("%sender%", sender)
|
||||||
.replace("%sender%", sender).replace("%msg%", message);
|
.replace("%msg%", message);
|
||||||
for (Player player : spies) {
|
for (Player player : spies) {
|
||||||
player.sendMessage(spyMessage);
|
player.sendMessage(spyMessage);
|
||||||
}
|
}
|
||||||
@ -1410,8 +1337,19 @@ import java.util.regex.Pattern;
|
|||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (player.getGameMode() != GameMode.SURVIVAL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
|
if (plot.getFlag(InstabreakFlag.class)) {
|
||||||
|
Block block = event.getBlock();
|
||||||
|
BlockBreakEvent call = new BlockBreakEvent(block, player);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(call);
|
||||||
|
if (!call.isCancelled()) {
|
||||||
|
event.getBlock().breakNaturally();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (location.getY() == 0) {
|
if (location.getY() == 0) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -1429,7 +1367,9 @@ import java.util.regex.Pattern;
|
|||||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||||
List<BlockTypeWrapper> destroy = plot.getFlag(BreakFlag.class);
|
List<BlockTypeWrapper> destroy = plot.getFlag(BreakFlag.class);
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
if (destroy.contains(BlockTypeWrapper.get(BukkitAdapter.asBlockType(block.getType()))) || Permissions
|
if (destroy
|
||||||
|
.contains(BlockTypeWrapper.get(BukkitAdapter.asBlockType(block.getType())))
|
||||||
|
|| Permissions
|
||||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1522,14 +1462,14 @@ import java.util.regex.Pattern;
|
|||||||
v
|
v
|
||||||
<-----O-----> x
|
<-----O-----> x
|
||||||
*/
|
*/
|
||||||
if (BukkitUtil.getPlot(location.clone().add(-1, 0, 1) /* A */ ) != null ||
|
if (BukkitUtil.getPlot(location.clone().add(-1, 0, 1) /* A */) != null
|
||||||
BukkitUtil.getPlot(location.clone().add(1, 0, 0) /* B */ ) != null ||
|
|| BukkitUtil.getPlot(location.clone().add(1, 0, 0) /* B */) != null
|
||||||
BukkitUtil.getPlot(location.clone().add(1, 0, 1) /* C */ ) != null ||
|
|| BukkitUtil.getPlot(location.clone().add(1, 0, 1) /* C */) != null
|
||||||
BukkitUtil.getPlot(location.clone().add(-1, 0, 0) /* D */ ) != null ||
|
|| BukkitUtil.getPlot(location.clone().add(-1, 0, 0) /* D */) != null
|
||||||
BukkitUtil.getPlot(location.clone().add(1, 0, 0) /* E */ ) != null ||
|
|| BukkitUtil.getPlot(location.clone().add(1, 0, 0) /* E */) != null
|
||||||
BukkitUtil.getPlot(location.clone().add(-1, 0, -1) /* F */ ) != null ||
|
|| BukkitUtil.getPlot(location.clone().add(-1, 0, -1) /* F */) != null
|
||||||
BukkitUtil.getPlot(location.clone().add(0, 0, -1) /* G */ ) != null ||
|
|| BukkitUtil.getPlot(location.clone().add(0, 0, -1) /* G */) != null
|
||||||
BukkitUtil.getPlot(location.clone().add(1, 0, 1) /* H */ ) != null) {
|
|| BukkitUtil.getPlot(location.clone().add(1, 0, 1) /* H */) != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1886,14 +1826,14 @@ import java.util.regex.Pattern;
|
|||||||
PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
|
PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
|
||||||
MainUtil
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.road");
|
||||||
.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.road");
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
||||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||||
|
Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1975,8 +1915,9 @@ import java.util.regex.Pattern;
|
|||||||
Block block = player.getTargetBlockExact(5, FluidCollisionMode.SOURCE_ONLY);
|
Block block = player.getTargetBlockExact(5, FluidCollisionMode.SOURCE_ONLY);
|
||||||
if (block != null && block.getType() != Material.AIR) {
|
if (block != null && block.getType() != Material.AIR) {
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||||
if (!EventUtil.manager
|
if (!PlotSquared.get().getEventDispatcher()
|
||||||
.checkPlayerBlockEvent(pp, PlayerBlockEventType.SPAWN_MOB, location, null, true)) {
|
.checkPlayerBlockEvent(pp, PlayerBlockEventType.SPAWN_MOB, location, null,
|
||||||
|
true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.setUseItemInHand(Event.Result.DENY);
|
event.setUseItemInHand(Event.Result.DENY);
|
||||||
}
|
}
|
||||||
@ -1998,7 +1939,8 @@ import java.util.regex.Pattern;
|
|||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||||
Action action = event.getAction();
|
Action action = event.getAction();
|
||||||
outer: switch (action) {
|
outer:
|
||||||
|
switch (action) {
|
||||||
case PHYSICAL: {
|
case PHYSICAL: {
|
||||||
eventType = PlayerBlockEventType.TRIGGER_PHYSICAL;
|
eventType = PlayerBlockEventType.TRIGGER_PHYSICAL;
|
||||||
blocktype1 = BukkitAdapter.asBlockType(block.getType());
|
blocktype1 = BukkitAdapter.asBlockType(block.getType());
|
||||||
@ -2105,11 +2047,13 @@ import java.util.regex.Pattern;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) {
|
if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) {
|
||||||
if (event.getMaterial() == Material.getMaterial(PlotSquared.get().worldedit.getConfiguration().wandItem)) {
|
if (event.getMaterial() == Material
|
||||||
|
.getMaterial(PlotSquared.get().worldedit.getConfiguration().wandItem)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EventUtil.manager.checkPlayerBlockEvent(pp, eventType, location, blocktype1, true)) {
|
if (!PlotSquared.get().getEventDispatcher()
|
||||||
|
.checkPlayerBlockEvent(pp, eventType, location, blocktype1, true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.setUseInteractedBlock(Event.Result.DENY);
|
event.setUseInteractedBlock(Event.Result.DENY);
|
||||||
}
|
}
|
||||||
@ -2308,12 +2252,11 @@ import java.util.regex.Pattern;
|
|||||||
Block ignitingBlock = event.getIgnitingBlock();
|
Block ignitingBlock = event.getIgnitingBlock();
|
||||||
Plot plotIgnited = BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot();
|
Plot plotIgnited = BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot();
|
||||||
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && (
|
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && (
|
||||||
!plot.getFlag(BlockIgnitionFlag.class) || plotIgnited == null
|
!plot.getFlag(BlockIgnitionFlag.class) || plotIgnited == null || !plotIgnited
|
||||||
|| !plotIgnited.equals(plot)) ||
|
.equals(plot)) || (igniteCause == BlockIgniteEvent.IgniteCause.SPREAD
|
||||||
(igniteCause == BlockIgniteEvent.IgniteCause.SPREAD
|
|
||||||
|| igniteCause == BlockIgniteEvent.IgniteCause.LAVA) && (
|
|| igniteCause == BlockIgniteEvent.IgniteCause.LAVA) && (
|
||||||
!plot.getFlag(BlockIgnitionFlag.class) || plotIgnited == null
|
!plot.getFlag(BlockIgnitionFlag.class) || plotIgnited == null || !plotIgnited
|
||||||
|| !plotIgnited.equals(plot))) {
|
.equals(plot))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2602,8 +2545,8 @@ import java.util.regex.Pattern;
|
|||||||
if (entity instanceof Animals && plot.getFlag(AnimalInteractFlag.class)) {
|
if (entity instanceof Animals && plot.getFlag(AnimalInteractFlag.class)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (entity instanceof Tameable && ((Tameable) entity).isTamed() && plot.getFlag(
|
if (entity instanceof Tameable && ((Tameable) entity).isTamed() && plot
|
||||||
TamedInteractFlag.class)) {
|
.getFlag(TamedInteractFlag.class)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (entity instanceof Vehicle && plot.getFlag(VehicleUseFlag.class)) {
|
if (entity instanceof Vehicle && plot.getFlag(VehicleUseFlag.class)) {
|
||||||
@ -2824,8 +2767,10 @@ import java.util.regex.Pattern;
|
|||||||
if (plot != null && (plot.getFlag(HangingBreakFlag.class)) || plot
|
if (plot != null && (plot.getFlag(HangingBreakFlag.class)) || plot
|
||||||
.isAdded(plotPlayer.getUUID())) {
|
.isAdded(plotPlayer.getUUID())) {
|
||||||
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
||||||
if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
if (!Permissions
|
||||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||||
|
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||||
|
Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2848,8 +2793,8 @@ import java.util.regex.Pattern;
|
|||||||
}
|
}
|
||||||
} else if (victim instanceof Monster
|
} else if (victim instanceof Monster
|
||||||
|| victim instanceof EnderDragon) { // victim is monster
|
|| victim instanceof EnderDragon) { // victim is monster
|
||||||
if (plot != null && (plot.getFlag(HostileAttackFlag.class) || plot.getFlag(PveFlag.class) ||
|
if (plot != null && (plot.getFlag(HostileAttackFlag.class) || plot
|
||||||
plot.isAdded(plotPlayer.getUUID()))) {
|
.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID()))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||||
@ -2858,8 +2803,8 @@ import java.util.regex.Pattern;
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (victim instanceof Tameable) { // victim is tameable
|
} else if (victim instanceof Tameable) { // victim is tameable
|
||||||
if (plot != null && (plot.getFlag(TamedAttackFlag.class) || plot.getFlag(PveFlag.class) ||
|
if (plot != null && (plot.getFlag(TamedAttackFlag.class) || plot
|
||||||
plot.isAdded(plotPlayer.getUUID()))) {
|
.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID()))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||||
@ -2884,8 +2829,8 @@ import java.util.regex.Pattern;
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (victim instanceof Creature) { // victim is animal
|
} else if (victim instanceof Creature) { // victim is animal
|
||||||
if (plot != null && (plot.getFlag(AnimalAttackFlag.class) || plot.getFlag(PveFlag.class)
|
if (plot != null && (plot.getFlag(AnimalAttackFlag.class) || plot
|
||||||
|| plot.isAdded(plotPlayer.getUUID()))) {
|
.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID()))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||||
@ -2981,7 +2926,8 @@ import java.util.regex.Pattern;
|
|||||||
List<BlockTypeWrapper> place = plot.getFlag(PlaceFlag.class);
|
List<BlockTypeWrapper> place = plot.getFlag(PlaceFlag.class);
|
||||||
if (place != null) {
|
if (place != null) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
if (place.contains(BlockTypeWrapper.get(BukkitAdapter.asBlockType(block.getType())))) {
|
if (place.contains(
|
||||||
|
BlockTypeWrapper.get(BukkitAdapter.asBlockType(block.getType())))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3010,5 +2956,49 @@ import java.util.regex.Pattern;
|
|||||||
Captions.PERMISSION_ADMIN_BUILD_ROAD);
|
Captions.PERMISSION_ADMIN_BUILD_ROAD);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH) public void onDamage(EntityDamageEvent event) {
|
||||||
|
if (event.getEntityType() != EntityType.PLAYER) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Plot plot = BukkitUtil.getLocation(event.getEntity()).getOwnedPlot();
|
||||||
|
if (plot == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (plot.getFlag(InvincibleFlag.class)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler public void onItemDrop(PlayerDropItemEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
|
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||||
|
if (plot == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UUID uuid = pp.getUUID();
|
||||||
|
if (!plot.isAdded(uuid)) {
|
||||||
|
if (!plot.getFlag(ItemDropFlag.class)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler public void onItemPickup(EntityPickupItemEvent event) {
|
||||||
|
LivingEntity ent = event.getEntity();
|
||||||
|
if (ent instanceof Player) {
|
||||||
|
Player player = (Player) ent;
|
||||||
|
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
|
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||||
|
if (plot == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UUID uuid = pp.getUUID();
|
||||||
|
if (!plot.isAdded(uuid) && plot.getFlag(DropProtectionFlag.class)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,195 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.listeners;
|
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerEnterPlotEvent;
|
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerLeavePlotEvent;
|
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DropProtectionFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.FeedFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HealFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.InstabreakFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.InvincibleFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.ItemDropFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.types.TimedFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.block.BlockDamageEvent;
|
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
|
||||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused") public class PlotPlusListener extends PlotListener implements Listener {
|
|
||||||
|
|
||||||
private static final HashMap<UUID, Interval> feedRunnable = new HashMap<>();
|
|
||||||
private static final HashMap<UUID, Interval> healRunnable = new HashMap<>();
|
|
||||||
|
|
||||||
public static void startRunnable(JavaPlugin plugin) {
|
|
||||||
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
|
||||||
if (!healRunnable.isEmpty()) {
|
|
||||||
for (Iterator<Entry<UUID, Interval>> iterator =
|
|
||||||
healRunnable.entrySet().iterator(); iterator.hasNext(); ) {
|
|
||||||
Entry<UUID, Interval> entry = iterator.next();
|
|
||||||
Interval value = entry.getValue();
|
|
||||||
++value.count;
|
|
||||||
if (value.count == value.interval) {
|
|
||||||
value.count = 0;
|
|
||||||
Player player = Bukkit.getPlayer(entry.getKey());
|
|
||||||
if (player == null) {
|
|
||||||
iterator.remove();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
double level = player.getHealth();
|
|
||||||
if (level != value.max) {
|
|
||||||
player.setHealth(Math.min(level + value.amount, value.max));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!feedRunnable.isEmpty()) {
|
|
||||||
for (Iterator<Entry<UUID, Interval>> iterator =
|
|
||||||
feedRunnable.entrySet().iterator(); iterator.hasNext(); ) {
|
|
||||||
Entry<UUID, Interval> entry = iterator.next();
|
|
||||||
Interval value = entry.getValue();
|
|
||||||
++value.count;
|
|
||||||
if (value.count == value.interval) {
|
|
||||||
value.count = 0;
|
|
||||||
Player player = Bukkit.getPlayer(entry.getKey());
|
|
||||||
if (player == null) {
|
|
||||||
iterator.remove();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
int level = player.getFoodLevel();
|
|
||||||
if (level != value.max) {
|
|
||||||
player.setFoodLevel(Math.min(level + value.amount, value.max));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 0L, 20L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH) public void onInteract(BlockDamageEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (player.getGameMode() != GameMode.SURVIVAL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
|
||||||
if (plot == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (plot.getFlag(InstabreakFlag.class)) {
|
|
||||||
Block block = event.getBlock();
|
|
||||||
BlockBreakEvent call = new BlockBreakEvent(block, player);
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(call);
|
|
||||||
if (!call.isCancelled()) {
|
|
||||||
event.getBlock().breakNaturally();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH) public void onDamage(EntityDamageEvent event) {
|
|
||||||
if (event.getEntityType() != EntityType.PLAYER) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Plot plot = BukkitUtil.getLocation(event.getEntity()).getOwnedPlot();
|
|
||||||
if (plot == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (plot.getFlag(InvincibleFlag.class)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler public void onItemDrop(PlayerDropItemEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
|
||||||
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
|
||||||
if (plot == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
UUID uuid = pp.getUUID();
|
|
||||||
if (!plot.isAdded(uuid)) {
|
|
||||||
if (!plot.getFlag(ItemDropFlag.class)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler public void onPlotEnter(PlayerEnterPlotEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
Plot plot = event.getPlot();
|
|
||||||
TimedFlag.Timed<Integer> feed = plot.getFlag(FeedFlag.class);
|
|
||||||
if (feed.getInterval() != 0 && feed.getValue() != 0) {
|
|
||||||
feedRunnable.put(player.getUniqueId(), new Interval(feed.getInterval(), feed.getValue(), 20));
|
|
||||||
}
|
|
||||||
TimedFlag.Timed<Integer> heal = plot.getFlag(HealFlag.class);
|
|
||||||
if (heal.getInterval() != 0 && heal.getValue() != 0) {
|
|
||||||
healRunnable.put(player.getUniqueId(), new Interval(heal.getInterval(), heal.getValue(), 20));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler public void onPlayerQuit(PlayerQuitEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
feedRunnable.remove(player.getUniqueId());
|
|
||||||
healRunnable.remove(player.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler public void onPlotLeave(PlayerLeavePlotEvent event) {
|
|
||||||
Player leaver = event.getPlayer();
|
|
||||||
Plot plot = event.getPlot();
|
|
||||||
if (!plot.hasOwner()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BukkitUtil.getPlayer(leaver);
|
|
||||||
feedRunnable.remove(leaver.getUniqueId());
|
|
||||||
healRunnable.remove(leaver.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler public void onItemPickup(EntityPickupItemEvent event) {
|
|
||||||
LivingEntity ent = event.getEntity();
|
|
||||||
if (ent instanceof Player) {
|
|
||||||
Player player = (Player) ent;
|
|
||||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
|
||||||
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
|
||||||
if (plot == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
UUID uuid = pp.getUUID();
|
|
||||||
if (!plot.isAdded(uuid) && plot.getFlag(DropProtectionFlag.class)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Interval {
|
|
||||||
|
|
||||||
final int interval;
|
|
||||||
final int amount;
|
|
||||||
final int max;
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
Interval(int interval, int amount, int max) {
|
|
||||||
this.interval = interval;
|
|
||||||
this.amount = amount;
|
|
||||||
this.max = max;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.object;
|
package com.github.intellectualsites.plotsquared.bukkit.object;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitEventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
|
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
@ -8,7 +7,6 @@ import com.github.intellectualsites.plotsquared.plot.object.Location;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.TeleportCause;
|
import com.github.intellectualsites.plotsquared.plot.object.TeleportCause;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
@ -204,7 +202,7 @@ public class BukkitPlayer extends PlotPlayer {
|
|||||||
}
|
}
|
||||||
final org.bukkit.Location bukkitLocation = new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX() + 0.5,
|
final org.bukkit.Location bukkitLocation = new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX() + 0.5,
|
||||||
location.getY(), location.getZ() + 0.5, location.getYaw(), location.getPitch());
|
location.getY(), location.getZ() + 0.5, location.getYaw(), location.getPitch());
|
||||||
PaperLib.teleportAsync(player, bukkitLocation, ((BukkitEventUtil) EventUtil.manager).getTeleportCause(cause));
|
PaperLib.teleportAsync(player, bukkitLocation, getTeleportCause(cause));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String getName() {
|
@Override public String getName() {
|
||||||
@ -313,4 +311,15 @@ public class BukkitPlayer extends PlotPlayer {
|
|||||||
@Override public boolean isBanned() {
|
@Override public boolean isBanned() {
|
||||||
return this.player.isBanned();
|
return this.player.isBanned();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public PlayerTeleportEvent.TeleportCause getTeleportCause(@NotNull final TeleportCause cause) {
|
||||||
|
switch (cause) {
|
||||||
|
case COMMAND:
|
||||||
|
return PlayerTeleportEvent.TeleportCause.COMMAND;
|
||||||
|
case PLUGIN:
|
||||||
|
return PlayerTeleportEvent.TeleportCause.PLUGIN;
|
||||||
|
default: return PlayerTeleportEvent.TeleportCause.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,145 +0,0 @@
|
|||||||
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.object.BukkitPlayer;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Rating;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.TeleportCause;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility class for handling Bukkit Events.
|
|
||||||
*/
|
|
||||||
public final class BukkitEventUtil extends EventUtil {
|
|
||||||
|
|
||||||
@Nullable public Player getPlayer(final PlotPlayer player) {
|
|
||||||
if (player instanceof BukkitPlayer) {
|
|
||||||
return ((BukkitPlayer) player).player;
|
|
||||||
}
|
|
||||||
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(PlotFlag<?, ?> flag, Plot plot) {
|
|
||||||
return callEvent(new PlotFlagAddEvent(flag, plot));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean callFlagRemove(PlotFlag<?, ?> 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerTeleportEvent.TeleportCause getTeleportCause(@NotNull final TeleportCause cause) {
|
|
||||||
switch (cause) {
|
|
||||||
case COMMAND:
|
|
||||||
return PlayerTeleportEvent.TeleportCause.COMMAND;
|
|
||||||
case PLUGIN:
|
|
||||||
return PlayerTeleportEvent.TeleportCause.PLUGIN;
|
|
||||||
default: return PlayerTeleportEvent.TeleportCause.UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -42,10 +42,13 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "WeakerAccess"}) public class BukkitUtil extends WorldUtil {
|
|
||||||
|
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||||
|
public class BukkitUtil extends WorldUtil {
|
||||||
|
|
||||||
private static Method biomeSetter;
|
private static Method biomeSetter;
|
||||||
static {
|
static {
|
||||||
@ -138,6 +141,18 @@ import java.util.Set;
|
|||||||
return PlotPlayer.wrap(player);
|
return PlotPlayer.wrap(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the PlotPlayer for a UUID. The PlotPlayer is usually cached and
|
||||||
|
* will provide useful functions relating to players.
|
||||||
|
*
|
||||||
|
* @param uuid the uuid to wrap
|
||||||
|
* @return a {@code PlotPlayer}
|
||||||
|
* @see PlotPlayer#wrap(Object)
|
||||||
|
*/
|
||||||
|
@Override public PlotPlayer wrapPlayer(UUID uuid) {
|
||||||
|
return PlotPlayer.wrap(Bukkit.getOfflinePlayer(uuid));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of plots, which the player is able to build in.
|
* Gets the number of plots, which the player is able to build in.
|
||||||
*
|
*
|
||||||
@ -232,8 +247,8 @@ import java.util.Set;
|
|||||||
|
|
||||||
public static Location getLocationFull(@NonNull final org.bukkit.Location location) {
|
public static Location getLocationFull(@NonNull final org.bukkit.Location location) {
|
||||||
return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()),
|
return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()),
|
||||||
MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()),
|
MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(),
|
||||||
location.getYaw(), location.getPitch());
|
location.getPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static org.bukkit.Location getLocation(@NonNull final Location location) {
|
public static org.bukkit.Location getLocation(@NonNull final Location location) {
|
||||||
@ -315,7 +330,8 @@ import java.util.Set;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override @Nullable public String[] getSign(@NonNull final Location location) {
|
@Override @Nullable public String[] getSign(@NonNull final Location location) {
|
||||||
Block block = getWorld(location.getWorld()).getBlockAt(location.getX(), location.getY(), location.getZ());
|
Block block = getWorld(location.getWorld())
|
||||||
|
.getBlockAt(location.getX(), location.getY(), location.getZ());
|
||||||
return TaskManager.IMP.sync(new RunnableVal<String[]>() {
|
return TaskManager.IMP.sync(new RunnableVal<String[]>() {
|
||||||
@Override public void run(String[] value) {
|
@Override public void run(String[] value) {
|
||||||
if (block.getState() instanceof Sign) {
|
if (block.getState() instanceof Sign) {
|
||||||
@ -395,7 +411,8 @@ import java.util.Set;
|
|||||||
Inventory inv = holder.getInventory();
|
Inventory inv = holder.getInventory();
|
||||||
for (int i = 0; i < items.types.length; i++) {
|
for (int i = 0; i < items.types.length; i++) {
|
||||||
// ItemStack item = new ItemStack(LegacyMappings.fromLegacyId(items.id[i]).getMaterial(), items.amount[i], items.data[i]);
|
// ItemStack item = new ItemStack(LegacyMappings.fromLegacyId(items.id[i]).getMaterial(), items.amount[i], items.data[i]);
|
||||||
ItemStack item = new ItemStack(BukkitAdapter.adapt(items.types[i]), items.amount[i]);
|
ItemStack item =
|
||||||
|
new ItemStack(BukkitAdapter.adapt(items.types[i]), items.amount[i]);
|
||||||
inv.addItem(item);
|
inv.addItem(item);
|
||||||
}
|
}
|
||||||
state.update(true);
|
state.update(true);
|
||||||
@ -432,7 +449,8 @@ import java.util.Set;
|
|||||||
}
|
}
|
||||||
final Biome biome = BukkitAdapter.adapt(biomeType);
|
final Biome biome = BukkitAdapter.adapt(biomeType);
|
||||||
for (int x = region.getMinimumPoint().getX(); x <= region.getMaximumPoint().getX(); x++) {
|
for (int x = region.getMinimumPoint().getX(); x <= region.getMaximumPoint().getX(); x++) {
|
||||||
for (int z = region.getMinimumPoint().getZ(); z <= region.getMaximumPoint().getZ(); z++) {
|
for (int z = region.getMinimumPoint().getZ();
|
||||||
|
z <= region.getMaximumPoint().getZ(); z++) {
|
||||||
for (int y = 0; y < world.getMaxHeight(); y++) {
|
for (int y = 0; y < world.getMaxHeight(); y++) {
|
||||||
try {
|
try {
|
||||||
if (biomeSetter != null) {
|
if (biomeSetter != null) {
|
||||||
@ -462,4 +480,20 @@ import java.util.Set;
|
|||||||
@Override public String getMainWorld() {
|
@Override public String getMainWorld() {
|
||||||
return Bukkit.getWorlds().get(0).getName();
|
return Bukkit.getWorlds().get(0).getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public double getHealth(PlotPlayer player) {
|
||||||
|
return Bukkit.getPlayer(player.getUUID()).getHealth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int getFoodLevel(PlotPlayer player) {
|
||||||
|
return Bukkit.getPlayer(player.getUUID()).getFoodLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void setHealth(PlotPlayer player, double health) {
|
||||||
|
Bukkit.getPlayer(player.getUUID()).setHealth(health);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void setFoodLevel(PlotPlayer player, int foodLevel) {
|
||||||
|
Bukkit.getPlayer(player.getUUID()).setFoodLevel(foodLevel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,7 @@ import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
||||||
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
|
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@ -201,4 +198,14 @@ import java.util.UUID;
|
|||||||
public PlotPlayer wrapPlayer(String player) {
|
public PlotPlayer wrapPlayer(String player) {
|
||||||
return PlotPlayer.wrap(player);
|
return PlotPlayer.wrap(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a listener for PlotSquared Events
|
||||||
|
*
|
||||||
|
* @param listener the listener class to register
|
||||||
|
* @see EventDispatcher#registerListener(Object)
|
||||||
|
*/
|
||||||
|
public void registerListener(Object listener) {
|
||||||
|
PlotSquared.get().getEventDispatcher().registerListener(listener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.ChatManager;
|
import com.github.intellectualsites.plotsquared.plot.util.ChatManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.InventoryUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.InventoryUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
||||||
@ -130,11 +129,6 @@ public interface IPlotMain extends ILogger {
|
|||||||
*/
|
*/
|
||||||
void registerPlayerEvents();
|
void registerPlayerEvents();
|
||||||
|
|
||||||
/**
|
|
||||||
* Register plot plus related events.
|
|
||||||
*/
|
|
||||||
void registerPlotPlusEvents();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register force field events.
|
* Register force field events.
|
||||||
*/
|
*/
|
||||||
@ -162,11 +156,6 @@ public interface IPlotMain extends ILogger {
|
|||||||
*/
|
*/
|
||||||
WorldUtil initWorldUtil();
|
WorldUtil initWorldUtil();
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the EventUtil class.
|
|
||||||
*/
|
|
||||||
EventUtil initEventUtil();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the chunk manager.
|
* Gets the chunk manager.
|
||||||
*
|
*
|
||||||
|
@ -41,7 +41,7 @@ import com.github.intellectualsites.plotsquared.plot.util.ChatManager;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.CommentManager;
|
import com.github.intellectualsites.plotsquared.plot.util.CommentManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.EventDispatcher;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.InventoryUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.InventoryUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.LegacyConverter;
|
import com.github.intellectualsites.plotsquared.plot.util.LegacyConverter;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
@ -73,8 +73,6 @@ import java.io.InputStreamReader;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -82,7 +80,6 @@ import java.util.Arrays;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -132,6 +129,7 @@ import java.util.zip.ZipInputStream;
|
|||||||
@Getter private File jarFile = null; // This file
|
@Getter private File jarFile = null; // This file
|
||||||
private File storageFile;
|
private File storageFile;
|
||||||
@Getter private PlotAreaManager plotAreaManager;
|
@Getter private PlotAreaManager plotAreaManager;
|
||||||
|
@Getter private EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize PlotSquared with the desired Implementation class.
|
* Initialize PlotSquared with the desired Implementation class.
|
||||||
@ -215,7 +213,6 @@ import java.util.zip.ZipInputStream;
|
|||||||
}
|
}
|
||||||
if (Settings.Enabled_Components.EVENTS) {
|
if (Settings.Enabled_Components.EVENTS) {
|
||||||
this.IMP.registerPlayerEvents();
|
this.IMP.registerPlayerEvents();
|
||||||
this.IMP.registerPlotPlusEvents();
|
|
||||||
}
|
}
|
||||||
// Required
|
// Required
|
||||||
this.IMP.registerWorldEvents();
|
this.IMP.registerWorldEvents();
|
||||||
@ -231,8 +228,8 @@ import java.util.zip.ZipInputStream;
|
|||||||
UUIDHandler.add(new StringWrapper("*"), DBFunc.EVERYONE);
|
UUIDHandler.add(new StringWrapper("*"), DBFunc.EVERYONE);
|
||||||
startExpiryTasks();
|
startExpiryTasks();
|
||||||
}
|
}
|
||||||
// create event util class
|
// Create Event utility class
|
||||||
EventUtil.manager = this.IMP.initEventUtil();
|
eventDispatcher = new EventDispatcher();
|
||||||
// create Hybrid utility class
|
// create Hybrid utility class
|
||||||
HybridUtils.manager = this.IMP.initHybridUtils();
|
HybridUtils.manager = this.IMP.initHybridUtils();
|
||||||
// Inventory utility class
|
// Inventory utility class
|
||||||
@ -1053,7 +1050,7 @@ import java.util.zip.ZipInputStream;
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (callEvent) {
|
if (callEvent) {
|
||||||
EventUtil.manager.callDelete(plot);
|
eventDispatcher.callDelete(plot);
|
||||||
}
|
}
|
||||||
if (plot.getArea().removePlot(plot.getId())) {
|
if (plot.getArea().removePlot(plot.getId())) {
|
||||||
PlotId last = (PlotId) plot.getArea().getMeta("lastPlot");
|
PlotId last = (PlotId) plot.getArea().getMeta("lastPlot");
|
||||||
@ -1527,6 +1524,7 @@ import java.util.zip.ZipInputStream;
|
|||||||
*/
|
*/
|
||||||
public void disable() {
|
public void disable() {
|
||||||
try {
|
try {
|
||||||
|
eventDispatcher.unregisterAll();
|
||||||
// Validate that all data in the db is correct
|
// Validate that all data in the db is correct
|
||||||
final HashSet<Plot> plots = new HashSet<>();
|
final HashSet<Plot> plots = new HashSet<>();
|
||||||
try {
|
try {
|
||||||
|
@ -2,13 +2,13 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ public class Add extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
plot.addMember(uuid);
|
plot.addMember(uuid);
|
||||||
EventUtil.manager.callMember(player, plot, uuid, true);
|
PlotSquared.get().getEventDispatcher().callMember(player, plot, uuid, true);
|
||||||
MainUtil.sendMessage(player, Captions.MEMBER_ADDED);
|
MainUtil.sendMessage(player, Captions.MEMBER_ADDED);
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
|
@ -6,6 +6,10 @@ import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlayerAutoPlotEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotAutoMergeEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotMergeEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Direction;
|
import com.github.intellectualsites.plotsquared.plot.object.Direction;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Expression;
|
import com.github.intellectualsites.plotsquared.plot.object.Expression;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
@ -21,6 +25,7 @@ import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
|||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@CommandDeclaration(command = "auto",
|
@CommandDeclaration(command = "auto",
|
||||||
@ -125,12 +130,21 @@ public class Auto extends SubCommand {
|
|||||||
player.deleteMeta(Auto.class.getName());
|
player.deleteMeta(Auto.class.getName());
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
MainUtil.sendMessage(player, Captions.NO_FREE_PLOTS);
|
MainUtil.sendMessage(player, Captions.NO_FREE_PLOTS);
|
||||||
} else if (checkAllowedPlots(player, area, allowedPlots, 1, 1)) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkAllowedPlots(player, area, allowedPlots, 1, 1)) {
|
||||||
plot.claim(player, true, schematic, false);
|
plot.claim(player, true, schematic, false);
|
||||||
if (area.AUTO_MERGE) {
|
if (area.AUTO_MERGE) {
|
||||||
plot.autoMerge(Direction.ALL, Integer.MAX_VALUE, player.getUUID(),
|
PlotMergeEvent event = PlotSquared.get().getEventDispatcher()
|
||||||
|
.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player);
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Auto merge");
|
||||||
|
} else {
|
||||||
|
plot.autoMerge(event.getDir(), event.getMax(), player.getUUID(),
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
DBFunc.delete(plot);
|
DBFunc.delete(plot);
|
||||||
}
|
}
|
||||||
@ -176,17 +190,22 @@ public class Auto extends SubCommand {
|
|||||||
int size_x = 1;
|
int size_x = 1;
|
||||||
int size_z = 1;
|
int size_z = 1;
|
||||||
String schematic = null;
|
String schematic = null;
|
||||||
|
boolean mega = false;
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
if (Permissions.hasPermission(player, Captions.PERMISSION_AUTO_MEGA)) {
|
|
||||||
try {
|
try {
|
||||||
String[] split = args[0].split(",|;");
|
String[] split = args[0].split(",|;");
|
||||||
if (split[1] == null) {
|
switch (split.length) {
|
||||||
MainUtil.sendMessage(player, "Correct use /plot auto [length,width]");
|
case 1:
|
||||||
size_x = 1;
|
size_x = 1;
|
||||||
size_z = 1;
|
size_z = 1;
|
||||||
} else {
|
break;
|
||||||
|
case 2:
|
||||||
size_x = Integer.parseInt(split[0]);
|
size_x = Integer.parseInt(split[0]);
|
||||||
size_z = Integer.parseInt(split[1]);
|
size_z = Integer.parseInt(split[1]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
MainUtil.sendMessage(player, "Correct use /plot auto [length,width]");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (size_x < 1 || size_z < 1) {
|
if (size_x < 1 || size_z < 1) {
|
||||||
MainUtil.sendMessage(player, "Error: size<=0");
|
MainUtil.sendMessage(player, "Error: size<=0");
|
||||||
@ -194,6 +213,7 @@ public class Auto extends SubCommand {
|
|||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
schematic = args[1];
|
schematic = args[1];
|
||||||
}
|
}
|
||||||
|
mega = true;
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
size_x = 1;
|
size_x = 1;
|
||||||
size_z = 1;
|
size_z = 1;
|
||||||
@ -202,20 +222,29 @@ public class Auto extends SubCommand {
|
|||||||
// "&cError: Invalid size (X,Y)");
|
// "&cError: Invalid size (X,Y)");
|
||||||
// return false;
|
// return false;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
schematic = args[0];
|
|
||||||
// PlayerFunctions.sendMessage(plr, Captions.NO_PERMISSION);
|
|
||||||
// return false;
|
|
||||||
}
|
}
|
||||||
|
PlayerAutoPlotEvent event = PlotSquared.get().getEventDispatcher()
|
||||||
|
.callAuto(player, plotarea, schematic, size_x, size_z);
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Auto claim");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (size_x * size_z > Settings.Claim.MAX_AUTO_AREA) {
|
boolean force = event.getEventResult() == Result.FORCE;
|
||||||
|
size_x = event.getSize_x();
|
||||||
|
size_z = event.getSize_z();
|
||||||
|
schematic = event.getSchematic();
|
||||||
|
if (!force && mega && !Permissions.hasPermission(player, Captions.PERMISSION_AUTO_MEGA)) {
|
||||||
|
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||||
|
CaptionUtility.format(player, Captions.PERMISSION_AUTO_MEGA));
|
||||||
|
}
|
||||||
|
if (!force && size_x * size_z > Settings.Claim.MAX_AUTO_AREA) {
|
||||||
MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS_NUM,
|
MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS_NUM,
|
||||||
Settings.Claim.MAX_AUTO_AREA + "");
|
Settings.Claim.MAX_AUTO_AREA + "");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final int allowed_plots = player.getAllowedPlots();
|
final int allowed_plots = player.getAllowedPlots();
|
||||||
if (player.getMeta(Auto.class.getName(), false) || !checkAllowedPlots(player, plotarea,
|
if (!force && (player.getMeta(Auto.class.getName(), false) || !checkAllowedPlots(player, plotarea,
|
||||||
allowed_plots, size_x, size_z)) {
|
allowed_plots, size_x, size_z))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +253,7 @@ public class Auto extends SubCommand {
|
|||||||
sendMessage(player, Captions.SCHEMATIC_INVALID, "non-existent: " + schematic);
|
sendMessage(player, Captions.SCHEMATIC_INVALID, "non-existent: " + schematic);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(player, CaptionUtility
|
if (!force && !Permissions.hasPermission(player, CaptionUtility
|
||||||
.format(player, Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic))
|
.format(player, Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic))
|
||||||
&& !Permissions
|
&& !Permissions
|
||||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
|
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
|
||||||
@ -241,7 +270,7 @@ public class Auto extends SubCommand {
|
|||||||
player.getPlotCount(plotarea.worldname)));
|
player.getPlotCount(plotarea.worldname)));
|
||||||
cost = (size_x * size_z) * cost;
|
cost = (size_x * size_z) * cost;
|
||||||
if (cost > 0d) {
|
if (cost > 0d) {
|
||||||
if (EconHandler.manager.getMoney(player) < cost) {
|
if (!force && EconHandler.manager.getMoney(player) < cost) {
|
||||||
sendMessage(player, Captions.CANNOT_AFFORD_PLOT, "" + cost);
|
sendMessage(player, Captions.CANNOT_AFFORD_PLOT, "" + cost);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -273,7 +302,15 @@ public class Auto extends SubCommand {
|
|||||||
plot.claim(player, teleport, null);
|
plot.claim(player, teleport, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!plotarea.mergePlots(MainUtil.getPlotSelectionIds(start, end), true)) {
|
ArrayList<PlotId> plotIds = MainUtil.getPlotSelectionIds(start, end);
|
||||||
|
final PlotId pos1 = plotIds.get(0);
|
||||||
|
final PlotAutoMergeEvent mergeEvent = PlotSquared.get().getEventDispatcher()
|
||||||
|
.callAutoMerge(plotarea.getPlotAbs(pos1), plotIds);
|
||||||
|
if (!force && mergeEvent.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Auto merge");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!plotarea.mergePlots(mergeEvent.getPlots(), true)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2,7 +2,11 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotFlagRemoveEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PriceFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PriceFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
@ -60,7 +64,11 @@ public class Buy extends Command {
|
|||||||
if (owner != null) {
|
if (owner != null) {
|
||||||
Captions.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price);
|
Captions.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price);
|
||||||
}
|
}
|
||||||
plot.removeFlag(PriceFlag.class);
|
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(PriceFlag.class);
|
||||||
|
PlotFlagRemoveEvent event = PlotSquared.get().getEventDispatcher().callFlagRemove(plotFlag, plot);
|
||||||
|
if(event.getEventResult() != Result.DENY) {
|
||||||
|
plot.removeFlag(event.getFlag());
|
||||||
|
}
|
||||||
plot.setOwner(player.getUUID());
|
plot.setOwner(player.getUUID());
|
||||||
Captions.CLAIMED.send(player);
|
Captions.CLAIMED.send(player);
|
||||||
whenDone.run(Buy.this, CommandResult.SUCCESS);
|
whenDone.run(Buy.this, CommandResult.SUCCESS);
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
|
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Direction;
|
import com.github.intellectualsites.plotsquared.plot.events.PlayerClaimPlotEvent;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Expression;
|
import com.github.intellectualsites.plotsquared.plot.events.PlotMergeEvent;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
@ -27,7 +25,7 @@ import com.google.common.primitives.Ints;
|
|||||||
public class Claim extends SubCommand {
|
public class Claim extends SubCommand {
|
||||||
|
|
||||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||||
String schematic = "";
|
String schematic = null;
|
||||||
if (args.length >= 1) {
|
if (args.length >= 1) {
|
||||||
schematic = args[0];
|
schematic = args[0];
|
||||||
}
|
}
|
||||||
@ -36,11 +34,18 @@ public class Claim extends SubCommand {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return sendMessage(player, Captions.NOT_IN_PLOT);
|
return sendMessage(player, Captions.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
|
PlayerClaimPlotEvent event = PlotSquared.get().getEventDispatcher().callClaim(player, plot, schematic);
|
||||||
|
schematic = event.getSchematic();
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Claim");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
boolean force = event.getEventResult() == Result.FORCE;
|
||||||
int currentPlots = Settings.Limit.GLOBAL ?
|
int currentPlots = Settings.Limit.GLOBAL ?
|
||||||
player.getPlotCount() :
|
player.getPlotCount() :
|
||||||
player.getPlotCount(location.getWorld());
|
player.getPlotCount(location.getWorld());
|
||||||
int grants = 0;
|
int grants = 0;
|
||||||
if (currentPlots >= player.getAllowedPlots()) {
|
if (currentPlots >= player.getAllowedPlots() && !force) {
|
||||||
if (player.hasPersistentMeta("grantedPlots")) {
|
if (player.hasPersistentMeta("grantedPlots")) {
|
||||||
grants = Ints.fromByteArray(player.getPersistentMeta("grantedPlots"));
|
grants = Ints.fromByteArray(player.getPersistentMeta("grantedPlots"));
|
||||||
if (grants <= 0) {
|
if (grants <= 0) {
|
||||||
@ -55,7 +60,7 @@ public class Claim extends SubCommand {
|
|||||||
return sendMessage(player, Captions.PLOT_IS_CLAIMED);
|
return sendMessage(player, Captions.PLOT_IS_CLAIMED);
|
||||||
}
|
}
|
||||||
final PlotArea area = plot.getArea();
|
final PlotArea area = plot.getArea();
|
||||||
if (!schematic.isEmpty()) {
|
if (schematic != null && !schematic.isEmpty()) {
|
||||||
if (area.SCHEMATIC_CLAIM_SPECIFY) {
|
if (area.SCHEMATIC_CLAIM_SPECIFY) {
|
||||||
if (!area.SCHEMATICS.contains(schematic.toLowerCase())) {
|
if (!area.SCHEMATICS.contains(schematic.toLowerCase())) {
|
||||||
return sendMessage(player, Captions.SCHEMATIC_INVALID,
|
return sendMessage(player, Captions.SCHEMATIC_INVALID,
|
||||||
@ -64,16 +69,12 @@ public class Claim extends SubCommand {
|
|||||||
if (!Permissions.hasPermission(player, CaptionUtility
|
if (!Permissions.hasPermission(player, CaptionUtility
|
||||||
.format(player, Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic))
|
.format(player, Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic))
|
||||||
&& !Permissions
|
&& !Permissions
|
||||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
|
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC) && !force) {
|
||||||
return sendMessage(player, Captions.NO_SCHEMATIC_PERMISSION, schematic);
|
return sendMessage(player, Captions.NO_SCHEMATIC_PERMISSION, schematic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int border = area.getBorder();
|
if ((EconHandler.manager != null) && area.USE_ECONOMY && !force) {
|
||||||
if (border != Integer.MAX_VALUE && plot.getDistanceFromOrigin() > border) {
|
|
||||||
return !sendMessage(player, Captions.BORDER);
|
|
||||||
}
|
|
||||||
if ((EconHandler.manager != null) && area.USE_ECONOMY) {
|
|
||||||
Expression<Double> costExr = area.PRICES.get("claim");
|
Expression<Double> costExr = area.PRICES.get("claim");
|
||||||
double cost = costExr.evaluate((double) currentPlots);
|
double cost = costExr.evaluate((double) currentPlots);
|
||||||
if (cost > 0d) {
|
if (cost > 0d) {
|
||||||
@ -92,21 +93,26 @@ public class Claim extends SubCommand {
|
|||||||
}
|
}
|
||||||
sendMessage(player, Captions.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1));
|
sendMessage(player, Captions.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1));
|
||||||
}
|
}
|
||||||
if (plot.canClaim(player)) {
|
int border = area.getBorder();
|
||||||
|
if (border != Integer.MAX_VALUE && plot.getDistanceFromOrigin() > border && !force) {
|
||||||
|
return !sendMessage(player, Captions.BORDER);
|
||||||
|
}
|
||||||
plot.owner = player.getUUID();
|
plot.owner = player.getUUID();
|
||||||
final String finalSchematic = schematic;
|
final String finalSchematic = schematic;
|
||||||
DBFunc.createPlotSafe(plot, () -> TaskManager.IMP.sync(new RunnableVal<Object>() {
|
DBFunc.createPlotSafe(plot, () -> TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||||
@Override public void run(Object value) {
|
@Override public void run(Object value) {
|
||||||
plot.claim(player, true, finalSchematic, false);
|
plot.claim(player, true, finalSchematic);
|
||||||
if (area.AUTO_MERGE) {
|
if (area.AUTO_MERGE) {
|
||||||
plot.autoMerge(Direction.ALL, Integer.MAX_VALUE, player.getUUID(), true);
|
PlotMergeEvent event = PlotSquared.get().getEventDispatcher()
|
||||||
|
.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player);
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Auto merge on claim");
|
||||||
|
} else {
|
||||||
|
plot.autoMerge(event.getDir(), event.getMax(), player.getUUID(), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}), () -> sendMessage(player, Captions.PLOT_NOT_CLAIMED));
|
}), () -> sendMessage(player, Captions.PLOT_NOT_CLAIMED));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,12 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotFlagRemoveEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnalysisFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnalysisFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
@ -16,6 +20,8 @@ import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue
|
|||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
import static com.github.intellectualsites.plotsquared.plot.commands.SubCommand.sendMessage;
|
||||||
|
|
||||||
@CommandDeclaration(command = "clear",
|
@CommandDeclaration(command = "clear",
|
||||||
description = "Clear the plot you stand on",
|
description = "Clear the plot you stand on",
|
||||||
requiredType = RequiredType.NONE,
|
requiredType = RequiredType.NONE,
|
||||||
@ -38,11 +44,18 @@ public class Clear extends Command {
|
|||||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||||
checkTrue(args.length == 0, Captions.COMMAND_SYNTAX, getUsage());
|
checkTrue(args.length == 0, Captions.COMMAND_SYNTAX, getUsage());
|
||||||
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
|
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
|
||||||
checkTrue(plot.isOwner(player.getUUID()) || Permissions
|
Result eventResult =
|
||||||
|
PlotSquared.get().getEventDispatcher().callClear(plot).getEventResult();
|
||||||
|
if (eventResult == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Clear");
|
||||||
|
return CompletableFuture.completedFuture(true);
|
||||||
|
}
|
||||||
|
boolean force = eventResult == Result.FORCE;
|
||||||
|
checkTrue(force || plot.isOwner(player.getUUID()) || Permissions
|
||||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_CLEAR),
|
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_CLEAR),
|
||||||
Captions.NO_PLOT_PERMS);
|
Captions.NO_PLOT_PERMS);
|
||||||
checkTrue(plot.getRunning() == 0, Captions.WAIT_FOR_TIMER);
|
checkTrue(plot.getRunning() == 0, Captions.WAIT_FOR_TIMER);
|
||||||
checkTrue(!Settings.Done.RESTRICT_BUILDING || !DoneFlag.isDone(plot) || Permissions
|
checkTrue(force || !Settings.Done.RESTRICT_BUILDING || !DoneFlag.isDone(plot) || Permissions
|
||||||
.hasPermission(player, Captions.PERMISSION_CONTINUE), Captions.DONE_ALREADY_DONE);
|
.hasPermission(player, Captions.PERMISSION_CONTINUE), Captions.DONE_ALREADY_DONE);
|
||||||
confirm.run(this, () -> {
|
confirm.run(this, () -> {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
@ -52,10 +65,21 @@ public class Clear extends Command {
|
|||||||
plot.removeRunning();
|
plot.removeRunning();
|
||||||
// If the state changes, then mark it as no longer done
|
// If the state changes, then mark it as no longer done
|
||||||
if (DoneFlag.isDone(plot)) {
|
if (DoneFlag.isDone(plot)) {
|
||||||
plot.removeFlag(DoneFlag.class);
|
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(DoneFlag.class);
|
||||||
|
PlotFlagRemoveEvent event =
|
||||||
|
PlotSquared.get().getEventDispatcher().callFlagRemove(plotFlag, plot);
|
||||||
|
if (event.getEventResult() != Result.DENY) {
|
||||||
|
plot.removeFlag(event.getFlag());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!plot.getFlag(AnalysisFlag.class).isEmpty()) {
|
if (!plot.getFlag(AnalysisFlag.class).isEmpty()) {
|
||||||
plot.removeFlag(AnalysisFlag.class);
|
PlotFlag<?, ?> plotFlag =
|
||||||
|
plot.getFlagContainer().getFlag(AnalysisFlag.class);
|
||||||
|
PlotFlagRemoveEvent event =
|
||||||
|
PlotSquared.get().getEventDispatcher().callFlagRemove(plotFlag, plot);
|
||||||
|
if (event.getEventResult() != Result.DENY) {
|
||||||
|
plot.removeFlag(event.getFlag());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, Captions.CLEARING_DONE,
|
MainUtil.sendMessage(player, Captions.CLEARING_DONE,
|
||||||
"" + (System.currentTimeMillis() - start));
|
"" + (System.currentTimeMillis() - start));
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotFlagRemoveEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
@ -41,7 +45,14 @@ public class Continue extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
plot.removeFlag(DoneFlag.class);
|
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(DoneFlag.class);
|
||||||
|
PlotFlagRemoveEvent event =
|
||||||
|
PlotSquared.get().getEventDispatcher().callFlagRemove(plotFlag, plot);
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Done flag removal");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
plot.removeFlag(event.getFlag());
|
||||||
MainUtil.sendMessage(player, Captions.DONE_REMOVED);
|
MainUtil.sendMessage(player, Captions.DONE_REMOVED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotFlagRemoveEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
|
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
|
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
|
||||||
@ -23,7 +25,6 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
||||||
@ -145,7 +146,7 @@ public class DebugExec extends SubCommand {
|
|||||||
this.scope.put("ChunkManager", ChunkManager.manager);
|
this.scope.put("ChunkManager", ChunkManager.manager);
|
||||||
this.scope.put("BlockManager", WorldUtil.IMP);
|
this.scope.put("BlockManager", WorldUtil.IMP);
|
||||||
this.scope.put("SetupUtils", SetupUtils.manager);
|
this.scope.put("SetupUtils", SetupUtils.manager);
|
||||||
this.scope.put("EventUtil", EventUtil.manager);
|
this.scope.put("EventUtil", PlotSquared.get().getEventDispatcher());
|
||||||
this.scope.put("EconHandler", EconHandler.manager);
|
this.scope.put("EconHandler", EconHandler.manager);
|
||||||
this.scope.put("UUIDHandler", UUIDHandler.implementation);
|
this.scope.put("UUIDHandler", UUIDHandler.implementation);
|
||||||
this.scope.put("DBFunc", DBFunc.dbManager);
|
this.scope.put("DBFunc", DBFunc.dbManager);
|
||||||
@ -226,7 +227,11 @@ public class DebugExec extends SubCommand {
|
|||||||
GlobalFlagContainer.getInstance().getFlagFromString(flag);
|
GlobalFlagContainer.getInstance().getFlagFromString(flag);
|
||||||
if (flagInstance != null) {
|
if (flagInstance != null) {
|
||||||
for (Plot plot : PlotSquared.get().getBasePlots()) {
|
for (Plot plot : PlotSquared.get().getBasePlots()) {
|
||||||
plot.removeFlag(flagInstance);
|
PlotFlagRemoveEvent event = PlotSquared.get().getEventDispatcher()
|
||||||
|
.callFlagRemove(flagInstance, plot);
|
||||||
|
if (event.getEventResult() != Result.DENY) {
|
||||||
|
plot.removeFlag(event.getFlag());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return MainUtil.sendMessage(player, "Cleared flag: " + flag);
|
return MainUtil.sendMessage(player, "Cleared flag: " + flag);
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Expression;
|
import com.github.intellectualsites.plotsquared.plot.object.Expression;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
@ -37,7 +40,13 @@ public class Delete extends SubCommand {
|
|||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
return !sendMessage(player, Captions.PLOT_UNOWNED);
|
return !sendMessage(player, Captions.PLOT_UNOWNED);
|
||||||
}
|
}
|
||||||
if (!plot.isOwner(player.getUUID()) && !Permissions
|
Result eventResult = PlotSquared.get().getEventDispatcher().callDelete(plot).getEventResult();
|
||||||
|
if (eventResult == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Delete");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
boolean force = eventResult == Result.FORCE;
|
||||||
|
if (!force && !plot.isOwner(player.getUUID()) && !Permissions
|
||||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_DELETE)) {
|
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_DELETE)) {
|
||||||
return !sendMessage(player, Captions.NO_PLOT_PERMS);
|
return !sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||||
}
|
}
|
||||||
@ -46,15 +55,13 @@ public class Delete extends SubCommand {
|
|||||||
final int currentPlots = Settings.Limit.GLOBAL ?
|
final int currentPlots = Settings.Limit.GLOBAL ?
|
||||||
player.getPlotCount() :
|
player.getPlotCount() :
|
||||||
player.getPlotCount(location.getWorld());
|
player.getPlotCount(location.getWorld());
|
||||||
Runnable run = new Runnable() {
|
Runnable run = () -> {
|
||||||
@Override public void run() {
|
|
||||||
if (plot.getRunning() > 0) {
|
if (plot.getRunning() > 0) {
|
||||||
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
boolean result = plot.deletePlot(new Runnable() {
|
boolean result = plot.deletePlot(() -> {
|
||||||
@Override public void run() {
|
|
||||||
plot.removeRunning();
|
plot.removeRunning();
|
||||||
if ((EconHandler.manager != null) && plotArea.USE_ECONOMY) {
|
if ((EconHandler.manager != null) && plotArea.USE_ECONOMY) {
|
||||||
Expression<Double> valueExr = plotArea.PRICES.get("sell");
|
Expression<Double> valueExr = plotArea.PRICES.get("sell");
|
||||||
@ -66,14 +73,12 @@ public class Delete extends SubCommand {
|
|||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, Captions.DELETING_DONE,
|
MainUtil.sendMessage(player, Captions.DELETING_DONE,
|
||||||
System.currentTimeMillis() - start);
|
System.currentTimeMillis() - start);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
if (result) {
|
if (result) {
|
||||||
plot.addRunning();
|
plot.addRunning();
|
||||||
} else {
|
} else {
|
||||||
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
if (hasConfirmation(player)) {
|
if (hasConfirmation(player)) {
|
||||||
CmdConfirm.addPending(player, getCommandString() + ' ' + plot.getId(), run);
|
CmdConfirm.addPending(player, getCommandString() + ' ' + plot.getId(), run);
|
||||||
|
@ -8,7 +8,6 @@ import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||||
@ -72,7 +71,7 @@ public class Deny extends SubCommand {
|
|||||||
plot.removeTrusted(uuid);
|
plot.removeTrusted(uuid);
|
||||||
}
|
}
|
||||||
plot.addDenied(uuid);
|
plot.addDenied(uuid);
|
||||||
EventUtil.manager.callDenied(player, plot, uuid, true);
|
PlotSquared.get().getEventDispatcher().callDenied(player, plot, uuid, true);
|
||||||
if (!uuid.equals(DBFunc.EVERYONE)) {
|
if (!uuid.equals(DBFunc.EVERYONE)) {
|
||||||
handleKick(UUIDHandler.getPlayer(uuid), plot);
|
handleKick(UUIDHandler.getPlayer(uuid), plot);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
|
import com.github.intellectualsites.plotsquared.plot.events.PlotFlagAddEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotFlagRemoveEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DescriptionFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DescriptionFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
@ -19,13 +22,23 @@ public class Desc extends SetCommand {
|
|||||||
|
|
||||||
@Override public boolean set(PlotPlayer player, Plot plot, String desc) {
|
@Override public boolean set(PlotPlayer player, Plot plot, String desc) {
|
||||||
if (desc.isEmpty()) {
|
if (desc.isEmpty()) {
|
||||||
plot.removeFlag(DescriptionFlag.class);
|
PlotFlagRemoveEvent event = PlotSquared.get().getEventDispatcher()
|
||||||
|
.callFlagRemove(plot.getFlagContainer().getFlag(DescriptionFlag.class), plot);
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Description removal");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
plot.removeFlag(event.getFlag());
|
||||||
MainUtil.sendMessage(player, Captions.DESC_UNSET);
|
MainUtil.sendMessage(player, Captions.DESC_UNSET);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
boolean result = plot.setFlag(
|
PlotFlagAddEvent event = PlotSquared.get().getEventDispatcher().callFlagAdd(
|
||||||
GlobalFlagContainer.getInstance().getFlag(DescriptionFlag.class)
|
plot.getFlagContainer().getFlag(DescriptionFlag.class).createFlagInstance(desc), plot);
|
||||||
.createFlagInstance(desc));
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Description set");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
boolean result = plot.setFlag(event.getFlag());
|
||||||
if (!result) {
|
if (!result) {
|
||||||
MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
|
MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotDoneEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotFlagAddEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
|
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
@ -28,7 +33,13 @@ public class Done extends SubCommand {
|
|||||||
if ((plot == null) || !plot.hasOwner()) {
|
if ((plot == null) || !plot.hasOwner()) {
|
||||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
if (!plot.isOwner(player.getUUID()) && !Permissions
|
PlotDoneEvent event = PlotSquared.get().getEventDispatcher().callDone(plot);
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Done");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
boolean force = event.getEventResult() == Result.FORCE;
|
||||||
|
if (!force && !plot.isOwner(player.getUUID()) && !Permissions
|
||||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_DONE)) {
|
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_DONE)) {
|
||||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
@ -61,12 +72,19 @@ public class Done extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void finish(Plot plot, PlotPlayer pp, boolean success) {
|
private void finish(Plot plot, PlotPlayer pp, boolean success) {
|
||||||
if (success) {
|
if (!success) {
|
||||||
long flagValue = System.currentTimeMillis() / 1000;
|
|
||||||
plot.setFlag(DoneFlag.class, Long.toString(flagValue));
|
|
||||||
MainUtil.sendMessage(pp, Captions.DONE_SUCCESS);
|
|
||||||
} else {
|
|
||||||
MainUtil.sendMessage(pp, Captions.DONE_INSUFFICIENT_COMPLEXITY);
|
MainUtil.sendMessage(pp, Captions.DONE_INSUFFICIENT_COMPLEXITY);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
long flagValue = System.currentTimeMillis() / 1000;
|
||||||
|
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(DoneFlag.class)
|
||||||
|
.createFlagInstance(Long.toString(flagValue));
|
||||||
|
PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot);
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(pp, Captions.EVENT_DENIED, "Done flag addition");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
plot.setFlag(plotFlag);
|
||||||
|
MainUtil.sendMessage(pp, Captions.DONE_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,9 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
|
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotFlagAddEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotFlagRemoveEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.FlagParseException;
|
import com.github.intellectualsites.plotsquared.plot.flags.FlagParseException;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
|
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.InternalFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.InternalFlag;
|
||||||
@ -270,8 +273,15 @@ public final class FlagCommand extends Command {
|
|||||||
if (plotFlag == null) {
|
if (plotFlag == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Plot plot = player.getLocation().getPlotAbs();
|
||||||
|
PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot);
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Flag set");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
boolean force = event.getEventResult() == Result.FORCE;
|
||||||
final String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " ");
|
final String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " ");
|
||||||
if (!checkPermValue(player, plotFlag, args[0], value)) {
|
if (!force && !checkPermValue(player, plotFlag, args[0], value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlotFlag<?, ?> parsed;
|
final PlotFlag<?, ?> parsed;
|
||||||
@ -283,7 +293,7 @@ public final class FlagCommand extends Command {
|
|||||||
.replace("%flag_value%", e.getValue()).replace("%error%", e.getErrorMessage()));
|
.replace("%flag_value%", e.getValue()).replace("%error%", e.getErrorMessage()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.getLocation().getPlotAbs().setFlag(parsed);
|
plot.setFlag(parsed);
|
||||||
MainUtil.sendMessage(player, Captions.FLAG_ADDED);
|
MainUtil.sendMessage(player, Captions.FLAG_ADDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,24 +314,32 @@ public final class FlagCommand extends Command {
|
|||||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag add <flag> <values>");
|
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag add <flag> <values>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlotFlag flag = getFlag(player, args[0]);
|
final PlotFlag<?, ?> plotFlag = getFlag(player, args[0]);
|
||||||
if (flag == null) {
|
if (plotFlag == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlotFlag localFlag =
|
Plot plot = player.getLocation().getPlotAbs();
|
||||||
player.getLocation().getPlotAbs().getFlagContainer().getFlag(flag.getClass());
|
PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot);
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Flag add");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
boolean force = event.getEventResult() == Result.FORCE;
|
||||||
|
final PlotFlag localFlag = player.getLocation().getPlotAbs().getFlagContainer()
|
||||||
|
.getFlag(event.getFlag().getClass());
|
||||||
|
if (!force) {
|
||||||
for (String entry : args[1].split(",")) {
|
for (String entry : args[1].split(",")) {
|
||||||
if (!checkPermValue(player, flag, args[0], entry)) {
|
if (!checkPermValue(player, event.getFlag(), args[0], entry)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " ");
|
} final String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " ");
|
||||||
final PlotFlag parsed;
|
final PlotFlag parsed;
|
||||||
try {
|
try {
|
||||||
parsed = flag.parse(value);
|
parsed = event.getFlag().parse(value);
|
||||||
} catch (FlagParseException e) {
|
} catch (FlagParseException e) {
|
||||||
MainUtil.sendMessage(player,
|
MainUtil.sendMessage(player,
|
||||||
Captions.FLAG_PARSE_ERROR.getTranslated().replace("%flag_name%", flag.getName())
|
Captions.FLAG_PARSE_ERROR.getTranslated().replace("%flag_name%", plotFlag.getName())
|
||||||
.replace("%flag_value%", e.getValue()).replace("%error%", e.getErrorMessage()));
|
.replace("%flag_value%", e.getValue()).replace("%error%", e.getErrorMessage()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -352,11 +370,19 @@ public final class FlagCommand extends Command {
|
|||||||
.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag remove <flag> [values]");
|
.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag remove <flag> [values]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlotFlag<?, ?> flag = getFlag(player, args[0]);
|
PlotFlag<?, ?> flag = getFlag(player, args[0]);
|
||||||
if (flag == null) {
|
if (flag == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(player, CaptionUtility
|
final Plot plot = player.getLocation().getPlotAbs();
|
||||||
|
PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(flag, plot);
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Flag remove");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
boolean force = event.getEventResult() == Result.FORCE;
|
||||||
|
flag = event.getFlag();
|
||||||
|
if (!force && !Permissions.hasPermission(player, CaptionUtility
|
||||||
.format(player, Captions.PERMISSION_SET_FLAG_KEY.getTranslated(),
|
.format(player, Captions.PERMISSION_SET_FLAG_KEY.getTranslated(),
|
||||||
args[0].toLowerCase()))) {
|
args[0].toLowerCase()))) {
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
@ -366,7 +392,6 @@ public final class FlagCommand extends Command {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Plot plot = player.getLocation().getPlotAbs();
|
|
||||||
if (args.length == 2 && flag instanceof ListFlag) {
|
if (args.length == 2 && flag instanceof ListFlag) {
|
||||||
String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " ");
|
String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " ");
|
||||||
final ListFlag listFlag = (ListFlag) flag;
|
final ListFlag listFlag = (ListFlag) flag;
|
||||||
@ -397,7 +422,13 @@ public final class FlagCommand extends Command {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// MainUtil.sendMessage(player, Captions.FLAG_REMOVED);
|
// MainUtil.sendMessage(player, Captions.FLAG_REMOVED);
|
||||||
if (plot.setFlag(parsedFlag.createFlagInstance(list))) {
|
PlotFlag plotFlag = parsedFlag.createFlagInstance(list);
|
||||||
|
PlotFlagAddEvent addEvent = new PlotFlagAddEvent(plotFlag, plot);
|
||||||
|
if (addEvent.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Re-addition of " + plotFlag.getName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (plot.setFlag(addEvent.getFlag())) {
|
||||||
MainUtil.sendMessage(player, Captions.FLAG_PARTIALLY_REMOVED);
|
MainUtil.sendMessage(player, Captions.FLAG_PARTIALLY_REMOVED);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,12 +2,12 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -38,10 +38,10 @@ public class Leave extends Command {
|
|||||||
UUID uuid = player.getUUID();
|
UUID uuid = player.getUUID();
|
||||||
if (plot.isAdded(uuid)) {
|
if (plot.isAdded(uuid)) {
|
||||||
if (plot.removeTrusted(uuid)) {
|
if (plot.removeTrusted(uuid)) {
|
||||||
EventUtil.manager.callTrusted(player, plot, uuid, false);
|
PlotSquared.get().getEventDispatcher().callTrusted(player, plot, uuid, false);
|
||||||
}
|
}
|
||||||
if (plot.removeMember(uuid)) {
|
if (plot.removeMember(uuid)) {
|
||||||
EventUtil.manager.callMember(player, plot, uuid, false);
|
PlotSquared.get().getEventDispatcher().callMember(player, plot, uuid, false);
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, Captions.PLOT_LEFT, player.getName());
|
MainUtil.sendMessage(player, Captions.PLOT_LEFT, player.getName());
|
||||||
} else {
|
} else {
|
||||||
|
@ -5,12 +5,12 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotRateEvent;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Rating;
|
import com.github.intellectualsites.plotsquared.plot.object.Rating;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.TeleportCause;
|
import com.github.intellectualsites.plotsquared.plot.object.TeleportCause;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
@ -99,9 +99,10 @@ public class Like extends SubCommand {
|
|||||||
rating = 1;
|
rating = 1;
|
||||||
}
|
}
|
||||||
plot.addRating(uuid, new Rating(rating));
|
plot.addRating(uuid, new Rating(rating));
|
||||||
final Rating result = EventUtil.manager.callRating(player, plot, new Rating(rating));
|
final PlotRateEvent
|
||||||
if (result != null) {
|
event = PlotSquared.get().getEventDispatcher().callRating(player, plot, new Rating(rating));
|
||||||
plot.addRating(uuid, result);
|
if (event.getRating() != null) {
|
||||||
|
plot.addRating(uuid, event.getRating());
|
||||||
if (like) {
|
if (like) {
|
||||||
sendMessage(player, Captions.RATING_LIKED, plot.getId().toString());
|
sendMessage(player, Captions.RATING_LIKED, plot.getId().toString());
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotMergeEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Direction;
|
import com.github.intellectualsites.plotsquared.plot.object.Direction;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Expression;
|
import com.github.intellectualsites.plotsquared.plot.object.Expression;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
@ -65,31 +68,7 @@ public class Merge extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, Captions.PLOT_UNOWNED);
|
MainUtil.sendMessage(player, Captions.PLOT_UNOWNED);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
UUID uuid = player.getUUID();
|
Direction direction = null;
|
||||||
if (!plot.isOwner(uuid)) {
|
|
||||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_MERGE)) {
|
|
||||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
uuid = plot.guessOwner();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final PlotArea plotArea = plot.getArea();
|
|
||||||
Expression<Double> priceExr = plotArea.PRICES.getOrDefault("merge", null);
|
|
||||||
final int size = plot.getConnectedPlots().size();
|
|
||||||
final double price = priceExr == null ? 0d : priceExr.evaluate((double) size);
|
|
||||||
if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d
|
|
||||||
&& EconHandler.manager.getMoney(player) < price) {
|
|
||||||
sendMessage(player, Captions.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final int maxSize =
|
|
||||||
Permissions.hasPermissionRange(player, "plots.merge", Settings.Limit.MAX_PLOTS);
|
|
||||||
if (size - 1 > maxSize) {
|
|
||||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION, "plots.merge." + (size + 1));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Direction direction = Direction.ALL;
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
switch (direction(player.getLocationFull().getYaw())) {
|
switch (direction(player.getLocationFull().getYaw())) {
|
||||||
case "NORTH":
|
case "NORTH":
|
||||||
@ -106,12 +85,47 @@ public class Merge extends SubCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ("all".equalsIgnoreCase(args[0]) || "auto".equalsIgnoreCase(args[0])) {
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
if (args[0].equalsIgnoreCase(values[i]) || args[0].equalsIgnoreCase(aliases[i])) {
|
||||||
|
direction = getFromIndex(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (direction == null) {
|
||||||
|
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||||
|
"/plot merge <" + StringMan.join(values, "|") + "> [removeroads]");
|
||||||
|
MainUtil.sendMessage(player, Captions.DIRECTION.getTranslated()
|
||||||
|
.replaceAll("%dir%", direction(location.getYaw())));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final int size = plot.getConnectedPlots().size();
|
||||||
|
int max = Permissions.hasPermissionRange(player, "plots.merge", Settings.Limit.MAX_PLOTS);
|
||||||
|
PlotMergeEvent event =
|
||||||
|
PlotSquared.get().getEventDispatcher().callMerge(plot, direction, max, player);
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Merge");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
boolean force = event.getEventResult() == Result.FORCE;
|
||||||
|
direction = event.getDir();
|
||||||
|
final int maxSize = event.getMax();
|
||||||
|
|
||||||
|
if (!force && size - 1 > maxSize) {
|
||||||
|
MainUtil.sendMessage(player, Captions.NO_PERMISSION, "plots.merge." + (size + 1));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final PlotArea plotArea = plot.getArea();
|
||||||
|
Expression<Double> priceExr = plotArea.PRICES.getOrDefault("merge", null);
|
||||||
|
final double price = priceExr == null ? 0d : priceExr.evaluate((double) size);
|
||||||
|
|
||||||
|
UUID uuid = player.getUUID();
|
||||||
|
if (direction == Direction.ALL) {
|
||||||
boolean terrain = true;
|
boolean terrain = true;
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
terrain = "true".equalsIgnoreCase(args[1]);
|
terrain = "true".equalsIgnoreCase(args[1]);
|
||||||
}
|
}
|
||||||
if (!terrain && !Permissions
|
if (!force && !terrain && !Permissions
|
||||||
.hasPermission(player, Captions.PERMISSION_MERGE_KEEP_ROAD)) {
|
.hasPermission(player, Captions.PERMISSION_MERGE_KEEP_ROAD)) {
|
||||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||||
Captions.PERMISSION_MERGE_KEEP_ROAD.getTranslated());
|
Captions.PERMISSION_MERGE_KEEP_ROAD.getTranslated());
|
||||||
@ -127,20 +141,18 @@ public class Merge extends SubCommand {
|
|||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, Captions.NO_AVAILABLE_AUTOMERGE);
|
MainUtil.sendMessage(player, Captions.NO_AVAILABLE_AUTOMERGE);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
for (int i = 0; i < values.length; i++) {
|
if (!force && !plot.isOwner(uuid)) {
|
||||||
if (args[0].equalsIgnoreCase(values[i]) || args[0].equalsIgnoreCase(aliases[i])) {
|
if (!Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_MERGE)) {
|
||||||
direction = getFromIndex(i);
|
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||||
break;
|
return false;
|
||||||
|
} else {
|
||||||
|
uuid = plot.guessOwner();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (!force && EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d
|
||||||
if (direction == Direction.ALL) {
|
&& EconHandler.manager.getMoney(player) < price) {
|
||||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
sendMessage(player, Captions.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
||||||
"/plot merge <" + StringMan.join(values, "|") + "> [removeroads]");
|
|
||||||
MainUtil.sendMessage(player, Captions.DIRECTION.getTranslated()
|
|
||||||
.replaceAll("%dir%", direction(location.getYaw())));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final boolean terrain;
|
final boolean terrain;
|
||||||
@ -149,7 +161,7 @@ public class Merge extends SubCommand {
|
|||||||
} else {
|
} else {
|
||||||
terrain = true;
|
terrain = true;
|
||||||
}
|
}
|
||||||
if (!terrain && !Permissions.hasPermission(player, Captions.PERMISSION_MERGE_KEEP_ROAD)) {
|
if (!force && !terrain && !Permissions.hasPermission(player, Captions.PERMISSION_MERGE_KEEP_ROAD)) {
|
||||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||||
Captions.PERMISSION_MERGE_KEEP_ROAD.getTranslated());
|
Captions.PERMISSION_MERGE_KEEP_ROAD.getTranslated());
|
||||||
return true;
|
return true;
|
||||||
@ -164,11 +176,11 @@ public class Merge extends SubCommand {
|
|||||||
}
|
}
|
||||||
Plot adjacent = plot.getRelative(direction);
|
Plot adjacent = plot.getRelative(direction);
|
||||||
if (adjacent == null || !adjacent.hasOwner() || adjacent
|
if (adjacent == null || !adjacent.hasOwner() || adjacent
|
||||||
.getMerged((direction.getIndex() + 2) % 4) || adjacent.isOwner(uuid)) {
|
.getMerged((direction.getIndex() + 2) % 4) || (!force && adjacent.isOwner(uuid))) {
|
||||||
MainUtil.sendMessage(player, Captions.NO_AVAILABLE_AUTOMERGE);
|
MainUtil.sendMessage(player, Captions.NO_AVAILABLE_AUTOMERGE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_MERGE_OTHER)) {
|
if (!force && !Permissions.hasPermission(player, Captions.PERMISSION_MERGE_OTHER)) {
|
||||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_MERGE_OTHER);
|
MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_MERGE_OTHER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -176,7 +188,7 @@ public class Merge extends SubCommand {
|
|||||||
boolean isOnline = false;
|
boolean isOnline = false;
|
||||||
for (final UUID owner : uuids) {
|
for (final UUID owner : uuids) {
|
||||||
final PlotPlayer accepter = UUIDHandler.getPlayer(owner);
|
final PlotPlayer accepter = UUIDHandler.getPlayer(owner);
|
||||||
if (accepter == null) {
|
if (!force && accepter == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
isOnline = true;
|
isOnline = true;
|
||||||
@ -190,7 +202,7 @@ public class Merge extends SubCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d) {
|
if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d) {
|
||||||
if (EconHandler.manager.getMoney(player) < price) {
|
if (!force && EconHandler.manager.getMoney(player) < price) {
|
||||||
sendMessage(player, Captions.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
sendMessage(player, Captions.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -199,14 +211,14 @@ public class Merge extends SubCommand {
|
|||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, Captions.SUCCESS_MERGE);
|
MainUtil.sendMessage(player, Captions.SUCCESS_MERGE);
|
||||||
};
|
};
|
||||||
if (hasConfirmation(player)) {
|
if (!force && hasConfirmation(player)) {
|
||||||
CmdConfirm.addPending(accepter, Captions.MERGE_REQUEST_CONFIRM.getTranslated()
|
CmdConfirm.addPending(accepter, Captions.MERGE_REQUEST_CONFIRM.getTranslated()
|
||||||
.replaceAll("%s", player.getName()), run);
|
.replaceAll("%s", player.getName()), run);
|
||||||
} else {
|
} else {
|
||||||
run.run();
|
run.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isOnline) {
|
if (!force && !isOnline) {
|
||||||
MainUtil.sendMessage(player, Captions.NO_AVAILABLE_AUTOMERGE);
|
MainUtil.sendMessage(player, Captions.NO_AVAILABLE_AUTOMERGE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,12 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
|
import com.github.intellectualsites.plotsquared.plot.events.PlotFlagAddEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotFlagRemoveEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MusicFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MusicFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotInventory;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotItemStack;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|
||||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -45,11 +44,24 @@ public class Music extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (item.getType() == ItemTypes.BEDROCK) {
|
if (item.getType() == ItemTypes.BEDROCK) {
|
||||||
plot.removeFlag(MusicFlag.class);
|
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(MusicFlag.class)
|
||||||
|
.createFlagInstance(item.getType());
|
||||||
|
PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(plotFlag, plot);
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Music removal");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
plot.removeFlag(event.getFlag());
|
||||||
Captions.FLAG_REMOVED.send(player);
|
Captions.FLAG_REMOVED.send(player);
|
||||||
} else if (item.name.toLowerCase(Locale.ENGLISH).contains("disc")) {
|
} else if (item.name.toLowerCase(Locale.ENGLISH).contains("disc")) {
|
||||||
plot.setFlag(GlobalFlagContainer.getInstance().getFlag(MusicFlag.class)
|
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(MusicFlag.class)
|
||||||
.createFlagInstance(item.getType()));
|
.createFlagInstance(item.getType());
|
||||||
|
PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot);
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Music addition");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
plot.setFlag(event.getFlag());
|
||||||
Captions.FLAG_ADDED.send(player);
|
Captions.FLAG_ADDED.send(player);
|
||||||
} else {
|
} else {
|
||||||
Captions.FLAG_NOT_ADDED.send(player);
|
Captions.FLAG_NOT_ADDED.send(player);
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotChangeOwnerEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotUnlinkEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.CmdConfirm;
|
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -31,27 +31,47 @@ public class Owner extends SetCommand {
|
|||||||
}
|
}
|
||||||
Set<Plot> plots = plot.getConnectedPlots();
|
Set<Plot> plots = plot.getConnectedPlots();
|
||||||
UUID uuid = null;
|
UUID uuid = null;
|
||||||
String name = null;
|
String name;
|
||||||
if (value.length() == 36) {
|
if (value.length() == 36) {
|
||||||
try {
|
try {
|
||||||
uuid = UUID.fromString(value);
|
uuid = UUID.fromString(value);
|
||||||
name = MainUtil.getName(uuid);
|
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uuid = UUIDHandler.getUUID(value, null);
|
uuid = UUIDHandler.getUUID(value, null);
|
||||||
name = uuid == null ? value : UUIDHandler.getName(uuid);
|
|
||||||
name = name == null ? value : name;
|
|
||||||
}
|
}
|
||||||
if (uuid == null || value.equalsIgnoreCase("-")) {
|
if (uuid == null) {
|
||||||
if (value.equalsIgnoreCase("none") || value.equalsIgnoreCase("null") || value
|
Captions.INVALID_PLAYER.send(player, value);
|
||||||
.equalsIgnoreCase("-")) {
|
|
||||||
if (!Permissions.hasPermission(player,
|
|
||||||
Captions.PERMISSION_ADMIN_COMMAND_SET_OWNER.getTranslated(), true)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (value.equalsIgnoreCase("none") || value.equalsIgnoreCase("null") || value
|
||||||
|
.equalsIgnoreCase("-")) {
|
||||||
|
uuid = null;
|
||||||
|
}
|
||||||
|
PlotChangeOwnerEvent event = PlotSquared.get().getEventDispatcher()
|
||||||
|
.callOwnerChange(player, plot, plot.hasOwner() ? plot.owner : null, uuid,
|
||||||
|
plot.hasOwner());
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Owner change");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
uuid = event.getNewOwner();
|
||||||
|
name = uuid == null ? value : UUIDHandler.getName(uuid);
|
||||||
|
boolean force = event.getEventResult() == Result.FORCE;
|
||||||
|
if (uuid == null) {
|
||||||
|
if (!force && !Permissions
|
||||||
|
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SET_OWNER.getTranslated(),
|
||||||
|
true)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PlotUnlinkEvent unlinkEvent = PlotSquared.get().getEventDispatcher()
|
||||||
|
.callUnlink(plot.getArea(), plot, false, false, PlotUnlinkEvent.REASON.NEW_OWNER);
|
||||||
|
if (unlinkEvent.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Unlink on owner change");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
plot.unlinkPlot(unlinkEvent.isCreateRoad(), unlinkEvent.isCreateRoad());
|
||||||
Set<Plot> connected = plot.getConnectedPlots();
|
Set<Plot> connected = plot.getConnectedPlots();
|
||||||
plot.unlinkPlot(false, false);
|
|
||||||
for (Plot current : connected) {
|
for (Plot current : connected) {
|
||||||
current.unclaim();
|
current.unclaim();
|
||||||
current.removeSign();
|
current.removeSign();
|
||||||
@ -59,15 +79,13 @@ public class Owner extends SetCommand {
|
|||||||
MainUtil.sendMessage(player, Captions.SET_OWNER);
|
MainUtil.sendMessage(player, Captions.SET_OWNER);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Captions.INVALID_PLAYER.send(player, value);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final PlotPlayer other = UUIDHandler.getPlayer(uuid);
|
final PlotPlayer other = UUIDHandler.getPlayer(uuid);
|
||||||
if (plot.isOwner(uuid)) {
|
if (plot.isOwner(uuid)) {
|
||||||
Captions.ALREADY_OWNER.send(player, MainUtil.getName(uuid));
|
Captions.ALREADY_OWNER.send(player, MainUtil.getName(uuid));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SET_OWNER)) {
|
if (!force && !Permissions
|
||||||
|
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SET_OWNER)) {
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
Captions.INVALID_PLAYER_OFFLINE.send(player, value);
|
Captions.INVALID_PLAYER_OFFLINE.send(player, value);
|
||||||
return false;
|
return false;
|
||||||
|
@ -6,6 +6,7 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotRateEvent;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotInventory;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotInventory;
|
||||||
@ -13,7 +14,6 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotItemStack;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Rating;
|
import com.github.intellectualsites.plotsquared.plot.object.Rating;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.TeleportCause;
|
import com.github.intellectualsites.plotsquared.plot.object.TeleportCause;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
@ -117,10 +117,10 @@ public class Rate extends SubCommand {
|
|||||||
index.increment();
|
index.increment();
|
||||||
if (index.getValue() >= Settings.Ratings.CATEGORIES.size()) {
|
if (index.getValue() >= Settings.Ratings.CATEGORIES.size()) {
|
||||||
int rV = rating.getValue();
|
int rV = rating.getValue();
|
||||||
Rating result =
|
PlotRateEvent event =
|
||||||
EventUtil.manager.callRating(this.player, plot, new Rating(rV));
|
PlotSquared.get().getEventDispatcher().callRating(this.player, plot, new Rating(rV));
|
||||||
if (result != null) {
|
if (event.getRating() != null) {
|
||||||
plot.addRating(this.player.getUUID(), result);
|
plot.addRating(this.player.getUUID(), event.getRating());
|
||||||
sendMessage(this.player, Captions.RATING_APPLIED,
|
sendMessage(this.player, Captions.RATING_APPLIED,
|
||||||
plot.getId().toString());
|
plot.getId().toString());
|
||||||
if (Permissions
|
if (Permissions
|
||||||
@ -186,9 +186,9 @@ public class Rate extends SubCommand {
|
|||||||
sendMessage(player, Captions.RATING_ALREADY_EXISTS, plot.getId().toString());
|
sendMessage(player, Captions.RATING_ALREADY_EXISTS, plot.getId().toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Rating result = EventUtil.manager.callRating(player, plot, new Rating(rating));
|
PlotRateEvent event = PlotSquared.get().getEventDispatcher().callRating(player, plot, new Rating(rating));
|
||||||
if (result != null) {
|
if (event.getRating() != null) {
|
||||||
plot.addRating(uuid, result);
|
plot.addRating(uuid, event.getRating());
|
||||||
sendMessage(player, Captions.RATING_APPLIED, plot.getId().toString());
|
sendMessage(player, Captions.RATING_APPLIED, plot.getId().toString());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -2,12 +2,12 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.Argument;
|
import com.github.intellectualsites.plotsquared.commands.Argument;
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||||
@ -72,28 +72,29 @@ public class Remove extends SubCommand {
|
|||||||
for (UUID uuid : uuids) {
|
for (UUID uuid : uuids) {
|
||||||
if (plot.getTrusted().contains(uuid)) {
|
if (plot.getTrusted().contains(uuid)) {
|
||||||
if (plot.removeTrusted(uuid)) {
|
if (plot.removeTrusted(uuid)) {
|
||||||
EventUtil.manager.callTrusted(player, plot, uuid, false);
|
PlotSquared
|
||||||
|
.get().getEventDispatcher().callTrusted(player, plot, uuid, false);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
} else if (plot.getMembers().contains(uuid)) {
|
} else if (plot.getMembers().contains(uuid)) {
|
||||||
if (plot.removeMember(uuid)) {
|
if (plot.removeMember(uuid)) {
|
||||||
EventUtil.manager.callMember(player, plot, uuid, false);
|
PlotSquared.get().getEventDispatcher().callMember(player, plot, uuid, false);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
} else if (plot.getDenied().contains(uuid)) {
|
} else if (plot.getDenied().contains(uuid)) {
|
||||||
if (plot.removeDenied(uuid)) {
|
if (plot.removeDenied(uuid)) {
|
||||||
EventUtil.manager.callDenied(player, plot, uuid, false);
|
PlotSquared.get().getEventDispatcher().callDenied(player, plot, uuid, false);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
} else if (uuid == DBFunc.EVERYONE) {
|
} else if (uuid == DBFunc.EVERYONE) {
|
||||||
if (plot.removeTrusted(uuid)) {
|
if (plot.removeTrusted(uuid)) {
|
||||||
EventUtil.manager.callTrusted(player, plot, uuid, false);
|
PlotSquared.get().getEventDispatcher().callTrusted(player, plot, uuid, false);
|
||||||
count++;
|
count++;
|
||||||
} else if (plot.removeMember(uuid)) {
|
} else if (plot.removeMember(uuid)) {
|
||||||
EventUtil.manager.callMember(player, plot, uuid, false);
|
PlotSquared.get().getEventDispatcher().callMember(player, plot, uuid, false);
|
||||||
count++;
|
count++;
|
||||||
} else if (plot.removeDenied(uuid)) {
|
} else if (plot.removeDenied(uuid)) {
|
||||||
EventUtil.manager.callDenied(player, plot, uuid, false);
|
PlotSquared.get().getEventDispatcher().callDenied(player, plot, uuid, false);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,13 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ public class Trust extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentPlot.addTrusted(uuid);
|
currentPlot.addTrusted(uuid);
|
||||||
EventUtil.manager.callTrusted(player, currentPlot, uuid, true);
|
PlotSquared.get().getEventDispatcher().callTrusted(player, currentPlot, uuid, true);
|
||||||
MainUtil.sendMessage(player, Captions.TRUSTED_ADDED);
|
MainUtil.sendMessage(player, Captions.TRUSTED_ADDED);
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotUnlinkEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
@ -29,10 +32,6 @@ public class Unlink extends SubCommand {
|
|||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
return !sendMessage(player, Captions.PLOT_UNOWNED);
|
return !sendMessage(player, Captions.PLOT_UNOWNED);
|
||||||
}
|
}
|
||||||
if (!plot.isOwner(player.getUUID()) && !Permissions
|
|
||||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_UNLINK)) {
|
|
||||||
return sendMessage(player, Captions.NO_PLOT_PERMS);
|
|
||||||
}
|
|
||||||
if (!plot.isMerged()) {
|
if (!plot.isMerged()) {
|
||||||
return sendMessage(player, Captions.UNLINK_IMPOSSIBLE);
|
return sendMessage(player, Captions.UNLINK_IMPOSSIBLE);
|
||||||
}
|
}
|
||||||
@ -46,6 +45,19 @@ public class Unlink extends SubCommand {
|
|||||||
} else {
|
} else {
|
||||||
createRoad = true;
|
createRoad = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlotUnlinkEvent event = PlotSquared.get().getEventDispatcher()
|
||||||
|
.callUnlink(plot.getArea(), plot, createRoad, createRoad,
|
||||||
|
PlotUnlinkEvent.REASON.PLAYER_COMMAND);
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Unlink");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
boolean force = event.getEventResult() == Result.FORCE;
|
||||||
|
if (!force && !plot.isOwner(player.getUUID()) && !Permissions
|
||||||
|
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_UNLINK)) {
|
||||||
|
return sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||||
|
}
|
||||||
Runnable runnable = () -> {
|
Runnable runnable = () -> {
|
||||||
if (!plot.unlinkPlot(createRoad, createRoad)) {
|
if (!plot.unlinkPlot(createRoad, createRoad)) {
|
||||||
MainUtil.sendMessage(player, Captions.UNMERGE_CANCELLED);
|
MainUtil.sendMessage(player, Captions.UNMERGE_CANCELLED);
|
||||||
|
@ -716,6 +716,10 @@ public enum Captions implements Caption {
|
|||||||
GRANTED_PLOT_FAILED("$1Grant failed: $2%s", "Grants"),
|
GRANTED_PLOT_FAILED("$1Grant failed: $2%s", "Grants"),
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
|
//<editor-fold desc="Events">
|
||||||
|
EVENT_DENIED("$1%s $2Cancelled by external plugin.", "Events"),
|
||||||
|
//</editor-fold>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Legacy Configuration Conversion
|
* Legacy Configuration Conversion
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PlotSquared event with {@link Result} to cancel, force, or allow.
|
||||||
|
*/
|
||||||
|
public interface CancellablePlotEvent {
|
||||||
|
|
||||||
|
Result getEventResult();
|
||||||
|
|
||||||
|
void setEventResult(Result eventResult);
|
||||||
|
|
||||||
|
default int getEventResultRaw() {
|
||||||
|
return getEventResult().getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class PlayerAutoPlotEvent extends PlotEvent implements CancellablePlotEvent {
|
||||||
|
|
||||||
|
private Result eventResult;
|
||||||
|
private String schematic;
|
||||||
|
@Getter private PlotPlayer player;
|
||||||
|
@Getter private PlotArea plotArea;
|
||||||
|
@Getter @Setter private int size_x;
|
||||||
|
@Getter @Setter private int size_z;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PlayerAutoPlotEvent: called when a player attempts to auto claim a plot.
|
||||||
|
*
|
||||||
|
* @param player The player attempting to auto claim
|
||||||
|
* @param plotArea The applicable plot area
|
||||||
|
* @param schematic The schematic defined or null
|
||||||
|
* @param size_x The size of the auto area
|
||||||
|
* @param size_z The size of the auto area
|
||||||
|
*/
|
||||||
|
public PlayerAutoPlotEvent(PlotPlayer player, PlotArea plotArea, @Nullable String schematic,
|
||||||
|
int size_x, int size_z) {
|
||||||
|
super(null);
|
||||||
|
this.player = player;
|
||||||
|
this.plotArea = plotArea;
|
||||||
|
this.schematic = schematic;
|
||||||
|
this.size_x = size_x;
|
||||||
|
this.size_z = size_z;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the schematic string as used by the {@link com.github.intellectualsites.plotsquared.plot.commands.Claim} command or null.
|
||||||
|
*
|
||||||
|
* @return schematic string
|
||||||
|
*/
|
||||||
|
@Nullable public String getSchematic() {
|
||||||
|
return this.schematic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the schematic string used in the claim.
|
||||||
|
*/
|
||||||
|
public void setSchematic(String schematic) {
|
||||||
|
this.schematic = schematic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public Result getEventResult() {
|
||||||
|
return eventResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void setEventResult(Result e) {
|
||||||
|
this.eventResult = e;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class PlayerClaimPlotEvent extends PlotPlayerEvent implements CancellablePlotEvent {
|
||||||
|
|
||||||
|
private Result eventResult;
|
||||||
|
private String schematic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PlayerClaimPlotEvent: Called when a plot is claimed.
|
||||||
|
*
|
||||||
|
* @param player Player that claimed the plot
|
||||||
|
* @param plot Plot that was claimed
|
||||||
|
* @param schematic The schematic defined or null
|
||||||
|
*/
|
||||||
|
public PlayerClaimPlotEvent(PlotPlayer player, Plot plot, @Nullable String schematic) {
|
||||||
|
super(player, plot);
|
||||||
|
this.schematic = schematic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the schematic string as used by the {@link com.github.intellectualsites.plotsquared.plot.commands.Claim} command or null.
|
||||||
|
*
|
||||||
|
* @return schematic string
|
||||||
|
*/
|
||||||
|
@Nullable public String getSchematic() {
|
||||||
|
return this.schematic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the schematic string used in the claim.
|
||||||
|
*/
|
||||||
|
public void setSchematic(String schematic) {
|
||||||
|
this.schematic = schematic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public Result getEventResult() {
|
||||||
|
return eventResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void setEventResult(Result e) {
|
||||||
|
this.eventResult = e;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
|
|
||||||
|
public class PlayerEnterPlotEvent extends PlotPlayerEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player leaves a plot.
|
||||||
|
*
|
||||||
|
* @param player Player that entered the plot
|
||||||
|
* @param plot Plot that was entered
|
||||||
|
*/
|
||||||
|
public PlayerEnterPlotEvent(PlotPlayer player, Plot plot) {
|
||||||
|
super(player, plot);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PlayerLeavePlotEvent extends PlotPlayerEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PlayerLeavePlotEvent: Called when a player leaves a plot
|
||||||
|
*
|
||||||
|
* @param player Player that left the plot
|
||||||
|
* @param plot Plot that was left
|
||||||
|
*/
|
||||||
|
public PlayerLeavePlotEvent(PlotPlayer player, Plot plot) {
|
||||||
|
super(player, plot);
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,13 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import org.bukkit.entity.Player;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlayerPlotDeniedEvent extends PlotEvent {
|
public class PlayerPlotDeniedEvent extends PlotEvent {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private final PlotPlayer initiator;
|
||||||
private final Player initiator;
|
|
||||||
private final boolean added;
|
private final boolean added;
|
||||||
private final UUID player;
|
private final UUID player;
|
||||||
|
|
||||||
@ -21,17 +19,13 @@ public class PlayerPlotDeniedEvent extends PlotEvent {
|
|||||||
* @param player Player that was denied/un-denied
|
* @param player Player that was denied/un-denied
|
||||||
* @param added true of add to deny list, false if removed
|
* @param added true of add to deny list, false if removed
|
||||||
*/
|
*/
|
||||||
public PlayerPlotDeniedEvent(Player initiator, Plot plot, UUID player, boolean added) {
|
public PlayerPlotDeniedEvent(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||||
super(plot);
|
super(plot);
|
||||||
this.initiator = initiator;
|
this.initiator = initiator;
|
||||||
this.added = added;
|
this.added = added;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a user was added.
|
* If a user was added.
|
||||||
*
|
*
|
||||||
@ -53,13 +47,9 @@ public class PlayerPlotDeniedEvent extends PlotEvent {
|
|||||||
/**
|
/**
|
||||||
* The player initiating the action.
|
* The player initiating the action.
|
||||||
*
|
*
|
||||||
* @return Player
|
* @return PlotPlayer
|
||||||
*/
|
*/
|
||||||
public Player getInitiator() {
|
public PlotPlayer getInitiator() {
|
||||||
return this.initiator;
|
return this.initiator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,8 +1,7 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import org.bukkit.entity.Player;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -11,8 +10,7 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class PlayerPlotHelperEvent extends PlotEvent {
|
public class PlayerPlotHelperEvent extends PlotEvent {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private final PlotPlayer initiator;
|
||||||
private final Player initiator;
|
|
||||||
private final boolean added;
|
private final boolean added;
|
||||||
private final UUID player;
|
private final UUID player;
|
||||||
|
|
||||||
@ -24,17 +22,13 @@ public class PlayerPlotHelperEvent extends PlotEvent {
|
|||||||
* @param player Player that was added/removed from the helper list
|
* @param player Player that was added/removed from the helper list
|
||||||
* @param added true of the player was added, false if the player was removed
|
* @param added true of the player was added, false if the player was removed
|
||||||
*/
|
*/
|
||||||
public PlayerPlotHelperEvent(Player initiator, Plot plot, UUID player, boolean added) {
|
public PlayerPlotHelperEvent(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||||
super(plot);
|
super(plot);
|
||||||
this.initiator = initiator;
|
this.initiator = initiator;
|
||||||
this.added = added;
|
this.added = added;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a player was added
|
* If a player was added
|
||||||
*
|
*
|
||||||
@ -56,13 +50,10 @@ public class PlayerPlotHelperEvent extends PlotEvent {
|
|||||||
/**
|
/**
|
||||||
* The player initiating the action
|
* The player initiating the action
|
||||||
*
|
*
|
||||||
* @return Player
|
* @return PlotPlayer
|
||||||
*/
|
*/
|
||||||
public Player getInitiator() {
|
public PlotPlayer getInitiator() {
|
||||||
return this.initiator;
|
return this.initiator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,15 +1,13 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import org.bukkit.entity.Player;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlayerPlotTrustedEvent extends PlotEvent {
|
public class PlayerPlotTrustedEvent extends PlotEvent {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private final PlotPlayer initiator;
|
||||||
private final Player initiator;
|
|
||||||
private final boolean added;
|
private final boolean added;
|
||||||
private final UUID player;
|
private final UUID player;
|
||||||
|
|
||||||
@ -21,17 +19,13 @@ public class PlayerPlotTrustedEvent extends PlotEvent {
|
|||||||
* @param player Player that was added/removed from the trusted list
|
* @param player Player that was added/removed from the trusted list
|
||||||
* @param added true of the player was added, false if the player was removed
|
* @param added true of the player was added, false if the player was removed
|
||||||
*/
|
*/
|
||||||
public PlayerPlotTrustedEvent(Player initiator, Plot plot, UUID player, boolean added) {
|
public PlayerPlotTrustedEvent(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||||
super(plot);
|
super(plot);
|
||||||
this.initiator = initiator;
|
this.initiator = initiator;
|
||||||
this.added = added;
|
this.added = added;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a player was added
|
* If a player was added
|
||||||
*
|
*
|
||||||
@ -53,13 +47,9 @@ public class PlayerPlotTrustedEvent extends PlotEvent {
|
|||||||
/**
|
/**
|
||||||
* The player initiating the action
|
* The player initiating the action
|
||||||
*
|
*
|
||||||
* @return Player
|
* @return PlotPlayer
|
||||||
*/
|
*/
|
||||||
public Player getInitiator() {
|
public PlotPlayer getInitiator() {
|
||||||
return this.initiator;
|
return this.initiator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player teleports to a plot
|
||||||
|
*/
|
||||||
|
public class PlayerTeleportToPlotEvent extends PlotPlayerEvent implements CancellablePlotEvent {
|
||||||
|
|
||||||
|
private final Location from;
|
||||||
|
private Result eventResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PlayerTeleportToPlotEvent: Called when a player teleports to a plot
|
||||||
|
*
|
||||||
|
* @param player That was teleported
|
||||||
|
* @param from Start location
|
||||||
|
* @param plot Plot to which the player was teleported
|
||||||
|
*/
|
||||||
|
public PlayerTeleportToPlotEvent(PlotPlayer player, Location from, Plot plot) {
|
||||||
|
super(player, plot);
|
||||||
|
this.from = from;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the from location
|
||||||
|
*
|
||||||
|
* @return Location
|
||||||
|
*/
|
||||||
|
public Location getFrom() {
|
||||||
|
return this.from;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result getEventResult() {
|
||||||
|
return eventResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEventResult(Result e) {
|
||||||
|
this.eventResult = e;
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,8 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -16,12 +12,11 @@ import java.util.List;
|
|||||||
* Event called when plots are automatically merged with /plot auto
|
* Event called when plots are automatically merged with /plot auto
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public final class PlotAutoMergeEvent extends PlotEvent implements Cancellable {
|
public final class PlotAutoMergeEvent extends PlotEvent implements CancellablePlotEvent {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
private final List<PlotId> plots;
|
private final List<PlotId> plots;
|
||||||
@Getter private final World world;
|
@Getter private final String world;
|
||||||
@Getter @Setter private boolean cancelled;
|
private Result eventResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PlotAutoMergeEvent: Called when plots are automatically merged with /plot auto
|
* PlotAutoMergeEvent: Called when plots are automatically merged with /plot auto
|
||||||
@ -30,17 +25,12 @@ public final class PlotAutoMergeEvent extends PlotEvent implements Cancellable {
|
|||||||
* @param plot Plot that was merged
|
* @param plot Plot that was merged
|
||||||
* @param plots A list of plots involved in the event
|
* @param plots A list of plots involved in the event
|
||||||
*/
|
*/
|
||||||
public PlotAutoMergeEvent(@NotNull final World world, @NotNull final Plot plot,
|
public PlotAutoMergeEvent(@NotNull final String world, @NotNull final Plot plot,
|
||||||
@NotNull final List<PlotId> plots) {
|
@NotNull final List<PlotId> plots) {
|
||||||
super(plot);
|
super(plot);
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.plots = plots;
|
this.plots = plots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the plots being added.
|
* Get the plots being added.
|
||||||
*
|
*
|
||||||
@ -50,7 +40,13 @@ public final class PlotAutoMergeEvent extends PlotEvent implements Cancellable {
|
|||||||
return Collections.unmodifiableList(this.plots);
|
return Collections.unmodifiableList(this.plots);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public HandlerList getHandlers() {
|
@Override
|
||||||
return handlers;
|
public Result getEventResult() {
|
||||||
|
return eventResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEventResult(Result e) {
|
||||||
|
this.eventResult = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,31 +1,31 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import org.bukkit.entity.Player;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlotChangeOwnerEvent extends PlotEvent implements Cancellable {
|
public class PlotChangeOwnerEvent extends PlotEvent implements CancellablePlotEvent {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private final PlotPlayer initiator;
|
||||||
private final Player initiator;
|
@Nullable private final UUID oldOwner;
|
||||||
private final UUID newOwner;
|
@Nullable private UUID newOwner;
|
||||||
private final UUID oldOwner;
|
|
||||||
private boolean hasOldOwner;
|
private boolean hasOldOwner;
|
||||||
private boolean cancelled;
|
private Result eventResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PlotChangeOwnerEvent: Called when a plot's owner is change.
|
* PlotChangeOwnerEvent: Called when a plot's owner is change.
|
||||||
*
|
*
|
||||||
* @param newOwner The new owner of the plot
|
* @param initiator The player attempting to set the plot's owner
|
||||||
* @param oldOwner The old owner of the plot
|
|
||||||
* @param plot The plot having its owner changed
|
* @param plot The plot having its owner changed
|
||||||
|
* @param oldOwner The old owner of the plot or null
|
||||||
|
* @param newOwner The new owner of the plot or null
|
||||||
|
* @param hasOldOwner If the plot has an old owner
|
||||||
*/
|
*/
|
||||||
public PlotChangeOwnerEvent(Player initiator, Plot plot, UUID oldOwner, UUID newOwner,
|
public PlotChangeOwnerEvent(PlotPlayer initiator, Plot plot, @Nullable UUID oldOwner,
|
||||||
boolean hasOldOwner) {
|
@Nullable UUID newOwner, boolean hasOldOwner) {
|
||||||
super(plot);
|
super(plot);
|
||||||
this.initiator = initiator;
|
this.initiator = initiator;
|
||||||
this.newOwner = newOwner;
|
this.newOwner = newOwner;
|
||||||
@ -33,10 +33,6 @@ public class PlotChangeOwnerEvent extends PlotEvent implements Cancellable {
|
|||||||
this.hasOldOwner = hasOldOwner;
|
this.hasOldOwner = hasOldOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the PlotId.
|
* Get the PlotId.
|
||||||
*
|
*
|
||||||
@ -60,7 +56,7 @@ public class PlotChangeOwnerEvent extends PlotEvent implements Cancellable {
|
|||||||
*
|
*
|
||||||
* @return Player
|
* @return Player
|
||||||
*/
|
*/
|
||||||
public Player getInitiator() {
|
public PlotPlayer getInitiator() {
|
||||||
return this.initiator;
|
return this.initiator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +65,7 @@ public class PlotChangeOwnerEvent extends PlotEvent implements Cancellable {
|
|||||||
*
|
*
|
||||||
* @return UUID
|
* @return UUID
|
||||||
*/
|
*/
|
||||||
public UUID getOldOwner() {
|
@Nullable public UUID getOldOwner() {
|
||||||
return this.oldOwner;
|
return this.oldOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,10 +74,20 @@ public class PlotChangeOwnerEvent extends PlotEvent implements Cancellable {
|
|||||||
*
|
*
|
||||||
* @return UUID
|
* @return UUID
|
||||||
*/
|
*/
|
||||||
public UUID getNewOwner() {
|
@Nullable public UUID getNewOwner() {
|
||||||
return this.newOwner;
|
return this.newOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the new owner of the plot. Null for no owner.
|
||||||
|
*
|
||||||
|
* @param newOwner the new owner or null
|
||||||
|
*/
|
||||||
|
public void setNewOwner(@Nullable UUID newOwner) {
|
||||||
|
this.newOwner = newOwner;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get if the plot had an old owner
|
* Get if the plot had an old owner
|
||||||
*
|
*
|
||||||
@ -91,15 +97,11 @@ public class PlotChangeOwnerEvent extends PlotEvent implements Cancellable {
|
|||||||
return this.hasOldOwner;
|
return this.hasOldOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public HandlerList getHandlers() {
|
@Override public Result getEventResult() {
|
||||||
return handlers;
|
return eventResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean isCancelled() {
|
@Override public void setEventResult(Result e) {
|
||||||
return this.cancelled;
|
this.eventResult = e;
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void setCancelled(boolean b) {
|
|
||||||
this.cancelled = b;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,26 +1,19 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a plot is cleared
|
* Called when a plot is cleared
|
||||||
*/
|
*/
|
||||||
public class PlotClearEvent extends PlotEvent implements Cancellable {
|
public class PlotClearEvent extends PlotEvent implements CancellablePlotEvent {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private Result eventResult;
|
||||||
private boolean cancelled;
|
|
||||||
|
|
||||||
public PlotClearEvent(Plot plot) {
|
public PlotClearEvent(Plot plot) {
|
||||||
super(plot);
|
super(plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the PlotId.
|
* Get the PlotId.
|
||||||
*
|
*
|
||||||
@ -39,15 +32,13 @@ public class PlotClearEvent extends PlotEvent implements Cancellable {
|
|||||||
return getPlot().getWorldName();
|
return getPlot().getWorldName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public HandlerList getHandlers() {
|
@Override
|
||||||
return handlers;
|
public Result getEventResult() {
|
||||||
|
return eventResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean isCancelled() {
|
@Override
|
||||||
return this.cancelled;
|
public void setEventResult(Result e) {
|
||||||
}
|
this.eventResult = e;
|
||||||
|
|
||||||
@Override public void setCancelled(boolean b) {
|
|
||||||
this.cancelled = b;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a plot component is set
|
||||||
|
*/
|
||||||
|
public class PlotComponentSetEvent extends PlotEvent {
|
||||||
|
|
||||||
|
private String component;
|
||||||
|
private Pattern pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PlotComponentSetEvent: Called when a player attempts to set the component of a plot (e.g. walls)
|
||||||
|
*
|
||||||
|
* @param plot The plot having its component set
|
||||||
|
* @param component The component being set
|
||||||
|
* @param pattern The pattern the component is being set to
|
||||||
|
*/
|
||||||
|
public PlotComponentSetEvent(Plot plot, String component, Pattern pattern) {
|
||||||
|
super(plot);
|
||||||
|
this.component = component;
|
||||||
|
this.pattern = pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 component which was set
|
||||||
|
*
|
||||||
|
* @return Component name
|
||||||
|
*/
|
||||||
|
public String getComponent() {
|
||||||
|
return this.component;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the component being set
|
||||||
|
*
|
||||||
|
* @param component the component to set
|
||||||
|
*/
|
||||||
|
public void setComponent(String component) {
|
||||||
|
this.component = component;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the pattern being set
|
||||||
|
*
|
||||||
|
* @return Pattern
|
||||||
|
*/
|
||||||
|
public Pattern getPattern() {
|
||||||
|
return this.pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the pattern being set
|
||||||
|
*
|
||||||
|
* @param pattern the pattern to set
|
||||||
|
*/
|
||||||
|
public void setPattern(Pattern pattern) {
|
||||||
|
this.pattern = pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,26 +1,19 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a plot is deleted
|
* Called when a plot is deleted
|
||||||
*/
|
*/
|
||||||
public class PlotDeleteEvent extends PlotEvent implements Cancellable {
|
public class PlotDeleteEvent extends PlotEvent implements CancellablePlotEvent {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private Result eventResult;
|
||||||
private boolean cancelled;
|
|
||||||
|
|
||||||
public PlotDeleteEvent(Plot plot) {
|
public PlotDeleteEvent(Plot plot) {
|
||||||
super(plot);
|
super(plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the PlotId.
|
* Get the PlotId.
|
||||||
*
|
*
|
||||||
@ -39,15 +32,13 @@ public class PlotDeleteEvent extends PlotEvent implements Cancellable {
|
|||||||
return getPlot().getWorldName();
|
return getPlot().getWorldName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public HandlerList getHandlers() {
|
@Override
|
||||||
return handlers;
|
public Result getEventResult() {
|
||||||
|
return eventResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean isCancelled() {
|
@Override
|
||||||
return this.cancelled;
|
public void setEventResult(Result e) {
|
||||||
}
|
this.eventResult = e;
|
||||||
|
|
||||||
@Override public void setCancelled(boolean b) {
|
|
||||||
this.cancelled = b;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a plot is cleared
|
||||||
|
*/
|
||||||
|
public class PlotDoneEvent extends PlotEvent implements CancellablePlotEvent {
|
||||||
|
|
||||||
|
private Result eventResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PlotDoneEvent: Called when a plot is being set as done
|
||||||
|
*
|
||||||
|
* @param plot The plot being set as done
|
||||||
|
*/
|
||||||
|
public PlotDoneEvent(Plot plot) {
|
||||||
|
super(plot);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the PlotId.
|
||||||
|
*
|
||||||
|
* @return PlotId
|
||||||
|
*/
|
||||||
|
public PlotId getPlotId() {
|
||||||
|
return getPlot().getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the world name.
|
||||||
|
*
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public String getWorld() {
|
||||||
|
return getPlot().getWorldName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public Result getEventResult() {
|
||||||
|
return eventResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void setEventResult(Result e) {
|
||||||
|
this.eventResult = e;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public abstract class PlotEvent {
|
||||||
|
|
||||||
|
private final Plot plot;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public PlotEvent(Plot plot) {
|
||||||
|
this.plot = plot;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the plot involved in the event
|
||||||
|
*
|
||||||
|
* @return Plot
|
||||||
|
*/
|
||||||
|
public final Plot getPlot() {
|
||||||
|
return this.plot;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the event's class name
|
||||||
|
*
|
||||||
|
* @return the event class name
|
||||||
|
*/
|
||||||
|
@NotNull public String getEventName() {
|
||||||
|
if (name == null) {
|
||||||
|
name = getClass().getSimpleName();
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a Flag is added to a plot.
|
||||||
|
*/
|
||||||
|
public class PlotFlagAddEvent extends PlotFlagEvent implements CancellablePlotEvent {
|
||||||
|
|
||||||
|
private Result eventResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PlotFlagAddEvent: Called when a Flag is added to a plot.
|
||||||
|
*
|
||||||
|
* @param flag Flag that was added
|
||||||
|
* @param plot Plot to which the flag was added
|
||||||
|
*/
|
||||||
|
public PlotFlagAddEvent(PlotFlag<?, ?> flag, Plot plot) {
|
||||||
|
super(plot, flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result getEventResult() {
|
||||||
|
return eventResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEventResult(Result e) {
|
||||||
|
this.eventResult = e;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a flag is removed from a plot
|
||||||
|
*/
|
||||||
|
public class PlotFlagRemoveEvent extends PlotFlagEvent implements CancellablePlotEvent {
|
||||||
|
|
||||||
|
private Result eventResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PlotFlagRemoveEvent: Called when a flag is removed from a plot
|
||||||
|
*
|
||||||
|
* @param flag Flag that was removed
|
||||||
|
* @param plot Plot from which the flag was removed
|
||||||
|
*/
|
||||||
|
public PlotFlagRemoveEvent(PlotFlag<?, ?> flag, Plot plot) {
|
||||||
|
super(plot, flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result getEventResult() {
|
||||||
|
return eventResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEventResult(Result e) {
|
||||||
|
this.eventResult = e;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Direction;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event called when several plots are merged
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public final class PlotMergeEvent extends PlotPlayerEvent implements CancellablePlotEvent {
|
||||||
|
|
||||||
|
@Getter private final String world;
|
||||||
|
@Getter @Setter private Direction dir;
|
||||||
|
@Getter @Setter private int max;
|
||||||
|
private Result eventResult;
|
||||||
|
@Getter private PlotPlayer player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PlotMergeEvent: Called when plots are merged
|
||||||
|
*
|
||||||
|
* @param world World in which the event occurred
|
||||||
|
* @param plot Plot that was merged
|
||||||
|
* @param dir The direction of the merge
|
||||||
|
* @param max Max merge size
|
||||||
|
* @param player The player attempting the merge
|
||||||
|
*/
|
||||||
|
public PlotMergeEvent(@NotNull final String world, @NotNull final Plot plot,
|
||||||
|
@NotNull final Direction dir, final int max, PlotPlayer player) {
|
||||||
|
super(player, plot);
|
||||||
|
this.world = world;
|
||||||
|
this.dir = dir;
|
||||||
|
this.max = max;
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override public Result getEventResult() {
|
||||||
|
return eventResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void setEventResult(Result e) {
|
||||||
|
this.eventResult = e;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
|
|
||||||
|
public abstract class PlotPlayerEvent extends PlotEvent {
|
||||||
|
|
||||||
|
private final PlotPlayer plotPlayer;
|
||||||
|
|
||||||
|
public PlotPlayerEvent(PlotPlayer plotPlayer, Plot plot) {
|
||||||
|
super(plot);
|
||||||
|
this.plotPlayer = plotPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlotPlayer getPlotPlayer() {
|
||||||
|
return this.plotPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.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.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public class PlotRateEvent extends PlotEvent implements CancellablePlotEvent {
|
||||||
|
|
||||||
|
private final PlotPlayer rater;
|
||||||
|
@Nullable private Rating rating;
|
||||||
|
private Result eventResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PlotRateEvent: Called when a player rates a plot
|
||||||
|
*
|
||||||
|
* @param rater The player rating the plot
|
||||||
|
* @param rating The rating being given
|
||||||
|
* @param plot The plot being rated
|
||||||
|
*/
|
||||||
|
public PlotRateEvent(PlotPlayer rater, @Nullable Rating rating, Plot plot) {
|
||||||
|
super(plot);
|
||||||
|
this.rater = rater;
|
||||||
|
this.rating = rating;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlotPlayer getRater() {
|
||||||
|
return this.rater;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable public Rating getRating() {
|
||||||
|
return this.rating;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRating(@Nullable Rating rating) {
|
||||||
|
this.rating = rating;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public Result getEventResult() {
|
||||||
|
return eventResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void setEventResult(Result e) {
|
||||||
|
this.eventResult = e;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event called when several merged plots are unlinked
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public final class PlotUnlinkEvent extends PlotEvent implements CancellablePlotEvent {
|
||||||
|
|
||||||
|
@Getter private final PlotArea area;
|
||||||
|
@Getter @Setter boolean createRoad;
|
||||||
|
@Getter @Setter boolean createSign;
|
||||||
|
@Getter REASON reason;
|
||||||
|
private Result eventResult = Result.ACCEPT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PlotUnlinkEvent: Called when a mega plot is unlinked
|
||||||
|
*
|
||||||
|
* @param area The applicable plot area
|
||||||
|
* @param plot The plot being unlinked from
|
||||||
|
* @param createRoad Whether to regenerate the road
|
||||||
|
* @param createSign Whether to regenerate signs
|
||||||
|
* @param reason The {@link REASON} for the unlink
|
||||||
|
*/
|
||||||
|
public PlotUnlinkEvent(@NotNull final PlotArea area, Plot plot, boolean createRoad,
|
||||||
|
boolean createSign, REASON reason) {
|
||||||
|
super(plot);
|
||||||
|
this.area = area;
|
||||||
|
this.createRoad = createRoad;
|
||||||
|
this.createSign = createSign;
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public Result getEventResult() {
|
||||||
|
return eventResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void setEventResult(Result e) {
|
||||||
|
this.eventResult = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum REASON {
|
||||||
|
NEW_OWNER, PLAYER_COMMAND, CLEAR, DELETE, EXPIRE_DELETE
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.events;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enum for {@link CancellablePlotEvent}.
|
||||||
|
* <p>
|
||||||
|
* DENY: do not allow the event to happen
|
||||||
|
* ALLOW: allow the event to continue as normal, subject to standard checks
|
||||||
|
* FORCE: force the event to occur, even if normal checks would deny.
|
||||||
|
* WARNING: this may have unintended consequences! Make sure you study the appropriate code before using!
|
||||||
|
*/
|
||||||
|
public enum Result {
|
||||||
|
|
||||||
|
DENY(0), ACCEPT(1), FORCE(2);
|
||||||
|
|
||||||
|
private static Map<Integer, Result> map = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (Result eventResult : Result.values()) {
|
||||||
|
map.put(eventResult.value, eventResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int value;
|
||||||
|
|
||||||
|
Result(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the Result enum associated with the int value
|
||||||
|
*
|
||||||
|
* @param eventResult the int value
|
||||||
|
* @return the corresponding Result
|
||||||
|
*/
|
||||||
|
public static Result valueOf(int eventResult) {
|
||||||
|
return map.get(eventResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get int value of enum
|
||||||
|
*
|
||||||
|
* @return integer value
|
||||||
|
*/
|
||||||
|
public int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,10 @@ package com.github.intellectualsites.plotsquared.plot.generator;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotFlagAddEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
|
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnalysisFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnalysisFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.listener.WEExtent;
|
import com.github.intellectualsites.plotsquared.plot.listener.WEExtent;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
@ -288,7 +291,14 @@ public abstract class HybridUtils {
|
|||||||
result.add(whenDone.value.data_sd);
|
result.add(whenDone.value.data_sd);
|
||||||
result.add(whenDone.value.air_sd);
|
result.add(whenDone.value.air_sd);
|
||||||
result.add(whenDone.value.variety_sd);
|
result.add(whenDone.value.variety_sd);
|
||||||
origin.setFlag(GlobalFlagContainer.getInstance().getFlag(AnalysisFlag.class).createFlagInstance(result));
|
PlotFlag<?, ?> plotFlag =
|
||||||
|
GlobalFlagContainer.getInstance().getFlag(AnalysisFlag.class)
|
||||||
|
.createFlagInstance(result);
|
||||||
|
PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, origin);
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
origin.setFlag(event.getFlag());
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,33 +1,20 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.listener;
|
package com.github.intellectualsites.plotsquared.plot.listener;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyExitFlag;
|
import com.github.intellectualsites.plotsquared.plot.events.PlotFlagRemoveEvent;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.FarewellFlag;
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.FlightFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.GamemodeFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.GreetingFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.GuestGamemodeFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.types.TimedFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MusicFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.NotifyEnterFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.NotifyLeaveFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.WeatherFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TimeFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TitlesFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.ByteArrayUtilities;
|
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.CommentManager;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
@ -35,11 +22,60 @@ import com.sk89q.worldedit.world.item.ItemType;
|
|||||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlotListener {
|
public class PlotListener {
|
||||||
|
|
||||||
|
private static final HashMap<UUID, Interval> feedRunnable = new HashMap<>();
|
||||||
|
private static final HashMap<UUID, Interval> healRunnable = new HashMap<>();
|
||||||
|
|
||||||
|
public static void startRunnable() {
|
||||||
|
TaskManager.runTaskRepeat(() -> {
|
||||||
|
if (!healRunnable.isEmpty()) {
|
||||||
|
for (Iterator<Map.Entry<UUID, Interval>> iterator =
|
||||||
|
healRunnable.entrySet().iterator(); iterator.hasNext(); ) {
|
||||||
|
Map.Entry<UUID, Interval> entry = iterator.next();
|
||||||
|
Interval value = entry.getValue();
|
||||||
|
++value.count;
|
||||||
|
if (value.count == value.interval) {
|
||||||
|
value.count = 0;
|
||||||
|
PlotPlayer player = WorldUtil.IMP.wrapPlayer(entry.getKey());
|
||||||
|
if (player == null) {
|
||||||
|
iterator.remove();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
double level = WorldUtil.IMP.getHealth(player);
|
||||||
|
if (level != value.max) {
|
||||||
|
WorldUtil.IMP.setHealth(player, Math.min(level + value.amount, value.max));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!feedRunnable.isEmpty()) {
|
||||||
|
for (Iterator<Map.Entry<UUID, Interval>> iterator =
|
||||||
|
feedRunnable.entrySet().iterator(); iterator.hasNext(); ) {
|
||||||
|
Map.Entry<UUID, Interval> entry = iterator.next();
|
||||||
|
Interval value = entry.getValue();
|
||||||
|
++value.count;
|
||||||
|
if (value.count == value.interval) {
|
||||||
|
value.count = 0;
|
||||||
|
PlotPlayer player = WorldUtil.IMP.wrapPlayer(entry.getKey());
|
||||||
|
if (player == null) {
|
||||||
|
iterator.remove();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int level = WorldUtil.IMP.getFoodLevel(player);
|
||||||
|
if (level != value.max) {
|
||||||
|
WorldUtil.IMP.setFoodLevel(player, Math.min(level + value.amount, value.max));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 20);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean plotEntry(final PlotPlayer player, final Plot plot) {
|
public static boolean plotEntry(final PlotPlayer player, final Plot plot) {
|
||||||
if (plot.isDenied(player.getUUID()) && !Permissions
|
if (plot.isDenied(player.getUUID()) && !Permissions
|
||||||
.hasPermission(player, "plots.admin.entry.denied")) {
|
.hasPermission(player, "plots.admin.entry.denied")) {
|
||||||
@ -53,7 +89,7 @@ public class PlotListener {
|
|||||||
ExpireManager.IMP.handleEntry(player, plot);
|
ExpireManager.IMP.handleEntry(player, plot);
|
||||||
}
|
}
|
||||||
player.setMeta(PlotPlayer.META_LAST_PLOT, plot);
|
player.setMeta(PlotPlayer.META_LAST_PLOT, plot);
|
||||||
EventUtil.manager.callEntry(player, plot);
|
PlotSquared.get().getEventDispatcher().callEntry(player, plot);
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
// This will inherit values from PlotArea
|
// This will inherit values from PlotArea
|
||||||
final TitlesFlag.TitlesFlagValue titleFlag = plot.getFlag(TitlesFlag.class);
|
final TitlesFlag.TitlesFlagValue titleFlag = plot.getFlag(TitlesFlag.class);
|
||||||
@ -131,7 +167,13 @@ public class PlotListener {
|
|||||||
try {
|
try {
|
||||||
player.setTime(time);
|
player.setTime(time);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
plot.removeFlag(TimeFlag.class);
|
PlotFlag<?, ?> plotFlag =
|
||||||
|
GlobalFlagContainer.getInstance().getFlag(TimeFlag.class);
|
||||||
|
PlotFlagRemoveEvent event =
|
||||||
|
PlotSquared.get().getEventDispatcher().callFlagRemove(plotFlag, plot);
|
||||||
|
if (event.getEventResult() != Result.DENY) {
|
||||||
|
plot.removeFlag(event.getFlag());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,6 +232,15 @@ public class PlotListener {
|
|||||||
}, 20);
|
}, 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TimedFlag.Timed<Integer> feed = plot.getFlag(FeedFlag.class);
|
||||||
|
if (feed != null && feed.getInterval() != 0 && feed.getValue() != 0) {
|
||||||
|
feedRunnable.put(player.getUUID(), new Interval(feed.getInterval(), feed.getValue(), 20));
|
||||||
|
}
|
||||||
|
TimedFlag.Timed<Integer> heal = plot.getFlag(HealFlag.class);
|
||||||
|
if (heal != null && heal.getInterval() != 0 && heal.getValue() != 0) {
|
||||||
|
healRunnable.put(player.getUUID(), new Interval(heal.getInterval(), heal.getValue(), 20));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -197,7 +248,7 @@ public class PlotListener {
|
|||||||
|
|
||||||
public static boolean plotExit(final PlotPlayer player, Plot plot) {
|
public static boolean plotExit(final PlotPlayer player, Plot plot) {
|
||||||
Object previous = player.deleteMeta(PlotPlayer.META_LAST_PLOT);
|
Object previous = player.deleteMeta(PlotPlayer.META_LAST_PLOT);
|
||||||
EventUtil.manager.callLeave(player, plot);
|
PlotSquared.get().getEventDispatcher().callLeave(player, plot);
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
PlotArea pw = plot.getArea();
|
PlotArea pw = plot.getArea();
|
||||||
if (pw == null) {
|
if (pw == null) {
|
||||||
@ -277,7 +328,29 @@ public class PlotListener {
|
|||||||
player.deleteMeta("music");
|
player.deleteMeta("music");
|
||||||
player.playMusic(lastLoc, ItemTypes.AIR);
|
player.playMusic(lastLoc, ItemTypes.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
feedRunnable.remove(player.getUUID());
|
||||||
|
healRunnable.remove(player.getUUID());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void logout(UUID uuid) {
|
||||||
|
feedRunnable.remove(uuid);
|
||||||
|
healRunnable.remove(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Interval {
|
||||||
|
|
||||||
|
final int interval;
|
||||||
|
final int amount;
|
||||||
|
final int max;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
Interval(int interval, int amount, int max) {
|
||||||
|
this.interval = interval;
|
||||||
|
this.amount = amount;
|
||||||
|
this.max = max;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.object;
|
package com.github.intellectualsites.plotsquared.plot.object;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Configuration;
|
import com.github.intellectualsites.plotsquared.plot.config.Configuration;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotComponentSetEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotMergeEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotUnlinkEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.FlagContainer;
|
import com.github.intellectualsites.plotsquared.plot.flags.FlagContainer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
|
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.InternalFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.InternalFlag;
|
||||||
@ -14,16 +19,7 @@ import com.github.intellectualsites.plotsquared.plot.generator.SquarePlotWorld;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
|
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
|
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||||
@ -66,6 +62,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.github.intellectualsites.plotsquared.plot.commands.SubCommand.sendMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plot class<br>
|
* The plot class<br>
|
||||||
* [IMPORTANT]
|
* [IMPORTANT]
|
||||||
@ -826,11 +824,6 @@ public class Plot {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public boolean setOwner(UUID owner, PlotPlayer initiator) {
|
public boolean setOwner(UUID owner, PlotPlayer initiator) {
|
||||||
boolean result = EventUtil.manager
|
|
||||||
.callOwnerChange(initiator, this, owner, hasOwner() ? this.owner : null, hasOwner());
|
|
||||||
if (!result) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!hasOwner()) {
|
if (!hasOwner()) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
create();
|
create();
|
||||||
@ -867,22 +860,18 @@ public class Plot {
|
|||||||
if (checkRunning && this.getRunning() != 0) {
|
if (checkRunning && this.getRunning() != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (isDelete) {
|
|
||||||
if (!EventUtil.manager.callDelete(this)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!EventUtil.manager.callClear(this)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final Set<CuboidRegion> regions = this.getRegions();
|
final Set<CuboidRegion> regions = this.getRegions();
|
||||||
final Set<Plot> plots = this.getConnectedPlots();
|
final Set<Plot> plots = this.getConnectedPlots();
|
||||||
final ArrayDeque<Plot> queue = new ArrayDeque<>(plots);
|
final ArrayDeque<Plot> queue = new ArrayDeque<>(plots);
|
||||||
if (isDelete) {
|
if (isDelete) {
|
||||||
this.removeSign();
|
this.removeSign();
|
||||||
}
|
}
|
||||||
this.unlinkPlot(true, !isDelete);
|
PlotUnlinkEvent event = PlotSquared.get().getEventDispatcher()
|
||||||
|
.callUnlink(getArea(), this, true, !isDelete,
|
||||||
|
isDelete ? PlotUnlinkEvent.REASON.DELETE : PlotUnlinkEvent.REASON.CLEAR);
|
||||||
|
if (event.getEventResult() != Result.DENY) {
|
||||||
|
this.unlinkPlot(event.isCreateRoad(), event.isCreateSign());
|
||||||
|
}
|
||||||
final PlotManager manager = this.area.getPlotManager();
|
final PlotManager manager = this.area.getPlotManager();
|
||||||
Runnable run = new Runnable() {
|
Runnable run = new Runnable() {
|
||||||
@Override public void run() {
|
@Override public void run() {
|
||||||
@ -996,10 +985,6 @@ public class Plot {
|
|||||||
current.setHome(null);
|
current.setHome(null);
|
||||||
ids.add(current.getId());
|
ids.add(current.getId());
|
||||||
}
|
}
|
||||||
boolean result = EventUtil.manager.callUnlink(this.area, ids);
|
|
||||||
if (!result) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this.clearRatings();
|
this.clearRatings();
|
||||||
if (createSign) {
|
if (createSign) {
|
||||||
this.removeSign();
|
this.removeSign();
|
||||||
@ -1105,9 +1090,6 @@ public class Plot {
|
|||||||
* @return A boolean indicating whether or not the operation succeeded
|
* @return A boolean indicating whether or not the operation succeeded
|
||||||
*/
|
*/
|
||||||
public <V> boolean setFlag(PlotFlag<V, ?> flag) {
|
public <V> boolean setFlag(PlotFlag<V, ?> flag) {
|
||||||
if (!EventUtil.manager.callFlagAdd(flag, origin)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (flag instanceof KeepFlag && ExpireManager.IMP != null) {
|
if (flag instanceof KeepFlag && ExpireManager.IMP != null) {
|
||||||
ExpireManager.IMP.updateExpired(this);
|
ExpireManager.IMP.updateExpired(this);
|
||||||
}
|
}
|
||||||
@ -1205,13 +1187,6 @@ public class Plot {
|
|||||||
if (value == null) {
|
if (value == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (plot == origin) {
|
|
||||||
boolean result = EventUtil.manager.callFlagRemove(flag, plot, value);
|
|
||||||
if (!result) {
|
|
||||||
plot.getFlagContainer().addFlag(flag);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
plot.reEnter();
|
plot.reEnter();
|
||||||
DBFunc.removeFlag(plot, flag);
|
DBFunc.removeFlag(plot, flag);
|
||||||
removed = true;
|
removed = true;
|
||||||
@ -1613,9 +1588,9 @@ public class Plot {
|
|||||||
|
|
||||||
public boolean claim(final PlotPlayer player, boolean teleport, String schematic,
|
public boolean claim(final PlotPlayer player, boolean teleport, String schematic,
|
||||||
boolean updateDB) {
|
boolean updateDB) {
|
||||||
boolean result = EventUtil.manager.callClaim(player, this, false);
|
|
||||||
if (updateDB) {
|
if (updateDB) {
|
||||||
if (!result || (!create(player.getUUID(), true))) {
|
if (!create(player.getUUID(), true)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1689,7 +1664,14 @@ public class Plot {
|
|||||||
DBFunc.createPlotAndSettings(this, () -> {
|
DBFunc.createPlotAndSettings(this, () -> {
|
||||||
PlotArea plotworld = Plot.this.area;
|
PlotArea plotworld = Plot.this.area;
|
||||||
if (notify && plotworld.AUTO_MERGE) {
|
if (notify && plotworld.AUTO_MERGE) {
|
||||||
Plot.this.autoMerge(Direction.ALL, Integer.MAX_VALUE, uuid, true);
|
PlotPlayer player = WorldUtil.IMP.wrapPlayer(uuid);
|
||||||
|
PlotMergeEvent event = PlotSquared.get().getEventDispatcher()
|
||||||
|
.callMerge(this, Direction.ALL, Integer.MAX_VALUE, player);
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Auto merge on claim");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Plot.this.autoMerge(event.getDir(), event.getMax(), uuid, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
@ -2338,10 +2320,6 @@ public class Plot {
|
|||||||
if (this.owner == null) {
|
if (this.owner == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//Call the merge event
|
|
||||||
if (!EventUtil.manager.callMerge(this, dir.getIndex(), max)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Set<Plot> connected = this.getConnectedPlots();
|
Set<Plot> connected = this.getConnectedPlots();
|
||||||
HashSet<PlotId> merged =
|
HashSet<PlotId> merged =
|
||||||
connected.stream().map(Plot::getId).collect(Collectors.toCollection(HashSet::new));
|
connected.stream().map(Plot::getId).collect(Collectors.toCollection(HashSet::new));
|
||||||
@ -2899,8 +2877,12 @@ public class Plot {
|
|||||||
*/
|
*/
|
||||||
public boolean teleportPlayer(final PlotPlayer player, TeleportCause cause) {
|
public boolean teleportPlayer(final PlotPlayer player, TeleportCause cause) {
|
||||||
Plot plot = this.getBasePlot(false);
|
Plot plot = this.getBasePlot(false);
|
||||||
boolean result = EventUtil.manager.callTeleport(player, player.getLocation(), plot);
|
Result result =
|
||||||
if (result) {
|
PlotSquared.get().getEventDispatcher().callTeleport(player, player.getLocation(), plot).getEventResult();
|
||||||
|
if (result == Result.DENY) {
|
||||||
|
sendMessage(player, Captions.EVENT_DENIED, "Teleport");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
final Location location;
|
final Location location;
|
||||||
if (this.area.HOME_ALLOW_NONMEMBER || plot.isAdded(player.getUUID())) {
|
if (this.area.HOME_ALLOW_NONMEMBER || plot.isAdded(player.getUUID())) {
|
||||||
location = this.getHome();
|
location = this.getHome();
|
||||||
@ -2913,8 +2895,7 @@ public class Plot {
|
|||||||
player.teleport(location, cause);
|
player.teleport(location, cause);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
MainUtil
|
MainUtil.sendMessage(player, Captions.TELEPORT_IN_SECONDS, Settings.Teleport.DELAY + "");
|
||||||
.sendMessage(player, Captions.TELEPORT_IN_SECONDS, Settings.Teleport.DELAY + "");
|
|
||||||
final String name = player.getName();
|
final String name = player.getName();
|
||||||
TaskManager.TELEPORT_QUEUE.add(name);
|
TaskManager.TELEPORT_QUEUE.add(name);
|
||||||
TaskManager.runTaskLater(() -> {
|
TaskManager.runTaskLater(() -> {
|
||||||
@ -2930,8 +2911,6 @@ public class Plot {
|
|||||||
}, Settings.Teleport.DELAY * 20);
|
}, Settings.Teleport.DELAY * 20);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the owner of this Plot is online.
|
* Checks if the owner of this Plot is online.
|
||||||
@ -2963,9 +2942,9 @@ public class Plot {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean setComponent(String component, Pattern blocks) {
|
public boolean setComponent(String component, Pattern blocks) {
|
||||||
if (StringMan.isEqualToAny(component, getManager().getPlotComponents(this.getId()))) {
|
PlotComponentSetEvent event = PlotSquared.get().getEventDispatcher().callComponentSet(this, component, blocks);
|
||||||
EventUtil.manager.callComponentSet(this, component);
|
component = event.getComponent();
|
||||||
}
|
blocks = event.getPattern();
|
||||||
return this.getManager().setComponent(this.getId(), component, blocks);
|
return this.getManager().setComponent(this.getId(), component, blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneF
|
|||||||
import com.github.intellectualsites.plotsquared.plot.generator.GridPlotWorld;
|
import com.github.intellectualsites.plotsquared.plot.generator.GridPlotWorld;
|
||||||
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
|
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
@ -828,11 +827,6 @@ public abstract class PlotArea {
|
|||||||
final PlotId pos2 = plotIds.get(plotIds.size() - 1);
|
final PlotId pos2 = plotIds.get(plotIds.size() - 1);
|
||||||
final PlotManager manager = getPlotManager();
|
final PlotManager manager = getPlotManager();
|
||||||
|
|
||||||
final boolean result = EventUtil.manager.callAutoMerge(getPlotAbs(pos1), plotIds);
|
|
||||||
if (!result) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
manager.startPlotMerge(plotIds);
|
manager.startPlotMerge(plotIds);
|
||||||
final Set<UUID> trusted = new HashSet<>();
|
final Set<UUID> trusted = new HashSet<>();
|
||||||
final Set<UUID> members = new HashSet<>();
|
final Set<UUID> members = new HashSet<>();
|
||||||
|
@ -12,7 +12,6 @@ import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManag
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager;
|
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
@ -522,7 +521,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
removePersistentMeta("quitLoc");
|
removePersistentMeta("quitLoc");
|
||||||
}
|
}
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
EventUtil.manager.callLeave(this, plot);
|
PlotSquared.get().getEventDispatcher().callLeave(this, plot);
|
||||||
}
|
}
|
||||||
if (Settings.Enabled_Components.BAN_DELETER && isBanned()) {
|
if (Settings.Enabled_Components.BAN_DELETER && isBanned()) {
|
||||||
for (Plot owned : getPlots()) {
|
for (Plot owned : getPlots()) {
|
||||||
|
@ -4,77 +4,171 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
|
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DeviceInteractFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscPlaceFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobPlaceFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PlaceFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UseFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehiclePlaceFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.types.BlockTypeWrapper;
|
import com.github.intellectualsites.plotsquared.plot.flags.types.BlockTypeWrapper;
|
||||||
import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType;
|
import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Rating;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||||
|
import com.google.common.eventbus.EventBus;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public abstract class EventUtil {
|
public class EventDispatcher {
|
||||||
|
|
||||||
public static EventUtil manager = null;
|
private EventBus eventBus = new EventBus("PlotSquaredEvents");
|
||||||
|
|
||||||
/**
|
private List<Object> listeners = new ArrayList<>();
|
||||||
* Submit a plot rate event and return the updated rating
|
|
||||||
*
|
|
||||||
* @param player Player that rated the plot
|
|
||||||
* @param plot Plot that was rated
|
|
||||||
* @param rating Rating given to the plot
|
|
||||||
* @return Updated rating or null if the event was cancelled
|
|
||||||
*/
|
|
||||||
@Nullable public abstract Rating callRating(PlotPlayer player, Plot plot, Rating rating);
|
|
||||||
|
|
||||||
public abstract boolean callClaim(PlotPlayer player, Plot plot, boolean auto);
|
public void registerListener(Object listener) {
|
||||||
|
eventBus.register(listener);
|
||||||
|
listeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract boolean callTeleport(PlotPlayer player, Location from, Plot plot);
|
public void unregisterListener(Object listener) {
|
||||||
|
eventBus.unregister(listener);
|
||||||
|
listeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract boolean callComponentSet(Plot plot, String component);
|
public void unregisterAll() {
|
||||||
|
for (Object listener : listeners) {
|
||||||
|
eventBus.unregister(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public abstract boolean callClear(Plot plot);
|
public void callEvent(@NotNull final PlotEvent event) {
|
||||||
|
eventBus.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract boolean callDelete(Plot plot);
|
public PlayerClaimPlotEvent callClaim(PlotPlayer player, Plot plot, String schematic) {
|
||||||
|
PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, schematic);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract boolean callFlagAdd(PlotFlag<?, ?> flag, Plot plot);
|
public PlayerAutoPlotEvent callAuto(PlotPlayer player, PlotArea area, String schematic,
|
||||||
|
int size_x, int size_z) {
|
||||||
|
PlayerAutoPlotEvent event =
|
||||||
|
new PlayerAutoPlotEvent(player, area, schematic, size_x, size_z);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract boolean callFlagRemove(PlotFlag<?, ?> flag, Plot plot, Object value);
|
public PlayerTeleportToPlotEvent callTeleport(PlotPlayer player, Location from, Plot plot) {
|
||||||
|
PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player, from, plot);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract boolean callMerge(Plot plot, int dir, int max);
|
public PlotComponentSetEvent callComponentSet(Plot plot, String component, Pattern pattern) {
|
||||||
|
PlotComponentSetEvent event = new PlotComponentSetEvent(plot, component, pattern);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract boolean callAutoMerge(Plot plot, List<PlotId> plots);
|
public PlotClearEvent callClear(Plot plot) {
|
||||||
|
PlotClearEvent event = new PlotClearEvent(plot);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract boolean callUnlink(PlotArea area, List<PlotId> plots);
|
public PlotDeleteEvent callDelete(Plot plot) {
|
||||||
|
PlotDeleteEvent event = new PlotDeleteEvent(plot);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void callEntry(PlotPlayer player, Plot plot);
|
public PlotFlagAddEvent callFlagAdd(PlotFlag<?, ?> flag, Plot plot) {
|
||||||
|
PlotFlagAddEvent event = new PlotFlagAddEvent(flag, plot);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void callLeave(PlotPlayer player, Plot plot);
|
public PlotFlagRemoveEvent callFlagRemove(PlotFlag<?, ?> flag, Plot plot) {
|
||||||
|
PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(flag, plot);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void callDenied(PlotPlayer initiator, Plot plot, UUID player, boolean added);
|
public PlotMergeEvent callMerge(Plot plot, Direction dir, int max, PlotPlayer player) {
|
||||||
|
PlotMergeEvent event = new PlotMergeEvent(plot.getWorldName(), plot, dir, max, player);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added);
|
public PlotAutoMergeEvent callAutoMerge(Plot plot, List<PlotId> plots) {
|
||||||
|
PlotAutoMergeEvent event = new PlotAutoMergeEvent(plot.getWorldName(), plot, plots);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added);
|
public PlotUnlinkEvent callUnlink(PlotArea area, Plot plot, boolean createRoad,
|
||||||
|
boolean createSign, PlotUnlinkEvent.REASON reason) {
|
||||||
|
PlotUnlinkEvent event = new PlotUnlinkEvent(area, plot, createRoad, createSign, reason);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract boolean callOwnerChange(PlotPlayer initiator, Plot plot, UUID newOwner,
|
public PlayerEnterPlotEvent callEntry(PlotPlayer player, Plot plot) {
|
||||||
UUID oldOwner, boolean hasOldOwner);
|
PlayerEnterPlotEvent event = new PlayerEnterPlotEvent(player, plot);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerLeavePlotEvent callLeave(PlotPlayer player, Plot plot) {
|
||||||
|
PlayerLeavePlotEvent event = new PlayerLeavePlotEvent(player, plot);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerPlotDeniedEvent callDenied(PlotPlayer initiator, Plot plot, UUID player,
|
||||||
|
boolean added) {
|
||||||
|
PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(initiator, plot, player, added);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerPlotTrustedEvent callTrusted(PlotPlayer initiator, Plot plot, UUID player,
|
||||||
|
boolean added) {
|
||||||
|
PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(initiator, plot, player, added);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerPlotHelperEvent callMember(PlotPlayer initiator, Plot plot, UUID player,
|
||||||
|
boolean added) {
|
||||||
|
PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(initiator, plot, player, added);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlotChangeOwnerEvent callOwnerChange(PlotPlayer initiator, Plot plot, UUID oldOwner,
|
||||||
|
UUID newOwner, boolean hasOldOwner) {
|
||||||
|
PlotChangeOwnerEvent event =
|
||||||
|
new PlotChangeOwnerEvent(initiator, plot, oldOwner, newOwner, hasOldOwner);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlotRateEvent callRating(PlotPlayer player, Plot plot, Rating rating) {
|
||||||
|
PlotRateEvent event = new PlotRateEvent(player, rating, plot);
|
||||||
|
eventBus.post(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlotDoneEvent callDone(Plot plot) {
|
||||||
|
PlotDoneEvent event = new PlotDoneEvent(plot);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public void doJoinTask(final PlotPlayer player) {
|
public void doJoinTask(final PlotPlayer player) {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
@ -93,8 +187,8 @@ public abstract class EventUtil {
|
|||||||
.getArea() instanceof SinglePlotArea)) {
|
.getArea() instanceof SinglePlotArea)) {
|
||||||
TaskManager.runTask(() -> plot.teleportPlayer(player));
|
TaskManager.runTask(() -> plot.teleportPlayer(player));
|
||||||
MainUtil.sendMessage(player,
|
MainUtil.sendMessage(player,
|
||||||
CaptionUtility.format(player, Captions.TELEPORTED_TO_ROAD.getTranslated()) + " (on-login) " + "(" + plot.getId().x + ";" + plot
|
CaptionUtility.format(player, Captions.TELEPORTED_TO_ROAD.getTranslated())
|
||||||
.getId().y + ")");
|
+ " (on-login) " + "(" + plot.getId().x + ";" + plot.getId().y + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,13 +226,15 @@ public abstract class EventUtil {
|
|||||||
}
|
}
|
||||||
final List<BlockTypeWrapper> use = plot.getFlag(UseFlag.class);
|
final List<BlockTypeWrapper> use = plot.getFlag(UseFlag.class);
|
||||||
for (final BlockTypeWrapper blockTypeWrapper : use) {
|
for (final BlockTypeWrapper blockTypeWrapper : use) {
|
||||||
if (blockTypeWrapper.accepts(BlockTypes.AIR) || blockTypeWrapper.accepts(blockType)) {
|
if (blockTypeWrapper.accepts(BlockTypes.AIR) || blockTypeWrapper
|
||||||
|
.accepts(blockType)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Permissions.hasPermission(player,
|
return Permissions
|
||||||
Captions.PERMISSION_ADMIN_INTERACT_OTHER.getTranslated(), false) || !(
|
.hasPermission(player, Captions.PERMISSION_ADMIN_INTERACT_OTHER.getTranslated(),
|
||||||
!notifyPerms || MainUtil.sendMessage(player, Captions.FLAG_TUTORIAL_USAGE,
|
false) || !(!notifyPerms || MainUtil
|
||||||
|
.sendMessage(player, Captions.FLAG_TUTORIAL_USAGE,
|
||||||
Captions.FLAG_USE.getTranslated()));
|
Captions.FLAG_USE.getTranslated()));
|
||||||
}
|
}
|
||||||
case TRIGGER_PHYSICAL: {
|
case TRIGGER_PHYSICAL: {
|
||||||
@ -155,12 +251,14 @@ public abstract class EventUtil {
|
|||||||
}
|
}
|
||||||
List<BlockTypeWrapper> use = plot.getFlag(UseFlag.class);
|
List<BlockTypeWrapper> use = plot.getFlag(UseFlag.class);
|
||||||
for (final BlockTypeWrapper blockTypeWrapper : use) {
|
for (final BlockTypeWrapper blockTypeWrapper : use) {
|
||||||
if (blockTypeWrapper.accepts(BlockTypes.AIR) || blockTypeWrapper.accepts(blockType)) {
|
if (blockTypeWrapper.accepts(BlockTypes.AIR) || blockTypeWrapper
|
||||||
|
.accepts(blockType)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Permissions.hasPermission(player,
|
return Permissions
|
||||||
Captions.PERMISSION_ADMIN_INTERACT_OTHER.getTranslated(), false);
|
.hasPermission(player, Captions.PERMISSION_ADMIN_INTERACT_OTHER.getTranslated(),
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
case SPAWN_MOB: {
|
case SPAWN_MOB: {
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
@ -176,16 +274,17 @@ public abstract class EventUtil {
|
|||||||
}
|
}
|
||||||
List<BlockTypeWrapper> place = plot.getFlag(PlaceFlag.class);
|
List<BlockTypeWrapper> place = plot.getFlag(PlaceFlag.class);
|
||||||
for (final BlockTypeWrapper blockTypeWrapper : place) {
|
for (final BlockTypeWrapper blockTypeWrapper : place) {
|
||||||
if (blockTypeWrapper.accepts(BlockTypes.AIR) || blockTypeWrapper.accepts(blockType)) {
|
if (blockTypeWrapper.accepts(BlockTypes.AIR) || blockTypeWrapper
|
||||||
|
.accepts(blockType)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Permissions.hasPermission(player,
|
if (Permissions
|
||||||
Captions.PERMISSION_ADMIN_INTERACT_OTHER.getTranslated(), false)) {
|
.hasPermission(player, Captions.PERMISSION_ADMIN_INTERACT_OTHER.getTranslated(),
|
||||||
|
false)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return !(!notifyPerms || MainUtil
|
return !(!notifyPerms || MainUtil.sendMessage(player, Captions.FLAG_TUTORIAL_USAGE,
|
||||||
.sendMessage(player, Captions.FLAG_TUTORIAL_USAGE,
|
|
||||||
Captions.FLAG_MOB_PLACE.getTranslated() + '/' + Captions.FLAG_PLACE
|
Captions.FLAG_MOB_PLACE.getTranslated() + '/' + Captions.FLAG_PLACE
|
||||||
.getTranslated()));
|
.getTranslated()));
|
||||||
}
|
}
|
||||||
@ -203,16 +302,17 @@ public abstract class EventUtil {
|
|||||||
}
|
}
|
||||||
List<BlockTypeWrapper> place = plot.getFlag(PlaceFlag.class);
|
List<BlockTypeWrapper> place = plot.getFlag(PlaceFlag.class);
|
||||||
for (final BlockTypeWrapper blockTypeWrapper : place) {
|
for (final BlockTypeWrapper blockTypeWrapper : place) {
|
||||||
if (blockTypeWrapper.accepts(BlockTypes.AIR) || blockTypeWrapper.accepts(blockType)) {
|
if (blockTypeWrapper.accepts(BlockTypes.AIR) || blockTypeWrapper
|
||||||
|
.accepts(blockType)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Permissions.hasPermission(player,
|
if (Permissions
|
||||||
Captions.PERMISSION_ADMIN_INTERACT_OTHER.getTranslated(), false)) {
|
.hasPermission(player, Captions.PERMISSION_ADMIN_INTERACT_OTHER.getTranslated(),
|
||||||
|
false)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return !(!notifyPerms || MainUtil
|
return !(!notifyPerms || MainUtil.sendMessage(player, Captions.FLAG_TUTORIAL_USAGE,
|
||||||
.sendMessage(player, Captions.FLAG_TUTORIAL_USAGE,
|
|
||||||
Captions.FLAG_MISC_PLACE.getTranslated() + '/' + Captions.FLAG_PLACE
|
Captions.FLAG_MISC_PLACE.getTranslated() + '/' + Captions.FLAG_PLACE
|
||||||
.getTranslated()));
|
.getTranslated()));
|
||||||
}
|
}
|
@ -3,6 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.util;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem;
|
import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
@ -157,4 +158,14 @@ public abstract class WorldUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean isBlockSame(BlockState block1, BlockState block2);
|
public abstract boolean isBlockSame(BlockState block1, BlockState block2);
|
||||||
|
|
||||||
|
public abstract PlotPlayer wrapPlayer(UUID uuid);
|
||||||
|
|
||||||
|
public abstract double getHealth(PlotPlayer player);
|
||||||
|
|
||||||
|
public abstract void setHealth(PlotPlayer player, double health);
|
||||||
|
|
||||||
|
public abstract int getFoodLevel(PlotPlayer player);
|
||||||
|
|
||||||
|
public abstract void setFoodLevel(PlotPlayer player, int foodLevel);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,11 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotFlagAddEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.PlotUnlinkEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.Result;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
|
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnalysisFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnalysisFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.KeepFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.KeepFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
|
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
|
||||||
@ -306,8 +310,13 @@ public class ExpireManager {
|
|||||||
confirmation);
|
confirmation);
|
||||||
}
|
}
|
||||||
}, () -> {
|
}, () -> {
|
||||||
newPlot.setFlag(GlobalFlagContainer.getInstance()
|
PlotFlag<?, ?> plotFlag = GlobalFlagContainer.getInstance()
|
||||||
.getFlag(AnalysisFlag.class).createFlagInstance(changed.asList()));
|
.getFlag(AnalysisFlag.class).createFlagInstance(changed.asList());
|
||||||
|
PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, newPlot);
|
||||||
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
newPlot.setFlag(event.getFlag());
|
||||||
TaskManager.runTaskLaterAsync(task, 20);
|
TaskManager.runTaskLaterAsync(task, 20);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -366,7 +375,12 @@ public class ExpireManager {
|
|||||||
|
|
||||||
public void deleteWithMessage(Plot plot, Runnable whenDone) {
|
public void deleteWithMessage(Plot plot, Runnable whenDone) {
|
||||||
if (plot.isMerged()) {
|
if (plot.isMerged()) {
|
||||||
plot.unlinkPlot(true, false);
|
PlotUnlinkEvent event = PlotSquared.get().getEventDispatcher()
|
||||||
|
.callUnlink(plot.getArea(), plot, true, false,
|
||||||
|
PlotUnlinkEvent.REASON.EXPIRE_DELETE);
|
||||||
|
if (event.getEventResult() != Result.DENY) {
|
||||||
|
plot.unlinkPlot(event.isCreateRoad(), event.isCreateSign());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (UUID helper : plot.getTrusted()) {
|
for (UUID helper : plot.getTrusted()) {
|
||||||
PlotPlayer player = UUIDHandler.getPlayer(helper);
|
PlotPlayer player = UUIDHandler.getPlayer(helper);
|
||||||
|
@ -2,8 +2,6 @@ package com.github.intellectualsites.plotsquared.plot;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.AbstractDBTest;
|
import com.github.intellectualsites.plotsquared.plot.database.AbstractDBTest;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtilTest;
|
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
@ -14,7 +12,7 @@ public class FlagTest {
|
|||||||
private ItemType testBlock;
|
private ItemType testBlock;
|
||||||
|
|
||||||
@Before public void setUp() throws Exception {
|
@Before public void setUp() throws Exception {
|
||||||
EventUtil.manager = new EventUtilTest();
|
//EventUtil.manager = new EventUtilTest();
|
||||||
DBFunc.dbManager = new AbstractDBTest();
|
DBFunc.dbManager = new AbstractDBTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,101 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.util;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.events.*;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class EventDispatcherTest extends EventDispatcher {
|
||||||
|
|
||||||
|
@Override public PlotRateEvent callRating(PlotPlayer player, Plot plot, Rating rating) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlayerClaimPlotEvent callClaim(PlotPlayer player, Plot plot, String schematic) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlayerAutoPlotEvent callAuto(PlotPlayer player, PlotArea area, String schematic,
|
||||||
|
int size_x, int size_z) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlayerTeleportToPlotEvent callTeleport(PlotPlayer player, Location from, Plot plot) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlotComponentSetEvent callComponentSet(Plot plot, String component, Pattern pattern) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public PlotClearEvent callClear(Plot plot) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public PlotDeleteEvent callDelete(Plot plot) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public PlotFlagAddEvent callFlagAdd(PlotFlag<?, ?> flag, Plot plot) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public PlotFlagRemoveEvent callFlagRemove(PlotFlag<?, ?> flag, Plot plot) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlotMergeEvent callMerge(Plot plot, Direction dir, int max, PlotPlayer player) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public PlotAutoMergeEvent callAutoMerge(Plot plot, List<PlotId> plots) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public PlotUnlinkEvent callUnlink(PlotArea area, Plot plot, boolean createRoad,
|
||||||
|
boolean createSign, PlotUnlinkEvent.REASON reason) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public PlayerEnterPlotEvent callEntry(PlotPlayer player, Plot plot) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public PlayerLeavePlotEvent callLeave(PlotPlayer player, Plot plot) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public PlayerPlotDeniedEvent callDenied(PlotPlayer initiator, Plot plot, UUID player,
|
||||||
|
boolean added) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlayerPlotTrustedEvent callTrusted(PlotPlayer initiator, Plot plot, UUID player,
|
||||||
|
boolean added) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public PlayerPlotHelperEvent callMember(PlotPlayer initiator, Plot plot, UUID player,
|
||||||
|
boolean added) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlotChangeOwnerEvent callOwnerChange(PlotPlayer initiator, Plot plot, UUID newOwner,
|
||||||
|
UUID oldOwner, boolean hasOldOwner) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public PlotDoneEvent callDone(Plot plot) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -1,80 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.util;
|
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Rating;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class EventUtilTest extends EventUtil {
|
|
||||||
|
|
||||||
@Override public Rating callRating(PlotPlayer player, Plot plot, Rating rating) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean callClaim(PlotPlayer player, Plot plot, boolean auto) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean callTeleport(PlotPlayer player, Location from, Plot plot) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean callComponentSet(Plot plot, String component) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean callClear(Plot plot) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean callDelete(Plot plot) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean callFlagAdd(PlotFlag<?, ?> flag, Plot plot) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean callFlagRemove(PlotFlag<?, ?> flag, Plot plot, Object value) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean callMerge(Plot plot, int dir, int max) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean callAutoMerge(Plot plot, List<PlotId> plots) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean callUnlink(PlotArea area, List<PlotId> plots) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void callEntry(PlotPlayer player, Plot plot) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void callLeave(PlotPlayer player, Plot plot) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void callDenied(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean callOwnerChange(PlotPlayer initiator, Plot plot, UUID newOwner, UUID oldOwner,
|
|
||||||
boolean hasOldOwner) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,7 +15,6 @@ public class UUIDHandlerImplementationTest extends UUIDHandlerImplementation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Before public void setUp() throws Exception {
|
@Before public void setUp() throws Exception {
|
||||||
EventUtil.manager = new EventUtilTest();
|
|
||||||
DBFunc.dbManager = new AbstractDBTest();
|
DBFunc.dbManager = new AbstractDBTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user