Merge remote-tracking branch 'origin/master'

This commit is contained in:
Joel 2021-05-06 22:14:06 +02:00
commit c14d0bc10f
8 changed files with 28 additions and 7 deletions

@ -1,10 +1,9 @@
# Project Structure # Project Structure
- **Commons**: Commons is common libraries and/or utilities that are shared across the network. - **Commons**: Commons is common libraries and/or utilities that are shared across the network.
g
- **ServerData**: This branch of the project controls the database backend for both Redis and MySQL. All modules that use Redis or MySQL must have this as a dependency. - **ServerData**: This branch of the project controls the database backend for both Redis and MySQL. All modules that use Redis or MySQL must have this as a dependency.
- **ServerController**: This will dynamically start and stop servers on demand. - **ServerController**: This will dynamically start and stop servers on demand.
- **Proxy**: The proxy will handle server balancing and player caching. - **Proxy**: The proxy will handle server balancing and player caching.
- **API**: This is the Restful API. The API has api keys which have access levels. Players will be able to generate an api key in-game with the /api command and they will have the standard access level. The standard access level has access to things such as stats, leaderboards, etc. The dev access level is granted to Jr.Developers and above. The dev access level has access to things such as server groups, Minecraft servers, etc. - **API**: This is the Restful API. The API has api keys which have access levels. Players will be able to generate an api key in-game with the /api command, and they will have the standard access level. The standard access level has access to things such as stats, leaderboards, etc. The dev access level is granted to Jr.Developers and above. The dev access level has access to things such as server groups, Minecraft servers, etc.
- **Core**: The core is a shared module between all Spigot plugins. Everything used between multiple Spigot servers will be created here. - **Core**: The core is a shared module between all Spigot plugins. Everything used between multiple Spigot servers will be created here.
- **Build Server**: The core for the build server - This handles map creating, parsing, etc - **Build Server**: The core for the build server - This handles map creating, parsing, etc
- **Hub**: This is pretty self-explanatory. Any Hub related things will go here. - **Hub**: This is pretty self-explanatory. Any Hub related things will go here.
@ -26,6 +25,7 @@ When something is being released for production, you must set the production par
- Create a **gradle.properties** file which will contain your - Create a **gradle.properties** file which will contain your
Nexus username and password. (It's recommended to add the properties below to your **gradle.properties** file to allow the use of parallel compiling and caching) Nexus username and password. (It's recommended to add the properties below to your **gradle.properties** file to allow the use of parallel compiling and caching)
- Stick to Java naming conventions, which can be found [here](https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html) - Stick to Java naming conventions, which can be found [here](https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html)
- Stick to the same code style as the rest of the project
```properties ```properties
org.gradle.parallel=true org.gradle.parallel=true
org.gradle.caching=true org.gradle.caching=true

@ -3,7 +3,6 @@ package zone.themcgamer.core.api;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import lombok.NonNull; import lombok.NonNull;
import org.apache.commons.lang3.StringEscapeUtils;
import zone.themcgamer.core.api.json.JsonRequest; import zone.themcgamer.core.api.json.JsonRequest;
import zone.themcgamer.core.api.json.JsonResponse; import zone.themcgamer.core.api.json.JsonResponse;
import zone.themcgamer.data.ChatFilterLevel; import zone.themcgamer.data.ChatFilterLevel;

@ -15,10 +15,7 @@ import zone.themcgamer.common.TriTuple;
import zone.themcgamer.core.account.Account; import zone.themcgamer.core.account.Account;
import zone.themcgamer.core.account.AccountManager; import zone.themcgamer.core.account.AccountManager;
import zone.themcgamer.core.command.help.HelpCommand; import zone.themcgamer.core.command.help.HelpCommand;
import zone.themcgamer.core.command.impl.DiscordCommand; import zone.themcgamer.core.command.impl.*;
import zone.themcgamer.core.command.impl.RulesCommand;
import zone.themcgamer.core.command.impl.StoreCommand;
import zone.themcgamer.core.command.impl.StressTestCommand;
import zone.themcgamer.core.command.impl.essentials.GameModeCommand; import zone.themcgamer.core.command.impl.essentials.GameModeCommand;
import zone.themcgamer.core.command.impl.essentials.TeleportCommand; import zone.themcgamer.core.command.impl.essentials.TeleportCommand;
import zone.themcgamer.core.common.Style; import zone.themcgamer.core.common.Style;
@ -96,6 +93,7 @@ public class CommandManager extends Module implements CommandExecutor {
registerCommand(plugin, new zone.themcgamer.core.command.impl.HelpCommand(this)); registerCommand(plugin, new zone.themcgamer.core.command.impl.HelpCommand(this));
registerCommand(plugin, new DiscordCommand()); registerCommand(plugin, new DiscordCommand());
registerCommand(plugin, new StoreCommand()); registerCommand(plugin, new StoreCommand());
registerCommand(plugin, new VoteCommand());
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
for (String disabledCommand : DISABLED_COMMANDS) { for (String disabledCommand : DISABLED_COMMANDS) {

@ -0,0 +1,17 @@
package zone.themcgamer.core.command.impl;
import lombok.AllArgsConstructor;
import zone.themcgamer.core.command.Command;
import zone.themcgamer.core.command.CommandProvider;
import zone.themcgamer.core.common.Style;
/**
* @author Nicholas
*/
@AllArgsConstructor
public class VoteCommand {
@Command(name = "vote", description = "Vote for McGamerZone", playersOnly = true)
public void onCommand(CommandProvider command) {
command.getPlayer().sendMessage(Style.main("Vote", "Vote for McGamerZone at §dhttps://vote.mcgamerzone.net§7."));
}
}

@ -6,4 +6,5 @@ package zone.themcgamer.data.jedis;
public class JedisConstants { public class JedisConstants {
public static final String HOST = "172.18.0.1"; public static final String HOST = "172.18.0.1";
public static final String AUTH = "CWhsuGvpYPhZt7ru"; public static final String AUTH = "CWhsuGvpYPhZt7ru";
public static final int SELECTED_DB = 0;
} }

@ -53,6 +53,7 @@ public class CacheRepository extends RedisRepository<String, ICacheItem<?>> {
List<ICacheItem<?>> cached = new ArrayList<>(); List<ICacheItem<?>> cached = new ArrayList<>();
try (Jedis jedis = getController().getPool().getResource()) { try (Jedis jedis = getController().getPool().getResource()) {
jedis.auth(JedisConstants.AUTH); jedis.auth(JedisConstants.AUTH);
jedis.select(JedisConstants.SELECTED_DB);
for (ItemCacheType cacheType : ItemCacheType.values()) { for (ItemCacheType cacheType : ItemCacheType.values()) {
for (String key : jedis.keys(cacheType.getIdentifier() + ":*")) { for (String key : jedis.keys(cacheType.getIdentifier() + ":*")) {
Map<String, String> map = jedis.hgetAll(key); Map<String, String> map = jedis.hgetAll(key);

@ -35,6 +35,7 @@ public class JedisCommandHandler {
new Thread(() -> { new Thread(() -> {
try (Jedis jedis = pool.getResource()) { try (Jedis jedis = pool.getResource()) {
jedis.auth(JedisConstants.AUTH); jedis.auth(JedisConstants.AUTH);
jedis.select(JedisConstants.SELECTED_DB);
jedis.psubscribe(new JedisPubSub() { jedis.psubscribe(new JedisPubSub() {
@Override @Override
public void onPMessage(String pattern, String channel, String message) { public void onPMessage(String pattern, String channel, String message) {
@ -80,6 +81,7 @@ public class JedisCommandHandler {
System.out.println("Dispatching Redis command for class \"" + className + "\" with json \"" + json + "\""); System.out.println("Dispatching Redis command for class \"" + className + "\" with json \"" + json + "\"");
try (Jedis jedis = pool.getResource()) { try (Jedis jedis = pool.getResource()) {
jedis.auth(JedisConstants.AUTH); jedis.auth(JedisConstants.AUTH);
jedis.select(JedisConstants.SELECTED_DB);
jedis.publish("mcGamerZone:commands:" + className, json); jedis.publish("mcGamerZone:commands:" + className, json);
} }
} }

@ -113,6 +113,7 @@ public abstract class RedisRepository<I, T> {
map.put(entry.getKey(), entry.getValue().toString()); map.put(entry.getKey(), entry.getValue().toString());
try (Jedis jedis = controller.getPool().getResource()) { try (Jedis jedis = controller.getPool().getResource()) {
jedis.auth(JedisConstants.AUTH); jedis.auth(JedisConstants.AUTH);
jedis.select(JedisConstants.SELECTED_DB);
jedis.hmset(key, map); jedis.hmset(key, map);
long expiration = getExpiration(t); long expiration = getExpiration(t);
@ -133,6 +134,7 @@ public abstract class RedisRepository<I, T> {
throw new IllegalArgumentException("Cannot remove, the key is null or empty: \"" + (key == null ? "null" : key) + "\""); throw new IllegalArgumentException("Cannot remove, the key is null or empty: \"" + (key == null ? "null" : key) + "\"");
try (Jedis jedis = controller.getPool().getResource()) { try (Jedis jedis = controller.getPool().getResource()) {
jedis.auth(JedisConstants.AUTH); jedis.auth(JedisConstants.AUTH);
jedis.select(JedisConstants.SELECTED_DB);
jedis.del(key); jedis.del(key);
} }
} }
@ -147,6 +149,7 @@ public abstract class RedisRepository<I, T> {
List<T> cached = new ArrayList<>(); List<T> cached = new ArrayList<>();
try (Jedis jedis = controller.getPool().getResource()) { try (Jedis jedis = controller.getPool().getResource()) {
jedis.auth(JedisConstants.AUTH); jedis.auth(JedisConstants.AUTH);
jedis.select(JedisConstants.SELECTED_DB);
Set<String> keys = jedis.keys(pattern); Set<String> keys = jedis.keys(pattern);
for (String key : keys) { for (String key : keys) {
Map<String, String> data = jedis.hgetAll(key); Map<String, String> data = jedis.hgetAll(key);