Refactor events
This commit is contained in:
parent
d3dc82cf7e
commit
226aaa2ba2
|
|
@ -7,25 +7,20 @@ import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlayerCreateShopEvent extends Event implements Cancellable {
|
public class PlayerCreateShopEvent extends ShopEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final Shop shop;
|
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
public PlayerCreateShopEvent(Player p, Shop s) {
|
public PlayerCreateShopEvent(Player player, Shop shop) {
|
||||||
player = p;
|
super(shop);
|
||||||
shop = s;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Shop getShop() {
|
|
||||||
return shop;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
|
|
|
||||||
|
|
@ -7,26 +7,21 @@ import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlayerDestroyShopEvent extends Event implements Cancellable {
|
public class PlayerDestroyShopEvent extends ShopEvent {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final Shop shop;
|
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
public PlayerDestroyShopEvent(Player p, Shop s) {
|
public PlayerDestroyShopEvent(Player player, Shop shop) {
|
||||||
player = p;
|
super(shop);
|
||||||
shop = s;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Shop getShop() {
|
|
||||||
return shop;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
|
|
|
||||||
|
|
@ -7,26 +7,21 @@ import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlayerExchangeShopEvent extends Event implements Cancellable {
|
public class PlayerExchangeShopEvent extends ShopEvent {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final Shop shop;
|
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
public PlayerExchangeShopEvent(Player p, Shop s) {
|
public PlayerExchangeShopEvent(Player player, Shop shop) {
|
||||||
player = p;
|
super(shop);
|
||||||
shop = s;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Shop getShop() {
|
|
||||||
return shop;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
|
|
|
||||||
|
|
@ -7,26 +7,21 @@ import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlayerInitializeShopEvent extends Event implements Cancellable {
|
public class PlayerInitializeShopEvent extends ShopEvent {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final Shop shop;
|
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
public PlayerInitializeShopEvent(Player p, Shop s) {
|
public PlayerInitializeShopEvent(Player player, Shop shop) {
|
||||||
player = p;
|
super(shop);
|
||||||
shop = s;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Shop getShop() {
|
|
||||||
return shop;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.alttd.playershops.api.events;
|
||||||
|
|
||||||
|
import com.alttd.playershops.api.Shop;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
|
||||||
|
public abstract class ShopEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
|
private boolean cancelled;
|
||||||
|
private final Shop shop;
|
||||||
|
|
||||||
|
public ShopEvent(Shop shop) {
|
||||||
|
this.shop = shop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Shop getShop() {
|
||||||
|
return shop;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean b) {
|
||||||
|
this.cancelled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user