Skip to content

Commit ead69a4

Browse files
committed
add: player finder for exp farms. bump: version. fix: deps of fork
1 parent 408e767 commit ead69a4

14 files changed

Lines changed: 163 additions & 101 deletions

File tree

build.gradle

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,40 @@ ext {
1919
}
2020

2121
repositories {
22+
// Maven Defaults
2223
mavenCentral()
2324
mavenLocal()
25+
26+
// SpigotMC Repos
2427
maven {
2528
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
2629
content {
2730
includeGroup 'org.bukkit'
2831
includeGroup 'org.spigotmc'
2932
}
3033
}
34+
35+
// Sonatype Repos
3136
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
3237
maven { url = 'https://oss.sonatype.org/content/repositories/central' }
3338
maven {
3439
name = "sonatype"
3540
url = "https://oss.sonatype.org/content/groups/public/"
3641
}
37-
38-
// Updated JitPack repo logic to be conditional
39-
// This prevents 401 errors on public repos if the authToken is empty
40-
maven {
41-
url "https://jitpack.io"
42-
if (project.hasProperty('authToken') && project.authToken.toString().trim()) {
43-
credentials {
44-
username = project.authToken
45-
}
46-
}
47-
}
48-
42+
43+
// CodeMC Streamline Essentials Repo
44+
maven { url "https://repo.codemc.org/repository/streamline-essentials/" }
45+
46+
// JitPack
47+
maven { url "https://jitpack.io" }
48+
49+
// PlaceholderAPI Repo
4950
maven {
5051
name = "placeholderapi"
5152
url = "https://repo.extendedclip.com/content/repositories/placeholderapi/"
5253
}
54+
55+
// Papermc Repositories
5356
maven { url 'https://repo.papermc.io/repository/maven-snapshots/' }
5457
maven { url 'https://repo.papermc.io/repository/maven-public/' }
5558
}

dependencies.gradle

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,30 @@ ext {
55
]
66
ANNO = [
77
// Lombok is handled by the plugin, but keeping standard dependencies here if needed
8-
'com.github.Streamline-Essentials:BukkitOfUtils:master-SNAPSHOT',
8+
'gg.drak:BukkitOfUtils:1.16.0',
99

1010
// StreamlineCore Dependencies (API & BAPI)
11-
'com.github.Streamline-Essentials.StreamlineCore:API:master-SNAPSHOT',
12-
'com.github.Streamline-Essentials.StreamlineCore:BAPI:master-SNAPSHOT',
11+
'gg.drak:StreamlineCore-API:2.5.5.6',
12+
'gg.drak:StreamlineCore-BAPI:2.5.5.6',
1313

14+
// Folia API for Folia compatibility
1415
'dev.folia:folia-api:1.20.4-R0.1-SNAPSHOT',
15-
'net.kyori:adventure-api:4.16.0',
16-
'net.kyori:adventure-text-serializer-gson:4.16.0',
17-
'net.kyori:adventure-text-serializer-legacy:4.16.0',
18-
'net.kyori:adventure-text-serializer-plain:4.16.0',
19-
'net.kyori:adventure-text-minimessage:4.16.0',
20-
'net.kyori:adventure-text-serializer-ansi:4.16.0',
21-
'net.kyori:ansi:1.0.3',
2216
]
2317
COMP_ONLY = [
24-
// Updated BukkitOfUtils to the new Group ID matching BrewFaster
25-
'com.github.Streamline-Essentials:BukkitOfUtils:master-SNAPSHOT',
26-
18+
// Lombok is handled by the plugin, but keeping standard dependencies here if needed
19+
'gg.drak:BukkitOfUtils:1.16.0',
20+
2721
// StreamlineCore Dependencies (API & BAPI)
28-
// Needed for tv.quaint classes
29-
'com.github.Streamline-Essentials.StreamlineCore:API:master-SNAPSHOT',
30-
'com.github.Streamline-Essentials.StreamlineCore:BAPI:master-SNAPSHOT',
31-
22+
'gg.drak:StreamlineCore-API:2.5.5.6',
23+
'gg.drak:StreamlineCore-BAPI:2.5.5.6',
24+
25+
// Folia API for Folia compatibility
3226
'dev.folia:folia-api:1.20.4-R0.1-SNAPSHOT',
33-
'net.kyori:adventure-api:4.16.0',
34-
'net.kyori:adventure-text-serializer-gson:4.16.0',
35-
'net.kyori:adventure-text-serializer-legacy:4.16.0',
36-
'net.kyori:adventure-text-serializer-plain:4.16.0',
37-
'net.kyori:adventure-text-minimessage:4.16.0',
38-
'net.kyori:adventure-text-serializer-ansi:4.16.0',
39-
'net.kyori:ansi:1.0.3',
4027
]
4128
FILES = [
4229
]
4330
OTHER_PLUGINS = [
44-
'me.clip:placeholderapi:2.11.5',
31+
// PlaceholderAPI for Placeholder support
32+
'me.clip:placeholderapi:2.11.7',
4533
]
4634
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = StoneDamager
22
group = host.plas
3-
version = 1.9.0
3+
version = 1.11.0
44

55
plugin.main = default

src/main/java/host/plas/stonedamager/StoneDamager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
import host.plas.stonedamager.utils.DamageHandler;
66
import lombok.Getter;
77
import lombok.Setter;
8-
import host.plas.stonedamager.config.DamagerConfig;
8+
import host.plas.stonedamager.config.MainConfig;
99
import host.plas.stonedamager.runnables.TickTicker;
1010

1111
@Getter @Setter
1212
public final class StoneDamager extends BetterPlugin {
1313
@Getter @Setter
1414
private static StoneDamager instance;
1515
@Getter @Setter
16-
private static DamagerConfig damagerConfig;
16+
private static MainConfig mainConfig;
1717

1818
@Getter @Setter
1919
private static TickTicker tickTicker;
@@ -27,7 +27,7 @@ public void onBaseEnabled() {
2727
// Plugin startup logic
2828
instance = this;
2929

30-
damagerConfig = new DamagerConfig();
30+
mainConfig = new MainConfig();
3131

3232
tickTicker = new TickTicker();
3333

src/main/java/host/plas/stonedamager/commands/ReloadCMD.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public boolean command(CommandContext ctx) {
1717
CompletableFuture.runAsync(() -> {
1818
ctx.sendMessage("&eReloading &cconfigurations&8...");
1919

20-
StoneDamager.getDamagerConfig().onReload();
20+
StoneDamager.getMainConfig().onReload();
2121

2222
ctx.sendMessage("&eReloaded &cconfigurations&8!");
2323
});

src/main/java/host/plas/stonedamager/config/DamagerConfig.java renamed to src/main/java/host/plas/stonedamager/config/MainConfig.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package host.plas.stonedamager.config;
22

3+
import gg.drak.thebase.storage.resources.flat.simple.SimpleConfiguration;
34
import host.plas.bou.configs.bits.ConfigurableWhitelist;
45
import host.plas.stonedamager.StoneDamager;
56
import host.plas.stonedamager.data.DamagableSelection;
67
import host.plas.stonedamager.utils.DamageHandler;
7-
import tv.quaint.storage.resources.flat.simple.SimpleConfiguration;
88

99
import java.util.ArrayList;
1010
import java.util.List;
1111
import java.util.concurrent.ConcurrentSkipListSet;
1212

13-
public class DamagerConfig extends SimpleConfiguration {
14-
public DamagerConfig() {
13+
public class MainConfig extends SimpleConfiguration {
14+
public MainConfig() {
1515
super("config.yml", StoneDamager.getInstance(), true);
1616
}
1717

@@ -26,7 +26,8 @@ public void onReload() {
2626

2727
StoneDamager.getInstance().logInfo("&fLoaded &a" + getSelections().size() + " &fdamager selections.");
2828

29-
isStoneCutterPatchEnabled();
29+
isTryFindPlayer();
30+
getFindPlayerRadius();
3031

3132
String configVersion = getConfigVersion();
3233
if (! configVersion.equals("1.0")) {
@@ -101,9 +102,15 @@ public String getConfigVersion() {
101102
return getResource().getOrDefault("config-version", "null");
102103
}
103104

104-
public boolean isStoneCutterPatchEnabled() {
105+
public boolean isTryFindPlayer() {
105106
reloadResource();
106107

107-
return getOrSetDefault("stonecutter-patch", true);
108+
return getOrSetDefault("settings.try-find-player.enabled", true);
109+
}
110+
111+
public double getFindPlayerRadius() {
112+
reloadResource();
113+
114+
return getOrSetDefault("settings.try-find-player.radius", 30d);
108115
}
109116
}

src/main/java/host/plas/stonedamager/data/DamagableSelection.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package host.plas.stonedamager.data;
22

3+
import gg.drak.thebase.objects.Identifiable;
34
import host.plas.bou.configs.bits.ConfigurableWhitelist;
4-
import host.plas.stonedamager.patch.StoneCutterPatch;
55
import lombok.Getter;
66
import lombok.Setter;
77
import org.bukkit.Location;
88
import org.bukkit.block.Block;
99
import org.bukkit.entity.Entity;
1010
import org.bukkit.entity.Player;
11-
import tv.quaint.objects.Identifiable;
1211

1312
import java.util.concurrent.atomic.AtomicBoolean;
1413

@@ -45,10 +44,6 @@ public boolean checkMaterial(String material) {
4544
}
4645

4746
public boolean checkMaterial(Block block) {
48-
if (isMaterialsContainsSC()) {
49-
if (StoneCutterPatch.isStoneCutter(block)) return ! materials.isBlacklist();
50-
}
51-
5247
return checkMaterial(block.getType().name());
5348
}
5449

@@ -63,14 +58,14 @@ public boolean checkEntity(String entity) {
6358
public boolean checkPermissions(Entity player) {
6459
if (! (player instanceof Player)) return true;
6560

66-
if (includePermission.isBlank() || includePermission.isEmpty()) {
67-
if (excludePermission.isBlank() || excludePermission.isEmpty()) {
61+
if (isEmptyPermission(includePermission)) {
62+
if (isEmptyPermission(excludePermission)) {
6863
return true;
6964
} else {
7065
return ! player.hasPermission(excludePermission);
7166
}
7267
} else {
73-
if (excludePermission.isBlank() || excludePermission.isEmpty()) {
68+
if (isEmptyPermission(excludePermission)) {
7469
return player.hasPermission(includePermission);
7570
} else {
7671
return player.hasPermission(includePermission) && ! player.hasPermission(excludePermission);
@@ -90,4 +85,11 @@ public boolean check(Entity entity) {
9085

9186
return checkAll(entity, block);
9287
}
88+
89+
public static boolean isEmptyPermission(String permission) {
90+
return permission == null || permission.isBlank() ||
91+
permission.equalsIgnoreCase("none") || permission.equalsIgnoreCase("null") ||
92+
permission.equalsIgnoreCase("disable") || permission.equalsIgnoreCase("disabled") ||
93+
permission.equalsIgnoreCase("off");
94+
}
9395
}
Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,61 @@
11
package host.plas.stonedamager.events;
22

3+
import host.plas.stonedamager.StoneDamager;
34
import host.plas.stonedamager.data.DamagableSelection;
5+
import host.plas.stonedamager.objects.DistanceComparator;
46
import lombok.Getter;
57
import lombok.Setter;
8+
import org.bukkit.Location;
69
import org.bukkit.entity.LivingEntity;
7-
import tv.quaint.events.components.BaseEvent;
10+
import org.bukkit.entity.Player;
11+
12+
import java.util.Optional;
813

914
@Setter
1015
@Getter
11-
public class ScheduledDamageEvent extends BaseEvent {
16+
public class ScheduledDamageEvent extends StoneDamagerEvent {
1217
private LivingEntity entity;
1318
private DamagableSelection damagableSelection;
1419

1520
public ScheduledDamageEvent(LivingEntity entity, DamagableSelection damagableSelection) {
1621
this.entity = entity;
1722
this.damagableSelection = damagableSelection;
1823
}
24+
25+
public Optional<Player> getClosestPlayer() {
26+
boolean tryFind = StoneDamager.getMainConfig().isTryFindPlayer();
27+
if (! tryFind) return Optional.empty();
28+
29+
double radius = StoneDamager.getMainConfig().getFindPlayerRadius();
30+
return entity.getNearbyEntities(radius, radius, radius).stream()
31+
.filter(e -> e instanceof Player)
32+
.map(e -> (Player) e)
33+
.min(new DistanceComparator(getEntityLocation()));
34+
}
35+
36+
public Location getEntityLocation() {
37+
return entity.getLocation();
38+
}
39+
40+
/**
41+
* Damages the entity by the specified amount.
42+
*
43+
* Call this method only in synchronous context.
44+
* @param damage the amount of damage to deal
45+
*/
46+
public void damageEntity(double damage) {
47+
getClosestPlayer().ifPresentOrElse(
48+
p -> getEntity().damage(damage, p),
49+
() -> getEntity().damage(damage)
50+
);
51+
}
52+
53+
/**
54+
* Damages the entity by the amount specified in the DamagableSelection.
55+
*
56+
* Call this method only in synchronous context.
57+
*/
58+
public void damageEntity() {
59+
damageEntity(getDamagableSelection().getDamageAmount());
60+
}
1961
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package host.plas.stonedamager.events;
2+
3+
import gg.drak.thebase.events.components.BaseEvent;
4+
import host.plas.stonedamager.StoneDamager;
5+
6+
public class StoneDamagerEvent extends BaseEvent {
7+
public StoneDamagerEvent() {
8+
super();
9+
}
10+
11+
public StoneDamager getPlugin() {
12+
return StoneDamager.getInstance();
13+
}
14+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package host.plas.stonedamager.objects;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
import org.bukkit.Location;
6+
import org.bukkit.entity.Entity;
7+
8+
import java.util.Comparator;
9+
10+
@Getter @Setter
11+
public class DistanceComparator implements Comparator<Entity> {
12+
private final Location referenceLocation;
13+
14+
public DistanceComparator(Location referenceLocation) {
15+
this.referenceLocation = referenceLocation;
16+
}
17+
18+
@Override
19+
public int compare(Entity o1, Entity o2) {
20+
Location l1 = o1.getLocation();
21+
Location l2 = o2.getLocation();
22+
23+
double d1 = l1.distanceSquared(referenceLocation);
24+
double d2 = l2.distanceSquared(referenceLocation);
25+
26+
return Double.compare(d1, d2);
27+
}
28+
}

0 commit comments

Comments
 (0)