diff --git a/src/main/java/com/github/mori01231/lifecore/LifeCore.java b/src/main/java/com/github/mori01231/lifecore/LifeCore.java index a522512..e7075d6 100644 --- a/src/main/java/com/github/mori01231/lifecore/LifeCore.java +++ b/src/main/java/com/github/mori01231/lifecore/LifeCore.java @@ -28,6 +28,10 @@ public void onEnable() { this.getCommand("guide").setExecutor(new GuideCommandExecutor()); this.getCommand("tutorial").setExecutor(new TutorialCommandExecutor()); this.getCommand("pve").setExecutor(new PveCommandExecutor()); + this.getCommand("pve0").setExecutor(new Pve0CommandExecutor()); + this.getCommand("pve1").setExecutor(new Pve1CommandExecutor()); + this.getCommand("pve2").setExecutor(new Pve2CommandExecutor()); + this.getCommand("pve3").setExecutor(new Pve3CommandExecutor()); this.getCommand("life").setExecutor(new LifeCommandExecutor()); this.getCommand("rank").setExecutor(new RankCommandExecutor()); this.getCommand("sara").setExecutor(new SaraCommandExecutor()); diff --git a/src/main/java/com/github/mori01231/lifecore/Pve0CommandExecutor.java b/src/main/java/com/github/mori01231/lifecore/Pve0CommandExecutor.java new file mode 100644 index 0000000..3036380 --- /dev/null +++ b/src/main/java/com/github/mori01231/lifecore/Pve0CommandExecutor.java @@ -0,0 +1,49 @@ +package com.github.mori01231.lifecore; + +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import static org.bukkit.Bukkit.getServer; + +public class Pve0CommandExecutor implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + + if (sender instanceof Player){ + Player player = (Player) sender; + String playerName = player.getName(); + + if(LifeCore.getInstance().getConfig().getBoolean("use-pve-command-as-teleport")){ + String pve = LifeCore.getInstance().getConfig().getString("pve-teleport"); + getServer().dispatchCommand(getServer().getConsoleSender(), "mvtp " + playerName + " " + pve); + sender.sendMessage(ChatColor.translateAlternateColorCodes('&',"&3ダンジョンロビーにテレポートしました。" )); + + }else{ + // create bytearray for sending player to server + ByteArrayOutputStream b = new ByteArrayOutputStream(); + DataOutputStream out = new DataOutputStream(b); + try { + out.writeUTF("Connect"); + out.writeUTF("lifepve"); + } catch (IOException e) { + // never happens + } + player.sendPluginMessage(LifeCore.getInstance(), "BungeeCord", b.toByteArray()); + } + + } + else{ + sender.sendMessage(ChatColor.translateAlternateColorCodes('&',"&3このコマンドはコンソールから使用できません。" )); + } + + + return true; + } +} diff --git a/src/main/java/com/github/mori01231/lifecore/Pve1CommandExecutor.java b/src/main/java/com/github/mori01231/lifecore/Pve1CommandExecutor.java new file mode 100644 index 0000000..1f053f6 --- /dev/null +++ b/src/main/java/com/github/mori01231/lifecore/Pve1CommandExecutor.java @@ -0,0 +1,49 @@ +package com.github.mori01231.lifecore; + +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import static org.bukkit.Bukkit.getServer; + +public class Pve1CommandExecutor implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + + if (sender instanceof Player){ + Player player = (Player) sender; + String playerName = player.getName(); + + if(LifeCore.getInstance().getConfig().getBoolean("use-pve-command-as-teleport")){ + String pve = LifeCore.getInstance().getConfig().getString("pve-teleport"); + getServer().dispatchCommand(getServer().getConsoleSender(), "mvtp " + playerName + " " + pve); + sender.sendMessage(ChatColor.translateAlternateColorCodes('&',"&3ダンジョンロビーにテレポートしました。" )); + + }else{ + // create bytearray for sending player to server + ByteArrayOutputStream b = new ByteArrayOutputStream(); + DataOutputStream out = new DataOutputStream(b); + try { + out.writeUTF("Connect"); + out.writeUTF("lifepve1"); + } catch (IOException e) { + // never happens + } + player.sendPluginMessage(LifeCore.getInstance(), "BungeeCord", b.toByteArray()); + } + + } + else{ + sender.sendMessage(ChatColor.translateAlternateColorCodes('&',"&3このコマンドはコンソールから使用できません。" )); + } + + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/com/github/mori01231/lifecore/Pve2CommandExecutor.java b/src/main/java/com/github/mori01231/lifecore/Pve2CommandExecutor.java new file mode 100644 index 0000000..8cb561f --- /dev/null +++ b/src/main/java/com/github/mori01231/lifecore/Pve2CommandExecutor.java @@ -0,0 +1,49 @@ +package com.github.mori01231.lifecore; + +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import static org.bukkit.Bukkit.getServer; + +public class Pve2CommandExecutor implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + + if (sender instanceof Player){ + Player player = (Player) sender; + String playerName = player.getName(); + + if(LifeCore.getInstance().getConfig().getBoolean("use-pve-command-as-teleport")){ + String pve = LifeCore.getInstance().getConfig().getString("pve-teleport"); + getServer().dispatchCommand(getServer().getConsoleSender(), "mvtp " + playerName + " " + pve); + sender.sendMessage(ChatColor.translateAlternateColorCodes('&',"&3ダンジョンロビーにテレポートしました。" )); + + }else{ + // create bytearray for sending player to server + ByteArrayOutputStream b = new ByteArrayOutputStream(); + DataOutputStream out = new DataOutputStream(b); + try { + out.writeUTF("Connect"); + out.writeUTF("lifepve2"); + } catch (IOException e) { + // never happens + } + player.sendPluginMessage(LifeCore.getInstance(), "BungeeCord", b.toByteArray()); + } + + } + else{ + sender.sendMessage(ChatColor.translateAlternateColorCodes('&',"&3このコマンドはコンソールから使用できません。" )); + } + + + return true; + } +} diff --git a/src/main/java/com/github/mori01231/lifecore/Pve3CommandExecutor.java b/src/main/java/com/github/mori01231/lifecore/Pve3CommandExecutor.java new file mode 100644 index 0000000..141ede2 --- /dev/null +++ b/src/main/java/com/github/mori01231/lifecore/Pve3CommandExecutor.java @@ -0,0 +1,49 @@ +package com.github.mori01231.lifecore; + +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import static org.bukkit.Bukkit.getServer; + +public class Pve3CommandExecutor implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + + if (sender instanceof Player){ + Player player = (Player) sender; + String playerName = player.getName(); + + if(LifeCore.getInstance().getConfig().getBoolean("use-pve-command-as-teleport")){ + String pve = LifeCore.getInstance().getConfig().getString("pve-teleport"); + getServer().dispatchCommand(getServer().getConsoleSender(), "mvtp " + playerName + " " + pve); + sender.sendMessage(ChatColor.translateAlternateColorCodes('&',"&3ダンジョンロビーにテレポートしました。" )); + + }else{ + // create bytearray for sending player to server + ByteArrayOutputStream b = new ByteArrayOutputStream(); + DataOutputStream out = new DataOutputStream(b); + try { + out.writeUTF("Connect"); + out.writeUTF("lifepve3"); + } catch (IOException e) { + // never happens + } + player.sendPluginMessage(LifeCore.getInstance(), "BungeeCord", b.toByteArray()); + } + + } + else{ + sender.sendMessage(ChatColor.translateAlternateColorCodes('&',"&3このコマンドはコンソールから使用できません。" )); + } + + + return true; + } +} \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 0012e83..d0f19cb 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -31,6 +31,22 @@ commands: description: Teleport to dungeon. permission: lifecore.pve usage: Syntax error! Simply type /pve to teleport to dungeon. + pve0: + description: Teleport to dungeon. + permission: lifecore.pve + usage: Syntax error! Simply type /pve0 to teleport to dungeon. + pve1: + description: Teleport to dungeon. + permission: lifecore.pve + usage: Syntax error! Simply type /pve1 to teleport to dungeon. + pve2: + description: Teleport to dungeon. + permission: lifecore.pve + usage: Syntax error! Simply type /pve2 to teleport to dungeon. + pve3: + description: Teleport to dungeon. + permission: lifecore.pve + usage: Syntax error! Simply type /pve3 to teleport to dungeon. life: description: Teleport to Life server. permission: lifecore.life