mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 05:55:27 +01:00
Added jobs action logging
Small improvements Small change for getting players permissions
This commit is contained in:
parent
26c42852e7
commit
02d6b5e0c2
@ -39,7 +39,6 @@ import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobItems;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.container.Log;
|
||||
import com.gamingmesh.jobs.dao.JobsDAO;
|
||||
import com.gamingmesh.jobs.economy.BufferedEconomy;
|
||||
import com.gamingmesh.jobs.economy.Economy;
|
||||
@ -382,9 +381,6 @@ public class Jobs {
|
||||
} else {
|
||||
PaymentData data = ExpLimit.get(playername);
|
||||
if (data.IsReachedExpLimit(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit, ConfigManager.getJobsConfiguration().EconomyExpLimit)) {
|
||||
|
||||
Debug.D("exp limit reached");
|
||||
|
||||
if (player.isOnline() && !data.Informed && !data.isReseted()) {
|
||||
((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedExplimit"));
|
||||
((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedExplimit2"));
|
||||
@ -445,6 +441,8 @@ public class Jobs {
|
||||
|
||||
Jobs.getEconomy().pay(jPlayer, amount, 0.0);
|
||||
|
||||
if (ConfigManager.getJobsConfiguration().LoggingUse)
|
||||
Loging.recordToLog(jPlayer, info, amount, 0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -564,11 +562,11 @@ public class Jobs {
|
||||
Jobs.getEconomy().pay(jPlayer, amount, expAmount);
|
||||
int oldLevel = prog.getLevel();
|
||||
|
||||
Loging.recordToLog(jPlayer, info, amount, expAmount);
|
||||
if (ConfigManager.getJobsConfiguration().LoggingUse)
|
||||
Loging.recordToLog(jPlayer, info, amount, expAmount);
|
||||
|
||||
if (prog.addExperience(expAmount))
|
||||
Jobs.getPlayerManager().performLevelUp(jPlayer, prog.getJob(), oldLevel);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ import com.gamingmesh.jobs.listeners.JobsListener;
|
||||
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
||||
import com.gamingmesh.jobs.listeners.McMMOlistener;
|
||||
import com.gamingmesh.jobs.listeners.PistonProtectionListener;
|
||||
import com.gamingmesh.jobs.stuff.OfflinePlayerList;
|
||||
import com.gamingmesh.jobs.stuff.ScheduleUtil;
|
||||
import com.gamingmesh.jobs.stuff.TabComplete;
|
||||
import com.gamingmesh.jobs.config.YmlMaker;
|
||||
@ -47,66 +48,66 @@ public class JobsPlugin extends JavaPlugin {
|
||||
public static boolean CPPresent = false;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
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();
|
||||
|
||||
Jobs.setPermissionHandler(new PermissionHandler(this));
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
OfflinePlayerList.fillList();
|
||||
YmlMaker jobConfig = new YmlMaker(this, "jobConfig.yml");
|
||||
jobConfig.saveDefaultConfig();
|
||||
|
||||
Jobs.setPluginLogger(getLogger());
|
||||
YmlMaker jobSigns = new YmlMaker(this, "Signs.yml");
|
||||
jobSigns.saveDefaultConfig();
|
||||
|
||||
Jobs.setDataFolder(getDataFolder());
|
||||
YmlMaker jobSchedule = new YmlMaker(this, "schedule.yml");
|
||||
jobSchedule.saveDefaultConfig();
|
||||
|
||||
ConfigManager.registerJobsConfiguration(new JobsConfiguration(this));
|
||||
ConfigManager.registerJobConfig(new JobConfig(this));
|
||||
Jobs.setPermissionHandler(new PermissionHandler(this));
|
||||
|
||||
getCommand("jobs").setExecutor(new JobsCommands());
|
||||
Jobs.setPluginLogger(getLogger());
|
||||
|
||||
this.getCommand("jobs").setTabCompleter(new TabComplete());
|
||||
Jobs.setDataFolder(getDataFolder());
|
||||
|
||||
try {
|
||||
Jobs.startup();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ConfigManager.registerJobsConfiguration(new JobsConfiguration(this));
|
||||
ConfigManager.registerJobConfig(new JobConfig(this));
|
||||
|
||||
// register the listeners
|
||||
getServer().getPluginManager().registerEvents(new JobsListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new JobsPaymentListener(this), this);
|
||||
getCommand("jobs").setExecutor(new JobsCommands());
|
||||
|
||||
if (McMMOlistener.CheckmcMMO())
|
||||
getServer().getPluginManager().registerEvents(new McMMOlistener(this), this);
|
||||
this.getCommand("jobs").setTabCompleter(new TabComplete());
|
||||
|
||||
if (ConfigManager.getJobsConfiguration().useBlockProtection)
|
||||
getServer().getPluginManager().registerEvents(new PistonProtectionListener(this), this);
|
||||
|
||||
// register economy
|
||||
Bukkit.getScheduler().runTask(this, new HookEconomyTask(this));
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("CoreProtect") != null) {
|
||||
CPPresent = true;
|
||||
CPAPI = ((CoreProtect) getServer().getPluginManager().getPlugin("CoreProtect")).getAPI();
|
||||
}
|
||||
|
||||
// all loaded properly.
|
||||
|
||||
|
||||
if (ConfigManager.getJobsConfiguration().useGlobalBoostScheduler)
|
||||
ScheduleUtil.scheduler();
|
||||
ScheduleUtil.DateUpdater();
|
||||
|
||||
String message = ChatColor.translateAlternateColorCodes('&', "&2Plugin has been enabled succesfully.");
|
||||
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
||||
console.sendMessage(message);
|
||||
try {
|
||||
Jobs.startup();
|
||||
} catch (IOException e) {
|
||||
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);
|
||||
|
||||
if (ConfigManager.getJobsConfiguration().useBlockProtection)
|
||||
getServer().getPluginManager().registerEvents(new PistonProtectionListener(this), this);
|
||||
|
||||
// register economy
|
||||
Bukkit.getScheduler().runTask(this, new HookEconomyTask(this));
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("CoreProtect") != null) {
|
||||
CPPresent = true;
|
||||
CPAPI = ((CoreProtect) getServer().getPluginManager().getPlugin("CoreProtect")).getAPI();
|
||||
}
|
||||
|
||||
// all loaded properly.
|
||||
|
||||
if (ConfigManager.getJobsConfiguration().useGlobalBoostScheduler)
|
||||
ScheduleUtil.scheduler();
|
||||
ScheduleUtil.DateUpdater();
|
||||
|
||||
String message = ChatColor.translateAlternateColorCodes('&', "&2Plugin has been enabled succesfully.");
|
||||
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
||||
console.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Jobs.shutdown();
|
||||
|
@ -46,6 +46,8 @@ import com.gamingmesh.jobs.stuff.ActionBar;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.PerformCommands;
|
||||
|
||||
import net.milkbowl.vault.Vault;
|
||||
|
||||
public class PlayerManager {
|
||||
private Map<String, JobsPlayer> players = Collections.synchronizedMap(new HashMap<String, JobsPlayer>());
|
||||
//private Map<String, JobsPlayer> players = new HashMap<String, JobsPlayer>();
|
||||
@ -153,7 +155,9 @@ public class PlayerManager {
|
||||
if (jPlayer != null)
|
||||
return jPlayer;
|
||||
|
||||
return JobsPlayer.loadFromDao(Jobs.getJobsDAO(), offlinePlayer);
|
||||
JobsPlayer player = JobsPlayer.loadFromDao(Jobs.getJobsDAO(), offlinePlayer);
|
||||
JobsPlayer.loadLogFromDao(player);
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -525,7 +529,7 @@ public class PlayerManager {
|
||||
return true;
|
||||
|
||||
short count = (short) ConfigManager.getJobsConfiguration().getMaxJobs();
|
||||
for (short ctr = 0; ctr < 255; ctr++) {
|
||||
for (short ctr = 0; ctr < 30; ctr++) {
|
||||
if (Perm(player, "jobs.max." + ctr))
|
||||
count = ctr;
|
||||
if (count > currentCount)
|
||||
@ -535,8 +539,7 @@ public class PlayerManager {
|
||||
}
|
||||
|
||||
private boolean Perm(Player player, String permission) {
|
||||
Permission p = new Permission(permission, PermissionDefault.FALSE);
|
||||
return player.hasPermission(p);
|
||||
return player.isPermissionSet(permission);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,9 +61,11 @@ import com.gamingmesh.jobs.i18n.Language;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
import com.gamingmesh.jobs.stuff.GiveItem;
|
||||
import com.gamingmesh.jobs.stuff.OfflinePlayerList;
|
||||
import com.gamingmesh.jobs.stuff.Perm;
|
||||
import com.gamingmesh.jobs.stuff.Scboard;
|
||||
import com.gamingmesh.jobs.stuff.Sorting;
|
||||
import com.gamingmesh.jobs.stuff.TimeManage;
|
||||
import com.gamingmesh.jobs.stuff.TranslateName;
|
||||
|
||||
public class JobsCommands implements CommandExecutor {
|
||||
@ -364,9 +366,12 @@ public class JobsCommands implements CommandExecutor {
|
||||
sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.permission"));
|
||||
return true;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
|
||||
jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
|
||||
// @SuppressWarnings("deprecation")
|
||||
// OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
|
||||
|
||||
OfflinePlayer offlinePlayer = OfflinePlayerList.getPlayer(args[0]);
|
||||
if (offlinePlayer != null)
|
||||
jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
|
||||
} else if (sender instanceof Player) {
|
||||
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
|
||||
}
|
||||
@ -1368,13 +1373,22 @@ public class JobsCommands implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
JobsPlayer JPlayer = null;
|
||||
if (args.length == 1)
|
||||
JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
|
||||
if (args.length == 0)
|
||||
JPlayer = Jobs.getPlayerManager().getJobsPlayer(sender.getName());
|
||||
JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
|
||||
else if (args.length == 1 ) {
|
||||
if (!sender.hasPermission("jobs.commands.log.others")){
|
||||
sender.sendMessage(Language.getMessage("command.error.permission"));
|
||||
return true;
|
||||
}
|
||||
JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
|
||||
if (JPlayer == null)
|
||||
JPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(OfflinePlayerList.getPlayer(args[0]));
|
||||
}
|
||||
|
||||
if (JPlayer == null)
|
||||
if (JPlayer == null) {
|
||||
sendUsage(sender, "log");
|
||||
return true;
|
||||
}
|
||||
|
||||
List<Log> logList = JPlayer.getLog();
|
||||
|
||||
@ -1393,15 +1407,20 @@ public class JobsCommands implements CommandExecutor {
|
||||
unsortMap = Sorting.sortDoubleDESC(unsortMap);
|
||||
int count = 0;
|
||||
int max = 10;
|
||||
sender.sendMessage("******************* " + JPlayer.getUserName() + " *******************");
|
||||
sender.sendMessage(Language.getMessage("command.log.output.topline").replace("%playername%", JPlayer.getUserName()));
|
||||
for (Log one : logList) {
|
||||
HashMap<String, LogAmounts> AmountList = one.getAmountList();
|
||||
for (Entry<String, Double> oneSorted : unsortMap.entrySet()) {
|
||||
for (Entry<String, LogAmounts> oneMap : AmountList.entrySet()) {
|
||||
if (oneMap.getKey().equalsIgnoreCase(oneSorted.getKey())) {
|
||||
count++;
|
||||
String msg = "&6" + count + ". &e" + one.getActionType() + ": &6" + oneMap.getValue().getItemName() + " &ecount: &6" + oneMap.getValue()
|
||||
.getCount() + " &emoney: &6" + oneMap.getValue().getMoney() + " &eexp: &6" + oneMap.getValue().getExp();
|
||||
String msg = Language.getMessage("command.log.output.list")
|
||||
.replace("%number%", String.valueOf(count))
|
||||
.replace("%action%", one.getActionType())
|
||||
.replace("%item%", oneMap.getValue().getItemName().replace(":0", "").toLowerCase())
|
||||
.replace("%qty%", String.valueOf(oneMap.getValue().getCount()))
|
||||
.replace("%money%", String.valueOf(oneMap.getValue().getMoney()))
|
||||
.replace("%exp%", String.valueOf(oneMap.getValue().getExp()));
|
||||
msg = org.bukkit.ChatColor.translateAlternateColorCodes('&', msg);
|
||||
sender.sendMessage(msg);
|
||||
break;
|
||||
@ -1413,7 +1432,7 @@ public class JobsCommands implements CommandExecutor {
|
||||
if (count > max)
|
||||
break;
|
||||
}
|
||||
sender.sendMessage("***********************************************");
|
||||
sender.sendMessage(Language.getMessage("command.log.output.bottomline"));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1429,12 +1448,15 @@ public class JobsCommands implements CommandExecutor {
|
||||
public void run() {
|
||||
Map<LogAmounts, Double> unsortMap = new HashMap<LogAmounts, Double>();
|
||||
|
||||
Collection<? extends Player> onlineP = Bukkit.getOnlinePlayers();
|
||||
|
||||
sender.sendMessage("Looking for players data");
|
||||
for (Player OneP : onlineP) {
|
||||
int time = TimeManage.timeInInt();
|
||||
|
||||
for (String OneP : Jobs.getJobsDAO().getLognameList(time, time)) {
|
||||
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(OneP);
|
||||
if (JPlayer == null) {
|
||||
OfflinePlayer offp = OfflinePlayerList.getPlayer(OneP);
|
||||
if (offp != null)
|
||||
JPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(OfflinePlayerList.getPlayer(OneP));
|
||||
}
|
||||
if (JPlayer == null)
|
||||
continue;
|
||||
List<Log> logList = JPlayer.getLog();
|
||||
@ -1444,7 +1466,7 @@ public class JobsCommands implements CommandExecutor {
|
||||
for (Log one : logList) {
|
||||
HashMap<String, LogAmounts> AmountList = one.getAmountList();
|
||||
for (Entry<String, LogAmounts> oneMap : AmountList.entrySet()) {
|
||||
oneMap.getValue().setUsername(OneP.getName());
|
||||
oneMap.getValue().setUsername(OneP);
|
||||
oneMap.getValue().setAction(one.getActionType());
|
||||
unsortMap.put(oneMap.getValue(), oneMap.getValue().getMoney());
|
||||
}
|
||||
@ -1453,14 +1475,21 @@ public class JobsCommands implements CommandExecutor {
|
||||
|
||||
unsortMap = Sorting.sortDoubleDESCByLog(unsortMap);
|
||||
|
||||
int count = 0;
|
||||
int count = 1;
|
||||
int max = 10;
|
||||
|
||||
sender.sendMessage(Language.getMessage("command.glog.output.topline"));
|
||||
for (Entry<LogAmounts, Double> one : unsortMap.entrySet()) {
|
||||
LogAmounts info = one.getKey();
|
||||
String msg = "&3" + info.getUsername() + " &e" + info.getAction() + ": &6" + (info.getItemName().toString().contains(":0") ? info.getItemName()
|
||||
.toString().replace(":0", "") : info.getItemName()) + " &ecount: &6" + info.getCount() + " &emoney: &6" + info.getMoney() + " &eexp: &6" + info
|
||||
.getExp();
|
||||
|
||||
String msg = Language.getMessage("command.glog.output.list")
|
||||
.replace("%username%", one.getKey().getUsername())
|
||||
.replace("%number%", String.valueOf(count))
|
||||
.replace("%action%", info.getAction())
|
||||
.replace("%item%", one.getKey().getItemName().replace(":0", "").toLowerCase())
|
||||
.replace("%qty%", String.valueOf(one.getKey().getCount()))
|
||||
.replace("%money%", String.valueOf(one.getKey().getMoney()))
|
||||
.replace("%exp%", String.valueOf(one.getKey().getExp()));
|
||||
msg = org.bukkit.ChatColor.translateAlternateColorCodes('&', msg);
|
||||
sender.sendMessage(msg);
|
||||
count++;
|
||||
@ -1471,6 +1500,7 @@ public class JobsCommands implements CommandExecutor {
|
||||
if (unsortMap.size() == 0) {
|
||||
sender.sendMessage("No data found");
|
||||
}
|
||||
sender.sendMessage(Language.getMessage("command.glog.output.bottomline"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -69,6 +69,8 @@ public class JobsConfiguration {
|
||||
protected boolean modifyChat;
|
||||
protected int economyBatchDelay;
|
||||
protected boolean saveOnDisconnect;
|
||||
public boolean LocalOfflinePlayersData;
|
||||
public boolean LoggingUse;
|
||||
public boolean EconomyLimitUse, EconomyExpLimitUse, PayForRenaming, PayForEachCraft, SignsEnabled,
|
||||
SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useCoreProtect, BlockPlaceUse,
|
||||
EnableAnounceMessage, useBlockPiston, useSilkTouchProtection, UseCustomNames, EconomyMoneyStop,
|
||||
@ -369,6 +371,16 @@ public class JobsConfiguration {
|
||||
"Only enable this if you have a multi-server setup, or have a really good reason for enabling this.", "Turning this on will decrease database performance.");
|
||||
saveOnDisconnect = getBoolean("save-on-disconnect", false, config, writer);
|
||||
|
||||
writer.addComment("Optimizations.UseLocalOfflinePlayersData", "With this set to true, offline player data will be taken from local player data files",
|
||||
"This will eliminate small lag spikes when request is being send to mojangs servers for offline players data",
|
||||
"Theroticali this should work without issues, but if you havving some, just disable",
|
||||
"But then you can feal some small (100-200ms) lag spikes while performings some jobs commands");
|
||||
LocalOfflinePlayersData = getBoolean("Optimizations.UseLocalOfflinePlayersData", true, config, writer);
|
||||
|
||||
writer.addComment("Logging.Use", "With this set to true all players jobs actions will be logged to database for easy to see statistics",
|
||||
"This is still in development and in feature it will expand");
|
||||
LoggingUse = getBoolean("Logging.Use", false, config, writer);
|
||||
|
||||
writer.addComment("broadcast.on-skill-up.use", "Do all players get a message when somone goes up a skill level?");
|
||||
isBroadcastingSkillups = getBoolean("broadcast.on-skill-up.use", false, config, writer);
|
||||
|
||||
@ -1289,6 +1301,20 @@ public class JobsConfiguration {
|
||||
GetConfigString("command.gtop.output.next", "&2|&e Next Page >>>>", writer, conf, true);
|
||||
GetConfigString("command.gtop.output.show", "&2Show from &e[from] &2until &e[until] &2global top list", writer, conf, true);
|
||||
|
||||
GetConfigString("command.log.help.info", "Shows statistics.", writer, conf, true);
|
||||
GetConfigString("command.log.help.args", "[playername]", writer, conf, true);
|
||||
GetConfigString("command.log.output.topline", "&7************************* &6%playername% &7*************************", writer, conf, true);
|
||||
GetConfigString("command.log.output.list", "&7* &6%number%. &3%action%: &6%item% &eqty: %qty% &6money: %money% &eexp: %exp%", writer, conf, true);
|
||||
GetConfigString("command.log.output.bottomline", "&7***********************************************************", writer, conf, true);
|
||||
GetConfigString("command.log.output.prev", "&e<<<<< Prev page &2|", writer, conf, true);
|
||||
GetConfigString("command.log.output.next", "&2|&e Next Page >>>>", writer, conf, true);
|
||||
|
||||
GetConfigString("command.glog.help.info", "Shows global statistics.", writer, conf, true);
|
||||
GetConfigString("command.glog.help.args", "", writer, conf, true);
|
||||
GetConfigString("command.glog.output.topline", "&7*********************** &6Global statistics &7***********************", writer, conf, true);
|
||||
GetConfigString("command.glog.output.list", "&7* &6%number%. &3%username% &e%action%: &6%item% &eqty: %qty% &6money: %money% &eexp: %exp%", writer, conf, true);
|
||||
GetConfigString("command.glog.output.bottomline", "&7**************************************************************", writer, conf, true);
|
||||
|
||||
GetConfigString("command.transfer.help.info", "Transfer a player's job from an old job to a new job.", writer, conf, true);
|
||||
GetConfigString("command.transfer.help.args", "[playername] [oldjob] [newjob]", writer, conf, true);
|
||||
GetConfigString("command.transfer.output.target", "You have been transferred from %oldjobname% to %newjobname%.", writer, conf, true);
|
||||
|
@ -4,42 +4,43 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.stuff.OfflinePlayerList;
|
||||
import com.gamingmesh.jobs.stuff.UUIDUtil;
|
||||
|
||||
public final class TopList {
|
||||
private String player;
|
||||
private int level;
|
||||
private int exp;
|
||||
private byte[] uuid;
|
||||
private String player;
|
||||
private int level;
|
||||
private int exp;
|
||||
private byte[] uuid;
|
||||
|
||||
public TopList(String player, int level, int exp, byte[] uuid) {
|
||||
this.player = player;
|
||||
this.level = level;
|
||||
this.exp = exp;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
public TopList(String player, int level, int exp, byte[] uuid) {
|
||||
this.player = player;
|
||||
this.level = level;
|
||||
this.exp = exp;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
if (this.player == null || this.player == "") {
|
||||
Player player = Bukkit.getPlayer(UUIDUtil.fromBytes(this.uuid));
|
||||
if (player != null)
|
||||
return player.getName();
|
||||
else {
|
||||
OfflinePlayer Offlineplayer = Bukkit.getOfflinePlayer(UUIDUtil.fromBytes(this.uuid));
|
||||
if (Offlineplayer != null)
|
||||
return Offlineplayer.getName();
|
||||
else
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
return this.player;
|
||||
public String getPlayerName() {
|
||||
if (this.player == null || this.player == "") {
|
||||
Player player = Bukkit.getPlayer(UUIDUtil.fromBytes(this.uuid));
|
||||
if (player != null)
|
||||
return player.getName();
|
||||
else {
|
||||
OfflinePlayer Offlineplayer = OfflinePlayerList.getPlayer(UUIDUtil.fromBytes(this.uuid));
|
||||
if (Offlineplayer != null)
|
||||
return Offlineplayer.getName();
|
||||
else
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return this.level;
|
||||
}
|
||||
public int getLevel() {
|
||||
return this.level;
|
||||
}
|
||||
|
||||
public int getExp() {
|
||||
return this.exp;
|
||||
}
|
||||
public int getExp() {
|
||||
return this.exp;
|
||||
}
|
||||
}
|
@ -587,12 +587,43 @@ public abstract class JobsDAO {
|
||||
while (res.next()) {
|
||||
Loging.loadToLog(player, res.getString("action"), res.getString("itemname"), res.getInt("count"), res.getDouble("money"), res.getDouble("exp"));
|
||||
}
|
||||
res.close();
|
||||
prest.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save player-job information
|
||||
* @param jobInfo - the information getting saved
|
||||
* @return
|
||||
*/
|
||||
public List<String> getLognameList(int fromtime, int untiltime) {
|
||||
JobsConnection conn = getConnection();
|
||||
if (conn == null)
|
||||
return null;
|
||||
try {
|
||||
List<String> nameList = new ArrayList<String>();
|
||||
|
||||
PreparedStatement prest = conn.prepareStatement("SELECT `username` FROM `" + prefix
|
||||
+ "log` WHERE `time` >= ? AND `time` <= ? ;");
|
||||
prest.setInt(1, fromtime);
|
||||
prest.setInt(2, untiltime);
|
||||
ResultSet res = prest.executeQuery();
|
||||
while (res.next()) {
|
||||
if (!nameList.contains(res.getString("username")))
|
||||
nameList.add(res.getString("username"));
|
||||
}
|
||||
res.close();
|
||||
prest.close();
|
||||
return nameList;
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show top list
|
||||
* @param toplist - toplist by jobs name
|
||||
|
@ -25,9 +25,11 @@ import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.OfflinePlayerList;
|
||||
import com.gamingmesh.jobs.stuff.UUIDUtil;
|
||||
|
||||
public class JobsDAOMySQL extends JobsDAO {
|
||||
@ -186,7 +188,12 @@ public class JobsDAOMySQL extends JobsDAO {
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.DARK_GREEN + "" + y + " of " + usernames.size());
|
||||
i = 0;
|
||||
}
|
||||
pst2.setBytes(1, UUIDUtil.toBytes(UUID.fromString(Bukkit.getOfflinePlayer(names).getUniqueId().toString())));
|
||||
|
||||
OfflinePlayer offPlayer = OfflinePlayerList.getPlayer(names);
|
||||
if (offPlayer == null)
|
||||
continue;
|
||||
|
||||
pst2.setBytes(1, UUIDUtil.toBytes(offPlayer.getUniqueId()));
|
||||
pst2.setString(2, names);
|
||||
pst2.execute();
|
||||
}
|
||||
|
@ -26,9 +26,11 @@ import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.OfflinePlayerList;
|
||||
import com.gamingmesh.jobs.stuff.UUIDUtil;
|
||||
|
||||
public class JobsDAOSQLite extends JobsDAO {
|
||||
@ -152,7 +154,12 @@ public class JobsDAOSQLite extends JobsDAO {
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.DARK_GREEN + "" + y + " of " + usernames.size());
|
||||
i = 0;
|
||||
}
|
||||
pst2.setBytes(1, UUIDUtil.toBytes(UUID.fromString(Bukkit.getOfflinePlayer(names).getUniqueId().toString())));
|
||||
|
||||
OfflinePlayer offPlayer = OfflinePlayerList.getPlayer(names);
|
||||
if (offPlayer == null)
|
||||
continue;
|
||||
|
||||
pst2.setBytes(1, UUIDUtil.toBytes(offPlayer.getUniqueId()));
|
||||
pst2.setString(2, names);
|
||||
pst2.execute();
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
import com.gamingmesh.jobs.stuff.ActionBar;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.OfflinePlayerList;
|
||||
import com.gamingmesh.jobs.tasks.BufferedPaymentTask;
|
||||
|
||||
public class BufferedEconomy {
|
||||
@ -80,7 +81,6 @@ public class BufferedEconomy {
|
||||
/**
|
||||
* Payout all players the amount they are going to be paid
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void payAll() {
|
||||
if (payments.isEmpty())
|
||||
return;
|
||||
@ -128,10 +128,10 @@ public class BufferedEconomy {
|
||||
String ServerAccountname = ConfigManager.getJobsConfiguration().ServerAcountName;
|
||||
String ServerTaxesAccountname = ConfigManager.getJobsConfiguration().ServertaxesAcountName;
|
||||
if (this.ServerAccount == null)
|
||||
this.ServerAccount = Bukkit.getOfflinePlayer(ServerAccountname);
|
||||
this.ServerAccount = OfflinePlayerList.getPlayer(ServerAccountname);
|
||||
|
||||
if (this.ServerTaxesAccount == null)
|
||||
this.ServerTaxesAccount = Bukkit.getOfflinePlayer(ServerAccountname);
|
||||
this.ServerTaxesAccount = OfflinePlayerList.getPlayer(ServerAccountname);
|
||||
|
||||
if (ConfigManager.getJobsConfiguration().UseTaxes && ConfigManager.getJobsConfiguration().TransferToServerAccount && ServerTaxesAccount != null) {
|
||||
|
||||
|
@ -51,6 +51,7 @@ import com.gamingmesh.jobs.config.ConfigManager;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
import com.gamingmesh.jobs.stuff.OfflinePlayerList;
|
||||
|
||||
public class JobsListener implements Listener {
|
||||
// hook to the main plugin
|
||||
@ -185,6 +186,7 @@ public class JobsListener implements Listener {
|
||||
if (!plugin.isEnabled())
|
||||
return;
|
||||
Jobs.getPlayerManager().playerQuit(event.getPlayer());
|
||||
OfflinePlayerList.addPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@ -205,15 +207,9 @@ public class JobsListener implements Listener {
|
||||
if (!ConfigManager.getJobsConfiguration().SignsEnabled)
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getPlayer();
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
Material material = event.getClickedBlock().getType();
|
||||
|
||||
if (material != Material.WALL_SIGN && material != Material.SIGN && material != Material.SIGN_POST)
|
||||
return;
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
if (block == null)
|
||||
@ -237,6 +233,7 @@ public class JobsListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
Player player = (Player) event.getPlayer();
|
||||
Bukkit.dispatchCommand(player, "jobs " + command + " " + ChatColor.stripColor(sign.getLine(2)) + " " + ChatColor.stripColor(sign.getLine(3)));
|
||||
}
|
||||
|
||||
@ -249,11 +246,6 @@ public class JobsListener implements Listener {
|
||||
if (!ConfigManager.getJobsConfiguration().SignsEnabled)
|
||||
return;
|
||||
|
||||
Material material = event.getBlock().getType();
|
||||
|
||||
if (material != Material.WALL_SIGN && material != Material.SIGN && material != Material.SIGN_POST)
|
||||
return;
|
||||
|
||||
Block block = event.getBlock();
|
||||
|
||||
if (block == null)
|
||||
|
2
com/gamingmesh/jobs/stuff/.gitignore
vendored
2
com/gamingmesh/jobs/stuff/.gitignore
vendored
@ -26,3 +26,5 @@
|
||||
/TimeManage.class
|
||||
/Loging.class
|
||||
/ScheduleUtil$2.class
|
||||
/OfflinePlayerList.class
|
||||
/OfflinePlayerList$1.class
|
||||
|
@ -19,9 +19,7 @@ public class Loging {
|
||||
|
||||
if (jPlayer.getLog().size() > 0 && ScheduleUtil.dateByInt != jPlayer.getLog().get(0).getDate()) {
|
||||
ScheduleUtil.dateByInt = TimeManage.timeInInt();
|
||||
Debug.D("1 Not equals " + ScheduleUtil.dateByInt + " " + jPlayer.getLog().get(0).getDate());
|
||||
if (ScheduleUtil.dateByInt != jPlayer.getLog().get(0).getDate()) {
|
||||
Debug.D("Not equals " + ScheduleUtil.dateByInt + " " + jPlayer.getLog().get(0).getDate());
|
||||
Jobs.getJobsDAO().saveLog(jPlayer);
|
||||
jPlayer.getLog().clear();
|
||||
}
|
||||
@ -30,19 +28,13 @@ public class Loging {
|
||||
for (Log one : logList) {
|
||||
if (!one.getActionType().equalsIgnoreCase(ActionName))
|
||||
continue;
|
||||
|
||||
one.add(item, amount, expAmount);
|
||||
|
||||
found = true;
|
||||
|
||||
Debug.D(item + " : " + one.getCount(item) + " money: " + one.getMoney(item) + " exp:" + one.getExp(item));
|
||||
}
|
||||
if (!found) {
|
||||
Log log = new Log(ActionName);
|
||||
log.add(item, amount, expAmount);
|
||||
logList.add(log);
|
||||
String msg = item + " : " + log.getCount(item) + " money: " + log.getMoney(item) + " exp:" + log.getExp(item);
|
||||
Debug.D(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,19 +44,13 @@ public class Loging {
|
||||
for (Log one : logList) {
|
||||
if (!one.getActionType().equalsIgnoreCase(ActionName))
|
||||
continue;
|
||||
|
||||
one.add(item, count, money, expAmount);
|
||||
|
||||
found = true;
|
||||
|
||||
Debug.D(item + " : " + one.getCount(item) + " money: " + one.getMoney(item) + " exp:" + one.getExp(item));
|
||||
}
|
||||
if (!found) {
|
||||
Log log = new Log(ActionName);
|
||||
log.add(item, count, money, expAmount);
|
||||
logList.add(log);
|
||||
String msg = item + " : " + log.getCount(item) + " money: " + log.getMoney(item) + " exp:" + log.getExp(item);
|
||||
Debug.D(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
56
com/gamingmesh/jobs/stuff/OfflinePlayerList.java
Normal file
56
com/gamingmesh/jobs/stuff/OfflinePlayerList.java
Normal file
@ -0,0 +1,56 @@
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import com.gamingmesh.jobs.JobsPlugin;
|
||||
import com.gamingmesh.jobs.config.ConfigManager;
|
||||
|
||||
public class OfflinePlayerList {
|
||||
|
||||
private static HashMap<String, OfflinePlayer> map = new HashMap<String, OfflinePlayer>();
|
||||
private static HashMap<UUID, OfflinePlayer> uuidmap = new HashMap<UUID, OfflinePlayer>();
|
||||
|
||||
public static void fillList() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(JobsPlugin.instance, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
OfflinePlayer[] players = Bukkit.getOfflinePlayers();
|
||||
for (OfflinePlayer one : players) {
|
||||
if (one == null)
|
||||
continue;
|
||||
map.put(one.getName().toLowerCase(), one);
|
||||
uuidmap.put(one.getUniqueId(), one);
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static OfflinePlayer getPlayer(UUID uuid) {
|
||||
if (!ConfigManager.getJobsConfiguration().LocalOfflinePlayersData)
|
||||
return Bukkit.getOfflinePlayer(uuid);
|
||||
|
||||
if (uuidmap.containsKey(uuid))
|
||||
return uuidmap.get(uuid);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static OfflinePlayer getPlayer(String name) {
|
||||
if (!ConfigManager.getJobsConfiguration().LocalOfflinePlayersData)
|
||||
return Bukkit.getOfflinePlayer(name);
|
||||
|
||||
if (map.containsKey(name.toLowerCase()))
|
||||
return map.get(name.toLowerCase());
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void addPlayer(OfflinePlayer player) {
|
||||
map.put(player.getName().toLowerCase(), player);
|
||||
uuidmap.put(player.getUniqueId(), player);
|
||||
}
|
||||
|
||||
}
|
13
plugin.yml
13
plugin.yml
@ -1,7 +1,7 @@
|
||||
name: Jobs
|
||||
description: Jobs Plugin for the BukkitAPI
|
||||
main: com.gamingmesh.jobs.JobsPlugin
|
||||
version: 2.50.1
|
||||
version: 2.51.0
|
||||
author: phrstbrn
|
||||
softdepend: [Vault]
|
||||
commands:
|
||||
@ -138,4 +138,13 @@ permissions:
|
||||
default: true
|
||||
jobs.command.limit:
|
||||
description: Grants access to the limit command
|
||||
default: true
|
||||
default: true
|
||||
jobs.command.log:
|
||||
description: Grants access to the log command
|
||||
default: true
|
||||
jobs.command.log.others:
|
||||
description: Grants access to the log command
|
||||
default: op
|
||||
jobs.command.glog:
|
||||
description: Grants access to the glog command
|
||||
default: op
|
Loading…
Reference in New Issue
Block a user