From 726cc05a2f1e814743fbf745d0169a97246cb67d Mon Sep 17 00:00:00 2001 From: Nicholas Rees <70386214+nickreesdev@users.noreply.github.com> Date: Thu, 6 May 2021 12:27:49 -0500 Subject: [PATCH 1/5] Added VoteCommand that sends a player a message containing the voting link. --- .../java/zone/themcgamer/core/api/WebAPI.java | 1 - .../themcgamer/core/command/CommandManager.java | 6 ++---- .../core/command/impl/VoteCommand.java | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 core/src/main/java/zone/themcgamer/core/command/impl/VoteCommand.java 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 From 6261296271ec4bd5c33925772629bc2bbf358b20 Mon Sep 17 00:00:00 2001 From: Braydon Date: Thu, 6 May 2021 13:47:56 -0400 Subject: [PATCH 2/5] [18.5k Lines] Updated #Before-Starting in README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 17a139c..e05bd76 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,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 From 544caeecdbb2c4222c77b83bf5a49cfbf3a124e6 Mon Sep 17 00:00:00 2001 From: Braydon Date: Thu, 6 May 2021 13:55:28 -0400 Subject: [PATCH 3/5] [18.5k Lines] Fixed a typo in the README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index e05bd76..37f9ac0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # 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. From 35641226a1e11a7876af080b19145951f9684a28 Mon Sep 17 00:00:00 2001 From: Braydon Date: Thu, 6 May 2021 13:56:17 -0400 Subject: [PATCH 4/5] [18.5k Lines] Fixed a typo in the README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 37f9ac0..5fcaafd 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ - **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. From 184d6a2be44a0d656626133ba21f791cae0d9473 Mon Sep 17 00:00:00 2001 From: Nicholas Rees <70386214+nickreesdev@users.noreply.github.com> Date: Thu, 6 May 2021 14:47:47 -0500 Subject: [PATCH 5/5] Added a field in JedisConstants for the selected Redis database. --- .../main/java/zone/themcgamer/data/jedis/JedisConstants.java | 1 + .../java/zone/themcgamer/data/jedis/cache/CacheRepository.java | 1 + .../themcgamer/data/jedis/command/JedisCommandHandler.java | 2 ++ .../zone/themcgamer/data/jedis/repository/RedisRepository.java | 3 +++ 4 files changed, 7 insertions(+) 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);