Initial Commit

This commit is contained in:
Melledy
2025-10-27 02:02:26 -07:00
commit f58951fe2a
378 changed files with 315914 additions and 0 deletions
@@ -0,0 +1,47 @@
package emu.nebula.command.commands;
import emu.nebula.command.Command;
import emu.nebula.command.CommandArgs;
import emu.nebula.command.CommandHandler;
import emu.nebula.game.account.AccountHelper;
import emu.nebula.util.Utils;
@Command(label = "account", permission = "admin.account", desc = "/account {create | delete} [username] (reserved player uid). Creates or deletes an account.")
public class AccountCommand implements CommandHandler {
@Override
public void execute(CommandArgs args) {
if (args.size() < 2) {
args.sendMessage("Invalid amount of args");
return;
}
String command = args.get(0).toLowerCase();
String username = args.get(1);
switch (command) {
case "create" -> {
// Reserved player uid
int reservedUid = 0;
if (args.size() >= 3) {
reservedUid = Utils.parseSafeInt(args.get(2));
}
if (AccountHelper.createAccount(username, null, reservedUid) != null) {
args.sendMessage("Account created");
} else {
args.sendMessage("Account already exists");
}
}
case "delete" -> {
if (AccountHelper.deleteAccount(username)) {
args.sendMessage("Account deleted");
} else {
args.sendMessage("Account doesnt exist");
}
}
}
}
}
@@ -0,0 +1,45 @@
package emu.nebula.command.commands;
import emu.nebula.util.Utils;
import emu.nebula.data.GameData;
import emu.nebula.game.mail.GameMail;
import emu.nebula.command.Command;
import emu.nebula.command.CommandArgs;
import emu.nebula.command.CommandHandler;
@Command(
label = "give",
aliases = {"g", "item"},
permission = "player.give",
requireTarget = true,
desc = "/give [item id] x(amount). Gives the targeted player an item."
)
public class GiveCommand implements CommandHandler {
@Override
public void execute(CommandArgs args) {
// Setup mail
var mail = new GameMail("System", "Give Command Result", "");
// Get amount to give
int amount = Math.max(args.getAmount(), 1);
// Parse items
for (String arg : args.getList()) {
// Parse item id
int itemId = Utils.parseSafeInt(arg);
var itemData = GameData.getItemDataTable().get(itemId);
if (itemData == null) {
args.sendMessage("Item \"" + arg + "\" does not exist!");
continue;
}
// Add
mail.addAttachment(itemId, amount);
}
// Add mail
args.getTarget().getMailbox().sendMail(mail);
}
}
@@ -0,0 +1,20 @@
package emu.nebula.command.commands;
import emu.nebula.command.Command;
import emu.nebula.command.CommandArgs;
import emu.nebula.command.CommandHandler;
import emu.nebula.game.mail.GameMail;
@Command(label = "mail", aliases = {"m"}, permission = "player.mail", requireTarget = true, desc = "/mail [content]. Sends the targeted player a system mail.")
public class MailCommand implements CommandHandler {
@Override
public void execute(CommandArgs args) {
// Setup mail
var mail = new GameMail("System", "Test", "This is a test mail");
// Add mail
args.getTarget().getMailbox().sendMail(mail);
}
}
@@ -0,0 +1,17 @@
package emu.nebula.command.commands;
import emu.nebula.Nebula;
import emu.nebula.command.Command;
import emu.nebula.command.CommandArgs;
import emu.nebula.command.CommandHandler;
@Command(label = "reload", permission = "admin.reload", desc = "/reload. Reloads the server config.")
public class ReloadCommand implements CommandHandler {
@Override
public void execute(CommandArgs args) {
Nebula.loadConfig();
args.sendMessage("Reloaded the server config");
}
}