1
0
mirror of https://e.coding.net/circlecloud/QuickShop.git synced 2024-11-22 01:58:54 +00:00

异步发送商店信息 防止getOfflinePlayer卡服

This commit is contained in:
502647092 2016-03-23 23:00:56 +08:00
parent 43c6c7a0ef
commit 44ec03bd30
3 changed files with 56 additions and 49 deletions

34
pom.xml
View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.maxgamer</groupId> <groupId>org.maxgamer</groupId>
<artifactId>QuickShop</artifactId> <artifactId>QuickShop</artifactId>
<version>1.8.5</version> <version>1.8.6</version>
<description>快捷商店重置版本...</description> <description>快捷商店重置版本...</description>
<build> <build>
<finalName>${project.name}</finalName> <finalName>${project.name}</finalName>
@ -52,18 +52,30 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<ciManagement>
<system>Jenkins</system>
<url>http://ci.yumc.pw/job/${project.artifactId}/</url>
</ciManagement>
<properties> <properties>
<jenkins.url>http://hs.yumc.pw:8080</jenkins.url>
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT> <env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
<update.description>&amp;a全新版本 &amp;c虚拟悬浮物(橙子提供 对 就是那个汉化COI的逗比)&amp;e7老板修复逗比BUG...</update.description> <update.description>&amp;a全新版本 &amp;c虚拟悬浮物(橙子提供 对 就是那个汉化COI的逗比)&amp;e7老板修复逗比BUG...</update.description>
<update.changes> <update.changes>
&amp;b1.8.5 - &amp;e我是打酱油的 我上个兄弟抽风 不能下载更新...; &amp;b1.8.6 - &amp;c修复getOfflinePlayer导致的服务器卡顿(连不上MOJANG...);
&amp;b1.8.4 - &amp;c清理多余的监听事件,修复部分版本不兼容问题 支持1.9...; &amp;b1.8.4 - &amp;7清理多余的监听事件,修复部分版本不兼容问题 支持1.9...;
&amp;b1.8.3 - &amp;c修复漏斗传输NPE错误...; &amp;b1.8.3 - &amp;7修复漏斗传输NPE错误...;
&amp;b1.8.2 - &amp;c修复箱子的标题为Null是产生的报错...;
</update.changes> </update.changes>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </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>
</repository>
</repositories>
<distributionManagement> <distributionManagement>
<repository> <repository>
<id>jtb</id> <id>jtb</id>
@ -71,16 +83,6 @@
<url>http://repo.yumc.pw/content/repositories/yumcenter/</url> <url>http://repo.yumc.pw/content/repositories/yumcenter/</url>
</repository> </repository>
</distributionManagement> </distributionManagement>
<repositories>
<repository>
<id>yumc-repo</id>
<url>${jenkins.url}/plugin/repository/everything/</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>

View File

@ -172,37 +172,42 @@ public class MsgUtil {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void sendShopInfo(final Player p, final Shop shop, final int stock) { public static void sendShopInfo(final Player p, final Shop shop, final int stock) {
// Potentially faster with an array? Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
final ItemStack item = shop.getItem(); @Override
p.sendMessage(""); public void run() {
p.sendMessage(""); // Potentially faster with an array?
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+"); final ItemStack item = shop.getItem();
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.shop-information")); p.sendMessage("");
p.sendMessage(ChatColor.DARK_PURPLE + "| " p.sendMessage("");
+ MsgUtil.p("menu.owner", Bukkit.getOfflinePlayer(shop.getOwner()).getName() == null ? (shop.isUnlimited() ? "系统商店" : "未知") : Bukkit.getOfflinePlayer(shop.getOwner()).getName())); p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
final String msg = ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.item", shop.getDataName()); p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.shop-information"));
sendItemMessage(p, shop.getItem(), msg); p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.owner",
if (Util.isTool(item.getType())) { Bukkit.getOfflinePlayer(shop.getOwner()).getName() == null ? (shop.isUnlimited() ? "系统商店" : "未知") : Bukkit.getOfflinePlayer(shop.getOwner()).getName()));
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.damage-percent-remaining", Util.getToolPercentage(item))); final String msg = ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.item", shop.getDataName());
} sendItemMessage(p, shop.getItem(), msg);
if (shop.isSelling()) { if (Util.isTool(item.getType())) {
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.stock", "" + (stock == 10000 ? "无限" : stock))); p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.damage-percent-remaining", Util.getToolPercentage(item)));
} else { }
final int space = shop.getRemainingSpace(); if (shop.isSelling()) {
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.space", "" + (space == 10000 ? "无限" : space))); p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.stock", "" + (stock == 10000 ? "无限" : stock)));
} } else {
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.price-per", shop.getDataName(), Util.format(shop.getPrice()))); final int space = shop.getRemainingSpace();
if (shop.isBuying()) { p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.space", "" + (space == 10000 ? "无限" : space)));
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.this-shop-is-buying")); }
} else { p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.price-per", shop.getDataName(), Util.format(shop.getPrice())));
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.this-shop-is-selling")); if (shop.isBuying()) {
} p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.this-shop-is-buying"));
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+"); } else {
if (shop.isSelling()) { p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.this-shop-is-selling"));
p.sendMessage(MsgUtil.p("how-many-buy")); }
} else { p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
final int items = Util.countItems(p.getInventory(), shop.getItem()); if (shop.isSelling()) {
p.sendMessage(MsgUtil.p("how-many-sell", items)); p.sendMessage(MsgUtil.p("how-many-buy"));
} } else {
final int items = Util.countItems(p.getInventory(), shop.getItem());
p.sendMessage(MsgUtil.p("how-many-sell", items));
}
}
});
} }
} }

View File

@ -10,7 +10,7 @@ authors:
softdepend: softdepend:
- Vault - Vault
- WowSuchCleaner - WowSuchCleaner
website: ${jenkins.url}/job/${project.artifactId}/ website: ${ciManagement.url}
commands: commands:
qs: qs:
description: QuickShop 命令 description: QuickShop 命令