1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-04-16 09:05:45 +02:00

Lets catch Throwable instead of Exception when not using spigot

- Now you can give the limited items with **/jobs give [playername] [jobname] [items/limiteditems] [jobitemname]** command to get limited items from jobConfig.
This commit is contained in:
montlikadani 2019-01-23 19:23:16 +01:00
parent 03a220e18f
commit b230c17292
29 changed files with 210 additions and 125 deletions

View File

@ -66,7 +66,7 @@
<artifactId>MythicMobs</artifactId>
<version>4.5.1</version>
<scope>system</scope>
<systemPath>${basedir}/libs/MythicMobs-4.5.0.jar</systemPath>
<systemPath>${basedir}/libs/MythicMobs-4.5.1.jar</systemPath>
</dependency>
<!-- WorldGuard -->
<dependency>

View File

@ -52,7 +52,7 @@ public class ItemManager {
String mojangName = one.name();
try {
mojangName = ItemReflection.getItemMinecraftName(new ItemStack(mat));
} catch (Exception e) {
} catch (Throwable e) {
}
CMIItemStack cm = new CMIItemStack(one);
@ -93,7 +93,7 @@ public class ItemManager {
String mojangName = one.name();
try {
mojangName = ItemReflection.getItemMinecraftName(new ItemStack(one));
} catch (Exception e) {
} catch (Throwable e) {
}
cm.setMojangName(mojangName);
String n = mojangName.toLowerCase().replace("_", "").replace(" ", "").replace("minecraft:", "");
@ -139,7 +139,7 @@ public class ItemManager {
String a = name.split("-")[1];
try {
amount = Integer.parseInt(a);
} catch (Exception e) {
} catch (Throwable e) {
}
name = name.split("-")[0];
}
@ -149,13 +149,13 @@ public class ItemManager {
if (name.contains(":")) {
try {
data = (short) Integer.parseInt(name.split(":")[1]);
} catch (Exception e) {
} catch (Throwable e) {
}
try {
CMIEntityType e = CMIEntityType.getByName(name.split(":")[1]);
if (e != null)
data = e.getType().getTypeId();
} catch (Exception e) {
} catch (Throwable e) {
}
name = name.split(":")[0];
}
@ -184,7 +184,7 @@ public class ItemManager {
try {
OfflinePlayer offPlayer = Bukkit.getOfflinePlayer(UUID.fromString(d));
skullMeta.setOwner(offPlayer.getName());
} catch (Exception e) {
} catch (Throwable e) {
break main;
}
skull.setItemMeta(skullMeta);
@ -205,7 +205,7 @@ public class ItemManager {
if (cm == null) {
try {
cm = byId.get(Integer.parseInt(name));
} catch (Exception e) {
} catch (Throwable e) {
}
if (cm == null) {
@ -516,7 +516,7 @@ public class ItemManager {
Integer id = null;
try {
id = Integer.parseInt(main);
} catch (Exception e) {
} catch (Throwable e) {
}
for (CMIEntityType one : CMIEntityType.values()) {
@ -1263,9 +1263,9 @@ public class ItemManager {
POTION_SWIFTNESS_3(373, 8258, 24020, "Swiftness Potion 3"),
POTION_SWIFTNESS_4(373, 8290, 24020, "Swiftness Potion 4"),
POTION_THICK(373, 32, 24020, "Thick Potion"),
POTION_TURTLE_MASTER_1(-1, -1, 24020, "Turtle Master Potion"),
POTION_TURTLE_MASTER_2(-1, -1, 24020, "Turtle Master Potion 2"),
POTION_TURTLE_MASTER_3(-1, -1, 24020, "Turtle Master Potion 3"),
POTION_TURTLE_MASTER_1(-1, -1, -1, "Turtle Master Potion"),
POTION_TURTLE_MASTER_2(-1, -1, -1, "Turtle Master Potion 2"),
POTION_TURTLE_MASTER_3(-1, -1, -1, "Turtle Master Potion 3"),
POTION_WATER_BREATHING_1(373, 8205, 24020, "Water Breathing Potion"),
POTION_WATER_BREATHING_2(373, 8269, 24020, "Water Breathing Potion 2"),
POTION_WEAKNESS_1(373, 8200, 24020, "Weakness Potion"),
@ -1545,7 +1545,7 @@ public class ItemManager {
LEGACY_BURNING_FURNACE(62, 0, -1, "Burning Furnace"),
LEGACY_NETHER_WARTS(115, 0, -1, "Nether Warts"),
LEGACY_IRON_DOOR_BLOCK(71, 0, -1, "Iron Door Block"),
LEGACY_GLOWING_REDSTON_ORE(74, 0, -1, "Glowing Redstone Ore"),
LEGACY_GLOWING_REDSTONE_ORE(74, 0, -1, "Glowing Redstone Ore"),
LEGACY_SUGAR_CANE_BLOCK(83, 0, -1, "Sugar Cane Block"),
LEGACY_RAW_FISH(349, 0, -1, "Raw Fish"),
LEGACY_SKULL(144, 0, -1, "Skull"),
@ -1742,19 +1742,19 @@ public class ItemManager {
id = id.replace("_", "").replace(" ", "").toLowerCase();
try {
ids = Integer.parseInt(id);
} catch (Exception e) {
} catch (Throwable e) {
if (id.contains(":")) {
try {
ids = Integer.parseInt(id.split(":")[0]);
data = Integer.parseInt(id.split(":")[1]);
return get(ids, data);
} catch (Exception ex) {
} catch (Throwable ex) {
}
try {
data = Integer.parseInt(id.split(":")[1]);
id = id.split(":")[0];
} catch (Exception ex) {
} catch (Throwable ex) {
}
}
}

View File

@ -77,7 +77,7 @@ public class ItemReflection {
Object res2 = secmeth.invoke(nmsStack);
Object res = meth.invoke(reg, res2);
return res.toString();
} catch (Exception e) {
} catch (Throwable e) {
return null;
}
}
@ -124,7 +124,7 @@ public class ItemReflection {
Method meth2 = res.getClass().getMethod(ff, IStack);
Object name = meth2.invoke(res, nmsStack);
return name.toString();
} catch (Exception e) {
} catch (Throwable e) {
return item != null ? item.getType().name() : "";
}
}
@ -138,7 +138,7 @@ public class ItemReflection {
Method nameThingy = Item.getMethod("j", IStack);
Object resThingy = nameThingy.invoke(res, nmsStack);
return resThingy.toString();
} catch (Exception e) {
} catch (Throwable e) {
return null;
}
}
@ -147,7 +147,7 @@ public class ItemReflection {
try {
Method meth = CraftItemStack.getMethod("asNMSCopy", ItemStack.class);
return meth.invoke(CraftItemStack, item);
} catch (Exception e) {
} catch (Throwable e) {
return null;
}
}
@ -156,7 +156,7 @@ public class ItemReflection {
try {
Method meth = CraftItemStack.getMethod("asBukkitCopy", IStack);
return meth.invoke(CraftItemStack, item);
} catch (Exception e) {
} catch (Throwable e) {
return null;
}
}

View File

@ -42,13 +42,13 @@ public class VersionChecker {
try {
version = Integer.parseInt(lVersion);
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
}
} else {
try {
version = Integer.parseInt(v);
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
}
}
@ -87,7 +87,7 @@ public class VersionChecker {
Version() {
try {
this.value = Integer.valueOf(this.name().replaceAll("[^\\d.]", ""));
} catch (Exception e) {
} catch (Throwable e) {
}
shortVersion = this.name().substring(0, this.name().length() - 3);
}
@ -181,7 +181,7 @@ public class VersionChecker {
String version = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
if (version.length() <= 7)
return version;
} catch (Exception ex) {
} catch (Throwable ex) {
Jobs.consoleMsg("&cFailed to check for " + plugin.getDescription().getName() + " update on spigot web page.");
}
return null;

View File

@ -579,7 +579,7 @@ public class Jobs extends JavaPlugin {
if (jPlayer == null)
continue;
pManager.addPlayerToCache(jPlayer);
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
}
}
@ -789,7 +789,7 @@ public class Jobs extends JavaPlugin {
consoleMsg("&ePlaceholderAPI was found - Enabling capabilities.");
PlaceholderAPIEnabled = true;
}
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
}
@ -863,7 +863,7 @@ public class Jobs extends JavaPlugin {
cManager.fillCommands();
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
System.out.println("There was some issues when starting plugin. Please contact dev about this. Plugin will be disabled.");
setEnabled(false);
@ -878,7 +878,7 @@ public class Jobs extends JavaPlugin {
dao.saveExplore();
dao.saveBlockProtection();
FurnaceBrewingHandling.save();
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
}
shutdown();
@ -1121,7 +1121,7 @@ public class Jobs extends JavaPlugin {
BBManager.ShowJobProgression(jPlayer, prog);
else
jPlayer.getUpdateBossBarFor().add(prog.getJob().getName());
} catch (Exception e) {
} catch (Throwable e) {
consoleMsg("&c[Jobs] Some issues with boss bar feature accured, try disabling it to avoid it.");
}

View File

@ -140,7 +140,7 @@ public class PermissionManager {
double t = Double.parseDouble(uno.getKey().replace(perm, ""));
if (amount == null || t > amount)
amount = t;
} catch (Exception e) {
} catch (Throwable e) {
}
}
}

View File

@ -87,7 +87,7 @@ public class Placeholder {
try {
int id = Integer.parseInt(matcher.group(1).substring(1));
groups.add(id);
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
}
}
@ -220,7 +220,7 @@ public class Placeholder {
for (Integer oneG : groups) {
lsInLs.add(matcher.group(oneG + 1));
}
} catch (Exception e) {
} catch (Throwable e) {
}
break;
}
@ -268,7 +268,7 @@ public class Placeholder {
if (placeholder.contains("%"))
if (!placeholder.equals(me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, placeholder)))
return JobsPlaceholderType.PAPI;
} catch (Exception e) {
} catch (Throwable e) {
}
}
@ -291,7 +291,7 @@ public class Placeholder {
try {
if (message.contains("%"))
message = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, message);
} catch (Exception e) {
} catch (Throwable e) {
}
}
@ -326,7 +326,7 @@ public class Placeholder {
with = "\\" + with;
message = message.replaceFirst(group, with);
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
}
}
@ -349,7 +349,7 @@ public class Placeholder {
int id = Integer.parseInt(value);
if (id > 0)
j = user.getJobProgression().get(id - 1);
} catch (Exception e) {
} catch (Throwable e) {
Job job = Jobs.getJob(value);
if (job != null)
j = user.getJobProgression(job);
@ -363,7 +363,7 @@ public class Placeholder {
int id = Integer.parseInt(value);
if (id > 0)
j = Jobs.getJobs().get(id - 1);
} catch (Exception e) {
} catch (Throwable e) {
j = Jobs.getJob(value);
}
return j;

View File

@ -545,7 +545,7 @@ public class PlayerManager {
} else
Jobs.consoleMsg("[Jobs] Can't find sound by name: " + levelUpEvent.getTitleChangeSound().name() + ". Please update it");
}
} catch (Exception e) {
} catch (Throwable e) {
}
String message;
@ -590,7 +590,7 @@ public class PlayerManager {
} else
Jobs.consoleMsg("[Jobs] Can't find sound by name: " + levelUpEvent.getTitleChangeSound().name() + ". Please update it");
}
} catch (Exception e) {
} catch (Throwable e) {
}
// user would skill up
if (Jobs.getGCManager().isBroadcastingSkillups())

View File

@ -108,7 +108,7 @@ public class Reflections {
Method meth2 = res.getClass().getMethod(ff, IStack);
Object name = meth2.invoke(res, nmsStack);
return name.toString();
} catch (Exception e) {
} catch (Throwable e) {
return item != null ? item.getType().name() : "";
}
}
@ -138,7 +138,7 @@ public class Reflections {
Method meth2 = nmsStack.getClass().getMethod("setTag", NBTTagCompound);
meth2.invoke(nmsStack, tag);
return (ItemStack) asBukkitCopy(nmsStack);
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
return null;
}
@ -154,7 +154,7 @@ public class Reflections {
Method meth = nbt.getClass().getMethod("getCompound", String.class);
Object res = meth.invoke(nbt, base);
return res != null;
} catch (Exception e) {
} catch (Throwable e) {
return false;
}
}
@ -167,7 +167,7 @@ public class Reflections {
Method methTag = nmsStack.getClass().getMethod("getTag");
Object tag = methTag.invoke(nmsStack);
return tag;
} catch (Exception e) {
} catch (Throwable e) {
return null;
}
}
@ -189,7 +189,7 @@ public class Reflections {
Method meth = compoundRes.getClass().getMethod("getString", String.class);
Object res = meth.invoke(compoundRes, path);
return res;
} catch (Exception e) {
} catch (Throwable e) {
return null;
}
}
@ -219,7 +219,7 @@ public class Reflections {
Method meth2 = nmsStack.getClass().getMethod("setTag", NBTTagCompound);
meth2.invoke(nmsStack, tag);
return (ItemStack) asBukkitCopy(nmsStack);
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
return null;
}
@ -229,7 +229,7 @@ public class Reflections {
try {
Method meth = CraftItemStack.getMethod("asNMSCopy", ItemStack.class);
return meth.invoke(CraftItemStack, item);
} catch (Exception e) {
} catch (Throwable e) {
return null;
}
}
@ -238,7 +238,7 @@ public class Reflections {
try {
Method meth = CraftItemStack.getMethod("asBukkitCopy", IStack);
return meth.invoke(CraftItemStack, item);
} catch (Exception e) {
} catch (Throwable e) {
return null;
}
}

View File

@ -208,12 +208,12 @@ public class JobsCommands implements CommandExecutor {
listOfCommands.add(name);
}
}
} catch (Exception e) {
} catch (Throwable e) {
} finally {
if (jarFile != null)
try {
jarFile.close();
} catch (Exception e) {
} catch (Throwable e) {
}
}
return listOfCommands;

View File

@ -483,8 +483,8 @@ public class editjobs implements Cmd {
player.sendMessage(ChatColor.GOLD + "Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
player.sendMessage(ChatColor.GOLD + "In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
player.sendMessage(ChatColor.GOLD + "In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly.");
material = CMIMaterial.LEGACY_GLOWING_REDSTON_ORE;
} else if (material == CMIMaterial.LEGACY_GLOWING_REDSTON_ORE && actionT == ActionType.BREAK && Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
material = CMIMaterial.LEGACY_GLOWING_REDSTONE_ORE;
} else if (material == CMIMaterial.LEGACY_GLOWING_REDSTONE_ORE && actionT == ActionType.BREAK && Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
player.sendMessage(ChatColor.GOLD + "Job " + job.getName() + " is using GLOWING_REDSTONE_ORE instead of REDSTONE_ORE.");
player.sendMessage(ChatColor.GOLD + "Automatically changing block to REDSTONE_ORE. Please update your configuration.");
material = CMIMaterial.REDSTONE_ORE;

View File

@ -9,16 +9,29 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobItems;
import com.gamingmesh.jobs.container.JobLimitedItems;
import com.gamingmesh.jobs.stuff.GiveItem;
public class give implements Cmd {
private enum actions {
items, limiteditems;
public static actions getByname(String name) {
for (actions one : actions.values()) {
if (one.name().equalsIgnoreCase(name))
return one;
}
return null;
}
}
@Override
@JobCommand(2500)
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
Player player = null;
Job job = null;
actions name = null;
String itemName = null;
for (String one : args) {
@ -33,6 +46,12 @@ public class give implements Cmd {
if (job != null)
continue;
}
if (name == null) {
name = actions.getByname(one);
if (name != null)
continue;
}
itemName = one;
}
@ -44,19 +63,35 @@ public class give implements Cmd {
return true;
}
if (job == null || itemName == null) {
if (job == null || name == null || itemName == null) {
Jobs.getCommandManager().sendUsage(sender, "give");
return true;
}
JobItems jItem = job.getItemBonus(itemName);
switch (name) {
case items:
JobItems jItem = job.getItemBonus(itemName);
if (jItem == null || jItem.getItemStack(player) == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.noitem"));
return true;
if (jItem == null || jItem.getItemStack(player) == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.noitem"));
return true;
}
GiveItem.GiveItemForPlayer(player, jItem.getItemStack(player, job));
break;
case limiteditems:
JobLimitedItems jLItem = job.getLimitedItems().get(itemName.toLowerCase());
if (jLItem == null || jLItem.getItemStack(player) == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.noitem"));
return true;
}
GiveItem.GiveItemForPlayer(player, jLItem.getItemStack(player));
break;
default:
break;
}
GiveItem.GiveItemForPlayer(player, jItem.getItemStack(player, job));
return true;
}
}

View File

@ -100,7 +100,7 @@ public class ConfigManager {
conf.load(s);
if (s != null)
s.close();
} catch (Exception e) {
} catch (Throwable e) {
Jobs.getPluginLogger().severe("==================== Jobs ====================");
Jobs.getPluginLogger().severe("Unable to load jobConfig.yml!");
Jobs.getPluginLogger().severe("Check your config for formatting issues!");
@ -276,8 +276,8 @@ public class ConfigManager {
Jobs.getPluginLogger().warning("Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
Jobs.getPluginLogger().warning("In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
Jobs.getPluginLogger().warning("In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly.");
material = CMIMaterial.LEGACY_GLOWING_REDSTON_ORE;
} else if (material == CMIMaterial.LEGACY_GLOWING_REDSTON_ORE && actionType == ActionType.BREAK && Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
material = CMIMaterial.LEGACY_GLOWING_REDSTONE_ORE;
} else if (material == CMIMaterial.LEGACY_GLOWING_REDSTONE_ORE && actionType == ActionType.BREAK && Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
Jobs.getPluginLogger().warning("Job " + jobName + " is using GLOWING_REDSTONE_ORE instead of REDSTONE_ORE.");
Jobs.getPluginLogger().warning("Automatically changing block to REDSTONE_ORE. Please update your configuration.");
material = CMIMaterial.REDSTONE_ORE;
@ -420,7 +420,7 @@ public class ConfigManager {
try {
conf.load(s);
s.close();
} catch (Exception e) {
} catch (Throwable e) {
Jobs.getPluginLogger().severe("==================== Jobs ====================");
Jobs.getPluginLogger().severe("Unable to load jobConfig.yml!");
Jobs.getPluginLogger().severe("Check your config for formatting issues!");
@ -522,7 +522,7 @@ public class ConfigManager {
maxExpEquation.setVariable("numjobs", 1);
maxExpEquation.setVariable("joblevel", 1);
maxExpEquation.getValue();
} catch (Exception e) {
} catch (Throwable e) {
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid leveling-progression-equation property. Skipping job!");
continue;
}
@ -537,7 +537,7 @@ public class ConfigManager {
incomeEquation.setVariable("joblevel", 1);
incomeEquation.setVariable("baseincome", 1);
incomeEquation.getValue();
} catch (Exception e) {
} catch (Throwable e) {
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid income-progression-equation property. Skipping job!");
continue;
}
@ -552,7 +552,7 @@ public class ConfigManager {
expEquation.setVariable("joblevel", 1);
expEquation.setVariable("baseexperience", 1);
expEquation.getValue();
} catch (Exception e) {
} catch (Throwable e) {
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid experience-progression-equation property. Skipping job!");
continue;
}
@ -567,7 +567,7 @@ public class ConfigManager {
pointsEquation.setVariable("joblevel", 1);
pointsEquation.setVariable("basepoints", 1);
pointsEquation.getValue();
} catch (Exception e) {
} catch (Throwable e) {
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid points-progression-equation property. Skipping job!");
continue;
}
@ -634,7 +634,7 @@ public class ConfigManager {
try {
OfflinePlayer offPlayer = Bukkit.getOfflinePlayer(UUID.fromString(skullOwner));
skullMeta.setOwner(offPlayer.getName());
} catch (Exception e) {
} catch (Throwable e) {
}
} else
skullMeta.setOwner(skullOwner);
@ -664,7 +664,7 @@ public class ConfigManager {
try {
OfflinePlayer offPlayer = Bukkit.getOfflinePlayer(UUID.fromString(skullOwner));
skullMeta.setOwner(offPlayer.getName());
} catch (Exception e) {
} catch (Throwable e) {
}
} else
skullMeta.setOwner(skullOwner);
@ -806,7 +806,7 @@ public class ConfigManager {
}
// Limited Items
ArrayList<JobLimitedItems> jobLimitedItems = new ArrayList<>();
HashMap<String, JobLimitedItems> jobLimitedItems = new HashMap<>();
ConfigurationSection LimitedItemsSection = jobSection.getConfigurationSection("limitedItems");
if (LimitedItemsSection != null) {
for (String itemKey : LimitedItemsSection.getKeys(false)) {
@ -850,7 +850,7 @@ public class ConfigManager {
int level = itemSection.getInt("level");
jobLimitedItems.add(new JobLimitedItems(node, id, name, lore, enchants, level));
jobLimitedItems.put(node.toLowerCase(), new JobLimitedItems(node, id, 0, 1, name, lore, enchants, level));
}
}
@ -904,7 +904,7 @@ public class ConfigManager {
quest.setDescription(desc);
quests.add(quest);
} catch (Exception e) {
} catch (Throwable e) {
Jobs.consoleMsg("&c[Jobs] Can't load " + one + " quest for " + jobName);
e.printStackTrace();
}
@ -1039,8 +1039,8 @@ public class ConfigManager {
Jobs.getPluginLogger().warning("Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
Jobs.getPluginLogger().warning("In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
Jobs.getPluginLogger().warning("In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly.");
material = CMIMaterial.LEGACY_GLOWING_REDSTON_ORE;
} else if (material == CMIMaterial.LEGACY_GLOWING_REDSTON_ORE && actionType == ActionType.BREAK && Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
material = CMIMaterial.LEGACY_GLOWING_REDSTONE_ORE;
} else if (material == CMIMaterial.LEGACY_GLOWING_REDSTONE_ORE && actionType == ActionType.BREAK && Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
Jobs.getPluginLogger().warning("Job " + job.getName() + " is using GLOWING_REDSTONE_ORE instead of REDSTONE_ORE.");
Jobs.getPluginLogger().warning("Automatically changing block to REDSTONE_ORE. Please update your configuration.");
material = CMIMaterial.REDSTONE_ORE;

View File

@ -63,12 +63,12 @@ public class LanguageManager {
listOfCommands.add(name);
}
}
} catch (Exception e) {
} catch (Throwable e) {
} finally {
if (jarFile != null)
try {
jarFile.close();
} catch (Exception e) {
} catch (Throwable e) {
}
}
return listOfCommands;
@ -342,7 +342,7 @@ public class LanguageManager {
c.get("command.archive.error.nojob", "There is no jobs saved.");
c.get("command.give.help.info", "Gives item by jobs name and item category name. Player name is optional");
c.get("command.give.help.args", "[playername] [jobname] [jobitemname]");
c.get("command.give.help.args", "[playername] [jobname] [items/limiteditems] [jobitemname]");
Jobs.getGCManager().commandArgs.put("give", Arrays.asList("[playername]", "[jobname]", "[jobitemname]"));
c.get("command.give.output.notonline", "&4Player [%playername%] is not online!");
c.get("command.give.output.noitem", "&4Can't find any item by given name!");

View File

@ -29,7 +29,7 @@ public class RestrictedBlockManager {
ConfigReader cfg = null;
try {
cfg = new ConfigReader("restrictedBlocks.yml");
} catch (Exception e1) {
} catch (Throwable e1) {
e1.printStackTrace();
}
if (cfg == null)

View File

@ -46,7 +46,7 @@ public class ScheduleManager {
public void run() {
try {
scheduler();
} catch (Exception e) {
} catch (Throwable e) {
}
}
};

View File

@ -310,7 +310,7 @@ public class ShopManager {
@SuppressWarnings("deprecation")
OfflinePlayer offPlayer = Bukkit.getOfflinePlayer(item.getCustomHead());
skullMeta.setOwner(offPlayer.getName());
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
}
}

View File

@ -43,7 +43,7 @@ public class YmlMaker {
if (f != null)
try {
f.close();
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
}
}

View File

@ -46,7 +46,7 @@ public class Job {
// items
private HashMap<String, JobItems> jobItems;
// limited items
private List<JobLimitedItems> jobLimitedItems;
private HashMap<String, JobLimitedItems> jobLimitedItems;
// job name
private String jobName = "N/A";
// job short name (for use in multiple jobs)
@ -108,7 +108,7 @@ public class Job {
*/
public Job(String jobName, String jobShortName, String description, ChatColor jobColour, Parser maxExpEquation, DisplayMethod displayMethod, int maxLevel,
int vipmaxLevel, Integer maxSlots, List<JobPermission> jobPermissions, List<JobCommands> jobCommands, List<JobConditions> jobConditions, HashMap<String, JobItems> jobItems,
List<JobLimitedItems> jobLimitedItems, List<String> CmdOnJoin, List<String> CmdOnLeave, ItemStack GUIitem, String bossbar, Long rejoinCD) {
HashMap<String, JobLimitedItems> jobLimitedItems, List<String> CmdOnJoin, List<String> CmdOnLeave, ItemStack GUIitem, String bossbar, Long rejoinCD) {
this.jobName = jobName;
this.jobShortName = jobShortName;
this.description = description;
@ -379,8 +379,12 @@ public class Job {
* Get the limited item nodes for this job
* @return Limited items for this job
*/
public List<JobLimitedItems> getLimitedItems() {
return Collections.unmodifiableList(jobLimitedItems);
public HashMap<String, JobLimitedItems> getLimitedItems() {
return jobLimitedItems;
}
public JobLimitedItems getLimitedITems(String key) {
return jobLimitedItems.get(key.toLowerCase());
}
public String getBossbar() {

View File

@ -18,21 +18,34 @@
package com.gamingmesh.jobs.container;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import org.bukkit.ChatColor;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
public class JobLimitedItems {
private String node;
private int id;
private int data;
private int amount;
private String name;
private List<String> lore;
private HashMap<Enchantment, Integer> enchants;
private int level;
public JobLimitedItems(String node, int id, String name, List<String> lore, HashMap<Enchantment, Integer> enchants, int level) {
public JobLimitedItems(String node, int id, int data, int amount, String name, List<String> lore, HashMap<Enchantment, Integer> enchants, int level) {
this.node = node;
this.id = id;
this.data = data;
this.amount = amount;
this.name = name;
this.lore = lore;
this.enchants = enchants;
@ -43,6 +56,33 @@ public class JobLimitedItems {
return node;
}
public ItemStack getItemStack(Player player) {
try {
CMIMaterial cm = CMIMaterial.get(id, data);
ItemStack item = cm.newItemStack();
item.setAmount(amount);
ItemMeta meta = item.getItemMeta();
if (this.name != null)
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
if (lore != null && !lore.isEmpty()) {
List<String> TranslatedLore = new ArrayList<>();
for (String oneLore : lore) {
TranslatedLore.add(ChatColor.translateAlternateColorCodes('&', oneLore.replace("[player]", player.getName())));
}
meta.setLore(TranslatedLore);
}
if (enchants != null)
for (Entry<Enchantment, Integer> OneEnchant : enchants.entrySet()) {
meta.addEnchant(OneEnchant.getKey(), OneEnchant.getValue(), true);
}
item.setItemMeta(meta);
return item;
} catch (Throwable e) {
}
return null;
}
public int getId() {
return id;
}

View File

@ -57,15 +57,15 @@ public class JobsManager {
public void start(LocaleReader c) {
c.getW().addComment("storage.method", "storage method, can be MySQL or sqlite");
String storageMethod = c.get("storage.method", "sqlite");
c.getW().addComment("mysql-username", "Requires Mysql.");
c.get("mysql-username", "root");
c.get("mysql-password", "");
c.get("mysql-hostname", "localhost:3306");
c.get("mysql-database", "minecraft");
c.get("mysql-table-prefix", "jobs_");
c.get("verify-server-certificate", false);
c.get("use-ssl", false);
c.get("auto-reconnect", false);
c.getW().addComment("mysql", "Requires Mysql.");
c.get("mysql.username", "root");
c.get("mysql.password", "");
c.get("mysql.hostname", "localhost:3306");
c.get("mysql.database", "minecraft");
c.get("mysql.table-prefix", "jobs_");
c.get("mysql.verify-server-certificate", false);
c.get("mysql.use-ssl", false);
c.get("mysql.auto-reconnect", false);
if (storageMethod.equalsIgnoreCase("mysql")) {
DbType = DataBaseType.MySQL;
@ -85,30 +85,30 @@ public class JobsManager {
private synchronized JobsMySQL startMysql() {
File f = new File(Jobs.getFolder(), "generalConfig.yml");
YamlConfiguration config = YamlConfiguration.loadConfiguration(f);
String legacyUrl = config.getString("mysql-url");
String legacyUrl = config.getString("mysql.url");
if (legacyUrl != null) {
String jdbcString = "jdbc:mysql://";
if (legacyUrl.toLowerCase().startsWith(jdbcString)) {
legacyUrl = legacyUrl.substring(jdbcString.length());
String[] parts = legacyUrl.split("/");
if (parts.length >= 2) {
config.set("mysql-hostname", parts[0]);
config.set("mysql-database", parts[1]);
config.set("mysql.hostname", parts[0]);
config.set("mysql.database", parts[1]);
}
}
}
String username = config.getString("mysql-username");
String username = config.getString("mysql.username");
if (username == null) {
Jobs.getPluginLogger().severe("mysql-username property invalid or missing");
Jobs.getPluginLogger().severe("mysql username property invalid or missing");
}
String password = config.getString("mysql-password");
String hostname = config.getString("mysql-hostname");
String database = config.getString("mysql-database");
String prefix = config.getString("mysql-table-prefix");
String password = config.getString("mysql.password");
String hostname = config.getString("mysql.hostname");
String database = config.getString("mysql.database");
String prefix = config.getString("mysql.table-prefix");
boolean certificate = config.getBoolean("verify-server-certificate", false);
boolean ssl = config.getBoolean("use-ssl", false);
boolean autoReconnect = config.getBoolean("auto-reconnect");
boolean certificate = config.getBoolean("mysql.verify-server-certificate", false);
boolean ssl = config.getBoolean("mysql.use-ssl", false);
boolean autoReconnect = config.getBoolean("mysql.auto-reconnect");
if (plugin.isEnabled()) {
JobsMySQL data = new JobsMySQL(plugin, hostname, database, username, password, prefix, certificate, ssl, autoReconnect);
data.initialize();

View File

@ -14,7 +14,8 @@ public class JobsMySQL extends JobsDAO {
private Jobs plugin;
JobsMySQL(Jobs plugin, String hostname, String database, String username, String password, String prefix, boolean certificate, boolean ssl, boolean autoReconnect) {
super(plugin, "com.mysql.jdbc.Driver", "jdbc:mysql://" + hostname + "/" + database + "?useUnicode=true&characterEncoding=UTF-8&autoReConnect=" + autoReconnect + "&useSSL=" + ssl + "&verifyServerCertificate=" + certificate, username, password, prefix);
super(plugin, "com.mysql.jdbc.Driver", "jdbc:mysql://" + hostname + "/" + database + "?useUnicode=true&characterEncoding=UTF-8&autoReConnect=" + autoReconnect + "&useSSL=" + ssl
+ "&verifyServerCertificate=" + certificate, username, password, prefix);
this.plugin = plugin;
this.database = database;
this.setDbType(DataBaseType.MySQL);
@ -43,7 +44,7 @@ public class JobsMySQL extends JobsDAO {
protected synchronized void setupConfig() throws SQLException {
JobsConnection conn = getConnection();
if (conn == null) {
Jobs.consoleMsg("&cCould not run database updates! Could not connect to MySQL!");
Jobs.consoleMsg("&cCould not run database updates! Could not connect to MySQL!");
return;
}
PreparedStatement prest = null;
@ -82,7 +83,7 @@ public class JobsMySQL extends JobsDAO {
protected synchronized void checkUpdate() throws SQLException {
JobsConnection conn = getConnection();
if (conn == null) {
Jobs.consoleMsg("&cCould not run database updates! Could not connect to MySQL!");
Jobs.consoleMsg("&cCould not run database updates! Could not connect to MySQL!");
return;
}
createDefaultUsersBase();
@ -170,7 +171,6 @@ public class JobsMySQL extends JobsDAO {
statement.close();
return true;
} catch (SQLException e) {
// e.printStackTrace();
Jobs.consoleMsg("Not a culumn |" + "SELECT " + collumn + " FROM " + table + "|");
close(statement);
return false;
@ -193,7 +193,6 @@ public class JobsMySQL extends JobsDAO {
return true;
} catch (SQLException e) {
close(statement);
// e.printStackTrace();
return false;
}
}

View File

@ -658,7 +658,7 @@ public class JobsListener implements Listener {
Map<Enchantment, Integer> enchants = new HashMap<>();
try {
enchants = iih.getEnchantments();
} catch (Exception e) {
} catch (Throwable e) {
return;
}
if (enchants.isEmpty())
@ -675,7 +675,7 @@ public class JobsListener implements Listener {
String meinOk = null;
mein: for (JobProgression one : prog) {
for (JobLimitedItems oneItem : one.getJob().getLimitedItems()) {
for (JobLimitedItems oneItem : one.getJob().getLimitedItems().values()) {
if (one.getLevel() >= oneItem.getLevel())
continue;
if (!isThisItem(oneItem, iih.getType().getId(), name, lore, enchants))

View File

@ -71,7 +71,7 @@ public class FurnaceBrewingHandling {
totalf += blist.size();
}
}
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
}
}
@ -111,7 +111,7 @@ public class FurnaceBrewingHandling {
totalb += blist.size();
}
}
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
}
}

View File

@ -33,13 +33,13 @@ public class GiveItem {
ItemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
itemStack.setItemMeta(ItemMeta);
player.getInventory().addItem(itemStack);
player.getPlayer().updateInventory();
player.updateInventory();
return true;
}
public static boolean GiveItemForPlayer(Player player, ItemStack item) {
player.getInventory().addItem(item);
player.getPlayer().updateInventory();
player.updateInventory();
return true;
}
}

View File

@ -16,6 +16,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobItems;
import com.gamingmesh.jobs.container.JobLimitedItems;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
@ -76,9 +77,15 @@ public class TabComplete implements TabCompleter {
case "[jobitemname]":
Job oneJob = Jobs.getJob(args[i - 1]);
if (oneJob != null)
for (Entry<String, JobItems> item : oneJob.getItemBonus().entrySet()) {
temp.add(item.getValue().getNode());
}
if (args[3].equals("items")) {
for (Entry<String, JobItems> item : oneJob.getItemBonus().entrySet()) {
temp.add(item.getValue().getNode());
}
} else if (args[3].equals("limiteditems")) {
for (Entry<String, JobLimitedItems> limitedItem : oneJob.getLimitedItems().entrySet()) {
temp.add(limitedItem.getValue().getNode());
}
}
break;
case "[oldjob]":
JobsPlayer onePlayerJob = Jobs.getPlayerManager().getJobsPlayer(args[i - 1]);

View File

@ -76,7 +76,7 @@ public class blockLoc {
y = Integer.parseInt(split[2]);
z = Integer.parseInt(split[3]);
return true;
} catch (Exception e) {
} catch (Throwable e) {
return false;
}
}

View File

@ -103,7 +103,7 @@ command:
finalExplanation: ' &eNem tartalmazza a Petpay és az idéző bónusz/penaltyFinal bónuszt'
convert:
help:
info: 'Adatbázis-rendszert alakít át egyik rendszerről a másikra. Ha jelenleg SQLite fut, ez átalakul MySQL-re és vise versa.'
info: 'Adatbázis-rendszert alakít át egyik rendszerről a másikra. Ha jelenleg SQLite fut, ez átalakul MySQL-re és oda-vissza.'
args: ''
limit:
help:
@ -118,7 +118,7 @@ command:
pointsLimit: '&ePont limit: &2%current%&e/&2%total%'
reachedmoneylimit: '&4Elérted a pénzkorlátot az adott időben!'
reachedmoneylimit2: '&eA korlátot ellenőrizheted a &2/jobs limit &eparanccsal.'
reachedmoneylimit3: '&eA szerzett pénz most már exponenciálisan csökkentve... De még mindig egy kicsit keres!!'
reachedmoneylimit3: '&eA szerzett pénz most már exponenciálisan csökkentve... De még mindig egy kicsit keres!'
reachedexplimit: '&4Elérted a határidőt a meghatározott időben!'
reachedexplimit2: '&eA korlátot ellenőrizheted a &2/jobs limit &eparanccsal.'
reachedpointslimit: '&4Elérted a határidőt a meghatározott időben!'
@ -247,7 +247,7 @@ command:
give:
help:
info: 'A tárgyakat a feladatok neve és az elemek kategóriája alapján adja meg. A játékos neve opcionális.'
args: '[playername] [jobname] [jobitemname]'
args: '[playername] [jobname] [items/limiteditems] [jobitemname]'
output:
notonline: '&4[%playername%] nem elérhető!'
noitem: '&4Nincs találat ezzel a névvel lévő tárgyról!'