diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4788b4b --- /dev/null +++ b/.gitignore @@ -0,0 +1,113 @@ +# User-specific stuff +.idea/ + +*.iml +*.ipr +*.iws + +# IntelliJ +out/ + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +target/ + +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next + +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar +.flattened-pom.xml + +# Common working directory +run/ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..3d63159 --- /dev/null +++ b/pom.xml @@ -0,0 +1,71 @@ + + + 4.0.0 + + cn.lunadeer + FrameFilm + 1.0 + jar + + FrameFilm + + + 1.8 + UTF-8 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + ${java.version} + ${java.version} + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + + + + + + src/main/resources + true + + + + + + + papermc-repo + https://repo.papermc.io/repository/maven-public/ + + + sonatype + https://oss.sonatype.org/content/groups/public/ + + + + + + dev.folia + folia-api + 1.20.1-R0.1-SNAPSHOT + provided + + + diff --git a/src/main/java/cn/lunadeer/framefilm/FrameFilm.java b/src/main/java/cn/lunadeer/framefilm/FrameFilm.java new file mode 100644 index 0000000..7d4184e --- /dev/null +++ b/src/main/java/cn/lunadeer/framefilm/FrameFilm.java @@ -0,0 +1,34 @@ +package cn.lunadeer.framefilm; + +import cn.lunadeer.framefilm.utils.ConfigManager; +import cn.lunadeer.framefilm.utils.XLogger; +import org.bukkit.plugin.java.JavaPlugin; + +public final class FrameFilm extends JavaPlugin { + + @Override + public void onEnable() { + // Plugin startup logic + instance = this; + config = new ConfigManager(this); + + XLogger.info("电源放映插件已启动"); + XLogger.info("版本:" + this.getPluginMeta().getVersion()); + // http://patorjk.com/software/taag/#p=display&f=Big&t=FrameFilm + XLogger.info(" ______ ______ _ _"); + XLogger.info(" | ____| | ____(_) |"); + XLogger.info(" | |__ _ __ __ _ _ __ ___ ___| |__ _| |_ __ ___"); + XLogger.info(" | __| '__/ _` | '_ ` _ \\ / _ \\ __| | | | '_ ` _ \\"); + XLogger.info(" | | | | | (_| | | | | | | __/ | | | | | | | | |"); + XLogger.info(" |_| |_| \\__,_|_| |_| |_|\\___|_| |_|_|_| |_| |_|"); + XLogger.info(" "); + } + + @Override + public void onDisable() { + // Plugin shutdown logic + } + + public static FrameFilm instance; + public static ConfigManager config; +} diff --git a/src/main/java/cn/lunadeer/framefilm/utils/ConfigManager.java b/src/main/java/cn/lunadeer/framefilm/utils/ConfigManager.java new file mode 100644 index 0000000..ae5ebfc --- /dev/null +++ b/src/main/java/cn/lunadeer/framefilm/utils/ConfigManager.java @@ -0,0 +1,35 @@ +package cn.lunadeer.framefilm.utils; + +import cn.lunadeer.framefilm.FrameFilm; +import org.bukkit.configuration.file.FileConfiguration; + +public class ConfigManager { + public ConfigManager(FrameFilm plugin) { + _plugin = plugin; + _plugin.saveDefaultConfig(); + reload(); + _plugin.saveConfig(); + } + + public void reload() { + _plugin.reloadConfig(); + _file = _plugin.getConfig(); + _debug = _file.getBoolean("Debug", false); + } + + public Boolean isDebug() { + return _debug; + } + + public void setDebug(Boolean debug) { + _debug = debug; + _file.set("Debug", debug); + _plugin.saveConfig(); + } + + + private final FrameFilm _plugin; + private FileConfiguration _file; + private Boolean _debug; + +} diff --git a/src/main/java/cn/lunadeer/framefilm/utils/Notification.java b/src/main/java/cn/lunadeer/framefilm/utils/Notification.java new file mode 100644 index 0000000..102b72b --- /dev/null +++ b/src/main/java/cn/lunadeer/framefilm/utils/Notification.java @@ -0,0 +1,63 @@ +package cn.lunadeer.framefilm.utils; + +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.Style; +import net.kyori.adventure.text.format.TextColor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class Notification { + private static final Style i_style = Style.style(TextColor.color(139, 255, 123)); + private static final Style w_style = Style.style(TextColor.color(255, 185, 69)); + private static final Style e_style = Style.style(TextColor.color(255, 96, 72)); + + private static final String prefix = "[FrameFilm] "; + + public static void info(Player player, String msg) { + player.sendMessage(Component.text(prefix + msg, i_style)); + } + + public static void warn(Player player, String msg) { + player.sendMessage(Component.text(prefix + msg, w_style)); + } + + public static void error(Player player, String msg) { + player.sendMessage(Component.text(prefix + msg, e_style)); + } + + public static void info(CommandSender sender, String msg) { + sender.sendMessage(Component.text(prefix + msg, i_style)); + } + + public static void warn(CommandSender sender, String msg) { + sender.sendMessage(Component.text(prefix + msg, w_style)); + } + + public static void error(CommandSender sender, String msg) { + sender.sendMessage(Component.text(prefix + msg, e_style)); + } + + public static void info(Player player, Component msg) { + player.sendMessage(Component.text(prefix, i_style).append(msg)); + } + + public static void warn(Player player, Component msg) { + player.sendMessage(Component.text(prefix, w_style).append(msg)); + } + + public static void error(Player player, Component msg) { + player.sendMessage(Component.text(prefix, e_style).append(msg)); + } + + public static void info(CommandSender player, Component msg) { + player.sendMessage(Component.text(prefix, i_style).append(msg)); + } + + public static void warn(CommandSender player, Component msg) { + player.sendMessage(Component.text(prefix, w_style).append(msg)); + } + + public static void error(CommandSender player, Component msg) { + player.sendMessage(Component.text(prefix, e_style).append(msg)); + } +} diff --git a/src/main/java/cn/lunadeer/framefilm/utils/XLogger.java b/src/main/java/cn/lunadeer/framefilm/utils/XLogger.java new file mode 100644 index 0000000..14869ab --- /dev/null +++ b/src/main/java/cn/lunadeer/framefilm/utils/XLogger.java @@ -0,0 +1,56 @@ +package cn.lunadeer.framefilm.utils; + +import cn.lunadeer.framefilm.FrameFilm; +import org.bukkit.entity.Player; + +import java.util.logging.Logger; + +public class XLogger { + private static final FrameFilm _plugin = FrameFilm.instance; + private static final Logger _logger = _plugin.getLogger(); + + private static final String prefix = "[FrameFilm] "; + + public static void info(Player player, String message) { + Notification.info(player, prefix + "I | " + message); + if (FrameFilm.config.isDebug()) + debug("来自玩家[ " + player.getName() + " ] 的信息 | " + message); + } + + public static void info(String message) { + _logger.info(" I | " + message); + } + + public static void warn(Player player, String message) { + Notification.warn(player, prefix + "W | " + message); + if (FrameFilm.config.isDebug()) + debug("来自玩家[ " + player.getName() + " ] 的警告 | " + message); + } + + public static void warn(String message) { + _logger.info(" W | " + message); + } + + public static void err(Player player, String message) { + Notification.error(player, prefix + "E | " + message); + if (FrameFilm.config.isDebug()) + debug("来自玩家[ " + player.getName() + " ] 的报错 | " + message); + } + + public static void err(String message) { + _logger.info(" E | " + message); + } + + public static void debug(Player player, String message) { + if (!FrameFilm.config.isDebug()) return; + if (player.isOp()) + Notification.info(player, prefix + "D | " + message); + else + debug("来自玩家[ " + player.getName() + " ] 的调试 | " + message); + } + + public static void debug(String message) { + if (!FrameFilm.config.isDebug()) return; + _logger.info(" D | " + message); + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml new file mode 100644 index 0000000..e9e3311 --- /dev/null +++ b/src/main/resources/config.yml @@ -0,0 +1 @@ +Debug: false \ 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..9720046 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,6 @@ +name: FrameFilm +version: '${project.version}' +main: cn.lunadeer.framefilm.FrameFilm +api-version: '1.20' +load: STARTUP +folia-supported: true