Skip to content

Commit 679c70b

Browse files
GD support maybe
1 parent fa74827 commit 679c70b

File tree

4 files changed

+109
-4
lines changed

4 files changed

+109
-4
lines changed

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ repositories {
7676
maven { url 'https://jitpack.io' }
7777
maven { url 'https://ci.ender.zone/plugin/repository/everything/' }
7878
maven { url "https://arcanearts.jfrog.io/artifactory/archives" }
79+
maven { url "https://repo.glaremasters.me/repository/bloodshot/" }
7980
mavenLocal()
8081

8182
}
@@ -141,6 +142,7 @@ dependencies {
141142
implementation "com.github.angeschossen:ChestProtectAPI:3.6.0"
142143
implementation "com.github.TechFortress:GriefPrevention:16.18.1"
143144
implementation 'xyz.xenondevs:particle:1.8.1'
145+
compileOnly 'com.griefdefender:api:2.1.0-SNAPSHOT'
144146

145147
// Dynamically Loaded
146148
compileOnly 'com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2'

src/main/java/com/volmit/adapt/Adapt.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@
2727
import com.volmit.adapt.api.world.AdaptServer;
2828
import com.volmit.adapt.command.CommandAdapt;
2929
import com.volmit.adapt.content.gui.SkillsGui;
30-
import com.volmit.adapt.content.protector.ChestProtectProtector;
31-
import com.volmit.adapt.content.protector.FactionsClaimProtector;
32-
import com.volmit.adapt.content.protector.ResidenceProtector;
33-
import com.volmit.adapt.content.protector.WorldGuardProtector;
30+
import com.volmit.adapt.content.protector.*;
3431
import com.volmit.adapt.nms.GlowingEntities;
3532
import com.volmit.adapt.nms.NMS;
3633
import com.volmit.adapt.util.*;
@@ -135,6 +132,9 @@ public void start() {
135132
if (getServer().getPluginManager().getPlugin("Residence") != null) {
136133
protectorRegistry.registerProtector(new ResidenceProtector());
137134
}
135+
if (getServer().getPluginManager().getPlugin("GriefDefender") != null) {
136+
protectorRegistry.registerProtector(new GriefDefenderProtector());
137+
}
138138
glowingEntities = new GlowingEntities(this);
139139
parser.parse(new CommandAdapt());
140140
}

src/main/java/com/volmit/adapt/AdaptConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public static AdaptConfig get() {
110110
@Getter
111111
public static class Protector {
112112
private boolean worldguard = true;
113+
private boolean griefdefender = true;
113114
private boolean factionsClaim = false;
114115
private boolean residence = true;
115116
private boolean chestProtect = true;
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*------------------------------------------------------------------------------
2+
- Adapt is a Skill/Integration plugin for Minecraft Bukkit Servers
3+
- Copyright (c) 2022 Arcane Arts (Volmit Software)
4+
-
5+
- This program is free software: you can redistribute it and/or modify
6+
- it under the terms of the GNU General Public License as published by
7+
- the Free Software Foundation, either version 3 of the License, or
8+
- (at your option) any later version.
9+
-
10+
- This program is distributed in the hope that it will be useful,
11+
- but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
- GNU General Public License for more details.
14+
-
15+
- You should have received a copy of the GNU General Public License
16+
- along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
-----------------------------------------------------------------------------*/
18+
19+
package com.volmit.adapt.content.protector;
20+
21+
import com.griefdefender.api.GriefDefender;
22+
import com.griefdefender.api.claim.Claim;
23+
import com.volmit.adapt.AdaptConfig;
24+
import com.volmit.adapt.api.adaptation.Adaptation;
25+
import com.volmit.adapt.api.protection.Protector;
26+
import org.bukkit.Location;
27+
import org.bukkit.entity.Player;
28+
29+
import java.util.UUID;
30+
31+
public class GriefDefenderProtector implements Protector {
32+
/**
33+
* This api is garbage, and obfuscated.
34+
* If i can get a jar ill improve it, but for now this is the best i can do.
35+
* Or if someone wants to make a PR feel free.
36+
*
37+
* I as an author do not support this api, and do not recommend it,
38+
* as they are making ME pay $15(spigot) + $5(patreon) per month to be
39+
* able to ask questions in their discord, and get unobfuscated jars.
40+
*
41+
*/
42+
43+
@Override
44+
public boolean checkRegion(Player player, Location location, Adaptation<?> adaptation) {
45+
final Claim claim = GriefDefender.getCore().getClaimAt(location);
46+
return checkPerm(player, claim, adaptation) || claim.isWilderness();
47+
}
48+
49+
@Override
50+
public boolean canPVP(Player player, Location entityLocation, Adaptation<?> adaptation) {
51+
final Claim claim = GriefDefender.getCore().getClaimAt(entityLocation);
52+
if (checkPerm(player, claim, adaptation)) {
53+
return claim.isPvpAllowed();
54+
}
55+
return false;
56+
}
57+
58+
private boolean checkPerm(Player player, Claim claim, Adaptation<?> adaptation) {
59+
if (claim == null) {
60+
return true;
61+
}
62+
UUID uuid = player.getUniqueId();
63+
return claim.isWilderness()
64+
|| claim.getOwnerUniqueId().equals(uuid)
65+
|| claim.getUserTrusts().contains(uuid);
66+
}
67+
68+
@Override
69+
public boolean canPVE(Player player, Location entityLocation, Adaptation<?> adaptation) {
70+
return checkPerm(player, GriefDefender.getCore().getClaimAt(entityLocation), adaptation);
71+
}
72+
73+
@Override
74+
public boolean canInteract(Player player, Location targetLocation, Adaptation<?> adaptation) {
75+
return checkPerm(player, GriefDefender.getCore().getClaimAt(targetLocation), adaptation);
76+
}
77+
78+
@Override
79+
public boolean canAccessChest(Player player, Location chestLocation, Adaptation<?> adaptation) {
80+
return checkPerm(player, GriefDefender.getCore().getClaimAt(chestLocation), adaptation);
81+
}
82+
83+
@Override
84+
public boolean canBlockBreak(Player player, Location blockLocation, Adaptation<?> adaptation) {
85+
return checkPerm(player, GriefDefender.getCore().getClaimAt(blockLocation), adaptation);
86+
}
87+
88+
@Override
89+
public boolean canBlockPlace(Player player, Location blockLocation, Adaptation<?> adaptation) {
90+
return checkPerm(player, GriefDefender.getCore().getClaimAt(blockLocation), adaptation);
91+
}
92+
93+
@Override
94+
public String getName() {
95+
return "GriefDefender";
96+
}
97+
98+
@Override
99+
public boolean isEnabledByDefault() {
100+
return AdaptConfig.get().getProtectorSupport().isFactionsClaim();
101+
}
102+
}

0 commit comments

Comments
 (0)