mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 11:45:19 +01:00
feat: Add -Post
events firing after operational plot events (#3334)
* Create Post* events * Address license violations * address review * standardize post event calls in EventDispatcher * Add package-info.java * Add @since-tag to Post* events * fix licenser issue Co-authored-by: Alex <mc.cache@web.de>
This commit is contained in:
parent
688056352b
commit
b9a130ab00
@ -758,6 +758,9 @@ public class PlotSquared {
|
|||||||
if (this_max < last_max) {
|
if (this_max < last_max) {
|
||||||
plot.getArea().setMeta("lastPlot", plot.getId());
|
plot.getArea().setMeta("lastPlot", plot.getId());
|
||||||
}
|
}
|
||||||
|
if (callEvent) {
|
||||||
|
eventDispatcher.callPostDelete(plot);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -344,6 +344,7 @@ public class Auto extends SubCommand {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
plot.claim(player, !plotIterator.hasNext(), null, true, true);
|
plot.claim(player, !plotIterator.hasNext(), null, true, true);
|
||||||
|
eventDispatcher.callPostAuto(player, plot);
|
||||||
}
|
}
|
||||||
final PlotAutoMergeEvent mergeEvent = this.eventDispatcher.callAutoMerge(
|
final PlotAutoMergeEvent mergeEvent = this.eventDispatcher.callAutoMerge(
|
||||||
plots.get(0),
|
plots.get(0),
|
||||||
|
@ -208,13 +208,15 @@ public class Claim extends SubCommand {
|
|||||||
Template.of("value", "Auto merge on claim")
|
Template.of("value", "Auto merge on claim")
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
plot.getPlotModificationManager().autoMerge(
|
if (plot.getPlotModificationManager().autoMerge(
|
||||||
mergeEvent.getDir(),
|
mergeEvent.getDir(),
|
||||||
mergeEvent.getMax(),
|
mergeEvent.getMax(),
|
||||||
player.getUUID(),
|
player.getUUID(),
|
||||||
player,
|
player,
|
||||||
true
|
true
|
||||||
);
|
)) {
|
||||||
|
eventDispatcher.callPostMerge(player, plot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -130,6 +130,7 @@ public class Delete extends SubCommand {
|
|||||||
Template.of("amount", String.valueOf(System.currentTimeMillis() - start)),
|
Template.of("amount", String.valueOf(System.currentTimeMillis() - start)),
|
||||||
Template.of("plot", plot.getId().toString())
|
Template.of("plot", plot.getId().toString())
|
||||||
);
|
);
|
||||||
|
eventDispatcher.callPostDelete(plot);
|
||||||
});
|
});
|
||||||
if (result) {
|
if (result) {
|
||||||
plot.addRunning();
|
plot.addRunning();
|
||||||
|
@ -189,6 +189,7 @@ public class Merge extends SubCommand {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
player.sendMessage(TranslatableCaption.of("merge.success_merge"));
|
player.sendMessage(TranslatableCaption.of("merge.success_merge"));
|
||||||
|
eventDispatcher.callPostMerge(player, plot);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
player.sendMessage(TranslatableCaption.of("merge.no_available_automerge"));
|
player.sendMessage(TranslatableCaption.of("merge.no_available_automerge"));
|
||||||
@ -225,6 +226,7 @@ public class Merge extends SubCommand {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
player.sendMessage(TranslatableCaption.of("merge.success_merge"));
|
player.sendMessage(TranslatableCaption.of("merge.success_merge"));
|
||||||
|
eventDispatcher.callPostMerge(player, plot);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Plot adjacent = plot.getRelative(direction);
|
Plot adjacent = plot.getRelative(direction);
|
||||||
@ -272,6 +274,7 @@ public class Merge extends SubCommand {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
player.sendMessage(TranslatableCaption.of("merge.success_merge"));
|
player.sendMessage(TranslatableCaption.of("merge.success_merge"));
|
||||||
|
eventDispatcher.callPostMerge(player, plot);
|
||||||
};
|
};
|
||||||
if (!force && hasConfirmation(player)) {
|
if (!force && hasConfirmation(player)) {
|
||||||
CmdConfirm.addPending(accepter, MINI_MESSAGE.serialize(MINI_MESSAGE
|
CmdConfirm.addPending(accepter, MINI_MESSAGE.serialize(MINI_MESSAGE
|
||||||
|
@ -44,6 +44,7 @@ import com.plotsquared.core.util.TabCompletions;
|
|||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.Template;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -76,6 +77,7 @@ public class Owner extends SetCommand {
|
|||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Nullable final UUID oldOwner = plot.getOwnerAbs();
|
||||||
Set<Plot> plots = plot.getConnectedPlots();
|
Set<Plot> plots = plot.getConnectedPlots();
|
||||||
|
|
||||||
final Consumer<UUID> uuidConsumer = uuid -> {
|
final Consumer<UUID> uuidConsumer = uuid -> {
|
||||||
@ -124,12 +126,15 @@ public class Owner extends SetCommand {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plot.getPlotModificationManager().unlinkPlot(unlinkEvent.isCreateRoad(), unlinkEvent.isCreateRoad());
|
if (plot.getPlotModificationManager().unlinkPlot(unlinkEvent.isCreateRoad(), unlinkEvent.isCreateRoad())) {
|
||||||
|
eventDispatcher.callPostUnlink(plot, PlotUnlinkEvent.REASON.NEW_OWNER);
|
||||||
|
}
|
||||||
Set<Plot> connected = plot.getConnectedPlots();
|
Set<Plot> connected = plot.getConnectedPlots();
|
||||||
for (Plot current : connected) {
|
for (Plot current : connected) {
|
||||||
current.unclaim();
|
current.unclaim();
|
||||||
current.getPlotModificationManager().removeSign();
|
current.getPlotModificationManager().removeSign();
|
||||||
}
|
}
|
||||||
|
eventDispatcher.callPostOwnerChange(player, plot, oldOwner);
|
||||||
player.sendMessage(TranslatableCaption.of("owner.set_owner"));
|
player.sendMessage(TranslatableCaption.of("owner.set_owner"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -178,6 +183,7 @@ public class Owner extends SetCommand {
|
|||||||
}
|
}
|
||||||
plot.getPlotModificationManager().setSign(finalName);
|
plot.getPlotModificationManager().setSign(finalName);
|
||||||
player.sendMessage(TranslatableCaption.of("owner.set_owner"));
|
player.sendMessage(TranslatableCaption.of("owner.set_owner"));
|
||||||
|
eventDispatcher.callPostOwnerChange(player, plot, oldOwner);
|
||||||
if (other != null) {
|
if (other != null) {
|
||||||
other.sendMessage(
|
other.sendMessage(
|
||||||
TranslatableCaption.of("owner.now_owner"),
|
TranslatableCaption.of("owner.now_owner"),
|
||||||
|
@ -109,6 +109,7 @@ public class Unlink extends SubCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.sendMessage(TranslatableCaption.of("merge.unlink_success"));
|
player.sendMessage(TranslatableCaption.of("merge.unlink_success"));
|
||||||
|
eventDispatcher.callPostUnlink(plot, PlotUnlinkEvent.REASON.PLAYER_COMMAND);
|
||||||
};
|
};
|
||||||
if (hasConfirmation(player)) {
|
if (hasConfirmation(player)) {
|
||||||
CmdConfirm.addPending(player, "/plot unlink " + plot.getId(), runnable);
|
CmdConfirm.addPending(player, "/plot unlink " + plot.getId(), runnable);
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2021 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.plotsquared.core.events.post;
|
||||||
|
|
||||||
|
import com.plotsquared.core.events.PlotPlayerEvent;
|
||||||
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after a plot was chosen for a player by {@code /plot auto}
|
||||||
|
* <br>
|
||||||
|
* Called after {@link com.plotsquared.core.events.PlayerAutoPlotEvent} and only, if no listener cancelled the action.
|
||||||
|
*
|
||||||
|
* @since 6.2.0
|
||||||
|
*/
|
||||||
|
public class PostPlayerAutoPlotEvent extends PlotPlayerEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate a new PlayerAutoPlotPostEvent.
|
||||||
|
*
|
||||||
|
* @param plotPlayer The player who claims a new plot by {@code /plot auto}.
|
||||||
|
* @param plot The plot that is assigned to the player.
|
||||||
|
*/
|
||||||
|
public PostPlayerAutoPlotEvent(final PlotPlayer<?> plotPlayer, final Plot plot) {
|
||||||
|
super(plotPlayer, plot);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2021 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.plotsquared.core.events.post;
|
||||||
|
|
||||||
|
import com.plotsquared.core.events.PlotPlayerEvent;
|
||||||
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after the owner of a plot was updated.
|
||||||
|
*
|
||||||
|
* @since 6.2.0
|
||||||
|
*/
|
||||||
|
public class PostPlotChangeOwnerEvent extends PlotPlayerEvent {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private final UUID oldOwner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate a new PlotChangedOwnerEvent.
|
||||||
|
*
|
||||||
|
* @param initiator The player who executed the owner change.
|
||||||
|
* @param plot The plot which owner was changed.
|
||||||
|
* @param oldOwner The previous owner - if present, otherwise {@code null}.
|
||||||
|
*/
|
||||||
|
public PostPlotChangeOwnerEvent(final PlotPlayer<?> initiator, final Plot plot, @Nullable UUID oldOwner) {
|
||||||
|
super(initiator, plot);
|
||||||
|
this.oldOwner = oldOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the old owner of the plot - if present, otherwise {@code null}.
|
||||||
|
*/
|
||||||
|
public @Nullable UUID getOldOwner() {
|
||||||
|
return oldOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@code true} if the plot had an owner, {@code false} otherwise.
|
||||||
|
* @see #getOldOwner()
|
||||||
|
*/
|
||||||
|
public boolean hasOldOwner() {
|
||||||
|
return getOldOwner() != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@code true} if the plot now has an owner, {@code false} otherwise.
|
||||||
|
* @see Plot#hasOwner()
|
||||||
|
*/
|
||||||
|
public boolean hasNewOwner() {
|
||||||
|
return getPlot().hasOwner();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2021 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.plotsquared.core.events.post;
|
||||||
|
|
||||||
|
import com.plotsquared.core.events.PlotEvent;
|
||||||
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after a {@link Plot} was deleted.
|
||||||
|
*
|
||||||
|
* @since 6.2.0
|
||||||
|
*/
|
||||||
|
public class PostPlotDeleteEvent extends PlotEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate a new PlotDeleteEvent.
|
||||||
|
*
|
||||||
|
* @param plot The plot which was deleted.
|
||||||
|
*/
|
||||||
|
public PostPlotDeleteEvent(final Plot plot) {
|
||||||
|
super(plot);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2021 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.plotsquared.core.events.post;
|
||||||
|
|
||||||
|
import com.plotsquared.core.events.PlotPlayerEvent;
|
||||||
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after multiple plots were merged with another.
|
||||||
|
*
|
||||||
|
* @since 6.2.0
|
||||||
|
*/
|
||||||
|
public class PostPlotMergeEvent extends PlotPlayerEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate a new PlotMergedEvent.
|
||||||
|
*
|
||||||
|
* @param plotPlayer The {@link PlotPlayer} that initiated the merge.
|
||||||
|
* @param plot The final merged plot.
|
||||||
|
*/
|
||||||
|
public PostPlotMergeEvent(final PlotPlayer<?> plotPlayer, final Plot plot) {
|
||||||
|
super(plotPlayer, plot);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2021 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.plotsquared.core.events.post;
|
||||||
|
|
||||||
|
import com.plotsquared.core.events.PlotEvent;
|
||||||
|
import com.plotsquared.core.events.PlotUnlinkEvent;
|
||||||
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when several plots were unlinked.
|
||||||
|
*
|
||||||
|
* @since 6.2.0
|
||||||
|
*/
|
||||||
|
public class PostPlotUnlinkEvent extends PlotEvent {
|
||||||
|
|
||||||
|
private final PlotUnlinkEvent.REASON reason;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate a new PlotUnlinkedEvent.
|
||||||
|
*
|
||||||
|
* @param plot The unlinked plot.
|
||||||
|
* @param reason The reason for the unlink.
|
||||||
|
*/
|
||||||
|
public PostPlotUnlinkEvent(final Plot plot, PlotUnlinkEvent.REASON reason) {
|
||||||
|
super(plot);
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The original reason provided by {@link PlotUnlinkEvent}.
|
||||||
|
*
|
||||||
|
* @return The reason for the unlink.
|
||||||
|
*/
|
||||||
|
public PlotUnlinkEvent.REASON getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2021 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Contains events which are fired after specific actions are completed.
|
||||||
|
* <br>
|
||||||
|
* E.g. {@link com.plotsquared.core.events.PlotDeleteEvent} is called <b>before</b> a plot is actually deleted and useful for
|
||||||
|
* cancelling the action itself. {@link com.plotsquared.core.events.post.PostPlotDeleteEvent} will be called after the plot was
|
||||||
|
* deleted.
|
||||||
|
*/
|
||||||
|
package com.plotsquared.core.events.post;
|
@ -229,8 +229,8 @@ public final class PlotModificationManager {
|
|||||||
!isDelete,
|
!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 && this.unlinkPlot(event.isCreateRoad(), event.isCreateSign())) {
|
||||||
this.unlinkPlot(event.isCreateRoad(), event.isCreateSign());
|
PlotSquared.get().getEventDispatcher().callPostUnlink(plot, event.getReason());
|
||||||
}
|
}
|
||||||
final PlotManager manager = this.plot.getArea().getPlotManager();
|
final PlotManager manager = this.plot.getArea().getPlotManager();
|
||||||
Runnable run = new Runnable() {
|
Runnable run = new Runnable() {
|
||||||
@ -502,7 +502,9 @@ public final class PlotModificationManager {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plot.getPlotModificationManager().autoMerge(event.getDir(), event.getMax(), uuid, player, true);
|
if (plot.getPlotModificationManager().autoMerge(event.getDir(), event.getMax(), uuid, player, true)) {
|
||||||
|
PlotSquared.get().getEventDispatcher().callPostMerge(player, plot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
@ -426,8 +426,11 @@ public class ExpireManager {
|
|||||||
.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 && plot.getPlotModificationManager().unlinkPlot(
|
||||||
plot.getPlotModificationManager().unlinkPlot(event.isCreateRoad(), event.isCreateSign());
|
event.isCreateRoad(),
|
||||||
|
event.isCreateSign()
|
||||||
|
)) {
|
||||||
|
this.eventDispatcher.callPostUnlink(plot, PlotUnlinkEvent.REASON.EXPIRE_DELETE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (UUID helper : plot.getTrusted()) {
|
for (UUID helper : plot.getTrusted()) {
|
||||||
|
@ -51,6 +51,11 @@ import com.plotsquared.core.events.PlotMergeEvent;
|
|||||||
import com.plotsquared.core.events.PlotRateEvent;
|
import com.plotsquared.core.events.PlotRateEvent;
|
||||||
import com.plotsquared.core.events.PlotUnlinkEvent;
|
import com.plotsquared.core.events.PlotUnlinkEvent;
|
||||||
import com.plotsquared.core.events.TeleportCause;
|
import com.plotsquared.core.events.TeleportCause;
|
||||||
|
import com.plotsquared.core.events.post.PostPlayerAutoPlotEvent;
|
||||||
|
import com.plotsquared.core.events.post.PostPlotChangeOwnerEvent;
|
||||||
|
import com.plotsquared.core.events.post.PostPlotDeleteEvent;
|
||||||
|
import com.plotsquared.core.events.post.PostPlotMergeEvent;
|
||||||
|
import com.plotsquared.core.events.post.PostPlotUnlinkEvent;
|
||||||
import com.plotsquared.core.listener.PlayerBlockEventType;
|
import com.plotsquared.core.listener.PlayerBlockEventType;
|
||||||
import com.plotsquared.core.location.Direction;
|
import com.plotsquared.core.location.Direction;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
@ -135,6 +140,12 @@ public class EventDispatcher {
|
|||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PostPlayerAutoPlotEvent callPostAuto(PlotPlayer<?> player, Plot plot) {
|
||||||
|
PostPlayerAutoPlotEvent event = new PostPlayerAutoPlotEvent(player, plot);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public PlayerAutoPlotsChosenEvent callAutoPlotsChosen(
|
public PlayerAutoPlotsChosenEvent callAutoPlotsChosen(
|
||||||
PlotPlayer<?> player, List<Plot> plots
|
PlotPlayer<?> player, List<Plot> plots
|
||||||
) {
|
) {
|
||||||
@ -174,6 +185,12 @@ public class EventDispatcher {
|
|||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PostPlotDeleteEvent callPostDelete(Plot plot) {
|
||||||
|
PostPlotDeleteEvent event = new PostPlotDeleteEvent(plot);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public PlotFlagAddEvent callFlagAdd(PlotFlag<?, ?> flag, Plot plot) {
|
public PlotFlagAddEvent callFlagAdd(PlotFlag<?, ?> flag, Plot plot) {
|
||||||
PlotFlagAddEvent event = new PlotFlagAddEvent(flag, plot);
|
PlotFlagAddEvent event = new PlotFlagAddEvent(flag, plot);
|
||||||
callEvent(event);
|
callEvent(event);
|
||||||
@ -192,6 +209,12 @@ public class EventDispatcher {
|
|||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PostPlotMergeEvent callPostMerge(PlotPlayer<?> player, Plot plot) {
|
||||||
|
PostPlotMergeEvent event = new PostPlotMergeEvent(player, plot);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public PlotAutoMergeEvent callAutoMerge(Plot plot, List<PlotId> plots) {
|
public PlotAutoMergeEvent callAutoMerge(Plot plot, List<PlotId> plots) {
|
||||||
PlotAutoMergeEvent event = new PlotAutoMergeEvent(plot.getWorldName(), plot, plots);
|
PlotAutoMergeEvent event = new PlotAutoMergeEvent(plot.getWorldName(), plot, plots);
|
||||||
callEvent(event);
|
callEvent(event);
|
||||||
@ -207,6 +230,12 @@ public class EventDispatcher {
|
|||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PostPlotUnlinkEvent callPostUnlink(Plot plot, PlotUnlinkEvent.REASON reason) {
|
||||||
|
PostPlotUnlinkEvent event = new PostPlotUnlinkEvent(plot, reason);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public PlayerEnterPlotEvent callEntry(PlotPlayer<?> player, Plot plot) {
|
public PlayerEnterPlotEvent callEntry(PlotPlayer<?> player, Plot plot) {
|
||||||
PlayerEnterPlotEvent event = new PlayerEnterPlotEvent(player, plot);
|
PlayerEnterPlotEvent event = new PlayerEnterPlotEvent(player, plot);
|
||||||
callEvent(event);
|
callEvent(event);
|
||||||
@ -256,6 +285,12 @@ public class EventDispatcher {
|
|||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PostPlotChangeOwnerEvent callPostOwnerChange(PlotPlayer<?> player, Plot plot, @Nullable UUID oldOwner) {
|
||||||
|
PostPlotChangeOwnerEvent event = new PostPlotChangeOwnerEvent(player, plot, oldOwner);
|
||||||
|
callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public PlotRateEvent callRating(PlotPlayer<?> player, Plot plot, Rating rating) {
|
public PlotRateEvent callRating(PlotPlayer<?> player, Plot plot, Rating rating) {
|
||||||
PlotRateEvent event = new PlotRateEvent(player, rating, plot);
|
PlotRateEvent event = new PlotRateEvent(player, rating, plot);
|
||||||
eventBus.post(event);
|
eventBus.post(event);
|
||||||
|
@ -69,6 +69,7 @@ public final class AutoClaimFinishTask implements Callable<Boolean> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
plot.claim(player, true, schematic, false, true);
|
plot.claim(player, true, schematic, false, true);
|
||||||
|
eventDispatcher.callPostAuto(player, plot);
|
||||||
if (area.isAutoMerge()) {
|
if (area.isAutoMerge()) {
|
||||||
PlotMergeEvent event = this.eventDispatcher.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player);
|
PlotMergeEvent event = this.eventDispatcher.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player);
|
||||||
if (event.getEventResult() == Result.DENY) {
|
if (event.getEventResult() == Result.DENY) {
|
||||||
@ -77,7 +78,9 @@ public final class AutoClaimFinishTask implements Callable<Boolean> {
|
|||||||
Templates.of("value", "Auto Merge")
|
Templates.of("value", "Auto Merge")
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
plot.getPlotModificationManager().autoMerge(event.getDir(), event.getMax(), player.getUUID(), player, true);
|
if (plot.getPlotModificationManager().autoMerge(event.getDir(), event.getMax(), player.getUUID(), player, true)) {
|
||||||
|
eventDispatcher.callPostMerge(player, plot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user