mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-28 12:07:38 +01:00
updated to use corrected joinList function.
This commit is contained in:
parent
53a73998a2
commit
6946488e0d
@ -11,7 +11,6 @@ import java.net.URL;
|
|||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.DecimalFormatSymbols;
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
@ -470,22 +469,34 @@ public class Util
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String joinList(Object... list)
|
public static String joinList(Object... list)
|
||||||
|
{
|
||||||
|
return joinList(", ", list);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String joinList(String seperator, Object... list)
|
||||||
{
|
{
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
for (Object each : list)
|
for (Object each : list)
|
||||||
{
|
{
|
||||||
if (buf.length() > 0)
|
if (buf.length() > 0)
|
||||||
{
|
{
|
||||||
buf.append(", ");
|
buf.append(seperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(each instanceof List)
|
if(each instanceof List)
|
||||||
{
|
{
|
||||||
buf.append(joinList(((List)each).toArray()));
|
buf.append(joinList(seperator, ((List)each).toArray()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buf.append(each.toString());
|
try
|
||||||
|
{
|
||||||
|
buf.append(each.toString());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
buf.append(each.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
|
@ -55,7 +55,7 @@ public class Commandhome extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
user.sendMessage(Util.format("homes", homes.toString()));
|
user.sendMessage(Util.format("homes", Util.joinList(homes)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.Util;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
@ -14,12 +15,6 @@ public class Commandjails extends EssentialsCommand
|
|||||||
@Override
|
@Override
|
||||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||||
{
|
{
|
||||||
StringBuilder jailList = new StringBuilder();
|
sender.sendMessage("§7" + Util.joinList(" ", ess.getJail().getJails()));
|
||||||
for (String j : ess.getJail().getJails())
|
|
||||||
{
|
|
||||||
jailList.append(j);
|
|
||||||
jailList.append(' ');
|
|
||||||
}
|
|
||||||
sender.sendMessage("§7" + jailList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,16 +55,6 @@ public class Commandrepair extends EssentialsCommand
|
|||||||
|
|
||||||
String armor = repairItems(user.getInventory().getArmorContents());
|
String armor = repairItems(user.getInventory().getArmorContents());
|
||||||
|
|
||||||
if (armor.length() > 0)
|
|
||||||
{
|
|
||||||
if (itemList.length() > 0)
|
|
||||||
{
|
|
||||||
itemList.append(", ");
|
|
||||||
}
|
|
||||||
|
|
||||||
itemList.append(armor);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemList.length() == 0)
|
if (itemList.length() == 0)
|
||||||
{
|
{
|
||||||
user.sendMessage(Util.format("repairNone"));
|
user.sendMessage(Util.format("repairNone"));
|
||||||
@ -72,7 +62,7 @@ public class Commandrepair extends EssentialsCommand
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
charge(user);
|
charge(user);
|
||||||
user.sendMessage(Util.format("repair", itemList.toString()));
|
user.sendMessage(Util.format("repair", Util.joinList(itemList)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,16 +55,7 @@ public class Commandwarp extends EssentialsCommand
|
|||||||
user.sendMessage(Util.format("warpsCount", warpNameList.size(), page, (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE)));
|
user.sendMessage(Util.format("warpsCount", warpNameList.size(), page, (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE)));
|
||||||
}
|
}
|
||||||
final int warpPage = (page - 1) * WARPS_PER_PAGE;
|
final int warpPage = (page - 1) * WARPS_PER_PAGE;
|
||||||
final StringBuilder sb = new StringBuilder();
|
user.sendMessage(Util.joinList(warpNameList.subList(warpPage, warpPage+Math.min(warpNameList.size() - warpPage, WARPS_PER_PAGE))));
|
||||||
for (int i = 0; i < Math.min(warpNameList.size() - warpPage, WARPS_PER_PAGE); i++)
|
|
||||||
{
|
|
||||||
if (i > 0)
|
|
||||||
{
|
|
||||||
sb.append(", ");
|
|
||||||
}
|
|
||||||
sb.append(warpNameList.get(i + warpPage));
|
|
||||||
}
|
|
||||||
user.sendMessage(sb.toString());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args.length > 0)
|
if (args.length > 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user