Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Docs/BukkitPlugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Supported Plugins: (And the sources we acquired Jar files from.)
- BossShopPro (https://www.spigotmc.org/resources/bossshop.222/)
- ChestShop (https://www.spigotmc.org/resources/chestshop.51856/)
- CoreProtect (https://www.spigotmc.org/resources/coreprotect.8631/)
- CoordinateOffset (https://github.com/joshuaprince/CoordinateOffset)
- CrackShot (https://www.spigotmc.org/resources/crackshot-guns.48301/)
- EffectLib (https://dev.bukkit.org/projects/effectlib)
- EssentialsX (https://www.spigotmc.org/resources/essentialsx.9089/)
Expand Down
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@
<scope>system</scope>
<systemPath>${project.basedir}/lib/CoreProtect.jar</systemPath>
</dependency>
<dependency>
<groupId>com.jtprince</groupId>
<artifactId>CoordinateOffset</artifactId>
<version>6.1.8-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/CoordinateOffset.jar</systemPath>
</dependency>
<dependency>
<groupId>de.slikey</groupId>
<artifactId>EffectLib</artifactId>
Expand Down Expand Up @@ -403,6 +410,7 @@
<scope>system</scope>
<systemPath>${basedir}/lib/BigDoors.jar</systemPath>
</dependency>

</dependencies>

<distributionManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public void registerCoreBridges() {
registerBridge("BigDoors", () -> new BigDoorsBridge());
registerBridge("BossShopPro", () -> new BossShopBridge());
registerBridge("ChestShop", () -> new ChestShopBridge());
registerBridge("CoordinateOffset", () -> new CoordinateOffsetBridge());
registerBridge("CoreProtect", () -> new CoreProtectBridge());
registerBridge("CrackShot", () -> new CrackShotBridge());
registerBridge("EffectLib", () -> new EffectLibBridge());
Expand Down Expand Up @@ -170,3 +171,4 @@ public void registerBridge(String name, String classCheck, Supplier<Bridge> brid
allBridges.put(name, new BridgeData(classCheck, bridgeSupplier));
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.denizenscript.depenizen.bukkit.bridges;

import com.denizenscript.depenizen.bukkit.Bridge;
import com.denizenscript.depenizen.bukkit.properties.coordinateoffset.CoordinateOffsetPlayerExtensions;

public class CoordinateOffsetBridge extends Bridge {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


@Override
public void init() {
CoordinateOffsetPlayerExtensions.register();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.denizenscript.depenizen.bukkit.properties.coordinateoffset;

import com.denizenscript.denizen.objects.LocationTag;
import com.denizenscript.denizen.objects.PlayerTag;
import com.jtprince.coordinateoffset.FixedOffset;
import com.jtprince.coordinateoffset.Offset;
import com.jtprince.coordinateoffset.api.CoordinateOffset;
import com.jtprince.coordinateoffset.adapter.OffsetPlayer;

public class CoordinateOffsetPlayerExtensions {

public static CoordinateOffset getApi() {
return CoordinateOffset.api();
}

public static OffsetPlayer getOffsetPlayer(PlayerTag player) {
return getApi().adaptPlayer(player.getPlayerEntity());
}

public static void register() {

// <--[tag]
// @attribute <PlayerTag.coordinate_offset>
// @returns LocationTag
// @mechanism PlayerTag.coordinate_offset
// @plugin Depenizen, CoordinateOffset
// @description
// Returns the player's current coordinate offset as a LocationTag (x, y, z).
// -->
PlayerTag.registerOnlineOnlyTag(LocationTag.class, "coordinate_offset", (attribute, player) -> {
OffsetPlayer offsetPlayer = getOffsetPlayer(player);
FixedOffset offset = getApi().getOffset(offsetPlayer);
if (offset.isZero()) {
return null;
}
return new LocationTag(null, offset.x(), offset.y(), offset.z());
});

// <--[mechanism]
// @object PlayerTag
// @name coordinate_offset
// @input LocationTag
// @plugin Depenizen, CoordinateOffset
// @description
// Sets the player's coordinate offset.
// @tags
// <PlayerTag.coordinate_offset>
// -->
PlayerTag.registerOnlineOnlyMechanism("coordinate_offset", LocationTag.class, (player, mechanism, loc) -> {
int x = (int) Math.round(loc.getX());
int y = (int) Math.round(loc.getY());
int z = (int) Math.round(loc.getZ());

// Align using ConstantOffsetProvider logic (multiples of configured blocks)
int alignedX = Offset.alignComponentToConfiguredMultiple(x);
int alignedZ = Offset.alignComponentToConfiguredMultiple(z);

OffsetPlayer offsetPlayer = getOffsetPlayer(player);
getApi().setOffset(offsetPlayer, Offset.scalable(alignedX, y, alignedZ));
});
}
}
1 change: 1 addition & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ softdepend:
- BossShopPro
- ChestShop
- CoreProtect
- CoordinateOffset
- CrackShot
- EffectLib
- Essentials
Expand Down