测试版

This commit is contained in:
tianyu 2024-07-26 22:37:58 +08:00
commit 903b9a89c8
9 changed files with 514 additions and 0 deletions

40
.gitignore vendored Normal file
View File

@ -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/

43
pom.xml Normal file
View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>DemonShouKeKit</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>public-rpg</id>
<url>https://repo.aurora-pixels.com/repository/public-rpg/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2</version>
</dependency>
<dependency>
<groupId>com.vexview.api</groupId>
<artifactId>vexview</artifactId>
<version>1.12.2</version>
</dependency>
<dependency>
<groupId>com.yaohun.nbtapi</groupId>
<artifactId>NBT-API</artifactId>
<version>1.12.2</version>
</dependency>
</dependencies>
</project>

View File

@ -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;
}
}

View File

@ -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<String> 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);
}
}

View File

@ -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<String> 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<String> getPlayerList() {
FileConfiguration yml = Main.DataG;
return yml.getStringList("PlayerList");
}
public static void addPlayerList(String playName) {
FileConfiguration yml = Main.DataG;
List<String> 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<String> list = new ArrayList<>();
yml.set("PlayerList", list);
for (String playName : yml.getConfigurationSection("PlayerData").getKeys(false))
yml.set("PlayerData." + playName, null);
Main.saveDataConfig();
}
}
}

View File

@ -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<String> 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<String> 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<String> list = new ArrayList<>();
list.add(kitType);
list.addAll(isSendKit(playName));
yml.set("ChongZhi." + playName + ".KitList", list);
}
}

View File

@ -0,0 +1,4 @@
Timemonth: 2021/11
RechargeMoney: 100
PlayerList: []
PlayerData: {}

View File

@ -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: {}

View File

@ -0,0 +1,6 @@
name: DemonShouKeKit
main: me.Demon.DemonShouKeKit.Main
version: 1.4.0
depend: [VexView ]
commands:
dshouk: