1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-30 21:07:48 +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

@ -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

@ -39,6 +39,7 @@ public class OfflinePlayerList {
return null;
}
@SuppressWarnings("deprecation")
public static OfflinePlayer getPlayer(String name) {
if (!ConfigManager.getJobsConfiguration().LocalOfflinePlayersData)
return Bukkit.getOfflinePlayer(name);

View File

@ -1,8 +1,8 @@
package com.gamingmesh.jobs.stuff;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -13,36 +13,36 @@ import com.gamingmesh.jobs.config.ConfigManager;
public class Scboard {
private static HashMap<String, Long> timerMap = new HashMap<String, Long>();
private static ConcurrentHashMap<String, Long> timerMap = new ConcurrentHashMap<String, Long>();
private static void RunScheduler() {
private static void RunScheduler() {
Iterator<Entry<String, Long>> MeinMapIter = timerMap.entrySet().iterator();
while (MeinMapIter.hasNext()) {
Entry<String, Long> Map = MeinMapIter.next();
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 (System.currentTimeMillis() > Map.getValue() + (ConfigManager.getJobsConfiguration().ToplistInScoreboardInterval * 1000)) {
Player player = Bukkit.getPlayer(Map.getKey());
if (player != null) {
player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
}
if (timerMap.size() > 0)
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() {
public void run() {
RunScheduler();
return;
}
}, 20L);
return;
timerMap.remove(Map.getKey());
}
}
public static void addNew(Player player) {
timerMap.put(player.getName(), System.currentTimeMillis());
RunScheduler();
}
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,7 +1,7 @@
name: Jobs
description: Jobs Plugin for the BukkitAPI
main: com.gamingmesh.jobs.JobsPlugin
version: 2.51.0
version: 2.51.2
author: phrstbrn
softdepend: [Vault]
commands: