From 903b9a89c806b1f592d4238aebac3e3eecf9506b Mon Sep 17 00:00:00 2001
From: tianyu <32282861@qq.com>
Date: Fri, 26 Jul 2024 22:37:58 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 40 ++++++
pom.xml | 43 ++++++
.../Event/RechargeBuyKitEvent.java | 33 +++++
.../java/me/Demon/DemonShouKeKit/Main.java | 71 ++++++++++
.../Demon/DemonShouKeKit/MonthChongZhi.java | 122 ++++++++++++++++++
.../me/Demon/DemonShouKeKit/ShouChong.java | 96 ++++++++++++++
src/main/resources/MonthData.yml | 4 +
src/main/resources/config.yml | 99 ++++++++++++++
src/main/resources/plugin.yml | 6 +
9 files changed, 514 insertions(+)
create mode 100644 .gitignore
create mode 100644 pom.xml
create mode 100644 src/main/java/me/Demon/DemonShouKeKit/Event/RechargeBuyKitEvent.java
create mode 100644 src/main/java/me/Demon/DemonShouKeKit/Main.java
create mode 100644 src/main/java/me/Demon/DemonShouKeKit/MonthChongZhi.java
create mode 100644 src/main/java/me/Demon/DemonShouKeKit/ShouChong.java
create mode 100644 src/main/resources/MonthData.yml
create mode 100644 src/main/resources/config.yml
create mode 100644 src/main/resources/plugin.yml
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c037f46
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,40 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
+/.idea/
+/out/
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..d4a65f1
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,43 @@
+
+
+ 4.0.0
+
+ org.example
+ DemonShouKeKit
+ 1.0-SNAPSHOT
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+ public-rpg
+ https://repo.aurora-pixels.com/repository/public-rpg/
+
+
+
+
+
+ org.spigotmc
+ spigot-api
+ 1.12.2
+
+
+ com.vexview.api
+ vexview
+ 1.12.2
+
+
+ com.yaohun.nbtapi
+ NBT-API
+ 1.12.2
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/me/Demon/DemonShouKeKit/Event/RechargeBuyKitEvent.java b/src/main/java/me/Demon/DemonShouKeKit/Event/RechargeBuyKitEvent.java
new file mode 100644
index 0000000..1144022
--- /dev/null
+++ b/src/main/java/me/Demon/DemonShouKeKit/Event/RechargeBuyKitEvent.java
@@ -0,0 +1,33 @@
+package me.Demon.DemonShouKeKit.Event;
+
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+public class RechargeBuyKitEvent extends Event {
+ private static HandlerList handlers = new HandlerList();
+
+ private String playName;
+
+ private String kit_type;
+
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ public RechargeBuyKitEvent(String playName, String kit_type) {
+ this.playName = playName;
+ this.kit_type = kit_type;
+ }
+
+ public String getPlayName() {
+ return this.playName;
+ }
+
+ public String getKit_type() {
+ return this.kit_type;
+ }
+}
diff --git a/src/main/java/me/Demon/DemonShouKeKit/Main.java b/src/main/java/me/Demon/DemonShouKeKit/Main.java
new file mode 100644
index 0000000..c6873ed
--- /dev/null
+++ b/src/main/java/me/Demon/DemonShouKeKit/Main.java
@@ -0,0 +1,71 @@
+package me.Demon.DemonShouKeKit;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Listener;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.java.JavaPlugin;
+
+public class Main extends JavaPlugin implements Listener {
+ public static Main plugin;
+
+ public static String prefix = "§f[§c礼包§f] §a";
+
+ public static List scList = new ArrayList<>();
+
+ public static File Datafile = new File("plugins/DemonShouKeKit", "MonthData.yml");
+
+ public static FileConfiguration DataG = (FileConfiguration)YamlConfiguration.loadConfiguration(Datafile);
+
+ public static void saveDataConfig() {
+ try {
+ DataG.save(Datafile);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void onEnable() {
+ plugin = this;
+ saveDefaultConfig();
+ if (getConfig().getConfigurationSection("ChongZhi") != null)
+ scList.addAll(getConfig().getConfigurationSection("ChongZhi").getKeys(false));
+ getServer().getPluginManager().registerEvents(new ShouChong(), (Plugin)plugin);
+ getServer().getPluginManager().registerEvents(this, (Plugin)this);
+ MonthChongZhi.updataMonthData();
+ }
+
+ public boolean onCommand(CommandSender sender, Command cmd, String str, String[] args) {
+ if (str.equalsIgnoreCase("dshouk") &&
+ args.length == 0)
+ ShouChong.OpenGui((Player)sender);
+ return false;
+ }
+
+ public static boolean isInvFull(Player player) {
+ if (player.getInventory().firstEmpty() == -1)
+ return true;
+ return false;
+ }
+
+ public static int getRandomInt(int max, int mix) {
+ return (new Random()).nextInt(max) + mix;
+ }
+
+ public static String getTime(String Format) {
+ Date date = Calendar.getInstance().getTime();
+ SimpleDateFormat datatime = new SimpleDateFormat(Format);
+ return datatime.format(date);
+ }
+}
diff --git a/src/main/java/me/Demon/DemonShouKeKit/MonthChongZhi.java b/src/main/java/me/Demon/DemonShouKeKit/MonthChongZhi.java
new file mode 100644
index 0000000..f468ae8
--- /dev/null
+++ b/src/main/java/me/Demon/DemonShouKeKit/MonthChongZhi.java
@@ -0,0 +1,122 @@
+package me.Demon.DemonShouKeKit;
+
+import de.tr7zw.itemnbtapi.NBTItem;
+import org.bukkit.Bukkit;
+import org.bukkit.Sound;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.scheduler.BukkitRunnable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MonthChongZhi implements Listener {
+ @EventHandler
+ public void click(InventoryClickEvent e) {
+ Player p = (Player)e.getWhoClicked();
+ if (e.getInventory() != null && "斗魂偙国 - 幸运儿资格查询".equalsIgnoreCase(e.getInventory().getTitle()))
+ e.setCancelled(true);
+ }
+
+ public static void OpenGui(Player p) {
+ Inventory inv = Bukkit.createInventory(null, 9, "斗魂偙国 - 幸运儿资格查询");
+ inv.setItem(4, showItems(p.getName()));
+ p.openInventory(inv);
+ }
+
+ public static ItemStack showItems(String playName) {
+ ItemStack item = new ItemStack(359);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName("§e§l幸运儿资格查询");
+ List lore = new ArrayList<>();
+ if (isPlayerData(playName)) {
+ lore.add("§a§l★§7资格查询: §d§l已使用");
+ } else if (getPlayerList().contains(playName)) {
+ lore.add("§a§l★§7资格查询: §a§l已获得");
+ } else {
+ lore.add("§a§l★§7资格查询: §c§l未获得");
+ }
+ lore.add("§a§l★§7剩余名额: §a§l" + (15 - getPlayerDataAmount()) + " §7§l/ §a§l15");
+ lore.add(" ");
+ lore.add("§a§l★§7玩法介绍:");
+ lore.add("§7 每月仅限30名玩家获得幸运儿资格");
+ lore.add("§7 您每月充值的每一笔软都概率触发幸运儿");
+ lore.add("§7 触发幸运儿后下一笔充值就会变为双倍");
+ lore.add("§c (但是下一笔需要满足100软以上才行)");
+ meta.setLore(lore);
+ item.setItemMeta(meta);
+ NBTItem nbti = new NBTItem(item);
+ nbti.setString("stex", "qiandai_5");
+ item = nbti.getItem();
+ return item;
+ }
+
+ public static void StartXingYunEr(final Player p) {
+ addPlayerList(p.getName());
+ (new BukkitRunnable() {
+ public void run() {
+ p.sendMessage("§f[§c幸运儿§f] §a恭喜成为本月幸运儿!下一次赞助可获得双倍!§7(不含赠送)");
+ p.sendTitle("§e§l赞助幸运儿", "§f下一笔充值§6[" + Main.DataG.getInt("RechargeMoney") + "元]§f以上即可翻倍!", 20, 60, 40);
+ p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0F, 1.0F);
+ }
+ }).runTaskLater(Main.plugin, 40L);
+ }
+
+ public static int getPlayerDataAmount() {
+ int amount = 0;
+ FileConfiguration yml = Main.DataG;
+ for (String playName : yml.getConfigurationSection("PlayerData").getKeys(false)) {
+ if (isPlayerData(playName))
+ amount++;
+ }
+ return amount;
+ }
+
+ public static boolean isPlayerData(String playName) {
+ FileConfiguration yml = Main.DataG;
+ return yml.getBoolean("PlayerData." + playName);
+ }
+
+ public static void setPlayerData(String playName, boolean butt) {
+ FileConfiguration yml = Main.DataG;
+ yml.set("PlayerData." + playName, butt);
+ Main.saveDataConfig();
+ }
+
+ public static List getPlayerList() {
+ FileConfiguration yml = Main.DataG;
+ return yml.getStringList("PlayerList");
+ }
+
+ public static void addPlayerList(String playName) {
+ FileConfiguration yml = Main.DataG;
+ List list = new ArrayList<>();
+ list.add(playName);
+ list.addAll(getPlayerList());
+ yml.set("PlayerList", list);
+ Main.saveDataConfig();
+ }
+
+ public static String getLastMonthtime() {
+ FileConfiguration yml = Main.DataG;
+ return yml.getString("Timemonth");
+ }
+
+ public static void updataMonthData() {
+ FileConfiguration yml = Main.DataG;
+ if (!getLastMonthtime().equalsIgnoreCase(Main.getTime("yyyy/MM"))) {
+ yml.set("Timemonth", Main.getTime("yyyy/MM"));
+ List list = new ArrayList<>();
+ yml.set("PlayerList", list);
+ for (String playName : yml.getConfigurationSection("PlayerData").getKeys(false))
+ yml.set("PlayerData." + playName, null);
+ Main.saveDataConfig();
+ }
+ }
+}
diff --git a/src/main/java/me/Demon/DemonShouKeKit/ShouChong.java b/src/main/java/me/Demon/DemonShouKeKit/ShouChong.java
new file mode 100644
index 0000000..0bd24d6
--- /dev/null
+++ b/src/main/java/me/Demon/DemonShouKeKit/ShouChong.java
@@ -0,0 +1,96 @@
+package me.Demon.DemonShouKeKit;
+
+import com.yaohun.aurechargedata.api.RechargeAPI;
+import com.yaohun.aurechargedata.util.TimeType;
+import lk.vexview.api.VexViewAPI;
+import lk.vexview.event.ButtonClickEvent;
+import lk.vexview.gui.VexGui;
+import lk.vexview.gui.components.VexButton;
+import lk.vexview.gui.components.VexSlot;
+import me.Demon.DemonShouKeKit.Event.RechargeBuyKitEvent;
+import org.bukkit.Bukkit;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ShouChong implements Listener {
+ public static int getCzCoins(String playName) {
+ return RechargeAPI.getRechargeData(playName, TimeType.ANNUAL);
+ }
+
+ public static ItemStack showItem(String key) {
+ FileConfiguration yml = Main.plugin.getConfig();
+ return yml.getItemStack("ItemShow." + key);
+ }
+
+ public static void OpenGui(Player p) {
+ VexGui gui = new VexGui("[local]LiBao/首充礼包.png", -1, -1, 240, 160);
+ if (!isSendKit(p.getName()).contains("首充大礼包"))
+ gui.addComponent(new VexButton("dshouk_butt", "§r", "[local]LiBao/点击领取_1.png", "[local]LiBao/点击领取_2.png", 95, 138, 40, 15));
+ gui.addComponent(new VexSlot(0, 98, 120, showItem("学院智慧头骨")));
+ gui.addComponent(new VexSlot(1, 121, 120, showItem("灵环幸运蛋")));
+ gui.addComponent(new VexSlot(2, 144, 120, showItem("远古精灵的秘药")));
+ gui.addComponent(new VexSlot(3, 166, 120, showItem("高级器师套装盒")));
+ gui.addComponent(new VexSlot(4, 189, 120, showItem("金币50000")));
+ VexViewAPI.openGui(p, gui);
+ }
+
+ @EventHandler
+ public void onkey(ButtonClickEvent e) {
+ Player p = e.getPlayer();
+ Object ButtonID = e.getButtonID();
+ if (ButtonID == null)
+ return;
+ if (String.valueOf(ButtonID).contains("dshouk_butt")) {
+ if (isSendKit(p.getName()).contains("首充大礼包")) {
+ p.sendMessage(Main.prefix + "您已经领取过该礼包,不能再次领取喔~");
+ return;
+ }
+ if (Main.isInvFull(p)) {
+ p.sendMessage(Main.prefix + "您的背包满了,请清理一下背包再尝试领取.");
+ return;
+ }
+ int money = getCzCoins(p.getName());
+ if (money >= 6) {
+ p.closeInventory();
+ Main.scList.add(p.getName());
+ addSendKit(p.getName(), "首充大礼包");
+ Main.plugin.saveConfig();
+ ItemStack tougu = showItem("学院智慧头骨").clone();
+ ItemMeta meta = tougu.getItemMeta();
+ List lore = meta.getLore();
+ lore.add("§c帝国绑定: §e" + p.getName());
+ meta.setLore(lore);
+ tougu.setItemMeta(meta);
+ p.getInventory().addItem(tougu);
+ p.getInventory().addItem(showItem("灵环幸运蛋"));
+ p.getInventory().addItem(showItem("高级器师套装盒"));
+ Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "eco give " + p.getName() + " 50000");
+ Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "dpotion give 远古精灵的秘药 2 " + p.getName());
+ RechargeBuyKitEvent event = new RechargeBuyKitEvent(p.getName(), "首充大礼包");
+ Bukkit.getPluginManager().callEvent(event);
+ } else {
+ p.sendMessage(Main.prefix + "你还需要充值§e§l" + (6 - money) + "元§a才能领取该礼包.");
+ }
+ }
+ }
+
+ public static List isSendKit(String playName) {
+ FileConfiguration yml = Main.plugin.getConfig();
+ return yml.getStringList("ChongZhi." + playName + ".KitList");
+ }
+
+ public static void addSendKit(String playName, String kitType) {
+ FileConfiguration yml = Main.plugin.getConfig();
+ List list = new ArrayList<>();
+ list.add(kitType);
+ list.addAll(isSendKit(playName));
+ yml.set("ChongZhi." + playName + ".KitList", list);
+ }
+}
diff --git a/src/main/resources/MonthData.yml b/src/main/resources/MonthData.yml
new file mode 100644
index 0000000..f9411d1
--- /dev/null
+++ b/src/main/resources/MonthData.yml
@@ -0,0 +1,4 @@
+Timemonth: 2021/11
+RechargeMoney: 100
+PlayerList: []
+PlayerData: {}
\ No newline at end of file
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
new file mode 100644
index 0000000..a61bbf8
--- /dev/null
+++ b/src/main/resources/config.yml
@@ -0,0 +1,99 @@
+ItemShow:
+ 学院智慧头骨:
+ ==: org.bukkit.inventory.ItemStack
+ type: BONE
+ meta:
+ ==: ItemMeta
+ meta-type: UNSPECIFIC
+ display-name: §6§l学院§b§l智慧§6§l头骨
+ lore:
+ - '§7类型: §a头部兽骨 §7品质: §d稀有'
+ - §f§l§m—=—=—=—§r§e§l兽骨介绍§f§l§m—=—=—=—§r
+ - §f贵族器师入驻帝国学院时
+ - §f斗魂导师赠予辅助你冲级
+ - §f§l§m—=—=—=—§r§e§l兽骨属性§f§l§m—=—=—=—§r
+ - '§b¤ §7PVE攻击: §a188'
+ - '§b¤ §7生命上限: §a200'
+ - '§b¤ §7攻击伤害: §a325'
+ - '§b¤ §7经验加成: §a10%'
+ - '§b¤ §7移速加成: §a8%'
+ - §f§l§m—=—=—=—§r§e§l兽骨宝石§f§l§m—=—=—=—§r
+ - '§8「 §b宝石 §8」§8「 §7未镶嵌 §8」'
+ - §f§l§m—=—=—=—§r§e§l兽骨宝石§f§l§m—=—=—=—§r
+ enchants:
+ PROTECTION_ENVIRONMENTAL: 1
+ ItemFlags:
+ - HIDE_ENCHANTS
+ internal: H4sIAAAAAAAAAONiYOBgYCkuSa1g4ExOzMzJTMyPN2EAAPNmhWoWAAAA
+ 灵环幸运蛋:
+ ==: org.bukkit.inventory.ItemStack
+ type: CLAY_BRICK
+ amount: 5
+ meta:
+ ==: ItemMeta
+ meta-type: UNSPECIFIC
+ display-name: '§e§l灵环幸运蛋§7[§eLv.10§7]'
+ lore:
+ - '§a§l✔§7SHIFT+右键开启幸运蛋'
+ - '§7§l★§7有100%得到物品'
+ - '§7§l★§7奖励列表:'
+ - '§7--------------'
+ - §71. §7§l★§71 §c§l十万年灵环§d[含献祭]
+ - §72. §7§l★§71 §c§l十万年灵环
+ - §73. §7§l★§71 §c§l异变灵环
+ - §74. §7§l★§71 §7§l万年灵环
+ - §75. §7§l★§71 §d§l千年灵环
+ - §7--------------
+ - §6祝君好运!
+ internal: H4sIAAAAAAAAAONiYOBgYCkuSa1g4EpKzK/ITMxLj7dgAADi48WQFwAAAA==
+ 远古精灵的秘药:
+ ==: org.bukkit.inventory.ItemStack
+ type: SUGAR
+ amount: 2
+ meta:
+ ==: ItemMeta
+ meta-type: UNSPECIFIC
+ display-name: §d§l远古精灵的秘药
+ lore:
+ - '§7类型: §a消耗品 §7品质: §d神器'
+ - §f§l§m—=—=—=—§r§e§l功能介绍§f§l§m—=—=—=—§r
+ - §f手持右键使用后将获得经验
+ - §d经验+100%§f效果并持续30分钟
+ - §b充满神秘的远古秘药!
+ - §f§l§m—=—=—=—§r§e§l功能介绍§f§l§m—=—=—=—§r
+ enchants:
+ LUCK: 1
+ ItemFlags:
+ - HIDE_ENCHANTS
+ internal: H4sIAAAAAAAAAONiYOBgYCkuSa1g4KxMzC/OKM2MN2cAAIp8il0WAAAA
+ 高级器师套装盒:
+ ==: org.bukkit.inventory.ItemStack
+ type: CLAY_BRICK
+ meta:
+ ==: ItemMeta
+ meta-type: UNSPECIFIC
+ display-name: §a高级器师套装盒§7[§eLv.15§7]
+ lore:
+ - §a§l★§7开启套装盒后即可
+ - §7获得整套高级器师防具
+ - §f§l§m—=—=—=—=—§r§6§l整套属性§f§l§m—=—=—=—=—§r
+ - '§b¤ §7物理防御§f§l: §a31.81'
+ - '§b¤ §7生命恢复§f§l: §a1.57'
+ - '§b¤ §7生命上限§f§l: §a166.55'
+ - '§b¤ §7格挡几率§f§l: §a3.03'
+ - '§b¤ §7闪避几率§f§l: §a3.83'
+ - '§b¤ §7移速加成§f§l: §a2.79'
+ - §f§l§m—=—=—=—=—§r§6§l防具信息§f§l§m—=—=—=—=—§r
+ - §e由普通器师的防具装备进阶而来
+ internal: H4sIAAAAAAAAAONiYOBgYCkuSa1g4E5KzK/ITMxLjzc0YgAAQR+hoxgAAAA=
+ 金币50000:
+ ==: org.bukkit.inventory.ItemStack
+ type: GOLD_INGOT
+ meta:
+ ==: ItemMeta
+ meta-type: UNSPECIFIC
+ display-name: §e§l金币§fx50000
+ internal: H4sIAAAAAAAAAONiYOBgYCkuSa1gYMtMzs+LN2QAAE7kyh4TAAAA
+Todaytime: 2022/04/25
+JoinOpenGui: []
+ChongZhi: {}
\ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
new file mode 100644
index 0000000..19e119b
--- /dev/null
+++ b/src/main/resources/plugin.yml
@@ -0,0 +1,6 @@
+name: DemonShouKeKit
+main: me.Demon.DemonShouKeKit.Main
+version: 1.4.0
+depend: [VexView ]
+commands:
+ dshouk:
\ No newline at end of file