Commit d468edcf authored by Akka's avatar Akka
Browse files

merge

parents 4b6842f0 3a5503de
......@@ -31,4 +31,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: Grasscutter
path: grasscutter-*-dev.jar
path: grasscutter-*.jar
......@@ -43,7 +43,7 @@ sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
group = 'xyz.grasscutters'
version = '1.0.3-dev'
version = '1.1.0'
sourceCompatibility = 17
targetCompatibility = 17
......
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "JSON schema for a Grasscutter Plugin",
"type": "object",
"additionalProperties": true,
"definitions": {
"plugin-name": {
"type": "string",
"pattern": "^[A-Za-z\\d_.-]+$"
}
},
"required": [ "name", "description", "mainClass" ],
"properties": {
"name": {
"description": "The unique name of plugin.",
"$ref": "#/definitions/plugin-name"
},
"mainClass": {
"description": "The plugin's initial class file.",
"type": "string",
"pattern": "^(?!org\\.bukkit\\.)([a-zA-Z_$][a-zA-Z\\d_$]*\\.)*[a-zA-Z_$][a-zA-Z\\d_$]*$"
},
"version": {
"description": "A plugin revision identifier.",
"type": [ "string", "number" ]
},
"description": {
"description": "Human readable plugin summary.",
"type": "string"
},
"author": {
"description": "The plugin author.",
"type": "string"
},
"authors": {
"description": "The plugin contributors.",
"type": "array",
"items": {
"type": "string"
}
},
"website": {
"title": "Website",
"description": "The URL to the plugin's site",
"type": "string",
"format": "uri"
}
}
}
\ No newline at end of file
......@@ -23,7 +23,7 @@ public final class Config {
public GameServerOptions GameServer = new GameServerOptions();
public DispatchServerOptions DispatchServer = new DispatchServerOptions();
public Locale LocaleLanguage = Locale.getDefault();
public Locale DefaultLanguage = Locale.US;
public Locale DefaultLanguage = Locale.ENGLISH;
public Boolean OpenStamina = true;
public GameServerOptions getGameServerOptions() {
......
......@@ -149,9 +149,10 @@ public final class Grasscutter {
public static void loadLanguage() {
var locale = config.LocaleLanguage;
String languageTag = locale.toLanguageTag();
var languageTag = locale.toLanguageTag();
if (languageTag.equals("und")) {
Grasscutter.getLogger().error("Illegal locale language, using en-US instead.");
Grasscutter.getLogger().error("Illegal locale language, using 'en-US' instead.");
language = Language.getLanguage("en-US");
} else {
language = Language.getLanguage(languageTag);
......
......@@ -9,7 +9,7 @@ public @interface Command {
String usage() default "No usage specified";
String description() default "No description specified";
String description() default "commands.generic.no_description_specified";
String[] aliases() default {};
......
......@@ -6,6 +6,7 @@ import emu.grasscutter.game.player.Player;
import java.util.List;
public interface CommandHandler {
/**
* Send a message to the target.
*
......
......@@ -79,6 +79,12 @@ public final class CommandMap {
return this;
}
public List<Command> getAnnotationsAsList() { return new LinkedList<>(this.annotations.values()); }
public HashMap<String, Command> getAnnotations() {
return new LinkedHashMap<>(this.annotations);
}
/**
* Returns a list of all registered commands.
*
......
......@@ -9,7 +9,7 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "account", usage = "account <create|delete> <username> [uid]", description = "Modify user accounts")
@Command(label = "account", usage = "account <create|delete> <username> [uid]", description = "commands.account.description")
public final class AccountCommand implements CommandHandler {
@Override
......
......@@ -9,8 +9,7 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "broadcast", usage = "broadcast <message>",
description = "Sends a message to all the players", aliases = {"b"}, permission = "server.broadcast")
@Command(label = "broadcast", usage = "broadcast <message>", aliases = {"b"}, permission = "server.broadcast", description = "commands.broadcast.description")
public final class BroadcastCommand implements CommandHandler {
@Override
......
......@@ -8,9 +8,9 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "changescene", usage = "changescene <scene id>",
description = "Changes your scene", aliases = {"scene"}, permission = "player.changescene")
@Command(label = "changescene", usage = "changescene <scene id>", aliases = {"scene"}, permission = "player.changescene", description = "commands.changescene.description")
public final class ChangeSceneCommand implements CommandHandler {
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {
......
......@@ -13,7 +13,7 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "clear", usage = "clear <all|wp|art|mat>", //Merged /clearartifacts and /clearweapons to /clear <args> [uid]
description = "Deletes unequipped unlocked items, including yellow rarity ones from your inventory",
description = "commands.clear.description",
aliases = {"clear"}, permission = "player.clearinv")
public final class ClearCommand implements CommandHandler {
......
......@@ -9,9 +9,9 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "coop", usage = "coop [host UID]",
description = "Forces someone to join the world of others", permission = "server.coop")
@Command(label = "coop", usage = "coop [host UID]", permission = "server.coop", description = "commands.coop.description")
public final class CoopCommand implements CommandHandler {
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {
......
......@@ -13,8 +13,7 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "drop", usage = "drop <itemId|itemName> [amount]",
description = "Drops an item near you", aliases = {"d", "dropitem"}, permission = "server.drop")
@Command(label = "drop", usage = "drop <itemId|itemName> [amount]", aliases = {"d", "dropitem"}, permission = "server.drop", description = "commands.drop.description")
public final class DropCommand implements CommandHandler {
@Override
......
......@@ -8,9 +8,9 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "enterdungeon", usage = "enterdungeon <dungeon id>",
description = "Enter a dungeon", aliases = {"dungeon"}, permission = "player.enterdungeon")
@Command(label = "enterdungeon", usage = "enterdungeon <dungeon id>", aliases = {"dungeon"}, permission = "player.enterdungeon", description = "commands.enter_dungeon.description")
public final class EnterDungeonCommand implements CommandHandler {
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {
......
......@@ -15,8 +15,7 @@ import java.util.*;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "giveall", usage = "giveall [amount]",
description = "Gives all items", aliases = {"givea"}, permission = "player.giveall", threading = true)
@Command(label = "giveall", usage = "giveall [amount]", aliases = {"givea"}, permission = "player.giveall", threading = true, description = "commands.giveAll.description")
public final class GiveAllCommand implements CommandHandler {
@Override
......
......@@ -16,8 +16,9 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "giveart", usage = "giveart <artifactId> <mainPropId> [<appendPropId>[,<times>]]... [level]", description = "Gives the player a specified artifact", aliases = {"gart"}, permission = "player.giveart")
@Command(label = "giveart", usage = "giveart <artifactId> <mainPropId> [<appendPropId>[,<times>]]... [level]", aliases = {"gart"}, permission = "player.giveart", description = "commands.giveArtifact.description")
public final class GiveArtifactCommand implements CommandHandler {
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {
......
......@@ -12,8 +12,7 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "givechar", usage = "givechar <avatarId> [level]",
description = "Gives the player a specified character", aliases = {"givec"}, permission = "player.givechar")
@Command(label = "givechar", usage = "givechar <avatarId> [level]", aliases = {"givec"}, permission = "player.givechar", description = "commands.giveChar.description")
public final class GiveCharCommand implements CommandHandler {
@Override
......@@ -77,6 +76,6 @@ public final class GiveCharCommand implements CommandHandler {
avatar.recalcStats();
targetPlayer.addAvatar(avatar);
CommandHandler.sendMessage(sender, translate("commands.execution.giveChar.given", Integer.toString(avatarId), Integer.toString(level), Integer.toString(targetPlayer.getUid())));
CommandHandler.sendMessage(sender, translate("commands.giveChar.given", Integer.toString(avatarId), Integer.toString(level), Integer.toString(targetPlayer.getUid())));
}
}
package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GameData;
......@@ -12,13 +11,13 @@ import emu.grasscutter.game.props.ActionReason;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "give", usage = "give <itemId|itemName> [amount] [level]", description = "Gives an item to you or the specified player", aliases = {
"g", "item", "giveitem"}, permission = "player.give")
@Command(label = "give", usage = "give <itemId|itemName> [amount] [level]", aliases = {
"g", "item", "giveitem"}, permission = "player.give", description = "commands.give.description")
public final class GiveCommand implements CommandHandler {
Pattern lvlRegex = Pattern.compile("l(?:vl?)?(\\d+)"); // Java is a joke of a proglang that doesn't have raw string literals
Pattern refineRegex = Pattern.compile("r(\\d+)");
......
package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.player.Player;
......@@ -9,8 +8,7 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "godmode", usage = "godmode [on|off|toggle]",
description = "Prevents you from taking damage. Defaults to toggle.", permission = "player.godmode")
@Command(label = "godmode", usage = "godmode [on|off|toggle]", permission = "player.godmode", description = "commands.godmode.description")
public final class GodModeCommand implements CommandHandler {
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment