mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-02-24 05:51:21 +01:00
Created biomes extension
This commit is contained in:
parent
04ae10cd33
commit
ed16dde180
14
Extensions/Biomes/build.gradle
Normal file
14
Extensions/Biomes/build.gradle
Normal file
@ -0,0 +1,14 @@
|
||||
dependencies {
|
||||
compileOnly 'org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT'
|
||||
compileOnly project(':plugin')
|
||||
}
|
||||
|
||||
jar{
|
||||
archiveFileName = project.name + " Extension" + ".jar"
|
||||
}
|
||||
|
||||
description = 'Biomes'
|
||||
|
||||
tasks.withType(Jar) {
|
||||
destinationDirectory = file("$rootDir/bin/")
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.willfp.ecoenchants.biomes;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.util.optional.Prerequisite;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Trident;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
public abstract class BiomesEnchantment extends EcoEnchant {
|
||||
protected BiomesEnchantment(String key, EnchantmentType type, Prerequisite... prerequisites) {
|
||||
super(key, type, BiomesMain.class, prerequisites);
|
||||
}
|
||||
|
||||
public abstract boolean isValid(Biome biome);
|
||||
|
||||
private boolean isInBiome(LivingEntity entity) {
|
||||
Biome entityBiome = entity.getLocation().getBlock().getBiome();
|
||||
return isValid(entityBiome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
if(!isInBiome(attacker))
|
||||
return;
|
||||
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
event.setDamage(event.getDamage() * (1 + (level * multiplier)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDamageWearingArmor(LivingEntity victim, int level, EntityDamageEvent event) {
|
||||
if(!isInBiome(victim))
|
||||
return;
|
||||
|
||||
double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "reduction-per-level");
|
||||
double multiplier = 1 - ((reduction/100) * level);
|
||||
event.setDamage(event.getDamage() * multiplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) {
|
||||
if(!isInBiome(attacker))
|
||||
return;
|
||||
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
event.setDamage(event.getDamage() * (1 + (level * multiplier)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) {
|
||||
if(!isInBiome(attacker))
|
||||
return;
|
||||
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
event.setDamage(event.getDamage() * (1 + (level * multiplier)));
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.willfp.ecoenchants.biomes;
|
||||
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.biomes.enchants.defensive.*;
|
||||
import com.willfp.ecoenchants.biomes.enchants.offensive.*;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.extensions.Extension;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class BiomesMain extends Extension {
|
||||
public static final EcoEnchant ELEVATION = new Elevation();
|
||||
public static final EcoEnchant GLACIAL = new Glacial();
|
||||
public static final EcoEnchant HEAT_TREATED = new HeatTreated();
|
||||
public static final EcoEnchant OCEANIC = new Oceanic();
|
||||
public static final EcoEnchant TROPICAL = new Tropical();
|
||||
public static final EcoEnchant ALTITUDE = new Altitude();
|
||||
public static final EcoEnchant AQUAMARINE = new Aquamarine();
|
||||
public static final EcoEnchant DEHYDRATION = new Dehydration();
|
||||
public static final EcoEnchant ICELORD = new Icelord();
|
||||
public static final EcoEnchant RAINFOREST = new Rainforest();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Bukkit.getPluginManager().registerEvents(ELEVATION, EcoEnchantsPlugin.getInstance());
|
||||
Bukkit.getPluginManager().registerEvents(GLACIAL, EcoEnchantsPlugin.getInstance());
|
||||
Bukkit.getPluginManager().registerEvents(HEAT_TREATED, EcoEnchantsPlugin.getInstance());
|
||||
Bukkit.getPluginManager().registerEvents(OCEANIC, EcoEnchantsPlugin.getInstance());
|
||||
Bukkit.getPluginManager().registerEvents(TROPICAL, EcoEnchantsPlugin.getInstance());
|
||||
Bukkit.getPluginManager().registerEvents(ALTITUDE, EcoEnchantsPlugin.getInstance());
|
||||
Bukkit.getPluginManager().registerEvents(AQUAMARINE, EcoEnchantsPlugin.getInstance());
|
||||
Bukkit.getPluginManager().registerEvents(DEHYDRATION, EcoEnchantsPlugin.getInstance());
|
||||
Bukkit.getPluginManager().registerEvents(ICELORD, EcoEnchantsPlugin.getInstance());
|
||||
Bukkit.getPluginManager().registerEvents(RAINFOREST, EcoEnchantsPlugin.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.willfp.ecoenchants.biomes.enchants.defensive;
|
||||
|
||||
import com.willfp.ecoenchants.biomes.BiomesEnchantment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Elevation extends BiomesEnchantment {
|
||||
public Elevation() {
|
||||
super("elevation", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Biome biome) {
|
||||
return Arrays.stream(new String[]{"mountain", "hill"}).anyMatch(biome.name().toLowerCase()::contains);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.willfp.ecoenchants.biomes.enchants.defensive;
|
||||
|
||||
import com.willfp.ecoenchants.biomes.BiomesEnchantment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Glacial extends BiomesEnchantment {
|
||||
public Glacial() {
|
||||
super("glacial", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Biome biome) {
|
||||
return Arrays.stream(new String[]{"snowy", "ice", "frozen"}).anyMatch(biome.name().toLowerCase()::contains);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.willfp.ecoenchants.biomes.enchants.defensive;
|
||||
|
||||
import com.willfp.ecoenchants.biomes.BiomesEnchantment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class HeatTreated extends BiomesEnchantment {
|
||||
public HeatTreated() {
|
||||
super("heat_treated", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Biome biome) {
|
||||
return Arrays.stream(new String[]{"desert", "badlands", "savanna"}).anyMatch(biome.name().toLowerCase()::contains);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.willfp.ecoenchants.biomes.enchants.defensive;
|
||||
|
||||
import com.willfp.ecoenchants.biomes.BiomesEnchantment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Oceanic extends BiomesEnchantment {
|
||||
public Oceanic() {
|
||||
super("oceanic", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Biome biome) {
|
||||
return Arrays.stream(new String[]{"ocean"}).anyMatch(biome.name().toLowerCase()::contains);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.willfp.ecoenchants.biomes.enchants.defensive;
|
||||
|
||||
import com.willfp.ecoenchants.biomes.BiomesEnchantment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Tropical extends BiomesEnchantment {
|
||||
public Tropical() {
|
||||
super("tropical", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Biome biome) {
|
||||
return Arrays.stream(new String[]{"jungle"}).anyMatch(biome.name().toLowerCase()::contains);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.willfp.ecoenchants.biomes.enchants.offensive;
|
||||
|
||||
import com.willfp.ecoenchants.biomes.BiomesEnchantment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Altitude extends BiomesEnchantment {
|
||||
public Altitude() {
|
||||
super("altitude", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Biome biome) {
|
||||
return Arrays.stream(new String[]{"mountain", "hill"}).anyMatch(biome.name().toLowerCase()::contains);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.willfp.ecoenchants.biomes.enchants.offensive;
|
||||
|
||||
import com.willfp.ecoenchants.biomes.BiomesEnchantment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Aquamarine extends BiomesEnchantment {
|
||||
public Aquamarine() {
|
||||
super("aquamarine", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Biome biome) {
|
||||
return Arrays.stream(new String[]{"ocean"}).anyMatch(biome.name().toLowerCase()::contains);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.willfp.ecoenchants.biomes.enchants.offensive;
|
||||
|
||||
import com.willfp.ecoenchants.biomes.BiomesEnchantment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Dehydration extends BiomesEnchantment {
|
||||
public Dehydration() {
|
||||
super("dehydration", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Biome biome) {
|
||||
return Arrays.stream(new String[]{"desert", "badlands", "savanna"}).anyMatch(biome.name().toLowerCase()::contains);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.willfp.ecoenchants.biomes.enchants.offensive;
|
||||
|
||||
import com.willfp.ecoenchants.biomes.BiomesEnchantment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Icelord extends BiomesEnchantment {
|
||||
public Icelord() {
|
||||
super("icelord", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Biome biome) {
|
||||
return Arrays.stream(new String[]{"snowy", "ice", "frozen"}).anyMatch(biome.name().toLowerCase()::contains);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.willfp.ecoenchants.biomes.enchants.offensive;
|
||||
|
||||
import com.willfp.ecoenchants.biomes.BiomesEnchantment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Rainforest extends BiomesEnchantment {
|
||||
public Rainforest() {
|
||||
super("rainforest", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Biome biome) {
|
||||
return Arrays.stream(new String[]{"jungle"}).anyMatch(biome.name().toLowerCase()::contains);
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
#
|
||||
# Altitude EcoEnchant
|
||||
#
|
||||
|
||||
name: "Altitude"
|
||||
description: Deal more damage in hilly biomes.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: rare
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- bow
|
||||
- crossbow
|
||||
- sword
|
||||
- axe
|
||||
- trident
|
||||
grindstoneable: true
|
||||
conflicts:
|
||||
- aquamarine
|
||||
- dehydration
|
||||
- icelord
|
||||
- rainforest
|
||||
maximum-level: 6
|
||||
|
||||
config:
|
||||
multiplier: 0.03
|
@ -0,0 +1,31 @@
|
||||
#
|
||||
# Aquamarine EcoEnchant
|
||||
#
|
||||
|
||||
name: "Aquamarine"
|
||||
description: Deal more damage in oceans.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: rare
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- bow
|
||||
- crossbow
|
||||
- sword
|
||||
- axe
|
||||
- trident
|
||||
grindstoneable: true
|
||||
conflicts:
|
||||
- altitude
|
||||
- dehydration
|
||||
- icelord
|
||||
- rainforest
|
||||
maximum-level: 6
|
||||
|
||||
config:
|
||||
multiplier: 0.03
|
@ -0,0 +1,31 @@
|
||||
#
|
||||
# Dehydration EcoEnchant
|
||||
#
|
||||
|
||||
name: "Dehydration"
|
||||
description: Deal more damage in hot biomes.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: rare
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- bow
|
||||
- crossbow
|
||||
- sword
|
||||
- axe
|
||||
- trident
|
||||
grindstoneable: true
|
||||
conflicts:
|
||||
- altitude
|
||||
- aquamarine
|
||||
- icelord
|
||||
- rainforest
|
||||
maximum-level: 6
|
||||
|
||||
config:
|
||||
multiplier: 0.03
|
@ -0,0 +1,30 @@
|
||||
#
|
||||
# Elevation EcoEnchant
|
||||
#
|
||||
|
||||
name: "Elevation"
|
||||
description: Take less damage in hilly biomes.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: rare
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- helmet
|
||||
- chestplate
|
||||
- leggings
|
||||
- boots
|
||||
grindstoneable: true
|
||||
conflicts:
|
||||
- glacial
|
||||
- heat_treated
|
||||
- oceanic
|
||||
- tropical
|
||||
maximum-level: 3
|
||||
|
||||
config:
|
||||
reduction-per-level: 2 # As percentage
|
@ -0,0 +1,30 @@
|
||||
#
|
||||
# Glacial EcoEnchant
|
||||
#
|
||||
|
||||
name: "Glacial"
|
||||
description: Take less damage in cold biomes.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: rare
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- helmet
|
||||
- chestplate
|
||||
- leggings
|
||||
- boots
|
||||
grindstoneable: true
|
||||
conflicts:
|
||||
- elevation
|
||||
- heat_treated
|
||||
- oceanic
|
||||
- tropical
|
||||
maximum-level: 3
|
||||
|
||||
config:
|
||||
reduction-per-level: 2 # As percentage
|
@ -0,0 +1,30 @@
|
||||
#
|
||||
# Heat Treated EcoEnchant
|
||||
#
|
||||
|
||||
name: "Heat Treated"
|
||||
description: Take less damage in hot biomes.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: rare
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- helmet
|
||||
- chestplate
|
||||
- leggings
|
||||
- boots
|
||||
grindstoneable: true
|
||||
conflicts:
|
||||
- elevation
|
||||
- glacial
|
||||
- oceanic
|
||||
- tropical
|
||||
maximum-level: 3
|
||||
|
||||
config:
|
||||
reduction-per-level: 2 # As percentage
|
@ -0,0 +1,31 @@
|
||||
#
|
||||
# Icelord EcoEnchant
|
||||
#
|
||||
|
||||
name: "Icelord"
|
||||
description: Deal more damage in cold biomes.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: rare
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- bow
|
||||
- crossbow
|
||||
- sword
|
||||
- axe
|
||||
- trident
|
||||
grindstoneable: true
|
||||
conflicts:
|
||||
- altitide
|
||||
- aquamarine
|
||||
- dehydration
|
||||
- rainforest
|
||||
maximum-level: 6
|
||||
|
||||
config:
|
||||
multiplier: 0.03
|
@ -0,0 +1,30 @@
|
||||
#
|
||||
# Oceanic EcoEnchant
|
||||
#
|
||||
|
||||
name: "Oceanic"
|
||||
description: Take less damage in oceans.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: rare
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- helmet
|
||||
- chestplate
|
||||
- leggings
|
||||
- boots
|
||||
grindstoneable: true
|
||||
conflicts:
|
||||
- elevation
|
||||
- glacial
|
||||
- heat_treated
|
||||
- tropical
|
||||
maximum-level: 3
|
||||
|
||||
config:
|
||||
reduction-per-level: 2 # As percentage
|
@ -0,0 +1,31 @@
|
||||
#
|
||||
# Rainforest EcoEnchant
|
||||
#
|
||||
|
||||
name: "Rainforest"
|
||||
description: Deal more damage in jungles.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: rare
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- bow
|
||||
- crossbow
|
||||
- sword
|
||||
- axe
|
||||
- trident
|
||||
grindstoneable: true
|
||||
conflicts:
|
||||
- altitude
|
||||
- aquamarine
|
||||
- dehydration
|
||||
- icelord
|
||||
maximum-level: 6
|
||||
|
||||
config:
|
||||
multiplier: 0.03
|
@ -0,0 +1,30 @@
|
||||
#
|
||||
# Tropical EcoEnchant
|
||||
#
|
||||
|
||||
name: "Tropical"
|
||||
description: Take less damage in jungles.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: rare
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- helmet
|
||||
- chestplate
|
||||
- leggings
|
||||
- boots
|
||||
grindstoneable: true
|
||||
conflicts:
|
||||
- elevation
|
||||
- glacial
|
||||
- heat_treated
|
||||
- oceanic
|
||||
maximum-level: 3
|
||||
|
||||
config:
|
||||
reduction-per-level: 2 # As percentage
|
3
Extensions/Biomes/src/main/resources/extension.yml
Normal file
3
Extensions/Biomes/src/main/resources/extension.yml
Normal file
@ -0,0 +1,3 @@
|
||||
name: Biomes
|
||||
main: com.willfp.ecoenchants.biomes.BiomesMain
|
||||
version: 1.0.0
|
@ -27,4 +27,7 @@ include('Summoning')
|
||||
findProject(':Summoning').projectDir = file('Extensions/Summoning')
|
||||
|
||||
include('Endershot')
|
||||
findProject(':Endershot').projectDir = file('Extensions/Endershot')
|
||||
findProject(':Endershot').projectDir = file('Extensions/Endershot')
|
||||
|
||||
include('Biomes')
|
||||
findProject(':Biomes').projectDir = file('Extensions/Biomes')
|
Loading…
Reference in New Issue
Block a user