001/* 002 * PlotSquared, a land and world management plugin for Minecraft. 003 * Copyright (C) IntellectualSites <https://intellectualsites.com> 004 * Copyright (C) IntellectualSites team and contributors 005 * 006 * This program is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * This program is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with this program. If not, see <https://www.gnu.org/licenses/>. 018 */ 019package com.plotsquared.core.events; 020 021import com.sk89q.worldedit.entity.Entity; 022import org.checkerframework.checker.nullness.qual.NonNull; 023 024/** 025 * @since 6.11.1 026 */ 027public abstract class EntityEvent { 028 029 private final Entity entity; 030 031 private String name; 032 033 /** 034 * @since 6.11.0 035 */ 036 public EntityEvent(Entity entity) { 037 this.entity = entity; 038 } 039 040 /** 041 * Obtain the entity involved in the event 042 * 043 * @return Entity 044 * @since 6.11.0 045 */ 046 public Entity getEntity() { 047 return this.entity; 048 } 049 050 /** 051 * Obtain the event's class name 052 * 053 * @return the event class name 054 * @since 6.11.0 055 */ 056 @NonNull public String getEventName() { 057 if (this.name == null) { 058 this.name = this.getClass().getSimpleName(); 059 } 060 return this.name; 061 } 062 063}