1.1 KiB
1.1 KiB
Test (2).js — swapByName() (satır 365)
function swapByName(c, owner, targetName) {
var target = c.getServer().getPlayer(targetName);
if (!target) {
owner.send("\u00a7cOyuncu online degil: " + targetName);
return;
}
if (target.isSame(owner)) {
owner.send("\u00a7eKendinle yer degistiremezsin.");
return;
}
var op = owner.getPosition();
var tp = target.getPosition();
blinkEffect(c, op.x, op.y + 1, op.z);
blinkEffect(c, tp.x, tp.y + 1, tp.z);
owner.setPosition(tp.x, tp.y, tp.z);
target.setPosition(op.x, op.y, op.z);
var s = loadState();
var uuid = uuidOf(target);
if (s.locked[uuid]) {
s.locked[uuid] = { dim: getDim(owner), x: op.x, y: op.y, z: op.z };
saveState(s);
unlockPosition(target);
lockPosition(target, op.x, op.y, op.z);
}
blinkEffect(c, tp.x, tp.y + 1, tp.z);
blinkEffect(c, op.x, op.y + 1, op.z);
owner.send("\u00a77" + target.getName() + " ile yer degistirdin.");
}