更新插件时检测在线玩家,如果有玩家则不会更新。
修复 /tlib iteminfo 命令的一些语法错误。
This commit is contained in:
parent
b10b11cff0
commit
6069ea9ad0
@ -12,6 +12,7 @@ import me.skymc.taboolib.commands.taboolib.*;
|
|||||||
import me.skymc.taboolib.fileutils.FileUtils;
|
import me.skymc.taboolib.fileutils.FileUtils;
|
||||||
import me.skymc.taboolib.inventory.ItemUtils;
|
import me.skymc.taboolib.inventory.ItemUtils;
|
||||||
import me.skymc.taboolib.other.NumberUtils;
|
import me.skymc.taboolib.other.NumberUtils;
|
||||||
|
import me.skymc.taboolib.player.PlayerUtils;
|
||||||
import me.skymc.taboolib.plugin.PluginUtils;
|
import me.skymc.taboolib.plugin.PluginUtils;
|
||||||
import me.skymc.taboolib.update.UpdateTask;
|
import me.skymc.taboolib.update.UpdateTask;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -807,6 +808,11 @@ public class TabooLibMainCommand extends BaseMainCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (PlayerUtils.getOnlinePlayers().size() > 0) {
|
||||||
|
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.UPDATEPLUGIN.PLAYER-ONLINE");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String url = Strings.replaceWithOrder("https://github.com/Bkm016/TabooLib/releases/download/{0}/TabooLib-{0}.jar", UpdateTask.getNewVersion());
|
String url = Strings.replaceWithOrder("https://github.com/Bkm016/TabooLib/releases/download/{0}/TabooLib-{0}.jar", UpdateTask.getNewVersion());
|
||||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.UPDATEPLUGIN.UPDATE-START", url);
|
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.UPDATEPLUGIN.UPDATE-START", url);
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ public class NBTCompound {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String asNBTString(){
|
public String asNBTString(){
|
||||||
return getCompound().toString();
|
return getCompound() == null ? "" : getCompound().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
package me.skymc.taboolib.player;
|
package me.skymc.taboolib.player;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,6 +17,30 @@ import java.util.HashSet;
|
|||||||
*/
|
*/
|
||||||
public class PlayerUtils {
|
public class PlayerUtils {
|
||||||
|
|
||||||
|
private static boolean setup;
|
||||||
|
private static boolean useReflection;
|
||||||
|
private static Method oldGetOnlinePlayersMethod;
|
||||||
|
|
||||||
|
public static Collection<? extends Player> getOnlinePlayers() {
|
||||||
|
try {
|
||||||
|
if (!setup) {
|
||||||
|
oldGetOnlinePlayersMethod = Bukkit.class.getDeclaredMethod("getOnlinePlayers");
|
||||||
|
if (oldGetOnlinePlayersMethod.getReturnType() == Player[].class) {
|
||||||
|
useReflection = true;
|
||||||
|
}
|
||||||
|
setup = true;
|
||||||
|
}
|
||||||
|
if (!useReflection) {
|
||||||
|
return Bukkit.getOnlinePlayers();
|
||||||
|
} else {
|
||||||
|
Player[] playersArray = (Player[]) oldGetOnlinePlayersMethod.invoke(null);
|
||||||
|
return ImmutableList.copyOf(playersArray);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取目标方块
|
* 获取目标方块
|
||||||
*
|
*
|
||||||
|
@ -239,6 +239,7 @@ COMMANDS:
|
|||||||
UPDATE-NOT-FOUND: '&8[&3&lTabooLib&8] &7插件已是最新版, 无需更新!'
|
UPDATE-NOT-FOUND: '&8[&3&lTabooLib&8] &7插件已是最新版, 无需更新!'
|
||||||
UPDATE-NOT-SUPPORT: '&8[&3&lTabooLib&8] &4您的服务器不支持在线更新!'
|
UPDATE-NOT-SUPPORT: '&8[&3&lTabooLib&8] &4您的服务器不支持在线更新!'
|
||||||
FILE-NOT-FOUND: '&8[&3&lTabooLib&8] &4尚未寻找到插件文件'
|
FILE-NOT-FOUND: '&8[&3&lTabooLib&8] &4尚未寻找到插件文件'
|
||||||
|
PLAYER-ONLINE: '&8[&3&lTabooLib&8] &4服务器有玩家在线无法更新插件.'
|
||||||
UPDATE-START: '&8[&3&lTabooLib&8] &7开始下载:&f {0}'
|
UPDATE-START: '&8[&3&lTabooLib&8] &7开始下载:&f {0}'
|
||||||
UPDATE-SUCCESS: '&8[&3&lTabooLib&8] &7最新版下载完成, 服务器即将重启!'
|
UPDATE-SUCCESS: '&8[&3&lTabooLib&8] &7最新版下载完成, 服务器即将重启!'
|
||||||
JAVASHELL:
|
JAVASHELL:
|
||||||
|
Loading…
Reference in New Issue
Block a user