mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-01-27 01:11:21 +01:00
Created alchemy extension
This commit is contained in:
parent
f8627836af
commit
fbe1cd7a5f
14
Extensions/Alchemy/build.gradle
Normal file
14
Extensions/Alchemy/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 = 'Alchemy'
|
||||||
|
|
||||||
|
tasks.withType(Jar) {
|
||||||
|
destinationDirectory = file("$rootDir/bin/")
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package com.willfp.ecoenchants.alchemy;
|
||||||
|
|
||||||
|
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||||
|
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||||
|
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||||
|
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
|
public class Alchemy extends EcoEnchant {
|
||||||
|
public Alchemy() {
|
||||||
|
super("alchemy", EnchantmentType.NORMAL, AlchemyMain.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPotionEffect(EntityPotionEffectEvent event) {
|
||||||
|
if(event.getNewEffect() == null) return;
|
||||||
|
if(!(event.getEntity() instanceof LivingEntity)) return;
|
||||||
|
|
||||||
|
LivingEntity entity = (LivingEntity) event.getEntity();
|
||||||
|
|
||||||
|
int level = EnchantChecks.getArmorPoints(entity, this);
|
||||||
|
if(level == 0) return;
|
||||||
|
|
||||||
|
if(!EnchantmentUtils.passedChance(this, level))
|
||||||
|
return;
|
||||||
|
|
||||||
|
PotionEffect effect = event.getNewEffect();
|
||||||
|
|
||||||
|
PotionEffect newEffect = new PotionEffect(
|
||||||
|
effect.getType(),
|
||||||
|
effect.getDuration(),
|
||||||
|
((effect.getAmplifier() + 1) * 2) - 1,
|
||||||
|
effect.isAmbient(),
|
||||||
|
effect.hasParticles(),
|
||||||
|
effect.hasIcon()
|
||||||
|
);
|
||||||
|
|
||||||
|
entity.removePotionEffect(effect.getType());
|
||||||
|
entity.addPotionEffect(newEffect);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.willfp.ecoenchants.alchemy;
|
||||||
|
|
||||||
|
import com.willfp.ecoenchants.extensions.Extension;
|
||||||
|
|
||||||
|
public class AlchemyMain extends Extension {
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
#
|
||||||
|
# Alchemy EcoEnchant
|
||||||
|
#
|
||||||
|
|
||||||
|
name: "Alchemy"
|
||||||
|
description: Chance to double the strength of potions
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
obtaining:
|
||||||
|
table: true
|
||||||
|
villager: true
|
||||||
|
loot: true
|
||||||
|
rarity: legendary
|
||||||
|
|
||||||
|
general-config:
|
||||||
|
targets:
|
||||||
|
- helmet
|
||||||
|
- chestplate
|
||||||
|
- leggings
|
||||||
|
- boots
|
||||||
|
grindstoneable: true
|
||||||
|
conflicts: []
|
||||||
|
maximum-level: 6
|
||||||
|
|
||||||
|
config:
|
||||||
|
chance-per-level: 4
|
3
Extensions/Alchemy/src/main/resources/extension.yml
Normal file
3
Extensions/Alchemy/src/main/resources/extension.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name: Alchemy
|
||||||
|
main: com.willfp.ecoenchants.alchemy.AlchemyMain
|
||||||
|
version: 1.0.0
|
@ -1,6 +1,7 @@
|
|||||||
package com.willfp.ecoenchants.config;
|
package com.willfp.ecoenchants.config;
|
||||||
|
|
||||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||||
|
import com.willfp.ecoenchants.util.Logger;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
@ -43,6 +44,10 @@ public abstract class UpdatingYamlConfig {
|
|||||||
config.load(configFile);
|
config.load(configFile);
|
||||||
|
|
||||||
InputStream newIn = EcoEnchantsPlugin.getInstance().getResource(name);
|
InputStream newIn = EcoEnchantsPlugin.getInstance().getResource(name);
|
||||||
|
if(newIn == null) {
|
||||||
|
Logger.error(name + " is null?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(newIn, StandardCharsets.UTF_8));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(newIn, StandardCharsets.UTF_8));
|
||||||
YamlConfiguration newConfig = new YamlConfiguration();
|
YamlConfiguration newConfig = new YamlConfiguration();
|
||||||
newConfig.load(reader);
|
newConfig.load(reader);
|
||||||
|
@ -35,3 +35,5 @@ findProject(':Biomes').projectDir = file('Extensions/Biomes')
|
|||||||
include('SprintArtifacts')
|
include('SprintArtifacts')
|
||||||
findProject(':SprintArtifacts').projectDir = file('Extensions/SprintArtifacts')
|
findProject(':SprintArtifacts').projectDir = file('Extensions/SprintArtifacts')
|
||||||
|
|
||||||
|
include('Alchemy')
|
||||||
|
findProject(':Alchemy').projectDir = file('Extensions/Alchemy')
|
||||||
|
Loading…
Reference in New Issue
Block a user