This commit is contained in:
expvintl 2023-01-10 00:36:36 +08:00
commit b14b3b2e0c
7 changed files with 250 additions and 0 deletions

118
.gitignore vendored Normal file
View File

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

43
build.gradle Normal file
View File

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

0
gradle.properties Normal file
View File

View File

@ -0,0 +1 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip

1
settings.gradle Normal file
View File

@ -0,0 +1 @@
rootProject.name = 'tools'

View File

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

View File

@ -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 <玩家名> <x> <y> <z>