-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix workflow indentations * Vault reset working * Squashed commit of the following: commit ad57afd Author: GroobleDierne <[email protected]> Date: Tue Dec 10 17:32:18 2024 +0100 Test when disabling cache commit dc1a04d Author: GroobleDierne <[email protected]> Date: Tue Dec 10 17:22:11 2024 +0100 Test commit e9d2bb1 Author: GroobleDierne <[email protected]> Date: Tue Dec 10 17:11:02 2024 +0100 Update gradle commit 34e55d9 Author: GroobleDierne <[email protected]> Date: Tue Dec 10 16:48:52 2024 +0100 Update gh actions commit f660bce Author: GroobleDierne <[email protected]> Date: Tue Dec 10 14:31:45 2024 +0100 Update gradle version commit 56b6c4d Author: Grooble <[email protected]> Date: Tue Dec 10 14:28:16 2024 +0100 Update ci-cd.yml commit 9bed99e Author: GroobleDierne <[email protected]> Date: Tue Dec 10 14:26:35 2024 +0100 Fix yml syntax may be commit 7d12c66 Merge: b2a9b35 8550650 Author: Grooble <[email protected]> Date: Tue Dec 10 14:19:26 2024 +0100 Merge pull request #23 from LaBoulangerie/1.21 1.21
- Loading branch information
1 parent
ad57afd
commit d10bfc9
Showing
5 changed files
with
143 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,28 +12,27 @@ jobs: | |
- name: JDk 21 setup | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 1.21 | ||
# - uses: actions/cache@v4 | ||
# env: | ||
# cache-name: cache-gradle | ||
# with: | ||
# path: | | ||
# ~/.gradle/caches | ||
# ~/.gradle/wrapper | ||
# .gradle/caches | ||
# key: ${{ runner.os }}-gradle-${{ env.cache-name }}-${{ hashFiles('*.gradle.kts', '**/gradle-wrapper.properties') }} | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
java-version: 1.21 | ||
- uses: actions/cache@v3 | ||
env: | ||
cache-name: cache-gradle | ||
with: | ||
gradle-version: "8.11.1" | ||
- name: Compile | ||
run: ./gradlew assemble | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
.gradle/caches | ||
key: ${{ runner.os }}-gradle-${{ env.cache-name }}-${{ hashFiles('*.gradle.kts', '**/gradle-wrapper.properties') }} | ||
- name: Gradle Build Action | ||
uses: gradle/[email protected] | ||
with: | ||
gradle-version: "7.4.1" | ||
arguments: assemble | ||
- name: Clean build outputs | ||
run: rm build/libs/LaBoulangerieCore-*dev*.jar | ||
- uses: actions/upload-artifact@v4 | ||
- uses: actions/upload-artifact@v1 | ||
with: | ||
name: laboulangeriecore | ||
path: build/libs/ | ||
name: laboulangeriecore | ||
path: build/libs/ | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: [build] | ||
|
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
77 changes: 77 additions & 0 deletions
77
src/main/java/net/laboulangerie/laboulangeriecore/misc/VaultsReset.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,77 @@ | ||
package net.laboulangerie.laboulangeriecore.misc; | ||
|
||
import java.util.List; | ||
|
||
import org.bukkit.Material; | ||
import org.bukkit.World; | ||
import org.bukkit.craftbukkit.CraftWorld; | ||
|
||
import com.sk89q.worldedit.bukkit.BukkitAdapter; | ||
import com.sk89q.worldedit.math.BlockVector3; | ||
import com.sk89q.worldguard.WorldGuard; | ||
import com.sk89q.worldguard.protection.managers.RegionManager; | ||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; | ||
import com.sk89q.worldguard.protection.regions.ProtectedRegion; | ||
import com.sk89q.worldguard.protection.regions.RegionContainer; | ||
|
||
import net.laboulangerie.laboulangeriecore.LaBoulangerieCore; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.HolderLookup; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
|
||
public class VaultsReset { | ||
|
||
public static void reset() { | ||
List<String> regionWorldPairs = LaBoulangerieCore.PLUGIN.getConfig().getStringList("vault-reset-regions"); | ||
|
||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); | ||
|
||
for (String regionWorldPair : regionWorldPairs) { | ||
String[] splitted = regionWorldPair.split(":"); | ||
String worldName = splitted[0]; | ||
String regionName = splitted[1]; | ||
|
||
World world = LaBoulangerieCore.PLUGIN.getServer().getWorld(worldName); | ||
RegionManager regions = container.get(BukkitAdapter.adapt(world)); | ||
ProtectedRegion region = regions.getRegion(regionName); | ||
// check if region is a cuboid | ||
if (region instanceof ProtectedCuboidRegion) { | ||
resetVault(region, world); | ||
} else { | ||
LaBoulangerieCore.PLUGIN.getLogger().warning("Region " + regionName + " in world " + worldName | ||
+ " is not a cuboid region, skipping..."); | ||
} | ||
} | ||
} | ||
|
||
private static void resetVault(ProtectedRegion region, World world) { | ||
BlockVector3 min = region.getMinimumPoint(); | ||
BlockVector3 max = region.getMaximumPoint(); | ||
|
||
HolderLookup.Provider minecraftProvider = MinecraftServer.getServer().registryAccess(); | ||
CraftWorld craftWorld = (CraftWorld) world; | ||
for (int x = min.x(); x <= max.x(); x++) { | ||
for (int y = min.y(); y <= max.y(); y++) { | ||
for (int z = min.z(); z <= max.z(); z++) { | ||
if (world.getBlockAt(x, y, z).getType() == Material.VAULT) { | ||
LaBoulangerieCore.PLUGIN.getLogger() | ||
.info("Resetting rewarded players of vault at " + x + " " + y + " " + z + " in world " | ||
+ world.getName()); | ||
BlockPos blockPos = new BlockPos(x, y, z); | ||
BlockEntity blockEntity = craftWorld.getHandle().getBlockEntity(blockPos); | ||
|
||
CompoundTag ct = blockEntity.saveWithFullMetadata(minecraftProvider); | ||
CompoundTag serverData = ct.getCompound("server_data"); | ||
serverData.remove("rewarded_players"); | ||
|
||
blockEntity.loadWithComponents(ct, minecraftProvider); | ||
blockEntity.setChanged(); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
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