Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Commit

Permalink
Msons are immutable, so reuse them
Browse files Browse the repository at this point in the history
  • Loading branch information
TheComputerGeek2 authored and oloflarsson committed Nov 8, 2017
1 parent fa9c320 commit 81ca676
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/com/massivecraft/massivecore/mson/Mson.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public class Mson implements Serializable
public static final transient Mson EMPTY = mson("");
public static final transient Mson NEWLINE = mson("\n");
public static final transient Mson DOT = mson(".");
public static final transient Mson NULL = mson("NULL");
public static final transient Mson SPACE_AND_SPACE = mson(" and ");
public static final transient Mson COMMA_SPACE = mson(", ");

// -------------------------------------------- //
// GSON
Expand Down Expand Up @@ -1082,7 +1085,7 @@ public static Mson implode(final Object[] list, final Mson glue, final Mson form
for (int i = 0; i < list.length; i++)
{
Object item = list[i];
Mson part = (item == null ? mson("NULL") : Mson.mson(item));
Mson part = (item == null ? NULL : Mson.mson(item));

if (i != 0)
{
Expand Down Expand Up @@ -1145,11 +1148,11 @@ public static Mson implodeCommaAnd(final Collection<?> objects, Mson comma, Mson
}
public static Mson implodeCommaAndDot(final Collection<?> objects, ChatColor color)
{
return implodeCommaAndDot(objects, mson(", ").color(color), mson(" and ").color(color), mson(".").color(color));
return implodeCommaAndDot(objects, COMMA_SPACE.color(color), SPACE_AND_SPACE.color(color), DOT.color(color));
}
public static Mson implodeCommaAnd(final Collection<?> objects, ChatColor color)
{
return implodeCommaAndDot(objects, mson(", ").color(color), mson(" and ").color(color), mson());
return implodeCommaAndDot(objects, COMMA_SPACE.color(color), SPACE_AND_SPACE.color(color), mson());
}
public static Mson implodeCommaAndDot(final Collection<?> objects)
{
Expand Down

0 comments on commit 81ca676

Please sign in to comment.