测试版
This commit is contained in:
commit
7b0fc3647e
39
.gitignore
vendored
Normal file
39
.gitignore
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
/.idea/
|
32
pom.xml
Normal file
32
pom.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?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>org.example</groupId>
|
||||
<artifactId>DemonDeathEvent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>public-rpg</id>
|
||||
<url>https://repo.aurora-pixels.com/repository/public-rpg/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
94
src/main/java/me/Demon/DemonDeathEvent/Main.java
Normal file
94
src/main/java/me/Demon/DemonDeathEvent/Main.java
Normal file
|
@ -0,0 +1,94 @@
|
|||
package me.Demon.DemonDeathEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class Main extends JavaPlugin implements Listener {
|
||||
|
||||
public static Main plugin;
|
||||
public static List<String> listWorld = new ArrayList<>();
|
||||
public static List<String> BlockWorld = new ArrayList<>();
|
||||
|
||||
public void onEnable() {
|
||||
plugin = this;
|
||||
saveDefaultConfig();
|
||||
Bukkit.getPluginManager().registerEvents( this, this );
|
||||
listWorld.addAll(getConfig().getConfigurationSection("WorldSpawn").getKeys(false));
|
||||
BlockWorld.addAll(getConfig().getStringList("BlockWorld"));
|
||||
Bukkit.getConsoleSender().sendMessage("§b[DemonDeathEvent] §a插件成功载入Sever!");
|
||||
Bukkit.getConsoleSender().sendMessage("§b[DemonDeathEvent] §a妖魂QQ:1763917516");
|
||||
}
|
||||
public void onDisable(){
|
||||
Bukkit.getConsoleSender().sendMessage("§b[DemonDeathEvent] §c插件已正常关闭!");
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String Command, String[] args) {
|
||||
if (Command.equalsIgnoreCase( "setrespawn" ) && sender.isOp() && (sender instanceof Player)) {
|
||||
Player p = (Player)sender;
|
||||
String worldName = p.getWorld().getName();
|
||||
String str = "WorldSpawn." + worldName + ".";
|
||||
getConfig().set(str + "world", p.getLocation().getWorld().getName());
|
||||
getConfig().set(str + "x", p.getLocation().getX());
|
||||
getConfig().set(str + "y", p.getLocation().getY());
|
||||
getConfig().set(str + "z", p.getLocation().getZ());
|
||||
getConfig().set(str + "yaw", p.getLocation().getYaw());
|
||||
getConfig().set(str + "pitch", p.getLocation().getPitch());
|
||||
p.getWorld().setSpawnLocation(p.getLocation().getBlockX(), p.getLocation().getBlockZ(), p.getLocation().getBlockY());
|
||||
saveConfig();
|
||||
sender.sendMessage("§f[§c消息§f] §a成功设置§e"+worldName+"§a的复活点.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Location TpSpawn(String worlName) {
|
||||
Location loc = null;
|
||||
FileConfiguration yml = Main.plugin.getConfig();
|
||||
String str = "WorldSpawn." + worlName + ".";
|
||||
if (yml.getString(str) != null) {
|
||||
String w = yml.getString(str + "world");
|
||||
double x = yml.getDouble(str + "x");
|
||||
double y = yml.getDouble(str + "y");
|
||||
double z = yml.getDouble(str + "z");
|
||||
float pi = (float) yml.getDouble(str + "pitch");
|
||||
float ya = (float) yml.getDouble(str + "yaw");
|
||||
loc = new Location(Bukkit.getWorld(w), x, y, z, ya, pi);
|
||||
}
|
||||
return loc;
|
||||
}
|
||||
|
||||
|
||||
public static String getTime(String Format){
|
||||
Date date = Calendar.getInstance().getTime();
|
||||
SimpleDateFormat datatime = new SimpleDateFormat(Format);
|
||||
return datatime.format(date);
|
||||
}
|
||||
|
||||
// 若玩家在禁止back的世界则直接复活
|
||||
@EventHandler
|
||||
public void onAutoRespawn(PlayerDeathEvent e){
|
||||
if(e.getEntity() == null){ return; }
|
||||
Player p = e.getEntity();
|
||||
Location loc = TpSpawn("hub");
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
p.spigot().respawn();
|
||||
p.teleport(loc);
|
||||
}
|
||||
}.runTaskLater(this, 5L);
|
||||
}
|
||||
}
|
63
src/main/resources/config.yml
Normal file
63
src/main/resources/config.yml
Normal file
|
@ -0,0 +1,63 @@
|
|||
BlockWorld:
|
||||
- hub
|
||||
- PlotSquared
|
||||
Todaytime: 2021/03/31
|
||||
BackAmount:
|
||||
虎牙妖魂: 10
|
||||
WorldSpawn:
|
||||
world:
|
||||
world: world
|
||||
x: 0.4529860503396992
|
||||
y: 93.0
|
||||
z: 2.4946512089232633
|
||||
yaw: 89.999275
|
||||
pitch: 0.15037563
|
||||
lrzs:
|
||||
world: lrzs
|
||||
x: 112.51658683192733
|
||||
y: 39.0
|
||||
z: -62.30000001192093
|
||||
yaw: -180.14899
|
||||
pitch: 0.45002207
|
||||
xdsl:
|
||||
world: xdsl
|
||||
x: -146.57872435534708
|
||||
y: 77.0
|
||||
z: -190.66123050974164
|
||||
yaw: 357.60358
|
||||
pitch: 5.100116
|
||||
jhby:
|
||||
world: jhby
|
||||
x: 0.634781297747613
|
||||
y: 50.0
|
||||
z: 0.4355539632605311
|
||||
yaw: -88.79977
|
||||
pitch: -0.45014793
|
||||
bhlyy:
|
||||
world: bhlyy
|
||||
x: 179.37079143213032
|
||||
y: 82.0
|
||||
z: 114.03616108316832
|
||||
yaw: 141.38824
|
||||
pitch: -0.8989827
|
||||
slds:
|
||||
world: slds
|
||||
x: -234.5158956025492
|
||||
y: 27.0
|
||||
z: -141.60707933744933
|
||||
yaw: 180.11926
|
||||
pitch: 0.8999367
|
||||
whd:
|
||||
world: whd
|
||||
x: 22.484167799538906
|
||||
y: 52.0
|
||||
z: -14.496803957077004
|
||||
yaw: -270.29922
|
||||
pitch: -0.4500123
|
||||
cjq:
|
||||
world: cjq
|
||||
x: 0.46134267863077005
|
||||
y: 53.0
|
||||
z: 0.8488541554841655
|
||||
yaw: 0.3026275
|
||||
pitch: -0.30001152
|
5
src/main/resources/plugin.yml
Normal file
5
src/main/resources/plugin.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
name: DemonDeathEvent
|
||||
main: me.Demon.DemonDeathEvent.Main
|
||||
version: 1.3.4
|
||||
commands:
|
||||
setrespawn:
|
Loading…
Reference in New Issue
Block a user