Skip to content

Commit d448602

Browse files
Merge pull request #73 from EpicPlayerA10/feature/shopchest
Added ShopChest Protection Module
2 parents 3e4f511 + cf1a7db commit d448602

4 files changed

Lines changed: 63 additions & 0 deletions

File tree

dough-api/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,14 @@
245245
<version>1.0.2-e60150d</version>
246246
<scope>provided</scope>
247247
</dependency>
248+
249+
<!-- ShopChest -->
250+
<dependency>
251+
<groupId>de.epiceric</groupId>
252+
<artifactId>ShopChest</artifactId>
253+
<version>1.13-SNAPSHOT</version>
254+
<scope>provided</scope>
255+
</dependency>
248256

249257
</dependencies>
250258

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import io.github.bakedlibs.dough.protection.modules.PlotSquaredProtectionModule;
3333
import io.github.bakedlibs.dough.protection.modules.PreciousStonesProtectionModule;
3434
import io.github.bakedlibs.dough.protection.modules.RedProtectProtectionModule;
35+
import io.github.bakedlibs.dough.protection.modules.ShopChestProtectionModule;
3536
import io.github.bakedlibs.dough.protection.modules.TownyProtectionModule;
3637
import io.github.bakedlibs.dough.protection.modules.WorldGuardProtectionModule;
3738

@@ -92,6 +93,7 @@ private void loadModuleImplementations(Plugin plugin) {
9293
registerModule(pm, "FunnyGuilds", funnyGuilds -> new FunnyGuildsProtectionModule(funnyGuilds));
9394
registerModule(pm, "PlotSquared", plotSquared -> new PlotSquaredProtectionModule(plotSquared));
9495
registerModule(pm, "HuskTowns", huskTowns -> new HuskTownsProtectionModule(huskTowns));
96+
registerModule(pm, "ShopChest", shopChest -> new ShopChestProtectionModule(shopChest));
9597
registerModule(pm, "HuskClaims", huskClaims -> new HuskClaimsProtectionModule(huskClaims));
9698

9799
/*
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)