Removing the small ugly language file
This commit is contained in:
parent
27c45bf7f3
commit
e402797c54
11
src/com/massivecraft/factions/zcore/Lang.java
Normal file
11
src/com/massivecraft/factions/zcore/Lang.java
Normal 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:";
|
||||||
|
}
|
@ -173,7 +173,7 @@ public abstract class MCommand<T extends MPlugin>
|
|||||||
{
|
{
|
||||||
if (informSenderIfNot)
|
if (informSenderIfNot)
|
||||||
{
|
{
|
||||||
sender.sendMessage(p.txt.get("command.sender_must_me_player"));
|
sendMessageParsed(Lang.commandSenderMustBePlayer);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ public abstract class MCommand<T extends MPlugin>
|
|||||||
{
|
{
|
||||||
if (sender != null)
|
if (sender != null)
|
||||||
{
|
{
|
||||||
sender.sendMessage(p.txt.get("command.to_few_args"));
|
sendMessageParsed(Lang.commandToFewArgs);
|
||||||
sender.sendMessage(this.getUseageTemplate());
|
sender.sendMessage(this.getUseageTemplate());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -204,7 +204,7 @@ public abstract class MCommand<T extends MPlugin>
|
|||||||
{
|
{
|
||||||
// Get the to many string slice
|
// Get the to many string slice
|
||||||
List<String> theToMany = args.subList(this.requiredArgs.size() + this.optionalArgs.size(), args.size());
|
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());
|
sender.sendMessage(this.getUseageTemplate());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -132,16 +132,6 @@ public abstract class MPlugin extends JavaPlugin
|
|||||||
// These are not supposed to be used directly.
|
// These are not supposed to be used directly.
|
||||||
// They are loaded and used through the TextUtil instance for the plugin.
|
// 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> 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()
|
public void addTags()
|
||||||
{
|
{
|
||||||
@ -175,20 +165,15 @@ public abstract class MPlugin extends JavaPlugin
|
|||||||
|
|
||||||
public void initTXT()
|
public void initTXT()
|
||||||
{
|
{
|
||||||
this.addLang();
|
|
||||||
this.addTags();
|
this.addTags();
|
||||||
|
|
||||||
Type type = new TypeToken<Map<String, String>>(){}.getType();
|
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");
|
Map<String, String> tagsFromFile = this.persist.load(type, "tags");
|
||||||
if (tagsFromFile != null) this.tags.putAll(tagsFromFile);
|
if (tagsFromFile != null) this.tags.putAll(tagsFromFile);
|
||||||
this.persist.save(this.tags, "tags");
|
this.persist.save(this.tags, "tags");
|
||||||
|
|
||||||
this.txt = new TextUtil(this.tags, this.lang);
|
this.txt = new TextUtil(this.tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import ru.tehkode.permissions.PermissionManager;
|
import ru.tehkode.permissions.PermissionManager;
|
||||||
import ru.tehkode.permissions.bukkit.PermissionsEx;
|
import ru.tehkode.permissions.bukkit.PermissionsEx;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.zcore.Lang;
|
||||||
import com.massivecraft.factions.zcore.MPlugin;
|
import com.massivecraft.factions.zcore.MPlugin;
|
||||||
import com.nijiko.permissions.PermissionHandler;
|
import com.nijiko.permissions.PermissionHandler;
|
||||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||||
@ -33,7 +34,7 @@ public class PermUtil {
|
|||||||
|
|
||||||
public String getForbiddenMessage(String perm)
|
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);
|
String desc = permissionDescriptions.get(perm);
|
||||||
if (desc == null)
|
if (desc == null)
|
||||||
{
|
{
|
||||||
return p.txt.get("perm.dothat");
|
return Lang.permDoThat;
|
||||||
}
|
}
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
@ -10,24 +10,18 @@ import org.bukkit.Material;
|
|||||||
public class TextUtil
|
public class TextUtil
|
||||||
{
|
{
|
||||||
private Map<String, String> tags = new HashMap<String, String>();
|
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)
|
if (tags != null)
|
||||||
{
|
{
|
||||||
this.tags.putAll(tags);
|
this.tags.putAll(tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lang != null)
|
|
||||||
{
|
|
||||||
this.lang.putAll(lang);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get is supposed to be the way we reach registered lang
|
// Get is supposed to be the way we reach registered lang
|
||||||
// TODO: Is the parse
|
// TODO: Is the parse
|
||||||
public String get(String name)
|
/*public String get(String name)
|
||||||
{
|
{
|
||||||
String str = lang.get(name);
|
String str = lang.get(name);
|
||||||
if (str == null) str = name;
|
if (str == null) str = name;
|
||||||
@ -41,7 +35,7 @@ public class TextUtil
|
|||||||
if (str == null) str = name;
|
if (str == null) str = name;
|
||||||
|
|
||||||
return this.parse(str, args);
|
return this.parse(str, args);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// Parse is used to handle non registered text
|
// Parse is used to handle non registered text
|
||||||
public String parse(String str, Object... args)
|
public String parse(String str, Object... args)
|
||||||
@ -59,11 +53,6 @@ public class TextUtil
|
|||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getLang()
|
|
||||||
{
|
|
||||||
return lang;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String tags(String str)
|
public String tags(String str)
|
||||||
{
|
{
|
||||||
return replaceTags(str, this.tags);
|
return replaceTags(str, this.tags);
|
||||||
|
Loading…
Reference in New Issue
Block a user