mirror of
https://e.coding.net/circlecloud/QuickShop.git
synced 2024-12-26 07:38:49 +00:00
fix(getOfflinePlayer): 修复getOfflinePlayer卡服问题
This commit is contained in:
parent
44ec03bd30
commit
c2ac919c40
BIN
lib/Vault.jar
BIN
lib/Vault.jar
Binary file not shown.
14
pom.xml
14
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.maxgamer</groupId>
|
||||
<artifactId>QuickShop</artifactId>
|
||||
<version>1.8.6</version>
|
||||
<version>1.8.7</version>
|
||||
<description>快捷商店重置版本...</description>
|
||||
<build>
|
||||
<finalName>${project.name}</finalName>
|
||||
@ -60,17 +60,14 @@
|
||||
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
|
||||
<update.description>&a全新版本 &c虚拟悬浮物(橙子提供 对 就是那个汉化COI的逗比)&e7老板修复逗比BUG...</update.description>
|
||||
<update.changes>
|
||||
&b1.8.7 - &e异步处理getOfflinePlayer 只能保证不卡服 连不上MOJANG-API还是一样...;
|
||||
- &c修复部分情况下可以跳过AuthMe和Residence的事件拦截...;
|
||||
&b1.8.6 - &c修复getOfflinePlayer导致的服务器卡顿(连不上MOJANG...);
|
||||
&b1.8.4 - &7清理多余的监听事件,修复部分版本不兼容问题 支持1.9...;
|
||||
&b1.8.3 - &7修复漏斗传输NPE错误...;
|
||||
</update.changes>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>yumc-repo</id>
|
||||
<url>http://repo.yumc.pw/content/groups/public/</url>
|
||||
@ -92,10 +89,9 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<artifactId>Vault</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.5.6</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Vault.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
|
@ -39,7 +39,7 @@ public class PlayerListener implements Listener {
|
||||
* Handles players left clicking a chest. Left click a NORMAL chest with
|
||||
* item : Send creation menu Left click a SHOP chest : Send purchase menu
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onClick(final PlayerInteractEvent e) {
|
||||
final Block b = e.getClickedBlock();
|
||||
final Player p = e.getPlayer();
|
||||
@ -154,7 +154,7 @@ public class PlayerListener implements Listener {
|
||||
plugin.getShopManager().getActions().remove(e.getPlayer().getName());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onSuperItemClick(final PlayerInteractEvent e) {
|
||||
final Player p = e.getPlayer();
|
||||
if (p.getGameMode() != GameMode.SURVIVAL || e.getMaterial() != plugin.getConfigManager().getSuperItem()) {
|
||||
|
@ -114,20 +114,25 @@ public class MsgUtil {
|
||||
* them in the database.
|
||||
*/
|
||||
public static void send(final String player, final String message) {
|
||||
@SuppressWarnings("deprecation")
|
||||
final OfflinePlayer p = Bukkit.getOfflinePlayer(player);
|
||||
if (p == null || !p.isOnline()) {
|
||||
LinkedList<String> msgs = player_messages.get(player);
|
||||
if (msgs == null) {
|
||||
msgs = new LinkedList<String>();
|
||||
player_messages.put(player, msgs);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@SuppressWarnings("deprecation")
|
||||
final OfflinePlayer p = Bukkit.getOfflinePlayer(player);
|
||||
if (p == null || !p.isOnline()) {
|
||||
LinkedList<String> msgs = player_messages.get(player);
|
||||
if (msgs == null) {
|
||||
msgs = new LinkedList<String>();
|
||||
player_messages.put(player, msgs);
|
||||
}
|
||||
msgs.add(message);
|
||||
final String q = "INSERT INTO messages (owner, message, time) VALUES (?, ?, ?)";
|
||||
plugin.getDB().execute(q, player.toString(), message, System.currentTimeMillis());
|
||||
} else {
|
||||
p.getPlayer().sendMessage(message);
|
||||
}
|
||||
}
|
||||
msgs.add(message);
|
||||
final String q = "INSERT INTO messages (owner, message, time) VALUES (?, ?, ?)";
|
||||
plugin.getDB().execute(q, player.toString(), message, System.currentTimeMillis());
|
||||
} else {
|
||||
p.getPlayer().sendMessage(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void sendItemMessage(final Player p, final ItemStack is, final String msg) {
|
||||
@ -181,8 +186,9 @@ public class MsgUtil {
|
||||
p.sendMessage("");
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.shop-information"));
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.owner",
|
||||
Bukkit.getOfflinePlayer(shop.getOwner()).getName() == null ? (shop.isUnlimited() ? "系统商店" : "未知") : Bukkit.getOfflinePlayer(shop.getOwner()).getName()));
|
||||
p.sendMessage(ChatColor.DARK_PURPLE
|
||||
+ "| "
|
||||
+ MsgUtil.p("menu.owner", Bukkit.getOfflinePlayer(shop.getOwner()).getName() == null ? (shop.isUnlimited() ? "系统商店" : "未知") : Bukkit.getOfflinePlayer(shop.getOwner()).getName()));
|
||||
final String msg = ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.item", shop.getDataName());
|
||||
sendItemMessage(p, shop.getItem(), msg);
|
||||
if (Util.isTool(item.getType())) {
|
||||
|
@ -12,36 +12,26 @@ import org.maxgamer.QuickShop.QuickShop;
|
||||
|
||||
public class LogWatcher implements Runnable {
|
||||
private PrintStream ps;
|
||||
private ArrayList<String> logs = new ArrayList<String>(5);
|
||||
private final ArrayList<String> logs = new ArrayList<String>(5);
|
||||
public BukkitTask task;
|
||||
|
||||
public LogWatcher(QuickShop plugin, File log) {
|
||||
public LogWatcher(final QuickShop plugin, final File log) {
|
||||
try {
|
||||
if (!log.exists()) {
|
||||
log.createNewFile();
|
||||
}
|
||||
FileOutputStream fos = new FileOutputStream(log, true);
|
||||
this.ps = new PrintStream(fos);
|
||||
} catch (FileNotFoundException e) {
|
||||
final FileOutputStream fos = new FileOutputStream(log, true);
|
||||
this.ps = new PrintStream(fos, true, "UTF-8");
|
||||
} catch (final FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
plugin.getLogger().severe("日志文件未找到!");
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
plugin.getLogger().severe("无法创建日志文件!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (logs) {
|
||||
for (String s : logs) {
|
||||
ps.println(s);
|
||||
}
|
||||
logs.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void add(String s) {
|
||||
public void add(final String s) {
|
||||
synchronized (logs) {
|
||||
logs.add(s);
|
||||
}
|
||||
@ -50,4 +40,14 @@ public class LogWatcher implements Runnable {
|
||||
public void close() {
|
||||
this.ps.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (logs) {
|
||||
for (final String s : logs) {
|
||||
ps.println(s);
|
||||
}
|
||||
logs.clear();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user