Skip to content

Commit

Permalink
Geyser prefix config.
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorfromhell committed Oct 6, 2023
1 parent ed989e2 commit 516f279
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .changelog/0.1.2.5.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# 0.1.2.5
- Added config option for Geyser player prefixes
- Added more debug logging for player account creation.
3 changes: 3 additions & 0 deletions Core/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ Core:
#All configurations relating to the server in general.
Server:

#The geyser prefix for the server.
Geyser: "."

#Whether the ServerID config should be random on each startup. This could impact syncing on
#restarts, but will not impact anything significant.
RandomUUID: false
Expand Down
14 changes: 13 additions & 1 deletion Core/src/net/tnemc/core/TNECore.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ protected void onEnable() {
//Set our server UUID. This is used for proxy messaging.
final boolean randomUUID = MainConfig.yaml().getBoolean("Core.Server.RandomUUID", false);

//Added in build 0.1.2.5-Pre1, removed in 0.1.2.6
//Added in build 0.1.2.4-Pre1, removed in 0.1.2.6
if(!MainConfig.yaml().contains("Core.Commands.LimitCurrency")) {
MainConfig.yaml().set("Core.Commands.LimitCurrency", false);
MainConfig.yaml().setComment("Core.Commands.LimitCurrency", "#Configuration if money action commands, such as give/take/set require individual permissions.");
Expand All @@ -271,6 +271,18 @@ protected void onEnable() {
}
}

//Added in build 0.1.2.5-Pre1, removed in 0.1.2.7
if(!MainConfig.yaml().contains("Core.Server.Geyser")) {
MainConfig.yaml().set("Core.Server.Geyser", ".");
MainConfig.yaml().setComment("Core.Server.Geyser", "#The geyser prefix for the server.");

try {
MainConfig.yaml().save();
} catch(IOException e) {
logger.error("Issue while updating config.yml to config.yml", e, DebugLevel.OFF);
}
}

if(!MessageConfig.yaml().contains("Messages.Account.BlockedAction")) {
MessageConfig.yaml().set("Messages.Account.BlockedAction", "<red>You don't have permission to perform the action \"$action\" with currency \"$currency\"!");

Expand Down
3 changes: 3 additions & 0 deletions Core/src/net/tnemc/core/currency/CurrencyType.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

import net.tnemc.core.EconomyManager;
import net.tnemc.core.TNECore;
import net.tnemc.core.account.Account;
import net.tnemc.core.account.holdings.HoldingsEntry;
import net.tnemc.core.account.holdings.HoldingsHandler;
Expand Down Expand Up @@ -172,5 +173,7 @@ default boolean setHoldings(Account account, String region, Currency currency, I

default void addDatabase(Account account, String region, Currency currency, Identifier type, BigDecimal amount) {
account.getWallet().setHoldings(new HoldingsEntry(region, currency.getUid(), amount, type));

TNECore.storage().store(account, account.getIdentifier());
}
}
24 changes: 19 additions & 5 deletions Core/src/net/tnemc/core/handlers/player/PlayerJoinHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ public class PlayerJoinHandler {
public HandlerResponse handle(PlayerProvider provider) {
final HandlerResponse response = new HandlerResponse("", false);

TNECore.log().debug("Player Join ID: " + provider.identifier());

final Optional<Account> account = TNECore.eco().account().findAccount(provider.identifier());

boolean firstJoin = false;
AccountAPIResponse apiResponse = null;

TNECore.log().debug("Join Account Check: " + account.isPresent());

//Our account doesn't exist, so now we need to continue from here
if(account.isEmpty()) {
firstJoin = true;
Expand All @@ -69,9 +73,15 @@ public HandlerResponse handle(PlayerProvider provider) {
response.setResponse(response.getResponse());
response.setCancelled(true);
return response;
} else {
if(!apiResponse.getResponse().success() && apiResponse.getAccount().isPresent()) {
firstJoin = false;
}
}
}

TNECore.log().debug("First Join: " + firstJoin);

final Optional<Account> acc = (apiResponse == null)? account :
apiResponse.getAccount();

Expand All @@ -96,11 +106,15 @@ public HandlerResponse handle(PlayerProvider provider) {
continue;
}

acc.get().setHoldings(new HoldingsEntry(region,
currency.getUid(),
currency.getStartingHoldings(),
EconomyManager.NORMAL
));
TNECore.log().debug("Setting Balance to Starting Holdings Currency: " + currency.getIdentifier());

if(firstJoin) {
acc.get().setHoldings(new HoldingsEntry(region,
currency.getUid(),
currency.getStartingHoldings(),
EconomyManager.NORMAL
));
}
}
} else {
TNECore.eco().account().getLoading().add(id);
Expand Down
2 changes: 1 addition & 1 deletion Core/src/net/tnemc/core/manager/AccountManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public AccountAPIResponse createAccount(final String identifier, final String na
return new AccountAPIResponse(null, AccountResponse.CREATION_FAILED);
}
}
} else if(!nonPlayer && name.startsWith("*") || !nonPlayer && TNECore.server().online(name)) {
} else if(!nonPlayer && name.startsWith(MainConfig.yaml().getString("Core.Server.Geyser", ".")) || !nonPlayer && TNECore.server().online(name)) {

//This is most definitely a geyser player, they're online but not of valid names
try {
Expand Down

0 comments on commit 516f279

Please sign in to comment.