Fix StringWriter

This commit is contained in:
filoghost 2014-09-01 16:23:48 +02:00
parent 32570b37e9
commit 3bc0d31d85
4 changed files with 24 additions and 16 deletions

View File

@ -95,7 +95,8 @@ public class FancyMessageImpl implements FancyMessage {
}
public String toJSONString() {
JsonWriter json = new JsonWriter(new StringWriter());
StringWriter stringWriter = new StringWriter();
JsonWriter json = new JsonWriter(stringWriter);
try {
if (messageParts.size() == 1) {
@ -111,7 +112,7 @@ public class FancyMessageImpl implements FancyMessage {
} catch (IOException e) {
throw new RuntimeException("invalid message");
}
return json.toString();
return stringWriter.toString();
}
public void send(Player player){
@ -123,7 +124,8 @@ public class FancyMessageImpl implements FancyMessage {
}
private String makeMultilineTooltip(String[] lines) {
JsonWriter json = new JsonWriter(new StringWriter());
StringWriter stringWriter = new StringWriter();
JsonWriter json = new JsonWriter(stringWriter);
try {
json.beginObject().name("id").value(1);
json.name("tag").beginObject().name("display").beginObject();
@ -138,7 +140,7 @@ public class FancyMessageImpl implements FancyMessage {
} catch (IOException e) {
throw new RuntimeException("invalid tooltip");
}
return json.toString();
return stringWriter.toString();
}
private void onClick(String name, String data) {

View File

@ -95,7 +95,8 @@ public class FancyMessageImpl implements FancyMessage {
}
public String toJSONString() {
JsonWriter json = new JsonWriter(new StringWriter());
StringWriter stringWriter = new StringWriter();
JsonWriter json = new JsonWriter(stringWriter);
try {
if (messageParts.size() == 1) {
@ -111,7 +112,7 @@ public class FancyMessageImpl implements FancyMessage {
} catch (IOException e) {
throw new RuntimeException("invalid message");
}
return json.toString();
return stringWriter.toString();
}
public void send(Player player){
@ -123,7 +124,8 @@ public class FancyMessageImpl implements FancyMessage {
}
private String makeMultilineTooltip(String[] lines) {
JsonWriter json = new JsonWriter(new StringWriter());
StringWriter stringWriter = new StringWriter();
JsonWriter json = new JsonWriter(stringWriter);
try {
json.beginObject().name("id").value(1);
json.name("tag").beginObject().name("display").beginObject();
@ -138,7 +140,7 @@ public class FancyMessageImpl implements FancyMessage {
} catch (IOException e) {
throw new RuntimeException("invalid tooltip");
}
return json.toString();
return stringWriter.toString();
}
private void onClick(String name, String data) {

View File

@ -95,7 +95,8 @@ public class FancyMessageImpl implements FancyMessage {
}
public String toJSONString() {
JsonWriter json = new JsonWriter(new StringWriter());
StringWriter stringWriter = new StringWriter();
JsonWriter json = new JsonWriter(stringWriter);
try {
if (messageParts.size() == 1) {
@ -111,7 +112,7 @@ public class FancyMessageImpl implements FancyMessage {
} catch (IOException e) {
throw new RuntimeException("invalid message");
}
return json.toString();
return stringWriter.toString();
}
public void send(Player player){
@ -123,7 +124,8 @@ public class FancyMessageImpl implements FancyMessage {
}
private String makeMultilineTooltip(String[] lines) {
JsonWriter json = new JsonWriter(new StringWriter());
StringWriter stringWriter = new StringWriter();
JsonWriter json = new JsonWriter(stringWriter);
try {
json.beginObject().name("id").value(1);
json.name("tag").beginObject().name("display").beginObject();
@ -138,7 +140,7 @@ public class FancyMessageImpl implements FancyMessage {
} catch (IOException e) {
throw new RuntimeException("invalid tooltip");
}
return json.toString();
return stringWriter.toString();
}
private void onClick(String name, String data) {

View File

@ -95,7 +95,8 @@ public class FancyMessageImpl implements FancyMessage {
}
public String toJSONString() {
JsonWriter json = new JsonWriter(new StringWriter());
StringWriter stringWriter = new StringWriter();
JsonWriter json = new JsonWriter(stringWriter);
try {
if (messageParts.size() == 1) {
@ -111,7 +112,7 @@ public class FancyMessageImpl implements FancyMessage {
} catch (IOException e) {
throw new RuntimeException("invalid message");
}
return json.toString();
return stringWriter.toString();
}
public void send(Player player){
@ -123,7 +124,8 @@ public class FancyMessageImpl implements FancyMessage {
}
private String makeMultilineTooltip(String[] lines) {
JsonWriter json = new JsonWriter(new StringWriter());
StringWriter stringWriter = new StringWriter();
JsonWriter json = new JsonWriter(stringWriter);
try {
json.beginObject().name("id").value(1);
json.name("tag").beginObject().name("display").beginObject();
@ -138,7 +140,7 @@ public class FancyMessageImpl implements FancyMessage {
} catch (IOException e) {
throw new RuntimeException("invalid tooltip");
}
return json.toString();
return stringWriter.toString();
}
private void onClick(String name, String data) {