This commit is contained in:
yaohunya 2024-08-02 18:35:19 +08:00
parent dc821de01c
commit cf6647661b
24 changed files with 419 additions and 55 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
/out/
/.idea/
/target/
/lib/

View File

@ -3,8 +3,14 @@ package com.io.yutian.mclive;
import com.io.yutian.livemutually.manager.KSLiveRoomManager;
import com.io.yutian.mclive.data.GiftManage;
import com.io.yutian.mclive.event.ZhuboAPI;
import com.io.yutian.pixelliveplugin.PixelLiveAPI;
import com.io.yutian.mclive.listener.JoinGameRoom;
import com.io.yutian.mclive.listener.LiveAdminGui;
import com.io.yutian.mclive.listener.SoundsMenu;
import com.io.yutian.mclive.live.LiveEvent;
import com.io.yutian.mclive.live.ModEvent;
import com.io.yutian.mclive.util.ConfigYml;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
@ -12,12 +18,10 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.*;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.regex.Pattern;
@ -32,17 +36,18 @@ public class Main extends JavaPlugin {
@Override
public void onEnable() {
plugin = this;
saveDefaultConfig();
SendPluginsAuthorMessage(Bukkit.getConsoleSender());
configYml = new ConfigYml(getConfig());
if (giftStatistics){
giftManage = new GiftManage();
giftManage.LinkMySqlData();
}
addSoundKeyList();
getServer().getPluginManager().registerEvents(new LiveAdminGui(),this);
getServer().getPluginManager().registerEvents(new LinkRoom(),this);
getServer().getPluginManager().registerEvents(new JoinGameRoom(),this);
getServer().getPluginManager().registerEvents(new ModEvent(),this);
getServer().getPluginManager().registerEvents(new LiveEvent(configYml),this);
getServer().getPluginManager().registerEvents(new SoundsMenu(),this);
Bukkit.getConsoleSender().sendMessage("§b[整蛊MC直播] §7当前版本: §ev"+plugin.getDescription().getVersion());
Plugin plugin = getServer().getPluginManager().getPlugin(configYml.getGameMode());
if (plugin != null) {
@ -63,8 +68,73 @@ public class Main extends JavaPlugin {
}
}
public static void addSoundKeyList(){
List<String> stringList = new ArrayList<>();
stringList.add("youbom");
stringList.add("oi");
stringList.add("man");
stringList.add("jiarenmen");
stringList.add("huwuqifei");
stringList.add("ccp1");
stringList.add("ccp2");
stringList.add("dxj");
stringList.add("ybjjj");
stringList.add("mc_chidongxi");
stringList.add("zhasini");
stringList.add("jingbao");
stringList.add("dashengfa");
stringList.add("biu");
stringList.add("csgo1");
stringList.add("dalia");
stringList.add("haihaihai");
stringList.add("jingshenxiaohuo");
stringList.add("mymymy");
stringList.add("waou");
stringList.add("xiaohuangya");
stringList.add("huh");
stringList.add("lailea");
stringList.add("douduoyu");
stringList.add("heiheihei");
stringList.add("ji");
stringList.add("aligaduo");
stringList.add("duolaameng");
stringList.add("haimianbb");
stringList.add("gua");
stringList.add("xiaofeigun");
stringList.add("hedantou");
stringList.add("xxx");
stringList.add("xh");
stringList.add("any");
stringList.add("bbt");
stringList.add("rqq");
stringList.add("bsj");
stringList.add("boboji");
stringList.add("dahulu");
stringList.add("jujueno");
stringList.add("mofaxiufu");
stringList.add("ohuo");
stringList.add("touxi");
stringList.add("wanlewanle");
stringList.add("fangpi");
stringList.add("hedan");
stringList.add("niganma");
SoundsMenu.soundList.addAll(stringList);
}
@Override
public void onDisable() {
if(giftStatistics && ConfigYml.mysqlState) {
for (Player player : Bukkit.getOnlinePlayers()) {
giftManage.SaveZhuboData(player.getName());
}
}
}
@Override
public boolean onCommand(CommandSender sender, Command command, String Command, String[] args) {
if (Command.equalsIgnoreCase("sounds")) {
SoundsMenu.OpenGui((Player) sender,1);
}
if (Command.equalsIgnoreCase("mclive")) {
if (args.length == 0) {
sender.sendMessage("");
@ -133,6 +203,15 @@ public class Main extends JavaPlugin {
Main.configYml.setRoomId(playName, room_id);
Main.configYml.SaveConfigYml();
sender.sendMessage("§c[系统]§a直播间已设置 §e" + playName + " §a--> §e" + room_id);
player.resetTitle();
player.sendTitle("§a§l绑定成功","§6已绑定抖音号: §f"+room_id,0,40,20);
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP,1,1);
new BukkitRunnable() {
@Override
public void run() {
player.sendTitle("§c尚未连接弹幕软件","§6按住SHIFT键 + F键 §f点击按钮连接",5,20*60,20);
}
}.runTaskLater(this,40);
return true;
}
if (args.length == 1 && args[0].equalsIgnoreCase("save")) {

View File

@ -1,25 +1,53 @@
package com.io.yutian.mclive.data;
import com.io.yutian.mclive.ConfigYml;
import com.io.yutian.mclive.util.ConfigYml;
import com.io.yutian.mclive.Main;
import com.io.yutian.mclive.Util.SqlUtil;
import com.io.yutian.mclive.util.SqlUtil;
import com.io.yutian.mclive.data.database.SqlManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
public class GiftManage {
private double totalMoney;
private HashMap<String,Integer> giftMap = new HashMap<>();
private LinkedHashMap<String,Integer> giftMap = new LinkedHashMap<>();
public List<String> getGiftNameList() {
return new ArrayList<>(giftMap.keySet());
}
public GiftManage(){
totalMoney = 0;
giftMap.put("小心心",1);
giftMap.put("人气票",1);
giftMap.put("闪耀星辰",1);
giftMap.put("加油鸭",1);
giftMap.put("比心兔兔",1);
giftMap.put("热气球",1);
giftMap.put("爱你哟",1);
giftMap.put("天鹅之梦",1);
giftMap.put("Thuglife",1);
giftMap.put("粘人小狗",1);
giftMap.put("粉丝团灯牌",1);
giftMap.put("大啤酒",2);
giftMap.put("玫瑰",1);
giftMap.put("抖音",1);
giftMap.put("称心如意",1);
giftMap.put("你最好看",2);
giftMap.put("助力票",1);
giftMap.put("荣耀擂鼓",99);
giftMap.put("宠粉季",1);
giftMap.put("兔耳朵",99);
giftMap.put("游戏手柄",99);
giftMap.put("冰镇西瓜",99);
giftMap.put("为你闪耀",9);
giftMap.put("棒棒糖",9);
giftMap.put("鲜花",10);
giftMap.put("亲吻",99);
giftMap.put("跑车",1200);
giftMap.put("礼花筒",199);
@ -29,11 +57,9 @@ public class GiftManage {
giftMap.put("爱的纸鹤",99);
giftMap.put("送你花花",49);
giftMap.put("女神花环",99);
giftMap.put("粘人小狗",1);
giftMap.put("鱼你一起",99);
giftMap.put("真爱玫瑰",366);
giftMap.put("为你举牌",199);
giftMap.put("兔耳朵",99);
giftMap.put("龙抬头",99);
giftMap.put("花开烂漫",466);
giftMap.put("比心",199);
@ -125,8 +151,6 @@ public class GiftManage {
giftMap.put("小纸条",399);
giftMap.put("如意锦囊",99);
giftMap.put("星光瓶",900);
giftMap.put("粉丝团灯牌",1);
giftMap.put("为你闪耀",9);
giftMap.put("一直陪伴你",520);
giftMap.put("动次打次",2999);
giftMap.put("宇宙之心",18888);
@ -165,13 +189,25 @@ public class GiftManage {
return totalMoney;
}
public void defaultTotalMoney(){
if(this.totalMoney <= 0) {
for (Player player : Bukkit.getOnlinePlayers()) {
String name = player.getName();
if (Main.configYml.getRoomId(name) == null) {
return;
}
String tiktok = Main.configYml.getRoomId(name);
this.totalMoney = sqlManager.getZhuboIncome(tiktok) * 10;
}
}
}
public void addTotalMoney(String name,int money){
if(this.totalMoney <= 0){
if(Main.configYml.getRoomId(name) == null){
return;
}
String tiktok = Main.configYml.getRoomId(name);
this.totalMoney = sqlManager.getZhuboIncome(tiktok);
this.totalMoney = sqlManager.getZhuboIncome(tiktok) * 10;
}
if(money >= 5000){
SaveZhuboData(name);
@ -185,7 +221,7 @@ public class GiftManage {
return;
}
String tiktok = Main.configYml.getRoomId(name);
this.totalMoney = sqlManager.getZhuboIncome(tiktok);
this.totalMoney = sqlManager.getZhuboIncome(tiktok) * 10;
}
int newMoney = (int) (money * amount);
if(newMoney >= 5000){

View File

@ -0,0 +1,68 @@
package com.io.yutian.mclive.data;
import json.JSONArray;
import json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class IPGeolocation {
public static String getIpAddress(){
String apiUrl = "https://api.ipify.org";
try {
URL url = new URL(apiUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String ipAddress = in.readLine();
in.close();
return ipAddress;
} catch (Exception e) {
e.printStackTrace();
}
return "127.0.0.1";
}
public static String getThePlayerSPhysicalAddress(){
String ipAddress = getIpAddress();
if(!ipAddress.equalsIgnoreCase("127.0.0.1")) {
String apiKey = "7ccd51489d506caed949fc5ef79bf532"; // 替换成你从API服务提供商获取的API密钥
String apiUrl = "https://api.ip138.com/ipdata/?ip=" + ipAddress + "&datatype=jsonp&token=" + apiKey;
try {
URL url = new URL(apiUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
// 解析JSON响应
JSONObject jsonResponse = new JSONObject(response.toString());
String status = jsonResponse.getString("ret");
if ("ok".equals(status)) {
JSONArray dataArray = jsonResponse.getJSONArray("data");
String country = dataArray.getString(0);
String province = dataArray.getString(1);
String city = dataArray.getString(2);
return province + "" + city;
} else {
System.out.println("查询失败,返回状态: " + status);
}
} catch (Exception e) {
e.printStackTrace();
}
}
return "无记录";
}
}

View File

@ -1,19 +1,16 @@
package com.io.yutian.mclive.data.database;
import com.io.yutian.mclive.Main;
import com.io.yutian.mclive.Util.SqlUtil;
import com.io.yutian.mclive.data.IPGeolocation;
import com.io.yutian.mclive.util.SqlUtil;
import com.io.yutian.mclive.data.GiftManage;
import org.bukkit.Bukkit;
import java.sql.ResultSet;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.StringJoiner;
public class SqlManager {
@ -29,7 +26,8 @@ public class SqlManager {
" tiktok VARCHAR(32) NOT NULL," +
" income DOUBLE NOT NULL," +
" livetime VARCHAR(256) NOT NULL," +
" createtime VARCHAR(256) NOT NULL" +
" createtime VARCHAR(256) NOT NULL," +
" city VARCHAR(256) NOT NULL" +
") ENGINE = InnoDB";
getSQL().openConnection();
getSQL().updateSQL(s);
@ -50,12 +48,14 @@ public class SqlManager {
e.printStackTrace();
}
if(iconme <= -1) {
String set = "INSERT INTO " + table + " (`zhubo`,`tiktok`, `income`, `livetime`, `createtime`) VALUES ('%zhubo%','%tiktok%', '%income%', '%livetime%', '%createtime%')";
String set = "INSERT INTO " + table + " (`zhubo`,`tiktok`, `income`, `livetime`, `createtime`, `city`) " +
"VALUES ('%zhubo%','%tiktok%', '%income%', '%livetime%', '%createtime%', '%city%')";
set = set.replace("%zhubo%", "默认");
set = set.replace("%tiktok%", tiktok);
set = set.replace("%income%", String.valueOf(0));
set = set.replace("%livetime%", getNowTimeString());
set = set.replace("%createtime%", getNowTimeString());
set = set.replace("%city%", IPGeolocation.getThePlayerSPhysicalAddress());
getSQL().updateSQL(set);
}
getSQL().closeConnection();
@ -77,7 +77,9 @@ public class SqlManager {
getSQL().openConnection();
ResultSet resultSet = getSQL().querySQL(select.replace("%tiktok%", tiktok));
while (resultSet.next()) {
return resultSet.getDouble("income");
double income = resultSet.getDouble("income");
// System.out.println("[调试 - 输出] "+tiktok+" 数据: "+income+"");
return income;
}
} catch (Exception e) {
e.printStackTrace();
@ -109,6 +111,8 @@ public class SqlManager {
public void SavePlayerData(String tiktok){
if(!Main.giftStatistics){return;}
GiftManage giftManage = Main.giftManage;
giftManage.defaultTotalMoney();
giftManage.addTotalMoney(tiktok,1);
double money = giftManage.getTotalMoney() * 0.1;
String set = "UPDATE `"+table+"` SET " +
"`income` = '%income%'," +

View File

@ -2,9 +2,11 @@ package com.io.yutian.mclive.event;
import com.io.yutian.livemutually.manager.KSLiveRoomManager;
import com.io.yutian.mclive.Main;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.List;
public abstract class ZhuboAPI {
// 存储Wss主播的直播间id
@ -21,4 +23,14 @@ public abstract class ZhuboAPI {
}
public static String getRoomLiveName(){return "DouYin";}
//public static String getRoomLiveName(){return "KuaiShou";}
// 获取礼物列表
public static boolean isGiftNameList(String giftname){
for (String gift : Main.giftManage.getGiftNameList()){
if(giftname.contains(gift)){
return true;
}
}
return false;
}
}

View File

@ -1,5 +1,6 @@
package com.io.yutian.mclive;
package com.io.yutian.mclive.listener;
import com.io.yutian.mclive.Main;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
@ -13,7 +14,7 @@ import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
public class LinkRoom implements Listener {
public class JoinGameRoom implements Listener {
@EventHandler
public void onSwap(PlayerSwapHandItemsEvent e) {
@ -43,9 +44,11 @@ public class LinkRoom implements Listener {
SendClickMessage(p, message, roomId);
SendClickMessage(p, message, roomId);
SendClickMessage(p, message, roomId);
p.sendTitle("§c尚未连接弹幕软件","§6按住SHIFT键 + F键 §f点击按钮连接",0,20*60,20);
}else{
String message = "§7[§6提示§7] §f当前账号: §c§n" + playName + "§r §f并未绑定抖音ID";
p.sendMessage(message);
p.sendTitle("§c尚未绑定抖音号","§6输入指令: §f/mclive 抖音号",0,20 * 60,20);
}
}

View File

@ -1,16 +1,10 @@
package com.io.yutian.mclive;
package com.io.yutian.mclive.listener;
import cn.hamster3.cdapi.CDTimeAPI;
import com.io.yutian.livemutually.manager.KSLiveRoomManager;
import com.io.yutian.livemutually.wss.KuaiShouUser;
import com.io.yutian.mclive.Util.MessageUtil;
import com.io.yutian.mclive.Main;
import com.io.yutian.mclive.event.LiveConnectEvents;
import com.io.yutian.mclive.event.LiveGiftEvents;
import com.io.yutian.mclive.event.ZhuboAPI;
import com.io.yutian.pixelliveplugin.PixelLiveAPI;
import com.io.yutian.pixelliveplugin.PixelLivePlugin;
import com.io.yutian.pixelliveplugin.event.KeyInputEvent;
import com.io.yutian.pixelliveplugin.event.WSMessageEvent;
import com.io.yutian.verify.AESUtil;
import org.bukkit.*;
import org.bukkit.entity.Player;
@ -93,9 +87,10 @@ public class LiveAdminGui implements Listener {
Main.giftManage.getSqlManager().createAnchorProfile(roomId);
}
Bukkit.getConsoleSender().sendMessage("######CONNECT#####");
player.resetTitle();
Location loc = player.getLocation();
loc.getWorld().playEffect(loc, Effect.MOBSPAWNER_FLAMES, 20);
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS,1,1);
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP,1,1);
}
}
if(rawSlot == 3){
@ -117,6 +112,9 @@ public class LiveAdminGui implements Listener {
player.closeInventory();
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"mclive stop");
}
if(rawSlot == 22){
SoundsMenu.OpenGui(player,1);
}
if(rawSlot == 20){
player.closeInventory();
if(Main.configYml.getRoomId(playName) == null) {
@ -145,10 +143,24 @@ public class LiveAdminGui implements Listener {
inv.setItem(5,Games_Edit());
inv.setItem(18,Stop_LiveLink());
inv.setItem(20,test_Verify(p));
//inv.setItem(22,getLiveRoomId(p));
inv.setItem(22,SoundMenuButt());
p.openInventory(inv);
}
public static ItemStack SoundMenuButt(){
ItemStack item = new ItemStack(Material.DIAMOND);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§d★ §e声音列表");
List<String> lore = new ArrayList<>();
lore.add("§c可通过此界面播放音效");
lore.add(" ");
lore.add("§b★ §6鼠标点击 §7打开界面");
meta.setLore(lore);
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
item.setItemMeta(meta);
return item;
}
public static ItemStack Stop_LiveLink(){
ItemStack item = new ItemStack(Material.FLINT);
ItemMeta meta = item.getItemMeta();

View File

@ -0,0 +1,125 @@
package com.io.yutian.mclive.listener;
import com.io.yutian.mclive.Main;
import de.tr7zw.nbtapi.NBTItem;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
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 SoundsMenu implements Listener {
public static String invTitle = "我的世界整蛊 - 声音列表";
@EventHandler
public void onClick(InventoryClickEvent e){
int rawSlot = e.getRawSlot();
Inventory inv = e.getInventory();
Player p = (Player) e.getWhoClicked();
ItemStack item = e.getCurrentItem();
if(e.getView().getTitle().equalsIgnoreCase(invTitle)){
e.setCancelled(true);
int Pages = e.getInventory().getItem(45).getAmount();
if(e.getRawSlot() == 45){
p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK,1,2);
if(Pages >= 2 && Pages <= 31){
SoundsMenu.OpenGui(p,Pages - 1);
} else {
p.sendMessage("§c[消息]§a已经是第一页了!");
}
}
if(e.getRawSlot() == 53){
p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK,1,2);
if(Pages >= 1 && Pages <= 32){
SoundsMenu.OpenGui(p,Pages + 1);
} else {
p.sendMessage("§c[消息]§a已经是最后一页了!");
}
}
if(rawSlot >= 0 && rawSlot < 45){
if(item != null && item.getType() != Material.AIR) {
NBTItem nbt = new NBTItem(item);
if (nbt.hasKey("sound")) {
String sound = nbt.getString("sound");
p.playSound(p.getLocation(), sound, 1.0F, 1.0F);
p.closeInventory();
new BukkitRunnable() {
@Override
public void run() {
SoundsMenu.OpenGui(p, Pages);
}
}.runTaskLater(Main.plugin, 15L);
}
}
}
}
}
public static List<String> soundList = new ArrayList<>();
public static void OpenGui(Player p,int page){
Inventory inv = Bukkit.createInventory(null,54,invTitle);
for (int i = 45;i < 53;i++){
inv.setItem(i,new ItemStack(Material.WHITE_STAINED_GLASS_PANE));
}
inv.setItem(45,Paper_Butt("§a上一页",page));
inv.setItem(53,Paper_Butt("§a下一页",page));
List<ItemStack> itemStackList = new ArrayList<>();
for (String soundKey : soundList){
ItemStack item = itemShow(soundKey).clone();
itemStackList.add(item);
}
if (itemStackList.size() >= 1) { // 如果物品列表不为空
if (page == 1) { // 如果是第一页
for (int i = 0; i < itemStackList.size(); i++) { // 遍历物品列表
ItemStack item = itemStackList.get(i);
inv.addItem(item); // 添加物品到物品栏
}
} else { // 如果是第二页或之后
int startIndex = 45 * (page - 1); // 计算起始索引
for (int i = startIndex; i < itemStackList.size(); i++) {
ItemStack item = itemStackList.get(i);
inv.addItem(item); // 添加物品到物品栏
}
}
}
p.openInventory(inv);
}
public static ItemStack itemShow(String sound){
ItemStack item = new ItemStack(Material.NOTE_BLOCK);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§6"+sound);
List<String> lore = new ArrayList<>();
lore.add("§7#礼物设置声音处填入 §6"+sound+" §7即可");
lore.add(" ");
lore.add("§a§l★ §6左键点击播放");
meta.setLore(lore);
item.setItemMeta(meta);
NBTItem nbtItem = new NBTItem(item);
nbtItem.setString("sound",sound);
return nbtItem.getItem();
}
public static ItemStack Paper_Butt(String name,int amount){
ItemStack item = new ItemStack(Material.ARROW);
item.setAmount(amount);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(name);
List<String> lore = new ArrayList<>();
lore.add("§a§l★ §7点击翻页 §a§l★");
meta.setLore(lore);
item.setItemMeta(meta);
return item;
}
}

View File

@ -1,8 +1,10 @@
package com.io.yutian.mclive;
package com.io.yutian.mclive.live;
import cn.hamster3.cdapi.CDTimeAPI;
import com.io.yutian.mclive.util.ConfigYml;
import com.io.yutian.mclive.Main;
import com.io.yutian.mclive.data.GiftManage;
import com.io.yutian.mclive.event.*;
import com.io.yutian.mclive.listener.LiveAdminGui;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;

View File

@ -1,9 +1,8 @@
package com.io.yutian.mclive;
package com.io.yutian.mclive.live;
import com.io.yutian.mclive.Util.MessageUtil;
import com.io.yutian.mclive.util.MessageUtil;
import com.io.yutian.pixelliveplugin.event.KeyInputEvent;
import com.io.yutian.pixelliveplugin.event.WSMessageEvent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

View File

@ -1,5 +1,6 @@
package com.io.yutian.mclive;
package com.io.yutian.mclive.util;
import com.io.yutian.mclive.Main;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;

View File

@ -1,4 +1,4 @@
package com.io.yutian.mclive.Util;
package com.io.yutian.mclive.util;
import cn.hamster3.cdapi.CDTimeAPI;
import com.io.yutian.livemutually.manager.GiftData;
@ -7,6 +7,7 @@ import com.io.yutian.livemutually.wss.*;
import com.io.yutian.mclive.Main;
import com.io.yutian.mclive.event.LiveGiftEvents;
import com.io.yutian.mclive.event.ZhuboAPI;
import com.io.yutian.verify.AESUtil;
import json.JSONObject;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -192,15 +193,16 @@ public class MessageUtil {
// Bukkit.getConsoleSender().sendMessage("§6[弹幕监听] " + message);
}
public static HashMap<String, UserData> userDataMap = new HashMap<>();
private static final String AES_KEY = "H8dyaR95ZJwZ6PikZ1qmoIY1"; // 与Python中相同的密钥
// H8dyaR95ZJwZ6PikZ1qmoIY1 密匙
private static final String AES_KEY = "01001000001110000110010001111001011000010101001000111001001101010101101001001010011101110101101000110110010100000110100101101"; // 与Python中相同的密钥
public static String decrypt_ecb(String encryptedMessage) throws Exception {
// Base64解码
byte[] decodedMessage = Base64.getDecoder().decode(encryptedMessage);
// AES解密
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
SecretKeySpec secretKeySpec = new SecretKeySpec(AES_KEY.getBytes(), "AES");
Cipher cipher = Cipher.getInstance(AESUtil.convertString("0100000101000101010100110010111101000101010000110100001000101111010100000100"+AESUtil.DEFAULT_CIPHER_ALGORITHM));
SecretKeySpec secretKeySpec = new SecretKeySpec(AESUtil.convertString(AES_KEY+"0110101101000110001011100010110110101101111010010010101100100110001").getBytes(), "AES");
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
byte[] decryptedBytes = cipher.doFinal(decodedMessage);

View File

@ -1,9 +1,7 @@
package com.io.yutian.mclive.Util;
package com.io.yutian.mclive.util;
import com.io.yutian.mclive.ConfigYml;
import com.io.yutian.mclive.Main;
import com.io.yutian.mclive.data.database.MegumiSQL;
import org.bukkit.Bukkit;
import java.sql.*;

View File

@ -15,7 +15,24 @@ import java.util.Base64;
public class AESUtil {
private static final String KEY_ALGORITHM = "AES";
private static final String DEFAULT_CIPHER_ALGORITHM = "AES/ECB/PKCS5Padding";
// AES/ECB/PKCS5Padding
public static final String DEFAULT_CIPHER_ALGORITHM = "101101000011010100110011010101010000011000010110010001100100011010010110111001100111";
// 将二进制字符串转换为普通字符串
public static String convertString(String binaryString) {
StringBuilder result = new StringBuilder();
// 每8位二进制表示一个字符
for (int i = 0; i < binaryString.length(); i += 8) {
// 获取8位二进制子串
String byteString = binaryString.substring(i, i + 8);
// 将二进制字符串转换为十进制整数
int charCode = Integer.parseInt(byteString, 2);
// 将十进制整数转换为字符
result.append((char) charCode);
}
return result.toString();
}
public static boolean isVerifyCheck(Player p, String pluginName, String roomId){
if(!Main.check_plugin){
@ -51,7 +68,7 @@ public class AESUtil {
public static String encrypt(String content, String key) {
try {
Cipher cipher = Cipher.getInstance(DEFAULT_CIPHER_ALGORITHM);
Cipher cipher = Cipher.getInstance(convertString("0100000101000101010100110010111101000101010000110100001000101111010100000100"+DEFAULT_CIPHER_ALGORITHM));
byte[] byteContent = content.getBytes("utf-8");
cipher.init(Cipher.ENCRYPT_MODE, getSecretKey(key));
byte[] result = cipher.doFinal(byteContent);
@ -63,7 +80,7 @@ public class AESUtil {
public static String decrypt(String content, String key) {
try {
Cipher cipher = Cipher.getInstance(DEFAULT_CIPHER_ALGORITHM);
Cipher cipher = Cipher.getInstance(convertString("0100000101000101010100110010111101000101010000110100001000101111010100000100"+DEFAULT_CIPHER_ALGORITHM));
cipher.init(Cipher.DECRYPT_MODE, getSecretKey(key));
byte[] result = cipher.doFinal(base642Byte(content));
return new String(result, "utf-8");

View File

@ -1,5 +1,5 @@
name: McLiveAPI
version: 1.3.2
version: 5.0
main: com.io.yutian.mclive.Main
api-version: 1.18
author: yutian
@ -8,3 +8,4 @@ softdepend:
- PixelLivePlugin
commands:
mclive:
sounds:

View File

@ -1,5 +1,5 @@
name: McLiveAPI
version: 1.3.2
version: 5.0
main: com.io.yutian.mclive.Main
api-version: 1.18
author: yutian
@ -8,3 +8,4 @@ softdepend:
- PixelLivePlugin
commands:
mclive:
sounds: