Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,11 @@ run/

*/target/*

.gradle
.gradle

.project
.settings/*
bin
.classpath
!gradle-wrapper.jar
build
13 changes: 6 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ plugins {
}

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 {
Expand All @@ -39,7 +39,7 @@ repositories {
}

maven {
url = uri("https://repo.jeff-media.com/public/")
url = uri("https://repo.papermc.io/repository/maven-public/")
}

maven {
Expand All @@ -59,11 +59,10 @@ 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")
Expand Down Expand Up @@ -118,7 +117,7 @@ tasks.jar {
}

tasks.runServer {
minecraftVersion("1.21.7")
minecraftVersion("1.21.10")
}

runPaper.folia.registerTask()
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 1 addition & 4 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions src/main/java/com/github/nutt1101/event/GUIClick.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")));
}
Expand Down
81 changes: 46 additions & 35 deletions src/main/java/com/github/nutt1101/event/HitEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
}
}
Expand All @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand All @@ -411,4 +422,4 @@ public String getIsCustomEntity(Entity hitEntity) {
return checkCustom;
}

}
}
3 changes: 3 additions & 0 deletions src/main/resources/entity/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ EntityList:
CREAKING:
DisplayName: "CREAKING"
Skull: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmI0OWUxOTY3ZmEyMzMyNzA5M2FjMDc0MmJjNDU3YjhhZTEyNTlhNDY4Yzk4MmMzZDM2OGNiNjNmODEyNGZhOSJ9fX0="
COPPER_GOLEM:
DisplayName: "COPPER_GOLEM"
Skull: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTllMjRlOTRkYmU0MmUyMzBkODMyOTNhNzdkNjFmZjcxMDFhOGM2OGFiNjhiYmM2YTkzZjk2MzBmYjJmZGI0In19fQ=="
HAPPY_GHAST:
DisplayName: "HAPPY_GHAST"
Skull: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2RhZWU4ODM0MTg4ZmVjMWMzMmUxZjYyYzE0ODVmZjk3MmVhOWI3NzE2OTM0MjRlMDEyYjZhYjhhMDcxMzUxYSJ9fX0="
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/entity/zh_tw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ EntityList:
COW:
DisplayName: "牛"
Skull: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWQ2YzZlZGE5NDJmN2Y1ZjcxYzMxNjFjNzMwNmY0YWVkMzA3ZDgyODk1ZjlkMmIwN2FiNDUyNTcxOGVkYzUifX19"
COPPER_GOLEM:
DisplayName: "銅魔像"
Skull: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTllMjRlOTRkYmU0MmUyMzBkODMyOTNhNzdkNjFmZjcxMDFhOGM2OGFiNjhiYmM2YTkzZjk2MzBmYjJmZGI0In19fQ=="
CREEPER:
DisplayName: "苦力怕"
Skull: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjQyNTQ4MzhjMzNlYTIyN2ZmY2EyMjNkZGRhYWJmZTBiMDIxNWY3MGRhNjQ5ZTk0NDQ3N2Y0NDM3MGNhNjk1MiJ9fX0="
Expand Down