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