Skip to content

Commit

Permalink
meta improvements and java 11 reflective access warning hider
Browse files Browse the repository at this point in the history
and take tab complete
  • Loading branch information
mcmonkey4eva committed Apr 16, 2021
1 parent 0dcce0a commit c096f8e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
Expand Up @@ -11,6 +11,7 @@
import com.denizenscript.denizen.nms.abstracts.ProfileEditor;
import com.denizenscript.denizen.nms.abstracts.Sidebar;
import com.denizenscript.denizen.utilities.packets.DenizenPacketHandler;
import com.denizenscript.denizencore.utilities.ReflectionHelper;
import net.md_5.bungee.api.chat.HoverEvent;
import org.bukkit.Location;
import org.bukkit.block.Biome;
Expand All @@ -30,7 +31,9 @@ public abstract class NMSHandler {

public static boolean initialize(JavaPlugin plugin) {
javaPlugin = plugin;
String packageName = javaPlugin.getServer().getClass().getPackage().getName();
Class<?> serverClass = javaPlugin.getServer().getClass();
ReflectionHelper.giveReflectiveAccess(serverClass, ReflectionHelper.class);
String packageName = serverClass.getPackage().getName();
int indexOfSubRevision = packageName.indexOf('R');
if (indexOfSubRevision > 0) {
// "v1_14_R1" should become "v1_14"
Expand Down
Expand Up @@ -1717,13 +1717,8 @@ else if (meta.hasDisplayName() && CoreUtilities.toLowerCase(meta.getDisplayName(
return new ElementTag(false);
});

// <--[tag]
// @attribute <InventoryTag.contains_any[<item>|...]>
// @returns ElementTag(Boolean)
// @description
// Returns whether the inventory contains any of the specified items.
// -->
registerTag("contains_any", (attribute, object) -> {
Deprecations.inventoryNonMatcherTags.warn(attribute.context);
if (!attribute.hasContext(1)) {
return null;
}
Expand All @@ -1733,12 +1728,6 @@ else if (meta.hasDisplayName() && CoreUtilities.toLowerCase(meta.getDisplayName(
}
int qty = 1;

// <--[tag]
// @attribute <InventoryTag.contains_any[<item>|...].quantity[<#>]>
// @returns ElementTag(Boolean)
// @description
// Returns whether the inventory contains a certain quantity of any of the specified items.
// -->
if ((attribute.startsWith("quantity", 2) || attribute.startsWith("qty", 2)) && attribute.hasContext(2)) {
if (attribute.startsWith("qty", 2)) {
Deprecations.qtyTags.warn(attribute.context);
Expand Down
Expand Up @@ -3368,7 +3368,6 @@ else if (material.hasModernData() && material.getModernData() instanceof org.buk
// @description
// If the location is part of a double-block structure (double chests, double plants, doors, beds, etc),
// returns the location of the other block in the double-block structure.
// You can test if this will be valid with <@link tag MaterialTag.is_bisected>.
// -->
registerTag("other_block", (attribute, object) -> {
Block b = object.getBlockForTag(attribute);
Expand Down
Expand Up @@ -72,7 +72,7 @@ public TakeCommand() {
//
// If an economy is registered, using 'money' instead of an item will take money from the player's economy balance.
//
// Material, Flagged, Slot, Bydisplay, and Scriptname all sort a list as input to take multiple different item types at once.
// Flagged, Slot, Bydisplay all take a list as input to take multiple different item types at once.
//
// If no quantity is specified, exactly 1 item will be taken.
//
Expand All @@ -92,15 +92,15 @@ public TakeCommand() {
//
// @Usage
// Use to take an arrow from the player's enderchest
// - take material:arrow from:<player.enderchest>
// - take item:arrow from:<player.enderchest>
//
// @Usage
// Use to take the current holding item from the player's hand
// - take iteminhand
//
// @Usage
// Use to take 5 emeralds from the player's inventory
// - take material:emerald quantity:5
// - take item:emerald quantity:5
// -->

private enum Type {MONEY, XP, ITEMINHAND, CURSORITEM, ITEM, INVENTORY, BYDISPLAY, SLOT, BYCOVER, SCRIPTNAME, NBT, MATERIAL, FLAGGED, MATCHER}
Expand All @@ -121,6 +121,16 @@ else if (arg.startsWith("scriptname:")) {
addOne.accept("scriptname:" + itemScript);
}
}
else if (arg.startsWith("item:")) {
for (Material material : Material.values()) {
if (material.isItem()) {
addOne.accept("item:" + material.name());
}
}
for (String itemScript : ItemScriptHelper.item_scripts.keySet()) {
addOne.accept("item:" + itemScript);
}
}
}

@Override
Expand Down

0 comments on commit c096f8e

Please sign in to comment.