Skip to content

Commit

Permalink
Update 2021-9-9 23:20,Release 2.2.1 is released
Browse files Browse the repository at this point in the history
  • Loading branch information
WinfXK committed Sep 9, 2021
1 parent e039eb9 commit a0fb9c6
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Knickers/language/chs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ Form:
Update: 自动更新
CycleUpdate: 循环检测更新
UpdateTime: 循环检查更新间隔
PositionLock: 启用快捷工具位置锁定
Position: 快捷工具锁定位置
Succeed: 设置成功!
SelectButton:
Title: '{RGBTextStart}请选择想要创建的按钮类型{RGBTextEnd}'
Expand Down
2 changes: 2 additions & 0 deletions Knickers/language/eng.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ Form:
Update: auto update
CycleUpdate: Cyclic detection update
UpdateTime: Check the update interval periodically
PositionLock: Enable FastTool location lock
Position: FastTool lock position
Succeed: successfully set
SelectButton:
Title: '{RGBTextStart}Select the type of button you want to create{RGBTextEnd}'
Expand Down
2 changes: 1 addition & 1 deletion Knickers/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Knickers
main: cn.winfxk.knickers.Knickers
api:
- 1.0.0
version: 2.2-Beta
version: 2.2.1
website: http://Winfxk.cn
description: Interesting menu
author: Winfxk
Expand Down
6 changes: 5 additions & 1 deletion Knickers/resource/Config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ Update: true
#是否循环检测更新
CycleUpdate: true
#循环检查更新的间隔(单位: 秒)
UpdateTime: 604800
UpdateTime: 604800
#是否开启快捷工具背包位置锁定
PositionLock: false
#若开启了位置锁定,快捷工具会出现的位置
Position: 0
2 changes: 2 additions & 0 deletions Knickers/resource/Message.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ Form:
Update: 自动更新
CycleUpdate: 循环检测更新
UpdateTime: 循环检查更新间隔
PositionLock: 启用快捷工具位置锁定
Position: 快捷工具锁定位置
Succeed: 设置成功!
SelectButton:
Title: '{RGBTextStart}请选择想要创建的按钮类型{RGBTextEnd}'
Expand Down
64 changes: 64 additions & 0 deletions Knickers/src/cn/winfxk/knickers/Knickers.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import cn.nukkit.event.EventHandler;
import cn.nukkit.event.Listener;
import cn.nukkit.event.block.BlockBreakEvent;
import cn.nukkit.event.inventory.InventoryClickEvent;
import cn.nukkit.event.player.PlayerDropItemEvent;
import cn.nukkit.event.player.PlayerFormRespondedEvent;
import cn.nukkit.event.player.PlayerInteractEvent;
Expand All @@ -22,6 +23,7 @@
import cn.nukkit.form.response.FormResponseModal;
import cn.nukkit.form.response.FormResponseSimple;
import cn.nukkit.inventory.Inventory;
import cn.nukkit.inventory.PlayerInventory;
import cn.nukkit.item.Item;
import cn.nukkit.item.enchantment.Enchantment;
import cn.nukkit.nbt.tag.CompoundTag;
Expand Down Expand Up @@ -150,6 +152,68 @@ public void onEnable() {
getLogger().info(message.getMessage("插件启动", "{loadTime}", (float) Duration.between(loadTime, Instant.now()).toMillis() + "ms"));
}

@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
Player player = e.getPlayer();
Item item = e.getSourceItem();
if (player == null || item == null || item.getId() == 0)
return;
if (e.getInventory() != player.getInventory()) {
if (isFastTool(item)) {
e.setCancelled();
Inventory inv = e.getInventory();
for (Map.Entry<Integer, Item> entry : inv.getContents().entrySet())
if (isFastTool(entry.getValue()))
inv.setItem(entry.getKey(), Item.get(0));
PlayerInventory inventory = player.getInventory();
e.setCancelled();
int FastIndex = 0;
for (Map.Entry<Integer, Item> entry : inventory.getContents().entrySet())
if (isFastTool(entry.getValue())) {
FastIndex = entry.getKey();
inventory.setItem(entry.getKey(), Item.get(0));
}
inventory.addItem(inventory.getItem(FastIndex));
inventory.setItem(config.getInt("Position"), getFastTool());
}
return;
}
PlayerInventory inventory = player.getInventory();
if (config.getInt("Position") == e.getSlot() && isFastTool(item)) {
e.setCancelled();
for (Map.Entry<Integer, Item> entry : inventory.getContents().entrySet())
if (isFastTool(entry.getValue()) && entry.getKey() != e.getSlot())
inventory.setItem(entry.getKey(), Item.get(0));
return;
}
if (config.getInt("Position") == e.getSlot()) {
e.setCancelled();
int FastIndex = 0;
for (Map.Entry<Integer, Item> entry : inventory.getContents().entrySet())
if (isFastTool(entry.getValue())) {
FastIndex = entry.getKey();
inventory.setItem(entry.getKey(), Item.get(0));
}
inventory.addItem(inventory.getItem(FastIndex));
inventory.setItem(config.getInt("Position"), getFastTool());
return;
}
Item item2 = inventory.getItem(e.getSlot());
if (isFastTool(item2)) {
Item item3 = inventory.getItem(config.getInt("Position"));
e.setCancelled();
for (Map.Entry<Integer, Item> entry : inventory.getContents().entrySet())
if (isFastTool(entry.getValue()))
inventory.setItem(entry.getKey(), Item.get(0));
if (inventory.isFull())
player.getLevel().dropItem(player, item3);
else
inventory.addItem(item3);
inventory.setItem(config.getInt("Position"), getFastTool());
}
return;
}

@Override
public void onDisable() {
try {
Expand Down
6 changes: 6 additions & 0 deletions Knickers/src/cn/winfxk/knickers/form/admin/Setting.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public boolean MakeMain() {
form.addToggle(getString("Update"), config.getBoolean("Update"));
form.addToggle(getString("CycleUpdate"), config.getBoolean("CycleUpdate"));
form.addInput(getString("UpdateTime"), config.getInt("UpdateTime"), getString("UpdateTime"));
form.addToggle(getString("PositionLock"), config.getBoolean("PositionLock"));
form.addSlider(getString("Position"), 0, player.getInventory().getSize(), 1, config.getInt("Position"));
form.sendPlayer(player);
return true;
}
Expand Down Expand Up @@ -90,6 +92,8 @@ public boolean disMain(FormResponse data) {
int UpdateTime = Tool.ObjToInt(string);
if (string == null || string.isEmpty() || !Tool.isInteger(string) || UpdateTime < 0)
return Tip(getString("UpdateTimeError"));
boolean PositionLock = d.getToggleResponse(16);
int Position = Tool.ObjToInt(d.getSliderResponse(17));
config.set("MoneyName", MoneyName);
config.set("MoneyAPI", MoneyApi.getEconomyName());
config.set("DiscardTool", DiscardTool);
Expand All @@ -105,6 +109,8 @@ public boolean disMain(FormResponse data) {
config.set("Update", Update);
config.set("CycleUpdate", CycleUpdate);
config.set("UpdateTime", cn.winfxk.knickers.tool.Update.CycleTime = UpdateTime);
config.set("PositionLock", PositionLock);
config.set("Position", Position);
config.save();
sendMessage(getString("Succeed"));
return isBack();
Expand Down
8 changes: 4 additions & 4 deletions Knickers/src/cn/winfxk/knickers/module/add/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
*/
public class Menu extends BaseMake implements FileFilter {
private static final File MenuDir = new File(Knickers.kis.getDataFolder(), Knickers.Menus);
private List<File> MenuFiles;
private List<File> MenuFiles = new ArrayList<>();
private List<String> list = new ArrayList<>();
private Config c;
private List<String> list;

public Menu(Player player, File file, FormBase upForm, String Key) {
super(player, file, upForm, Key);
Expand All @@ -31,14 +31,14 @@ public Menu(Player player, File file, FormBase upForm, String Key) {

public Menu(Player player, File file, FormBase upForm) {
super(player, file, upForm);
MenuFiles = new ArrayList<>();
}

@Override
public boolean MakeMain() {
if (!super.MakeMain())
return false;
MenuFiles.clear();
(list = (list == null ? new ArrayList<>() : list)).clear();
(MenuFiles = (MenuFiles == null ? new ArrayList<>() : MenuFiles)).clear();
form.addInput(getString("InputTitle"), Key == null ? msg.config.get("Tip") : c.get("Title"), getString("InputTitle"));
form.addInput(getString("InputContent"), Key == null ? "" : c.get("Content"), getString("InputContent"));
form.addDropdown(getString("SelectMenuConfig"), getMenus(), list.indexOf(map.get("Config")));
Expand Down

0 comments on commit a0fb9c6

Please sign in to comment.