mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 14:05:25 +01:00
Improve using player uuids in shop gui as items
This commit is contained in:
parent
735137cd04
commit
97050a5de0
@ -955,8 +955,6 @@ public class ConfigManager {
|
||||
// Translating unicode
|
||||
jobFullName = StringEscapeUtils.unescapeJava(jobFullName);
|
||||
|
||||
String jobDisplayName = jobSection.getString("displayName");
|
||||
|
||||
int maxLevel = jobSection.getInt("max-level");
|
||||
if (maxLevel < 0)
|
||||
maxLevel = 0;
|
||||
@ -1294,35 +1292,6 @@ public class ConfigManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<String> lore = itemSection.getStringList("lore");
|
||||
|
||||
for (int a = 0; a < lore.size(); a++) {
|
||||
lore.set(a, CMIChatColor.translate(lore.get(a)));
|
||||
}
|
||||
|
||||
Map<Enchantment, Integer> enchants = new HashMap<>();
|
||||
if (itemSection.isList("enchants"))
|
||||
for (String eachLine : itemSection.getStringList("enchants")) {
|
||||
if (!eachLine.contains("="))
|
||||
continue;
|
||||
|
||||
String[] split = eachLine.split("=", 2);
|
||||
Enchantment ench = CMIEnchantment.getEnchantment(split[0]);
|
||||
if (ench == null)
|
||||
continue;
|
||||
|
||||
int level = -1;
|
||||
try {
|
||||
level = Integer.parseInt(split[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
if (level != -1)
|
||||
enchants.put(ench, level);
|
||||
}
|
||||
|
||||
String node = itemKey.toLowerCase();
|
||||
|
||||
CMIMaterial mat = null;
|
||||
|
||||
if (itemSection.isInt("id")) {
|
||||
@ -1336,11 +1305,40 @@ public class ConfigManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<String> lore = itemSection.getStringList("lore");
|
||||
|
||||
for (int a = 0; a < lore.size(); a++) {
|
||||
lore.set(a, CMIChatColor.translate(lore.get(a)));
|
||||
}
|
||||
|
||||
Map<Enchantment, Integer> enchants = new HashMap<>();
|
||||
for (String eachLine : itemSection.getStringList("enchants")) {
|
||||
if (!eachLine.contains("="))
|
||||
continue;
|
||||
|
||||
String[] split = eachLine.split("=", 2);
|
||||
Enchantment ench = CMIEnchantment.getEnchantment(split[0]);
|
||||
if (ench == null)
|
||||
continue;
|
||||
|
||||
int level = -1;
|
||||
try {
|
||||
level = Integer.parseInt(split[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
if (level != -1)
|
||||
enchants.put(ench, level);
|
||||
}
|
||||
|
||||
String node = itemKey.toLowerCase();
|
||||
|
||||
jobLimitedItems.put(node, new JobLimitedItems(node, mat, 1, itemSection.getString("name"), lore, enchants, itemSection.getInt("level")));
|
||||
}
|
||||
}
|
||||
|
||||
Job job = new Job(jobKey, jobDisplayName, jobFullName, jobShortName, description, color, maxExpEquation, displayMethod, maxLevel, vipmaxLevel, maxSlots, jobPermissions, jobCommand,
|
||||
Job job = new Job(jobKey, jobSection.getString("displayName"), jobFullName, jobShortName, description,
|
||||
color, maxExpEquation, displayMethod, maxLevel, vipmaxLevel, maxSlots, jobPermissions, jobCommand,
|
||||
jobConditions, jobItems, jobLimitedItems, jobSection.getStringList("cmd-on-join"),
|
||||
jobSection.getStringList("cmd-on-leave"), guiItem, guiSlot, bossbar, rejoinCd,
|
||||
jobSection.getStringList("world-blacklist"));
|
||||
@ -1355,21 +1353,24 @@ public class ConfigManager {
|
||||
job.setIgnoreMaxJobs(jobSection.getBoolean("ignore-jobs-max"));
|
||||
job.setReversedWorldBlacklist(jobSection.getBoolean("reverse-world-blacklist-functionality"));
|
||||
|
||||
if (jobSection.isConfigurationSection("Quests")) {
|
||||
ConfigurationSection qsection = jobSection.getConfigurationSection("Quests");
|
||||
if (qsection != null) {
|
||||
List<Quest> quests = new ArrayList<>();
|
||||
ConfigurationSection qsection = jobSection.getConfigurationSection("Quests");
|
||||
|
||||
for (String one : qsection.getKeys(false)) {
|
||||
try {
|
||||
ConfigurationSection sqsection = qsection.getConfigurationSection(one);
|
||||
if (sqsection == null) {
|
||||
if (sqsection == null)
|
||||
continue;
|
||||
}
|
||||
|
||||
Quest quest = new Quest(sqsection.getString("Name", one), job);
|
||||
|
||||
if (sqsection.isString("Target")) {
|
||||
ActionType actionType = ActionType.getByName(sqsection.getString("Action"));
|
||||
|
||||
if (actionType == null)
|
||||
continue;
|
||||
|
||||
KeyValues kv = getKeyValue(sqsection.getString("Target").toUpperCase(), actionType, jobFullName);
|
||||
if (kv != null) {
|
||||
int amount = sqsection.getInt("Amount", 1);
|
||||
@ -1380,6 +1381,7 @@ public class ConfigManager {
|
||||
if (sqsection.isList("Objectives")) {
|
||||
for (String oneObjective : sqsection.getStringList("Objectives")) {
|
||||
String[] split = oneObjective.split(";", 3);
|
||||
|
||||
if (split.length < 2) {
|
||||
log.warning("Job " + jobKey + " has incorrect quest objective (" + oneObjective + ")!");
|
||||
continue;
|
||||
@ -1387,6 +1389,9 @@ public class ConfigManager {
|
||||
|
||||
try {
|
||||
ActionType actionType = ActionType.getByName(split[0]);
|
||||
if (actionType == null)
|
||||
continue;
|
||||
|
||||
String mats = split[1].toUpperCase();
|
||||
String[] co = mats.split(",");
|
||||
|
||||
@ -1524,16 +1529,14 @@ public class ConfigManager {
|
||||
subType = keyValue.getSubType(),
|
||||
meta = keyValue.getMeta();
|
||||
|
||||
double income = section.getDouble("income", 0.0);
|
||||
double income = section.getDouble("income");
|
||||
income = updateValue(CurrencyType.MONEY, income);
|
||||
double points = section.getDouble("points", 0.0);
|
||||
double points = section.getDouble("points");
|
||||
points = updateValue(CurrencyType.POINTS, points);
|
||||
double experience = section.getDouble("experience", 0.0);
|
||||
double experience = section.getDouble("experience");
|
||||
experience = updateValue(CurrencyType.EXP, experience);
|
||||
|
||||
int fromlevel = 1;
|
||||
if (section.isInt("from-level"))
|
||||
fromlevel = section.getInt("from-level");
|
||||
int fromlevel = section.getInt("from-level", 1);
|
||||
|
||||
int untilLevel = -1;
|
||||
if (section.isInt("until-level")) {
|
||||
|
@ -198,20 +198,20 @@ public class RestrictedAreaManager {
|
||||
ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas");
|
||||
if (areaSection != null) {
|
||||
for (String areaKey : areaSection.getKeys(false)) {
|
||||
double multiplier = conf.getDouble("restrictedareas." + areaKey + ".multiplier");
|
||||
double multiplier = areaSection.getDouble(areaKey + ".multiplier");
|
||||
|
||||
if (conf.isBoolean("restrictedareas." + areaKey + ".WG")) {
|
||||
if (areaSection.isBoolean(areaKey + ".WG")) {
|
||||
addNew(new RestrictedArea(areaKey, areaKey, multiplier));
|
||||
worldGuardArea = true;
|
||||
} else {
|
||||
World world = Bukkit.getServer().getWorld(conf.getString("restrictedareas." + areaKey + ".world", ""));
|
||||
World world = Bukkit.getServer().getWorld(areaSection.getString(areaKey + ".world", ""));
|
||||
if (world == null)
|
||||
continue;
|
||||
Location point1 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point1.x"), conf.getDouble("restrictedareas." + areaKey
|
||||
+ ".point1.y"), conf.getDouble("restrictedareas." + areaKey + ".point1.z"));
|
||||
Location point1 = new Location(world, areaSection.getDouble(areaKey + ".point1.x"), areaSection.getDouble(areaKey
|
||||
+ ".point1.y"), areaSection.getDouble(areaKey + ".point1.z"));
|
||||
|
||||
Location point2 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point2.x"), conf.getDouble("restrictedareas." + areaKey
|
||||
+ ".point2.y"), conf.getDouble("restrictedareas." + areaKey + ".point2.z"));
|
||||
Location point2 = new Location(world, areaSection.getDouble(areaKey + ".point2.x"), areaSection.getDouble(areaKey
|
||||
+ ".point2.y"), areaSection.getDouble(areaKey + ".point2.z"));
|
||||
addNew(new RestrictedArea(areaKey, new CuboidArea(point1, point2), multiplier));
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -34,7 +35,6 @@ import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobItems;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.container.PlayerPoints;
|
||||
import com.gamingmesh.jobs.container.ShopItem;
|
||||
import com.gamingmesh.jobs.stuff.GiveItem;
|
||||
|
||||
@ -110,10 +110,7 @@ public class ShopManager {
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
|
||||
PlayerPoints pointsInfo = jPlayer.getPointsData();
|
||||
double points = 0D;
|
||||
if (pointsInfo != null)
|
||||
points = (int) (pointsInfo.getCurrentPoints() * 100.0) / 100.0;
|
||||
double points = (int) (jPlayer.getPointsData().getCurrentPoints() * 100.0) / 100.0;
|
||||
|
||||
for (int i = 0; i < ls.size(); i++) {
|
||||
ShopItem item = ls.get(i);
|
||||
@ -201,8 +198,13 @@ public class ShopManager {
|
||||
if (item.isHeadOwner()) {
|
||||
Jobs.getNms().setSkullOwner(skullMeta, jPlayer.getPlayer());
|
||||
} else {
|
||||
Jobs.getNms().setSkullOwner(skullMeta, Bukkit.getOfflinePlayer(item.getCustomHead()));
|
||||
try {
|
||||
Jobs.getNms().setSkullOwner(skullMeta, Bukkit.getOfflinePlayer(UUID.fromString(item.getCustomHead())));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
Jobs.getNms().setSkullOwner(skullMeta, Bukkit.getOfflinePlayer(item.getCustomHead()));
|
||||
}
|
||||
}
|
||||
|
||||
guiItem.setItemMeta(skullMeta);
|
||||
} else
|
||||
guiItem.setItemMeta(meta);
|
||||
@ -231,13 +233,14 @@ public class ShopManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (pointsInfo == null || pointsInfo.getCurrentPoints() < item.getPrice()) {
|
||||
if (jPlayer.getPointsData().getCurrentPoints() < item.getPrice()) {
|
||||
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoPoints"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getRequiredTotalLevels() != -1 && jPlayer.getTotalLevels() < item.getRequiredTotalLevels()) {
|
||||
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoTotalLevel", "%totalLevel%", jPlayer.getTotalLevels()));
|
||||
int totalLevels = jPlayer.getTotalLevels();
|
||||
if (item.getRequiredTotalLevels() != -1 && totalLevels < item.getRequiredTotalLevels()) {
|
||||
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoTotalLevel", "%totalLevel%", totalLevels));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -260,7 +263,7 @@ public class ShopManager {
|
||||
GiveItem.giveItemForPlayer(player, one.getItemStack(player));
|
||||
}
|
||||
|
||||
pointsInfo.takePoints(item.getPrice());
|
||||
jPlayer.getPointsData().takePoints(item.getPrice());
|
||||
Jobs.getJobsDAO().savePoints(jPlayer);
|
||||
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.Paid", "%amount%", item.getPrice()));
|
||||
}
|
||||
@ -437,8 +440,10 @@ public class ShopManager {
|
||||
|
||||
Object potionData = null;
|
||||
if (itemSection.contains("potion-type")) {
|
||||
PotionType type = PotionType.valueOf(itemSection.getString("potion-type", "speed").toUpperCase());
|
||||
if (type == null) {
|
||||
PotionType type;
|
||||
try {
|
||||
type = PotionType.valueOf(itemSection.getString("potion-type", "speed").toUpperCase());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
type = PotionType.SPEED;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class Quest {
|
||||
private Long validUntil = 0L;
|
||||
|
||||
private int chance = 100, minLvl = 0;
|
||||
private Integer maxLvl = null;
|
||||
private Integer maxLvl;
|
||||
|
||||
private final List<String> rewardCmds = new ArrayList<>(), rewards = new ArrayList<>(), area = new ArrayList<>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user