-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rename
protectj module
into multiplier module
and gener…
…alized the module.
- Loading branch information
1 parent
524bf75
commit d4abbfc
Showing
7 changed files
with
118 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/main/java/io/github/sakurawald/module/mixin/chat/ServerGamePacketListenerImplMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/io/github/sakurawald/module/mixin/multiplier/ServerPlayerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.github.sakurawald.module.mixin.multiplier; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import io.github.sakurawald.util.LuckPermsUtil; | ||
import lombok.extern.slf4j.Slf4j; | ||
import net.minecraft.entity.damage.DamageSource; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyVariable; | ||
|
||
import java.util.Optional; | ||
|
||
@Mixin(ServerPlayerEntity.class) | ||
@Slf4j | ||
public abstract class ServerPlayerMixin { | ||
|
||
@Unique | ||
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this; | ||
|
||
@Unique | ||
float transform(ServerPlayerEntity player, String type, String key, float f) { | ||
Optional<Float> meta = LuckPermsUtil.getMeta(player, "fuji.multiplier.%s.%s".formatted(type, key), Float::valueOf); | ||
return meta.map(factor -> f * factor).orElse(f); | ||
} | ||
|
||
@ModifyVariable(method = "damage", at = @At(value = "HEAD"), argsOnly = true) | ||
public float transformDamage(float damage, @Local(argsOnly = true) DamageSource damageSource) { | ||
damage = transform(player, "damage", "all", damage); | ||
damage = transform(player, "damage", damageSource.getTypeRegistryEntry().getIdAsString(), damage); | ||
return damage; | ||
} | ||
|
||
@ModifyVariable(method = "addExperience", at = @At(value = "HEAD"), argsOnly = true) | ||
public int transformExperience(int exp) { | ||
exp = (int) transform(player, "experience", "all", exp); | ||
return exp; | ||
} | ||
|
||
} |
33 changes: 0 additions & 33 deletions
33
src/main/java/io/github/sakurawald/module/mixin/protect/ServerPlayerMixin.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters