Skip to content

Commit

Permalink
1.16.2 part 1: version numbers bump
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Aug 13, 2020
1 parent 2289553 commit 09dc542
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -3,7 +3,7 @@ The Denizen Scripting Language - Spigot Impl

An implementation of the Denizen Scripting Language for Spigot servers, with strong Citizens interlinks to emphasize the power of using Denizen with NPCs!

**Version 1.1.5**: Compatible with Spigot 1.13.2, 1.14.4, 1.15.2, and 1.16.1!
**Version 1.1.5**: Compatible with Spigot 1.13.2, 1.14.4, 1.15.2, and 1.16.2!

**Learn about Denizen from the Beginner's guide:** https://guide.denizenscript.com/guides/background/index.html

Expand Down
Expand Up @@ -68,10 +68,7 @@ enum Type {ITEM, MONEY, EXP}

@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {

/* Match arguments to expected variables */
for (Argument arg : scriptEntry.getProcessedArgs()) {

if (!scriptEntry.hasObject("quantity")
&& arg.matchesPrefix("q", "qty", "quantity")
&& arg.matchesFloat()) {
Expand Down Expand Up @@ -112,50 +109,38 @@ else if (!scriptEntry.hasObject("slot")
else {
arg.reportUnhandled();
}

}

scriptEntry.defaultObject("type", Type.ITEM)
.defaultObject("engrave", new ElementTag(false))
.defaultObject("unlimit_stack_size", new ElementTag(false))
.defaultObject("quantity", new ElementTag(1))
.defaultObject("slot", new ElementTag(1));

Type type = (Type) scriptEntry.getObject("type");

if (type != Type.MONEY && scriptEntry.getObject("inventory") == null) {
scriptEntry.addObject("inventory", Utilities.entryHasPlayer(scriptEntry) ? Utilities.getEntryPlayer(scriptEntry).getInventory() : null);
}

if (!scriptEntry.hasObject("inventory") && type != Type.MONEY) {
throw new InvalidArgumentsException("Must specify an inventory to give to!");
}

if (type == Type.ITEM && scriptEntry.getObject("items") == null) {
throw new InvalidArgumentsException("Must specify item/items!");
}

}

@Override
public void execute(ScriptEntry scriptEntry) {

ElementTag engrave = scriptEntry.getElement("engrave");
ElementTag unlimit_stack_size = scriptEntry.getElement("unlimit_stack_size");
InventoryTag inventory = scriptEntry.getObjectTag("inventory");
ElementTag quantity = scriptEntry.getElement("quantity");
Type type = (Type) scriptEntry.getObject("type");
ElementTag slot = scriptEntry.getElement("slot");

Object items_object = scriptEntry.getObject("items");
List<ItemTag> items = null;

if (items_object != null) {
items = (List<ItemTag>) items_object;
}

if (scriptEntry.dbCallShouldDebug()) {

Debug.report(scriptEntry, getName(),
ArgumentHelper.debugObj("Type", type.name())
+ (inventory != null ? inventory.debug() : "")
Expand All @@ -164,11 +149,8 @@ public void execute(ScriptEntry scriptEntry) {
+ unlimit_stack_size.debug()
+ (items != null ? ArgumentHelper.debugObj("Items", items) : "")
+ slot.debug());

}

switch (type) {

case MONEY:
if (Depends.economy != null) {
Depends.economy.depositPlayer(Utilities.getEntryPlayer(scriptEntry).getOfflinePlayer(), quantity.asDouble());
Expand All @@ -177,11 +159,9 @@ public void execute(ScriptEntry scriptEntry) {
Debug.echoError("No economy loaded! Have you installed Vault and a compatible economy plugin?");
}
break;

case EXP:
Utilities.getEntryPlayer(scriptEntry).getPlayerEntity().giveExp(quantity.asInt());
break;

case ITEM:
boolean set_quantity = scriptEntry.hasObject("set_quantity");
boolean limited = !unlimit_stack_size.asBoolean();
Expand All @@ -203,9 +183,7 @@ public void execute(ScriptEntry scriptEntry) {
Debug.echoError(scriptEntry.getResidingQueue(), "The input '" + slot.asString() + "' is not a valid slot!");
return;
}

List<ItemStack> leftovers = inventory.addWithLeftovers(slotId, limited, is);

if (!leftovers.isEmpty()) {
Debug.echoDebug(scriptEntry, "The inventory didn't have enough space, the rest of the items have been placed on the floor.");
for (ItemStack leftoverItem : leftovers) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -10,7 +10,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<craftbukkit.version>1.16.1-R0.1-SNAPSHOT</craftbukkit.version>
<craftbukkit.version>1.16.2-R0.1-SNAPSHOT</craftbukkit.version>
<citizens.version>2.0.27-SNAPSHOT</citizens.version>
<dcore.version>1.90-SNAPSHOT</dcore.version>
<BUILD_NUMBER>Unknown</BUILD_NUMBER>
Expand Down
4 changes: 2 additions & 2 deletions v1_16/pom.xml
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version>
<version>1.16.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
Expand All @@ -34,7 +34,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version>
<version>1.16.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
Expand Down

0 comments on commit 09dc542

Please sign in to comment.