mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Inject EventDispatcher and PlotListener
This commit is contained in:
parent
2dab7c8dda
commit
d00dc658df
@ -94,6 +94,7 @@ import com.plotsquared.core.util.ChatManager;
|
|||||||
import com.plotsquared.core.util.ChunkManager;
|
import com.plotsquared.core.util.ChunkManager;
|
||||||
import com.plotsquared.core.util.ConsoleColors;
|
import com.plotsquared.core.util.ConsoleColors;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.InventoryUtil;
|
import com.plotsquared.core.util.InventoryUtil;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.PermHandler;
|
import com.plotsquared.core.util.PermHandler;
|
||||||
@ -183,7 +184,10 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
private BukkitPlayerManager playerManager;
|
private BukkitPlayerManager playerManager;
|
||||||
private EconHandler econ;
|
private EconHandler econ;
|
||||||
private PermHandler perm;
|
private PermHandler perm;
|
||||||
|
|
||||||
private PlotAreaManager plotAreaManager;
|
private PlotAreaManager plotAreaManager;
|
||||||
|
private EventDispatcher eventDispatcher;
|
||||||
|
private PlotListener plotListener;
|
||||||
|
|
||||||
@Override public int[] getServerVersion() {
|
@Override public int[] getServerVersion() {
|
||||||
if (this.version == null) {
|
if (this.version == null) {
|
||||||
@ -215,8 +219,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
PlotPlayer.registerConverter(Player.class, BukkitUtil::getPlayer);
|
PlotPlayer.registerConverter(Player.class, BukkitUtil::getPlayer);
|
||||||
|
|
||||||
final PlotSquared plotSquared = new PlotSquared(this, "Bukkit");
|
final PlotSquared plotSquared = new PlotSquared(this, "Bukkit");
|
||||||
|
|
||||||
this.plotAreaManager = plotSquared.getPlotAreaManager();
|
this.plotAreaManager = plotSquared.getPlotAreaManager();
|
||||||
this.playerManager = new BukkitPlayerManager(this.plotAreaManager);
|
this.eventDispatcher = plotSquared.getEventDispatcher();
|
||||||
|
this.plotListener = plotSquared.getPlotListener();
|
||||||
|
this.playerManager = new BukkitPlayerManager(this.plotAreaManager, this.eventDispatcher);
|
||||||
|
|
||||||
if (PlotSquared.platform().getServerVersion()[1] < 13) {
|
if (PlotSquared.platform().getServerVersion()[1] < 13) {
|
||||||
System.out.println(
|
System.out.println(
|
||||||
@ -897,13 +904,13 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public void registerPlayerEvents() {
|
@Override public void registerPlayerEvents() {
|
||||||
final PlayerEvents main = new PlayerEvents(this.plotAreaManager);
|
final PlayerEvents main = new PlayerEvents(this.plotAreaManager, this.eventDispatcher);
|
||||||
getServer().getPluginManager().registerEvents(main, this);
|
getServer().getPluginManager().registerEvents(main, this);
|
||||||
getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this);
|
getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this);
|
||||||
if (PaperLib.isPaper() && Settings.Paper_Components.PAPER_LISTENERS) {
|
if (PaperLib.isPaper() && Settings.Paper_Components.PAPER_LISTENERS) {
|
||||||
getServer().getPluginManager().registerEvents(new PaperListener(this.plotAreaManager), this);
|
getServer().getPluginManager().registerEvents(new PaperListener(this.plotAreaManager), this);
|
||||||
}
|
}
|
||||||
PlotListener.startRunnable();
|
this.plotListener.startRunnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void registerForceFieldEvents() {
|
@Override public void registerForceFieldEvents() {
|
||||||
@ -1051,7 +1058,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull @Override public IndependentPlotGenerator getDefaultGenerator() {
|
@NotNull @Override public IndependentPlotGenerator getDefaultGenerator() {
|
||||||
return new HybridGen();
|
return new HybridGen(this.eventDispatcher, this.plotListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public InventoryUtil initInventoryUtil() {
|
@Override public InventoryUtil initInventoryUtil() {
|
||||||
|
@ -101,6 +101,7 @@ import com.plotsquared.core.plot.flag.types.BlockTypeWrapper;
|
|||||||
import com.plotsquared.core.plot.message.PlotMessage;
|
import com.plotsquared.core.plot.message.PlotMessage;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.EntityUtil;
|
import com.plotsquared.core.util.EntityUtil;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
@ -232,6 +233,7 @@ import java.util.regex.Pattern;
|
|||||||
new com.sk89q.worldedit.world.entity.EntityType("plotsquared:fake");
|
new com.sk89q.worldedit.world.entity.EntityType("plotsquared:fake");
|
||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
private boolean pistonBlocks = true;
|
private boolean pistonBlocks = true;
|
||||||
private float lastRadius;
|
private float lastRadius;
|
||||||
@ -241,8 +243,10 @@ import java.util.regex.Pattern;
|
|||||||
private PlayerMoveEvent moveTmp;
|
private PlayerMoveEvent moveTmp;
|
||||||
private String internalVersion;
|
private String internalVersion;
|
||||||
|
|
||||||
public PlayerEvents(@NotNull final PlotAreaManager plotAreaManager) {
|
public PlayerEvents(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher) {
|
||||||
|
super(eventDispatcher);
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
try {
|
try {
|
||||||
fieldPlayer = PlayerEvent.class.getDeclaredField("player");
|
fieldPlayer = PlayerEvent.class.getDeclaredField("player");
|
||||||
fieldPlayer.setAccessible(true);
|
fieldPlayer.setAccessible(true);
|
||||||
@ -688,7 +692,7 @@ import java.util.regex.Pattern;
|
|||||||
if (!player.hasPlayedBefore() && player.isOnline()) {
|
if (!player.hasPlayedBefore() && player.isOnline()) {
|
||||||
player.saveData();
|
player.saveData();
|
||||||
}
|
}
|
||||||
PlotSquared.get().getEventDispatcher().doJoinTask(pp);
|
this.eventDispatcher.doJoinTask(pp);
|
||||||
}, 20);
|
}, 20);
|
||||||
|
|
||||||
if (pp.hasPermission(Captions.PERMISSION_ADMIN_UPDATE_NOTIFICATION.getTranslated())
|
if (pp.hasPermission(Captions.PERMISSION_ADMIN_UPDATE_NOTIFICATION.getTranslated())
|
||||||
@ -711,7 +715,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<Player> pp = BukkitUtil.getPlayer(player);
|
PlotPlayer<Player> pp = BukkitUtil.getPlayer(player);
|
||||||
PlotSquared.get().getEventDispatcher().doRespawnTask(pp);
|
this.eventDispatcher.doRespawnTask(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@ -1968,7 +1972,7 @@ 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 (!PlotSquared.get().getEventDispatcher()
|
if (!this.eventDispatcher
|
||||||
.checkPlayerBlockEvent(pp, PlayerBlockEventType.SPAWN_MOB, location, null,
|
.checkPlayerBlockEvent(pp, PlayerBlockEventType.SPAWN_MOB, location, null,
|
||||||
true)) {
|
true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -2105,7 +2109,7 @@ import java.util.regex.Pattern;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!PlotSquared.get().getEventDispatcher()
|
if (!this.eventDispatcher
|
||||||
.checkPlayerBlockEvent(pp, eventType, location, blocktype1, true)) {
|
.checkPlayerBlockEvent(pp, eventType, location, blocktype1, true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.setUseInteractedBlock(Event.Result.DENY);
|
event.setUseInteractedBlock(Event.Result.DENY);
|
||||||
@ -2393,7 +2397,7 @@ import java.util.regex.Pattern;
|
|||||||
TaskManager.TELEPORT_QUEUE.remove(event.getPlayer().getName());
|
TaskManager.TELEPORT_QUEUE.remove(event.getPlayer().getName());
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
|
BukkitPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
|
||||||
pp.unregister();
|
pp.unregister();
|
||||||
PlotListener.logout(pp.getUUID());
|
this.logout(pp.getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
@ -36,6 +36,7 @@ import com.plotsquared.core.player.PlotPlayer;
|
|||||||
import com.plotsquared.core.plot.PlotWeather;
|
import com.plotsquared.core.plot.PlotWeather;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
@ -77,16 +78,19 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
|||||||
*
|
*
|
||||||
* @param player Bukkit player instance
|
* @param player Bukkit player instance
|
||||||
*/
|
*/
|
||||||
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final Player player) {
|
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher,
|
||||||
this(plotAreaManager, player, false);
|
@NotNull final Player player) {
|
||||||
|
this(plotAreaManager, eventDispatcher, player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final Player player, final boolean offline) {
|
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher,
|
||||||
this(plotAreaManager, player, offline, true);
|
@NotNull final Player player, final boolean offline) {
|
||||||
|
this(plotAreaManager, eventDispatcher, player, offline, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final Player player, final boolean offline, final boolean realPlayer) {
|
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final
|
||||||
super(plotAreaManager);
|
EventDispatcher eventDispatcher, @NotNull final Player player, final boolean offline, final boolean realPlayer) {
|
||||||
|
super(plotAreaManager, eventDispatcher);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.offline = offline;
|
this.offline = offline;
|
||||||
if (realPlayer) {
|
if (realPlayer) {
|
||||||
|
@ -26,7 +26,9 @@
|
|||||||
package com.plotsquared.bukkit.player;
|
package com.plotsquared.bukkit.player;
|
||||||
|
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.PlayerManager;
|
import com.plotsquared.core.util.PlayerManager;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -37,19 +39,16 @@ import java.util.UUID;
|
|||||||
/**
|
/**
|
||||||
* Player manager providing {@link BukkitPlayer Bukkit players}
|
* Player manager providing {@link BukkitPlayer Bukkit players}
|
||||||
*/
|
*/
|
||||||
public class BukkitPlayerManager extends PlayerManager<BukkitPlayer, Player> {
|
@RequiredArgsConstructor public class BukkitPlayerManager extends PlayerManager<BukkitPlayer, Player> {
|
||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
public BukkitPlayerManager(@NotNull final PlotAreaManager plotAreaManager) {
|
|
||||||
this.plotAreaManager = plotAreaManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public BukkitPlayer getPlayer(@NotNull final Player object) {
|
@NotNull @Override public BukkitPlayer getPlayer(@NotNull final Player object) {
|
||||||
try {
|
try {
|
||||||
return getPlayer(object.getUniqueId());
|
return getPlayer(object.getUniqueId());
|
||||||
} catch (final NoSuchPlayerException exception) {
|
} catch (final NoSuchPlayerException exception) {
|
||||||
return new BukkitPlayer(this.plotAreaManager, object, object.isOnline(), false);
|
return new BukkitPlayer(this.plotAreaManager, this.eventDispatcher, object, object.isOnline(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +57,7 @@ public class BukkitPlayerManager extends PlayerManager<BukkitPlayer, Player> {
|
|||||||
if (player == null || !player.isOnline()) {
|
if (player == null || !player.isOnline()) {
|
||||||
throw new NoSuchPlayerException(uuid);
|
throw new NoSuchPlayerException(uuid);
|
||||||
}
|
}
|
||||||
return new BukkitPlayer(this.plotAreaManager, player);
|
return new BukkitPlayer(this.plotAreaManager, this.eventDispatcher, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable @Override public BukkitOfflinePlayer getOfflinePlayer(@Nullable final UUID uuid) {
|
@Nullable @Override public BukkitOfflinePlayer getOfflinePlayer(@Nullable final UUID uuid) {
|
||||||
|
@ -129,7 +129,8 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
}
|
}
|
||||||
final Player player = OfflinePlayerUtil.loadPlayer(op);
|
final Player player = OfflinePlayerUtil.loadPlayer(op);
|
||||||
player.loadData();
|
player.loadData();
|
||||||
return new BukkitPlayer(PlotSquared.get().getPlotAreaManager(), player, true);
|
return new BukkitPlayer(PlotSquared.get().getPlotAreaManager(),
|
||||||
|
PlotSquared.get().getEventDispatcher(), player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,9 +23,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.plotsquared.core.api;
|
package com.plotsquared.core;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.Caption;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
@ -46,6 +46,7 @@ import com.plotsquared.core.generator.GeneratorWrapper;
|
|||||||
import com.plotsquared.core.generator.HybridPlotWorld;
|
import com.plotsquared.core.generator.HybridPlotWorld;
|
||||||
import com.plotsquared.core.generator.HybridUtils;
|
import com.plotsquared.core.generator.HybridUtils;
|
||||||
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
||||||
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.listener.WESubscriber;
|
import com.plotsquared.core.listener.WESubscriber;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.player.ConsolePlayer;
|
import com.plotsquared.core.player.ConsolePlayer;
|
||||||
@ -166,6 +167,7 @@ public class PlotSquared {
|
|||||||
private File storageFile;
|
private File storageFile;
|
||||||
@Getter private PlotAreaManager plotAreaManager;
|
@Getter private PlotAreaManager plotAreaManager;
|
||||||
@Getter private EventDispatcher eventDispatcher;
|
@Getter private EventDispatcher eventDispatcher;
|
||||||
|
@Getter private PlotListener plotListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize PlotSquared with the desired Implementation class.
|
* Initialize PlotSquared with the desired Implementation class.
|
||||||
@ -217,9 +219,14 @@ public class PlotSquared {
|
|||||||
+ ".use_THIS.yml");
|
+ ".use_THIS.yml");
|
||||||
Captions.load(this.translationFile);
|
Captions.load(this.translationFile);
|
||||||
|
|
||||||
|
// Create Event utility class
|
||||||
|
this.eventDispatcher = new EventDispatcher();
|
||||||
|
// Create plot listener
|
||||||
|
this.plotListener = new PlotListener(this.eventDispatcher);
|
||||||
|
|
||||||
// Setup plotAreaManager
|
// Setup plotAreaManager
|
||||||
if (Settings.Enabled_Components.WORLDS) {
|
if (Settings.Enabled_Components.WORLDS) {
|
||||||
this.plotAreaManager = new SinglePlotAreaManager();
|
this.plotAreaManager = new SinglePlotAreaManager(this.eventDispatcher, this.plotListener);
|
||||||
} else {
|
} else {
|
||||||
this.plotAreaManager = new DefaultPlotAreaManager();
|
this.plotAreaManager = new DefaultPlotAreaManager();
|
||||||
}
|
}
|
||||||
@ -254,8 +261,6 @@ public class PlotSquared {
|
|||||||
if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
|
if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
|
||||||
this.platform.registerChunkProcessor();
|
this.platform.registerChunkProcessor();
|
||||||
}
|
}
|
||||||
// Create Event utility class
|
|
||||||
eventDispatcher = new EventDispatcher();
|
|
||||||
// create Hybrid utility class
|
// create Hybrid utility class
|
||||||
HybridUtils.manager = this.platform.initHybridUtils();
|
HybridUtils.manager = this.platform.initHybridUtils();
|
||||||
// Inventory utility class
|
// Inventory utility class
|
||||||
@ -427,7 +432,7 @@ public class PlotSquared {
|
|||||||
|
|
||||||
private void startExpiryTasks() {
|
private void startExpiryTasks() {
|
||||||
if (Settings.Enabled_Components.PLOT_EXPIRY) {
|
if (Settings.Enabled_Components.PLOT_EXPIRY) {
|
||||||
ExpireManager.IMP = new ExpireManager();
|
ExpireManager.IMP = new ExpireManager(this.eventDispatcher);
|
||||||
ExpireManager.IMP.runAutomatedTask();
|
ExpireManager.IMP.runAutomatedTask();
|
||||||
for (Settings.Auto_Clear settings : Settings.AUTO_CLEAR.getInstances()) {
|
for (Settings.Auto_Clear settings : Settings.AUTO_CLEAR.getInstances()) {
|
||||||
ExpiryTask task = new ExpiryTask(settings, this.plotAreaManager);
|
ExpiryTask task = new ExpiryTask(settings, this.plotAreaManager);
|
||||||
@ -1207,7 +1212,8 @@ public class PlotSquared {
|
|||||||
split = combinedArgs;
|
split = combinedArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
HybridPlotWorld plotworld = new HybridPlotWorld(world, null, generator, null, null);
|
HybridPlotWorld plotworld = new HybridPlotWorld(world, null, generator,
|
||||||
|
null, null, this.eventDispatcher, this.plotListener);
|
||||||
for (String element : split) {
|
for (String element : split) {
|
||||||
String[] pair = element.split("=");
|
String[] pair = element.split("=");
|
||||||
if (pair.length != 2) {
|
if (pair.length != 2) {
|
||||||
@ -1420,7 +1426,7 @@ public class PlotSquared {
|
|||||||
this.platform.shutdown(); //shutdown used instead of disable because no database is set
|
this.platform.shutdown(); //shutdown used instead of disable because no database is set
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DBFunc.dbManager = new SQLManager(database, Storage.PREFIX, false);
|
DBFunc.dbManager = new SQLManager(database, Storage.PREFIX, this.eventDispatcher, this.plotListener);
|
||||||
this.plots_tmp = DBFunc.getPlots();
|
this.plots_tmp = DBFunc.getPlots();
|
||||||
if (plotAreaManager instanceof SinglePlotAreaManager) {
|
if (plotAreaManager instanceof SinglePlotAreaManager) {
|
||||||
SinglePlotArea area = ((SinglePlotAreaManager) plotAreaManager).getArea();
|
SinglePlotArea area = ((SinglePlotAreaManager) plotAreaManager).getArea();
|
||||||
|
@ -25,16 +25,17 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.database.DBFunc;
|
import com.plotsquared.core.database.DBFunc;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.TabCompletions;
|
import com.plotsquared.core.util.TabCompletions;
|
||||||
import com.plotsquared.core.util.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -51,8 +52,11 @@ import java.util.concurrent.TimeoutException;
|
|||||||
requiredType = RequiredType.PLAYER)
|
requiredType = RequiredType.PLAYER)
|
||||||
public class Add extends Command {
|
public class Add extends Command {
|
||||||
|
|
||||||
public Add() {
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
public Add(@NotNull final EventDispatcher eventDispatcher) {
|
||||||
super(MainCommand.getInstance(), true);
|
super(MainCommand.getInstance(), true);
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -116,7 +120,7 @@ public class Add extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
plot.addMember(uuid);
|
plot.addMember(uuid);
|
||||||
PlotSquared.get().getEventDispatcher().callMember(player, plot, uuid, true);
|
this.eventDispatcher.callMember(player, plot, uuid, true);
|
||||||
MainUtil.sendMessage(player, Captions.MEMBER_ADDED);
|
MainUtil.sendMessage(player, Captions.MEMBER_ADDED);
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
|
@ -32,6 +32,7 @@ import com.plotsquared.core.configuration.ConfigurationUtil;
|
|||||||
import com.plotsquared.core.events.TeleportCause;
|
import com.plotsquared.core.events.TeleportCause;
|
||||||
import com.plotsquared.core.generator.AugmentedUtils;
|
import com.plotsquared.core.generator.AugmentedUtils;
|
||||||
import com.plotsquared.core.generator.HybridPlotWorld;
|
import com.plotsquared.core.generator.HybridPlotWorld;
|
||||||
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.player.ConsolePlayer;
|
import com.plotsquared.core.player.ConsolePlayer;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
@ -42,6 +43,7 @@ import com.plotsquared.core.plot.PlotId;
|
|||||||
import com.plotsquared.core.plot.message.PlotMessage;
|
import com.plotsquared.core.plot.message.PlotMessage;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.setup.PlotAreaBuilder;
|
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
@ -66,6 +68,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -85,13 +88,12 @@ import java.util.Set;
|
|||||||
aliases = "world",
|
aliases = "world",
|
||||||
usage = "/plot area <create|info|list|tp|regen>",
|
usage = "/plot area <create|info|list|tp|regen>",
|
||||||
confirmation = true)
|
confirmation = true)
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class Area extends SubCommand {
|
public class Area extends SubCommand {
|
||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
public Area(@NotNull final PlotAreaManager plotAreaManager) {
|
private final PlotListener plotListener;
|
||||||
this.plotAreaManager = plotAreaManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
@ -148,7 +150,7 @@ public class Area extends SubCommand {
|
|||||||
// There's only one plot in the area...
|
// There's only one plot in the area...
|
||||||
final PlotId plotId = new PlotId(1, 1);
|
final PlotId plotId = new PlotId(1, 1);
|
||||||
final HybridPlotWorld hybridPlotWorld = new HybridPlotWorld(player.getLocation().getWorldName(), args[1],
|
final HybridPlotWorld hybridPlotWorld = new HybridPlotWorld(player.getLocation().getWorldName(), args[1],
|
||||||
Objects.requireNonNull(PlotSquared.platform()).getDefaultGenerator(), plotId, plotId);
|
Objects.requireNonNull(PlotSquared.platform()).getDefaultGenerator(), plotId, plotId, this.eventDispatcher, this.plotListener);
|
||||||
// Plot size is the same as the region width
|
// Plot size is the same as the region width
|
||||||
hybridPlotWorld.PLOT_WIDTH = hybridPlotWorld.SIZE = (short) selectedRegion.getWidth();
|
hybridPlotWorld.PLOT_WIDTH = hybridPlotWorld.SIZE = (short) selectedRegion.getWidth();
|
||||||
// We use a schematic generator
|
// We use a schematic generator
|
||||||
@ -349,7 +351,7 @@ public class Area extends SubCommand {
|
|||||||
PlotAreaBuilder builder = new PlotAreaBuilder();
|
PlotAreaBuilder builder = new PlotAreaBuilder();
|
||||||
builder.worldName(split[0]);
|
builder.worldName(split[0]);
|
||||||
final HybridPlotWorld pa = new HybridPlotWorld(builder.worldName(), id,
|
final HybridPlotWorld pa = new HybridPlotWorld(builder.worldName(), id,
|
||||||
PlotSquared.platform().getDefaultGenerator(), null, null);
|
PlotSquared.platform().getDefaultGenerator(), null, null, this.eventDispatcher, this.plotListener);
|
||||||
PlotArea other = this.plotAreaManager.getPlotArea(pa.getWorldName(), id);
|
PlotArea other = this.plotAreaManager.getPlotArea(pa.getWorldName(), id);
|
||||||
if (other != null && Objects.equals(pa.getId(), other.getId())) {
|
if (other != null && Objects.equals(pa.getId(), other.getId())) {
|
||||||
Captions.SETUP_WORLD_TAKEN.send(player, pa.toString());
|
Captions.SETUP_WORLD_TAKEN.send(player, pa.toString());
|
||||||
|
@ -42,6 +42,7 @@ import com.plotsquared.core.plot.PlotAreaType;
|
|||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.Expression;
|
import com.plotsquared.core.util.Expression;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
@ -64,9 +65,11 @@ import java.util.Set;
|
|||||||
public class Auto extends SubCommand {
|
public class Auto extends SubCommand {
|
||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
public Auto(@NotNull final PlotAreaManager plotAreaManager) {
|
public Auto(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher) {
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated public static PlotId getNextPlotId(PlotId id, int step) {
|
@Deprecated public static PlotId getNextPlotId(PlotId id, int step) {
|
||||||
@ -144,7 +147,8 @@ public class Auto extends SubCommand {
|
|||||||
player.setMeta(Auto.class.getName(), true);
|
player.setMeta(Auto.class.getName(), true);
|
||||||
autoClaimFromDatabase(player, area, start, new RunnableVal<Plot>() {
|
autoClaimFromDatabase(player, area, start, new RunnableVal<Plot>() {
|
||||||
@Override public void run(final Plot plot) {
|
@Override public void run(final Plot plot) {
|
||||||
TaskManager.IMP.sync(new AutoClaimFinishTask(player, plot, area, schematic));
|
TaskManager.IMP.sync(new AutoClaimFinishTask(player, plot, area, schematic,
|
||||||
|
PlotSquared.get().getEventDispatcher()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -221,7 +225,7 @@ public class Auto extends SubCommand {
|
|||||||
// return false;
|
// return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlayerAutoPlotEvent event = PlotSquared.get().getEventDispatcher()
|
PlayerAutoPlotEvent event = this.eventDispatcher
|
||||||
.callAuto(player, plotarea, schematic, size_x, size_z);
|
.callAuto(player, plotarea, schematic, size_x, size_z);
|
||||||
if (event.getEventResult() == Result.DENY) {
|
if (event.getEventResult() == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Auto claim");
|
sendMessage(player, Captions.EVENT_DENIED, "Auto claim");
|
||||||
@ -302,7 +306,7 @@ public class Auto extends SubCommand {
|
|||||||
}
|
}
|
||||||
ArrayList<PlotId> plotIds = MainUtil.getPlotSelectionIds(start, end);
|
ArrayList<PlotId> plotIds = MainUtil.getPlotSelectionIds(start, end);
|
||||||
final PlotId pos1 = plotIds.get(0);
|
final PlotId pos1 = plotIds.get(0);
|
||||||
final PlotAutoMergeEvent mergeEvent = PlotSquared.get().getEventDispatcher()
|
final PlotAutoMergeEvent mergeEvent = this.eventDispatcher
|
||||||
.callAutoMerge(plotarea.getPlotAbs(pos1), plotIds);
|
.callAutoMerge(plotarea.getPlotAbs(pos1), plotIds);
|
||||||
if (!force && mergeEvent.getEventResult() == Result.DENY) {
|
if (!force && mergeEvent.getEventResult() == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Auto merge");
|
sendMessage(player, Captions.EVENT_DENIED, "Auto merge");
|
||||||
|
@ -34,9 +34,11 @@ import com.plotsquared.core.plot.Plot;
|
|||||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.PriceFlag;
|
import com.plotsquared.core.plot.flag.implementations.PriceFlag;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@ -49,8 +51,11 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
requiredType = RequiredType.NONE)
|
requiredType = RequiredType.NONE)
|
||||||
public class Buy extends Command {
|
public class Buy extends Command {
|
||||||
|
|
||||||
public Buy() {
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
public Buy(@NotNull final EventDispatcher eventDispatcher) {
|
||||||
super(MainCommand.getInstance(), true);
|
super(MainCommand.getInstance(), true);
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -89,8 +94,7 @@ public class Buy extends Command {
|
|||||||
Captions.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price);
|
Captions.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price);
|
||||||
}
|
}
|
||||||
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(PriceFlag.class);
|
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(PriceFlag.class);
|
||||||
PlotFlagRemoveEvent event =
|
PlotFlagRemoveEvent event = this.eventDispatcher.callFlagRemove(plotFlag, plot);
|
||||||
PlotSquared.get().getEventDispatcher().callFlagRemove(plotFlag, plot);
|
|
||||||
if (event.getEventResult() != Result.DENY) {
|
if (event.getEventResult() != Result.DENY) {
|
||||||
plot.removeFlag(event.getFlag());
|
plot.removeFlag(event.getFlag());
|
||||||
}
|
}
|
||||||
|
@ -40,10 +40,12 @@ import com.plotsquared.core.player.PlotPlayer;
|
|||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.Expression;
|
import com.plotsquared.core.util.Expression;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@CommandDeclaration(command = "claim",
|
@CommandDeclaration(command = "claim",
|
||||||
aliases = "c",
|
aliases = "c",
|
||||||
@ -54,18 +56,23 @@ import com.plotsquared.core.util.task.TaskManager;
|
|||||||
usage = "/plot claim")
|
usage = "/plot claim")
|
||||||
public class Claim extends SubCommand {
|
public class Claim extends SubCommand {
|
||||||
|
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
public Claim(@NotNull final EventDispatcher eventDispatcher) {
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||||
String schematic = null;
|
String schematic = null;
|
||||||
if (args.length >= 1) {
|
if (args.length >= 1) {
|
||||||
schematic = args[0];
|
schematic = args[0];
|
||||||
}
|
}
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
final Plot plot = location.getPlotAbs();
|
Plot plot = location.getPlotAbs();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return sendMessage(player, Captions.NOT_IN_PLOT);
|
return sendMessage(player, Captions.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
PlayerClaimPlotEvent event =
|
final PlayerClaimPlotEvent event = this.eventDispatcher.callClaim(player, plot, schematic);
|
||||||
PlotSquared.get().getEventDispatcher().callClaim(player, plot, schematic);
|
|
||||||
schematic = event.getSchematic();
|
schematic = event.getSchematic();
|
||||||
if (event.getEventResult() == Result.DENY) {
|
if (event.getEventResult() == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Claim");
|
sendMessage(player, Captions.EVENT_DENIED, "Claim");
|
||||||
@ -138,7 +145,7 @@ public class Claim extends SubCommand {
|
|||||||
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
||||||
plot.setOwnerAbs(null);
|
plot.setOwnerAbs(null);
|
||||||
} else if (area.isAutoMerge()) {
|
} else if (area.isAutoMerge()) {
|
||||||
PlotMergeEvent event = PlotSquared.get().getEventDispatcher()
|
PlotMergeEvent event = Claim.this.eventDispatcher
|
||||||
.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player);
|
.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player);
|
||||||
if (event.getEventResult() == Result.DENY) {
|
if (event.getEventResult() == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Auto merge on claim");
|
sendMessage(player, Captions.EVENT_DENIED, "Auto merge on claim");
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.backup.BackupManager;
|
import com.plotsquared.core.backup.BackupManager;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
@ -37,10 +36,12 @@ import com.plotsquared.core.plot.flag.PlotFlag;
|
|||||||
import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
|
import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@ -56,11 +57,11 @@ import static com.plotsquared.core.command.SubCommand.sendMessage;
|
|||||||
confirmation = true)
|
confirmation = true)
|
||||||
public class Clear extends Command {
|
public class Clear extends Command {
|
||||||
|
|
||||||
// Note: To clear a specific plot use /plot <plot> clear
|
private final EventDispatcher eventDispatcher;
|
||||||
// The syntax also works with any command: /plot <plot> <command>
|
|
||||||
|
|
||||||
public Clear() {
|
public Clear(@NotNull final EventDispatcher eventDispatcher) {
|
||||||
super(MainCommand.getInstance(), true);
|
super(MainCommand.getInstance(), true);
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -69,8 +70,7 @@ 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);
|
||||||
Result eventResult =
|
Result eventResult = this.eventDispatcher.callClear(plot).getEventResult();
|
||||||
PlotSquared.get().getEventDispatcher().callClear(plot).getEventResult();
|
|
||||||
if (eventResult == Result.DENY) {
|
if (eventResult == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Clear");
|
sendMessage(player, Captions.EVENT_DENIED, "Clear");
|
||||||
return CompletableFuture.completedFuture(true);
|
return CompletableFuture.completedFuture(true);
|
||||||
@ -93,7 +93,7 @@ public class Clear extends Command {
|
|||||||
if (DoneFlag.isDone(plot)) {
|
if (DoneFlag.isDone(plot)) {
|
||||||
PlotFlag<?, ?> plotFlag =
|
PlotFlag<?, ?> plotFlag =
|
||||||
plot.getFlagContainer().getFlag(DoneFlag.class);
|
plot.getFlagContainer().getFlag(DoneFlag.class);
|
||||||
PlotFlagRemoveEvent event = PlotSquared.get().getEventDispatcher()
|
PlotFlagRemoveEvent event = this.eventDispatcher
|
||||||
.callFlagRemove(plotFlag, plot);
|
.callFlagRemove(plotFlag, plot);
|
||||||
if (event.getEventResult() != Result.DENY) {
|
if (event.getEventResult() != Result.DENY) {
|
||||||
plot.removeFlag(event.getFlag());
|
plot.removeFlag(event.getFlag());
|
||||||
@ -102,7 +102,7 @@ public class Clear extends Command {
|
|||||||
if (!plot.getFlag(AnalysisFlag.class).isEmpty()) {
|
if (!plot.getFlag(AnalysisFlag.class).isEmpty()) {
|
||||||
PlotFlag<?, ?> plotFlag =
|
PlotFlag<?, ?> plotFlag =
|
||||||
plot.getFlagContainer().getFlag(AnalysisFlag.class);
|
plot.getFlagContainer().getFlag(AnalysisFlag.class);
|
||||||
PlotFlagRemoveEvent event = PlotSquared.get().getEventDispatcher()
|
PlotFlagRemoveEvent event = this.eventDispatcher
|
||||||
.callFlagRemove(plotFlag, plot);
|
.callFlagRemove(plotFlag, plot);
|
||||||
if (event.getEventResult() != Result.DENY) {
|
if (event.getEventResult() != Result.DENY) {
|
||||||
plot.removeFlag(event.getFlag());
|
plot.removeFlag(event.getFlag());
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.events.PlotFlagRemoveEvent;
|
import com.plotsquared.core.events.PlotFlagRemoveEvent;
|
||||||
@ -34,8 +33,10 @@ import com.plotsquared.core.player.PlotPlayer;
|
|||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@CommandDeclaration(command = "continue",
|
@CommandDeclaration(command = "continue",
|
||||||
description = "Continue a plot that was previously marked as done",
|
description = "Continue a plot that was previously marked as done",
|
||||||
@ -44,6 +45,12 @@ import com.plotsquared.core.util.Permissions;
|
|||||||
requiredType = RequiredType.PLAYER)
|
requiredType = RequiredType.PLAYER)
|
||||||
public class Continue extends SubCommand {
|
public class Continue extends SubCommand {
|
||||||
|
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
public Continue(@NotNull final EventDispatcher eventDispatcher) {
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||||
Plot plot = player.getCurrentPlot();
|
Plot plot = player.getCurrentPlot();
|
||||||
if ((plot == null) || !plot.hasOwner()) {
|
if ((plot == null) || !plot.hasOwner()) {
|
||||||
@ -71,7 +78,7 @@ public class Continue extends SubCommand {
|
|||||||
}
|
}
|
||||||
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(DoneFlag.class);
|
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(DoneFlag.class);
|
||||||
PlotFlagRemoveEvent event =
|
PlotFlagRemoveEvent event =
|
||||||
PlotSquared.get().getEventDispatcher().callFlagRemove(plotFlag, plot);
|
this.eventDispatcher.callFlagRemove(plotFlag, plot);
|
||||||
if (event.getEventResult() == Result.DENY) {
|
if (event.getEventResult() == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Done flag removal");
|
sendMessage(player, Captions.EVENT_DENIED, "Done flag removal");
|
||||||
return true;
|
return true;
|
||||||
|
@ -31,12 +31,14 @@ import com.plotsquared.core.database.Database;
|
|||||||
import com.plotsquared.core.database.MySQL;
|
import com.plotsquared.core.database.MySQL;
|
||||||
import com.plotsquared.core.database.SQLManager;
|
import com.plotsquared.core.database.SQLManager;
|
||||||
import com.plotsquared.core.database.SQLite;
|
import com.plotsquared.core.database.SQLite;
|
||||||
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.query.PlotQuery;
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
@ -60,9 +62,14 @@ import java.util.Map.Entry;
|
|||||||
public class DatabaseCommand extends SubCommand {
|
public class DatabaseCommand extends SubCommand {
|
||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
private final PlotListener plotListener;
|
||||||
|
|
||||||
public DatabaseCommand(@NotNull final PlotAreaManager plotAreaManager) {
|
public DatabaseCommand(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher,
|
||||||
|
@NotNull final PlotListener plotListener) {
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
this.plotListener = plotListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void insertPlots(final SQLManager manager, final List<Plot> plots,
|
public static void insertPlots(final SQLManager manager, final List<Plot> plots,
|
||||||
@ -119,8 +126,8 @@ public class DatabaseCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, "&6Starting...");
|
MainUtil.sendMessage(player, "&6Starting...");
|
||||||
implementation = new SQLite(file);
|
implementation = new SQLite(file);
|
||||||
SQLManager manager =
|
SQLManager manager = new SQLManager(implementation, args.length == 3 ? args[2] : "",
|
||||||
new SQLManager(implementation, args.length == 3 ? args[2] : "", true);
|
this.eventDispatcher, this.plotListener);
|
||||||
HashMap<String, HashMap<PlotId, Plot>> map = manager.getPlots();
|
HashMap<String, HashMap<PlotId, Plot>> map = manager.getPlots();
|
||||||
plots = new ArrayList<>();
|
plots = new ArrayList<>();
|
||||||
for (Entry<String, HashMap<PlotId, Plot>> entry : map.entrySet()) {
|
for (Entry<String, HashMap<PlotId, Plot>> entry : map.entrySet()) {
|
||||||
@ -195,7 +202,7 @@ public class DatabaseCommand extends SubCommand {
|
|||||||
return MainUtil.sendMessage(player, "/plot database [sqlite/mysql]");
|
return MainUtil.sendMessage(player, "/plot database [sqlite/mysql]");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
SQLManager manager = new SQLManager(implementation, prefix, true);
|
SQLManager manager = new SQLManager(implementation, prefix, this.eventDispatcher, this.plotListener);
|
||||||
DatabaseCommand.insertPlots(manager, plots, player);
|
DatabaseCommand.insertPlots(manager, plots, player);
|
||||||
return true;
|
return true;
|
||||||
} catch (ClassNotFoundException | SQLException e) {
|
} catch (ClassNotFoundException | SQLException e) {
|
||||||
|
@ -48,6 +48,7 @@ import com.plotsquared.core.plot.world.PlotAreaManager;
|
|||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
import com.plotsquared.core.util.ChunkManager;
|
import com.plotsquared.core.util.ChunkManager;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.SchematicHandler;
|
import com.plotsquared.core.util.SchematicHandler;
|
||||||
@ -85,11 +86,13 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
public class DebugExec extends SubCommand {
|
public class DebugExec extends SubCommand {
|
||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
private ScriptEngine engine;
|
private ScriptEngine engine;
|
||||||
private Bindings scope;
|
private Bindings scope;
|
||||||
|
|
||||||
public DebugExec(@NotNull final PlotAreaManager plotAreaManager) {
|
public DebugExec(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher) {
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
init();
|
init();
|
||||||
/*
|
/*
|
||||||
try {
|
try {
|
||||||
@ -170,7 +173,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", PlotSquared.get().getEventDispatcher());
|
this.scope.put("EventUtil", this.eventDispatcher);
|
||||||
this.scope.put("EconHandler", EconHandler.getEconHandler());
|
this.scope.put("EconHandler", EconHandler.getEconHandler());
|
||||||
this.scope.put("DBFunc", DBFunc.dbManager);
|
this.scope.put("DBFunc", DBFunc.dbManager);
|
||||||
this.scope.put("HybridUtils", HybridUtils.manager);
|
this.scope.put("HybridUtils", HybridUtils.manager);
|
||||||
@ -250,7 +253,7 @@ 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()) {
|
||||||
PlotFlagRemoveEvent event = PlotSquared.get().getEventDispatcher()
|
PlotFlagRemoveEvent event = this.eventDispatcher
|
||||||
.callFlagRemove(flagInstance, plot);
|
.callFlagRemove(flagInstance, plot);
|
||||||
if (event.getEventResult() != Result.DENY) {
|
if (event.getEventResult() != Result.DENY) {
|
||||||
plot.removeFlag(event.getFlag());
|
plot.removeFlag(event.getFlag());
|
||||||
@ -293,7 +296,7 @@ public class DebugExec extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
case "start-expire":
|
case "start-expire":
|
||||||
if (ExpireManager.IMP == null) {
|
if (ExpireManager.IMP == null) {
|
||||||
ExpireManager.IMP = new ExpireManager();
|
ExpireManager.IMP = new ExpireManager(this.eventDispatcher);
|
||||||
}
|
}
|
||||||
if (ExpireManager.IMP.runAutomatedTask()) {
|
if (ExpireManager.IMP.runAutomatedTask()) {
|
||||||
return MainUtil.sendMessage(player, "Started plot expiry task");
|
return MainUtil.sendMessage(player, "Started plot expiry task");
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.events.Result;
|
import com.plotsquared.core.events.Result;
|
||||||
@ -34,10 +33,12 @@ import com.plotsquared.core.player.PlotPlayer;
|
|||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.Expression;
|
import com.plotsquared.core.util.Expression;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
|
||||||
@CommandDeclaration(command = "delete",
|
@CommandDeclaration(command = "delete",
|
||||||
@ -50,8 +51,11 @@ import com.plotsquared.core.util.task.TaskManager;
|
|||||||
confirmation = true)
|
confirmation = true)
|
||||||
public class Delete extends SubCommand {
|
public class Delete extends SubCommand {
|
||||||
|
|
||||||
// Note: To delete a specific plot use /plot <plot> delete
|
private final EventDispatcher eventDispatcher;
|
||||||
// The syntax also works with any command: /plot <plot> <command>
|
|
||||||
|
public Delete(@NotNull final EventDispatcher eventDispatcher) {
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
@ -62,8 +66,7 @@ public class Delete extends SubCommand {
|
|||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
return !sendMessage(player, Captions.PLOT_UNOWNED);
|
return !sendMessage(player, Captions.PLOT_UNOWNED);
|
||||||
}
|
}
|
||||||
Result eventResult =
|
Result eventResult = this.eventDispatcher.callDelete(plot).getEventResult();
|
||||||
PlotSquared.get().getEventDispatcher().callDelete(plot).getEventResult();
|
|
||||||
if (eventResult == Result.DENY) {
|
if (eventResult == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Delete");
|
sendMessage(player, Captions.EVENT_DENIED, "Delete");
|
||||||
return true;
|
return true;
|
||||||
|
@ -32,6 +32,7 @@ import com.plotsquared.core.location.Location;
|
|||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.TabCompletions;
|
import com.plotsquared.core.util.TabCompletions;
|
||||||
@ -53,10 +54,12 @@ import java.util.concurrent.TimeoutException;
|
|||||||
public class Deny extends SubCommand {
|
public class Deny extends SubCommand {
|
||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
public Deny(@NotNull final PlotAreaManager plotAreaManager) {
|
public Deny(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher) {
|
||||||
super(Argument.PlayerName);
|
super(Argument.PlayerName);
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||||
@ -99,7 +102,7 @@ public class Deny extends SubCommand {
|
|||||||
plot.removeTrusted(uuid);
|
plot.removeTrusted(uuid);
|
||||||
}
|
}
|
||||||
plot.addDenied(uuid);
|
plot.addDenied(uuid);
|
||||||
PlotSquared.get().getEventDispatcher().callDenied(player, plot, uuid, true);
|
this.eventDispatcher.callDenied(player, plot, uuid, true);
|
||||||
if (!uuid.equals(DBFunc.EVERYONE)) {
|
if (!uuid.equals(DBFunc.EVERYONE)) {
|
||||||
handleKick(PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid), plot);
|
handleKick(PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid), plot);
|
||||||
} else {
|
} else {
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.events.PlotFlagAddEvent;
|
import com.plotsquared.core.events.PlotFlagAddEvent;
|
||||||
import com.plotsquared.core.events.PlotFlagRemoveEvent;
|
import com.plotsquared.core.events.PlotFlagRemoveEvent;
|
||||||
@ -33,7 +32,9 @@ import com.plotsquared.core.events.Result;
|
|||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.flag.implementations.DescriptionFlag;
|
import com.plotsquared.core.plot.flag.implementations.DescriptionFlag;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@CommandDeclaration(command = "setdescription",
|
@CommandDeclaration(command = "setdescription",
|
||||||
permission = "plots.set.desc",
|
permission = "plots.set.desc",
|
||||||
@ -44,10 +45,15 @@ import com.plotsquared.core.util.MainUtil;
|
|||||||
requiredType = RequiredType.PLAYER)
|
requiredType = RequiredType.PLAYER)
|
||||||
public class Desc extends SetCommand {
|
public class Desc extends SetCommand {
|
||||||
|
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
public Desc(@NotNull final EventDispatcher eventDispatcher) {
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
@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()) {
|
||||||
PlotFlagRemoveEvent event = PlotSquared.get().getEventDispatcher()
|
PlotFlagRemoveEvent event = this.eventDispatcher.callFlagRemove(plot.getFlagContainer().getFlag(DescriptionFlag.class), plot);
|
||||||
.callFlagRemove(plot.getFlagContainer().getFlag(DescriptionFlag.class), plot);
|
|
||||||
if (event.getEventResult() == Result.DENY) {
|
if (event.getEventResult() == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Description removal");
|
sendMessage(player, Captions.EVENT_DENIED, "Description removal");
|
||||||
return false;
|
return false;
|
||||||
@ -56,8 +62,7 @@ public class Desc extends SetCommand {
|
|||||||
MainUtil.sendMessage(player, Captions.DESC_UNSET);
|
MainUtil.sendMessage(player, Captions.DESC_UNSET);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
PlotFlagAddEvent event = PlotSquared.get().getEventDispatcher().callFlagAdd(
|
PlotFlagAddEvent event = this.eventDispatcher.callFlagAdd(plot.getFlagContainer().getFlag(DescriptionFlag.class).createFlagInstance(desc), plot);
|
||||||
plot.getFlagContainer().getFlag(DescriptionFlag.class).createFlagInstance(desc), plot);
|
|
||||||
if (event.getEventResult() == Result.DENY) {
|
if (event.getEventResult() == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Description set");
|
sendMessage(player, Captions.EVENT_DENIED, "Description set");
|
||||||
return false;
|
return false;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@CommandDeclaration(command = "dislike",
|
@CommandDeclaration(command = "dislike",
|
||||||
permission = "plots.dislike",
|
permission = "plots.dislike",
|
||||||
@ -35,8 +36,14 @@ import com.plotsquared.core.player.PlotPlayer;
|
|||||||
requiredType = RequiredType.PLAYER)
|
requiredType = RequiredType.PLAYER)
|
||||||
public class Dislike extends SubCommand {
|
public class Dislike extends SubCommand {
|
||||||
|
|
||||||
|
private final Like like;
|
||||||
|
|
||||||
|
public Dislike(@NotNull final Like like) {
|
||||||
|
this.like = like;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||||
return Like.handleLike(player, args, false);
|
return this.like.handleLike(player, args, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.events.PlotDoneEvent;
|
import com.plotsquared.core.events.PlotDoneEvent;
|
||||||
@ -39,9 +38,11 @@ import com.plotsquared.core.plot.expiration.ExpireManager;
|
|||||||
import com.plotsquared.core.plot.expiration.PlotAnalysis;
|
import com.plotsquared.core.plot.expiration.PlotAnalysis;
|
||||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@CommandDeclaration(command = "done",
|
@CommandDeclaration(command = "done",
|
||||||
aliases = {"submit"},
|
aliases = {"submit"},
|
||||||
@ -51,13 +52,19 @@ import com.plotsquared.core.util.task.RunnableVal;
|
|||||||
requiredType = RequiredType.NONE)
|
requiredType = RequiredType.NONE)
|
||||||
public class Done extends SubCommand {
|
public class Done extends SubCommand {
|
||||||
|
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
public Done(@NotNull final EventDispatcher eventDispatcher) {
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
final Plot plot = location.getPlotAbs();
|
final Plot plot = location.getPlotAbs();
|
||||||
if ((plot == null) || !plot.hasOwner()) {
|
if ((plot == null) || !plot.hasOwner()) {
|
||||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
PlotDoneEvent event = PlotSquared.get().getEventDispatcher().callDone(plot);
|
PlotDoneEvent event = this.eventDispatcher.callDone(plot);
|
||||||
if (event.getEventResult() == Result.DENY) {
|
if (event.getEventResult() == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Done");
|
sendMessage(player, Captions.EVENT_DENIED, "Done");
|
||||||
return true;
|
return true;
|
||||||
|
@ -25,13 +25,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@ -43,8 +44,12 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
category = CommandCategory.CLAIMING,
|
category = CommandCategory.CLAIMING,
|
||||||
requiredType = RequiredType.PLAYER)
|
requiredType = RequiredType.PLAYER)
|
||||||
public class Leave extends Command {
|
public class Leave extends Command {
|
||||||
public Leave() {
|
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
public Leave(@NotNull final EventDispatcher eventDispatcher) {
|
||||||
super(MainCommand.getInstance(), true);
|
super(MainCommand.getInstance(), true);
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -62,10 +67,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)) {
|
||||||
PlotSquared.get().getEventDispatcher().callTrusted(player, plot, uuid, false);
|
this.eventDispatcher.callTrusted(player, plot, uuid, false);
|
||||||
}
|
}
|
||||||
if (plot.removeMember(uuid)) {
|
if (plot.removeMember(uuid)) {
|
||||||
PlotSquared.get().getEventDispatcher().callMember(player, plot, uuid, false);
|
this.eventDispatcher.callMember(player, plot, uuid, false);
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, Captions.PLOT_LEFT, player.getName());
|
MainUtil.sendMessage(player, Captions.PLOT_LEFT, player.getName());
|
||||||
} else {
|
} else {
|
||||||
|
@ -35,9 +35,11 @@ import com.plotsquared.core.player.PlotPlayer;
|
|||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.Rating;
|
import com.plotsquared.core.plot.Rating;
|
||||||
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -53,7 +55,13 @@ import java.util.UUID;
|
|||||||
requiredType = RequiredType.PLAYER)
|
requiredType = RequiredType.PLAYER)
|
||||||
public class Like extends SubCommand {
|
public class Like extends SubCommand {
|
||||||
|
|
||||||
protected static boolean handleLike(final PlotPlayer player, String[] args,
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
public Like(@NotNull final EventDispatcher eventDispatcher) {
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean handleLike(final PlotPlayer<?> player, String[] args,
|
||||||
final boolean like) {
|
final boolean like) {
|
||||||
final UUID uuid = player.getUUID();
|
final UUID uuid = player.getUUID();
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
@ -125,7 +133,7 @@ public class Like extends SubCommand {
|
|||||||
}
|
}
|
||||||
plot.addRating(uuid, new Rating(rating));
|
plot.addRating(uuid, new Rating(rating));
|
||||||
final PlotRateEvent event =
|
final PlotRateEvent event =
|
||||||
PlotSquared.get().getEventDispatcher().callRating(player, plot, new Rating(rating));
|
this.eventDispatcher.callRating(player, plot, new Rating(rating));
|
||||||
if (event.getRating() != null) {
|
if (event.getRating() != null) {
|
||||||
plot.addRating(uuid, event.getRating());
|
plot.addRating(uuid, event.getRating());
|
||||||
if (like) {
|
if (like) {
|
||||||
|
@ -28,6 +28,7 @@ package com.plotsquared.core.command;
|
|||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.player.ConsolePlayer;
|
import com.plotsquared.core.player.ConsolePlayer;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
@ -35,6 +36,7 @@ import com.plotsquared.core.plot.Plot;
|
|||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.Expression;
|
import com.plotsquared.core.util.Expression;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
@ -62,9 +64,13 @@ public class MainCommand extends Command {
|
|||||||
public static MainCommand getInstance() {
|
public static MainCommand getInstance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new MainCommand();
|
instance = new MainCommand();
|
||||||
|
|
||||||
final PlotAreaManager plotAreaManager = PlotSquared.get().getPlotAreaManager();
|
final PlotAreaManager plotAreaManager = PlotSquared.get().getPlotAreaManager();
|
||||||
|
final EventDispatcher eventDispatcher = PlotSquared.get().getEventDispatcher();
|
||||||
|
final PlotListener plotListener = PlotSquared.get().getPlotListener();
|
||||||
|
|
||||||
new Caps();
|
new Caps();
|
||||||
new Buy();
|
new Buy(eventDispatcher);
|
||||||
new Save(plotAreaManager);
|
new Save(plotAreaManager);
|
||||||
new Load(plotAreaManager);
|
new Load(plotAreaManager);
|
||||||
new Confirm();
|
new Confirm();
|
||||||
@ -72,45 +78,45 @@ public class MainCommand extends Command {
|
|||||||
new Download(plotAreaManager);
|
new Download(plotAreaManager);
|
||||||
new Template(plotAreaManager);
|
new Template(plotAreaManager);
|
||||||
new Setup();
|
new Setup();
|
||||||
new Area(plotAreaManager);
|
new Area(plotAreaManager, eventDispatcher, plotListener);
|
||||||
new DebugSaveTest();
|
new DebugSaveTest();
|
||||||
new DebugLoadTest();
|
new DebugLoadTest();
|
||||||
new CreateRoadSchematic();
|
new CreateRoadSchematic();
|
||||||
new DebugAllowUnsafe();
|
new DebugAllowUnsafe();
|
||||||
new RegenAllRoads(plotAreaManager);
|
new RegenAllRoads(plotAreaManager);
|
||||||
new Claim();
|
new Claim(eventDispatcher);
|
||||||
new Auto(plotAreaManager);
|
new Auto(plotAreaManager, eventDispatcher);
|
||||||
new HomeCommand(plotAreaManager);
|
new HomeCommand(plotAreaManager);
|
||||||
new Visit(plotAreaManager);
|
new Visit(plotAreaManager);
|
||||||
new Set();
|
new Set();
|
||||||
new Clear();
|
new Clear(eventDispatcher);
|
||||||
new Delete();
|
new Delete(eventDispatcher);
|
||||||
new Trust();
|
new Trust(eventDispatcher);
|
||||||
new Add();
|
new Add(eventDispatcher);
|
||||||
new Leave();
|
new Leave(eventDispatcher);
|
||||||
new Deny(plotAreaManager);
|
new Deny(plotAreaManager, eventDispatcher);
|
||||||
new Remove();
|
new Remove(eventDispatcher);
|
||||||
new Info();
|
new Info();
|
||||||
new Near();
|
new Near();
|
||||||
new ListCmd(plotAreaManager);
|
new ListCmd(plotAreaManager);
|
||||||
new Debug(plotAreaManager);
|
new Debug(plotAreaManager);
|
||||||
new SchematicCmd(plotAreaManager);
|
new SchematicCmd(plotAreaManager);
|
||||||
new PluginCmd();
|
new PluginCmd();
|
||||||
new Purge(plotAreaManager);
|
new Purge(plotAreaManager, plotListener);
|
||||||
new Reload(plotAreaManager);
|
new Reload(plotAreaManager);
|
||||||
new Relight();
|
new Relight();
|
||||||
new Merge();
|
new Merge(eventDispatcher);
|
||||||
new DebugPaste();
|
new DebugPaste();
|
||||||
new Unlink();
|
new Unlink(eventDispatcher);
|
||||||
new Kick(plotAreaManager);
|
new Kick(plotAreaManager);
|
||||||
new Inbox();
|
new Inbox();
|
||||||
new Comment();
|
new Comment();
|
||||||
new DatabaseCommand(plotAreaManager);
|
new DatabaseCommand(plotAreaManager, eventDispatcher, plotListener);
|
||||||
new Swap();
|
new Swap();
|
||||||
new Music();
|
new Music();
|
||||||
new DebugRoadRegen();
|
new DebugRoadRegen();
|
||||||
new Trust();
|
new Trust(eventDispatcher);
|
||||||
new DebugExec(plotAreaManager);
|
new DebugExec(plotAreaManager, eventDispatcher);
|
||||||
new FlagCommand();
|
new FlagCommand();
|
||||||
new Target();
|
new Target();
|
||||||
new Move(plotAreaManager);
|
new Move(plotAreaManager);
|
||||||
@ -118,13 +124,13 @@ public class MainCommand extends Command {
|
|||||||
new Copy();
|
new Copy();
|
||||||
new Chat();
|
new Chat();
|
||||||
new Trim(plotAreaManager);
|
new Trim(plotAreaManager);
|
||||||
new Done();
|
new Done(eventDispatcher);
|
||||||
new Continue();
|
new Continue(eventDispatcher);
|
||||||
new Middle();
|
new Middle();
|
||||||
new Grant();
|
new Grant();
|
||||||
// Set commands
|
// Set commands
|
||||||
new Owner();
|
new Owner(eventDispatcher);
|
||||||
new Desc();
|
new Desc(eventDispatcher);
|
||||||
new Biome();
|
new Biome();
|
||||||
new Alias();
|
new Alias();
|
||||||
new SetHome();
|
new SetHome();
|
||||||
@ -133,10 +139,10 @@ public class MainCommand extends Command {
|
|||||||
new Backup();
|
new Backup();
|
||||||
|
|
||||||
if (Settings.Ratings.USE_LIKES) {
|
if (Settings.Ratings.USE_LIKES) {
|
||||||
new Like();
|
final Like like = new Like(eventDispatcher);
|
||||||
new Dislike();
|
new Dislike(like);
|
||||||
} else {
|
} else {
|
||||||
new Rate();
|
new Rate(eventDispatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Referenced commands
|
// Referenced commands
|
||||||
|
@ -36,10 +36,12 @@ import com.plotsquared.core.player.PlotPlayer;
|
|||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.Expression;
|
import com.plotsquared.core.util.Expression;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -56,6 +58,12 @@ public class Merge extends SubCommand {
|
|||||||
public static final String[] values = new String[] {"north", "east", "south", "west"};
|
public static final String[] values = new String[] {"north", "east", "south", "west"};
|
||||||
public static final String[] aliases = new String[] {"n", "e", "s", "w"};
|
public static final String[] aliases = new String[] {"n", "e", "s", "w"};
|
||||||
|
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
public Merge(@NotNull final EventDispatcher eventDispatcher) {
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
public static String direction(float yaw) {
|
public static String direction(float yaw) {
|
||||||
yaw = yaw / 90;
|
yaw = yaw / 90;
|
||||||
int i = Math.round(yaw);
|
int i = Math.round(yaw);
|
||||||
@ -126,7 +134,7 @@ public class Merge extends SubCommand {
|
|||||||
final int size = plot.getConnectedPlots().size();
|
final int size = plot.getConnectedPlots().size();
|
||||||
int max = Permissions.hasPermissionRange(player, "plots.merge", Settings.Limit.MAX_PLOTS);
|
int max = Permissions.hasPermissionRange(player, "plots.merge", Settings.Limit.MAX_PLOTS);
|
||||||
PlotMergeEvent event =
|
PlotMergeEvent event =
|
||||||
PlotSquared.get().getEventDispatcher().callMerge(plot, direction, max, player);
|
this.eventDispatcher.callMerge(plot, direction, max, player);
|
||||||
if (event.getEventResult() == Result.DENY) {
|
if (event.getEventResult() == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Merge");
|
sendMessage(player, Captions.EVENT_DENIED, "Merge");
|
||||||
return false;
|
return false;
|
||||||
|
@ -33,9 +33,11 @@ import com.plotsquared.core.events.PlotUnlinkEvent;
|
|||||||
import com.plotsquared.core.events.Result;
|
import com.plotsquared.core.events.Result;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -52,6 +54,12 @@ import java.util.function.Consumer;
|
|||||||
confirmation = true)
|
confirmation = true)
|
||||||
public class Owner extends SetCommand {
|
public class Owner extends SetCommand {
|
||||||
|
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
public Owner(@NotNull final EventDispatcher eventDispatcher) {
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public boolean set(final PlotPlayer player, final Plot plot, String value) {
|
@Override public boolean set(final PlotPlayer player, final Plot plot, String value) {
|
||||||
if (value == null || value.isEmpty()) {
|
if (value == null || value.isEmpty()) {
|
||||||
Captions.SET_OWNER_MISSING_PLAYER.send(player);
|
Captions.SET_OWNER_MISSING_PLAYER.send(player);
|
||||||
@ -65,8 +73,7 @@ public class Owner extends SetCommand {
|
|||||||
Captions.INVALID_PLAYER.send(player, value);
|
Captions.INVALID_PLAYER.send(player, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotChangeOwnerEvent event = PlotSquared.get().getEventDispatcher()
|
PlotChangeOwnerEvent event = this.eventDispatcher.callOwnerChange(player, plot, plot.hasOwner() ? plot.getOwnerAbs() : null, uuid,
|
||||||
.callOwnerChange(player, plot, plot.hasOwner() ? plot.getOwnerAbs() : null, uuid,
|
|
||||||
plot.hasOwner());
|
plot.hasOwner());
|
||||||
if (event.getEventResult() == Result.DENY) {
|
if (event.getEventResult() == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Owner change");
|
sendMessage(player, Captions.EVENT_DENIED, "Owner change");
|
||||||
@ -80,8 +87,7 @@ public class Owner extends SetCommand {
|
|||||||
true)) {
|
true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotUnlinkEvent unlinkEvent = PlotSquared.get().getEventDispatcher()
|
PlotUnlinkEvent unlinkEvent = this.eventDispatcher.callUnlink(plot.getArea(), plot, false, false, PlotUnlinkEvent.REASON.NEW_OWNER);
|
||||||
.callUnlink(plot.getArea(), plot, false, false, PlotUnlinkEvent.REASON.NEW_OWNER);
|
|
||||||
if (unlinkEvent.getEventResult() == Result.DENY) {
|
if (unlinkEvent.getEventResult() == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Unlink on owner change");
|
sendMessage(player, Captions.EVENT_DENIED, "Unlink on owner change");
|
||||||
return;
|
return;
|
||||||
|
@ -56,9 +56,11 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
public class Purge extends SubCommand {
|
public class Purge extends SubCommand {
|
||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
private final PlotListener plotListener;
|
||||||
|
|
||||||
public Purge(@NotNull final PlotAreaManager plotAreaManager) {
|
public Purge(@NotNull final PlotAreaManager plotAreaManager, @NotNull final PlotListener plotListener) {
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
this.plotListener = plotListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||||
@ -197,8 +199,8 @@ public class Purge extends SubCommand {
|
|||||||
plot.removeSign();
|
plot.removeSign();
|
||||||
}
|
}
|
||||||
plot.getArea().removePlot(plot.getId());
|
plot.getArea().removePlot(plot.getId());
|
||||||
for (PlotPlayer pp : plot.getPlayersInPlot()) {
|
for (PlotPlayer<?> pp : plot.getPlayersInPlot()) {
|
||||||
PlotListener.plotEntry(pp, plot);
|
Purge.this.plotListener.plotEntry(pp, plot);
|
||||||
}
|
}
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
PlotSquared.log(
|
PlotSquared.log(
|
||||||
|
@ -37,10 +37,12 @@ import com.plotsquared.core.plot.PlotInventory;
|
|||||||
import com.plotsquared.core.plot.PlotItemStack;
|
import com.plotsquared.core.plot.PlotItemStack;
|
||||||
import com.plotsquared.core.plot.Rating;
|
import com.plotsquared.core.plot.Rating;
|
||||||
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -56,6 +58,12 @@ import java.util.UUID;
|
|||||||
requiredType = RequiredType.PLAYER)
|
requiredType = RequiredType.PLAYER)
|
||||||
public class Rate extends SubCommand {
|
public class Rate extends SubCommand {
|
||||||
|
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
public Rate(@NotNull final EventDispatcher eventDispatcher) {
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
@ -141,7 +149,7 @@ 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();
|
||||||
PlotRateEvent event = PlotSquared.get().getEventDispatcher()
|
PlotRateEvent event = Rate.this.eventDispatcher
|
||||||
.callRating(this.player, plot, new Rating(rV));
|
.callRating(this.player, plot, new Rating(rV));
|
||||||
if (event.getRating() != null) {
|
if (event.getRating() != null) {
|
||||||
plot.addRating(this.player.getUUID(), event.getRating());
|
plot.addRating(this.player.getUUID(), event.getRating());
|
||||||
@ -211,7 +219,7 @@ public class Rate extends SubCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotRateEvent event =
|
PlotRateEvent event =
|
||||||
PlotSquared.get().getEventDispatcher().callRating(player, plot, new Rating(rating));
|
this.eventDispatcher.callRating(player, plot, new Rating(rating));
|
||||||
if (event.getRating() != null) {
|
if (event.getRating() != null) {
|
||||||
plot.addRating(uuid, event.getRating());
|
plot.addRating(uuid, event.getRating());
|
||||||
sendMessage(player, Captions.RATING_APPLIED, plot.getId().toString());
|
sendMessage(player, Captions.RATING_APPLIED, plot.getId().toString());
|
||||||
|
@ -25,15 +25,16 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.database.DBFunc;
|
import com.plotsquared.core.database.DBFunc;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.TabCompletions;
|
import com.plotsquared.core.util.TabCompletions;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -49,8 +50,11 @@ import java.util.concurrent.TimeoutException;
|
|||||||
permission = "plots.remove")
|
permission = "plots.remove")
|
||||||
public class Remove extends SubCommand {
|
public class Remove extends SubCommand {
|
||||||
|
|
||||||
public Remove() {
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
public Remove(@NotNull final EventDispatcher eventDispatcher) {
|
||||||
super(Argument.PlayerName);
|
super(Argument.PlayerName);
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||||
@ -81,34 +85,28 @@ 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)) {
|
||||||
PlotSquared.get().getEventDispatcher()
|
this.eventDispatcher.callTrusted(player, plot, uuid, false);
|
||||||
.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)) {
|
||||||
PlotSquared.get().getEventDispatcher()
|
this.eventDispatcher.callMember(player, plot, uuid, false);
|
||||||
.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)) {
|
||||||
PlotSquared.get().getEventDispatcher()
|
this.eventDispatcher.callDenied(player, plot, uuid, false);
|
||||||
.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)) {
|
||||||
PlotSquared.get().getEventDispatcher()
|
this.eventDispatcher.callTrusted(player, plot, uuid, false);
|
||||||
.callTrusted(player, plot, uuid, false);
|
|
||||||
count++;
|
count++;
|
||||||
} else if (plot.removeMember(uuid)) {
|
} else if (plot.removeMember(uuid)) {
|
||||||
PlotSquared.get().getEventDispatcher()
|
this.eventDispatcher.callMember(player, plot, uuid, false);
|
||||||
.callMember(player, plot, uuid, false);
|
|
||||||
count++;
|
count++;
|
||||||
} else if (plot.removeDenied(uuid)) {
|
} else if (plot.removeDenied(uuid)) {
|
||||||
PlotSquared.get().getEventDispatcher()
|
this.eventDispatcher.callDenied(player, plot, uuid, false);
|
||||||
.callDenied(player, plot, uuid, false);
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,16 +25,17 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.database.DBFunc;
|
import com.plotsquared.core.database.DBFunc;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.TabCompletions;
|
import com.plotsquared.core.util.TabCompletions;
|
||||||
import com.plotsquared.core.util.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -51,8 +52,11 @@ import java.util.concurrent.TimeoutException;
|
|||||||
category = CommandCategory.SETTINGS)
|
category = CommandCategory.SETTINGS)
|
||||||
public class Trust extends Command {
|
public class Trust extends Command {
|
||||||
|
|
||||||
public Trust() {
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
public Trust(@NotNull final EventDispatcher eventDispatcher) {
|
||||||
super(MainCommand.getInstance(), true);
|
super(MainCommand.getInstance(), true);
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -119,7 +123,7 @@ public class Trust extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentPlot.addTrusted(uuid);
|
currentPlot.addTrusted(uuid);
|
||||||
PlotSquared.get().getEventDispatcher().callTrusted(player, currentPlot, uuid, true);
|
this.eventDispatcher.callTrusted(player, currentPlot, uuid, true);
|
||||||
MainUtil.sendMessage(player, Captions.TRUSTED_ADDED);
|
MainUtil.sendMessage(player, Captions.TRUSTED_ADDED);
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
|
@ -25,17 +25,18 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.events.PlotUnlinkEvent;
|
import com.plotsquared.core.events.PlotUnlinkEvent;
|
||||||
import com.plotsquared.core.events.Result;
|
import com.plotsquared.core.events.Result;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@CommandDeclaration(command = "unlink",
|
@CommandDeclaration(command = "unlink",
|
||||||
aliases = {"u", "unmerge"},
|
aliases = {"u", "unmerge"},
|
||||||
@ -46,6 +47,12 @@ import com.plotsquared.core.util.task.TaskManager;
|
|||||||
confirmation = true)
|
confirmation = true)
|
||||||
public class Unlink extends SubCommand {
|
public class Unlink extends SubCommand {
|
||||||
|
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
public Unlink(@NotNull final EventDispatcher eventDispatcher) {
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
final Plot plot = location.getPlotAbs();
|
final Plot plot = location.getPlotAbs();
|
||||||
@ -69,7 +76,7 @@ public class Unlink extends SubCommand {
|
|||||||
createRoad = true;
|
createRoad = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotUnlinkEvent event = PlotSquared.get().getEventDispatcher()
|
PlotUnlinkEvent event = this.eventDispatcher
|
||||||
.callUnlink(plot.getArea(), plot, createRoad, createRoad,
|
.callUnlink(plot.getArea(), plot, createRoad, createRoad,
|
||||||
PlotUnlinkEvent.REASON.PLAYER_COMMAND);
|
PlotUnlinkEvent.REASON.PLAYER_COMMAND);
|
||||||
if (event.getEventResult() == Result.DENY) {
|
if (event.getEventResult() == Result.DENY) {
|
||||||
|
@ -31,6 +31,7 @@ import com.plotsquared.core.configuration.Captions;
|
|||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.configuration.Storage;
|
import com.plotsquared.core.configuration.Storage;
|
||||||
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.location.BlockLoc;
|
import com.plotsquared.core.location.BlockLoc;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
@ -43,6 +44,7 @@ import com.plotsquared.core.plot.flag.FlagParseException;
|
|||||||
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
|
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
|
||||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||||
import com.plotsquared.core.plot.flag.types.BlockTypeListFlag;
|
import com.plotsquared.core.plot.flag.types.BlockTypeListFlag;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
@ -128,6 +130,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
private Connection connection;
|
private Connection connection;
|
||||||
private boolean closed = false;
|
private boolean closed = false;
|
||||||
|
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
private final PlotListener plotListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -136,9 +141,12 @@ public class SQLManager implements AbstractDB {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
public SQLManager(final Database database, String prefix, boolean debug)
|
public SQLManager(final Database database, String prefix,
|
||||||
|
@NotNull final EventDispatcher eventDispatcher, @NotNull final PlotListener plotListener)
|
||||||
throws SQLException, ClassNotFoundException {
|
throws SQLException, ClassNotFoundException {
|
||||||
// Private final
|
// Private final
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
this.plotListener = plotListener;
|
||||||
this.database = database;
|
this.database = database;
|
||||||
this.connection = database.openConnection();
|
this.connection = database.openConnection();
|
||||||
this.mySQL = database instanceof MySQL;
|
this.mySQL = database instanceof MySQL;
|
||||||
@ -1828,7 +1836,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
Plot p = new Plot(plot_id, user, new HashSet<>(), new HashSet<>(),
|
Plot p = new Plot(plot_id, user, new HashSet<>(), new HashSet<>(),
|
||||||
new HashSet<>(), "", null, null, null,
|
new HashSet<>(), "", null, null, null,
|
||||||
new boolean[] {false, false, false, false}, time, id);
|
new boolean[] {false, false, false, false}, time, id, this.eventDispatcher, this.plotListener);
|
||||||
HashMap<PlotId, Plot> map = newPlots.get(areaID);
|
HashMap<PlotId, Plot> map = newPlots.get(areaID);
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
Plot last = map.put(p.getId(), p);
|
Plot last = map.put(p.getId(), p);
|
||||||
|
@ -28,8 +28,10 @@ package com.plotsquared.core.generator;
|
|||||||
import com.plotsquared.core.configuration.ConfigurationNode;
|
import com.plotsquared.core.configuration.ConfigurationNode;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
import com.plotsquared.core.configuration.ConfigurationUtil;
|
import com.plotsquared.core.configuration.ConfigurationUtil;
|
||||||
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.plot.BlockBucket;
|
import com.plotsquared.core.plot.BlockBucket;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -54,8 +56,9 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
|
|||||||
public boolean PLOT_BEDROCK = true;
|
public boolean PLOT_BEDROCK = true;
|
||||||
|
|
||||||
public ClassicPlotWorld(String worldName, String id,
|
public ClassicPlotWorld(String worldName, String id,
|
||||||
@NotNull IndependentPlotGenerator generator, PlotId min, PlotId max) {
|
@NotNull IndependentPlotGenerator generator, PlotId min, PlotId max, @NotNull final
|
||||||
super(worldName, id, generator, min, max);
|
EventDispatcher eventDispatcher, @NotNull final PlotListener plotListener) {
|
||||||
|
super(worldName, id, generator, min, max, eventDispatcher, plotListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,8 +25,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.generator;
|
package com.plotsquared.core.generator;
|
||||||
|
|
||||||
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public abstract class GridPlotWorld extends PlotArea {
|
public abstract class GridPlotWorld extends PlotArea {
|
||||||
@ -34,7 +36,8 @@ public abstract class GridPlotWorld extends PlotArea {
|
|||||||
public short SIZE;
|
public short SIZE;
|
||||||
|
|
||||||
public GridPlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
|
public GridPlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
|
||||||
PlotId min, PlotId max) {
|
PlotId min, PlotId max, @NotNull final EventDispatcher eventDispatcher, @NotNull final
|
||||||
super(worldName, id, generator, min, max);
|
PlotListener plotListener) {
|
||||||
|
super(worldName, id, generator, min, max, eventDispatcher, plotListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,17 +28,23 @@ package com.plotsquared.core.generator;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HybridGen extends IndependentPlotGenerator {
|
@RequiredArgsConstructor public class HybridGen extends IndependentPlotGenerator {
|
||||||
|
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
private final PlotListener plotListener;
|
||||||
|
|
||||||
@Override public String getName() {
|
@Override public String getName() {
|
||||||
return PlotSquared.platform().getPluginName();
|
return PlotSquared.platform().getPluginName();
|
||||||
@ -220,7 +226,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
@Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
||||||
return new HybridPlotWorld(world, id, this, min, max);
|
return new HybridPlotWorld(world, id, this, min, max, this.eventDispatcher, this.plotListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void initialize(PlotArea area) {
|
@Override public void initialize(PlotArea area) {
|
||||||
|
@ -29,12 +29,14 @@ import com.plotsquared.core.PlotSquared;
|
|||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.plot.PlotManager;
|
import com.plotsquared.core.plot.PlotManager;
|
||||||
import com.plotsquared.core.plot.schematic.Schematic;
|
import com.plotsquared.core.plot.schematic.Schematic;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.SchematicHandler;
|
import com.plotsquared.core.util.SchematicHandler;
|
||||||
@ -73,8 +75,9 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
@Getter private File root = null;
|
@Getter private File root = null;
|
||||||
|
|
||||||
public HybridPlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
|
public HybridPlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
|
||||||
PlotId min, PlotId max) {
|
PlotId min, PlotId max, @NotNull final EventDispatcher eventDispatcher, @NotNull final
|
||||||
super(worldName, id, generator, min, max);
|
PlotListener plotListener) {
|
||||||
|
super(worldName, id, generator, min, max, eventDispatcher, plotListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte wrap(byte data, int start) {
|
public static byte wrap(byte data, int start) {
|
||||||
|
@ -27,7 +27,9 @@ package com.plotsquared.core.generator;
|
|||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public abstract class SquarePlotWorld extends GridPlotWorld {
|
public abstract class SquarePlotWorld extends GridPlotWorld {
|
||||||
@ -38,8 +40,9 @@ public abstract class SquarePlotWorld extends GridPlotWorld {
|
|||||||
public int ROAD_OFFSET_Z = 0;
|
public int ROAD_OFFSET_Z = 0;
|
||||||
|
|
||||||
public SquarePlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
|
public SquarePlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
|
||||||
PlotId min, PlotId max) {
|
PlotId min, PlotId max, @NotNull final EventDispatcher eventDispatcher, @NotNull final
|
||||||
super(worldName, id, generator, min, max);
|
PlotListener plotListener) {
|
||||||
|
super(worldName, id, generator, min, max, eventDispatcher, plotListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void loadConfiguration(ConfigurationSection config) {
|
@Override public void loadConfiguration(ConfigurationSection config) {
|
||||||
|
@ -55,6 +55,7 @@ import com.plotsquared.core.plot.flag.implementations.TimeFlag;
|
|||||||
import com.plotsquared.core.plot.flag.implementations.TitlesFlag;
|
import com.plotsquared.core.plot.flag.implementations.TitlesFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.WeatherFlag;
|
import com.plotsquared.core.plot.flag.implementations.WeatherFlag;
|
||||||
import com.plotsquared.core.plot.flag.types.TimedFlag;
|
import com.plotsquared.core.plot.flag.types.TimedFlag;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
@ -65,18 +66,21 @@ import com.sk89q.worldedit.world.gamemode.GameMode;
|
|||||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlotListener {
|
@RequiredArgsConstructor public class PlotListener {
|
||||||
|
|
||||||
private static final HashMap<UUID, Interval> feedRunnable = new HashMap<>();
|
private final HashMap<UUID, Interval> feedRunnable = new HashMap<>();
|
||||||
private static final HashMap<UUID, Interval> healRunnable = new HashMap<>();
|
private final HashMap<UUID, Interval> healRunnable = new HashMap<>();
|
||||||
|
|
||||||
public static void startRunnable() {
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
public void startRunnable() {
|
||||||
TaskManager.runTaskRepeat(() -> {
|
TaskManager.runTaskRepeat(() -> {
|
||||||
if (!healRunnable.isEmpty()) {
|
if (!healRunnable.isEmpty()) {
|
||||||
for (Iterator<Map.Entry<UUID, Interval>> iterator =
|
for (Iterator<Map.Entry<UUID, Interval>> iterator =
|
||||||
@ -123,7 +127,7 @@ public class PlotListener {
|
|||||||
}, 20);
|
}, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean plotEntry(final PlotPlayer<?> player, final Plot plot) {
|
public 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")) {
|
||||||
return false;
|
return false;
|
||||||
@ -136,7 +140,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);
|
||||||
PlotSquared.get().getEventDispatcher().callEntry(player, plot);
|
this.eventDispatcher.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);
|
||||||
@ -215,7 +219,7 @@ public class PlotListener {
|
|||||||
PlotFlag<?, ?> plotFlag =
|
PlotFlag<?, ?> plotFlag =
|
||||||
GlobalFlagContainer.getInstance().getFlag(TimeFlag.class);
|
GlobalFlagContainer.getInstance().getFlag(TimeFlag.class);
|
||||||
PlotFlagRemoveEvent event =
|
PlotFlagRemoveEvent event =
|
||||||
PlotSquared.get().getEventDispatcher().callFlagRemove(plotFlag, plot);
|
this.eventDispatcher.callFlagRemove(plotFlag, plot);
|
||||||
if (event.getEventResult() != Result.DENY) {
|
if (event.getEventResult() != Result.DENY) {
|
||||||
plot.removeFlag(event.getFlag());
|
plot.removeFlag(event.getFlag());
|
||||||
}
|
}
|
||||||
@ -293,9 +297,9 @@ public class PlotListener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean plotExit(final PlotPlayer<?> player, Plot plot) {
|
public boolean plotExit(final PlotPlayer<?> player, Plot plot) {
|
||||||
Object previous = player.deleteMeta(PlotPlayer.META_LAST_PLOT);
|
Object previous = player.deleteMeta(PlotPlayer.META_LAST_PLOT);
|
||||||
PlotSquared.get().getEventDispatcher().callLeave(player, plot);
|
this.eventDispatcher.callLeave(player, plot);
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
PlotArea pw = plot.getArea();
|
PlotArea pw = plot.getArea();
|
||||||
if (pw == null) {
|
if (pw == null) {
|
||||||
@ -383,7 +387,7 @@ public class PlotListener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logout(UUID uuid) {
|
public void logout(UUID uuid) {
|
||||||
feedRunnable.remove(uuid);
|
feedRunnable.remove(uuid);
|
||||||
healRunnable.remove(uuid);
|
healRunnable.remove(uuid);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import com.plotsquared.core.location.Location;
|
|||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotWeather;
|
import com.plotsquared.core.plot.PlotWeather;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
@ -46,8 +47,8 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
|
|||||||
|
|
||||||
private static ConsolePlayer instance;
|
private static ConsolePlayer instance;
|
||||||
|
|
||||||
private ConsolePlayer(final PlotAreaManager plotAreaManager) {
|
private ConsolePlayer(final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher) {
|
||||||
super(plotAreaManager);
|
super(plotAreaManager, eventDispatcher);
|
||||||
final PlotArea[] areas = plotAreaManager.getAllPlotAreas();
|
final PlotArea[] areas = plotAreaManager.getAllPlotAreas();
|
||||||
final PlotArea area;
|
final PlotArea area;
|
||||||
if (areas.length > 0) {
|
if (areas.length > 0) {
|
||||||
@ -69,7 +70,7 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
|
|||||||
|
|
||||||
public static ConsolePlayer getConsole() {
|
public static ConsolePlayer getConsole() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new ConsolePlayer(PlotSquared.get().getPlotAreaManager());
|
instance = new ConsolePlayer(PlotSquared.get().getPlotAreaManager(), PlotSquared.get().getEventDispatcher());
|
||||||
instance.teleport(instance.getLocation());
|
instance.teleport(instance.getLocation());
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
package com.plotsquared.core.player;
|
package com.plotsquared.core.player;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.plotsquared.core.PlotPlatform;
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.command.CommandCaller;
|
import com.plotsquared.core.command.CommandCaller;
|
||||||
import com.plotsquared.core.command.RequiredType;
|
import com.plotsquared.core.command.RequiredType;
|
||||||
@ -47,6 +46,7 @@ import com.plotsquared.core.plot.world.PlotAreaManager;
|
|||||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.query.PlotQuery;
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
@ -90,9 +90,11 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
|||||||
private int hash;
|
private int hash;
|
||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
public PlotPlayer(@NotNull final PlotAreaManager plotAreaManager) {
|
public PlotPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher) {
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> PlotPlayer<T> from(@NonNull final T object) {
|
public static <T> PlotPlayer<T> from(@NonNull final T object) {
|
||||||
@ -583,7 +585,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
|||||||
removePersistentMeta("quitLoc");
|
removePersistentMeta("quitLoc");
|
||||||
}
|
}
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
PlotSquared.get().getEventDispatcher().callLeave(this, plot);
|
this.eventDispatcher.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()) {
|
||||||
|
@ -55,6 +55,7 @@ import com.plotsquared.core.plot.flag.implementations.KeepFlag;
|
|||||||
import com.plotsquared.core.plot.schematic.Schematic;
|
import com.plotsquared.core.plot.schematic.Schematic;
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.LocalBlockQueue;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
@ -123,6 +124,9 @@ public class Plot {
|
|||||||
private static Set<CuboidRegion> regions_cache;
|
private static Set<CuboidRegion> regions_cache;
|
||||||
|
|
||||||
@NotNull private final PlotId id;
|
@NotNull private final PlotId id;
|
||||||
|
@NotNull private final EventDispatcher eventDispatcher;
|
||||||
|
@NotNull private final PlotListener plotListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plot flag container
|
* Plot flag container
|
||||||
*/
|
*/
|
||||||
@ -193,8 +197,9 @@ public class Plot {
|
|||||||
* @param owner the plot owner
|
* @param owner the plot owner
|
||||||
* @see Plot#getPlot(Location) for existing plots
|
* @see Plot#getPlot(Location) for existing plots
|
||||||
*/
|
*/
|
||||||
public Plot(PlotArea area, @NotNull PlotId id, UUID owner) {
|
public Plot(final PlotArea area, @NotNull final PlotId id, final UUID owner,
|
||||||
this(area, id, owner, 0);
|
@NotNull final EventDispatcher eventDispatcher, @NotNull final PlotListener plotListener) {
|
||||||
|
this(area, id, owner, 0, eventDispatcher, plotListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -205,8 +210,9 @@ public class Plot {
|
|||||||
* @param id the plot id
|
* @param id the plot id
|
||||||
* @see Plot#getPlot(Location) for existing plots
|
* @see Plot#getPlot(Location) for existing plots
|
||||||
*/
|
*/
|
||||||
public Plot(@NotNull PlotArea area, @NotNull PlotId id) {
|
public Plot(@NotNull final PlotArea area, @NotNull final PlotId id,
|
||||||
this(area, id, null, 0);
|
@NotNull final EventDispatcher eventDispatcher, @NotNull final PlotListener plotListener) {
|
||||||
|
this(area, id, null, 0, eventDispatcher, plotListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -220,12 +226,15 @@ public class Plot {
|
|||||||
* @param temp Represents whatever the database manager needs it to
|
* @param temp Represents whatever the database manager needs it to
|
||||||
* @see Plot#getPlot(Location) for existing plots
|
* @see Plot#getPlot(Location) for existing plots
|
||||||
*/
|
*/
|
||||||
public Plot(PlotArea area, @NotNull PlotId id, UUID owner, int temp) {
|
public Plot(final PlotArea area, @NotNull final PlotId id, final UUID owner, final int temp,
|
||||||
|
@NotNull final EventDispatcher eventDispatcher, @NotNull final PlotListener plotListener) {
|
||||||
this.area = area;
|
this.area = area;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.temp = temp;
|
this.temp = temp;
|
||||||
this.flagContainer.setParentContainer(area.getFlagContainer());
|
this.flagContainer.setParentContainer(area.getFlagContainer());
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
this.plotListener = plotListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -240,7 +249,8 @@ public class Plot {
|
|||||||
*/
|
*/
|
||||||
public Plot(@NotNull PlotId id, UUID owner, HashSet<UUID> trusted, HashSet<UUID> members,
|
public Plot(@NotNull PlotId id, UUID owner, HashSet<UUID> trusted, HashSet<UUID> members,
|
||||||
HashSet<UUID> denied, String alias, BlockLoc position, Collection<PlotFlag<?, ?>> flags,
|
HashSet<UUID> denied, String alias, BlockLoc position, Collection<PlotFlag<?, ?>> flags,
|
||||||
PlotArea area, boolean[] merged, long timestamp, int temp) {
|
PlotArea area, boolean[] merged, long timestamp, int temp,
|
||||||
|
@NotNull final EventDispatcher eventDispatcher, @NotNull final PlotListener plotListener) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.area = area;
|
this.area = area;
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
@ -261,6 +271,8 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
this.plotListener = plotListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -925,7 +937,7 @@ public class Plot {
|
|||||||
if (isDelete) {
|
if (isDelete) {
|
||||||
this.removeSign();
|
this.removeSign();
|
||||||
}
|
}
|
||||||
PlotUnlinkEvent event = PlotSquared.get().getEventDispatcher()
|
PlotUnlinkEvent event = this.eventDispatcher
|
||||||
.callUnlink(getArea(), this, true, !isDelete,
|
.callUnlink(getArea(), this, true, !isDelete,
|
||||||
isDelete ? PlotUnlinkEvent.REASON.DELETE : PlotUnlinkEvent.REASON.CLEAR);
|
isDelete ? PlotUnlinkEvent.REASON.DELETE : PlotUnlinkEvent.REASON.CLEAR);
|
||||||
if (event.getEventResult() != Result.DENY) {
|
if (event.getEventResult() != Result.DENY) {
|
||||||
@ -1325,7 +1337,7 @@ public class Plot {
|
|||||||
for (Plot current : getConnectedPlots()) {
|
for (Plot current : getConnectedPlots()) {
|
||||||
List<PlotPlayer<?>> players = current.getPlayersInPlot();
|
List<PlotPlayer<?>> players = current.getPlayersInPlot();
|
||||||
for (PlotPlayer<?> pp : players) {
|
for (PlotPlayer<?> pp : players) {
|
||||||
PlotListener.plotExit(pp, current);
|
this.plotListener.plotExit(pp, current);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.Backup.DELETE_ON_UNCLAIM) {
|
if (Settings.Backup.DELETE_ON_UNCLAIM) {
|
||||||
@ -1339,7 +1351,7 @@ public class Plot {
|
|||||||
current.setOwnerAbs(null);
|
current.setOwnerAbs(null);
|
||||||
current.settings = null;
|
current.settings = null;
|
||||||
for (PlotPlayer pp : players) {
|
for (PlotPlayer pp : players) {
|
||||||
PlotListener.plotEntry(pp, current);
|
this.plotListener.plotEntry(pp, current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1816,7 +1828,7 @@ public class Plot {
|
|||||||
PlotArea plotworld = Plot.this.area;
|
PlotArea plotworld = Plot.this.area;
|
||||||
if (notify && plotworld.isAutoMerge()) {
|
if (notify && plotworld.isAutoMerge()) {
|
||||||
PlotPlayer player = WorldUtil.IMP.wrapPlayer(uuid);
|
PlotPlayer player = WorldUtil.IMP.wrapPlayer(uuid);
|
||||||
PlotMergeEvent event = PlotSquared.get().getEventDispatcher()
|
PlotMergeEvent event = this.eventDispatcher
|
||||||
.callMerge(this, Direction.ALL, Integer.MAX_VALUE, player);
|
.callMerge(this, Direction.ALL, Integer.MAX_VALUE, player);
|
||||||
if (event.getEventResult() == Result.DENY) {
|
if (event.getEventResult() == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Auto merge on claim");
|
sendMessage(player, Captions.EVENT_DENIED, "Auto merge on claim");
|
||||||
@ -2906,8 +2918,8 @@ public class Plot {
|
|||||||
public void reEnter() {
|
public void reEnter() {
|
||||||
TaskManager.runTaskLater(() -> {
|
TaskManager.runTaskLater(() -> {
|
||||||
for (PlotPlayer<?> pp : Plot.this.getPlayersInPlot()) {
|
for (PlotPlayer<?> pp : Plot.this.getPlayersInPlot()) {
|
||||||
PlotListener.plotExit(pp, Plot.this);
|
this.plotListener.plotExit(pp, Plot.this);
|
||||||
PlotListener.plotEntry(pp, Plot.this);
|
this.plotListener.plotEntry(pp, Plot.this);
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
@ -2977,7 +2989,7 @@ public class Plot {
|
|||||||
Consumer<Boolean> resultConsumer) {
|
Consumer<Boolean> resultConsumer) {
|
||||||
Plot plot = this.getBasePlot(false);
|
Plot plot = this.getBasePlot(false);
|
||||||
Result result =
|
Result result =
|
||||||
PlotSquared.get().getEventDispatcher().callTeleport(player, player.getLocation(), plot)
|
this.eventDispatcher.callTeleport(player, player.getLocation(), plot)
|
||||||
.getEventResult();
|
.getEventResult();
|
||||||
if (result == Result.DENY) {
|
if (result == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Teleport");
|
sendMessage(player, Captions.EVENT_DENIED, "Teleport");
|
||||||
@ -3049,7 +3061,7 @@ public class Plot {
|
|||||||
*/
|
*/
|
||||||
public boolean setComponent(String component, Pattern blocks) {
|
public boolean setComponent(String component, Pattern blocks) {
|
||||||
PlotComponentSetEvent event =
|
PlotComponentSetEvent event =
|
||||||
PlotSquared.get().getEventDispatcher().callComponentSet(this, component, blocks);
|
this.eventDispatcher.callComponentSet(this, component, blocks);
|
||||||
component = event.getComponent();
|
component = event.getComponent();
|
||||||
blocks = event.getPattern();
|
blocks = event.getPattern();
|
||||||
return this.getManager().setComponent(this.getId(), component, blocks);
|
return this.getManager().setComponent(this.getId(), component, blocks);
|
||||||
|
@ -37,6 +37,7 @@ import com.plotsquared.core.configuration.ConfigurationUtil;
|
|||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.generator.GridPlotWorld;
|
import com.plotsquared.core.generator.GridPlotWorld;
|
||||||
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
||||||
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.location.Direction;
|
import com.plotsquared.core.location.Direction;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.location.PlotLoc;
|
import com.plotsquared.core.location.PlotLoc;
|
||||||
@ -49,6 +50,7 @@ import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
|||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.LocalBlockQueue;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.Expression;
|
import com.plotsquared.core.util.Expression;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
@ -133,9 +135,13 @@ public abstract class PlotArea {
|
|||||||
@Getter private final FlagContainer roadFlagContainer =
|
@Getter private final FlagContainer roadFlagContainer =
|
||||||
new FlagContainer(GlobalFlagContainer.getInstance());
|
new FlagContainer(GlobalFlagContainer.getInstance());
|
||||||
|
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
private final PlotListener plotListener;
|
||||||
|
|
||||||
public PlotArea(@NotNull final String worldName, @Nullable final String id,
|
public PlotArea(@NotNull final String worldName, @Nullable final String id,
|
||||||
@NotNull IndependentPlotGenerator generator, @Nullable final PlotId min,
|
@NotNull IndependentPlotGenerator generator, @Nullable final PlotId min,
|
||||||
@Nullable final PlotId max) {
|
@Nullable final PlotId max, @NotNull final EventDispatcher eventDispatcher,
|
||||||
|
@NotNull final PlotListener plotListener) {
|
||||||
this.worldName = worldName;
|
this.worldName = worldName;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.plotManager = createManager();
|
this.plotManager = createManager();
|
||||||
@ -152,6 +158,8 @@ public abstract class PlotArea {
|
|||||||
this.max = max;
|
this.max = max;
|
||||||
}
|
}
|
||||||
this.worldHash = worldName.hashCode();
|
this.worldHash = worldName.hashCode();
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
this.plotListener = plotListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull protected abstract PlotManager createManager();
|
@NotNull protected abstract PlotManager createManager();
|
||||||
@ -649,7 +657,7 @@ public abstract class PlotArea {
|
|||||||
|| id.y > this.max.y)) {
|
|| id.y > this.max.y)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new Plot(this, id);
|
return new Plot(this, id, this.eventDispatcher, this.plotListener);
|
||||||
}
|
}
|
||||||
return plot;
|
return plot;
|
||||||
}
|
}
|
||||||
@ -661,7 +669,7 @@ public abstract class PlotArea {
|
|||||||
|| id.y > this.max.y)) {
|
|| id.y > this.max.y)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new Plot(this, id);
|
return new Plot(this, id, this.eventDispatcher, this.plotListener);
|
||||||
}
|
}
|
||||||
return plot.getBasePlot(false);
|
return plot.getBasePlot(false);
|
||||||
}
|
}
|
||||||
|
@ -42,12 +42,14 @@ import com.plotsquared.core.plot.flag.PlotFlag;
|
|||||||
import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
|
import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.KeepFlag;
|
import com.plotsquared.core.plot.flag.implementations.KeepFlag;
|
||||||
import com.plotsquared.core.plot.message.PlotMessage;
|
import com.plotsquared.core.plot.message.PlotMessage;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
import com.plotsquared.core.util.query.PlotQuery;
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -66,17 +68,20 @@ public class ExpireManager {
|
|||||||
public static ExpireManager IMP;
|
public static ExpireManager IMP;
|
||||||
private final ConcurrentHashMap<UUID, Long> dates_cache;
|
private final ConcurrentHashMap<UUID, Long> dates_cache;
|
||||||
private final ConcurrentHashMap<UUID, Long> account_age_cache;
|
private final ConcurrentHashMap<UUID, Long> account_age_cache;
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
private volatile HashSet<Plot> plotsToDelete;
|
private volatile HashSet<Plot> plotsToDelete;
|
||||||
private ArrayDeque<ExpiryTask> tasks;
|
private ArrayDeque<ExpiryTask> tasks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 0 = stopped, 1 = stopping, 2 = running
|
* 0 = stopped, 1 = stopping, 2 = running
|
||||||
*/
|
*/
|
||||||
private int running;
|
private int running;
|
||||||
|
|
||||||
public ExpireManager() {
|
public ExpireManager(@NotNull final EventDispatcher eventDispatcher) {
|
||||||
tasks = new ArrayDeque<>();
|
this.tasks = new ArrayDeque<>();
|
||||||
dates_cache = new ConcurrentHashMap<>();
|
this.dates_cache = new ConcurrentHashMap<>();
|
||||||
account_age_cache = new ConcurrentHashMap<>();
|
this.account_age_cache = new ConcurrentHashMap<>();
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTask(ExpiryTask task) {
|
public void addTask(ExpiryTask task) {
|
||||||
@ -402,7 +407,7 @@ public class ExpireManager {
|
|||||||
|
|
||||||
public void deleteWithMessage(Plot plot, Runnable whenDone) {
|
public void deleteWithMessage(Plot plot, Runnable whenDone) {
|
||||||
if (plot.isMerged()) {
|
if (plot.isMerged()) {
|
||||||
PlotUnlinkEvent event = PlotSquared.get().getEventDispatcher()
|
PlotUnlinkEvent event = this.eventDispatcher
|
||||||
.callUnlink(plot.getArea(), plot, true, false,
|
.callUnlink(plot.getArea(), plot, true, false,
|
||||||
PlotUnlinkEvent.REASON.EXPIRE_DELETE);
|
PlotUnlinkEvent.REASON.EXPIRE_DELETE);
|
||||||
if (event.getEventResult() != Result.DENY) {
|
if (event.getEventResult() != Result.DENY) {
|
||||||
|
@ -25,12 +25,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.plot.world;
|
package com.plotsquared.core.plot.world;
|
||||||
|
|
||||||
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.location.BlockLoc;
|
import com.plotsquared.core.location.BlockLoc;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -47,23 +49,17 @@ public class SinglePlot extends Plot {
|
|||||||
new CuboidRegion(BlockVector3.at(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE),
|
new CuboidRegion(BlockVector3.at(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE),
|
||||||
BlockVector3.at(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE)));
|
BlockVector3.at(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE)));
|
||||||
|
|
||||||
public SinglePlot(PlotArea area, PlotId id, UUID owner) {
|
public SinglePlot(PlotArea area, PlotId id, @NotNull final EventDispatcher eventDispatcher, @NotNull final
|
||||||
super(area, id, owner);
|
PlotListener plotListener) {
|
||||||
}
|
super(area, id, eventDispatcher, plotListener);
|
||||||
|
|
||||||
public SinglePlot(PlotArea area, PlotId id) {
|
|
||||||
super(area, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SinglePlot(PlotArea area, PlotId id, UUID owner, int temp) {
|
|
||||||
super(area, id, owner, temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SinglePlot(PlotId id, UUID owner, HashSet<UUID> trusted, HashSet<UUID> members,
|
public SinglePlot(PlotId id, UUID owner, HashSet<UUID> trusted, HashSet<UUID> members,
|
||||||
HashSet<UUID> denied, String alias, BlockLoc position, Collection<PlotFlag<?, ?>> flags,
|
HashSet<UUID> denied, String alias, BlockLoc position, Collection<PlotFlag<?, ?>> flags,
|
||||||
PlotArea area, boolean[] merged, long timestamp, int temp) {
|
PlotArea area, boolean[] merged, long timestamp, int temp,
|
||||||
|
@NotNull final EventDispatcher eventDispatcher, @NotNull final PlotListener plotListener) {
|
||||||
super(id, owner, trusted, members, denied, alias, position, flags, area, merged, timestamp,
|
super(id, owner, trusted, members, denied, alias, position, flags, area, merged, timestamp,
|
||||||
temp);
|
temp, eventDispatcher, plotListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String getWorldName() {
|
@Override public String getWorldName() {
|
||||||
|
@ -31,6 +31,7 @@ import com.plotsquared.core.configuration.ConfigurationSection;
|
|||||||
import com.plotsquared.core.configuration.ConfigurationUtil;
|
import com.plotsquared.core.configuration.ConfigurationUtil;
|
||||||
import com.plotsquared.core.generator.GridPlotWorld;
|
import com.plotsquared.core.generator.GridPlotWorld;
|
||||||
import com.plotsquared.core.generator.SingleWorldGenerator;
|
import com.plotsquared.core.generator.SingleWorldGenerator;
|
||||||
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.location.PlotLoc;
|
import com.plotsquared.core.location.PlotLoc;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
@ -41,6 +42,7 @@ import com.plotsquared.core.plot.PlotSettings;
|
|||||||
import com.plotsquared.core.plot.flag.FlagContainer;
|
import com.plotsquared.core.plot.flag.FlagContainer;
|
||||||
import com.plotsquared.core.setup.PlotAreaBuilder;
|
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||||
import com.plotsquared.core.setup.SettingsNodesWrapper;
|
import com.plotsquared.core.setup.SettingsNodesWrapper;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.SetupUtils;
|
import com.plotsquared.core.util.SetupUtils;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
@ -56,8 +58,13 @@ public class SinglePlotArea extends GridPlotWorld {
|
|||||||
|
|
||||||
public boolean VOID = false;
|
public boolean VOID = false;
|
||||||
|
|
||||||
public SinglePlotArea(@NotNull final PlotAreaManager plotAreaManager) {
|
private final EventDispatcher eventDispatcher;
|
||||||
super("*", null, new SingleWorldGenerator(plotAreaManager), null, null);
|
private final PlotListener plotListener;
|
||||||
|
|
||||||
|
public SinglePlotArea(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher, @NotNull final PlotListener plotListener) {
|
||||||
|
super("*", null, new SingleWorldGenerator(plotAreaManager), null, null, eventDispatcher, plotListener);
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
this.plotListener = plotListener;
|
||||||
this.setAllowSigns(false);
|
this.setAllowSigns(false);
|
||||||
this.setDefaultHome(new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE));
|
this.setDefaultHome(new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE));
|
||||||
}
|
}
|
||||||
@ -200,7 +207,7 @@ public class SinglePlotArea extends GridPlotWorld {
|
|||||||
final FlagContainer oldContainer = p.getFlagContainer();
|
final FlagContainer oldContainer = p.getFlagContainer();
|
||||||
p = new SinglePlot(p.getId(), p.getOwnerAbs(), p.getTrusted(), p.getMembers(),
|
p = new SinglePlot(p.getId(), p.getOwnerAbs(), p.getTrusted(), p.getMembers(),
|
||||||
p.getDenied(), s.getAlias(), s.getPosition(), null, this, s.getMerged(),
|
p.getDenied(), s.getAlias(), s.getPosition(), null, this, s.getMerged(),
|
||||||
p.getTimestamp(), p.temp);
|
p.getTimestamp(), p.temp, this.eventDispatcher, this.plotListener);
|
||||||
p.getFlagContainer().addAll(oldContainer);
|
p.getFlagContainer().addAll(oldContainer);
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
@ -209,7 +216,7 @@ public class SinglePlotArea extends GridPlotWorld {
|
|||||||
@Nullable public Plot getPlotAbs(@NotNull final PlotId id) {
|
@Nullable public Plot getPlotAbs(@NotNull final PlotId id) {
|
||||||
Plot plot = getOwnedPlotAbs(id);
|
Plot plot = getOwnedPlotAbs(id);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return new SinglePlot(this, id);
|
return new SinglePlot(this, id, this.eventDispatcher, this.plotListener);
|
||||||
}
|
}
|
||||||
return plot;
|
return plot;
|
||||||
}
|
}
|
||||||
@ -218,7 +225,7 @@ public class SinglePlotArea extends GridPlotWorld {
|
|||||||
// TODO
|
// TODO
|
||||||
Plot plot = getOwnedPlotAbs(id);
|
Plot plot = getOwnedPlotAbs(id);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return new SinglePlot(this, id);
|
return new SinglePlot(this, id, this.eventDispatcher, this.plotListener);
|
||||||
}
|
}
|
||||||
return plot.getBasePlot(false);
|
return plot.getBasePlot(false);
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,10 @@ package com.plotsquared.core.plot.world;
|
|||||||
|
|
||||||
import com.plotsquared.core.collection.ArrayUtil;
|
import com.plotsquared.core.collection.ArrayUtil;
|
||||||
import com.plotsquared.core.generator.SingleWorldGenerator;
|
import com.plotsquared.core.generator.SingleWorldGenerator;
|
||||||
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.SetupUtils;
|
import com.plotsquared.core.util.SetupUtils;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -40,8 +42,9 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager {
|
|||||||
private SinglePlotArea area;
|
private SinglePlotArea area;
|
||||||
private PlotArea[] all;
|
private PlotArea[] all;
|
||||||
|
|
||||||
public SinglePlotAreaManager() {
|
public SinglePlotAreaManager(@NotNull final EventDispatcher eventDispatcher, @NotNull final
|
||||||
this.area = new SinglePlotArea(this);
|
PlotListener plotListener) {
|
||||||
|
this.area = new SinglePlotArea(this, eventDispatcher, plotListener);
|
||||||
this.array = new SinglePlotArea[] {area};
|
this.array = new SinglePlotArea[] {area};
|
||||||
this.all = new PlotArea[] {area};
|
this.all = new PlotArea[] {area};
|
||||||
SetupUtils.generators.put("PlotSquared:single",
|
SetupUtils.generators.put("PlotSquared:single",
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.util.task;
|
package com.plotsquared.core.util.task;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.command.Auto;
|
import com.plotsquared.core.command.Auto;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.events.PlotMergeEvent;
|
import com.plotsquared.core.events.PlotMergeEvent;
|
||||||
@ -34,6 +33,7 @@ import com.plotsquared.core.location.Direction;
|
|||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import static com.plotsquared.core.util.MainUtil.sendMessage;
|
import static com.plotsquared.core.util.MainUtil.sendMessage;
|
||||||
@ -45,6 +45,7 @@ public final class AutoClaimFinishTask extends RunnableVal<Object> {
|
|||||||
private final Plot plot;
|
private final Plot plot;
|
||||||
private final PlotArea area;
|
private final PlotArea area;
|
||||||
private final String schematic;
|
private final String schematic;
|
||||||
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
@Override public void run(Object value) {
|
@Override public void run(Object value) {
|
||||||
player.deleteMeta(Auto.class.getName());
|
player.deleteMeta(Auto.class.getName());
|
||||||
@ -54,8 +55,7 @@ public final class AutoClaimFinishTask extends RunnableVal<Object> {
|
|||||||
}
|
}
|
||||||
plot.claim(player, true, schematic, false);
|
plot.claim(player, true, schematic, false);
|
||||||
if (area.isAutoMerge()) {
|
if (area.isAutoMerge()) {
|
||||||
PlotMergeEvent event = PlotSquared.get().getEventDispatcher()
|
PlotMergeEvent event = this.eventDispatcher.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player);
|
||||||
.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player);
|
|
||||||
if (event.getEventResult() == Result.DENY) {
|
if (event.getEventResult() == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Auto merge");
|
sendMessage(player, Captions.EVENT_DENIED, "Auto merge");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user