Skip to content

Commit

Permalink
Add Plethora Protection
Browse files Browse the repository at this point in the history
Move to 1.20.1
Rename to rcc-protection
  • Loading branch information
dimaguy committed Sep 3, 2024
1 parent e2f9c60 commit 39c3423
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 37 deletions.
68 changes: 65 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,71 @@ repositories {
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
mavenLocal()
maven {
name = "Flemmli97"
url "https://gitlab.com/api/v4/projects/21830712/packages/maven"
}
mavenLocal {
content {
includeModule("io.sc3", "sc-library")
includeModule("io.sc3", "sc-peripherals")
}
}

maven {
url = uri("https://repo.lem.sh/releases")
content {
includeGroup("io.sc3")
}
}

maven {
name = "squiddev"
url "https://maven.squiddev.cc"
content {
includeGroup("cc.tweaked")
includeModule("org.squiddev", "Cobalt")
}
}

maven {
name = "shedaniel"
url "https://maven.shedaniel.me"
// cloth-config
content {
includeGroup("me.shedaniel.cloth")
includeGroup("me.shedaniel.cloth.api")
}
}

maven {
name = "terraformersmc"
url "https://maven.terraformersmc.com"
// Trinkets, mod-menu
content {
includeModule("dev.emi", "trinkets")
includeGroup("com.terraformersmc")
}
}

maven {
name = "ladysnake"
url = "https://maven.ladysnake.org/releases"
// Cardinal Components API (dependency of Trinkets)
content {
includeGroup("dev.onyxstudios.cardinal-components-api")
}
}

maven {
name = "sonatype"
url "https://oss.sonatype.org/content/repositories/snapshots"
// fabric-permissions-api (dependency of sc-goodies)
content {
includeModule("me.lucko", "fabric-permissions-api")
}
}
}

dependencies {
Expand All @@ -36,6 +97,7 @@ dependencies {
modRuntimeOnly("io.github.flemmli97:flan:${flan_mcversion}-${flan_version}-fabric") {
transitive = false //Remove this if you want to have all those optional dependencies
}
modImplementation("io.sc3:Plethora-Fabric:1.12.0")
}

processResources {
Expand All @@ -47,7 +109,7 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 21
it.options.release = 17
}

java {
Expand All @@ -56,8 +118,8 @@ java {
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

jar {
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.2
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.16.3

# Mod Properties
mod_version=1.0.0
mod_version=1.1.0
maven_group=cc.reconnected.protection
archives_base_name=rcc-protection

# Dependencies
fabric_version=0.102.1+1.21.1
fabric_version=0.92.2+1.20.1

flan_mcversion=1.21
flan_version=1.10.7
flan_mcversion=1.20.1
flan_version=1.10.8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ct.protection;
package cc.reconnected.protection;

import net.fabricmc.api.ModInitializer;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package ct.protection.mixin;
package cc.reconnected.protection.mixin;

import com.mojang.logging.LogUtils;
import io.github.flemmli97.flan.api.ClaimHandler;
import io.github.flemmli97.flan.api.data.IPermissionContainer;
import io.github.flemmli97.flan.api.data.IPermissionStorage;
import io.github.flemmli97.flan.api.permission.BuiltinPermission;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.dedicated.MinecraftDedicatedServer;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
Expand All @@ -17,23 +13,9 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(MinecraftDedicatedServer.class)
public class CCTurtleProtect {
public class FlanCCProtect {
@Inject(at = @At("HEAD"), method = "isSpawnProtected", cancellable = true)
private void InjectSpawn(ServerWorld world, BlockPos pos, PlayerEntity player, CallbackInfoReturnable<Boolean> cir) {
//bad way of doing it, this uses non-api methods
MinecraftServer server = world.getServer();
IPermissionStorage storage = ClaimHandler.getPermissionStorage(world);
IPermissionContainer claim = storage.getForPermissionCheck(pos);
LogUtils.getLogger().info(String.valueOf(player.getUuid()));
cir.setReturnValue(!claim.canInteract((ServerPlayerEntity) player, BuiltinPermission.BREAK, pos));
/*
try {
cir.setReturnValue(!ClaimHandler.canInteract((ServerPlayerEntity) player, pos, BuiltinPermission.BREAK));
} catch (NullPointerException e) {
// Do nothing because this is likely just the claim not existing
cir.setReturnValue(false);
}
*/
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cc.reconnected.protection.mixin;

import io.github.flemmli97.flan.api.ClaimHandler;
import io.github.flemmli97.flan.api.permission.BuiltinPermission;
import io.sc3.plethora.gameplay.modules.laser.LaserEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(LaserEntity.class)
public abstract class FlanPlethoraProtect {
@Shadow protected abstract PlayerEntity getShooterPlayer();

@Inject(at = @At("HEAD"), method = "canDamageEntity", cancellable = true)
private void InjectDamageEntity(Entity entity, CallbackInfoReturnable<Boolean> cir) {
if (entity.isPlayer()) cir.setReturnValue(!ClaimHandler.canInteract((ServerPlayerEntity) getShooterPlayer(), entity.getBlockPos(), BuiltinPermission.HURTPLAYER));
else cir.setReturnValue(!ClaimHandler.canInteract((ServerPlayerEntity) getShooterPlayer(), entity.getBlockPos(), BuiltinPermission.HURTANIMAL));
}
}
8 changes: 4 additions & 4 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
"environment": "*",
"entrypoints": {
"main": [
"ct.protection.RCCProtection"
"cc.reconnected.protection.RCCProtection"
]
},
"mixins": [
"rcc-protection.mixins.json"
],
"depends": {
"fabricloader": ">=0.15.11",
"minecraft": "~1.21",
"java": ">=21",
"fabricloader": ">=0.16.3",
"minecraft": "~1.20.1",
"java": ">=17",
"fabric-api": "*"
},
"suggests": {
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/rcc-protection.mixins.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"required": true,
"package": "cc.reconnected.protection.mixin",
"compatibilityLevel": "JAVA_21",
"compatibilityLevel": "JAVA_17",
"mixins": [
"CCTurtleProtect"
"FlanCCProtect",
"FlanPlethoraProtect"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 39c3423

Please sign in to comment.