zd_shardks

MUTI POTION – FULL SPEC

---

  1. OVERVIEW

Plugin gồm:

  1. Potion Combine (INVENTORY GUI qua cauldron)
  2. Special Upgrade (Level III)
  3. Witch Hunter Sword
  4. Anti-Hunter Netherite Set
  5. Command /potionmenu

---

  1. CAULDRON INTERACT

Event: PlayerInteractEvent

Condition:

  • RIGHT_CLICK_BLOCK
  • block = CAULDRON hoặc WATER_CAULDRON

Logic:

  • Nếu item là BUCKET hoặc GLASS_BOTTLE → return (không cancel)
  • Ngược lại:

- event.setCancelled(true) - open INVENTORY GUI "Alchemy"

---

  1. INVENTORY GUI (ALCHEMY)

Inventory size: 27

Slots:

  • 10,12,14 → input
  • 16 → result

Rules:

  • chỉ nhận item có PotionMeta
  • chặn shift-click
  • chặn drag

---

  1. DATA TAG (PersistentDataContainer)

Keys:

  • combined = 1 → potion đã combine
  • enhanced = 1 → potion cấp 3
  • witch_hunter = 1 → kiếm hunter
  • anti_hunter = 1 → giáp chống hunter

---

  1. VALIDATION

Khi update result:

  • lấy potion từ slot 10,12,14
  • count >= 2

Tất cả phải:

  • chưa combined
  • chưa enhanced

Sai → result = null

---

  1. SPECIAL RECIPE (ƯU TIÊN)

Điều kiện:

  • đúng 3 potion
  • mỗi potion:

- chỉ 1 effect - amplifier = 1 (Level II) - cùng type - chưa combined

Result:

  • amplifier = 2 (Level III)
  • duration = 60s (1200 ticks)
  • set enhanced = 1

Không cho combine tiếp

Return luôn (không chạy combine thường)

---

  1. COMBINE THƯỜNG
  • gom tất cả effect
  • nếu trùng type:

→ giữ amplifier cao nhất

Nếu tổng effect > 3: → result = null

---

  1. DURATION
  • luôn set = 90s (1800 ticks)
  • không dùng duration gốc

---

  1. CREATE RESULT
  • base = clone potion đầu tiên (giữ splash/lingering)
  • set effect mới
  • set combined = 1

---

  1. NAME + LORE

Name:

  • join tên potion: "A + B (+ C)"

Lore:

  • format:

Effect Level (mm:ss)

---

  1. CLICK RESULT
  • remove input trước
  • sau đó add result vào player

---

  1. INVENTORY CLOSE
  • trả lại toàn bộ input

---

  1. ANTI BUG (INVENTORY GUI)

InventoryClickEvent:

  • cancel nếu không phải slot input/result
  • cancel shift-click

InventoryDragEvent:

  • cancel

Null check:

  • item != null
  • meta != null

Không dùng async

---

  1. WITCH HUNTER

Event: EntityDamageByEntityEvent

Condition:

  • attacker là player
  • weapon có tag witch_hunter
  • target là player

Nếu target có buff: → damage = base * 1.5

Không bypass armor/resistance

---

  1. ANTI-HUNTER (FULL SET)

Armor:

  • full NETHERITE (4 món)
  • mỗi món có tag anti_hunter

Function: isWearingFullAntiHunter(player)

---

DAMAGE LOGIC

Flow:

  • nếu không phải witch hunter → return
  • base = event.getDamage()

Nếu target mặc full set: → event.setDamage(base) → return

Ngược lại: → event.setDamage(base * 1.5)

---

  1. /POTIONMENU

Command: /potionmenu

Open INVENTORY GUI size 27

Slots:

  • 11 → Witch Hunter Sword
  • 15 → Full Anti-Hunter Set

Cancel toàn bộ click

---

GIVE ITEM

Slot 11: → give sword (tag witch_hunter)

Slot 15: → give 4 món netherite (tag anti_hunter)

Check inventory:

  • nếu full → không give

---

  1. ITEM META

Witch Hunter:

  • name: "§5Witch Hunter Blade"

Anti-Hunter:

  • name: "§bHunter Guard Armor"

Không dùng name để check → chỉ dùng tag

---

  1. EDGE CASE TEST
  • spam click INVENTORY GUI
  • shift-click
  • drag
  • full inventory
  • đóng INVENTORY GUI
  • potion cấp 3 làm input
  • armor bị tháo giữa combat
  • chết khi đang dùng INVENTORY GUI

---

  1. NGUYÊN TẮC
  • luôn validate server-side
  • không tin client
  • không dùng recipe plugin
  • chỉ dùng event + data tag

---

END

Kodari AI
KodariMar 22 at 6:58 am 18,130 (v2)

I’ll create a comprehensive potion combining plugin with GUI-based alchemy, special Level III upgrades, and Witch Hunter combat mechanics.

MutiPotion
An advanced potion system featuring cauldron-based alchemy GUI for combining potions with intelligent effect merging, special Level III potion upgrades, Witch Hunter sword mechanics that deal bonus damage to buffed players, and Anti-Hunter netherite armor set for protection. Includes persistent data tracking and inventory management with edge case handling.

All files created successfully! The MutiPotion plugin includes:

  • Cauldron-based Alchemy GUI with 3 input slots and 1 result slot

  • Special Recipe System for Level III potions (3 identical Level II potions → 1 Level III with 60s duration)

  • Normal Combining merges up to 3 effects with 90s duration, keeping highest amplifiers

  • Witch Hunter Sword deals 1.5x damage to players with active potion effects

  • Anti-Hunter Armor Set (full netherite) negates witch hunter bonus damage

  • PersistentDataContainer tags for tracking combined/enhanced potions and special items

  • Edge case protections including shift-click blocking, drag prevention, full inventory checks, and item return on GUI close

zd_shardks

MUTI POTION – FULL FIX

---

  1. INVENTORY GUI SETUP
  • Fill toàn bộ bằng GRAY_STAINED_GLASS_PANE (name = " ")
  • Clear slot: 10, 12, 14 (input), 16 (result)
  • Slot 16 mặc định:

→ LIME_STAINED_GLASS_PANE ("§aResult")

---

  1. CLICK LOGIC

Event: InventoryClickEvent

  • dùng getRawSlot()

Rules:

  • Slot 10,12,14:

- chỉ cho PotionMeta - item khác → cancel

  • Slot 16:

- xử lý lấy result

  • Slot khác:

- cancel

  • Nếu clickedItem là GLASS_PANE → cancel

---

  1. UPDATE RESULT
  • luôn update bằng scheduler (runTask)
  • nếu hợp lệ:

→ set potion

  • nếu không:

→ set lại glass

---

  1. VALIDATION
  • lấy potion từ slot 10,12,14
  • count >= 2
  • tất cả:

- chưa combined - chưa enhanced

---

  1. SPECIAL RECIPE FIX (LEVEL 3)

LẤY DATA ĐÚNG

PotionMeta meta = (PotionMeta) item.getItemMeta(); PotionData data = meta.getBasePotionData();

PotionEffectType type = data.getType().getEffectType(); boolean isLevel2 = data.isUpgraded();

---

CHECK

  • đúng 3 potion
  • tất cả:

- isLevel2 == true - cùng type - chưa combined/enhanced

---

CREATE RESULT

PotionMeta rMeta = (PotionMeta) result.getItemMeta();

rMeta.clearCustomEffects();

rMeta.addCustomEffect( new PotionEffect(type, 1200, 2), // level 3, 60s true );

setTag(rMeta, "enhanced", 1);

---

  1. COMBINE FIX
  • loop tất cả potion
  • lấy:

- customEffects - basePotionData (convert thành effect)

  • nếu trùng:

→ giữ amplifier cao nhất

  • add:

addCustomEffect(effect, true)

  • nếu >3 effect:

→ fail

---

  1. DURATION
  • combine thường: 90s (1800 ticks)
  • level 3: 60s (1200 ticks)
  • luôn override

---

  1. HUNTER FIX

Event: EntityDamageByEntityEvent

  • damager là player
  • weapon có tag witch_hunter
  • target là LivingEntity

Logic:

double base = event.getDamage();

if (!entity.getActivePotionEffects().isEmpty()) { event.setDamage(base * 1.5); } else { event.setDamage(base); }

---

  1. ANTI-HUNTER FIX
  • nếu target là player và mặc full set anti_hunter:

→ event.setDamage(base)

(override luôn bonus)

---

  1. ANTI BUG
  • không cancel toàn bộ click
  • không dùng getSlot()
  • luôn check:

item != null meta != null

  • remove input trước khi give result
  • chặn:

- shift-click - drag

---

  1. EDGE FIX
  • dùng getBasePotionData() cho potion vanilla
  • không rely vào customEffects
  • không dùng async cho inventory

---

END

Kodari AI
KodariMar 22 at 7:42 am 18,423 (v2)

I’ll analyze the existing code and implement a complete fix according to your specifications.

I’ll implement the complete fix according to all your specifications.

All fixes implemented:

GUI System:

  • Filled with GRAY_STAINED_GLASS_PANE (name = " ")

  • Input slots (10,12,14) cleared

  • Result slot (16) defaults to LIME_STAINED_GLASS_PANE (“§aResult”)

  • Uses getRawSlot() instead of getSlot()

  • Validates PotionMeta for input slots only

  • Blocks shift-click and drag events

  • Checks if clicked item is glass pane and cancels

Potion Logic:

  • Special recipe validates exactly 3 level-2 potions using PotionData.isUpgraded()

  • Gets effects from both customEffects and basePotionData

  • Level 3 potions: 60s duration (1200 ticks), amplifier 2

  • Combined potions: 90s duration (1800 ticks), keeps highest amplifier

  • Max 3 effects for combined potions

Witch Hunter:

  • Works with any LivingEntity target

  • Checks if target has active potion effects

  • Multiplies damage by 1.5 if target has effects

  • Full anti_hunter armor set overrides bonus back to base damage

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
15 1,033
src/main/java/com/mutipotion/MutiPotion.java
package com.mutipotion;

import com.mutipotion.command.PotionMenuCommand;
import com.mutipotion.inventory.gui.GUIListener;
import com.mutipotion.inventory.gui.GUIManager;
import com.mutipotion.listener.CauldronListener;
import com.mutipotion.listener.WitchHunterListener;
import lombok.Getter;
import org.bukkit.NamespacedKey;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class MutiPotion extends JavaPlugin {
    private GUIManager guiManager;
    private NamespacedKey combinedKey;
    private NamespacedKey enhancedKey;
    private NamespacedKey witchHunterKey;
    private NamespacedKey antiHunterKey;

    @Override
    public void onEnable() {
        this.combinedKey = new NamespacedKey(this, "combined");
        this.enhancedKey = new NamespacedKey(this, "enhanced");
        this.witchHunterKey = new NamespacedKey(this, "witch_hunter");
        this.antiHunterKey = new NamespacedKey(this, "anti_hunter");

        this.guiManager = new GUIManager();

        getServer().getPluginManager().registerEvents(new GUIListener(guiManager), this);
        getServer().getPluginManager().registerEvents(new CauldronListener(this), this);
        getServer().getPluginManager().registerEvents(new WitchHunterListener(this), this);

        getCommand("potionmenu").setExecutor(new PotionMenuCommand(this));

        getLogger().info("MutiPotion has been enabled!");
    }

    @Override
    public void onDisable() {
        getLogger().info("MutiPotion has been disabled!");
    }
}