1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 20:16:13 +01:00

Fix potion recognition bug

- /jobs editjobs now actually check for off hand.
- Some fixes in /jobs editjobs command
- Fix translatable words file generating problems for potions
- Fix NPE when enchant action was pay for item enchanting but throws exception
- MythicMobs update
This commit is contained in:
montlikadani 2019-02-22 19:31:57 +01:00
parent 8aafd9f903
commit 78ff26d124
25 changed files with 312 additions and 256 deletions

View File

@ -64,9 +64,9 @@
<dependency>
<groupId>io.lumine.xikage.mythicmobs</groupId>
<artifactId>MythicMobs</artifactId>
<version>4.5.1</version>
<version>4.5.5</version>
<scope>system</scope>
<systemPath>${basedir}/libs/MythicMobs-4.5.1.jar</systemPath>
<systemPath>${basedir}/libs/MythicMobs-4.5.5.jar</systemPath>
</dependency>
<!-- WorldGuard -->
<dependency>
@ -176,4 +176,4 @@
<!-- </plugin> -->
</plugins>
</build>
</project>
</project>

View File

@ -20,6 +20,7 @@ import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.potion.PotionType;
import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
@ -360,6 +361,195 @@ public class ItemManager {
}
}
public enum CMIPotionType {
Awkward(373, 16, "Awkard Potion"),
Fire_Resistance_1(373, 8195, "Fire Resistance Potion"),
Fire_Resistance_2(373, 8259, "Fire Resistance potion 2"),
Harming_1(373, 8204, "Harming Potion"),
Harming_2(373, 8236, "Harming Potion 2"),
Healing_1(373, 8197, "Healing Potion"),
Healing_2(373, 8229, "Healing Potion 2"),
Invisibility_1(373, 8206, "Invisibility Potion"),
Invisibility_2(373, 8270, "Invisibility Potion 2"),
Leaping_1(373, 8267, "Leaping Potion"),
Leaping_2(373, 8235, "Leaping Potion 2"),
Luck(-1, -1, "Luck Potion"),
Mundane(373, 64, "Mundane Potion"),
Night_Vision_1(373, 8198, "Night Vision Potion"),
Night_Vision_2(373, 8262, "Night Vision Potion 2"),
Poison_1(373, 8196, "Poison Potion"),
Poison_2(373, 8228, "Poison Potion 2"),
Poison_3(373, 8260, "Poison Potion 3"),
Poison_4(373, 8292, "Poison Potion 4"),
Regeneration_1(373, 8193, "Regeneration Potion"),
Regeneration_2(373, 8225, "Regeneration Potion 2"),
Regeneration_3(373, 8257, "Regeneration Potion 3"),
Regeneration_4(373, 8289, "Regeneration Potion 4"),
Slow_Falling_1(-1, -1, "Slow Falling Potion"),
Slow_Falling_2(-1, -1, "Slow Falling Potion 2"),
Slowness_1(373, 8202, "Slowness Potion"),
Slowness_2(373, 8266, "Slowness Potion 2"),
Strength_1(373, 8201, "Strength Potion"),
Strength_2(373, 8233, "Strength Potion 2"),
Strength_3(373, 8265, "Strength Potion 3"),
Strength_4(373, 8297, "Strength Potion 4"),
Swiftness_1(373, 8194, "Swiftness Potion"),
Swiftness_2(373, 8226, "Swiftness Potion 2"),
Swiftness_3(373, 8258, "Swiftness Potion 3"),
Swiftness_4(373, 8290, "Swiftness Potion 4"),
Thick(373, 32, "Thick Potion"),
Turtle_Master_1(-1, -1, "Turtle Master Potion"),
Turtle_Master_2(-1, -1, "Turtle Master Potion 2"),
Turtle_Master_3(-1, -1, "Turtle Master Potion 3"),
Water_Breathing_1(373, 8205, "Water Breathing Potion"),
Water_Breathing_2(373, 8269, "Water Breathing Potion 2"),
Weakness_1(373, 8200, "Weakness Potion"),
Weakness_2(373, 8264, "Weakness Potion 2"),
Water(373, 0, "Water Potion");
private int id;
private int subId;
private String name;
PotionType type = null;
CMIPotionType(int id, int subId, String name) {
this.id = id;
this.subId = subId;
this.name = name;
}
public int getId() {
return id;
}
public int getSubId() {
return subId;
}
public String getName() {
return name;
}
public String getOneWordName() {
return name.replace(" ", "");
}
public static CMIPotionType getById(int id) {
for (CMIPotionType one : CMIPotionType.values()) {
if (one.getId() == id)
return one;
}
return CMIPotionType.Water;
}
public static CMIPotionType getByType(PotionType potion) {
return getByName(potion.toString());
}
public static CMIPotionType getByName(String name) {
String main = name;
String sub = null;
if (name.contains("_")) {
main = name.split("_")[0];
sub = name.split("_")[1];
}
if (name.contains(":")) {
main = name.split(":")[0];
sub = name.split(":")[1];
}
String updated = (main + (sub == null ? "" : sub)).toLowerCase();
String reverse = ((sub == null ? "" : sub) + main).toLowerCase();
CMIPotionType type = null;
Integer id = null;
try {
id = Integer.parseInt(main);
} catch (Throwable e) {
}
for (CMIPotionType one : CMIPotionType.values()) {
if (one.name().replace("_", "").equalsIgnoreCase(updated) || one.name.replace(" ", "").equalsIgnoreCase(updated)) {
type = one;
break;
}
}
if (type == null)
for (CMIPotionType one : CMIPotionType.values()) {
if (one.name.replace("_", "").contains(updated)) {
type = one;
break;
}
}
if (sub != null) {
if (type == null)
for (CMIPotionType one : CMIPotionType.values()) {
if (one.name().replace("_", "").equalsIgnoreCase(reverse) || one.name.replace(" ", "").equalsIgnoreCase(reverse)) {
type = one;
break;
}
}
if (type == null)
for (CMIPotionType one : CMIPotionType.values()) {
if (one.name.replace("_", "").contains(reverse)) {
type = one;
break;
}
}
}
if (id != null) {
if (type == null)
for (CMIPotionType one : CMIPotionType.values()) {
if (one.getId() == id) {
type = one;
break;
}
}
}
if (type == null)
for (CMIPotionType one : CMIPotionType.values()) {
if (one.name.contains("_"))
continue;
if (one.name.equalsIgnoreCase(main)) {
type = one;
break;
}
}
return type;
}
public PotionType getType() {
if (type != null)
return type;
for (PotionType one : PotionType.values()) {
if (one.toString().equalsIgnoreCase(this.name())) {
type = one;
break;
}
}
return type;
}
public static String getRealNameByType(PotionType type) {
if (type == null)
return null;
CMIPotionType ctype = CMIPotionType.getByType(type);
if (ctype != null)
return ctype.getName();
String name = type.name();
name = name.toLowerCase().replace("_", " ");
name = name.substring(0, 1).toUpperCase() + name.substring(1);
return name;
}
}
public enum CMIEntityType {
PLAYER(-1, "Player"),
DROPPED_ITEM(1, "Item"),
@ -1224,53 +1414,6 @@ public class ItemManager {
PORKCHOP(319, 0, 30896, "Raw Porkchop"),
POTATO(392, 0, 21088, "Potato", "Potatoitem"),
POTATOES(142, 0, 10879, "Potatoes"),
// Potions
POTION(373, 0, 24020, "Potion", "POTION_WATER"),
POTION_AWKWARD(373, 16, 24020, "Awkard Potion"),
POTION_FIRE_RESISTANCE_1(373, 8195, 24020, "Fire Resistance Potion"),
POTION_FIRE_RESISTANCE_2(373, 8259, 24020, "Fire Resistance potion 2"),
POTION_HARMING_1(373, 8204, 24020, "Harming Potion"),
POTION_HARMING_2(373, 8236, 24020, "Harming Potion 2"),
POTION_HEALING_1(373, 8197, 24020, "Healing Potion"),
POTION_HEALING_2(373, 8229, 24020, "Healing Potion 2"),
POTION_INVISIBILITY_1(373, 8206, 24020, "Invisibility Potion"),
POTION_INVISIBILITY_2(373, 8270, 24020, "Invisibility Potion 2"),
POTION_LEAPING_1(373, 8267, 24020, "Leaping Potion"),
POTION_LEAPING_2(373, 8235, 24020, "Leaping Potion 2"),
POTION_LUCK(-1, -1, 24020, "Luck Potion"),
POTION_MUNDANE(373, 64, 24020, "Mundane Potion"),
POTION_NIGHT_VISION_1(373, 8198, 24020, "Night Vision Potion"),
POTION_NIGHT_VISION_2(373, 8262, 24020, "Night Vision Potion 2"),
POTION_POISON_1(373, 8196, 24020, "Poison Potion"),
POTION_POISON_2(373, 8228, 24020, "Poison Potion 2"),
POTION_POISON_3(373, 8260, 24020, "Poison Potion 3"),
POTION_POISON_4(373, 8292, 24020, "Poison Potion 4"),
POTION_REGENERATION_1(373, 8193, 24020, "Regeneration Potion"),
POTION_REGENERATION_2(373, 8225, 24020, "Regeneration Potion 2"),
POTION_REGENERATION_3(373, 8257, 24020, "Regeneration Potion 3"),
POTION_REGENERATION_4(373, 8289, 24020, "Regeneration Potion 4"),
POTION_SLOW_FALLING_1(-1, -1, 24020, "Slow Falling Potion"),
POTION_SLOW_FALLING_2(-1, -1, 24020, "Slow Falling Potion 2"),
POTION_SLOWNESS_1(373, 8202, 24020, "Slowness Potion"),
POTION_SLOWNESS_2(373, 8266, 24020, "Slowness Potion 2"),
POTION_STRENGTH_1(373, 8201, 24020, "Strength Potion"),
POTION_STRENGTH_2(373, 8233, 24020, "Strength Potion 2"),
POTION_STRENGTH_3(373, 8265, 24020, "Strength Potion 3"),
POTION_STRENGTH_4(373, 8297, 24020, "Strength Potion 4"),
POTION_SWIFTNESS_1(373, 8194, 24020, "Swiftness Potion"),
POTION_SWIFTNESS_2(373, 8226, 24020, "Swiftness Potion 2"),
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, -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"),
POTION_WEAKNESS_2(373, 8264, 24020, "Weakness Potion 2"),
POTTED_ACACIA_SAPLING(-1, -1, 14096, "Potted Acacia Sapling"),
POTTED_ALLIUM(-1, -1, 13184, "Potted Allium"),
POTTED_AZURE_BLUET(-1, -1, 8754, "Potted Azure Bluet"),
@ -2082,69 +2225,6 @@ public class ItemManager {
return false;
}
public static boolean isPotion(Material mat) {
CMIMaterial m = CMIMaterial.get(mat);
if (m == null)
return false;
return m.isPotion();
}
public boolean isPotion() {
switch (this) {
case LINGERING_POTION:
case SPLASH_POTION:
case POTION:
case POTION_AWKWARD:
case POTION_FIRE_RESISTANCE_1:
case POTION_FIRE_RESISTANCE_2:
case POTION_HARMING_1:
case POTION_HARMING_2:
case POTION_HEALING_1:
case POTION_HEALING_2:
case POTION_INVISIBILITY_1:
case POTION_INVISIBILITY_2:
case POTION_LEAPING_1:
case POTION_LEAPING_2:
case POTION_LUCK:
case POTION_MUNDANE:
case POTION_NIGHT_VISION_1:
case POTION_NIGHT_VISION_2:
case POTION_POISON_1:
case POTION_POISON_2:
case POTION_POISON_3:
case POTION_POISON_4:
case POTION_REGENERATION_1:
case POTION_REGENERATION_2:
case POTION_REGENERATION_3:
case POTION_REGENERATION_4:
case POTION_SLOW_FALLING_1:
case POTION_SLOW_FALLING_2:
case POTION_SLOWNESS_1:
case POTION_SLOWNESS_2:
case POTION_STRENGTH_1:
case POTION_STRENGTH_2:
case POTION_STRENGTH_3:
case POTION_STRENGTH_4:
case POTION_SWIFTNESS_1:
case POTION_SWIFTNESS_2:
case POTION_SWIFTNESS_3:
case POTION_SWIFTNESS_4:
case POTION_THICK:
case POTION_TURTLE_MASTER_1:
case POTION_TURTLE_MASTER_2:
case POTION_TURTLE_MASTER_3:
case POTION_WATER_BREATHING_1:
case POTION_WATER_BREATHING_2:
case POTION_WEAKNESS_1:
case POTION_WEAKNESS_2:
return true;
default:
break;
}
return false;
}
public static boolean isBoat(Material mat) {
CMIMaterial m = CMIMaterial.get(mat);
if (m == null)

View File

@ -27,9 +27,6 @@ public class GuiManager {
public HashMap<UUID, GuiInfoList> GuiList = new HashMap<>();
public GuiManager() {
}
public void CloseInventories() {
for (Entry<UUID, GuiInfoList> one : GuiList.entrySet()) {
Player player = Bukkit.getPlayer(one.getKey());

View File

@ -24,10 +24,6 @@ public class ItemBoostManager {
private static HashMap<String, JobItems> items = new HashMap<>();
private static HashMap<String, JobItems> legacy = new HashMap<>();
public ItemBoostManager() {
}
public static void load() {
ConfigReader cfg = null;

View File

@ -174,7 +174,7 @@ public class Jobs extends JavaPlugin {
try {
Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType");
getServer().getPluginManager().registerEvents(new McMMO2_X_listener(this), this);
} catch (Exception e) {
} catch (Throwable e) {
getServer().getPluginManager().registerEvents(new McMMO1_X_listener(this), this);
}
}
@ -853,9 +853,9 @@ public class Jobs extends JavaPlugin {
getServer().getPluginManager().registerEvents(new JobsListener(this), this);
getServer().getPluginManager().registerEvents(new JobsPaymentListener(this), this);
if (getMcMMOManager().CheckmcMMO())
setMcMMOlistener();
setMcMMOlistener();
setMyPetManager();
setWorldGuard();

View File

@ -14,7 +14,6 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.actions.ItemActionInfo;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.Debug;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;

View File

@ -13,7 +13,6 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.actions.ItemActionInfo;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;

View File

@ -15,10 +15,6 @@ public class McMMOManager {
private HashMap<UUID, HashMap<String, Long>> map = new HashMap<>();
public McMMOManager() {
// TODO Auto-generated constructor stub
}
public double getMultiplier(Player player) {
if (player == null)

View File

@ -56,7 +56,6 @@ import com.gamingmesh.jobs.dao.JobsDAO;
import com.gamingmesh.jobs.dao.JobsDAOData;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.economy.PointsData;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.PerformCommands;
public class PlayerManager {
@ -73,9 +72,6 @@ public class PlayerManager {
private HashMap<Integer, PlayerInfo> PlayerIDMap = new HashMap<>();
private HashMap<String, PlayerInfo> PlayerNameMap = new HashMap<>();
public PlayerManager() {
}
public PointsData getPointsData() {
return PointsDatabase;
}
@ -789,14 +785,14 @@ public class PlayerManager {
Object itemName = Jobs.getReflections().getNbt(item, "JobsItemBoost");
if (itemName == null || ((String) itemName).isEmpty()) {
if (itemName == null || itemName.toString().isEmpty()) {
// Checking old boost items and converting to new format if needed
if (Jobs.getReflections().hasNbt(item, "JobsItemBoost")) {
for (Job one : Jobs.getJobs()) {
itemName = Jobs.getReflections().getNbt(item, "JobsItemBoost", one.getName());
if (itemName != null) {
JobItems b = ItemBoostManager.getItemByKey((String) itemName);
JobItems b = ItemBoostManager.getItemByKey(itemName.toString());
if (b != null) {
ItemStack ic = Jobs.getReflections().setNbt(item, "JobsItemBoost", b.getNode());
item.setItemMeta(ic.getItemMeta());
@ -808,7 +804,7 @@ public class PlayerManager {
if (itemName == null)
return null;
}
JobItems b = ItemBoostManager.getItemByKey((String) itemName);
JobItems b = ItemBoostManager.getItemByKey(itemName.toString());
if (b == null)
return null;

View File

@ -1,31 +1,26 @@
/**
* Jobs Plugin for Bukkit
* Copyright (C) 2011 Zak Ford <zak.j.ford@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.gamingmesh.jobs.actions;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionType;
import com.gamingmesh.jobs.container.ActionInfo;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.BaseActionInfo;
public class PotionDrinkInfo extends MaterialActionInfo implements ActionInfo {
@SuppressWarnings("deprecation")
public PotionDrinkInfo(ItemStack potion, ActionType type) {
super(potion.getType(), potion.getData().getData(), type);
public class PotionDrinkInfo extends BaseActionInfo implements ActionInfo {
private PotionType potion;
public PotionDrinkInfo(PotionType potion, ActionType type) {
super(type);
this.potion = potion;
}
@Override
public String getName() {
return potion.name();
}
@Override
public String getNameWithSub() {
return getName();
}
}

View File

@ -13,6 +13,8 @@ import org.bukkit.inventory.ItemStack;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.ItemManager.CMIEntityType;
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
import com.gamingmesh.jobs.CMILib.ItemManager.CMIPotionType;
import com.gamingmesh.jobs.CMILib.ItemReflection;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.ActionType;
@ -372,6 +374,9 @@ public class editjobs implements Cmd {
ItemStack item = Jobs.getNms().getItemInMainHand(player);
key = item.getType().name() + "-" + item.getData().getData();
break;
case "offhand":
item = ItemReflection.getItemInOffHand(player);
key = item.getType().name() + "-" + item.getData().getData();
case "looking":
case "lookingat":
Block block = Util.getTargetBlock(player, 30);
@ -416,6 +421,7 @@ public class editjobs implements Cmd {
case CRAFT:
case BREW:
case BREAK:
case STRIPLOGS:
material = CMIMaterial.get(myKey + (subType));
if (material == null)
@ -442,7 +448,7 @@ public class editjobs implements Cmd {
}
c: if (material != null) {
c: if (material != null && material.getMaterial() != null) {
// Need to include thos ones and count as regular blocks
switch (key.replace("_", "").toLowerCase()) {
@ -463,22 +469,22 @@ public class editjobs implements Cmd {
break c;
}
if (actionT == ActionType.BREAK || actionT == ActionType.PLACE) {
if (actionT == ActionType.BREAK || actionT == ActionType.PLACE || actionT == ActionType.STRIPLOGS) {
if (!material.isBlock()) {
player.sendMessage(ChatColor.GOLD + "Job " + job.getName() + " has an invalid " + actionT.getName() + " type property: " + key
+ "! Material must be a block!");
player.sendMessage(ChatColor.GOLD + "Job " + job.getName() + " has an invalid " + actionT.getName() + " type property: " + material
+ "(" + key + ")! Material must be a block!");
break;
}
}
if (material == CMIMaterial.REDSTONE_ORE && actionT == ActionType.BREAK && Version.isCurrentLower(Version.v1_13_R1)) {
player.sendMessage(ChatColor.GOLD + "Job " + job.getName() + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE.");
player.sendMessage(ChatColor.GOLD + "Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
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_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.");
player.sendMessage(ChatColor.GOLD + "Automatically changing block to REDSTONE_ORE. Please update your configuration.");
material = CMIMaterial.REDSTONE_ORE;
}
@ -487,10 +493,10 @@ public class editjobs implements Cmd {
} else if (actionT == ActionType.KILL || actionT == ActionType.TAME || actionT == ActionType.BREED || actionT == ActionType.MILK) {
// check entities
EntityType entity = EntityType.fromName(key);
EntityType entity = EntityType.fromName(myKey.toUpperCase());
if (entity == null) {
try {
entity = EntityType.valueOf(key.toUpperCase());
entity = EntityType.valueOf(myKey.toUpperCase());
} catch (IllegalArgumentException e) {
}
}
@ -504,6 +510,7 @@ public class editjobs implements Cmd {
Jobs.getGCManager().setBreederFinder(true);
}
if (entity == null) {
switch (key.toLowerCase()) {
case "skeletonwither":
type = CMIEntityType.WITHER_SKELETON.name();
@ -541,6 +548,7 @@ public class editjobs implements Cmd {
meta = "1";
break;
}
}
} else if (actionT == ActionType.ENCHANT) {
Enchantment enchant = Enchantment.getByName(myKey);
@ -553,9 +561,9 @@ public class editjobs implements Cmd {
}
}
type = myKey;
} else if (actionT == ActionType.CUSTOMKILL || actionT == ActionType.SHEAR || actionT == ActionType.MMKILL) {
} else if (actionT == ActionType.CUSTOMKILL || actionT == ActionType.SHEAR || actionT == ActionType.MMKILL)
type = myKey;
} else if (actionT == ActionType.EXPLORE) {
else if (actionT == ActionType.EXPLORE) {
type = myKey;
int amount = 10;
try {
@ -566,8 +574,15 @@ public class editjobs implements Cmd {
}
Jobs.getExplore().setExploreEnabled();
Jobs.getExplore().setPlayerAmount(amount + 1);
} else if (actionT == ActionType.CRAFT && myKey.startsWith("!")) {
} else if (actionT == ActionType.CRAFT && myKey.startsWith("!"))
type = myKey.substring(1, myKey.length());
else if (actionT == ActionType.DRINK) {
type = myKey;
CMIPotionType potion = CMIPotionType.valueOf(myKey);
if (potion != null) {
type = potion.toString();
id = potion.getId();
}
}
if (type == null) {

View File

@ -46,6 +46,7 @@ import com.gamingmesh.jobs.ItemBoostManager;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.ItemManager.CMIEntityType;
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
import com.gamingmesh.jobs.CMILib.ItemManager.CMIPotionType;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.BoostMultiplier;
import com.gamingmesh.jobs.container.CurrencyType;
@ -233,7 +234,7 @@ public class ConfigManager {
}
c: if (material != null) {
c: if (material != null && material.getMaterial() != null) {
// Need to include thos ones and count as regular blocks
switch (myKey.replace("_", "").toLowerCase()) {
@ -359,9 +360,9 @@ public class ConfigManager {
}
}
type = myKey;
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.SHEAR || actionType == ActionType.MMKILL) {
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.SHEAR || actionType == ActionType.MMKILL)
type = myKey;
} else if (actionType == ActionType.EXPLORE) {
else if (actionType == ActionType.EXPLORE) {
type = myKey;
int amount = 10;
try {
@ -372,13 +373,18 @@ public class ConfigManager {
}
Jobs.getExplore().setExploreEnabled();
Jobs.getExplore().setPlayerAmount(amount);
} else if (actionType == ActionType.CRAFT && myKey.startsWith("!")) {
} else if (actionType == ActionType.CRAFT && myKey.startsWith("!"))
type = myKey.substring(1, myKey.length());
} else if (actionType == ActionType.DRINK) {
else if (actionType == ActionType.DRINK) {
type = myKey;
PotionType potion = PotionType.valueOf(myKey);
if (potion != null)
type = potion.name().toString().replace("_", "").toLowerCase();
try {
PotionType potion = PotionType.valueOf(myKey);
if (potion != null)
type = potion.name().toString().replace("_", "").toLowerCase();
} catch (IllegalArgumentException i) {
// Ignoring the not invalid potion
// Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid potion " + myKey + "!");
}
}
if (type == null) {
@ -884,7 +890,7 @@ public class ConfigManager {
kv = getKeyValue(sqsection.getString("Target"), actionType, jobName);
else if (sqsection.isList("Target")) {
for (int i = 0; i < sqsection.getStringList("Target").size(); i++) {
kv = getKeyValue(sqsection.getStringList("Target").get(i), actionType, jobName);
kv = getKeyValue(sqsection.getStringList("Target").get(i), actionType, jobName);
}
}
@ -1126,9 +1132,9 @@ public class ConfigManager {
}
}
type = myKey;
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.SHEAR || actionType == ActionType.MMKILL) {
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.SHEAR || actionType == ActionType.MMKILL)
type = myKey;
} else if (actionType == ActionType.EXPLORE) {
else if (actionType == ActionType.EXPLORE) {
type = myKey;
int amount = 10;
try {
@ -1142,13 +1148,16 @@ public class ConfigManager {
} else if (actionType == ActionType.CRAFT && myKey.startsWith("!"))
type = myKey.substring(1, myKey.length());
else if (actionType == ActionType.DRINK) {
type = myKey;
// type = myKey;
try {
PotionType potion = PotionType.valueOf(myKey);
if (potion != null)
type = potion.name().toString().replace("_", "").toLowerCase();
CMIPotionType potion = CMIPotionType.getByName(key);
if (potion != null) {
type = potion.toString();
id = potion.getId();
}
} catch (IllegalArgumentException i) {
Jobs.getPluginLogger().warning("Job" + jobKey + " has an invalid potion " + myKey + "!");
// Ignoring the not invalid potion
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid potion " + key + "!");
}
}

View File

@ -13,6 +13,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.ConfigReader;
import com.gamingmesh.jobs.CMILib.ItemManager.CMIEntityType;
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
import com.gamingmesh.jobs.CMILib.ItemManager.CMIPotionType;
import com.gamingmesh.jobs.container.JobInfo;
import com.gamingmesh.jobs.container.NameList;
import com.gamingmesh.jobs.stuff.Util;
@ -496,33 +497,24 @@ public class NameTranslatorManager {
c.get("ColorList." + cn.getId() + "-" + cn.toString(), name);
}*/
for (CMIMaterial one : CMIMaterial.values()) {
if (one.getMaterial() == null)
continue;
if (!one.isPotion())
continue;
String n = one.getLegacyId() + (one.getLegacyData() == -1 ? "" : ":" + one.getLegacyData());
for (CMIPotionType one : CMIPotionType.values()) {
String n = String.valueOf(one.getSubId());
String name = null;
if (c.getC().isConfigurationSection("PotionNamesList." + n)) {
if (c.getC().isConfigurationSection("PotionNamesList." + n))
name = c.getC().getString("PotionNamesList." + n + ".Name");
}
if (name == null) {
n = one.getLegacyData() + "-" + one.toString();
if (c.getC().isConfigurationSection("PotionNamesList." + n)) {
n = n + "-" + one.toString();
if (c.getC().isConfigurationSection("PotionNamesList." + n))
name = c.getC().getString("PotionNamesList." + n);
}
}
if (name == null) {
if (name == null)
name = one.getName();
}
c.get("PotionNamesList." + one.getLegacyData() + "-" + one.toString(), name);
c.get("PotionNamesList." + one.getSubId() + "-" + one.toString(), name);
}
c.save();

View File

@ -22,9 +22,6 @@ public class RestrictedAreaManager {
protected HashMap<String, RestrictedArea> restrictedAreas = new HashMap<>();
public RestrictedAreaManager() {
}
public boolean isExist(String name) {
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
if (area.getKey().equalsIgnoreCase(name))

View File

@ -13,9 +13,6 @@ public class RestrictedBlockManager {
public HashMap<Integer, Integer> restrictedBlocksTimer = new HashMap<>();
public RestrictedBlockManager() {
}
/**
* Method to load the restricted areas configuration
*

View File

@ -34,9 +34,6 @@ public class ShopManager {
public List<ShopItem> list = new ArrayList<>();
public HashMap<String, Integer> GuiList = new HashMap<>();
public ShopManager() {
}
public List<ShopItem> getShopItemList() {
return list;
}

View File

@ -37,7 +37,7 @@ public class JobConditions {
int jobLevel = 0;
try {
jobLevel = Integer.valueOf(one.toLowerCase().replace("j:", "").split("-")[1]);
} catch (Exception e) {
} catch (Throwable e) {
continue;
}
requiresJobs.put(jobName, jobLevel);

View File

@ -56,9 +56,8 @@ public class JobsMySQL extends JobsDAO {
prest.setString(1, database);
prest.setString(2, getPrefix() + "config");
res = prest.executeQuery();
if (res.next()) {
if (res.next())
rows = res.getInt(1);
}
} finally {
close(res);
close(prest);
@ -131,10 +130,10 @@ public class JobsMySQL extends JobsDAO {
statement.close();
} catch (SQLException e) {
Jobs.consoleMsg("&cCould not create table, SQLException: " + e.getMessage());
this.close(statement);
close(statement);
return false;
} finally {
this.close(statement);
close(statement);
}
return true;
}
@ -176,7 +175,7 @@ public class JobsMySQL extends JobsDAO {
return false;
} catch (SQLException e) {
Jobs.consoleMsg("Not a table |" + "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ='" + table + "';" + "|");
JobsDAO.close(statement);
close(statement);
return false;
}
}

View File

@ -11,8 +11,6 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.dao.JobsManager.DataBaseType;
public class JobsSQLite extends JobsDAO {
@SuppressWarnings("unused")
private Jobs plugin;
public void initialize() {
try {
@ -22,8 +20,7 @@ public class JobsSQLite extends JobsDAO {
}
}
public JobsSQLite initialize(Jobs plugin, File dir) {
this.plugin = plugin;
public JobsSQLite initialize(File dir) {
if (!dir.exists())
dir.mkdirs();
try {

View File

@ -10,9 +10,6 @@ public class PointsData {
private HashMap<UUID, PlayerPoints> Pointbase = new HashMap<>();
public PointsData() {
}
public HashMap<UUID, PlayerPoints> getPointBase() {
return Pointbase;
}

View File

@ -78,6 +78,7 @@ import org.bukkit.inventory.AnvilInventory;
import org.bukkit.inventory.EnchantingInventory;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.projectiles.ProjectileSource;
@ -774,29 +775,25 @@ public class JobsPaymentListener implements Listener {
if (resultStack == null)
return;
if (inv.getItem(1).getType() != Material.ENCHANTED_BOOK) {
// Checking if this is only item rename
ItemStack FirstSlot = null;
try {
FirstSlot = inv.getItem(0);
} catch (NullPointerException e) {
return;
}
if (FirstSlot == null)
return;
String OriginalName = null;
String NewName = null;
if (FirstSlot.hasItemMeta())
if (FirstSlot.getItemMeta().getDisplayName() != null)
OriginalName = FirstSlot.getItemMeta().getDisplayName();
if (resultStack.hasItemMeta())
if (resultStack.getItemMeta().getDisplayName() != null)
NewName = resultStack.getItemMeta().getDisplayName();
if (OriginalName != NewName && inv.getItem(1) == null)
if (!Jobs.getGCManager().PayForRenaming)
return;
// Checking if this is only item rename
ItemStack FirstSlot = null;
try {
FirstSlot = inv.getItem(0);
} catch (NullPointerException e) {
return;
}
if (FirstSlot == null)
return;
String OriginalName = null;
String NewName = null;
if (FirstSlot.hasItemMeta() && FirstSlot.getItemMeta().getDisplayName() != null)
OriginalName = FirstSlot.getItemMeta().getDisplayName();
if (resultStack.hasItemMeta() && resultStack.getItemMeta().getDisplayName() != null)
NewName = resultStack.getItemMeta().getDisplayName();
if (OriginalName != NewName && inv.getItem(1) == null)
if (!Jobs.getGCManager().PayForRenaming)
return;
// Check for world permissions
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
@ -1593,8 +1590,15 @@ public class JobsPaymentListener implements Listener {
if (jPlayer == null)
return;
if (event.getItem().getType() != Material.POTION)
return;
// Player drinking a potion
Jobs.action(jPlayer, new PotionDrinkInfo(Jobs.getNms().getItemInMainHand(p), ActionType.DRINK));
PotionMeta meta = (PotionMeta) event.getItem().getItemMeta();
if (meta == null)
return;
Jobs.action(jPlayer, new PotionDrinkInfo(meta.getBasePotionData().getType(), ActionType.DRINK));
}
@EventHandler

View File

@ -13,9 +13,6 @@ import com.gamingmesh.jobs.Jobs;
public class PistonProtectionListener implements Listener {
public PistonProtectionListener() {
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void OnBlockMove(BlockPistonExtendEvent event) {

View File

@ -22,9 +22,6 @@ import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
public class TabComplete implements TabCompleter {
public TabComplete() {
Debug.D("created tab complete");
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {

View File

@ -227,13 +227,13 @@ Jobs:
experience: 1.0
# payment for drinking a potion
Drink:
potion:
water:
income: 0.5
experience: 2.0
potion_regeneration_2:
regeneration_2:
income: 1.3
experience: 2.0
potion_healing_1:
healing_1:
income: 1.4
experience: 2.0
# payment for breaking a block with tnt