mirror of
https://e.coding.net/circlecloud/TeleportRandom.git
synced 2025-11-25 21:56:10 +00:00
refactor: 修改版本 格式化代码
This commit is contained in:
26
pom.xml
26
pom.xml
@@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>cn.citycraft</groupId>
|
<groupId>cn.citycraft</groupId>
|
||||||
<artifactId>TeleportRandom</artifactId>
|
<artifactId>TeleportRandom</artifactId>
|
||||||
<version>1.1</version>
|
<version>1.2</version>
|
||||||
<name>TeleportRandom</name>
|
<name>TeleportRandom</name>
|
||||||
<build>
|
<build>
|
||||||
<finalName>${project.name}</finalName>
|
<finalName>${project.name}</finalName>
|
||||||
@@ -52,29 +52,35 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
<ciManagement>
|
||||||
|
<system>Jenkins</system>
|
||||||
|
<url>http://ci.yumc.pw/job/${project.artifactId}/</url>
|
||||||
|
</ciManagement>
|
||||||
<properties>
|
<properties>
|
||||||
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
|
<update.description>&e添加后台传送功能...</update.description>
|
||||||
<update.description>修复一直提示更新的问题...</update.description>
|
|
||||||
<update.changes></update.changes>
|
<update.changes></update.changes>
|
||||||
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
|
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>yumc-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
<url>http://repo.yumc.pw/content/groups/public/</url>
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>citycraft-repo</id>
|
|
||||||
<url>${jenkins.url}/plugin/repository/everything/</url>
|
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
<distributionManagement>
|
||||||
|
<repository>
|
||||||
|
<id>jtb</id>
|
||||||
|
<name>YUMC</name>
|
||||||
|
<url>http://repo.yumc.pw/content/repositories/yumcenter/</url>
|
||||||
|
</repository>
|
||||||
|
</distributionManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
<version>1.9-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.citycraft</groupId>
|
<groupId>cn.citycraft</groupId>
|
||||||
|
|||||||
@@ -16,120 +16,120 @@ import cn.citycraft.PluginHelper.config.FileConfig;
|
|||||||
import cn.citycraft.PluginHelper.utils.VersionChecker;
|
import cn.citycraft.PluginHelper.utils.VersionChecker;
|
||||||
|
|
||||||
public class TeleportRandom extends JavaPlugin implements CommandExecutor {
|
public class TeleportRandom extends JavaPlugin implements CommandExecutor {
|
||||||
public FileConfig config;
|
public FileConfig config;
|
||||||
public String pluginname;
|
public String pluginname;
|
||||||
public String servername;
|
public String servername;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String string, final String[] args) {
|
public boolean onCommand(final CommandSender sender, final Command cmd, final String string, final String[] args) {
|
||||||
if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
|
if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
|
||||||
this.onLoad();
|
this.onLoad();
|
||||||
sender.sendMessage(servername + pluginname + config.getMessage("Message.Reload"));
|
sender.sendMessage(servername + pluginname + config.getMessage("Message.Reload"));
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
final Player p = (Player) sender;
|
|
||||||
if (!p.hasPermission("tpr.use")) {
|
|
||||||
sender.sendMessage(servername + pluginname + config.getMessage("Message.NoPerm"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
switch (args.length) {
|
|
||||||
case 0:
|
|
||||||
RandomTP(0, p);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
RandomTP(Integer.parseInt(args[0]), p);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
RandomTP(Integer.parseInt(args[0]), Bukkit.getWorld(args[1]), p);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (final Exception e) {
|
|
||||||
sender.sendMessage(pluginname + "§c非法的参数或不存在的世界!");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if(args.length>0){
|
|
||||||
try {
|
|
||||||
switch (args.length) {
|
|
||||||
case 1:
|
|
||||||
RandomTP(0,Bukkit.getPlayer(args[0]));
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
RandomTP(Integer.parseInt(args[1]),Bukkit.getPlayer(args[0]));
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
RandomTP(Integer.parseInt(args[1]),Bukkit.getWorld(args[2]),Bukkit.getPlayer(args[0]));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} catch (final Exception e) {
|
|
||||||
sender.sendMessage(pluginname + "§c非法的参数或不存在的世界!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sender.sendMessage(pluginname + "§c非法的参数!");
|
if (sender instanceof Player) {
|
||||||
return false;
|
final Player p = (Player) sender;
|
||||||
}
|
if (!p.hasPermission("tpr.use")) {
|
||||||
|
sender.sendMessage(servername + pluginname + config.getMessage("Message.NoPerm"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
RandomTP(0, p);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
RandomTP(Integer.parseInt(args[0]), p);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
RandomTP(Integer.parseInt(args[0]), Bukkit.getWorld(args[1]), p);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (final Exception e) {
|
||||||
|
sender.sendMessage(pluginname + "§c非法的参数或不存在的世界!");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (args.length > 0) {
|
||||||
|
try {
|
||||||
|
switch (args.length) {
|
||||||
|
case 1:
|
||||||
|
RandomTP(0, Bukkit.getPlayer(args[0]));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
RandomTP(Integer.parseInt(args[1]), Bukkit.getPlayer(args[0]));
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
RandomTP(Integer.parseInt(args[1]), Bukkit.getWorld(args[2]), Bukkit.getPlayer(args[0]));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (final Exception e) {
|
||||||
|
sender.sendMessage(pluginname + "§c非法的参数或不存在的世界!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sender.sendMessage(pluginname + "§c非法的参数!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
new VersionChecker(this);
|
new VersionChecker(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
config = new FileConfig(this);
|
config = new FileConfig(this);
|
||||||
servername = config.getMessage("servername");
|
servername = config.getMessage("servername");
|
||||||
pluginname = config.getMessage("pluginname");
|
pluginname = config.getMessage("pluginname");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RandomTP(final int limit, final Player p) {
|
public void RandomTP(final int limit, final Player p) {
|
||||||
RandomTP(limit, p.getWorld(), p);
|
RandomTP(limit, p.getWorld(), p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RandomTP(final int limit, final World world, final Player p) {
|
public void RandomTP(final int limit, final World world, final Player p) {
|
||||||
final Random rr = new Random();
|
final Random rr = new Random();
|
||||||
int lr = config.getInt("default");
|
int lr = config.getInt("default");
|
||||||
if (limit == 0) {
|
if (limit == 0) {
|
||||||
p.sendMessage(pluginname + config.getMessage("Message.default1"));
|
p.sendMessage(pluginname + config.getMessage("Message.default1"));
|
||||||
p.sendMessage(pluginname + config.getMessage("Message.default2"));
|
p.sendMessage(pluginname + config.getMessage("Message.default2"));
|
||||||
} else {
|
} else {
|
||||||
lr = limit;
|
lr = limit;
|
||||||
final int lrLimit = config.getInt("Limit");
|
final int lrLimit = config.getInt("Limit");
|
||||||
if (lr > lrLimit) {
|
if (lr > lrLimit) {
|
||||||
lr = lrLimit;
|
lr = lrLimit;
|
||||||
p.sendMessage(String.format(pluginname + config.getMessage("Message.Wran"), lrLimit));
|
p.sendMessage(String.format(pluginname + config.getMessage("Message.Wran"), lrLimit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int x = rr.nextInt(lr);
|
int x = rr.nextInt(lr);
|
||||||
int z = rr.nextInt(lr);
|
int z = rr.nextInt(lr);
|
||||||
final int xf = rr.nextInt(x);
|
final int xf = rr.nextInt(x);
|
||||||
final int yf = rr.nextInt(z);
|
final int yf = rr.nextInt(z);
|
||||||
if (xf % 2 != 0) {
|
if (xf % 2 != 0) {
|
||||||
x = -x;
|
x = -x;
|
||||||
}
|
}
|
||||||
if (yf % 2 != 0) {
|
if (yf % 2 != 0) {
|
||||||
z = -z;
|
z = -z;
|
||||||
}
|
}
|
||||||
final int y = world.getHighestBlockYAt(x, z);
|
final int y = world.getHighestBlockYAt(x, z);
|
||||||
final Location trl = new Location(world, x, y - 1, z);
|
final Location trl = new Location(world, x, y - 1, z);
|
||||||
final Material rbm = trl.getBlock().getType();
|
final Material rbm = trl.getBlock().getType();
|
||||||
final String blockname = rbm.name();
|
final String blockname = rbm.name();
|
||||||
for (final String protectblock : config.getStringList("ProtectBlock")) {
|
for (final String protectblock : config.getStringList("ProtectBlock")) {
|
||||||
if (protectblock.equalsIgnoreCase(blockname)) {
|
if (protectblock.equalsIgnoreCase(blockname)) {
|
||||||
trl.getBlock().setType(Material.GLASS);
|
trl.getBlock().setType(Material.GLASS);
|
||||||
p.sendMessage(pluginname + config.getMessage("Message.Protect"));
|
p.sendMessage(pluginname + config.getMessage("Message.Protect"));
|
||||||
this.getServer().getScheduler().runTaskLater(this, new Runnable() {
|
this.getServer().getScheduler().runTaskLater(this, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
trl.getBlock().setType(rbm);
|
trl.getBlock().setType(rbm);
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Location nrl = new Location(world, x, y + 3, z);
|
final Location nrl = new Location(world, x, y + 3, z);
|
||||||
p.teleport(nrl);
|
p.teleport(nrl);
|
||||||
p.sendMessage(String.format(pluginname + config.getMessage("Message.Tip"), world.getName(), x, y, z));
|
p.sendMessage(String.format(pluginname + config.getMessage("Message.Tip"), world.getName(), x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user