diff --git a/.gitignore b/.gitignore index 460434d..8dd6654 100644 --- a/.gitignore +++ b/.gitignore @@ -115,4 +115,11 @@ run/ */target/* -.gradle \ No newline at end of file +.gradle + +.project +.settings/* +bin +.classpath +!gradle-wrapper.jar +build \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 843b369..3438d3b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,19 +3,19 @@ plugins { `java-library` `maven-publish` kotlin("jvm") version "2.2.0" - id("com.gradleup.shadow") version "8.3.8" + id("com.gradleup.shadow") version "9.2.2" id("xyz.jpenilla.run-paper") version "2.3.1" } group = "com.github.nutt1101" -version = "2.1.1" +version = "2.1.2" description = "CatchBall" java.sourceCompatibility = JavaVersion.VERSION_21 repositories { mavenLocal() maven { - url = uri("https://repo.destroystokyo.com/repository/maven-public//") + url = uri("https://repo.destroystokyo.com/repository/maven-public/") } maven { @@ -39,7 +39,7 @@ repositories { } maven { - url = uri("https://repo.jeff-media.com/public/") + url = uri("https://repo.papermc.io/repository/maven-public/") } maven { @@ -59,18 +59,17 @@ repositories { dependencies { api("org.bstats:bstats-bukkit:3.1.0") - api("com.jeff_media:SpigotUpdateChecker:3.0.4") - api("de.tr7zw:item-nbt-api:2.15.1") + api("de.tr7zw:item-nbt-api:2.15.5") api("cn.handyplus.lib.adapter:FoliaLib:1.2.1") api("com.tchristofferson:ConfigUpdater:2.2-SNAPSHOT") - compileOnly("org.spigotmc:spigot-api:1.20.5-R0.1-SNAPSHOT") + compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT") compileOnly("io.lumine:Mythic-Dist:5.9.0") compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.14") compileOnly("com.github.TechFortress:GriefPrevention:17.0.0") compileOnly("com.github.angeschossen:LandsAPI:7.15.4") compileOnly("com.github.Xyness:SimpleClaimSystem:1.12.3.2") compileOnly("me.clip:placeholderapi:2.11.6") - compileOnly("com.palmergames.bukkit.towny:towny:0.101.1.14") + compileOnly("com.palmergames.bukkit.towny:towny:0.101.2.6") compileOnly ("io.github.fabiozumbi12.RedProtect:RedProtect-Core:8.1.2"){ exclude(group = "*")} // Core is not needed but allow access to all region methods compileOnly ("io.github.fabiozumbi12.RedProtect:RedProtect-Spigot:8.1.2"){ exclude(group = "*")} compileOnly(files("./libs/Residence5.1.7.5.jar")) @@ -118,7 +117,7 @@ tasks.jar { } tasks.runServer { - minecraftVersion("1.21.7") + minecraftVersion("1.21.10") } runPaper.folia.registerTask() diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index eaf3e62..accb301 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,7 +9,7 @@ com-github-techfortress-griefprevention = "17.0.0" com-github-xyness-simpleclaimsystem = "1.12.3.2" com-jeff-media-spigotupdatechecker = "3.0.4" com-sk89q-worldguard-worldguard-bukkit = "7.0.14" -de-tr7zw-item-nbt-api = "2.15.0" +de-tr7zw-item-nbt-api = "2.15.1" io-lumine-mythic-dist = "5.9.0" me-clip-placeholderapi = "2.11.6" org-bstats-bstats-bukkit = "3.1.0" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f8e1ee3 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ff23a68..23449a2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 23d15a9..adff685 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -114,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -172,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -212,7 +210,6 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" diff --git a/gradlew.bat b/gradlew.bat index db3a6ac..c4bdd3a 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -70,11 +70,10 @@ goto fail :execute @rem Setup the command line -set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell diff --git a/src/main/java/com/github/nutt1101/event/GUIClick.java b/src/main/java/com/github/nutt1101/event/GUIClick.java index 713a0fa..900f36e 100644 --- a/src/main/java/com/github/nutt1101/event/GUIClick.java +++ b/src/main/java/com/github/nutt1101/event/GUIClick.java @@ -56,13 +56,14 @@ public void guiClick(InventoryClickEvent event) { EntityType entityType = EntityType.valueOf(ChatColor.stripColor(clickItem.getItemMeta().getDisplayName())); int loreIndex = getLoreIndex(lore, "{CATCHABLE}"); - if (ConfigSetting.catchableEntity.contains(entityType)) { - ConfigSetting.catchableEntity.remove(entityType); + String entityName = ChatColor.stripColor(clickItem.getItemMeta().getDisplayName()); + if (ConfigSetting.catchableEntity.contains(entityName)) { + ConfigSetting.catchableEntity.remove(entityName); lore.set(loreIndex, ChatColor.translateAlternateColorCodes('&', ConfigSetting. toChat(TranslationFileReader.guiSkullLore.get(loreIndex), "", "").replace("{CATCHABLE}", "&cFALSE"))); } else { - ConfigSetting.catchableEntity.add(String.valueOf(entityType)); + ConfigSetting.catchableEntity.add(entityName); lore.set(loreIndex, ChatColor.translateAlternateColorCodes('&', ConfigSetting. toChat(TranslationFileReader.guiSkullLore.get(loreIndex), "", "").replace("{CATCHABLE}", "&aTRUE"))); } diff --git a/src/main/java/com/github/nutt1101/event/HitEvent.java b/src/main/java/com/github/nutt1101/event/HitEvent.java index 064350c..24d0d11 100644 --- a/src/main/java/com/github/nutt1101/event/HitEvent.java +++ b/src/main/java/com/github/nutt1101/event/HitEvent.java @@ -77,15 +77,12 @@ public void CatchBallHitEvent(ProjectileHitEvent event){ event.getEntity().remove(); // hit a entity if (event.getHitEntity() != null) { - handleEntityCatch(player, event.getHitEntity(), true); + handleEntityCatch(player, event.getHitEntity(), true, null); // hit block, catchBall will be return } else if (event.getHitBlock() != null) { - event.getEntity().remove(); - hitLocation = event.getHitBlock().getLocation(); player.sendMessage(ConfigSetting.toChat(TranslationFileReader.ballHitBlock, getCoordinate(hitLocation), "")); - event.getHitBlock().getWorld().dropItem(event.getHitBlock().getLocation(), Ball.makeBall()); return; } @@ -150,71 +147,80 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { } // Handle the entity catch - handleEntityCatch(player, targetEntity, false); + handleEntityCatch(player, targetEntity, false, itemInHand); } - private void handleEntityCatch(Player player, Entity hitEntity, boolean isProjectile) { + private boolean handleEntityCatch(Player player, Entity hitEntity, boolean isProjectile, ItemStack itemInHand) { hitLocation = hitEntity.getLocation(); // Check all protection plugins using static flags if (!resCheck(player, hitEntity.getLocation()) && ConfigSetting.UseRes) { - hitEntity.getWorld().dropItem(hitEntity.getLocation(), Ball.makeBall()); + if (isProjectile) { + hitEntity.getWorld().dropItem(hitEntity.getLocation(), Ball.makeBall()); + } player.sendMessage(ConfigSetting.toChat(TranslationFileReader.canNotCatchable, getCoordinate(hitEntity.getLocation()), "")); - return; + return false; } if (!mmCheck(player, hitEntity) && ConfigSetting.UseMM) { - hitEntity.getWorld().dropItem(hitEntity.getLocation(), Ball.makeBall()); + if (isProjectile) { + hitEntity.getWorld().dropItem(hitEntity.getLocation(), Ball.makeBall()); + } player.sendMessage(ConfigSetting.toChat(TranslationFileReader.canNotCatchable, getCoordinate(hitEntity.getLocation()), "")); - return; + return false; } if (!gfCheck(player, hitEntity.getLocation()) && ConfigSetting.UseGF) { - hitEntity.getWorld().dropItem(hitEntity.getLocation(), Ball.makeBall()); + if (isProjectile) { + hitEntity.getWorld().dropItem(hitEntity.getLocation(), Ball.makeBall()); + } player.sendMessage(ConfigSetting.toChat(TranslationFileReader.canNotCatchable, getCoordinate(hitEntity.getLocation()), "")); - return; + return false; } if (!landsCheck(player, hitEntity.getLocation()) && ConfigSetting.UseLands) { - hitEntity.getWorld().dropItem(hitEntity.getLocation(), Ball.makeBall()); + if (isProjectile) { + hitEntity.getWorld().dropItem(hitEntity.getLocation(), Ball.makeBall()); + } player.sendMessage(ConfigSetting.toChat(TranslationFileReader.canNotCatchable, getCoordinate(hitEntity.getLocation()), "")); - return; + return false; } if (!rpCheck(player, hitEntity.getLocation()) && ConfigSetting.UseRP) { - hitEntity.getWorld().dropItem(hitEntity.getLocation(), Ball.makeBall()); + if (isProjectile) { + hitEntity.getWorld().dropItem(hitEntity.getLocation(), Ball.makeBall()); + } player.sendMessage(ConfigSetting.toChat(TranslationFileReader.canNotCatchable, getCoordinate(hitEntity.getLocation()), "")); - return; + return false; } if (!scsCheck(player, hitEntity.getLocation()) && ConfigSetting.UseSCS) { - hitEntity.getWorld().dropItem(hitEntity.getLocation(), Ball.makeBall()); + if (isProjectile) { + hitEntity.getWorld().dropItem(hitEntity.getLocation(), Ball.makeBall()); + } player.sendMessage(ConfigSetting.toChat(TranslationFileReader.canNotCatchable, getCoordinate(hitEntity.getLocation()), "")); - return; + return false; } if (!townyCheck(player, hitEntity.getLocation()) && ConfigSetting.UseTowny) { - hitEntity.getWorld().dropItem(hitEntity.getLocation(), Ball.makeBall()); + if (isProjectile) { + hitEntity.getWorld().dropItem(hitEntity.getLocation(), Ball.makeBall()); + } player.sendMessage(ConfigSetting.toChat(TranslationFileReader.canNotCatchable, getCoordinate(hitEntity.getLocation()), "")); - return; + return false; } - // TODO: Uncomment when WorldGuard check is implemented - /*if (!wgCheck(player, hitEntity.getLocation()) && ConfigSetting.UseWG) { - hitEntity.getWorld().dropItem(hitEntity.getLocation(), Ball.makeBall()); - player.sendMessage(ConfigSetting.toChat(TranslationFileReader.canNotCatchable, getCoordinate(hitEntity.getLocation()), "")); - return; - }*/ - // Check if entity is tameable and owned by someone else if (hitEntity instanceof Tameable tameable) { if (tameable.isTamed()) { boolean isNullOwnerValue = tameable.getOwner() == null; boolean sameOwner = isNullOwnerValue ? true : tameable.getOwner().getName().equals(player.getName()); if ((isNullOwnerValue && !ConfigSetting.allowCatchableTamedOwnerIsNull) || !sameOwner) { - hitEntity.getWorld().dropItem(hitEntity.getLocation(), Ball.makeBall()); + if (isProjectile) { + hitEntity.getWorld().dropItem(hitEntity.getLocation(), Ball.makeBall()); + } player.sendMessage(ConfigSetting.toChat(TranslationFileReader.canNotCatchable, getCoordinate(hitEntity.getLocation()), "")); - return; + return false; } } } @@ -225,9 +231,11 @@ private void handleEntityCatch(Player player, Entity hitEntity, boolean isProjec if (isEntityCatchable(hitEntity.getType()) && !(hitEntity instanceof Player) && !checkCustom.equals("CUSTOM")) { // Check catch failure rate if(Math.random() < ConfigSetting.catchFailRate) { - hitEntity.getWorld().dropItem(hitLocation, Ball.makeBall()); + if (isProjectile) { + hitEntity.getWorld().dropItem(hitLocation, Ball.makeBall()); + } player.sendMessage(ConfigSetting.toChat(TranslationFileReader.catchFail, getCoordinate(hitLocation), hitEntity.getType().name())); - return; + return false; } // Success sound @@ -245,12 +253,15 @@ private void handleEntityCatch(Player player, Entity hitEntity, boolean isProjec } player.sendMessage(ConfigSetting.toChat(TranslationFileReader.catchSuccess, getCoordinate(hitLocation), hitEntity.getType().name())); - return; + return true; } // If entity cannot be caught, return catch ball player.sendMessage(ConfigSetting.toChat(TranslationFileReader.canNotCatchable, getCoordinate(hitLocation), "")); - hitEntity.getWorld().dropItem(hitLocation, Ball.makeBall()); + if (isProjectile) { + hitEntity.getWorld().dropItem(hitLocation, Ball.makeBall()); + } + return false; } private boolean isCatchBall(ItemStack item) { @@ -388,7 +399,7 @@ public Chunk getChunkFromLocation(Location location) { public boolean townyCheck(Player player, Location location) { if (!CatchBall.hasTowny) { return true; } - boolean bBuild = PlayerCacheUtil.getCachePermission(player, location, Material.valueOf("dirt"), TownyPermission.ActionType.BUILD); + boolean bBuild = PlayerCacheUtil.getCachePermission(player, location, Material.DIRT, TownyPermission.ActionType.BUILD); return bBuild; } @@ -411,4 +422,4 @@ public String getIsCustomEntity(Entity hitEntity) { return checkCustom; } -} \ No newline at end of file +} diff --git a/src/main/resources/entity/en.yml b/src/main/resources/entity/en.yml index 49e7b91..19c66ae 100644 --- a/src/main/resources/entity/en.yml +++ b/src/main/resources/entity/en.yml @@ -35,6 +35,9 @@ EntityList: CREAKING: DisplayName: "CREAKING" Skull: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmI0OWUxOTY3ZmEyMzMyNzA5M2FjMDc0MmJjNDU3YjhhZTEyNTlhNDY4Yzk4MmMzZDM2OGNiNjNmODEyNGZhOSJ9fX0=" + COPPER_GOLEM: + DisplayName: "COPPER_GOLEM" + Skull: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTllMjRlOTRkYmU0MmUyMzBkODMyOTNhNzdkNjFmZjcxMDFhOGM2OGFiNjhiYmM2YTkzZjk2MzBmYjJmZGI0In19fQ==" HAPPY_GHAST: DisplayName: "HAPPY_GHAST" Skull: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2RhZWU4ODM0MTg4ZmVjMWMzMmUxZjYyYzE0ODVmZjk3MmVhOWI3NzE2OTM0MjRlMDEyYjZhYjhhMDcxMzUxYSJ9fX0=" diff --git a/src/main/resources/entity/zh_tw.yml b/src/main/resources/entity/zh_tw.yml index 06f47eb..3d8039c 100644 --- a/src/main/resources/entity/zh_tw.yml +++ b/src/main/resources/entity/zh_tw.yml @@ -50,6 +50,9 @@ EntityList: COW: DisplayName: "牛" Skull: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWQ2YzZlZGE5NDJmN2Y1ZjcxYzMxNjFjNzMwNmY0YWVkMzA3ZDgyODk1ZjlkMmIwN2FiNDUyNTcxOGVkYzUifX19" + COPPER_GOLEM: + DisplayName: "銅魔像" + Skull: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTllMjRlOTRkYmU0MmUyMzBkODMyOTNhNzdkNjFmZjcxMDFhOGM2OGFiNjhiYmM2YTkzZjk2MzBmYjJmZGI0In19fQ==" CREEPER: DisplayName: "苦力怕" Skull: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjQyNTQ4MzhjMzNlYTIyN2ZmY2EyMjNkZGRhYWJmZTBiMDIxNWY3MGRhNjQ5ZTk0NDQ3N2Y0NDM3MGNhNjk1MiJ9fX0="