From b14b3b2e0c0e68403d8a0969a8ccf11fa452b0c6 Mon Sep 17 00:00:00 2001 From: expvintl Date: Tue, 10 Jan 2023 00:36:36 +0800 Subject: [PATCH] init --- .gitignore | 118 +++++++++++++++++++++++ build.gradle | 43 +++++++++ gradle.properties | 0 gradle/wrapper/gradle-wrapper.properties | 1 + settings.gradle | 1 + src/main/java/expvintl/tools/Tools.java | 74 ++++++++++++++ src/main/resources/plugin.yml | 13 +++ 7 files changed, 250 insertions(+) create mode 100644 .gitignore create mode 100644 build.gradle create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100644 settings.gradle create mode 100644 src/main/java/expvintl/tools/Tools.java create mode 100644 src/main/resources/plugin.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c37caf --- /dev/null +++ b/.gitignore @@ -0,0 +1,118 @@ +# User-specific stuff +.idea/ + +*.iml +*.ipr +*.iws + +# IntelliJ +out/ +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# 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 + +.gradle +build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Cache of project +.gradletasknamecache + +**/build/ + +# Common working directory +run/ + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..ec02695 --- /dev/null +++ b/build.gradle @@ -0,0 +1,43 @@ +plugins { + id 'java' +} + +group = 'expvintl' +version = '1.0-SNAPSHOT' + +repositories { + mavenCentral() + maven { + name = 'spigotmc-repo' + url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' + } +} + +dependencies { + compileOnly 'org.bukkit:bukkit:1.15.2-R0.1-SNAPSHOT' +} + +def targetJavaVersion = 8 +java { + def javaVersion = JavaVersion.toVersion(targetJavaVersion) + sourceCompatibility = javaVersion + targetCompatibility = javaVersion + if (JavaVersion.current() < javaVersion) { + toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) + } +} + +tasks.withType(JavaCompile).configureEach { + if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { + options.release = targetJavaVersion + } +} + +processResources { + def props = [version: version] + inputs.properties props + filteringCharset 'UTF-8' + filesMatching('plugin.yml') { + expand props + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..e69de29 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..c5aa630 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..be26104 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'tools' diff --git a/src/main/java/expvintl/tools/Tools.java b/src/main/java/expvintl/tools/Tools.java new file mode 100644 index 0000000..78dbd6c --- /dev/null +++ b/src/main/java/expvintl/tools/Tools.java @@ -0,0 +1,74 @@ +package expvintl.tools; + +import org.bukkit.Location; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import java.util.Objects; +import java.util.Random; +import java.util.logging.Logger; + +public final class Tools extends JavaPlugin { + + Logger logger=getLogger(); + @Override + public void onEnable() { + // Plugin startup logic + logger.info("Plugin Enabled!"); + } + + @Override + public boolean onCommand(CommandSender sender,Command command,String label,String[] args) { + Player player=this.getServer().getPlayer(sender.getName()); + if(Objects.isNull(player)){ + sender.sendMessage("玩家不存在!"); + return false; + } + if(label.equals("kill")){ + if(args.length>0){ + sender.sendMessage(args[0]+" 死了"); + return true; + } + player.setHealth(0); + } + if(label.equals("tp")){ + if(args.length==4){ + try { + double x = Double.parseDouble(args[1]); + double y = Double.parseDouble(args[2]); + double z = Double.parseDouble(args[3]); + player.teleport(new Location(player.getWorld(),x,y,z)); + getServer().broadcastMessage(String.format("%s 传送到了 X:%.2f Y:%.2f Z:%.2f",player.getName(),x,y,z)); + }catch (NumberFormatException f) { + sender.sendMessage("错误的数字格式!"); + } + }else if(args.length==3) { + try { + double x = Double.parseDouble(args[0]); + double y = Double.parseDouble(args[1]); + double z = Double.parseDouble(args[2]); + player.teleport(new Location(player.getWorld(), x, y, z)); + getServer().broadcastMessage(String.format("%s 传送到了 X:%.2f Y:%.2f Z:%.2f", player.getName(), x, y, z)); + } catch (NumberFormatException f) { + sender.sendMessage("错误的数字格式!"); + } + }else{ + sender.sendMessage("缺少应有的坐标参数!"); + return false; + } + } + return true; + } + + @Override + public void onDisable() { + // Plugin shutdown logic + } + + public Player getRandomOnlinePlayer(){ + int r=new Random().nextInt(getServer().getOnlinePlayers().size()); + return (Player)getServer().getOnlinePlayers().toArray()[r]; + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..8866ee0 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,13 @@ +name: Tools +version: '${version}' +main: expvintl.tools.Tools +api-version: 1.15 +authors: [ expvintl ] +description: Tools +commands: + kill: #鎸囦护鍚 + description: "kill self" #鎸囦护鐨勬敞瑙 + usage: /kill + tp: + description: "teleport" + usage: /tp <鐜╁鍚> \ No newline at end of file