Removing the small ugly language file

This commit is contained in:
Olof Larsson 2011-10-10 01:59:36 +02:00
parent 27c45bf7f3
commit e402797c54
5 changed files with 21 additions and 35 deletions

View File

@ -0,0 +1,11 @@
package com.massivecraft.factions.zcore;
public class Lang
{
public static final String permForbidden = "<b>You don't have permission to %s.";
public static final String permDoThat = "do that";
public static final String commandSenderMustBePlayer = "<b>This command can only be used by ingame players.";
public static final String commandToFewArgs = "<b>To few arguments. <i>Use like this:";
public static final String commandToManyArgs = "<b>Strange argument \"<p>%s<b>\". <i>Use the command like this:";
}

View File

@ -173,7 +173,7 @@ public abstract class MCommand<T extends MPlugin>
{
if (informSenderIfNot)
{
sender.sendMessage(p.txt.get("command.sender_must_me_player"));
sendMessageParsed(Lang.commandSenderMustBePlayer);
}
return false;
}
@ -192,7 +192,7 @@ public abstract class MCommand<T extends MPlugin>
{
if (sender != null)
{
sender.sendMessage(p.txt.get("command.to_few_args"));
sendMessageParsed(Lang.commandToFewArgs);
sender.sendMessage(this.getUseageTemplate());
}
return false;
@ -204,7 +204,7 @@ public abstract class MCommand<T extends MPlugin>
{
// Get the to many string slice
List<String> theToMany = args.subList(this.requiredArgs.size() + this.optionalArgs.size(), args.size());
sender.sendMessage(String.format(p.txt.get("command.to_many_args"), TextUtil.implode(theToMany, " ")));
sendMessageParsed(Lang.commandToManyArgs, TextUtil.implode(theToMany, " "));
sender.sendMessage(this.getUseageTemplate());
}
return false;

View File

@ -132,16 +132,6 @@ public abstract class MPlugin extends JavaPlugin
// These are not supposed to be used directly.
// They are loaded and used through the TextUtil instance for the plugin.
public Map<String, String> tags = new LinkedHashMap<String, String>();
public Map<String, String> lang = new LinkedHashMap<String, String>();
public void addLang()
{
this.lang.put("perm.forbidden", "<b>You don't have permission to %s.");
this.lang.put("perm.dothat", "do that");
this.lang.put("command.sender_must_me_player", "<b>This command can only be used by ingame players.");
this.lang.put("command.to_few_args", "<b>To few arguments. <i>Use like this:");
this.lang.put("command.to_many_args", "<b>Strange argument \"<p>%s<b>\". <i>Use the command like this:");
}
public void addTags()
{
@ -175,20 +165,15 @@ public abstract class MPlugin extends JavaPlugin
public void initTXT()
{
this.addLang();
this.addTags();
Type type = new TypeToken<Map<String, String>>(){}.getType();
Map<String, String> langFromFile = this.persist.load(type, "lang");
if (langFromFile != null) this.lang.putAll(langFromFile);
this.persist.save(this.lang, "lang");
Map<String, String> tagsFromFile = this.persist.load(type, "tags");
if (tagsFromFile != null) this.tags.putAll(tagsFromFile);
this.persist.save(this.tags, "tags");
this.txt = new TextUtil(this.tags, this.lang);
this.txt = new TextUtil(this.tags);
}

View File

@ -12,6 +12,7 @@ import org.bukkit.plugin.Plugin;
import ru.tehkode.permissions.PermissionManager;
import ru.tehkode.permissions.bukkit.PermissionsEx;
import com.massivecraft.factions.zcore.Lang;
import com.massivecraft.factions.zcore.MPlugin;
import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
@ -33,7 +34,7 @@ public class PermUtil {
public String getForbiddenMessage(String perm)
{
return p.txt.get("perm.forbidden", getPermissionDescription(perm));
return p.txt.parse(Lang.permForbidden, getPermissionDescription(perm));
}
/**
@ -69,7 +70,7 @@ public class PermUtil {
String desc = permissionDescriptions.get(perm);
if (desc == null)
{
return p.txt.get("perm.dothat");
return Lang.permDoThat;
}
return desc;
}

View File

@ -10,24 +10,18 @@ import org.bukkit.Material;
public class TextUtil
{
private Map<String, String> tags = new HashMap<String, String>();
private Map<String, String> lang = new HashMap<String, String>();
public TextUtil(Map<String, String> tags, Map<String, String> lang)
public TextUtil(Map<String, String> tags)
{
if (tags != null)
{
this.tags.putAll(tags);
}
if (lang != null)
{
this.lang.putAll(lang);
}
}
// Get is supposed to be the way we reach registered lang
// TODO: Is the parse
public String get(String name)
/*public String get(String name)
{
String str = lang.get(name);
if (str == null) str = name;
@ -41,7 +35,7 @@ public class TextUtil
if (str == null) str = name;
return this.parse(str, args);
}
}*/
// Parse is used to handle non registered text
public String parse(String str, Object... args)
@ -59,11 +53,6 @@ public class TextUtil
return tags;
}
public Map<String, String> getLang()
{
return lang;
}
public String tags(String str)
{
return replaceTags(str, this.tags);