Skip to content

Commit

Permalink
Add Dense Modifier and other Mace Enchants
Browse files Browse the repository at this point in the history
  • Loading branch information
Flo56958 committed Jul 21, 2024
1 parent 4a1a21e commit 20c77c8
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/main/java/de/flo56958/minetinker/MineTinker.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ private void addCoreMods() {
modManager.register(Berserk.instance());
modManager.register(Building.instance());
modManager.register(Channeling.instance());
modManager.register(Dense.instance());
modManager.register(Directing.instance());
modManager.register(Drilling.instance());
modManager.register(Ender.instance());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ public class ModManager {
incompatibilityList.add(Phasing.instance().getKey() + ":" + Ender.instance().getKey());
incompatibilityList.add(Phasing.instance().getKey() + ":" + Magical.instance().getKey());
incompatibilityList.add(Phasing.instance().getKey() + ":" + Homing.instance().getKey());
incompatibilityList.add(Dense.instance().getKey() + ":" + Smite.instance().getKey());
incompatibilityList.add(Dense.instance().getKey() + ":" + SpidersBane.instance().getKey());
incompatibilityList.add(Dense.instance().getKey() + ":" + Piercing.instance().getKey());
incompatibilityList.add(Piercing.instance().getKey() + ":" + Smite.instance().getKey());
incompatibilityList.add(Piercing.instance().getKey() + ":" + SpidersBane.instance().getKey());


Plugin plugin = Bukkit.getPluginManager().getPlugin("ProtocolLib");
if (plugin != null && plugin.isEnabled())
Expand Down
86 changes: 86 additions & 0 deletions src/main/java/de/flo56958/minetinker/modifiers/types/Dense.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package de.flo56958.minetinker.modifiers.types;

import de.flo56958.minetinker.MineTinker;
import de.flo56958.minetinker.data.ToolType;
import de.flo56958.minetinker.modifiers.Modifier;
import de.flo56958.minetinker.utils.ConfigurationManager;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.util.Collections;
import java.util.List;

public class Dense extends Modifier {

private static Dense instance;

private Dense() {
super(MineTinker.getPlugin());
customModelData = 10_070;
}

public static Dense instance() {
synchronized (Dense.class) {
if (instance == null)
instance = new Dense();
}

return instance;
}

@Override
public String getKey() {
return "Dense";
}

@Override
public List<ToolType> getAllowedTools() {
return Collections.singletonList(ToolType.MACE);
}

@Override
public @NotNull List<Enchantment> getAppliedEnchantments() {
return Collections.singletonList(Enchantment.DENSITY);
}

@Override
public void reload() {
FileConfiguration config = getConfig();
config.options().copyDefaults(true);

config.addDefault("Allowed", true);
config.addDefault("Color", "%DARK_GRAY%");
config.addDefault("MaxLevel", 5);
config.addDefault("SlotCost", 1);
config.addDefault("ModifierItemMaterial", Material.DEEPSLATE.name());

config.addDefault("EnchantCost", 10);
config.addDefault("Enchantable", true);
config.addDefault("MinimumToolLevelRequirement", 1);

config.addDefault("Recipe.Enabled", false);

ConfigurationManager.saveConfig(config);
ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName());

init();
}

@Override
public boolean applyMod(Player player, ItemStack tool, boolean isCommand) {
ItemMeta meta = tool.getItemMeta();

if (meta != null) {
meta.addEnchant(Enchantment.DENSITY, modManager.getModLevel(tool, this), true);
tool.setItemMeta(meta);
} else return false;

return true;
}
}
28 changes: 23 additions & 5 deletions src/main/java/de/flo56958/minetinker/modifiers/types/Piercing.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Piercing extends Modifier implements Listener {

Expand Down Expand Up @@ -47,15 +51,15 @@ public String getKey() {

@Override
public List<ToolType> getAllowedTools() {
if (allowBow) return Arrays.asList(ToolType.CROSSBOW, ToolType.BOW);
return Collections.singletonList(ToolType.CROSSBOW);
if (allowBow) return Arrays.asList(ToolType.CROSSBOW, ToolType.BOW, ToolType.MACE);
return Arrays.asList(ToolType.CROSSBOW, ToolType.MACE);
}

@Override
public @NotNull List<Enchantment> getAppliedEnchantments() {
return Collections.singletonList(Enchantment.PIERCING);
return Arrays.asList(Enchantment.BREACH, Enchantment.PIERCING);
}
//The mod does not apply the enchantment anymore
//The mod does not apply the enchantment anymore (only the Mace enchant is still active)

@Override
public void reload() {
Expand Down Expand Up @@ -94,6 +98,20 @@ public void reload() {
this.allowBow = config.getBoolean("AllowBow", true);
}

@Override
public boolean applyMod(Player player, ItemStack tool, boolean isCommand) {
final ItemMeta meta = tool.getItemMeta();

if (meta != null && ToolType.MACE.contains(tool.getType())) {
meta.addEnchant(Enchantment.BREACH, modManager.getModLevel(tool, this), true);
tool.setItemMeta(meta);
}

// No enchant for Bow and Crossbow

return true;
}

@EventHandler
public void onLaunch(final MTProjectileLaunchEvent event) {
final Projectile projectile = event.getEvent().getEntity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;

Expand Down Expand Up @@ -55,12 +54,12 @@ public String getKey() {

@Override
public List<ToolType> getAllowedTools() {
return Arrays.asList(ToolType.ELYTRA, ToolType.TRIDENT);
return Arrays.asList(ToolType.ELYTRA, ToolType.TRIDENT, ToolType.MACE, ToolType.SWORD, ToolType.AXE);
}

@Override
public @NotNull List<Enchantment> getAppliedEnchantments() {
return Collections.singletonList(Enchantment.RIPTIDE);
return Arrays.asList(Enchantment.RIPTIDE, Enchantment.WIND_BURST);
}

@Override
Expand Down Expand Up @@ -109,6 +108,8 @@ public boolean applyMod(Player player, ItemStack tool, boolean isCommand) {
if (meta != null) {
if (ToolType.TRIDENT.contains(tool.getType()))
meta.addEnchant(Enchantment.RIPTIDE, modManager.getModLevel(tool, this), true);
else if (!ToolType.ELYTRA.contains(tool.getType()))
meta.addEnchant(Enchantment.WIND_BURST, modManager.getModLevel(tool, this), true);
//Elytra does not get an enchantment

tool.setItemMeta(meta);
Expand Down
12 changes: 10 additions & 2 deletions src/main/resources/lang/en_US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ Modifier:
Description_OnlyStorms: "This only works during thunderstorms!"
ModifierItemName: "Lightning Infused Shard"
DescriptionModifierItem: "Modifier-Item for the Channeling-Modifier"
Dense:
Name: "Dense"
Description: "Increases damage dealt per block fallen before the melee attack!"
ModifierItemName: "Dense Iron"
DescriptionModifierItem: "Modifier-Item for the Dense-Modifier"
Directing:
Name: "Directing"
Description: "Loot from killed mobs or broken Blocks goes directly into your Inventory!"
Expand Down Expand Up @@ -332,7 +337,7 @@ Modifier:
Statistic_Healed: "Total Durability Restored: %amount"
Piercing:
Name: "Piercing"
Description: "Arrows pass through multiple enemies!"
Description: "Arrows pass through multiple enemies and melee hit penetrate armor!"
ModifierItemName: "Bodkin Point"
DescriptionModifierItem: "Modifier-Item for the Piercing-Modifier"
Poisonous:
Expand All @@ -347,7 +352,7 @@ Modifier:
DescriptionModifierItem: "Modifier-Item for the Power-Modifier"
Propelling:
Name: "Propelling"
Description: "Propel yourself through the air with sneaking while gliding with the elytra or standing in water with the trident!"
Description: "Propel yourself through the air with sneaking while gliding with the elytra, standing in water with the trident or attacking from above while falling with a melee weapon!"
ModifierItemName: "Enchanted Fireworkstar"
DescriptionModifierItem: "Modifier-Item for the Propelling-Modifier"
Protecting:
Expand Down Expand Up @@ -569,6 +574,9 @@ Enchantment:
aqua_affinity: "Aqua Affinity"
soul_speed: "Soul Speed"
swift_sneak: "Swift Sneak"
density: "Density"
wind_burst: "Wind Burst"
breach: "Breach"

Updater.Unable: "Unable to check for updates!"
Updater.UpdateAvailable: "There is an update available on spigotmc.org!"
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ permissions:
minetinker.modifiers.berserk.*: true
minetinker.modifiers.building.*: true
minetinker.modifiers.channeling.*: true
minetinker.modifiers.dense.*: true
minetinker.modifiers.directing.*: true
minetinker.modifiers.drilling.*: true
minetinker.modifiers.echoing.*: true
Expand Down Expand Up @@ -443,6 +444,13 @@ permissions:
description: Allows to use Directing on a MineTinker-Tool
default: true

minetinker.modifiers.dense.*:
children:
minetinker.modifiers.dense.apply: true
minetinker.modifiers.dense.apply:
description: Allows to apply Dense to a MineTinker-Tool
default: true

minetinker.modifiers.drilling.*:
children:
minetinker.modifiers.drilling.apply: true
Expand Down

0 comments on commit 20c77c8

Please sign in to comment.