Merge pull request #9 from BlockCat/master

Start of: operation: letuserstranslatethepluginforus
This commit is contained in:
BlockCat 2013-08-06 23:45:48 -07:00
commit 08de2395df
3 changed files with 284 additions and 271 deletions

View File

@ -431,7 +431,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
public String getPromptText(ConversationContext context) { public String getPromptText(ConversationContext context) {
String text = GOLD + "- Create Quest -\n"; String text = GOLD + "- Create Quest -\n";
text += AQUA + "Create new Quest " + GOLD + "- Enter a name for the Quest (Or enter \'cancel\' to return)"; text += AQUA + "Create new Quest " + GOLD + "- " + Lang.get("enterQuestName");
return text; return text;

View File

@ -69,6 +69,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
public class Quests extends JavaPlugin implements ConversationAbandonedListener, ColorUtil { public class Quests extends JavaPlugin implements ConversationAbandonedListener, ColorUtil {
public final static Logger log = Logger.getLogger("Minecraft");
public static Economy economy = null; public static Economy economy = null;
public static Permission permission = null; public static Permission permission = null;
public static mcMMO mcmmo = null; public static mcMMO mcmmo = null;
@ -77,35 +78,35 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
public static boolean npcEffects = true; public static boolean npcEffects = true;
public static boolean broadcastPartyCreation = true; public static boolean broadcastPartyCreation = true;
public static int maxPartySize = 0; public static int maxPartySize = 0;
public static String effect = "note";
final List<String> questerBlacklist = new LinkedList<String>();
public ConversationFactory conversationFactory;
ConversationFactory NPCConversationFactory;
QuestFactory questFactory;
EventFactory eventFactory;
Vault vault = null;
public CitizensPlugin citizens;
PlayerListener pListener;
NpcEffectThread effListener;
NpcListener npcListener;
EpicBossListener bossListener;
public Denizen denizen = null;
QuestTaskTrigger trigger;
final Map<String, Quester> questers = new HashMap<String, Quester>();
final LinkedList<Quest> quests = new LinkedList<Quest>();
public final LinkedList<Event> events = new LinkedList<Event>();
final LinkedList<NPC> questNPCs = new LinkedList<NPC>();
boolean allowCommands = true;
boolean allowCommandsForNpcQuests = false;
boolean showQuestReqs = true;
boolean allowQuitting = true;
boolean debug = false;
boolean load = false;
int killDelay = 0;
public static int acceptTimeout = 20; public static int acceptTimeout = 20;
public static int inviteTimeout = 20; public static int inviteTimeout = 20;
int totalQuestPoints = 0; public static String effect = "note";
public final static Logger log = Logger.getLogger("Minecraft"); public final Map<String, Quester> questers = new HashMap<String, Quester>();
public final List<String> questerBlacklist = new LinkedList<String>();
public final LinkedList<Quest> quests = new LinkedList<Quest>();
public final LinkedList<Event> events = new LinkedList<Event>();
public final LinkedList<NPC> questNPCs = new LinkedList<NPC>();
public ConversationFactory conversationFactory;
public ConversationFactory NPCConversationFactory;
public QuestFactory questFactory;
public EventFactory eventFactory;
public Vault vault = null;
public CitizensPlugin citizens;
public PlayerListener pListener;
public NpcListener npcListener;
public EpicBossListener bossListener;
public NpcEffectThread effListener;
public Denizen denizen = null;
public QuestTaskTrigger trigger;
public boolean allowCommands = true;
public boolean allowCommandsForNpcQuests = false;
public boolean showQuestReqs = true;
public boolean allowQuitting = true;
public boolean debug = false;
public boolean load = false;
public int killDelay = 0;
public int totalQuestPoints = 0;
public Lang lang;
@Override @Override
public void onEnable() { public void onEnable() {
@ -180,7 +181,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
loadConfig(); loadConfig();
Lang.initPhrases(); lang = new Lang(this);
lang.initPhrases();
lang.save();
if (new File(this.getDataFolder(), "quests.yml").exists() == false) { if (new File(this.getDataFolder(), "quests.yml").exists() == false) {
printInfo("[Quests] Quest data not found, writing default to file."); printInfo("[Quests] Quest data not found, writing default to file.");
@ -327,6 +330,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
killDelay = config.getInt("kill-delay"); killDelay = config.getInt("kill-delay");
acceptTimeout = config.getInt("accept-timeout"); acceptTimeout = config.getInt("accept-timeout");
if (config.contains("language")) {
Lang.lang = config.getString("language");
} else {
config.set("language", "en");
}
if(config.contains("broadcast-party-creation")){ if(config.contains("broadcast-party-creation")){
broadcastPartyCreation = config.getBoolean("broadcast-party-creation"); broadcastPartyCreation = config.getBoolean("broadcast-party-creation");
}else{ }else{

View File

@ -1,50 +1,32 @@
package me.blackvein.quests.util; package me.blackvein.quests.util;
import java.util.HashMap; import java.io.File;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import me.blackvein.quests.Quests;
import org.bukkit.configuration.file.YamlConfiguration;
public class Lang { public class Lang {
public static String lang = "en"; public static String lang = "en";
private static Map<String, String> en = new HashMap<String, String>();
private static Map<String, String> fr = new HashMap<String, String>();
private static Map<String, String> es = new HashMap<String, String>();
private static Map<String, String> de = new HashMap<String, String>();
private static Map<String, String> sv = new HashMap<String, String>();
private static Map<String, String> nl = new HashMap<String, String>();
private static Map<String, String> pl = new HashMap<String, String>();
private static Map<String, String> da = new HashMap<String, String>();
private static Map<String, String> zh = new HashMap<String, String>();
private static Map<String, String> no = new HashMap<String, String>();
public static String get(String key){ private static Map<String, String> en = new LinkedHashMap<String, String>();
if(lang.equals("en")) private Quests plugin;
return en.get(key);
else if(lang.equals("fr"))
return fr.get(key);
else if(lang.equals("es"))
return es.get(key);
else if(lang.equals("de"))
return de.get(key);
else if(lang.equals("sv"))
return sv.get(key);
else if(lang.equals("nl"))
return nl.get(key);
else if(lang.equals("pl"))
return pl.get(key);
else if(lang.equals("da"))
return da.get(key);
else if(lang.equals("zh"))
return zh.get(key);
else if(lang.equals("no"))
return no.get(key);
else
return en.get(key);
public Lang (Quests plugin) {
this.plugin = plugin;
} }
public static void initPhrases(){ public static String get(String key){
return en.get(key);
}
public void initPhrases(){
//English //English
@ -184,17 +166,17 @@ public class Lang {
en.put("eventEditorSetPotionDurationsPrompt", "Enter effect durations (in milliseconds) separating each one by a space, or enter \"cancel\" to return"); en.put("eventEditorSetPotionDurationsPrompt", "Enter effect durations (in milliseconds) separating each one by a space, or enter \"cancel\" to return");
en.put("eventEditorSetPotionMagnitudesPrompt", "Enter potion effect magnitudes separating each one by a space, or enter \"cancel\" to return"); en.put("eventEditorSetPotionMagnitudesPrompt", "Enter potion effect magnitudes separating each one by a space, or enter \"cancel\" to return");
en.put("eventEditorSetHungerPrompt", "Enter hunger level, or -1 to remove it"); en.put("eventEditorSetHungerPrompt", "Enter hunger level, or -1 to remove it");
en.put("eventEditorHungerLevelAtLeastZero", "Hunger level must be at least 0!"); en.put("eventEditorHungerLevelAtLeastZero", "Hunger level must be at least 0!");
en.put("eventEditorSetSaturationPrompt", "Enter saturation level, or -1 to remove it"); en.put("eventEditorSetSaturationPrompt", "Enter saturation level, or -1 to remove it");
en.put("eventEditorSaturationLevelAtLeastZero", "Saturation level must be at least 0!"); en.put("eventEditorSaturationLevelAtLeastZero", "Saturation level must be at least 0!");
en.put("eventEditorSetHealthPrompt", "Enter health level, or -1 to remove it"); en.put("eventEditorSetHealthPrompt", "Enter health level, or -1 to remove it");
en.put("eventEditorHealthLevelAtLeastZero", "Health level must be at least 0!"); en.put("eventEditorHealthLevelAtLeastZero", "Health level must be at least 0!");
en.put("eventEditorSetTeleportPrompt", "Right-click on a block to teleport the player to, then enter \"done\" to finish,\nor enter \"clear\" to clear the teleport location, or \"cancel\" to return"); en.put("eventEditorSetTeleportPrompt", "Right-click on a block to teleport the player to, then enter \"done\" to finish,\nor enter \"clear\" to clear the teleport location, or \"cancel\" to return");
en.put("eventEditorCommandsNote", "Note: You may use <player> to refer to the player's name."); en.put("eventEditorCommandsNote", "Note: You may use <player> to refer to the player's name.");
en.put("eventEditorSetCommandsPrompt", "Enter commands separating each one by a comma, or enter \"clear\" to clear the list, or enter \"cancel\" to return."); en.put("eventEditorSetCommandsPrompt", "Enter commands separating each one by a comma, or enter \"clear\" to clear the list, or enter \"cancel\" to return.");
en.put("eventEditorSet", ""); en.put("eventEditorSet", "");
en.put("eventEditorSet", ""); //en.put("eventEditorSet", "");
en.put("eventEditorSet", ""); //en.put("eventEditorSet", "");
// //
@ -238,5 +220,27 @@ public class Lang {
// //
// //
File file = new File(plugin.getDataFolder(), "/lang/" + lang + ".yml");
YamlConfiguration langFile = YamlConfiguration.loadConfiguration(file);
for (Entry<String, Object> e : langFile.getValues(true).entrySet()) {
en.put(e.getKey(), (String) e.getValue());
}
}
public void save() {
File file = new File(plugin.getDataFolder(), "/lang/" + lang + ".yml");
YamlConfiguration langFile = YamlConfiguration.loadConfiguration(file);
for (Entry<String, String> e : en.entrySet()) {
langFile.set(e.getKey(), e.getValue());
}
try {
langFile.save(file);
} catch (IOException e1) {
e1.printStackTrace();
}
} }
} }