diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..3d8b5a1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,39 @@ +--- +name: Bug report +about: Report issues with this plugin +title: "[BUG] Short summary of the issue here" +labels: triage +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Provide a numbered list of steps to reproduce the behavior. + +**Expected behavior** +A clear and concise description of what should happen. + +**Version Information:** + - Version of this plugin + - Minecraft version [e.g. Minecraft 1.20.2] + - Server software [Bukkit, Paper, Fabric, Purpur, etc.] + +If applicable, also attach the following information: + - Any other installed plugins + - Server build [e.g. Paper build #65] + - Minecraft client [e.g. vanilla minecraft] + +**Configuration and logs:** +If applicable, attach the `config.yml` and `data.yml` files inside the `/plugins/EggHunt/` directory, which is generated when the plugin is first run. + +Also attach any relevant log files. +Do not upload zipped log files (ending in `.gz`), first unzip the log file(s) inside with a utility like (7-zip)[https://www.7-zip.org/]. + +**Screenshots** +If applicable, attach screenshots to help explain the issue. + +**Additional context** +Add any other relevant context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..12d1c95 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,27 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: "[Feature Req] Short summary of the request here" +labels: enhancement, triage +assignees: '' + +--- + +Improving player experience is an important focus of this project. However, please note that due to technical and time restrictions, it may not be possible to implement any given feature requests. + +See [here](https://github.com/HyperSMP/EggHuntPlugin/projects/1) for this project's to-do list. + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe a good solution** +A clear and concise description of what should happen instead. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. + +**Screenshots** +Please attach any relevant screenshots. diff --git a/README.md b/README.md index 102eca5..f494958 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ A plugin for hunting down the dragon egg and stealing it from other players. ## Customization -This plugin's configuration file (`config.yml`) allows for several gameplay customizations to accomodate different types of servers. +This plugin's configuration file (`config.yml`) allows for several gameplay customizations to accommodate different types of servers. - The egg can be made invulnerable, or can be set to respawn in The End when it is destroyed - If set to respawn, the egg can either respawn immediately, or only after the dragon is beaten again - When the egg teleports, it can become "lost", so it will no longer have an owner until a player finds it @@ -45,4 +45,4 @@ This plugin's configuration file (`config.yml`) allows for several gameplay cust # Reporting Bugs Make sure you are running the latest version of this plugin and read that version's Known Issues list to make sure you aren't reporting a known issue. -To report a bug, please open a new [Issue](https://github.com/HyperSMP/EggHuntPlugin/issues) in this repository and fill out the bug report template. \ No newline at end of file +To report a bug, please open a new [Issue](https://github.com/HyperSMP/EggHuntPlugin/issues) in this repository and fill out the bug report template. diff --git a/media/commands.jpg b/media/commands.jpg new file mode 100644 index 0000000..a47d743 Binary files /dev/null and b/media/commands.jpg differ diff --git a/media/event.jpg b/media/event.jpg new file mode 100644 index 0000000..70977c1 Binary files /dev/null and b/media/event.jpg differ diff --git a/media/explode.jpg b/media/explode.jpg new file mode 100644 index 0000000..e703aca Binary files /dev/null and b/media/explode.jpg differ diff --git a/media/tracking.jpg b/media/tracking.jpg new file mode 100644 index 0000000..44c7cad Binary files /dev/null and b/media/tracking.jpg differ diff --git a/media/void.jpg b/media/void.jpg new file mode 100644 index 0000000..c7a2f3e Binary files /dev/null and b/media/void.jpg differ diff --git a/pom.xml b/pom.xml index ac93d40..0c798f2 100644 --- a/pom.xml +++ b/pom.xml @@ -1,56 +1,78 @@ - - 4.0.0 - io.github.J0hnL0cke - EggHunt - 1.20.1 - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - - - maven-shade-plugin - 3.2.4 - - true - true - - - - - - - - shade - - - - - - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/public/ - - - - - org.spigotmc - spigot-api - LATEST - jar - provided - - - com.google.code.gson - gson - 2.10.1 - - + + 4.0.0 + + EggHunt + 1.1.1 + https://github.com/HyperSMP/EggHuntPlugin + Minecraft plugin adding the ability to track and steal the Dragon Egg from other players. + + io.github.J0hnL0cke + EggHunt + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + maven-shade-plugin + 3.2.4 + + true + true + + + + + + + + shade + + + + + + + + + ${basedir}/src/main/resources + true + + plugin.yml + config.yml + + + + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/public/ + + + + + + org.spigotmc + spigot-api + LATEST + jar + provided + + + com.google.code.gson + gson + 2.10.1 + + \ No newline at end of file diff --git a/src/main/java/io/github/J0hnL0cke/egghunt/Controller/CommandHandler.java b/src/main/java/io/github/J0hnL0cke/egghunt/Controller/CommandHandler.java index e09c1f2..95882e4 100644 --- a/src/main/java/io/github/J0hnL0cke/egghunt/Controller/CommandHandler.java +++ b/src/main/java/io/github/J0hnL0cke/egghunt/Controller/CommandHandler.java @@ -43,13 +43,17 @@ public class CommandHandler { String storageMsg = data.getEggHolderString(); //"is in " - Location origin = null; //get location of player that sent the command for distance calculation - if(sender instanceof Player){ - origin = ((Player) sender).getLocation(); - } + if (data.getEggType() != Egg_Storage_Type.DNE) { + Location origin = null; //get location of player that sent the command for distance calculation + if (sender instanceof Player) { + origin = ((Player) sender).getLocation(); + } - String locStr = Announcement.formatLocation(data.getEggLocation(), origin); - sendMessage(sender, String.format("%s %s at %s.", msgStart, storageMsg, locStr)); + String locStr = Announcement.formatLocation(data.getEggLocation(), origin); + sendMessage(sender, String.format("%s %s at %s.", msgStart, storageMsg, locStr)); + } else { + sendMessage(sender, String.format("%s %s.", msgStart, storageMsg)); + } } else { sendMessage(sender, NOT_PERMITTED_MSG); diff --git a/src/main/java/io/github/J0hnL0cke/egghunt/Controller/EggDestroyListener.java b/src/main/java/io/github/J0hnL0cke/egghunt/Controller/EggDestroyListener.java index e255ecd..2125295 100644 --- a/src/main/java/io/github/J0hnL0cke/egghunt/Controller/EggDestroyListener.java +++ b/src/main/java/io/github/J0hnL0cke/egghunt/Controller/EggDestroyListener.java @@ -155,10 +155,22 @@ public class EggDestroyListener implements Listener { //that means editing the list does not change which blocks are actually affected by the event //as a workaround, allow egg blocks to be destroyed, but respawn the egg as an item - for (Block egg : eggs) { - EggController.spawnEggItem(egg.getLocation(), config, data); + if (!eggs.isEmpty()) { + if (config.getEggInvulnerable()) { + + for (Block egg : eggs) { + EggController.spawnEggItem(egg.getLocation(), config, data); + } + logger.log("Egg overwritten by the end spawn platform, spawning egg item at block location"); + + } else { + for (Block b : eggs) { + Egg.removeEgg(b); //delete egg + } + log("Dragon egg was replaced"); + EggController.eggDestroyed(config, data, logger); + } } - logger.log("Egg overwritten by the end spawn platform, spawning egg item at block location"); } } diff --git a/src/main/java/io/github/J0hnL0cke/egghunt/Controller/ScoreboardController.java b/src/main/java/io/github/J0hnL0cke/egghunt/Controller/ScoreboardController.java index ac4c589..662b8ce 100644 --- a/src/main/java/io/github/J0hnL0cke/egghunt/Controller/ScoreboardController.java +++ b/src/main/java/io/github/J0hnL0cke/egghunt/Controller/ScoreboardController.java @@ -6,6 +6,7 @@ import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Entity; import org.bukkit.scoreboard.Criteria; +import org.bukkit.scoreboard.Criterias; import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.RenderType; import org.bukkit.scoreboard.Score; @@ -15,6 +16,7 @@ import org.bukkit.scoreboard.ScoreboardManager; import io.github.J0hnL0cke.egghunt.Model.Configuration; import io.github.J0hnL0cke.egghunt.Model.Data; import io.github.J0hnL0cke.egghunt.Model.LogHandler; +import io.github.J0hnL0cke.egghunt.Model.Version; /** * Handles interactions with the scoreboard api @@ -26,6 +28,7 @@ public class ScoreboardController { private Data data; private Configuration config; private LogHandler logger; + private Version version; private ScoreboardManager manager; private Scoreboard board; private Objective eggMinutes; @@ -34,17 +37,18 @@ public class ScoreboardController { private static final String EGG_MINUTES_KEY = "eggOwnedMinutes"; private static final String EGG_SECONDS_KEY = "eggOwnedSeconds"; - public static ScoreboardController getScoreboardHandler(Data data, Configuration configuration, LogHandler logger) { + public static ScoreboardController getScoreboardHandler(Data data, Configuration configuration, LogHandler logger, Version version) { if (thisHandler == null) { - thisHandler = new ScoreboardController(data, configuration, logger); + thisHandler = new ScoreboardController(data, configuration, logger, version); } return thisHandler; } - private ScoreboardController(Data data, Configuration config, LogHandler logger) { + private ScoreboardController(Data data, Configuration config, LogHandler logger, Version version) { this.data = data; this.config = config; this.logger = logger; + this.version = version; if (config.getKeepScore()) { logger.log("Scorekeeping is enabled, loading scoreboard..."); @@ -81,6 +85,10 @@ public class ScoreboardController { public void updateScores() { if (config.getKeepScore() && data.getEggType()!= Data.Egg_Storage_Type.DNE) { logger.log("Updating scoreboard"); + if(eggMinutes == null || eggSeconds == null){ + logger.warning("Objective does not exist, cannot update scoreboard!"); + return; + } if (data.getEggType() == Data.Egg_Storage_Type.ENTITY) { Entity eggEntity = data.getEggEntity(); @@ -112,23 +120,30 @@ public class ScoreboardController { int mins = Math.floorDiv(getScore(entityName, eggSeconds), 60); //convert seconds into minutes setScore(entityName, eggMinutes, mins); //update eggMinutes - + lastUpdate = newUpdate; //update lastUpdate time } public Objective getOrMakeObjective(String key, String displayName) { - Objective obj = board.getObjective(key); - if (obj == null) { - logger.info(String.format("No scoreboard objective \"%s\" found, creating new objective", key)); - obj = board.registerNewObjective(key, Criteria.DUMMY, displayName, RenderType.INTEGER); - } - - if (!obj.isModifiable()) { - String msg = "Could not modify objective \"%s\"! Make sure objective criteria is set to dummy!"; - logger.warning(String.format(msg, obj.getName())); + Objective objective = board.getObjective(key); + if (objective == null) { + logger.warning(String.format("No scoreboard objective \"%s\" found, creating new objective", key)); + //older versions of the Bukkit API use Criterias instead of Criteria, so handle older versions + if (version.hasCriteria()) { + + objective = board.registerNewObjective(key, Criteria.DUMMY, displayName, RenderType.INTEGER); + } else { + @SuppressWarnings("deprecation") + Objective o = board.registerNewObjective(key, "dummy", displayName, RenderType.INTEGER); + objective = o; + } } - return obj; + if (!objective.isModifiable()) { + String msg = "Could not modify objective \"%s\"! Make sure objective criteria is set to dummy!"; + logger.warning(String.format(msg, objective.getName())); + } + return objective; } private void addScore(String name, Objective obj, int score) { diff --git a/src/main/java/io/github/J0hnL0cke/egghunt/Model/Version.java b/src/main/java/io/github/J0hnL0cke/egghunt/Model/Version.java new file mode 100644 index 0000000..719dd7a --- /dev/null +++ b/src/main/java/io/github/J0hnL0cke/egghunt/Model/Version.java @@ -0,0 +1,62 @@ +package io.github.J0hnL0cke.egghunt.Model; + +import org.bukkit.Bukkit; + +/** + * Provides functionality related to backwards compatability + */ +public class Version { + + private int majorVersion; + + private boolean cavesAndCliffsPart1; + private boolean netherUpdate; + + public Version() { + //Convert raw version string to major game version + String version = Bukkit.getVersion(); //git-Paper-411 (MC: 1.17.1) + version = version.substring(version.indexOf(":")); //: 1.17.1) + String[] v = version.split("\\."); //[": 1","17","1)"] split at periods, use \\ to escape period in regex + version = v[1]; //17 + majorVersion = Integer.parseInt(version); + + cavesAndCliffsPart1 = majorVersion >= 17; + netherUpdate = majorVersion >= 16; + } + + public boolean hasPortalCreate() { + return majorVersion >= 13; + } + + public boolean hasShulkers() { + return majorVersion >= 14; + } + + public boolean hasCustomWorlds() { + return cavesAndCliffsPart1; + } + + public boolean hasGlowFrames() { + return cavesAndCliffsPart1; + } + + public boolean hasBundles() { + return cavesAndCliffsPart1; + } + + public boolean hasDragonFight() { + return netherUpdate; + } + + public boolean hasLodestone() { + return netherUpdate; + } + + public boolean hasAllays() { + return majorVersion >= 1.19; + } + + public boolean hasCriteria() { + return majorVersion >= 20; + } +} diff --git a/src/main/java/io/github/J0hnL0cke/egghunt/egghunt.java b/src/main/java/io/github/J0hnL0cke/egghunt/egghunt.java index ab9ebed..a3b725f 100644 --- a/src/main/java/io/github/J0hnL0cke/egghunt/egghunt.java +++ b/src/main/java/io/github/J0hnL0cke/egghunt/egghunt.java @@ -19,6 +19,7 @@ import io.github.J0hnL0cke.egghunt.Controller.InventoryListener; import io.github.J0hnL0cke.egghunt.Model.Configuration; import io.github.J0hnL0cke.egghunt.Model.Data; import io.github.J0hnL0cke.egghunt.Model.LogHandler; +import io.github.J0hnL0cke.egghunt.Model.Version; import io.github.J0hnL0cke.egghunt.Persistence.ConfigFileDAO; import io.github.J0hnL0cke.egghunt.Persistence.DataFileDAO; @@ -26,6 +27,7 @@ import io.github.J0hnL0cke.egghunt.Persistence.DataFileDAO; public final class egghunt extends JavaPlugin { Configuration config; Data data; + Version version; CommandHandler commandHandler; BukkitTask belowWorldTask; @@ -42,11 +44,12 @@ public final class egghunt extends JavaPlugin { //create model instances using dependency injection config = new Configuration(new ConfigFileDAO(this)); data = new Data(DataFileDAO.getDataDAO(this, logger), logger); + version = new Version(); logger.setDebug(config.getDebugEnabled()); //create controller instances - ScoreboardController scoreboardController = ScoreboardController.getScoreboardHandler(data, config, logger); + ScoreboardController scoreboardController = ScoreboardController.getScoreboardHandler(data, config, logger, version); MiscListener miscListener = new MiscListener(logger, config, data); InventoryListener inventoryListener = new InventoryListener(logger, config, data); EggDestroyListener destroyListener = new EggDestroyListener(logger, config, data); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 64ffb93..a6e1fa9 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,5 +1,5 @@ #If enabled, logs extra debugging information to the console. This information will appear in logs regardless of debug setting. -debug: true +debug: false #Name of your end world, usually to "world_the_end" on spigot end: world_the_end diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index a25e059..30e586c 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,10 +1,12 @@ -name: EggHunt -main: io.github.J0hnL0cke.egghunt.egghunt -website: https://github.com/HyperSMP/EggHuntPlugin -version: 1.20.1 -api-version: '1.20' +#See pom.xml for this information +name: ${project.name} +website: ${project.url} +version: ${project.version} +description: ${project.description} +api-version: '1.17' author: J0hnL0cke +main: io.github.J0hnL0cke.egghunt.egghunt commands: locateegg: description: Gives the current coordinates of the dragon egg