From b2d71bd7852fd7183b52ead618151775cf860c05 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sat, 10 Jun 2017 09:49:10 -0700 Subject: [PATCH] Added Hello Players page --- .../presents/hello/HelloComponent.java | 2 ++ .../presents/hello/pages/HelloDataPage.java | 5 +-- .../hello/pages/HelloPlayersPage.java | 33 +++++++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 src/main/java/buttondevteam/presents/hello/pages/HelloPlayersPage.java diff --git a/src/main/java/buttondevteam/presents/hello/HelloComponent.java b/src/main/java/buttondevteam/presents/hello/HelloComponent.java index 3a93a41..bc66783 100644 --- a/src/main/java/buttondevteam/presents/hello/HelloComponent.java +++ b/src/main/java/buttondevteam/presents/hello/HelloComponent.java @@ -15,6 +15,7 @@ import buttondevteam.presents.hello.effects.HelloMagicPotato; import buttondevteam.presents.hello.effects.HelloParticle; import buttondevteam.presents.hello.effects.HelloSound; import buttondevteam.presents.hello.pages.HelloDataPage; +import buttondevteam.presents.hello.pages.HelloPlayersPage; import buttondevteam.presents.hello.pages.HelloWorldPage; public class HelloComponent extends Component{ @@ -35,5 +36,6 @@ public class HelloComponent extends Component{ this.addPage(plugin, new HelloWorldPage()); this.addPage(plugin, new HelloDataPage()); + this.addPage(plugin, new HelloPlayersPage(plugin)); } } diff --git a/src/main/java/buttondevteam/presents/hello/pages/HelloDataPage.java b/src/main/java/buttondevteam/presents/hello/pages/HelloDataPage.java index 2c2dc84..b673a14 100644 --- a/src/main/java/buttondevteam/presents/hello/pages/HelloDataPage.java +++ b/src/main/java/buttondevteam/presents/hello/pages/HelloDataPage.java @@ -15,10 +15,7 @@ public class HelloDataPage extends Page{ @Override public Response handlePage(HttpExchange exchange) { - String responseString = - "

Come check out this data!

" - + "

" + data + "

" - + "

This is not suspicious shit at all

"; + String responseString = String.valueOf(data); return new Response(200, responseString, exchange); } diff --git a/src/main/java/buttondevteam/presents/hello/pages/HelloPlayersPage.java b/src/main/java/buttondevteam/presents/hello/pages/HelloPlayersPage.java new file mode 100644 index 0000000..1eea68a --- /dev/null +++ b/src/main/java/buttondevteam/presents/hello/pages/HelloPlayersPage.java @@ -0,0 +1,33 @@ +package buttondevteam.presents.hello.pages; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import com.sun.net.httpserver.HttpExchange; + +import buttondevteam.website.io.Response; +import buttondevteam.website.page.Page; + +public class HelloPlayersPage extends Page{ + private JavaPlugin plugin; + + public HelloPlayersPage(JavaPlugin plugin){ + this.plugin = plugin; + } + + @Override + public String GetName() { + // TODO Auto-generated method stub + return "ali/hello/players"; + } + + @Override + public Response handlePage(HttpExchange exchange) { + String playerList = ""; + for(Player player : plugin.getServer().getOnlinePlayers()){ + playerList += player.getPlayerListName() + "
"; + } + return new Response(200, playerList, exchange); + } + +}