mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-26 04:25:15 +01:00
update for 1.10 and stuff
This commit is contained in:
parent
454b9f5c35
commit
b6bf2ad4b6
@ -5,7 +5,7 @@
|
|||||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/Vault1.5.3.jar"/>
|
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/Vault1.5.3.jar"/>
|
||||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/mcMMO#127.jar"/>
|
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/mcMMO#127.jar"/>
|
||||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/CoreProtect_2.12.0.jar"/>
|
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/CoreProtect_2.12.0.jar"/>
|
||||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/spigot-1.9.2.jar"/>
|
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/spigot-1.10.jar"/>
|
||||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/MythicMobs-2.1.8.jar"/>
|
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/MythicMobs-2.1.8.jar"/>
|
||||||
<classpathentry kind="output" path=""/>
|
<classpathentry kind="output" path=""/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -19,6 +19,7 @@ import com.gamingmesh.jobs.container.Job;
|
|||||||
import com.gamingmesh.jobs.container.JobInfo;
|
import com.gamingmesh.jobs.container.JobInfo;
|
||||||
import com.gamingmesh.jobs.container.JobProgression;
|
import com.gamingmesh.jobs.container.JobProgression;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
|
import com.gamingmesh.jobs.stuff.Perm;
|
||||||
|
|
||||||
public class GuiManager {
|
public class GuiManager {
|
||||||
|
|
||||||
@ -91,7 +92,7 @@ public class GuiManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int maxlevel = 0;
|
int maxlevel = 0;
|
||||||
if (player.hasPermission("jobs." + job.getName() + ".vipmaxlevel") && job.getVipMaxLevel() != 0)
|
if (Perm.hasPermission(player, "jobs." + job.getName() + ".vipmaxlevel") && job.getVipMaxLevel() != 0)
|
||||||
maxlevel = job.getVipMaxLevel();
|
maxlevel = job.getVipMaxLevel();
|
||||||
else
|
else
|
||||||
maxlevel = job.getMaxLevel();
|
maxlevel = job.getMaxLevel();
|
||||||
|
@ -410,6 +410,28 @@ public class Jobs {
|
|||||||
*/
|
*/
|
||||||
public static void startup() throws IOException {
|
public static void startup() throws IOException {
|
||||||
reload();
|
reload();
|
||||||
|
|
||||||
|
// add all online players
|
||||||
|
if (!Jobs.getGCManager().MultiServerCompatability()) {
|
||||||
|
int i = 0;
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
for (OfflinePlayer offline : Bukkit.getServer().getOfflinePlayers()) {
|
||||||
|
if (offline.isOnline())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
long lastPlayed = offline.getLastPlayed();
|
||||||
|
int dif = (int) ((time - lastPlayed) / 1000 / 60 / 60 / 24);
|
||||||
|
if (dif >= 7)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
JobsPlayer jPlayer = JobsPlayer.loadFromDao(Jobs.getJobsDAO(), offline);
|
||||||
|
JobsPlayer.loadLogFromDao(jPlayer);
|
||||||
|
Jobs.getPlayerManager().getPlayersCache().put(offline.getName().toLowerCase(), jPlayer);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Preloaded " + i + " players data from last week");
|
||||||
|
}
|
||||||
|
|
||||||
// add all online players
|
// add all online players
|
||||||
for (Player online : Bukkit.getServer().getOnlinePlayers()) {
|
for (Player online : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
Jobs.getPlayerManager().playerJoin(online);
|
Jobs.getPlayerManager().playerJoin(online);
|
||||||
|
@ -40,10 +40,9 @@ public class JobsPlugin extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
String packageName = getServer().getClass().getPackage().getName();
|
String packageName = getServer().getClass().getPackage().getName();
|
||||||
|
String[] packageSplit = packageName.split("\\.");
|
||||||
String[] packageSplit = packageName.split("\\.");
|
String version = packageSplit[packageSplit.length - 1].substring(0,packageSplit[packageSplit.length - 1].length()-3);
|
||||||
String version = packageSplit[packageSplit.length - 1].split("(?<=\\G.{4})")[0];
|
|
||||||
try {
|
try {
|
||||||
Class<?> nmsClass;
|
Class<?> nmsClass;
|
||||||
nmsClass = Class.forName("com.gamingmesh.jobs.nmsUtil." + version);
|
nmsClass = Class.forName("com.gamingmesh.jobs.nmsUtil." + version);
|
||||||
@ -53,110 +52,94 @@ public class JobsPlugin extends JavaPlugin {
|
|||||||
System.out.println("Something went wrong, please note down version and contact author v:" + version);
|
System.out.println("Something went wrong, please note down version and contact author v:" + version);
|
||||||
this.setEnabled(false);
|
this.setEnabled(false);
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
|
||||||
|
| SecurityException e) {
|
||||||
System.out.println("Your server version is not compatible with this plugins version! Plugin will be disabled: " + version);
|
System.out.println("Your server version is not compatible with this plugins version! Plugin will be disabled: " + version);
|
||||||
this.setEnabled(false);
|
this.setEnabled(false);
|
||||||
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
} catch (InstantiationException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
this.setEnabled(false);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
this.setEnabled(false);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
this.setEnabled(false);
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
this.setEnabled(false);
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
this.setEnabled(false);
|
|
||||||
} catch (SecurityException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
this.setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Jobs.setActionBar(new ActionBar());
|
|
||||||
|
|
||||||
// OfflinePlayerList.fillList();
|
|
||||||
YmlMaker jobConfig = new YmlMaker(this, "jobConfig.yml");
|
|
||||||
jobConfig.saveDefaultConfig();
|
|
||||||
|
|
||||||
YmlMaker jobSigns = new YmlMaker(this, "Signs.yml");
|
|
||||||
jobSigns.saveDefaultConfig();
|
|
||||||
|
|
||||||
YmlMaker jobSchedule = new YmlMaker(this, "schedule.yml");
|
|
||||||
jobSchedule.saveDefaultConfig();
|
|
||||||
|
|
||||||
YmlMaker jobShopItems = new YmlMaker(this, "shopItems.yml");
|
|
||||||
jobShopItems.saveDefaultConfig();
|
|
||||||
|
|
||||||
Jobs.setPermissionHandler(new PermissionHandler(this));
|
|
||||||
|
|
||||||
Jobs.setPlayerManager(this);
|
|
||||||
|
|
||||||
Jobs.setScboard(this);
|
|
||||||
Jobs.setLanguage(this);
|
|
||||||
Jobs.setGUIManager(this);
|
|
||||||
Jobs.setExplore();
|
|
||||||
|
|
||||||
Jobs.setBBManager(this);
|
|
||||||
|
|
||||||
Jobs.setPluginLogger(getLogger());
|
|
||||||
|
|
||||||
Jobs.setDataFolder(getDataFolder());
|
|
||||||
|
|
||||||
Jobs.setGCManager(this);
|
|
||||||
Jobs.setConfigManager(this);
|
|
||||||
|
|
||||||
Jobs.setCommandManager(this);
|
|
||||||
|
|
||||||
getCommand("jobs").setExecutor(Jobs.getCommandManager());
|
|
||||||
|
|
||||||
this.getCommand("jobs").setTabCompleter(new TabComplete());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Jobs.setActionBar(new ActionBar());
|
||||||
|
// OfflinePlayerList.fillList();
|
||||||
|
YmlMaker jobConfig = new YmlMaker(this, "jobConfig.yml");
|
||||||
|
jobConfig.saveDefaultConfig();
|
||||||
|
|
||||||
|
YmlMaker jobSigns = new YmlMaker(this, "Signs.yml");
|
||||||
|
jobSigns.saveDefaultConfig();
|
||||||
|
|
||||||
|
YmlMaker jobSchedule = new YmlMaker(this, "schedule.yml");
|
||||||
|
jobSchedule.saveDefaultConfig();
|
||||||
|
|
||||||
|
YmlMaker jobShopItems = new YmlMaker(this, "shopItems.yml");
|
||||||
|
jobShopItems.saveDefaultConfig();
|
||||||
|
|
||||||
|
Jobs.setPermissionHandler(new PermissionHandler(this));
|
||||||
|
|
||||||
|
Jobs.setPlayerManager(this);
|
||||||
|
|
||||||
|
Jobs.setScboard(this);
|
||||||
|
Jobs.setLanguage(this);
|
||||||
|
Jobs.setGUIManager(this);
|
||||||
|
Jobs.setExplore();
|
||||||
|
|
||||||
|
Jobs.setBBManager(this);
|
||||||
|
|
||||||
|
Jobs.setPluginLogger(getLogger());
|
||||||
|
|
||||||
|
Jobs.setDataFolder(getDataFolder());
|
||||||
|
|
||||||
|
Jobs.setGCManager(this);
|
||||||
|
Jobs.setConfigManager(this);
|
||||||
|
|
||||||
|
Jobs.setCommandManager(this);
|
||||||
|
|
||||||
|
getCommand("jobs").setExecutor(Jobs.getCommandManager());
|
||||||
|
|
||||||
|
this.getCommand("jobs").setTabCompleter(new TabComplete());
|
||||||
|
|
||||||
Jobs.startup();
|
Jobs.startup();
|
||||||
|
|
||||||
|
// register the listeners
|
||||||
|
getServer().getPluginManager().registerEvents(new JobsListener(this), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new JobsPaymentListener(this), this);
|
||||||
|
|
||||||
|
if (McMMOlistener.CheckmcMMO())
|
||||||
|
getServer().getPluginManager().registerEvents(new McMMOlistener(this), this);
|
||||||
|
|
||||||
|
Jobs.setMythicManager(this);
|
||||||
|
if (Jobs.getMythicManager().Check() && Jobs.getGCManager().MythicMobsEnabled) {
|
||||||
|
getServer().getPluginManager().registerEvents(new MythicMobsListener(this), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Jobs.getGCManager().useBlockProtection)
|
||||||
|
getServer().getPluginManager().registerEvents(new PistonProtectionListener(this), this);
|
||||||
|
|
||||||
|
// register economy
|
||||||
|
Bukkit.getScheduler().runTask(this, new HookEconomyTask(this));
|
||||||
|
|
||||||
|
if (getServer().getPluginManager().getPlugin("CoreProtect") != null) {
|
||||||
|
Jobs.setCoreProtectApi(((CoreProtect) getServer().getPluginManager().getPlugin("CoreProtect")).getAPI());
|
||||||
|
}
|
||||||
|
|
||||||
|
// all loaded properly.
|
||||||
|
|
||||||
|
Jobs.getScheduleManager().DateUpdater();
|
||||||
|
|
||||||
|
String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Plugin has been enabled succesfully.");
|
||||||
|
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
||||||
|
console.sendMessage(message);
|
||||||
|
Jobs.getLanguage().reload(Jobs.getGCManager().getLocale());
|
||||||
|
|
||||||
|
Jobs.getJobsDAO().loadExplore();
|
||||||
|
|
||||||
|
Jobs.getCommandManager().fillCommands();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
System.out.println("There was some issues when starting plugin. Please contact dev about this. Plugin will be disabled.");
|
||||||
|
this.setEnabled(false);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// register the listeners
|
|
||||||
getServer().getPluginManager().registerEvents(new JobsListener(this), this);
|
|
||||||
getServer().getPluginManager().registerEvents(new JobsPaymentListener(this), this);
|
|
||||||
|
|
||||||
if (McMMOlistener.CheckmcMMO())
|
|
||||||
getServer().getPluginManager().registerEvents(new McMMOlistener(this), this);
|
|
||||||
|
|
||||||
Jobs.setMythicManager(this);
|
|
||||||
if (Jobs.getMythicManager().Check() && Jobs.getGCManager().MythicMobsEnabled) {
|
|
||||||
getServer().getPluginManager().registerEvents(new MythicMobsListener(this), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Jobs.getGCManager().useBlockProtection)
|
|
||||||
getServer().getPluginManager().registerEvents(new PistonProtectionListener(this), this);
|
|
||||||
|
|
||||||
// register economy
|
|
||||||
Bukkit.getScheduler().runTask(this, new HookEconomyTask(this));
|
|
||||||
|
|
||||||
if (getServer().getPluginManager().getPlugin("CoreProtect") != null) {
|
|
||||||
Jobs.setCoreProtectApi(((CoreProtect) getServer().getPluginManager().getPlugin("CoreProtect")).getAPI());
|
|
||||||
}
|
|
||||||
|
|
||||||
// all loaded properly.
|
|
||||||
|
|
||||||
Jobs.getScheduleManager().DateUpdater();
|
|
||||||
|
|
||||||
String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Plugin has been enabled succesfully.");
|
|
||||||
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
|
||||||
console.sendMessage(message);
|
|
||||||
Jobs.getLanguage().reload(Jobs.getGCManager().getLocale());
|
|
||||||
|
|
||||||
Jobs.getJobsDAO().loadExplore();
|
|
||||||
|
|
||||||
Jobs.getCommandManager().fillCommands();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -11,7 +11,7 @@ public interface NMS {
|
|||||||
|
|
||||||
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event);
|
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event);
|
||||||
|
|
||||||
public boolean isElderGuardian(Entity entity);
|
public String getRealType(Entity entity);
|
||||||
|
|
||||||
public ItemStack getItemInMainHand(Player player);
|
public ItemStack getItemInMainHand(Player player);
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ import org.bukkit.enchantments.Enchantment;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.api.JobsJoinEvent;
|
import com.gamingmesh.jobs.api.JobsJoinEvent;
|
||||||
import com.gamingmesh.jobs.api.JobsLeaveEvent;
|
import com.gamingmesh.jobs.api.JobsLeaveEvent;
|
||||||
import com.gamingmesh.jobs.api.JobsLevelUpEvent;
|
import com.gamingmesh.jobs.api.JobsLevelUpEvent;
|
||||||
@ -50,10 +49,13 @@ import com.gamingmesh.jobs.dao.JobsDAO;
|
|||||||
import com.gamingmesh.jobs.dao.JobsDAOData;
|
import com.gamingmesh.jobs.dao.JobsDAOData;
|
||||||
import com.gamingmesh.jobs.economy.PointsData;
|
import com.gamingmesh.jobs.economy.PointsData;
|
||||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||||
|
import com.gamingmesh.jobs.stuff.Debug;
|
||||||
import com.gamingmesh.jobs.stuff.PerformCommands;
|
import com.gamingmesh.jobs.stuff.PerformCommands;
|
||||||
|
import com.gamingmesh.jobs.stuff.Perm;
|
||||||
|
|
||||||
public class PlayerManager {
|
public class PlayerManager {
|
||||||
// private Map<String, JobsPlayer> players = Collections.synchronizedMap(new HashMap<String, JobsPlayer>());
|
// private Map<String, JobsPlayer> players = Collections.synchronizedMap(new HashMap<String, JobsPlayer>());
|
||||||
|
private ConcurrentHashMap<String, JobsPlayer> playersCache = new ConcurrentHashMap<String, JobsPlayer>();
|
||||||
private ConcurrentHashMap<String, JobsPlayer> players = new ConcurrentHashMap<String, JobsPlayer>();
|
private ConcurrentHashMap<String, JobsPlayer> players = new ConcurrentHashMap<String, JobsPlayer>();
|
||||||
private PointsData PointsDatabase = new PointsData();
|
private PointsData PointsDatabase = new PointsData();
|
||||||
|
|
||||||
@ -72,6 +74,14 @@ public class PlayerManager {
|
|||||||
return PlayerMap;
|
return PlayerMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConcurrentHashMap<String, JobsPlayer> getPlayersCache() {
|
||||||
|
return playersCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConcurrentHashMap<String, JobsPlayer> getPlayers() {
|
||||||
|
return players;
|
||||||
|
}
|
||||||
|
|
||||||
public int getPlayerIdByName(String name) {
|
public int getPlayerIdByName(String name) {
|
||||||
for (Entry<String, PlayerInfo> one : PlayerMap.entrySet()) {
|
for (Entry<String, PlayerInfo> one : PlayerMap.entrySet()) {
|
||||||
if (one.getValue().getName() == null)
|
if (one.getValue().getName() == null)
|
||||||
@ -107,12 +117,16 @@ public class PlayerManager {
|
|||||||
* @param playername
|
* @param playername
|
||||||
*/
|
*/
|
||||||
public void playerJoin(Player player) {
|
public void playerJoin(Player player) {
|
||||||
JobsPlayer jPlayer = players.get(player.getName().toLowerCase());
|
JobsPlayer jPlayer = playersCache.get(player.getName().toLowerCase());
|
||||||
if (jPlayer == null) {
|
if (jPlayer == null) {
|
||||||
jPlayer = JobsPlayer.loadFromDao(Jobs.getJobsDAO(), player);
|
jPlayer = JobsPlayer.loadFromDao(Jobs.getJobsDAO(), player);
|
||||||
|
|
||||||
JobsPlayer.loadLogFromDao(jPlayer);
|
JobsPlayer.loadLogFromDao(jPlayer);
|
||||||
players.put(player.getName().toLowerCase(), jPlayer);
|
playersCache.put(player.getName().toLowerCase(), jPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
players.put(player.getName().toLowerCase(), jPlayer);
|
||||||
|
|
||||||
AutoJoinJobs(player);
|
AutoJoinJobs(player);
|
||||||
jPlayer.onConnect();
|
jPlayer.onConnect();
|
||||||
jPlayer.reloadHonorific();
|
jPlayer.reloadHonorific();
|
||||||
@ -174,7 +188,7 @@ public class PlayerManager {
|
|||||||
* @return the player job info of the player
|
* @return the player job info of the player
|
||||||
*/
|
*/
|
||||||
public JobsPlayer getJobsPlayer(Player player) {
|
public JobsPlayer getJobsPlayer(Player player) {
|
||||||
return players.get(player.getName().toLowerCase());
|
return playersCache.get(player.getName().toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -183,7 +197,7 @@ public class PlayerManager {
|
|||||||
* @return the player job info of the player
|
* @return the player job info of the player
|
||||||
*/
|
*/
|
||||||
public JobsPlayer getJobsPlayer(String playerName) {
|
public JobsPlayer getJobsPlayer(String playerName) {
|
||||||
return players.get(playerName.toLowerCase());
|
return playersCache.get(playerName.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public JobsPlayer getJobsPlayerOffline(OfflinePlayer player) {
|
public JobsPlayer getJobsPlayerOffline(OfflinePlayer player) {
|
||||||
@ -196,7 +210,7 @@ public class PlayerManager {
|
|||||||
* @return the player job info of the player
|
* @return the player job info of the player
|
||||||
*/
|
*/
|
||||||
public JobsPlayer getJobsPlayerOffline(String playerName) {
|
public JobsPlayer getJobsPlayerOffline(String playerName) {
|
||||||
JobsPlayer jPlayer = players.get(playerName.toLowerCase());
|
JobsPlayer jPlayer = playersCache.get(playerName.toLowerCase());
|
||||||
if (jPlayer != null)
|
if (jPlayer != null)
|
||||||
return jPlayer;
|
return jPlayer;
|
||||||
|
|
||||||
@ -419,7 +433,7 @@ public class PlayerManager {
|
|||||||
*/
|
*/
|
||||||
public void performLevelUp(JobsPlayer jPlayer, Job job, int oldLevel) {
|
public void performLevelUp(JobsPlayer jPlayer, Job job, int oldLevel) {
|
||||||
|
|
||||||
Player player = (Player) jPlayer.getPlayer();
|
Player player = jPlayer.getPlayer();
|
||||||
JobProgression prog = jPlayer.getJobProgression(job);
|
JobProgression prog = jPlayer.getJobProgression(job);
|
||||||
if (prog == null)
|
if (prog == null)
|
||||||
return;
|
return;
|
||||||
@ -594,14 +608,14 @@ public class PlayerManager {
|
|||||||
*/
|
*/
|
||||||
public boolean getJobsLimit(Player player, Short currentCount) {
|
public boolean getJobsLimit(Player player, Short currentCount) {
|
||||||
|
|
||||||
if (Perm(player, "jobs.max.*"))
|
if (Perm.hasPermission(player, "jobs.max.*"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
int totalJobs = Jobs.getJobs().size() + 5;
|
int totalJobs = Jobs.getJobs().size() + 5;
|
||||||
|
|
||||||
short count = (short) Jobs.getGCManager().getMaxJobs();
|
short count = (short) Jobs.getGCManager().getMaxJobs();
|
||||||
for (short ctr = 0; ctr < totalJobs; ctr++) {
|
for (short ctr = 0; ctr < totalJobs; ctr++) {
|
||||||
if (Perm(player, "jobs.max." + ctr))
|
if (Perm.hasPermission(player, "jobs.max." + ctr))
|
||||||
count = ctr;
|
count = ctr;
|
||||||
if (count > currentCount)
|
if (count > currentCount)
|
||||||
return true;
|
return true;
|
||||||
@ -609,29 +623,27 @@ public class PlayerManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean Perm(Player player, String permission) {
|
|
||||||
return player.hasPermission(permission);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get job money boost
|
* Get job money boost
|
||||||
* @param player
|
* @param player
|
||||||
* @param job
|
* @param job
|
||||||
* @return double of boost
|
* @return double of boost
|
||||||
*/
|
*/
|
||||||
public Double GetMoneyBoost(Player dude, Job job) {
|
public Double GetMoneyBoost(Player player, Job job) {
|
||||||
Double Boost = 1.0;
|
Double Boost = 1.0;
|
||||||
if (dude != null && job.getName() != null) {
|
if (player != null && job.getName() != null) {
|
||||||
if (Perm(dude, "jobs.boost." + job.getName() + ".money") || Perm(dude, "jobs.boost." + job.getName() + ".all") || Perm(dude, "jobs.boost.all.all") || Perm(
|
if (Perm.hasPermission(player, "jobs.boost." + job.getName() + ".money") ||
|
||||||
dude, "jobs.boost.all.money")) {
|
Perm.hasPermission(player, "jobs.boost." + job.getName() + ".all") ||
|
||||||
|
Perm.hasPermission(player, "jobs.boost.all.all") ||
|
||||||
|
Perm.hasPermission(player, "jobs.boost.all.money")) {
|
||||||
Boost = Jobs.getGCManager().BoostMoney;
|
Boost = Jobs.getGCManager().BoostMoney;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Boost;
|
return Boost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double GetMoneyBoostInPerc(Player dude, Job job) {
|
public double GetMoneyBoostInPerc(Player player, Job job) {
|
||||||
double Boost = GetMoneyBoost(dude, job) * 100.0 - 100.0;
|
double Boost = GetMoneyBoost(player, job) * 100.0 - 100.0;
|
||||||
return Boost;
|
return Boost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,19 +653,21 @@ public class PlayerManager {
|
|||||||
* @param job
|
* @param job
|
||||||
* @return double of boost
|
* @return double of boost
|
||||||
*/
|
*/
|
||||||
public Double GetPointBoost(Player dude, Job job) {
|
public Double GetPointBoost(Player player, Job job) {
|
||||||
Double Boost = 1.0;
|
Double Boost = 1.0;
|
||||||
if (dude != null && job.getName() != null) {
|
if (player != null && job.getName() != null) {
|
||||||
if (Perm(dude, "jobs.boost." + job.getName() + ".points") || Perm(dude, "jobs.boost." + job.getName() + ".all") || Perm(dude, "jobs.boost.all.all") || Perm(
|
if (Perm.hasPermission(player, "jobs.boost." + job.getName() + ".points") ||
|
||||||
dude, "jobs.boost.all.points")) {
|
Perm.hasPermission(player, "jobs.boost." + job.getName() + ".all") ||
|
||||||
|
Perm.hasPermission(player, "jobs.boost.all.all") ||
|
||||||
|
Perm.hasPermission(player, "jobs.boost.all.points")) {
|
||||||
Boost = Jobs.getGCManager().BoostPoints;
|
Boost = Jobs.getGCManager().BoostPoints;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Boost;
|
return Boost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double GetPointBoostInPerc(Player dude, Job job) {
|
public double GetPointBoostInPerc(Player player, Job job) {
|
||||||
double Boost = GetPointBoost(dude, job) * 100.0 - 100.0;
|
double Boost = GetPointBoost(player, job) * 100.0 - 100.0;
|
||||||
return Boost;
|
return Boost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -663,20 +677,22 @@ public class PlayerManager {
|
|||||||
* @param job
|
* @param job
|
||||||
* @return double of boost
|
* @return double of boost
|
||||||
*/
|
*/
|
||||||
public Double GetExpBoost(Player dude, Job job) {
|
public Double GetExpBoost(Player player, Job job) {
|
||||||
Double Boost = 1.0;
|
Double Boost = 1.0;
|
||||||
if (dude == null || job.getName() == null)
|
if (player == null || job.getName() == null)
|
||||||
return 1.0;
|
return 1.0;
|
||||||
if (Perm(dude, "jobs.boost." + job.getName() + ".exp") || Perm(dude, "jobs.boost." + job.getName() + ".all") || Perm(dude, "jobs.boost.all.all") || Perm(dude,
|
if (Perm.hasPermission(player, "jobs.boost." + job.getName() + ".exp") ||
|
||||||
"jobs.boost.all.exp")) {
|
Perm.hasPermission(player, "jobs.boost." + job.getName() + ".all") ||
|
||||||
|
Perm.hasPermission(player, "jobs.boost.all.all") ||
|
||||||
|
Perm.hasPermission(player, "jobs.boost.all.exp")) {
|
||||||
Boost = Jobs.getGCManager().BoostExp;
|
Boost = Jobs.getGCManager().BoostExp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Boost;
|
return Boost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double GetExpBoostInPerc(Player dude, Job job) {
|
public double GetExpBoostInPerc(Player player, Job job) {
|
||||||
double Boost = GetExpBoost(dude, job) * 100.0 - 100.0;
|
double Boost = GetExpBoost(player, job) * 100.0 - 100.0;
|
||||||
return Boost;
|
return Boost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -814,7 +830,6 @@ public class PlayerManager {
|
|||||||
public void AutoJoinJobs(final Player player) {
|
public void AutoJoinJobs(final Player player) {
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
// ignoring OP players for obvious reasons
|
|
||||||
if (player.isOp())
|
if (player.isOp())
|
||||||
return;
|
return;
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
@ -824,11 +839,21 @@ public class PlayerManager {
|
|||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||||
if (jPlayer == null)
|
if (jPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
int confMaxJobs = Jobs.getGCManager().getMaxJobs();
|
||||||
for (Job one : Jobs.getJobs()) {
|
for (Job one : Jobs.getJobs()) {
|
||||||
JobProgression cur = jPlayer.getJobProgression(one);
|
|
||||||
if (cur == null && player.hasPermission("jobs.autojoin." + one.getName().toLowerCase())) {
|
if (one.getMaxSlots() != null && Jobs.getUsedSlots(one) >= one.getMaxSlots())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
short PlayerMaxJobs = (short) jPlayer.getJobProgression().size();
|
||||||
|
if (confMaxJobs > 0 && PlayerMaxJobs >= confMaxJobs && !Jobs.getPlayerManager().getJobsLimit(player, PlayerMaxJobs))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (jPlayer.isInJob(one))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (Perm.hasPermission(player, "jobs.autojoin." + one.getName().toLowerCase()))
|
||||||
Jobs.getPlayerManager().joinJob(jPlayer, one);
|
Jobs.getPlayerManager().joinJob(jPlayer, one);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.Skull;
|
import org.bukkit.block.Skull;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -148,7 +149,7 @@ public class SignUtil {
|
|||||||
sign.setLine(i, line);
|
sign.setLine(i, line);
|
||||||
}
|
}
|
||||||
sign.update();
|
sign.update();
|
||||||
UpdateHead(sign.getLocation(), ((TopList) PlayerList.get(0)).getPlayerName(), timelapse);
|
UpdateHead(sign, ((TopList) PlayerList.get(0)).getPlayerName(), timelapse);
|
||||||
} else {
|
} else {
|
||||||
String PlayerName = ((TopList) PlayerList.get(0)).getPlayerName();
|
String PlayerName = ((TopList) PlayerList.get(0)).getPlayerName();
|
||||||
if (PlayerName.length() > 8) {
|
if (PlayerName.length() > 8) {
|
||||||
@ -183,7 +184,7 @@ public class SignUtil {
|
|||||||
|
|
||||||
sign.setLine(3, line1);
|
sign.setLine(3, line1);
|
||||||
sign.update();
|
sign.update();
|
||||||
UpdateHead(sign.getLocation(), ((TopList) PlayerList.get(0)).getPlayerName(), timelapse);
|
UpdateHead(sign, ((TopList) PlayerList.get(0)).getPlayerName(), timelapse);
|
||||||
}
|
}
|
||||||
|
|
||||||
timelapse++;
|
timelapse++;
|
||||||
@ -194,22 +195,28 @@ public class SignUtil {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateHead(final Location loc, final String Playername, final int timelapse) {
|
public void UpdateHead(final org.bukkit.block.Sign sign, final String Playername, final int timelapse) {
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
loc.setY(loc.getY() + 1);
|
org.bukkit.material.Sign signMat = (org.bukkit.material.Sign) sign.getData();
|
||||||
|
BlockFace directionFacing = signMat.getFacing();
|
||||||
|
|
||||||
|
Location loc = sign.getLocation().clone();
|
||||||
|
loc.add(0, 1, 0);
|
||||||
|
|
||||||
if (Playername == null)
|
if (Playername == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Block block = loc.getBlock();
|
Block block = loc.getBlock();
|
||||||
|
|
||||||
if (block == null)
|
if (block == null || !(block.getState() instanceof Skull))
|
||||||
return;
|
loc.add(directionFacing.getOppositeFace().getModX(), 0, directionFacing.getOppositeFace().getModZ());
|
||||||
|
|
||||||
if (!(block.getState() instanceof Skull))
|
block = loc.getBlock();
|
||||||
|
|
||||||
|
if (block == null || !(block.getState() instanceof Skull))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Skull skull = (Skull) block.getState();
|
Skull skull = (Skull) block.getState();
|
||||||
|
@ -18,14 +18,41 @@
|
|||||||
|
|
||||||
package com.gamingmesh.jobs.actions;
|
package com.gamingmesh.jobs.actions;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.container.ActionInfo;
|
import com.gamingmesh.jobs.container.ActionInfo;
|
||||||
import com.gamingmesh.jobs.container.ActionType;
|
import com.gamingmesh.jobs.container.ActionType;
|
||||||
|
|
||||||
public class BlockActionInfo extends MaterialActionInfo implements ActionInfo {
|
public class BlockActionInfo extends MaterialActionInfo implements ActionInfo {
|
||||||
@SuppressWarnings("deprecation")
|
public BlockActionInfo(Block block, ActionType type) {
|
||||||
public BlockActionInfo(Block block, ActionType type) {
|
super(block.getType(), getData(block), type);
|
||||||
super(block.getType(), block.getData(), type);
|
}
|
||||||
|
|
||||||
|
private static byte getData(Block block) {
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
byte data = block.getData();
|
||||||
|
if (block.getType() == Material.COCOA)
|
||||||
|
switch (data) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
data = 0;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
case 6:
|
||||||
|
case 7:
|
||||||
|
data = 1;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
case 9:
|
||||||
|
case 10:
|
||||||
|
case 11:
|
||||||
|
data = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,6 @@
|
|||||||
package com.gamingmesh.jobs.actions;
|
package com.gamingmesh.jobs.actions;
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Skeleton;
|
|
||||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
|
||||||
import org.bukkit.entity.Zombie;
|
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
import com.gamingmesh.jobs.container.ActionInfo;
|
import com.gamingmesh.jobs.container.ActionInfo;
|
||||||
import com.gamingmesh.jobs.container.ActionType;
|
import com.gamingmesh.jobs.container.ActionType;
|
||||||
@ -38,22 +34,7 @@ public class EntityActionInfo extends BaseActionInfo implements ActionInfo {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
if (this.entity instanceof Skeleton) {
|
return Jobs.getNms().getRealType(entity);
|
||||||
Skeleton skeleton = (Skeleton) this.entity;
|
|
||||||
if (skeleton.getSkeletonType() == SkeletonType.WITHER)
|
|
||||||
return "WitherSkeleton";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.entity instanceof Zombie) {
|
|
||||||
Zombie zombie = (Zombie) this.entity;
|
|
||||||
if (zombie.isVillager())
|
|
||||||
return "ZombieVillager";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Jobs.getNms().isElderGuardian(this.entity))
|
|
||||||
return "ElderGuardian";
|
|
||||||
|
|
||||||
return entity.getType().toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -518,10 +518,16 @@ public class JobsCommands implements CommandExecutor {
|
|||||||
String pros = ChatColor.YELLOW + "\u258F";
|
String pros = ChatColor.YELLOW + "\u258F";
|
||||||
if (current < 0)
|
if (current < 0)
|
||||||
current = 0;
|
current = 0;
|
||||||
|
if (max < current)
|
||||||
|
max = current;
|
||||||
int percentage = (int) ((current * 50.0) / max);
|
int percentage = (int) ((current * 50.0) / max);
|
||||||
for (int i = 0; i < percentage; i++) {
|
for (int i = 0; i < percentage; i++) {
|
||||||
message += pos;
|
message += pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (50 - percentage < 0)
|
||||||
|
percentage = 50;
|
||||||
|
|
||||||
for (int i = 0; i < 50 - percentage; i++) {
|
for (int i = 0; i < 50 - percentage; i++) {
|
||||||
message += pros;
|
message += pros;
|
||||||
}
|
}
|
||||||
|
@ -31,12 +31,12 @@ public class blockinfo implements Cmd {
|
|||||||
if (block == null || block.getState().getType() == Material.AIR)
|
if (block == null || block.getState().getType() == Material.AIR)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
String dataString = block.getData() == 0 ? "" : "-" + block.getData();
|
String dataString = getData(block) == 0 ? "" : "-" + getData(block);
|
||||||
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.name", "%blockname%", block.getType().name()));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.name", "%blockname%", block.getType().name()));
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.id", "%blockid%", block.getTypeId()));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.id", "%blockid%", block.getTypeId()));
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.data", "%blockdata%", block.getData()));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.data", "%blockdata%", getData(block)));
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.usage", "%first%", block.getTypeId() + dataString,
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.usage", "%first%", block.getTypeId() + dataString,
|
||||||
"%second%", block.getType().name() + dataString));
|
"%second%", block.getType().name() + dataString));
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
||||||
@ -44,4 +44,31 @@ public class blockinfo implements Cmd {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private byte getData(Block block) {
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
byte data = block.getData();
|
||||||
|
if (block.getType() == Material.COCOA)
|
||||||
|
switch (data) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
data = 0;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
case 6:
|
||||||
|
case 7:
|
||||||
|
data = 1;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
case 9:
|
||||||
|
case 10:
|
||||||
|
case 11:
|
||||||
|
data = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,12 @@ public class fire implements Cmd {
|
|||||||
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job"));
|
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (jPlayer == null){
|
||||||
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!jPlayer.isInJob(job)) {
|
if (!jPlayer.isInJob(job)) {
|
||||||
String message = ChatColor.RED + Jobs.getLanguage().getMessage("command.fire.error.nojob", "%jobname%", job.getChatColor() + job.getName() + ChatColor.RED);
|
String message = ChatColor.RED + Jobs.getLanguage().getMessage("command.fire.error.nojob", "%jobname%", job.getChatColor() + job.getName() + ChatColor.RED);
|
||||||
sender.sendMessage(message);
|
sender.sendMessage(message);
|
||||||
|
@ -584,6 +584,10 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + Jobs.getJobs().size() + " jobs!");
|
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + Jobs.getJobs().size() + " jobs!");
|
||||||
|
if (!Jobs.getExplore().isExploreEnabled()) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "[Jobs] Explorer jobs manager are not enabled!");
|
||||||
|
} else
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Explorer job manager registered!");
|
||||||
//try {
|
//try {
|
||||||
// conf.save(f);
|
// conf.save(f);
|
||||||
//} catch (IOException e) {
|
//} catch (IOException e) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.gamingmesh.jobs.config;
|
package com.gamingmesh.jobs.config;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -32,8 +33,10 @@ public class ExploreManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setExploreEnabled() {
|
public void setExploreEnabled() {
|
||||||
this.exploreEnabled = true;
|
if (!exploreEnabled) {
|
||||||
Jobs.getJobsDAO().loadExplore();
|
this.exploreEnabled = true;
|
||||||
|
Jobs.getJobsDAO().loadExplore();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, ExploreRegion> getWorlds() {
|
public HashMap<String, ExploreRegion> getWorlds() {
|
||||||
|
@ -379,8 +379,8 @@ public class LanguageManager {
|
|||||||
|
|
||||||
c.get("command.reload.help.info", "Reload configurations.");
|
c.get("command.reload.help.info", "Reload configurations.");
|
||||||
|
|
||||||
c.get("command.toggle.help.info", "Toggles payment output on action bar.");
|
c.get("command.toggle.help.info", "Toggles payment output on action bar or bossbar.");
|
||||||
c.get("command.toggle.help.args", "");
|
c.get("command.toggle.help.args", "[actionbar/bossbar]");
|
||||||
c.get("command.toggle.output.turnedoff", "&4This feature are turned off!");
|
c.get("command.toggle.output.turnedoff", "&4This feature are turned off!");
|
||||||
c.get("command.toggle.output.paid.main", "&aYou got:");
|
c.get("command.toggle.output.paid.main", "&aYou got:");
|
||||||
c.get("command.toggle.output.paid.money", "&e[amount] money");
|
c.get("command.toggle.output.paid.money", "&e[amount] money");
|
||||||
|
@ -27,6 +27,7 @@ import com.gamingmesh.jobs.container.JobProgression;
|
|||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
import com.gamingmesh.jobs.container.PlayerPoints;
|
import com.gamingmesh.jobs.container.PlayerPoints;
|
||||||
import com.gamingmesh.jobs.container.ShopItem;
|
import com.gamingmesh.jobs.container.ShopItem;
|
||||||
|
import com.gamingmesh.jobs.stuff.Perm;
|
||||||
|
|
||||||
public class ShopManager {
|
public class ShopManager {
|
||||||
private JobsPlugin plugin;
|
private JobsPlugin plugin;
|
||||||
@ -46,9 +47,9 @@ public class ShopManager {
|
|||||||
ShopItem item = list.get(slot);
|
ShopItem item = list.get(slot);
|
||||||
PlayerPoints pointsInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(player.getUniqueId());
|
PlayerPoints pointsInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(player.getUniqueId());
|
||||||
|
|
||||||
if (!player.hasPermission("jobs.items.bypass")) {
|
if (!Perm.hasPermission(player, "jobs.items.bypass")) {
|
||||||
for (String onePerm : item.getRequiredPerm()) {
|
for (String onePerm : item.getRequiredPerm()) {
|
||||||
if (!player.hasPermission(onePerm)) {
|
if (!Perm.hasPermission(player, onePerm)) {
|
||||||
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoPermForItem"));
|
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoPermForItem"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -119,7 +120,7 @@ public class ShopManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.hasPermission("jobs.items.bypass")) {
|
if (!Perm.hasPermission(player, "jobs.items.bypass")) {
|
||||||
pointsInfo.takePoints(item.getPrice());
|
pointsInfo.takePoints(item.getPrice());
|
||||||
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.Paid", "%amount%", item.getPrice()));
|
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.Paid", "%amount%", item.getPrice()));
|
||||||
}
|
}
|
||||||
@ -169,7 +170,7 @@ public class ShopManager {
|
|||||||
|
|
||||||
if (item.isHideWithoutPerm()) {
|
if (item.isHideWithoutPerm()) {
|
||||||
for (String onePerm : item.getRequiredPerm()) {
|
for (String onePerm : item.getRequiredPerm()) {
|
||||||
if (!player.hasPermission(onePerm)) {
|
if (!Perm.hasPermission(player, onePerm)) {
|
||||||
mat = Material.STONE_BUTTON;
|
mat = Material.STONE_BUTTON;
|
||||||
Lore.add(Jobs.getLanguage().getMessage("command.shop.info.NoPermToBuy"));
|
Lore.add(Jobs.getLanguage().getMessage("command.shop.info.NoPermToBuy"));
|
||||||
break;
|
break;
|
||||||
|
@ -23,6 +23,7 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -46,7 +47,8 @@ public class JobsPlayer {
|
|||||||
// player online status
|
// player online status
|
||||||
private volatile boolean isOnline = false;
|
private volatile boolean isOnline = false;
|
||||||
|
|
||||||
private OfflinePlayer player = null;
|
private OfflinePlayer OffPlayer = null;
|
||||||
|
private Player player = null;
|
||||||
|
|
||||||
private double VipSpawnerMultiplier = -1;
|
private double VipSpawnerMultiplier = -1;
|
||||||
|
|
||||||
@ -66,7 +68,7 @@ public class JobsPlayer {
|
|||||||
|
|
||||||
public JobsPlayer(String userName, OfflinePlayer player) {
|
public JobsPlayer(String userName, OfflinePlayer player) {
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
this.player = player;
|
this.OffPlayer = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JobsPlayer loadFromDao(JobsDAO dao, OfflinePlayer player) {
|
public static JobsPlayer loadFromDao(JobsDAO dao, OfflinePlayer player) {
|
||||||
@ -99,6 +101,10 @@ public class JobsPlayer {
|
|||||||
return jPlayer;
|
return jPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPlayer(Player p) {
|
||||||
|
this.player = p;
|
||||||
|
}
|
||||||
|
|
||||||
public static void loadLogFromDao(JobsPlayer jPlayer) {
|
public static void loadLogFromDao(JobsPlayer jPlayer) {
|
||||||
Jobs.getJobsDAO().loadLog(jPlayer);
|
Jobs.getJobsDAO().loadLog(jPlayer);
|
||||||
}
|
}
|
||||||
@ -109,7 +115,6 @@ public class JobsPlayer {
|
|||||||
|
|
||||||
public synchronized void clearUpdateBossBarFor() {
|
public synchronized void clearUpdateBossBarFor() {
|
||||||
this.updateBossBarFor.clear();
|
this.updateBossBarFor.clear();
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized List<BossBarInfo> getBossBarInfo() {
|
public synchronized List<BossBarInfo> getBossBarInfo() {
|
||||||
@ -138,8 +143,10 @@ public class JobsPlayer {
|
|||||||
* Get the player
|
* Get the player
|
||||||
* @return the player
|
* @return the player
|
||||||
*/
|
*/
|
||||||
public OfflinePlayer getPlayer() {
|
public Player getPlayer() {
|
||||||
return this.player;
|
if (this.player != null)
|
||||||
|
return this.player;
|
||||||
|
return Bukkit.getPlayer(this.playerUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -147,7 +154,7 @@ public class JobsPlayer {
|
|||||||
* @return the Multiplier
|
* @return the Multiplier
|
||||||
*/
|
*/
|
||||||
public double getVipSpawnerMultiplier() {
|
public double getVipSpawnerMultiplier() {
|
||||||
if (!this.player.isOnline())
|
if (!this.OffPlayer.isOnline())
|
||||||
return 1.0;
|
return 1.0;
|
||||||
if (VipSpawnerMultiplier < 0)
|
if (VipSpawnerMultiplier < 0)
|
||||||
updateVipSpawnerMultiplier();
|
updateVipSpawnerMultiplier();
|
||||||
@ -165,7 +172,7 @@ public class JobsPlayer {
|
|||||||
* Get the MoneyBoost
|
* Get the MoneyBoost
|
||||||
* @return the MoneyBoost
|
* @return the MoneyBoost
|
||||||
*/
|
*/
|
||||||
public static double getMoneyBoost(String JobName, OfflinePlayer player) {
|
public static double getMoneyBoost(String JobName, Player player) {
|
||||||
double MoneyBoost = 1.0;
|
double MoneyBoost = 1.0;
|
||||||
if (JobName != null) {
|
if (JobName != null) {
|
||||||
if (Perm.hasPermission(player, "jobs.boost." + JobName + ".money") || Perm.hasPermission(player, "jobs.boost." + JobName + ".both") || Perm.hasPermission(
|
if (Perm.hasPermission(player, "jobs.boost." + JobName + ".money") || Perm.hasPermission(player, "jobs.boost." + JobName + ".both") || Perm.hasPermission(
|
||||||
@ -180,7 +187,7 @@ public class JobsPlayer {
|
|||||||
* Get the PointBoost
|
* Get the PointBoost
|
||||||
* @return the PointBoost
|
* @return the PointBoost
|
||||||
*/
|
*/
|
||||||
public static double getPointBoost(String JobName, OfflinePlayer player) {
|
public static double getPointBoost(String JobName, Player player) {
|
||||||
double PointBoost = 1.0;
|
double PointBoost = 1.0;
|
||||||
if (JobName != null) {
|
if (JobName != null) {
|
||||||
if (Perm.hasPermission(player, "jobs.boost." + JobName + ".points") || Perm.hasPermission(player, "jobs.boost." + JobName + ".both") || Perm.hasPermission(
|
if (Perm.hasPermission(player, "jobs.boost." + JobName + ".points") || Perm.hasPermission(player, "jobs.boost." + JobName + ".both") || Perm.hasPermission(
|
||||||
@ -195,7 +202,7 @@ public class JobsPlayer {
|
|||||||
* Get the ExpBoost
|
* Get the ExpBoost
|
||||||
* @return the ExpBoost
|
* @return the ExpBoost
|
||||||
*/
|
*/
|
||||||
public static double getExpBoost(String JobName, OfflinePlayer player) {
|
public static double getExpBoost(String JobName, Player player) {
|
||||||
Double ExpBoost = 1.0;
|
Double ExpBoost = 1.0;
|
||||||
if (player == null || JobName == null)
|
if (player == null || JobName == null)
|
||||||
return 1.0;
|
return 1.0;
|
||||||
@ -285,8 +292,10 @@ public class JobsPlayer {
|
|||||||
* @return true if have
|
* @return true if have
|
||||||
*/
|
*/
|
||||||
public boolean havePermission(String perm) {
|
public boolean havePermission(String perm) {
|
||||||
if (this.isOnline)
|
if (this.player == null)
|
||||||
return ((Player) player).hasPermission(perm);
|
this.player = Bukkit.getPlayer(this.playerUUID);
|
||||||
|
if (this.player != null)
|
||||||
|
return Perm.hasPermission(player, perm);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,6 @@ import com.gamingmesh.jobs.container.LogAmounts;
|
|||||||
import com.gamingmesh.jobs.container.PlayerInfo;
|
import com.gamingmesh.jobs.container.PlayerInfo;
|
||||||
import com.gamingmesh.jobs.container.PlayerPoints;
|
import com.gamingmesh.jobs.container.PlayerPoints;
|
||||||
import com.gamingmesh.jobs.container.TopList;
|
import com.gamingmesh.jobs.container.TopList;
|
||||||
import com.gamingmesh.jobs.stuff.Debug;
|
|
||||||
import com.gamingmesh.jobs.stuff.Loging;
|
import com.gamingmesh.jobs.stuff.Loging;
|
||||||
import com.gamingmesh.jobs.stuff.TimeManage;
|
import com.gamingmesh.jobs.stuff.TimeManage;
|
||||||
|
|
||||||
@ -77,18 +76,17 @@ public abstract class JobsDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Debug.D("V"+version);
|
|
||||||
if (version <= 1)
|
if (version <= 1)
|
||||||
checkUpdate();
|
checkUpdate();
|
||||||
else {
|
else {
|
||||||
if (version <= 2)
|
if (version <= 2)
|
||||||
checkUpdate2();
|
checkUpdate2();
|
||||||
|
|
||||||
checkUpdate4();
|
checkUpdate4();
|
||||||
checkUpdate5();
|
checkUpdate5();
|
||||||
checkUpdate6();
|
if (version <= 6)
|
||||||
checkUpdate7();
|
checkUpdate6();
|
||||||
|
if (version <= 7)
|
||||||
|
checkUpdate7();
|
||||||
// creating explore database
|
// creating explore database
|
||||||
checkUpdate8();
|
checkUpdate8();
|
||||||
checkUpdate9();
|
checkUpdate9();
|
||||||
@ -126,7 +124,7 @@ public abstract class JobsDAO {
|
|||||||
return prefix;
|
return prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized List<JobsDAOData> getAllJobs(OfflinePlayer player) {
|
public List<JobsDAOData> getAllJobs(OfflinePlayer player) {
|
||||||
return getAllJobs(player.getName(), player.getUniqueId());
|
return getAllJobs(player.getName(), player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +133,7 @@ public abstract class JobsDAO {
|
|||||||
* @param playerUUID - the player being searched for
|
* @param playerUUID - the player being searched for
|
||||||
* @return list of all of the names of the jobs the players are part of.
|
* @return list of all of the names of the jobs the players are part of.
|
||||||
*/
|
*/
|
||||||
public synchronized List<JobsDAOData> getAllJobs(String playerName, UUID uuid) {
|
public List<JobsDAOData> getAllJobs(String playerName, UUID uuid) {
|
||||||
|
|
||||||
int id = -1;
|
int id = -1;
|
||||||
PlayerInfo userData = null;
|
PlayerInfo userData = null;
|
||||||
@ -924,9 +922,10 @@ public abstract class JobsDAO {
|
|||||||
|
|
||||||
JobsPlayer jobsinfo = Jobs.getPlayerManager().getJobsPlayer(player);
|
JobsPlayer jobsinfo = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||||
Job job = Jobs.getJob(jobsname);
|
Job job = Jobs.getJob(jobsname);
|
||||||
if (job != null) {
|
if (job != null && jobsinfo != null) {
|
||||||
JobProgression prog = jobsinfo.getJobProgression(job);
|
JobProgression prog = jobsinfo.getJobProgression(job);
|
||||||
jobs.add(new TopList(jobsinfo.getUserId(), prog.getLevel(), (int) prog.getExperience()));
|
if (prog != null)
|
||||||
|
jobs.add(new TopList(jobsinfo.getUserId(), prog.getLevel(), (int) prog.getExperience()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
jobs.add(new TopList(res.getInt("userid"), res.getInt("level"), res.getInt("experience")));
|
jobs.add(new TopList(res.getInt("userid"), res.getInt("level"), res.getInt("experience")));
|
||||||
|
@ -162,6 +162,8 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
if (res.next()) {
|
if (res.next()) {
|
||||||
rows = res.getInt(1);
|
rows = res.getInt(1);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
if (prest != null) {
|
if (prest != null) {
|
||||||
try {
|
try {
|
||||||
@ -175,6 +177,8 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
if (rows == 0)
|
if (rows == 0)
|
||||||
executeSQL("CREATE TABLE `" + getPrefix()
|
executeSQL("CREATE TABLE `" + getPrefix()
|
||||||
+ "archive` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `player_uuid` binary(16) NOT NULL, `username` varchar(20), `job` varchar(20), `experience` int, `level` int);");
|
+ "archive` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `player_uuid` binary(16) NOT NULL, `username` varchar(20), `job` varchar(20), `experience` int, `level` int);");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,6 +228,7 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
try {
|
try {
|
||||||
executeSQL("ALTER TABLE `" + getPrefix() + "log` MODIFY `itemname` VARCHAR(60);");
|
executeSQL("ALTER TABLE `" + getPrefix() + "log` MODIFY `itemname` VARCHAR(60);");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,6 +445,7 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
try {
|
try {
|
||||||
executeSQL("ALTER TABLE `" + getPrefix() + "log_temp` RENAME TO `" + getPrefix() + "log`;");
|
executeSQL("ALTER TABLE `" + getPrefix() + "log_temp` RENAME TO `" + getPrefix() + "log`;");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -462,6 +468,8 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
if (res.next()) {
|
if (res.next()) {
|
||||||
rows = res.getInt(1);
|
rows = res.getInt(1);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
if (prest != null) {
|
if (prest != null) {
|
||||||
try {
|
try {
|
||||||
@ -473,8 +481,13 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (rows == 0)
|
if (rows == 0)
|
||||||
createDefaultExploreBase();
|
try {
|
||||||
|
executeSQL("CREATE TABLE `" + getPrefix()
|
||||||
|
+ "explore` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `worldname` varchar(64), `chunkX` int, `chunkZ` int, `playerName` varchar(32));");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -498,6 +511,8 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
if (res.next()) {
|
if (res.next()) {
|
||||||
rows = res.getInt(1);
|
rows = res.getInt(1);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
if (tempPrest != null) {
|
if (tempPrest != null) {
|
||||||
try {
|
try {
|
||||||
@ -516,13 +531,7 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
while (res.next()) {
|
while (res.next()) {
|
||||||
tempMap.put(res.getString("player_uuid"), res.getString("username"));
|
tempMap.put(res.getString("player_uuid"), res.getString("username"));
|
||||||
}
|
}
|
||||||
} finally {
|
} catch (Exception e) {
|
||||||
if (prest != null) {
|
|
||||||
try {
|
|
||||||
prest.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -531,13 +540,7 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
while (res.next()) {
|
while (res.next()) {
|
||||||
tempMap.put(res.getString("player_uuid"), res.getString("username"));
|
tempMap.put(res.getString("player_uuid"), res.getString("username"));
|
||||||
}
|
}
|
||||||
} finally {
|
} catch (Exception e) {
|
||||||
if (prest != null) {
|
|
||||||
try {
|
|
||||||
prest.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -546,18 +549,14 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
while (res.next()) {
|
while (res.next()) {
|
||||||
tempMap.put(res.getString("player_uuid"), res.getString("username"));
|
tempMap.put(res.getString("player_uuid"), res.getString("username"));
|
||||||
}
|
}
|
||||||
} finally {
|
} catch (Exception e) {
|
||||||
if (prest != null)
|
|
||||||
try {
|
|
||||||
prest.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
executeSQL("CREATE TABLE `" + getPrefix()
|
executeSQL("CREATE TABLE `" + getPrefix()
|
||||||
+ "users` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `player_uuid` varchar(36) NOT NULL, `username` varchar(20));");
|
+ "users` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `player_uuid` varchar(36) NOT NULL, `username` varchar(20));");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -571,13 +570,8 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
prest.executeBatch();
|
prest.executeBatch();
|
||||||
conn.commit();
|
conn.commit();
|
||||||
conn.setAutoCommit(true);
|
conn.setAutoCommit(true);
|
||||||
} finally {
|
} catch (Exception e) {
|
||||||
if (prest != null) {
|
e.printStackTrace();
|
||||||
try {
|
|
||||||
prest.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<String, PlayerInfo> tempPlayerMap = new HashMap<String, PlayerInfo>();
|
HashMap<String, PlayerInfo> tempPlayerMap = new HashMap<String, PlayerInfo>();
|
||||||
@ -588,13 +582,8 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
while (res.next()) {
|
while (res.next()) {
|
||||||
tempPlayerMap.put(res.getString("player_uuid"), new PlayerInfo(res.getString("username"), res.getInt("id")));
|
tempPlayerMap.put(res.getString("player_uuid"), new PlayerInfo(res.getString("username"), res.getInt("id")));
|
||||||
}
|
}
|
||||||
} finally {
|
} catch (Exception e) {
|
||||||
if (prest != null) {
|
e.printStackTrace();
|
||||||
try {
|
|
||||||
prest.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modifying jobs main table
|
// Modifying jobs main table
|
||||||
@ -613,14 +602,10 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
prest.executeBatch();
|
prest.executeBatch();
|
||||||
conn.commit();
|
conn.commit();
|
||||||
conn.setAutoCommit(true);
|
conn.setAutoCommit(true);
|
||||||
} finally {
|
} catch (Exception e) {
|
||||||
if (prest != null) {
|
e.printStackTrace();
|
||||||
try {
|
|
||||||
prest.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
executeSQL("ALTER TABLE `" + getPrefix() + "jobs` DROP COLUMN `player_uuid`, DROP COLUMN `username`;");
|
executeSQL("ALTER TABLE `" + getPrefix() + "jobs` DROP COLUMN `player_uuid`, DROP COLUMN `username`;");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -641,14 +626,10 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
prest.executeBatch();
|
prest.executeBatch();
|
||||||
conn.commit();
|
conn.commit();
|
||||||
conn.setAutoCommit(true);
|
conn.setAutoCommit(true);
|
||||||
} finally {
|
} catch (Exception e) {
|
||||||
if (prest != null) {
|
e.printStackTrace();
|
||||||
try {
|
|
||||||
prest.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
executeSQL("ALTER TABLE `" + getPrefix() + "archive` DROP COLUMN `player_uuid`, DROP COLUMN `username`;");
|
executeSQL("ALTER TABLE `" + getPrefix() + "archive` DROP COLUMN `player_uuid`, DROP COLUMN `username`;");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -669,6 +650,8 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
prest.executeBatch();
|
prest.executeBatch();
|
||||||
conn.commit();
|
conn.commit();
|
||||||
conn.setAutoCommit(true);
|
conn.setAutoCommit(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
if (prest != null) {
|
if (prest != null) {
|
||||||
try {
|
try {
|
||||||
@ -682,7 +665,12 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
// Create new points table
|
// Create new points table
|
||||||
createDefaultPointsBase();
|
try {
|
||||||
|
executeSQL("CREATE TABLE `" + getPrefix()
|
||||||
|
+ "points` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `userid` int, `totalpoints` double, `currentpoints` double);");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@ import java.sql.SQLException;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
import com.gamingmesh.jobs.container.PlayerInfo;
|
import com.gamingmesh.jobs.container.PlayerInfo;
|
||||||
import com.gamingmesh.jobs.stuff.UUIDUtil;
|
import com.gamingmesh.jobs.stuff.UUIDUtil;
|
||||||
@ -266,11 +268,18 @@ public class JobsDAOSQLite extends JobsDAO {
|
|||||||
}
|
}
|
||||||
if (noJobsdata) {
|
if (noJobsdata) {
|
||||||
dropDataBase("jobs");
|
dropDataBase("jobs");
|
||||||
createDefaultJobsBase();
|
try {
|
||||||
|
executeSQL("CREATE TABLE `" + getPrefix()
|
||||||
|
+ "jobs` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `job` varchar(20), `experience` int, `level` int);");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
}
|
||||||
convertJobs = false;
|
convertJobs = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (convertJobs) {
|
if (convertJobs) {
|
||||||
|
|
||||||
|
Bukkit.getConsoleSender().sendMessage("convert jobs table from byte");
|
||||||
|
|
||||||
Jobs.getPluginLogger().info("Converting byte uuids to string. This could take a long time!!!");
|
Jobs.getPluginLogger().info("Converting byte uuids to string. This could take a long time!!!");
|
||||||
try {
|
try {
|
||||||
executeSQL("CREATE TABLE `" + getPrefix()
|
executeSQL("CREATE TABLE `" + getPrefix()
|
||||||
@ -335,7 +344,11 @@ public class JobsDAOSQLite extends JobsDAO {
|
|||||||
}
|
}
|
||||||
if (noArchivedata) {
|
if (noArchivedata) {
|
||||||
dropDataBase("archive");
|
dropDataBase("archive");
|
||||||
createDefaultArchiveBase();
|
try {
|
||||||
|
executeSQL("CREATE TABLE `" + getPrefix()
|
||||||
|
+ "archive` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `job` varchar(20), `experience` int, `level` int);");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
}
|
||||||
convertArchive = false;
|
convertArchive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,7 +414,11 @@ public class JobsDAOSQLite extends JobsDAO {
|
|||||||
}
|
}
|
||||||
if (nodata) {
|
if (nodata) {
|
||||||
dropDataBase("log");
|
dropDataBase("log");
|
||||||
createDefaultLogBase();
|
try {
|
||||||
|
executeSQL("CREATE TABLE `" + getPrefix()
|
||||||
|
+ "log` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `time` bigint, `action` varchar(20), `itemname` varchar(60), `count` int, `money` double, `exp` double);");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
}
|
||||||
convertLog = false;
|
convertLog = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -510,279 +527,275 @@ public class JobsDAOSQLite extends JobsDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rows == 0) {
|
if (rows != 0)
|
||||||
HashMap<String, String> tempMap = new HashMap<String, String>();
|
return;
|
||||||
PreparedStatement prestJobs = null;
|
|
||||||
try {
|
|
||||||
prestJobs = conn.prepareStatement("SELECT DISTINCT(player_uuid),username FROM " + getPrefix() + "jobs;");
|
|
||||||
ResultSet res = prestJobs.executeQuery();
|
|
||||||
while (res.next()) {
|
|
||||||
tempMap.put(res.getString("player_uuid"), res.getString("username"));
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (prestJobs != null) {
|
|
||||||
try {
|
|
||||||
prestJobs.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PreparedStatement prestArchive = null;
|
|
||||||
try {
|
|
||||||
prestArchive = conn.prepareStatement("SELECT DISTINCT(player_uuid),username FROM " + getPrefix() + "archive;");
|
|
||||||
ResultSet res = prestArchive.executeQuery();
|
|
||||||
while (res.next()) {
|
|
||||||
tempMap.put(res.getString("player_uuid"), res.getString("username"));
|
|
||||||
}
|
|
||||||
if (res != null)
|
|
||||||
res.close();
|
|
||||||
} finally {
|
|
||||||
if (prestArchive != null) {
|
|
||||||
try {
|
|
||||||
prestArchive.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PreparedStatement prestLog = null;
|
|
||||||
try {
|
|
||||||
prestLog = conn.prepareStatement("SELECT DISTINCT(player_uuid),username FROM " + getPrefix() + "log;");
|
|
||||||
ResultSet res = prestLog.executeQuery();
|
|
||||||
while (res.next()) {
|
|
||||||
tempMap.put(res.getString("player_uuid"), res.getString("username"));
|
|
||||||
}
|
|
||||||
if (res != null)
|
|
||||||
res.close();
|
|
||||||
} finally {
|
|
||||||
if (prestLog != null) {
|
|
||||||
try {
|
|
||||||
prestLog.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
HashMap<String, String> tempMap = new HashMap<String, String>();
|
||||||
executeSQL("CREATE TABLE `" + getPrefix()
|
PreparedStatement prestJobs = null;
|
||||||
+ "users` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_uuid` varchar(36) NOT NULL, `username` varchar(20));");
|
try {
|
||||||
} catch (Exception e) {
|
prestJobs = conn.prepareStatement("SELECT * FROM " + getPrefix() + "jobs;");
|
||||||
|
ResultSet res = prestJobs.executeQuery();
|
||||||
|
while (res.next()) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(res.getString("player_uuid") + " -> " + res.getString("username"));
|
||||||
|
tempMap.put(res.getString("player_uuid"), res.getString("username"));
|
||||||
}
|
}
|
||||||
PreparedStatement prestUsers = null;
|
} finally {
|
||||||
try {
|
if (prestJobs != null) {
|
||||||
prestUsers = conn.prepareStatement("INSERT INTO `" + getPrefix() + "users` (`player_uuid`, `username`) VALUES (?, ?);");
|
try {
|
||||||
conn.setAutoCommit(false);
|
prestJobs.close();
|
||||||
for (Entry<String, String> users : tempMap.entrySet()) {
|
} catch (SQLException e) {
|
||||||
prestUsers.setString(1, users.getKey());
|
|
||||||
prestUsers.setString(2, users.getValue());
|
|
||||||
prestUsers.addBatch();
|
|
||||||
}
|
}
|
||||||
prestUsers.executeBatch();
|
|
||||||
conn.commit();
|
|
||||||
conn.setAutoCommit(true);
|
|
||||||
} finally {
|
|
||||||
if (prestUsers != null) {
|
|
||||||
try {
|
|
||||||
prestUsers.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HashMap<String, PlayerInfo> tempPlayerMap = new HashMap<String, PlayerInfo>();
|
|
||||||
|
|
||||||
PreparedStatement prestUsers2 = null;
|
|
||||||
try {
|
|
||||||
prestUsers2 = conn.prepareStatement("SELECT * FROM " + getPrefix() + "users;");
|
|
||||||
ResultSet res = prestUsers2.executeQuery();
|
|
||||||
while (res.next()) {
|
|
||||||
tempPlayerMap.put(res.getString("player_uuid"), new PlayerInfo(res.getString("username"), res.getInt("id")));
|
|
||||||
}
|
|
||||||
if (res != null)
|
|
||||||
res.close();
|
|
||||||
} finally {
|
|
||||||
if (prestUsers2 != null) {
|
|
||||||
try {
|
|
||||||
prestUsers2.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Modifying jobs main table
|
|
||||||
try {
|
|
||||||
executeSQL("ALTER TABLE `" + getPrefix() + "jobs` ADD COLUMN `userid` int;");
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
PreparedStatement prestJobsT = null;
|
|
||||||
try {
|
|
||||||
prestJobsT = conn.prepareStatement("UPDATE `" + getPrefix() + "jobs` SET `userid` = ? WHERE `player_uuid` = ?;");
|
|
||||||
conn.setAutoCommit(false);
|
|
||||||
for (Entry<String, PlayerInfo> users : tempPlayerMap.entrySet()) {
|
|
||||||
prestJobsT.setInt(1, users.getValue().getID());
|
|
||||||
prestJobsT.setString(2, users.getKey());
|
|
||||||
prestJobsT.addBatch();
|
|
||||||
}
|
|
||||||
prestJobsT.executeBatch();
|
|
||||||
conn.commit();
|
|
||||||
conn.setAutoCommit(true);
|
|
||||||
} finally {
|
|
||||||
if (prestJobsT != null) {
|
|
||||||
try {
|
|
||||||
prestJobsT.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// dropping 2 columns
|
|
||||||
try {
|
|
||||||
executeSQL("CREATE TABLE `" + getPrefix()
|
|
||||||
+ "jobs_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `job` varchar(20), `experience` int, `level` int);");
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
PreparedStatement pst111 = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "jobs`;");
|
|
||||||
ResultSet rs11 = pst111.executeQuery();
|
|
||||||
PreparedStatement insert11 = null;
|
|
||||||
while (rs11.next()) {
|
|
||||||
String uuid = UUIDUtil.fromBytes(rs11.getBytes("player_uuid")).toString();
|
|
||||||
if (uuid != null) {
|
|
||||||
insert11 = conn.prepareStatement("INSERT INTO `" + getPrefix() + "jobs_temp` (`userid`, `job`, `experience`, `level`) VALUES (?, ?, ?, ?);");
|
|
||||||
insert11.setInt(1, rs11.getInt("userid"));
|
|
||||||
insert11.setString(2, rs11.getString("job"));
|
|
||||||
insert11.setInt(3, rs11.getInt("experience"));
|
|
||||||
insert11.setInt(4, rs11.getInt("level"));
|
|
||||||
insert11.execute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rs11.close();
|
|
||||||
if (insert11 != null)
|
|
||||||
insert11.close();
|
|
||||||
try {
|
|
||||||
executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "jobs`;");
|
|
||||||
executeSQL("ALTER TABLE `" + getPrefix() + "jobs_temp` RENAME TO `" + getPrefix() + "jobs`;");
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Modifying jobs archive table
|
|
||||||
try {
|
|
||||||
executeSQL("ALTER TABLE `" + getPrefix() + "archive` ADD COLUMN `userid` int;");
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
PreparedStatement prestArchiveT = null;
|
|
||||||
try {
|
|
||||||
prestArchiveT = conn.prepareStatement("UPDATE `" + getPrefix() + "archive` SET `userid` = ? WHERE `player_uuid` = ?;");
|
|
||||||
conn.setAutoCommit(false);
|
|
||||||
for (Entry<String, PlayerInfo> users : tempPlayerMap.entrySet()) {
|
|
||||||
prestArchiveT.setInt(1, users.getValue().getID());
|
|
||||||
prestArchiveT.setString(2, users.getKey());
|
|
||||||
prestArchiveT.addBatch();
|
|
||||||
}
|
|
||||||
prestArchiveT.executeBatch();
|
|
||||||
conn.commit();
|
|
||||||
conn.setAutoCommit(true);
|
|
||||||
} finally {
|
|
||||||
if (prestArchiveT != null) {
|
|
||||||
try {
|
|
||||||
prestArchiveT.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// dropping 2 columns
|
|
||||||
try {
|
|
||||||
executeSQL("CREATE TABLE `" + getPrefix()
|
|
||||||
+ "archive_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `job` varchar(20), `experience` int, `level` int);");
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
PreparedStatement pstArchive = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "archive`;");
|
|
||||||
ResultSet rsArchive = pstArchive.executeQuery();
|
|
||||||
PreparedStatement insertArchive = null;
|
|
||||||
while (rsArchive.next()) {
|
|
||||||
String uuid = UUIDUtil.fromBytes(rsArchive.getBytes("player_uuid")).toString();
|
|
||||||
if (uuid != null) {
|
|
||||||
insertArchive = conn.prepareStatement("INSERT INTO `" + getPrefix() + "archive_temp` (`userid`, `job`, `experience`, `level`) VALUES (?, ?, ?, ?);");
|
|
||||||
insertArchive.setInt(1, rsArchive.getInt("userid"));
|
|
||||||
insertArchive.setString(2, rsArchive.getString("job"));
|
|
||||||
insertArchive.setInt(3, rsArchive.getInt("experience"));
|
|
||||||
insertArchive.setInt(4, rsArchive.getInt("level"));
|
|
||||||
insertArchive.execute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (rsArchive != null)
|
|
||||||
rsArchive.close();
|
|
||||||
if (insertArchive != null)
|
|
||||||
insertArchive.close();
|
|
||||||
if (pstArchive != null)
|
|
||||||
pstArchive.close();
|
|
||||||
executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "archive`;");
|
|
||||||
try {
|
|
||||||
executeSQL("ALTER TABLE `" + getPrefix() + "archive_temp` RENAME TO `" + getPrefix() + "archive`;");
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
// Modifying jobs log table
|
|
||||||
PreparedStatement prestPreLog = null;
|
|
||||||
try {
|
|
||||||
executeSQL("ALTER TABLE `" + getPrefix() + "log` ADD COLUMN `userid` int;");
|
|
||||||
prestPreLog = conn.prepareStatement("UPDATE `" + getPrefix() + "log` SET `userid` = ? WHERE `player_uuid` = ?;");
|
|
||||||
conn.setAutoCommit(false);
|
|
||||||
for (Entry<String, PlayerInfo> users : tempPlayerMap.entrySet()) {
|
|
||||||
prestPreLog.setInt(1, users.getValue().getID());
|
|
||||||
prestPreLog.setString(2, users.getKey());
|
|
||||||
prestPreLog.addBatch();
|
|
||||||
}
|
|
||||||
prestPreLog.executeBatch();
|
|
||||||
conn.commit();
|
|
||||||
conn.setAutoCommit(true);
|
|
||||||
} finally {
|
|
||||||
if (prestPreLog != null) {
|
|
||||||
try {
|
|
||||||
prestPreLog.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// dropping 2 columns
|
|
||||||
try {
|
|
||||||
executeSQL("CREATE TABLE `" + getPrefix()
|
|
||||||
+ "log_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `time` bigint, `action` varchar(20), `itemname` varchar(60), `count` int, `money` double, `exp` double);");
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
PreparedStatement prestLogT = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "log`;");
|
|
||||||
ResultSet rsLog = prestLogT.executeQuery();
|
|
||||||
PreparedStatement insertLog = null;
|
|
||||||
while (rsLog.next()) {
|
|
||||||
String uuid = UUIDUtil.fromBytes(rsLog.getBytes("player_uuid")).toString();
|
|
||||||
if (uuid != null) {
|
|
||||||
insertLog = conn.prepareStatement("INSERT INTO `" + getPrefix()
|
|
||||||
+ "log_temp` (`userid`, `time`, `action`, `itemname`, `count`, `money`, `exp`) VALUES (?, ?, ?, ?, ?, ?, ?);");
|
|
||||||
insertLog.setInt(1, rsLog.getInt("userid"));
|
|
||||||
insertLog.setLong(2, rsLog.getLong("time"));
|
|
||||||
insertLog.setString(3, rsLog.getString("action"));
|
|
||||||
insertLog.setString(4, rsLog.getString("itemname"));
|
|
||||||
insertLog.setInt(5, rsLog.getInt("count"));
|
|
||||||
insertLog.setDouble(6, rsLog.getDouble("money"));
|
|
||||||
insertLog.setDouble(7, rsLog.getDouble("exp"));
|
|
||||||
insertLog.execute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rsLog.close();
|
|
||||||
if (insertLog != null)
|
|
||||||
insertLog.close();
|
|
||||||
|
|
||||||
try {
|
|
||||||
executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "log`;");
|
|
||||||
executeSQL("ALTER TABLE `" + getPrefix() + "log_temp` RENAME TO `" + getPrefix() + "log`;");
|
|
||||||
|
|
||||||
// Create new points table
|
|
||||||
createDefaultPointsBase();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PreparedStatement prestArchive = null;
|
||||||
|
try {
|
||||||
|
prestArchive = conn.prepareStatement("SELECT * FROM " + getPrefix() + "archive;");
|
||||||
|
ResultSet res = prestArchive.executeQuery();
|
||||||
|
while (res.next()) {
|
||||||
|
tempMap.put(res.getString("player_uuid"), res.getString("username"));
|
||||||
|
Bukkit.getConsoleSender().sendMessage(res.getString("player_uuid") + " -> " + res.getString("username"));
|
||||||
|
}
|
||||||
|
if (res != null)
|
||||||
|
res.close();
|
||||||
|
} finally {
|
||||||
|
if (prestArchive != null) {
|
||||||
|
try {
|
||||||
|
prestArchive.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
executeSQL("CREATE TABLE `" + getPrefix()
|
||||||
|
+ "users` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_uuid` varchar(36) NOT NULL, `username` varchar(20));");
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
PreparedStatement prestUsers = null;
|
||||||
|
try {
|
||||||
|
prestUsers = conn.prepareStatement("INSERT INTO `" + getPrefix() + "users` (`player_uuid`, `username`) VALUES (?, ?);");
|
||||||
|
conn.setAutoCommit(false);
|
||||||
|
for (Entry<String, String> users : tempMap.entrySet()) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(users.getKey() + " -----> " + users.getValue());
|
||||||
|
prestUsers.setString(1, users.getKey());
|
||||||
|
prestUsers.setString(2, users.getValue());
|
||||||
|
prestUsers.addBatch();
|
||||||
|
}
|
||||||
|
prestUsers.executeBatch();
|
||||||
|
conn.commit();
|
||||||
|
conn.setAutoCommit(true);
|
||||||
|
} finally {
|
||||||
|
if (prestUsers != null) {
|
||||||
|
try {
|
||||||
|
prestUsers.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap<String, PlayerInfo> tempPlayerMap = new HashMap<String, PlayerInfo>();
|
||||||
|
|
||||||
|
PreparedStatement prestUsers2 = null;
|
||||||
|
try {
|
||||||
|
prestUsers2 = conn.prepareStatement("SELECT * FROM " + getPrefix() + "users;");
|
||||||
|
ResultSet res = prestUsers2.executeQuery();
|
||||||
|
while (res.next()) {
|
||||||
|
tempPlayerMap.put(res.getString("player_uuid"), new PlayerInfo(res.getString("username"), res.getInt("id")));
|
||||||
|
}
|
||||||
|
if (res != null)
|
||||||
|
res.close();
|
||||||
|
} finally {
|
||||||
|
if (prestUsers2 != null) {
|
||||||
|
try {
|
||||||
|
prestUsers2.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modifying jobs main table
|
||||||
|
try {
|
||||||
|
executeSQL("ALTER TABLE `" + getPrefix() + "jobs` ADD COLUMN `userid` int;");
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
PreparedStatement prestJobsT = null;
|
||||||
|
try {
|
||||||
|
prestJobsT = conn.prepareStatement("UPDATE `" + getPrefix() + "jobs` SET `userid` = ? WHERE `player_uuid` = ?;");
|
||||||
|
conn.setAutoCommit(false);
|
||||||
|
for (Entry<String, PlayerInfo> users : tempPlayerMap.entrySet()) {
|
||||||
|
prestJobsT.setInt(1, users.getValue().getID());
|
||||||
|
prestJobsT.setString(2, users.getKey());
|
||||||
|
prestJobsT.addBatch();
|
||||||
|
}
|
||||||
|
prestJobsT.executeBatch();
|
||||||
|
conn.commit();
|
||||||
|
conn.setAutoCommit(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
} finally {
|
||||||
|
if (prestJobsT != null) {
|
||||||
|
try {
|
||||||
|
prestJobsT.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// dropping 2 columns
|
||||||
|
try {
|
||||||
|
executeSQL("CREATE TABLE `" + getPrefix()
|
||||||
|
+ "jobs_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `job` varchar(20), `experience` int, `level` int);");
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
PreparedStatement pst111 = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "jobs`;");
|
||||||
|
ResultSet rs11 = pst111.executeQuery();
|
||||||
|
PreparedStatement insert11 = null;
|
||||||
|
while (rs11.next()) {
|
||||||
|
String uuid = UUIDUtil.fromBytes(rs11.getBytes("player_uuid")).toString();
|
||||||
|
if (uuid != null) {
|
||||||
|
insert11 = conn.prepareStatement("INSERT INTO `" + getPrefix() + "jobs_temp` (`userid`, `job`, `experience`, `level`) VALUES (?, ?, ?, ?);");
|
||||||
|
insert11.setInt(1, rs11.getInt("userid"));
|
||||||
|
insert11.setString(2, rs11.getString("job"));
|
||||||
|
insert11.setInt(3, rs11.getInt("experience"));
|
||||||
|
insert11.setInt(4, rs11.getInt("level"));
|
||||||
|
insert11.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rs11.close();
|
||||||
|
if (insert11 != null)
|
||||||
|
insert11.close();
|
||||||
|
try {
|
||||||
|
executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "jobs`;");
|
||||||
|
executeSQL("ALTER TABLE `" + getPrefix() + "jobs_temp` RENAME TO `" + getPrefix() + "jobs`;");
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modifying jobs archive table
|
||||||
|
try {
|
||||||
|
executeSQL("ALTER TABLE `" + getPrefix() + "archive` ADD COLUMN `userid` int;");
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
PreparedStatement prestArchiveT = null;
|
||||||
|
try {
|
||||||
|
prestArchiveT = conn.prepareStatement("UPDATE `" + getPrefix() + "archive` SET `userid` = ? WHERE `player_uuid` = ?;");
|
||||||
|
conn.setAutoCommit(false);
|
||||||
|
for (Entry<String, PlayerInfo> users : tempPlayerMap.entrySet()) {
|
||||||
|
prestArchiveT.setInt(1, users.getValue().getID());
|
||||||
|
prestArchiveT.setString(2, users.getKey());
|
||||||
|
prestArchiveT.addBatch();
|
||||||
|
}
|
||||||
|
prestArchiveT.executeBatch();
|
||||||
|
conn.commit();
|
||||||
|
conn.setAutoCommit(true);
|
||||||
|
} finally {
|
||||||
|
if (prestArchiveT != null) {
|
||||||
|
try {
|
||||||
|
prestArchiveT.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// dropping 2 columns
|
||||||
|
try {
|
||||||
|
executeSQL("CREATE TABLE `" + getPrefix()
|
||||||
|
+ "archive_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `job` varchar(20), `experience` int, `level` int);");
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
PreparedStatement pstArchive = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "archive`;");
|
||||||
|
ResultSet rsArchive = pstArchive.executeQuery();
|
||||||
|
PreparedStatement insertArchive = null;
|
||||||
|
while (rsArchive.next()) {
|
||||||
|
String uuid = UUIDUtil.fromBytes(rsArchive.getBytes("player_uuid")).toString();
|
||||||
|
if (uuid != null) {
|
||||||
|
insertArchive = conn.prepareStatement("INSERT INTO `" + getPrefix() + "archive_temp` (`userid`, `job`, `experience`, `level`) VALUES (?, ?, ?, ?);");
|
||||||
|
insertArchive.setInt(1, rsArchive.getInt("userid"));
|
||||||
|
insertArchive.setString(2, rsArchive.getString("job"));
|
||||||
|
insertArchive.setInt(3, rsArchive.getInt("experience"));
|
||||||
|
insertArchive.setInt(4, rsArchive.getInt("level"));
|
||||||
|
insertArchive.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rsArchive != null)
|
||||||
|
rsArchive.close();
|
||||||
|
if (insertArchive != null)
|
||||||
|
insertArchive.close();
|
||||||
|
if (pstArchive != null)
|
||||||
|
pstArchive.close();
|
||||||
|
executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "archive`;");
|
||||||
|
try {
|
||||||
|
executeSQL("ALTER TABLE `" + getPrefix() + "archive_temp` RENAME TO `" + getPrefix() + "archive`;");
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
// Modifying jobs log table
|
||||||
|
PreparedStatement prestPreLog = null;
|
||||||
|
try {
|
||||||
|
executeSQL("ALTER TABLE `" + getPrefix() + "log` ADD COLUMN `userid` int;");
|
||||||
|
prestPreLog = conn.prepareStatement("UPDATE `" + getPrefix() + "log` SET `userid` = ? WHERE `player_uuid` = ?;");
|
||||||
|
conn.setAutoCommit(false);
|
||||||
|
for (Entry<String, PlayerInfo> users : tempPlayerMap.entrySet()) {
|
||||||
|
prestPreLog.setInt(1, users.getValue().getID());
|
||||||
|
prestPreLog.setString(2, users.getKey());
|
||||||
|
prestPreLog.addBatch();
|
||||||
|
}
|
||||||
|
prestPreLog.executeBatch();
|
||||||
|
conn.commit();
|
||||||
|
conn.setAutoCommit(true);
|
||||||
|
} finally {
|
||||||
|
if (prestPreLog != null) {
|
||||||
|
try {
|
||||||
|
prestPreLog.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// dropping 2 columns
|
||||||
|
try {
|
||||||
|
executeSQL("CREATE TABLE `" + getPrefix()
|
||||||
|
+ "log_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `time` bigint, `action` varchar(20), `itemname` varchar(60), `count` int, `money` double, `exp` double);");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
PreparedStatement prestLogT = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "log`;");
|
||||||
|
ResultSet rsLog = prestLogT.executeQuery();
|
||||||
|
PreparedStatement insertLog = null;
|
||||||
|
while (rsLog.next()) {
|
||||||
|
String uuid = UUIDUtil.fromBytes(rsLog.getBytes("player_uuid")).toString();
|
||||||
|
if (uuid != null) {
|
||||||
|
insertLog = conn.prepareStatement("INSERT INTO `" + getPrefix()
|
||||||
|
+ "log_temp` (`userid`, `time`, `action`, `itemname`, `count`, `money`, `exp`) VALUES (?, ?, ?, ?, ?, ?, ?);");
|
||||||
|
insertLog.setInt(1, rsLog.getInt("userid"));
|
||||||
|
insertLog.setLong(2, rsLog.getLong("time"));
|
||||||
|
insertLog.setString(3, rsLog.getString("action"));
|
||||||
|
insertLog.setString(4, rsLog.getString("itemname"));
|
||||||
|
insertLog.setInt(5, rsLog.getInt("count"));
|
||||||
|
insertLog.setDouble(6, rsLog.getDouble("money"));
|
||||||
|
insertLog.setDouble(7, rsLog.getDouble("exp"));
|
||||||
|
insertLog.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rsLog.close();
|
||||||
|
if (insertLog != null)
|
||||||
|
insertLog.close();
|
||||||
|
|
||||||
|
executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "log`;");
|
||||||
|
try {
|
||||||
|
executeSQL("ALTER TABLE `" + getPrefix() + "log_temp` RENAME TO `" + getPrefix() + "log`;");
|
||||||
|
|
||||||
|
// Create new points table
|
||||||
|
try {
|
||||||
|
executeSQL("CREATE TABLE `" + getPrefix()
|
||||||
|
+ "points` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `totalpoints` double, `currentpoints` double);");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean createDefaultExploreBase() {
|
private boolean createDefaultExploreBase() {
|
||||||
|
@ -133,10 +133,9 @@ public class BufferedEconomy {
|
|||||||
this.ServerAccount = Bukkit.getOfflinePlayer(ServerAccountname);
|
this.ServerAccount = Bukkit.getOfflinePlayer(ServerAccountname);
|
||||||
|
|
||||||
if (this.ServerTaxesAccount == null)
|
if (this.ServerTaxesAccount == null)
|
||||||
this.ServerTaxesAccount = Bukkit.getOfflinePlayer(ServerAccountname);
|
this.ServerTaxesAccount = Bukkit.getOfflinePlayer(ServerTaxesAccountname);
|
||||||
|
|
||||||
if (Jobs.getGCManager().UseTaxes && Jobs.getGCManager().TransferToServerAccount && ServerTaxesAccount != null) {
|
if (Jobs.getGCManager().UseTaxes && Jobs.getGCManager().TransferToServerAccount && ServerTaxesAccount != null) {
|
||||||
|
|
||||||
economy.depositPlayer(ServerTaxesAccount, TaxesAmount);
|
economy.depositPlayer(ServerTaxesAccount, TaxesAmount);
|
||||||
|
|
||||||
if (ServerTaxesAccount.isOnline()) {
|
if (ServerTaxesAccount.isOnline()) {
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package com.gamingmesh.jobs.listeners;
|
package com.gamingmesh.jobs.listeners;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@ -543,7 +544,14 @@ public class JobsListener implements Listener {
|
|||||||
String name = null;
|
String name = null;
|
||||||
List<String> lore = new ArrayList<String>();
|
List<String> lore = new ArrayList<String>();
|
||||||
|
|
||||||
Map<Enchantment, Integer> enchants = iih.getEnchantments();
|
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
|
||||||
|
try {
|
||||||
|
enchants = iih.getEnchantments();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (enchants.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
if (iih.hasItemMeta()) {
|
if (iih.hasItemMeta()) {
|
||||||
ItemMeta meta = iih.getItemMeta();
|
ItemMeta meta = iih.getItemMeta();
|
||||||
|
1
com/gamingmesh/jobs/nmsUtil/.gitignore
vendored
1
com/gamingmesh/jobs/nmsUtil/.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
/v1_8.class
|
/v1_8.class
|
||||||
/v1_7.class
|
/v1_7.class
|
||||||
/v1_9.class
|
/v1_9.class
|
||||||
|
/v1_10.class
|
||||||
|
74
com/gamingmesh/jobs/nmsUtil/v1_10.java
Normal file
74
com/gamingmesh/jobs/nmsUtil/v1_10.java
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
package com.gamingmesh.jobs.nmsUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Guardian;
|
||||||
|
import org.bukkit.entity.Horse;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Skeleton;
|
||||||
|
import org.bukkit.entity.Zombie;
|
||||||
|
import org.bukkit.entity.Horse.Variant;
|
||||||
|
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||||
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.gamingmesh.jobs.NMS;
|
||||||
|
|
||||||
|
public class v1_10 implements NMS {
|
||||||
|
@Override
|
||||||
|
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
|
||||||
|
List<Block> blocks = new ArrayList<Block>();
|
||||||
|
blocks.addAll(event.getBlocks());
|
||||||
|
return blocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRealType(Entity entity) {
|
||||||
|
String name = entity.getType().name();
|
||||||
|
switch (entity.getType()) {
|
||||||
|
case GUARDIAN:
|
||||||
|
Guardian g = (Guardian) entity;
|
||||||
|
if (g.isElder())
|
||||||
|
name = "GuardianElder";
|
||||||
|
break;
|
||||||
|
case HORSE:
|
||||||
|
Horse horse = (Horse) entity;
|
||||||
|
if (horse.getVariant() == Variant.UNDEAD_HORSE)
|
||||||
|
name = "HorseZombie";
|
||||||
|
if (horse.getVariant() == Variant.SKELETON_HORSE)
|
||||||
|
name = "HorseSkeleton";
|
||||||
|
break;
|
||||||
|
case SKELETON:
|
||||||
|
Skeleton skeleton = (Skeleton) entity;
|
||||||
|
if (skeleton.getSkeletonType() == SkeletonType.WITHER)
|
||||||
|
name = "SkeletonWither";
|
||||||
|
if (skeleton.getSkeletonType() == SkeletonType.STRAY)
|
||||||
|
name = "SkeletonStray";
|
||||||
|
break;
|
||||||
|
case ZOMBIE:
|
||||||
|
Zombie zombie = (Zombie) entity;
|
||||||
|
if (zombie.isVillager())
|
||||||
|
return "ZombieVillager";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getItemInMainHand(Player player) {
|
||||||
|
return player.getInventory().getItemInMainHand();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Block getTargetBlock(Player player, int range) {
|
||||||
|
return player.getTargetBlock((Set<Material>) null, range);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,7 +5,12 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Horse;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Skeleton;
|
||||||
|
import org.bukkit.entity.Zombie;
|
||||||
|
import org.bukkit.entity.Horse.Variant;
|
||||||
|
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -20,8 +25,30 @@ public class v1_7 implements NMS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isElderGuardian(Entity entity) {
|
public String getRealType(Entity entity) {
|
||||||
return false;
|
String name = entity.getType().name();
|
||||||
|
switch (entity.getType()) {
|
||||||
|
case HORSE:
|
||||||
|
Horse horse = (Horse) entity;
|
||||||
|
if (horse.getVariant() == Variant.UNDEAD_HORSE)
|
||||||
|
name = "HorseZombie";
|
||||||
|
if (horse.getVariant() == Variant.SKELETON_HORSE)
|
||||||
|
name = "HorseSkeleton";
|
||||||
|
break;
|
||||||
|
case SKELETON:
|
||||||
|
Skeleton skeleton = (Skeleton) entity;
|
||||||
|
if (skeleton.getSkeletonType() == SkeletonType.WITHER)
|
||||||
|
name = "SkeletonWither";
|
||||||
|
break;
|
||||||
|
case ZOMBIE:
|
||||||
|
Zombie zombie = (Zombie) entity;
|
||||||
|
if (zombie.isVillager())
|
||||||
|
return "ZombieVillager";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
@ -8,7 +8,12 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Guardian;
|
import org.bukkit.entity.Guardian;
|
||||||
|
import org.bukkit.entity.Horse;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Skeleton;
|
||||||
|
import org.bukkit.entity.Zombie;
|
||||||
|
import org.bukkit.entity.Horse.Variant;
|
||||||
|
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -23,14 +28,37 @@ public class v1_8 implements NMS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isElderGuardian(Entity entity) {
|
public String getRealType(Entity entity) {
|
||||||
if (entity instanceof Guardian) {
|
String name = entity.getType().name();
|
||||||
Guardian guardian = (Guardian) entity;
|
switch (entity.getType()) {
|
||||||
if (guardian.isElder())
|
case GUARDIAN:
|
||||||
return true;
|
Guardian g = (Guardian) entity;
|
||||||
|
if (g.isElder())
|
||||||
|
name = "GuardianElder";
|
||||||
|
break;
|
||||||
|
case HORSE:
|
||||||
|
Horse horse = (Horse) entity;
|
||||||
|
if (horse.getVariant() == Variant.UNDEAD_HORSE)
|
||||||
|
name = "HorseZombie";
|
||||||
|
if (horse.getVariant() == Variant.SKELETON_HORSE)
|
||||||
|
name = "HorseSkeleton";
|
||||||
|
break;
|
||||||
|
case SKELETON:
|
||||||
|
Skeleton skeleton = (Skeleton) entity;
|
||||||
|
if (skeleton.getSkeletonType() == SkeletonType.WITHER)
|
||||||
|
name = "SkeletonWither";
|
||||||
|
break;
|
||||||
|
case ZOMBIE:
|
||||||
|
Zombie zombie = (Zombie) entity;
|
||||||
|
if (zombie.isVillager())
|
||||||
|
return "ZombieVillager";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItemInMainHand(Player player) {
|
public ItemStack getItemInMainHand(Player player) {
|
||||||
|
Binary file not shown.
@ -8,7 +8,12 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Guardian;
|
import org.bukkit.entity.Guardian;
|
||||||
|
import org.bukkit.entity.Horse;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Skeleton;
|
||||||
|
import org.bukkit.entity.Zombie;
|
||||||
|
import org.bukkit.entity.Horse.Variant;
|
||||||
|
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -23,13 +28,35 @@ public class v1_9 implements NMS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isElderGuardian(Entity entity) {
|
public String getRealType(Entity entity) {
|
||||||
if (entity instanceof Guardian) {
|
String name = entity.getType().name();
|
||||||
Guardian guardian = (Guardian) entity;
|
switch (entity.getType()) {
|
||||||
if (guardian.isElder())
|
case GUARDIAN:
|
||||||
return true;
|
Guardian g = (Guardian) entity;
|
||||||
|
if (g.isElder())
|
||||||
|
name = "GuardianElder";
|
||||||
|
break;
|
||||||
|
case HORSE:
|
||||||
|
Horse horse = (Horse) entity;
|
||||||
|
if (horse.getVariant() == Variant.UNDEAD_HORSE)
|
||||||
|
name = "HorseZombie";
|
||||||
|
if (horse.getVariant() == Variant.SKELETON_HORSE)
|
||||||
|
name = "HorseSkeleton";
|
||||||
|
break;
|
||||||
|
case SKELETON:
|
||||||
|
Skeleton skeleton = (Skeleton) entity;
|
||||||
|
if (skeleton.getSkeletonType() == SkeletonType.WITHER)
|
||||||
|
name = "SkeletonWither";
|
||||||
|
break;
|
||||||
|
case ZOMBIE:
|
||||||
|
Zombie zombie = (Zombie) entity;
|
||||||
|
if (zombie.isVillager())
|
||||||
|
return "ZombieVillager";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,21 +36,22 @@ public class ActionBar {
|
|||||||
|
|
||||||
private void getInfo() {
|
private void getInfo() {
|
||||||
try {
|
try {
|
||||||
version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
String[] v = Bukkit.getServer().getClass().getPackage().getName().split("\\.");
|
||||||
|
version = v[v.length - 1];
|
||||||
// Translating version to integer for simpler use
|
// Translating version to integer for simpler use
|
||||||
try {
|
try {
|
||||||
cleanVersion = Integer.parseInt(version.replace("v", "").replace("V", "").replace("_", "").replace("r", "").replace("R", ""));
|
cleanVersion = Integer.parseInt(version.replace("v", "").replace("V", "").replace("_", "").replace("r", "").replace("R", ""));
|
||||||
|
cleanVersion *= 10;
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// Fail save if it for some reason can't translate version to integer
|
// Fail safe if it for some reason can't translate version to integer
|
||||||
if (version.contains("v1_7"))
|
|
||||||
cleanVersion = 1700;
|
|
||||||
if (version.contains("v1_6"))
|
|
||||||
cleanVersion = 1600;
|
|
||||||
if (version.contains("v1_5"))
|
|
||||||
cleanVersion = 1500;
|
|
||||||
if (version.contains("v1_4"))
|
if (version.contains("v1_4"))
|
||||||
cleanVersion = 1400;
|
cleanVersion = 1400;
|
||||||
|
if (version.contains("v1_5"))
|
||||||
|
cleanVersion = 1500;
|
||||||
|
if (version.contains("v1_6"))
|
||||||
|
cleanVersion = 1600;
|
||||||
|
if (version.contains("v1_7"))
|
||||||
|
cleanVersion = 1700;
|
||||||
if (version.contains("v1_8_R1"))
|
if (version.contains("v1_8_R1"))
|
||||||
cleanVersion = 1810;
|
cleanVersion = 1810;
|
||||||
if (version.contains("v1_8_R2"))
|
if (version.contains("v1_8_R2"))
|
||||||
@ -61,12 +62,12 @@ public class ActionBar {
|
|||||||
cleanVersion = 1910;
|
cleanVersion = 1910;
|
||||||
if (version.contains("v1_9_R2"))
|
if (version.contains("v1_9_R2"))
|
||||||
cleanVersion = 1920;
|
cleanVersion = 1920;
|
||||||
|
if (version.contains("v1_10_R1"))
|
||||||
|
cleanVersion = 11010;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cleanVersion < 100)
|
if (cleanVersion < 1400)
|
||||||
cleanVersion = cleanVersion * 10;
|
cleanVersion *= 10;
|
||||||
if (cleanVersion < 1000)
|
|
||||||
cleanVersion = cleanVersion * 10;
|
|
||||||
|
|
||||||
packetType = Class.forName(getPacketPlayOutChat());
|
packetType = Class.forName(getPacketPlayOutChat());
|
||||||
Class<?> typeCraftPlayer = Class.forName(getCraftPlayerClasspath());
|
Class<?> typeCraftPlayer = Class.forName(getCraftPlayerClasspath());
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
package com.gamingmesh.jobs.stuff;
|
package com.gamingmesh.jobs.stuff;
|
||||||
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
import org.bukkit.permissions.PermissionDefault;
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
|
|
||||||
public class Perm {
|
public class Perm {
|
||||||
public static boolean hasPermission(OfflinePlayer player, String permission) {
|
|
||||||
Permission p = new Permission(permission, PermissionDefault.FALSE);
|
|
||||||
return ((Player) player).hasPermission(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasPermission(CommandSender player, String permission) {
|
public static boolean hasPermission(CommandSender player, String permission) {
|
||||||
if (player instanceof Player)
|
if (player instanceof Player)
|
||||||
@ -19,6 +14,8 @@ public class Perm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasPermission(Player player, String permission) {
|
public static boolean hasPermission(Player player, String permission) {
|
||||||
|
if (player == null)
|
||||||
|
return false;
|
||||||
Permission p = new Permission(permission, PermissionDefault.FALSE);
|
Permission p = new Permission(permission, PermissionDefault.FALSE);
|
||||||
return player.hasPermission(p);
|
return player.hasPermission(p);
|
||||||
}
|
}
|
||||||
|
@ -99,17 +99,23 @@ Jobs:
|
|||||||
# Ghast
|
# Ghast
|
||||||
# Giant
|
# Giant
|
||||||
# Guardian
|
# Guardian
|
||||||
|
# GuardianElder
|
||||||
# Horse
|
# Horse
|
||||||
|
# HorseZombie
|
||||||
|
# HorseSkeleton
|
||||||
# Iron_golem
|
# Iron_golem
|
||||||
# Magma_cube
|
# Magma_cube
|
||||||
# Mushroom_cow
|
# Mushroom_cow
|
||||||
# Ocelot
|
# Ocelot
|
||||||
# Pig
|
# Pig
|
||||||
# Player
|
# Player
|
||||||
|
# Polar_Bear
|
||||||
# Rabbit
|
# Rabbit
|
||||||
# Sheep
|
# Sheep
|
||||||
# Silverfish
|
# Silverfish
|
||||||
# Skeleton
|
# Skeleton
|
||||||
|
# SkeletonWither
|
||||||
|
# SkeletonStray
|
||||||
# Shulker
|
# Shulker
|
||||||
# Slime
|
# Slime
|
||||||
# Snowman
|
# Snowman
|
||||||
@ -120,6 +126,8 @@ Jobs:
|
|||||||
# Wither
|
# Wither
|
||||||
# Wolf
|
# Wolf
|
||||||
# Zombie
|
# Zombie
|
||||||
|
# ZombieVillager
|
||||||
|
# ZombieHusk
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# NOTE: mob names are case sensitive.
|
# NOTE: mob names are case sensitive.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: Jobs
|
name: Jobs
|
||||||
description: Jobs Plugin for the BukkitAPI
|
description: Jobs Plugin for the BukkitAPI
|
||||||
main: com.gamingmesh.jobs.JobsPlugin
|
main: com.gamingmesh.jobs.JobsPlugin
|
||||||
version: 3.3.3
|
version: 3.4.0
|
||||||
author: phrstbrn
|
author: phrstbrn
|
||||||
depend: [Vault]
|
depend: [Vault]
|
||||||
softdepend: [CoreProtect, MythicMobs, McMMO]
|
softdepend: [CoreProtect, MythicMobs, McMMO]
|
||||||
@ -14,6 +14,8 @@ permissions:
|
|||||||
description: Grants access to all Jobs commands
|
description: Grants access to all Jobs commands
|
||||||
children:
|
children:
|
||||||
jobs.admin: true
|
jobs.admin: true
|
||||||
|
jobs.autojoin.*:
|
||||||
|
default: false
|
||||||
jobs.admin:
|
jobs.admin:
|
||||||
description: Grants permissions as an admin
|
description: Grants permissions as an admin
|
||||||
default: false
|
default: false
|
||||||
|
Loading…
Reference in New Issue
Block a user