Skip to content

Commit b62c0b9

Browse files
authored
Merge pull request #3 from ProjectsForAll/dev
Dev
2 parents be3f5df + ead69a4 commit b62c0b9

15 files changed

Lines changed: 233 additions & 91 deletions

File tree

.github/workflows/maven.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Java CI with Gradle
2+
3+
on:
4+
push:
5+
branches: [ "master", "main" ]
6+
pull_request:
7+
branches: [ "master", "main" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up JDK 17
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: '17'
20+
distribution: 'temurin'
21+
cache: gradle
22+
23+
- name: Grant execute permission for gradlew
24+
run: chmod +x gradlew
25+
26+
- name: Build with Gradle
27+
run: ./gradlew build
28+
29+
- name: Upload Artifact
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: StoneDamager-Build
33+
path: build/libs/*.jar

build.gradle

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +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/'
26-
27-
// As of Gradle 5.1, you can limit this to only those
28-
// dependencies you expect from it
2929
content {
3030
includeGroup 'org.bukkit'
3131
includeGroup 'org.spigotmc'
3232
}
3333
}
34+
35+
// Sonatype Repos
3436
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
3537
maven { url = 'https://oss.sonatype.org/content/repositories/central' }
3638
maven {
3739
name = "sonatype"
3840
url = "https://oss.sonatype.org/content/groups/public/"
3941
}
42+
43+
// CodeMC Streamline Essentials Repo
44+
maven { url "https://repo.codemc.org/repository/streamline-essentials/" }
45+
46+
// JitPack
4047
maven { url "https://jitpack.io" }
48+
49+
// PlaceholderAPI Repo
4150
maven {
4251
name = "placeholderapi"
4352
url = "https://repo.extendedclip.com/content/repositories/placeholderapi/"
4453
}
54+
55+
// Papermc Repositories
4556
maven { url 'https://repo.papermc.io/repository/maven-snapshots/' }
4657
maven { url 'https://repo.papermc.io/repository/maven-public/' }
4758
}
@@ -95,4 +106,4 @@ artifacts {
95106
wrapper {
96107
gradleVersion = '8.9'
97108
distributionType = Wrapper.DistributionType.ALL
98-
}
109+
}

dependencies.gradle

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,31 @@ ext {
44
SHADOW = [
55
]
66
ANNO = [
7-
'com.github.streamline-essentials:BukkitOfUtils:master-SNAPSHOT',
7+
// Lombok is handled by the plugin, but keeping standard dependencies here if needed
8+
'gg.drak:BukkitOfUtils:1.16.0',
9+
10+
// StreamlineCore Dependencies (API & BAPI)
11+
'gg.drak:StreamlineCore-API:2.5.5.6',
12+
'gg.drak:StreamlineCore-BAPI:2.5.5.6',
13+
14+
// Folia API for Folia compatibility
815
'dev.folia:folia-api:1.20.4-R0.1-SNAPSHOT',
9-
'net.kyori:adventure-api:4.16.0',
10-
'net.kyori:adventure-text-serializer-gson:4.16.0',
11-
'net.kyori:adventure-text-serializer-legacy:4.16.0',
12-
'net.kyori:adventure-text-serializer-plain:4.16.0',
13-
'net.kyori:adventure-text-minimessage:4.16.0',
14-
'net.kyori:adventure-text-serializer-ansi:4.16.0',
15-
'net.kyori:ansi:1.0.3',
1616
]
1717
COMP_ONLY = [
18-
'com.github.streamline-essentials:BukkitOfUtils:master-SNAPSHOT',
18+
// Lombok is handled by the plugin, but keeping standard dependencies here if needed
19+
'gg.drak:BukkitOfUtils:1.16.0',
20+
21+
// StreamlineCore Dependencies (API & BAPI)
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
1926
'dev.folia:folia-api:1.20.4-R0.1-SNAPSHOT',
20-
'net.kyori:adventure-api:4.16.0',
21-
'net.kyori:adventure-text-serializer-gson:4.16.0',
22-
'net.kyori:adventure-text-serializer-legacy:4.16.0',
23-
'net.kyori:adventure-text-serializer-plain:4.16.0',
24-
'net.kyori:adventure-text-minimessage:4.16.0',
25-
'net.kyori:adventure-text-serializer-ansi:4.16.0',
26-
'net.kyori:ansi:1.0.3',
2727
]
2828
FILES = [
2929
]
3030
OTHER_PLUGINS = [
31-
'me.clip:placeholderapi:2.11.5',
31+
// PlaceholderAPI for Placeholder support
32+
'me.clip:placeholderapi:2.11.7',
3233
]
33-
}
34+
}

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+
}

0 commit comments

Comments
 (0)