仅管理员在线时可以召唤指令之剑,召唤时如果背包内空间不足,则丢在地上
This commit is contained in:
@@ -32,7 +32,9 @@ import org.jooq.impl.DSL;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import static ling.database.tables.LocationnotepadTB.LOCATIONNOTEPAD;
|
import static ling.database.tables.LocationnotepadTB.LOCATIONNOTEPAD;
|
||||||
import static ling.database.tables.PlayersettingsTB.PLAYERSETTINGS;
|
import static ling.database.tables.PlayersettingsTB.PLAYERSETTINGS;
|
||||||
@@ -446,6 +448,16 @@ public class ZbCommand implements CommandExecutor, TabCompleter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AtomicBoolean isAdmin = new AtomicBoolean(false);
|
||||||
|
PlayerMap.getCurrent().traversePlayer(p -> {
|
||||||
|
if (p.getPlayer().isOp())
|
||||||
|
isAdmin.set(true);
|
||||||
|
});
|
||||||
|
if (!isAdmin.get()) {
|
||||||
|
player.sendMessage("没有任何管理员用户在线,无法召唤指令之剑");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
data.addFraction(30);
|
data.addFraction(30);
|
||||||
PlayerMap.getCurrent().broadcastScore(data);
|
PlayerMap.getCurrent().broadcastScore(data);
|
||||||
@@ -474,7 +486,12 @@ public class ZbCommand implements CommandExecutor, TabCompleter {
|
|||||||
cheat.save(per);
|
cheat.save(per);
|
||||||
|
|
||||||
sword.setItemMeta(meta);
|
sword.setItemMeta(meta);
|
||||||
player.getInventory().addItem(sword);
|
HashMap<Integer, ItemStack> map = player.getInventory().addItem(sword);
|
||||||
|
//如果玩家背包没有足够的容量容纳物品,则丢弃在玩家附近
|
||||||
|
Location dropLocation = player.getLocation().add(0, 1, 0);
|
||||||
|
for (ItemStack item : map.values()) {
|
||||||
|
player.getWorld().dropItem(dropLocation, item);
|
||||||
|
}
|
||||||
|
|
||||||
BaseComponent message = new TextComponent("玩家 " + player.getName() + " 召唤了");
|
BaseComponent message = new TextComponent("玩家 " + player.getName() + " 召唤了");
|
||||||
message.addExtra(CoordinateRecorder.getItemShowService().addItem(sword));
|
message.addExtra(CoordinateRecorder.getItemShowService().addItem(sword));
|
||||||
|
|||||||
Reference in New Issue
Block a user