Skip to content

Commit 3ca52c6

Browse files
Merge branch 'main' into dev/gp-performance
2 parents dff8205 + d448602 commit 3ca52c6

File tree

7 files changed

+188
-44
lines changed

7 files changed

+188
-44
lines changed

dough-api/pom.xml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<plugin>
107107
<groupId>org.apache.maven.plugins</groupId>
108108
<artifactId>maven-shade-plugin</artifactId>
109-
<version>3.5.1</version>
109+
<version>3.5.2</version>
110110

111111
<configuration>
112112
<createSourcesJar>true</createSourcesJar>
@@ -267,7 +267,7 @@
267267
<dependency>
268268
<groupId>com.sk89q.worldguard</groupId>
269269
<artifactId>worldguard-bukkit</artifactId>
270-
<version>7.0.8</version>
270+
<version>7.0.9</version>
271271
<scope>provided</scope>
272272
</dependency>
273273

@@ -283,7 +283,7 @@
283283
<dependency>
284284
<groupId>net.coreprotect</groupId>
285285
<artifactId>coreprotect</artifactId>
286-
<version>21.2</version>
286+
<version>21.3</version>
287287
<scope>provided</scope>
288288
</dependency>
289289

@@ -307,7 +307,7 @@
307307
<dependency>
308308
<groupId>com.github.TechFortress</groupId>
309309
<artifactId>GriefPrevention</artifactId>
310-
<version>16.18.1</version>
310+
<version>16.18.2</version>
311311
<scope>provided</scope>
312312
</dependency>
313313

@@ -323,13 +323,13 @@
323323
<dependency>
324324
<groupId>me.lucko</groupId>
325325
<artifactId>helper</artifactId>
326-
<version>5.6.10</version>
326+
<version>5.6.14</version>
327327
<scope>provided</scope>
328328
</dependency>
329329
<dependency>
330330
<groupId>com.massivecraft</groupId>
331331
<artifactId>Factions</artifactId>
332-
<version>1.6.9.5-2.7.0-STABLE</version>
332+
<version>1.6.9.5-4.1.4-STABLE</version>
333333
<scope>provided</scope>
334334
</dependency>
335335

@@ -405,7 +405,7 @@
405405
<dependency>
406406
<groupId>com.github.angeschossen</groupId>
407407
<artifactId>ChestProtectAPI</artifactId>
408-
<version>3.6.0</version>
408+
<version>3.9.1</version>
409409
<scope>provided</scope>
410410
</dependency>
411411

@@ -424,6 +424,14 @@
424424
<version>1.7</version>
425425
<scope>provided</scope>
426426
</dependency>
427+
428+
<!-- ShopChest -->
429+
<dependency>
430+
<groupId>de.epiceric</groupId>
431+
<artifactId>ShopChest</artifactId>
432+
<version>1.13-SNAPSHOT</version>
433+
<scope>provided</scope>
434+
</dependency>
427435
</dependencies>
428436

429437
</project>

dough-protection/pom.xml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
<id>logblock-repo</id>
5151
<url>https://www.iani.de/nexus/content/repositories/snapshots/</url>
5252
</repository>
53+
<repository>
54+
<id>william278-repo</id>
55+
<url>https://repo.william278.net/snapshots/</url>
56+
</repository>
5357
</repositories>
5458

5559
<dependencies>
@@ -76,7 +80,7 @@
7680
<dependency>
7781
<groupId>com.sk89q.worldguard</groupId>
7882
<artifactId>worldguard-bukkit</artifactId>
79-
<version>7.0.8</version>
83+
<version>7.0.9</version>
8084
<scope>provided</scope>
8185
</dependency>
8286

@@ -92,7 +96,7 @@
9296
<dependency>
9397
<groupId>net.coreprotect</groupId>
9498
<artifactId>coreprotect</artifactId>
95-
<version>21.2</version>
99+
<version>21.3</version>
96100
<scope>provided</scope>
97101
</dependency>
98102

@@ -116,7 +120,7 @@
116120
<dependency>
117121
<groupId>com.github.GriefPrevention</groupId>
118122
<artifactId>GriefPrevention</artifactId>
119-
<version>16.18.1</version>
123+
<version>16.18.2</version>
120124
<scope>provided</scope>
121125
</dependency>
122126

@@ -132,13 +136,13 @@
132136
<dependency>
133137
<groupId>me.lucko</groupId>
134138
<artifactId>helper</artifactId>
135-
<version>5.6.10</version>
139+
<version>5.6.14</version>
136140
<scope>provided</scope>
137141
</dependency>
138142
<dependency>
139143
<groupId>com.massivecraft</groupId>
140144
<artifactId>Factions</artifactId>
141-
<version>1.6.9.5-2.7.0-STABLE</version>
145+
<version>1.6.9.5-4.1.4-STABLE</version>
142146
<scope>provided</scope>
143147
</dependency>
144148

@@ -228,9 +232,25 @@
228232

229233
<!-- HuskTowns -->
230234
<dependency>
231-
<groupId>net.william278</groupId>
232-
<artifactId>HuskTowns</artifactId>
233-
<version>2.5.3</version>
235+
<groupId>net.william278.husktowns</groupId>
236+
<artifactId>husktowns-bukkit</artifactId>
237+
<version>3.0-988161b</version>
238+
<scope>provided</scope>
239+
</dependency>
240+
241+
<!-- HuskClaims -->
242+
<dependency>
243+
<groupId>net.william278.huskclaims</groupId>
244+
<artifactId>huskclaims-bukkit</artifactId>
245+
<version>1.0.2-e60150d</version>
246+
<scope>provided</scope>
247+
</dependency>
248+
249+
<!-- ShopChest -->
250+
<dependency>
251+
<groupId>de.epiceric</groupId>
252+
<artifactId>ShopChest</artifactId>
253+
<version>1.13-SNAPSHOT</version>
234254
<scope>provided</scope>
235255
</dependency>
236256

dough-protection/src/main/java/io/github/bakedlibs/dough/protection/ProtectionManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@
2525
import io.github.bakedlibs.dough.protection.modules.FunnyGuildsProtectionModule;
2626
import io.github.bakedlibs.dough.protection.modules.GriefPreventionProtectionModule;
2727
import io.github.bakedlibs.dough.protection.modules.HuskTownsProtectionModule;
28+
import io.github.bakedlibs.dough.protection.modules.HuskClaimsProtectionModule;
2829
import io.github.bakedlibs.dough.protection.modules.LWCProtectionModule;
2930
import io.github.bakedlibs.dough.protection.modules.LandsProtectionModule;
3031
import io.github.bakedlibs.dough.protection.modules.LocketteProtectionModule;
3132
import io.github.bakedlibs.dough.protection.modules.PlotSquaredProtectionModule;
3233
import io.github.bakedlibs.dough.protection.modules.PreciousStonesProtectionModule;
3334
import io.github.bakedlibs.dough.protection.modules.RedProtectProtectionModule;
35+
import io.github.bakedlibs.dough.protection.modules.ShopChestProtectionModule;
3436
import io.github.bakedlibs.dough.protection.modules.TownyProtectionModule;
3537
import io.github.bakedlibs.dough.protection.modules.WorldGuardProtectionModule;
3638

@@ -91,6 +93,8 @@ private void loadModuleImplementations(Plugin plugin) {
9193
registerModule(pm, "FunnyGuilds", funnyGuilds -> new FunnyGuildsProtectionModule(funnyGuilds));
9294
registerModule(pm, "PlotSquared", plotSquared -> new PlotSquaredProtectionModule(plotSquared));
9395
registerModule(pm, "HuskTowns", huskTowns -> new HuskTownsProtectionModule(huskTowns));
96+
registerModule(pm, "ShopChest", shopChest -> new ShopChestProtectionModule(shopChest));
97+
registerModule(pm, "HuskClaims", huskClaims -> new HuskClaimsProtectionModule(huskClaims));
9498

9599
/*
96100
* The following Plugins work by utilising one of the above listed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package io.github.bakedlibs.dough.protection.modules;
2+
3+
import io.github.bakedlibs.dough.protection.Interaction;
4+
import io.github.bakedlibs.dough.protection.ProtectionModule;
5+
import net.william278.huskclaims.api.BukkitHuskClaimsAPI;
6+
import net.william278.huskclaims.libraries.cloplib.operation.Operation;
7+
import net.william278.huskclaims.libraries.cloplib.operation.OperationType;
8+
import org.bukkit.Location;
9+
import org.bukkit.OfflinePlayer;
10+
import org.bukkit.plugin.Plugin;
11+
12+
import javax.annotation.Nonnull;
13+
14+
/**
15+
* Protection handling module for HuskClaims
16+
*
17+
* @author William278
18+
*/
19+
public class HuskClaimsProtectionModule implements ProtectionModule {
20+
21+
private BukkitHuskClaimsAPI huskClaimsAPI;
22+
private final Plugin plugin;
23+
24+
public HuskClaimsProtectionModule(@Nonnull Plugin plugin) {
25+
this.plugin = plugin;
26+
}
27+
28+
@Override
29+
public void load() {
30+
huskClaimsAPI = BukkitHuskClaimsAPI.getInstance();
31+
}
32+
33+
@Override
34+
public Plugin getPlugin() {
35+
return plugin;
36+
}
37+
38+
@Override
39+
public boolean hasPermission(OfflinePlayer p, Location l, Interaction action) {
40+
// Offline player have no permissions
41+
if (!p.isOnline()) {
42+
return false;
43+
}
44+
45+
// Convert the dough interaction to HuskClaims' ActionType and check via the API
46+
return huskClaimsAPI.isOperationAllowed(Operation.of(
47+
huskClaimsAPI.getOnlineUser(p.getPlayer()),
48+
getHuskClaimsAction(action),
49+
huskClaimsAPI.getPosition(l)
50+
));
51+
}
52+
53+
/**
54+
* Returns the corresponding HuskClaims {@link OperationType} from the dough {@link Interaction}
55+
*
56+
* @param doughAction The dough {@link Interaction}
57+
* @return The corresponding HuskClaims {@link OperationType}
58+
*/
59+
public @Nonnull OperationType getHuskClaimsAction(@Nonnull Interaction doughAction) {
60+
switch (doughAction) {
61+
case BREAK_BLOCK:
62+
return OperationType.BLOCK_BREAK;
63+
case PLACE_BLOCK:
64+
return OperationType.BLOCK_PLACE;
65+
case ATTACK_ENTITY:
66+
return OperationType.PLAYER_DAMAGE_ENTITY;
67+
case ATTACK_PLAYER:
68+
return OperationType.PLAYER_DAMAGE_PLAYER;
69+
case INTERACT_BLOCK:
70+
return OperationType.BLOCK_INTERACT;
71+
default:
72+
return OperationType.ENTITY_INTERACT;
73+
}
74+
}
75+
}

dough-protection/src/main/java/io/github/bakedlibs/dough/protection/modules/HuskTownsProtectionModule.java

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
import io.github.bakedlibs.dough.protection.Interaction;
44
import io.github.bakedlibs.dough.protection.ProtectionModule;
5-
import net.william278.husktowns.api.HuskTownsAPI;
6-
import net.william278.husktowns.claim.Position;
7-
import net.william278.husktowns.claim.World;
8-
import net.william278.husktowns.listener.Operation;
9-
import net.william278.husktowns.user.OnlineUser;
5+
import net.william278.husktowns.api.BukkitHuskTownsAPI;
6+
import net.william278.husktowns.libraries.cloplib.operation.Operation;
7+
import net.william278.husktowns.libraries.cloplib.operation.OperationType;
108
import org.bukkit.Location;
119
import org.bukkit.OfflinePlayer;
1210
import org.bukkit.plugin.Plugin;
@@ -20,7 +18,7 @@
2018
*/
2119
public class HuskTownsProtectionModule implements ProtectionModule {
2220

23-
private HuskTownsAPI huskTownsAPI;
21+
private BukkitHuskTownsAPI huskTownsAPI;
2422
private final Plugin plugin;
2523

2624
public HuskTownsProtectionModule(@Nonnull Plugin plugin) {
@@ -29,7 +27,7 @@ public HuskTownsProtectionModule(@Nonnull Plugin plugin) {
2927

3028
@Override
3129
public void load() {
32-
huskTownsAPI = HuskTownsAPI.getInstance();
30+
huskTownsAPI = BukkitHuskTownsAPI.getInstance();
3331
}
3432

3533
@Override
@@ -46,38 +44,32 @@ public boolean hasPermission(OfflinePlayer p, Location l, Interaction action) {
4644

4745
// Convert the dough interaction to HuskTowns' ActionType and check via the API
4846
return huskTownsAPI.isOperationAllowed(Operation.of(
49-
getOnlineUser(p), getHuskTownsAction(action), getPosition(l)));
50-
}
51-
52-
private OnlineUser getOnlineUser(OfflinePlayer p) {
53-
return huskTownsAPI.getOnlineUser(p.getPlayer());
54-
}
55-
56-
private Position getPosition(Location l) {
57-
org.bukkit.World w = l.getWorld();
58-
return Position.at(l.getX(), l.getY(), l.getZ(), World.of(w.getUID(), w.getName(), w.getEnvironment().name()));
47+
huskTownsAPI.getOnlineUser(p.getPlayer()),
48+
getHuskTownsAction(action),
49+
huskTownsAPI.getPosition(l)
50+
));
5951
}
6052

6153
/**
62-
* Returns the corresponding HuskTowns {@link Operation.Type} from the dough {@link Interaction}
54+
* Returns the corresponding HuskTowns {@link OperationType} from the dough {@link Interaction}
6355
*
6456
* @param doughAction The dough {@link Interaction}
65-
* @return The corresponding HuskTowns {@link Operation.Type}
57+
* @return The corresponding HuskTowns {@link OperationType}
6658
*/
67-
public @Nonnull Operation.Type getHuskTownsAction(@Nonnull Interaction doughAction) {
59+
public @Nonnull OperationType getHuskTownsAction(@Nonnull Interaction doughAction) {
6860
switch (doughAction) {
6961
case BREAK_BLOCK:
70-
return Operation.Type.BLOCK_BREAK;
62+
return OperationType.BLOCK_BREAK;
7163
case PLACE_BLOCK:
72-
return Operation.Type.BLOCK_PLACE;
64+
return OperationType.BLOCK_PLACE;
7365
case ATTACK_ENTITY:
74-
return Operation.Type.PLAYER_DAMAGE_ENTITY;
66+
return OperationType.PLAYER_DAMAGE_ENTITY;
7567
case ATTACK_PLAYER:
76-
return Operation.Type.PLAYER_DAMAGE_PLAYER;
68+
return OperationType.PLAYER_DAMAGE_PLAYER;
7769
case INTERACT_BLOCK:
78-
return Operation.Type.BLOCK_INTERACT;
70+
return OperationType.BLOCK_INTERACT;
7971
default:
80-
return Operation.Type.ENTITY_INTERACT;
72+
return OperationType.ENTITY_INTERACT;
8173
}
8274
}
8375
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package io.github.bakedlibs.dough.protection.modules;
2+
3+
import de.epiceric.shopchest.ShopChest;
4+
5+
import io.github.bakedlibs.dough.protection.Interaction;
6+
import io.github.bakedlibs.dough.protection.ProtectionModule;
7+
8+
import org.bukkit.Location;
9+
import org.bukkit.OfflinePlayer;
10+
import org.bukkit.plugin.Plugin;
11+
12+
import javax.annotation.Nonnull;
13+
14+
/**
15+
* Provides protection handling for ShopChest
16+
*
17+
* @author EpicPlayerA10
18+
*/
19+
public class ShopChestProtectionModule implements ProtectionModule {
20+
private ShopChest shopChest;
21+
private final Plugin plugin;
22+
23+
public ShopChestProtectionModule(@Nonnull Plugin plugin) {
24+
this.plugin = plugin;
25+
}
26+
27+
@Override
28+
public void load() {
29+
this.shopChest = ShopChest.getInstance();
30+
}
31+
32+
@Override
33+
public Plugin getPlugin() {
34+
return this.plugin;
35+
}
36+
37+
@Override
38+
public boolean hasPermission(OfflinePlayer p, Location l, Interaction action) {
39+
if (action == Interaction.BREAK_BLOCK) {
40+
return !this.shopChest.getShopUtils().isShop(l);
41+
} else {
42+
return true;
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)