Support for builder messages through SendMessageLocalisationData.

This commit is contained in:
MobiusDevelopment
2020-01-18 12:48:58 +00:00
parent ed7267ebac
commit 91a2ae4f93
51 changed files with 697 additions and 765 deletions
@@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatsSet; import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/** /**
* @author Mobius * @author Mobius
@@ -86,52 +87,55 @@ public class SendMessageLocalisationData implements IXmlReader
})); }));
} }
public String getLocalisation(String lang, String message) public static String getLocalisation(PlayerInstance player, String message)
{ {
final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(lang); if (Config.MULTILANG_ENABLE)
if (localisations != null)
{ {
// No pretty way of doing something like this. final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(player.getLang());
// Consider using proper SystemMessages where possible. if (localisations != null)
String[] searchMessage;
String[] replacementMessage;
boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
searchMessage = entry.getKey(); // No pretty way of doing something like this.
replacementMessage = entry.getValue(); // Consider using proper SystemMessages where possible.
String[] searchMessage;
// Exact match. String[] replacementMessage;
if (searchMessage.length == 1) boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
if (searchMessage[0].equals(message)) searchMessage = entry.getKey();
replacementMessage = entry.getValue();
// Exact match.
if (searchMessage.length == 1)
{ {
return replacementMessage[0]; if (searchMessage[0].equals(message))
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{ {
found = false; return replacementMessage[0];
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{
found = false;
break;
}
}
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
break; break;
} }
} }
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
return message;
}
} }
} }
} }
return null; return message;
} }
public static SendMessageLocalisationData getInstance() public static SendMessageLocalisationData getInstance()
@@ -8985,16 +8985,7 @@ public class PlayerInstance extends Playable
@Override @Override
public void sendMessage(String message) public void sendMessage(String message)
{ {
if (Config.MULTILANG_ENABLE) sendPacket(new SystemMessage(SendMessageLocalisationData.getLocalisation(this, message)));
{
final String localisation = SendMessageLocalisationData.getInstance().getLocalisation(_lang, message);
if (localisation != null)
{
sendPacket(new SystemMessage(localisation));
return;
}
}
sendPacket(new SystemMessage(message));
} }
public void setObserving(boolean state) public void setObserving(boolean state)
@@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.util; package org.l2jmobius.gameserver.util;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.SendMessageLocalisationData;
import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@@ -41,7 +42,7 @@ public class BuilderUtil
{ {
if (Config.GM_STARTUP_BUILDER_HIDE) if (Config.GM_STARTUP_BUILDER_HIDE)
{ {
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message)); player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", SendMessageLocalisationData.getLocalisation(player, message)));
} }
else else
{ {
@@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatsSet; import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/** /**
* @author Mobius * @author Mobius
@@ -86,52 +87,55 @@ public class SendMessageLocalisationData implements IXmlReader
})); }));
} }
public String getLocalisation(String lang, String message) public static String getLocalisation(PlayerInstance player, String message)
{ {
final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(lang); if (Config.MULTILANG_ENABLE)
if (localisations != null)
{ {
// No pretty way of doing something like this. final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(player.getLang());
// Consider using proper SystemMessages where possible. if (localisations != null)
String[] searchMessage;
String[] replacementMessage;
boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
searchMessage = entry.getKey(); // No pretty way of doing something like this.
replacementMessage = entry.getValue(); // Consider using proper SystemMessages where possible.
String[] searchMessage;
// Exact match. String[] replacementMessage;
if (searchMessage.length == 1) boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
if (searchMessage[0].equals(message)) searchMessage = entry.getKey();
replacementMessage = entry.getValue();
// Exact match.
if (searchMessage.length == 1)
{ {
return replacementMessage[0]; if (searchMessage[0].equals(message))
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{ {
found = false; return replacementMessage[0];
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{
found = false;
break;
}
}
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
break; break;
} }
} }
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
return message;
}
} }
} }
} }
return null; return message;
} }
public static SendMessageLocalisationData getInstance() public static SendMessageLocalisationData getInstance()
@@ -8992,16 +8992,7 @@ public class PlayerInstance extends Playable
@Override @Override
public void sendMessage(String message) public void sendMessage(String message)
{ {
if (Config.MULTILANG_ENABLE) sendPacket(new SystemMessage(SendMessageLocalisationData.getLocalisation(this, message)));
{
final String localisation = SendMessageLocalisationData.getInstance().getLocalisation(_lang, message);
if (localisation != null)
{
sendPacket(new SystemMessage(localisation));
return;
}
}
sendPacket(new SystemMessage(message));
} }
public void setObserving(boolean state) public void setObserving(boolean state)
@@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.util; package org.l2jmobius.gameserver.util;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.SendMessageLocalisationData;
import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@@ -41,7 +42,7 @@ public class BuilderUtil
{ {
if (Config.GM_STARTUP_BUILDER_HIDE) if (Config.GM_STARTUP_BUILDER_HIDE)
{ {
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message)); player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", SendMessageLocalisationData.getLocalisation(player, message)));
} }
else else
{ {
@@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatsSet; import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/** /**
* @author Mobius * @author Mobius
@@ -86,52 +87,55 @@ public class SendMessageLocalisationData implements IXmlReader
})); }));
} }
public String getLocalisation(String lang, String message) public static String getLocalisation(PlayerInstance player, String message)
{ {
final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(lang); if (Config.MULTILANG_ENABLE)
if (localisations != null)
{ {
// No pretty way of doing something like this. final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(player.getLang());
// Consider using proper SystemMessages where possible. if (localisations != null)
String[] searchMessage;
String[] replacementMessage;
boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
searchMessage = entry.getKey(); // No pretty way of doing something like this.
replacementMessage = entry.getValue(); // Consider using proper SystemMessages where possible.
String[] searchMessage;
// Exact match. String[] replacementMessage;
if (searchMessage.length == 1) boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
if (searchMessage[0].equals(message)) searchMessage = entry.getKey();
replacementMessage = entry.getValue();
// Exact match.
if (searchMessage.length == 1)
{ {
return replacementMessage[0]; if (searchMessage[0].equals(message))
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{ {
found = false; return replacementMessage[0];
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{
found = false;
break;
}
}
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
break; break;
} }
} }
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
return message;
}
} }
} }
} }
return null; return message;
} }
public static SendMessageLocalisationData getInstance() public static SendMessageLocalisationData getInstance()
@@ -8994,16 +8994,7 @@ public class PlayerInstance extends Playable
@Override @Override
public void sendMessage(String message) public void sendMessage(String message)
{ {
if (Config.MULTILANG_ENABLE) sendPacket(new SystemMessage(SendMessageLocalisationData.getLocalisation(this, message)));
{
final String localisation = SendMessageLocalisationData.getInstance().getLocalisation(_lang, message);
if (localisation != null)
{
sendPacket(new SystemMessage(localisation));
return;
}
}
sendPacket(new SystemMessage(message));
} }
public void setObserving(boolean state) public void setObserving(boolean state)
@@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.util; package org.l2jmobius.gameserver.util;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.SendMessageLocalisationData;
import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@@ -41,7 +42,7 @@ public class BuilderUtil
{ {
if (Config.GM_STARTUP_BUILDER_HIDE) if (Config.GM_STARTUP_BUILDER_HIDE)
{ {
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message)); player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", SendMessageLocalisationData.getLocalisation(player, message)));
} }
else else
{ {
@@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatsSet; import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/** /**
* @author Mobius * @author Mobius
@@ -86,52 +87,55 @@ public class SendMessageLocalisationData implements IXmlReader
})); }));
} }
public String getLocalisation(String lang, String message) public static String getLocalisation(PlayerInstance player, String message)
{ {
final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(lang); if (Config.MULTILANG_ENABLE)
if (localisations != null)
{ {
// No pretty way of doing something like this. final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(player.getLang());
// Consider using proper SystemMessages where possible. if (localisations != null)
String[] searchMessage;
String[] replacementMessage;
boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
searchMessage = entry.getKey(); // No pretty way of doing something like this.
replacementMessage = entry.getValue(); // Consider using proper SystemMessages where possible.
String[] searchMessage;
// Exact match. String[] replacementMessage;
if (searchMessage.length == 1) boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
if (searchMessage[0].equals(message)) searchMessage = entry.getKey();
replacementMessage = entry.getValue();
// Exact match.
if (searchMessage.length == 1)
{ {
return replacementMessage[0]; if (searchMessage[0].equals(message))
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{ {
found = false; return replacementMessage[0];
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{
found = false;
break;
}
}
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
break; break;
} }
} }
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
return message;
}
} }
} }
} }
return null; return message;
} }
public static SendMessageLocalisationData getInstance() public static SendMessageLocalisationData getInstance()
@@ -8978,16 +8978,7 @@ public class PlayerInstance extends Playable
@Override @Override
public void sendMessage(String message) public void sendMessage(String message)
{ {
if (Config.MULTILANG_ENABLE) sendPacket(new SystemMessage(SendMessageLocalisationData.getLocalisation(this, message)));
{
final String localisation = SendMessageLocalisationData.getInstance().getLocalisation(_lang, message);
if (localisation != null)
{
sendPacket(new SystemMessage(localisation));
return;
}
}
sendPacket(new SystemMessage(message));
} }
public void setObserving(boolean state) public void setObserving(boolean state)
@@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.util; package org.l2jmobius.gameserver.util;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.SendMessageLocalisationData;
import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@@ -41,7 +42,7 @@ public class BuilderUtil
{ {
if (Config.GM_STARTUP_BUILDER_HIDE) if (Config.GM_STARTUP_BUILDER_HIDE)
{ {
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message)); player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", SendMessageLocalisationData.getLocalisation(player, message)));
} }
else else
{ {
@@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatsSet; import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/** /**
* @author Mobius * @author Mobius
@@ -86,52 +87,55 @@ public class SendMessageLocalisationData implements IXmlReader
})); }));
} }
public String getLocalisation(String lang, String message) public static String getLocalisation(PlayerInstance player, String message)
{ {
final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(lang); if (Config.MULTILANG_ENABLE)
if (localisations != null)
{ {
// No pretty way of doing something like this. final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(player.getLang());
// Consider using proper SystemMessages where possible. if (localisations != null)
String[] searchMessage;
String[] replacementMessage;
boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
searchMessage = entry.getKey(); // No pretty way of doing something like this.
replacementMessage = entry.getValue(); // Consider using proper SystemMessages where possible.
String[] searchMessage;
// Exact match. String[] replacementMessage;
if (searchMessage.length == 1) boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
if (searchMessage[0].equals(message)) searchMessage = entry.getKey();
replacementMessage = entry.getValue();
// Exact match.
if (searchMessage.length == 1)
{ {
return replacementMessage[0]; if (searchMessage[0].equals(message))
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{ {
found = false; return replacementMessage[0];
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{
found = false;
break;
}
}
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
break; break;
} }
} }
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
return message;
}
} }
} }
} }
return null; return message;
} }
public static SendMessageLocalisationData getInstance() public static SendMessageLocalisationData getInstance()
@@ -8964,16 +8964,7 @@ public class PlayerInstance extends Playable
@Override @Override
public void sendMessage(String message) public void sendMessage(String message)
{ {
if (Config.MULTILANG_ENABLE) sendPacket(new SystemMessage(SendMessageLocalisationData.getLocalisation(this, message)));
{
final String localisation = SendMessageLocalisationData.getInstance().getLocalisation(_lang, message);
if (localisation != null)
{
sendPacket(new SystemMessage(localisation));
return;
}
}
sendPacket(new SystemMessage(message));
} }
public void setObserving(boolean state) public void setObserving(boolean state)
@@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.util; package org.l2jmobius.gameserver.util;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.SendMessageLocalisationData;
import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@@ -41,7 +42,7 @@ public class BuilderUtil
{ {
if (Config.GM_STARTUP_BUILDER_HIDE) if (Config.GM_STARTUP_BUILDER_HIDE)
{ {
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message)); player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", SendMessageLocalisationData.getLocalisation(player, message)));
} }
else else
{ {
@@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatsSet; import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/** /**
* @author Mobius * @author Mobius
@@ -86,52 +87,55 @@ public class SendMessageLocalisationData implements IXmlReader
})); }));
} }
public String getLocalisation(String lang, String message) public static String getLocalisation(PlayerInstance player, String message)
{ {
final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(lang); if (Config.MULTILANG_ENABLE)
if (localisations != null)
{ {
// No pretty way of doing something like this. final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(player.getLang());
// Consider using proper SystemMessages where possible. if (localisations != null)
String[] searchMessage;
String[] replacementMessage;
boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
searchMessage = entry.getKey(); // No pretty way of doing something like this.
replacementMessage = entry.getValue(); // Consider using proper SystemMessages where possible.
String[] searchMessage;
// Exact match. String[] replacementMessage;
if (searchMessage.length == 1) boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
if (searchMessage[0].equals(message)) searchMessage = entry.getKey();
replacementMessage = entry.getValue();
// Exact match.
if (searchMessage.length == 1)
{ {
return replacementMessage[0]; if (searchMessage[0].equals(message))
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{ {
found = false; return replacementMessage[0];
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{
found = false;
break;
}
}
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
break; break;
} }
} }
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
return message;
}
} }
} }
} }
return null; return message;
} }
public static SendMessageLocalisationData getInstance() public static SendMessageLocalisationData getInstance()
@@ -8964,16 +8964,7 @@ public class PlayerInstance extends Playable
@Override @Override
public void sendMessage(String message) public void sendMessage(String message)
{ {
if (Config.MULTILANG_ENABLE) sendPacket(new SystemMessage(SendMessageLocalisationData.getLocalisation(this, message)));
{
final String localisation = SendMessageLocalisationData.getInstance().getLocalisation(_lang, message);
if (localisation != null)
{
sendPacket(new SystemMessage(localisation));
return;
}
}
sendPacket(new SystemMessage(message));
} }
public void setObserving(boolean state) public void setObserving(boolean state)
@@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.util; package org.l2jmobius.gameserver.util;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.SendMessageLocalisationData;
import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@@ -41,7 +42,7 @@ public class BuilderUtil
{ {
if (Config.GM_STARTUP_BUILDER_HIDE) if (Config.GM_STARTUP_BUILDER_HIDE)
{ {
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message)); player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", SendMessageLocalisationData.getLocalisation(player, message)));
} }
else else
{ {
@@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatsSet; import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/** /**
* @author Mobius * @author Mobius
@@ -86,52 +87,55 @@ public class SendMessageLocalisationData implements IXmlReader
})); }));
} }
public String getLocalisation(String lang, String message) public static String getLocalisation(PlayerInstance player, String message)
{ {
final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(lang); if (Config.MULTILANG_ENABLE)
if (localisations != null)
{ {
// No pretty way of doing something like this. final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(player.getLang());
// Consider using proper SystemMessages where possible. if (localisations != null)
String[] searchMessage;
String[] replacementMessage;
boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
searchMessage = entry.getKey(); // No pretty way of doing something like this.
replacementMessage = entry.getValue(); // Consider using proper SystemMessages where possible.
String[] searchMessage;
// Exact match. String[] replacementMessage;
if (searchMessage.length == 1) boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
if (searchMessage[0].equals(message)) searchMessage = entry.getKey();
replacementMessage = entry.getValue();
// Exact match.
if (searchMessage.length == 1)
{ {
return replacementMessage[0]; if (searchMessage[0].equals(message))
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{ {
found = false; return replacementMessage[0];
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{
found = false;
break;
}
}
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
break; break;
} }
} }
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
return message;
}
} }
} }
} }
return null; return message;
} }
public static SendMessageLocalisationData getInstance() public static SendMessageLocalisationData getInstance()
@@ -8965,16 +8965,7 @@ public class PlayerInstance extends Playable
@Override @Override
public void sendMessage(String message) public void sendMessage(String message)
{ {
if (Config.MULTILANG_ENABLE) sendPacket(new SystemMessage(SendMessageLocalisationData.getLocalisation(this, message)));
{
final String localisation = SendMessageLocalisationData.getInstance().getLocalisation(_lang, message);
if (localisation != null)
{
sendPacket(new SystemMessage(localisation));
return;
}
}
sendPacket(new SystemMessage(message));
} }
public void setObserving(boolean state) public void setObserving(boolean state)
@@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.util; package org.l2jmobius.gameserver.util;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.SendMessageLocalisationData;
import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@@ -41,7 +42,7 @@ public class BuilderUtil
{ {
if (Config.GM_STARTUP_BUILDER_HIDE) if (Config.GM_STARTUP_BUILDER_HIDE)
{ {
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message)); player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", SendMessageLocalisationData.getLocalisation(player, message)));
} }
else else
{ {
@@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatsSet; import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/** /**
* @author Mobius * @author Mobius
@@ -86,52 +87,55 @@ public class SendMessageLocalisationData implements IXmlReader
})); }));
} }
public String getLocalisation(String lang, String message) public static String getLocalisation(PlayerInstance player, String message)
{ {
final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(lang); if (Config.MULTILANG_ENABLE)
if (localisations != null)
{ {
// No pretty way of doing something like this. final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(player.getLang());
// Consider using proper SystemMessages where possible. if (localisations != null)
String[] searchMessage;
String[] replacementMessage;
boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
searchMessage = entry.getKey(); // No pretty way of doing something like this.
replacementMessage = entry.getValue(); // Consider using proper SystemMessages where possible.
String[] searchMessage;
// Exact match. String[] replacementMessage;
if (searchMessage.length == 1) boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
if (searchMessage[0].equals(message)) searchMessage = entry.getKey();
replacementMessage = entry.getValue();
// Exact match.
if (searchMessage.length == 1)
{ {
return replacementMessage[0]; if (searchMessage[0].equals(message))
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{ {
found = false; return replacementMessage[0];
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{
found = false;
break;
}
}
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
break; break;
} }
} }
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
return message;
}
} }
} }
} }
return null; return message;
} }
public static SendMessageLocalisationData getInstance() public static SendMessageLocalisationData getInstance()
@@ -8930,16 +8930,7 @@ public class PlayerInstance extends Playable
@Override @Override
public void sendMessage(String message) public void sendMessage(String message)
{ {
if (Config.MULTILANG_ENABLE) sendPacket(new SystemMessage(SendMessageLocalisationData.getLocalisation(this, message)));
{
final String localisation = SendMessageLocalisationData.getInstance().getLocalisation(_lang, message);
if (localisation != null)
{
sendPacket(new SystemMessage(localisation));
return;
}
}
sendPacket(new SystemMessage(message));
} }
public void setObserving(boolean state) public void setObserving(boolean state)
@@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.util; package org.l2jmobius.gameserver.util;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.SendMessageLocalisationData;
import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@@ -41,7 +42,7 @@ public class BuilderUtil
{ {
if (Config.GM_STARTUP_BUILDER_HIDE) if (Config.GM_STARTUP_BUILDER_HIDE)
{ {
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message)); player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", SendMessageLocalisationData.getLocalisation(player, message)));
} }
else else
{ {
@@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatsSet; import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/** /**
* @author Mobius * @author Mobius
@@ -86,52 +87,55 @@ public class SendMessageLocalisationData implements IXmlReader
})); }));
} }
public String getLocalisation(String lang, String message) public static String getLocalisation(PlayerInstance player, String message)
{ {
final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(lang); if (Config.MULTILANG_ENABLE)
if (localisations != null)
{ {
// No pretty way of doing something like this. final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(player.getLang());
// Consider using proper SystemMessages where possible. if (localisations != null)
String[] searchMessage;
String[] replacementMessage;
boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
searchMessage = entry.getKey(); // No pretty way of doing something like this.
replacementMessage = entry.getValue(); // Consider using proper SystemMessages where possible.
String[] searchMessage;
// Exact match. String[] replacementMessage;
if (searchMessage.length == 1) boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
if (searchMessage[0].equals(message)) searchMessage = entry.getKey();
replacementMessage = entry.getValue();
// Exact match.
if (searchMessage.length == 1)
{ {
return replacementMessage[0]; if (searchMessage[0].equals(message))
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{ {
found = false; return replacementMessage[0];
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{
found = false;
break;
}
}
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
break; break;
} }
} }
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
return message;
}
} }
} }
} }
return null; return message;
} }
public static SendMessageLocalisationData getInstance() public static SendMessageLocalisationData getInstance()
@@ -9608,16 +9608,7 @@ public class PlayerInstance extends Playable
@Override @Override
public void sendMessage(String message) public void sendMessage(String message)
{ {
if (Config.MULTILANG_ENABLE) sendPacket(new SystemMessage(SendMessageLocalisationData.getLocalisation(this, message)));
{
final String localisation = SendMessageLocalisationData.getInstance().getLocalisation(_lang, message);
if (localisation != null)
{
sendPacket(new SystemMessage(localisation));
return;
}
}
sendPacket(new SystemMessage(message));
} }
public void enterObserverMode(Location loc) public void enterObserverMode(Location loc)
@@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.util; package org.l2jmobius.gameserver.util;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.SendMessageLocalisationData;
import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@@ -40,7 +41,7 @@ public class BuilderUtil
{ {
if (Config.GM_STARTUP_BUILDER_HIDE) if (Config.GM_STARTUP_BUILDER_HIDE)
{ {
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message)); player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", SendMessageLocalisationData.getLocalisation(player, message)));
} }
else else
{ {
@@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatsSet; import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/** /**
* @author Mobius * @author Mobius
@@ -86,52 +87,55 @@ public class SendMessageLocalisationData implements IXmlReader
})); }));
} }
public String getLocalisation(String lang, String message) public static String getLocalisation(PlayerInstance player, String message)
{ {
final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(lang); if (Config.MULTILANG_ENABLE)
if (localisations != null)
{ {
// No pretty way of doing something like this. final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(player.getLang());
// Consider using proper SystemMessages where possible. if (localisations != null)
String[] searchMessage;
String[] replacementMessage;
boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
searchMessage = entry.getKey(); // No pretty way of doing something like this.
replacementMessage = entry.getValue(); // Consider using proper SystemMessages where possible.
String[] searchMessage;
// Exact match. String[] replacementMessage;
if (searchMessage.length == 1) boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
if (searchMessage[0].equals(message)) searchMessage = entry.getKey();
replacementMessage = entry.getValue();
// Exact match.
if (searchMessage.length == 1)
{ {
return replacementMessage[0]; if (searchMessage[0].equals(message))
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{ {
found = false; return replacementMessage[0];
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{
found = false;
break;
}
}
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
break; break;
} }
} }
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
return message;
}
} }
} }
} }
return null; return message;
} }
public static SendMessageLocalisationData getInstance() public static SendMessageLocalisationData getInstance()
@@ -9488,16 +9488,7 @@ public class PlayerInstance extends Playable
@Override @Override
public void sendMessage(String message) public void sendMessage(String message)
{ {
if (Config.MULTILANG_ENABLE) sendPacket(new SystemMessage(SendMessageLocalisationData.getLocalisation(this, message)));
{
final String localisation = SendMessageLocalisationData.getInstance().getLocalisation(_lang, message);
if (localisation != null)
{
sendPacket(new SystemMessage(localisation));
return;
}
}
sendPacket(new SystemMessage(message));
} }
public void enterObserverMode(Location loc) public void enterObserverMode(Location loc)
@@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.util; package org.l2jmobius.gameserver.util;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.SendMessageLocalisationData;
import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@@ -40,7 +41,7 @@ public class BuilderUtil
{ {
if (Config.GM_STARTUP_BUILDER_HIDE) if (Config.GM_STARTUP_BUILDER_HIDE)
{ {
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message)); player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", SendMessageLocalisationData.getLocalisation(player, message)));
} }
else else
{ {
@@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatsSet; import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/** /**
* @author Mobius * @author Mobius
@@ -86,52 +87,55 @@ public class SendMessageLocalisationData implements IXmlReader
})); }));
} }
public String getLocalisation(String lang, String message) public static String getLocalisation(PlayerInstance player, String message)
{ {
final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(lang); if (Config.MULTILANG_ENABLE)
if (localisations != null)
{ {
// No pretty way of doing something like this. final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(player.getLang());
// Consider using proper SystemMessages where possible. if (localisations != null)
String[] searchMessage;
String[] replacementMessage;
boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
searchMessage = entry.getKey(); // No pretty way of doing something like this.
replacementMessage = entry.getValue(); // Consider using proper SystemMessages where possible.
String[] searchMessage;
// Exact match. String[] replacementMessage;
if (searchMessage.length == 1) boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
if (searchMessage[0].equals(message)) searchMessage = entry.getKey();
replacementMessage = entry.getValue();
// Exact match.
if (searchMessage.length == 1)
{ {
return replacementMessage[0]; if (searchMessage[0].equals(message))
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{ {
found = false; return replacementMessage[0];
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{
found = false;
break;
}
}
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
break; break;
} }
} }
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
return message;
}
} }
} }
} }
return null; return message;
} }
public static SendMessageLocalisationData getInstance() public static SendMessageLocalisationData getInstance()
@@ -8936,16 +8936,7 @@ public class PlayerInstance extends Playable
@Override @Override
public void sendMessage(String message) public void sendMessage(String message)
{ {
if (Config.MULTILANG_ENABLE) sendPacket(new SystemMessage(SendMessageLocalisationData.getLocalisation(this, message)));
{
final String localisation = SendMessageLocalisationData.getInstance().getLocalisation(_lang, message);
if (localisation != null)
{
sendPacket(new SystemMessage(localisation));
return;
}
}
sendPacket(new SystemMessage(message));
} }
public void setObserving(boolean state) public void setObserving(boolean state)
@@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.util; package org.l2jmobius.gameserver.util;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.SendMessageLocalisationData;
import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@@ -41,7 +42,7 @@ public class BuilderUtil
{ {
if (Config.GM_STARTUP_BUILDER_HIDE) if (Config.GM_STARTUP_BUILDER_HIDE)
{ {
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message)); player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", SendMessageLocalisationData.getLocalisation(player, message)));
} }
else else
{ {
@@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatsSet; import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/** /**
* @author Mobius * @author Mobius
@@ -86,52 +87,55 @@ public class SendMessageLocalisationData implements IXmlReader
})); }));
} }
public String getLocalisation(String lang, String message) public static String getLocalisation(PlayerInstance player, String message)
{ {
final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(lang); if (Config.MULTILANG_ENABLE)
if (localisations != null)
{ {
// No pretty way of doing something like this. final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(player.getLang());
// Consider using proper SystemMessages where possible. if (localisations != null)
String[] searchMessage;
String[] replacementMessage;
boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
searchMessage = entry.getKey(); // No pretty way of doing something like this.
replacementMessage = entry.getValue(); // Consider using proper SystemMessages where possible.
String[] searchMessage;
// Exact match. String[] replacementMessage;
if (searchMessage.length == 1) boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
if (searchMessage[0].equals(message)) searchMessage = entry.getKey();
replacementMessage = entry.getValue();
// Exact match.
if (searchMessage.length == 1)
{ {
return replacementMessage[0]; if (searchMessage[0].equals(message))
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{ {
found = false; return replacementMessage[0];
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{
found = false;
break;
}
}
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
break; break;
} }
} }
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
return message;
}
} }
} }
} }
return null; return message;
} }
public static SendMessageLocalisationData getInstance() public static SendMessageLocalisationData getInstance()
@@ -8937,16 +8937,7 @@ public class PlayerInstance extends Playable
@Override @Override
public void sendMessage(String message) public void sendMessage(String message)
{ {
if (Config.MULTILANG_ENABLE) sendPacket(new SystemMessage(SendMessageLocalisationData.getLocalisation(this, message)));
{
final String localisation = SendMessageLocalisationData.getInstance().getLocalisation(_lang, message);
if (localisation != null)
{
sendPacket(new SystemMessage(localisation));
return;
}
}
sendPacket(new SystemMessage(message));
} }
public void setObserving(boolean state) public void setObserving(boolean state)
@@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.util; package org.l2jmobius.gameserver.util;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.SendMessageLocalisationData;
import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@@ -41,7 +42,7 @@ public class BuilderUtil
{ {
if (Config.GM_STARTUP_BUILDER_HIDE) if (Config.GM_STARTUP_BUILDER_HIDE)
{ {
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message)); player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", SendMessageLocalisationData.getLocalisation(player, message)));
} }
else else
{ {
@@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatsSet; import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/** /**
* @author Mobius * @author Mobius
@@ -86,52 +87,55 @@ public class SendMessageLocalisationData implements IXmlReader
})); }));
} }
public String getLocalisation(String lang, String message) public static String getLocalisation(PlayerInstance player, String message)
{ {
final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(lang); if (Config.MULTILANG_ENABLE)
if (localisations != null)
{ {
// No pretty way of doing something like this. final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(player.getLang());
// Consider using proper SystemMessages where possible. if (localisations != null)
String[] searchMessage;
String[] replacementMessage;
boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
searchMessage = entry.getKey(); // No pretty way of doing something like this.
replacementMessage = entry.getValue(); // Consider using proper SystemMessages where possible.
String[] searchMessage;
// Exact match. String[] replacementMessage;
if (searchMessage.length == 1) boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
if (searchMessage[0].equals(message)) searchMessage = entry.getKey();
replacementMessage = entry.getValue();
// Exact match.
if (searchMessage.length == 1)
{ {
return replacementMessage[0]; if (searchMessage[0].equals(message))
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{ {
found = false; return replacementMessage[0];
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{
found = false;
break;
}
}
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
break; break;
} }
} }
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
return message;
}
} }
} }
} }
return null; return message;
} }
public static SendMessageLocalisationData getInstance() public static SendMessageLocalisationData getInstance()
@@ -8922,16 +8922,7 @@ public class PlayerInstance extends Playable
@Override @Override
public void sendMessage(String message) public void sendMessage(String message)
{ {
if (Config.MULTILANG_ENABLE) sendPacket(new SystemMessage(SendMessageLocalisationData.getLocalisation(this, message)));
{
final String localisation = SendMessageLocalisationData.getInstance().getLocalisation(_lang, message);
if (localisation != null)
{
sendPacket(new SystemMessage(localisation));
return;
}
}
sendPacket(new SystemMessage(message));
} }
public void setObserving(boolean state) public void setObserving(boolean state)
@@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.util; package org.l2jmobius.gameserver.util;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.SendMessageLocalisationData;
import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@@ -41,7 +42,7 @@ public class BuilderUtil
{ {
if (Config.GM_STARTUP_BUILDER_HIDE) if (Config.GM_STARTUP_BUILDER_HIDE)
{ {
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message)); player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", SendMessageLocalisationData.getLocalisation(player, message)));
} }
else else
{ {
@@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatsSet; import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/** /**
* @author Mobius * @author Mobius
@@ -86,52 +87,55 @@ public class SendMessageLocalisationData implements IXmlReader
})); }));
} }
public String getLocalisation(String lang, String message) public static String getLocalisation(PlayerInstance player, String message)
{ {
final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(lang); if (Config.MULTILANG_ENABLE)
if (localisations != null)
{ {
// No pretty way of doing something like this. final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(player.getLang());
// Consider using proper SystemMessages where possible. if (localisations != null)
String[] searchMessage;
String[] replacementMessage;
boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
searchMessage = entry.getKey(); // No pretty way of doing something like this.
replacementMessage = entry.getValue(); // Consider using proper SystemMessages where possible.
String[] searchMessage;
// Exact match. String[] replacementMessage;
if (searchMessage.length == 1) boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
if (searchMessage[0].equals(message)) searchMessage = entry.getKey();
replacementMessage = entry.getValue();
// Exact match.
if (searchMessage.length == 1)
{ {
return replacementMessage[0]; if (searchMessage[0].equals(message))
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{ {
found = false; return replacementMessage[0];
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{
found = false;
break;
}
}
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
break; break;
} }
} }
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
return message;
}
} }
} }
} }
return null; return message;
} }
public static SendMessageLocalisationData getInstance() public static SendMessageLocalisationData getInstance()
@@ -8949,16 +8949,7 @@ public class PlayerInstance extends Playable
@Override @Override
public void sendMessage(String message) public void sendMessage(String message)
{ {
if (Config.MULTILANG_ENABLE) sendPacket(new SystemMessage(SendMessageLocalisationData.getLocalisation(this, message)));
{
final String localisation = SendMessageLocalisationData.getInstance().getLocalisation(_lang, message);
if (localisation != null)
{
sendPacket(new SystemMessage(localisation));
return;
}
}
sendPacket(new SystemMessage(message));
} }
public void setObserving(boolean state) public void setObserving(boolean state)
@@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.util; package org.l2jmobius.gameserver.util;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.SendMessageLocalisationData;
import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@@ -41,7 +42,7 @@ public class BuilderUtil
{ {
if (Config.GM_STARTUP_BUILDER_HIDE) if (Config.GM_STARTUP_BUILDER_HIDE)
{ {
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message)); player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", SendMessageLocalisationData.getLocalisation(player, message)));
} }
else else
{ {
@@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatsSet; import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/** /**
* @author Mobius * @author Mobius
@@ -86,52 +87,55 @@ public class SendMessageLocalisationData implements IXmlReader
})); }));
} }
public String getLocalisation(String lang, String message) public static String getLocalisation(PlayerInstance player, String message)
{ {
final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(lang); if (Config.MULTILANG_ENABLE)
if (localisations != null)
{ {
// No pretty way of doing something like this. final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(player.getLang());
// Consider using proper SystemMessages where possible. if (localisations != null)
String[] searchMessage;
String[] replacementMessage;
boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
searchMessage = entry.getKey(); // No pretty way of doing something like this.
replacementMessage = entry.getValue(); // Consider using proper SystemMessages where possible.
String[] searchMessage;
// Exact match. String[] replacementMessage;
if (searchMessage.length == 1) boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
if (searchMessage[0].equals(message)) searchMessage = entry.getKey();
replacementMessage = entry.getValue();
// Exact match.
if (searchMessage.length == 1)
{ {
return replacementMessage[0]; if (searchMessage[0].equals(message))
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{ {
found = false; return replacementMessage[0];
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{
found = false;
break;
}
}
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
break; break;
} }
} }
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
return message;
}
} }
} }
} }
return null; return message;
} }
public static SendMessageLocalisationData getInstance() public static SendMessageLocalisationData getInstance()
@@ -8949,16 +8949,7 @@ public class PlayerInstance extends Playable
@Override @Override
public void sendMessage(String message) public void sendMessage(String message)
{ {
if (Config.MULTILANG_ENABLE) sendPacket(new SystemMessage(SendMessageLocalisationData.getLocalisation(this, message)));
{
final String localisation = SendMessageLocalisationData.getInstance().getLocalisation(_lang, message);
if (localisation != null)
{
sendPacket(new SystemMessage(localisation));
return;
}
}
sendPacket(new SystemMessage(message));
} }
public void setObserving(boolean state) public void setObserving(boolean state)
@@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.util; package org.l2jmobius.gameserver.util;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.SendMessageLocalisationData;
import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@@ -41,7 +42,7 @@ public class BuilderUtil
{ {
if (Config.GM_STARTUP_BUILDER_HIDE) if (Config.GM_STARTUP_BUILDER_HIDE)
{ {
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message)); player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", SendMessageLocalisationData.getLocalisation(player, message)));
} }
else else
{ {
@@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatsSet; import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/** /**
* @author Mobius * @author Mobius
@@ -86,52 +87,55 @@ public class SendMessageLocalisationData implements IXmlReader
})); }));
} }
public String getLocalisation(String lang, String message) public static String getLocalisation(PlayerInstance player, String message)
{ {
final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(lang); if (Config.MULTILANG_ENABLE)
if (localisations != null)
{ {
// No pretty way of doing something like this. final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(player.getLang());
// Consider using proper SystemMessages where possible. if (localisations != null)
String[] searchMessage;
String[] replacementMessage;
boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
searchMessage = entry.getKey(); // No pretty way of doing something like this.
replacementMessage = entry.getValue(); // Consider using proper SystemMessages where possible.
String[] searchMessage;
// Exact match. String[] replacementMessage;
if (searchMessage.length == 1) boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
if (searchMessage[0].equals(message)) searchMessage = entry.getKey();
replacementMessage = entry.getValue();
// Exact match.
if (searchMessage.length == 1)
{ {
return replacementMessage[0]; if (searchMessage[0].equals(message))
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{ {
found = false; return replacementMessage[0];
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{
found = false;
break;
}
}
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
break; break;
} }
} }
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
return message;
}
} }
} }
} }
return null; return message;
} }
public static SendMessageLocalisationData getInstance() public static SendMessageLocalisationData getInstance()
@@ -8853,16 +8853,7 @@ public class PlayerInstance extends Playable
@Override @Override
public void sendMessage(String message) public void sendMessage(String message)
{ {
if (Config.MULTILANG_ENABLE) sendPacket(new SystemMessage(SendMessageLocalisationData.getLocalisation(this, message)));
{
final String localisation = SendMessageLocalisationData.getInstance().getLocalisation(_lang, message);
if (localisation != null)
{
sendPacket(new SystemMessage(localisation));
return;
}
}
sendPacket(new SystemMessage(message));
} }
public void setObserving(boolean state) public void setObserving(boolean state)
@@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.util; package org.l2jmobius.gameserver.util;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.SendMessageLocalisationData;
import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@@ -41,7 +42,7 @@ public class BuilderUtil
{ {
if (Config.GM_STARTUP_BUILDER_HIDE) if (Config.GM_STARTUP_BUILDER_HIDE)
{ {
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message)); player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", SendMessageLocalisationData.getLocalisation(player, message)));
} }
else else
{ {
@@ -28,6 +28,7 @@ import org.w3c.dom.Document;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatsSet; import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/** /**
* @author Mobius * @author Mobius
@@ -86,52 +87,55 @@ public class SendMessageLocalisationData implements IXmlReader
})); }));
} }
public String getLocalisation(String lang, String message) public static String getLocalisation(PlayerInstance player, String message)
{ {
final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(lang); if (Config.MULTILANG_ENABLE)
if (localisations != null)
{ {
// No pretty way of doing something like this. final Map<String[], String[]> localisations = SEND_MESSAGE_LOCALISATIONS.get(player.getLang());
// Consider using proper SystemMessages where possible. if (localisations != null)
String[] searchMessage;
String[] replacementMessage;
boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
searchMessage = entry.getKey(); // No pretty way of doing something like this.
replacementMessage = entry.getValue(); // Consider using proper SystemMessages where possible.
String[] searchMessage;
// Exact match. String[] replacementMessage;
if (searchMessage.length == 1) boolean found;
for (Entry<String[], String[]> entry : localisations.entrySet())
{ {
if (searchMessage[0].equals(message)) searchMessage = entry.getKey();
replacementMessage = entry.getValue();
// Exact match.
if (searchMessage.length == 1)
{ {
return replacementMessage[0]; if (searchMessage[0].equals(message))
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{ {
found = false; return replacementMessage[0];
}
}
else // Split match.
{
found = true;
for (String part : searchMessage)
{
if (!message.contains(part))
{
found = false;
break;
}
}
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
break; break;
} }
} }
if (found)
{
for (int i = 0; i < searchMessage.length; i++)
{
message = message.replace(searchMessage[i], replacementMessage[i]);
}
return message;
}
} }
} }
} }
return null; return message;
} }
public static SendMessageLocalisationData getInstance() public static SendMessageLocalisationData getInstance()
@@ -8937,16 +8937,7 @@ public class PlayerInstance extends Playable
@Override @Override
public void sendMessage(String message) public void sendMessage(String message)
{ {
if (Config.MULTILANG_ENABLE) sendPacket(new SystemMessage(SendMessageLocalisationData.getLocalisation(this, message)));
{
final String localisation = SendMessageLocalisationData.getInstance().getLocalisation(_lang, message);
if (localisation != null)
{
sendPacket(new SystemMessage(localisation));
return;
}
}
sendPacket(new SystemMessage(message));
} }
public void setObserving(boolean state) public void setObserving(boolean state)
@@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.util; package org.l2jmobius.gameserver.util;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.SendMessageLocalisationData;
import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@@ -41,7 +42,7 @@ public class BuilderUtil
{ {
if (Config.GM_STARTUP_BUILDER_HIDE) if (Config.GM_STARTUP_BUILDER_HIDE)
{ {
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message)); player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", SendMessageLocalisationData.getLocalisation(player, message)));
} }
else else
{ {