Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Geyser & Floodgate support #410

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 2 additions & 0 deletions Docs/BukkitPlugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Supported Plugins: (And the sources we acquired Jar files from.)
- EffectLib (https://dev.bukkit.org/projects/effectlib)
- EssentialsX (https://www.spigotmc.org/resources/essentialsx.9089/)
- Factions (https://www.spigotmc.org/resources/factions3-for-1-13.63602/)
- Floodgate (https://geysermc.org/download)
- Geyser (https://geysermc.org/download)
- GriefPrevention (https://www.spigotmc.org/resources/griefprevention.1884/)
- Jobs Reborn (https://www.spigotmc.org/resources/jobs-reborn.4216/)
- Lib's Disguises (https://www.spigotmc.org/resources/libs-disguises.32453/)
Expand Down
14 changes: 14 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,20 @@
<scope>system</scope>
<systemPath>${basedir}/lib/Factions.jar</systemPath>
</dependency>
<dependency>
<groupId>org.geysermc.floodgate</groupId>
<artifactId>api</artifactId>
<version>2.2.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${basedir}/lib/Floodgate.jar</systemPath>
</dependency>
<dependency>
<groupId>org.geysermc.geyser</groupId>
<artifactId>api</artifactId>
<version>2.1.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${basedir}/lib/Geyser.jar</systemPath>
</dependency>
<dependency>
<groupId>me.ryanhamshire</groupId>
<artifactId>GriefPrevention</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public void registerCoreBridges() {
registerBridge("EffectLib", () -> new EffectLibBridge());
registerBridge("Essentials", () -> new EssentialsBridge());
registerBridge("Factions", () -> new FactionsBridge());
registerBridge("floodgate", () -> new FloodgateBridge());
registerBridge("Geyser-Spigot", () -> new GeyserBridge());
registerBridge("GriefPrevention", () -> new GriefPreventionBridge());
registerBridge("Jobs", () -> new JobsBridge());
registerBridge("LibsDisguises", () -> new LibsDisguisesBridge());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.denizenscript.depenizen.bukkit.bridges;

import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizencore.objects.properties.PropertyParser;
import com.denizenscript.depenizen.bukkit.Bridge;
import com.denizenscript.depenizen.bukkit.containers.floodgate.FormContainer;
import com.denizenscript.depenizen.bukkit.properties.floodgate.FloodgatePlayerProperties;

import java.util.HashMap;
import java.util.Map;

public class FloodgateBridge extends Bridge {
@Override
public void init() {
PropertyParser.registerProperty(FloodgatePlayerProperties.class, PlayerTag.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.denizenscript.depenizen.bukkit.bridges;

import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizencore.objects.properties.PropertyParser;
import com.denizenscript.depenizen.bukkit.Bridge;
import com.denizenscript.depenizen.bukkit.properties.geyser.GeyserPlayerProperties;

public class GeyserBridge extends Bridge {
@Override
public void init() {
PropertyParser.registerProperty(GeyserPlayerProperties.class, PlayerTag.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
package com.denizenscript.depenizen.bukkit.properties.floodgate;

import com.denizenscript.denizencore.objects.properties.Property;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.depenizen.bukkit.bridges.EssentialsBridge;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.tags.Attribute;
import org.geysermc.floodgate.api.FloodgateApi;
import org.geysermc.floodgate.api.player.FloodgatePlayer;

public class FloodgatePlayerProperties implements Property {

@Override
public String getPropertyString() {
return null;
}

@Override
public String getPropertyId() {
return "FloodgatePlayer";
}

@Override
public void adjust(Mechanism mechanism) {
// None
}

public static boolean describes(ObjectTag object) {
return object instanceof PlayerTag;
}

public static FloodgatePlayerProperties getFrom(ObjectTag object) {
if (!describes(object)) {
return null;
}
else {
return new FloodgatePlayerProperties((PlayerTag) object);
}
}

public static final String[] handledTags = new String[] {
"floodgate"
};

public static final String[] handledMechs = new String[] {
}; // None

public FloodgatePlayerProperties(PlayerTag object) { this.player = object; }

public FloodgatePlayer getFloodgatePlayer() {
return FloodgateApi.getInstance().getPlayer(player.getUUID());
}

PlayerTag player;

@Override
public ObjectTag getObjectAttribute(Attribute attribute) {

if (getFloodgatePlayer() == null) {
return null;
}

if (attribute.startsWith("floodgate")) {
attribute = attribute.fulfill(1);

// <--[tag]
// @attribute <PlayerTag.floodgate.version>
// @returns ElementTag(String)
// @plugin Depenizen, Floodgate
// @description
// Returns the version of the Bedrock client.
// -->
if (attribute.startsWith("version")) {
return new ElementTag(getFloodgatePlayer().getVersion()).getObjectAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <PlayerTag.floodgate.username>
// @returns ElementTag(String)
// @plugin Depenizen, Floodgate
// @description
// Returns the real username of the Bedrock client.
// -->
if (attribute.startsWith("username")) {
return new ElementTag(getFloodgatePlayer().getUsername()).getObjectAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <PlayerTag.floodgate.device>
// @returns ElementTag(String)
// @plugin Depenizen, Floodgate
// @description
// Returns the Operating System of the Bedrock client.
// -->
if (attribute.startsWith("device")) {
return new ElementTag(getFloodgatePlayer().getDeviceOs()).getObjectAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <PlayerTag.floodgate.locale>
// @returns ElementTag(String)
// @plugin Depenizen, Floodgate
// @description
// Returns the language code of the Bedrock client.
// -->
if (attribute.startsWith("locale")) {
return new ElementTag(getFloodgatePlayer().getLanguageCode()).getObjectAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <PlayerTag.floodgate.xuid>
// @returns ElementTag(String)
// @plugin Depenizen, Floodgate
// @description
// Returns the Xbox Unique Identifier of the Bedrock client.
// -->
if (attribute.startsWith("xuid")) {
return new ElementTag(getFloodgatePlayer().getXuid()).getObjectAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <PlayerTag.floodgate.is_from_proxy>
// @returns ElementTag(Boolean)
// @plugin Depenizen, Floodgate
// @description
// Returns if the Floodgate player is connected through a proxy.
// -->
if (attribute.startsWith("is_from_proxy")) {
return new ElementTag(getFloodgatePlayer().isFromProxy()).getObjectAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <PlayerTag.floodgate.is_linked>
// @returns ElementTag(Boolean)
// @plugin Depenizen, Floodgate
// @description
// Returns if the player is linked to a Java account.
// -->
if (attribute.startsWith("is_linked")) {
return new ElementTag(getFloodgatePlayer().isLinked()).getObjectAttribute(attribute.fulfill(1));
}
}

return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.denizenscript.depenizen.bukkit.properties.geyser;

import com.denizenscript.denizencore.objects.properties.Property;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizen.objects.PlayerTag;
import org.geysermc.geyser.api.GeyserApi;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.tags.Attribute;

public class GeyserPlayerProperties implements Property {

@Override
public String getPropertyString() {
return null;
}

@Override
public String getPropertyId() {
return "GeyserPlayer";
}

@Override
public void adjust(Mechanism mechanism) {
// None
}

public static boolean describes(ObjectTag object) {
return object instanceof PlayerTag;
}

public static GeyserPlayerProperties getFrom(ObjectTag object) {
if (!describes(object)) {
return null;
}
else {
return new GeyserPlayerProperties((PlayerTag) object);
}
}

public static final String[] handledTags = new String[] {
"geyser"
};

public static final String[] handledMechs = new String[] {
}; // None

public GeyserPlayerProperties(PlayerTag object) { this.player = object; }

PlayerTag player;

@Override
public ObjectTag getObjectAttribute(Attribute attribute) {

if (attribute.startsWith("geyser")) {
attribute = attribute.fulfill(1);

// <--[tag]
// @attribute <PlayerTag.geyser.is_bedrock>
// @returns ElementTag(Boolean)
// @plugin Depenizen, Geyser
// @description
// Returns is player plays from Minecraft Bedrock Edition.
// -->
if (attribute.startsWith("is_bedrock")) {
return new ElementTag(GeyserApi.api().connectionByUuid(player.getUUID()) != null).getObjectAttribute(attribute.fulfill(1));
}
}

return null;
}
}