1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-02 14:29:07 +01:00

Back to Vault 1.6.7

- Clean up code
This commit is contained in:
montlikadani 2018-09-17 17:38:58 +02:00
parent 7240f6cb39
commit bb8a32a6f0
11 changed files with 64 additions and 80 deletions

BIN
libs/Vault-1.6.7.jar Normal file

Binary file not shown.

Binary file not shown.

View File

@ -64,7 +64,7 @@
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>1.7.1</version>
<version>1.6.7</version>
<scope>provided</scope>
<exclusions>
<exclusion>

View File

@ -30,7 +30,7 @@ public class ItemManager {
static HashMap<String, CMIItemStack> byBukkitName = new HashMap<>();
static HashMap<String, CMIItemStack> byMojangName = new HashMap<>();
static HashMap<CMIMaterial, CMIItemStack> byMaterial = new HashMap<>();
static final Version version = Jobs.getVersionCheckManager().getVersion();
private final static Version version = Jobs.getVersionCheckManager().getVersion();
@SuppressWarnings("deprecation")
public static void load() {
@ -1560,7 +1560,7 @@ public class ItemManager {
}
public int getId() {
if (Jobs.getVersionCheckManager().getVersion().isEqualOrHigher(Version.v1_13_R1)) {
if (version.isEqualOrHigher(Version.v1_13_R1)) {
return this.id;
}
return getLegacyId();
@ -1616,7 +1616,7 @@ public class ItemManager {
break;
}
}
if (Jobs.getVersionCheckManager().getVersion().isEqualOrHigher(Version.v1_13_R1)) {
if (version.isEqualOrHigher(Version.v1_13_R1)) {
return new ItemStack(mat == null ? Material.STONE : mat);
}
return new ItemStack(mat == null ? Material.STONE : mat, 1, (short) this.getLegacyData());
@ -1625,7 +1625,7 @@ public class ItemManager {
@Deprecated
public short getData() {
if (Jobs.getVersionCheckManager().getVersion().isEqualOrHigher(Version.v1_13_R1)) {
if (version.isEqualOrHigher(Version.v1_13_R1)) {
return 0;
}
return (short) legacyData;

View File

@ -34,7 +34,6 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -148,9 +147,9 @@ public class Jobs extends JavaPlugin {
public static WeakHashMap<String, Boolean> actionbartoggle = new WeakHashMap<>();
public static WeakHashMap<String, Boolean> BossBartoggle = new WeakHashMap<>();
// public static WeakHashMap<String, Double> GlobalBoost = new WeakHashMap<String, Double>();
private static BufferedEconomy economy;
private static PermissionHandler permissionHandler;
private static PermissionManager permissionManager;
private static BufferedEconomy economy = null;
private static PermissionHandler permissionHandler = null;
private static PermissionManager permissionManager = null;
// private static ItemManager itemManager;
@ -243,7 +242,7 @@ public class Jobs extends JavaPlugin {
public static Reflections getReflections() {
if (reflections == null)
reflections = new Reflections(instance);
reflections = new Reflections();
return reflections;
}
@ -543,14 +542,14 @@ public class Jobs extends JavaPlugin {
loadAllPlayersData();
// add all online players
for (Player online : Bukkit.getServer().getOnlinePlayers()) {
Jobs.getPlayerManager().playerJoin(online);
pManager.playerJoin(online);
}
}
public static void loadAllPlayersData() {
long time = System.currentTimeMillis();
// Cloning to avoid issues
HashMap<UUID, PlayerInfo> temp = new HashMap<>(Jobs.getPlayerManager().getPlayersInfoUUIDMap());
HashMap<UUID, PlayerInfo> temp = new HashMap<>(pManager.getPlayersInfoUUIDMap());
HashMap<Integer, List<JobsDAOData>> playersJobs = dao.getAllJobs();
HashMap<Integer, PlayerPoints> playersPoints = dao.getAllPoints();
HashMap<Integer, HashMap<String, Log>> playersLogs = dao.getAllLogs();
@ -561,7 +560,7 @@ public class Jobs extends JavaPlugin {
Entry<UUID, PlayerInfo> one = it.next();
try {
int id = one.getValue().getID();
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(
JobsPlayer jPlayer = pManager.getJobsPlayerOffline(
one.getValue(),
playersJobs.get(id),
playersPoints.get(id),
@ -570,15 +569,15 @@ public class Jobs extends JavaPlugin {
playersLimits.get(id));
if (jPlayer == null)
continue;
Jobs.getPlayerManager().addPlayerToCache(jPlayer);
pManager.addPlayerToCache(jPlayer);
} catch (Exception e) {
e.printStackTrace();
}
}
dao.getMap().clear();
if (Jobs.getPlayerManager().getPlayersCache().size() != 0)
consoleMsg("&e[Jobs] Preloaded " + Jobs.getPlayerManager().getPlayersCache().size() + " players data in " + ((int) (((System.currentTimeMillis() - time)
if (pManager.getPlayersCache().size() != 0)
consoleMsg("&e[Jobs] Preloaded " + pManager.getPlayersCache().size() + " players data in " + ((int) (((System.currentTimeMillis() - time)
/ 1000d) * 100) / 100D));
}
@ -604,7 +603,7 @@ public class Jobs extends JavaPlugin {
GconfigManager.reload();
lManager.reload();
Jobs.getConfigManager().reload();
configManager.reload();
usedSlots.clear();
for (Job job : jobs) {
usedSlots.put(job, getJobsDAO().getSlotsTaken(job));
@ -625,8 +624,8 @@ public class Jobs extends JavaPlugin {
dao.loadPlayerData();
// Schedule
Jobs.getScheduleManager().load();
Jobs.getScheduleManager().start();
scheduleManager.load();
scheduleManager.start();
permissionManager = new PermissionManager();
}
@ -652,7 +651,7 @@ public class Jobs extends JavaPlugin {
* Executes close connections
*/
public static void ChangeDatabase() {
getDBManager().switchDataBase();
DBManager.switchDataBase();
pManager.reload();
}
@ -701,8 +700,8 @@ public class Jobs extends JavaPlugin {
* Sets the permission handler
* @param h - the permission handler
*/
public void setPermissionHandler(PermissionHandler h) {
permissionHandler = h;
public void setPermissionHandler(PermissionHandler permissionHandler) {
Jobs.permissionHandler = permissionHandler;
}
/**
@ -839,7 +838,7 @@ public class Jobs extends JavaPlugin {
// all loaded properly.
dao.loadBlockProtection();
getExplore().load();
exploreManager.load();
FurnaceBrewingHandling.load();
@ -866,7 +865,7 @@ public class Jobs extends JavaPlugin {
FurnaceBrewingHandling.save();
Jobs.shutdown();
shutdown();
consoleMsg("&e[Jobs] &2Plugin has been disabled succesfully.");
running = false;
this.setEnabled(false);
@ -982,12 +981,12 @@ public class Jobs extends JavaPlugin {
return;
if (info.getType() == ActionType.BREAK && block != null)
Jobs.getBpManager().remove(block);
BpManager.remove(block);
if (pointAmount != 0D)
jPlayer.setSaved(false);
Jobs.getEconomy().pay(jPlayer, income, pointAmount, 0.0);
economy.pay(jPlayer, income, pointAmount, 0.0);
if (GconfigManager.LoggingUse) {
HashMap<CurrencyType, Double> amounts = new HashMap<>();
@ -1039,7 +1038,7 @@ public class Jobs extends JavaPlugin {
player.giveExp(expInt);
}
}
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, prog.getJob(), ent, victim);
Boost boost = pManager.getFinalBonus(jPlayer, prog.getJob(), ent, victim);
// Calculate income
if (income != 0D) {
@ -1100,11 +1099,11 @@ public class Jobs extends JavaPlugin {
try {
if (expAmount != 0D && GconfigManager.BossBarEnabled)
if (GconfigManager.BossBarShowOnEachAction)
Jobs.getBBManager().ShowJobProgression(jPlayer, prog);
BBManager.ShowJobProgression(jPlayer, prog);
else
jPlayer.getUpdateBossBarFor().add(prog.getJob().getName());
} catch (Exception e) {
Bukkit.getConsoleSender().sendMessage("[Jobs] Some issues with boss bar feature accured, try disabling it to avoid it.");
consoleMsg("[Jobs] Some issues with boss bar feature accured, try disabling it to avoid it.");
}
// JobsPayment event
@ -1153,17 +1152,17 @@ public class Jobs extends JavaPlugin {
//player.sendMessage("This block is protected using Rukes' system!");
return false;
}
BlockProtection bp = getBpManager().getBp(block.getLocation());
BlockProtection bp = BpManager.getBp(block.getLocation());
if (bp != null) {
Long time = bp.getTime();
Integer cd = getBpManager().getBlockDelayTime(block);
Integer cd = BpManager.getBlockDelayTime(block);
if (time == -1L) {
getBpManager().add(block, cd);
BpManager.add(block, cd);
return false;
}
if ((time < System.currentTimeMillis()) && (bp.getAction() != DBAction.DELETE)) {
getBpManager().remove(block);
BpManager.remove(block);
return true;
}
if (time > System.currentTimeMillis() || bp.isPaid() && bp.getAction() != DBAction.DELETE) {
@ -1174,22 +1173,22 @@ public class Jobs extends JavaPlugin {
}
return false;
}
getBpManager().add(block, cd);
BpManager.add(block, cd);
if ((cd == null || cd == 0) && getGCManager().useGlobalTimer) {
getBpManager().add(block, getGCManager().globalblocktimer);
BpManager.add(block, getGCManager().globalblocktimer);
}
} else if (getGCManager().useGlobalTimer) {
getBpManager().add(block, getGCManager().globalblocktimer);
BpManager.add(block, getGCManager().globalblocktimer);
}
} else if (info.getType() == ActionType.PLACE) {
BlockProtection bp = getBpManager().getBp(block.getLocation());
BlockProtection bp = BpManager.getBp(block.getLocation());
if (bp != null) {
Long time = bp.getTime();
Integer cd = getBpManager().getBlockDelayTime(block);
Integer cd = BpManager.getBlockDelayTime(block);
if (time != -1L) {
if (time < System.currentTimeMillis() && bp.getAction() != DBAction.DELETE) {
getBpManager().add(block, cd);
BpManager.add(block, cd);
return true;
}
if (time > System.currentTimeMillis() || bp.isPaid() && bp.getAction() != DBAction.DELETE) {
@ -1198,16 +1197,16 @@ public class Jobs extends JavaPlugin {
if (player.canGetPaid(info))
getActionBar().send(player.getPlayer(), getLanguage().getMessage("message.blocktimer", "[time]", sec));
}
getBpManager().add(block, cd);
BpManager.add(block, cd);
return false;
}
} else if (bp.isPaid().booleanValue() && bp.getTime() == -1L && cd != null && cd == -1) {
getBpManager().add(block, cd);
BpManager.add(block, cd);
return false;
} else
getBpManager().add(block, cd);
BpManager.add(block, cd);
} else
getBpManager().add(block, getBpManager().getBlockDelayTime(block));
BpManager.add(block, BpManager.getBlockDelayTime(block));
}
return true;
@ -1304,8 +1303,7 @@ public class Jobs extends JavaPlugin {
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("general.error.permission"), "&2" + perm);
rm.show((Player) sender);
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
Jobs.sendMessage(console, Jobs.getLanguage().getMessage("general.error.permission"));
sendMessage(Bukkit.getServer().getConsoleSender(), Jobs.getLanguage().getMessage("general.error.permission"));
return false;
}
return true;

View File

@ -20,11 +20,8 @@ public class Reflections {
private Class<?> CraftItemStack;
private Class<?> Item;
private Class<?> IStack;
@SuppressWarnings("unused")
private Jobs plugin;
public Reflections(Jobs plugin) {
this.plugin = plugin;
public Reflections() {
initialize();
}

View File

@ -25,7 +25,6 @@ import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
@ -43,7 +42,7 @@ public class JobsCommands implements CommandExecutor {
private static final String label = "jobs";
private static final String packagePath = "com.gamingmesh.jobs.commands.list";
private static final List<String> hidenCommands = new ArrayList<>();
Map<String, Integer> CommandList = new HashMap<>();
private Map<String, Integer> CommandList = new HashMap<>();
protected Jobs plugin;
@ -94,8 +93,7 @@ public class JobsCommands implements CommandExecutor {
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("general.error.permission"), "&2" + label + ".command." + cmd);
rm.show(sender);
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
Jobs.sendMessage(console, Jobs.getLanguage().getMessage("general.error.permission"));
Jobs.sendMessage(Bukkit.getServer().getConsoleSender(), Jobs.getLanguage().getMessage("general.error.permission"));
} else
Jobs.sendMessage(sender, Jobs.getLanguage().getMessage("general.error.permission"));
return true;

View File

@ -21,7 +21,7 @@ public class ExploreManager {
private int playerAmount = 1;
public int getPlayerAmount() {
return this.playerAmount;
return playerAmount;
}
public void setPlayerAmount(int amount) {
@ -30,12 +30,12 @@ public class ExploreManager {
}
public boolean isExploreEnabled() {
return this.exploreEnabled;
return exploreEnabled;
}
public void setExploreEnabled() {
if (!exploreEnabled) {
this.exploreEnabled = true;
exploreEnabled = true;
}
}

View File

@ -25,7 +25,7 @@ public class RestrictedArea {
private CuboidArea area;
private double multiplier;
private String name;
private String wgName;
private String wgName;
public RestrictedArea(String name, CuboidArea area, double multiplier) {
this.name = name;

View File

@ -11,11 +11,9 @@ import java.util.Map.Entry;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
@ -1601,7 +1599,6 @@ public abstract class JobsDAO {
int deleted = 0;
Long current = System.currentTimeMillis();
Long mark = System.currentTimeMillis() - (Jobs.getGCManager().BlockProtectionDays * 24L * 60L * 60L * 1000L);
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
for (Entry<World, HashMap<String, HashMap<String, HashMap<String, BlockProtection>>>> worlds : Jobs.getBpManager().getMap().entrySet()) {
for (Entry<String, HashMap<String, HashMap<String, BlockProtection>>> regions : worlds.getValue().entrySet()) {
@ -1617,8 +1614,7 @@ public abstract class JobsDAO {
deleted++;
if (deleted % 10000 == 0) {
delete.executeBatch();
String message = ChatColor.translateAlternateColorCodes('&', "&6[Jobs] Removed " + deleted + " old block protection entries.");
console.sendMessage(message);
Jobs.consoleMsg("&6[Jobs] Removed " + deleted + " old block protection entries.");
}
break;
case INSERT:
@ -1635,8 +1631,7 @@ public abstract class JobsDAO {
inserted++;
if (inserted % 10000 == 0) {
insert.executeBatch();
String message = ChatColor.translateAlternateColorCodes('&', "&6[Jobs] Added " + inserted + " new block protection entries.");
console.sendMessage(message);
Jobs.consoleMsg("&6[Jobs] Added " + inserted + " new block protection entries.");
}
break;
case UPDATE:
@ -1650,8 +1645,7 @@ public abstract class JobsDAO {
updated++;
if (updated % 10000 == 0) {
update.executeBatch();
String message = ChatColor.translateAlternateColorCodes('&', "&6[Jobs] Upadated " + updated + " old block protection entries.");
console.sendMessage(message);
Jobs.consoleMsg("&6[Jobs] Upadated " + updated + " old block protection entries.");
}
break;
case NONE:
@ -1683,16 +1677,13 @@ public abstract class JobsDAO {
conn.commit();
conn.setAutoCommit(true);
if (inserted > 0) {
String message = ChatColor.translateAlternateColorCodes('&', "&6[Jobs] Added " + inserted + " new block protection entries.");
console.sendMessage(message);
Jobs.consoleMsg("&6[Jobs] Added " + inserted + " new block protection entries.");
}
if (updated > 0) {
String message = ChatColor.translateAlternateColorCodes('&', "&6[Jobs] Updated " + updated + " with new block protection entries.");
console.sendMessage(message);
Jobs.consoleMsg("&6[Jobs] Updated " + updated + " with new block protection entries.");
}
if (deleted > 0) {
String message = ChatColor.translateAlternateColorCodes('&', "&6[Jobs] Deleted " + deleted + " old block protection entries.");
console.sendMessage(message);
Jobs.consoleMsg("&6[Jobs] Deleted " + deleted + " old block protection entries.");
}
} catch (SQLException e) {
e.printStackTrace();
@ -1747,15 +1738,13 @@ public abstract class JobsDAO {
ii++;
if (ii >= 100000) {
String message = ChatColor.translateAlternateColorCodes('&', "&6[Jobs] Loading (" + i + ") BP");
Bukkit.getServer().getConsoleSender().sendMessage(message);
Jobs.consoleMsg("&6[Jobs] Loading (" + i + ") BP");
ii = 0;
}
Jobs.getBpManager().timer += System.currentTimeMillis() - t;
}
if (i > 0) {
String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Loaded " + i + " block protection entries. " + Jobs.getBpManager().timer);
Bukkit.getServer().getConsoleSender().sendMessage(message);
Jobs.consoleMsg("&e[Jobs] Loaded " + i + " block protection entries. " + Jobs.getBpManager().timer);
}
} catch (SQLException e) {
e.printStackTrace();
@ -1808,7 +1797,7 @@ public abstract class JobsDAO {
conn.setAutoCommit(true);
if (i > 0)
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Saved " + i + " new explorer entries."));
Jobs.consoleMsg("&e[Jobs] Saved " + i + " new explorer entries.");
} catch (SQLException e) {
e.printStackTrace();
@ -1855,7 +1844,7 @@ public abstract class JobsDAO {
conn.setAutoCommit(true);
if (i > 0)
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Updated " + i + " explorer entries."));
Jobs.consoleMsg("&e[Jobs] Updated " + i + " explorer entries.");
} catch (SQLException e) {
e.printStackTrace();

View File

@ -1532,6 +1532,8 @@ public class JobsPaymentListener implements Listener {
//disabling plugin in world
if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld()))
return;
if (event.isCancelled())
return;
if (!Jobs.getExplore().isExploreEnabled())
return;
@ -1540,7 +1542,7 @@ public class JobsPaymentListener implements Listener {
if (!Jobs.getGCManager().payExploringWhenFlying() && player.isFlying())
return;
ExploreRespond respond = Jobs.getExplore().ChunkRespond(event.getPlayer(), event.getNewChunk());
ExploreRespond respond = Jobs.getExplore().ChunkRespond(player, event.getNewChunk());
if (!respond.isNewChunk())
return;
@ -1553,7 +1555,7 @@ public class JobsPaymentListener implements Listener {
return;
// check if in creative
if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative())
if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative())
return;
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))