-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/") | ||
} |
46 changes: 46 additions & 0 deletions
46
Extensions/Alchemy/src/main/java/com/willfp/ecoenchants/alchemy/Alchemy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Extensions/Alchemy/src/main/java/com/willfp/ecoenchants/alchemy/AlchemyMain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() { | ||
|
||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
Extensions/Alchemy/src/main/resources/enchants/normal/alchemy.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: Alchemy | ||
main: com.willfp.ecoenchants.alchemy.AlchemyMain | ||
version: 1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters