Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mcmonkey4eva/Denizen
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Feb 11, 2017
2 parents ed3ed92 + 822221d commit 2f960fd
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Denizen: Helpful Citizens for Bukkit!
-------------------------------------

**Version 1.0.0**: Compatible with Spigot 1.8.8, 1.9.4, and 1.10.2!
**Version 1.0.1**: Compatible with Spigot 1.8.8, 1.9.4, 1.10.2, and 1.11.2!

**Download (Developmental builds)**: http://ci.citizensnpcs.co/job/Denizen/
**Download (VERY Developmental builds)**: http://ci.citizensnpcs.co/job/Denizen_Developmental/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class EntityDeathScriptEvent extends BukkitScriptEvent implements Listene
// <context.inventory> returns the dInventory of the entity if it was a player.
// <context.cause> returns an Element of the cause of the death. See <@link language damage cause> for a list of possible damage causes.
// <context.drops> returns a dList of all pending item drops.
// <context.xp> returns an Element of the amount of experience to be dropped.
//
// @Determine
// Element to change the death message.
Expand Down Expand Up @@ -201,6 +202,9 @@ else if (name.equals("cause") && cause != null) {
else if (name.equals("drops") && drops != null) {
return drops;
}
else if (name.equals("xp") && xp != null) {
return new Element(xp);
}
return super.getContext(name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1250,8 +1250,21 @@ public String getAttribute(Attribute attribute) {
// Returns the number of empty slots in an inventory.
// -->
if (attribute.startsWith("empty_slots")) {
int full = new dInventory(inventory).count(null, true);
return new Element(inventory.getSize() - full).getAttribute(attribute.fulfill(1));
dInventory dummyInv;
if (inventory.getType() == InventoryType.PLAYER) {
dummyInv = new dInventory(Bukkit.createInventory(null, InventoryType.CHEST));
ItemStack[] contents = getStorageContents();
dummyInv.setSize(contents.length);
if (contents.length != dummyInv.getSize()) {
contents = Arrays.copyOf(contents, dummyInv.getSize());
}
dummyInv.setContents(contents);
}
else {
dummyInv = new dInventory(inventory);
}
int full = dummyInv.count(null, true);
return new Element(dummyInv.getSize() - full).getAttribute(attribute.fulfill(1));
}

// <--[tag]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,9 @@ public void registerCoreMembers() {
// @Description
// The flag command sets or modifies custom value storage database entries connected to
// each player, each NPC, each entity, and the server.
// All the flag values are stored default in "plugins/denizen/saves.yml" file.
// For an alternative way of storing values, use either yaml (See <@link command yaml>)
// or sql (See <@link command sql>)
// TODO: Document Command Details
//
// @Tags
Expand Down Expand Up @@ -1615,6 +1618,11 @@ public void registerCoreMembers() {
//
// @Description
// Gives the linked player or inventory any form of giveable object, including items, xp, or money.
// If the player's inventory if full, the item will be dropped at the inventory location.
// Specifying a slot will give the player the item to that slot.
// If an item is already in that slot, the item will not be given
// unless they are exactly the same items, then it will stack.
// If an economy is registered, specifying money instead of a item will give money to the player's economy.
// TODO: Document Command Details
//
// @Tags
Expand All @@ -1630,7 +1638,11 @@ public void registerCoreMembers() {
//
// @Usage
// Use to give an item to the player.
// - give i@iron_sword quantity:1
// - give i@iron_sword
//
// @Usage
// Use to give an item and place it in a specific slot if possible.
// - give WATCH slot:5
// -->
registerCoreMember(GiveCommand.class,
"GIVE", "give [money/xp/<item>|...] (qty:<#>) (engrave) (to:<inventory>) (slot:<#>)", 1);
Expand Down Expand Up @@ -2425,7 +2437,12 @@ public void registerCoreMembers() {
// - modifyblock cu@<player.location>|<player.location.cursor_on> li@stone|dirt li@25|25
//
// @Usage
// TODO: Document Command Details
// Use to clear the area around the player and drop their respective items.
// - modifyblock <player.location> air radius:5 naturally delayed
//
// @Usage
// Use to modify the ground beneath the player's feet.
// - modifyblock cu@<player.location.add[2,-1,2]>|<player.location.add[-2,-1,-2]> WOOL,14
// -->
registerCoreMember(ModifyBlockCommand.class,
"MODIFYBLOCK", "modifyblock [<location>|.../<ellipsoid>/<cuboid>] [<material>|...] (radius:<#>) (height:<#>) (depth:<#>) (no_physics/naturally) (delayed) (<script>) (<percent chance>|...)", 2);
Expand Down Expand Up @@ -2643,7 +2660,16 @@ public void registerCoreMembers() {
// None
//
// @Usage
// TODO: Document Command Details
// Use to create a fake explosion.
// - playeffect <player.location> effect:EXPLOSION_HUGE visibility:500 quantity:10 offset:2.0
//
// @Usage
// Use to play a cloud effect.
// - playeffect <player.location.add[0,5,0]> effect:CLOUD quantity:20 data:1 offset:0.0
//
// @Usage
// Use to play some effects at spawn.
// - playeffect <w@world.spawn_location> effect:FIREWORKS_SPARK visibility:100 quantity:375 data:0 offset:50.0
// -->
registerCoreMember(PlayEffectCommand.class,
"PLAYEFFECT", "playeffect [<location>|...] [effect:<name>] (data:<#.#>) (visibility:<#.#>) (qty:<#>) (offset:<#.#>,<#.#>,<#.#>) (targets:<player>|...)", 2);
Expand Down Expand Up @@ -3096,7 +3122,7 @@ public void registerCoreMembers() {
// Specifying context or definitions as argument
// allows the transfer oof definitions to the new queue.
// Definitions are not carried over if not specified.
// (See <a href="/cmds/Define">command/Define</a>)
// (See <@link command define>)
//
// Specifying a player argument will run the queue with a player attached
// to that queue. The same can be done to attach an npc.
Expand Down Expand Up @@ -3761,14 +3787,28 @@ public void registerCoreMembers() {
// @Group item
//
// @Description
// TODO: Document Command Details
// Takes items from a player or inventory.
// If the player or inventory does not have the item being taken, nothing happens.
// Specifying a slot will take the items from that specific slot.
// If an economy is registered, specifying money instead of a item will take money from the player's economy.
// If no quantity is specified, it is assmued one.
//
// @Tags
// <p@player.item_in_hand>
// <p@player.money>
//
// @Usage
// TODO: Document Command Details
// Use to take money from the player
// - take money quantity:10
// @Usage
// Use to take an arrow from the player's enderchest
// - take 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 emerald quantity:5
// -->
registerCoreMember(TakeCommand.class,
"TAKE", "take [money/iteminhand/bydisplay:<name>/bycover:<title>|<author>/slot:<#>/<item>|...] (qty:<#>) (from:<inventory>)", 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,30 @@ else if (arg.startsWith("iconcrack_")) {
}
else if (arg.startsWith("blockcrack_")) {
String shrunk = arg.getValue().substring("blockcrack_".length());
Element typeId = new Element(shrunk);
String[] split = shrunk.split(",");
Element typeId = new Element(split[0]);
if (typeId.isInt() && typeId.asInt() > 0 && Material.getMaterial(typeId.asInt()) != null) {
scriptEntry.addObject("iconcrack", typeId);
}
else {
dB.echoError("Invalid blockcrack_[id]. Must be a valid Material ID, besides 0.");
}
Element dataId = new Element(split.length <= 1 ? "0" : split[1]);
scriptEntry.addObject("iconcrack_data", dataId);
scriptEntry.addObject("iconcrack_type", new Element("blockcrack"));
}
else if (arg.startsWith("blockdust_")) {
String shrunk = arg.getValue().substring("blockdust_".length());
Element typeId = new Element(shrunk);
String[] split = shrunk.split(",");
Element typeId = new Element(split[0]);
if (typeId.isInt() && typeId.asInt() > 0 && Material.getMaterial(typeId.asInt()) != null) {
scriptEntry.addObject("iconcrack", typeId);
}
else {
dB.echoError("Invalid blockdust_[id]. Must be a valid Material ID, besides 0.");
}
Element dataId = new Element(split.length <= 1 ? "0" : split[1]);
scriptEntry.addObject("iconcrack_data", dataId);
scriptEntry.addObject("iconcrack_type", new Element("blockdust"));
}
else if (particleHelper.hasEffect(arg.getValue())) {
Expand Down Expand Up @@ -278,9 +284,6 @@ else if (particleEffect != null) {

// Play an iconcrack (item break) effect
else {
float osX = (float) offset.getX();
float osY = (float) offset.getY();
float osZ = (float) offset.getZ();
List<Player> players = new ArrayList<Player>();
if (targets == null) {
float rad = radius.asFloat();
Expand All @@ -299,7 +302,7 @@ else if (particleEffect != null) {
}
// TODO: better this all
if (iconcrack_type.asString().equalsIgnoreCase("iconcrack")) {
ItemStack itemStack = new ItemStack(iconcrack.asInt(), iconcrack_data != null ? iconcrack_data.asInt() : 0);
ItemStack itemStack = new ItemStack(iconcrack.asInt(), 1, (short)(iconcrack_data != null ? iconcrack_data.asInt() : 0));
Particle particle = NMSHandler.getInstance().getParticleHelper().getParticle("ITEM_CRACK");
for (Player player : players) {
particle.playFor(player, location, qty.asInt(), offset.toVector(), data.asFloat(), itemStack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ public class InventoryScriptContainer extends ScriptContainer {
// my item: i@item
// other item: i@item
//
// # Procedural items can be used to specify a list of dItems for the empty slots to be filled with.
// # Each item in the list represents the next available empty slot.
// # When the inventory has no more empty slots, it will discard any remaining items in the list.
// # A slot is considered empty when it has no value specified in the slots section.
// # If the slot is filled with air, it will no longer count as being empty.
// procedural items:
// - define list li@
// - foreach <server.list_online_players>:
// - define item i@human_skull[skull_skin=<def[value].name>]
// - define list <def[list].include[<def[item]>]>
// - determine <def[list]>
//
// # You can specify the items in the slots of the inventory. For empty spaces, simply put
// # an empty "slot". Note the quotes around the entire lines.
// slots:
Expand Down

0 comments on commit 2f960fd

Please sign in to comment.