|
@@ -1,3 +1,14 @@
|
|
|
+function sendOnlineMessage(player, message) {
|
|
|
+ nickname = player.getNickName(player);
|
|
|
+ rank = getRank(player);
|
|
|
+ colorcode = text.subString(rank, 0, 2);
|
|
|
+ msg("online", "[", text.hover(concat(colorcode, nickname), rank), "§r] §r", message);
|
|
|
+}
|
|
|
+
|
|
|
+function perm.no(player, perm) {
|
|
|
+ player.speak(player, "§zPerms", "You have no permission for §c", perm, ".");
|
|
|
+}
|
|
|
+
|
|
|
function checkIfEverOnline(player_name) {
|
|
|
if(player.getUuid(player_name) == null) {
|
|
|
return false;
|
|
@@ -218,16 +229,14 @@ function teleportPlayer(player, location, backPos) {
|
|
|
display.reset(player);
|
|
|
entity.setName(player, player.getName(player));
|
|
|
world_name = world.getName(world);
|
|
|
- if(world_name == "gpvp_spawn") {
|
|
|
- if(!registerGpvpPlayer(player)) {
|
|
|
- joinGpvpWorld(player);
|
|
|
- }
|
|
|
+ if(world_name == "games") {
|
|
|
+ joinGamesWorld(player);
|
|
|
}
|
|
|
if(isSurvWorldName(world_name)) {
|
|
|
joinSurvWorld(player);
|
|
|
}
|
|
|
//Tabliste
|
|
|
- nickname = map.getOrDefault(getScriptVar("nicknames"), player.getUuid(player), player.getName(player));
|
|
|
+ nickname = player.getNickName(player);
|
|
|
if(isAfk(player)) {
|
|
|
player.setDisplayName(player, concat("§7§m", nickname));
|
|
|
} else {
|
|
@@ -239,7 +248,7 @@ function teleportPlayer(player, location, backPos) {
|
|
|
}
|
|
|
|
|
|
function getBlockLocation(location) {
|
|
|
- world = world.get(loc.getCoord(location, "w"));
|
|
|
+ world = loc.getWorld(location, "w");
|
|
|
bx = loc.getCoord(location, "bx");
|
|
|
by = loc.getCoord(location, "by");
|
|
|
bz = loc.getCoord(location, "bz");
|
|
@@ -334,6 +343,85 @@ function getSurvivalSpawn() {
|
|
|
return read.location(config.getString(getScriptVar("server_config"), "surv_spawn", "games:0:0:0"));
|
|
|
}
|
|
|
|
|
|
+//--------------------------------------------------
|
|
|
+//Showcoords-Utils
|
|
|
+//--------------------------------------------------
|
|
|
+
|
|
|
+function showCoords.get(player_or_id) {
|
|
|
+ config = playerdata.getSurvival(player_or_id);
|
|
|
+ return config.getBool(config, "showcoords", false);
|
|
|
+}
|
|
|
+
|
|
|
+function showCoords.set(player_or_id, bool) {
|
|
|
+ config = playerdata.getSurvival(player_or_id);
|
|
|
+ config.set(config, "showcoords", bool);
|
|
|
+ config.saveAsync(config);
|
|
|
+}
|
|
|
+
|
|
|
+//--------------------------------------------------
|
|
|
+//Quest-Utils
|
|
|
+//--------------------------------------------------
|
|
|
+
|
|
|
+function msg.quest(player, speaker, line_now, line_max, message) {
|
|
|
+ msg(player, "[§b", text.number(line_now), "§r/§b", text.number(line_max), "§r] §a", speaker, " §r| ", concat("§e", message));
|
|
|
+}
|
|
|
+
|
|
|
+function quest.display(player, quest_name, stage, all_stages) {
|
|
|
+ sb.add(player, 1, concat("§dQuest: ", quest_name, " [", text.number(stage), "/", text.number(all_stages), "]"));
|
|
|
+}
|
|
|
+
|
|
|
+function quest.removeDisplay(player) {
|
|
|
+ sb.remove(player, 1);
|
|
|
+}
|
|
|
+
|
|
|
+function quest.addPlayer(script, player) {
|
|
|
+ quest_ids = getScriptVar("quest_ids");
|
|
|
+ map.add(quest_ids, player.getUuid(player), script.getId(script));
|
|
|
+}
|
|
|
+
|
|
|
+function quest.removePlayer(player) {
|
|
|
+ quest_ids = getScriptVar("quest_ids");
|
|
|
+ map.remove(quest_ids, player.getUuid(player));
|
|
|
+}
|
|
|
+
|
|
|
+function player.hasQuest2(player) {
|
|
|
+ quest_ids = getScriptVar("quest_ids");
|
|
|
+ return map.contains(quest_ids, player.getUuid(player));
|
|
|
+}
|
|
|
+
|
|
|
+function quest.getFromPlayer(player) {
|
|
|
+ quest_ids = getScriptVar("quest_ids");
|
|
|
+ return map.get(quest_ids, player.getUuid(player));
|
|
|
+}
|
|
|
+
|
|
|
+function quest.getCounter(player_or_id) {
|
|
|
+ config = playerdata.getSurvival(player_or_id);
|
|
|
+ return config.getDouble(config, "quests_solved", 0);
|
|
|
+}
|
|
|
+
|
|
|
+function quest.setCounter(player_or_id, amount) {
|
|
|
+ config = playerdata.getSurvival(player_or_id);
|
|
|
+ config.set(config, "quests_solved", amount);
|
|
|
+ config.saveAsync(config);
|
|
|
+}
|
|
|
+
|
|
|
+function quest.addCounter(player_or_id, amount) {
|
|
|
+ config = playerdata.getSurvival(player_or_id);
|
|
|
+ config.set(config, "quests_solved", config.getDouble(config, "quests_solved", 0) + amount);
|
|
|
+ config.saveAsync(config);
|
|
|
+}
|
|
|
+
|
|
|
+function quest.finish(script, player) {
|
|
|
+ addCounter(player, 1);
|
|
|
+ quest.term(script, player);
|
|
|
+}
|
|
|
+
|
|
|
+function quest.term(script, player) {
|
|
|
+ quest.removeDisplay(player);
|
|
|
+ quest.removePlayer(player);
|
|
|
+ script.term(script);
|
|
|
+}
|
|
|
+
|
|
|
//--------------------------------------------------
|
|
|
//Teleporter-Utils
|
|
|
//--------------------------------------------------
|
|
@@ -956,6 +1044,22 @@ function playerdata.getSurvival(player_or_id) {
|
|
|
return config;
|
|
|
}
|
|
|
|
|
|
+function playerdata.getGames(player_or_id) {
|
|
|
+ if(isPlayer(player_or_id)) {
|
|
|
+ player_id = player.getId(player_or_id);
|
|
|
+ } else {
|
|
|
+ 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
|
|
|
+ config = map.get(getScriptVar("games_data"), player_id);
|
|
|
+ if(config == null) {
|
|
|
+ loadData(player_id, getScriptVar("games_data"), "games_data");
|
|
|
+ config = map.get(getScriptVar("games_data"), player_id);
|
|
|
+ }
|
|
|
+ return config;
|
|
|
+}
|
|
|
+
|
|
|
function loadData(player_or_id, map, name) {
|
|
|
if(isPlayer(player_or_id)) {
|
|
|
player_id = player.getId(player_or_id);
|
|
@@ -1033,6 +1137,133 @@ function money.split(money) {
|
|
|
array[2] = bronze;
|
|
|
return array;
|
|
|
}
|
|
|
+//--------------------------------------------------
|
|
|
+//Skill-Utils
|
|
|
+//--------------------------------------------------
|
|
|
+
|
|
|
+function skill.getAmount(player_or_id, tech_name) {
|
|
|
+ config = playerdata.getSurvival(player_or_id);
|
|
|
+ return config.getDouble(config, tech_name, 0);
|
|
|
+}
|
|
|
+
|
|
|
+function skill.setAmount(player_or_id, tech_name, amount) {
|
|
|
+ config = playerdata.getSurvival(player_or_id);
|
|
|
+ config.set(config, tech_name, amount);
|
|
|
+ config.saveAsync(config);
|
|
|
+}
|
|
|
+
|
|
|
+function skill.addAmount(player_or_id, tech_name, amount) {
|
|
|
+ config = playerdata.getSurvival(player_or_id);
|
|
|
+ config.set(config, tech_name, config.getDouble(config, tech_name, 0) + amount);
|
|
|
+ config.saveAsync(config);
|
|
|
+}
|
|
|
+
|
|
|
+function skill.add(skill_name, tech_name, item, description, cost, permanent) {
|
|
|
+ skill = array.new(6);
|
|
|
+ skill[0] = skill_name;
|
|
|
+ skill[1] = tech_name;
|
|
|
+ skill[2] = item;
|
|
|
+ skill[3] = description;
|
|
|
+ skill[4] = cost;
|
|
|
+ skill[5] = permanent;
|
|
|
+ list.add(getScriptVar("skills"), skill);
|
|
|
+}
|
|
|
+
|
|
|
+function skill.get(skill_name) {
|
|
|
+ skill_list = getScriptVar("skills");
|
|
|
+ for(i = 0; i < list.getSize(skill_list); i++) {
|
|
|
+ array = list.getIndex(skill_list, i);
|
|
|
+ temp_skill_name = array[0];
|
|
|
+ if(temp_skill_name == skill_name) {
|
|
|
+ return array;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function skill.getShopItem(player, skill_name) {
|
|
|
+ if(skill_name == null) {
|
|
|
+ return read.item("minecraft:air");
|
|
|
+ }
|
|
|
+ skill = skill.get(skill_name);
|
|
|
+ config = playerdata.getSurvival(player);
|
|
|
+ amount = config.getDouble(config, skill[1], 0);
|
|
|
+ if(skill[5]) {
|
|
|
+ prop = "Permanent";
|
|
|
+ } else {
|
|
|
+ prop = "Levelable";
|
|
|
+ }
|
|
|
+ item = read.item(skill[2], 1, skill_name, concat("Cost:", text.number(skill[4])), skill[3], prop, concat("Amount you have: ", text.number(amount)));
|
|
|
+ return item;
|
|
|
+}
|
|
|
+
|
|
|
+function skill.getTechName(skill_name) {
|
|
|
+ skill_list = getScriptVar("skills");
|
|
|
+ for(i = 0; i < list.getSize(skill_list); i++) {
|
|
|
+ array = list.getIndex(skill_list, i);
|
|
|
+ temp_skill_name = array[0];
|
|
|
+ if(temp_skill_name == skill_name) {
|
|
|
+ return array[1];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function skill.getItem(skill_name) {
|
|
|
+ skill_list = getScriptVar("skills");
|
|
|
+ for(i = 0; i < list.getSize(skill_list); i++) {
|
|
|
+ array = list.getIndex(skill_list, i);
|
|
|
+ temp_skill_name = array[0];
|
|
|
+ if(temp_skill_name == skill_name) {
|
|
|
+ return array[2];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function skill.getDescription(skill_name) {
|
|
|
+ skill_list = getScriptVar("skills");
|
|
|
+ for(i = 0; i < list.getSize(skill_list); i++) {
|
|
|
+ array = list.getIndex(skill_list, i);
|
|
|
+ temp_skill_name = array[0];
|
|
|
+ if(temp_skill_name == skill_name) {
|
|
|
+ return array[3];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function skill.getCost(skill_name) {
|
|
|
+ skill_list = getScriptVar("skills");
|
|
|
+ for(i = 0; i < list.getSize(skill_list); i++) {
|
|
|
+ array = list.getIndex(skill_list, i);
|
|
|
+ temp_skill_name = array[0];
|
|
|
+ if(temp_skill_name == skill_name) {
|
|
|
+ return array[4];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function skill.isPermanent(skill_name) {
|
|
|
+ skill_list = getScriptVar("skills");
|
|
|
+ for(i = 0; i < list.getSize(skill_list); i++) {
|
|
|
+ array = list.getIndex(skill_list, i);
|
|
|
+ temp_skill_name = array[0];
|
|
|
+ if(temp_skill_name == skill_name) {
|
|
|
+ return array[5];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function skill.showShop(player, skill_name1, skill_name2, skill_name3, skill_name4, skill_name5, skill_name6, skill_name7, skill_name8, skill_name9) {
|
|
|
+ inv = inv.new(333333333);
|
|
|
+ inv.setItem(inv, 0, skill.getShopItem(player, skill_name1));
|
|
|
+ inv.setItem(inv, 1, skill.getShopItem(player, skill_name2));
|
|
|
+ inv.setItem(inv, 2, skill.getShopItem(player, skill_name3));
|
|
|
+ inv.setItem(inv, 3, skill.getShopItem(player, skill_name4));
|
|
|
+ inv.setItem(inv, 4, skill.getShopItem(player, skill_name5));
|
|
|
+ inv.setItem(inv, 5, skill.getShopItem(player, skill_name6));
|
|
|
+ inv.setItem(inv, 6, skill.getShopItem(player, skill_name7));
|
|
|
+ inv.setItem(inv, 7, skill.getShopItem(player, skill_name8));
|
|
|
+ inv.setItem(inv, 8, skill.getShopItem(player, skill_name9));
|
|
|
+ inv.open(inv, player, "Skillshop");
|
|
|
+}
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
//Survival-Utils
|
|
@@ -1040,7 +1271,43 @@ function money.split(money) {
|
|
|
|
|
|
function joinSurvWorld(player) {
|
|
|
displayMoney(player, getMoney(player));
|
|
|
- return;
|
|
|
+}
|
|
|
+
|
|
|
+//--------------------------------------------------
|
|
|
+//Games-Utils
|
|
|
+//--------------------------------------------------
|
|
|
+
|
|
|
+function joinGamesWorld(player) {
|
|
|
+ minigame.displayElo(player, minigame.getElo(player));
|
|
|
+}
|
|
|
+
|
|
|
+function minigame.displayElo(player, elo) {
|
|
|
+ display.add(player, 101, concat("§tElo: §r", text.number(elo)));
|
|
|
+}
|
|
|
+
|
|
|
+function minigame.setElo(player_or_id, elo) {
|
|
|
+ config = playerdata.getGames(player_or_id);
|
|
|
+ config.set(config, "game_elo", elo);
|
|
|
+ config.saveAsync(config);
|
|
|
+ if(isPlayer(player_or_id)) {
|
|
|
+ minigame.displayElo(player_or_id, elo);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function minigame.getElo(player_or_id) {
|
|
|
+ config = playerdata.getGames(player_or_id);
|
|
|
+ return config.getDouble(config, "game_elo", 0);
|
|
|
+}
|
|
|
+
|
|
|
+function minigame.addElo(player_or_id, elo) {
|
|
|
+ config = playerdata.getGames(player_or_id);
|
|
|
+ new_elo = config.getDouble(config, "game_elo", 0) + elo;
|
|
|
+ config.set(config, "game_elo", new_elo);
|
|
|
+ config.saveAsync(config);
|
|
|
+ if(isPlayer(player_or_id)) {
|
|
|
+ minigame.displayElo(player_or_id, new_elo);
|
|
|
+ speakPrefix(player_or_id, "§tElo", concat("§r+§e", text.number(elo)));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//--------------------------------------------------
|
|
@@ -1070,69 +1337,36 @@ function setAfk(player, boolean) {
|
|
|
//PvP-Utils
|
|
|
//--------------------------------------------------
|
|
|
|
|
|
-function hasPvpOn(player) {
|
|
|
- player_uuid = player.getUuid(player);
|
|
|
- pvp_set = getScriptVar("pvp_set");
|
|
|
- if(set.contains(pvp_set, player_uuid)) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
+function hasPvpOn(player_or_id) {
|
|
|
+ config = playerdata.getSurvival(player_or_id);
|
|
|
+ return config.getBool(config, "pvp", false);
|
|
|
}
|
|
|
|
|
|
-function setPvp(player, mode) {
|
|
|
- player_uuid = player.getUuid(player);
|
|
|
- pvp_set = getScriptVar("pvp_set");
|
|
|
- if(mode == "on") {
|
|
|
- set.add(pvp_set, player_uuid);
|
|
|
- } else {
|
|
|
- set.remove(pvp_set, player_uuid);
|
|
|
- }
|
|
|
+function setPvp(player_or_id, bool) {
|
|
|
+ config = playerdata.getSurvival(player_or_id);
|
|
|
+ config.set(config, "pvp", bool);
|
|
|
+ config.save(config);
|
|
|
}
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
//Rank-Utils
|
|
|
//--------------------------------------------------
|
|
|
|
|
|
-function setRank(player_name, category, rank) {
|
|
|
- rank = text.replace(rank, "&", "§");
|
|
|
- stmt = databank.prepare("INSERT INTO chatranks (player_id, category, rank) VALUES (?,?,?) ON DUPLICATE KEY UPDATE chatranks.rank = ?;");
|
|
|
- player_uuid = player.getUuid(player_name);
|
|
|
- player_id = player.getId(player_uuid);
|
|
|
- databank.setInt(stmt, 1, player_id);
|
|
|
- databank.setString(stmt, 2, category);
|
|
|
- databank.setString(stmt, 3, rank);
|
|
|
- databank.setString(stmt, 4, rank);
|
|
|
- databank.workerExecute(stmt);
|
|
|
+function getRank(player_or_id) {
|
|
|
+ config = playerdata.getSurvival(player_or_id);
|
|
|
+ return config.getString(config, "rank", "§bUser");
|
|
|
}
|
|
|
|
|
|
-function getRank(player_id) {
|
|
|
- player_name = player.getNameFromId(player_id);
|
|
|
- player = read.player(player_name);
|
|
|
- world_name = world.getName(loc.getWorld(entity.getLocation(player)));
|
|
|
- if(isSurvWorldName(world_name)) {
|
|
|
- world_name = "survival";
|
|
|
- }
|
|
|
- stmt = databank.prepare("SELECT rank FROM chatranks WHERE player_id = ? AND category = ?;");
|
|
|
- databank.setInt(stmt, 1, player_id);
|
|
|
- databank.setString(stmt, 2, world_name);
|
|
|
- result = databank.execute(stmt);
|
|
|
- if(databank.next(result)) {
|
|
|
- rank = databank.getString(result, 1);
|
|
|
- } else {
|
|
|
- rank = "§bUser";
|
|
|
- }
|
|
|
- databank.close(result);
|
|
|
- databank.close(stmt);
|
|
|
- return rank;
|
|
|
+function setRank(player_or_id, rank) {
|
|
|
+ rank = text.replace(rank, "&", "§");
|
|
|
+ config = playerdata.getSurvival(player_or_id);
|
|
|
+ config.set(config, "rank", rank);
|
|
|
+ config.save(config);
|
|
|
}
|
|
|
|
|
|
function offerRank(player, rank) {
|
|
|
rank2 = text.replace(rank, "§", "&");
|
|
|
- world_name = world.getName(loc.getWorld(entity.getLocation(player)));
|
|
|
- if(isSurvWorldName(world_name)) {
|
|
|
- world_name = "survival";
|
|
|
- }
|
|
|
- player.speak(player, "§6Commands", "Neuer Rang verfügbar: ", text.hover(text.click(concat("[", rank, "§r]"), concat("/setrank ", player.getName(player), " ", world_name, " ", rank2)), "Zum Auswählen klicken"));
|
|
|
+ player.speak(player, "§6Commands", "New rank available: ", text.hover(text.click(concat("[", rank, "§r]"), concat("/setrank ", player.getName(player), " ", rank2)), "Click to set"));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1182,7 +1416,7 @@ function removeAllPerms(player_id) {
|
|
|
}
|
|
|
|
|
|
function isAPermGroup(permstring) {
|
|
|
- if(list.contains($permgroups, text.toLowerCase(permstring))) {
|
|
|
+ if(map.contains($permgroupsmap, text.toLowerCase(permstring))) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
@@ -1226,15 +1460,15 @@ function registerAllPerms() {
|
|
|
//Nickname-Utils
|
|
|
//--------------------------------------------------
|
|
|
|
|
|
-function setNickName(player, nickname) {
|
|
|
+function player.setNickName(player, nickname) {
|
|
|
map.add(getScriptVar("nicknames"), player.getUuid(player), nickname);
|
|
|
}
|
|
|
|
|
|
-function getNickName(player) {
|
|
|
+function player.getNickName(player) {
|
|
|
return map.getOrDefault(getScriptVar("nicknames"), player.getUuid(player), player.getName(player));
|
|
|
}
|
|
|
|
|
|
-function removeNickName(player) {
|
|
|
+function player.removeNickName(player) {
|
|
|
map.remove(getScriptVar("nicknames"), player.getUuid(player));
|
|
|
}
|
|
|
|