From 3bc0d31d85af5d7621f80b2e5c8ca6ff8b5d8974 Mon Sep 17 00:00:00 2001 From: filoghost Date: Mon, 1 Sep 2014 16:23:48 +0200 Subject: [PATCH] Fix StringWriter --- .../holograms/nms/v1_7_R1/FancyMessageImpl.java | 10 ++++++---- .../holograms/nms/v1_7_R2/FancyMessageImpl.java | 10 ++++++---- .../holograms/nms/v1_7_R3/FancyMessageImpl.java | 10 ++++++---- .../holograms/nms/v1_7_R4/FancyMessageImpl.java | 10 ++++++---- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R1/FancyMessageImpl.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R1/FancyMessageImpl.java index dd9eb4f1..1ef005da 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R1/FancyMessageImpl.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R1/FancyMessageImpl.java @@ -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) { diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R2/FancyMessageImpl.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R2/FancyMessageImpl.java index 3c26adec..c7d8e54a 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R2/FancyMessageImpl.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R2/FancyMessageImpl.java @@ -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) { diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R3/FancyMessageImpl.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R3/FancyMessageImpl.java index 480bd386..67cfddf1 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R3/FancyMessageImpl.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R3/FancyMessageImpl.java @@ -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) { diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R4/FancyMessageImpl.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R4/FancyMessageImpl.java index ffdde71c..06e73ba6 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R4/FancyMessageImpl.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R4/FancyMessageImpl.java @@ -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) {