[Version 0.7.8.0]
- Updated languages to include sign text (Please update any languages you are able!) - Resolved NPE due to Bukkit bug with signs - Resolved issue regarding new getTargetBlock code throwing an exception - Languages now auto-update based on the .JAR version (New entries only, doesnt overwrite customization) - New command "/sg about", will list the author of the current language file if available - Language now has a fallback to English for missing lines (Its the only language I can personally update on release) - Added Spanish (Thanks Manuestaire) and Hungarian (Thanks HPoltergeist)
This commit is contained in:
parent
d3834c5709
commit
de7134f0a4
8
README
8
README
@ -212,6 +212,14 @@ Client randomly crashes on teleport.
|
||||
=============
|
||||
Changes
|
||||
=============
|
||||
[Version 0.7.8.0]
|
||||
- Updated languages to include sign text (Please update any languages you are able!)
|
||||
- Resolved NPE due to Bukkit bug with signs
|
||||
- Resolved issue regarding new getTargetBlock code throwing an exception
|
||||
- Languages now auto-update based on the .JAR version (New entries only, doesn't overwrite customization)
|
||||
- New command "/sg about", will list the author of the current language file if available
|
||||
- Language now has a fallback to English for missing lines (It's the only language I can personally update on release)
|
||||
- Added Spanish (Thanks Manuestaire) and Hungarian (Thanks HPoltergeist)
|
||||
[Version 0.7.7.5]
|
||||
- Resolve issue of right clicking introduced in 1.3.1/2
|
||||
[Version 0.7.7.4]
|
||||
|
@ -35,29 +35,39 @@ public class LangLoader {
|
||||
private String datFolder;
|
||||
private String lang;
|
||||
private HashMap<String, String> strList;
|
||||
private HashMap<String, String> defList;
|
||||
|
||||
public LangLoader(String datFolder, String lang) {
|
||||
this.lang = lang;
|
||||
this.datFolder = datFolder;
|
||||
strList = new HashMap<String, String>();
|
||||
|
||||
File tmp = new File(datFolder, lang + ".txt");
|
||||
if (!tmp.exists()) {
|
||||
tmp.getParentFile().mkdirs();
|
||||
loadDefaults();
|
||||
}
|
||||
updateLanguage(lang);
|
||||
|
||||
load();
|
||||
strList = load(lang);
|
||||
// We have a default hashMap used for when new text is added.
|
||||
InputStream is = Stargate.class.getResourceAsStream("resources/" + lang + ".txt");
|
||||
if (is != null) {
|
||||
defList = load("en", is);
|
||||
} else {
|
||||
defList = null;
|
||||
Stargate.log.severe("[Stargate] Error loading backup language. There may be missing text ingame");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean reload() {
|
||||
strList = new HashMap<String, String>();
|
||||
load();
|
||||
// This extracts/updates the language as needed
|
||||
updateLanguage(lang);
|
||||
strList = load(lang);
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getString(String name) {
|
||||
String val = strList.get(name);
|
||||
if (val == null && defList != null) val = defList.get(name);
|
||||
if (val == null) return "";
|
||||
return val;
|
||||
}
|
||||
@ -66,11 +76,16 @@ public class LangLoader {
|
||||
this.lang = lang;
|
||||
}
|
||||
|
||||
private void loadDefaults() {
|
||||
// This function updates on-disk language files
|
||||
// with missing lines from the in-JAR files
|
||||
private void updateLanguage(String lang) {
|
||||
// Load the current language file
|
||||
HashMap<String, String> curLang = load(lang);
|
||||
|
||||
InputStream is = Stargate.class.getResourceAsStream("resources/" + lang + ".txt");
|
||||
if (is == null) return;
|
||||
Stargate.log.info("[Stargate] Extracting initial language file -- " + lang + ".txt");
|
||||
|
||||
boolean updated = false;
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
// Input stuff
|
||||
@ -83,9 +98,28 @@ public class LangLoader {
|
||||
BufferedWriter bw = new BufferedWriter(out);
|
||||
|
||||
String line = br.readLine();
|
||||
boolean firstLine = true;
|
||||
while (line != null) {
|
||||
bw.write(line);
|
||||
bw.newLine();
|
||||
// Strip UTF BOM
|
||||
if (firstLine) line = removeUTF8BOM(line);
|
||||
firstLine = false;
|
||||
// Split at first "="
|
||||
int eq = line.indexOf('=');
|
||||
if (eq == -1) {
|
||||
bw.newLine();
|
||||
line = br.readLine();
|
||||
continue;
|
||||
}
|
||||
String key = line.substring(0, eq);
|
||||
|
||||
if (curLang == null || curLang.get(key) == null) {
|
||||
bw.write(line);
|
||||
bw.newLine();
|
||||
updated = true;
|
||||
} else {
|
||||
bw.write(key + "=" + curLang.get(key));
|
||||
bw.newLine();
|
||||
}
|
||||
line = br.readLine();
|
||||
}
|
||||
bw.close();
|
||||
@ -96,13 +130,25 @@ public class LangLoader {
|
||||
try {fos.close();} catch (Exception ex) {}
|
||||
}
|
||||
}
|
||||
if (updated)
|
||||
Stargate.log.info("[Stargate] Your language file (" + lang + ".txt) has been updated");
|
||||
}
|
||||
|
||||
private boolean load() {
|
||||
private HashMap<String, String> load(String lang) {
|
||||
return load(lang, null);
|
||||
}
|
||||
|
||||
private HashMap<String, String> load(String lang, InputStream is) {
|
||||
HashMap<String, String> strings = new HashMap<String, String>();
|
||||
FileInputStream fis = null;
|
||||
InputStreamReader isr = null;
|
||||
try {
|
||||
fis = new FileInputStream(datFolder + lang + ".txt");
|
||||
InputStreamReader isr = new InputStreamReader(fis, "UTF8");
|
||||
if (is == null) {
|
||||
fis = new FileInputStream(datFolder + lang + ".txt");
|
||||
isr = new InputStreamReader(fis, "UTF8");
|
||||
} else {
|
||||
isr = new InputStreamReader(is, "UTF8");
|
||||
}
|
||||
BufferedReader br = new BufferedReader(isr);
|
||||
String line = br.readLine();
|
||||
boolean firstLine = true;
|
||||
@ -118,24 +164,29 @@ public class LangLoader {
|
||||
}
|
||||
String key = line.substring(0, eq);
|
||||
String val = line.substring(eq + 1);
|
||||
strList.put(key, val);
|
||||
strings.put(key, val);
|
||||
line = br.readLine();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
return false;
|
||||
return null;
|
||||
} finally {
|
||||
if (fis != null) {
|
||||
try {fis.close();}
|
||||
catch (Exception ex) {}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return strings;
|
||||
}
|
||||
|
||||
public void debug() {
|
||||
Set<String> keys = strList.keySet();
|
||||
for (String key : keys) {
|
||||
Stargate.debug("LangLoader::Debug", key + " => " + strList.get(key));
|
||||
Stargate.debug("LangLoader::Debug::strList", key + " => " + strList.get(key));
|
||||
}
|
||||
if (defList == null) return;
|
||||
keys = defList.keySet();
|
||||
for (String key : keys) {
|
||||
Stargate.debug("LangLoader::Debug::defList", key + " => " + defList.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -670,28 +669,27 @@ public class Portal {
|
||||
}
|
||||
|
||||
public final void drawSign() {
|
||||
BlockState bs = null;
|
||||
bs = id.getBlock().getState();
|
||||
if (!(bs instanceof Sign)) {
|
||||
Material sMat = id.getBlock().getType();
|
||||
if (sMat != Material.SIGN && sMat != Material.WALL_SIGN && sMat != Material.SIGN_POST) {
|
||||
Stargate.log.warning("[Stargate] Sign block is not a Sign object");
|
||||
Stargate.debug("Portal::drawSign", "Block: " + id.getBlock().getType() + " @ " + id.getBlock().getLocation());
|
||||
return;
|
||||
}
|
||||
Sign sign = (Sign)id.getBlock().getState();
|
||||
Sign sign = (Sign)new StargateSign(id.getBlock());
|
||||
Stargate.setLine(sign, 0, "-" + name + "-");
|
||||
int max = destinations.size() - 1;
|
||||
int done = 0;
|
||||
|
||||
if (!isActive()) {
|
||||
Stargate.setLine(sign, ++done, "Right click");
|
||||
Stargate.setLine(sign, ++done, "to use gate");
|
||||
Stargate.setLine(sign, ++done, Stargate.getString("signRightClick"));
|
||||
Stargate.setLine(sign, ++done, Stargate.getString("signToUse"));
|
||||
if (!noNetwork) {
|
||||
Stargate.setLine(sign, ++done, "(" + network + ")");
|
||||
}
|
||||
} else {
|
||||
if (isFixed()) {
|
||||
if (isRandom()) {
|
||||
Stargate.setLine(sign, ++done, "> Random <");
|
||||
Stargate.setLine(sign, ++done, "> " + Stargate.getString("signRandom") + " <");
|
||||
} else {
|
||||
Stargate.setLine(sign, ++done, ">" + destination + "<");
|
||||
}
|
||||
@ -702,7 +700,7 @@ public class Portal {
|
||||
}
|
||||
Portal dest = Portal.getByName(destination, network);
|
||||
if (dest == null && !isRandom()) {
|
||||
Stargate.setLine(sign, ++done, "Disconnected");
|
||||
Stargate.setLine(sign, ++done, Stargate.getString("signDisconnected"));
|
||||
} else {
|
||||
Stargate.setLine(sign, ++done, "");
|
||||
}
|
||||
|
@ -144,9 +144,12 @@ public class Stargate extends JavaPlugin {
|
||||
pm.registerEvents(new sListener(), this);
|
||||
|
||||
this.loadConfig();
|
||||
|
||||
// It is important to load languages here, as they are used during reloadGates()
|
||||
lang = new LangLoader(langFolder, Stargate.langName);
|
||||
|
||||
this.migrate();
|
||||
this.reloadGates();
|
||||
lang = new LangLoader(langFolder, Stargate.langName);
|
||||
|
||||
// Check to see if iConomy/Permissions is loaded yet.
|
||||
permissions = (Permissions)checkPlugin("Permissions");
|
||||
@ -792,7 +795,12 @@ public class Stargate extends JavaPlugin {
|
||||
Player player = event.getPlayer();
|
||||
Block block = null;
|
||||
if (event.isCancelled() && event.getAction() == Action.RIGHT_CLICK_AIR) {
|
||||
block = player.getTargetBlock(null, 5);
|
||||
try {
|
||||
block = player.getTargetBlock(null, 5);
|
||||
} catch (IllegalStateException ex) {
|
||||
// We can safely ignore this exception, it only happens in void or max height
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
block = event.getClickedBlock();
|
||||
}
|
||||
@ -1228,16 +1236,22 @@ public class Stargate extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player)sender;
|
||||
if (!hasPerm(p, "stargate.admin") && !hasPerm(p, "stargate.admin.reload")) {
|
||||
sendMessage(sender, "Permission Denied");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
String cmd = command.getName();
|
||||
if (cmd.equalsIgnoreCase("sg")) {
|
||||
if (args.length != 1) return false;
|
||||
if (args[0].equalsIgnoreCase("about")) {
|
||||
sender.sendMessage("Stargate Plugin created by Drakia");
|
||||
if (!lang.getString("author").isEmpty())
|
||||
sender.sendMessage("Language created by " + lang.getString("author"));
|
||||
return true;
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player)sender;
|
||||
if (!hasPerm(p, "stargate.admin") && !hasPerm(p, "stargate.admin.reload")) {
|
||||
sendMessage(sender, "Permission Denied");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
// Deactivate portals
|
||||
for (Portal p : activeList) {
|
||||
|
58
src/net/TheDgtl/Stargate/StargateSign.java
Normal file
58
src/net/TheDgtl/Stargate/StargateSign.java
Normal file
@ -0,0 +1,58 @@
|
||||
package net.TheDgtl.Stargate;
|
||||
|
||||
import net.minecraft.server.TileEntitySign;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||
|
||||
public class StargateSign extends CraftBlockState implements Sign {
|
||||
private final TileEntitySign sign;
|
||||
private final String[] lines;
|
||||
|
||||
public StargateSign(final Block block) {
|
||||
super(block);
|
||||
|
||||
CraftWorld world = (CraftWorld) block.getWorld();
|
||||
sign = (TileEntitySign) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
if (sign != null) {
|
||||
lines = new String[sign.lines.length];
|
||||
System.arraycopy(sign.lines, 0, lines, 0, lines.length);
|
||||
} else {
|
||||
// Sadly, due to Minecraft having many issues with blocks, chunks
|
||||
// and entities, we must assume a 4-line sign if the sign is null
|
||||
lines = new String[4];
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getLines() {
|
||||
return lines;
|
||||
}
|
||||
|
||||
public String getLine(int index) throws IndexOutOfBoundsException {
|
||||
return lines[index];
|
||||
}
|
||||
|
||||
public void setLine(int index, String line) throws IndexOutOfBoundsException {
|
||||
lines[index] = line;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(boolean force) {
|
||||
boolean result = super.update(force) && (sign != null);
|
||||
|
||||
if (result) {
|
||||
for(int i = 0; i < sign.lines.length; i++) {
|
||||
if(lines[i] != null) {
|
||||
sign.lines[i] = lines[i];
|
||||
} else {
|
||||
sign.lines[i] = "";
|
||||
}
|
||||
}
|
||||
sign.update();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
author=EduardBaer
|
||||
prefix=[Stargate]
|
||||
teleportMsg=Du wurdest Teleportiert.
|
||||
destroyMsg=Gate zerstört
|
||||
@ -20,3 +21,8 @@ createExists=Ein Gate mit diesem Name existiert bereits.
|
||||
createFull=Dieses Netzwerk ist voll.
|
||||
createWorldDeny=Du hast keinen Zugriff auf diese Welt.
|
||||
createConflict=Dieses Gate steht im Konflikt mit einem bereits existierenden.
|
||||
|
||||
signRightClick=Right click
|
||||
signToUse=to use gate
|
||||
signRandom=Random
|
||||
signDisconnected=Disconnected
|
@ -20,3 +20,8 @@ createExists=A gate by that name already exists
|
||||
createFull=This network is full
|
||||
createWorldDeny=You do not have access to that world
|
||||
createConflict=Gate conflicts with existing gate
|
||||
|
||||
signRightClick=Right click
|
||||
signToUse=to use gate
|
||||
signRandom=Random
|
||||
signDisconnected=Disconnected
|
28
src/net/TheDgtl/Stargate/resources/es.txt
Normal file
28
src/net/TheDgtl/Stargate/resources/es.txt
Normal file
@ -0,0 +1,28 @@
|
||||
author=Manuestaire
|
||||
prefix=[Stargate]
|
||||
teleportMsg=Teletransportado
|
||||
destroyMsg=Portal Destruido
|
||||
invalidMsg=Destino Inválido
|
||||
blockMsg=Destino Bloqueado
|
||||
destEmpty=La lista de destinos está vacía
|
||||
denyMsg=Acceso denegado
|
||||
|
||||
ecoDeduct=Pagaste %cost%
|
||||
ecoRefund=Reembolsado %cost%
|
||||
ecoObtain=Obtenido %cost% del Portal %portal%
|
||||
ecoInFunds=No tienes suficiente dinero
|
||||
|
||||
createMsg=Portal creado
|
||||
createNetDeny=No tienes acceso a esta red
|
||||
createGateDeny=No tienes acceso a este diseño de portal
|
||||
createPersonal=Creando el portal en una red personal
|
||||
createNameLength=Nombre demasiado largo o demasiado corto
|
||||
createExists=Ya existe una puerta con este nombre
|
||||
createFull=Esta red está llena
|
||||
createWorldDeny=No tienes permisos para acceder a ese mundo
|
||||
createConflict=El portal entra en conflicto con un portal ya existente
|
||||
|
||||
signRightClick=Right click
|
||||
signToUse=to use gate
|
||||
signRandom=Random
|
||||
signDisconnected=Disconnected
|
@ -1,4 +1,5 @@
|
||||
prefix=[Stargate]
|
||||
author=Dauphin14
|
||||
prefix=[Stargate]
|
||||
teleportMsg=Téléportation Réussie.
|
||||
destroyMsg=Portail detruit.
|
||||
invalidMsg=Destination invalide.
|
||||
@ -20,3 +21,8 @@ createExists=Il existe déjà un portail avec le même nom.
|
||||
createFull=Le reseau est plein.
|
||||
createWorldDeny=Vous n'avez pas accès à ce monde.
|
||||
createConflict=Ce portail entre en conflit avec un portail déjà existant.
|
||||
|
||||
signRightClick=Right click
|
||||
signToUse=to use gate
|
||||
signRandom=Random
|
||||
signDisconnected=Disconnected
|
28
src/net/TheDgtl/Stargate/resources/hu.txt
Normal file
28
src/net/TheDgtl/Stargate/resources/hu.txt
Normal file
@ -0,0 +1,28 @@
|
||||
author=HPoltergeist
|
||||
prefix=[Stargate]
|
||||
teleportMsg=Teleportálás
|
||||
destroyMsg=Kapu törölve
|
||||
invalidMsg=Nincs ilyen cél
|
||||
blockMsg=Cél blokkolva
|
||||
destEmpty=A cél lista üres
|
||||
denyMsg=Hozzáférés megtagadva
|
||||
|
||||
ecoDeduct=%cost% levonva
|
||||
ecoRefund=%cost% visszatérítve
|
||||
ecoObtain=%cost% bevétel a következő kapuból: %portal%
|
||||
ecoInFunds=Nincs elég pénzed
|
||||
|
||||
createMsg=Kapu elkészült
|
||||
createNetDeny=Nincs hozzáférésed ahhoz a hálózathoz
|
||||
createGateDeny=Nincs hozzáférésed ahhoz a kapucsoporthoz
|
||||
createPersonal=Kapu készítése magán hálózaton
|
||||
createNameLength=A név túl rövid vagy túl hosszú
|
||||
createExists=Már van ilyen nevű kapu
|
||||
createFull=Ez a hálózat tele van
|
||||
createWorldDeny=Nincs hozzáférésed ahhoz a világhoz
|
||||
createConflict=Ez a kapu ütközik egy meglévö kapuval
|
||||
|
||||
signRightClick=Right click
|
||||
signToUse=to use gate
|
||||
signRandom=Random
|
||||
signDisconnected=Disconnected
|
@ -1,3 +1,4 @@
|
||||
author=fr33soul
|
||||
prefix=[Stargate]
|
||||
teleportMsg=Teletrasporto
|
||||
destroyMsg=Portale distrutto
|
||||
@ -20,3 +21,8 @@ createExists=Questo nome gia' esiste
|
||||
createFull=Questa rete e' piena
|
||||
createWorldDeny=Non hai accesso a questo mondo
|
||||
createConflict=Il portale crea conflitti con uno gia' esistente
|
||||
|
||||
signRightClick=Right click
|
||||
signToUse=to use gate
|
||||
signRandom=Random
|
||||
signDisconnected=Disconnected
|
@ -1,3 +1,4 @@
|
||||
author=Grovert11
|
||||
prefix=[Stargate]
|
||||
teleportMsg=Je bent geteleporteerd.
|
||||
destroyMsg=Gate kapot gemaakt
|
||||
@ -20,3 +21,8 @@ createExists=Er bestaat al een gate met die naam
|
||||
createFull=Dit netwerk is vol.
|
||||
createWorldDeny=Je mag niet in die wereld komen.
|
||||
createConflict=Gate maakt een conflict met een bestaande gate.
|
||||
|
||||
signRightClick=Right click
|
||||
signToUse=to use gate
|
||||
signRandom=Random
|
||||
signDisconnected=Disconnected
|
@ -1,3 +1,4 @@
|
||||
author=TheProbleemm
|
||||
prefix=[Stargate]
|
||||
teleportMsg=Voce foi teleportado.
|
||||
destroyMsg=Portal destruido.
|
||||
@ -20,3 +21,8 @@ createExists=J
|
||||
createFull=Esta rede esta cheia.
|
||||
createWorldDeny=Voce nao tem acesso a esse mundo.
|
||||
createConflict=Portal em conflito com um portal ja existente.
|
||||
|
||||
signRightClick=Right click
|
||||
signToUse=to use gate
|
||||
signRandom=Random
|
||||
signDisconnected=Disconnected
|
@ -1,4 +1,5 @@
|
||||
prefix=[Портал]
|
||||
author=ckr@jk
|
||||
prefix=[Портал]
|
||||
teleportMsg=Вы перемещены
|
||||
destroyMsg=Портал уничтожен
|
||||
invalidMsg=Недопустимый пункт назначения
|
||||
@ -20,3 +21,8 @@ createExists=Портал с таким именем уже существует
|
||||
createFull=Эта сеть порталов заполнена
|
||||
createWorldDeny=У вас нет доступа к этому миру
|
||||
createConflict=Портал конфликтует с уже существующим порталом
|
||||
|
||||
signRightClick=Right click
|
||||
signToUse=to use gate
|
||||
signRandom=Random
|
||||
signDisconnected=Disconnected
|
@ -1,6 +1,6 @@
|
||||
name: Stargate
|
||||
main: net.TheDgtl.Stargate.Stargate
|
||||
version: 0.7.7.5
|
||||
version: 0.7.8.0
|
||||
description: Stargate mod for Bukkit
|
||||
author: Drakia
|
||||
website: http://www.thedgtl.net
|
||||
|
Loading…
Reference in New Issue
Block a user