1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-04 23:37:49 +01:00
- Fix when points are not added to the player account, Fixes #833
This commit is contained in:
montlikadani 2020-06-29 13:19:12 +02:00
parent 21fa78ee92
commit db82201051
23 changed files with 61 additions and 165 deletions

View File

@ -17,7 +17,7 @@ import com.gamingmesh.jobs.CMIGUI.GUIManager.GUIClickType;
import com.gamingmesh.jobs.CMIGUI.GUIManager.GUIFieldType;
import com.gamingmesh.jobs.CMILib.CMIItemStack;
import com.gamingmesh.jobs.CMILib.CMIMaterial;
import com.gamingmesh.jobs.CMILib.Reflections;
import com.gamingmesh.jobs.CMILib.CMIReflections;
public class CMIGuiButton {
@ -25,7 +25,7 @@ public class CMIGuiButton {
private GUIFieldType fieldType = GUIFieldType.Locked;
private boolean closeInv = false;
private HashMap<GUIClickType, List<GUIButtonCommand>> commandMap = new HashMap<GUIClickType, List<GUIButtonCommand>>();
private HashMap<GUIClickType, List<GUIButtonCommand>> commandMap = new HashMap<>();
private List<String> permissions = new ArrayList<String>();
private ItemStack item = null;
@ -260,7 +260,7 @@ public class CMIGuiButton {
ItemStack i = item.clone();
if (isLocked()) {
i = Reflections.setNbt(item, GUIManager.CMIGUIIcon, GUIManager.LIProtection);
i = CMIReflections.setNbt(item, GUIManager.CMIGUIIcon, GUIManager.LIProtection);
}
ItemMeta meta = i.getItemMeta();

View File

@ -18,8 +18,7 @@ import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.Reflections;
import com.gamingmesh.jobs.CMILib.CMIReflections;
public class GUIListener implements Listener {
Jobs plugin;
@ -41,14 +40,14 @@ public class GUIListener implements Listener {
private static void clearIconItems(Player player) {
for (ItemStack one : player.getInventory().getContents()) {
Object res = Reflections.getNbt(one, GUIManager.CMIGUIIcon);
Object res = CMIReflections.getNbt(one, GUIManager.CMIGUIIcon);
if (res == null || !(res instanceof String) || !((String) res).equalsIgnoreCase(GUIManager.LIProtection))
continue;
player.getInventory().remove(one);
}
}
private HashMap<UUID, Long> LastClick = new HashMap<UUID, Long>();
private HashMap<UUID, Long> LastClick = new HashMap<>();
private boolean canClickByTimer(UUID uuid) {
Long time = LastClick.get(uuid);
@ -97,7 +96,7 @@ public class GUIListener implements Listener {
return;
}
final List<Integer> buttons = new ArrayList<Integer>();
final List<Integer> buttons = new ArrayList<>();
buttons.add(event.getRawSlot());
if (!GUIManager.canClick(player, buttons)) {
event.setCancelled(true);
@ -142,7 +141,7 @@ public class GUIListener implements Listener {
return;
}
final List<Integer> buttons = new ArrayList<Integer>();
final List<Integer> buttons = new ArrayList<>();
buttons.addAll(event.getRawSlots());
if (!GUIManager.canClick(player, buttons)) {
event.setCancelled(true);

View File

@ -16,11 +16,11 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.Reflections;
import com.gamingmesh.jobs.CMILib.CMIReflections;
public class GUIManager {
private static HashMap<UUID, CMIGui> map = new HashMap<UUID, CMIGui>();
private static HashMap<UUID, CMIGui> map = new HashMap<>();
public final static String CMIGUIIcon = "CMIGUIIcon";
public final static String LIProtection = "LIProtection";
@ -346,7 +346,7 @@ public class GUIManager {
ItemStack item = one.getValue().getItem(gui.getPlayer());
item = item == null ? null : item.clone();
if (item != null && one.getValue().isLocked()) {
item = Reflections.setNbt(item, CMIGUIIcon, LIProtection);
item = CMIReflections.setNbt(item, CMIGUIIcon, LIProtection);
}
GuiInv.setItem(one.getKey(), item);
} catch (ArrayIndexOutOfBoundsException e) {

View File

@ -11,7 +11,6 @@ import java.util.regex.Pattern;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.jetbrains.annotations.Nullable;
public class CMIChatColor {
@ -203,7 +202,7 @@ public class CMIChatColor {
}
public static CMIChatColor getRandomColor() {
List<CMIChatColor> ls = new ArrayList<CMIChatColor>();
List<CMIChatColor> ls = new ArrayList<>();
for (Entry<String, CMIChatColor> one : BY_NAME.entrySet()) {
if (!one.getValue().isColor())
continue;

View File

@ -2,16 +2,13 @@ package com.gamingmesh.jobs.CMILib;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta;
import org.bukkit.inventory.meta.ItemMeta;
public enum CMIEntityType {
@ -264,7 +261,7 @@ public enum CMIEntityType {
private String name;
private String secondaryName;
EntityType type = null;
public static HashMap<String, ItemStack> cache = new HashMap<String, ItemStack>();
public static HashMap<String, ItemStack> cache = new HashMap<>();
CMIEntityType(int id, String name, List<String> headTextures) {
this(id, name, null, headTextures);

View File

@ -17,7 +17,6 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
public class CMIItemStack {

View File

@ -1218,7 +1218,6 @@ public enum CMIMaterial {
}
CMIMaterial(Integer legacyId, Integer legacyData, Integer id, List<CMIMaterialCriteria> criteria, String name, String... legacyName) {
this.legacyId = legacyId;
this.legacyData = legacyData;
this.id = id;
@ -1354,8 +1353,7 @@ public enum CMIMaterial {
}
public static CMIMaterial getRandom(CMIMaterial mat) {
List<CMIMaterial> ls = new ArrayList<CMIMaterial>();
List<CMIMaterial> ls = new ArrayList<>();
for (CMIMaterial one : CMIMaterial.values()) {
if (one.getLegacyId() == null)
@ -1401,16 +1399,15 @@ public enum CMIMaterial {
}
public static CMIMaterial get(String id) {
if (id == null)
return CMIMaterial.NONE;
Integer ids = null;
Integer data = null;
id = id.replace("_", "").replace(" ", "").replace("minecraft:", "").toLowerCase();
if (id.contains(":")) {
try {
ids = Integer.parseInt(id.split(":")[0]);
Integer ids = Integer.parseInt(id.split(":")[0]);
data = Integer.parseInt(id.split(":")[1]);
if (ids <= 0)
return CMIMaterial.NONE;
@ -1498,12 +1495,8 @@ public enum CMIMaterial {
if (block == null)
return CMIMaterial.NONE;
try {
if (Bukkit.getWorld(block.getWorld().getUID()) == null)
return CMIMaterial.NONE;
} catch (Throwable e) {
e.printStackTrace();
}
if (Bukkit.getWorld(block.getWorld().getUID()) == null)
return CMIMaterial.NONE;
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) {
return ItemManager.byRealMaterial.get(block.getType());
@ -2408,6 +2401,8 @@ public enum CMIMaterial {
case CRIMSON_WALL_SIGN:
case WARPED_WALL_SIGN:
return true;
default:
break;
}
return false;
}
@ -2644,7 +2639,8 @@ public enum CMIMaterial {
return false;
}
public static CMISlabType getSlabType(Block block) {
@SuppressWarnings("deprecation")
public static CMISlabType getSlabType(Block block) {
if (!isSlab(block.getType()))
return CMISlabType.NOTSLAB;
@ -2658,6 +2654,8 @@ public enum CMIMaterial {
return CMISlabType.BOTTOM;
case DOUBLE:
return CMISlabType.DOUBLE;
default:
break;
}
}
@ -2705,6 +2703,8 @@ public enum CMIMaterial {
default:
return CMISlabType.DOUBLE;
}
default:
break;
}
}
@ -2770,14 +2770,12 @@ public enum CMIMaterial {
}
public List<String> getLegacyNames() {
if (legacyName == null)
return new ArrayList<String>();
return legacyName;
return legacyName == null ? new ArrayList<>() : legacyName;
}
public void addLegacyName(String legacyName) {
if (legacyName == null)
this.legacyName = new ArrayList<String>();
this.legacyName = new ArrayList<>();
this.legacyName.add(legacyName);
}

View File

@ -7,15 +7,14 @@ package com.gamingmesh.jobs.CMILib;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import org.bukkit.Bukkit;
import org.bukkit.inventory.ItemStack;
import com.gamingmesh.jobs.Jobs;
public class CMIReflections {
private Class<?> CraftServerClass;
private Object CraftServer;
//private Class<?> CraftServerClass;
//private Object CraftServer;
private static Class<?> NBTTagCompound;
private Class<?> NBTBase;
@ -31,8 +30,8 @@ public class CMIReflections {
private void initialize() {
try {
CraftServerClass = getBukkitClass("CraftServer");
CraftServer = CraftServerClass.cast(Bukkit.getServer());
//CraftServerClass = getBukkitClass("CraftServer");
//CraftServer = CraftServerClass.cast(Bukkit.getServer());
NBTTagCompound = getMinecraftClass("NBTTagCompound");
NBTBase = getMinecraftClass("NBTBase");
/*try {

View File

@ -15,7 +15,6 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.Version;
import com.gamingmesh.jobs.container.Potion;
import com.gamingmesh.jobs.stuff.Util;

View File

@ -12,7 +12,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
public class ItemReflection {

View File

@ -15,8 +15,8 @@ import org.bukkit.inventory.ItemStack;
public class RawMessage {
List<String> parts = new ArrayList<String>();
List<String> cleanParts = new ArrayList<String>();
List<String> parts = new ArrayList<>();
List<String> cleanParts = new ArrayList<>();
private String unfinished = "";
private String unfinishedClean = "";
@ -29,8 +29,8 @@ public class RawMessage {
// private boolean colorizeEntireWithLast = true;
public void clear() {
parts = new ArrayList<String>();
cleanParts = new ArrayList<String>();
parts = new ArrayList<>();
cleanParts = new ArrayList<>();
combined = "";
combinedClean = "";
}
@ -63,10 +63,10 @@ public class RawMessage {
return add(text, hoverText, command, suggestion, null);
}
Set<CMIChatColor> formats = new HashSet<CMIChatColor>();
Set<CMIChatColor> formats = new HashSet<>();
CMIChatColor lastColor = null;
Set<CMIChatColor> savedFormats = new HashSet<CMIChatColor>();
Set<CMIChatColor> savedFormats = new HashSet<>();
CMIChatColor savedLastColor = null;
CMIChatColor firstBlockColor = null;
@ -91,7 +91,7 @@ public class RawMessage {
text = text.replaceAll(decolmatch.group(), string);
}
List<String> splited = new ArrayList<String>();
List<String> splited = new ArrayList<>();
if (text.contains(" ")) {
for (String one : text.split(" ")) {
// if (this.isBreakLine() && one.contains("\\n")) {
@ -120,7 +120,7 @@ public class RawMessage {
Pattern prepattern = Pattern.compile(CMIChatColor.hexColorRegex);
List<String> plt = new ArrayList<String>(splited);
List<String> plt = new ArrayList<>(splited);
splited.clear();
for (String one : plt) {
Matcher match = prepattern.matcher(one);
@ -234,10 +234,10 @@ public class RawMessage {
}
one = one.replace(c.getColorCode(), c.getColorCode() + form);
} else if (c.getHex() != null) {
String form = "";
for (CMIChatColor oneC : formats) {
form += oneC.getColorCode();
}
//String form = "";
//for (CMIChatColor oneC : formats) {
//form += oneC.getColorCode();
//}
// CMIDebug.d("*"+net.md_5.bungee.api.ChatColor.of("#" + c.getHex())+ "_"+net.md_5.bungee.api.ChatColor.of("#FF00FF")+ "+");
@ -567,7 +567,7 @@ public class RawMessage {
}
public List<String> softCombine() {
List<String> ls = new ArrayList<String>();
List<String> ls = new ArrayList<>();
String f = "";
for (String part : parts) {
if (f.isEmpty())

View File

@ -44,97 +44,6 @@ public class VersionChecker {
return version;
}
public enum Version {
v1_7_R1,
v1_7_R2,
v1_7_R3,
v1_7_R4,
v1_8_R1,
v1_8_R2,
v1_8_R3,
v1_9_R1,
v1_9_R2,
v1_10_R1,
v1_11_R1,
v1_12_R1,
v1_13_R1,
v1_13_R2,
v1_14_R1,
v1_14_R2,
v1_15_R1,
v1_15_R2,
v1_16_R1,
v1_16_R2,
v1_17_R1,
v1_17_R2;
private Integer value;
private String shortVersion;
private static Version current = null;
Version() {
try {
this.value = Integer.valueOf(this.name().replaceAll("[^\\d.]", ""));
} catch (Exception e) {
}
shortVersion = this.name().substring(0, this.name().length() - 3);
}
public Integer getValue() {
return value;
}
public String getShortVersion() {
return shortVersion;
}
public static Version getCurrent() {
if (current != null)
return current;
String[] v = Bukkit.getServer().getClass().getPackage().getName().split("\\.");
String vv = v[v.length - 1];
for (Version one : values()) {
if (one.name().equalsIgnoreCase(vv)) {
current = one;
break;
}
}
return current;
}
public boolean isLower(Version version) {
return getValue() < version.getValue();
}
public boolean isHigher(Version version) {
return getValue() > version.getValue();
}
public boolean isEqualOrLower(Version version) {
return getValue() <= version.getValue();
}
public boolean isEqualOrHigher(Version version) {
return getValue() >= version.getValue();
}
public static boolean isCurrentEqualOrHigher(Version v) {
return getCurrent().getValue() >= v.getValue();
}
public static boolean isCurrentHigher(Version v) {
return getCurrent().getValue() > v.getValue();
}
public static boolean isCurrentLower(Version v) {
return getCurrent().getValue() < v.getValue();
}
public static boolean isCurrentEqualOrLower(Version v) {
return getCurrent().getValue() <= v.getValue();
}
}
public void VersionCheck(final Player player) {
if (!Jobs.getGCManager().isShowNewVersion())
return;

View File

@ -49,7 +49,6 @@ import com.gamingmesh.jobs.stuff.*;
import com.gamingmesh.jobs.tasks.BufferedPaymentThread;
import com.gamingmesh.jobs.tasks.DatabaseSaveThread;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;

View File

@ -19,14 +19,14 @@ import org.bukkit.configuration.file.YamlConfiguration;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.CMIMaterial;
import com.gamingmesh.jobs.CMILib.ConfigReader;
import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
import com.gamingmesh.jobs.CMILib.Version;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.TopList;
public class SignUtil {
private HashMap<String, HashMap<String, jobsSign>> SignsByType = new HashMap<String, HashMap<String, jobsSign>>();
private HashMap<String, jobsSign> SignsByLocation = new HashMap<String, jobsSign>();
private HashMap<String, HashMap<String, jobsSign>> SignsByType = new HashMap<>();
private HashMap<String, jobsSign> SignsByLocation = new HashMap<>();
public HashMap<String, HashMap<String, jobsSign>> getSigns() {
return SignsByType;

View File

@ -15,6 +15,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.ActionBarManager;
import com.gamingmesh.jobs.CMILib.RawMessage;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.Boost;
@ -142,7 +143,7 @@ public class JobsCommands implements CommandExecutor {
PageInfo pi = new PageInfo(7, commands.size(), page);
if (page > pi.getTotalPages() || page < 1) {
Jobs.getActionBar().send(sender, Jobs.getLanguage().getMessage("general.error.noHelpPage"));
ActionBarManager.send(sender, Jobs.getLanguage().getMessage("general.error.noHelpPage"));
return true;
}

View File

@ -5,7 +5,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.CMIMaterial;
import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
import com.gamingmesh.jobs.CMILib.Version;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.stuff.Util;

View File

@ -4,7 +4,7 @@ import com.gamingmesh.jobs.CMILib.CMIEntityType;
import com.gamingmesh.jobs.CMILib.CMIMaterial;
import com.gamingmesh.jobs.CMILib.ItemReflection;
import com.gamingmesh.jobs.CMILib.RawMessage;
import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
import com.gamingmesh.jobs.CMILib.Version;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;

View File

@ -58,7 +58,6 @@ public class editpoints implements Cmd {
}
Jobs.getJobsDAO().savePoints(jPlayer);
Jobs.getJobsDAO().loadPoints(jPlayer);
return true;
}
}

View File

@ -17,7 +17,7 @@ import com.gamingmesh.jobs.CMILib.CMIEntityType;
import com.gamingmesh.jobs.CMILib.CMIMaterial;
import com.gamingmesh.jobs.CMILib.ItemReflection;
import com.gamingmesh.jobs.CMILib.RawMessage;
import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
import com.gamingmesh.jobs.CMILib.Version;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.ActionType;

View File

@ -8,7 +8,6 @@ import java.util.Map.Entry;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.ConfigurationSection;

View File

@ -23,7 +23,6 @@ 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;

View File

@ -18,8 +18,9 @@
package com.gamingmesh.jobs.economy;
import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.ActionBarManager;
import com.gamingmesh.jobs.CMILib.Version;
import com.gamingmesh.jobs.api.JobsPaymentEvent;
import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.JobsPlayer;
@ -159,7 +160,7 @@ public class BufferedEconomy {
if (ServerTaxesAccount.isOnline()) {
if (Jobs.getGCManager().ActionBarsMessageByDefault) {
Jobs.getActionBar().send(Bukkit.getPlayer(ServerAccountname),
ActionBarManager.send(Bukkit.getPlayer(ServerAccountname),
Jobs.getLanguage().getMessage("message.taxes", "[amount]", (int) (TotalAmount * 100) / 100.0));
}
}
@ -191,7 +192,7 @@ public class BufferedEconomy {
if (Jobs.getGCManager().UseServerAccount) {
if (!hasMoney) {
Jobs.getActionBar().send(payment.getOfflinePlayer().getPlayer(), Jobs.getLanguage().getMessage("economy.error.nomoney"));
ActionBarManager.send(payment.getOfflinePlayer().getPlayer(), Jobs.getLanguage().getMessage("economy.error.nomoney"));
continue;
}
}
@ -242,7 +243,7 @@ public class BufferedEconomy {
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.exp", new Object[] { "[exp]", String.format(Jobs.getGCManager().getDecimalPlacesExp(), new Object[] {
Double.valueOf(payment.get(CurrencyType.EXP)) }) });
}
Jobs.getActionBar().send(abp, Message);
ActionBarManager.send(abp, Message);
}
}
}

View File

@ -17,8 +17,8 @@ import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.Reflections;
import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
import com.gamingmesh.jobs.CMILib.CMIReflections;
import com.gamingmesh.jobs.CMILib.Version;
import com.gamingmesh.jobs.container.ScoreboardInfo;
public class CMIScoreboardManager {
@ -204,7 +204,7 @@ public class CMIScoreboardManager {
}
private static Class<?> getNMSClass(String nmsClassString) throws ClassNotFoundException {
return Reflections.getMinecraftClass(nmsClassString);
return CMIReflections.getMinecraftClass(nmsClassString);
}
private static Object getConnection(Player player) throws Exception {