the playerlist is still funky not sure on how to get by name yet also the commits with return 0; you'll have to fix since they are no longer even close to the lines on the previous patch
Some checks failed
build / build (21) (push) Has been cancelled
Some checks failed
build / build (21) (push) Has been cancelled
This commit is contained in:
parent
7e4eb94248
commit
46bdc1aad4
@ -31,8 +31,7 @@ public class BankManager {
|
|||||||
if (!existingFile) {
|
if (!existingFile) {
|
||||||
System.out.println(ChatUtil.ColoredString("Trying to create new file", CONSOLE_COLOR.BLUE));
|
System.out.println(ChatUtil.ColoredString("Trying to create new file", CONSOLE_COLOR.BLUE));
|
||||||
try {
|
try {
|
||||||
bankInfo.uuid = uuid;
|
FlashConfig(bankInfo.uuid);
|
||||||
FlashConfig();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println(ChatUtil.ColoredString("Could not write to file", CONSOLE_COLOR.RED));
|
System.out.println(ChatUtil.ColoredString("Could not write to file", CONSOLE_COLOR.RED));
|
||||||
}
|
}
|
||||||
@ -58,7 +57,7 @@ public class BankManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
long balance = 0;
|
long balance = 0;
|
||||||
String reason;
|
String reason; //not sure why my compiler is saying unused
|
||||||
long payment;
|
long payment;
|
||||||
String otherParty;
|
String otherParty;
|
||||||
Integer time;
|
Integer time;
|
||||||
@ -98,55 +97,55 @@ public class BankManager {
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
//https://maven.fabricmc.net/docs/fabric-api-0.34.8+1.17/net/fabricmc/fabric/api/networking/v1/PlayerLookup.html maybe this for getting the players im still not sure
|
||||||
public void SetBalance(Integer newBalance, String reason, long payment, String otherParty, Integer time) {
|
public void SetBalance(Integer newBalance, String reason, String otherParty) {
|
||||||
Integer transactionNumber = bankInfo.bank.size();
|
Integer transactionNumber = bankInfo.bank.size();
|
||||||
bankInfo.bank.put(transactionNumber.toString(),
|
bankInfo.bank.put(transactionNumber.toString(),
|
||||||
new BankManagerMetaData(newBalance, reason, payment, otherParty, time));
|
new BankManagerMetaData(newBalance, reason, newBalance, otherParty, 0));
|
||||||
|
|
||||||
FlashConfig();
|
FlashConfig(PlayerListNameChecker(otherParty));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddMoney(Integer newBalance, String reason, long payment, String otherParty, Integer time) {
|
public void AddMoney(String reason, long payment, String otherParty) {
|
||||||
if (bankInfo.bank.size() > 0) {
|
if (bankInfo.bank.size() > 0) {
|
||||||
for (Entry<String, BankManagerMetaData> entry : bankInfo.bank.entrySet()) {
|
for (Entry<String, BankManagerMetaData> entry : bankInfo.bank.entrySet()) {
|
||||||
entry.getValue().balance += newBalance;
|
entry.getValue().balance += payment;
|
||||||
entry.getValue().reason = reason;
|
entry.getValue().reason = "SERVER: " + reason;
|
||||||
entry.getValue().payment = payment;
|
entry.getValue().payment = payment;
|
||||||
entry.getValue().otherParty = otherParty;
|
entry.getValue().otherParty = otherParty;
|
||||||
entry.getValue().time = time;
|
entry.getValue().time = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bankInfo.bank.put(bankInfo.uuid, new BankManagerMetaData(newBalance, reason, payment, otherParty, time));
|
bankInfo.bank.put(bankInfo.uuid, new BankManagerMetaData(payment, reason, payment, otherParty, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
FlashConfig();
|
FlashConfig(PlayerListNameChecker(otherParty));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SubtractBalance(Integer newBalance, String reason, long payment, String otherParty, Integer time) {
|
public void SubtractBalance(String reason, long payment, String otherParty) {
|
||||||
if (bankInfo.bank.size() > 0) {
|
if (bankInfo.bank.size() > 0) {
|
||||||
for (Entry<String, BankManagerMetaData> entry : bankInfo.bank.entrySet()) {
|
for (Entry<String, BankManagerMetaData> entry : bankInfo.bank.entrySet()) {
|
||||||
entry.getValue().balance -= newBalance;
|
entry.getValue().balance -= payment;//not working?
|
||||||
entry.getValue().reason = reason;
|
entry.getValue().reason = "SERVER: " + reason;
|
||||||
entry.getValue().payment = payment;
|
entry.getValue().payment = payment;
|
||||||
entry.getValue().otherParty = otherParty;
|
entry.getValue().otherParty = otherParty;
|
||||||
entry.getValue().time = time;
|
entry.getValue().time = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bankInfo.bank.put(bankInfo.uuid, new BankManagerMetaData(newBalance, reason, payment, otherParty, time));
|
bankInfo.bank.put(bankInfo.uuid, new BankManagerMetaData(0, reason, payment, otherParty, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
FlashConfig();
|
FlashConfig(PlayerListNameChecker(otherParty));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Wire(Integer newBalance, String reason, long payment, String otherParty, Integer time) {
|
public void Wire(String reason, long payment, String otherParty) {
|
||||||
if (bankInfo.bank.size() > 0) {
|
if (bankInfo.bank.size() > 0) {
|
||||||
for (Entry<String, BankManagerMetaData> entry : bankInfo.bank.entrySet()) {
|
for (Entry<String, BankManagerMetaData> entry : bankInfo.bank.entrySet()) {
|
||||||
entry.getValue().balance -= newBalance;
|
entry.getValue().balance -= payment;
|
||||||
entry.getValue().reason = reason;
|
entry.getValue().reason = reason;
|
||||||
entry.getValue().payment = payment;
|
entry.getValue().payment = payment;
|
||||||
entry.getValue().otherParty = otherParty;
|
entry.getValue().otherParty = otherParty;
|
||||||
entry.getValue().time = time;
|
entry.getValue().time = 0;
|
||||||
|
|
||||||
if (payment <= 0) {
|
if (payment <= 0) {
|
||||||
// add a error for the PLAYER not the server
|
// add a error for the PLAYER not the server
|
||||||
@ -180,15 +179,15 @@ public class BankManager {
|
|||||||
newBankInfo = config.GetJsonObjectFromFile("bank/" + GetUuidByName(server, otherParty) + ".json", BankManagerFile.class);
|
newBankInfo = config.GetJsonObjectFromFile("bank/" + GetUuidByName(server, otherParty) + ".json", BankManagerFile.class);
|
||||||
// for now we will only use adding valance and not subtracting since that dosent make any sense
|
// for now we will only use adding valance and not subtracting since that dosent make any sense
|
||||||
for (Entry<String, BankManagerMetaData> entry : newBankInfo.bank.entrySet()) {
|
for (Entry<String, BankManagerMetaData> entry : newBankInfo.bank.entrySet()) {
|
||||||
entry.getValue().balance += newBalance;
|
entry.getValue().balance += payment;
|
||||||
entry.getValue().reason = reason;
|
entry.getValue().reason = reason;
|
||||||
entry.getValue().payment = payment;
|
entry.getValue().payment = payment;
|
||||||
entry.getValue().otherParty = otherParty;
|
entry.getValue().otherParty = otherParty;
|
||||||
entry.getValue().time = time;
|
entry.getValue().time = 0;
|
||||||
}
|
}
|
||||||
//cannot use regular flash config since the hard coded values need to add agurment for the uuid
|
//cannot use regular flash config since the hard coded values need to add agurment for the uuid
|
||||||
//needs to be inside the player check
|
//needs to be inside the player check
|
||||||
FlashConfig();
|
FlashConfig(newBankInfo.uuid);
|
||||||
try {
|
try {
|
||||||
config.WriteToJsonFile("bank/" + newBankInfo.uuid + ".json", bankInfo);
|
config.WriteToJsonFile("bank/" + newBankInfo.uuid + ".json", bankInfo);
|
||||||
} catch (FILE_WRITE_EXCEPTION e) {
|
} catch (FILE_WRITE_EXCEPTION e) {
|
||||||
@ -216,9 +215,40 @@ public class BankManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FlashConfig() {
|
String PlayerListNameChecker(String otherParty) {
|
||||||
|
MinecraftServer server = CommonServerUtils.GetServerInstance();
|
||||||
|
String[] playerList = server.getPlayerNames();
|
||||||
|
|
||||||
|
for (int i = 0; i < playerList.length; i++) {
|
||||||
|
System.out.println(ChatUtil.ColoredString("PLAYERS: " + playerList, CONSOLE_COLOR.YELLOW));
|
||||||
|
if (playerList[i] == otherParty) {
|
||||||
|
System.out.println(ChatUtil.ColoredString("Found Player: " + otherParty, CONSOLE_COLOR.GREEN));
|
||||||
|
// we will use getuuidbyname then set the other VALID players bank BE SURE TO
|
||||||
|
// MAKE THEM A BANK FIRST IF THEY DONT HAVE ONE fortnite forever
|
||||||
|
if (config.GetFile("bank/" + GetUuidByName(server, otherParty) + ".json").size() < 1) {
|
||||||
|
BankManagerFile newBankInfo = new BankManagerFile();
|
||||||
|
BankManagerMetaData newBank = new BankManagerMetaData(0, "Account Created", 0, "Server", 0);
|
||||||
|
newBankInfo.bank.put(GetUuidByName(server, otherParty).toString(), newBank);
|
||||||
try {
|
try {
|
||||||
config.WriteToJsonFile("bank/" + bankInfo.uuid.toString() + ".json", bankInfo);
|
config.WriteToJsonFile("bank/" + newBankInfo.uuid + ".json", newBankInfo);
|
||||||
|
} catch (FILE_WRITE_EXCEPTION e) {
|
||||||
|
System.out.println(ChatUtil.ColoredString("Could not flash notes configuration file", CONSOLE_COLOR.RED));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println(ChatUtil.ColoredString("Bank Account Found", CONSOLE_COLOR.GREEN));
|
||||||
|
}
|
||||||
|
return GetUuidByName(server, otherParty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println(ChatUtil.ColoredString("For Loop condition bypassed Null Playerlist or Null Server instance", CONSOLE_COLOR.RED));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FlashConfig(String uuid) {
|
||||||
|
try {
|
||||||
|
config.WriteToJsonFile("bank/" + uuid + ".json", bankInfo);
|
||||||
} catch (FILE_WRITE_EXCEPTION e) {
|
} catch (FILE_WRITE_EXCEPTION e) {
|
||||||
System.out.println(ChatUtil.ColoredString("Could not flash notes configuration file", CONSOLE_COLOR.RED));
|
System.out.println(ChatUtil.ColoredString("Could not flash notes configuration file", CONSOLE_COLOR.RED));
|
||||||
}
|
}
|
||||||
|
@ -23,82 +23,62 @@ public class BankCommands {
|
|||||||
.executes(context -> GetBalance(context)));
|
.executes(context -> GetBalance(context)));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Command: "/setbalance"
|
// Command: "/setbalance || rootSetBalance"
|
||||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
||||||
final var rootSetBalance = dispatcher.register(CommandManager.literal("setbalance")
|
final var rootSetBalance = dispatcher.register(CommandManager.literal("setbalance")
|
||||||
.then(CommandManager.argument("newBalance", IntegerArgumentType.integer())
|
.then(CommandManager.argument("newBalance", IntegerArgumentType.integer())
|
||||||
.then(CommandManager.argument("reason", StringArgumentType.string())
|
.then(CommandManager.argument("reason", StringArgumentType.string())
|
||||||
.then(CommandManager.argument("payment", LongArgumentType.longArg())
|
|
||||||
.then(CommandManager.argument("otherParty", StringArgumentType.string())
|
.then(CommandManager.argument("otherParty", StringArgumentType.string())
|
||||||
//probably will remove time and otherParty from this agurment list not sure yet
|
|
||||||
.then(CommandManager.argument("time", IntegerArgumentType.integer())
|
|
||||||
.executes(context -> SetBalance(
|
.executes(context -> SetBalance(
|
||||||
IntegerArgumentType.getInteger(context, "newBalance"),
|
IntegerArgumentType.getInteger(context, "newBalance"),
|
||||||
StringArgumentType.getString(context, "reason"),
|
StringArgumentType.getString(context, "reason"),
|
||||||
LongArgumentType.getLong(context, "payment"),
|
|
||||||
StringArgumentType.getString(context, "otherParty"),
|
StringArgumentType.getString(context, "otherParty"),
|
||||||
IntegerArgumentType.getInteger(context, "time"),
|
context))))));
|
||||||
context))))))));
|
|
||||||
|
|
||||||
dispatcher.register(CommandManager.literal("resetbalance").redirect(rootSetBalance));
|
dispatcher.register(CommandManager.literal("setbalance").redirect(rootSetBalance));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Command: "/AddMoney"
|
// Command: "/AddMoney"
|
||||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
||||||
dispatcher.register(CommandManager.literal("AddMoney")
|
dispatcher.register(CommandManager.literal("AddMoney")
|
||||||
.then(CommandManager.argument("newBalance", IntegerArgumentType.integer())
|
|
||||||
.then(CommandManager.argument("reason", StringArgumentType.string())
|
.then(CommandManager.argument("reason", StringArgumentType.string())
|
||||||
.then(CommandManager.argument("payment", LongArgumentType.longArg())
|
.then(CommandManager.argument("payment", LongArgumentType.longArg())
|
||||||
.then(CommandManager.argument("otherParty", StringArgumentType.string())
|
.then(CommandManager.argument("otherParty", StringArgumentType.string())
|
||||||
//probably will remove time and otherParty from this agurment list not sure yet
|
|
||||||
.then(CommandManager.argument("time", IntegerArgumentType.integer())
|
|
||||||
.executes(context -> AddMoney(
|
.executes(context -> AddMoney(
|
||||||
IntegerArgumentType.getInteger(context, "newBalance"),
|
|
||||||
StringArgumentType.getString(context, "reason"),
|
StringArgumentType.getString(context, "reason"),
|
||||||
LongArgumentType.getLong(context, "payment"),
|
LongArgumentType.getLong(context, "payment"),
|
||||||
StringArgumentType.getString(context, "otherParty"),
|
StringArgumentType.getString(context, "otherParty"),
|
||||||
IntegerArgumentType.getInteger(context, "time"),
|
context))))));
|
||||||
context))))))));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Command: "/removebalance"
|
// Command: "/subtractbalance || /SubtractBalance"
|
||||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
||||||
final var rootSubtractBalance = dispatcher.register(CommandManager.literal("subtractbalance")
|
final var SubtractBalance = dispatcher.register(CommandManager.literal("subtractbalance")
|
||||||
.then(CommandManager.argument("newBalance", IntegerArgumentType.integer())
|
|
||||||
.then(CommandManager.argument("reason", StringArgumentType.string())
|
.then(CommandManager.argument("reason", StringArgumentType.string())
|
||||||
.then(CommandManager.argument("payment", LongArgumentType.longArg())
|
.then(CommandManager.argument("payment", LongArgumentType.longArg())
|
||||||
.then(CommandManager.argument("otherParty", StringArgumentType.string())
|
.then(CommandManager.argument("otherParty", StringArgumentType.string())
|
||||||
//probably will remove time and otherParty from this agurment list not sure yet
|
|
||||||
.then(CommandManager.argument("time", IntegerArgumentType.integer())
|
|
||||||
.executes(context -> SubtractBalance(
|
.executes(context -> SubtractBalance(
|
||||||
IntegerArgumentType.getInteger(context, "newBalance"),
|
|
||||||
StringArgumentType.getString(context, "reason"),
|
StringArgumentType.getString(context, "reason"),
|
||||||
LongArgumentType.getLong(context, "payment"),
|
LongArgumentType.getLong(context, "payment"),
|
||||||
StringArgumentType.getString(context, "otherParty"),
|
StringArgumentType.getString(context, "otherParty"),
|
||||||
IntegerArgumentType.getInteger(context, "time"),
|
context))))));
|
||||||
context))))))));
|
|
||||||
|
|
||||||
dispatcher.register(CommandManager.literal("-balance").redirect(rootSubtractBalance));
|
dispatcher.register(CommandManager.literal("subtractbalance").redirect(SubtractBalance));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Command: "/wire"
|
// Command: "/wire || /sendmoney"
|
||||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
||||||
final var sendmoney = dispatcher.register(CommandManager.literal("wire")
|
final var sendmoney = dispatcher.register(CommandManager.literal("wire")
|
||||||
.then(CommandManager.argument("newBalance", IntegerArgumentType.integer())
|
|
||||||
.then(CommandManager.argument("reason", StringArgumentType.string())
|
.then(CommandManager.argument("reason", StringArgumentType.string())
|
||||||
.then(CommandManager.argument("payment", LongArgumentType.longArg())
|
.then(CommandManager.argument("payment", LongArgumentType.longArg())
|
||||||
.then(CommandManager.argument("otherParty", StringArgumentType.string())
|
.then(CommandManager.argument("otherParty", StringArgumentType.string())
|
||||||
//probably will remove time and otherParty from this agurment list not sure yet
|
|
||||||
.then(CommandManager.argument("time", IntegerArgumentType.integer())
|
|
||||||
.executes(context -> Wire(
|
.executes(context -> Wire(
|
||||||
IntegerArgumentType.getInteger(context, "newBalance"),
|
|
||||||
StringArgumentType.getString(context, "reason"),
|
StringArgumentType.getString(context, "reason"),
|
||||||
LongArgumentType.getLong(context, "payment"),
|
LongArgumentType.getLong(context, "payment"),
|
||||||
StringArgumentType.getString(context, "otherParty"),
|
StringArgumentType.getString(context, "otherParty"),
|
||||||
IntegerArgumentType.getInteger(context, "time"),
|
context))))));
|
||||||
context))))))));
|
|
||||||
|
|
||||||
dispatcher.register(CommandManager.literal("resetbalance").redirect(sendmoney));
|
dispatcher.register(CommandManager.literal("wire").redirect(sendmoney));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,58 +95,58 @@ public class BankCommands {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
//SetBalance will be a ServerCommand only
|
//SetBalance will be a ServerCommand only Perm level Op
|
||||||
public Integer SetBalance(Integer newBalance, String reason, long payment, String otherParty, Integer time, CommandContext<ServerCommandSource> context) {
|
public Integer SetBalance(Integer newBalance, String reason, String otherParty, CommandContext<ServerCommandSource> context) {
|
||||||
Integer ret = -1;
|
Integer ret = -1;
|
||||||
|
|
||||||
if (context.getSource().isExecutedByPlayer()) {
|
if (context.getSource().hasPermissionLevel(1)) {
|
||||||
ServerPlayerEntity player = context.getSource().getPlayer();
|
ServerPlayerEntity player = context.getSource().getPlayer();
|
||||||
BankManager playerBank = new BankManager(player.getUuidAsString());
|
BankManager playerBank = new BankManager(player.getUuidAsString());
|
||||||
playerBank.SetBalance(newBalance, reason, payment, otherParty, time);
|
playerBank.SetBalance(newBalance, reason, otherParty);
|
||||||
player.sendMessage(Text.literal(String.valueOf(playerBank.GetBalance())));
|
player.sendMessage(Text.literal(String.valueOf(playerBank.GetBalance())));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
//AddMoney will be a ServerCommand Only
|
//AddMoney will be a ServerCommand Only Perm level Op
|
||||||
public Integer AddMoney(Integer newBalance, String reason, long payment, String otherParty, Integer time, CommandContext<ServerCommandSource> context) {
|
public Integer AddMoney(String reason, long payment, String otherParty, CommandContext<ServerCommandSource> context) {
|
||||||
Integer ret = -1;
|
Integer ret = -1;
|
||||||
|
|
||||||
if (context.getSource().isExecutedByPlayer()) {
|
if (context.getSource().hasPermissionLevel(1)) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
ServerPlayerEntity player = context.getSource().getPlayer();
|
ServerPlayerEntity player = context.getSource().getPlayer();
|
||||||
BankManager playerBank = new BankManager(player.getUuidAsString());
|
BankManager playerBank = new BankManager(player.getUuidAsString());
|
||||||
playerBank.AddMoney(newBalance, reason, payment, otherParty, time);
|
playerBank.AddMoney(reason, payment, otherParty);
|
||||||
player.sendMessage(Text.literal(String.valueOf(playerBank.GetBalance())));
|
player.sendMessage(Text.literal(String.valueOf(playerBank.GetBalance())));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
//SubtractBalance will be a ServerCommand only
|
//SubtractBalance will be a ServerCommand Perm leve Op
|
||||||
public Integer SubtractBalance(Integer newBalance, String reason, long payment, String otherParty, Integer time, CommandContext<ServerCommandSource> context) {
|
public Integer SubtractBalance(String reason, long payment, String otherParty, CommandContext<ServerCommandSource> context) {
|
||||||
Integer ret = -1;
|
Integer ret = -1;
|
||||||
|
|
||||||
if (context.getSource().isExecutedByPlayer()) {
|
if (context.getSource().hasPermissionLevel(1)) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
ServerPlayerEntity player = context.getSource().getPlayer();
|
ServerPlayerEntity player = context.getSource().getPlayer();
|
||||||
BankManager playerBank = new BankManager(player.getUuidAsString());
|
BankManager playerBank = new BankManager(player.getUuidAsString());
|
||||||
playerBank.SubtractBalance(newBalance, reason, payment, otherParty, time);
|
playerBank.SubtractBalance(reason, payment, otherParty);
|
||||||
player.sendMessage(Text.literal(String.valueOf(playerBank.GetBalance())));
|
player.sendMessage(Text.literal(String.valueOf(playerBank.GetBalance())));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer Wire(Integer newBalance, String reason, long payment, String otherParty, Integer time, CommandContext<ServerCommandSource> context) {
|
public Integer Wire(String reason, long payment, String otherParty, CommandContext<ServerCommandSource> context) {
|
||||||
Integer ret = -1;
|
Integer ret = -1;
|
||||||
|
|
||||||
if (context.getSource().isExecutedByPlayer()) {
|
if (context.getSource().isExecutedByPlayer()) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
ServerPlayerEntity player = context.getSource().getPlayer();
|
ServerPlayerEntity player = context.getSource().getPlayer();
|
||||||
BankManager playerBank = new BankManager(player.getUuidAsString());
|
BankManager playerBank = new BankManager(player.getUuidAsString());
|
||||||
playerBank.Wire(newBalance, reason, payment, otherParty, time);
|
playerBank.Wire(reason, payment, otherParty);
|
||||||
player.sendMessage(Text.literal(String.valueOf(playerBank.GetBalance())));
|
player.sendMessage(Text.literal(String.valueOf(playerBank.GetBalance())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,38 +150,6 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//NOTE: THIS APPENDS TO EXISITING JSON FILE
|
|
||||||
// public void AppendToJsonFile(String fileName, Object data) throws FILE_WRITE_EXCEPTION {
|
|
||||||
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
|
||||||
// File file = new File(fileName);
|
|
||||||
// if (!file.exists()) {
|
|
||||||
// WriteToJsonFile(fileName, data);
|
|
||||||
// }
|
|
||||||
// try {
|
|
||||||
// //read the json file and get the objects and store them in a array
|
|
||||||
// FileReader jsonParser = new FileReader(fileName);
|
|
||||||
// JsonArray jsonArray = new JsonArray();
|
|
||||||
// jsonArray = JsonParser.parseReader(jsonParser).getAsJsonArray();
|
|
||||||
// FileWriter writer = new FileWriter(fileName);
|
|
||||||
// jsonParser.close();
|
|
||||||
|
|
||||||
// //make the new json object here convert the map with gson and put in the array
|
|
||||||
// JsonObject createJsonObject = new JsonObject();
|
|
||||||
// Gson mapper = new Gson();
|
|
||||||
// createJsonObject = mapper.toJsonTree(data).getAsJsonObject();
|
|
||||||
// jsonArray.add(createJsonObject);
|
|
||||||
|
|
||||||
// //write to file
|
|
||||||
// gson.toJson(jsonArray, writer);
|
|
||||||
// writer.flush();
|
|
||||||
// writer.close();
|
|
||||||
// }
|
|
||||||
// catch (JsonIOException | IOException e) {
|
|
||||||
// System.out.println(ChatUtil.ColoredString("Could not successfully write to json file", CONSOLE_COLOR.RED));
|
|
||||||
// throw new FILE_WRITE_EXCEPTION();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// GetJsonStringFromFile
|
// GetJsonStringFromFile
|
||||||
//
|
//
|
||||||
// Retrieves json file and converts to desired object. Returns JsonSyntaxException if file could not be fitted to class input
|
// Retrieves json file and converts to desired object. Returns JsonSyntaxException if file could not be fitted to class input
|
||||||
|
Loading…
Reference in New Issue
Block a user