mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2026-01-04 15:31:38 +00:00
New registry API, breaks existing API
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
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, boolean wearingRequired, List<ItemStack> ignoreItems) {
|
||||
super(wearingRequired, ignoreItems);
|
||||
this.potionEffect = potionEffect;
|
||||
}
|
||||
|
||||
public PotionEffect getPotionEffect() {
|
||||
return potionEffect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void effect(Player player) {
|
||||
if (this.isIgnorePerm() || player.hasPermission(this.getPermission())) {
|
||||
player.addPotionEffect(potionEffect);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "PotionRegionEffect";
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package net.islandearth.rpgregions.effects;
|
||||
|
||||
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class RegionEffect {
|
||||
@@ -11,7 +13,11 @@ public abstract class RegionEffect {
|
||||
private final List<ItemStack> ignoreItems;
|
||||
private final boolean ignorePerm;
|
||||
|
||||
public RegionEffect(boolean wearingRequired, List<ItemStack> ignoreItems) {
|
||||
public RegionEffect(IRPGRegionsAPI api) {
|
||||
this(api, false, new ArrayList<>());
|
||||
}
|
||||
|
||||
public RegionEffect(IRPGRegionsAPI api, boolean wearingRequired, List<ItemStack> ignoreItems) {
|
||||
this.wearingRequired = wearingRequired;
|
||||
this.ignoreItems = ignoreItems;
|
||||
this.ignorePerm = true;
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.islandearth.rpgregions.managers;
|
||||
import net.islandearth.rpgregions.api.integrations.IntegrationManager;
|
||||
import net.islandearth.rpgregions.managers.data.IRPGRegionsCache;
|
||||
import net.islandearth.rpgregions.managers.data.IStorageManager;
|
||||
import net.islandearth.rpgregions.managers.registry.IRPGRegionsRegistry;
|
||||
|
||||
public interface IRPGRegionsManagers {
|
||||
|
||||
@@ -13,4 +14,6 @@ public interface IRPGRegionsManagers {
|
||||
IRPGRegionsCache getRegionsCache();
|
||||
|
||||
IRegenerationManager getRegenerationManager();
|
||||
|
||||
IRPGRegionsRegistry<?> getRegistry(Class<? extends IRPGRegionsRegistry<?>> clazz);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.islandearth.rpgregions.managers.registry;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
||||
import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface IRPGRegionsRegistry<T> {
|
||||
|
||||
@NotNull
|
||||
ImmutableMap<String, Class<? extends T>> get();
|
||||
|
||||
/**
|
||||
* Attempts to register a class.
|
||||
* @param clazz class to register
|
||||
* @throws IllegalArgumentException if class is already registered
|
||||
*/
|
||||
void register(Class<? extends T> clazz);
|
||||
|
||||
@Nullable
|
||||
T getNew(String name, IRPGRegionsAPI plugin, Object... data);
|
||||
|
||||
@Nullable
|
||||
T getNew(Class<? extends T> clazz, IRPGRegionsAPI plugin, Object... data);
|
||||
|
||||
String getRegistryName();
|
||||
|
||||
Class<T> getImplementation();
|
||||
|
||||
Material getIcon();
|
||||
}
|
||||
@@ -1,17 +1,23 @@
|
||||
package net.islandearth.rpgregions.requirements;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class DependencyRequirement extends RegionRequirement {
|
||||
|
||||
private final List<String> requiredRegions;
|
||||
|
||||
public DependencyRequirement(List<String> requiredRegions) {
|
||||
super();
|
||||
|
||||
public DependencyRequirement(IRPGRegionsAPI api) {
|
||||
this(api, new ArrayList<>());
|
||||
}
|
||||
|
||||
public DependencyRequirement(IRPGRegionsAPI api, List<String> requiredRegions) {
|
||||
super(api);
|
||||
this.requiredRegions = requiredRegions;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,27 @@
|
||||
package net.islandearth.rpgregions.requirements;
|
||||
|
||||
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class RegionRequirement {
|
||||
|
||||
private final IRPGRegionsAPI api;
|
||||
private final PreventType preventType;
|
||||
|
||||
public RegionRequirement() {
|
||||
super();
|
||||
public RegionRequirement(IRPGRegionsAPI api) {
|
||||
this.api = api;
|
||||
this.preventType = PreventType.TELEPORT;
|
||||
}
|
||||
|
||||
public RegionRequirement(PreventType preventType) {
|
||||
public RegionRequirement(IRPGRegionsAPI api, PreventType preventType) {
|
||||
this.api = api;
|
||||
this.preventType = preventType;
|
||||
}
|
||||
|
||||
public IRPGRegionsAPI getApi() {
|
||||
return api;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether this player meets the requirements to enter.
|
||||
* @param player player to check
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
package net.islandearth.rpgregions.rewards;
|
||||
|
||||
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class DiscoveryReward {
|
||||
|
||||
private final IRPGRegionsAPI api;
|
||||
|
||||
public DiscoveryReward(IRPGRegionsAPI api) {
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
public IRPGRegionsAPI getAPI() {
|
||||
return api;
|
||||
}
|
||||
|
||||
/**
|
||||
* Awards this reward to the specified player
|
||||
* @param player player to award to
|
||||
|
||||
Reference in New Issue
Block a user