Compare commits

..

9 Commits

Author SHA1 Message Date
hyperdefined
71f3a3ea10 Update ToolStats.java 2025-03-27 22:01:54 -04:00
hyperdefined
3f850aaef7 Merge pull request #96 from sebampuero/fix-unhandled-githubrelease-exception
Fix: catch unhandled exception when version does not exist yet
2025-03-27 21:49:04 -04:00
hyperdefined
427628da6e Merge pull request #92 from hyperdefined/dependabot/maven/org.apache.maven.plugins-maven-clean-plugin-3.4.1
Bump org.apache.maven.plugins:maven-clean-plugin from 3.4.0 to 3.4.1
2025-03-27 21:45:30 -04:00
hyperdefined
820c1dce51 Merge pull request #93 from hyperdefined/dependabot/maven/org.apache.maven.plugins-maven-compiler-plugin-3.14.0
Bump org.apache.maven.plugins:maven-compiler-plugin from 3.13.0 to 3.14.0
2025-03-27 21:44:10 -04:00
sebampuero
ad1a4fe26e fix: catch unhandled exception when version does not exist yet 2025-03-15 16:00:00 +01:00
dependabot[bot]
ceb1dbd297 Bump org.apache.maven.plugins:maven-compiler-plugin
Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.13.0 to 3.14.0.
- [Release notes](https://github.com/apache/maven-compiler-plugin/releases)
- [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.13.0...maven-compiler-plugin-3.14.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-compiler-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-21 11:03:35 +00:00
dependabot[bot]
49f4727100 Bump org.apache.maven.plugins:maven-clean-plugin from 3.4.0 to 3.4.1
Bumps [org.apache.maven.plugins:maven-clean-plugin](https://github.com/apache/maven-clean-plugin) from 3.4.0 to 3.4.1.
- [Release notes](https://github.com/apache/maven-clean-plugin/releases)
- [Commits](https://github.com/apache/maven-clean-plugin/compare/maven-clean-plugin-3.4.0...maven-clean-plugin-3.4.1)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-clean-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-19 12:50:38 +00:00
hyperdefined
cb5345bd14 1.9.2-hotfix-2 2025-02-15 13:10:39 -05:00
hyperdefined
eeb6038b66 1.9.2-hotfix 2025-02-11 15:57:49 -05:00
7 changed files with 57 additions and 23 deletions

View File

@@ -23,7 +23,7 @@
<groupId>lol.hyper</groupId>
<artifactId>toolstats</artifactId>
<version>1.9.2</version>
<version>1.9.3</version>
<packaging>jar</packaging>
<name>ToolStats</name>
@@ -37,7 +37,7 @@
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
<version>3.4.1</version>
<executions>
<execution>
<id>auto-clean</id>
@@ -51,7 +51,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<version>3.14.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>

View File

@@ -19,6 +19,7 @@ package lol.hyper.toolstats;
import lol.hyper.githubreleaseapi.GitHubRelease;
import lol.hyper.githubreleaseapi.GitHubReleaseAPI;
import lol.hyper.githubreleaseapi.ReleaseNotFoundException;
import lol.hyper.toolstats.commands.CommandToolStats;
import lol.hyper.toolstats.events.*;
import lol.hyper.toolstats.tools.*;
@@ -251,12 +252,14 @@ public final class ToolStats extends JavaPlugin {
e.printStackTrace();
return;
}
GitHubRelease current = api.getReleaseByTag(this.getPluginMeta().getVersion());
GitHubRelease latest = api.getLatestVersion();
if (current == null) {
GitHubRelease current;
try {
current = api.getReleaseByTag(this.getPluginMeta().getVersion());
} catch (ReleaseNotFoundException e) {
logger.warning("You are running a version that does not exist on GitHub. If you are in a dev environment, you can ignore this. Otherwise, this is a bug!");
return;
}
GitHubRelease latest = api.getLatestVersion();
int buildsBehind = api.getBuildsBehind(current);
if (buildsBehind == 0) {
logger.info("You are running the latest version.");

View File

@@ -19,6 +19,7 @@ package lol.hyper.toolstats.events;
import lol.hyper.toolstats.ToolStats;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@@ -119,17 +120,32 @@ public class EntityDamage implements Listener {
return;
}
boolean isMain = shootingPlayerInventory.getItemInMainHand().getType() == Material.BOW || shootingPlayerInventory.getItemInMainHand().getType() == Material.CROSSBOW;
boolean isOffHand = shootingPlayerInventory.getItemInOffHand().getType() == Material.BOW || shootingPlayerInventory.getItemInOffHand().getType() == Material.CROSSBOW;
// player is shooting another player
if (mobBeingAttacked instanceof Player) {
ItemMeta newItem = toolStats.itemLore.updatePlayerKills(heldBow, 1);
if (newItem != null) {
shootingPlayerInventory.getItemInMainHand().setItemMeta(newItem);
ItemMeta newBow = toolStats.itemLore.updatePlayerKills(heldBow, 1);
if (newBow != null) {
if (isMain && isOffHand) {
shootingPlayerInventory.getItemInMainHand().setItemMeta(newBow);
} else if (isMain) {
shootingPlayerInventory.getItemInMainHand().setItemMeta(newBow);
} else if (isOffHand) {
shootingPlayerInventory.getItemInOffHand().setItemMeta(newBow);
}
}
} else {
// player is shooting a mob
ItemMeta newItem = toolStats.itemLore.updateMobKills(heldBow, 1);
if (newItem != null) {
shootingPlayerInventory.getItemInMainHand().setItemMeta(newItem);
ItemMeta newBow = toolStats.itemLore.updateMobKills(heldBow, 1);
if (newBow != null) {
if (isMain && isOffHand) {
shootingPlayerInventory.getItemInMainHand().setItemMeta(newBow);
} else if (isMain) {
shootingPlayerInventory.getItemInMainHand().setItemMeta(newBow);
} else if (isOffHand) {
shootingPlayerInventory.getItemInOffHand().setItemMeta(newBow);
}
}
trackedMobs.add(mobBeingAttacked.getUniqueId());
}

View File

@@ -72,7 +72,9 @@ public class PlayerFish implements Listener {
PlayerInventory inventory = player.getInventory();
boolean isMain = inventory.getItemInMainHand().getType() == Material.FISHING_ROD;
boolean isOffHand = inventory.getItemInOffHand().getType() == Material.FISHING_ROD;
if (isMain) {
if (isMain && isOffHand) {
inventory.getItemInMainHand().setItemMeta(newFishingRod);
} else if (isMain) {
inventory.getItemInMainHand().setItemMeta(newFishingRod);
} else if (isOffHand) {
inventory.getItemInOffHand().setItemMeta(newFishingRod);

View File

@@ -65,15 +65,17 @@ public class SheepShear implements Listener {
}
// update the stats
ItemMeta newItem = toolStats.itemLore.updateSheepSheared(heldShears, 1);
if (newItem != null) {
ItemMeta newShears = toolStats.itemLore.updateSheepSheared(heldShears, 1);
if (newShears != null) {
PlayerInventory inventory = player.getInventory();
boolean isMain = inventory.getItemInMainHand().getType() == Material.SHEARS;
boolean isOffHand = inventory.getItemInOffHand().getType() == Material.SHEARS;
if (isMain) {
inventory.getItemInMainHand().setItemMeta(newItem);
if (isMain && isOffHand) {
inventory.getItemInMainHand().setItemMeta(newShears);
} else if (isMain) {
inventory.getItemInMainHand().setItemMeta(newShears);
} else if (isOffHand) {
inventory.getItemInOffHand().setItemMeta(newItem);
inventory.getItemInOffHand().setItemMeta(newShears);
}
}
}

View File

@@ -56,15 +56,17 @@ public class ShootBow implements Listener {
return;
}
ItemMeta newItem = toolStats.itemLore.updateArrowsShot(heldBow, 1);
if (newItem != null) {
ItemMeta newBow = toolStats.itemLore.updateArrowsShot(heldBow, 1);
if (newBow != null) {
PlayerInventory inventory = player.getInventory();
boolean isMain = inventory.getItemInMainHand().getType() == Material.BOW || inventory.getItemInMainHand().getType() == Material.CROSSBOW;
boolean isOffHand = inventory.getItemInOffHand().getType() == Material.BOW || inventory.getItemInOffHand().getType() == Material.CROSSBOW;
if (isMain) {
inventory.getItemInMainHand().setItemMeta(newItem);
if (isMain && isOffHand) {
inventory.getItemInMainHand().setItemMeta(newBow);
} else if (isMain) {
inventory.getItemInMainHand().setItemMeta(newBow);
} else if (isOffHand) {
inventory.getItemInOffHand().setItemMeta(newItem);
inventory.getItemInOffHand().setItemMeta(newBow);
}
}
}

View File

@@ -220,6 +220,9 @@ public class ItemChecker {
// if the player is holding a bow in their main hand, use that one
// if the bow is in their offhand instead, use that one after checking main hand
// Minecraft prioritizes main hand if the player holds in both hands
if (isMain && isOffHand) {
return main;
}
if (isMain) {
return main;
}
@@ -246,6 +249,9 @@ public class ItemChecker {
// if the player is holding shears in their main hand, use that one
// if the shears are in their offhand instead, use that one after checking main hand
// Minecraft prioritizes main hand if the player holds in both hands
if (isMain && isOffHand) {
return main;
}
if (isMain) {
return main;
}
@@ -272,6 +278,9 @@ public class ItemChecker {
// if the player is holding a fishing rod in their main hand, use that one
// if the fishing rod is in their offhand instead, use that one after checking main hand
// Minecraft prioritizes main hand if the player holds in both hands
if (isMain && isOffHand) {
return main;
}
if (isMain) {
return main;
}