Skip to content

Commit

Permalink
Update 2019-7-26 18:41
Browse files Browse the repository at this point in the history
  • Loading branch information
WinfXK committed Jul 26, 2019
1 parent ac6aa80 commit 77b7bcb
Show file tree
Hide file tree
Showing 11 changed files with 263 additions and 54 deletions.
9 changes: 6 additions & 3 deletions Knickers/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Knickers
main: xiaokai.knickers.Knickers
api:
- 1.0.0
version: 1.0d
version: 1.1d
load: POSTWORLD
website: http://EpicFX.cn
description: 多功能菜单,如传送、命令、提示等功能,并且支持多功能个人商店!并且支持自定义商品搜索等!后期还会加入更多功能哦!
Expand All @@ -12,13 +12,16 @@ loadbefore:
commands:
mis:
description: §9菜单工具主命令
permission: MiniatureS.Command.main
permission: Knickers.Command.main
usage: §b/§6mis §chelp
aliases:
- miniature
- miniatures
- 菜单
- knickers
- 内裤
- 胖次
permissions:
MiniatureS.Command.main:
Knickers.Command.main:
description: 菜单工具主命令
default: true
6 changes: 5 additions & 1 deletion Knickers/resources/Config.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#配置开始==================
#每个玩家进服的时候都会给一个,当拿着这个玩意右键的时候打开菜单主页,特殊值可以不限定,当特殊值为x时默认匹配所有,特殊值默认为0,当这个值为空(null{在Yml文件内用~表示})时不适用快捷工具!
快捷工具: '347:0'
#当这个值为真时,撤销使用快捷工具打开的事件
打开撤销: true
货币单位: 金币
检测更新: true
检测更新间隔: 21600
#假如玩家在这个时间段内双击,将无法用快捷工具多次打开主页,防止刷屏
屏蔽玩家双击间隔: 500
仅允许白名单管理菜单: false
白名单: []
白名单: []
定时检查快捷工具间隔: 60
是否允许玩家丢弃快捷工具: false
5 changes: 5 additions & 0 deletions Knickers/resources/Message.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@
没有按钮时提示: §4这个页面还不存在按钮哦!快去找管理员添加一个吧~
权限不足: §4你无权限执行此操作!
金币不足: §4您的{MoneyName}不足!{n}{n}{n}{n}
撤销丢掉快捷工具的提示: §6{ItemName}§f(§9{{ItemID}}§f)§4是你的命根子!你不能丢掉你的命根子!
命令:
无法打开界面: §4无法打开此界面!{Error}
未输入想要打开的界面的配置文件名: 请输入想要打开的界面的配置文件名(支持只输入部分)
界面:
打开按钮失败: §4打开按钮失败:§6{Error}
取消按钮: '{RandColor}取消'
返回上级: '{RandColor}返回上级'
执行命令:
标题: §6提示
打开失败: §4无法执行该命令!{Error}
Tpa界面:
传送请求被拒绝: §6亲爱的§9{TpaPlayer}§6您好, 您的请求已被§8{Player}{Msg}!
发请求的标题: §6提示
Expand Down
97 changes: 91 additions & 6 deletions Knickers/src/xiaokai/knickers/Knickers.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package xiaokai.knickers;

import java.io.File;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;

import cn.nukkit.Player;
import cn.nukkit.command.Command;
Expand All @@ -19,6 +22,7 @@
/**
* @author Winfxk
*/
@SuppressWarnings("unchecked")
public class Knickers extends PluginBase {
private Instant loadTime = Instant.now();
/**
Expand All @@ -28,13 +32,94 @@ public class Knickers extends PluginBase {

@Override
public boolean onCommand(CommandSender player, Command command, String label, String[] args) {
new Thread() {
public void run() {
Belle.exMaterials((Player) player);
if (player.isPlayer()) {
new Thread() {
public void run() {
Belle.exMaterials((Player) player);
}
}.start();
if (args.length < 1)
return MakeForm.Main((Player) player);
} else if (args.length < 1)
return false;
switch (args[0]) {
case "help":
case "h":
case "帮助":
player.sendMessage(
"§4=====§6=====§a=====§e=====§f[§9命令帮助§f]§e=====§a=====§6=====§4=====\n§f/§bmis §dhelp §c:§9打开命令帮助\n§f/§bmis §dadmin §2<§3玩家名§2> §c:§9添加或删除管理员权限\n§f/§bmis §dshow §2<§3文件名§2> §c:§9打开一个界面[文件名支持只写部分]\n§f/§bmis §dui §c:§9打开主页面\n§f/§bmis §c:§9打开主页并且检查是否拥有快捷工具");
return true;
case "admin":
case "a":
case "管理":
if (!Kick.isAdmin(player)) {
player.sendMessage(kick.Message.getMessage("权限不足"));
return true;
}
}.start();
MakeForm.Main((Player) player);
return true;
if (args.length < 2 || args[1] == null || args[1].isEmpty()) {
player.sendMessage("§4请输入想要添加或删除管理员的玩家名称!");
return true;
}
List<Object> list = kick.config.getList("白名单") == null ? new ArrayList<Object>()
: kick.config.getList("白名单");
if (list.contains(args[1])) {
for (int i = 0; i < list.size(); i++)
if (list.get(i).equals(args[1]))
list.remove(i);
} else
list.add(args[1]);
kick.config.set("白名单", list);
if (kick.config.save())
player.sendMessage("§6您已" + (list.contains(args[1]) ? "§e添加§9" : "§4删除§9") + args[1] + "§6的管理员权限");
else
player.sendMessage("§4设置异常!");
return true;
case "show":
case "打开":
case "open":
if (!player.isPlayer()) {
player.sendMessage("§4请在游戏内执行此命令!");
return true;
}
if (args.length < 2 || args[1] == null || args[1].isEmpty()) {
player.sendMessage(kick.Message.getSon("命令", "未输入想要打开的界面的配置文件名", new String[] { "{Player}" },
new String[] { player.getName() }));
return true;
}
String ConfigName = args[1];
File dFile = new File(getDataFolder(), Kick.MenuConfigPath);
File file = new File(dFile, ConfigName);
boolean isOK = false;
if (!file.exists()) {
String ConfigNames = (ConfigName.lastIndexOf("yml") == ConfigName.length() - 3) ? ConfigName
: ConfigName + ".yml";
file = new File(dFile, ConfigNames);
if (!file.exists()) {
for (String FileN : dFile.list()) {
file = new File(dFile, FileN);
if (file.isFile() && FileN.contains(ConfigName)) {
isOK = true;
break;
}
}
} else
isOK = file.isFile();
} else
isOK = file.isFile();
if (isOK)
return MakeForm.OpenMenu((Player) player, file);
else
player.sendMessage(kick.Message.getSon("命令", "无法打开界面", new String[] { "{Error}", "{Player}" },
new Object[] { "找不到该界面", player.getName() }));
return true;
case "ui":
if (!player.isPlayer()) {
player.sendMessage("§4请在游戏内执行此命令!");
return true;
}
return MakeForm.Main((Player) player);
}
return false;
}

/**
Expand Down
50 changes: 43 additions & 7 deletions Knickers/src/xiaokai/knickers/event/PlayerEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
import cn.nukkit.Player;
import cn.nukkit.event.EventHandler;
import cn.nukkit.event.Listener;
import cn.nukkit.event.block.BlockBreakEvent;
import cn.nukkit.event.player.PlayerDropItemEvent;
import cn.nukkit.event.player.PlayerInteractEvent;
import cn.nukkit.event.player.PlayerInteractEvent.Action;
import cn.nukkit.item.Item;
import cn.nukkit.event.player.PlayerQuitEvent;
import cn.nukkit.event.player.PlayerRespawnEvent;
import xiaokai.knickers.form.MakeForm;
import xiaokai.knickers.mtp.Belle;
import xiaokai.knickers.mtp.Kick;
import xiaokai.knickers.mtp.MyPlayer;
import xiaokai.tool.ItemIDSunName;

/**
* @author Winfxk
Expand All @@ -21,17 +25,49 @@ public class PlayerEvent implements Listener {
public PlayerEvent(Kick kick) {
this.kick = kick;
}
/**
* 玩家脑残了点击东西
* @param e
*/

@EventHandler
public void onSB(PlayerDropItemEvent e) {
Item item = e.getItem();
if (kick.config.getBoolean("是否允许玩家丢弃快捷工具") || !Belle.isMaterials(item))
return;
e.setCancelled();
Player player = e.getPlayer();
player.sendMessage(kick.Message.getMessage("撤销丢掉快捷工具的提示", new String[] { "{Player}", "{ItemName}", "{ItemID}" },
new Object[] { player.getName(), ItemIDSunName.getIDByName(item.getId(), item.getDamage()),
item.getId() + ":" + item.getDamage() }));
}

/**
* 玩家脑残了砸碎点击东西
*
* @param e
*/
@EventHandler
public void onBreak(BlockBreakEvent e) {
Player player = e.getPlayer();
if (Belle.isMaterials(e.getItem())) {
MakeForm.Main(player);
if (kick.config.getBoolean("打开撤销"))
e.setCancelled();
}
}

/**
* 玩家脑残了点击东西
*
* @param e
*/
@EventHandler
public void onClick(PlayerInteractEvent e) {
Player player = e.getPlayer();
if ((e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK
|| e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK)
&& Belle.isMaterials(e.getItem()))
Action ac = e.getAction();
if ((ac == Action.LEFT_CLICK_AIR || ac == Action.LEFT_CLICK_BLOCK || ac == Action.RIGHT_CLICK_AIR
|| ac == Action.RIGHT_CLICK_BLOCK) && Belle.isMaterials(e.getItem())) {
MakeForm.Main(player);
if (kick.config.getBoolean("打开撤销"))
e.setCancelled();
}
}

/**
Expand Down
43 changes: 32 additions & 11 deletions Knickers/src/xiaokai/knickers/form/Dispose.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,36 @@ public boolean Setting(FormResponseCustom data) {
boolean isWh = data.getToggleResponse(5);
List<String> list = new ArrayList<String>();
String wsString = data.getInputResponse(6);
if (wsString.contains(";")) {
String[] Ws = wsString.split(";");
for (int i = 0; i < Ws.length; i++)
if (Ws[i] != null && !Ws[i].isEmpty())
list.add(Ws[i]);
} else
list = Arrays.asList(wsString);
if (wsString != null && !wsString.isEmpty())
if (wsString.contains(";")) {
String[] Ws = wsString.split(";");
for (int i = 0; i < Ws.length; i++)
if (Ws[i] != null && !Ws[i].isEmpty())
list.add(Ws[i]);
} else
list = Arrays.asList(wsString);
boolean isC = data.getToggleResponse(7);
String sovString = data.getInputResponse(8);
if (sovString == null || sovString.isEmpty())
return MakeForm.Tip(player, "§4请输入自动检查快捷工具的间隔");
int SovTime = 0;
if (!Tool.isInteger(sovString) || (SovTime = Float.valueOf(sovString).intValue()) < 1)
return MakeForm.Tip(player, "§4自动检查快捷工具的间隔仅支持大于等于0的纯整数!");
Config config = kick.config;
boolean isD = data.getToggleResponse(9);
config.set("快捷工具", id);
config.set("货币单位", MoneyName);
config.set("检测更新", isUpdate);
config.set("检测更新间隔", UpdateTime);
config.set("屏蔽玩家双击间隔", ClickTime);
config.set("仅允许白名单管理菜单", isWh);
config.set("白名单", list);
config.set("打开撤销", isC);
config.set("定时检查快捷工具间隔", SovTime);
config.set("是否允许玩家丢弃快捷工具", isD);
kick.config = config;
if (config.save())
return MakeForm.Tip(player, "§6数据保存正常!");
if (kick.config.save())
return MakeForm.Tip(player, "§6数据保存正常!\n\n§a各类时间间隔将在检查一次后生效");
else
return MakeForm.Tip(player, "§4数据保存可能出现问题!");
}
Expand All @@ -99,11 +111,20 @@ public boolean start(FormResponseSimple data) {
int ID = data.getClickedButtonId();
if (ID >= myPlayer.Items.size())
if (ID == myPlayer.Items.size()) {
if (myPlayer.OpenMenuList == null || myPlayer.OpenMenuList.size() < 1)
if (myPlayer.OpenMenuList == null || myPlayer.OpenMenuList.size() < 1
|| (new File(kick.mis.getDataFolder(), kick.MainFileName).getAbsolutePath()
.equals(myPlayer.BackFile.getAbsolutePath()))
|| (myPlayer.OpenMenuList.size() >= 2 && myPlayer.BackFile.getAbsolutePath()
.equals(myPlayer.OpenMenuList.get(myPlayer.OpenMenuList.size() - 2).getAbsolutePath())))
return true;
if (myPlayer.OpenMenuList.size() > 1) {
myPlayer.OpenMenuList.remove(myPlayer.OpenMenuList.size() - 1);
File file = myPlayer.OpenMenuList.get(myPlayer.OpenMenuList.size() - 1);
myPlayer.OpenMenuList.remove(myPlayer.OpenMenuList.size() - 1);
while (file.getAbsolutePath().equals(myPlayer.BackFile.getAbsolutePath())
&& myPlayer.OpenMenuList.size() > 0) {
file = myPlayer.OpenMenuList.get(myPlayer.OpenMenuList.size() - 1);
myPlayer.OpenMenuList.remove(myPlayer.OpenMenuList.size() - 1);
}
kick.PlayerDataMap.put(player.getName(), myPlayer);
return MakeForm.OpenMenu(player, file, false, false);
} else if (!myPlayer.isMain)
Expand Down
Loading

0 comments on commit 77b7bcb

Please sign in to comment.