1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-29 04:18:07 +01:00

Fixed issue with sign top list not being updated in "real" time

Changed some data storage methods for better performance and possible
small issue fixing.
Changed jobs.petpay permission to jobs.vippetpay to be more accurate for
what it stands.
This commit is contained in:
Zrips 2015-10-13 13:13:22 +03:00
parent da358aef0b
commit ba506a1e62
13 changed files with 269 additions and 274 deletions

View File

@ -45,7 +45,6 @@ import com.gamingmesh.jobs.economy.Economy;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.ActionBar;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.JobsClassLoader;
import com.gamingmesh.jobs.stuff.Loging;
import com.gamingmesh.jobs.tasks.BufferedPaymentThread;

View File

@ -28,9 +28,6 @@ import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import com.gamingmesh.jobs.api.JobsJoinEvent;
import com.gamingmesh.jobs.api.JobsLeaveEvent;
import com.gamingmesh.jobs.api.JobsLevelUpEvent;
@ -46,8 +43,6 @@ 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>();

View File

@ -24,7 +24,6 @@ import java.lang.reflect.Method;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -59,7 +58,6 @@ import com.gamingmesh.jobs.container.TopList;
import com.gamingmesh.jobs.economy.PaymentData;
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;

View File

@ -1,7 +1,5 @@
package com.gamingmesh.jobs.container;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import com.gamingmesh.jobs.stuff.TimeManage;

View File

@ -26,6 +26,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
@ -639,7 +640,18 @@ public abstract class JobsDAO {
prest.setString(1, jobsname);
ResultSet res = prest.executeQuery();
while (res.next()) {
jobs.add(new TopList(res.getString(1), res.getInt(2), res.getInt(3), res.getBytes(4)));
Player player = Bukkit.getPlayer(res.getString(1));
if (player != null) {
JobsPlayer jobsinfo = Jobs.getPlayerManager().getJobsPlayer(player);
Job job = Jobs.getJob(jobsname);
if (job != null) {
JobProgression prog = jobsinfo.getJobProgression(job);
jobs.add(new TopList(player.getName(), prog.getLevel(), (int) prog.getExperience(), UUIDUtil.toBytes(player.getUniqueId())));
}
} else
jobs.add(new TopList(res.getString(1), res.getInt(2), res.getInt(3), res.getBytes(4)));
}
prest.close();
} catch (SQLException e) {

View File

@ -22,8 +22,6 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@ -97,7 +95,6 @@ public class JobsDAOMySQL extends JobsDAO {
}
}
@SuppressWarnings("deprecation")
@Override
protected synchronized void checkUpdate1() throws SQLException {
JobsConnection conn = getConnection();

View File

@ -23,8 +23,6 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;

View File

@ -26,8 +26,6 @@ import java.util.concurrent.LinkedBlockingQueue;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.JobsPlugin;
import com.gamingmesh.jobs.api.JobsPaymentEvent;

View File

@ -23,7 +23,6 @@ import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;

View File

@ -254,7 +254,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
// remove furnace metadata for broken block
Block block = event.getBlock();
if (block == null)
@ -875,7 +875,7 @@ public class JobsPaymentListener implements Listener {
Tameable t = (Tameable) ((EntityDamageByEntityEvent) event.getEntity().getLastDamageCause()).getDamager();
if (t.isTamed() && t.getOwner() instanceof Player) {
pDamager = (Player) t.getOwner();
if (Perm.hasPermission(pDamager, "jobs.petpay"))
if (Perm.hasPermission(pDamager, "jobs.petpay") || Perm.hasPermission(pDamager, "jobs.vippetpay"))
PetPayMultiplier = ConfigManager.getJobsConfiguration().VipPetPay;
else
PetPayMultiplier = ConfigManager.getJobsConfiguration().PetPay;

View File

@ -1,56 +1,57 @@
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);
}
}
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;
}
@SuppressWarnings("deprecation")
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);
}
}

View File

@ -1,48 +1,48 @@
package com.gamingmesh.jobs.stuff;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import com.gamingmesh.jobs.JobsPlugin;
import com.gamingmesh.jobs.config.ConfigManager;
public class Scboard {
private static HashMap<String, Long> timerMap = new HashMap<String, Long>();
private static void RunScheduler() {
Iterator<Entry<String, Long>> MeinMapIter = timerMap.entrySet().iterator();
while (MeinMapIter.hasNext()) {
Entry<String, Long> Map = MeinMapIter.next();
if (System.currentTimeMillis() > Map.getValue() + (ConfigManager.getJobsConfiguration().ToplistInScoreboardInterval * 1000)) {
Player player = Bukkit.getPlayer(Map.getKey());
if (player != null) {
player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
}
timerMap.remove(Map.getKey());
}
}
if (timerMap.size() > 0)
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() {
public void run() {
RunScheduler();
return;
}
}, 20L);
return;
}
public static void addNew(Player player) {
timerMap.put(player.getName(), System.currentTimeMillis());
RunScheduler();
}
}
package com.gamingmesh.jobs.stuff;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import com.gamingmesh.jobs.JobsPlugin;
import com.gamingmesh.jobs.config.ConfigManager;
public class Scboard {
private static ConcurrentHashMap<String, Long> timerMap = new ConcurrentHashMap<String, Long>();
private static void RunScheduler() {
Iterator<Entry<String, Long>> MeinMapIter = timerMap.entrySet().iterator();
while (MeinMapIter.hasNext()) {
Entry<String, Long> Map = MeinMapIter.next();
if (System.currentTimeMillis() > Map.getValue() + (ConfigManager.getJobsConfiguration().ToplistInScoreboardInterval * 1000)) {
Player player = Bukkit.getPlayer(Map.getKey());
if (player != null) {
player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
}
timerMap.remove(Map.getKey());
}
}
if (timerMap.size() > 0)
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() {
public void run() {
RunScheduler();
return;
}
}, 20L);
return;
}
public static void addNew(Player player) {
timerMap.put(player.getName(), System.currentTimeMillis());
RunScheduler();
}
}

View File

@ -1,150 +1,150 @@
name: Jobs
description: Jobs Plugin for the BukkitAPI
main: com.gamingmesh.jobs.JobsPlugin
version: 2.51.0
author: phrstbrn
softdepend: [Vault]
commands:
jobs:
description: Jobs
usage: /jobs
permissions:
jobs.*:
description: Grants access to all Jobs commands
children:
jobs.admin: true
jobs.admin:
description: Grants permissions as an admin
default: false
children:
jobs.use: true
jobs.command.*: true
jobs.use:
description: Grants ability to use this plugin
default: true
jobs.command.*:
description: Grants player access to all commands
default: false
children:
jobs.command.browse: true
jobs.command.stats: true
jobs.command.admin.stats: true
jobs.command.admin.archive: true
jobs.command.archive: true
jobs.command.join: true
jobs.command.leave: true
jobs.command.leaveall: true
jobs.command.info: true
jobs.command.playerinfo: true
jobs.command.fire: true
jobs.command.fireall: true
jobs.command.employ: true
jobs.command.promote: true
jobs.command.demote: true
jobs.command.grantxp: true
jobs.command.removexp: true
jobs.command.transfer: true
jobs.command.reload: true
jobs.command.help: true
jobs.command.top: true
jobs.command.gtop: true
jobs.command.toggle: true
jobs.command.limit: true
jobs.command.give: true
jobs.command.signs: true
jobs.command.signupdate: true
jobs.command.moneyboost: true
jobs.command.expboost: true
jobs.command.browse:
description: Grants access to the browse command
default: true
jobs.command.top:
description: Grants access to the top command
default: true
jobs.command.gtop:
description: Grants access to the gtop command
default: true
jobs.command.stats:
description: Grants access to the stats command
default: true
jobs.command.archive:
description: Grants access to the archive command
default: true
jobs.command.admin.archive:
description: Grants access to the archive command on other players
default: true
jobs.command.admin.stats:
description: Grants access to the stats command on other players
default: true
jobs.command.join:
description: Grants access to the join command
default: true
jobs.command.leave:
description: Grants access to the leave command
default: true
jobs.command.leaveall:
description: Grants access to the leaveall command
default: true
jobs.command.info:
description: Grants access to the info command
default: true
jobs.command.playerinfo:
description: Grants access to the playerinfo command
default: op
jobs.command.fire:
description: Grants access to the fire command
default: op
jobs.command.fireall:
description: Grants access to the fireall command
default: op
jobs.command.employ:
description: Grants access to the employ command
default: op
jobs.command.promote:
description: Grants access to the promote command
default: op
jobs.command.demote:
description: Grants access to the demote command
default: op
jobs.command.grantxp:
description: Grants access to the grantxp command
default: op
jobs.command.removexp:
description: Grants access to the removexp command
default: op
jobs.command.transfer:
description: Grants access to the transfer command
default: op
jobs.command.reload:
description: Grants access to the reload command
default: op
jobs.command.signupdate:
description: Grants access to the reload command
default: op
jobs.command.give:
description: Grants access to the give command
default: op
jobs.command.expboost:
description: Grants access to the expboost command
default: op
jobs.command.moneyboost:
description: Grants access to the moneyboost command
default: op
jobs.command.help:
description: Grants access to the help command
default: true
jobs.command.toggle:
description: Grants access to the toggle command
default: true
jobs.command.limit:
description: Grants access to the limit command
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
name: Jobs
description: Jobs Plugin for the BukkitAPI
main: com.gamingmesh.jobs.JobsPlugin
version: 2.51.2
author: phrstbrn
softdepend: [Vault]
commands:
jobs:
description: Jobs
usage: /jobs
permissions:
jobs.*:
description: Grants access to all Jobs commands
children:
jobs.admin: true
jobs.admin:
description: Grants permissions as an admin
default: false
children:
jobs.use: true
jobs.command.*: true
jobs.use:
description: Grants ability to use this plugin
default: true
jobs.command.*:
description: Grants player access to all commands
default: false
children:
jobs.command.browse: true
jobs.command.stats: true
jobs.command.admin.stats: true
jobs.command.admin.archive: true
jobs.command.archive: true
jobs.command.join: true
jobs.command.leave: true
jobs.command.leaveall: true
jobs.command.info: true
jobs.command.playerinfo: true
jobs.command.fire: true
jobs.command.fireall: true
jobs.command.employ: true
jobs.command.promote: true
jobs.command.demote: true
jobs.command.grantxp: true
jobs.command.removexp: true
jobs.command.transfer: true
jobs.command.reload: true
jobs.command.help: true
jobs.command.top: true
jobs.command.gtop: true
jobs.command.toggle: true
jobs.command.limit: true
jobs.command.give: true
jobs.command.signs: true
jobs.command.signupdate: true
jobs.command.moneyboost: true
jobs.command.expboost: true
jobs.command.browse:
description: Grants access to the browse command
default: true
jobs.command.top:
description: Grants access to the top command
default: true
jobs.command.gtop:
description: Grants access to the gtop command
default: true
jobs.command.stats:
description: Grants access to the stats command
default: true
jobs.command.archive:
description: Grants access to the archive command
default: true
jobs.command.admin.archive:
description: Grants access to the archive command on other players
default: true
jobs.command.admin.stats:
description: Grants access to the stats command on other players
default: true
jobs.command.join:
description: Grants access to the join command
default: true
jobs.command.leave:
description: Grants access to the leave command
default: true
jobs.command.leaveall:
description: Grants access to the leaveall command
default: true
jobs.command.info:
description: Grants access to the info command
default: true
jobs.command.playerinfo:
description: Grants access to the playerinfo command
default: op
jobs.command.fire:
description: Grants access to the fire command
default: op
jobs.command.fireall:
description: Grants access to the fireall command
default: op
jobs.command.employ:
description: Grants access to the employ command
default: op
jobs.command.promote:
description: Grants access to the promote command
default: op
jobs.command.demote:
description: Grants access to the demote command
default: op
jobs.command.grantxp:
description: Grants access to the grantxp command
default: op
jobs.command.removexp:
description: Grants access to the removexp command
default: op
jobs.command.transfer:
description: Grants access to the transfer command
default: op
jobs.command.reload:
description: Grants access to the reload command
default: op
jobs.command.signupdate:
description: Grants access to the reload command
default: op
jobs.command.give:
description: Grants access to the give command
default: op
jobs.command.expboost:
description: Grants access to the expboost command
default: op
jobs.command.moneyboost:
description: Grants access to the moneyboost command
default: op
jobs.command.help:
description: Grants access to the help command
default: true
jobs.command.toggle:
description: Grants access to the toggle command
default: true
jobs.command.limit:
description: Grants access to the limit command
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