mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2025-12-27 18:59:10 +00:00
Add basic region effects
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package net.islandearth.rpgregions.api.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RegionsEffectEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
private final Player player;
|
||||
private final List<String> regions;
|
||||
|
||||
public RegionsEffectEvent(Player player, List<String> regions) {
|
||||
this.player = player;
|
||||
this.regions = regions;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public List<String> getRegions() {
|
||||
return regions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.islandearth.rpgregions.effects;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PotionRegionEffect extends RegionEffect {
|
||||
|
||||
private final PotionEffect potionEffect;
|
||||
|
||||
public PotionRegionEffect(PotionEffect potionEffect, List<ItemStack> ignoreItems) {
|
||||
super(ignoreItems);
|
||||
this.potionEffect = potionEffect;
|
||||
}
|
||||
|
||||
public PotionEffect getPotionEffect() {
|
||||
return potionEffect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void effect(Player player) {
|
||||
player.addPotionEffect(potionEffect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package net.islandearth.rpgregions.effects;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class RegionEffect {
|
||||
|
||||
private final List<ItemStack> ignoreItems;
|
||||
|
||||
public RegionEffect(List<ItemStack> ignoreItems) {
|
||||
this.ignoreItems = ignoreItems;
|
||||
}
|
||||
|
||||
public abstract void effect(Player player);
|
||||
|
||||
public List<ItemStack> getIgnoreItems() {
|
||||
return ignoreItems;
|
||||
}
|
||||
|
||||
public boolean shouldIgnore(ItemStack item) {
|
||||
return ignoreItems.contains(item);
|
||||
}
|
||||
|
||||
public abstract String getName();
|
||||
}
|
||||
Reference in New Issue
Block a user