mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2025-12-28 03:09:14 +00:00
Add isWearingRequired
This commit is contained in:
@@ -10,8 +10,8 @@ public class PotionRegionEffect extends RegionEffect {
|
||||
|
||||
private final PotionEffect potionEffect;
|
||||
|
||||
public PotionRegionEffect(PotionEffect potionEffect, List<ItemStack> ignoreItems) {
|
||||
super(ignoreItems);
|
||||
public PotionRegionEffect(PotionEffect potionEffect, boolean wearingRequired, List<ItemStack> ignoreItems) {
|
||||
super(wearingRequired, ignoreItems);
|
||||
this.potionEffect = potionEffect;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,6 @@ public class PotionRegionEffect extends RegionEffect {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
return "PotionRegionEffect";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,20 @@ import java.util.List;
|
||||
|
||||
public abstract class RegionEffect {
|
||||
|
||||
private final boolean wearingRequired;
|
||||
private final List<ItemStack> ignoreItems;
|
||||
|
||||
public RegionEffect(List<ItemStack> ignoreItems) {
|
||||
public RegionEffect(boolean wearingRequired, List<ItemStack> ignoreItems) {
|
||||
this.wearingRequired = wearingRequired;
|
||||
this.ignoreItems = ignoreItems;
|
||||
}
|
||||
|
||||
public abstract void effect(Player player);
|
||||
|
||||
public boolean isWearingRequired() {
|
||||
return wearingRequired;
|
||||
}
|
||||
|
||||
public List<ItemStack> getIgnoreItems() {
|
||||
return ignoreItems;
|
||||
}
|
||||
|
||||
@@ -47,12 +47,25 @@ public class RegionListener implements Listener {
|
||||
ConfiguredRegion configuredRegion = plugin.getManagers().getRegionsCache().getConfiguredRegions().get(region);
|
||||
configuredRegion.getEffects().forEach(regionEffect -> {
|
||||
boolean canEffect = true;
|
||||
if (regionEffect.isWearingRequired()) {
|
||||
for (ItemStack itemStack : player.getInventory().getArmorContents()) {
|
||||
if (regionEffect.shouldIgnore(itemStack)) {
|
||||
canEffect = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (canEffect) regionEffect.effect(player);
|
||||
return;
|
||||
}
|
||||
|
||||
for (ItemStack itemStack : player.getInventory()) {
|
||||
if (regionEffect.shouldIgnore(itemStack)) {
|
||||
canEffect = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (canEffect) regionEffect.effect(player);
|
||||
});
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ public class RPGRegionsManagers {
|
||||
List<RegionEffect> effects = new ArrayList<>();
|
||||
effects.add(new PotionRegionEffect(
|
||||
new PotionEffect(PotionEffectType.GLOWING, 100, 1, true, true, true),
|
||||
true,
|
||||
Collections.singletonList(new ItemStackBuilder(Material.IRON_CHESTPLATE).build())));
|
||||
ConfiguredRegion configuredRegion = new ConfiguredRegion(null, "exampleconfig", "ExampleConfig", rewards, effects,
|
||||
XSound.AMBIENT_UNDERWATER_EXIT.parseSound(),
|
||||
|
||||
Reference in New Issue
Block a user