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

修复异步载入商店信息未刷新的问题...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-12-18 15:37:08 +08:00
parent 8c26cd6fa4
commit 2397e33d35
2 changed files with 19 additions and 19 deletions

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.6.6</version> <version>1.6.6.1</version>
<description>快捷商店重置版本...</description> <description>快捷商店重置版本...</description>
<build> <build>
<finalName>${project.name}</finalName> <finalName>${project.name}</finalName>
@ -55,7 +55,7 @@
<properties> <properties>
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url> <jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
<env.BUILD_NUMBER>DEBUG</env.BUILD_NUMBER> <env.BUILD_NUMBER>DEBUG</env.BUILD_NUMBER>
<update.description>&amp;c修改本地化工具载入为异步(&amp;a妈妈再也不担心卡服啦&amp;c)...</update.description> <update.description>&amp;c修复异步载入商店信息未刷新的问题...</update.description>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<repositories> <repositories>

View File

@ -8,6 +8,7 @@ import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.Iterator;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -150,32 +151,31 @@ public class QuickShop extends JavaPlugin {
} }
public void loadShop() { public void loadShop() {
loadShop(false); if (!LocalUtil.isInit()) {
} this.getLogger().warning("本地化工具尚未初始化完成 商店汉化信息将在稍后刷新...");
public void loadShop(final boolean async) {
if (!async && !LocalUtil.isInit()) {
this.getLogger().warning("本地化工具尚未初始化完成 商店将在稍后载入...");
this.getServer().getScheduler().runTaskAsynchronously(this, new Runnable() { this.getServer().getScheduler().runTaskAsynchronously(this, new Runnable() {
@Override @Override
public void run() { public void run() {
loadShop(true); while (!LocalUtil.isInit()) {
}
});
return;
}
while (LocalUtil.isInit()) {
try { try {
Thread.sleep(500); Thread.sleep(500);
} catch (final InterruptedException e) { } catch (final InterruptedException e) {
} }
} }
/* Load shops from database to memory */ getLogger().info("本地化工具载入完成 刷新汉化信息...");
int count = 0; // Shops count final Iterator<Shop> shops = shopManager.getShopIterator();
while (shops.hasNext()) {
shops.next().onClick();
}
}
});
}
/* 从数据库载入商店信息到内存 */
int count = 0; // 商店个数
int unload = 0; int unload = 0;
Connection con; Connection con;
try { try {
getLogger().info("本地化工具载入完成 从数据库载入商店数据..."); getLogger().info("开始从数据库载入商店数据...");
con = database.getConnection(); con = database.getConnection();
final PreparedStatement ps = con.prepareStatement("SELECT * FROM shops"); final PreparedStatement ps = con.prepareStatement("SELECT * FROM shops");
final ResultSet rs = ps.executeQuery(); final ResultSet rs = ps.executeQuery();