Update remote staff fetcher to translate... (#623)

* Update remote staff fetcher to translate...

...color codes, use proper link, and use multiline entry management

* Implement maven shading for external libraries and set up remote staff fetcher to appropriately handle html pages

* Use maven instead of ant with travis
This commit is contained in:
Alexander Meech 2016-10-18 20:49:54 -04:00 committed by Christopher Martin
parent 9cc5742668
commit 13050a81cd
4 changed files with 279 additions and 21 deletions

View file

@ -1,5 +1,5 @@
language: java language: java
script: ant main script: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
sudo: false sudo: false
jdk: jdk:
- oraclejdk7 - oraclejdk7

223
dependency-reduced-pom.xml Normal file
View file

@ -0,0 +1,223 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.projectkorra</groupId>
<artifactId>projectkorra</artifactId>
<version>don't matter</version>
<build>
<sourceDirectory>${project.basedir}/src</sourceDirectory>
<resources>
<resource>
<filtering>true</filtering>
<directory>${basedir}/src</directory>
<includes>
<include>plugin.yml</include>
</includes>
</resource>
</resources>
<finalName>${project.name}</finalName>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration />
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>worldedit-worldguard-repo</id>
<url>http://maven.sk89q.com/repo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>commons-lang</artifactId>
<groupId>commons-lang</groupId>
</exclusion>
<exclusion>
<artifactId>gson</artifactId>
<groupId>com.google.code.gson</groupId>
</exclusion>
<exclusion>
<artifactId>ebean</artifactId>
<groupId>org.avaje</groupId>
</exclusion>
<exclusion>
<artifactId>snakeyaml</artifactId>
<groupId>org.yaml</groupId>
</exclusion>
<exclusion>
<artifactId>bungeecord-chat</artifactId>
<groupId>net.md-5</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>
<version>6.1.1-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>worldedit</artifactId>
<groupId>com.sk89q</groupId>
</exclusion>
<exclusion>
<artifactId>bukkit-classloader-check</artifactId>
<groupId>com.sk89q.spigot</groupId>
</exclusion>
<exclusion>
<artifactId>bukkit</artifactId>
<groupId>org.bukkit</groupId>
</exclusion>
<exclusion>
<artifactId>commandbook</artifactId>
<groupId>com.sk89q</groupId>
</exclusion>
<exclusion>
<artifactId>jsr305</artifactId>
<groupId>com.google.code.findbugs</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>6.1.4-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>dummypermscompat</artifactId>
<groupId>com.sk89q</groupId>
</exclusion>
<exclusion>
<artifactId>worldedit-core</artifactId>
<groupId>com.sk89q.worldedit</groupId>
</exclusion>
<exclusion>
<artifactId>bukkit</artifactId>
<groupId>org.bukkit</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>junit</artifactId>
<groupId>junit</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>me.ryanhamshire</groupId>
<artifactId>GriefPrevention</artifactId>
<version>10.5.3</version>
<scope>system</scope>
<systemPath>C:\Users\alexj\Desktop\ProjectKorra\code\ProjectKorra/lib/GriefPrevention 10.5.3.jar</systemPath>
</dependency>
<dependency>
<groupId>com.griefcraft</groupId>
<artifactId>lwc</artifactId>
<version>4.5.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>C:\Users\alexj\Desktop\ProjectKorra\code\ProjectKorra/lib/LWC.jar</systemPath>
</dependency>
<dependency>
<groupId>com.massivecraft</groupId>
<artifactId>massivecore</artifactId>
<version>2.7.5</version>
<scope>system</scope>
<systemPath>C:\Users\alexj\Desktop\ProjectKorra\code\ProjectKorra/lib/MassiveCore 2.7.5.jar</systemPath>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus</artifactId>
<version>3.11.0-RC-sMD5NET-b739</version>
<scope>system</scope>
<systemPath>C:\Users\alexj\Desktop\ProjectKorra\code\ProjectKorra/lib/NoCheatPlus.jar</systemPath>
</dependency>
<dependency>
<groupId>com.palmergames.bukkit</groupId>
<artifactId>towny</artifactId>
<version>0.89.2.0</version>
<scope>system</scope>
<systemPath>C:\Users\alexj\Desktop\ProjectKorra\code\ProjectKorra/lib/Towny.jar</systemPath>
</dependency>
<dependency>
<groupId>com.bekvon.bukkit</groupId>
<artifactId>residence</artifactId>
<version>4.0.0.4</version>
<scope>system</scope>
<systemPath>C:\Users\alexj\Desktop\ProjectKorra\code\ProjectKorra/lib/Residence4.0.0.4.jar</systemPath>
</dependency>
<dependency>
<groupId>com.projectkorra</groupId>
<artifactId>spirits</artifactId>
<version>1.0.0 PRIVATE PREALPHA</version>
<scope>system</scope>
<systemPath>C:\Users\alexj\Desktop\ProjectKorra\code\ProjectKorra/lib/ProjectKorraSpirits.jar</systemPath>
</dependency>
<dependency>
<groupId>com.projectkorra</groupId>
<artifactId>rpg</artifactId>
<version>1.0.2</version>
<scope>system</scope>
<systemPath>C:\Users\alexj\Desktop\ProjectKorra\code\ProjectKorra/lib/ProjectKorraRPG.jar</systemPath>
</dependency>
<dependency>
<groupId>com.projectkorra</groupId>
<artifactId>items</artifactId>
<version>1.2.0</version>
<scope>system</scope>
<systemPath>C:\Users\alexj\Desktop\ProjectKorra\code\ProjectKorra/lib/ProjectKorraItems.jar</systemPath>
</dependency>
<dependency>
<groupId>net.sacredlabyrinth.Phaed</groupId>
<artifactId>PreciousStones</artifactId>
<version>9.7.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>C:\Users\alexj\Desktop\ProjectKorra\code\ProjectKorra/lib/PreciousStones 9.7.1.jar</systemPath>
</dependency>
<dependency>
<groupId>com.massivecraft</groupId>
<artifactId>factions</artifactId>
<version>2.7.5</version>
<scope>system</scope>
<systemPath>C:\Users\alexj\Desktop\ProjectKorra\code\ProjectKorra/lib/Factions 2.7.5.jar</systemPath>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
</project>

27
pom.xml
View file

@ -36,6 +36,23 @@
</includes> </includes>
</resource> </resource>
</resources> </resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build> </build>
<dependencies> <dependencies>
<!--Spigot API--> <!--Spigot API-->
@ -50,24 +67,34 @@
<groupId>com.sk89q</groupId> <groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId> <artifactId>worldguard</artifactId>
<version>6.1.1-SNAPSHOT</version> <version>6.1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency> </dependency>
<!--WorldGuard depends on WorldEdit--> <!--WorldGuard depends on WorldEdit-->
<dependency> <dependency>
<groupId>com.sk89q.worldedit</groupId> <groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId> <artifactId>worldedit-bukkit</artifactId>
<version>6.1.4-SNAPSHOT</version> <version>6.1.4-SNAPSHOT</version>
<scope>provided</scope>
</dependency> </dependency>
<!--Google stuff--> <!--Google stuff-->
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>19.0</version> <version>19.0</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.googlecode.json-simple</groupId> <groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId> <artifactId>json-simple</artifactId>
<version>1.1.1</version> <version>1.1.1</version>
<scope>provided</scope>
</dependency> </dependency>
<!-- jsoup HTML parser library @ http://jsoup.org/ -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.9.2</version>
</dependency>
<dependency> <dependency>
<groupId>me.ryanhamshire</groupId> <groupId>me.ryanhamshire</groupId>
<artifactId>GriefPrevention</artifactId> <artifactId>GriefPrevention</artifactId>

View file

@ -1,15 +1,17 @@
package com.projectkorra.projectkorra.command; package com.projectkorra.projectkorra.command;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -17,6 +19,8 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.Element;
@ -52,29 +56,33 @@ public class WhoCommand extends PKCommand {
{ {
public void run() public void run()
{ {
try { try
{
// Create a URL for the desired page // Create a URL for the desired page
URL url = new URL("http://www.projectkorra.com/internals/staff.html"); URLConnection url = new URL("http://www.projectkorra.com/staff.html").openConnection();
url.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11");
// Read all the text returned by the server // Read all the text returned by the server
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); BufferedReader in = new BufferedReader(new InputStreamReader(url.getInputStream(), Charset.forName("UTF-8")));
String unparsed = in.readLine(); // Read first line String unparsed;
if (unparsed != null) while ((unparsed = in.readLine()) != null)
{ {
String[] staffUUIDS = unparsed.split("\\|"); Document doc = Jsoup.parse(unparsed);
for (String s : staffUUIDS) String parsed = doc.body().text();
String[] staffEntry = parsed.split("/");
if (staffEntry.length >= 2)
{ {
String[] parts = s.split("/"); staff.put(staffEntry[0], ChatColor.translateAlternateColorCodes('&', staffEntry[1]));
if (parts.length == 2)
{
staff.put(parts[0], parts[1]);
}
} }
} }
in.close(); in.close();
} catch (MalformedURLException e) { }
catch (MalformedURLException e)
{
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { }
catch (IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }