From 099ac6af87fe2eff73cd3ba3c5e7d60fff3ec881 Mon Sep 17 00:00:00 2001 From: wisdommen <41609381+wisdommen@users.noreply.github.com> Date: Mon, 25 Dec 2023 14:29:10 +1100 Subject: [PATCH] =?UTF-8?q?2023/12/25=E6=9B=B4=E6=96=B0=20API=E7=89=88?= =?UTF-8?q?=E6=9C=AC6.0.1=20[UltiTools-API]=201.=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=BA=86spigot=201.20.1-1.20.4=202.=E6=B7=BB=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E6=8C=87=E4=BB=A4=E5=9B=BE=E5=BD=A2=E5=8C=96=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E5=8D=B8=E8=BD=BD=E6=A8=A1=E5=9D=97=203.=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E4=BA=86=E9=83=A8=E5=88=86=E6=A8=A1=E5=9D=97=E7=9A=84=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BasicFunctions/pom.xml | 2 +- MysqlConnector/src/main/resources/plugin.yml | 2 +- Sidebar/src/main/resources/plugin.yml | 2 +- UltiTools-API/pom.xml | 2 +- .../com/ultikits/ultitools/UltiTools.java | 5 +- .../abstracts/AbstractCommendExecutor.java | 1 - .../commands/PluginInstallCommands.java | 108 ++++++--- .../ultitools/commands/UltiToolsCommands.java | 2 +- UltiTools-API/src/main/resources/lang/en.json | 9 +- UltiTools-API/src/main/resources/lang/zh.json | 9 +- .../com/ultikits/v1_20_R1/Wrapper1_20_R1.java | 19 -- Versions/1_20_R2/pom.xml | 23 ++ .../com/ultikits/v1_20_R2/Wrapper1_20_R2.java | 207 ++++++++++++++++++ Versions/1_20_R3/pom.xml | 23 ++ .../com/ultikits/v1_20_R3/Wrapper1_20_R3.java | 207 ++++++++++++++++++ Versions/1_20_R4/pom.xml | 23 ++ .../com/ultikits/v1_20_R4/Wrapper1_20_R4.java | 207 ++++++++++++++++++ Versions/pom.xml | 9 +- 18 files changed, 801 insertions(+), 59 deletions(-) create mode 100644 Versions/1_20_R2/pom.xml create mode 100644 Versions/1_20_R2/src/main/java/com/ultikits/v1_20_R2/Wrapper1_20_R2.java create mode 100644 Versions/1_20_R3/pom.xml create mode 100644 Versions/1_20_R3/src/main/java/com/ultikits/v1_20_R3/Wrapper1_20_R3.java create mode 100644 Versions/1_20_R4/pom.xml create mode 100644 Versions/1_20_R4/src/main/java/com/ultikits/v1_20_R4/Wrapper1_20_R4.java diff --git a/BasicFunctions/pom.xml b/BasicFunctions/pom.xml index 85174da..e1696a8 100644 --- a/BasicFunctions/pom.xml +++ b/BasicFunctions/pom.xml @@ -74,7 +74,7 @@ ultitools-maven-plugin 1.0.0 - Basic Functions + BasicFunctions UltiTools-Basic-Functions All basic functions of the UltiTools access_key.txt diff --git a/MysqlConnector/src/main/resources/plugin.yml b/MysqlConnector/src/main/resources/plugin.yml index 6a38f2e..94cd852 100644 --- a/MysqlConnector/src/main/resources/plugin.yml +++ b/MysqlConnector/src/main/resources/plugin.yml @@ -1,4 +1,4 @@ -name: UltiTools-MysqlConnector +name: MysqlConnector version: '${project.version}' main: com.ultikits.plugins.mysqlconnector.MysqlConnector api-version: 600 diff --git a/Sidebar/src/main/resources/plugin.yml b/Sidebar/src/main/resources/plugin.yml index ce04820..fc2cbba 100644 --- a/Sidebar/src/main/resources/plugin.yml +++ b/Sidebar/src/main/resources/plugin.yml @@ -1,4 +1,4 @@ -name: UltiTools-SidebarPlugin +name: Sidebar version: '${project.version}' main: com.ultikits.plugins.sidebar.SidebarPlugin api-version: 600 diff --git a/UltiTools-API/pom.xml b/UltiTools-API/pom.xml index 6461463..7eb5e25 100755 --- a/UltiTools-API/pom.xml +++ b/UltiTools-API/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> UltiTools-API com.ultikits - 6.0.0.202312150106 + 6.0.1 4.0.0 UltiTools-API This project is the base of the Ultitools plugin development. diff --git a/UltiTools-API/src/main/java/com/ultikits/ultitools/UltiTools.java b/UltiTools-API/src/main/java/com/ultikits/ultitools/UltiTools.java index 478fc74..79fc77a 100755 --- a/UltiTools-API/src/main/java/com/ultikits/ultitools/UltiTools.java +++ b/UltiTools-API/src/main/java/com/ultikits/ultitools/UltiTools.java @@ -3,6 +3,7 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.json.JSON; import cn.hutool.json.JSONUtil; +import com.ultikits.ultitools.abstracts.UltiToolsPlugin; import com.ultikits.ultitools.context.ContextConfig; import com.ultikits.ultitools.commands.PluginInstallCommands; import com.ultikits.ultitools.commands.UltiToolsCommands; @@ -37,7 +38,7 @@ * UltiTools plugin main class. * * @author wisdommen, qianmo - * @version 6.0.0 + * @version 6.0.1 */ public final class UltiTools extends JavaPlugin implements Localized { private static UltiTools ultiTools; @@ -78,7 +79,7 @@ public static UltiTools getInstance() { * @return the version of the UltiTools */ public static int getPluginVersion() { - return 600; + return 601; } /** diff --git a/UltiTools-API/src/main/java/com/ultikits/ultitools/abstracts/AbstractCommendExecutor.java b/UltiTools-API/src/main/java/com/ultikits/ultitools/abstracts/AbstractCommendExecutor.java index 1d9e1ea..b09cefc 100644 --- a/UltiTools-API/src/main/java/com/ultikits/ultitools/abstracts/AbstractCommendExecutor.java +++ b/UltiTools-API/src/main/java/com/ultikits/ultitools/abstracts/AbstractCommendExecutor.java @@ -259,7 +259,6 @@ private Object[] parseParams(String[] strings, Method method, CommandSender comm CmdParam cmdParam = parameter.getAnnotation(CmdParam.class); String value = params.get(cmdParam.value()); try { - if (parameter.getType() == float.class || parameter.getType() == Float.class) { ParamList.add(Float.parseFloat(value)); continue; diff --git a/UltiTools-API/src/main/java/com/ultikits/ultitools/commands/PluginInstallCommands.java b/UltiTools-API/src/main/java/com/ultikits/ultitools/commands/PluginInstallCommands.java index 5c19186..34bb7cd 100644 --- a/UltiTools-API/src/main/java/com/ultikits/ultitools/commands/PluginInstallCommands.java +++ b/UltiTools-API/src/main/java/com/ultikits/ultitools/commands/PluginInstallCommands.java @@ -2,11 +2,18 @@ import com.ultikits.ultitools.UltiTools; import com.ultikits.ultitools.abstracts.AbstractCommendExecutor; +import com.ultikits.ultitools.abstracts.UltiToolsPlugin; import com.ultikits.ultitools.annotations.command.*; import com.ultikits.ultitools.entities.PluginEntity; +import com.ultikits.ultitools.utils.MessageUtils; import com.ultikits.ultitools.utils.PluginInstallUtils; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TextComponent; +import net.kyori.adventure.text.event.ClickEvent; +import net.kyori.adventure.text.format.TextColor; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import java.io.IOException; @@ -25,33 +32,84 @@ public void listPlugins(@CmdSender CommandSender sender, @CmdParam("page") Strin } catch (NumberFormatException ignored) { } } + List installedPlugins = UltiTools.getInstance().getPluginManager().getPluginList(); List plugins = PluginInstallUtils.getPluginList(pageInt, 10); - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(UltiTools.getInstance().i18n("========|可用插件列表|========\n")); - int i = 1; - for (PluginEntity plugin : plugins) { - stringBuilder.append(i); - stringBuilder.append(UltiTools.getInstance().i18n(". 名字:")); - stringBuilder.append(plugin.getName()); - stringBuilder.append("\n"); - stringBuilder.append(UltiTools.getInstance().i18n(" 安装命令:/upm install ")); - stringBuilder.append(plugin.getIdentifyString()); - stringBuilder.append("\n"); - stringBuilder.append(UltiTools.getInstance().i18n(" 简介:")); - stringBuilder.append(plugin.getShortDescription()); - stringBuilder.append("\n"); - if (i < plugins.size()) { - stringBuilder.append("---------------------\n"); + if (sender instanceof Player) { + TextComponent text = Component.text(UltiTools.getInstance().i18n("========|可用插件列表|========\n")) + .color(TextColor.color(0x00ffff)); + int i = 1; + for (PluginEntity plugin : plugins) { + text = text.append(Component.text(i + UltiTools.getInstance().i18n(". 名字:") + plugin.getName() + "\n").color(TextColor.color(0x00ffff))); + text = text.append(Component.text(UltiTools.getInstance().i18n(" 安装状态:")).color(TextColor.color(127, 127, 127))); + boolean installed = false; + for (UltiToolsPlugin installedPlugin : installedPlugins) { + if (installedPlugin.getPluginName().equals(plugin.getName())) { + installed = true; + break; + } + } + if (installed) { + text = text.append(Component.text(UltiTools.getInstance().i18n(" 已安装") + "\n").color(TextColor.color(0x00ff00))); + text = text.append( + Component + .text(UltiTools.getInstance().i18n(" | 卸载 | ") + "\n") + .color(TextColor.color(255, 0, 0)) + .hoverEvent(Component.text(UltiTools.getInstance().i18n("点击卸载模块"))) + .clickEvent(ClickEvent.runCommand("/upm uninstall " + plugin.getName())) + ); + } else { + text = text.append(Component.text(UltiTools.getInstance().i18n(" 未安装") + "\n").color(TextColor.color(0xff0000))); + text = text.append( + Component + .text(UltiTools.getInstance().i18n(" | 安装 | ") + "\n") + .color(TextColor.color(0, 255, 0)) + .hoverEvent(Component.text(UltiTools.getInstance().i18n("点击安装模块"))) + .clickEvent(ClickEvent.runCommand("/upm install " + plugin.getIdentifyString())) + ); + } + text = text.append(Component.text(UltiTools.getInstance().i18n(" 简介:") + plugin.getShortDescription() + "\n").color(TextColor.color(127, 127, 127))); + if (i < plugins.size()) { + text = text.append(Component.text("---------------------\n").color(TextColor.color(0x00ffff))); + } + i++; } - i++; - } - stringBuilder.append(String.format(UltiTools.getInstance().i18n("======== 第%d页 ========"), pageInt)); - new BukkitRunnable() { - @Override - public void run() { - sender.sendMessage(stringBuilder.toString()); + text = text.append(Component.text(String.format(UltiTools.getInstance().i18n("======== 第%d页 ========"), pageInt)) + .color(TextColor.color(0x00ffff))); + TextComponent finalText = text; + new BukkitRunnable() { + @Override + public void run() { + MessageUtils.sendMessage((Player) sender, finalText); + } + }.runTask(UltiTools.getInstance()); + } else { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(UltiTools.getInstance().i18n("========|可用插件列表|========\n")); + int i = 1; + for (PluginEntity plugin : plugins) { + stringBuilder.append(i); + stringBuilder.append(UltiTools.getInstance().i18n(". 名字:")); + stringBuilder.append(plugin.getName()); + stringBuilder.append("\n"); + stringBuilder.append(UltiTools.getInstance().i18n(" 安装命令:/upm install ")); + stringBuilder.append(plugin.getIdentifyString()); + stringBuilder.append("\n"); + stringBuilder.append(UltiTools.getInstance().i18n(" 简介:")); + stringBuilder.append(plugin.getShortDescription()); + stringBuilder.append("\n"); + if (i < plugins.size()) { + stringBuilder.append("---------------------\n"); + } + i++; } - }.runTask(UltiTools.getInstance()); + stringBuilder.append(String.format(UltiTools.getInstance().i18n("======== 第%d页 ========"), pageInt)); + new BukkitRunnable() { + @Override + public void run() { + sender.sendMessage(stringBuilder.toString()); + } + }.runTask(UltiTools.getInstance()); + } } @CmdMapping(format = "list") @@ -96,7 +154,7 @@ public void listVersions(@CmdSender CommandSender sender, @CmdParam("plugin") St if (i1 == pluginVersions.size()) { stringBuilder.append(UltiTools.getInstance().i18n(" 安装命令:/upm install ")); stringBuilder.append(plugin); - stringBuilder.append(" [版本]"); + stringBuilder.append(" [version]"); stringBuilder.append("\n"); stringBuilder.append("---------------------\n"); } diff --git a/UltiTools-API/src/main/java/com/ultikits/ultitools/commands/UltiToolsCommands.java b/UltiTools-API/src/main/java/com/ultikits/ultitools/commands/UltiToolsCommands.java index b07910d..bc188db 100644 --- a/UltiTools-API/src/main/java/com/ultikits/ultitools/commands/UltiToolsCommands.java +++ b/UltiTools-API/src/main/java/com/ultikits/ultitools/commands/UltiToolsCommands.java @@ -19,7 +19,7 @@ * @version 1.0.0 */ @CmdExecutor(description = "UltiToolsCommands" ,alias = {"ul", "ultitools", "ulti"}, requireOp = true) -@CmdTarget(CmdTarget.CmdTargetType.CONSOLE) +@CmdTarget(CmdTarget.CmdTargetType.BOTH) public class UltiToolsCommands extends AbstractCommendExecutor { @CmdMapping(format = "reload") public void reloadPlugins() { diff --git a/UltiTools-API/src/main/resources/lang/en.json b/UltiTools-API/src/main/resources/lang/en.json index 68ec734..5a195eb 100644 --- a/UltiTools-API/src/main/resources/lang/en.json +++ b/UltiTools-API/src/main/resources/lang/en.json @@ -38,5 +38,12 @@ "卸载成功!请手动删除本地文件,否则重启之后还会启用!": "Uninstalled! Please delete local files manually, otherwise it will be enabled after restart!", "文件位置:%s": "File Location: %s", "卸载失败!请检查是否拼写正确!": "Uninstall Failed! Please check if the spelling is correct!", - "删除失败!文件访问错误!请手动删除!": "Delete Failed! File access error! Please delete it manually!" + "删除失败!文件访问错误!请手动删除!": "Delete Failed! File access error! Please delete it manually!", + " 安装状态:": " Install Status:", + "已安装": "Installed", + "未安装": "Not Installed", + " | 安装 | ": " | Install | ", + " | 卸载 | ": " | Uninstall | ", + "点击卸载模块": "Click to uninstall module", + "点击安装模块": "Click to install module" } diff --git a/UltiTools-API/src/main/resources/lang/zh.json b/UltiTools-API/src/main/resources/lang/zh.json index 9c31c2a..2a9ff6f 100644 --- a/UltiTools-API/src/main/resources/lang/zh.json +++ b/UltiTools-API/src/main/resources/lang/zh.json @@ -21,5 +21,12 @@ "请先等待其他玩家发送的命令执行完毕!": "请先等待其他玩家发送的命令执行完毕!", "操作频繁,请稍后再试": "操作频繁,请稍后再试", "参数 '%s' 格式错误:'%s' 不是一个有效的 %s 类型": "参数 '%s' 格式错误:'%s' 不是一个有效的 %s 类型", - "=== UltiTools 命令列表 ===\n/ul reload 重载插件模块\n/ul list 查看已加载的模块列表\n================": "=== UltiTools 命令列表 ===\n/ul reload 重载插件模块\n/ul list 查看已加载的模块列表\n================" + "=== UltiTools 命令列表 ===\n/ul reload 重载插件模块\n/ul list 查看已加载的模块列表\n================": "=== UltiTools 命令列表 ===\n/ul reload 重载插件模块\n/ul list 查看已加载的模块列表\n================", + " 安装状态:": " 安装状态:", + "已安装": "已安装", + "未安装": "未安装", + " | 安装 | ": " | 安装 | ", + " | 卸载 | ": " | 卸载 | ", + "点击卸载模块": "点击卸载模块", + "点击安装模块": "点击安装模块" } diff --git a/Versions/1_20_R1/src/main/java/com/ultikits/v1_20_R1/Wrapper1_20_R1.java b/Versions/1_20_R1/src/main/java/com/ultikits/v1_20_R1/Wrapper1_20_R1.java index 75c719b..324c005 100644 --- a/Versions/1_20_R1/src/main/java/com/ultikits/v1_20_R1/Wrapper1_20_R1.java +++ b/Versions/1_20_R1/src/main/java/com/ultikits/v1_20_R1/Wrapper1_20_R1.java @@ -3,15 +3,12 @@ import com.ultikits.ultitools.entities.Colors; import com.ultikits.ultitools.entities.Sounds; import com.ultikits.ultitools.interfaces.VersionWrapper; -import io.netty.channel.Channel; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.ComponentBuilder; -import net.minecraft.network.NetworkManager; import net.minecraft.network.chat.IChatBaseComponent; import net.minecraft.network.protocol.game.ClientboundSystemChatPacket; import net.minecraft.network.protocol.game.PacketPlayOutPlayerListHeaderFooter; -import net.minecraft.server.network.PlayerConnection; import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.Sound; @@ -207,20 +204,4 @@ public BlockFace getBlockFace(Block placedBlock) { BlockData blockData = placedBlock.getBlockData(); return ((Directional) blockData).getFacing(); } - - public PlayerConnection getPlayerConnection(Player player) { - return null; - } - - public NetworkManager getNetworkManager(Player player) { - return null; - } - - public Channel getChannel(Player player) { - return null; - } - - public Object getHandle(Player player) { - return ((CraftPlayer) player).getHandle(); - } } diff --git a/Versions/1_20_R2/pom.xml b/Versions/1_20_R2/pom.xml new file mode 100644 index 0000000..42231a7 --- /dev/null +++ b/Versions/1_20_R2/pom.xml @@ -0,0 +1,23 @@ + + + + com.ultikits.versions + Versions + 1.0-SNAPSHOT + + 4.0.0 + + 1_20_R2 + + + + org.spigotmc + spigot + 1.20.2-R0.1-SNAPSHOT + provided + + + + diff --git a/Versions/1_20_R2/src/main/java/com/ultikits/v1_20_R2/Wrapper1_20_R2.java b/Versions/1_20_R2/src/main/java/com/ultikits/v1_20_R2/Wrapper1_20_R2.java new file mode 100644 index 0000000..a53e330 --- /dev/null +++ b/Versions/1_20_R2/src/main/java/com/ultikits/v1_20_R2/Wrapper1_20_R2.java @@ -0,0 +1,207 @@ +package com.ultikits.v1_20_R2; + +import com.ultikits.ultitools.entities.Colors; +import com.ultikits.ultitools.entities.Sounds; +import com.ultikits.ultitools.interfaces.VersionWrapper; +import net.md_5.bungee.api.ChatMessageType; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.minecraft.network.chat.IChatBaseComponent; +import net.minecraft.network.protocol.game.ClientboundSystemChatPacket; +import net.minecraft.network.protocol.game.PacketPlayOutPlayerListHeaderFooter; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Directional; +import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.Damageable; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Scoreboard; + +import java.util.Objects; + +public class Wrapper1_20_R2 implements VersionWrapper { + + public ItemStack getColoredPlaneGlass(Colors plane) { + switch (plane) { + case RED: + return new ItemStack(Material.RED_STAINED_GLASS_PANE); + case BLUE: + return new ItemStack(Material.BLUE_STAINED_GLASS_PANE); + case CYAN: + return new ItemStack(Material.CYAN_STAINED_GLASS_PANE); + case GRAY: + return new ItemStack(Material.GRAY_STAINED_GLASS_PANE); + case LIME: + return new ItemStack(Material.LIME_STAINED_GLASS_PANE); + case PINK: + return new ItemStack(Material.PINK_STAINED_GLASS_PANE); + case BLACK: + return new ItemStack(Material.BLACK_STAINED_GLASS_PANE); + case BROWN: + return new ItemStack(Material.BROWN_STAINED_GLASS_PANE); + case GREEN: + return new ItemStack(Material.GREEN_STAINED_GLASS_PANE); + case WHITE: + return new ItemStack(Material.WHITE_STAINED_GLASS_PANE); + case ORANGE: + return new ItemStack(Material.ORANGE_STAINED_GLASS_PANE); + case PURPLE: + return new ItemStack(Material.PURPLE_STAINED_GLASS_PANE); + case YELLOW: + return new ItemStack(Material.YELLOW_STAINED_GLASS_PANE); + case MAGENTA: + return new ItemStack(Material.MAGENTA_STAINED_GLASS_PANE); + case LIGHT_BLUE: + return new ItemStack(Material.LIGHT_BLUE_STAINED_GLASS_PANE); + case LIGHT_GRAY: + return new ItemStack(Material.LIGHT_GRAY_STAINED_GLASS_PANE); + default: + return null; + } + } + + public ItemStack getSign() { + return new ItemStack(Material.OAK_SIGN, 1); + } + + public ItemStack getEndEye() { + return new ItemStack(Material.ENDER_EYE, 1); + } + + public ItemStack getEmailMaterial(boolean isRead) { + if (isRead) { + return new ItemStack(Material.FILLED_MAP, 1); + } else { + return new ItemStack(Material.PAPER, 1); + } + } + + public ItemStack getHead(OfflinePlayer player) { + if (player.isOp()) { + return new ItemStack(Material.DRAGON_HEAD); + } else { + return new ItemStack(Material.PLAYER_HEAD); + } + } + + public ItemStack getGrassBlock() { + return new ItemStack(Material.GRASS_BLOCK, 1); + } + + public Objective registerNewObjective(Scoreboard scoreboard, String name, String criteria, String displayName) { + Objective objective = scoreboard.getObjective(name); + if (objective == null) { + objective = scoreboard.registerNewObjective(name, criteria, displayName); + } + return objective; + } + + public Sound getSound(Sounds sound) { + switch (sound) { + case UI_TOAST_OUT: + return Sound.UI_TOAST_OUT; + case BLOCK_CHEST_OPEN: + return Sound.BLOCK_CHEST_OPEN; + case BLOCK_CHEST_LOCKED: + return Sound.BLOCK_CHEST_LOCKED; + case ITEM_BOOK_PAGE_TURN: + return Sound.ITEM_BOOK_PAGE_TURN; + case BLOCK_NOTE_BLOCK_HAT: + return Sound.BLOCK_NOTE_BLOCK_HAT; + case BLOCK_NOTE_BLOCK_BELL: + return Sound.BLOCK_NOTE_BLOCK_BELL; + case BLOCK_WET_GRASS_BREAK: + return Sound.BLOCK_WET_GRASS_BREAK; + case BLOCK_NOTE_BLOCK_CHIME: + return Sound.BLOCK_NOTE_BLOCK_CHIME; + case ENTITY_ENDERMAN_TELEPORT: + return Sound.ENTITY_ENDERMAN_TELEPORT; + case BLOCK_CHEST_CLOSE: + return Sound.BLOCK_CHEST_CLOSE; + default: + return null; + } + } + + public ItemStack getBed(Colors bedColor) { + switch (bedColor) { + case RED: + return new ItemStack(Material.RED_BED); + case BLUE: + return new ItemStack(Material.BLUE_BED); + case CYAN: + return new ItemStack(Material.CYAN_BED); + case GRAY: + return new ItemStack(Material.GRAY_BED); + case LIME: + return new ItemStack(Material.LIME_BED); + case PINK: + return new ItemStack(Material.PINK_BED); + case BLACK: + return new ItemStack(Material.BLACK_BED); + case BROWN: + return new ItemStack(Material.BROWN_BED); + case GREEN: + return new ItemStack(Material.GREEN_BED); + case WHITE: + return new ItemStack(Material.WHITE_BED); + case ORANGE: + return new ItemStack(Material.ORANGE_BED); + case PURPLE: + return new ItemStack(Material.PURPLE_BED); + case YELLOW: + return new ItemStack(Material.YELLOW_BED); + case MAGENTA: + return new ItemStack(Material.MAGENTA_BED); + case LIGHT_BLUE: + return new ItemStack(Material.LIGHT_BLUE_BED); + case LIGHT_GRAY: + return new ItemStack(Material.LIGHT_GRAY_BED); + default: + return null; + } + } + + public int getItemDurability(ItemStack itemStack) { + return itemStack.getType().getMaxDurability() - ((Damageable) Objects.requireNonNull(itemStack.getItemMeta())).getDamage(); + } + + public ItemStack getItemInHand(Player player, boolean isMainHand) { + if (isMainHand) { + return player.getInventory().getItemInMainHand(); + } else { + return player.getInventory().getItemInOffHand(); + } + } + + public void sendActionBar(Player player, String message) { + try { + IChatBaseComponent iChatBaseComponent = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + message + "\"}"); + ClientboundSystemChatPacket packetPlayOutChat = new ClientboundSystemChatPacket(iChatBaseComponent, true); + ((CraftPlayer) player).getHandle().c.a(packetPlayOutChat); + } catch (Exception e) { + //Spigot 下解决 No Such Method Error + BaseComponent[] baseComponents = new ComponentBuilder(message).create(); + player.spigot().sendMessage(ChatMessageType.ACTION_BAR, baseComponents); + } + } + + public void sendPlayerList(Player player, String header, String footer) { + IChatBaseComponent tabHeader = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + header + "\"}"); + IChatBaseComponent tabFooter = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + footer + "\"}"); + PacketPlayOutPlayerListHeaderFooter tabPacket = new PacketPlayOutPlayerListHeaderFooter(tabHeader, tabFooter); + ((CraftPlayer) player).getHandle().c.a(tabPacket); + } + + @Override + public BlockFace getBlockFace(Block placedBlock) { + BlockData blockData = placedBlock.getBlockData(); + return ((Directional) blockData).getFacing(); + } +} diff --git a/Versions/1_20_R3/pom.xml b/Versions/1_20_R3/pom.xml new file mode 100644 index 0000000..ffd6e27 --- /dev/null +++ b/Versions/1_20_R3/pom.xml @@ -0,0 +1,23 @@ + + + + com.ultikits.versions + Versions + 1.0-SNAPSHOT + + 4.0.0 + + 1_20_R3 + + + + org.spigotmc + spigot + 1.20.3-R0.1-SNAPSHOT + provided + + + + diff --git a/Versions/1_20_R3/src/main/java/com/ultikits/v1_20_R3/Wrapper1_20_R3.java b/Versions/1_20_R3/src/main/java/com/ultikits/v1_20_R3/Wrapper1_20_R3.java new file mode 100644 index 0000000..b16d992 --- /dev/null +++ b/Versions/1_20_R3/src/main/java/com/ultikits/v1_20_R3/Wrapper1_20_R3.java @@ -0,0 +1,207 @@ +package com.ultikits.v1_20_R3; + +import com.ultikits.ultitools.entities.Colors; +import com.ultikits.ultitools.entities.Sounds; +import com.ultikits.ultitools.interfaces.VersionWrapper; +import net.md_5.bungee.api.ChatMessageType; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.minecraft.network.chat.IChatBaseComponent; +import net.minecraft.network.protocol.game.ClientboundSystemChatPacket; +import net.minecraft.network.protocol.game.PacketPlayOutPlayerListHeaderFooter; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Directional; +import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.Damageable; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Scoreboard; + +import java.util.Objects; + +public class Wrapper1_20_R3 implements VersionWrapper { + + public ItemStack getColoredPlaneGlass(Colors plane) { + switch (plane) { + case RED: + return new ItemStack(Material.RED_STAINED_GLASS_PANE); + case BLUE: + return new ItemStack(Material.BLUE_STAINED_GLASS_PANE); + case CYAN: + return new ItemStack(Material.CYAN_STAINED_GLASS_PANE); + case GRAY: + return new ItemStack(Material.GRAY_STAINED_GLASS_PANE); + case LIME: + return new ItemStack(Material.LIME_STAINED_GLASS_PANE); + case PINK: + return new ItemStack(Material.PINK_STAINED_GLASS_PANE); + case BLACK: + return new ItemStack(Material.BLACK_STAINED_GLASS_PANE); + case BROWN: + return new ItemStack(Material.BROWN_STAINED_GLASS_PANE); + case GREEN: + return new ItemStack(Material.GREEN_STAINED_GLASS_PANE); + case WHITE: + return new ItemStack(Material.WHITE_STAINED_GLASS_PANE); + case ORANGE: + return new ItemStack(Material.ORANGE_STAINED_GLASS_PANE); + case PURPLE: + return new ItemStack(Material.PURPLE_STAINED_GLASS_PANE); + case YELLOW: + return new ItemStack(Material.YELLOW_STAINED_GLASS_PANE); + case MAGENTA: + return new ItemStack(Material.MAGENTA_STAINED_GLASS_PANE); + case LIGHT_BLUE: + return new ItemStack(Material.LIGHT_BLUE_STAINED_GLASS_PANE); + case LIGHT_GRAY: + return new ItemStack(Material.LIGHT_GRAY_STAINED_GLASS_PANE); + default: + return null; + } + } + + public ItemStack getSign() { + return new ItemStack(Material.OAK_SIGN, 1); + } + + public ItemStack getEndEye() { + return new ItemStack(Material.ENDER_EYE, 1); + } + + public ItemStack getEmailMaterial(boolean isRead) { + if (isRead) { + return new ItemStack(Material.FILLED_MAP, 1); + } else { + return new ItemStack(Material.PAPER, 1); + } + } + + public ItemStack getHead(OfflinePlayer player) { + if (player.isOp()) { + return new ItemStack(Material.DRAGON_HEAD); + } else { + return new ItemStack(Material.PLAYER_HEAD); + } + } + + public ItemStack getGrassBlock() { + return new ItemStack(Material.GRASS_BLOCK, 1); + } + + public Objective registerNewObjective(Scoreboard scoreboard, String name, String criteria, String displayName) { + Objective objective = scoreboard.getObjective(name); + if (objective == null) { + objective = scoreboard.registerNewObjective(name, criteria, displayName); + } + return objective; + } + + public Sound getSound(Sounds sound) { + switch (sound) { + case UI_TOAST_OUT: + return Sound.UI_TOAST_OUT; + case BLOCK_CHEST_OPEN: + return Sound.BLOCK_CHEST_OPEN; + case BLOCK_CHEST_LOCKED: + return Sound.BLOCK_CHEST_LOCKED; + case ITEM_BOOK_PAGE_TURN: + return Sound.ITEM_BOOK_PAGE_TURN; + case BLOCK_NOTE_BLOCK_HAT: + return Sound.BLOCK_NOTE_BLOCK_HAT; + case BLOCK_NOTE_BLOCK_BELL: + return Sound.BLOCK_NOTE_BLOCK_BELL; + case BLOCK_WET_GRASS_BREAK: + return Sound.BLOCK_WET_GRASS_BREAK; + case BLOCK_NOTE_BLOCK_CHIME: + return Sound.BLOCK_NOTE_BLOCK_CHIME; + case ENTITY_ENDERMAN_TELEPORT: + return Sound.ENTITY_ENDERMAN_TELEPORT; + case BLOCK_CHEST_CLOSE: + return Sound.BLOCK_CHEST_CLOSE; + default: + return null; + } + } + + public ItemStack getBed(Colors bedColor) { + switch (bedColor) { + case RED: + return new ItemStack(Material.RED_BED); + case BLUE: + return new ItemStack(Material.BLUE_BED); + case CYAN: + return new ItemStack(Material.CYAN_BED); + case GRAY: + return new ItemStack(Material.GRAY_BED); + case LIME: + return new ItemStack(Material.LIME_BED); + case PINK: + return new ItemStack(Material.PINK_BED); + case BLACK: + return new ItemStack(Material.BLACK_BED); + case BROWN: + return new ItemStack(Material.BROWN_BED); + case GREEN: + return new ItemStack(Material.GREEN_BED); + case WHITE: + return new ItemStack(Material.WHITE_BED); + case ORANGE: + return new ItemStack(Material.ORANGE_BED); + case PURPLE: + return new ItemStack(Material.PURPLE_BED); + case YELLOW: + return new ItemStack(Material.YELLOW_BED); + case MAGENTA: + return new ItemStack(Material.MAGENTA_BED); + case LIGHT_BLUE: + return new ItemStack(Material.LIGHT_BLUE_BED); + case LIGHT_GRAY: + return new ItemStack(Material.LIGHT_GRAY_BED); + default: + return null; + } + } + + public int getItemDurability(ItemStack itemStack) { + return itemStack.getType().getMaxDurability() - ((Damageable) Objects.requireNonNull(itemStack.getItemMeta())).getDamage(); + } + + public ItemStack getItemInHand(Player player, boolean isMainHand) { + if (isMainHand) { + return player.getInventory().getItemInMainHand(); + } else { + return player.getInventory().getItemInOffHand(); + } + } + + public void sendActionBar(Player player, String message) { + try { + IChatBaseComponent iChatBaseComponent = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + message + "\"}"); + ClientboundSystemChatPacket packetPlayOutChat = new ClientboundSystemChatPacket(iChatBaseComponent, true); + ((CraftPlayer) player).getHandle().c.a(packetPlayOutChat); + } catch (Exception e) { + //Spigot 下解决 No Such Method Error + BaseComponent[] baseComponents = new ComponentBuilder(message).create(); + player.spigot().sendMessage(ChatMessageType.ACTION_BAR, baseComponents); + } + } + + public void sendPlayerList(Player player, String header, String footer) { + IChatBaseComponent tabHeader = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + header + "\"}"); + IChatBaseComponent tabFooter = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + footer + "\"}"); + PacketPlayOutPlayerListHeaderFooter tabPacket = new PacketPlayOutPlayerListHeaderFooter(tabHeader, tabFooter); + ((CraftPlayer) player).getHandle().c.a(tabPacket); + } + + @Override + public BlockFace getBlockFace(Block placedBlock) { + BlockData blockData = placedBlock.getBlockData(); + return ((Directional) blockData).getFacing(); + } +} diff --git a/Versions/1_20_R4/pom.xml b/Versions/1_20_R4/pom.xml new file mode 100644 index 0000000..26ce7bf --- /dev/null +++ b/Versions/1_20_R4/pom.xml @@ -0,0 +1,23 @@ + + + + com.ultikits.versions + Versions + 1.0-SNAPSHOT + + 4.0.0 + + 1_20_R4 + + + + org.spigotmc + spigot + 1.20.4-R0.1-SNAPSHOT + provided + + + + diff --git a/Versions/1_20_R4/src/main/java/com/ultikits/v1_20_R4/Wrapper1_20_R4.java b/Versions/1_20_R4/src/main/java/com/ultikits/v1_20_R4/Wrapper1_20_R4.java new file mode 100644 index 0000000..c947be0 --- /dev/null +++ b/Versions/1_20_R4/src/main/java/com/ultikits/v1_20_R4/Wrapper1_20_R4.java @@ -0,0 +1,207 @@ +package com.ultikits.v1_20_R4; + +import com.ultikits.ultitools.entities.Colors; +import com.ultikits.ultitools.entities.Sounds; +import com.ultikits.ultitools.interfaces.VersionWrapper; +import net.md_5.bungee.api.ChatMessageType; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.minecraft.network.chat.IChatBaseComponent; +import net.minecraft.network.protocol.game.ClientboundSystemChatPacket; +import net.minecraft.network.protocol.game.PacketPlayOutPlayerListHeaderFooter; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Directional; +import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.Damageable; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Scoreboard; + +import java.util.Objects; + +public class Wrapper1_20_R4 implements VersionWrapper { + + public ItemStack getColoredPlaneGlass(Colors plane) { + switch (plane) { + case RED: + return new ItemStack(Material.RED_STAINED_GLASS_PANE); + case BLUE: + return new ItemStack(Material.BLUE_STAINED_GLASS_PANE); + case CYAN: + return new ItemStack(Material.CYAN_STAINED_GLASS_PANE); + case GRAY: + return new ItemStack(Material.GRAY_STAINED_GLASS_PANE); + case LIME: + return new ItemStack(Material.LIME_STAINED_GLASS_PANE); + case PINK: + return new ItemStack(Material.PINK_STAINED_GLASS_PANE); + case BLACK: + return new ItemStack(Material.BLACK_STAINED_GLASS_PANE); + case BROWN: + return new ItemStack(Material.BROWN_STAINED_GLASS_PANE); + case GREEN: + return new ItemStack(Material.GREEN_STAINED_GLASS_PANE); + case WHITE: + return new ItemStack(Material.WHITE_STAINED_GLASS_PANE); + case ORANGE: + return new ItemStack(Material.ORANGE_STAINED_GLASS_PANE); + case PURPLE: + return new ItemStack(Material.PURPLE_STAINED_GLASS_PANE); + case YELLOW: + return new ItemStack(Material.YELLOW_STAINED_GLASS_PANE); + case MAGENTA: + return new ItemStack(Material.MAGENTA_STAINED_GLASS_PANE); + case LIGHT_BLUE: + return new ItemStack(Material.LIGHT_BLUE_STAINED_GLASS_PANE); + case LIGHT_GRAY: + return new ItemStack(Material.LIGHT_GRAY_STAINED_GLASS_PANE); + default: + return null; + } + } + + public ItemStack getSign() { + return new ItemStack(Material.OAK_SIGN, 1); + } + + public ItemStack getEndEye() { + return new ItemStack(Material.ENDER_EYE, 1); + } + + public ItemStack getEmailMaterial(boolean isRead) { + if (isRead) { + return new ItemStack(Material.FILLED_MAP, 1); + } else { + return new ItemStack(Material.PAPER, 1); + } + } + + public ItemStack getHead(OfflinePlayer player) { + if (player.isOp()) { + return new ItemStack(Material.DRAGON_HEAD); + } else { + return new ItemStack(Material.PLAYER_HEAD); + } + } + + public ItemStack getGrassBlock() { + return new ItemStack(Material.GRASS_BLOCK, 1); + } + + public Objective registerNewObjective(Scoreboard scoreboard, String name, String criteria, String displayName) { + Objective objective = scoreboard.getObjective(name); + if (objective == null) { + objective = scoreboard.registerNewObjective(name, criteria, displayName); + } + return objective; + } + + public Sound getSound(Sounds sound) { + switch (sound) { + case UI_TOAST_OUT: + return Sound.UI_TOAST_OUT; + case BLOCK_CHEST_OPEN: + return Sound.BLOCK_CHEST_OPEN; + case BLOCK_CHEST_LOCKED: + return Sound.BLOCK_CHEST_LOCKED; + case ITEM_BOOK_PAGE_TURN: + return Sound.ITEM_BOOK_PAGE_TURN; + case BLOCK_NOTE_BLOCK_HAT: + return Sound.BLOCK_NOTE_BLOCK_HAT; + case BLOCK_NOTE_BLOCK_BELL: + return Sound.BLOCK_NOTE_BLOCK_BELL; + case BLOCK_WET_GRASS_BREAK: + return Sound.BLOCK_WET_GRASS_BREAK; + case BLOCK_NOTE_BLOCK_CHIME: + return Sound.BLOCK_NOTE_BLOCK_CHIME; + case ENTITY_ENDERMAN_TELEPORT: + return Sound.ENTITY_ENDERMAN_TELEPORT; + case BLOCK_CHEST_CLOSE: + return Sound.BLOCK_CHEST_CLOSE; + default: + return null; + } + } + + public ItemStack getBed(Colors bedColor) { + switch (bedColor) { + case RED: + return new ItemStack(Material.RED_BED); + case BLUE: + return new ItemStack(Material.BLUE_BED); + case CYAN: + return new ItemStack(Material.CYAN_BED); + case GRAY: + return new ItemStack(Material.GRAY_BED); + case LIME: + return new ItemStack(Material.LIME_BED); + case PINK: + return new ItemStack(Material.PINK_BED); + case BLACK: + return new ItemStack(Material.BLACK_BED); + case BROWN: + return new ItemStack(Material.BROWN_BED); + case GREEN: + return new ItemStack(Material.GREEN_BED); + case WHITE: + return new ItemStack(Material.WHITE_BED); + case ORANGE: + return new ItemStack(Material.ORANGE_BED); + case PURPLE: + return new ItemStack(Material.PURPLE_BED); + case YELLOW: + return new ItemStack(Material.YELLOW_BED); + case MAGENTA: + return new ItemStack(Material.MAGENTA_BED); + case LIGHT_BLUE: + return new ItemStack(Material.LIGHT_BLUE_BED); + case LIGHT_GRAY: + return new ItemStack(Material.LIGHT_GRAY_BED); + default: + return null; + } + } + + public int getItemDurability(ItemStack itemStack) { + return itemStack.getType().getMaxDurability() - ((Damageable) Objects.requireNonNull(itemStack.getItemMeta())).getDamage(); + } + + public ItemStack getItemInHand(Player player, boolean isMainHand) { + if (isMainHand) { + return player.getInventory().getItemInMainHand(); + } else { + return player.getInventory().getItemInOffHand(); + } + } + + public void sendActionBar(Player player, String message) { + try { + IChatBaseComponent iChatBaseComponent = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + message + "\"}"); + ClientboundSystemChatPacket packetPlayOutChat = new ClientboundSystemChatPacket(iChatBaseComponent, true); + ((CraftPlayer) player).getHandle().c.a(packetPlayOutChat); + } catch (Exception e) { + //Spigot 下解决 No Such Method Error + BaseComponent[] baseComponents = new ComponentBuilder(message).create(); + player.spigot().sendMessage(ChatMessageType.ACTION_BAR, baseComponents); + } + } + + public void sendPlayerList(Player player, String header, String footer) { + IChatBaseComponent tabHeader = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + header + "\"}"); + IChatBaseComponent tabFooter = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + footer + "\"}"); + PacketPlayOutPlayerListHeaderFooter tabPacket = new PacketPlayOutPlayerListHeaderFooter(tabHeader, tabFooter); + ((CraftPlayer) player).getHandle().c.a(tabPacket); + } + + @Override + public BlockFace getBlockFace(Block placedBlock) { + BlockData blockData = placedBlock.getBlockData(); + return ((Directional) blockData).getFacing(); + } +} diff --git a/Versions/pom.xml b/Versions/pom.xml index 8268acd..fa0337a 100644 --- a/Versions/pom.xml +++ b/Versions/pom.xml @@ -25,17 +25,13 @@ spigotmc-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - ultikits - https://maven.wisdommee.com/repository/ultikits-dev/ - com.ultikits UltiTools-API - 6.0.0.202310142230 + 6.0.0.202312150106 provided @@ -64,6 +60,9 @@ 1_19_R2 1_19_R3 1_20_R1 + 1_20_R2 + 1_20_R3 + 1_20_R4