Use guava's stream toString method

This commit is contained in:
Gabriele C 2017-01-22 23:24:04 +01:00
parent a32319df28
commit 35a3b44168
2 changed files with 22 additions and 17 deletions

29
pom.xml
View File

@ -6,9 +6,13 @@
<groupId>me.jaimemartz</groupId>
<artifactId>lobbybalancer</artifactId>
<version>2.0.7</version>
<version>2.0.8-SNAPSHOT</version>
<name>LobbyBalancer</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>bungee-repo</id>
@ -22,12 +26,16 @@
<id>inventive-repo</id>
<url>http://repo.inventivetalent.org/content/groups/public/</url>
</repository>
<repository>
<id>xephi-repo</id>
<url>http://ci.xephi.fr/plugin/repository/everything/</url>
</repository>
</repositories>
<build>
<defaultGoal>clean install</defaultGoal>
<plugins>
<plugin>
<version>3.1</version>
<version>3.6.0</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
@ -38,7 +46,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
@ -63,8 +71,7 @@
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.10-SNAPSHOT</version>
<type>jar</type>
<version>1.11-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -77,26 +84,24 @@
<groupId>org.inventivetalent.update</groupId>
<artifactId>bungee</artifactId>
<version>1.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.jaimemartz</groupId>
<artifactId>faucet-bungee</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.maxmind.geoip2</groupId>
<artifactId>geoip2</artifactId>
<version>2.8.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@ -1,11 +1,11 @@
package me.jaimemartz.lobbybalancer.manager;
import com.google.common.io.CharStreams;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.api.scheduler.ScheduledTask;
import org.apache.commons.io.IOUtils;
import org.jpaste.exceptions.PasteException;
import org.jpaste.pastebin.PasteExpireDate;
import org.jpaste.pastebin.PastebinLink;
@ -13,7 +13,7 @@ import org.jpaste.pastebin.PastebinPaste;
import java.io.File;
import java.io.FileInputStream;
import java.nio.charset.Charset;
import java.io.InputStreamReader;
import java.util.concurrent.TimeUnit;
public enum PasteHelper {
@ -36,7 +36,7 @@ public enum PasteHelper {
paste.setVisibility(PastebinPaste.VISIBILITY_UNLISTED);
paste.setPasteFormat("yaml");
try (FileInputStream stream = new FileInputStream(file)) {
paste.setContents(IOUtils.toString(stream, Charset.forName("UTF-8")));
paste.setContents(CharStreams.toString(new InputStreamReader(stream, "UTF-8")));
}
PastebinLink link = paste.paste();
return link.getLink().toString();
@ -60,7 +60,7 @@ public enum PasteHelper {
paste.setVisibility(PastebinPaste.VISIBILITY_UNLISTED);
paste.setPasteFormat("yaml");
try (FileInputStream stream = new FileInputStream(file)) {
paste.setContents(IOUtils.toString(stream, Charset.forName("UTF-8")));
paste.setContents(CharStreams.toString(new InputStreamReader(stream, "UTF-8")));
}
PastebinLink link = paste.paste();
return link.getLink().toString();
@ -85,7 +85,7 @@ public enum PasteHelper {
paste.setVisibility(PastebinPaste.VISIBILITY_UNLISTED);
paste.setPasteFormat("text");
try (FileInputStream stream = new FileInputStream(file)) {
paste.setContents(IOUtils.toString(stream, Charset.forName("UTF-8")));
paste.setContents(CharStreams.toString(new InputStreamReader(stream, "UTF-8")));
}
PastebinLink link = paste.paste();
return link.getLink().toString();