mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
add causingPlayer to McMMOReplaceVanillaTreasureEvent and update Fish Event to use it (#5104)
* add causingPlayer to McMMOReplaceVanillaTreasureEvent and update Fishing Event to use it * make requested changes --------- Co-authored-by: Jacob Cuomo <jcuomo3@gatech.edu>
This commit is contained in:
parent
8087d5f647
commit
571013cf55
@ -1,18 +1,26 @@
|
|||||||
package com.gmail.nossr50.events;
|
package com.gmail.nossr50.events;
|
||||||
|
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class McMMOReplaceVanillaTreasureEvent extends Event {
|
public class McMMOReplaceVanillaTreasureEvent extends Event {
|
||||||
private @NotNull ItemStack replacementItemStack;
|
private @NotNull ItemStack replacementItemStack;
|
||||||
private final @NotNull Item originalItem;
|
private final @NotNull Item originalItem;
|
||||||
|
private final @Nullable Player causingPlayer;
|
||||||
|
|
||||||
public McMMOReplaceVanillaTreasureEvent(@NotNull Item originalItem, @NotNull ItemStack replacementItemStack) {
|
public McMMOReplaceVanillaTreasureEvent(@NotNull Item originalItem, @NotNull ItemStack replacementItemStack) {
|
||||||
|
this(originalItem, replacementItemStack, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public McMMOReplaceVanillaTreasureEvent(@NotNull Item originalItem, @NotNull ItemStack replacementItemStack, @Nullable Player causingPlayer) {
|
||||||
this.originalItem = originalItem;
|
this.originalItem = originalItem;
|
||||||
this.replacementItemStack = replacementItemStack;
|
this.replacementItemStack = replacementItemStack;
|
||||||
|
this.causingPlayer = causingPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Rest of file is required boilerplate for custom events **/
|
/** Rest of file is required boilerplate for custom events **/
|
||||||
@ -31,6 +39,10 @@ public class McMMOReplaceVanillaTreasureEvent extends Event {
|
|||||||
return replacementItemStack;
|
return replacementItemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @Nullable Player getCausingPlayer() {
|
||||||
|
return causingPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
public void setReplacementItemStack(@NotNull ItemStack replacementItemStack) {
|
public void setReplacementItemStack(@NotNull ItemStack replacementItemStack) {
|
||||||
this.replacementItemStack = replacementItemStack;
|
this.replacementItemStack = replacementItemStack;
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
ItemStack replacementCatch = new ItemStack(Material.SALMON, 1);
|
ItemStack replacementCatch = new ItemStack(Material.SALMON, 1);
|
||||||
|
|
||||||
McMMOReplaceVanillaTreasureEvent replaceVanillaTreasureEvent = new McMMOReplaceVanillaTreasureEvent(fishingCatch, replacementCatch);
|
McMMOReplaceVanillaTreasureEvent replaceVanillaTreasureEvent = new McMMOReplaceVanillaTreasureEvent(fishingCatch, replacementCatch, player);
|
||||||
Bukkit.getPluginManager().callEvent(replaceVanillaTreasureEvent);
|
Bukkit.getPluginManager().callEvent(replaceVanillaTreasureEvent);
|
||||||
|
|
||||||
//Replace
|
//Replace
|
||||||
|
Loading…
Reference in New Issue
Block a user