项目初始化

This commit is contained in:
zhangyuheng 2024-03-28 11:37:17 +08:00
parent 00a4466edd
commit ad21fce01a
8 changed files with 379 additions and 0 deletions

113
.gitignore vendored Normal file
View File

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

71
pom.xml Normal file
View File

@ -0,0 +1,71 @@
<?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>cn.lunadeer</groupId>
<artifactId>FrameFilm</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>FrameFilm</name>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>papermc-repo</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>dev.folia</groupId>
<artifactId>folia-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1 @@
Debug: false

View File

@ -0,0 +1,6 @@
name: FrameFilm
version: '${project.version}'
main: cn.lunadeer.framefilm.FrameFilm
api-version: '1.20'
load: STARTUP
folia-supported: true