make this an anarchy type smp plugin based on bliss/infuse smp
📎
1 file
7,971 chars
📄
pasted-code-1775657355106.txt
txt
371 lines
▶
pasted-code-1775657355106.txt
txt
371 lines
/*
=========================================
INFUSE SMP - FULL CORE PLUGIN
=========================================
FEATURES:
✔ 3 Ability Slot System (INVENTORY GUI)
✔ Physical ability items (PDC IDs)
✔ Cooldown system
✔ 1-step upgrade system
✔ Death drops 1 random ability
✔ Kill reward ability drops
✔ /infuse admin commands
✔ /infusesmp start event (circle reroll)
✔ Rarity system
✔ Anti-dupe safety
=========================================
*/
// =======================
// ABILITY DATABASE
// =======================
const ABILITIES = {
"ember_pulse": {
name: "§cEmber Pulse Core",
material: "NETHER_STAR",
cooldown: 25,
upgraded: "ash_implosion",
rarity: "common"
},
"ash_implosion": {
name: "§4Ash Implosion Core",
material: "NETHER_STAR",
cooldown: 30,
upgraded: null,
rarity: "rare"
},
"dash": {
name: "§bDash Core",
material: "FEATHER",
cooldown: 12,
upgraded: "triple_dash",
rarity: "common"
},
"triple_dash": {
name: "§3Triple Dash Core",
material: "FEATHER",
cooldown: 16,
upgraded: null,
rarity: "rare"
},
"phantom_escape": {
name: "§5Phantom Escape Core",
material: "ENDER_PEARL",
cooldown: 35,
upgraded: "phase_shift",
rarity: "rare"
},
"phase_shift": {
name: "§dPhase Shift Core",
material: "ENDER_PEARL",
cooldown: 40,
upgraded: null,
rarity: "epic"
}
};
// =======================
// PLAYER DATA
// =======================
let data = {};
// structure:
// data[uuid] = {
// slots: [abilityId, abilityId, abilityId],
// cooldowns: { abilityId: timestamp }
// }
// =======================
// ITEM SYSTEM
// =======================
function createAbilityItem(id) {
let a = ABILITIES[id];
let item = createItem(a.material);
item.setName(a.name);
item.setLore([
"§7Right-click to use",
"§7Cooldown: " + a.cooldown + "s",
"§8Rarity: " + a.rarity,
"§8ID: " + id
]);
item.setTag("ability_id", id);
return item;
}
// =======================
// SLOT SYSTEM (MAX 3)
// =======================
function addAbility(player, id) {
let uuid = player.uuid;
if (!data[uuid]) data[uuid] = { slots: [], cooldowns: {} };
if (data[uuid].slots.includes(id)) return;
if (data[uuid].slots.length >= 3) {
player.sendMessage("§cMax 3 abilities!");
return;
}
data[uuid].slots.push(id);
}
// =======================
// COOLDOWN SYSTEM
// =======================
function isOnCooldown(player, id) {
let cd = data[player.uuid]?.cooldowns?.[id];
return cd && Date.now() < cd;
}
function setCooldown(player, id) {
data[player.uuid].cooldowns[id] =
Date.now() + (ABILITIES[id].cooldown * 1000);
}
function getCooldownLeft(player, id) {
let cd = data[player.uuid]?.cooldowns?.[id];
if (!cd) return 0;
return Math.ceil((cd - Date.now()) / 1000);
}
// =======================
// ABILITY USAGE
// =======================
onPlayerRightClick((player, item) => {
if (!item || !item.hasTag("ability_id")) return;
let id = item.getTag("ability_id");
if (!data[player.uuid]?.slots.includes(id)) {
player.sendMessage("§cAbility not equipped!");
return;
}
if (isOnCooldown(player, id)) {
player.sendMessage("§7Cooldown: " + getCooldownLeft(player, id) + "s");
return;
}
useAbility(player, id);
setCooldown(player, id);
});
// =======================
// ABILITY EFFECTS
// =======================
function useAbility(player, id) {
switch(id) {
case "ember_pulse":
spawnParticle("FLAME", player.location, 50);
damageNearby(player, 6, 5);
break;
case "ash_implosion":
pullNearby(player, 6);
explosion(player.location, 4);
break;
case "dash":
dashForward(player, 2);
break;
case "triple_dash":
dashForward(player, 2);
delay(10, () => dashForward(player, 2));
delay(20, () => dashForward(player, 2));
break;
case "phantom_escape":
giveInvisibility(player, 5);
giveSpeed(player, 5);
break;
case "phase_shift":
teleportRandom(player, 6);
break;
}
}
// =======================
// INVENTORY GUI SYSTEM (/infuse)
// =======================
command("infuse", (player, args) => {
if (!player.isOp()) {
player.sendMessage("§cNo permission.");
return;
}
openGUI(player);
});
function openGUI(player) {
let INVENTORY GUI = createGUI("Infuse Loadout", 27);
let uuid = player.uuid;
if (!data[uuid]) data[uuid] = { slots: [], cooldowns: {} };
let slots = data[uuid].slots;
for (let i = 0; i < 3; i++) {
if (slots[i]) {
INVENTORY GUI.setItem(i, createAbilityItem(slots[i]));
} else {
INVENTORY GUI.setItem(i, createItem("GRAY_STAINED_GLASS_PANE")
.setName("Empty Slot"));
}
}
INVENTORY GUI.onClick((slot, item) => {
if (!item || !item.hasTag("ability_id")) return;
let id = item.getTag("ability_id");
addAbility(player, id);
});
player.openGUI(INVENTORY GUI);
}
// =======================
// DEATH DROP SYSTEM
// =======================
onPlayerDeath((player, killer) => {
let uuid = player.uuid;
if (!data[uuid] || data[uuid].slots.length === 0) return;
let slots = data[uuid].slots;
let index = Math.floor(Math.random() * slots.length);
let abilityId = slots[index];
slots.splice(index, 1);
dropItem(player.location, createAbilityItem(abilityId));
player.sendMessage("§cYou lost: §7" + abilityId);
});
// =======================
// KILL REWARD SYSTEM
// =======================
onKill((killer, victim) => {
if (Math.random() <= 0.25) {
let keys = Object.keys(ABILITIES);
let id = keys[Math.floor(Math.random() * keys.length)];
giveItem(killer, createAbilityItem(id));
killer.sendMessage("§aYou found an ability core!");
}
});
// =======================
// /INFUSE SMP START EVENT
// =======================
command("infusesmp", (player, args) => {
if (!player.isOp()) return;
if (args[0] === "start") {
let players = getOnlinePlayers();
let center = players[0].getLocation();
let radius = 6;
broadcast("§5⚡ INFUSION RESET ⚡");
// circle formation
for (let i = 0; i < players.length; i++) {
let angle = (2 * Math.PI * i) / players.length;
let x = center.x + radius * Math.cos(angle);
let z = center.z + radius * Math.sin(angle);
let loc = location(center.world, x, center.y, z);
let p = players[i];
p.teleport(loc);
p.lookAt(center);
p.addPotionEffect("SLOW", 60, 255);
}
// reroll
delay(100, () => {
players.forEach(p => {
data[p.uuid].slots = [];
let keys = Object.keys(ABILITIES);
let random = keys[Math.floor(Math.random() * keys.length)];
addAbility(p, random);
giveAbilityCore(p, random);
p.sendTitle("§aNew Power", "§71 ability assigned", 10, 40, 10);
});
});
}
});
Kodari can make mistakes. Review important code before using.
Files
No files in this session
Code