mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2025-12-28 03:09:14 +00:00
Added per-region biomes/fog
This commit is contained in:
@@ -4,6 +4,7 @@ import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
||||
import net.islandearth.rpgregions.gui.IGuiEditable;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -30,6 +31,21 @@ public abstract class RegionEffect implements IGuiEditable {
|
||||
*/
|
||||
public abstract void effect(Player player);
|
||||
|
||||
/**
|
||||
* Called when a player exits all regions and effects should be entirely removed.
|
||||
* @param player
|
||||
*/
|
||||
public void uneffect(Player player) {}
|
||||
|
||||
/**
|
||||
* Gets the required Minecraft version for this effect to function.
|
||||
* @return minecraft version
|
||||
*/
|
||||
@Nullable
|
||||
public String getRequiredVersion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the items are required to be worn in armour slots
|
||||
* @return whether items should be worn in armour slots
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.islandearth.rpgregions.effects;
|
||||
|
||||
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
||||
import net.islandearth.rpgregions.managers.registry.RPGRegionsRegistry;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -14,8 +15,16 @@ public final class RegionEffectRegistry extends RPGRegionsRegistry<RegionEffect>
|
||||
@Override
|
||||
public @Nullable RegionEffect getNew(Class<? extends RegionEffect> clazz, IRPGRegionsAPI plugin, Object... data) {
|
||||
try {
|
||||
Constructor<?> constructor = clazz.getConstructor(IRPGRegionsAPI.class);
|
||||
return (RegionEffect) constructor.newInstance(plugin);
|
||||
try {
|
||||
Constructor<?> constructor = clazz.getConstructor(IRPGRegionsAPI.class);
|
||||
RegionEffect effect = (RegionEffect) constructor.newInstance(plugin);
|
||||
if (effect.getRequiredVersion() != null && !Bukkit.getVersion().contains(effect.getRequiredVersion())) {
|
||||
return null;
|
||||
}
|
||||
return effect;
|
||||
} catch (NoClassDefFoundError e) {
|
||||
return null;
|
||||
}
|
||||
} catch (ReflectiveOperationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user