Skip to content

Commit

Permalink
Update 2022-05-02 16:35
Browse files Browse the repository at this point in the history
  • Loading branch information
WinfXK committed May 2, 2022
1 parent d6a7787 commit bb1e35b
Show file tree
Hide file tree
Showing 21 changed files with 565 additions and 38 deletions.
Binary file modified WinfxkLib.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions Winfxklib/.idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Winfxklib/Winfxklib.iml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,14 @@
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
<orderEntry type="library" name="EconomyAPI" level="project" />
<orderEntry type="library" name="PowerNukkit" level="project" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/20.1.0/annotations-20.1.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
Empty file added Winfxklib/logs/server.log
Empty file.
10 changes: 8 additions & 2 deletions Winfxklib/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: WinfxkLib
main: cn.winfxk.nukkit.winfxklib.WinfxkLib
api:
- 1.0.0
version: 1.1
version: 1.2
load: STARTUP
website: http://Winfxk.cn
author: Winfxk
Expand All @@ -12,4 +12,10 @@ permissions:
default: op
WinfxkLib.Form.Item:
description: 修改物品数据
default: op
default: op
WinfxkLib.Command.Player:
description: 玩家命令
default: true
WinfxkLib.use.LeaveWord:
description: 留言面板权限
default: true
6 changes: 5 additions & 1 deletion Winfxklib/res/Command.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
AdminCommand:
- wlib
- awlib
- awl
PlayerCommand:
- wlib
- wl
6 changes: 5 additions & 1 deletion Winfxklib/res/Config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ EconomyAPI-MoneyName: 金币
EasyEconomy:
Name: 狗屎
ID: EasyEconomy
物品列表页最大数量: 30
物品列表页最大数量: 30
#每日留言限制
LeaveWordAstrict: 10
#如果玩家配置文件不存在,是否允许留言
UnrealLeaveWord: true
33 changes: 32 additions & 1 deletion Winfxklib/res/Message.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,40 @@ Command:
AdminCommand:
无权执行: 你没有权限执行此命令!
Description: 管理员命令
usageMessage: /WinfxkLib help
usageMessage: /AdminWinfxkLib help
Help: 插件帮助
Add: 添加数据
PlayerCommand:
无权执行: 你没有权限执行此命令!
Description: '{PluginName}命令'
usageMessage: /WinfxkLib help
Help: 插件帮助
LeaveWord: 查看留言板
LeaveWord:
JoinServer: '{RandColor}欢迎来到{ServerName}{RandColor},您当前有{LeaveWordCount}条未读留言,使用“/WinfxkLib LeaveWord”可以查看您的留言。'
Unread:
Title: "{RandColor}未读留言"
Content: " "
NotLeaveWord: §4当前你还没有留言哦!
Item: '{RandColor}{LeaveWordTitle} {LeaveWordDate}{n}{Streamline}'
ClearMessage: "{RandColor}清空留言"
ClearMessageSucceed: §4成功清空了所有的留言
Attachment: §4这个留言包含附件,请注意背包预留空间,否则可能会领取失败。
Accept: '{RandColor}已读留言'
AcceptAndDelete: §7已读并删除
Delete: §4删除留言
DeleteSucceed: §4删除成功!
Exception: §4出现异常!请联系管理员{n}{Error}
Main:
Title: "{RandColor}留言系统"
Content: " "
NotLeaveWord: §4当前你还没有留言哦!
Unread: "{RandColor}未读留言({LeaveWordCount})"
MarkRead: "{RandColor}已读留言({LeaveWordCount})"
AddLeaveWord: "{RandColor}添加留言({LeaveWordCount}/{LeaveWordAstrict})"
ClearMessage: "{RandColor}清空留言"
ClearMessageSucceed: §4成功清空了所有的留言
Sure: §4确定要删除所有留言吗?
Form:
Back: '{RandColor}返回'
Exit: '{RandColor}关闭'
Expand Down
55 changes: 44 additions & 11 deletions Winfxklib/src/cn/winfxk/nukkit/winfxklib/Check.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,34 @@ public class Check {
private final MyBase kis;
private int index = 0;
public static Check check;
private String[] Meta, Mkdir;
/**
* 会与预留文件做参数匹配是否一致
*/
private String[] Meta;
/**
* 想要存在的文件夹
*/
private String[] Mkdir;
/**
* 只需判断文件是否存在,如果不存在写入一份默认文件不进行参数检查
*/
private String[] Load;
private File ConfigDir;

public Check(MyBase kis, String[] Meta, String[] Mkdir, String[] Load) {
this.kis = kis;
check = this;
this.Meta = Meta;
this.Mkdir = Mkdir;
this.Load = Load;
}

public Check(MyBase kis, String[] Meta, String[] Mkdir) {
this.kis = kis;
check = this;
this.Meta = Meta;
this.Mkdir = Mkdir;
Load = null;
}

/**
Expand Down Expand Up @@ -122,17 +142,30 @@ public int start() {
Message();
Config config;
Map<String, Object> map;
for (String string : Meta) {
config = new Config(new File(kis.getConfigDir(), string));
try {
map = Matc(Config.yaml.loadAs(Tool.getResource(string), Map.class), config.getMap());
config.setAll(map);
config.save();
} catch (Exception e) {
kis.getLogger().error("Unable to obtain resource: " + string);
continue;
if (Meta != null)
for (String string : Meta) {
config = new Config(new File(kis.getConfigDir(), string));
try {
map = Matc(Config.yaml.loadAs(kis.getClass().getResourceAsStream("/res/" + string), Map.class), config.getMap());
config.setAll(map);
config.save();
} catch (Exception e) {
kis.getLogger().error("Unable to obtain resource: " + string);
continue;
}
}
if (Load != null)
for (String s : Load) {
file = new File(kis.getConfigDir(), s);
if (!file.exists()) {
try {
Utils.writeFile(file, Utils.readFile(kis.getClass().getResourceAsStream("/res/" + s)));
} catch (Exception e) {
kis.getLogger().error("Unable to obtain resource: " + s);
e.printStackTrace();
}
}
}
}
return index;
}

Expand Down
23 changes: 22 additions & 1 deletion Winfxklib/src/cn/winfxk/nukkit/winfxklib/WinfxkLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
import cn.nukkit.event.player.PlayerQuitEvent;
import cn.nukkit.form.response.FormResponse;
import cn.nukkit.plugin.Plugin;
import cn.winfxk.nukkit.winfxklib.cmd.AdminCommand;
import cn.winfxk.nukkit.winfxklib.cmd.PlayerCommand;
import cn.winfxk.nukkit.winfxklib.form.FormID;
import cn.winfxk.nukkit.winfxklib.module.leave_word.LeaveWord;
import cn.winfxk.nukkit.winfxklib.money.EasyEconomy;
import cn.winfxk.nukkit.winfxklib.money.EconomyAPI;
import cn.winfxk.nukkit.winfxklib.money.MyEconomy;
import cn.winfxk.nukkit.winfxklib.tool.*;
import com.sun.org.apache.bcel.internal.generic.RET;

import java.io.File;
import java.time.Duration;
Expand All @@ -26,6 +30,7 @@ public class WinfxkLib extends MyBase implements Listener {
public static final String CommandFileName = "Command.yml";
public static final String ConfigFileName = "Config.yml";
public static final String ItemListFileName = "Itemlist.yml";
public static final String LeaveWordFileName = "LeaveWord.yml";
public static final String EffectlistFileName = "Effectlist.yml";
public static final String EnchantListFileName = "Enchantlist.yml";
public static final String[] Meta = {MsgConfigName, ConfigFileName, ItemListFileName, CommandFileName, EnchantListFileName, EffectlistFileName};
Expand All @@ -42,10 +47,15 @@ public class WinfxkLib extends MyBase implements Listener {
private Enchantlist enchantlist;
private static FormID formID;

public static List<String> getBlacklistEconomy() {
return BlacklistEconomy;
}

@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
WinfxkLib.getMyPlayers().put(player.getName(), new MyPlayer(player));
LeaveWord.PlayerJoinEvent(player);
}

@EventHandler
Expand Down Expand Up @@ -75,6 +85,16 @@ public void onFormResponded(PlayerFormRespondedEvent event) {
}
}

@Deprecated
@Override
public cn.nukkit.utils.Config getConfig() {
return null;
}

public static Config getconfig() {
return config;
}

public static MyMap<String, MyPlayer> getMyPlayers() {
return MyPlayers;
}
Expand Down Expand Up @@ -123,7 +143,8 @@ public void onEnable() {
effectlist = new Effectlist();
enchantlist = new Enchantlist();
formID = new FormID();
getServer().getCommandMap().register(getFullName() + "-Command", new AdminCommand(this));
getServer().getCommandMap().register(getFullName() + "-AdminCommand", new AdminCommand());
getServer().getCommandMap().register(getFullName() + "-PlayerCommand", new PlayerCommand());
super.onEnable();
getLogger().info(message.getMessage("插件启动", "{loadTime}", (float) Duration.between(loadTime, Instant.now()).toMillis() + "ms"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
package cn.winfxk.nukkit.winfxklib;
package cn.winfxk.nukkit.winfxklib.cmd;

import cn.nukkit.Player;
import cn.nukkit.command.Command;
import cn.nukkit.command.CommandSender;
import cn.nukkit.command.data.CommandParameter;
import cn.winfxk.nukkit.winfxklib.MyPlayer;
import cn.winfxk.nukkit.winfxklib.module.PostData;
import cn.winfxk.nukkit.winfxklib.tool.Config;
import cn.winfxk.nukkit.winfxklib.tool.Tool;

import java.io.File;
import java.util.Locale;

public class AdminCommand extends Command {
private WinfxkLib lib;
private static final Message msg = WinfxkLib.getMessage();
private static final File file = new File(WinfxkLib.getMain().getConfigDir(), WinfxkLib.CommandFileName);
private static final Config config = new Config(file);
private static final String Permission = "WinfxkLib.Command.Admin";

public AdminCommand(WinfxkLib lib) {
super(lib.getName().toLowerCase(Locale.ROOT), msg.getSun("Command", "AdminCommand", "Description"), msg.getSun("Command", "AdminCommand", "usageMessage"), Tool.getArray(config.getList("AdminCommand"), new String[]{}));
this.lib = lib;
public class AdminCommand extends MyCommand {
public AdminCommand() {
super("admin" + lib.getName().toLowerCase(Locale.ROOT), msg.getSun("Command", "AdminCommand", "Description"), msg.getSun("Command", "AdminCommand", "usageMessage"), Tool.getArray(config.getList("AdminCommand"), new String[]{}));
commandParameters.clear();
commandParameters.put(getString("Help"), new CommandParameter[]{new CommandParameter(getString("Help"), false, new String[]{"help"})});
commandParameters.put(getString("Add"), new CommandParameter[]{new CommandParameter(getString("Add"), false, new String[]{"data", "数据"})});
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!sender.hasPermission(Permission)) {
if (!sender.hasPermission(AdminPermission)) {
sender.sendMessage(getString("无权执行"));
return true;
}
Expand All @@ -41,7 +32,6 @@ public boolean execute(CommandSender sender, String commandLabel, String[] args)
sender.sendMessage(Tool.getCommandHelp(this));
return true;
}
String minorKey;
switch (mainKey.toLowerCase(Locale.ROOT)) {
case "data":
case "数据":
Expand All @@ -51,8 +41,4 @@ public boolean execute(CommandSender sender, String commandLabel, String[] args)
}
return true;
}

private String getString(String Key) {
return msg.getSun("Command", "AdminCommand", Key);
}
}
27 changes: 27 additions & 0 deletions Winfxklib/src/cn/winfxk/nukkit/winfxklib/cmd/MyCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cn.winfxk.nukkit.winfxklib.cmd;

import cn.nukkit.command.Command;
import cn.winfxk.nukkit.winfxklib.Message;
import cn.winfxk.nukkit.winfxklib.WinfxkLib;
import cn.winfxk.nukkit.winfxklib.tool.Config;

import java.io.File;

public abstract class MyCommand extends Command {
protected static WinfxkLib lib = WinfxkLib.getMain();
protected static final Message msg = WinfxkLib.getMessage();
protected static final File file = new File(WinfxkLib.getMain().getConfigDir(), WinfxkLib.CommandFileName);
protected static final Config config = new Config(file);
protected static final String AdminPermission = "WinfxkLib.Command.Admin";
protected static final String PlayerPermission = "WinfxkLib.Command.Player";
protected String CommandKey;

public MyCommand(String name, String description, String usageMessage, String[] aliases) {
super(name, description, usageMessage, aliases);
CommandKey = getClass().getSimpleName();
}

protected String getString(String Key) {
return msg.getSun("Command", CommandKey, Key);
}
}
45 changes: 45 additions & 0 deletions Winfxklib/src/cn/winfxk/nukkit/winfxklib/cmd/PlayerCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package cn.winfxk.nukkit.winfxklib.cmd;

import cn.nukkit.command.CommandSender;
import cn.nukkit.command.data.CommandParameter;
import cn.winfxk.nukkit.winfxklib.MyPlayer;
import cn.winfxk.nukkit.winfxklib.WinfxkLib;
import cn.winfxk.nukkit.winfxklib.module.leave_word.LeaveWord;
import cn.winfxk.nukkit.winfxklib.tool.Tool;

import java.util.Locale;

public class PlayerCommand extends MyCommand {
public PlayerCommand() {
super("admin-" + lib.getName().toLowerCase(Locale.ROOT), msg.getSun("Command", "PlayerCommand", "Description"), msg.getSun("Command", "PlayerCommand", "usageMessage"), Tool.getArray(config.getList("PlayerCommand"), new String[]{}));
commandParameters.clear();
commandParameters.put(getString("Help"), new CommandParameter[]{new CommandParameter(getString("Help"), false, new String[]{"help", "h"})});
commandParameters.put(getString("LeaveWord"), new CommandParameter[]{new CommandParameter(getString("LeaveWord"), false, new String[]{"leaveword", "lw"})});
}

@Override
public boolean execute(CommandSender sender, String s, String[] args) {
if (!sender.hasPermission(PlayerPermission)) {
sender.sendMessage(getString("无权执行"));
return true;
}
if (!sender.isPlayer()) {
sender.sendMessage(getString("NotPlayer"));
return true;
}
String mainKey;
if (args == null || args.length <= 0 || (mainKey = args[0]) == null || mainKey.isEmpty()) {
sender.sendMessage(Tool.getCommandHelp(this));
return true;
}
MyPlayer myPlayer = WinfxkLib.getMyPlayer(sender.getName());
switch (mainKey.toLowerCase(Locale.ROOT)) {
case "leaveword":
case "lw":
return myPlayer.showForm(new LeaveWord(myPlayer.getPlayer(), null, true));
default:
sender.sendMessage(Tool.getCommandHelp(this));
}
return true;
}
}
Loading

0 comments on commit bb1e35b

Please sign in to comment.