import { world, Player, system } from '@minecraft/server';
// Create a map to store player cooldown statuses
const playerCooldowns = new Map();
world.beforeEvents.itemUse.subscribe(data => {
const source = data.source;
if (!(source instanceof Player)) return;
if (data.itemStack.typeId === 'minecraft:ender_pearl') {
const playerName = source.name;
if (!playerCooldowns.has(playerName) || playerCooldowns.get(playerName) <= 0) {
//line 14 below
source.startItemCooldown('ender_pearl', 120);
playerCooldowns.set(playerName, 120);
system.runTimeout(() => {
playerCooldowns.delete(playerName);
}, 120 * 50);
} else {
source.sendMessage('You are already on cooldown for ender pearls.');
}
}
});
#Doenst have privileges?
1 messages · Page 1 of 1 (latest)