Files
src
build.gradle
Code
8 2,211
src/main/java/com/godmace/GodMace.java
package com.godmace;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.entity.Player;
import org.bukkit.Material;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.RecipeChoice;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class GodMace extends JavaPlugin {
private GodMaceItem godMaceItem;
private MaceTracker maceTracker;
private final Map<UUID, Long> airLaunchCooldown = new HashMap<>();
private final Map<UUID, Long> dashCooldown = new HashMap<>();
private final Map<UUID, Integer> soulReaperHits = new HashMap<>();
private final Map<UUID, Boolean> soulReaperReady = new HashMap<>();
private final Map<UUID, Long> airLaunchTime = new HashMap<>(); // when Air Launch was used
private final Map<UUID, Long> thunderSmashCooldown = new HashMap<>();
private final Map<UUID, Long> thunderLaunchCooldown = new HashMap<>();
private final Map<UUID, Long> flameAuraCooldown = new HashMap<>();
private final Map<UUID, Long> icePrisonCooldown = new HashMap<>();
private final Map<UUID, Long> freezeCooldown = new HashMap<>();
private final Map<UUID, Long> windBurstCooldown = new HashMap<>();
private final Map<UUID, Long> doomSmashCooldown = new HashMap<>();
private final Map<UUID, Long> doomDashCooldown = new HashMap<>();
private final Map<UUID, Long> doomMarked = new HashMap<>();
private final Map<UUID, Long> doomMarkCooldown = new HashMap<>();
private final Map<UUID, Long> summonWitherCooldown = new HashMap<>();
private final Map<UUID, Long> witherAuraCooldown = new HashMap<>();
private final Map<UUID, Long> voidCloakCooldown = new HashMap<>();
private final Map<UUID, Long> voidExcavateCooldown = new HashMap<>();
private final Map<UUID, Long> lungeCooldown = new HashMap<>();
private final Map<UUID, Long> regenerationCooldown = new HashMap<>();
private long godMaceLastCraftTime = 0L;
@Override
public void onEnable() {
saveDefaultConfig();
godMaceItem = new GodMaceItem(this);
getServer().getPluginManager().registerEvents(new GodMaceListener(this), this);
getCommand("godmace").setExecutor(new GodMaceCommand(this));
maceTracker = new MaceTracker(this);
// Flame Mace passive — fire resistance every second while holding
getServer().getScheduler().runTaskTimer(this, () -> {
for (Player p : getServer().getOnlinePlayers()) {
ItemStack hand = p.getInventory().getItemInMainHand();
if (godMaceItem.isFlameMace(hand)) {
p.addPotionEffect(new org.bukkit.potion.PotionEffect(
org.bukkit.potion.PotionEffectType.FIRE_RESISTANCE,
40, 0, false, false, true
));
}
if (godMaceItem.isStormMace(hand)) {
p.addPotionEffect(new org.bukkit.potion.PotionEffect(
org.bukkit.potion.PotionEffectType.SPEED,
40, 2, false, false, true
));
}
}
}, 0L, 20L);
// Remove vanilla mace recipe
Bukkit.removeRecipe(NamespacedKey.minecraft("mace"));
// Thunder Mace Recipe
NamespacedKey thunderKey = new NamespacedKey(this, "thunder_mace");
ShapedRecipe thunderRecipe = new ShapedRecipe(thunderKey, godMaceItem.createThunderMace());
thunderRecipe.shape("LBL", "EHE", "DDD");
thunderRecipe.setIngredient('L', Material.LIGHTNING_ROD);
thunderRecipe.setIngredient('B', Material.BREEZE_ROD);
thunderRecipe.setIngredient('E', Material.EMERALD);
thunderRecipe.setIngredient('H', Material.HEAVY_CORE);
thunderRecipe.setIngredient('D', Material.DIAMOND_BLOCK);
Bukkit.addRecipe(thunderRecipe);
// Flame Mace Recipe
NamespacedKey flameKey = new NamespacedKey(this, "flame_mace");
ShapedRecipe flameRecipe = new ShapedRecipe(flameKey, godMaceItem.createFlameMace());
flameRecipe.shape("BBB", "BFF", " H ");
flameRecipe.setIngredient('B', Material.BLAZE_ROD);
flameRecipe.setIngredient('F', Material.FIRE_CHARGE);
flameRecipe.setIngredient('H', Material.HEAVY_CORE);
Bukkit.addRecipe(flameRecipe);
// Frost Mace Recipe
NamespacedKey frostKey = new NamespacedKey(this, "frost_mace");
ShapedRecipe frostRecipe = new ShapedRecipe(frostKey, godMaceItem.createFrostMace());
frostRecipe.shape("III", "IHW", "WB ");
frostRecipe.setIngredient('I', Material.ICE);
frostRecipe.setIngredient('H', Material.HEAVY_CORE);
frostRecipe.setIngredient('W', Material.WATER_BUCKET);
frostRecipe.setIngredient('B', Material.BREEZE_ROD);
Bukkit.addRecipe(frostRecipe);
// Doom Mace Recipe
NamespacedKey doomKey = new NamespacedKey(this, "doom_mace");
ShapedRecipe doomRecipe = new ShapedRecipe(doomKey, godMaceItem.createDoomMace());
doomRecipe.shape("NNN", "CCC", "HBB");
doomRecipe.setIngredient('N', Material.NETHERITE_INGOT);
doomRecipe.setIngredient('C', Material.DEEPSLATE_COAL_ORE);
doomRecipe.setIngredient('H', Material.HEAVY_CORE);
doomRecipe.setIngredient('B', Material.BREEZE_ROD);
Bukkit.addRecipe(doomRecipe);
// Storm Mace Recipe
NamespacedKey stormKey = new NamespacedKey(this, "storm_mace");
ShapedRecipe stormRecipe = new ShapedRecipe(stormKey, godMaceItem.createStormMace());
stormRecipe.shape("WWW", "NHB", "TBD");
stormRecipe.setIngredient('W', Material.WIND_CHARGE);
stormRecipe.setIngredient('N', Material.NETHERITE_INGOT);
stormRecipe.setIngredient('H', Material.HEAVY_CORE);
stormRecipe.setIngredient('B', Material.BREEZE_ROD);
stormRecipe.setIngredient('T', Material.TRIDENT);
stormRecipe.setIngredient('D', Material.DIAMOND);
Bukkit.addRecipe(stormRecipe);
// Void Mace Recipe
NamespacedKey voidKey = new NamespacedKey(this, "void_mace");
ShapedRecipe voidRecipe = new ShapedRecipe(voidKey, godMaceItem.createVoidMace());
voidRecipe.shape("NNN", "DHD", "DDD");
voidRecipe.setIngredient('N', Material.NETHERITE_INGOT);
voidRecipe.setIngredient('D', Material.DIAMOND_BLOCK);
voidRecipe.setIngredient('H', Material.HEAVY_CORE);
Bukkit.addRecipe(voidRecipe);
// Lunge Mace Recipe
NamespacedKey lungeKey = new NamespacedKey(this, "lunge_mace");
ShapedRecipe lungeRecipe = new ShapedRecipe(lungeKey, godMaceItem.createLungeMace());
lungeRecipe.shape("EEE", "EHE", "EEE");
lungeRecipe.setIngredient('E', Material.EMERALD_BLOCK);
lungeRecipe.setIngredient('H', Material.HEAVY_CORE);
Bukkit.addRecipe(lungeRecipe);
// God Mace Recipe
NamespacedKey godKey = new NamespacedKey(this, "god_mace");
ShapedRecipe godRecipe = new ShapedRecipe(godKey, godMaceItem.create());
godRecipe.shape("SLF", "TNM", "VED");
godRecipe.setIngredient('S', new RecipeChoice.ExactChoice(godMaceItem.createStormMace()));
godRecipe.setIngredient('L', new RecipeChoice.ExactChoice(godMaceItem.createLungeMace()));
godRecipe.setIngredient('F', new RecipeChoice.ExactChoice(godMaceItem.createFrostMace()));
godRecipe.setIngredient('T', new RecipeChoice.ExactChoice(godMaceItem.createThunderMace()));
godRecipe.setIngredient('N', Material.NETHERITE_BLOCK);
godRecipe.setIngredient('M', new RecipeChoice.ExactChoice(godMaceItem.createFlameMace()));
godRecipe.setIngredient('V', new RecipeChoice.ExactChoice(godMaceItem.createVoidMace()));
godRecipe.setIngredient('E', Material.NETHER_STAR);
godRecipe.setIngredient('D', new RecipeChoice.ExactChoice(godMaceItem.createDoomMace()));
Bukkit.addRecipe(godRecipe);
getLogger().info("GodMace enabled!");
}
@Override
public void onDisable() {
getLogger().info("GodMace disabled!");
}
public GodMaceItem getGodMaceItem() {
return godMaceItem;
}
public MaceTracker getMaceTracker() {
return maceTracker;
}
public String color(String text) {
return text == null ? "" : org.bukkit.ChatColor.translateAlternateColorCodes('&', text);
}
// === Cooldowns ===
public boolean isOnCooldown(Player p, Map<UUID, Long> map, long ms) {
long now = System.currentTimeMillis();
long last = map.getOrDefault(p.getUniqueId(), 0L);
return (now - last) < ms;
}
public void setCooldown(Player p, Map<UUID, Long> map) {
map.put(p.getUniqueId(), System.currentTimeMillis());
}
public Map<UUID, Long> getAirLaunchCooldown() {
return airLaunchCooldown;
}
public Map<UUID, Long> getDashCooldown() {
return dashCooldown;
}
public Map<UUID, Integer> getSoulReaperHits() {
return soulReaperHits;
}
public Map<UUID, Boolean> getSoulReaperReady() {