Search in sources :

Example 6 with PlotFlagRemoveEvent

use of com.plotsquared.core.events.PlotFlagRemoveEvent in project PlotSquared by IntellectualSites.

the class Continue method onCommand.

@Override
public boolean onCommand(PlotPlayer<?> player, String[] args) {
    Plot plot = player.getCurrentPlot();
    if ((plot == null) || !plot.hasOwner()) {
        player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
        return false;
    }
    if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_CONTINUE)) {
        player.sendMessage(TranslatableCaption.of("permission.no_permission"), Template.of("node", TranslatableCaption.of("permission.no_plot_perms").getComponent(player)));
        return false;
    }
    if (!DoneFlag.isDone(plot)) {
        player.sendMessage(TranslatableCaption.of("done.done_not_done"));
        return false;
    }
    int size = plot.getConnectedPlots().size();
    if (Settings.Done.COUNTS_TOWARDS_LIMIT && (player.getAllowedPlots() < player.getPlotCount() + size)) {
        player.sendMessage(TranslatableCaption.of("permission.cant_claim_more_plots"), Template.of("amount", String.valueOf(player.getAllowedPlots())));
        return false;
    }
    if (plot.getRunning() > 0) {
        player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
        return false;
    }
    PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(DoneFlag.class);
    PlotFlagRemoveEvent event = this.eventDispatcher.callFlagRemove(plotFlag, plot);
    if (event.getEventResult() == Result.DENY) {
        player.sendMessage(TranslatableCaption.of("events.event_denied"), Template.of("value", "Done flag removal"));
        return true;
    }
    plot.removeFlag(event.getFlag());
    player.sendMessage(TranslatableCaption.of("done.done_removed"));
    return true;
}
Also used : Plot(com.plotsquared.core.plot.Plot) PlotFlagRemoveEvent(com.plotsquared.core.events.PlotFlagRemoveEvent)

Example 7 with PlotFlagRemoveEvent

use of com.plotsquared.core.events.PlotFlagRemoveEvent in project PlotSquared by IntellectualSites.

the class EventDispatcher method callFlagRemove.

public PlotFlagRemoveEvent callFlagRemove(PlotFlag<?, ?> flag, Plot plot) {
    PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(flag, plot);
    callEvent(event);
    return event;
}
Also used : PlotFlagRemoveEvent(com.plotsquared.core.events.PlotFlagRemoveEvent)

Aggregations

PlotFlagRemoveEvent (com.plotsquared.core.events.PlotFlagRemoveEvent)7 Plot (com.plotsquared.core.plot.Plot)5 PlotFlag (com.plotsquared.core.plot.flag.PlotFlag)3 Settings (com.plotsquared.core.configuration.Settings)2 TranslatableCaption (com.plotsquared.core.configuration.caption.TranslatableCaption)2 PlotFlagAddEvent (com.plotsquared.core.events.PlotFlagAddEvent)2 Result (com.plotsquared.core.events.Result)2 Location (com.plotsquared.core.location.Location)2 PlotPlayer (com.plotsquared.core.player.PlotPlayer)2 PlotArea (com.plotsquared.core.plot.PlotArea)2 MusicFlag (com.plotsquared.core.plot.flag.implementations.MusicFlag)2 ItemType (com.sk89q.worldedit.world.item.ItemType)2 Inject (com.google.inject.Inject)1 PlotSquared (com.plotsquared.core.PlotSquared)1 BackupManager (com.plotsquared.core.backup.BackupManager)1 Caption (com.plotsquared.core.configuration.caption.Caption)1 StaticCaption (com.plotsquared.core.configuration.caption.StaticCaption)1 DBFunc (com.plotsquared.core.database.DBFunc)1 TeleportCause (com.plotsquared.core.events.TeleportCause)1 Permission (com.plotsquared.core.permissions.Permission)1