From 8e842d1e17aa9db1d78d2b223f97685b76d56ee3 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 1 May 2020 16:41:02 -0700 Subject: [PATCH 01/44] Add workflow to create release Will create a release when a tagged commit is pushed, compile, and attach the JAR to release. --- .github/workflows/create-release.yaml | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/create-release.yaml diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml new file mode 100644 index 0000000..5d8b42c --- /dev/null +++ b/.github/workflows/create-release.yaml @@ -0,0 +1,42 @@ +# This workflow will create a release on v-tag push + +name: Create release +descriptiom: "create a release on pushs with v-tag" +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + - uses: actions/checkout@v2 + - name: Build project + uses: OrangeLabs-moe/gradle-actions@v5.0-openjdk-8 + with: + args: build + - uses: meeDamian/github-release@2.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + # TODO Edit body with changelog before pushing tags. + body: | + Changelog for ${{ steps.get_version.outputs.VERSION }} : + * Remove lombok from dependency list + * Add lombok plugin for Gradle + * Rename workflow files for easy identification + * Cleanup action.yml workflow + * Create-release workflow only zips folders + files: build/libs/BreedablePets-${{ steps.get_version.outputs.VERSION }}.jar + gzip: folders + + - name: Send file JAR to discord channel + uses: sinshutu/upload-to-discord@master + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + with: + args: build/libs/BreedablePets-${{ steps.get_version.outputs.VERSION }}.jar +# args: README.md From 47339191ad2f46232d7e8723c49e69f754539a1f Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 1 May 2020 19:00:01 -0700 Subject: [PATCH 02/44] Create issue with TODO tags in code --- .github/workflows/todo-issue.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/todo-issue.yaml diff --git a/.github/workflows/todo-issue.yaml b/.github/workflows/todo-issue.yaml new file mode 100644 index 0000000..3fa1304 --- /dev/null +++ b/.github/workflows/todo-issue.yaml @@ -0,0 +1,27 @@ +name: "Workflow" +on: ["push"] +jobs: + build: + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@master" + - name: "TODO to Issue for YAML / Python" + uses: "alstr/todo-to-issue-action@master" + with: + REPO: ${{ github.repository }} + BEFORE: ${{ github.event.before }} + SHA: ${{ github.sha }} + TOKEN: ${{ secrets.GITHUB_TOKEN }} + LABEL: "# TODO" + COMMENT_MARKER: "#" + id: "todo" + - name: "TODO to Issue for Java" + uses: "alstr/todo-to-issue-action@master" + with: + REPO: ${{ github.repository }} + BEFORE: ${{ github.event.before }} + SHA: ${{ github.sha }} + TOKEN: ${{ secrets.GITHUB_TOKEN }} + LABEL: "// TODO" + COMMENT_MARKER: "//" + id: "todo" From f81305a98d5b11451c301fadb431f0ca86190d3f Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 1 May 2020 11:09:17 -0700 Subject: [PATCH 03/44] Retructure build.gradle Add Spigradle to project and configure Plugin not loading --- build.gradle | 78 +-- gradle/wrapper/gradle-wrapper.jar | Bin 55616 -> 58694 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 35 +- gradlew.bat | 5 +- lombok.config | 2 + .../java/me/magnum/breedablepets/Command.java | 9 +- .../java/me/magnum/breedablepets/Main.java | 53 +- .../listeners/BreedListener.java | 59 +-- .../breedablepets/listeners/MyListener.java | 14 +- .../me/magnum/breedablepets/util/Config.java | 75 --- .../breedablepets/util/ItemFactory.java | 500 ++++++++++++++++++ .../magnum/breedablepets/util/ItemUtil.java | 17 +- .../magnum/breedablepets/util/Messages.java | 17 + .../breedablepets/util/SimpleConfig.java | 267 ++++++++++ .../util/SimpleConfigManager.java | 424 +++++++++++++++ .../magnum/breedablepets/util/SpawnPets.java | 12 +- src/main/resources/plugin.yml | 5 - 18 files changed, 1349 insertions(+), 225 deletions(-) mode change 100644 => 100755 gradlew create mode 100644 lombok.config delete mode 100644 src/main/java/me/magnum/breedablepets/util/Config.java create mode 100644 src/main/java/me/magnum/breedablepets/util/ItemFactory.java create mode 100644 src/main/java/me/magnum/breedablepets/util/Messages.java create mode 100644 src/main/java/me/magnum/breedablepets/util/SimpleConfig.java create mode 100644 src/main/java/me/magnum/breedablepets/util/SimpleConfigManager.java delete mode 100644 src/main/resources/plugin.yml diff --git a/build.gradle b/build.gradle index 96ada28..07a4582 100644 --- a/build.gradle +++ b/build.gradle @@ -2,13 +2,14 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation // We use this to replace version in plugin.yml -import org.apache.tools.ant.filters.ReplaceTokens - +// import org.apache.tools.ant.filters.ReplaceTokens plugins { id 'java' id 'application' - id 'com.github.johnrengelman.shadow' version '5.0.0' + id 'kr.entree.spigradle' version '1.2.4' + id "io.freefair.lombok" version "5.0.0-rc2" + id 'com.github.johnrengelman.shadow' version '5.1.0' } group= 'me.magnum' // Put your groupId here @@ -18,54 +19,61 @@ mainClassName = 'me.magnum.breedablepets.Main' targetCompatibility = 1.8 sourceCompatibility = 1.8 +// See https://github.com/EntryPointKR/Spigradle#repositories for repository shortcodes repositories { mavenLocal() mavenCentral() + paper() + enderZone() maven { url = "https://repo.aikar.co/content/groups/aikar/" } - maven { url = "https://hub.spigotmc.org/nexus/content/groups/public/" } + jitpack() // For vault +} + +dependencies { + compileOnly spigot('1.15.2') + implementation 'fr.mrmicky:FastParticles:1.2.0' + implementation 'com.github.JavaFactoryDev:LightningStorage:3.0.3' + implementation "co.aikar:acf-bukkit:0.5.0-SNAPSHOT" + implementation 'com.github.kangarko:Foundation:5.3.8@jar' // Kangerko's Foundation library - maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots" } // Spigot Repo - maven { url "https://oss.sonatype.org/content/repositories/snapshots" } // Sonatype snapshots - maven { url 'https://jitpack.io' } } compileJava { options.compilerArgs += ["-parameters"] options.fork = true options.forkOptions.executable = 'javac' } -dependencies { - testCompile group: 'junit', name: 'junit', version: '4.12' - compileOnly 'org.projectlombok:lombok:1.18.8' - annotationProcessor 'org.projectlombok:lombok:1.18.8' - compileOnly "org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT" - implementation 'fr.mrmicky:FastParticles:1.2.0' -// implementation 'com.github.ByteZ1337:ParticleLib:1.1' - - implementation "co.aikar:acf-bukkit:0.5.0-SNAPSHOT" - implementation 'me.magnum.lib:CommonLibrary:1.0.3-SNAPSHOT' -// implementation 'com.github.kangarko:Remain:3.2.0' -} task relocateShadowJar(type: ConfigureShadowRelocation) { target = tasks.shadowJar prefix = "shadow" // Default value is "shadow" } -/* This will replace '@VERSION@' in the plugin.yml with the version declared above, just put '@VERSION@' for the version in the plugin.yml */ -processResources { - filter ReplaceTokens, tokens: [ - "VERSION": version, - "NAME" : archivesBaseName, - "MAIN" : mainClassName, - ] -} shadowJar { -// archiveClassifier.set("dev") - archiveClassifier.set(null) - archiveVersion.set(null) - relocate 'co.aikar.commands', 'me.magnum.breedablepets.acf' - relocate 'org.mineacademy.remain', 'me.magnum.breedablepets.remain' + classifier = null // remove -all from end of jar +} +spigot { + authors = ['Magnum1997'] +// depends = ['ProtocolLib'] + apiVersion = '1.15' + load = STARTUP + commands { + give { + aliases = ['i'] + description = 'Give command.' + permission = 'test.foo' + permissionMessage = 'You do not have permission!' + usage = '/ [test|stop]' + } + } + permissions { + 'test.foo' { + description = 'Allows foo command' + defaults = 'true' + } + 'test.*' { + description = 'Wildcard permission' + defaults = 'op' + children = ['test.foo': true] + } + } } - -build.dependsOn shadowJar - compileJava.options.encoding = 'UTF-8' // Encode your source code with UTF-8 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 5c2d1cf016b3885f6930543d57b744ea8c220a1a..490fda8577df6c95960ba7077c43220e5bb2c0d9 100644 GI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)pAVJ*;9^}8bmLL%Re~TcNVI)Zs4XaZT?=iuV$Ins!tIWr4$^9dw2QN;F0@w6O zW|cV|m@^4O9^Vf6uOGD`N%;5Xh%oZ_s``J0tj7NcSx9YjnnD1cmq`@P7Db|p9AR{S zJo2%jR^ZZ2zMok34uPB3vs3s7()LRBzv1qKStB7hIKK;8l*Xf=Bd2=yYtY+puF?i4Y1 z{tk(%T}FZua|l2%fM^PUp%GNz%eOG(|JOcfAQ0taHDC-R30)!);Ov|zP!~cn>F+ax zs`D`9u}R%Azml-u!sK`^q8kjXpGN@XktEmcc{$|&hj>g7i0U!7+GvuFp=z)pSgAU|kJL=^4GgOVVM*iQD>|Lt&*E^uwx5jf}ucZQXTJs}E=^n%SR7Xbb~ Z5H)%VJiSWIAOn$sbP+#;Q{V4m{s)AkOUM8K diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f4d7b2b..a4b4429 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 index b0d6d0a..2fe81a7 --- a/gradlew +++ b/gradlew @@ -7,7 +7,7 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -125,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` @@ -154,19 +154,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -175,14 +175,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 9991c50..62bd9b9 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -5,7 +5,7 @@ @rem you may not use this file except in compliance with the License. @rem You may obtain a copy of the License at @rem -@rem http://www.apache.org/licenses/LICENSE-2.0 +@rem https://www.apache.org/licenses/LICENSE-2.0 @rem @rem Unless required by applicable law or agreed to in writing, software @rem distributed under the License is distributed on an "AS IS" BASIS, @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" diff --git a/lombok.config b/lombok.config new file mode 100644 index 0000000..6aa51d7 --- /dev/null +++ b/lombok.config @@ -0,0 +1,2 @@ +# This file is generated by the 'io.freefair.lombok' Gradle plugin +config.stopBubbling = true diff --git a/src/main/java/me/magnum/breedablepets/Command.java b/src/main/java/me/magnum/breedablepets/Command.java index 437bd41..e7d5516 100644 --- a/src/main/java/me/magnum/breedablepets/Command.java +++ b/src/main/java/me/magnum/breedablepets/Command.java @@ -30,9 +30,9 @@ import co.aikar.commands.annotation.*; import me.magnum.breedablepets.util.ItemUtil; import me.magnum.breedablepets.util.SpawnPets; -import me.magnum.lib.CheckSender; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.mineacademy.fo.command.SimpleCommand; @CommandAlias("breedablepet|bp") public class Command extends BaseCommand { @@ -48,8 +48,7 @@ public void onHelp (CommandSender sender, CommandHelp help) { public void onCommand (CommandSender sender, @Default("false") String fertile) { ItemUtil util = new ItemUtil(); Player p = (Player) sender; - - if (!CheckSender.isPlayer(sender)) { + if (sender == null){ return; } if ((fertile.equalsIgnoreCase("fertile"))&& sender.hasPermission("breedable.parrot.fertile")) { @@ -62,13 +61,13 @@ public void onCommand (CommandSender sender, @Default("false") String fertile) { @Subcommand("reload") @CommandPermission("breedable.reload") public void onReload (CommandSender sender) { - Main.cfg.reloadConfig(); + Main.getCfg().reloadConfig(); } @CommandAlias("sp") @CommandPermission("me.magnum") public void onCommand (CommandSender sender) { - if (!CheckSender.isPlayer(sender)) { + if (sender == null){ return; } Player p = (Player) sender; diff --git a/src/main/java/me/magnum/breedablepets/Main.java b/src/main/java/me/magnum/breedablepets/Main.java index 8608a08..def328c 100644 --- a/src/main/java/me/magnum/breedablepets/Main.java +++ b/src/main/java/me/magnum/breedablepets/Main.java @@ -26,61 +26,56 @@ package me.magnum.breedablepets; import co.aikar.commands.BukkitCommandManager; +import lombok.Getter; import me.magnum.breedablepets.listeners.BreedListener; import me.magnum.breedablepets.listeners.MyListener; -import me.magnum.breedablepets.util.Config; -import me.magnum.lib.Common; -import me.magnum.lib.SimpleConfig; +import me.magnum.breedablepets.util.SimpleConfig; +import me.magnum.breedablepets.util.SimpleConfigManager; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.EntityType; -import org.bukkit.plugin.java.JavaPlugin; +import org.mineacademy.fo.Common; +import org.mineacademy.fo.plugin.SimplePlugin; +@kr.entree.spigradle.Plugin +public class Main extends SimplePlugin { + + @Getter + private static Main plugin; + @Getter + private static SimpleConfig cfg; + @Getter + private SimpleConfigManager configManager; -public class Main extends JavaPlugin { - - - public static Main plugin; - public static SimpleConfig cfg; - @Override - public void onEnable () { + public void onPluginStart () { plugin = this; - Common.setInstance(plugin); + configManager = new SimpleConfigManager(plugin); Common.log("Loading breed-able pets..."); - cfg = new SimpleConfig("config.yml", plugin); - Config.init(); + cfg = configManager.getNewConfig("config.yml"); + // cfg = new SimpleConfig("config.yml", plugin); // Remain.setPlugin(plugin); //todo Add compatability plugin.getServer().getPluginManager().registerEvents(new MyListener(), plugin); plugin.getServer().getPluginManager().registerEvents(new BreedListener(), plugin); registerCommands(); } - - @SuppressWarnings("deprecation") + + @SuppressWarnings ("deprecation") private void registerCommands () { BukkitCommandManager commandManager = new BukkitCommandManager(plugin); commandManager.registerCommand(new me.magnum.breedablepets.Command()); commandManager.enableUnstableAPI("help"); } - - + + @Override - public void onDisable () { - Common.setInstance(plugin); + public void onPluginStop () { Common.log("Disabling Breedable pets."); // Remain.setPlugin(null); cfg = null; plugin = null; } - - public Main getPlugin () { - return plugin; - } - - public SimpleConfig getCfg () { - return cfg; - } - + public void spawnMob (World world, Location location, EntityType mobType) { world.spawnEntity(location, mobType); } diff --git a/src/main/java/me/magnum/breedablepets/listeners/BreedListener.java b/src/main/java/me/magnum/breedablepets/listeners/BreedListener.java index 2782127..8a8b6b2 100644 --- a/src/main/java/me/magnum/breedablepets/listeners/BreedListener.java +++ b/src/main/java/me/magnum/breedablepets/listeners/BreedListener.java @@ -28,9 +28,7 @@ import fr.mrmicky.fastparticle.FastParticle; import fr.mrmicky.fastparticle.ParticleType; import me.magnum.breedablepets.Main; -import me.magnum.breedablepets.util.Config; import me.magnum.breedablepets.util.ItemUtil; -import me.magnum.lib.SimpleConfig; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; @@ -46,14 +44,14 @@ import java.util.concurrent.ThreadLocalRandom; public class BreedListener implements Listener { - + private final ItemUtil items = new ItemUtil(); - private final SimpleConfig cfg = Main.cfg; - + // private final SimpleConfig cfg = Main.getCfg(); + public BreedListener () { } - - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + + @EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onFeed (PlayerInteractEntityEvent pie) { Player player = pie.getPlayer(); Entity target = pie.getRightClicked(); @@ -63,7 +61,7 @@ public void onFeed (PlayerInteractEntityEvent pie) { } Tameable tamed = (Tameable) target; Sittable sitting = (Sittable) target; - if ((!tamed.isTamed()) || (!sitting.isSitting())) { + if ((! tamed.isTamed()) || (! sitting.isSitting())) { return; } int chanceModifier; @@ -71,10 +69,10 @@ public void onFeed (PlayerInteractEntityEvent pie) { return; } if (Arrays.asList(Material.BEETROOT_SEEDS, - Material.MELON_SEEDS, - Material.MELON, - Material.PUMPKIN_SEEDS, - Material.SPECKLED_MELON).contains(hand)) { + Material.MELON_SEEDS, + Material.MELON, + Material.PUMPKIN_SEEDS, + Material.GLISTERING_MELON_SLICE).contains(hand)) { chanceModifier = foodCalc(target, hand); // todo increase chance of egg/fertile egg by type of food. } else { @@ -83,16 +81,16 @@ public void onFeed (PlayerInteractEntityEvent pie) { pie.setCancelled(true); sitting.setSitting(true); player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount() - 1); - + // Common.tell(player, "Base chance of egg: " + chanceModifier); // todo remove before deploy - + List nearby = target.getNearbyEntities(5, 2, 5); - + World w = player.getWorld(); Location loc = target.getLocation(); Entity mate = null; boolean hasMate = false; - + for (Entity entity : nearby) { if (entity.getType() == target.getType()) { hasMate = true; @@ -109,13 +107,13 @@ public void onFeed (PlayerInteractEntityEvent pie) { } } */ - + // int random = new Random().nextInt(100); double x = target.getLocation().getX(); double y = target.getLocation().getY() + 1; double z = target.getLocation().getZ(); if (hasMate) { - if (ThreadLocalRandom.current().nextInt(100) < Config.fertileChance ) { + if (ThreadLocalRandom.current().nextInt(100) < (Main.getCfg().getInt("fertile-egg-chance"))) { w.dropItemNaturally(loc, items.regEgg.clone()); // w.dropItemNaturally(loc, items.fertileEgg.clone()); // todo To be fertile egg - disabled until single throw bug fixed FastParticle.spawnParticle(target.getWorld(), ParticleType.HEART, target.getLocation(), 3); @@ -124,7 +122,7 @@ public void onFeed (PlayerInteractEntityEvent pie) { FastParticle.spawnParticle(w, ParticleType.HEART, x, y, z, 3); } else { - if (ThreadLocalRandom.current().nextInt(1, 101) < Config.eggChance ) { + if (ThreadLocalRandom.current().nextInt(1, 101) < Main.getCfg().getInt("egg-chance")) { w.dropItemNaturally(loc, items.regEgg.clone()); FastParticle.spawnParticle(target.getWorld(), ParticleType.HEART, target.getLocation(), 3); FastParticle.spawnParticle(target.getWorld(), ParticleType.HEART, x, y, z, 3); @@ -132,36 +130,37 @@ public void onFeed (PlayerInteractEntityEvent pie) { FastParticle.spawnParticle(w, ParticleType.HEART, x, y, z, 3); } } - + } else { - if (ThreadLocalRandom.current().nextInt(100) < Config.eggChance) { + if (ThreadLocalRandom.current().nextInt(100) < Main.getCfg().getInt("egg-change")) { FastParticle.spawnParticle(w, ParticleType.NOTE, target.getLocation(), 3, x, y, z); // FastParticle.spawnParticle(w, ParticleType.NOTE, x, y, z, 1); w.dropItemNaturally(loc, items.regEgg.clone()); } } - + } - + // todo get length of configuration section and make array of item/chance pairs. private Integer foodCalc (Entity target, Material type) { int chance = 0; switch (type) { - case SEEDS: - chance = cfg.getInt("modifier.wheat"); + case WHEAT_SEEDS: + chance = Main.getCfg().getInt("modifier.wheat"); break; case BEETROOT_SEEDS: - chance = cfg.getInt("modifier.beetroot"); + chance = Main.getCfg().getInt("modifier.beetroot"); break; case PUMPKIN_SEEDS: - chance = cfg.getInt("modifier.pumpkin"); + chance = Main.getCfg().getInt("modifier.pumpkin"); break; case MELON_SEEDS: - chance = cfg.getInt("modifier.melon"); + chance = Main.getCfg().getInt("modifier.melon"); break; - case SPECKLED_MELON: - chance = cfg.getInt("modifier.glistering"); + case GLISTERING_MELON_SLICE: + _MELON: + chance = Main.getCfg().getInt("modifier.glistering"); break; } return chance; diff --git a/src/main/java/me/magnum/breedablepets/listeners/MyListener.java b/src/main/java/me/magnum/breedablepets/listeners/MyListener.java index 1e247c3..f6c5636 100644 --- a/src/main/java/me/magnum/breedablepets/listeners/MyListener.java +++ b/src/main/java/me/magnum/breedablepets/listeners/MyListener.java @@ -26,17 +26,15 @@ package me.magnum.breedablepets.listeners; import me.magnum.breedablepets.Main; -import me.magnum.breedablepets.util.Config; import me.magnum.breedablepets.util.ItemUtil; +import me.magnum.breedablepets.util.Messages; import me.magnum.breedablepets.util.SpawnPets; -import me.magnum.lib.Common; import org.bukkit.Material; import org.bukkit.block.Dispenser; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockDispenseEvent; -import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.player.PlayerEggThrowEvent; import org.bukkit.inventory.ItemStack; @@ -44,20 +42,21 @@ public class MyListener implements Listener { - private ItemUtil itemsAPI = new ItemUtil(); + private final ItemUtil itemsAPI = new ItemUtil(); @EventHandler(priority = EventPriority.HIGH) public void onEggThrow (PlayerEggThrowEvent e) { if (e.getPlayer().getInventory().getItemInMainHand().isSimilar(itemsAPI.regEgg)) { e.setHatching(false); - Common.sendABar(e.getPlayer(), "I really hope it hatches..."); - if (ThreadLocalRandom.current().nextInt(100) < Config.eggChance) { + + Messages.sendBar(e.getPlayer(), "I really hope it hatches..."); + if (ThreadLocalRandom.current().nextInt(100) < Main.getCfg().getInt("egg-change")) { SpawnPets.newParrot(e.getPlayer(), e.getEgg().getLocation()); } } if (e.getPlayer().getInventory().getItemInMainHand().isSimilar(itemsAPI.fertileEgg)) { e.setHatching(false); - Common.sendABar(e.getPlayer(), "You try hatching the Parrot egg..."); + Messages.sendBar(e.getPlayer(), "You try hatching the Parrot egg..."); SpawnPets.newParrot(e.getPlayer(), e.getEgg().getLocation()); } } @@ -74,7 +73,6 @@ public void onHatch (CreatureSpawnEvent e) { @EventHandler public void onDispenseEgg (BlockDispenseEvent e) { // todo add config option here - Common.setInstance(Main.plugin); if ((e.getItem() != null) && (e.getItem().getType() != Material.AIR)) { if (e.getItem().getType() == Material.EGG) { Dispenser dispenser = (Dispenser) e.getBlock().getState(); diff --git a/src/main/java/me/magnum/breedablepets/util/Config.java b/src/main/java/me/magnum/breedablepets/util/Config.java deleted file mode 100644 index 9eca7cd..0000000 --- a/src/main/java/me/magnum/breedablepets/util/Config.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * - * Breedable PetsMC is a plugin to customize breeding of Minecraft mobs - * Copyright (C) 2019 Richard Simpson - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see - * - * Contact information: - * Richard Simpson - * 19084 Leaf Lane - * Redding, CA 96003 - * USA - * - */ -package me.magnum.breedablepets.util; - -import lombok.Getter; -import me.magnum.breedablepets.Main; -import me.magnum.lib.Common; -import me.magnum.lib.SimpleConfig; -import org.bukkit.plugin.java.JavaPlugin; - -@Getter -public class Config extends SimpleConfig { - - // public static String version; - public static int eggChance; - public static int pairedChance; - public static int hatchChance; - public static int fertileChance; - public static boolean nameHatchling; - public static String hatchLingName; - public static boolean tamedHatchling; - - private Config (String fileName, JavaPlugin plugin) { - super(fileName, plugin); - setHeader(new String[] { - "--------------------------------------------------------", - " Your configuration file got updated automatically!", - " ", - " Unfortunately, due to how Bukkit saves .yml files,", - " all comments in your file were lost. Please open", - " " + fileName + " from jar to browse the default values.", - "--------------------------------------------------------" - }); - } - - public static void init () { - new Config("config.yml", Main.plugin).onLoad(); - } - - private void onLoad () { - Common.setInstance(Main.plugin); - // version = getString("version"); - eggChance = getInt("egg-chance"); - pairedChance = getInt("paired-egg-chance"); - fertileChance = getInt("fertile-egg-chance"); - nameHatchling = getBoolean("hatches.named"); - hatchLingName = getString("hatches.name"); - tamedHatchling = getBoolean("hatches.tamed"); - - } - -} diff --git a/src/main/java/me/magnum/breedablepets/util/ItemFactory.java b/src/main/java/me/magnum/breedablepets/util/ItemFactory.java new file mode 100644 index 0000000..7483bce --- /dev/null +++ b/src/main/java/me/magnum/breedablepets/util/ItemFactory.java @@ -0,0 +1,500 @@ +package me.magnum.breedablepets.util; +/* Copyright 2018 Melvin Snijders + * + * Licensed under the MIT License. + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://spdx.org/licenses/MIT.html + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.attribute.Attribute; +import org.bukkit.attribute.AttributeModifier; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.Damageable; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * ItemFactory - Build your {@link ItemStack} the easy way. (1.13) + * @version 1.0.0 + * @author Melvin Snijders + * @since 20/11/2018 + */ + +public class ItemFactory { + + private final ItemStack itemStack; + private ItemMeta itemMeta; + private List lore = new ArrayList<>(); + + /** + * Construct ItemFactory class with given {@link Material}. + * @param material The {@link Material} for the ItemFactory. + */ + + public ItemFactory(Material material) { + + this.itemStack = new ItemStack(material); + this.itemMeta = this.itemStack.getItemMeta(); + + } + + /** + * Construct ItemFactory class with given {@link Material} and amount. + * @param material The {@link Material} for the ItemFactory. + * @param amount The amount for the ItemFactory. + */ + + public ItemFactory(Material material, int amount) { + + this.itemStack = new ItemStack(material, amount); + this.itemMeta = this.itemStack.getItemMeta(); + + } + + /** + * Construct ItemFactory class with given {@link ItemStack}. + * @param itemStack The {@link ItemStack} for the ItemFactory. + */ + + public ItemFactory(ItemStack itemStack) { + + this.itemStack = itemStack; + this.itemMeta = itemStack.getItemMeta(); + this.lore = this.itemMeta.getLore(); + + } + + /** + * Create a new ItemFactory with a static method (lazy people) + * @param material The {@link Material} for the ItemFactory. + * @return The new ItemFactory instance. + */ + + public static ItemFactory newFactory(Material material) { + + return new ItemFactory(material); + + } + + /** + * Set the {@link ItemMeta} for the ItemStack. + * @param itemMeta The {@link ItemMeta}. + * @return The existing ItemFactory instance. + */ + + public ItemFactory setItemMeta(ItemMeta itemMeta) { + + this.itemMeta = itemMeta; + return this; + + } + + /** + * Set the {@link Material} for the ItemStack. + * @param material The {@link Material}. + * @return The existing ItemFactory instance. + */ + + public ItemFactory setType(Material material) { + + this.itemStack.setType(material); + return this; + + } + + /** + * Set the amount for the ItemStack. + * @param amount The amount. + * @return The existing ItemFactory instance. + */ + + public ItemFactory setAmount(int amount) { + + this.itemStack.setAmount(amount); + return this; + + } + + /** + * Add an {@link Enchantment} to the ItemStack. + * @param enchantment The {@link Enchantment} to add. + * @param level The level of the {@link Enchantment}. + * @return The existing ItemFactory instance. + */ + + public ItemFactory addEnchantment(Enchantment enchantment, int level) { + + this.itemStack.addEnchantment(enchantment, level); + return this; + + } + + /** + * Add multiple {@link Enchantment} to the ItemStack. + * @param enchantments Map of enchantments to be added. + * @return The existing ItemFactory instance. + */ + + public ItemFactory addEnchantments(Map enchantments) { + + this.itemStack.addEnchantments(enchantments); + return this; + + } + + /** + * Add an unsafe {@link Enchantment} to the ItemStack. + * @param enchantment The unsafe {@link Enchantment} to add. + * @param level The level of the {@link Enchantment}. + * @return The existing ItemFactory instance. + */ + + public ItemFactory addUnsafeEnchantment(Enchantment enchantment, int level) { + + this.itemStack.addUnsafeEnchantment(enchantment, level); + return this; + + } + + /** + * Add multiple unsafe {@link Enchantment} to the ItemStack. + * @param enchantments Map of unsafe enchantments to be added. + * @return The existing ItemFactory instance. + */ + + public ItemFactory addUnsafeEnchantments(Map enchantments) { + + this.itemStack.addUnsafeEnchantments(enchantments); + return this; + + } + + /** + * Remove an {@link Enchantment} from the ItemStack. + * @param enchantment The {@link Enchantment} to remove. + * @return The existing ItemFactory instance. + */ + + public ItemFactory removeEnchantment(Enchantment enchantment) { + + this.itemStack.removeEnchantment(enchantment); + return this; + + } + + /** + * Set the display name of the ItemStack. + * @param displayName The display name to set. + * @return The existing ItemFactory instance. + */ + + public ItemFactory setDisplayName(String displayName) { + + this.itemMeta.setDisplayName(color(displayName)); + return this; + + } + + /** + * Add a new lore line to the ItemStack. + * @param line The line to add. + * @return The existing ItemFactory instance. + */ + + public ItemFactory addLoreLine(String line) { + + this.lore.add(line); + return this; + + } + + /** + * Add multiple lore lines to the ItemStack. + * @param lines The lines to add. + * @return The existing ItemFactory instance. + */ + + public ItemFactory addLoreLines(String... lines) { + + this.lore.addAll(Arrays.asList(lines)); + return this; + + } + + /** + * Set the lore of the ItemStack. + * @param lore The lore as {@link List} to set. + * @return The existing ItemFactory instance. + */ + + public ItemFactory setLore(List lore) { + + this.lore = lore; + return this; + + } + + /** + * Set the lore of the ItemStack. + * @param lore The lore as {@link String[]} to set. + * @return The existing ItemFactory instance. + */ + + public ItemFactory setLore(String[] lore) { + + this.lore = Arrays.asList(lore); + return this; + + } + + /** + * Remove a lore line by index. + * @param index The index of the line to remove. + * @return The existing ItemFactory instance. + */ + + public ItemFactory removeLore(int index) { + + this.lore.remove(index); + return this; + + } + + /** + * Clear the lore of the ItemStack. + * @return The existing ItemFactory instance. + */ + + public ItemFactory clearLore() { + + this.lore.clear(); + return this; + + } + + /** + * Set the ItemStack unbreakable or not. + * @param unbreakable Whether it should be unbreakable. + * @return The existing ItemFactory instance. + */ + + public ItemFactory setUnbreakable(boolean unbreakable) { + + this.itemMeta.setUnbreakable(unbreakable); + return this; + + } + + /** + * Set the damage of the ItemStack. + * @param damage The damage to set. + * @return The existing ItemFactory instance. + */ + + public ItemFactory setDamage(short damage) { + + ((Damageable) this.itemMeta).setDamage(damage); + return this; + + } + + /** + * Add one {@link ItemFlag} to the ItemStack. + * @param flag The flag to add. + * @return The existing ItemFactory instance. + */ + + public ItemFactory addItemFlag(ItemFlag flag) { + + this.itemMeta.addItemFlags(flag); + return this; + + } + + /** + * Add multiple {@link ItemFlag} to the ItemStack. + * @param flags The flags to add. + * @return The existing ItemFactory instance. + */ + + public ItemFactory addItemFlag(ItemFlag... flags) { + + this.itemMeta.addItemFlags(flags); + return this; + + } + + /** + * Remove an {@link ItemFlag} from the ItemStack. + * @param flag The flag to remove. + * @return The existing ItemFactory instance. + */ + + public ItemFactory removeItemFlag(ItemFlag flag) { + + this.itemMeta.removeItemFlags(flag); + return this; + + } + + /** + * Remove multiple {@link ItemFlag} from the ItemStack. + * @param flags The flags to remove. + * @return The existing ItemFactory instance. + */ + + public ItemFactory removeItemFlag(ItemFlag... flags) { + + this.itemMeta.removeItemFlags(flags); + return this; + + } + + /** + * Add an {@link AttributeModifier} to the ItemStack. + * @param attribute The {@link Attribute} for the modifier. + * @param modifier The {@link AttributeModifier} to add. + * @return The existing ItemFactory instance. + */ + + public ItemFactory addAttributeModifier(Attribute attribute, AttributeModifier modifier) { + + this.itemMeta.addAttributeModifier(attribute, modifier); + return this; + + } + + /** + * Remove an {@link AttributeModifier} by {@link Attribute} + * @param attribute The {@link Attribute} of the modifier to remove. + * @return The existing ItemFactory instance. + */ + + public ItemFactory removeAttributeModifier(Attribute attribute) { + + this.itemMeta.removeAttributeModifier(attribute); + return this; + + } + + /** + * Remove an {@link AttributeModifier} by {@link EquipmentSlot} + * @param attribute The {@link EquipmentSlot} of the modifier to remove. + * @return The existing ItemFactory instance. + */ + + public ItemFactory removeAttributeModifier(EquipmentSlot attribute) { + + this.itemMeta.removeAttributeModifier(attribute); + return this; + + } + + /** + * Remove an {@link AttributeModifier} by {@link Attribute} and modifier. + * @param attribute The {@link Attribute} of the modifier to remove. + * @param modifier The {@link AttributeModifier} to remove. + * @return The existing ItemFactory instance. + */ + + public ItemFactory removeAttributeModifier(Attribute attribute, AttributeModifier modifier) { + + this.itemMeta.removeAttributeModifier(attribute, modifier); + return this; + + } + + /** + * Change if the ItemStack should glow or not. + * @param glowing Whether the ItemStack shoud glow. + * @return The existing ItemFactory instance. + */ + + public ItemFactory setGlowing(boolean glowing) { + + Enchantment enchantment = this.itemStack.getType() != Material.BOW ? Enchantment.ARROW_INFINITE : Enchantment.LUCK; + + if(glowing) { + this.removeEnchantment(enchantment); + this.removeItemFlag(ItemFlag.HIDE_ENCHANTS); + } else { + this.addEnchantment(enchantment, 10); + this.addItemFlag(ItemFlag.HIDE_ENCHANTS); + } + + return this; + + } + + /** + * Hide all attributes of the ItemStack. + * @return The existing ItemFactory instance. + */ + + public ItemFactory hideAttributes() { + + this.addItemFlag(ItemFlag.HIDE_ATTRIBUTES); + return this; + + } + + /** + * Show all attributes of the ItemStack. + * @return The existing ItemFactory instance. + */ + + public ItemFactory showAttributes() { + + this.removeItemFlag(ItemFlag.HIDE_ATTRIBUTES); + return this; + + } + + /** + * Build the {@link ItemStack}. + * @return The newly created {@link ItemStack}. + * @since 1.0.0 + */ + + public ItemStack build() { + + List newLore = new ArrayList<>(); + this.lore.forEach((lore) -> newLore.add(color(lore))); + + this.itemMeta.setLore(newLore); + this.itemStack.setItemMeta(this.itemMeta); + + return itemStack; + + } + + /** + * Color format a String (replace '&'). + * @param color The String to format. + * @return The color formatted String. + */ + + private String color(String color) { + + return ChatColor.translateAlternateColorCodes('&', color); + + } + +} diff --git a/src/main/java/me/magnum/breedablepets/util/ItemUtil.java b/src/main/java/me/magnum/breedablepets/util/ItemUtil.java index 2e78c0d..f95a45e 100644 --- a/src/main/java/me/magnum/breedablepets/util/ItemUtil.java +++ b/src/main/java/me/magnum/breedablepets/util/ItemUtil.java @@ -25,7 +25,6 @@ */ package me.magnum.breedablepets.util; -import me.magnum.lib.ItemBuilder; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -44,24 +43,22 @@ private ItemStack makeEgg () { private ItemStack makeEgg (boolean fertile) { ItemStack egg; if (fertile) { - egg = new ItemBuilder(Material.EGG) - .setName("§eFertile Parrot Egg") + egg = new ItemFactory(Material.EGG) + .setDisplayName("§eFertile Parrot Egg") .addLoreLine("Did it just move?") - .addLoreLine("I think it is ready to hatch!") - .toItemStack(); + .addLoreLine("I think it is ready to hatch!").build(); } else { - egg = new ItemBuilder(Material.EGG) - .setName("§aParrot Egg") + egg = new ItemFactory(Material.EGG) + .setDisplayName("§aParrot Egg") .addLoreLine("We don't know how it got here,") .addLoreLine("but it might hatch a parrot!") - .toItemStack(); + .build(); } return egg; } public ItemStack birdFood () { - ItemStack bf = new ItemBuilder(Material.PUMPKIN_SEEDS).toItemStack(); - return bf; + return new ItemFactory(Material.PUMPKIN_SEEDS).build(); } } diff --git a/src/main/java/me/magnum/breedablepets/util/Messages.java b/src/main/java/me/magnum/breedablepets/util/Messages.java new file mode 100644 index 0000000..a33fb0e --- /dev/null +++ b/src/main/java/me/magnum/breedablepets/util/Messages.java @@ -0,0 +1,17 @@ +package me.magnum.breedablepets.util; + +import net.md_5.bungee.api.ChatMessageType; +import net.md_5.bungee.api.chat.TextComponent; +import org.bukkit.entity.Player; +import org.mineacademy.fo.Common; + +public class Messages { + public static void sendBar(Player pl, String title) { + try { + pl.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(Common.colorize(title))); + + } catch (final Throwable t) { + Common.tell(pl, title); + } + } +} diff --git a/src/main/java/me/magnum/breedablepets/util/SimpleConfig.java b/src/main/java/me/magnum/breedablepets/util/SimpleConfig.java new file mode 100644 index 0000000..15ed7ab --- /dev/null +++ b/src/main/java/me/magnum/breedablepets/util/SimpleConfig.java @@ -0,0 +1,267 @@ +package me.magnum.breedablepets.util; +/* + * Base with comment and header features created by Log-out + * https://bukkit.org/threads/tut-custom-yaml-configurations-with-comments.142592/ + * Updated by Magnum1997 to auto update config files from resources + */ + +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.java.JavaPlugin; +import org.mineacademy.fo.Common; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; + +public class SimpleConfig extends YamlConfiguration { + + private final JavaPlugin plugin; + private int comments; + private final SimpleConfigManager manager; + + private File file; + private FileConfiguration config; + private final boolean useDefaults; + private final YamlConfiguration defaults; + + public SimpleConfig (InputStreamReader configStream, File configFile, int comments, boolean useDefaults, JavaPlugin plugin) { + this.plugin = plugin; + this.comments = comments; + this.manager = new SimpleConfigManager(plugin); + + this.file = configFile; + this.config = YamlConfiguration.loadConfiguration(configStream); + this.useDefaults = useDefaults; + + if (useDefaults) { + this.defaults = YamlConfiguration.loadConfiguration(new InputStreamReader(SimpleConfig.class.getResourceAsStream("/" + file.getName()), StandardCharsets.UTF_8)); + Objects.requireNonNull(defaults, "Could not find the default " + file.getName() + " in jar file."); + } + else + this.defaults = null; + this.file = extract(file.getName()); + + + } + + // Extract the file from your jar to the plugins/YourPlugin folder. + // Does nothing if the file exists + private File extract (String fileName) { + File file = new File(plugin.getDataFolder(), fileName); + + if (file.exists()) + return file; + createPath(fileName); + + if (defaults != null) + try (InputStream inputStream = plugin.getResource(fileName)) { + Objects.requireNonNull(inputStream, "File not found in archive: +" + fileName); + Files.copy(inputStream, Paths.get(file.toURI()), StandardCopyOption.REPLACE_EXISTING); + } + catch (final IOException e) { + e.printStackTrace(); + } + return file; + } + + + private File createPath (String fileName) { + final File datafolder = plugin.getDataFolder(); + final int lastIndex = fileName.lastIndexOf("/"); + final File directory = new File(datafolder, fileName.substring(0, Math.max(lastIndex, 0))); + directory.mkdirs(); + final File destination = new File(datafolder, fileName); + try { + destination.createNewFile(); + } + catch (IOException e) { + e.printStackTrace(); + System.out.println("File creation failed: " + fileName); + } + + return destination; + } + + public Object get (String path) { + return get(path, null); + } + + + /** + * Gets an unspecified value from your file, so you must cast it to your desired value (example: (boolean) get("disable.this.feature", true)) + * The "def" is the default value, must be null since we use default values from your file in your .jar. + */ + @Override + public Object get (String path, Object def) { + if (defaults != null) { + + if (def != null && ! def.getClass().isPrimitive() && ! PrimitiveWrapper.isWrapperType(def.getClass())) + throw new IllegalArgumentException("The default value must be null since we use defaults from file inside of the plugin! Path: " + path + ", default called: " + def); + + if (super.get(path, null) == null) { + final Object defaultValue = defaults.get(path); + Objects.requireNonNull(defaultValue, "Default " + file.getName() + " in your .jar lacks a key at '" + path + "' path"); + + Common.log("&fUpdating &a" + file.getName() + "&f. Set '&b" + path + "&f' to '" + defaultValue + "'"); + set(path, defaultValue); + saveConfig(); + reloadConfig(); + } + } + +/* + // prevent infinite loop due to how get works in the parent class + final String m = new Throwable().getStackTrace()[1].getMethodName(); + + // Add path prefix, but only when the default file doesn't exist + if (defaults == null && pathPrefix != null && !m.equals("getConfigurationSection") && !m.equals("get")) + path = pathPrefix + "." + path; +*/ + + // return super.get(path, null); + return this.config.get(path, null); + } + + public String getString (String path) { + return this.config.getString(path); + } + + public String getString (String path, String def) { + return this.config.getString(path, def); + } + + public int getInt (String path) { + return this.config.getInt(path); + } + + public int getInt (String path, int def) { + return this.config.getInt(path, def); + } + + public boolean getBoolean (String path) { + return this.config.getBoolean(path); + } + + public boolean getBoolean (String path, boolean def) { + return this.config.getBoolean(path, def); + } + + +/* + public void createSection (String path) { + this.config.createSection(path); + } +*/ + + public ConfigurationSection getConfigurationSection (String path) { + return this.config.getConfigurationSection(path); + } + + public double getDouble (String path) { + return this.config.getDouble(path); + } + + public double getDouble (String path, double def) { + return this.config.getDouble(path, def); + } + + public List getList (String path) { + return this.config.getList(path); + } + + public List getList (String path, List def) { + return this.config.getList(path, def); + } + + public boolean contains (String path) { + return this.config.contains(path); + } + + public void removeKey (String path) { + this.config.set(path, null); + } + + public void set (String path, Object value) { + this.config.set(path, value); + } + + public void set (String path, Object value, String comment) { + if (! this.config.contains(path)) { + this.config.set(manager.getPluginName() + "_COMMENT_" + comments, " " + comment); + comments++; + } + + this.config.set(path, value); + + } + + public void set (String path, Object value, String[] comment) { + + for (String comm : comment) { + + if (! this.config.contains(path)) { + this.config.set(manager.getPluginName() + "_COMMENT_" + comments, " " + comm); + comments++; + } + + } + + this.config.set(path, value); + + } + + public void setHeader (String[] header) { + manager.setHeader(this.file, header); + this.comments = header.length + 2; + this.reloadConfig(); + } + + public void reloadConfig () { + this.config = YamlConfiguration.loadConfiguration(manager.getConfigContent(file)); + } + + public void saveConfig () { + String config = this.config.saveToString(); + manager.saveConfig(config, this.file); + + } + + public Set getKeys () { + return this.config.getKeys(false); + } + + // A helper class + private static final class PrimitiveWrapper { + + private static final Set > WRAPPER_TYPES = getWrapperTypes(); + + private static boolean isWrapperType (Class clazz) { + return WRAPPER_TYPES.contains(clazz); + } + + private static Set > getWrapperTypes () { + final Set > ret = new HashSet <>(); + ret.add(Boolean.class); + ret.add(Character.class); + ret.add(Byte.class); + ret.add(Short.class); + ret.add(Integer.class); + ret.add(Long.class); + ret.add(Float.class); + ret.add(Double.class); + ret.add(Void.class); + return ret; + } + } +} diff --git a/src/main/java/me/magnum/breedablepets/util/SimpleConfigManager.java b/src/main/java/me/magnum/breedablepets/util/SimpleConfigManager.java new file mode 100644 index 0000000..fd33ffa --- /dev/null +++ b/src/main/java/me/magnum/breedablepets/util/SimpleConfigManager.java @@ -0,0 +1,424 @@ +package me.magnum.breedablepets.util; + +/* + * Base with comment and header features created by Log-out + * https://bukkit.org/threads/tut-custom-yaml-configurations-with-comments.142592/ + * Updated by Magnum1997 to auto update config files from resources + */ + +import org.bukkit.plugin.java.JavaPlugin; + +import java.io.*; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; + +public class SimpleConfigManager { + + private final JavaPlugin plugin; + + /** + * Manage custom configurations and files + */ + public SimpleConfigManager (JavaPlugin plugin) { + this.plugin = plugin; + } + + /** + * Get new configuration with header + * + * @param filePath - Path to file + * @return - New SimpleConfig + */ + public SimpleConfig getNewConfig (String filePath, String[] header,boolean useDefaults) { + + File file = this.getConfigFile(filePath); + + if (! file.exists()) { + this.prepareFile(filePath); + + if (header != null && header.length != 0) { + this.setHeader(file, header); + } + + } + + SimpleConfig config = new SimpleConfig(this.getConfigContent(filePath), file, this.getCommentsNum(file), useDefaults,plugin); + return config; + + } + + /** + * Get new configuration. + *

It will be blank unless (@link useDefaults) is true + * and include it in resources.

+ * + * @param filePath - Path to file + * @return - New SimpleConfig + */ + public SimpleConfig getNewConfig (String filePath) { + return this.getNewConfig(filePath, null,false); + } + + /** + * Get configuration file from string + * + * @param file - File path + * @return - New file object + */ + private File getConfigFile (String file) { + + if (file == null || file.isEmpty()) { + return null; + } + + File configFile; + + if (file.contains("/")) { + + if (file.startsWith("/")) { + configFile = new File(plugin.getDataFolder() + file.replace("/", File.separator)); + } + else { + configFile = new File(plugin.getDataFolder() + File.separator + file.replace("/", File.separator)); + } + + } + else { + configFile = new File(plugin.getDataFolder(), file); + } + + return configFile; + + } + + /** + * Create new file for config and copy resource into it + * + * @param filePath - Path to file + * @param resource - Resource to copy + */ + public void prepareFile (String filePath, String resource) { + + File file = this.getConfigFile(filePath); + + if (file.exists()) { + return; + } + + try { + file.getParentFile().mkdirs(); + file.createNewFile(); + + if (resource != null && ! resource.isEmpty()) { + this.copyResource(plugin.getResource(resource), file); + } + + } + catch (IOException e) { + e.printStackTrace(); + } + + } + + /** + * Create new file for config without resource + * + * @param filePath - File to create + */ + public void prepareFile (String filePath) { + this.prepareFile(filePath, null); + } + + /** + * Adds header block to config + * + * @param file - Config file + * @param header - Header lines + */ + public void setHeader (File file, String[] header) { + + if (! file.exists()) { + return; + } + + try { + String currentLine; + StringBuilder config = new StringBuilder(); + BufferedReader reader = new BufferedReader(new FileReader(file)); + + while ((currentLine = reader.readLine()) != null) { + config.append(currentLine + "\n"); + } + + reader.close(); + config.append("# +----------------------------------------------------+ #\n"); + + for (String line : header) { + + if (line.length() > 50) { + continue; + } + + int lenght = (50 - line.length()) / 2; + StringBuilder finalLine = new StringBuilder(line); + + for (int i = 0; i < lenght; i++) { + finalLine.append(" "); + finalLine.reverse(); + finalLine.append(" "); + finalLine.reverse(); + } + + if (line.length() % 2 != 0) { + finalLine.append(" "); + } + + config.append("# < " + finalLine.toString() + " > #\n"); + + } + + config.append("# +----------------------------------------------------+ #"); + + BufferedWriter writer = new BufferedWriter(new FileWriter(file)); + writer.write(this.prepareConfigString(config.toString())); + writer.flush(); + writer.close(); + + } + catch (IOException e) { + e.printStackTrace(); + } + + } + + /** + * Read file and make comments SnakeYAML friendly + * + * @param file - Path to file + * @return - File as Input Stream + */ + public InputStreamReader getConfigContent (File file) { + + if (! file.exists()) { + return null; + } + + try { + int commentNum = 0; + + String addLine; + String currentLine; + String pluginName = this.getPluginName(); + + StringBuilder whole = new StringBuilder(); + BufferedReader reader = new BufferedReader(new FileReader(file)); + + while ((currentLine = reader.readLine()) != null) { + + if (currentLine.startsWith("#")) { + addLine = currentLine.replaceFirst("#", pluginName + "_COMMENT_" + commentNum + ":"); + whole.append(addLine + "\n"); + commentNum++; + + } + else { + whole.append(currentLine + "\n"); + } + + } + + String config = whole.toString(); + InputStream configStream = new ByteArrayInputStream(config.getBytes(StandardCharsets.UTF_8)); + InputStreamReader configStreamReader = new InputStreamReader(configStream); + reader.close(); + return configStreamReader; + + } + catch (IOException e) { + e.printStackTrace(); + return null; + } + + } + + + /** + * Get comments from file + * + * @param file - File + * @return - Comments number + */ + private int getCommentsNum (File file) { + + if (! file.exists()) { + return 0; + } + + try { + int comments = 0; + String currentLine; + + BufferedReader reader = new BufferedReader(new FileReader(file)); + + while ((currentLine = reader.readLine()) != null) { + + if (currentLine.startsWith("#")) { + comments++; + } + + } + + reader.close(); + return comments; + + } + catch (IOException e) { + e.printStackTrace(); + return 0; + } + + } + + /** + * Get config content from file + * + * @param filePath - Path to file + * @return - readied file + */ + public InputStreamReader getConfigContent (String filePath) { + return this.getConfigContent(this.getConfigFile(filePath)); + } + + + private String prepareConfigString (String configString) { + + int lastLine = 0; + int headerLine = 0; + + String[] lines = configString.split("\n"); + StringBuilder config = new StringBuilder(); + + for (String line : lines) { + + if (line.startsWith(this.getPluginName() + "_COMMENT")) { + String comment = "#" + line.trim().substring(line.indexOf(":") + 1); + + if (comment.startsWith("# +-")) { + + /* + * If header line = 0 then it is + * header start, if it's equal + * to 1 it's the end of header + */ + + if (headerLine == 0) { + config.append(comment + "\n"); + + lastLine = 0; + headerLine = 1; + + } + else if (headerLine == 1) { + config.append(comment + "\n\n"); + + lastLine = 0; + headerLine = 0; + + } + + } + else { + + /* + * Last line = 0 - Comment + * Last line = 1 - Normal path + */ + + String normalComment; + + if (comment.startsWith("# ' ")) { + normalComment = comment.substring(0, comment.length() - 1).replaceFirst("# ' ", "# "); + } + else { + normalComment = comment; + } + + if (lastLine == 0) { + config.append(normalComment + "\n"); + } + else if (lastLine == 1) { + config.append("\n" + normalComment + "\n"); + } + + lastLine = 0; + + } + + } + else { + config.append(line + "\n"); + lastLine = 1; + } + + } + + return config.toString(); + + } + + + /** + * Saves configuration to file + * + * @param configString - Config string + * @param file - Config file + */ + public void saveConfig (String configString, File file) { + String configuration = this.prepareConfigString(configString); + + try { + BufferedWriter writer = new BufferedWriter(new FileWriter(file)); + writer.write(configuration); + writer.flush(); + writer.close(); + + } + catch (IOException e) { + e.printStackTrace(); + } + + } + + public String getPluginName () { + return plugin.getDescription().getName(); + } + + /** + * Copy resource from Input Stream to file + * + * @param resource - Resource from .jar + * @param file - File to write + */ + private void copyResource (InputStream resource, File file) { + + try { + OutputStream out = new FileOutputStream(file); + + int lenght; + byte[] buf = new byte[1024]; + + while ((lenght = resource.read(buf)) > 0) { + out.write(buf, 0, lenght); + } + + out.close(); + resource.close(); + + } + catch (Exception e) { + e.printStackTrace(); + } + + } + +} diff --git a/src/main/java/me/magnum/breedablepets/util/SpawnPets.java b/src/main/java/me/magnum/breedablepets/util/SpawnPets.java index 5233075..fab76e5 100644 --- a/src/main/java/me/magnum/breedablepets/util/SpawnPets.java +++ b/src/main/java/me/magnum/breedablepets/util/SpawnPets.java @@ -27,7 +27,6 @@ package me.magnum.breedablepets.util; import me.magnum.breedablepets.Main; -import me.magnum.lib.SimpleConfig; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.World; @@ -35,27 +34,28 @@ import org.bukkit.entity.Parrot; import org.bukkit.entity.Player; +import java.util.Objects; + public class SpawnPets { - private static SimpleConfig cfg = Main.cfg; - + public SpawnPets () { } public static void newParrot (Player player, Location location) { World world = player.getWorld(); Parrot parrot = (Parrot) world.spawnEntity(location, EntityType.PARROT); - parrot.setTamed(cfg.getBoolean("hatches.tamed")); + parrot.setTamed(Main.getCfg().getBoolean("hatches.tamed")); parrot.setHealth(1); //todo add to config parrot.setVariant(Parrot.Variant.RED); if (parrot.isTamed()) { parrot.setOwner(player); parrot.setSitting(true); } - if (Main.cfg.getBoolean("hatches.named")) { + if (Main.getCfg().getBoolean("hatches.named")) { parrot.setCustomNameVisible(true); - parrot.setCustomName(ChatColor.translateAlternateColorCodes('&', Main.cfg.getString("hatches.name"))); + parrot.setCustomName(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(Main.getCfg().getString("hatches.name")))); } } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml deleted file mode 100644 index c6b6747..0000000 --- a/src/main/resources/plugin.yml +++ /dev/null @@ -1,5 +0,0 @@ -name: @NAME@ -main: @MAIN@ -version: @VERSION@ -api-version: 1.13 -author: Magnum1997 From 0e494d4225c8b143d8bfc04ee37162ba175f9173 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 1 May 2020 16:10:26 -0700 Subject: [PATCH 04/44] Replace Foundation API with custom Common class Restored CheckSender. Main class extends JavaPlugin --- .../java/me/magnum/breedablepets/Command.java | 7 +- .../java/me/magnum/breedablepets/Main.java | 10 +-- .../breedablepets/listeners/MyListener.java | 18 ++-- .../breedablepets/util/CheckSender.java | 26 ++++++ .../me/magnum/breedablepets/util/Common.java | 86 +++++++++++++++++++ .../magnum/breedablepets/util/Messages.java | 1 - 6 files changed, 130 insertions(+), 18 deletions(-) create mode 100755 src/main/java/me/magnum/breedablepets/util/CheckSender.java create mode 100644 src/main/java/me/magnum/breedablepets/util/Common.java diff --git a/src/main/java/me/magnum/breedablepets/Command.java b/src/main/java/me/magnum/breedablepets/Command.java index e7d5516..011d501 100644 --- a/src/main/java/me/magnum/breedablepets/Command.java +++ b/src/main/java/me/magnum/breedablepets/Command.java @@ -28,11 +28,11 @@ import co.aikar.commands.BaseCommand; import co.aikar.commands.CommandHelp; import co.aikar.commands.annotation.*; +import me.magnum.breedablepets.util.CheckSender; import me.magnum.breedablepets.util.ItemUtil; import me.magnum.breedablepets.util.SpawnPets; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.mineacademy.fo.command.SimpleCommand; @CommandAlias("breedablepet|bp") public class Command extends BaseCommand { @@ -48,7 +48,8 @@ public void onHelp (CommandSender sender, CommandHelp help) { public void onCommand (CommandSender sender, @Default("false") String fertile) { ItemUtil util = new ItemUtil(); Player p = (Player) sender; - if (sender == null){ + + if (! CheckSender.isPlayer(sender)) { return; } if ((fertile.equalsIgnoreCase("fertile"))&& sender.hasPermission("breedable.parrot.fertile")) { @@ -67,7 +68,7 @@ public void onReload (CommandSender sender) { @CommandAlias("sp") @CommandPermission("me.magnum") public void onCommand (CommandSender sender) { - if (sender == null){ + if (!CheckSender.isPlayer(sender)) { return; } Player p = (Player) sender; diff --git a/src/main/java/me/magnum/breedablepets/Main.java b/src/main/java/me/magnum/breedablepets/Main.java index def328c..4593f93 100644 --- a/src/main/java/me/magnum/breedablepets/Main.java +++ b/src/main/java/me/magnum/breedablepets/Main.java @@ -29,16 +29,16 @@ import lombok.Getter; import me.magnum.breedablepets.listeners.BreedListener; import me.magnum.breedablepets.listeners.MyListener; +import me.magnum.breedablepets.util.Common; import me.magnum.breedablepets.util.SimpleConfig; import me.magnum.breedablepets.util.SimpleConfigManager; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.EntityType; -import org.mineacademy.fo.Common; -import org.mineacademy.fo.plugin.SimplePlugin; +import org.bukkit.plugin.java.JavaPlugin; @kr.entree.spigradle.Plugin -public class Main extends SimplePlugin { +public class Main extends JavaPlugin { @Getter private static Main plugin; @@ -48,7 +48,7 @@ public class Main extends SimplePlugin { private SimpleConfigManager configManager; @Override - public void onPluginStart () { + public void onEnable () { plugin = this; configManager = new SimpleConfigManager(plugin); Common.log("Loading breed-able pets..."); @@ -69,7 +69,7 @@ private void registerCommands () { @Override - public void onPluginStop () { + public void onDisable () { Common.log("Disabling Breedable pets."); // Remain.setPlugin(null); cfg = null; diff --git a/src/main/java/me/magnum/breedablepets/listeners/MyListener.java b/src/main/java/me/magnum/breedablepets/listeners/MyListener.java index f6c5636..e7ae073 100644 --- a/src/main/java/me/magnum/breedablepets/listeners/MyListener.java +++ b/src/main/java/me/magnum/breedablepets/listeners/MyListener.java @@ -26,8 +26,8 @@ package me.magnum.breedablepets.listeners; import me.magnum.breedablepets.Main; +import me.magnum.breedablepets.util.Common; import me.magnum.breedablepets.util.ItemUtil; -import me.magnum.breedablepets.util.Messages; import me.magnum.breedablepets.util.SpawnPets; import org.bukkit.Material; import org.bukkit.block.Dispenser; @@ -41,22 +41,22 @@ import java.util.concurrent.ThreadLocalRandom; public class MyListener implements Listener { - + private final ItemUtil itemsAPI = new ItemUtil(); - - @EventHandler(priority = EventPriority.HIGH) + + @EventHandler (priority = EventPriority.HIGH) public void onEggThrow (PlayerEggThrowEvent e) { if (e.getPlayer().getInventory().getItemInMainHand().isSimilar(itemsAPI.regEgg)) { e.setHatching(false); - - Messages.sendBar(e.getPlayer(), "I really hope it hatches..."); - if (ThreadLocalRandom.current().nextInt(100) < Main.getCfg().getInt("egg-change")) { + Common.sendBar(e.getPlayer(), "I really hope it hatches..."); + if (ThreadLocalRandom.current().nextInt(100) < Main.getCfg().getInt("egg-change")) ; + { SpawnPets.newParrot(e.getPlayer(), e.getEgg().getLocation()); } } if (e.getPlayer().getInventory().getItemInMainHand().isSimilar(itemsAPI.fertileEgg)) { e.setHatching(false); - Messages.sendBar(e.getPlayer(), "You try hatching the Parrot egg..."); + Common.sendBar(e.getPlayer(), "You try hatching the Parrot egg..."); SpawnPets.newParrot(e.getPlayer(), e.getEgg().getLocation()); } } @@ -69,7 +69,7 @@ public void onHatch (CreatureSpawnEvent e) { } } */ - + @EventHandler public void onDispenseEgg (BlockDispenseEvent e) { // todo add config option here diff --git a/src/main/java/me/magnum/breedablepets/util/CheckSender.java b/src/main/java/me/magnum/breedablepets/util/CheckSender.java new file mode 100755 index 0000000..3e675d0 --- /dev/null +++ b/src/main/java/me/magnum/breedablepets/util/CheckSender.java @@ -0,0 +1,26 @@ +package me.magnum.breedablepets.util; + +import org.bukkit.block.CommandBlock; +import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.entity.Player; + +public class CheckSender { + + + public static boolean isPlayer(CommandSender sender) { + return (sender instanceof Player); + } + + public static boolean isConsole(CommandSender sender) { + return (sender instanceof ConsoleCommandSender); + } + + public static boolean isCommand(CommandSender sender) { + return (sender instanceof CommandBlock); + } + + +} + + diff --git a/src/main/java/me/magnum/breedablepets/util/Common.java b/src/main/java/me/magnum/breedablepets/util/Common.java new file mode 100644 index 0000000..24b60d4 --- /dev/null +++ b/src/main/java/me/magnum/breedablepets/util/Common.java @@ -0,0 +1,86 @@ +package me.magnum.breedablepets.util; + +import lombok.Getter; +import lombok.Setter; +import me.magnum.breedablepets.Main; +import net.md_5.bungee.api.ChatMessageType; +import net.md_5.bungee.api.chat.TextComponent; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandMap; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; + +import java.lang.reflect.Field; +public class Common { + // ------------------------------------------------------------------------------------------------------------ + // Logging and error handling + // ------------------------------------------------------------------------------------------------------------ + + // This is the common library + + + public static void sendTitle(Player pl, String title, String subtitle) { + pl.sendTitle(colorize(title), colorize(subtitle), 20, 3 * 20, 10); + + } + + public static void sendBar(Player pl, String title) { + try { + pl.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(colorize(title))); + + } catch (final Throwable t) { + tell(pl, title); + } + } + + public static void log(String... messages) { + for (final String message : messages) + log(message); + } + + public static void log(String messages) { + tell(Bukkit.getConsoleSender(), "[" + Main.getPlugin().getName() + "] " + messages); + } + + public static void tell(CommandSender toWhom, String... messages) { + for (final String message : messages) + tell(toWhom, message); + } + + public static void tell(CommandSender toWhom, String message) { + toWhom.sendMessage(colorize(message)); + } + + public static String colorize(String message) { + return ChatColor.translateAlternateColorCodes('&', message); + } + + public static void registerCommand(Command command) { + try { + final Field commandMapField = Bukkit.getServer().getClass().getDeclaredField("commandMap"); + commandMapField.setAccessible(true); + + final CommandMap commandMap = (CommandMap) commandMapField.get(Bukkit.getServer()); + commandMap.register(command.getLabel(), command); + + } catch(final Exception e) { + e.printStackTrace(); + } + } + + public static T getOrDefault(T nullable, T def) { + return nullable != null ? nullable : def; + } + + public static void runLater(int delay, BukkitRunnable task) { + runLater(delay, task); + } + + public static void runLater(int delay, Runnable task) { + Bukkit.getScheduler().runTaskLater(Main.getPlugin(), task, delay); + } +} diff --git a/src/main/java/me/magnum/breedablepets/util/Messages.java b/src/main/java/me/magnum/breedablepets/util/Messages.java index a33fb0e..bff6c83 100644 --- a/src/main/java/me/magnum/breedablepets/util/Messages.java +++ b/src/main/java/me/magnum/breedablepets/util/Messages.java @@ -3,7 +3,6 @@ import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.Player; -import org.mineacademy.fo.Common; public class Messages { public static void sendBar(Player pl, String title) { From fc538ab833b7fe77663a9d31d8099f2dd7b437c1 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 1 May 2020 16:12:32 -0700 Subject: [PATCH 05/44] Add todo list --- build.gradle | 1 + src/main/java/me/magnum/breedablepets/Main.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 07a4582..cff92e3 100644 --- a/build.gradle +++ b/build.gradle @@ -50,6 +50,7 @@ task relocateShadowJar(type: ConfigureShadowRelocation) { shadowJar { classifier = null // remove -all from end of jar } +// TODO Create plugin.yml with correct info spigot { authors = ['Magnum1997'] // depends = ['ProtocolLib'] diff --git a/src/main/java/me/magnum/breedablepets/Main.java b/src/main/java/me/magnum/breedablepets/Main.java index 4593f93..d592ed1 100644 --- a/src/main/java/me/magnum/breedablepets/Main.java +++ b/src/main/java/me/magnum/breedablepets/Main.java @@ -38,7 +38,7 @@ import org.bukkit.plugin.java.JavaPlugin; @kr.entree.spigradle.Plugin -public class Main extends JavaPlugin { +public class Main extends JavaPlugin { // TODO Refactor & rename class @Getter private static Main plugin; From c3dca1abda1ccdbc0acd644de696350bb229c389 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 1 May 2020 19:18:31 -0700 Subject: [PATCH 06/44] Edit workflow --- .github/workflows/todo-issue.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/todo-issue.yaml b/.github/workflows/todo-issue.yaml index 3fa1304..486ed00 100644 --- a/.github/workflows/todo-issue.yaml +++ b/.github/workflows/todo-issue.yaml @@ -1,7 +1,7 @@ name: "Workflow" on: ["push"] jobs: - build: + yaml-to-list: runs-on: "ubuntu-latest" steps: - uses: "actions/checkout@master" @@ -15,6 +15,10 @@ jobs: LABEL: "# TODO" COMMENT_MARKER: "#" id: "todo" + java-to-list: + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@master" - name: "TODO to Issue for Java" uses: "alstr/todo-to-issue-action@master" with: From 728c33dfe26c11847e7a1eddaa752ea7ced2a69b Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 1 May 2020 23:59:40 -0700 Subject: [PATCH 07/44] Refactor Main class --- .github/workflows/create-release.yaml | 9 +++------ .../Main.java => Breedable.java} | 6 +++--- .../java/me/magnum/breedablepets/Command.java | 3 ++- .../breedablepets/listeners/BreedListener.java | 18 +++++++++--------- .../breedablepets/listeners/MyListener.java | 4 ++-- .../me/magnum/breedablepets/util/Common.java | 9 +++------ .../magnum/breedablepets/util/SpawnPets.java | 8 ++++---- 7 files changed, 26 insertions(+), 31 deletions(-) rename src/main/java/me/magnum/{breedablepets/Main.java => Breedable.java} (95%) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 5d8b42c..97fbd30 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -22,14 +22,11 @@ jobs: - uses: meeDamian/github-release@2.0 with: token: ${{ secrets.GITHUB_TOKEN }} - # TODO Edit body with changelog before pushing tags. body: | Changelog for ${{ steps.get_version.outputs.VERSION }} : - * Remove lombok from dependency list - * Add lombok plugin for Gradle - * Rename workflow files for easy identification - * Cleanup action.yml workflow - * Create-release workflow only zips folders + * Change Materials to match Minecraft 1.15 + * Integrated code from local API + * Add workflows for issue and release creation. files: build/libs/BreedablePets-${{ steps.get_version.outputs.VERSION }}.jar gzip: folders diff --git a/src/main/java/me/magnum/breedablepets/Main.java b/src/main/java/me/magnum/Breedable.java similarity index 95% rename from src/main/java/me/magnum/breedablepets/Main.java rename to src/main/java/me/magnum/Breedable.java index d592ed1..7d8ee60 100644 --- a/src/main/java/me/magnum/breedablepets/Main.java +++ b/src/main/java/me/magnum/Breedable.java @@ -23,7 +23,7 @@ * USA * */ -package me.magnum.breedablepets; +package me.magnum; import co.aikar.commands.BukkitCommandManager; import lombok.Getter; @@ -38,10 +38,10 @@ import org.bukkit.plugin.java.JavaPlugin; @kr.entree.spigradle.Plugin -public class Main extends JavaPlugin { // TODO Refactor & rename class +public class Breedable extends JavaPlugin { // TODO Refactor & rename class @Getter - private static Main plugin; + private static Breedable plugin; @Getter private static SimpleConfig cfg; @Getter diff --git a/src/main/java/me/magnum/breedablepets/Command.java b/src/main/java/me/magnum/breedablepets/Command.java index 011d501..36e82c7 100644 --- a/src/main/java/me/magnum/breedablepets/Command.java +++ b/src/main/java/me/magnum/breedablepets/Command.java @@ -28,6 +28,7 @@ import co.aikar.commands.BaseCommand; import co.aikar.commands.CommandHelp; import co.aikar.commands.annotation.*; +import me.magnum.Breedable; import me.magnum.breedablepets.util.CheckSender; import me.magnum.breedablepets.util.ItemUtil; import me.magnum.breedablepets.util.SpawnPets; @@ -62,7 +63,7 @@ public void onCommand (CommandSender sender, @Default("false") String fertile) { @Subcommand("reload") @CommandPermission("breedable.reload") public void onReload (CommandSender sender) { - Main.getCfg().reloadConfig(); + Breedable.getCfg().reloadConfig(); } @CommandAlias("sp") diff --git a/src/main/java/me/magnum/breedablepets/listeners/BreedListener.java b/src/main/java/me/magnum/breedablepets/listeners/BreedListener.java index 8a8b6b2..202dd4f 100644 --- a/src/main/java/me/magnum/breedablepets/listeners/BreedListener.java +++ b/src/main/java/me/magnum/breedablepets/listeners/BreedListener.java @@ -27,7 +27,7 @@ import fr.mrmicky.fastparticle.FastParticle; import fr.mrmicky.fastparticle.ParticleType; -import me.magnum.breedablepets.Main; +import me.magnum.Breedable; import me.magnum.breedablepets.util.ItemUtil; import org.bukkit.Location; import org.bukkit.Material; @@ -113,7 +113,7 @@ public void onFeed (PlayerInteractEntityEvent pie) { double y = target.getLocation().getY() + 1; double z = target.getLocation().getZ(); if (hasMate) { - if (ThreadLocalRandom.current().nextInt(100) < (Main.getCfg().getInt("fertile-egg-chance"))) { + if (ThreadLocalRandom.current().nextInt(100) < (Breedable.getCfg().getInt("fertile-egg-chance"))) { w.dropItemNaturally(loc, items.regEgg.clone()); // w.dropItemNaturally(loc, items.fertileEgg.clone()); // todo To be fertile egg - disabled until single throw bug fixed FastParticle.spawnParticle(target.getWorld(), ParticleType.HEART, target.getLocation(), 3); @@ -122,7 +122,7 @@ public void onFeed (PlayerInteractEntityEvent pie) { FastParticle.spawnParticle(w, ParticleType.HEART, x, y, z, 3); } else { - if (ThreadLocalRandom.current().nextInt(1, 101) < Main.getCfg().getInt("egg-chance")) { + if (ThreadLocalRandom.current().nextInt(1, 101) < Breedable.getCfg().getInt("egg-chance")) { w.dropItemNaturally(loc, items.regEgg.clone()); FastParticle.spawnParticle(target.getWorld(), ParticleType.HEART, target.getLocation(), 3); FastParticle.spawnParticle(target.getWorld(), ParticleType.HEART, x, y, z, 3); @@ -133,7 +133,7 @@ public void onFeed (PlayerInteractEntityEvent pie) { } else { - if (ThreadLocalRandom.current().nextInt(100) < Main.getCfg().getInt("egg-change")) { + if (ThreadLocalRandom.current().nextInt(100) < Breedable.getCfg().getInt("egg-change")) { FastParticle.spawnParticle(w, ParticleType.NOTE, target.getLocation(), 3, x, y, z); // FastParticle.spawnParticle(w, ParticleType.NOTE, x, y, z, 1); w.dropItemNaturally(loc, items.regEgg.clone()); @@ -147,20 +147,20 @@ private Integer foodCalc (Entity target, Material type) { int chance = 0; switch (type) { case WHEAT_SEEDS: - chance = Main.getCfg().getInt("modifier.wheat"); + chance = Breedable.getCfg().getInt("modifier.wheat"); break; case BEETROOT_SEEDS: - chance = Main.getCfg().getInt("modifier.beetroot"); + chance = Breedable.getCfg().getInt("modifier.beetroot"); break; case PUMPKIN_SEEDS: - chance = Main.getCfg().getInt("modifier.pumpkin"); + chance = Breedable.getCfg().getInt("modifier.pumpkin"); break; case MELON_SEEDS: - chance = Main.getCfg().getInt("modifier.melon"); + chance = Breedable.getCfg().getInt("modifier.melon"); break; case GLISTERING_MELON_SLICE: _MELON: - chance = Main.getCfg().getInt("modifier.glistering"); + chance = Breedable.getCfg().getInt("modifier.glistering"); break; } return chance; diff --git a/src/main/java/me/magnum/breedablepets/listeners/MyListener.java b/src/main/java/me/magnum/breedablepets/listeners/MyListener.java index e7ae073..e828b4a 100644 --- a/src/main/java/me/magnum/breedablepets/listeners/MyListener.java +++ b/src/main/java/me/magnum/breedablepets/listeners/MyListener.java @@ -25,7 +25,7 @@ */ package me.magnum.breedablepets.listeners; -import me.magnum.breedablepets.Main; +import me.magnum.Breedable; import me.magnum.breedablepets.util.Common; import me.magnum.breedablepets.util.ItemUtil; import me.magnum.breedablepets.util.SpawnPets; @@ -49,7 +49,7 @@ public void onEggThrow (PlayerEggThrowEvent e) { if (e.getPlayer().getInventory().getItemInMainHand().isSimilar(itemsAPI.regEgg)) { e.setHatching(false); Common.sendBar(e.getPlayer(), "I really hope it hatches..."); - if (ThreadLocalRandom.current().nextInt(100) < Main.getCfg().getInt("egg-change")) ; + if (ThreadLocalRandom.current().nextInt(100) < Breedable.getCfg().getInt("egg-change")) ; { SpawnPets.newParrot(e.getPlayer(), e.getEgg().getLocation()); } diff --git a/src/main/java/me/magnum/breedablepets/util/Common.java b/src/main/java/me/magnum/breedablepets/util/Common.java index 24b60d4..bbdedca 100644 --- a/src/main/java/me/magnum/breedablepets/util/Common.java +++ b/src/main/java/me/magnum/breedablepets/util/Common.java @@ -1,8 +1,6 @@ package me.magnum.breedablepets.util; -import lombok.Getter; -import lombok.Setter; -import me.magnum.breedablepets.Main; +import me.magnum.Breedable; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; @@ -11,7 +9,6 @@ import org.bukkit.command.CommandMap; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; import java.lang.reflect.Field; @@ -43,7 +40,7 @@ public static void log(String... messages) { } public static void log(String messages) { - tell(Bukkit.getConsoleSender(), "[" + Main.getPlugin().getName() + "] " + messages); + tell(Bukkit.getConsoleSender(), "[" + Breedable.getPlugin().getName() + "] " + messages); } public static void tell(CommandSender toWhom, String... messages) { @@ -81,6 +78,6 @@ public static void runLater(int delay, BukkitRunnable task) { } public static void runLater(int delay, Runnable task) { - Bukkit.getScheduler().runTaskLater(Main.getPlugin(), task, delay); + Bukkit.getScheduler().runTaskLater(Breedable.getPlugin(), task, delay); } } diff --git a/src/main/java/me/magnum/breedablepets/util/SpawnPets.java b/src/main/java/me/magnum/breedablepets/util/SpawnPets.java index fab76e5..f14216f 100644 --- a/src/main/java/me/magnum/breedablepets/util/SpawnPets.java +++ b/src/main/java/me/magnum/breedablepets/util/SpawnPets.java @@ -26,7 +26,7 @@ package me.magnum.breedablepets.util; -import me.magnum.breedablepets.Main; +import me.magnum.Breedable; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.World; @@ -46,16 +46,16 @@ public SpawnPets () { public static void newParrot (Player player, Location location) { World world = player.getWorld(); Parrot parrot = (Parrot) world.spawnEntity(location, EntityType.PARROT); - parrot.setTamed(Main.getCfg().getBoolean("hatches.tamed")); + parrot.setTamed(Breedable.getCfg().getBoolean("hatches.tamed")); parrot.setHealth(1); //todo add to config parrot.setVariant(Parrot.Variant.RED); if (parrot.isTamed()) { parrot.setOwner(player); parrot.setSitting(true); } - if (Main.getCfg().getBoolean("hatches.named")) { + if (Breedable.getCfg().getBoolean("hatches.named")) { parrot.setCustomNameVisible(true); - parrot.setCustomName(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(Main.getCfg().getString("hatches.name")))); + parrot.setCustomName(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(Breedable.getCfg().getString("hatches.name")))); } } } From 12c919b05ad9c8f92830c1cb130681a3f674d259 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Sat, 2 May 2020 01:49:29 -0700 Subject: [PATCH 08/44] Change how BreedListener handles eggs --- .github/workflows/create-release.yaml | 2 ++ src/main/java/me/magnum/Breedable.java | 2 +- .../listeners/BreedListener.java | 10 +++--- .../breedablepets/listeners/MyListener.java | 36 ++++++++++++++----- .../magnum/breedablepets/util/SpawnPets.java | 4 ++- src/main/resources/config.yml | 4 +-- 6 files changed, 39 insertions(+), 19 deletions(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 97fbd30..67d6e95 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -27,6 +27,8 @@ jobs: * Change Materials to match Minecraft 1.15 * Integrated code from local API * Add workflows for issue and release creation. + * Refactored main class + * Change how plugin watches for eggs to hatch files: build/libs/BreedablePets-${{ steps.get_version.outputs.VERSION }}.jar gzip: folders diff --git a/src/main/java/me/magnum/Breedable.java b/src/main/java/me/magnum/Breedable.java index 7d8ee60..7762e67 100644 --- a/src/main/java/me/magnum/Breedable.java +++ b/src/main/java/me/magnum/Breedable.java @@ -54,7 +54,7 @@ public void onEnable () { Common.log("Loading breed-able pets..."); cfg = configManager.getNewConfig("config.yml"); // cfg = new SimpleConfig("config.yml", plugin); - // Remain.setPlugin(plugin); //todo Add compatability + // Remain.setPlugin(plugin); // TODO Add compatability plugin.getServer().getPluginManager().registerEvents(new MyListener(), plugin); plugin.getServer().getPluginManager().registerEvents(new BreedListener(), plugin); registerCommands(); diff --git a/src/main/java/me/magnum/breedablepets/listeners/BreedListener.java b/src/main/java/me/magnum/breedablepets/listeners/BreedListener.java index 202dd4f..6cb8cd7 100644 --- a/src/main/java/me/magnum/breedablepets/listeners/BreedListener.java +++ b/src/main/java/me/magnum/breedablepets/listeners/BreedListener.java @@ -73,7 +73,7 @@ public void onFeed (PlayerInteractEntityEvent pie) { Material.MELON, Material.PUMPKIN_SEEDS, Material.GLISTERING_MELON_SLICE).contains(hand)) { - chanceModifier = foodCalc(target, hand); // todo increase chance of egg/fertile egg by type of food. + chanceModifier = foodCalc(target, hand); // TODO increase chance of egg/fertile egg by type of food. } else { return; @@ -82,7 +82,7 @@ public void onFeed (PlayerInteractEntityEvent pie) { sitting.setSitting(true); player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount() - 1); - // Common.tell(player, "Base chance of egg: " + chanceModifier); // todo remove before deploy + // Common.tell(player, "Base chance of egg: " + chanceModifier); // TODO remove before deploy List nearby = target.getNearbyEntities(5, 2, 5); @@ -98,7 +98,7 @@ public void onFeed (PlayerInteractEntityEvent pie) { } } -/* todo find nearest parrot +/* // TODO find nearest parrot for (int i = 0; i < nearby.size(); i++) { if (nearby.get(i).getType().equals(EntityType.PARROT)){ hasMate=true; @@ -115,7 +115,7 @@ public void onFeed (PlayerInteractEntityEvent pie) { if (hasMate) { if (ThreadLocalRandom.current().nextInt(100) < (Breedable.getCfg().getInt("fertile-egg-chance"))) { w.dropItemNaturally(loc, items.regEgg.clone()); - // w.dropItemNaturally(loc, items.fertileEgg.clone()); // todo To be fertile egg - disabled until single throw bug fixed + // w.dropItemNaturally(loc, items.fertileEgg.clone()); // TODO To be fertile egg - disabled until single throw bug fixed FastParticle.spawnParticle(target.getWorld(), ParticleType.HEART, target.getLocation(), 3); FastParticle.spawnParticle(target.getWorld(), ParticleType.HEART, x, y, z, 3); FastParticle.spawnParticle(w, ParticleType.HEART, mate.getLocation(), 3); @@ -142,7 +142,7 @@ public void onFeed (PlayerInteractEntityEvent pie) { } - // todo get length of configuration section and make array of item/chance pairs. + // TODO get length of configuration section and make array of item/chance pairs. private Integer foodCalc (Entity target, Material type) { int chance = 0; switch (type) { diff --git a/src/main/java/me/magnum/breedablepets/listeners/MyListener.java b/src/main/java/me/magnum/breedablepets/listeners/MyListener.java index e828b4a..001b090 100644 --- a/src/main/java/me/magnum/breedablepets/listeners/MyListener.java +++ b/src/main/java/me/magnum/breedablepets/listeners/MyListener.java @@ -31,36 +31,54 @@ import me.magnum.breedablepets.util.SpawnPets; import org.bukkit.Material; import org.bukkit.block.Dispenser; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockDispenseEvent; +import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerEggThrowEvent; import org.bukkit.inventory.ItemStack; +import java.util.HashMap; +import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; public class MyListener implements Listener { + private static HashMap flyingEggs = new HashMap <>(); + private static HashMap flyingFertileEggs = new HashMap <>(); private final ItemUtil itemsAPI = new ItemUtil(); @EventHandler (priority = EventPriority.HIGH) public void onEggThrow (PlayerEggThrowEvent e) { + UUID eggId = e.getEgg().getUniqueId(); + e.setHatching(false); if (e.getPlayer().getInventory().getItemInMainHand().isSimilar(itemsAPI.regEgg)) { - e.setHatching(false); Common.sendBar(e.getPlayer(), "I really hope it hatches..."); - if (ThreadLocalRandom.current().nextInt(100) < Breedable.getCfg().getInt("egg-change")) ; - { - SpawnPets.newParrot(e.getPlayer(), e.getEgg().getLocation()); - } + flyingEggs.put(eggId, e.getPlayer()); } if (e.getPlayer().getInventory().getItemInMainHand().isSimilar(itemsAPI.fertileEgg)) { - e.setHatching(false); + flyingFertileEggs.put(eggId, e.getPlayer()); Common.sendBar(e.getPlayer(), "You try hatching the Parrot egg..."); - SpawnPets.newParrot(e.getPlayer(), e.getEgg().getLocation()); + + } + } + + @EventHandler + public void eggHit (ProjectileHitEvent hitEvent) { + UUID projectile = hitEvent.getEntity().getUniqueId(); + if (flyingEggs.containsKey(projectile)) { + // handle regular egg + if (ThreadLocalRandom.current().nextInt(100) < Breedable.getCfg().getInt("egg-change")) { + SpawnPets.newParrot(flyingEggs.get(projectile), hitEvent.getHitBlock().getLocation()); + } + } + if (flyingFertileEggs.containsKey(projectile)) { + // handle fertile egg + SpawnPets.newParrot(flyingFertileEggs.get(projectile), hitEvent.getHitBlock().getLocation()); } } - /* @EventHandler public void onHatch (CreatureSpawnEvent e) { @@ -72,7 +90,7 @@ public void onHatch (CreatureSpawnEvent e) { @EventHandler public void onDispenseEgg (BlockDispenseEvent e) { - // todo add config option here + // TODO add config option here if ((e.getItem() != null) && (e.getItem().getType() != Material.AIR)) { if (e.getItem().getType() == Material.EGG) { Dispenser dispenser = (Dispenser) e.getBlock().getState(); diff --git a/src/main/java/me/magnum/breedablepets/util/SpawnPets.java b/src/main/java/me/magnum/breedablepets/util/SpawnPets.java index f14216f..72508f1 100644 --- a/src/main/java/me/magnum/breedablepets/util/SpawnPets.java +++ b/src/main/java/me/magnum/breedablepets/util/SpawnPets.java @@ -27,6 +27,7 @@ package me.magnum.breedablepets.util; import me.magnum.Breedable; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.World; @@ -45,9 +46,10 @@ public SpawnPets () { public static void newParrot (Player player, Location location) { World world = player.getWorld(); + location = world.getHighestBlockAt(location).getLocation().add(0,1,0); Parrot parrot = (Parrot) world.spawnEntity(location, EntityType.PARROT); parrot.setTamed(Breedable.getCfg().getBoolean("hatches.tamed")); - parrot.setHealth(1); //todo add to config + parrot.setHealth(1); // TODO add to config parrot.setVariant(Parrot.Variant.RED); if (parrot.isTamed()) { parrot.setOwner(player); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 1542db8..5e3812f 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,5 +1,3 @@ -# Config for @NAME@ version @VERSION@ -version: @VERSION@ # base chance that feeding a _tamed_ parrot will produce an egg. egg-chance: 10 # chance that feeding with a mate nearby produces an egg @@ -13,7 +11,7 @@ rare-chance: 1 # chance modifiers increase chance of eggs depending on what food you use # modifier of 0 does not change base chance -# This is for future version todo Add food modifiers +# This is for future version # TODO Add food modifiers modifier: wheat: 10 beetroot: 20 From a0c9ceb558a25a4c5d268e7aa33190e3c1e57b11 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Sat, 9 May 2020 00:02:24 -0700 Subject: [PATCH 09/44] Add config helper to make framed header in yaml files --- .../breedablepets/util/ConfigHelper.java | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 src/main/java/me/magnum/breedablepets/util/ConfigHelper.java diff --git a/src/main/java/me/magnum/breedablepets/util/ConfigHelper.java b/src/main/java/me/magnum/breedablepets/util/ConfigHelper.java new file mode 100644 index 0000000..527f6b3 --- /dev/null +++ b/src/main/java/me/magnum/breedablepets/util/ConfigHelper.java @@ -0,0 +1,123 @@ +package me.magnum.breedablepets.util; + +import lombok.NoArgsConstructor; +import me.magnum.Breedable; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +@NoArgsConstructor +public class ConfigHelper { + + private String[] header; + + public List framedHeader (String... header) { + List stringList = new ArrayList<>(); + String border = "# +----------------------------------------------------+ #"; + stringList.add(border); + + for (String line : header) { + StringBuilder builder = new StringBuilder(); + if (line.length() > 50) { + continue; + } + + int length = (50 - line.length()) / 2; + StringBuilder finalLine = new StringBuilder(line); + + for (int i = 0; i < length; i++) { + finalLine.append(" "); + finalLine.reverse(); + finalLine.append(" "); + finalLine.reverse(); + } + + if (line.length() % 2 != 0) { + finalLine.append(" "); + } + + builder.append("# < ").append(finalLine.toString()).append(" > #"); + stringList.add(builder.toString()); + } + stringList.add(border); + return stringList; + } + + private String prepareConfigString (String configString) { + + int lastLine = 0; + int headerLine = 0; + + String[] lines = configString.split("\n"); + StringBuilder config = new StringBuilder(); + + for (String line : lines) { + // Hard coded plugin instance - TODO Change to field + if (line.startsWith(Breedable.getPlugin().getName() + "_COMMENT")) { + String comment = "#" + line.trim().substring(line.indexOf(":") + 1); + + if (comment.startsWith("# +-")) { + + /* + * If header line = 0 then it is + * header start, if it's equal + * to 1 it's the end of header + */ + + if (headerLine == 0) { + config.append(comment).append("\n"); + + lastLine = 0; + headerLine = 1; + + } + else { + config.append(comment).append("\n\n"); + + lastLine = 0; + headerLine = 0; + + } + + } + else { + + /* + * Last line = 0 - Comment + * Last line = 1 - Normal path + */ + + String normalComment; + + if (comment.startsWith("# ' ")) { + normalComment = comment.substring(0, comment.length() - 1).replaceFirst("# ' ", "# "); + } + else { + normalComment = comment; + } + + if (lastLine == 0) { + config.append(normalComment).append("\n"); + } + else { + config.append("\n").append(normalComment).append("\n"); + } + + lastLine = 0; + + } + + } + else { + config.append(line).append("\n"); + lastLine = 1; + } + + } + + return config.toString(); + + } + +} From f99aa5acea4e515aaf98d33261cf2744d530960c Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Tue, 19 May 2020 13:39:55 -0700 Subject: [PATCH 10/44] Rename classes Changed ConfigHelper -> YamlHelper Changed MyListener -> EggListener --- src/main/java/me/magnum/Breedable.java | 2 +- .../{MyListener.java => EggListener.java} | 24 +++- .../breedablepets/util/ConfigHelper.java | 123 ------------------ .../magnum/breedablepets/util/YamlHelper.java | 44 +++++++ src/main/resources/config.yml | 2 +- 5 files changed, 63 insertions(+), 132 deletions(-) rename src/main/java/me/magnum/breedablepets/listeners/{MyListener.java => EggListener.java} (78%) delete mode 100644 src/main/java/me/magnum/breedablepets/util/ConfigHelper.java create mode 100644 src/main/java/me/magnum/breedablepets/util/YamlHelper.java diff --git a/src/main/java/me/magnum/Breedable.java b/src/main/java/me/magnum/Breedable.java index 7762e67..e8dccdd 100644 --- a/src/main/java/me/magnum/Breedable.java +++ b/src/main/java/me/magnum/Breedable.java @@ -28,7 +28,7 @@ import co.aikar.commands.BukkitCommandManager; import lombok.Getter; import me.magnum.breedablepets.listeners.BreedListener; -import me.magnum.breedablepets.listeners.MyListener; +import me.magnum.breedablepets.listeners.EggListener; import me.magnum.breedablepets.util.Common; import me.magnum.breedablepets.util.SimpleConfig; import me.magnum.breedablepets.util.SimpleConfigManager; diff --git a/src/main/java/me/magnum/breedablepets/listeners/MyListener.java b/src/main/java/me/magnum/breedablepets/listeners/EggListener.java similarity index 78% rename from src/main/java/me/magnum/breedablepets/listeners/MyListener.java rename to src/main/java/me/magnum/breedablepets/listeners/EggListener.java index 001b090..50464a9 100644 --- a/src/main/java/me/magnum/breedablepets/listeners/MyListener.java +++ b/src/main/java/me/magnum/breedablepets/listeners/EggListener.java @@ -29,6 +29,7 @@ import me.magnum.breedablepets.util.Common; import me.magnum.breedablepets.util.ItemUtil; import me.magnum.breedablepets.util.SpawnPets; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Dispenser; import org.bukkit.entity.Player; @@ -44,14 +45,17 @@ import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; -public class MyListener implements Listener { +public class EggListener implements Listener { - private static HashMap flyingEggs = new HashMap <>(); - private static HashMap flyingFertileEggs = new HashMap <>(); + private static final HashMap flyingEggs = new HashMap <>(); + private static final HashMap flyingFertileEggs = new HashMap <>(); private final ItemUtil itemsAPI = new ItemUtil(); @EventHandler (priority = EventPriority.HIGH) public void onEggThrow (PlayerEggThrowEvent e) { + ItemStack hand = e.getPlayer().getInventory().getItemInMainHand(); + if (! hand.isSimilar(itemsAPI.regEgg) || hand.isSimilar(itemsAPI.fertileEgg)) return; + UUID eggId = e.getEgg().getUniqueId(); e.setHatching(false); if (e.getPlayer().getInventory().getItemInMainHand().isSimilar(itemsAPI.regEgg)) { @@ -61,22 +65,28 @@ public void onEggThrow (PlayerEggThrowEvent e) { if (e.getPlayer().getInventory().getItemInMainHand().isSimilar(itemsAPI.fertileEgg)) { flyingFertileEggs.put(eggId, e.getPlayer()); Common.sendBar(e.getPlayer(), "You try hatching the Parrot egg..."); - } } @EventHandler public void eggHit (ProjectileHitEvent hitEvent) { UUID projectile = hitEvent.getEntity().getUniqueId(); + Location loc = hitEvent.getEntity().getLocation(); if (flyingEggs.containsKey(projectile)) { // handle regular egg - if (ThreadLocalRandom.current().nextInt(100) < Breedable.getCfg().getInt("egg-change")) { - SpawnPets.newParrot(flyingEggs.get(projectile), hitEvent.getHitBlock().getLocation()); + // todo debugging + int random = ThreadLocalRandom.current().nextInt(100); + int chance = (int) Breedable.getPlugin().getCfg().get("hatch-chance"); + Breedable.getPlugin().getServer().broadcastMessage("Random: " + random + " Chance: " + chance); + if (random < chance) { + SpawnPets.newParrot(flyingEggs.get(projectile), loc); } + flyingEggs.remove(projectile); } if (flyingFertileEggs.containsKey(projectile)) { // handle fertile egg - SpawnPets.newParrot(flyingFertileEggs.get(projectile), hitEvent.getHitBlock().getLocation()); + SpawnPets.newParrot(flyingFertileEggs.get(projectile), loc); + flyingFertileEggs.remove(projectile); } } /* diff --git a/src/main/java/me/magnum/breedablepets/util/ConfigHelper.java b/src/main/java/me/magnum/breedablepets/util/ConfigHelper.java deleted file mode 100644 index 527f6b3..0000000 --- a/src/main/java/me/magnum/breedablepets/util/ConfigHelper.java +++ /dev/null @@ -1,123 +0,0 @@ -package me.magnum.breedablepets.util; - -import lombok.NoArgsConstructor; -import me.magnum.Breedable; - -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Logger; - -@NoArgsConstructor -public class ConfigHelper { - - private String[] header; - - public List framedHeader (String... header) { - List stringList = new ArrayList<>(); - String border = "# +----------------------------------------------------+ #"; - stringList.add(border); - - for (String line : header) { - StringBuilder builder = new StringBuilder(); - if (line.length() > 50) { - continue; - } - - int length = (50 - line.length()) / 2; - StringBuilder finalLine = new StringBuilder(line); - - for (int i = 0; i < length; i++) { - finalLine.append(" "); - finalLine.reverse(); - finalLine.append(" "); - finalLine.reverse(); - } - - if (line.length() % 2 != 0) { - finalLine.append(" "); - } - - builder.append("# < ").append(finalLine.toString()).append(" > #"); - stringList.add(builder.toString()); - } - stringList.add(border); - return stringList; - } - - private String prepareConfigString (String configString) { - - int lastLine = 0; - int headerLine = 0; - - String[] lines = configString.split("\n"); - StringBuilder config = new StringBuilder(); - - for (String line : lines) { - // Hard coded plugin instance - TODO Change to field - if (line.startsWith(Breedable.getPlugin().getName() + "_COMMENT")) { - String comment = "#" + line.trim().substring(line.indexOf(":") + 1); - - if (comment.startsWith("# +-")) { - - /* - * If header line = 0 then it is - * header start, if it's equal - * to 1 it's the end of header - */ - - if (headerLine == 0) { - config.append(comment).append("\n"); - - lastLine = 0; - headerLine = 1; - - } - else { - config.append(comment).append("\n\n"); - - lastLine = 0; - headerLine = 0; - - } - - } - else { - - /* - * Last line = 0 - Comment - * Last line = 1 - Normal path - */ - - String normalComment; - - if (comment.startsWith("# ' ")) { - normalComment = comment.substring(0, comment.length() - 1).replaceFirst("# ' ", "# "); - } - else { - normalComment = comment; - } - - if (lastLine == 0) { - config.append(normalComment).append("\n"); - } - else { - config.append("\n").append(normalComment).append("\n"); - } - - lastLine = 0; - - } - - } - else { - config.append(line).append("\n"); - lastLine = 1; - } - - } - - return config.toString(); - - } - -} diff --git a/src/main/java/me/magnum/breedablepets/util/YamlHelper.java b/src/main/java/me/magnum/breedablepets/util/YamlHelper.java new file mode 100644 index 0000000..cd599ab --- /dev/null +++ b/src/main/java/me/magnum/breedablepets/util/YamlHelper.java @@ -0,0 +1,44 @@ +package me.magnum.breedablepets.util; + +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +@NoArgsConstructor +public class YamlHelper { + + private String[] header; + + public List framedHeader (String... header) { + List stringList = new ArrayList <>(); + String border = "# +----------------------------------------------------+ #"; + stringList.add(border); + + for (String line : header) { + StringBuilder builder = new StringBuilder(); + if (line.length() > 50) { + continue; + } + + int length = (50 - line.length()) / 2; + StringBuilder finalLine = new StringBuilder(line); + + for (int i = 0; i < length; i++) { + finalLine.append(" "); + finalLine.reverse(); + finalLine.append(" "); + finalLine.reverse(); + } + + if (line.length() % 2 != 0) { + finalLine.append(" "); + } + + builder.append("# < ").append(finalLine.toString()).append(" > #"); + stringList.add(builder.toString()); + } + stringList.add(border); + return stringList; + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 5e3812f..e1838f0 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,4 +1,4 @@ -# base chance that feeding a _tamed_ parrot will produce an egg. +# Base chance that feeding a _tamed_ parrot will produce an egg. egg-chance: 10 # chance that feeding with a mate nearby produces an egg paired-egg-chance: 20 From 3fc41ca1a502cd0b552e0f9df3c507e4a6986105 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Tue, 19 May 2020 13:45:45 -0700 Subject: [PATCH 11/44] Apply formatting changes Changed files: build.gradle README.md Command.java SpawnPets.java --- README.md | 11 ++++-- build.gradle | 37 ++++++++++--------- .../java/me/magnum/breedablepets/Command.java | 8 ++-- .../listeners/BreedListener.java | 16 ++++---- .../magnum/breedablepets/util/SpawnPets.java | 7 ++-- 5 files changed, 42 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index bb860bf..376e69b 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,14 @@ # BreedablePetsMC -Breed parrots and polar bears. Customize the food/item you use to tame each mob. +Breed animals that are not normally breed-able in Minecraft. -**Breedable Pets** is a [Minecraft](http://minecraft.net) server plugin for [Bukkit](http://http://bukkit.org) / [Spigot](http://spigotmc.org) / [Paper](http://papermc.io) that allows you to breed animals that are not usually breedable. + + +**Breedable Pets** is a [Minecraft](http://minecraft.net) server plugin for [Bukkit](http://http://bukkit.org) / [Spigot](http://spigotmc.org) / [Paper](http://papermc.io) that allows you to breed animals that are not usually breed-able. ### Installation -Drop the jar in your plugins folder and start the server. +Download jar from the [releases](https://github.com/Magnum97/BreedablePetsMC/releases) page and put it in your server's `plugins/` folder, then start the server. +Optionally you can compile it yourself. ## Usage There is only one command, `/breedablepets` alias `/bp`. Sub commands are: @@ -15,7 +18,7 @@ There is only one command, `/breedablepets` alias `/bp`. Sub commands are: For settings see [config.yml](https://github.com/Magnum97/BreedablePetsMC/blob/master/src/main/resources/config.yml)\ I tried to put all options in there. Some are not implemented yet. \ -Currently only parrots are breedable. You must feed them seeds *other* than wheat. Wheat seeds are still used for taming wild parrots. Foods are hard coded but plan to move to config in a future version. +Currently only parrots are breed-able. You must feed them seeds *other* than wheat. Wheat seeds are still used for taming wild parrots. Foods are hard coded but plan to move to config in a future version. ### Contributing This is a pretty basic plugin. If you have any thoughts, good or bad, I would like them or any suggestions for features or improvements.\ diff --git a/build.gradle b/build.gradle index cff92e3..f3abee7 100644 --- a/build.gradle +++ b/build.gradle @@ -12,16 +12,16 @@ plugins { id 'com.github.johnrengelman.shadow' version '5.1.0' } -group= 'me.magnum' // Put your groupId here -version= '1.3.1a' // Put your version here +group = 'me.magnum' // Put your groupId here +version = '1.3.1a' // Put your version here archivesBaseName = 'BreedablePets' // Put your artifactId here -mainClassName = 'me.magnum.breedablepets.Main' +mainClassName = 'me.magnum.Breedable' targetCompatibility = 1.8 sourceCompatibility = 1.8 // See https://github.com/EntryPointKR/Spigradle#repositories for repository shortcodes repositories { - mavenLocal() +// mavenLocal() mavenCentral() paper() enderZone() @@ -32,9 +32,10 @@ repositories { dependencies { compileOnly spigot('1.15.2') implementation 'fr.mrmicky:FastParticles:1.2.0' - implementation 'com.github.JavaFactoryDev:LightningStorage:3.0.3' + implementation files ('/home/rich/.m2/repository/com/github/javafactorydev/lightningstorage/3.1.1-SNAPSHOT/lightningstorage-3.1.1-SNAPSHOT.jar') +// implementation 'com.github.JavaFactoryDev:LightningStorage:3.1.1-SNAPSHOT' implementation "co.aikar:acf-bukkit:0.5.0-SNAPSHOT" - implementation 'com.github.kangarko:Foundation:5.3.8@jar' // Kangerko's Foundation library +// implementation 'com.github.kangarko:Foundation:5.3.8@jar' // Kangerko's Foundation library } compileJava { @@ -47,33 +48,33 @@ task relocateShadowJar(type: ConfigureShadowRelocation) { prefix = "shadow" // Default value is "shadow" } +tasks.shadowJar.dependsOn tasks.relocateShadowJar shadowJar { classifier = null // remove -all from end of jar } -// TODO Create plugin.yml with correct info spigot { authors = ['Magnum1997'] // depends = ['ProtocolLib'] apiVersion = '1.15' load = STARTUP commands { - give { - aliases = ['i'] - description = 'Give command.' - permission = 'test.foo' - permissionMessage = 'You do not have permission!' - usage = '/ [test|stop]' + breedablepets { + aliases = ['bp'] + description = 'Main command for BreedablePets' + permission = 'breedablepets.command' + permissionMessage = 'You do not have permission: breedablepets.command' + usage = '/ [ help | parrotegg [fertile]]' } } permissions { - 'test.foo' { - description = 'Allows foo command' - defaults = 'true' + 'breedablepets.command' { + description = 'Allows main command' + defaults = 'op' } - 'test.*' { + 'breedablepets.*' { description = 'Wildcard permission' defaults = 'op' - children = ['test.foo': true] + children = ['breedablepets.command': true, 'breedablepets.command.parrot': true, 'breedabpepets.reload': true] } } } diff --git a/src/main/java/me/magnum/breedablepets/Command.java b/src/main/java/me/magnum/breedablepets/Command.java index 36e82c7..c5e3c8d 100644 --- a/src/main/java/me/magnum/breedablepets/Command.java +++ b/src/main/java/me/magnum/breedablepets/Command.java @@ -35,7 +35,9 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandAlias("breedablepet|bp") +// TODO refine permissions +// ie. breedable.command breedable.command.parrot breedable.command.reload +@CommandAlias("breedablepets|bp") public class Command extends BaseCommand { @HelpCommand @@ -45,7 +47,7 @@ public void onHelp (CommandSender sender, CommandHelp help) { @Subcommand("parrotegg") @Description("Get a parrot egg") - @CommandPermission("breedable.parrot.egg") + @CommandPermission("breedablepets.command.parrotegg") public void onCommand (CommandSender sender, @Default("false") String fertile) { ItemUtil util = new ItemUtil(); Player p = (Player) sender; @@ -63,7 +65,7 @@ public void onCommand (CommandSender sender, @Default("false") String fertile) { @Subcommand("reload") @CommandPermission("breedable.reload") public void onReload (CommandSender sender) { - Breedable.getCfg().reloadConfig(); + Breedable.getPlugin().getCfg().forceReload(); } @CommandAlias("sp") diff --git a/src/main/java/me/magnum/breedablepets/listeners/BreedListener.java b/src/main/java/me/magnum/breedablepets/listeners/BreedListener.java index 6cb8cd7..db011c2 100644 --- a/src/main/java/me/magnum/breedablepets/listeners/BreedListener.java +++ b/src/main/java/me/magnum/breedablepets/listeners/BreedListener.java @@ -113,7 +113,7 @@ public void onFeed (PlayerInteractEntityEvent pie) { double y = target.getLocation().getY() + 1; double z = target.getLocation().getZ(); if (hasMate) { - if (ThreadLocalRandom.current().nextInt(100) < (Breedable.getCfg().getInt("fertile-egg-chance"))) { + if (ThreadLocalRandom.current().nextInt(100) < (Breedable.getPlugin().getCfg().getInt("fertile-egg-chance"))) { w.dropItemNaturally(loc, items.regEgg.clone()); // w.dropItemNaturally(loc, items.fertileEgg.clone()); // TODO To be fertile egg - disabled until single throw bug fixed FastParticle.spawnParticle(target.getWorld(), ParticleType.HEART, target.getLocation(), 3); @@ -122,7 +122,7 @@ public void onFeed (PlayerInteractEntityEvent pie) { FastParticle.spawnParticle(w, ParticleType.HEART, x, y, z, 3); } else { - if (ThreadLocalRandom.current().nextInt(1, 101) < Breedable.getCfg().getInt("egg-chance")) { + if (ThreadLocalRandom.current().nextInt(1, 101) < Breedable.getPlugin().getCfg().getInt("egg-chance")) { w.dropItemNaturally(loc, items.regEgg.clone()); FastParticle.spawnParticle(target.getWorld(), ParticleType.HEART, target.getLocation(), 3); FastParticle.spawnParticle(target.getWorld(), ParticleType.HEART, x, y, z, 3); @@ -133,7 +133,7 @@ public void onFeed (PlayerInteractEntityEvent pie) { } else { - if (ThreadLocalRandom.current().nextInt(100) < Breedable.getCfg().getInt("egg-change")) { + if (ThreadLocalRandom.current().nextInt(100) < Breedable.getPlugin().getCfg().getInt("egg-change")) { FastParticle.spawnParticle(w, ParticleType.NOTE, target.getLocation(), 3, x, y, z); // FastParticle.spawnParticle(w, ParticleType.NOTE, x, y, z, 1); w.dropItemNaturally(loc, items.regEgg.clone()); @@ -147,20 +147,20 @@ private Integer foodCalc (Entity target, Material type) { int chance = 0; switch (type) { case WHEAT_SEEDS: - chance = Breedable.getCfg().getInt("modifier.wheat"); + chance = Breedable.getPlugin().getCfg().getInt("modifier.wheat"); break; case BEETROOT_SEEDS: - chance = Breedable.getCfg().getInt("modifier.beetroot"); + chance = Breedable.getPlugin().getCfg().getInt("modifier.beetroot"); break; case PUMPKIN_SEEDS: - chance = Breedable.getCfg().getInt("modifier.pumpkin"); + chance = Breedable.getPlugin().getCfg().getInt("modifier.pumpkin"); break; case MELON_SEEDS: - chance = Breedable.getCfg().getInt("modifier.melon"); + chance = Breedable.getPlugin().getCfg().getInt("modifier.melon"); break; case GLISTERING_MELON_SLICE: _MELON: - chance = Breedable.getCfg().getInt("modifier.glistering"); + chance = Breedable.getPlugin().getCfg().getInt("modifier.glistering"); break; } return chance; diff --git a/src/main/java/me/magnum/breedablepets/util/SpawnPets.java b/src/main/java/me/magnum/breedablepets/util/SpawnPets.java index 72508f1..c9e4f15 100644 --- a/src/main/java/me/magnum/breedablepets/util/SpawnPets.java +++ b/src/main/java/me/magnum/breedablepets/util/SpawnPets.java @@ -27,7 +27,6 @@ package me.magnum.breedablepets.util; import me.magnum.Breedable; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.World; @@ -48,16 +47,16 @@ public static void newParrot (Player player, Location location) { World world = player.getWorld(); location = world.getHighestBlockAt(location).getLocation().add(0,1,0); Parrot parrot = (Parrot) world.spawnEntity(location, EntityType.PARROT); - parrot.setTamed(Breedable.getCfg().getBoolean("hatches.tamed")); + parrot.setTamed(Breedable.getPlugin().getCfg().getBoolean("hatches.tamed")); parrot.setHealth(1); // TODO add to config parrot.setVariant(Parrot.Variant.RED); if (parrot.isTamed()) { parrot.setOwner(player); parrot.setSitting(true); } - if (Breedable.getCfg().getBoolean("hatches.named")) { + if (Breedable.getPlugin().getCfg().getBoolean("hatches.named")) { parrot.setCustomNameVisible(true); - parrot.setCustomName(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(Breedable.getCfg().getString("hatches.name")))); + parrot.setCustomName(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(Breedable.getPlugin().getCfg().getString("hatches.name")))); } } } From 22afb0722f453a1eaa55ecd832c546e0e341b652 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Tue, 19 May 2020 13:53:53 -0700 Subject: [PATCH 12/44] Change yaml library Changed to Lightning Storage by JavaFactoryDev --- .github/workflows/create-release.yaml | 2 + src/main/java/me/magnum/Breedable.java | 54 +++++-- .../breedablepets/util/SimpleConfig.java | 137 ++---------------- .../util/SimpleConfigManager.java | 10 +- .../magnum/breedablepets/util/YamlHelper.java | 56 ++++++- 5 files changed, 111 insertions(+), 148 deletions(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 67d6e95..75d51b3 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -29,6 +29,8 @@ jobs: * Add workflows for issue and release creation. * Refactored main class * Change how plugin watches for eggs to hatch + * Change ProjectileHitEvent: getBlock location -> getEnttity location + * Changed Config library to Lightning Storage files: build/libs/BreedablePets-${{ steps.get_version.outputs.VERSION }}.jar gzip: folders diff --git a/src/main/java/me/magnum/Breedable.java b/src/main/java/me/magnum/Breedable.java index e8dccdd..5ddc8d9 100644 --- a/src/main/java/me/magnum/Breedable.java +++ b/src/main/java/me/magnum/Breedable.java @@ -26,52 +26,74 @@ package me.magnum; import co.aikar.commands.BukkitCommandManager; +import de.leonhard.storage.Yaml; +import de.leonhard.storage.sections.FlatFileSection; import lombok.Getter; +import lombok.SneakyThrows; +import me.magnum.breedablepets.Command; import me.magnum.breedablepets.listeners.BreedListener; import me.magnum.breedablepets.listeners.EggListener; import me.magnum.breedablepets.util.Common; -import me.magnum.breedablepets.util.SimpleConfig; -import me.magnum.breedablepets.util.SimpleConfigManager; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.EntityType; import org.bukkit.plugin.java.JavaPlugin; -@kr.entree.spigradle.Plugin -public class Breedable extends JavaPlugin { // TODO Refactor & rename class +public class Breedable extends JavaPlugin { @Getter private static Breedable plugin; + // @Getter +// private SimpleConfig cfg; @Getter - private static SimpleConfig cfg; - @Getter - private SimpleConfigManager configManager; + private Yaml cfg; @Override public void onEnable () { plugin = this; - configManager = new SimpleConfigManager(plugin); - Common.log("Loading breed-able pets..."); - cfg = configManager.getNewConfig("config.yml"); - // cfg = new SimpleConfig("config.yml", plugin); - // Remain.setPlugin(plugin); // TODO Add compatability - plugin.getServer().getPluginManager().registerEvents(new MyListener(), plugin); - plugin.getServer().getPluginManager().registerEvents(new BreedListener(), plugin); + setupConfig(); +// Remain.setPlugin(plugin); // TODO Add compatability + plugin.getServer().getPluginManager().registerEvents(new EggListener(), this); + plugin.getServer().getPluginManager().registerEvents(new BreedListener(), this); registerCommands(); } + private void setupConfig () { + cfg = new Yaml("settings.yml", getDataFolder().toString(), getResource("settings.yml")); + String[] header = {"Config file for BreedablePets", + "by Magnum1997", + "This should be self-explanatory. I tried to comment settings.", + "For problems, questions, or feedback please visit", + "https://github.com/Magnum97/BreedablePetsMC/issues"}; + cfg.framedHeader(header); + // Set defaults + cfg.setDefault("parrots.hatch-chance", 10); + cfg.setDefault("parrot.egg-chance", 25); + cfg.setDefault("paired-egg-chance", 20); + cfg.setDefault("fertile-egg-chance", 30); + cfg.setDefault("hatch-chance", 10); + cfg.setDefault("rare-chance", 1); + FlatFileSection modifiers = cfg.getSection("modifiers"); + modifiers.setDefault("wheat", 10); + modifiers.setDefault("beetroot", 20); + modifiers.setDefault("pumpkin", 30); + modifiers.setDefault("melon", 30); + modifiers.setDefault("glistering-melon", 100); + } + @SuppressWarnings ("deprecation") private void registerCommands () { BukkitCommandManager commandManager = new BukkitCommandManager(plugin); - commandManager.registerCommand(new me.magnum.breedablepets.Command()); + commandManager.registerCommand(new Command()); commandManager.enableUnstableAPI("help"); } @Override public void onDisable () { - Common.log("Disabling Breedable pets."); + Common.log("Disabling Breed-able pets."); // Remain.setPlugin(null); + // cfg.saveConfig(); cfg = null; plugin = null; } diff --git a/src/main/java/me/magnum/breedablepets/util/SimpleConfig.java b/src/main/java/me/magnum/breedablepets/util/SimpleConfig.java index 15ed7ab..4241c6f 100644 --- a/src/main/java/me/magnum/breedablepets/util/SimpleConfig.java +++ b/src/main/java/me/magnum/breedablepets/util/SimpleConfig.java @@ -1,136 +1,49 @@ -package me.magnum.breedablepets.util; /* * Base with comment and header features created by Log-out * https://bukkit.org/threads/tut-custom-yaml-configurations-with-comments.142592/ * Updated by Magnum1997 to auto update config files from resources */ +package me.magnum.breedablepets.util; + +import de.leonhard.storage.internal.FileData; +import de.leonhard.storage.internal.FlatFile; +import me.magnum.Breedable; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.java.JavaPlugin; -import org.mineacademy.fo.Common; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; -import java.util.HashSet; import java.util.List; -import java.util.Objects; +import java.util.Map; import java.util.Set; -public class SimpleConfig extends YamlConfiguration { - - private final JavaPlugin plugin; +public class SimpleConfig { +private JavaPlugin plugin; private int comments; - private final SimpleConfigManager manager; + private SimpleConfigManager manager; private File file; private FileConfiguration config; - private final boolean useDefaults; - private final YamlConfiguration defaults; - public SimpleConfig (InputStreamReader configStream, File configFile, int comments, boolean useDefaults, JavaPlugin plugin) { + public SimpleConfig (InputStreamReader configStream, File configFile, int comments, JavaPlugin plugin) { this.plugin = plugin; this.comments = comments; this.manager = new SimpleConfigManager(plugin); this.file = configFile; this.config = YamlConfiguration.loadConfiguration(configStream); - this.useDefaults = useDefaults; - - if (useDefaults) { - this.defaults = YamlConfiguration.loadConfiguration(new InputStreamReader(SimpleConfig.class.getResourceAsStream("/" + file.getName()), StandardCharsets.UTF_8)); - Objects.requireNonNull(defaults, "Could not find the default " + file.getName() + " in jar file."); - } - else - this.defaults = null; - this.file = extract(file.getName()); - - - } - - // Extract the file from your jar to the plugins/YourPlugin folder. - // Does nothing if the file exists - private File extract (String fileName) { - File file = new File(plugin.getDataFolder(), fileName); - - if (file.exists()) - return file; - createPath(fileName); - - if (defaults != null) - try (InputStream inputStream = plugin.getResource(fileName)) { - Objects.requireNonNull(inputStream, "File not found in archive: +" + fileName); - Files.copy(inputStream, Paths.get(file.toURI()), StandardCopyOption.REPLACE_EXISTING); - } - catch (final IOException e) { - e.printStackTrace(); - } - return file; - } - - - private File createPath (String fileName) { - final File datafolder = plugin.getDataFolder(); - final int lastIndex = fileName.lastIndexOf("/"); - final File directory = new File(datafolder, fileName.substring(0, Math.max(lastIndex, 0))); - directory.mkdirs(); - final File destination = new File(datafolder, fileName); - try { - destination.createNewFile(); - } - catch (IOException e) { - e.printStackTrace(); - System.out.println("File creation failed: " + fileName); - } - - return destination; } public Object get (String path) { - return get(path, null); + return this.config.get(path); } - - /** - * Gets an unspecified value from your file, so you must cast it to your desired value (example: (boolean) get("disable.this.feature", true)) - * The "def" is the default value, must be null since we use default values from your file in your .jar. - */ - @Override public Object get (String path, Object def) { - if (defaults != null) { - - if (def != null && ! def.getClass().isPrimitive() && ! PrimitiveWrapper.isWrapperType(def.getClass())) - throw new IllegalArgumentException("The default value must be null since we use defaults from file inside of the plugin! Path: " + path + ", default called: " + def); - - if (super.get(path, null) == null) { - final Object defaultValue = defaults.get(path); - Objects.requireNonNull(defaultValue, "Default " + file.getName() + " in your .jar lacks a key at '" + path + "' path"); - - Common.log("&fUpdating &a" + file.getName() + "&f. Set '&b" + path + "&f' to '" + defaultValue + "'"); - set(path, defaultValue); - saveConfig(); - reloadConfig(); - } - } - -/* - // prevent infinite loop due to how get works in the parent class - final String m = new Throwable().getStackTrace()[1].getMethodName(); - - // Add path prefix, but only when the default file doesn't exist - if (defaults == null && pathPrefix != null && !m.equals("getConfigurationSection") && !m.equals("get")) - path = pathPrefix + "." + path; -*/ - - // return super.get(path, null); - return this.config.get(path, null); + return this.config.get(path, def); } public String getString (String path) { @@ -157,12 +70,9 @@ public boolean getBoolean (String path, boolean def) { return this.config.getBoolean(path, def); } - -/* public void createSection (String path) { this.config.createSection(path); } -*/ public ConfigurationSection getConfigurationSection (String path) { return this.config.getConfigurationSection(path); @@ -241,27 +151,4 @@ public Set getKeys () { return this.config.getKeys(false); } - // A helper class - private static final class PrimitiveWrapper { - - private static final Set > WRAPPER_TYPES = getWrapperTypes(); - - private static boolean isWrapperType (Class clazz) { - return WRAPPER_TYPES.contains(clazz); - } - - private static Set > getWrapperTypes () { - final Set > ret = new HashSet <>(); - ret.add(Boolean.class); - ret.add(Character.class); - ret.add(Byte.class); - ret.add(Short.class); - ret.add(Integer.class); - ret.add(Long.class); - ret.add(Float.class); - ret.add(Double.class); - ret.add(Void.class); - return ret; - } - } } diff --git a/src/main/java/me/magnum/breedablepets/util/SimpleConfigManager.java b/src/main/java/me/magnum/breedablepets/util/SimpleConfigManager.java index fd33ffa..299a13a 100644 --- a/src/main/java/me/magnum/breedablepets/util/SimpleConfigManager.java +++ b/src/main/java/me/magnum/breedablepets/util/SimpleConfigManager.java @@ -9,12 +9,11 @@ import org.bukkit.plugin.java.JavaPlugin; import java.io.*; -import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; public class SimpleConfigManager { - private final JavaPlugin plugin; + private JavaPlugin plugin; /** * Manage custom configurations and files @@ -29,7 +28,7 @@ public SimpleConfigManager (JavaPlugin plugin) { * @param filePath - Path to file * @return - New SimpleConfig */ - public SimpleConfig getNewConfig (String filePath, String[] header,boolean useDefaults) { + public SimpleConfig getNewConfig (String filePath, String[] header) { File file = this.getConfigFile(filePath); @@ -42,7 +41,7 @@ public SimpleConfig getNewConfig (String filePath, String[] header,boolean useDe } - SimpleConfig config = new SimpleConfig(this.getConfigContent(filePath), file, this.getCommentsNum(file), useDefaults,plugin); + SimpleConfig config = new SimpleConfig(this.getConfigContent(filePath), file, this.getCommentsNum(file), plugin); return config; } @@ -56,7 +55,7 @@ public SimpleConfig getNewConfig (String filePath, String[] header,boolean useDe * @return - New SimpleConfig */ public SimpleConfig getNewConfig (String filePath) { - return this.getNewConfig(filePath, null,false); + return this.getNewConfig(filePath, null); } /** @@ -230,6 +229,7 @@ public InputStreamReader getConfigContent (File file) { String config = whole.toString(); InputStream configStream = new ByteArrayInputStream(config.getBytes(StandardCharsets.UTF_8)); InputStreamReader configStreamReader = new InputStreamReader(configStream); + reader.close(); return configStreamReader; diff --git a/src/main/java/me/magnum/breedablepets/util/YamlHelper.java b/src/main/java/me/magnum/breedablepets/util/YamlHelper.java index cd599ab..1f4dc8f 100644 --- a/src/main/java/me/magnum/breedablepets/util/YamlHelper.java +++ b/src/main/java/me/magnum/breedablepets/util/YamlHelper.java @@ -1,7 +1,12 @@ package me.magnum.breedablepets.util; +import de.leonhard.storage.Yaml; import lombok.NoArgsConstructor; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -9,10 +14,11 @@ public class YamlHelper { private String[] header; + private int commentsCounter; public List framedHeader (String... header) { List stringList = new ArrayList <>(); - String border = "# +----------------------------------------------------+ #"; + String border = "# ┼─────────────────────────────────────────────────────┼ #"; stringList.add(border); for (String line : header) { @@ -35,10 +41,56 @@ public List framedHeader (String... header) { finalLine.append(" "); } - builder.append("# < ").append(finalLine.toString()).append(" > #"); + builder.append("# │").append(finalLine.toString()).append(" │#"); stringList.add(builder.toString()); } stringList.add(border); return stringList; } + + public void setComment (Yaml yaml, String path, Object value, String comment) { + int comments = getCommentsNum(yaml.getFile()); + if (! yaml.contains(path)) { + yaml.set(yaml.getName() + "_COMMENT_" + comments, " " + comment); + } + yaml.set(path, value); + } + + /** + * Get comments from file + * + * @param file - File + * @return - Comments number + */ + private int getCommentsNum (File file) { + + if (! file.exists()) { + return 0; + } + + try { + int comments = 0; + String currentLine; + + BufferedReader reader = new BufferedReader(new FileReader(file)); + + while ((currentLine = reader.readLine()) != null) { + + if (currentLine.startsWith("#")) { + comments++; + } + + } + + reader.close(); + return comments; + + } + catch (IOException e) { + e.printStackTrace(); + return 0; + } + + } + } From 99e83a575bf7882e95d9110ad2775553140d9a31 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Tue, 19 May 2020 15:06:39 -0700 Subject: [PATCH 13/44] Add Changelog Remove send file to discord action --- .github/workflows/create-release.yaml | 10 +--------- CHANGELOG.md | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 75d51b3..156f051 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -31,13 +31,5 @@ jobs: * Change how plugin watches for eggs to hatch * Change ProjectileHitEvent: getBlock location -> getEnttity location * Changed Config library to Lightning Storage - files: build/libs/BreedablePets-${{ steps.get_version.outputs.VERSION }}.jar + files: build/libs/BreedablePets.jar gzip: folders - - - name: Send file JAR to discord channel - uses: sinshutu/upload-to-discord@master - env: - DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} - with: - args: build/libs/BreedablePets-${{ steps.get_version.outputs.VERSION }}.jar -# args: README.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..668117c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +# Changelog + +[Full Changelog](http://link.to/commit/history) + +### v1.2.3 (*Unreleased*) + + +* Change Materials to work with Minecraft 1.15 +* Change how plugin listens for eggs to hatch +* Change hatch location to prevent suffocation +* Add a changelog + + + From 8492a6d225df2b62b8bd164c69b18062627daf92 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Tue, 19 May 2020 15:06:50 -0700 Subject: [PATCH 14/44] Bump version for 2.0.0-SNAPSHOT release --- build.gradle | 2 +- src/main/java/me/magnum/Breedable.java | 2 +- .../java/me/magnum/breedablepets/listeners/EggListener.java | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index f3abee7..184dfb2 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ plugins { } group = 'me.magnum' // Put your groupId here -version = '1.3.1a' // Put your version here +version = '2.0.0-SNAPSHOT' // Put your version here archivesBaseName = 'BreedablePets' // Put your artifactId here mainClassName = 'me.magnum.Breedable' targetCompatibility = 1.8 diff --git a/src/main/java/me/magnum/Breedable.java b/src/main/java/me/magnum/Breedable.java index 5ddc8d9..1d914c8 100644 --- a/src/main/java/me/magnum/Breedable.java +++ b/src/main/java/me/magnum/Breedable.java @@ -52,7 +52,7 @@ public class Breedable extends JavaPlugin { public void onEnable () { plugin = this; setupConfig(); -// Remain.setPlugin(plugin); // TODO Add compatability +// Remain.setPlugin(plugin); // TODO Add backwards compatibility plugin.getServer().getPluginManager().registerEvents(new EggListener(), this); plugin.getServer().getPluginManager().registerEvents(new BreedListener(), this); registerCommands(); diff --git a/src/main/java/me/magnum/breedablepets/listeners/EggListener.java b/src/main/java/me/magnum/breedablepets/listeners/EggListener.java index 50464a9..9897f1b 100644 --- a/src/main/java/me/magnum/breedablepets/listeners/EggListener.java +++ b/src/main/java/me/magnum/breedablepets/listeners/EggListener.java @@ -74,7 +74,6 @@ public void eggHit (ProjectileHitEvent hitEvent) { Location loc = hitEvent.getEntity().getLocation(); if (flyingEggs.containsKey(projectile)) { // handle regular egg - // todo debugging int random = ThreadLocalRandom.current().nextInt(100); int chance = (int) Breedable.getPlugin().getCfg().get("hatch-chance"); Breedable.getPlugin().getServer().broadcastMessage("Random: " + random + " Chance: " + chance); From 0a1f6d9b5630db20d96733a784cc48281f2ac049 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Tue, 19 May 2020 15:06:50 -0700 Subject: [PATCH 15/44] Fix release action --- .github/workflows/create-release.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 156f051..089deb0 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -1,7 +1,6 @@ # This workflow will create a release on v-tag push name: Create release -descriptiom: "create a release on pushs with v-tag" on: push: # Sequence of patterns matched against refs/tags From e43a8fbbbe23ccefc4c1ce50ec048dc6a7d58078 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Wed, 20 May 2020 00:02:24 -0700 Subject: [PATCH 16/44] Add upload action for dev branch --- .github/workflows/upload.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/upload.yaml diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml new file mode 100644 index 0000000..98da006 --- /dev/null +++ b/.github/workflows/upload.yaml @@ -0,0 +1,28 @@ +name: "Build and upload artifact" +on: + push: + branches: + - 'dev' +defaults: + run: + shell: bash + working-directory: $GITHUB_WORKSPACE +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: "Checkout and build repository" + uses: actions/checkout@v2 + - name: "Build JAR with gradle wrapper" + uses: OrangeLabs-moe/gradle-actions@v5.0-openjdk-8 + with: + args: shadowJar + upload: + needs: build + runs-on: ubuntu-latest + steps: + uses: actions/upload-artifact@v1 + with: + name: BreedablePets + path: $GITHUB_WORKSPACE/build/libs/BreedablePets.jar + From 0f674df9b814f5b31780ea3bd8811158d52a9240 Mon Sep 17 00:00:00 2001 From: Richard Simpson <39318657+Magnum97@users.noreply.github.com> Date: Wed, 20 May 2020 00:05:45 -0700 Subject: [PATCH 17/44] Fix workflow formatting --- .github/workflows/upload.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index 98da006..807457a 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -21,7 +21,7 @@ jobs: needs: build runs-on: ubuntu-latest steps: - uses: actions/upload-artifact@v1 + - uses: actions/upload-artifact@v1 with: name: BreedablePets path: $GITHUB_WORKSPACE/build/libs/BreedablePets.jar From 3b6506e3049b8128499b0dcbb44f835e59df13e8 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Wed, 20 May 2020 00:11:52 -0700 Subject: [PATCH 18/44] Change gradle action --- .github/workflows/upload.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index 807457a..7cfffc1 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -16,7 +16,7 @@ jobs: - name: "Build JAR with gradle wrapper" uses: OrangeLabs-moe/gradle-actions@v5.0-openjdk-8 with: - args: shadowJar + args: build upload: needs: build runs-on: ubuntu-latest From 583f47afa113d70c55a4fda71f971a9bc2c90828 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Wed, 20 May 2020 00:27:22 -0700 Subject: [PATCH 19/44] Change Lightning Storage dependency --- build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 184dfb2..79e6fca 100644 --- a/build.gradle +++ b/build.gradle @@ -32,7 +32,8 @@ repositories { dependencies { compileOnly spigot('1.15.2') implementation 'fr.mrmicky:FastParticles:1.2.0' - implementation files ('/home/rich/.m2/repository/com/github/javafactorydev/lightningstorage/3.1.1-SNAPSHOT/lightningstorage-3.1.1-SNAPSHOT.jar') +// implementation files ('/home/rich/.m2/repository/com/github/javafactorydev/lightningstorage/3.1.1-SNAPSHOT/lightningstorage-3.1.1-SNAPSHOT.jar') + implementation 'com.github.Magnum97:LightningStorage:frame-header-SNAPSHOT' // implementation 'com.github.JavaFactoryDev:LightningStorage:3.1.1-SNAPSHOT' implementation "co.aikar:acf-bukkit:0.5.0-SNAPSHOT" // implementation 'com.github.kangarko:Foundation:5.3.8@jar' // Kangerko's Foundation library From 93e1d8eb58f9b69e931b01fc6b3833deeb586412 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Wed, 20 May 2020 00:35:11 -0700 Subject: [PATCH 20/44] Remove env var from upload flow --- .github/workflows/upload.yaml | 2 +- src/main/java/me/magnum/Breedable.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index 7cfffc1..69f5d9a 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -24,5 +24,5 @@ jobs: - uses: actions/upload-artifact@v1 with: name: BreedablePets - path: $GITHUB_WORKSPACE/build/libs/BreedablePets.jar + path: build/libs/BreedablePets.jar diff --git a/src/main/java/me/magnum/Breedable.java b/src/main/java/me/magnum/Breedable.java index 1d914c8..d33793e 100644 --- a/src/main/java/me/magnum/Breedable.java +++ b/src/main/java/me/magnum/Breedable.java @@ -29,7 +29,6 @@ import de.leonhard.storage.Yaml; import de.leonhard.storage.sections.FlatFileSection; import lombok.Getter; -import lombok.SneakyThrows; import me.magnum.breedablepets.Command; import me.magnum.breedablepets.listeners.BreedListener; import me.magnum.breedablepets.listeners.EggListener; From e2fb45ea14f39835156b86f092d5af68d6a59e4c Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Wed, 20 May 2020 00:41:48 -0700 Subject: [PATCH 21/44] Remove extra job Eventually I will understand github actions! ^_^ --- .github/workflows/upload.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index 69f5d9a..497d65c 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -17,10 +17,6 @@ jobs: uses: OrangeLabs-moe/gradle-actions@v5.0-openjdk-8 with: args: build - upload: - needs: build - runs-on: ubuntu-latest - steps: - uses: actions/upload-artifact@v1 with: name: BreedablePets From 0ba46dcb8b29be016edb15495cdd9e6395ae8f27 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Wed, 20 May 2020 00:48:54 -0700 Subject: [PATCH 22/44] Change upload path --- .github/workflows/upload.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index 497d65c..6eeeda4 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -18,7 +18,8 @@ jobs: with: args: build - uses: actions/upload-artifact@v1 + - name: "Upload artifact" with: name: BreedablePets - path: build/libs/BreedablePets.jar + path: build/libs/ From 91a08e1a4af4bd5a4da339aee2b2cc2e78d4822d Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Wed, 20 May 2020 00:50:13 -0700 Subject: [PATCH 23/44] Fix Picky YAML --- .github/workflows/upload.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index 6eeeda4..5f36231 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -17,8 +17,8 @@ jobs: uses: OrangeLabs-moe/gradle-actions@v5.0-openjdk-8 with: args: build - - uses: actions/upload-artifact@v1 - name: "Upload artifact" + - uses: actions/upload-artifact@v1 with: name: BreedablePets path: build/libs/ From 2222644b35897da16a95dd71c16b652d427df7fb Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Wed, 20 May 2020 00:53:38 -0700 Subject: [PATCH 24/44] Maybe this time --- .github/workflows/upload.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index 5f36231..91648ac 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -11,15 +11,16 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: "Checkout and build repository" + - name: "Checkout repository" uses: actions/checkout@v2 - - name: "Build JAR with gradle wrapper" + + - name: "Build project" uses: OrangeLabs-moe/gradle-actions@v5.0-openjdk-8 with: args: build + - name: "Upload artifact" - - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v1 with: - name: BreedablePets + name: rc-jars path: build/libs/ - From b04147c888cc486176f6bd690e351374044bd71e Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 22 May 2020 00:18:01 -0700 Subject: [PATCH 25/44] Rename artifact uploaded from build test --- .github/workflows/upload.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index 91648ac..b4ec5b2 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -22,5 +22,5 @@ jobs: - name: "Upload artifact" uses: actions/upload-artifact@v1 with: - name: rc-jars + name: BreedablePets-JAR path: build/libs/ From 687e85659565f35aafc62cb0310af88deed9e6f7 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 22 May 2020 00:20:34 -0700 Subject: [PATCH 26/44] Only create release if build succeeds --- .github/workflows/create-release.yaml | 33 +++++++++++++++------------ 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 089deb0..9032145 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -18,17 +18,22 @@ jobs: uses: OrangeLabs-moe/gradle-actions@v5.0-openjdk-8 with: args: build - - uses: meeDamian/github-release@2.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - body: | - Changelog for ${{ steps.get_version.outputs.VERSION }} : - * Change Materials to match Minecraft 1.15 - * Integrated code from local API - * Add workflows for issue and release creation. - * Refactored main class - * Change how plugin watches for eggs to hatch - * Change ProjectileHitEvent: getBlock location -> getEnttity location - * Changed Config library to Lightning Storage - files: build/libs/BreedablePets.jar - gzip: folders + release: + needs: build + runs-on: ubuntu-latest + steps: + - uses: meeDamian/github-release@2.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + body: | + Changelog for ${{ steps.get_version.outputs.VERSION }} : + * Change Materials to match Minecraft 1.15 + * Integrated code from local API + * Add workflows for issue and release creation. + * Refactored main class + * Change how plugin watches for eggs to hatch + * Change ProjectileHitEvent: getBlock location -> getEnttity location + * Changed Config library to Lightning Storage + files: build/libs/BreedablePets.jar + gzip: folders + From a0f7a2d927dd8d7f1d26cd85037e19b37fd2e4ab Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 22 May 2020 00:25:32 -0700 Subject: [PATCH 27/44] Make upload depend on build --- .github/workflows/upload.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index b4ec5b2..8d446c6 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -18,7 +18,10 @@ jobs: uses: OrangeLabs-moe/gradle-actions@v5.0-openjdk-8 with: args: build - + upload: + needs: build + runs-on: ubuntu-latest + steps: - name: "Upload artifact" uses: actions/upload-artifact@v1 with: From 4ff455364a24beb74a806c27d9035637d340cc48 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 22 May 2020 00:29:29 -0700 Subject: [PATCH 28/44] Remove unused files --- MethodTest/.idea/artifacts/MethodTest_jar.xml | 8 -------- MethodTest/.idea/vcs.xml | 6 ------ 2 files changed, 14 deletions(-) delete mode 100644 MethodTest/.idea/artifacts/MethodTest_jar.xml delete mode 100644 MethodTest/.idea/vcs.xml diff --git a/MethodTest/.idea/artifacts/MethodTest_jar.xml b/MethodTest/.idea/artifacts/MethodTest_jar.xml deleted file mode 100644 index fb455c6..0000000 --- a/MethodTest/.idea/artifacts/MethodTest_jar.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - $PROJECT_DIR$/out/artifacts - - - - - \ No newline at end of file diff --git a/MethodTest/.idea/vcs.xml b/MethodTest/.idea/vcs.xml deleted file mode 100644 index 6c0b863..0000000 --- a/MethodTest/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 61453de2dfe054fcf7152ab20d6b838435bac458 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 22 May 2020 00:32:57 -0700 Subject: [PATCH 29/44] Fix workflow indentation --- .github/workflows/create-release.yaml | 32 +++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 9032145..d8f0943 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -20,20 +20,20 @@ jobs: args: build release: needs: build - runs-on: ubuntu-latest - steps: - - uses: meeDamian/github-release@2.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - body: | - Changelog for ${{ steps.get_version.outputs.VERSION }} : - * Change Materials to match Minecraft 1.15 - * Integrated code from local API - * Add workflows for issue and release creation. - * Refactored main class - * Change how plugin watches for eggs to hatch - * Change ProjectileHitEvent: getBlock location -> getEnttity location - * Changed Config library to Lightning Storage - files: build/libs/BreedablePets.jar - gzip: folders + runs-on: ubuntu-latest + steps: + - uses: meeDamian/github-release@2.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + body: | + Changelog for ${{ steps.get_version.outputs.VERSION }} : + * Change Materials to match Minecraft 1.15 + * Integrated code from local API + * Add workflows for issue and release creation. + * Refactored main class + * Change how plugin watches for eggs to hatch + * Change ProjectileHitEvent: getBlock location -> getEnttity location + * Changed Config library to Lightning Storage + files: build/libs/BreedablePets.jar + gzip: folders From 4c25146ba70280470c00efd47ba69bdc58ca8713 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 22 May 2020 00:35:57 -0700 Subject: [PATCH 30/44] Give all workflows names --- .github/workflows/create-release.yaml | 2 +- .github/workflows/todo-issue.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index d8f0943..2a36248 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -1,6 +1,6 @@ # This workflow will create a release on v-tag push -name: Create release +name: "Create release" on: push: # Sequence of patterns matched against refs/tags diff --git a/.github/workflows/todo-issue.yaml b/.github/workflows/todo-issue.yaml index 486ed00..a856fe0 100644 --- a/.github/workflows/todo-issue.yaml +++ b/.github/workflows/todo-issue.yaml @@ -1,4 +1,4 @@ -name: "Workflow" +name: "Manage TODO <-> Issue" on: ["push"] jobs: yaml-to-list: From 851f4be48aa323bc9a3d0a1af1126c5e4e2011cc Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 22 May 2020 00:55:48 -0700 Subject: [PATCH 31/44] Add default Gradle tasks --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index 79e6fca..7dd2815 100644 --- a/build.gradle +++ b/build.gradle @@ -39,6 +39,7 @@ dependencies { // implementation 'com.github.kangarko:Foundation:5.3.8@jar' // Kangerko's Foundation library } +defaultTasks 'clean', 'build' compileJava { options.compilerArgs += ["-parameters"] options.fork = true From 1fe66424e01bbd34d63f0248af1ebab25c7e8412 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 22 May 2020 00:56:19 -0700 Subject: [PATCH 32/44] Add tag/ref to artifact archive --- .github/workflows/upload.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index 8d446c6..2f4dd53 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -11,7 +11,11 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: "Checkout repository" + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + + - name: "Checkout repository" uses: actions/checkout@v2 - name: "Build project" @@ -25,5 +29,5 @@ jobs: - name: "Upload artifact" uses: actions/upload-artifact@v1 with: - name: BreedablePets-JAR + name: BreedablePets-${{ steps.get_version.outputs.VERSION }} path: build/libs/ From b0c3148d094176d55e039c4b872ff7e87fadf28f Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 22 May 2020 01:07:20 -0700 Subject: [PATCH 33/44] Change github action for upload Remove version from JAR making name static --- .github/workflows/create-release.yaml | 9 +++++---- .github/workflows/upload.yaml | 25 +++++++++++-------------- build.gradle | 1 + 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 2a36248..3d92568 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -14,10 +14,11 @@ jobs: id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - uses: actions/checkout@v2 - - name: Build project - uses: OrangeLabs-moe/gradle-actions@v5.0-openjdk-8 - with: - args: build + + - name: Generate the artifacts + uses: skx/github-action-build@master + args: ./gradlew + release: needs: build runs-on: ubuntu-latest diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index 2f4dd53..87c6b8f 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -15,19 +15,16 @@ jobs: id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - - name: "Checkout repository" - uses: actions/checkout@v2 + - name: Checkout the repository + uses: actions/checkout@master - - name: "Build project" - uses: OrangeLabs-moe/gradle-actions@v5.0-openjdk-8 - with: - args: build - upload: - needs: build - runs-on: ubuntu-latest - steps: - - name: "Upload artifact" - uses: actions/upload-artifact@v1 + - name: Generate the artifacts + uses: skx/github-action-build@master + args: ./gradlew + + - name: Upload the artifacts + uses: skx/github-action-publish-binaries@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - name: BreedablePets-${{ steps.get_version.outputs.VERSION }} - path: build/libs/ + args: 'build/libs/BreedablePets.jar' diff --git a/build.gradle b/build.gradle index 7dd2815..600cfd4 100644 --- a/build.gradle +++ b/build.gradle @@ -53,6 +53,7 @@ task relocateShadowJar(type: ConfigureShadowRelocation) { tasks.shadowJar.dependsOn tasks.relocateShadowJar shadowJar { classifier = null // remove -all from end of jar + version = null } spigot { authors = ['Magnum1997'] From 30a2b56c943b9b95eb6196678b5c1fc098436ec0 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 22 May 2020 01:12:22 -0700 Subject: [PATCH 34/44] Curse syntax errors --- .github/workflows/create-release.yaml | 4 ++-- .github/workflows/upload.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 3d92568..3d8926d 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -17,8 +17,8 @@ jobs: - name: Generate the artifacts uses: skx/github-action-build@master - args: ./gradlew - + args: './gradlew' + release: needs: build runs-on: ubuntu-latest diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index 87c6b8f..605d202 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -20,7 +20,7 @@ jobs: - name: Generate the artifacts uses: skx/github-action-build@master - args: ./gradlew + args: './gradlew' - name: Upload the artifacts uses: skx/github-action-publish-binaries@master From ed2a073f6aafeed5300e1fe4b64f5174155c200c Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 22 May 2020 01:16:38 -0700 Subject: [PATCH 35/44] More cursing at syntax --- .github/workflows/create-release.yaml | 3 ++- .github/workflows/upload.yaml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 3d8926d..cf2ee71 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -17,7 +17,8 @@ jobs: - name: Generate the artifacts uses: skx/github-action-build@master - args: './gradlew' + with: + builder: './gradlew' release: needs: build diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index 605d202..95c3e78 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -20,7 +20,8 @@ jobs: - name: Generate the artifacts uses: skx/github-action-build@master - args: './gradlew' + with: + builder: './gradlew' - name: Upload the artifacts uses: skx/github-action-publish-binaries@master From 20ce3de815ded8f554c4cb9a682302847c975573 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 22 May 2020 01:21:16 -0700 Subject: [PATCH 36/44] Remove unnecessary workflow steps --- .github/workflows/upload.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index 95c3e78..372bb15 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -11,9 +11,9 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} +# - name: Get the version +# id: get_version +# run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - name: Checkout the repository uses: actions/checkout@master From 15f1d7e4d7186ddd21c11187b08295d7105cd719 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 22 May 2020 01:27:46 -0700 Subject: [PATCH 37/44] Add setup Java action to workflow --- .github/workflows/create-release.yaml | 5 +++++ .github/workflows/upload.yaml | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index cf2ee71..e321061 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -15,6 +15,11 @@ jobs: run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - uses: actions/checkout@v2 + - name: Setup Java + used: actions/setup-java@v1 + with: + java-version: 8 + - name: Generate the artifacts uses: skx/github-action-build@master with: diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index 372bb15..c5e5be7 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -11,13 +11,15 @@ jobs: build: runs-on: ubuntu-latest steps: -# - name: Get the version -# id: get_version -# run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - name: Checkout the repository uses: actions/checkout@master + - name: Setup Java + used: actions/setup-java@v1 + with: + java-version: 8 + - name: Generate the artifacts uses: skx/github-action-build@master with: From a3b00ae699d26742978cf0c469db728db3e3606b Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 22 May 2020 01:30:04 -0700 Subject: [PATCH 38/44] Fix workflow typo --- .github/workflows/create-release.yaml | 2 +- .github/workflows/upload.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index e321061..41823b3 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v2 - name: Setup Java - used: actions/setup-java@v1 + uses: actions/setup-java@v1 with: java-version: 8 diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index c5e5be7..92f1963 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@master - name: Setup Java - used: actions/setup-java@v1 + uses: actions/setup-java@v1 with: java-version: 8 From 34fc42ce51f51f57a108e35e2a15d44d39d20615 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 22 May 2020 01:38:13 -0700 Subject: [PATCH 39/44] KISS - Simplify workflow --- .github/workflows/upload.yaml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index 92f1963..75d9a00 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -11,19 +11,17 @@ jobs: build: runs-on: ubuntu-latest steps: - - - name: Checkout the repository - uses: actions/checkout@master - - - name: Setup Java + - uses: actions/checkout@v2 + - name: Set up JDK 1.8 uses: actions/setup-java@v1 with: - java-version: 8 + java-version: 1.8 - - name: Generate the artifacts - uses: skx/github-action-build@master - with: - builder: './gradlew' + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew build - name: Upload the artifacts uses: skx/github-action-publish-binaries@master From 11ec6c0d61cb61fc527a274cb5a255dd93a6c165 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 5 Jun 2020 22:17:23 -0700 Subject: [PATCH 40/44] Rename workflows --- .github/workflows/{upload.yaml => CI-Test.yaml} | 0 .github/workflows/{create-release.yaml => do-release.yaml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{upload.yaml => CI-Test.yaml} (100%) rename .github/workflows/{create-release.yaml => do-release.yaml} (100%) diff --git a/.github/workflows/upload.yaml b/.github/workflows/CI-Test.yaml similarity index 100% rename from .github/workflows/upload.yaml rename to .github/workflows/CI-Test.yaml diff --git a/.github/workflows/create-release.yaml b/.github/workflows/do-release.yaml similarity index 100% rename from .github/workflows/create-release.yaml rename to .github/workflows/do-release.yaml From c628c4718b9a083a49325757f72c38f7ab773c5f Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 5 Jun 2020 22:41:19 -0700 Subject: [PATCH 41/44] Re-write workflows Slight changes to CI-Test Major re-write of do-release --- .github/workflows/CI-Test.yaml | 35 ++++++++++++------------ .github/workflows/do-release.yaml | 44 +++++++++++++++---------------- build.gradle | 1 - 3 files changed, 39 insertions(+), 41 deletions(-) diff --git a/.github/workflows/CI-Test.yaml b/.github/workflows/CI-Test.yaml index 75d9a00..901543a 100644 --- a/.github/workflows/CI-Test.yaml +++ b/.github/workflows/CI-Test.yaml @@ -1,31 +1,30 @@ -name: "Build and upload artifact" +name: CI Test + on: push: - branches: - - 'dev' -defaults: - run: - shell: bash - working-directory: $GITHUB_WORKSPACE + branches: [ dev ] + pull_request: + branches: [ master, dev ] + jobs: - build: + check: runs-on: ubuntu-latest steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 + - name: Set up JDK 1.8 uses: actions/setup-java@v1 with: java-version: 1.8 - - name: Grant execute permission for gradlew run: chmod +x gradlew + - name: Gradle build task + run: ./gradlew check - - name: Build with Gradle - run: ./gradlew build - - - name: Upload the artifacts - uses: skx/github-action-publish-binaries@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - args: 'build/libs/BreedablePets.jar' +# - name: Upload artifact +# uses: actions/upload-artifact@v2 +# with: +# name: Archive +# path: build/libs/actions-test-1.0-SNAPSHOT.jar +# diff --git a/.github/workflows/do-release.yaml b/.github/workflows/do-release.yaml index 41823b3..cb66152 100644 --- a/.github/workflows/do-release.yaml +++ b/.github/workflows/do-release.yaml @@ -1,37 +1,38 @@ -# This workflow will create a release on v-tag push +# This work flow will build project with Gradle wrapper, +# create a release, and upload contents of ./build/libs/ +# to the release. +name: Create or update release -name: "Create release" on: push: - # Sequence of patterns matched against refs/tags - tags: - - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + branches: [ release ] + jobs: build: runs-on: ubuntu-latest steps: - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - uses: actions/checkout@v2 - - name: Setup Java - uses: actions/setup-java@v1 - with: - java-version: 8 + - name: Get version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF#refs/heads/release/} - - name: Generate the artifacts - uses: skx/github-action-build@master + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 with: - builder: './gradlew' + java-version: 1.8 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Gradle build task + run: ./gradlew build - release: - needs: build - runs-on: ubuntu-latest - steps: - - uses: meeDamian/github-release@2.0 + - name: Create release, update, and upload assets + uses: meeDamian/github-release@v2.0.1 with: token: ${{ secrets.GITHUB_TOKEN }} + prerelease: true + draft: true + allow_override: true body: | Changelog for ${{ steps.get_version.outputs.VERSION }} : * Change Materials to match Minecraft 1.15 @@ -41,6 +42,5 @@ jobs: * Change how plugin watches for eggs to hatch * Change ProjectileHitEvent: getBlock location -> getEnttity location * Changed Config library to Lightning Storage - files: build/libs/BreedablePets.jar + files: build/libs/* gzip: folders - diff --git a/build.gradle b/build.gradle index 600cfd4..7dd2815 100644 --- a/build.gradle +++ b/build.gradle @@ -53,7 +53,6 @@ task relocateShadowJar(type: ConfigureShadowRelocation) { tasks.shadowJar.dependsOn tasks.relocateShadowJar shadowJar { classifier = null // remove -all from end of jar - version = null } spigot { authors = ['Magnum1997'] From aca9985d55fed612cbe7130ce288ec66e088f367 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Fri, 5 Jun 2020 23:58:05 -0700 Subject: [PATCH 42/44] Change release branch name --- .github/workflows/do-release.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/do-release.yaml b/.github/workflows/do-release.yaml index cb66152..15b2bec 100644 --- a/.github/workflows/do-release.yaml +++ b/.github/workflows/do-release.yaml @@ -5,7 +5,8 @@ name: Create or update release on: push: - branches: [ release ] + branches: + - 'release*' jobs: build: From e53a934e0f1890169315278b55d67ca9ae6bb198 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Sat, 6 Jun 2020 00:11:14 -0700 Subject: [PATCH 43/44] Fix action --- .github/workflows/do-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/do-release.yaml b/.github/workflows/do-release.yaml index 15b2bec..1ca7a36 100644 --- a/.github/workflows/do-release.yaml +++ b/.github/workflows/do-release.yaml @@ -6,7 +6,7 @@ name: Create or update release on: push: branches: - - 'release*' + - 'release/**' jobs: build: From 4249d9ff0fd2816cbcf0c65a15cdb1742d58dff2 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Sat, 6 Jun 2020 00:14:32 -0700 Subject: [PATCH 44/44] Add release tag --- .github/workflows/do-release.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/do-release.yaml b/.github/workflows/do-release.yaml index 1ca7a36..ef5cde3 100644 --- a/.github/workflows/do-release.yaml +++ b/.github/workflows/do-release.yaml @@ -30,6 +30,7 @@ jobs: - name: Create release, update, and upload assets uses: meeDamian/github-release@v2.0.1 with: + tag: ${{ steps.get_version.outputs.VERSION }} token: ${{ secrets.GITHUB_TOKEN }} prerelease: true draft: true