Remove configurable language feature

This commit is contained in:
P0nk
2024-09-14 15:34:01 +02:00
parent 4778482cdd
commit f8726640c3
10 changed files with 54 additions and 205 deletions

View File

@@ -7074,7 +7074,6 @@ public class Character extends AbstractCharacterObject {
retClient.setAccountName(rs.getString("name"));
retClient.setCharacterSlots(rs.getByte("characterslots"));
retClient.setLanguage(rs.getInt("language")); // thanks Zein for noticing user language not overriding default once player is in-game
}
}
}
@@ -11082,23 +11081,6 @@ public class Character extends AbstractCharacterObject {
return this.ariantPoints;
}
public void setLanguage(int num) {
getClient().setLanguage(num);
try (Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE accounts SET language = ? WHERE id = ?")) {
ps.setInt(1, num);
ps.setInt(2, getClient().getAccID());
ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
public int getLanguage() {
return getClient().getLanguage();
}
public boolean isChasing() {
return chasing;
}

View File

@@ -129,7 +129,6 @@ public class Client extends ChannelInboundHandlerAdapter {
private Calendar tempBanCalendar;
private long lastNpcClick;
private long lastPacket = System.currentTimeMillis();
private int lang = 0;
public enum Type {
LOGIN,
@@ -523,7 +522,7 @@ public class Client extends ChannelInboundHandlerAdapter {
}
try (Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT id, password, gender, banned, pin, pic, characterslots, tos, language FROM accounts WHERE name = ?")) {
PreparedStatement ps = con.prepareStatement("SELECT id, password, gender, banned, pin, pic, characterslots, tos FROM accounts WHERE name = ?")) {
ps.setString(1, login);
try (ResultSet rs = ps.executeQuery()) {
@@ -541,7 +540,6 @@ public class Client extends ChannelInboundHandlerAdapter {
pic = rs.getString("pic");
gender = rs.getByte("gender");
characterSlots = rs.getByte("characterslots");
lang = rs.getInt("language");
String passhash = rs.getString("password");
byte tos = rs.getByte("tos");
@@ -1125,12 +1123,4 @@ public class Client extends ChannelInboundHandlerAdapter {
public boolean canBypassPic() {
return LoginBypassCoordinator.getInstance().canLoginBypass(hwid, accId, true);
}
public int getLanguage() {
return lang;
}
public void setLanguage(int lingua) {
this.lang = lingua;
}
}

View File

@@ -24,7 +24,6 @@
package client.command;
import client.Client;
import client.command.commands.gm0.ChangeLanguageCommand;
import client.command.commands.gm0.DisposeCommand;
import client.command.commands.gm0.DropLimitCommand;
import client.command.commands.gm0.EnableAuthCommand;
@@ -345,7 +344,6 @@ public class CommandsExecutor {
addCommand("uptime", UptimeCommand.class);
addCommand("gacha", GachaCommand.class);
addCommand("dispose", DisposeCommand.class);
addCommand("changel", ChangeLanguageCommand.class);
addCommand("equiplv", EquipLvCommand.class);
addCommand("showrates", ShowRatesCommand.class);
addCommand("rates", RatesCommand.class);

View File

@@ -1,43 +0,0 @@
/*
This file is part of the HeavenMS MapleStory Server, commands OdinMS-based
Copyleft (L) 2016 - 2019 RonanLana
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
@Author: Arthur L - Refactored command content into modules
*/
package client.command.commands.gm0;
import client.Client;
import client.command.Command;
import client.command.CommandContext;
public class ChangeLanguageCommand extends Command {
{
setDescription("Change language settings.");
}
@Override
public void execute(Client c, String[] params, CommandContext ctx) {
if (params.length < 1) {
c.getPlayer().yellowMessage("Syntax: !changel <0=ptb, 1=esp, 2=eng>");
return;
}
c.setLanguage(Integer.parseInt(params[0]));
}
}

View File

@@ -1,95 +0,0 @@
package constants.string;
import client.Character;
/**
* @author Drago (Dragohe4rt)
*/
public class LanguageConstants {
enum Language {
LANG_PRT(0),
LANG_ESP(1),
LANG_ENG(2);
int lang;
Language(int lang) {
this.lang = lang;
}
private int getValue() {
return this.lang;
}
}
public static String[] CPQBlue = new String[3];
public static String[] CPQError = new String[3];
public static String[] CPQEntry = new String[3];
public static String[] CPQFindError = new String[3];
public static String[] CPQRed = new String[3];
public static String[] CPQPlayerExit = new String[3];
public static String[] CPQEntryLobby = new String[3];
public static String[] CPQPickRoom = new String[3];
public static String[] CPQExtendTime = new String[3];
public static String[] CPQLeaderNotFound = new String[3];
public static String[] CPQChallengeRoomAnswer = new String[3];
public static String[] CPQChallengeRoomSent = new String[3];
public static String[] CPQChallengeRoomDenied = new String[3];
static {
int lang;
lang = Language.LANG_PRT.getValue();
LanguageConstants.CPQBlue[lang] = "Maple Azul";
LanguageConstants.CPQRed[lang] = "Maple Vermelho";
LanguageConstants.CPQExtendTime[lang] = "O tempo foi estendido.";
LanguageConstants.CPQPlayerExit[lang] = " deixou o Carnaval de Monstros.";
LanguageConstants.CPQError[lang] = "Ocorreu um problema. Favor recriar a sala.";
LanguageConstants.CPQLeaderNotFound[lang] = "Nao foi possivel encontrar o Lider.";
LanguageConstants.CPQPickRoom[lang] = "Inscreva-se no Festival de Monstros!\r\n";
LanguageConstants.CPQChallengeRoomAnswer[lang] = "O grupo esta respondendo um desafio no momento.";
LanguageConstants.CPQChallengeRoomSent[lang] = "Um desafio foi enviado para o grupo na sala. Aguarde um momento.";
LanguageConstants.CPQChallengeRoomDenied[lang] = "O grupo na sala cancelou seu desafio.";
LanguageConstants.CPQFindError[lang] = "Nao foi possivel encontrar um grupo nesta sala.\r\nProvavelmente o grupo foi desfeito dentro da sala!";
LanguageConstants.CPQEntryLobby[lang] = "Agora voce ira receber desafios de outros grupos. Se voce nao aceitar um desafio em 3 minutos, voce sera levado para fora.";
LanguageConstants.CPQEntry[lang] = "Voce pode selecionar \"Invocar Monstros\", \"Habilidade\", ou \"Protetor\" como sua tatica durante o Carnaval dos Monstros. Use Tab a F1~F12 para acesso rapido!";
lang = Language.LANG_ESP.getValue();
LanguageConstants.CPQBlue[lang] = "Maple Azul";
LanguageConstants.CPQRed[lang] = "Maple Rojo";
LanguageConstants.CPQExtendTime[lang] = "El tiempo se ha ampliado.";
LanguageConstants.CPQPlayerExit[lang] = " ha dejado el Carnaval de Monstruos.";
LanguageConstants.CPQLeaderNotFound[lang] = "No se pudo encontrar el Lider.";
LanguageConstants.CPQPickRoom[lang] = "!Inscribete en el Festival de Monstruos!\r\n";
LanguageConstants.CPQError[lang] = "Se ha producido un problema. Por favor, volver a crear una sala.";
LanguageConstants.CPQChallengeRoomAnswer[lang] = "El grupo esta respondiendo un desafio en el momento.";
LanguageConstants.CPQChallengeRoomSent[lang] = "Un desafio fue enviado al grupo en la sala. Espera un momento.";
LanguageConstants.CPQChallengeRoomDenied[lang] = "El grupo en la sala cancelo su desafio.";
LanguageConstants.CPQFindError[lang] = "No se pudo encontrar un grupo en esta sala.\r\nProbablemente el grupo fue deshecho dentro de la sala!";
LanguageConstants.CPQEntryLobby[lang] = "Ahora usted recibira los retos de otros grupos. Si usted no acepta un desafio en 3 minutos, usted sera llevado hacia fuera.";
LanguageConstants.CPQEntry[lang] = "Usted puede seleccionar \"Invocar Monstruos\", \"Habilidad\", o \"Protector\" como su tactica durante el Carnaval de los Monstruos. Utilice Tab y F1 ~ F12 para acceso rapido!";
lang = Language.LANG_ENG.getValue();
LanguageConstants.CPQBlue[lang] = "Maple Blue";
LanguageConstants.CPQRed[lang] = "Maple Red";
LanguageConstants.CPQPlayerExit[lang] = " left the Carnival of Monsters.";
LanguageConstants.CPQExtendTime[lang] = "The time has been extended.";
LanguageConstants.CPQLeaderNotFound[lang] = "Could not find the Leader.";
LanguageConstants.CPQError[lang] = "There was a problem. Please re-create a room.";
LanguageConstants.CPQPickRoom[lang] = "Sign up for the Monster Festival!\r\n";
LanguageConstants.CPQChallengeRoomAnswer[lang] = "The group is currently facing a challenge.";
LanguageConstants.CPQChallengeRoomSent[lang] = "A challenge has been sent to the group in the room. Please wait a while.";
LanguageConstants.CPQChallengeRoomDenied[lang] = "The group in the room canceled your challenge.";
LanguageConstants.CPQFindError[lang] = "We could not find a group in this room.\r\nProbably the group was scrapped inside the room!";
LanguageConstants.CPQEntryLobby[lang] = "You will now receive challenges from other groups. If you do not accept a challenge within 3 minutes, you will be taken out.";
LanguageConstants.CPQEntry[lang] = "You can select \"Summon Monsters\", \"Ability\", or \"Protector\" as your tactic during the Monster Carnival. Use Tab and F1 ~ F12 for quick access!";
}
public static String getMessage(Character chr, String[] message) {
return message[chr.getLanguage()];
}
}

View File

@@ -217,7 +217,6 @@ public final class PlayerLoggedinHandler extends AbstractPacketHandler {
}
if (!newcomer) {
c.setLanguage(player.getClient().getLanguage());
c.setCharacterSlots((byte) player.getClient().getCharacterSlots());
player.newClient(c);
}

View File

@@ -20,12 +20,12 @@
package net.server.coordinator.matchchecker.listener;
import client.Character;
import constants.string.LanguageConstants;
import net.server.coordinator.matchchecker.AbstractMatchCheckerListener;
import net.server.coordinator.matchchecker.MatchCheckerListenerRecipe;
import net.server.world.PartyCharacter;
import scripting.npc.NPCConversationManager;
import scripting.npc.NPCScriptManager;
import server.partyquest.MonsterCarnival;
import java.util.LinkedList;
import java.util.List;
@@ -82,7 +82,7 @@ public class MatchCheckerCPQChallenge implements MatchCheckerListenerRecipe {
NPCScriptManager.getInstance().startCpqScript("cpqchallenge2", ldr.getClient(), npcid, chrMembers);
}
cm.sendOk(LanguageConstants.getMessage(chr, LanguageConstants.CPQChallengeRoomSent));
cm.sendOk("A challenge has been sent to the group in the room. Please wait a while.");
}
@Override
@@ -111,7 +111,7 @@ public class MatchCheckerCPQChallenge implements MatchCheckerListenerRecipe {
@Override
public void onMatchDeclined(int leaderid, Set<Character> matchPlayers, String message) {
Character chr = getChallenger(leaderid, matchPlayers);
chr.dropMessage(5, LanguageConstants.getMessage(chr, LanguageConstants.CPQChallengeRoomDenied));
chr.dropMessage(5, MonsterCarnival.CANCELED_CHALLENGE_TEXT);
}
@Override

View File

@@ -22,7 +22,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package scripting.npc;
import client.Character;
import client.*;
import client.Client;
import client.Job;
import client.Skill;
import client.SkillFactory;
import client.SkinColor;
import client.Stat;
import client.inventory.Item;
import client.inventory.ItemFactory;
import client.inventory.Pet;
@@ -31,7 +36,6 @@ import constants.game.GameConstants;
import constants.id.MapId;
import constants.id.NpcId;
import constants.inventory.ItemConstants;
import constants.string.LanguageConstants;
import net.server.Server;
import net.server.channel.Channel;
import net.server.coordinator.matchchecker.MatchCheckerListenerFactory.MatchCheckerType;
@@ -46,8 +50,13 @@ import provider.Data;
import provider.DataProviderFactory;
import provider.wz.WZFiles;
import scripting.AbstractPlayerInteraction;
import server.*;
import server.ItemInformationProvider;
import server.MapleLeafLogger;
import server.Marriage;
import server.SkillbookInformationProvider;
import server.SkillbookInformationProvider.SkillBookEntry;
import server.StatEffect;
import server.TimerManager;
import server.events.gm.Event;
import server.expeditions.Expedition;
import server.expeditions.ExpeditionType;
@@ -68,8 +77,13 @@ import tools.packets.WeddingPackets;
import java.awt.*;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.*;
import java.util.Map;
import java.util.Set;
import static java.util.concurrent.TimeUnit.MINUTES;
@@ -622,7 +636,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
}
public boolean sendCPQMapLists() {
String msg = LanguageConstants.getMessage(getPlayer(), LanguageConstants.CPQPickRoom);
String msg = MonsterCarnival.PICK_ROOM_TEXT;
int msgLen = msg.length();
for (int i = 0; i < 6; i++) {
if (fieldTaken(i)) {
@@ -678,7 +692,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
if (mc != null) {
mc.setChallenged(false);
mc.changeMap(map, map.getPortal(0));
mc.sendPacket(PacketCreator.serverNotice(6, LanguageConstants.getMessage(mc, LanguageConstants.CPQEntryLobby)));
mc.sendPacket(PacketCreator.serverNotice(6, MonsterCarnival.ENTER_LOBBY_TEXT));
TimerManager tMan = TimerManager.getInstance();
tMan.schedule(() -> mapClock((int) MINUTES.toSeconds(3)), 1500);
@@ -865,7 +879,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
}
public boolean sendCPQMapLists2() {
String msg = LanguageConstants.getMessage(getPlayer(), LanguageConstants.CPQPickRoom);
String msg = MonsterCarnival.PICK_ROOM_TEXT;
int msgLen = msg.length();
for (int i = 0; i < 3; i++) {
if (fieldTaken2(i)) {
@@ -921,7 +935,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
if (mc != null) {
mc.setChallenged(false);
mc.changeMap(map, map.getPortal(0));
mc.sendPacket(PacketCreator.serverNotice(6, LanguageConstants.getMessage(mc, LanguageConstants.CPQEntryLobby)));
mc.sendPacket(PacketCreator.serverNotice(6, MonsterCarnival.ENTER_LOBBY_TEXT));
TimerManager tMan = TimerManager.getInstance();
tMan.schedule(() -> mapClock((int) MINUTES.toSeconds(3)), 1500);
@@ -955,7 +969,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
for (MapObject mmo : map.getAllPlayer()) {
Character mc = (Character) mmo;
if (mc.getParty() == null) {
sendOk(LanguageConstants.getMessage(mc, LanguageConstants.CPQFindError));
sendOk(MonsterCarnival.FIND_ERROR_TEXT);
return;
}
if (mc.getParty().getLeader().getId() == mc.getId()) {
@@ -966,13 +980,13 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
if (leader != null) {
if (!leader.isChallenged()) {
if (!sendCPQChallenge("cpq2", leader.getId())) {
sendOk(LanguageConstants.getMessage(leader, LanguageConstants.CPQChallengeRoomAnswer));
sendOk(MonsterCarnival.FACING_CHALLENGE_TEXT);
}
} else {
sendOk(LanguageConstants.getMessage(leader, LanguageConstants.CPQChallengeRoomAnswer));
sendOk(MonsterCarnival.FACING_CHALLENGE_TEXT);
}
} else {
sendOk(LanguageConstants.getMessage(leader, LanguageConstants.CPQLeaderNotFound));
sendOk(MonsterCarnival.LEADER_NOT_FOUND_TEXT);
}
}
@@ -986,7 +1000,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
for (MapObject mmo : map.getAllPlayer()) {
Character mc = (Character) mmo;
if (mc.getParty() == null) {
sendOk(LanguageConstants.getMessage(mc, LanguageConstants.CPQFindError));
sendOk(MonsterCarnival.FIND_ERROR_TEXT);
return;
}
if (mc.getParty().getLeader().getId() == mc.getId()) {
@@ -997,13 +1011,13 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
if (leader != null) {
if (!leader.isChallenged()) {
if (!sendCPQChallenge("cpq1", leader.getId())) {
sendOk(LanguageConstants.getMessage(leader, LanguageConstants.CPQChallengeRoomAnswer));
sendOk(MonsterCarnival.FACING_CHALLENGE_TEXT);
}
} else {
sendOk(LanguageConstants.getMessage(leader, LanguageConstants.CPQChallengeRoomAnswer));
sendOk(MonsterCarnival.FACING_CHALLENGE_TEXT);
}
} else {
sendOk(LanguageConstants.getMessage(leader, LanguageConstants.CPQLeaderNotFound));
sendOk(MonsterCarnival.LEADER_NOT_FOUND_TEXT);
}
}

View File

@@ -2,7 +2,6 @@ package server.partyquest;
import client.Character;
import config.YamlConfig;
import constants.string.LanguageConstants;
import net.server.Server;
import net.server.channel.Channel;
import net.server.world.Party;
@@ -21,6 +20,15 @@ import static java.util.concurrent.TimeUnit.SECONDS;
* @author Drago (Dragohe4rt)
*/
public class MonsterCarnival {
private static final String ENTRY_TEXT = "You can select \"Summon Monsters\", \"Ability\", or \"Protector\" as your tactic during the Monster Carnival. Use Tab and F1 ~ F12 for quick access!";
private static final String TIME_EXTENSION_TEXT = "The time has been extended.";
public static final String FIND_ERROR_TEXT = "We could not find a group in this room.\r\nProbably the group was scrapped inside the room!";
public static final String ENTER_LOBBY_TEXT = "You will now receive challenges from other groups. If you do not accept a challenge within 3 minutes, you will be taken out.";
public static final String PICK_ROOM_TEXT = "Sign up for the Monster Festival!\r\n";
public static final String LEADER_NOT_FOUND_TEXT = "Could not find the Leader.";
public static final String FACING_CHALLENGE_TEXT = "The group is currently facing a challenge.";
public static final String CANCELED_CHALLENGE_TEXT = "The group in the room canceled your challenge.";
public static int D = 3;
public static int C = 2;
@@ -60,7 +68,7 @@ public class MonsterCarnival {
mc.setTeam(0);
mc.setFestivalPoints(0);
mc.forceChangeMap(map, map.getPortal(redPortal));
mc.dropMessage(6, LanguageConstants.getMessage(mc, LanguageConstants.CPQEntry));
mc.dropMessage(6, ENTRY_TEXT);
if (p1.getLeader().getId() == mc.getId()) {
leader1 = mc;
}
@@ -74,7 +82,7 @@ public class MonsterCarnival {
mc.setTeam(1);
mc.setFestivalPoints(0);
mc.forceChangeMap(map, map.getPortal(bluePortal));
mc.dropMessage(6, LanguageConstants.getMessage(mc, LanguageConstants.CPQEntry));
mc.dropMessage(6, ENTRY_TEXT);
if (p2.getLeader().getId() == mc.getId()) {
leader2 = mc;
}
@@ -85,13 +93,13 @@ public class MonsterCarnival {
for (PartyCharacter mpc : p1.getMembers()) {
Character chr = mpc.getPlayer();
if (chr != null) {
chr.dropMessage(5, LanguageConstants.getMessage(chr, LanguageConstants.CPQError));
chr.dropMessage(5, "There was a problem. Please re-create a room.");
}
}
for (PartyCharacter mpc : p2.getMembers()) {
Character chr = mpc.getPlayer();
if (chr != null) {
chr.dropMessage(5, LanguageConstants.getMessage(chr, LanguageConstants.CPQError));
chr.dropMessage(5, "There was a problem. Please re-create a room.");
}
}
return;
@@ -129,16 +137,12 @@ public class MonsterCarnival {
if (team == -1) {
team = 1;
}
String teamS = "";
switch (team) {
case 0:
teamS = LanguageConstants.getMessage(chrMap, LanguageConstants.CPQRed);
break;
case 1:
teamS = LanguageConstants.getMessage(chrMap, LanguageConstants.CPQBlue);
break;
}
chrMap.dropMessage(5, teamS + LanguageConstants.getMessage(chrMap, LanguageConstants.CPQPlayerExit));
String teamName = switch (team) {
case 0 -> "Maple Red";
case 1 -> "Maple Blue";
default -> "";
};
chrMap.dropMessage(5, "%s left the Carnival of Monsters.".formatted(teamName));
}
earlyFinish();
}
@@ -345,7 +349,7 @@ public class MonsterCarnival {
private void extendTime() {
for (Character chrMap : map.getAllPlayers()) {
chrMap.dropMessage(5, LanguageConstants.getMessage(chrMap, LanguageConstants.CPQExtendTime));
chrMap.dropMessage(5, TIME_EXTENSION_TEXT);
}
startTime = System.currentTimeMillis() + MINUTES.toMillis(3);