Skip to content
Open
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: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
<dependency>
<groupId>com.garbagemule</groupId>
<artifactId>MobArena</artifactId>
<version>0.97.1</version>
<version>0.109</version>
<scope>system</scope>
<systemPath>${basedir}/lib/MobArena.jar</systemPath>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
package com.denizenscript.depenizen.bukkit.bridges;

import com.denizenscript.denizencore.DenizenCore;
import com.denizenscript.depenizen.bukkit.events.mobarena.MobArenaStartsScriptEvent;
import com.denizenscript.depenizen.bukkit.Bridge;
import com.garbagemule.MobArena.MobArena;
import com.garbagemule.MobArena.framework.Arena;
import com.denizenscript.depenizen.bukkit.commands.mobarena.MobArenaCommand;
import com.denizenscript.depenizen.bukkit.events.mobarena.MobArenaEndsScriptEvent;
import com.denizenscript.depenizen.bukkit.properties.mobarena.MobArenaPlayerProperties;
import com.denizenscript.depenizen.bukkit.objects.mobarena.MobArenaArenaTag;
import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizencore.events.ScriptEvent;
import com.denizenscript.denizencore.objects.ObjectFetcher;
import com.denizenscript.denizencore.tags.TagRunnable;
import com.denizenscript.denizencore.objects.properties.PropertyParser;
import com.denizenscript.denizencore.tags.ReplaceableTagEvent;
import com.denizenscript.denizencore.objects.core.ListTag;
import com.denizenscript.denizencore.tags.Attribute;
import com.denizenscript.depenizen.bukkit.events.mobarena.MobArenaWaveChangesScriptEvent;
import com.denizenscript.denizencore.tags.ReplaceableTagEvent;
import com.denizenscript.denizencore.tags.TagManager;
import com.denizenscript.denizencore.tags.TagRunnable;
import com.denizenscript.depenizen.bukkit.Bridge;
import com.denizenscript.depenizen.bukkit.commands.mobarena.*;
import com.denizenscript.depenizen.bukkit.events.mobarena.*;
import com.denizenscript.depenizen.bukkit.objects.mobarena.*;
import com.denizenscript.depenizen.bukkit.properties.mobarena.*;
import com.garbagemule.MobArena.MobArena;
import com.garbagemule.MobArena.framework.Arena;

public class MobArenaBridge extends Bridge {

Expand All @@ -38,7 +34,7 @@ public void run(ReplaceableTagEvent event) {
ScriptEvent.registerScriptEvent(MobArenaStartsScriptEvent.class);
ScriptEvent.registerScriptEvent(MobArenaEndsScriptEvent.class);
ScriptEvent.registerScriptEvent(MobArenaWaveChangesScriptEvent.class);
PropertyParser.registerProperty(MobArenaPlayerProperties.class, PlayerTag.class);
MobArenaPlayerExtensions.register();
}

public void tagEvent(ReplaceableTagEvent event) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
package com.denizenscript.depenizen.bukkit.properties.mobarena;

import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.core.MapTag;
import com.denizenscript.denizencore.utilities.debugging.SlowWarning;
import com.denizenscript.depenizen.bukkit.bridges.MobArenaBridge;
import com.denizenscript.depenizen.bukkit.objects.mobarena.MobArenaArenaTag;
import com.garbagemule.MobArena.ArenaPlayer;
import com.garbagemule.MobArena.ArenaPlayerStatistics;
import com.garbagemule.MobArena.MobArena;
import com.garbagemule.MobArena.framework.Arena;

public class MobArenaPlayerExtensions {

public static SlowWarning mobArenaPlayerTags = new SlowWarning("mobArenaPlayerTags", "Tags in the format 'PlayerTag.mobarena.x' have been deprecated: check the meta site for updated versions.");
Copy link
Member

Choose a reason for hiding this comment

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

in the format X -> in the X format, meta docs for more information


public static Arena getArena(PlayerTag player) {
return ((MobArena) MobArenaBridge.instance.plugin).getArenaMaster().getArenaWithPlayer(player.getPlayerEntity());
}

public static ArenaPlayer getArenaPlayer(PlayerTag player) {
return getArena(player).getArenaPlayer(player.getPlayerEntity());
}

public static void register() {

// <--[tag]
// @attribute <PlayerTag.in_mobarena>
// @returns ElementTag(Boolean)
// @plugin Depenizen, MobArena
// @description
// Returns whether the player is in a mobarena.
// -->
PlayerTag.tagProcessor.registerTag(ElementTag.class, "in_mobarena", (attribute, player) -> {
return new ElementTag(getArena(player) != null);
});

// <--[tag]
// @attribute <PlayerTag.current_mobarena>
// @returns MobArenaArenaTag
// @plugin Depenizen, MobArena
// @description
// Returns the arena the player is in.
// NOTE: Requires the player to be in an arena.
// -->
PlayerTag.tagProcessor.registerTag(MobArenaArenaTag.class, "current_mobarena", (attribute, player) -> {
return getArena(player) != null ? new MobArenaArenaTag(getArena(player)) : null;
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to be calling getArena twice here? The old code seems to put it in a variable

});

// <--[tag]
// @attribute <PlayerTag.mobarena_class>
// @returns ElementTag
// @plugin Depenizen, MobArena
// @description
// Returns the name of the class the player is using.
// NOTE: Requires the player to be in an arena.
// -->
PlayerTag.tagProcessor.registerTag(ElementTag.class, "mobarena_class", (attribute, player) -> {
return getArena(player) != null ? new ElementTag(getArenaPlayer(player).getArenaClass().getConfigName(), true) : null;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe same thing here, alongside making getArenaPlayer null safe?

});

// <--[tag]
// @attribute <PlayerTag.mobarena_stats>
// @returns MapTag
// @plugin Depenizen, MobArena
// @description
// Returns the stats of a player in their current arena.
// Valid keys are 'KILLS', 'DAMAGE_DONE', 'DAMAGE_TAKEN', 'LAST_WAVE', 'TIMES_SWUNG', and 'TIMES_HIT'.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe includes keys or something? Valid sounds like an input - also stating ElementTag(Number) could be handy

// -->
PlayerTag.tagProcessor.registerTag(MapTag.class, "mobarena_stats", (attribute, player) -> {
if (getArena(player) == null) {
attribute.echoError("This player is not in an arena.");
return null;
}
ArenaPlayerStatistics stats = getArenaPlayer(player).getStats();
MapTag values = new MapTag();
values.putObject("kills", new ElementTag(stats.getInt("kills")));
values.putObject("damage_done", new ElementTag(stats.getInt("dmgDone")));
values.putObject("damage_taken", new ElementTag(stats.getInt("dmgTaken")));
values.putObject("last_wave", new ElementTag(stats.getInt("lastWave")));
values.putObject("times_swung", new ElementTag(stats.getInt("swings")));
values.putObject("times_hit", new ElementTag(stats.getInt("hits")));
return values;
});

PlayerTag.tagProcessor.registerTag(ObjectTag.class, "mobarena", (attribute, player) -> {
mobArenaPlayerTags.warn(attribute.context);

// <--[tag]
// @attribute <PlayerTag.mobarena.in_arena>
// @returns ElementTag(Boolean)
// @plugin Depenizen, MobArena
// @deprecated Use 'PlayerTag.in_mobarena'
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick but these should start lowercase, as they're used as a part of a bigger message in e.g. VSC

// @description
// Deprecated in favor of <@link tag PlayerTag.in_mobarena>.
// -->
if (attribute.startsWith("in_arena", 2)) {
attribute.fulfill(1);
return new ElementTag(getArena(player) != null);
}
if (getArena(player) != null) {
Copy link
Member

Choose a reason for hiding this comment

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

Same here, no need to call it each time - seeing as this is all one big tag block anyway just put it in a variable


// <--[tag]
// @attribute <PlayerTag.mobarena.current_arena>
// @returns MobArenaArenaTag
// @plugin Depenizen, MobArena
// @deprecated Use 'PlayerTag.current_mobarena'
// @description
// Deprecated in favor of <@link tag PlayerTag.current_mobarena>.
// -->
if (attribute.startsWith("current_arena", 2)) {
attribute.fulfill(1);
return new MobArenaArenaTag(getArena(player));
}

// <--[tag]
// @attribute <PlayerTag.mobarena.class>
// @returns ElementTag
// @plugin Depenizen, MobArena
// @deprecated Use 'PlayerTag.mobarena_class'
// @description
// Deprecated in favor of <@link tag PlayerTag.mobarena_class>.
// -->
else if (attribute.startsWith("class", 2)) {
attribute.fulfill(1);
return new ElementTag(getArenaPlayer(player).getArenaClass().getConfigName(), true);
}
}

if (attribute.startsWith("stats", 2)) {
attribute.fulfill(1);
ArenaPlayerStatistics stats = getArenaPlayer(player).getStats();
Copy link
Member

Choose a reason for hiding this comment

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

Does this not remove functionality? Looks like it let you input any mob arena previously (same for the new mobarena_stats, looks like you can't do what the old tag did currently)

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

// <--[tag]
// @attribute <PlayerTag.mobarena.stats[<mobarena>].kills>
// @returns ElementTag(Number)
// @plugin Depenizen, MobArena
// @deprecated Use 'PlayerTag.mobarena_stats.get[kills]'
// @description
// Deprecated in favor of <@link tag PlayerTag.mobarena_stats> with the 'KILLS' key.
// -->
if (attribute.startsWith("kills", 2)) {
attribute.fulfill(1);
return new ElementTag(stats.getInt("kills"));
}

// <--[tag]
// @attribute <PlayerTag.mobarena.stats[<mobarena>].damage_done>
// @returns ElementTag(Number)
// @plugin Depenizen, MobArena
// @deprecated Use 'PlayerTag.mobarena_stats.get[damage_done]'
// @description
// Deprecated in favor of <@link tag PlayerTag.mobarena_stats> with the 'DAMAGE_DONE' key.
// @description
// Returns the amount of damage the player has dealt in the arena.
// -->
else if (attribute.startsWith("damage_done", 2)) {
attribute.fulfill(1);
return new ElementTag(stats.getInt("dmgDone"));
}

// <--[tag]
// @attribute <PlayerTag.mobarena.stats[<mobarena>].damage_taken>
// @returns ElementTag(Number)
// @plugin Depenizen, MobArena
// @deprecated Use 'PlayerTag.mobarena_stats.get[damage_taken]'
// @description
// Deprecated in favor of <@link tag PlayerTag.mobarena_stats> with the 'DAMAGE_TAKEN' key.
// -->
else if (attribute.startsWith("damage_taken", 2)) {
attribute.fulfill(1);
return new ElementTag(stats.getInt("dmgTaken"));
}

// <--[tag]
// @attribute <PlayerTag.mobarena.stats[<mobarena>].last_wave>
// @returns ElementTag(Number)
// @plugin Depenizen, MobArena
// @deprecated Use 'PlayerTag.mobarena_stats.get[last_wave]'
// @description
// Deprecated in favor of <@link tag PlayerTag.mobarena_stats> with the 'LAST_WAVE' key.
// -->
else if (attribute.startsWith("last_wave", 2)) {
attribute.fulfill(1);
return new ElementTag(stats.getInt("lastWave"));
}

// <--[tag]
// @attribute <PlayerTag.mobarena.stats[<mobarena>].times_swung>
// @returns ElementTag(Number)
// @plugin Depenizen, MobArena
// @deprecated Use 'PlayerTag.mobarena_stats.get[times_swung]'
// @description
// Deprecated in favor of <@link tag PlayerTag.mobarena_stats> with the 'TIMES_SWUNG' key.
// -->
else if (attribute.startsWith("times_swung", 2)) {
attribute.fulfill(1);
return new ElementTag(stats.getInt("swings"));
}

// <--[tag]
// @attribute <PlayerTag.mobarena.stats[<mobarena>].times_hit>
// @returns ElementTag(Number)
// @plugin Depenizen, MobArena
// @deprecated Use 'PlayerTag.mobarena_stats.get[times_hit]'
// @description
// Deprecated in favor of <@link tag PlayerTag.mobarena_stats> with the 'TIMES_HIT' key.
// -->
else if (attribute.startsWith("times_hit", 2)) {
attribute.fulfill(1);
return new ElementTag(stats.getInt("hits"));
}
}
return null;
});
}
}
Loading