mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-08-22 11:21:57 +00:00
Added many new MOTD possibilities + getI18n() to Essentials.java
This commit is contained in:
parent
8356624479
commit
4c1c3e4852
|
@ -597,4 +597,10 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||
{
|
||||
return userMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public I18n getI18n()
|
||||
{
|
||||
return i18n;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ public interface IEssentials extends Plugin
|
|||
boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix);
|
||||
|
||||
User getUser(Object base);
|
||||
|
||||
I18n getI18n();
|
||||
|
||||
User getOfflineUser(String name);
|
||||
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
package com.earth2me.essentials.textreader;
|
||||
|
||||
import com.earth2me.essentials.DescParseTickFormat;
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public class KeywordReplacer implements IText
|
||||
|
@ -27,6 +29,7 @@ public class KeywordReplacer implements IText
|
|||
{
|
||||
String displayName, ipAddress, balance, mails, world;
|
||||
String worlds, online, unique, playerlist, date, time;
|
||||
String worldTime12, worldTime24, worldDate, plugins;
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
final User user = ess.getUser(sender);
|
||||
|
@ -35,10 +38,13 @@ public class KeywordReplacer implements IText
|
|||
balance = Double.toString(user.getMoney());
|
||||
mails = Integer.toString(user.getMails().size());
|
||||
world = user.getLocation().getWorld().getName();
|
||||
worldTime12 = DescParseTickFormat.format12(user.getWorld().getTime());
|
||||
worldTime24 = DescParseTickFormat.format24(user.getWorld().getTime());
|
||||
worldDate = DateFormat.getDateInstance(DateFormat.MEDIUM, ess.getI18n().getCurrentLocale()).format(DescParseTickFormat.ticksToDate(user.getWorld().getTime()));
|
||||
}
|
||||
else
|
||||
{
|
||||
displayName = ipAddress = balance = mails = world = "";
|
||||
displayName = ipAddress = balance = mails = world = worldTime12 = worldTime24= worldDate = "";
|
||||
}
|
||||
|
||||
int playerHidden = 0;
|
||||
|
@ -77,9 +83,20 @@ public class KeywordReplacer implements IText
|
|||
playerlistBuilder.append(p.getDisplayName());
|
||||
}
|
||||
playerlist = playerlistBuilder.toString();
|
||||
|
||||
date = new SimpleDateFormat("MMMM/dd/yyyy").format(new Date());
|
||||
time = new SimpleDateFormat("hh:mm:ss").format(new Date());
|
||||
|
||||
final StringBuilder pluginlistBuilder = new StringBuilder();
|
||||
for (Plugin p : ess.getServer().getPluginManager().getPlugins())
|
||||
{
|
||||
if (pluginlistBuilder.length() > 0)
|
||||
{
|
||||
pluginlistBuilder.append(", ");
|
||||
}
|
||||
pluginlistBuilder.append(p.getDescription().getName());
|
||||
}
|
||||
plugins = pluginlistBuilder.toString();
|
||||
|
||||
date = DateFormat.getDateInstance(DateFormat.MEDIUM, ess.getI18n().getCurrentLocale()).format(new Date());
|
||||
time = DateFormat.getTimeInstance(DateFormat.MEDIUM, ess.getI18n().getCurrentLocale()).format(new Date());
|
||||
|
||||
for (int i = 0; i < input.getLines().size(); i++)
|
||||
{
|
||||
|
@ -95,6 +112,10 @@ public class KeywordReplacer implements IText
|
|||
line = line.replace("{PLAYERLIST}", playerlist);
|
||||
line = line.replace("{TIME}", time);
|
||||
line = line.replace("{DATE}", date);
|
||||
line = line.replace("{WORLDTIME12}", worldTime12);
|
||||
line = line.replace("{WORLDTIME24}", worldTime24);
|
||||
line = line.replace("{WORLDDATE}", worldDate);
|
||||
line = line.replace("{PLUGINS}", plugins);
|
||||
input.getLines().set(i, line);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue