Merge branch 'v6' into v7

This commit is contained in:
Alexander Brandes
2023-02-10 16:44:57 +01:00
7 changed files with 166 additions and 13 deletions

View File

@ -0,0 +1,63 @@
/*
* PlotSquared, a land and world management plugin for Minecraft.
* Copyright (C) IntellectualSites <https://intellectualsites.com>
* Copyright (C) IntellectualSites team and contributors
*
* 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;
import com.sk89q.worldedit.entity.Entity;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* @since TODO
*/
public abstract class EntityEvent {
private final Entity entity;
private String name;
/**
* @since TODO
*/
public EntityEvent(Entity entity) {
this.entity = entity;
}
/**
* Obtain the entity involved in the event
*
* @return Entity
* @since TODO
*/
public Entity getEntity() {
return this.entity;
}
/**
* Obtain the event's class name
*
* @return the event class name
* @since TODO
*/
@NonNull public String getEventName() {
if (this.name == null) {
this.name = this.getClass().getSimpleName();
}
return this.name;
}
}

View File

@ -0,0 +1,50 @@
/*
* PlotSquared, a land and world management plugin for Minecraft.
* Copyright (C) IntellectualSites <https://intellectualsites.com>
* Copyright (C) IntellectualSites team and contributors
*
* 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;
import com.sk89q.worldedit.entity.Entity;
/**
* @since TODO
*/
public class RemoveRoadEntityEvent extends EntityEvent implements CancellablePlotEvent {
private Result eventResult;
/**
* RemoveRoadEntityEvent: Called when an entity on road is removed.
*
* @param entity The entity to remove
* @since TODO
*/
public RemoveRoadEntityEvent(Entity entity) {
super(entity);
}
@Override
public Result getEventResult() {
return this.eventResult;
}
@Override
public void setEventResult(Result eventResult) {
this.eventResult = eventResult;
}
}

View File

@ -45,6 +45,7 @@ import com.plotsquared.core.events.PlotFlagRemoveEvent;
import com.plotsquared.core.events.PlotMergeEvent;
import com.plotsquared.core.events.PlotRateEvent;
import com.plotsquared.core.events.PlotUnlinkEvent;
import com.plotsquared.core.events.RemoveRoadEntityEvent;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.events.post.PostPlayerAutoPlotEvent;
import com.plotsquared.core.events.post.PostPlotChangeOwnerEvent;
@ -71,6 +72,7 @@ import com.plotsquared.core.plot.flag.types.BlockTypeWrapper;
import com.plotsquared.core.plot.world.SinglePlotArea;
import com.plotsquared.core.util.task.TaskManager;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
@ -298,6 +300,12 @@ public class EventDispatcher {
return event;
}
public RemoveRoadEntityEvent callRemoveRoadEntity(Entity entity) {
RemoveRoadEntityEvent event = new RemoveRoadEntityEvent(entity);
eventBus.post(event);
return event;
}
public void doJoinTask(final PlotPlayer<?> player) {
if (player == null) {
return; //possible future warning message to figure out where we are retrieving null