Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
WinfXK committed Nov 14, 2019
1 parent 3ba52ff commit 4679435
Show file tree
Hide file tree
Showing 18 changed files with 415 additions and 24 deletions.
1 change: 1 addition & 0 deletions Bemilk/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/EconomyAPI"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Nukkit"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Kis"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
2 changes: 1 addition & 1 deletion Bemilk/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Bemilk
main: xiaokai.bemilk.Bemilk
api:
- 1.0.0
version: 1.2.0
version: 1.2.1
load: POSTWORLD
website: http://EpicFX.cn
author: Winfxk
Expand Down
7 changes: 5 additions & 2 deletions Bemilk/resources/Message.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,17 @@
售罄删除: §6您的个人商店已售罄删除!
无效删除: §4您的个人商店已失效删除!
数据错误: §4数据错误!购买失败!{Error}
个人简介: §6请输入您商店的简介
背包无物品: §4您的背包没有任何一个物品可供出售或回收的选择
想要添加的物品在黑名单: §4物品添加失败!您当前想要添加的物品§f(§4{ItemName}§f)已经在服务器个人商店上架黑名单!
出售项目:
内容: §e欢迎尊敬的§4{Player}§e使用§5{ByPlayer}§e的个人商店!{n}§6商店收购项目:§5{ItemName}§f(§4{ItemID}§f){n}§6价格:{Money}{n}§6数量:§9{Count}{n}§7您当前有§2{MyMoney}§7{MoneyName}{n}§3约能购§5{MoneyItemCount}§3个§2{ItemName}{n}{isInt}{n}§e购买前请检查背包空间,否则购买后货物可能无法正常到账
内容: '{Mydata}{n}§e欢迎尊敬的§4{Player}§e使用§5{ByPlayer}§e的个人商店!{n}§6商店收购项目:§5{ItemName}§f(§4{ItemID}§f){n}§6价格:{Money}{n}§6数量:§9{Count}{n}§7您当前有§2{MyMoney}§7{MoneyName}{n}§3约能购§5{MoneyItemCount}§3个§2{ItemName}{n}{isInt}{n}§e购买前请检查背包空间,否则购买后货物可能无法正常到账'
钱不够: §4滚你妹的!钱不够还来消遣我!滚去多挖点矿吧ヽ(‘⌒´メ)ノ
背包已满: §4您的背包已满!
购买数量: §6回收数量
购买成功: §6购买成功!花费§5{Money}§6获得§2{Count}§6个§5{ItemName}§f(§4{ItemID}§f)
回收项目:
内容: §e欢迎尊敬的§4{Player}§e使用§5{ByPlayer}§e的个人商店!{n}§6商店收购项目:§5{ItemName}§f(§4{ItemID}§f){n}§6数量:§9{Count}{n}§7您当前有§2{MyMoney}§7{MoneyName}{n}{isInt}
内容: '{Mydata}{n}§e欢迎尊敬的§4{Player}§e使用§5{ByPlayer}§e的个人商店!{n}§6商店收购项目:§5{ItemName}§f(§4{ItemID}§f){n}§6数量:§9{Count}{n}§7您当前有§2{MyMoney}§7{MoneyName}{n}{isInt}'
回收数量: §6回收数量
背包为空: §4您的背包为空!
物品到账: §6{Player}§e卖给你§5{ItemCount}§e个§5{ItemName}§f(§4{ItemID}§f)
Expand Down
4 changes: 4 additions & 0 deletions Bemilk/src/xiaokai/bemilk/Bemilk.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
* @author Winfxk
*/
public class Bemilk extends PluginBase {
public static void main(String[] args) {
System.out.println("\n尊敬的 先生/女士 您好!\n 首先感谢您使用本“程序”,但是很遗憾的告诉您,本程序需要依赖一款名为“Nukkit”的Java程序才能运行!详情请搜索引擎搜索了解!");
}

private Instant loadTime = Instant.now();
/**
* 插件缓存数据集合
Expand Down
6 changes: 5 additions & 1 deletion Bemilk/src/xiaokai/bemilk/Dispose.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import xiaokai.bemilk.mtp.SeekData;
import xiaokai.bemilk.set.CustomEffect;
import xiaokai.bemilk.set.CustomItem;
import xiaokai.bemilk.set.MyshopBl;
import xiaokai.bemilk.set.SetConfig;
import xiaokai.bemilk.shop.addShop;
import xiaokai.bemilk.shop.delShop;
Expand Down Expand Up @@ -233,7 +234,7 @@ public static boolean OpenShop(Player player, FormResponseSimple data) {
return MakeForm.Tip(player, kick.Message.getSon("个人商店", "限制OP使用个人商店", DsK, DsO));
if (!Kick.isAdmin(player) && kick.config.getBoolean("限制创造模式使用个人商店") && player.getGamemode() == 1)
return MakeForm.Tip(player, kick.Message.getSon("个人商店", "限制创造模式使用个人商店", DsK, DsO));
return xiaokai.bemilk.shop.myshop.MyShop.MakeMain(player, myPlayer.file);
return xiaokai.bemilk.shop.add.MyShop.MakeMain(player, myPlayer.file);
case "seek":
return MakeForm.OpenShopFoSeek(player, myPlayer.file);
case "add":
Expand Down Expand Up @@ -348,6 +349,9 @@ public static boolean SettingSwitch(Player player, FormResponseSimple data) {
case "effect":
myPlayer.baseset = new CustomEffect(player);
break;
case "msbl":
myPlayer.baseset = new MyshopBl(player);
break;
default:
return MakeForm.Tip(player, "§4无法获取项目类型!");
}
Expand Down
2 changes: 2 additions & 0 deletions Bemilk/src/xiaokai/bemilk/MakeForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public static boolean Setting(Player player) {
AdminList.add("item");
form.addButton(Tool.getRandColor() + "自定义效果");
AdminList.add("effect");
form.addButton(Tool.getRandColor() + "个人商店物品黑名单");
AdminList.add("msbl");
myPlayer.ExtraKeys = AdminList;
kick.PlayerDataMap.put(player.getName(), myPlayer);
form.sendPlayer(player);
Expand Down
11 changes: 7 additions & 4 deletions Bemilk/src/xiaokai/bemilk/Monitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
import xiaokai.bemilk.mtp.FormID;
import xiaokai.bemilk.mtp.Kick;
import xiaokai.bemilk.mtp.MyPlayer;
import xiaokai.bemilk.set.delMyshopBlItem;
import xiaokai.bemilk.shop.addShop;
import xiaokai.bemilk.shop.delShop;
import xiaokai.bemilk.shop.delShopItem;
import xiaokai.bemilk.shop.setShop;
import xiaokai.bemilk.shop.add.ItemEnchant;
import xiaokai.bemilk.shop.add.ItemRepair;
import xiaokai.bemilk.shop.add.ItemTradeItem;
import xiaokai.bemilk.shop.add.MyShopReceive;
import xiaokai.bemilk.shop.add.ShopOrSell;
import xiaokai.bemilk.shop.add.addShopItem;
import xiaokai.bemilk.shop.add.effect.addEffect;
import xiaokai.bemilk.shop.myshop.Receive;

import cn.nukkit.Player;
import cn.nukkit.event.EventHandler;
Expand Down Expand Up @@ -107,11 +108,11 @@ else if (f.getID(22) == ID)
else if (f.getID(23) == ID)
delShopItem.disOK(player, (FormResponseSimple) data);
else if (f.getID(24) == ID)
Receive.MakeMain(player, (FormResponseSimple) data);
MyShopReceive.MakeMain(player, (FormResponseSimple) data);
else if (f.getID(25) == ID)
Receive.InputItem(player, (FormResponseCustom) data);
MyShopReceive.InputItem(player, (FormResponseCustom) data);
else if (f.getID(26) == ID)
Receive.InventoryGetItem(player, (FormResponseCustom) data);
MyShopReceive.InventoryGetItem(player, (FormResponseCustom) data);
else if (f.getID(27) == ID && myPlayer != null && myPlayer.OpenShopDis != null)
myPlayer.OpenShopDis.disMain((FormResponseCustom) data);
else if (f.getID(28) == ID)
Expand All @@ -130,6 +131,8 @@ else if (f.getID(34) == ID && myPlayer != null && myPlayer.baseset != null)
myPlayer.baseset.disMain(data);
else if (f.getID(35) == ID && myPlayer != null && myPlayer.basesetForm != null)
myPlayer.basesetForm.disMain(data);
else if (f.getID(36) == ID)
delMyshopBlItem.Del(player, (FormResponseSimple) data);
} catch (Exception e2) {
e2.printStackTrace();
kick.mis.getLogger().error("ID为" + ID + "的表单数据发生错误!");
Expand Down
36 changes: 34 additions & 2 deletions Bemilk/src/xiaokai/bemilk/mtp/Kick.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@
import xiaokai.bemilk.Bemilk;
import xiaokai.bemilk.tool.Effectrec;
import xiaokai.bemilk.tool.ItemID;
import xiaokai.bemilk.tool.Tool;

import java.io.File;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import cn.nukkit.Player;
import cn.nukkit.command.CommandSender;
import cn.nukkit.item.Item;
import cn.nukkit.utils.Config;

/**
* @author Winfxk
*/
@SuppressWarnings("unchecked")
public class Kick {
public static Kick kick;
/**
Expand All @@ -25,7 +30,7 @@ public class Kick {
* 表单ID配置文件 <b>formIdConfig</b> </br>
* 商店配置文件 <b>ShopConfig</b>
*/
public Config config, formIdConfig, ShopConfig;
public Config config, formIdConfig, ShopConfig, MyShopBlacklist;
/**
* 系统配置文件的文件名
*/
Expand Down Expand Up @@ -58,7 +63,7 @@ public class Kick {
/* 21 */"物品兑换上架从背包选择物品的物品列表备用页面", /* 22 */"商店删除项目页面显示列表", /* 23 */"商店删除项目确认界面",
/* 24 */"创建个人商店让选择添加物品方式的页面", /* 25 */"创建个人商店并且是以手动输入数据的页面", /* 26 */"创建个人商店并且是以从背包获取物品数据的页面",
/* 27 */"商店项目数据交互界面", /* 28 */"处理搜索结果", /* 29 */"主页搜索", /* 30 */"子页搜索页", /* 31 */"添加药水项目主页",
/* 32 */"输入药水信息页", /* 33 */"服务器设置主页", /* 34 */"服务器设置子页", /* 35 */"服务器设置子页中的子页" };
/* 32 */"输入药水信息页", /* 33 */"服务器设置主页", /* 34 */"服务器设置子页", /* 35 */"服务器设置子页中的子页", /* 36 */"个人商店黑名单删除确认页面" };
/**
* 表单ID存储位置
*/
Expand Down Expand Up @@ -141,6 +146,7 @@ public Kick(Bemilk bemilk) {
(new Belle(this)).start();
config = new Config(new File(bemilk.getDataFolder(), ConfigName), Config.YAML);
ShopConfig = new Config(new File(mis.getDataFolder(), ShopConfigName), Config.YAML);
MyShopBlacklist = new Config(new File(mis.getDataFolder(), "MyShopBlacklist.yml"), Config.YAML);
formID = new FormID(this);
formID.setConfig(formIdConfig.getAll());
Message = new Message(this);
Expand Down Expand Up @@ -177,4 +183,30 @@ public static boolean isAdmin(Player player) {
} else
return player.isOp();
}

/**
* 判断一个物品是否是个人商店黑名单
*
* @param item
* @return
*/
public static boolean isBL(Item item) {
Map<String, Object> all = kick.MyShopBlacklist.getAll();
Map<String, Object> map;
for (Object obj : all.values()) {
map = (obj == null || !(obj instanceof Map)) ? new HashMap<>() : (HashMap<String, Object>) obj;
Object obj2 = map.get("Item");
if (map.size() < 1 || obj2 == null || !(obj2 instanceof Map))
continue;
Item item2 = Tool.loadItem((Map<String, Object>) obj2);
if (item2.equals(item))
return true;
if (Tool.isMateID(item.getId() + ":" + item.getDamage(), item2.getId() + ":" + item2.getDamage())) {
if (Tool.ObjToBool(map.get("Skip")))
return true;
return item.getNamedTag().equals(item2.getNamedTag());
}
}
return false;
}
}
36 changes: 36 additions & 0 deletions Bemilk/src/xiaokai/bemilk/set/MyshopBl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package xiaokai.bemilk.set;

import xiaokai.bemilk.mtp.MyPlayer;
import xiaokai.bemilk.tool.SimpleForm;
import xiaokai.bemilk.tool.Tool;

import cn.nukkit.Player;
import cn.nukkit.form.response.FormResponse;
import cn.nukkit.form.response.FormResponseSimple;

/**
* @author Winfxk
*/
public class MyshopBl extends Baseset {

public MyshopBl(Player player) {
super(player);
}

@Override
public boolean makeMain() {
SimpleForm form = new SimpleForm(FormID, Tool.getColorFont("个人商店黑名单设置"));
form.addButton(Tool.getColorFont("添加物品")).addButton(Tool.getColorFont("删除物品")).sendPlayer(player);
return true;
}

@Override
public boolean disMain(FormResponse data) {
MyPlayer myPlayer = kick.PlayerDataMap.get(player.getName());
myPlayer.basesetForm = (((FormResponseSimple) data).getClickedButtonId() == 0 ? new addMyshopBlItem(player)
: new delMyshopBlItem(player));
kick.PlayerDataMap.put(player.getName(), myPlayer);
return myPlayer.basesetForm.makeMain();
}

}
77 changes: 77 additions & 0 deletions Bemilk/src/xiaokai/bemilk/set/addMyshopBlItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package xiaokai.bemilk.set;

import xiaokai.bemilk.MakeForm;
import xiaokai.bemilk.mtp.Belle;
import xiaokai.bemilk.mtp.Kick;
import xiaokai.bemilk.tool.CustomForm;
import xiaokai.bemilk.tool.ItemID;
import xiaokai.bemilk.tool.Tool;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.nukkit.Player;
import cn.nukkit.Server;
import cn.nukkit.form.response.FormResponse;
import cn.nukkit.form.response.FormResponseCustom;
import cn.nukkit.item.Item;
import cn.nukkit.plugin.Plugin;

/**
* @author Winfxk
*/
public class addMyshopBlItem extends BasesetForm {
private List<Item> items = new ArrayList<>();

public addMyshopBlItem(Player player) {
super(player);
}

@Override
public boolean makeMain() {
CustomForm form = new CustomForm(kick.formID.getID(35), "添加个人商店黑名单");
Map<Integer, Item> Contents = player.getInventory().getContents();
List<String> list = new ArrayList<>();
Plugin kis = Server.getInstance().getPluginManager().getPlugin("Knickers");
for (Item item : Contents.values()) {
if (Belle.isMaterials(item)
|| (kis != null && kis.isEnabled() && xiaokai.knickers.mtp.Belle.isMaterials(item))
|| Kick.isBL(item))
continue;
items.add(item);
list.add("§6" + ItemID.getName(item) + "§4(§9" + ItemID.getID(item) + "§4)§f>§8" + item.getCount());
}
if (items.size() < 1)
return MakeForm.Tip(player, "您的背包无任何可以添加黑名单的物品!");
form.addDropdown("请选择想要添加黑名单的物品", list, 0);
form.addToggle("忽略Nbt", false);
form.sendPlayer(player);
return true;
}

@Override
public boolean disMain(FormResponse d) {
FormResponseCustom data = (FormResponseCustom) d;
Item item = items.get(data.getDropdownResponse(0).getElementID());
boolean isOK = data.getToggleResponse(1);
Map<String, Object> map = new HashMap<>();
String Key = getKey(1);
map.put("Skip", isOK);
map.put("Key", Key);
map.put("Item", Tool.saveItem(item));
kick.MyShopBlacklist.set(Key, map);
kick.MyShopBlacklist.save();
return MakeForm.Tip(player, "黑名单添加成功!", true);
}

public String getKey(int Length) {
String key = "";
for (int i = 0; i < Length; i++)
key += Tool.getRandString("qwertyuiop[]asdfghjkl;'\\zxcvbnm,./0123456789-+=()*&^%$#@!~");
if (kick.MyShopBlacklist.exists(key))
return getKey(Length++);
return key;
}
}
Loading

0 comments on commit 4679435

Please sign in to comment.