Skip to content

Commit

Permalink
[Add] Random server selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Mori01231 committed Jun 26, 2021
1 parent 0ca6573 commit 7f4164d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 43 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'java'

group = 'com.github.mori01231'
version = '1.0.0'
version = '1.0.1'

sourceCompatibility = '1.8'
targetCompatibility = '1.8'
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/github/mori01231/lifecore/LifeCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public void onEnable() {
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());
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;

import static org.bukkit.Bukkit.getLogger;
import static org.bukkit.Bukkit.getServer;
Expand All @@ -27,12 +29,24 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',"&3ダンジョンロビーにテレポートしました。" ));

}else{
// create list of servers
ArrayList<String> servers = new ArrayList<String>();
servers.add("lifepve");
servers.add("lifepve1");
servers.add("lifepve2");
//servers.add("lifepve3");

// create random index to select from servers
Random random = new Random();
int index = random.nextInt(servers.size());

// create bytearray for sending player to server
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
// send player to random server
out.writeUTF("Connect");
out.writeUTF("lifepve");
out.writeUTF(servers.get(index));
} catch (IOException e) {
// never happens
}
Expand Down
4 changes: 0 additions & 4 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ commands:
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
Expand Down

0 comments on commit 7f4164d

Please sign in to comment.