Skip to content

Commit

Permalink
Update 2019-8-13 16:16
Browse files Browse the repository at this point in the history
  • Loading branch information
WinfXK committed Aug 13, 2019
1 parent 0e5af3b commit 5e6e2d7
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 29 deletions.
6 changes: 3 additions & 3 deletions Knickers/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Knickers
main: xiaokai.knickers.Knickers
api:
- 1.0.0
version: 2.1.01alpha
version: 2.1.1
load: POSTWORLD
website: http://EpicFX.cn
description: 多功能菜单,如传送、命令、提示等功能,并且支持多功能个人商店!并且支持自定义商品搜索等!后期还会加入更多功能哦!
website: http://Winfxk.EpicFX.cn
description: 多功能菜单,如传送、命令、提示等功能,并且支持自定义快捷菜单,将一个菜单装进物品内!后期还会加入更多功能哦!
author: Winfxk
loadbefore:
- EconomyAPI
Expand Down
6 changes: 5 additions & 1 deletion Knickers/resources/Config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@
定时检查快捷工具: true
自定义工具异步检查持有: true
OP命令延时撤销: 1000
折叠更多设置: true
折叠更多设置: true
快捷工具监听点击: true
快捷工具监听破坏: true
快捷工具监听快捷栏双击: true
快捷工具快捷栏双击间隔: 1000
13 changes: 8 additions & 5 deletions Knickers/src/xiaokai/knickers/Knickers.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
* @author Winfxk
*/
public class Knickers extends PluginBase {
private Instant loadTime;
private Instant loadTime = Instant.now();
private Instant EnableTime;
/**
* 插件缓存数据集合
*/
Expand All @@ -28,14 +29,16 @@ public class Knickers extends PluginBase {
*/
@Override
public void onEnable() {
loadTime = Instant.now();
EnableTime = Instant.now();
PluginManager pm = getServer().getPluginManager();
pm.registerEvents(new PlayerEvent(kick), this);
pm.registerEvents(new Monitor(kick), this);
this.getServer().getLogger()
.info(Tool.getColorFont(this.getName() + "启动!") + "§6耗时:§9"
+ ((float) (Duration.between(loadTime, Instant.now()).toMillis()) / 1000)
+ (Tool.getRand(1, 5) == 1 ? "\n" + Tool.getColorFont("本插件完全免费,如果你是给钱了的,那你就可能被坑啦~") : ""));
.info(Tool.getColorFont(this.getName() + "启动!") + "§6总耗时:§9"
+ ((float) (Duration.between(loadTime, Instant.now()).toMillis())) + "§6ms 启动耗时:§9"
+ ((float) (Duration.between(EnableTime, Instant.now()).toMillis())) + "§6ms");
if (Tool.getRand(1, 5) == 1)
getLogger().info(Tool.getColorFont("本插件完全免费,如果你是给钱了的,那你就可能被坑啦~"));
}

/**
Expand Down
52 changes: 43 additions & 9 deletions Knickers/src/xiaokai/knickers/event/PlayerEvent.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package xiaokai.knickers.event;

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

import cn.nukkit.Player;
import cn.nukkit.Server;
import cn.nukkit.event.EventHandler;
import cn.nukkit.event.Listener;
import cn.nukkit.event.block.BlockBreakEvent;
import cn.nukkit.event.inventory.InventoryMoveItemEvent;
import cn.nukkit.event.player.PlayerDropItemEvent;
import cn.nukkit.event.player.PlayerInteractEvent;
import cn.nukkit.event.player.PlayerInteractEvent.Action;
import cn.nukkit.event.player.PlayerItemHeldEvent;
import cn.nukkit.item.Item;
import cn.nukkit.event.player.PlayerQuitEvent;
import cn.nukkit.event.player.PlayerRespawnEvent;
Expand All @@ -29,13 +31,41 @@ public PlayerEvent(Kick kick) {
this.kick = kick;
}

//测试中..
public void onIMI(InventoryMoveItemEvent e) {
Server.getInstance().broadcastMessage("asdasd");
Item item = e.getItem();
if (e.getAction().equals(cn.nukkit.event.inventory.InventoryMoveItemEvent.Action.DROP)
&& Belle.isMaterials(item) && !kick.config.getBoolean("是否允许玩家将快捷工具装箱"))
e.setCancelled();
/**
* 玩家点击快捷物品栏物品事件事件
*
* @param e
*/
@EventHandler
public void onClicks(PlayerItemHeldEvent e) {
if (!kick.config.getBoolean("快捷工具监听快捷栏双击"))
return;
Player player = e.getPlayer();
MyPlayer myPlayer = Kick.kick.PlayerDataMap.get(player.getName());
Item item = player.getInventory().getItemInHand();
if (Belle.isMaterials(item)) {
if (myPlayer.ClickHeldTime == null || Duration.between(myPlayer.ClickHeldTime, Instant.now())
.toMillis() > kick.config.getInt("快捷工具快捷栏双击间隔")) {
myPlayer.ClickHeldTime = Instant.now();
kick.PlayerDataMap.put(player.getName(), myPlayer);
return;
}
MakeForm.Main(player);
if (kick.config.getBoolean("打开撤销"))
e.setCancelled();
return;
} else if (Appliance.isGirl(item)) {
if (myPlayer.ClickHeldTime == null || Duration.between(myPlayer.ClickHeldTime, Instant.now())
.toMillis() > kick.config.getInt("快捷工具快捷栏双击间隔")) {
myPlayer.ClickHeldTime = Instant.now();
kick.PlayerDataMap.put(player.getName(), myPlayer);
return;
}
kick.App.start(player, item);
if (kick.config.getBoolean("打开撤销"))
e.setCancelled();
return;
}
}

/**
Expand Down Expand Up @@ -70,6 +100,8 @@ public void onDropItem(PlayerDropItemEvent e) {
*/
@EventHandler
public void onBreak(BlockBreakEvent e) {
if (!kick.config.getBoolean("快捷工具监听破坏"))
return;
Player player = e.getPlayer();
Item item = e.getItem();
if (Belle.isMaterials(item)) {
Expand All @@ -90,6 +122,8 @@ public void onBreak(BlockBreakEvent e) {
*/
@EventHandler
public void onClick(PlayerInteractEvent e) {
if (!kick.config.getBoolean("快捷工具监听点击"))
return;
Player player = e.getPlayer();
Action ac = e.getAction();
Item item = e.getItem();
Expand Down
14 changes: 14 additions & 0 deletions Knickers/src/xiaokai/knickers/form/Dispose.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public boolean disMoreSettings(FormResponseSimple data) {
return AddButton.addButton(player, myPlayer.CacheFile);
case "del":
return DelButton.delButton(player, myPlayer.CacheFile);
case "set":
return MakeForm.Setting(player);
case "back":
default:
return MakeForm.OpenMenu(player, myPlayer.CacheFile, false, false);
Expand Down Expand Up @@ -143,6 +145,14 @@ public boolean Setting(FormResponseCustom data) {
boolean 自定义工具异步检查持有 = data.getToggleResponse(13);
int OP命令延时撤销 = Float.valueOf(data.getSliderResponse(14)).intValue();
boolean 折叠更多设置 = data.getToggleResponse(15);
boolean 快捷工具监听点击 = data.getToggleResponse(16);
boolean 快捷工具监听破坏 = data.getToggleResponse(17);
boolean 快捷工具监听快捷栏双击 = data.getToggleResponse(18);
String 快捷工具快捷栏双击间隔文字 = data.getInputResponse(19);
int 快捷工具快捷栏双击间隔 = 1000;
if (快捷工具快捷栏双击间隔文字 == null || 快捷工具快捷栏双击间隔文字.isEmpty() || !Tool.isInteger(快捷工具快捷栏双击间隔文字)
|| Float.valueOf(快捷工具快捷栏双击间隔文字).intValue() < 1)
return MakeForm.Tip(player, "§4快捷工具快捷栏双击间隔仅支持大于等于0的纯整数!");
config.set("快捷工具", id);
config.set("货币单位", MoneyName);
config.set("检测更新", isUpdate);
Expand All @@ -159,6 +169,10 @@ public boolean Setting(FormResponseCustom data) {
config.set("自定义工具异步检查持有", 自定义工具异步检查持有);
config.set("OP命令延时撤销", OP命令延时撤销);
config.set("折叠更多设置", 折叠更多设置);
config.set("快捷工具监听点击", 快捷工具监听点击);
config.set("快捷工具监听破坏", 快捷工具监听破坏);
config.set("快捷工具监听快捷栏双击", 快捷工具监听快捷栏双击);
config.set("快捷工具快捷栏双击间隔", 快捷工具快捷栏双击间隔);
kick.config = config;
kick.sThread.Update = Tool.ObjectToInt(config.get("检测更新间隔"), 500);
kick.sThread.time = Tool.ObjectToInt(config.get("定时检查快捷工具间隔"), 60);
Expand Down
4 changes: 4 additions & 0 deletions Knickers/src/xiaokai/knickers/form/MakeForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ protected static boolean Setting(Player player) {
form.addSlider("OP命令延时撤销\n\n这个值决定了命令型按钮在使用“玩家OP权限”执行命令后多久撤销玩家OP,建议值在500到1500之间", 50, 5000, 5,
Tool.ObjectToInt(config.get("OP命令延时撤销"), 1000));
form.addToggle("折叠更多设置", config.getBoolean("折叠更多设置"));
form.addToggle("快捷工具监听点击", config.getBoolean("快捷工具监听点击"));
form.addToggle("快捷工具监听破坏", config.getBoolean("快捷工具监听破坏"));
form.addToggle("快捷工具监听快捷栏双击", config.getBoolean("快捷工具监听快捷栏双击"));
form.addInput("快捷工具快捷栏双击间隔", config.get("快捷工具快捷栏双击间隔"));
form.sendPlayer(player);
return true;
}
Expand Down
10 changes: 5 additions & 5 deletions Knickers/src/xiaokai/knickers/form/man/AddButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ public boolean Teleport() {
form.addStepSlider("按钮的图标类型", new String[] { "无图标", "本地资源", "网络资源" });
form.addInput("请输入图标的路径", getHandItemID(player));
form.addStepSlider("过滤模式", Kick.FilteredModel);
form.addInput("黑名单列表,多个使用;分割", "");
form.addInput("黑/白 名单列表,多个使用;分割", "");
form.sendPlayer(player);
return true;
}
Expand Down Expand Up @@ -597,7 +597,7 @@ public boolean Transfer() {
form.addStepSlider("按钮的图标类型", new String[] { "无图标", "本地资源", "网络资源" });
form.addInput("请输入图标的路径", getHandItemID(player));
form.addStepSlider("过滤模式", Kick.FilteredModel);
form.addInput("黑名单列表,多个使用;分割", "");
form.addInput("黑/白 名单列表,多个使用;分割", "");
form.sendPlayer(player);
return true;
}
Expand All @@ -621,7 +621,7 @@ public boolean Command() {
form.addStepSlider("按钮的图标类型", new String[] { "无图标", "本地资源", "网络资源" });
form.addInput("请输入图标的路径", getHandItemID(player));
form.addStepSlider("过滤模式", Kick.FilteredModel);
form.addInput("黑名单列表,多个使用;分割", "");
form.addInput("黑/白 名单列表,多个使用;分割", "");
form.sendPlayer(player);
return true;
}
Expand All @@ -647,7 +647,7 @@ public boolean Open() {
form.addStepSlider("按钮的图标类型", new String[] { "无图标", "本地资源", "网络资源" });
form.addInput("请输入图标的路径", getHandItemID(player));
form.addStepSlider("过滤模式", Kick.FilteredModel);
form.addInput("黑名单列表,多个使用;分割", "");
form.addInput("黑/白 名单列表,多个使用;分割", "");
form.sendPlayer(player);
return true;
}
Expand All @@ -673,7 +673,7 @@ public boolean Tip() {
form.addStepSlider("按钮的图标类型", new String[] { "无图标", "本地资源", "网络资源" });
form.addInput("请输入图标的路径", getHandItemID(player));
form.addStepSlider("过滤模式", Kick.FilteredModel);
form.addInput("黑名单列表,多个使用;分割", "");
form.addInput("黑/白 名单列表,多个使用;分割", "");
form.sendPlayer(player);
return true;
}
Expand Down
10 changes: 5 additions & 5 deletions Knickers/src/xiaokai/knickers/form/man/AlterButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public boolean Teleport() {
Tool.ObjectToInt(map.get("IconType")));
form.addInput("请输入图标的路径", map.get("IconPath"));
form.addStepSlider("过滤模式", Kick.FilteredModel, Tool.ObjectToInt("FilteredModel"));
form.addInput("黑名单列表,多个使用;分割", ListToString(map.get("FilteredPlayer")));
form.addInput("黑/白 名单列表,多个使用;分割", ListToString(map.get("FilteredPlayer")));
form.sendPlayer(player);
return true;
}
Expand Down Expand Up @@ -163,7 +163,7 @@ public boolean Transfer() {
Tool.ObjectToInt(map.get("IconType")));
form.addInput("请输入图标的路径", map.get("IconPath"));
form.addStepSlider("过滤模式", Kick.FilteredModel, Tool.ObjectToInt("FilteredModel"));
form.addInput("黑名单列表,多个使用;分割", ListToString(map.get("FilteredPlayer")));
form.addInput("黑/白 名单列表,多个使用;分割", ListToString(map.get("FilteredPlayer")));
form.sendPlayer(player);
return true;
}
Expand Down Expand Up @@ -191,7 +191,7 @@ public boolean Command() {
Tool.ObjectToInt(map.get("IconType")));
form.addInput("请输入图标的路径", map.get("IconPath"));
form.addStepSlider("过滤模式", Kick.FilteredModel, Tool.ObjectToInt("FilteredModel"));
form.addInput("黑名单列表,多个使用;分割", ListToString(map.get("FilteredPlayer")));
form.addInput("黑/白 名单列表,多个使用;分割", ListToString(map.get("FilteredPlayer")));
form.sendPlayer(player);
return true;
}
Expand All @@ -218,7 +218,7 @@ public boolean Open() {
Tool.ObjectToInt(map.get("IconType")));
form.addInput("请输入图标的路径", map.get("IconPath"));
form.addStepSlider("过滤模式", Kick.FilteredModel, Tool.ObjectToInt("FilteredModel"));
form.addInput("黑名单列表,多个使用;分割", ListToString(map.get("FilteredPlayer")));
form.addInput("黑/白 名单列表,多个使用;分割", ListToString(map.get("FilteredPlayer")));
form.sendPlayer(player);
return true;
}
Expand All @@ -245,7 +245,7 @@ public boolean Tip() {
Tool.ObjectToInt(map.get("IconType")));
form.addInput("请输入图标的路径", map.get("IconPath"));
form.addStepSlider("过滤模式", Kick.FilteredModel, Tool.ObjectToInt("FilteredModel"));
form.addInput("黑名单列表,多个使用;分割", ListToString(map.get("FilteredPlayer")));
form.addInput("黑/白 名单列表,多个使用;分割", ListToString(map.get("FilteredPlayer")));
form.sendPlayer(player);
return true;
}
Expand Down
9 changes: 8 additions & 1 deletion Knickers/src/xiaokai/knickers/mtp/MyPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@
import cn.nukkit.Player;

public class MyPlayer {
/**
* 记录玩家点击时的事时间
*/
public Instant ClickHeldTime;
/**
* 记录玩家点击时的事时间
*/
public Instant loadTime;
public boolean isPlayerOnJoin = true;
/**
* 玩家对象
*/
Expand Down Expand Up @@ -83,6 +89,7 @@ public class MyPlayer {
* 是修改还是创建
*/
public boolean isAlter;

public MyPlayer(Player player) {
this.player = player;
}
Expand Down
Binary file added Knickers_v2.1.1.jar
Binary file not shown.

0 comments on commit 5e6e2d7

Please sign in to comment.