Skip to content

Commit

Permalink
1.169.0 (#1212)
Browse files Browse the repository at this point in the history
**[New]**
- `/oraxen take <players> <itemid>` command

**[Changes]**
- Improve HUD-check for players under water
- Drop-mechanic now uses the base-item if none is specified for a drop
- Drop reliance on LightAPI for `light`-mechanic in favor of light-blocks

**[Fixes]**
- Issues with 1.18.x Paper servers
- Error in EnergyBlastMechanic on new Spigot/Paper 1.20.4 builds
- `/oraxen inventory` icon sometimes breaking displayname of OraxenItem
- `is_falling` for NoteBlock-mechanic not working
- Dyed furniture not retaining color when placed
- Sculk Sensor not triggering in some scenarios:
  * Placing/breaking custom blocks
  * Placing block on custom block
  * Placing/Breaking Furniture
  • Loading branch information
Boy0000 committed Feb 14, 2024
1 parent f102ab7 commit 5f4c47a
Show file tree
Hide file tree
Showing 33 changed files with 292 additions and 237 deletions.
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ allprojects {
compileOnly("net.kyori:adventure-platform-bukkit:$platformVersion")
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
compileOnly("me.clip:placeholderapi:2.11.4")
compileOnly("com.github.LinsMinecraftStudio.LighterAPI:lightapi-bukkit-common:5.4.0-SNAPSHOT")
compileOnly("me.gabytm.util:actions-core:$actionsVersion")
compileOnly("org.springframework:spring-expression:6.0.6")
compileOnly("io.lumine:Mythic-Dist:5.3.5")
Expand Down
3 changes: 2 additions & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ publishing {
artifactId = rootProject.name
version = publishData.getVersion()

from(components["java"])
//from(components["java"])
artifact(tasks.shadowJar.get().apply { archiveClassifier.set("") })
}
}

Expand Down
24 changes: 12 additions & 12 deletions core/src/main/java/io/th0rgal/oraxen/api/OraxenBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import io.th0rgal.oraxen.OraxenPlugin;
import io.th0rgal.oraxen.api.events.noteblock.OraxenNoteBlockBreakEvent;
import io.th0rgal.oraxen.api.events.stringblock.OraxenStringBlockBreakEvent;
import io.th0rgal.oraxen.compatibilities.provided.lightapi.WrappedLightAPI;
import io.th0rgal.oraxen.mechanics.Mechanic;
import io.th0rgal.oraxen.mechanics.provided.gameplay.block.BlockMechanic;
import io.th0rgal.oraxen.mechanics.provided.gameplay.block.BlockMechanicFactory;
Expand All @@ -18,10 +17,7 @@
import io.th0rgal.oraxen.utils.BlockHelpers;
import io.th0rgal.oraxen.utils.EventUtils;
import io.th0rgal.oraxen.utils.drops.Drop;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
Expand Down Expand Up @@ -170,8 +166,9 @@ private static void placeNoteBlock(Location location, String itemID) {
NoteBlockMechanic mechanic = getNoteBlockMechanic(block);
if (mechanic == null) return;

if (mechanic.hasLight())
WrappedLightAPI.createBlockLight(block.getLocation(), mechanic.getLight());
if (mechanic.hasLight()) {
mechanic.getLight().createBlockLight(block);
}

if (mechanic.hasDryout() && mechanic.getDryout().isFarmBlock()) {
pdc.set(FARMBLOCK_KEY, PersistentDataType.STRING, mechanic.getItemID());
Expand Down Expand Up @@ -203,8 +200,8 @@ private static void placeStringBlock(Location location, String itemID) {
else blockAbove.setType(Material.TRIPWIRE);
}

if (mechanic.getLight() != -1)
WrappedLightAPI.createBlockLight(block.getLocation(), mechanic.getLight());
if (mechanic.hasLight())
mechanic.getLight().createBlockLight(block);
if (mechanic.isSapling()) {
SaplingMechanic sapling = mechanic.getSaplingMechanic();
if (sapling != null && sapling.canGrowNaturally())
Expand Down Expand Up @@ -255,11 +252,12 @@ private static void removeNoteBlock(Block block, @Nullable Player player, boolea

if (forceDrop || player.getGameMode() != GameMode.CREATIVE)
drop = noteBlockBreakEvent.getDrop();

block.getWorld().sendGameEvent(null, GameEvent.BLOCK_DESTROY, block.getLocation().toVector());
}
if (drop != null) drop.spawns(block.getLocation(), itemInHand);

if (mechanic.hasLight())
WrappedLightAPI.removeBlockLight(block.getLocation());
if (mechanic.hasLight()) mechanic.getLight().removeBlockLight(block);
if (mechanic.isStorage() && mechanic.getStorage().getStorageType() == StorageMechanic.StorageType.STORAGE) {
mechanic.getStorage().dropStorageContent(block);
}
Expand All @@ -281,11 +279,13 @@ private static void removeStringBlock(Block block, @Nullable Player player, bool

if (forceDrop || player.getGameMode() != GameMode.CREATIVE)
drop = wireBlockBreakEvent.getDrop();

block.getWorld().sendGameEvent(null, GameEvent.BLOCK_DESTROY, block.getLocation().toVector());
}
if (drop != null) drop.spawns(block.getLocation(), itemInHand);

final Block blockAbove = block.getRelative(BlockFace.UP);
if (mechanic.hasLight()) WrappedLightAPI.removeBlockLight(block.getLocation());
if (mechanic.hasLight()) mechanic.getLight().removeBlockLight(block);
if (mechanic.isTall()) blockAbove.setType(Material.AIR);
block.setType(Material.AIR);
Bukkit.getScheduler().runTaskLater(OraxenPlugin.get(), () -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ public static boolean remove(@NotNull Location location, @Nullable Player player
StorageMechanic storage = mechanic.getStorage();
if (storage != null && (storage.isStorage() || storage.isShulker()))
storage.dropStorageContent(mechanic, baseEntity);

baseEntity.getWorld().sendGameEvent(null, GameEvent.BLOCK_DESTROY, baseEntity.getLocation().toVector());
}

if (mechanic.hasBarriers())
Expand Down Expand Up @@ -206,6 +208,7 @@ public static boolean remove(Entity baseEntity, @Nullable Player player, @Nullab
StorageMechanic storage = mechanic.getStorage();
if (storage != null && (storage.isStorage() || storage.isShulker()))
storage.dropStorageContent(mechanic, baseEntity);
baseEntity.getWorld().sendGameEvent(null, GameEvent.BLOCK_DESTROY, baseEntity.getLocation().toVector());
}

// Check if the mechanic or the baseEntity has barriers tied to it
Expand Down Expand Up @@ -297,7 +300,7 @@ public static void updateFurniture(@NotNull Entity entity) {
}

if (!OraxenFurniture.remove(entity, null)) return;
Entity newEntity = mechanic.place(entity.getLocation(), FurnitureMechanic.getFurnitureYaw(entity), oldFacing);
Entity newEntity = mechanic.place(entity.getLocation(), newItem, FurnitureMechanic.getFurnitureYaw(entity), oldFacing, true);
if (newEntity == null) return;

// Copy old PDC to new PDC, skip keys that should not persist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import java.util.*;

public class AdminCommands {
public class AdminCommand {

CommandAPICommand getAdminCommand() {
return new CommandAPICommand("admin")
Expand Down
36 changes: 20 additions & 16 deletions core/src/main/java/io/th0rgal/oraxen/commands/CommandsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
import io.th0rgal.oraxen.items.ItemBuilder;
import io.th0rgal.oraxen.items.ItemUpdater;
import io.th0rgal.oraxen.utils.AdventureUtils;
import io.th0rgal.oraxen.utils.ItemUtils;
import org.bukkit.Color;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.MapMeta;
import org.bukkit.inventory.meta.PotionMeta;

import java.util.Collection;
import java.util.Map;
Expand All @@ -25,7 +22,7 @@ public void loadCommands() {
new CommandAPICommand("oraxen")
.withAliases("o", "oxn")
.withPermission("oraxen.command")
.withSubcommands(getDyeCommand(), getInvCommand(), getSimpleGiveCommand(), getGiveCommand(),
.withSubcommands(getDyeCommand(), getInvCommand(), getSimpleGiveCommand(), getGiveCommand(), getTakeCommand(),
(new PackCommand()).getPackCommand(),
(new UpdateCommand()).getUpdateCommand(),
(new RepairCommand()).getRepairCommand(),
Expand All @@ -41,7 +38,7 @@ public void loadCommands() {
(new LogDumpCommand().getLogDumpCommand()),
(new GestureCommand().getGestureCommand()),
(new VersionCommand()).getVersionCommand(),
(new AdminCommands()).getAdminCommand())
(new AdminCommand()).getAdminCommand())
.executes((sender, args) -> {
Message.COMMAND_HELP.send(sender);
})
Expand All @@ -68,16 +65,7 @@ private CommandAPICommand getDyeCommand() {
Message.DYE_WRONG_COLOR.send(sender);
return;
}
ItemStack item = player.getInventory().getItemInMainHand();
ItemMeta itemMeta = item.getItemMeta();
if (itemMeta instanceof LeatherArmorMeta meta) meta.setColor(hexColor);
else if (itemMeta instanceof PotionMeta meta) meta.setColor(hexColor);
else if (itemMeta instanceof MapMeta meta) meta.setColor(hexColor);
else {
Message.DYE_FAILED.send(sender);
return;
}
item.setItemMeta(itemMeta);
ItemUtils.dyeItem(player.getInventory().getItemInMainHand(), hexColor);
Message.DYE_SUCCESS.send(sender);
} else
Message.NOT_PLAYER.send(sender);
Expand Down Expand Up @@ -166,4 +154,20 @@ private CommandAPICommand getSimpleGiveCommand() {
AdventureUtils.tagResolver("item", itemID));
});
}

private CommandAPICommand getTakeCommand() {
return new CommandAPICommand("take")
.withPermission("oraxen.command.take")
.withArguments(new EntitySelectorArgument.ManyPlayers("targets"),
new TextArgument("item").replaceSuggestions(ArgumentSuggestions.strings(OraxenItems.getItemNames())))
.executes((sender, args) -> {
final Collection<Player> targets = (Collection<Player>) args.get(0);
final String itemID = (String) args.get(1);
if (!OraxenItems.exists(itemID)) {
Message.ITEM_NOT_FOUND.send(sender, AdventureUtils.tagResolver("item", itemID));
} else for (final Player target : targets) for (ItemStack itemStack : target.getInventory().getContents())
if (!ItemUtils.isEmpty(itemStack) && OraxenItems.getIdByItem(itemStack).equals(itemID))
target.getInventory().remove(itemStack);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io.th0rgal.oraxen.compatibilities.provided.blocklocker.BlockLockerCompatibility;
import io.th0rgal.oraxen.compatibilities.provided.bossshoppro.BossShopProCompatibility;
import io.th0rgal.oraxen.compatibilities.provided.lightapi.WrappedLightAPI;
import io.th0rgal.oraxen.compatibilities.provided.mythicmobs.MythicMobsCompatibility;
import io.th0rgal.oraxen.compatibilities.provided.placeholderapi.PlaceholderAPICompatibility;
import io.th0rgal.oraxen.compatibilities.provided.worldedit.WrappedWorldEdit;
Expand All @@ -22,7 +21,6 @@ private CompatibilitiesManager() {}
private static final ConcurrentHashMap<String, CompatibilityProvider<?>> ACTIVE_COMPATIBILITY_PROVIDERS = new ConcurrentHashMap<>();

public static void enableNativeCompatibilities() {
WrappedLightAPI.init();
WrappedWorldEdit.init();
WrappedWorldEdit.registerParser();
new CompatibilityListener();
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic;
import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanic;
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanic;
import io.th0rgal.oraxen.utils.VersionUtil;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
Expand Down Expand Up @@ -47,8 +48,10 @@ public WorldEditHandlers(boolean register) {

static {
furnitureTypes.add(BukkitAdapter.adapt(EntityType.ITEM_FRAME));
furnitureTypes.add(BukkitAdapter.adapt(EntityType.ITEM_DISPLAY));
furnitureTypes.add(BukkitAdapter.adapt(EntityType.INTERACTION));
if (VersionUtil.atOrAbove("1.19.4")){
furnitureTypes.add(BukkitAdapter.adapt(EntityType.ITEM_DISPLAY));
furnitureTypes.add(BukkitAdapter.adapt(EntityType.INTERACTION));
}
}


Expand Down
4 changes: 1 addition & 3 deletions core/src/main/java/io/th0rgal/oraxen/hud/HudManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,13 @@ public void setActiveHudForPlayer(Player player, Hud hud) {
}

public boolean getHudStateForPlayer(Player player) {
return !Boolean.FALSE.equals(player.getPersistentDataContainer().get(hudToggleKey, DataType.BOOLEAN));
return player.getPersistentDataContainer().getOrDefault(hudToggleKey, DataType.BOOLEAN, true);
}

public void setHudStateForPlayer(Player player, boolean state) {
player.getPersistentDataContainer().set(hudToggleKey, DataType.BOOLEAN, state);
}



public Collection<Hud> getDefaultEnabledHuds() {
return huds.values().stream().filter(Hud::isEnabledByDefault).toList();
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/io/th0rgal/oraxen/hud/HudTask.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.th0rgal.oraxen.hud;

import io.th0rgal.oraxen.OraxenPlugin;
import io.th0rgal.oraxen.utils.EntityUtils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
Expand All @@ -21,7 +22,7 @@ public void run() {
Hud hud = manager.getActiveHudForPlayer(player) != null ? manager.getActiveHudForPlayer(player) : manager.getDefaultEnabledHuds().stream().findFirst().orElse(null);

if (hud == null || manager.getHudID(hud) == null) continue;
if (hud.disableWhilstInWater() && player.isInWater()) continue;
if (hud.disableWhilstInWater() && EntityUtils.isUnderWater(player)) continue;
if (!player.hasPermission(hud.getPerm())) continue;

manager.updateHud(player);
Expand Down

0 comments on commit 5f4c47a

Please sign in to comment.