Made the classes (ForceRedeem, VoucherReceive, VoucherRedeem) follow the contract provided by Event properly

This commit is contained in:
theone1000 2019-09-16 20:43:21 -06:00
parent f27a76a583
commit c1b57454b9
4 changed files with 119 additions and 108 deletions

View File

@ -8,48 +8,52 @@ import org.bukkit.event.HandlerList;
public class ForceRedeemEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private static final HandlerList handlers = new HandlerList();
private final Player player;
private final String voucher;
private final int amount;
private final CommandSender sender;
private boolean cancelled;
private final Player player;
private final String voucher;
private final int amount;
private final CommandSender sender;
private boolean cancelled;
public ForceRedeemEvent(Player player, String voucher, int amount, CommandSender sender) {
this.player = player;
this.voucher = voucher;
this.amount = amount;
this.sender = sender;
this.cancelled = false;
}
public ForceRedeemEvent(Player player, String voucher, int amount, CommandSender sender) {
this.player = player;
this.voucher = voucher;
this.amount = amount;
this.sender = sender;
this.cancelled = false;
}
public Player getPlayer() {
return player;
}
public Player getPlayer() {
return player;
}
public String getVoucher() {
return voucher;
}
public String getVoucher() {
return voucher;
}
public int getAmount() {
return amount;
}
public int getAmount() {
return amount;
}
public CommandSender getSender() {
return sender;
}
public CommandSender getSender() {
return sender;
}
public boolean isCancelled() {
return cancelled;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
public HandlerList getHandlers() {
return handlers;
}
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -9,54 +9,58 @@ import org.bukkit.inventory.ItemStack;
public class VoucherReceiveEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private static final HandlerList handlers = new HandlerList();
private final Player player;
private final String voucher;
private final ItemStack item;
private final int amount;
private final CommandSender sender;
private boolean cancelled;
private final Player player;
private final String voucher;
private final ItemStack item;
private final int amount;
private final CommandSender sender;
private boolean cancelled;
public VoucherReceiveEvent(Player player, String voucher, ItemStack item, int amount, CommandSender sender) {
this.player = player;
this.voucher = voucher;
this.item = item;
this.amount = amount;
this.sender = sender;
this.cancelled = false;
}
public VoucherReceiveEvent(Player player, String voucher, ItemStack item, int amount, CommandSender sender) {
this.player = player;
this.voucher = voucher;
this.item = item;
this.amount = amount;
this.sender = sender;
this.cancelled = false;
}
public Player getPlayer() {
return player;
}
public Player getPlayer() {
return player;
}
public String getVoucher() {
return voucher;
}
public String getVoucher() {
return voucher;
}
public ItemStack getItem() {
return item;
}
public ItemStack getItem() {
return item;
}
public int getAmount() {
return amount;
}
public int getAmount() {
return amount;
}
public CommandSender getSender() {
return sender;
}
public CommandSender getSender() {
return sender;
}
public boolean isCancelled() {
return cancelled;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
public HandlerList getHandlers() {
return handlers;
}
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -8,48 +8,52 @@ import org.bukkit.inventory.ItemStack;
public class VoucherRedeemEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private static final HandlerList handlers = new HandlerList();
private final Player player;
private final String voucher;
private final ItemStack item;
private final boolean manual;
private boolean cancelled;
private final Player player;
private final String voucher;
private final ItemStack item;
private final boolean manual;
private boolean cancelled;
public VoucherRedeemEvent(Player player, String voucher, ItemStack item, boolean manual) {
this.player = player;
this.voucher = voucher;
this.item = item;
this.manual = manual;
this.cancelled = false;
}
public VoucherRedeemEvent(Player player, String voucher, ItemStack item, boolean manual) {
this.player = player;
this.voucher = voucher;
this.item = item;
this.manual = manual;
this.cancelled = false;
}
public Player getPlayer() {
return player;
}
public Player getPlayer() {
return player;
}
public String getVoucher() {
return voucher;
}
public String getVoucher() {
return voucher;
}
public ItemStack getItem() {
return item;
}
public ItemStack getItem() {
return item;
}
public boolean getManual() {
return manual;
}
public boolean getManual() {
return manual;
}
public boolean isCancelled() {
return cancelled;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
public HandlerList getHandlers() {
return handlers;
}
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -141,7 +141,6 @@ public class Voucher {
}
public void give(CommandSender sender, List<Player> players, int amount) {
String giveMessage = instance.getLocale().getMessage("command.give.send")
.processPlaceholder("player", players.size() == 1 ? players.get(0).getName() : "everyone")
.processPlaceholder("voucher", Matcher.quoteReplacement(getName(true)))