|
@@ -137,19 +137,21 @@ function player.teleport(player, location, backPos) {
|
|
|
if(backPos) {
|
|
|
player.setBackPos(player);
|
|
|
}
|
|
|
+ from_location = entity.getLocation(player);
|
|
|
+ from_world_name = world.getName(loc.getWorld(from_location));
|
|
|
inv.checkForChange(player, location);
|
|
|
entity.teleport(player, location);
|
|
|
world = loc.getWorld(location);
|
|
|
display.reset(player);
|
|
|
- entity.setName(player, player.getName(player));
|
|
|
- world_name = world.getName(world);
|
|
|
- if(isGamesWorldName(world_name)) {
|
|
|
+ player.setHeadName(player);
|
|
|
+ to_world_name = world.getName(world);
|
|
|
+ if(isGamesWorldName(to_world_name)) {
|
|
|
joinGamesWorld(player);
|
|
|
}
|
|
|
- if(isSurvWorldName(world_name)) {
|
|
|
+ if(isSurvWorldName(to_world_name)) {
|
|
|
joinSurvWorld(player);
|
|
|
}
|
|
|
- if(world.isCreativeWorldName(world_name)) {
|
|
|
+ if(world.isCreativeName(to_world_name)) {
|
|
|
world.joinCreative(player);
|
|
|
}
|
|
|
//Tabliste
|
|
@@ -287,7 +289,7 @@ function world.joinCreative(player) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-function world.isCreativeWorldName(world_name) {
|
|
|
+function world.isCreativeName(world_name) {
|
|
|
return world_name == "creative";
|
|
|
}
|
|
|
|
|
@@ -317,6 +319,16 @@ function inv.checkForChange(player, location) {
|
|
|
return;
|
|
|
}
|
|
|
//Weltwechsel
|
|
|
+ script_id = quest.getFromPlayer(player);
|
|
|
+ if(script_id != null) {
|
|
|
+ script = script.getFromId(script_id);
|
|
|
+ if(script != null) {
|
|
|
+ setScriptVar("player", player);
|
|
|
+ script.callEvent("quest_term", script);
|
|
|
+ quest.term(script, player);
|
|
|
+ msg.prefix(player, "§dQuest", "Quest termed.");
|
|
|
+ }
|
|
|
+ }
|
|
|
entity.clearEffects(player);
|
|
|
inv.saveForPlayer(player, player, from_world);
|
|
|
inv.loadFromPlayer(player, player, to_world);
|
|
@@ -1108,7 +1120,7 @@ function playerdata.getSurvival(player_or_id) {
|
|
|
player_id = player_or_id;
|
|
|
loadData(player_id, getScriptVar("survival_data"), "survival_data");
|
|
|
}
|
|
|
- //On player_login data is needed, but the data isn't loaded yet, so the config can be null at this point
|
|
|
+ //On player_login data is needed, but the data isn't loaded yet. So the config can be null at this point. That's why else {} already do loadData.
|
|
|
config = map.get(getScriptVar("survival_data"), player_id);
|
|
|
if(config == null) {
|
|
|
loadData(player_id, getScriptVar("survival_data"), "survival_data");
|
|
@@ -1124,7 +1136,7 @@ function playerdata.getGames(player_or_id) {
|
|
|
player_id = player_or_id;
|
|
|
loadData(player_id, getScriptVar("games_data"), "games_data");
|
|
|
}
|
|
|
- //On player_login data is needed, but the data isn't loaded yet, so the config can be null at this point
|
|
|
+ //On player_login data is needed, but the data isn't loaded yet. So the config can be null at this point. That's why else {} already do loadData.
|
|
|
config = map.get(getScriptVar("games_data"), player_id);
|
|
|
if(config == null) {
|
|
|
loadData(player_id, getScriptVar("games_data"), "games_data");
|
|
@@ -1231,7 +1243,7 @@ function player.sendMessage(from_player, to_name, prefix, message, send_mail) {
|
|
|
if(p == null) {
|
|
|
mail.send(player.getName(from_player), to_name, message);
|
|
|
} elseif(send_mail) {
|
|
|
- player.speakPrefix(p, prefix, message);
|
|
|
+ msg.prefix(p, prefix, message);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1242,7 +1254,7 @@ function speakPrefix(player, prefix, message) { //Deprecated
|
|
|
function player.speakPrefix(player, prefix, message) { //Deprecated
|
|
|
msg.prefix(player, prefix, message);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function msg.prefix(player, prefix, message) {
|
|
|
msg(player, concat("§r[", prefix, "§r] ", message));
|
|
|
}
|
|
@@ -1251,7 +1263,7 @@ function msg.radius(prefix, message, location, radius) {
|
|
|
list = players.near(location, radius);
|
|
|
iter = list.iterator(list);
|
|
|
while(hasNext(iter)) {
|
|
|
- player.speakPrefix(next(iter), prefix, message);
|
|
|
+ msg.prefix(next(iter), prefix, message);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1348,6 +1360,12 @@ function player.setBackPos(player) {
|
|
|
config.saveAsync(config);
|
|
|
}
|
|
|
|
|
|
+function player.setBackPosLoc(player, location) {
|
|
|
+ config = playerdata.getSurvival(player);
|
|
|
+ config.set(config, "backpos", text.location(location));
|
|
|
+ config.saveAsync(config);
|
|
|
+}
|
|
|
+
|
|
|
function player.clearBackPos(player) {
|
|
|
config = playerdata.getSurvival(player);
|
|
|
config.set(config, "backpos", "null");
|
|
@@ -1424,6 +1442,62 @@ function player.invIgnore(player_or_id, boolean) {
|
|
|
config.saveAsync(config);
|
|
|
}
|
|
|
|
|
|
+function player.getClanId(player_or_id) {
|
|
|
+ config = playerdata.getSurvival(player_or_id);
|
|
|
+ return config.getDouble(config, "clan_id", -1);
|
|
|
+}
|
|
|
+
|
|
|
+function player.setClanId(player_or_id, clan_id) {
|
|
|
+ config = playerdata.getSurvival(player_or_id);
|
|
|
+ config.set(config, "clan_id", clan_id);
|
|
|
+ config.saveAsync(config);
|
|
|
+}
|
|
|
+
|
|
|
+function player.getClanRole(player_or_id) {
|
|
|
+ config = playerdata.getSurvival(player_or_id);
|
|
|
+ return config.getString(config, "clan_role", "null");
|
|
|
+}
|
|
|
+
|
|
|
+function player.setClanRole(player_or_id, clan_id) {
|
|
|
+ config = playerdata.getSurvival(player_or_id);
|
|
|
+ config.set(config, "clan_role", clan_id);
|
|
|
+ config.saveAsync(config);
|
|
|
+}
|
|
|
+
|
|
|
+function player.isInClan(player_or_id) {
|
|
|
+ return player.getClanId(player_or_id) >= 0;
|
|
|
+}
|
|
|
+
|
|
|
+function player.isClanLeader(player_or_id) {
|
|
|
+ return player.getClanRole(player_or_id) == "leader";
|
|
|
+}
|
|
|
+
|
|
|
+function player.isClanMod(player_or_id) {
|
|
|
+ return player.getClanRole(player_or_id) == "mod";
|
|
|
+}
|
|
|
+
|
|
|
+function player.isClanMember(player_or_id) {
|
|
|
+ return player.getClanRole(player_or_id) == "member";
|
|
|
+}
|
|
|
+
|
|
|
+function player.isSameClan(player_or_id_1, player_or_id_2) {
|
|
|
+ id_1 = player.getClanId(player_or_id_1);
|
|
|
+ id_2 = player.getClanId(player_or_id_2);
|
|
|
+ if(id_1 < 0 || id_2 < 0) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return id_1 == id_2;
|
|
|
+}
|
|
|
+
|
|
|
+function player.setHeadName(player) {
|
|
|
+ player_name = player.getName(player);
|
|
|
+ clan_string = "";
|
|
|
+ if(player.isInClan(player)) {
|
|
|
+ clan_id = player.getClanId(player);
|
|
|
+ clan_string = text.concat(" [§6", clan.getTag(clan_id), "§r]");
|
|
|
+ }
|
|
|
+ entity.setName(player, text.concat(player_name, clan_string));
|
|
|
+}
|
|
|
|
|
|
function player.setAdventureAmounts(player_or_id, amount) {
|
|
|
config = playerdata.getSurvival(player_or_id);
|
|
@@ -1702,6 +1776,16 @@ function plot.getIdFromLocation(location) {
|
|
|
return plot_id;
|
|
|
}
|
|
|
|
|
|
+function plot.getIdListFromLocation(location) {
|
|
|
+ list = plot.get(location);
|
|
|
+ for(i = 0; i < list.getSize(list); i++) {
|
|
|
+ plot = list.getIndex(list, i);
|
|
|
+ list.setIndex(list, i, plot.getId(plot));
|
|
|
+
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+}
|
|
|
+
|
|
|
function plot.addPlayer(plot, player_name) {
|
|
|
list = plot.getOwners(plot);
|
|
|
uuid = player.getUuid(player_name);
|
|
@@ -2025,6 +2109,10 @@ function skill.showShop(player, skill_name1, skill_name2, skill_name3, skill_nam
|
|
|
//Loc-Utils
|
|
|
//--------------------------------------------------
|
|
|
|
|
|
+function loc.hasPlotId(location, plot_id) {
|
|
|
+ return list.contains(plot.getIdListFromLocation(location), plot_id);
|
|
|
+}
|
|
|
+
|
|
|
function loc.isAir(location) {
|
|
|
type = block.getType(location);
|
|
|
return type == "minecraft:air" || type == "minecraft:cave_air";
|
|
@@ -2066,7 +2154,7 @@ function joinGamesWorld(player) {
|
|
|
}
|
|
|
|
|
|
function minigame.displayElo(player, elo) {
|
|
|
- display.add(player, 101, concat("§b§tElo: §r", text.number(elo)));
|
|
|
+ display.add(player, 101, concat("§bElo: §r", text.number(elo)));
|
|
|
}
|
|
|
|
|
|
function minigame.setElo(player_or_id, elo) {
|
|
@@ -2090,7 +2178,7 @@ function minigame.addElo(player_or_id, elo) {
|
|
|
config.saveAsync(config);
|
|
|
if(isPlayer(player_or_id)) {
|
|
|
minigame.displayElo(player_or_id, new_elo);
|
|
|
- player.speakPrefix(player_or_id, "§b§tElo", concat("§r+§e", text.number(elo)));
|
|
|
+ msg.prefix(player_or_id, "§bElo", concat("§r+§e", text.number(elo)));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2281,7 +2369,7 @@ function mail.send(from_name, to_name, message) {
|
|
|
//Wenn Spieler online, dann Pushmeldung veranlassen
|
|
|
p = read.player(to_name);
|
|
|
if(p != null) {
|
|
|
- player.speak(p, "§bMail", concat("§rYou´ve got a new mail from §b", from_name, "."));
|
|
|
+ msg.prefix(p, "§bMail", concat("§rYou´ve got a new mail from §b", from_name, "."));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2305,9 +2393,9 @@ function mail.checkForNew(player) {
|
|
|
databank.close(stmt);
|
|
|
if(newmails > 0) {
|
|
|
if(newmails > 1) {
|
|
|
- player.speakPrefix(player, "§bMail", concat("§rYou´ve got §b", text.number(newmails), "§r new mails."));
|
|
|
+ msg.prefix(player, "§bMail", concat("§rYou´ve got §b", text.number(newmails), "§r new mails."));
|
|
|
} else {
|
|
|
- player.speakPrefix(player, "§bMail", "§rYou´ve got §b1 §rnew mail.");
|
|
|
+ msg.prefix(player, "§bMail", "§rYou´ve got §b1 §rnew mail.");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2370,4 +2458,264 @@ function friend.getList(player_id) {
|
|
|
databank.close(result);
|
|
|
databank.close(stmt);
|
|
|
return list;
|
|
|
+}
|
|
|
+
|
|
|
+//--------------------------------------------------
|
|
|
+//Clan-Utils
|
|
|
+//--------------------------------------------------
|
|
|
+
|
|
|
+function clan.getIdList() {
|
|
|
+ file = file.new("scripts/configs/clan_data");
|
|
|
+ if(file.exists(file) && file.isDirectory(file)) {
|
|
|
+ list = file.getList(file);
|
|
|
+ }
|
|
|
+ id_list = list.new();
|
|
|
+ iter = list.iterator(list);
|
|
|
+ while(hasNext(iter)) {
|
|
|
+ element = next(iter);
|
|
|
+ file_name = file.getName(element);
|
|
|
+ file_name = text.subString(file_name, 0, 1);
|
|
|
+ list.add(id_list, read.number(file_name));
|
|
|
+ }
|
|
|
+ return id_list;
|
|
|
+}
|
|
|
+
|
|
|
+function clan.loadData() {
|
|
|
+ list = clan.getIdList();
|
|
|
+ iter = list.iterator(list);
|
|
|
+ map = map.new();
|
|
|
+ while(hasNext(iter)) {
|
|
|
+ clan_id = next(iter);
|
|
|
+ config = config.new("scripts/configs/clan_data", clan_id);
|
|
|
+ if(config.exists(config)) {
|
|
|
+ config.load(config);
|
|
|
+ }
|
|
|
+ map.add(map, clan_id, config);
|
|
|
+ }
|
|
|
+ setScriptVar("clan_data", map);
|
|
|
+}
|
|
|
+
|
|
|
+function clan.getData(clan_id) {
|
|
|
+ if(clan_id == null) {
|
|
|
+ snuvi.debug("script termed. clan_id was null");
|
|
|
+ term();
|
|
|
+ }
|
|
|
+ map = getScriptVar("clan_data");
|
|
|
+ config = map.get(map, clan_id);
|
|
|
+ if(config == null) {
|
|
|
+ config = config.new("scripts/configs/clan_data", clan_id);
|
|
|
+ if(config.exists(config)) {
|
|
|
+ config.load(config);
|
|
|
+ }
|
|
|
+ map.add(map, clan_id, config);
|
|
|
+ }
|
|
|
+ return config;
|
|
|
+}
|
|
|
+
|
|
|
+function clan.setName(clan_id, name) {
|
|
|
+ config = clan.getData(clan_id);
|
|
|
+ config.set(config, "name", name);
|
|
|
+ config.saveAsync(config);
|
|
|
+}
|
|
|
+
|
|
|
+function clan.getName(clan_id) {
|
|
|
+ config = clan.getData(clan_id);
|
|
|
+ return config.getString(config, "name", "null");
|
|
|
+}
|
|
|
+
|
|
|
+function clan.setTag(clan_id, tag) {
|
|
|
+ config = clan.getData(clan_id);
|
|
|
+ config.set(config, "tag", tag);
|
|
|
+ config.saveAsync(config);
|
|
|
+}
|
|
|
+
|
|
|
+function clan.getTag(clan_id) {
|
|
|
+ config = clan.getData(clan_id);
|
|
|
+ return config.getString(config, "tag", "null");
|
|
|
+}
|
|
|
+
|
|
|
+function clan.setMoney(clan_id, money) {
|
|
|
+ config = clan.getData(clan_id);
|
|
|
+ config.set(config, "money", money);
|
|
|
+ config.saveAsync(config);
|
|
|
+}
|
|
|
+
|
|
|
+function clan.getMoney(clan_id) {
|
|
|
+ config = clan.getData(clan_id);
|
|
|
+ return config.getDouble(config, "money", 0);
|
|
|
+}
|
|
|
+
|
|
|
+function clan.addMoney(clan_id, money) {
|
|
|
+ config = clan.getData(clan_id);
|
|
|
+ new_money = config.getDouble(config, "money", 0) + money;
|
|
|
+ config.set(config, "money", new_money);
|
|
|
+ config.saveAsync(config);
|
|
|
+}
|
|
|
+
|
|
|
+function clan.subMoney(clan_id, money) {
|
|
|
+ config = clan.getData(clan_id);
|
|
|
+ new_money = config.getDouble(config, "money", 0) - money;
|
|
|
+ config.set(config, "money", new_money);
|
|
|
+ config.saveAsync(config);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function clan.getIdFromName(name) {
|
|
|
+ list = clan.getIdList();
|
|
|
+ iter = list.iterator(list);
|
|
|
+ while(hasNext(iter)) {
|
|
|
+ clan_id = next(iter);
|
|
|
+ if(clan.getName(clan_id) == name) {
|
|
|
+ return clan_id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+}
|
|
|
+
|
|
|
+function clan.getIdFromTag(clan_tag) {
|
|
|
+ list = clan.getIdList();
|
|
|
+ iter = list.iterator(list);
|
|
|
+ while(hasNext(iter)) {
|
|
|
+ clan_id = next(iter);
|
|
|
+ if(clan.getTag(clan_id) == clan_tag) {
|
|
|
+ return clan_id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+}
|
|
|
+
|
|
|
+function clan.isExistingTag(clan_tag) {
|
|
|
+ return !(clan.getIdFromTag(clan_tag) == null);
|
|
|
+}
|
|
|
+
|
|
|
+function clan.isExistingName(name) {
|
|
|
+ return !(clan.getIdFromName(name) == null);
|
|
|
+}
|
|
|
+
|
|
|
+function clan.getNextFreeId() {
|
|
|
+ server_config = getScriptVar("server_config");
|
|
|
+ id = config.getDouble(server_config, "clan.id.next", 0) + 1;
|
|
|
+ config.set(server_config, "clan.id.next", id);
|
|
|
+ config.saveAsync(server_config);
|
|
|
+ return id;
|
|
|
+}
|
|
|
+
|
|
|
+function clan.create(name, tag) {
|
|
|
+ clan_id = clan.getNextFreeId();
|
|
|
+ config = clan.getData(clan_id);
|
|
|
+ config.set(config, "name", name);
|
|
|
+ config.set(config, "tag", tag);
|
|
|
+ config.set(config, "members", 0);
|
|
|
+ config.save(config);
|
|
|
+ return clan_id;
|
|
|
+}
|
|
|
+
|
|
|
+function clan.getMembersAmount(clan_id) {
|
|
|
+ config = clan.getData(clan_id);
|
|
|
+ return config.getDouble(config, "members", 0);
|
|
|
+}
|
|
|
+
|
|
|
+function clan.setMembersAmount(clan_id, amount) {
|
|
|
+ config = clan.getData(clan_id);
|
|
|
+ config.set(config, "members", amount);
|
|
|
+ config.saveAsync(config);
|
|
|
+}
|
|
|
+
|
|
|
+function clan.addMember(clan_id, player_or_id, role) {
|
|
|
+ //Player
|
|
|
+ player.setClanId(player_or_id, clan_id);
|
|
|
+ player.setClanRole(player_or_id, role);
|
|
|
+ //Clan
|
|
|
+ new_amount = clan.getMembersAmount(clan_id) + 1;
|
|
|
+ if(isPlayer(player_or_id)) {
|
|
|
+ player_uuid = player.getUuid(player_or_id);
|
|
|
+ } else {
|
|
|
+ player_uuid = player.getUuidFromId(player_or_id);
|
|
|
+ }
|
|
|
+ config = clan.getData(clan_id);
|
|
|
+ config.set(config, text.concat("player_", new_amount), text(player_uuid));
|
|
|
+ config.set(config, "members", new_amount);
|
|
|
+ config.saveAsync(config);
|
|
|
+}
|
|
|
+
|
|
|
+function clan.removeMember(clan_id, player_or_id) {
|
|
|
+ //Player
|
|
|
+ player.setClanId(player_or_id, -1);
|
|
|
+ player.setClanRole(player_or_id, "null");
|
|
|
+ if(isPlayer(player_or_id)) {
|
|
|
+ player_uuid = player.getUuid(player_or_id);
|
|
|
+ } else {
|
|
|
+ player_uuid = player.getUuidFromId(player_or_id);
|
|
|
+ }
|
|
|
+ //Clan
|
|
|
+ config = clan.getData(clan_id);
|
|
|
+ amount = config.getDouble(config, "members", 0);
|
|
|
+ for(i = 1; i <= amount; i++) {
|
|
|
+ if(config.getString(config, text.concat("player_", i), "null") == text(player_uuid)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(i != amount) {
|
|
|
+ config.set(config, text.concat("player_", i), config.getString(config, text.concat("player_", amount), "null"));
|
|
|
+ }
|
|
|
+ config.set(config, text.concat("player_", amount), "null");
|
|
|
+ config.set(config, "members", amount - 1);
|
|
|
+ config.saveAsync(config);
|
|
|
+}
|
|
|
+
|
|
|
+function clan.delete(clan_id) {
|
|
|
+ //Members
|
|
|
+ list = clan.getMembersList(clan_id);
|
|
|
+ iter = list.iterator(list);
|
|
|
+ while(hasNext(iter)) {
|
|
|
+ player_uuid = next(iter);
|
|
|
+ player_id = player.getId(player_uuid);
|
|
|
+ player.setClanId(player_id, -1);
|
|
|
+ player.setClanRole(player_id, "null");
|
|
|
+ }
|
|
|
+ //Clan
|
|
|
+ config.delete(clan.getData(clan_id));
|
|
|
+ map.remove(getScriptVar("clan_data"), clan_id);
|
|
|
+}
|
|
|
+
|
|
|
+function clan.getMembersList(clan_id) {
|
|
|
+ list = list.new();
|
|
|
+ config = clan.getData(clan_id);
|
|
|
+ amount = config.getDouble(config, "members", 0);
|
|
|
+ for(i = 1; i <= amount; i++) {
|
|
|
+ player_uuid = read.uuid(config.getString(config, text.concat("player_", i), "null"));
|
|
|
+ list.add(list, player_uuid);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+}
|
|
|
+
|
|
|
+function clan.updateHeadNames(clan_id) {
|
|
|
+ list = clan.getMembersList(clan_id);
|
|
|
+ iter = list.iterator(list);
|
|
|
+ while(hasNext(iter)) {
|
|
|
+ p = player.get(next(iter));
|
|
|
+ if(p != null) {
|
|
|
+ player.setHeadName(p);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function clan.msg(clan_id, message) {
|
|
|
+ list = clan.getMembersList(clan_id);
|
|
|
+ iter = list.iterator(list);
|
|
|
+ while(hasNext(iter)) {
|
|
|
+ p = player.get(next(iter));
|
|
|
+ if(p != null) {
|
|
|
+ msg.prefix(p, "§2Clan", message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function clan.mail(clan_id, from_name, message) {
|
|
|
+ list = clan.getMembersList(clan_id);
|
|
|
+ iter = list.iterator(list);
|
|
|
+ while(hasNext(iter)) {
|
|
|
+ to_name = player.getName(next(iter));
|
|
|
+ mail.send(from_name, to_name, message);
|
|
|
+ }
|
|
|
}
|