Skip to content
This repository was archived by the owner on Nov 10, 2021. It is now read-only.

Commit 003a91c

Browse files
committed
Merge branch 'release/0.0.2'
2 parents c65d2e0 + a4c3410 commit 003a91c

File tree

5 files changed

+246
-1
lines changed

5 files changed

+246
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.froxynetwork</groupId>
77
<artifactId>FroxyAPI</artifactId>
8-
<version>0.0.1</version>
8+
<version>0.0.2</version>
99
<packaging>jar</packaging>
1010

1111
<name>FroxyAPI</name>

src/main/java/com/froxynetwork/froxyapi/API.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package com.froxynetwork.froxyapi;
22

33
import java.io.File;
4+
import java.util.List;
45

56
import org.bukkit.Server;
67
import org.bukkit.plugin.java.JavaPlugin;
78
import org.slf4j.Logger;
89

10+
import com.froxynetwork.froxyapi.command.Command;
11+
import com.froxynetwork.froxyapi.command.CommandManager;
912
import com.froxynetwork.froxyapi.language.LanguageManager;
1013
import com.froxynetwork.froxyapi.language.Languages;
1114

@@ -124,6 +127,45 @@ public default void register(File path) {
124127
public default String $_(String id, Languages lang, String... params) {
125128
return getLanguageManager().$_(id, lang, params);
126129
}
130+
131+
132+
// -----------------------------------------
133+
// | |
134+
// | Command Manager |
135+
// | |
136+
// -----------------------------------------
137+
138+
/**
139+
* @return The CommandManager
140+
*/
141+
public CommandManager getCommandManager();
142+
143+
/**
144+
* Register a command
145+
*
146+
* @param cmd
147+
* The command
148+
*/
149+
public default void registerCommand(Command cmd) {
150+
getCommandManager().registerCommand(cmd);
151+
}
152+
153+
/**
154+
* Unregister a command
155+
*
156+
* @param cmd
157+
* The command
158+
*/
159+
public default void unregisterCommand(Command cmd) {
160+
getCommandManager().unregisterCommand(cmd);
161+
}
162+
163+
/**
164+
* @return All commands
165+
*/
166+
public default List<Command> getCommands() {
167+
return getCommandManager().getCommands();
168+
}
127169

128170
// -----------------------------------------
129171
// | |

src/main/java/com/froxynetwork/froxyapi/Froxy.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.froxynetwork.froxyapi;
22

33
import java.io.File;
4+
import java.util.List;
45

56
import org.bukkit.plugin.java.JavaPlugin;
67
import org.slf4j.Logger;
78

9+
import com.froxynetwork.froxyapi.command.Command;
10+
import com.froxynetwork.froxyapi.command.CommandManager;
811
import com.froxynetwork.froxyapi.language.LanguageManager;
912
import com.froxynetwork.froxyapi.language.Languages;
1013

@@ -100,10 +103,16 @@ public static Logger getLogger() {
100103
// | |
101104
// -----------------------------------------
102105

106+
/**
107+
* @return The LanguageManager
108+
*/
103109
public static LanguageManager getLanguageManager() {
104110
return api.getLanguageManager();
105111
}
106112

113+
/**
114+
* @return The default language
115+
*/
107116
public static Languages getDefaultLanguage() {
108117
return api.getDefaultLanguage();
109118
}
@@ -155,6 +164,47 @@ public static void register(File path) {
155164
public static String $_(String id, Languages lang, String... params) {
156165
return api.$_(id, lang, params);
157166
}
167+
168+
169+
// -----------------------------------------
170+
// | |
171+
// | Command Manager |
172+
// | |
173+
// -----------------------------------------
174+
175+
/**
176+
* @return The CommandManager
177+
*/
178+
public static CommandManager getCommandManager() {
179+
return api.getCommandManager();
180+
}
181+
182+
/**
183+
* Register a command
184+
*
185+
* @param cmd
186+
* The command
187+
*/
188+
public static void registerCommand(Command cmd) {
189+
api.registerCommand(cmd);
190+
}
191+
192+
/**
193+
* Unregister a command
194+
*
195+
* @param cmd
196+
* The command
197+
*/
198+
public static void unregisterCommand(Command cmd) {
199+
api.unregisterCommand(cmd);
200+
}
201+
202+
/**
203+
* @return All commands
204+
*/
205+
public static List<Command> getCommands() {
206+
return api.getCommands();
207+
}
158208

159209
// -----------------------------------------
160210
// | |
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package com.froxynetwork.froxyapi.command;
2+
3+
import static com.froxynetwork.froxyapi.Froxy.$;
4+
5+
import org.bukkit.entity.Player;
6+
7+
/**
8+
* MIT License
9+
*
10+
* Copyright (c) 2019 FroxyNetwork
11+
*
12+
* Permission is hereby granted, free of charge, to any person obtaining a copy
13+
* of this software and associated documentation files (the "Software"), to deal
14+
* in the Software without restriction, including without limitation the rights
15+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16+
* copies of the Software, and to permit persons to whom the Software is
17+
* furnished to do so, subject to the following conditions:
18+
*
19+
* The above copyright notice and this permission notice shall be included in
20+
* all copies or substantial portions of the Software.
21+
*
22+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28+
* SOFTWARE.
29+
*
30+
* @author 0ddlyoko
31+
*/
32+
/**
33+
* A command
34+
*/
35+
public interface Command {
36+
37+
/**
38+
* The name of the command
39+
*
40+
* @return The name of the command
41+
*/
42+
public String getCommand();
43+
44+
/**
45+
* Aliases of command<br />
46+
* Can be null
47+
*
48+
* @return A list of aliases
49+
*/
50+
public String[] getAliases();
51+
52+
/**
53+
* Permission to execute specific command
54+
*
55+
* @return Permission associated with specific command
56+
*/
57+
public String getPermission();
58+
59+
/**
60+
* Execute command
61+
*
62+
* @param cmd
63+
* The command
64+
* @param p
65+
* The player
66+
* @param args
67+
* The args
68+
*
69+
* @return true if no errors
70+
*/
71+
public boolean execute(String cmd, Player p, String[] args);
72+
73+
/**
74+
* Method to call when a player doesn't have permission to execute a command
75+
*
76+
* @param sender
77+
* The player
78+
*/
79+
public default void noPermission(Player sender) {
80+
// TODO Change that
81+
String msg = $("command.nopermission");
82+
sender.sendMessage(msg);
83+
}
84+
85+
/**
86+
* Method to call when there is a syntax error
87+
*
88+
* @param player
89+
* The player
90+
* @param syntax
91+
* The correct syntax
92+
*/
93+
public default void syntaxError(Player sender, String syntax) {
94+
String msg = $("command.syntaxerror", syntax);
95+
sender.sendMessage(msg);
96+
}
97+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.froxynetwork.froxyapi.command;
2+
3+
import java.util.List;
4+
5+
/**
6+
* MIT License
7+
*
8+
* Copyright (c) 2019 FroxyNetwork
9+
*
10+
* Permission is hereby granted, free of charge, to any person obtaining a copy
11+
* of this software and associated documentation files (the "Software"), to deal
12+
* in the Software without restriction, including without limitation the rights
13+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
* copies of the Software, and to permit persons to whom the Software is
15+
* furnished to do so, subject to the following conditions:
16+
*
17+
* The above copyright notice and this permission notice shall be included in
18+
* all copies or substantial portions of the Software.
19+
*
20+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26+
* SOFTWARE.
27+
*
28+
* @author 0ddlyoko
29+
*/
30+
/**
31+
* Interface for the Command Manager.<br />
32+
* With this interface, you can manage commands
33+
*/
34+
public interface CommandManager {
35+
36+
/**
37+
* Register a command
38+
*
39+
* @param cmd
40+
* The command
41+
*/
42+
public void registerCommand(Command cmd);
43+
44+
/**
45+
* Unregister a command
46+
*
47+
* @param cmd
48+
* The command
49+
*/
50+
public void unregisterCommand(Command cmd);
51+
52+
/**
53+
* @return All commands
54+
*/
55+
public List<Command> getCommands();
56+
}

0 commit comments

Comments
 (0)