diff --git a/README.md b/README.md index 17a139c..5fcaafd 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ # Project Structure - **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. - **ServerController**: This will dynamically start and stop servers on demand. - **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. - **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. @@ -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 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 the same code style as the rest of the project ```properties org.gradle.parallel=true org.gradle.caching=true diff --git a/core/src/main/java/zone/themcgamer/core/api/WebAPI.java b/core/src/main/java/zone/themcgamer/core/api/WebAPI.java index a933754..92ecf36 100644 --- a/core/src/main/java/zone/themcgamer/core/api/WebAPI.java +++ b/core/src/main/java/zone/themcgamer/core/api/WebAPI.java @@ -3,7 +3,6 @@ package zone.themcgamer.core.api; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import lombok.NonNull; -import org.apache.commons.lang3.StringEscapeUtils; import zone.themcgamer.core.api.json.JsonRequest; import zone.themcgamer.core.api.json.JsonResponse; import zone.themcgamer.data.ChatFilterLevel; diff --git a/core/src/main/java/zone/themcgamer/core/command/CommandManager.java b/core/src/main/java/zone/themcgamer/core/command/CommandManager.java index 5e7ea9e..77a71e5 100644 --- a/core/src/main/java/zone/themcgamer/core/command/CommandManager.java +++ b/core/src/main/java/zone/themcgamer/core/command/CommandManager.java @@ -15,10 +15,7 @@ import zone.themcgamer.common.TriTuple; import zone.themcgamer.core.account.Account; import zone.themcgamer.core.account.AccountManager; import zone.themcgamer.core.command.help.HelpCommand; -import zone.themcgamer.core.command.impl.DiscordCommand; -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.*; import zone.themcgamer.core.command.impl.essentials.GameModeCommand; import zone.themcgamer.core.command.impl.essentials.TeleportCommand; 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 DiscordCommand()); registerCommand(plugin, new StoreCommand()); + registerCommand(plugin, new VoteCommand()); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> { for (String disabledCommand : DISABLED_COMMANDS) { diff --git a/core/src/main/java/zone/themcgamer/core/command/impl/VoteCommand.java b/core/src/main/java/zone/themcgamer/core/command/impl/VoteCommand.java new file mode 100644 index 0000000..dfa896b --- /dev/null +++ b/core/src/main/java/zone/themcgamer/core/command/impl/VoteCommand.java @@ -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.")); + } +} \ No newline at end of file diff --git a/serverdata/src/main/java/zone/themcgamer/data/jedis/JedisConstants.java b/serverdata/src/main/java/zone/themcgamer/data/jedis/JedisConstants.java index 691d154..ff21939 100644 --- a/serverdata/src/main/java/zone/themcgamer/data/jedis/JedisConstants.java +++ b/serverdata/src/main/java/zone/themcgamer/data/jedis/JedisConstants.java @@ -6,4 +6,5 @@ package zone.themcgamer.data.jedis; public class JedisConstants { public static final String HOST = "172.18.0.1"; public static final String AUTH = "CWhsuGvpYPhZt7ru"; + public static final int SELECTED_DB = 0; } \ No newline at end of file diff --git a/serverdata/src/main/java/zone/themcgamer/data/jedis/cache/CacheRepository.java b/serverdata/src/main/java/zone/themcgamer/data/jedis/cache/CacheRepository.java index 244bb24..1a76235 100644 --- a/serverdata/src/main/java/zone/themcgamer/data/jedis/cache/CacheRepository.java +++ b/serverdata/src/main/java/zone/themcgamer/data/jedis/cache/CacheRepository.java @@ -53,6 +53,7 @@ public class CacheRepository extends RedisRepository> { List> cached = new ArrayList<>(); try (Jedis jedis = getController().getPool().getResource()) { jedis.auth(JedisConstants.AUTH); + jedis.select(JedisConstants.SELECTED_DB); for (ItemCacheType cacheType : ItemCacheType.values()) { for (String key : jedis.keys(cacheType.getIdentifier() + ":*")) { Map map = jedis.hgetAll(key); diff --git a/serverdata/src/main/java/zone/themcgamer/data/jedis/command/JedisCommandHandler.java b/serverdata/src/main/java/zone/themcgamer/data/jedis/command/JedisCommandHandler.java index cb37724..e9a6925 100644 --- a/serverdata/src/main/java/zone/themcgamer/data/jedis/command/JedisCommandHandler.java +++ b/serverdata/src/main/java/zone/themcgamer/data/jedis/command/JedisCommandHandler.java @@ -35,6 +35,7 @@ public class JedisCommandHandler { new Thread(() -> { try (Jedis jedis = pool.getResource()) { jedis.auth(JedisConstants.AUTH); + jedis.select(JedisConstants.SELECTED_DB); jedis.psubscribe(new JedisPubSub() { @Override 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 + "\""); try (Jedis jedis = pool.getResource()) { jedis.auth(JedisConstants.AUTH); + jedis.select(JedisConstants.SELECTED_DB); jedis.publish("mcGamerZone:commands:" + className, json); } } diff --git a/serverdata/src/main/java/zone/themcgamer/data/jedis/repository/RedisRepository.java b/serverdata/src/main/java/zone/themcgamer/data/jedis/repository/RedisRepository.java index e681098..4785f52 100644 --- a/serverdata/src/main/java/zone/themcgamer/data/jedis/repository/RedisRepository.java +++ b/serverdata/src/main/java/zone/themcgamer/data/jedis/repository/RedisRepository.java @@ -113,6 +113,7 @@ public abstract class RedisRepository { map.put(entry.getKey(), entry.getValue().toString()); try (Jedis jedis = controller.getPool().getResource()) { jedis.auth(JedisConstants.AUTH); + jedis.select(JedisConstants.SELECTED_DB); jedis.hmset(key, map); long expiration = getExpiration(t); @@ -133,6 +134,7 @@ public abstract class RedisRepository { throw new IllegalArgumentException("Cannot remove, the key is null or empty: \"" + (key == null ? "null" : key) + "\""); try (Jedis jedis = controller.getPool().getResource()) { jedis.auth(JedisConstants.AUTH); + jedis.select(JedisConstants.SELECTED_DB); jedis.del(key); } } @@ -147,6 +149,7 @@ public abstract class RedisRepository { List cached = new ArrayList<>(); try (Jedis jedis = controller.getPool().getResource()) { jedis.auth(JedisConstants.AUTH); + jedis.select(JedisConstants.SELECTED_DB); Set keys = jedis.keys(pattern); for (String key : keys) { Map data = jedis.hgetAll(key);