From 2c471166547f46b7b7dccf8d87e80007e4e5fddb Mon Sep 17 00:00:00 2001 From: Abby Date: Wed, 14 Nov 2018 20:36:20 +0900 Subject: [PATCH] better compatibility with old params, default params no longer needed --- .../ratel/landlords/client/SimpleClient.java | 24 ++++++++++++------- .../ratel/landlords/helper/PokerHelper.java | 14 ++++------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/landlords-client/src/main/java/org/nico/ratel/landlords/client/SimpleClient.java b/landlords-client/src/main/java/org/nico/ratel/landlords/client/SimpleClient.java index 70c3046..31c286a 100644 --- a/landlords-client/src/main/java/org/nico/ratel/landlords/client/SimpleClient.java +++ b/landlords-client/src/main/java/org/nico/ratel/landlords/client/SimpleClient.java @@ -2,9 +2,9 @@ package org.nico.ratel.landlords.client; import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; +import java.net.URLConnection; import java.util.List; import org.nico.noson.Noson; @@ -23,9 +23,9 @@ public class SimpleClient { public static int id = -1; - public static String serverAddress = "39.105.65.8"; + public static String serverAddress = ""; - public static int port = 1024; + public static int port = 0; public static void main(String[] args) throws InterruptedException, IOException { if(args != null && args.length > 0) { @@ -39,18 +39,22 @@ public class SimpleClient { } } } - }else{ + } + + if(serverAddress.equals("") || port == 0){ StringBuffer buffer = new StringBuffer(); try { - InputStream is = new URL("https://raw.githubusercontent.com/abbychau/ratel/master/serverlist.json").openStream(); - InputStreamReader isr = new InputStreamReader(is); + URL url = new URL("https://raw.githubusercontent.com/abbychau/ratel/master/serverlist.json"); + URLConnection con = url.openConnection(); + con.setUseCaches(false); + InputStreamReader isr = new InputStreamReader(con.getInputStream()); BufferedReader in = new BufferedReader(isr); String s = null; while ( (s = in.readLine()) != null) { buffer.append(s).append("\n"); } } catch ( Exception e ) { - System.out.println( e.toString() ); + System.out.println(e.toString()); buffer = null; } List serverAddressList = Noson.convert(buffer.toString(), new NoType>() {}); @@ -63,6 +67,9 @@ public class SimpleClient { SimplePrinter.printNotice("Invalid Option"); } serverAddress = serverAddressList.get(serverPick-1); + String[] elements = serverAddress.split(":"); + serverAddress = elements[0]; + port = Integer.parseInt(elements[1]); } EventLoopGroup group = new NioEventLoopGroup(); @@ -71,14 +78,13 @@ public class SimpleClient { .group(group) .channel(NioSocketChannel.class) .handler(new DefaultChannelInitializer()); - SimplePrinter.printNotice("Connecting to " + serverAddress); + SimplePrinter.printNotice("Connecting to " + serverAddress + ":" + port); Channel channel = bootstrap.connect(serverAddress, port).sync().channel(); channel.closeFuture().sync(); } finally { group.shutdownGracefully().sync(); } - } } diff --git a/landlords-common/src/main/java/org/nico/ratel/landlords/helper/PokerHelper.java b/landlords-common/src/main/java/org/nico/ratel/landlords/helper/PokerHelper.java index 9551f06..def5afa 100644 --- a/landlords-common/src/main/java/org/nico/ratel/landlords/helper/PokerHelper.java +++ b/landlords-common/src/main/java/org/nico/ratel/landlords/helper/PokerHelper.java @@ -261,11 +261,9 @@ public class PokerHelper { for(int index = 0; index < pokers.size(); index ++) { if(index == 0) { - builder.append("┌──┐"); - }else if(index == pokers.size() - 1) { - builder.append("──┐"); + builder.append("┌──╮"); }else { - builder.append("──┐"); + builder.append("──╮"); } } builder.append(System.lineSeparator()); @@ -286,11 +284,9 @@ public class PokerHelper { builder.append(System.lineSeparator()); for(int index = 0; index < pokers.size(); index ++) { if(index == 0) { - builder.append("└──┘"); - }else if(index == pokers.size() - 1) { - builder.append("──┘"); - }else { - builder.append("──┘"); + builder.append("└──╯"); + } else { + builder.append("──╯"); } } }