Skip to content

Commit

Permalink
Remove i18n (#15)
Browse files Browse the repository at this point in the history
* Always use US-ASCII instead of making it configurable

* Remove LanguageConstants and update references

* Update Character.java

* Update Client.java

* Add missing semicolons

* Fix additional compiler errors
  • Loading branch information
MarloDelatorre authored Aug 24, 2024
1 parent 8fa61f9 commit 6714a46
Show file tree
Hide file tree
Showing 17 changed files with 58 additions and 307 deletions.
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ server:

#Miscellaneous Configuration
TIMEZONE: GMT
CHARSET: US-ASCII # Is loaded first, so applies to the rest of this config. Defaults to US-ASCII if invalid or not set.

USE_DISPLAY_NUMBERS_WITH_COMMA: true #Enforce comma on displayed strings (use this when USE_UNITPRICE_WITH_COMMA is active and you still want to display comma-separated values).
USE_UNITPRICE_WITH_COMMA: true #Set this accordingly with the layout of the unitPrices on Item.wz XML's, whether it's using commas or dots to represent fractions.
MAX_MONITORED_BUFFSTATS: 5 #Limits accounting for "dormant" buff effects, that should take place when stronger stat buffs expires.
Expand Down
1 change: 0 additions & 1 deletion database/migration/V1__db_database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ CREATE TABLE IF NOT EXISTS `accounts` (
`rewardpoints` int(11) NOT NULL DEFAULT '0',
`votepoints` int(11) NOT NULL DEFAULT '0',
`hwid` varchar(12) NOT NULL DEFAULT '',
`language` int(1) NOT NULL DEFAULT '2',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `ranking1` (`id`,`banned`),
Expand Down
22 changes: 2 additions & 20 deletions src/main/java/client/Character.java
Original file line number Diff line number Diff line change
Expand Up @@ -7070,7 +7070,7 @@ public static Character loadCharFromDB(final int charid, Client client, boolean
}

// Account info
try (PreparedStatement ps = con.prepareStatement("SELECT name, characterslots, language FROM accounts WHERE id = ?", Statement.RETURN_GENERATED_KEYS)) {
try (PreparedStatement ps = con.prepareStatement("SELECT name, characterslots FROM accounts WHERE id = ?", Statement.RETURN_GENERATED_KEYS)) {
ps.setInt(1, ret.accountid);

try (ResultSet rs = ps.executeQuery()) {
Expand All @@ -7079,7 +7079,6 @@ public static Character loadCharFromDB(final int charid, Client client, boolean

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
}
}
}
Expand Down Expand Up @@ -11120,24 +11119,7 @@ public void gainAriantPoints(int points) {
public int getAriantPoints() {
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;
}
Expand Down
11 changes: 1 addition & 10 deletions src/main/java/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ public int login(String login, String pwd, Hwid hwid) {
}

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()) {
Expand All @@ -499,7 +499,6 @@ public int login(String login, String pwd, Hwid hwid) {
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");

Expand Down Expand Up @@ -1387,12 +1386,4 @@ public void resetCsCoupon() {
public void enableCSActions() {
sendPacket(PacketCreator.enableCSUse(player));
}

public int getLanguage() {
return lang;
}

public void setLanguage(int lingua) {
this.lang = lingua;
}
}
2 changes: 0 additions & 2 deletions src/main/java/client/command/CommandsExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.EquipLvCommand;
Expand Down Expand Up @@ -346,7 +345,6 @@ private void registerLv0Commands() {
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);
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/java/config/YamlConfig.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package config;

import com.esotericsoftware.yamlbeans.YamlReader;
import constants.string.CharsetConstants;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
Expand All @@ -19,7 +19,7 @@ public class YamlConfig {

private static YamlConfig loadConfig() {
try {
YamlReader reader = new YamlReader(Files.newBufferedReader(Path.of(CONFIG_FILE_NAME), CharsetConstants.CHARSET));
YamlReader reader = new YamlReader(Files.newBufferedReader(Path.of(CONFIG_FILE_NAME), StandardCharsets.US_ASCII));
YamlConfig config = reader.read(YamlConfig.class);
reader.close();
return config;
Expand Down
94 changes: 0 additions & 94 deletions src/main/java/constants/string/CharsetConstants.java

This file was deleted.

95 changes: 0 additions & 95 deletions src/main/java/constants/string/LanguageConstants.java

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/java/net/packet/ByteBufInPacket.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package net.packet;

import constants.string.CharsetConstants;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;

import java.awt.*;
import java.nio.charset.StandardCharsets;

public class ByteBufInPacket implements InPacket {
private final ByteBuf byteBuf;
Expand Down Expand Up @@ -52,7 +52,7 @@ public String readString() {
short length = readShort();
byte[] stringBytes = new byte[length];
byteBuf.readBytes(stringBytes);
return new String(stringBytes, CharsetConstants.CHARSET);
return new String(stringBytes, StandardCharsets.US_ASCII);
}

@Override
Expand Down
Loading

0 comments on commit 6714a46

Please sign in to comment.