Skip to content

Commit d351b64

Browse files
Some more lib documentation
1 parent 60419e8 commit d351b64

21 files changed

+187
-7
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,6 @@ bin/
3939
### Mac OS ###
4040
.DS_Store
4141

42-
server/run
42+
server/run
43+
44+
build.sh

lib/src/main/java/org/galliumpowered/annotation/Args.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22

33
import org.galliumpowered.command.args.ArgumentType;
44

5+
/**
6+
* Command arguments
7+
*/
58
public @interface Args {
9+
/**
10+
* The {@link ArgumentType} of the arg
11+
* @return Argument type
12+
*/
613
ArgumentType type();
14+
15+
/**
16+
* Name/Id of the argument
17+
* @return Argument name
18+
*/
719
String name();
820
}

lib/src/main/java/org/galliumpowered/annotation/PluginLifecycleListener.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@
1010
*/
1111
@Retention(RetentionPolicy.RUNTIME)
1212
public @interface PluginLifecycleListener {
13+
/**
14+
* The state which is listened for
15+
* @return The state which is listened for
16+
*/
1317
PluginLifecycleState value();
1418
}

lib/src/main/java/org/galliumpowered/bridge/Bridge.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,48 @@
66
import java.util.Optional;
77

88
/**
9-
* For bridging NMS to lib
9+
* For bridging NMS to lib. For internal use.
1010
*/
1111
public interface Bridge {
12+
13+
/**
14+
* Regusters a command to the server
15+
* @param alias The alias for the command (i.e. /example)
16+
* @param permission The permission required to execute the command (i.e. "EXAMPLE)
17+
*/
1218
void registerCommand(String alias, String permission);
1319

20+
/**
21+
*
22+
* Regusters a command to the server
23+
* @param alias The alias for the command (i.e. /example)
24+
* @param permission The permission required to execute the command (i.e. "EXAMPLE)
25+
* @param args Arguments for the command which may be required
26+
*/
1427
void registerCommand(String alias, String permission, Args[] args);
1528

29+
/**
30+
* Get a {@link Player} by their username
31+
* @param name The username of the player
32+
* @return Player (or Optional.empty() if they are not found)
33+
*/
1634
Optional<Player> getPlayerByName(String name);
1735

36+
/**
37+
* Version of Minecraft the server is running.
38+
* @return Minecraft version
39+
*/
1840
String getServerVersion();
1941

42+
/**
43+
* FOR INTERNAL USE ONLY
44+
* Loads the internal plugins (id: gallium)
45+
*/
2046
void loadInternalPlugin();
2147

48+
/**
49+
* FOR INTERNAL USE ONLY
50+
* Loads the test plugin
51+
*/
2252
void loadTestPlugin();
2353
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package org.galliumpowered.command;
22

3+
/**
4+
* The type the command caller is. Either the console or a player.
5+
*/
36
public enum CommandCallerType {
47
CONSOLE,
58
PLAYER
9+
// TODO: huh command blocks should probably be here as well
610
}

lib/src/main/java/org/galliumpowered/command/CommandContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public interface CommandContext {
1818
* @return Command arguments
1919
*/
2020
String[] getCommandArgs();
21+
2122
CommandContext ifPlayer(Consumer<Player> consumer);
2223

2324
CommandContext ifConsole(Consumer<ConsoleCommandCaller> consumer);

lib/src/main/java/org/galliumpowered/command/CommandManager.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,19 @@ private void internalRegister(String alias, MCommand cmd, PluginMetadata meta) {
6565
}
6666
}
6767

68+
/**
69+
* Unregister a command from the server
70+
* @param alias The alias of the command
71+
*/
6872
public void unregisterCommand(String alias) {
6973
commands.remove(alias);
7074
pluginCommands.remove(alias);
7175
}
7276

77+
/**
78+
* Unregister all commands from a plugin
79+
* @param meta The plugin's metadata
80+
*/
7381
public void unregisterAllPluginCommands(PluginMetadata meta) {
7482
for (String alias : pluginCommands.keySet()) {
7583
if (pluginCommands.get(alias) == meta) {
@@ -78,10 +86,20 @@ public void unregisterAllPluginCommands(PluginMetadata meta) {
7886
}
7987
}
8088

89+
/**
90+
* Command names and their metadata
91+
* Should not be modified under normal conditions!
92+
* @return Command names and their metadata
93+
*/
8194
public HashMap<String, MCommand> getCommands() {
8295
return commands;
8396
}
8497

98+
/**
99+
* Subcommands and their parents
100+
* Should not be modified under normal conditions!
101+
* @return Subcommands and their parents
102+
*/
85103
public HashMap<MCommand, MCommand> getSubcommands() {
86104
return subcommands;
87105
}

lib/src/main/java/org/galliumpowered/command/MCommand.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import java.util.*;
88
import java.util.concurrent.atomic.AtomicBoolean;
99

10+
/**
11+
* Command metadata
12+
*/
1013
public class MCommand {
1114
Command command;
1215
Object clazz;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
package org.galliumpowered.command.args;
22

3+
/**
4+
* Command argument type
5+
*/
36
public enum ArgumentType {
7+
/**
8+
* Takes up the remainder of the command
9+
* For example, /mycommand subcommand this will be taken by greedy
10+
*/
411
GREEDY,
12+
13+
/**
14+
* It is a single word.
15+
*/
516
SINGLE,
17+
18+
/**
19+
* It is surrounded in quotes
20+
* For example, /mycommand "hello there" "hello again"
21+
*/
622
QUOTED
723
}

lib/src/main/java/org/galliumpowered/config/Configuration.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,33 @@
22

33
import java.nio.file.Path;
44

5+
/**
6+
* A configuration file.
7+
*/
58
public interface Configuration {
9+
/**
10+
* The directory that the configuration file is in.
11+
* @return Configuration directory
12+
*/
613
Path getDirectory();
714

15+
/**
16+
* Name of the configuration file
17+
* @return Config file name
18+
*/
819
String getName();
920

21+
/**
22+
* Sets key to a value
23+
* @param key Key
24+
* @param value Value
25+
*/
1026
void setValue(String key, String value);
1127

28+
/**
29+
* Gets the value of a key
30+
* @param key Key
31+
* @return Key value
32+
*/
1233
String getValue(String key);
1334
}

0 commit comments

Comments
 (0)