Skip to content

Commit

Permalink
improve project
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiao-MoMi committed Feb 27, 2024
1 parent cfd9356 commit 6f800a6
Show file tree
Hide file tree
Showing 22 changed files with 477 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

# build cache
build/
target/
.gradle/
.idea/

Expand Down
53 changes: 52 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
### Supported Plugins
BentoBox \
CrashClaim \
FabledSkyBlock \
FactionsUUID \
GriefDefender \
GriefPrevention \
HuskClaims \
HuskTowns \
IridiumSkyBlock \
KingdomsX \
Landlord \
Lands \
PlotSquared \
ProtectionStones \
RedProtect \
Residence \
SaberFactions \
SuperiorSkyBlock \
Towny \
USkyBlock \
WorldGuard

### Use this project as dependency
![GitHub](https://img.shields.io/github/license/Xiao-MoMi/AntiGriefLib)
[![](https://jitpack.io/v/Xiao-MoMi/AntiGriefLib.svg)](https://jitpack.io/#Xiao-MoMi/AntiGriefLib)
[![](https://jitpack.io/v/Xiao-MoMi/AntiGriefLib.svg)](https://jitpack.io/#Xiao-MoMi/AntiGriefLib) \
Gradle (kts)
```
repositories {
maven("https://jitpack.io/")
Expand All @@ -9,4 +34,30 @@ repositories {
dependencies {
compileOnly("com.github.Xiao-MoMi:AntiGriefLib:{LATEST}")
}
```

### API Guide
```java
// create a lib instance
var lib = AntiGriefLib.builder(this)
.silentLogs(true)
.ignoreOP(true)
.placeFlag(
Flag.builder("custom-place")
.defaultValue(false)
.displayName("Custom place")
.description(List.of("My custom place flag"))
.displayItem(new ItemStack(Material.STONE))
.build()
)
.addCompatibility(new MyCustomAntiGriefImpl())
.build();

// init the lib after all the compatible plugins enabled
lib.init();

// use the api to check permissions
if (!lib.canPlace(player, location)) {
player.sendMessage(Component.text("You can't place it here!"));
}
```
17 changes: 11 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
plugins {
id("java")
id("maven-publish")
id("com.github.johnrengelman.shadow") version "8.1.1"
}

val projectVersion : String by project
val projectGroup : String by project

subprojects {
allprojects {

apply(plugin = "java")
apply(plugin = "maven-publish")

tasks.jar {
archiveFileName = "AntiGriefLib-${projectVersion}.jar"
}
apply(plugin = "com.github.johnrengelman.shadow")

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(17)
}

if ("project" == project.name) {

tasks.shadowJar {
destinationDirectory.set(file("$rootDir/target"))
archiveClassifier.set("")
archiveFileName.set("AntiGriefLib-${projectVersion}.jar")
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
groupId = "net.momirealms"
artifactId = "AntiGriefLib"
version = rootProject.version.toString()
artifact(tasks.jar)
artifact(tasks.shadowJar)
}
}
}
Expand Down
42 changes: 42 additions & 0 deletions common/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
8 changes: 8 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
repositories {
mavenCentral()
maven("https://papermc.io/repo/repository/maven-public/") // Paper
}

dependencies {
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT") // Paper
}
42 changes: 42 additions & 0 deletions conflict-packages/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
13 changes: 13 additions & 0 deletions conflict-packages/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repositories {
mavenCentral()
maven("https://papermc.io/repo/repository/maven-public/") // Paper
maven("https://jitpack.io/") // SaberFactions
maven("https://repo.codemc.org/repository/maven-public/") // NBTAPI
}

@Suppress
dependencies {
implementation(project(":common"))
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT") // Paper
compileOnly("com.github.SaberLLC:Saber-Factions:4.1.2-STABLE") // SaberFactions
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package net.momirealms.antigrieflib.comp;

import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import net.momirealms.antigrieflib.AbstractComp;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Optional;

public class SaberFactionsComp extends AbstractComp {

public SaberFactionsComp(JavaPlugin plugin) {
super(plugin, "SaberFactions");
}

@Override
public void init() {
}

@Override
public boolean canPlace(Player player, Location location) {
return Optional.ofNullable(Board.getInstance().getFactionAt(FLocation.wrap(location)))
.map(faction -> faction.getAccess(FPlayers.getInstance().getByPlayer(player), PermissableAction.BUILD) == Access.ALLOW)
.orElse(true);
}

@Override
public boolean canBreak(Player player, Location location) {
return Optional.ofNullable(Board.getInstance().getFactionAt(FLocation.wrap(location)))
.map(faction -> faction.getAccess(FPlayers.getInstance().getByPlayer(player), PermissableAction.DESTROY) == Access.ALLOW)
.orElse(true);
}

@Override
public boolean canInteract(Player player, Location location) {
return Optional.ofNullable(Board.getInstance().getFactionAt(FLocation.wrap(location)))
.map(faction -> faction.getAccess(FPlayers.getInstance().getByPlayer(player), PermissableAction.CONTAINER) == Access.ALLOW)
.orElse(true);
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
projectVersion = 0.1
projectVersion = 0.5
projectGroup=net.momirealms

#systemProp.socks.proxyHost=127.0.0.1
Expand Down
17 changes: 15 additions & 2 deletions project/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
repositories {
mavenCentral()
mavenCentral() // ProtectionStones
maven("https://papermc.io/repo/repository/maven-public/") // Paper, PlotSquared
maven("https://maven.enginehub.org/repo/") // WorldGuard
maven("https://jitpack.io/") // Lands
maven("https://jitpack.io/") // Lands, GriefPrevention
maven("https://nexus.iridiumdevelopment.net/repository/maven-releases/") // IridiumSkyblock
maven("https://repo.codemc.org/repository/maven-public/") // BentoBox
maven("https://repo.glaremasters.me/repository/bloodshot/") // GriefDefender
maven("https://repo.william278.net/releases/") // HuskTowns, HuskClaims
maven("https://repo.bg-software.com/repository/api/") // SuperiorSkyblock
maven("https://repo.glaremasters.me/repository/towny/") // Towny
maven("https://repo.craftaro.com/repository/minecraft-plugins/") // FabledSkyBlock
maven("https://ci.ender.zone/plugin/repository/everything/") // FactionsUUID
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") // RedProtect
maven("https://eldonexus.de/repository/maven-releases/") // Landlord
maven("https://www.uskyblock.ovh/maven/uskyblock/") // uSkyBlock
}

dependencies {
implementation(project(":common"))
implementation(project(":conflict-packages")) // SaberFactions
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT") // Paper
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.9") // WorldGuard
compileOnly("com.github.angeschossen:LandsAPI:6.44.10") // Lands
Expand All @@ -25,8 +31,15 @@ dependencies {
compileOnly("com.bgsoftware:SuperiorSkyblockAPI:2023.3") // SuperiorSkyblock2
compileOnly("com.palmergames.bukkit.towny:towny:0.100.1.17") // Towny
compileOnly("com.craftaro:FabledSkyBlock:3.0.4") // FabledSkyBlock
compileOnly("com.github.TechFortress:GriefPrevention:16.18.2") // GriefPrevention
compileOnly("com.massivecraft:Factions:1.6.9.5-U0.6.33") // FactionsUUID
compileOnly("dev.espi:protectionstones:2.10.2") // ProtectionStones
compileOnly("biz.princeps:landlord-core:4.364") // Landlord
compileOnly("ovh.uskyblock:uSkyBlock-Core:3.0.0") // uSkyBlock
compileOnly(files("libs/Residence-pruned.jar")) // Residence
compileOnly(files("libs/KingdomsX-pruned.jar")) // KingdomsX
compileOnly(files("libs/CrashClaim-pruned.jar")) // CrashClaim
compileOnly("io.github.fabiozumbi12.RedProtect:RedProtect-Core:8.1.1") { exclude(group = "*") } // RedProtect
compileOnly("io.github.fabiozumbi12.RedProtect:RedProtect-Spigot:8.1.1") { exclude(group = "*") } // RedProtect
}

Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,30 @@ private void detectSupportedPlugins() {
if (manager.getPlugin("FabledSkyBlock") != null) {
registerNewCompatibility(new FabledSkyBlockComp(plugin));
}
if (manager.getPlugin("GriefPrevention") != null) {
registerNewCompatibility(new GriefPreventionComp(plugin));
}
if (manager.getPlugin("RedProtect") != null) {
registerNewCompatibility(new RedProtectComp(plugin));
}
if (manager.getPlugin("Landlord") != null) {
registerNewCompatibility(new LandlordComp(plugin));
}
if (manager.getPlugin("uSkyBlock") != null) {
registerNewCompatibility(new USkyBlockComp(plugin));
}
if (manager.getPlugin("Factions") != null) {
try {
Class.forName("com.massivecraft.factions.zcore.fperms.PermissableAction");
registerNewCompatibility(new SaberFactionsComp(plugin));
} catch (ClassNotFoundException ignore) {
}
try {
Class.forName("com.massivecraft.factions.perms.PermissibleActions");
registerNewCompatibility(new FactionsUUIDComp(plugin));
} catch (ClassNotFoundException ignore) {
}
}
}

private void logHook(String pluginName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

import com.craftaro.skyblock.api.SkyBlockAPI;
import net.momirealms.antigrieflib.AbstractComp;
import net.momirealms.antigrieflib.CustomFlag;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Optional;

public class FabledSkyBlockComp extends AbstractComp implements CustomFlag {
public class FabledSkyBlockComp extends AbstractComp {

public FabledSkyBlockComp(JavaPlugin plugin) {
super(plugin, "FabledSkyBlock");
Expand Down
Loading

0 comments on commit 6f800a6

Please sign in to comment.