diff --git a/pom.xml b/pom.xml index a238ca2..f67b95a 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 cn.citycraft TeleportRandom - 1.1 + 1.2 TeleportRandom ${project.name} @@ -52,29 +52,35 @@ + + Jenkins + http://ci.yumc.pw/job/${project.artifactId}/ + - http://ci.citycraft.cn:8080 - 修复一直提示更新的问题... + &e添加后台传送功能... DEBUG UTF-8 - spigot-repo - https://hub.spigotmc.org/nexus/content/groups/public/ - - - citycraft-repo - ${jenkins.url}/plugin/repository/everything/ + yumc-repo + http://repo.yumc.pw/content/groups/public/ + + + jtb + YUMC + http://repo.yumc.pw/content/repositories/yumcenter/ + + org.spigotmc spigot-api jar - 1.8.8-R0.1-SNAPSHOT + 1.9-R0.1-SNAPSHOT cn.citycraft diff --git a/src/main/java/cn/citycraft/TeleportRandom/TeleportRandom.java b/src/main/java/cn/citycraft/TeleportRandom/TeleportRandom.java index fcbe7d5..62a7664 100644 --- a/src/main/java/cn/citycraft/TeleportRandom/TeleportRandom.java +++ b/src/main/java/cn/citycraft/TeleportRandom/TeleportRandom.java @@ -16,120 +16,120 @@ import cn.citycraft.PluginHelper.config.FileConfig; import cn.citycraft.PluginHelper.utils.VersionChecker; public class TeleportRandom extends JavaPlugin implements CommandExecutor { - public FileConfig config; - public String pluginname; - public String servername; + public FileConfig config; + public String pluginname; + public String servername; - @Override - public boolean onCommand(final CommandSender sender, final Command cmd, final String string, final String[] args) { - if (args.length == 1 && args[0].equalsIgnoreCase("reload")) { - this.onLoad(); - sender.sendMessage(servername + pluginname + config.getMessage("Message.Reload")); - 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非法的参数或不存在的世界!"); - } + @Override + public boolean onCommand(final CommandSender sender, final Command cmd, final String string, final String[] args) { + if (args.length == 1 && args[0].equalsIgnoreCase("reload")) { + this.onLoad(); + sender.sendMessage(servername + pluginname + config.getMessage("Message.Reload")); + return true; } - sender.sendMessage(pluginname + "§c非法的参数!"); - return false; - } + 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非法的参数!"); + return false; + } - @Override - public void onEnable() { - new VersionChecker(this); - } + @Override + public void onEnable() { + new VersionChecker(this); + } - @Override - public void onLoad() { - config = new FileConfig(this); - servername = config.getMessage("servername"); - pluginname = config.getMessage("pluginname"); - } + @Override + public void onLoad() { + config = new FileConfig(this); + servername = config.getMessage("servername"); + pluginname = config.getMessage("pluginname"); + } - public void RandomTP(final int limit, final Player p) { - RandomTP(limit, p.getWorld(), p); - } + public void RandomTP(final int limit, final Player p) { + RandomTP(limit, p.getWorld(), p); + } - public void RandomTP(final int limit, final World world, final Player p) { - final Random rr = new Random(); - int lr = config.getInt("default"); - if (limit == 0) { - p.sendMessage(pluginname + config.getMessage("Message.default1")); - p.sendMessage(pluginname + config.getMessage("Message.default2")); - } else { - lr = limit; - final int lrLimit = config.getInt("Limit"); - if (lr > lrLimit) { - lr = lrLimit; - p.sendMessage(String.format(pluginname + config.getMessage("Message.Wran"), lrLimit)); - } - } - int x = rr.nextInt(lr); - int z = rr.nextInt(lr); - final int xf = rr.nextInt(x); - final int yf = rr.nextInt(z); - if (xf % 2 != 0) { - x = -x; - } - if (yf % 2 != 0) { - z = -z; - } - final int y = world.getHighestBlockYAt(x, z); - final Location trl = new Location(world, x, y - 1, z); - final Material rbm = trl.getBlock().getType(); - final String blockname = rbm.name(); - for (final String protectblock : config.getStringList("ProtectBlock")) { - if (protectblock.equalsIgnoreCase(blockname)) { - trl.getBlock().setType(Material.GLASS); - p.sendMessage(pluginname + config.getMessage("Message.Protect")); - this.getServer().getScheduler().runTaskLater(this, new Runnable() { - @Override - public void run() { - trl.getBlock().setType(rbm); - } - }, 200); - } - } - final Location nrl = new Location(world, x, y + 3, z); - p.teleport(nrl); - p.sendMessage(String.format(pluginname + config.getMessage("Message.Tip"), world.getName(), x, y, z)); - } + public void RandomTP(final int limit, final World world, final Player p) { + final Random rr = new Random(); + int lr = config.getInt("default"); + if (limit == 0) { + p.sendMessage(pluginname + config.getMessage("Message.default1")); + p.sendMessage(pluginname + config.getMessage("Message.default2")); + } else { + lr = limit; + final int lrLimit = config.getInt("Limit"); + if (lr > lrLimit) { + lr = lrLimit; + p.sendMessage(String.format(pluginname + config.getMessage("Message.Wran"), lrLimit)); + } + } + int x = rr.nextInt(lr); + int z = rr.nextInt(lr); + final int xf = rr.nextInt(x); + final int yf = rr.nextInt(z); + if (xf % 2 != 0) { + x = -x; + } + if (yf % 2 != 0) { + z = -z; + } + final int y = world.getHighestBlockYAt(x, z); + final Location trl = new Location(world, x, y - 1, z); + final Material rbm = trl.getBlock().getType(); + final String blockname = rbm.name(); + for (final String protectblock : config.getStringList("ProtectBlock")) { + if (protectblock.equalsIgnoreCase(blockname)) { + trl.getBlock().setType(Material.GLASS); + p.sendMessage(pluginname + config.getMessage("Message.Protect")); + this.getServer().getScheduler().runTaskLater(this, new Runnable() { + @Override + public void run() { + trl.getBlock().setType(rbm); + } + }, 200); + } + } + final Location nrl = new Location(world, x, y + 3, z); + p.teleport(nrl); + p.sendMessage(String.format(pluginname + config.getMessage("Message.Tip"), world.getName(), x, y, z)); + } }