Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
WinfXK committed Nov 25, 2019
1 parent c40486c commit afc91d2
Show file tree
Hide file tree
Showing 11 changed files with 2,374 additions and 2,691 deletions.
18 changes: 1 addition & 17 deletions Knickers/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,13 @@ name: Knickers
main: xiaokai.knickers.Knickers
api:
- 1.0.0
version: 2.1.4
version: 2.1.5
load: POSTWORLD
website: http://Winfxk.EpicFX.cn
description: 多功能菜单,如传送、命令、提示等功能,并且支持自定义快捷菜单,将一个菜单装进物品内!后期还会加入更多功能哦!
author: Winfxk
loadbefore:
- EconomyAPI
commands:
tool:
description: §9菜单快捷工具主命令
permission: Knickers.Command.Tool
usage: §b/§6mis §chelp
mis:
description: §9菜单工具主命令
permission: Knickers.Command.main
usage: §b/§6mis §chelp
aliases:
- miniature
- miniatures
- 菜单
- knickers
- 内裤
- 胖次
permissions:
Knickers.Command.main:
description: 菜单工具主命令
Expand Down
24 changes: 9 additions & 15 deletions Knickers/src/xiaokai/knickers/Knickers.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package xiaokai.knickers;

import xiaokai.knickers.event.Monitor;
import xiaokai.knickers.event.PlayerEvent;
import xiaokai.knickers.mtp.Kick;
import xiaokai.knickers.tool.Tool;

import java.time.Duration;
import java.time.Instant;

import cn.nukkit.command.Command;
import cn.nukkit.command.CommandSender;
import cn.nukkit.plugin.PluginBase;
import cn.nukkit.plugin.PluginManager;
import cn.nukkit.utils.TextFormat;
import xiaokai.knickers.event.Monitor;
import xiaokai.knickers.event.PlayerEvent;
import xiaokai.knickers.mtp.Kick;
import xiaokai.knickers.tool.Tool;

/**
* @author Winfxk
Expand All @@ -29,9 +27,10 @@ public class Knickers extends PluginBase {
@Override
public void onEnable() {
Instant EnableTime = Instant.now();
PluginManager pm = getServer().getPluginManager();
pm.registerEvents(new PlayerEvent(kick), this);
pm.registerEvents(new Monitor(kick), this);
getServer().getPluginManager().registerEvents(new PlayerEvent(kick), this);
getServer().getPluginManager().registerEvents(new Monitor(kick), this);
getServer().getCommandMap().register(getName(), new ToolCommand());
getServer().getCommandMap().register(getName(), new toCommand());
this.getServer().getLogger()
.info(Tool.getColorFont(this.getName() + "启动!") + "§6总耗时:§9"
+ ((float) (Duration.between(loadTime, Instant.now()).toMillis())) + "§6ms 启动耗时:§9"
Expand Down Expand Up @@ -80,9 +79,4 @@ public static Kick getKick() {
public static Knickers getPY() {
return kick.mis;
}

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return kick.command.onCommand(sender, command, label, args);
}
}
37 changes: 37 additions & 0 deletions Knickers/src/xiaokai/knickers/ToolCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package xiaokai.knickers;

import xiaokai.knickers.appliance.EstablishForm;
import xiaokai.knickers.mtp.Kick;

import cn.nukkit.Player;
import cn.nukkit.command.Command;
import cn.nukkit.command.CommandSender;

/**
* @author Winfxk
*/
public class ToolCommand extends Command {
private final String Permission = "Knickers.Command.Tool";

public ToolCommand() {
super("tool", "§9打开菜单快捷工具主界面", "§b/§6mis §chelp");
this.commandParameters.clear();
this.setPermission(Permission);
}

@Override
public boolean execute(CommandSender player, String commandLabel, String[] args) {
if (!Kick.kick.mis.isEnabled())
return false;
if (!player.hasPermission(Permission)) {
player.sendMessage(Kick.kick.Message.getMessage("权限不足"));
return true;
}
if (!player.isPlayer()) {
player.sendMessage("§4请在游戏内执行此命令!");
return true;
} else
return EstablishForm.Main((Player) player);
}

}
9 changes: 8 additions & 1 deletion Knickers/src/xiaokai/knickers/event/Monitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import xiaokai.knickers.form.man.DelButton;
import xiaokai.knickers.mtp.FormID;
import xiaokai.knickers.mtp.Kick;
import xiaokai.knickers.mtp.MyPlayer;

import cn.nukkit.Player;
import cn.nukkit.event.EventHandler;
Expand Down Expand Up @@ -44,8 +45,14 @@ public void onPlayerForm(PlayerFormRespondedEvent e) {
if (player == null || e.wasClosed() || e.getResponse() == null
|| (!(e.getResponse() instanceof FormResponseCustom)
&& !(e.getResponse() instanceof FormResponseSimple)
&& !(e.getResponse() instanceof FormResponseModal)))
&& !(e.getResponse() instanceof FormResponseModal))) {
if (player != null && e.wasClosed() && fId.isMyFormID(ID)) {
MyPlayer myPlayer = kick.PlayerDataMap.get(player.getName());
myPlayer.OpenMenuList = null;
kick.PlayerDataMap.put(player.getName(), myPlayer);
}
return;
}
if (ID == fId.getID(0) || ID == fId.getID(8) || ID == fId.getID(10) || ID == fId.getID(11)
|| ID == fId.getID(12) || ID == fId.getID(13))
(new Dispose(kick, player)).start((FormResponseSimple) data);
Expand Down
9 changes: 6 additions & 3 deletions Knickers/src/xiaokai/knickers/form/MakeForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,11 @@ public static boolean OpenMenu(Player player, File file, boolean isBack, boolean
msg.getSon("界面", "被列入黑名单", new String[] { "{Player}" }, new String[] { player.getName() }));
}
MyPlayer myPlayer = kick.PlayerDataMap.get(player.getName());
if (isBack)
if (isBack) {
if (myPlayer.OpenMenuList == null)
myPlayer.OpenMenuList = new ArrayList<>();
myPlayer.OpenMenuList.add(file);
}
List<Map<String, Object>> Items = new ArrayList<>();
int ID = isMain ? kick.formID.getID(0) : getID(myPlayer);
SimpleForm form = new SimpleForm(ID,
Expand Down Expand Up @@ -216,8 +219,8 @@ public static boolean OpenMenu(Player player, File file, boolean isBack, boolean
if (myPlayer.OpenMenuList == null || myPlayer.OpenMenuList.size() < 1
|| file.getAbsolutePath()
.equals(new File(kick.mis.getDataFolder(), kick.MainFileName).getAbsolutePath())
|| (myPlayer.BackFile != null
&& file.getAbsolutePath().equals(myPlayer.BackFile.getAbsolutePath()))) {
|| (myPlayer.BackFile != null && file.getAbsolutePath().equals(myPlayer.BackFile.getAbsolutePath()))
|| (myPlayer.OpenMenuList.size() == 1 && myPlayer.OpenMenuList.get(0).equals(file))) {
form.addButton(
msg.getSon("界面", "取消按钮", new String[] { "{Player}" }, new Object[] { player.getName() }));
kis.add("quit");
Expand Down
24 changes: 5 additions & 19 deletions Knickers/src/xiaokai/knickers/form/OpenButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,7 @@ public boolean make(String Key, Config config, Map<String, Object> Item) {
new Object[] { player.getName() }) }),
kick.Message.getSun("界面", "Tpa界面", "玩家列表内容", new String[] { "{Player}" },
new Object[] { player.getName() }));
for (UUID uuid : Players.keySet()) {
Player player2 = Players.get(uuid);
for (Player player2 : Players.values()) {
if (player2.getName().equals(player.getName()))
continue;
Plist.add(player2);
Expand Down Expand Up @@ -503,7 +502,6 @@ && delMoney(player, Item)) {
Command = Kick.kick.Message.getText(Command, new String[] { "{Player}" },
new Object[] { player.getName() });
Command = (Command.lastIndexOf("}") == Command.length() - 1) ? Command + " " : Command;
System.out.println(Command);
if (Command.contains("{msg}")) {
return make(Command, Commander, Item);
} else
Expand All @@ -522,31 +520,19 @@ && delMoney(player, Item)) {
* @return
*/
private static boolean carryCommand(Player player, String Command, String Commander) {
boolean isOP = player.isOp();
boolean cmdr = Commander.toLowerCase().equals("playerbyop");
boolean isOP = player.isOp(), cmdr = Commander.toLowerCase().equals("playerbyop"), cmd = false;
if (cmdr && !isOP)
player.setOp(true);
boolean cmd = false;
try {
cmd = Server.getInstance().dispatchCommand(
(Commander.toLowerCase().equals("player") || cmdr) ? player : new ConsoleCommandSender(),
Command);
} catch (Exception e) {
Kick.kick.mis.getLogger().error("§4执行命令出现错误!" + e.getMessage());
} finally {
if (cmdr && !isOP)
player.setOp(false);
}
if (cmdr && !isOP)
new Thread() {
@Override
public void run() {
try {
sleep(Tool.ObjectToInt(Kick.kick.config.get("OP命令延时撤销"), 1000));
} catch (InterruptedException e) {
Kick.kick.mis.getLogger().error("§4警告!OP命令执行出现问题!Op撤销可能已经失败!请检查OP列表!玩家名:§e"
+ player.getName() + "\nError: \n " + e.getMessage());
}
player.setOp(false);
}
}.start();
return cmd;
}
}
Expand Down
6 changes: 5 additions & 1 deletion Knickers/src/xiaokai/knickers/mtp/FormID.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
* @author Winfxk
*/
*/
public class FormID {
private Map<String, Integer> config;
private Kick kick;
Expand All @@ -25,6 +25,10 @@ public int getID(int Key) {
return getID(kick.FormIDName[Key]);
}

public boolean isMyFormID(int ID) {
return config.containsValue(ID);
}

public void setConfig(Map<String, Object> config) {
for (String key : config.keySet())
this.config.put(key,
Expand Down
29 changes: 15 additions & 14 deletions Knickers/src/xiaokai/knickers/mtp/Kick.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/**
* @author Winfxk
*/
*/
@SuppressWarnings("unchecked")
public class Kick {
public static Kick kick;
Expand Down Expand Up @@ -137,7 +137,6 @@ public Kick(Knickers knickers) {
formID.setConfig(formIdConfig.getAll());
Message = new Message(this);
App = new Appliance(this);
command = new toCommand(this);
sThread = new startThread();
sThread.start();
}
Expand Down Expand Up @@ -167,6 +166,11 @@ public startThread() {

@Override
public void run() {
Map<UUID, Player> Players;
Map<String, Object> item, map;
String ID;
Object obj;
Item Item;
while (true) {
try {
sleep(1000);
Expand All @@ -175,31 +179,28 @@ public void run() {
Update = Tool.ObjectToInt(config.get("检测更新间隔"), 500);
}
if (time-- < 0 && config.getBoolean("定时检查快捷工具")) {
Map<UUID, Player> Players = Server.getInstance().getOnlinePlayers();
for (UUID u : Players.keySet()) {
Player player = Players.get(u);
Players = Server.getInstance().getOnlinePlayers();
for (Player player : Players.values())
if (player.isOnline())
Belle.exMaterials(player);
}
time = Tool.ObjectToInt(config.get("定时检查快捷工具间隔"), 60);
}
if (config.getBoolean("自定义工具异步检查持有") && UpdateAutoTool-- < 0) {
Map<UUID, Player> Players = Server.getInstance().getOnlinePlayers();
for (UUID u : Players.keySet()) {
Player player = Players.get(u);
Players = Server.getInstance().getOnlinePlayers();
for (Player player : Players.values()) {
if (player.isOnline() && !player.getInventory().isFull()) {
Map<String, Object> map = Appliance.config.getAll();
map = Appliance.config.getAll();
for (String ike : map.keySet()) {
Map<String, Object> item = (Map<String, Object>) map.get(ike);
item = (Map<String, Object>) map.get(ike);
if (Tool.ObjToBool(item.get("isThread"), true)
&& !Appliance.isAlready(player, ike)) {
Object obj = item.get("ID");
obj = item.get("ID");
if (obj != null) {
String ID = String.valueOf(obj);
ID = String.valueOf(obj);
if (!ID.isEmpty()) {
int[] IDs = Tool.IDtoFullID(ID);
if (IDs[0] != 0) {
Item Item = new Item(IDs[0], IDs[1]);
Item = new Item(IDs[0], IDs[1]);
Item = Appliance.setData(Item, item);
player.getInventory().addItem(Item);
player.sendMessage(kick.Message.getSun("界面", "快捷工具列表页",
Expand Down
Loading

0 comments on commit afc91d2

Please sign in to comment.