Skip to content

Commit d23732e

Browse files
authored
WorldGuard & Residence hooks, fix TConstruct traits (#4)
* WorldGuard hook, fix Residence hooks, fix TConstruct traits, and detailed errors Prepare for 0.1.0 * Include WorldGuard jar
1 parent 6b1aaa7 commit d23732e

File tree

15 files changed

+180
-14
lines changed

15 files changed

+180
-14
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Provide bugfixes, optimizations and utilities for Forge+Bukkit server environmen
1717
- Fix Twilight Forest entities(e.g. Naga) can break blocks in protected areas
1818
- Fix Twilight Forest Chain with Block can break blocks in protected areas
1919
- Fix Thaumcraft 6 taint can spread into protected areas
20+
- Fix trait effects in Tinkers' Construct can bypass damage protection
2021

2122
## Features
2223

@@ -30,6 +31,13 @@ Provide bugfixes, optimizations and utilities for Forge+Bukkit server environmen
3031

3132
Configuration file is under `${minecraftDir}/config/hybridfix.cfg`
3233

34+
## Plugin Hooks
35+
Thanks to HybridFix internal plugin, we can hook into plugins from Forge side to provide more fixes.
36+
37+
Currently patched plugins:
38+
- Residence[(SpigotMC)](https://www.spigotmc.org/resources/residence-1-7-10-up-to-1-21.11480/)[(GitHub)](https://github.com/Zrips/Residence)
39+
- WorldGuard[(BukkitDev)](https://dev.bukkit.org/projects/worldguard)[(GitHub)](https://github.com/EngineHub/WorldGuard)
40+
3341
## Commands
3442

3543
- `/hybridfix dumpitem` - Show details of the item in hand.

build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,18 @@ dependencies {
125125
compileOnly 'org.spigotmc:spigot:1.12.2-R0.1-SNAPSHOT'
126126

127127
compileOnly files("libs/Residence5.1.6.4.jar")
128+
compileOnly files("libs/worldguard-bukkit-6.2.2.jar")
128129

129130
// The twilight forest
130131
compileOnly rfg.deobf("curse.maven:the-twilight-forest-227639:3051450")
131132

132133
// Thaumcraft 6
133134
compileOnly rfg.deobf('curse.maven:thaumcraft-223628:2629023')
134135
compileOnly rfg.deobf('curse.maven:baubles-227083:2518667')
136+
137+
// Tinkers Construct
138+
compileOnly rfg.deobf("curse.maven:tinkers-construct-74072:2902483")
139+
compileOnly rfg.deobf("curse.maven:mantle-74924:2713386")
135140
if (propertyBool('use_modern_java_syntax')) {
136141
annotationProcessor 'com.github.bsideup.jabel:jabel-javac-plugin:1.0.0'
137142
// Workaround for https://github.com/bsideup/jabel/issues/174

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ mixin_booter_version = 10.5
101101
# You should change package root once they are generated
102102
generate_mixins_json = true
103103
# Delimit configs with spaces. Should only put configs name instead of full file name
104-
mixin_configs = fix.respawn thaumcraft.taint twilight_forest.item twilight_forest.entity twilight_forest.sapling bridge.duck bridge.explosion.mohist fix.respawn.mohist perf.eventbus perf.server perf.timings.v1 misc.command bukkit.plugin
104+
mixin_configs = fix.respawn tconstruct.tools thaumcraft.taint twilight_forest.item twilight_forest.entity twilight_forest.sapling bridge.duck bridge.explosion.mohist fix.respawn.mohist perf.eventbus perf.server perf.timings.v1 misc.command bukkit.plugin
105105
# A refmap is a json that denotes mapping conversions, this json is generated automatically, with the name `mixins.mod_id.refmap.json`
106106
# Use the property `mixin_refmap` if you want it to use a different name, only one name is accepted
107107
mixin_refmap = mixins.${mod_id}.refmap.json

libs/worldguard-bukkit-6.2.2.jar

1.04 MB
Binary file not shown.

src/main/java/io/wdsj/hybridfix/HybridFix.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ public void onPreInit(FMLPreInitializationEvent event) {
2424
LOGGER.warn("HybridFix requires a Forge+Bukkit server environment to work properly, disabling.");
2525
return;
2626
}
27-
if (HAS_CLEANROOM) {
28-
return;
29-
}
3027
HybridFixServer.preInit();
3128
}
3229

src/main/java/io/wdsj/hybridfix/HybridFixLateLoader.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public class HybridFixLateLoader implements ILateMixinLoader {
2727
put("mixins.twilight_forest.entity.json", () -> isModLoaded("twilightforest") && Settings.modPatchSettings.patchTwilightForestEntityEvent);
2828
// Thaumcraft patches
2929
put("mixins.thaumcraft.taint.json", () -> isModLoaded("thaumcraft") && Settings.modPatchSettings.patchThaumcraftTaintSpread);
30+
// Tconstruct patches
31+
put("mixins.tconstruct.tools.json", () -> isModLoaded("tconstruct") && Settings.modPatchSettings.patchTconstructToolDamage);
3032
}
3133
});
3234

src/main/java/io/wdsj/hybridfix/HybridFixServer.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,22 @@
99
import io.wdsj.hybridfix.util.Utils;
1010
import net.minecraftforge.common.MinecraftForge;
1111
import net.minecraftforge.server.permission.PermissionAPI;
12+
import org.bukkit.Bukkit;
13+
import org.bukkit.craftbukkit.v1_12_R1.CraftCrashReport;
14+
15+
import java.util.logging.Level;
16+
17+
import static io.wdsj.hybridfix.HybridFix.HAS_CLEANROOM;
1218

1319
public class HybridFixServer {
1420
public static void preInit() {
15-
if (Settings.passExplosionEventToBukkit) {
16-
MinecraftForge.EVENT_BUS.register(new ExplosionHandler());
17-
}
18-
if (Settings.bridgeForgePermissionsToBukkit) {
19-
PermissionAPI.setPermissionHandler(new BukkitForgePermissionHandler());
21+
if (!HAS_CLEANROOM) {
22+
if (Settings.passExplosionEventToBukkit) {
23+
MinecraftForge.EVENT_BUS.register(new ExplosionHandler());
24+
}
25+
if (Settings.bridgeForgePermissionsToBukkit) {
26+
PermissionAPI.setPermissionHandler(new BukkitForgePermissionHandler());
27+
}
2028
}
2129
}
2230

@@ -39,4 +47,9 @@ public static void onStartComplete() {
3947
});
4048
}
4149
}
50+
51+
public static void createServerDump(Throwable t) {
52+
HybridFix.LOGGER.error("--- REPORT THIS TO YOUR SERVER SOFTWARE - If you think this is a HybridFix bug, please report it at https://github.com/HaHaWTH/HybridFix/issues - THIS IS NOT A CRASH - {} ---", Bukkit.getServer().getVersion());
53+
HybridFix.LOGGER.error(t);
54+
}
4255
}

src/main/java/io/wdsj/hybridfix/config/Settings.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,17 @@ public static class ModPatchSettings {
7575
@Config.Comment("Patch taint in thaumcraft spread event.")
7676
@Config.RequiresMcRestart
7777
public boolean patchThaumcraftTaintSpread = true;
78+
79+
@Config.Comment("Patch Tinkers Construct tool damage,\nUseful for some traits that adds extra effects and disarming, etc.\nYou can use property -Dhybridfix.tconstruct.supersedeVanillaEvent=true to prevent calling original damage event.")
80+
@Config.RequiresMcRestart
81+
public boolean patchTconstructToolDamage = false;
7882
}
7983
@Config.Comment("Configuration for HybridFix built-in bukkit plugin.")
8084
@Config.RequiresMcRestart
8185
public static BukkitPluginSettings bukkitPluginConfig = new BukkitPluginSettings();
8286

8387
public static class BukkitPluginSettings {
84-
@Config.Comment("Enable HybridFix built-in bukkit plugin.(All bukkit plugin features in this section won't work if you disabled this!)")
88+
@Config.Comment("Enable HybridFix built-in bukkit plugin.\n***All bukkit plugin features in this section won't work if you disabled this!***")
8589
@Config.RequiresMcRestart
8690
public boolean enable = false;
8791

@@ -93,6 +97,10 @@ public static class BukkitPluginSettings {
9397
@Config.RequiresMcRestart
9498
public boolean hookResidence = false;
9599

100+
@Config.Comment("Enable HybridFix WorldGuard hook.")
101+
@Config.RequiresMcRestart
102+
public boolean hookWorldGuard = false;
103+
96104
@Config.Comment("Worlds that AntiExplode should protect.")
97105
@Config.RequiresMcRestart
98106
public String[] antiExplodeWorlds = new String[]{"world", "DIM-1", "DIM1"};

src/main/java/io/wdsj/hybridfix/entry/bukkit/hook/residence/ResHookBlockFormListener.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import com.bekvon.bukkit.residence.Residence;
44
import com.bekvon.bukkit.residence.containers.Flags;
55
import com.bekvon.bukkit.residence.protection.FlagPermissions;
6+
import org.bukkit.Material;
7+
import org.bukkit.block.BlockState;
8+
import org.bukkit.entity.Snowman;
69
import org.bukkit.event.EventHandler;
710
import org.bukkit.event.EventPriority;
811
import org.bukkit.event.Listener;
@@ -17,6 +20,13 @@ public void onForm(BlockFormEvent event) {
1720
Residence plugin = Residence.getInstance();
1821
if (plugin == null) return;
1922
if (plugin.isDisabledWorldListener(event.getBlock().getWorld())) return;
23+
// Skip checks that have already been done by Residence
24+
if (((EntityBlockFormEvent) event).getEntity() instanceof Snowman) return;
25+
final BlockState newState = event.getNewState();
26+
Material newType = newState.getType();
27+
if (newType == Material.SNOW || newType == Material.ICE || newType == Material.FROSTED_ICE) return;
28+
// End
29+
2030
FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
2131
if (!perms.has(Flags.spread, true)) {
2232
event.setCancelled(true);

src/main/java/io/wdsj/hybridfix/entry/bukkit/hook/residence/ResHookEntityChangeBlockListener.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.bekvon.bukkit.residence.Residence;
44
import com.bekvon.bukkit.residence.containers.Flags;
55
import com.bekvon.bukkit.residence.protection.FlagPermissions;
6+
import org.bukkit.entity.Entity;
7+
import org.bukkit.entity.EntityType;
68
import org.bukkit.event.EventHandler;
79
import org.bukkit.event.EventPriority;
810
import org.bukkit.event.Listener;
@@ -15,6 +17,12 @@ public void onChangeBlock(EntityChangeBlockEvent event) {
1517
if (plugin == null) return;
1618
// disabling event on world
1719
if (plugin.isDisabledWorldListener(event.getBlock().getWorld())) return;
20+
// Skip checks that have already been done by Residence
21+
Entity entity = event.getEntity();
22+
EntityType type = entity.getType();
23+
if (type == EntityType.ENDERMAN || type == EntityType.WITHER) return;
24+
// End
25+
1826
FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
1927
if (!perms.has(Flags.destroy, true)) {
2028
event.setCancelled(true);

0 commit comments

Comments
 (0)