Skip to content

Commit

Permalink
Merge branch 'master' into database-performance-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
DrexHD committed Feb 11, 2024
2 parents c3e264a + 8b5522c commit a3cca95
Show file tree
Hide file tree
Showing 75 changed files with 1,632 additions and 145 deletions.
32 changes: 21 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,25 @@ jobs:
with:
java-version: 17

- name: Release versions
env:
CURSEFORGE_TOKEN: ${{ secrets.CF_API_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
CHANGELOG: ${{ github.event.body }}
run: ./gradlew release

- name: Upload GitHub release
uses: AButler/[email protected]
- name: Build release
run: ./gradlew build

- name: Upload assets to GitHub, Modrinth and CurseForge
uses: Kir-Antipov/[email protected]
with:
files: 'build/libs/*.jar;!build/libs/*-sources.jar;!build/libs/*-dev-all.jar'
repo-token: ${{ secrets.GITHUB_TOKEN }}
modrinth-id: LVN9ygNV
modrinth-featured: false
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}

curseforge-id: 491137
curseforge-token: ${{ secrets.CF_API_TOKEN }}

github-token: ${{ secrets.GITHUB_TOKEN }}

loaders: |
fabric
quilt
files: |
build/libs/!(*-@(dev-all|sources|javadoc)).jar
build/libs/*-@(dev-all|sources|javadocs).jar
11 changes: 7 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ plugins {
`maven-publish`
}

var release = false
val props = properties

val modId: String by project
Expand Down Expand Up @@ -103,6 +102,7 @@ tasks {
"name" to modName,
"fabricApi" to libs.versions.fabric.api.get(),
"fabricKotlin" to libs.versions.fabric.kotlin.get(),
"minecraft" to libs.versions.minecraft.get(),
)
)
}
Expand Down Expand Up @@ -202,15 +202,18 @@ gitHooks {
}

fun getVersionMetadata(): String {
if (release) return ""

val buildId = System.getenv("GITHUB_RUN_NUMBER")
val workflow = System.getenv("GITHUB_WORKFLOW")

if (workflow == "Release") {
return ""
}

// CI builds only
if (buildId != null) {
return "+build.$buildId"
}

// No tracking information could be found about the build
return ""
return "+local"
}
4 changes: 2 additions & 2 deletions docs/commands/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ After executing your search, you will see all the results and can paginate betwe
![Search example](../assets/search-example.png)

| `Display:` | Time ago | Source of the action | Action that occurred | Object that was changed | Location |
|------------|------------|----------------------|---------------------|-------------------------|-------------------|
| `Hover:` | Exact time | | Action identifier | Object identifier | Teleport on click |
|------------|------------|----------------------|----------------------|-------------------------|-------------------|
| `Hover:` | Exact time | | Action identifier | Object identifier | Teleport on click |

*Order can be customized, see [configuration](../config.md)*
12 changes: 6 additions & 6 deletions docs/commands/status.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Permission: `ledger.commands.status`
### `/ledger status`
This command will give you the following information.

| Info | Explanation |
|--------------|-----------------------------------------------------------------|
| Version | The current version of Ledger on your server |
| Queue Status | Whether or not the [queue](../queue.md) is **free** or **busy**.|
| Discord | A link to the Fabric Server Tools discord for support |
| Wiki | A link to the wiki |
| Info | Explanation |
|--------------|------------------------------------------------------------------|
| Version | The current version of Ledger on your server |
| Queue Status | Whether or not the [queue](../queue.md) is **free** or **busy**. |
| Discord | A link to the Fabric Server Tools discord for support |
| Wiki | A link to the wiki |

![status example](../assets/status-example.png)
9 changes: 7 additions & 2 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Found under `[search]`

`purgePermissionLevel` [Default: 4] controls the permission level required to run the purge command

`timeZone` [Default: "UTC"] sets the timezone to display timestamps in when hovered.
This uses the Java TimeZone format. You can provide offsets ("UTC", "UTC+3"), but the "continent/region" format is preferred. A full list can be found [here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).

### Message theme

Found under `[color]`
Expand All @@ -49,7 +52,7 @@ blocks = ["minecraft:air", "minecraft:dirt"]

`objectBlacklist` [Default: empty] controls which objects are logged. These can be item types, block types or entities

`sourceBlacklist` [Default: empty] controls which sources are logged. Examples are `"lava"` and `"gravity"`
`sourceBlacklist` [Default: empty] controls which sources are logged. Examples are `"lava"`, `"@playerName"` and `"gravity"`. Player names can be specified by prefixing them with `"@"`

## Default Config
```toml
Expand All @@ -64,6 +67,8 @@ queueCheckDelaySec = 10
pageSize = 8
# Permission level for purge command
purgePermissionLevel = 4
# Time zone to display timestamps in. EX: "UTC", "UTC+1", "America/Los_Angeles"
timeZone = "UTC"

[color]
# Colors in hex format
Expand All @@ -87,7 +92,7 @@ typeBlacklist = []
worldBlacklist = []
# Blacklists objects (Items, Mobs, Blocks). Ex: "minecraft:cobblestone", "minecraft:blaze"
objectBlacklist = []
# Blacklists sources. Ex: "lava", "gravity", "fire", "fall"
# Blacklists sources. Ex: "lava", "gravity", "fire", "fall", "@playerName"
sourceBlacklist = []

[networking]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;

@Mixin(AnvilScreenHandler.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.github.quiltservertools.ledger.mixin;

import com.github.quiltservertools.ledger.callbacks.EntityModifyCallback;
import com.github.quiltservertools.ledger.utility.Sources;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.DyeItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(DyeItem.class)
public abstract class DyeItemMixin {
@Unique
private NbtCompound oldEntityTags;

@Inject(method = "useOnEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/SheepEntity;setColor(Lnet/minecraft/util/DyeColor;)V"))
private void ledgerOldEntity(ItemStack stack, PlayerEntity player, LivingEntity entity, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
oldEntityTags = entity.writeNbt(new NbtCompound());
}

@Inject(method = "useOnEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/SheepEntity;setColor(Lnet/minecraft/util/DyeColor;)V", shift = At.Shift.AFTER))
private void ledgerPlayerDyeSheep(ItemStack stack, PlayerEntity player, LivingEntity entity, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
EntityModifyCallback.EVENT.invoker().modify(player.getWorld(), entity.getBlockPos(), oldEntityTags, entity, stack, player, Sources.DYE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;

@Mixin(ItemScatterer.class)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.github.quiltservertools.ledger.mixin.blocks;

import com.github.quiltservertools.ledger.callbacks.BlockBreakCallback;
import com.github.quiltservertools.ledger.utility.Sources;
import net.minecraft.block.BedBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.enums.BedPart;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(BedBlock.class)
public abstract class BedBlockMixin {
@Unique
private BlockEntity oldBlockEntity = null;

@Inject(method = "onBreak", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
public void storeBlockEntity(World world, BlockPos pos, BlockState state, PlayerEntity player, CallbackInfoReturnable<BlockState> cir, BedPart bedPart, BlockPos blockPos, BlockState blockState) {
oldBlockEntity = world.getBlockEntity(blockPos);
}

@Inject(method = "onBreak", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
public void logBedBreak(World world, BlockPos pos, BlockState state, PlayerEntity player, CallbackInfoReturnable<BlockState> cir, BedPart bedPart, BlockPos blockPos, BlockState blockState) {
BlockBreakCallback.EVENT.invoker().breakBlock(world, blockPos, blockState, oldBlockEntity, player);
}

@Inject(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;removeBlock(Lnet/minecraft/util/math/BlockPos;Z)Z"))
public void storeBlockEntity(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
oldBlockEntity = world.getBlockEntity(pos);
}

@Inject(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;removeBlock(Lnet/minecraft/util/math/BlockPos;Z)Z", shift = At.Shift.AFTER))
public void logBedExplosion(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, state, oldBlockEntity, Sources.INTERACT, player);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.github.quiltservertools.ledger.mixin.blocks;

import com.github.quiltservertools.ledger.callbacks.BlockBreakCallback;
import com.github.quiltservertools.ledger.utility.Sources;
import net.minecraft.block.BlockState;
import net.minecraft.block.CactusBlock;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(CactusBlock.class)
public abstract class CactusBlockMixin {
@Inject(method = "scheduledTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;breakBlock(Lnet/minecraft/util/math/BlockPos;Z)Z"))
public void logCactusBreak(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) {
BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, state, null, Sources.GRAVITY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.minecraft.block.BlockState;
import net.minecraft.block.CampfireBlock;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.CampfireBlockEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.github.quiltservertools.ledger.mixin.blocks;

import com.github.quiltservertools.ledger.callbacks.BlockBreakCallback;
import com.github.quiltservertools.ledger.utility.Sources;
import net.minecraft.block.CarvedPumpkinBlock;
import net.minecraft.block.pattern.BlockPattern;
import net.minecraft.block.pattern.CachedBlockPosition;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(CarvedPumpkinBlock.class)
public abstract class CarvedPumpkinBlockMixin {
@Inject(method = "breakPatternBlocks", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
private static void logStatueBreak(World world, BlockPattern.Result patternResult, CallbackInfo ci, int i, int j, CachedBlockPosition cachedBlockPosition) {
if (cachedBlockPosition.getBlockState().isAir()) {
return;
}
BlockBreakCallback.EVENT.invoker().breakBlock(world, cachedBlockPosition.getBlockPos(), cachedBlockPosition.getBlockState(), cachedBlockPosition.getBlockEntity(), Sources.STATUE);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.github.quiltservertools.ledger.mixin.blocks;

import com.github.quiltservertools.ledger.callbacks.BlockBreakCallback;
import com.github.quiltservertools.ledger.utility.Sources;
import net.minecraft.block.BlockState;
import net.minecraft.block.ChorusFlowerBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ChorusFlowerBlock.class)
public abstract class ChorusFlowerBlockMixin {
@Inject(method = "onProjectileHit", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;breakBlock(Lnet/minecraft/util/math/BlockPos;ZLnet/minecraft/entity/Entity;)Z"))
public void logChorusFlowerBreak(World world, BlockState state, BlockHitResult hit, ProjectileEntity projectile, CallbackInfo ci) {
Entity entity = projectile.getOwner();
if (entity instanceof PlayerEntity player) {
BlockBreakCallback.EVENT.invoker().breakBlock(world, hit.getBlockPos(), state, null, Sources.PROJECTILE, player);
} else {
BlockBreakCallback.EVENT.invoker().breakBlock(world, hit.getBlockPos(), state, null, Sources.PROJECTILE);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.github.quiltservertools.ledger.mixin.blocks;

import com.github.quiltservertools.ledger.callbacks.BlockBreakCallback;
import com.github.quiltservertools.ledger.utility.Sources;
import net.minecraft.block.BlockState;
import net.minecraft.block.ChorusPlantBlock;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ChorusPlantBlock.class)
public abstract class ChorusPlantBlockMixin {
@Inject(method = "scheduledTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;breakBlock(Lnet/minecraft/util/math/BlockPos;Z)Z"))
public void logChorusPlantBreak(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) {
BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, state, null, Sources.GRAVITY);
}
}
Loading

0 comments on commit a3cca95

Please sign in to comment.