Skip to content

Commit 612736e

Browse files
authored
Merge pull request #1249 from Lildirt/attack_cooldown
Added pattack_cooldown().
2 parents f5ecef5 + 1b3af52 commit 612736e

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

src/main/java/com/laytonsmith/abstraction/MCHumanEntity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ public interface MCHumanEntity extends MCInventoryHolder, MCLivingEntity, MCAnim
4242

4343
void setCooldown(MCMaterial material, int ticks);
4444
//boolean setWindowProperty(MCInventoryView.Property prop, int value);
45+
46+
float getAttackCooldown();
4547
}

src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCHumanEntity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ public void setCooldown(MCMaterial material, int ticks) {
9393
he.setCooldown((Material) material.getHandle(), ticks);
9494
}
9595

96+
@Override
97+
public float getAttackCooldown() {
98+
return he.getAttackCooldown();
99+
}
100+
96101
@Override
97102
public MCInventoryView openInventory(MCInventory inventory) {
98103
return new BukkitMCInventoryView(he.openInventory((Inventory) inventory.getHandle()));

src/main/java/com/laytonsmith/core/functions/PlayerManagement.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.laytonsmith.abstraction.MCCommandSender;
88
import com.laytonsmith.abstraction.MCConsoleCommandSender;
99
import com.laytonsmith.abstraction.MCEntity;
10+
import com.laytonsmith.abstraction.MCHumanEntity;
1011
import com.laytonsmith.abstraction.MCItemStack;
1112
import com.laytonsmith.abstraction.MCLocation;
1213
import com.laytonsmith.abstraction.MCOfflinePlayer;
@@ -5560,6 +5561,58 @@ public MSVersion since() {
55605561

55615562
}
55625563

5564+
@api(environments = {CommandHelperEnvironment.class})
5565+
public static class pattack_cooldown extends AbstractFunction {
5566+
5567+
@Override
5568+
public Class<? extends CREThrowable>[] thrown() {
5569+
return new Class[] { CREPlayerOfflineException.class, CRELengthException.class };
5570+
}
5571+
5572+
@Override
5573+
public boolean isRestricted() {
5574+
return true;
5575+
}
5576+
5577+
@Override
5578+
public Boolean runAsync() {
5579+
return false;
5580+
}
5581+
5582+
@Override
5583+
public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException {
5584+
MCHumanEntity he;
5585+
if(args.length == 0) {
5586+
he = env.getEnv(CommandHelperEnvironment.class).GetPlayer();
5587+
} else {
5588+
he = Static.GetPlayer(args[0], t);
5589+
}
5590+
return new CDouble(he.getAttackCooldown(), t);
5591+
}
5592+
5593+
@Override
5594+
public String getName() {
5595+
return "pattack_cooldown";
5596+
}
5597+
5598+
@Override
5599+
public Integer[] numArgs() {
5600+
return new Integer[]{0, 1};
5601+
}
5602+
5603+
@Override
5604+
public String docs() {
5605+
return "double {[player]} Gets the charge value of the player's attack cooldown. This is a "
5606+
+ " double with range 0.0-1.0 inclusive. 1.0 is fully charged, while 0.0 is no charge.";
5607+
}
5608+
5609+
@Override
5610+
public MSVersion since() {
5611+
return MSVersion.V3_3_4;
5612+
}
5613+
5614+
}
5615+
55635616
@api(environments = {CommandHelperEnvironment.class})
55645617
public static class get_plist_header extends AbstractFunction {
55655618

0 commit comments

Comments
 (0)