Skip to content

Commit

Permalink
Add spell descriptions and command
Browse files Browse the repository at this point in the history
  • Loading branch information
spraetz committed Apr 1, 2014
1 parent f5caf5b commit 09e6a1a
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 33 deletions.
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.spraetz</groupId>
<artifactId>MineCraftSpells</artifactId>
<version>2.4.0</version>
<version>2.5.0</version>
<build>
<plugins>
<plugin>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.gmail.spraetz</groupId>
<artifactId>MineCraftSpells</artifactId>
<version>2.4.0</version>
<version>2.5.0</version>

<build>
<plugins>
Expand Down Expand Up @@ -52,7 +52,7 @@
<phase>package</phase>
<configuration>
<tasks>
<copy file="/Users/spraetz/dev/MineCraftSpells/target/MineCraftSpells-2.4.0.jar" tofile="/Users/spraetz/MineCraft/MineCraftSpells/plugins/MineCraftSpells-2.4.0.jar"/>
<copy file="/Users/spraetz/dev/MineCraftSpells/target/MineCraftSpells-2.5.0.jar" tofile="/Users/spraetz/MineCraft/MineCraftSpells/plugins/MineCraftSpells-2.5.0.jar"/>
</tasks>
</configuration>
<goals>
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/gmail/spraetz/commands/LaunchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.Player;

/**
Expand Down
58 changes: 43 additions & 15 deletions src/main/java/com/gmail/spraetz/commands/SpellHelp.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.bukkit.command.CommandSender;
import org.bukkit.inventory.ItemStack;

import java.util.ArrayList;
import java.util.Set;

/**
Expand All @@ -23,24 +22,53 @@ public SpellHelp(MineCraftSpells plugin){
}

@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
//Get the list of spell names
Set<String> spellNames = plugin.getConfig().getConfigurationSection("spells").getKeys(false);
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {

//Iterate over them and return a message to the commandSender with info
for(String spellName : spellNames){
ItemStack[] items = Spellbook.getReagents(spellName, plugin);
String reagentString = "";
for(int i = 0; i < items.length; i++){
reagentString += items[i].getType().toString() + ": " + items[i].getAmount();
if(i != items.length - 1){
reagentString += ", ";
}
}
//Check if it has any args.
if(args.length == 0){
listAllSpells(commandSender);
}
if(args.length == 1){

String spellName = args[0];

commandSender.sendMessage(ChatColor.AQUA + spellName + ": " + ChatColor.RED + reagentString);
// Check if the arg is a spell name.
if(Spellbook.spellExists(spellName, plugin)){
sendSpellDescription(commandSender, spellName);
}
else{
commandSender.sendMessage("There is no spell called " + spellName);
}
}
else if(args.length > 1){
return false;
}

return true;
}

private void sendSpellDescription(CommandSender commandSender, String spellName){
commandSender.sendMessage(ChatColor.BOLD + spellName + ": " + ChatColor.LIGHT_PURPLE + getReagentString(spellName));
commandSender.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("spells." + spellName + ".description"));
}

private void listAllSpells(CommandSender commandSender){
//Get the list of spell names
Set<String> spellNames = plugin.getConfig().getConfigurationSection("spells").getKeys(false);

commandSender.sendMessage(ChatColor.GOLD + "Spell names: " + ChatColor.AQUA + spellNames.toString());
commandSender.sendMessage(ChatColor.GOLD + "To learn more about a spell, try /spells spell_name.");
}

private String getReagentString(String spellName){
ItemStack[] items = Spellbook.getReagents(spellName, plugin);
String reagentString = "";
for(int i = 0; i < items.length; i++){
reagentString += items[i].getType().toString() + ": " + items[i].getAmount();
if(i != items.length - 1){
reagentString += ", ";
}
}
return reagentString;
}
}
13 changes: 13 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Default config.yml for Engine
spells:
explosion:
description: Launches a projectile that causes a large explosion.
class: com.gmail.spraetz.spells.Explosion
reagents:
- reagent: FLINT
Expand All @@ -11,6 +12,7 @@ spells:
radius: 3
damage_multiplier: 1
fire_ball:
description: Launches a projectile that ignites nearby things.
class: com.gmail.spraetz.spells.FireBall
reagents:
- reagent: FLINT
Expand All @@ -23,20 +25,23 @@ spells:
ignite_radius: 3
fire_ticks: 100
lightning_bolt:
description: Causes a bolt of lightning to strike where targeted.
class: com.gmail.spraetz.spells.LightningBolt
reagents:
- reagent: COAL
quantity: 1
- reagent: WHEAT
quantity: 1
teleport:
description: Teleports the player to the targeted location.
class: com.gmail.spraetz.spells.Teleport
reagents:
- reagent: EGG
quantity: 1
- reagent: LEATHER
quantity: 1
stone_wall:
description: Creates a temporary wall made of bedrock where targeted.
class: com.gmail.spraetz.spells.Wall
reagents:
- reagent: WHEAT
Expand All @@ -48,6 +53,7 @@ spells:
minimum_ticks: 80
maximum_ticks: 120
heal_self:
description: Restores your own hearts.
class: com.gmail.spraetz.spells.HealSelf
reagents:
- reagent: WOOL
Expand All @@ -57,6 +63,7 @@ spells:
settings:
percent_of_max_health: 30
heal_other:
description: Restores the health of the entity you click. Must be close enough to touch.
class: com.gmail.spraetz.spells.HealOther
reagents:
- reagent: WOOL
Expand All @@ -66,13 +73,15 @@ spells:
settings:
percent_of_max_health: 30
recall:
description: Takes the player back to their bed spawn or server spawn if there is none.
class: com.gmail.spraetz.spells.Recall
reagents:
- reagent: EGG
quantity: 1
- reagent: WOOL
quantity: 1
flight:
description: Grants the player the ability to fly temporarily.
class: com.gmail.spraetz.spells.Flight
reagents:
- reagent: FEATHER
Expand All @@ -82,6 +91,7 @@ spells:
settings:
ticks: 400
push:
description: Knocks an entity way back. Must be close enough to touch.
class: com.gmail.spraetz.spells.Push
reagents:
- reagent: WHEAT
Expand All @@ -91,13 +101,15 @@ spells:
up_force: 0.5
max_up_force: 1.0
ignite:
description: Sets an entity on fire. Must be close enough to touch.
class: com.gmail.spraetz.spells.Ignite
reagents:
- reagent: COAL
quantity: 2
settings:
ticks: 150
poison:
description: Poisons an entity. Must be close enough to touch.
class: com.gmail.spraetz.spells.Poison
reagents:
- reagent: NETHER_STALK
Expand All @@ -106,6 +118,7 @@ spells:
ticks: 300
amplifier: 1
restore:
description: Removes all negative effects from yourself.
class: com.gmail.spraetz.spells.Restore
reagents:
- reagent: WHEAT
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: MineCraftSpells
version: 2.4.0
version: 2.5.0
main: com.gmail.spraetz.plugin.MineCraftSpells

commands:
Expand All @@ -10,7 +10,7 @@ commands:
permission-message: You don't have <permission>
spells:
description: Lists all spells and their required components
usage: /<command>
usage: /<command> [spell_name]
permission: player
permission-message: You don't have <permission>
particle:
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite failures="0" time="2.069" errors="0" skipped="0" tests="1" name="com.gmail.spraetz.CastSpellTest">
<testsuite failures="0" time="1.251" errors="0" skipped="0" tests="1" name="com.gmail.spraetz.CastSpellTest">
<properties>
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
<property name="sun.boot.library.path" value="/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib"/>
Expand All @@ -20,7 +20,7 @@
<property name="basedir" value="/Users/spraetz/dev/MineCraftSpells"/>
<property name="java.endorsed.dirs" value="/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/endorsed"/>
<property name="os.arch" value="x86_64"/>
<property name="surefire.real.class.path" value="/var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/surefirebooter8741787849859179176.jar"/>
<property name="surefire.real.class.path" value="/var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/surefirebooter3822806075622066586.jar"/>
<property name="java.io.tmpdir" value="/var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/"/>
<property name="line.separator" value="
"/>
Expand All @@ -44,7 +44,7 @@
<property name="java.vm.specification.version" value="1.7"/>
<property name="sun.arch.data.model" value="64"/>
<property name="java.home" value="/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre"/>
<property name="sun.java.command" value="/var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/surefirebooter8741787849859179176.jar /var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/surefire9107638454879623794tmp /var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/surefire4422197644465893282tmp"/>
<property name="sun.java.command" value="/var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/surefirebooter3822806075622066586.jar /var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/surefire7954240581945534735tmp /var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/surefire6847184097586539604tmp"/>
<property name="java.specification.vendor" value="Oracle Corporation"/>
<property name="user.language" value="en"/>
<property name="awt.toolkit" value="sun.lwawt.macosx.LWCToolkit"/>
Expand All @@ -62,5 +62,5 @@
<property name="ftp.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
<property name="sun.cpu.isalist" value=""/>
</properties>
<testcase time="0.931" classname="com.gmail.spraetz.CastSpellTest" name="testCastSpell"/>
<testcase time="0.588" classname="com.gmail.spraetz.CastSpellTest" name="testCastSpell"/>
</testsuite>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite failures="0" time="3.437" errors="0" skipped="0" tests="6" name="com.gmail.spraetz.ChargeSpellbookTest">
<testsuite failures="0" time="2.255" errors="0" skipped="0" tests="6" name="com.gmail.spraetz.ChargeSpellbookTest">
<properties>
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
<property name="sun.boot.library.path" value="/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib"/>
Expand All @@ -20,7 +20,7 @@
<property name="basedir" value="/Users/spraetz/dev/MineCraftSpells"/>
<property name="java.endorsed.dirs" value="/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/endorsed"/>
<property name="os.arch" value="x86_64"/>
<property name="surefire.real.class.path" value="/var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/surefirebooter8741787849859179176.jar"/>
<property name="surefire.real.class.path" value="/var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/surefirebooter3822806075622066586.jar"/>
<property name="java.io.tmpdir" value="/var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/"/>
<property name="line.separator" value="
"/>
Expand All @@ -44,7 +44,7 @@
<property name="java.vm.specification.version" value="1.7"/>
<property name="sun.arch.data.model" value="64"/>
<property name="java.home" value="/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre"/>
<property name="sun.java.command" value="/var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/surefirebooter8741787849859179176.jar /var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/surefire9107638454879623794tmp /var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/surefire4422197644465893282tmp"/>
<property name="sun.java.command" value="/var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/surefirebooter3822806075622066586.jar /var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/surefire7954240581945534735tmp /var/folders/wr/nmgyr2_n1ls2cx3z3y7phl4c0000gn/T/surefire6847184097586539604tmp"/>
<property name="java.specification.vendor" value="Oracle Corporation"/>
<property name="user.language" value="en"/>
<property name="awt.toolkit" value="sun.lwawt.macosx.LWCToolkit"/>
Expand All @@ -62,10 +62,10 @@
<property name="ftp.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
<property name="sun.cpu.isalist" value=""/>
</properties>
<testcase time="1.063" classname="com.gmail.spraetz.ChargeSpellbookTest" name="testChargeSpellbook"/>
<testcase time="0.017" classname="com.gmail.spraetz.ChargeSpellbookTest" name="testChargeSpellAtMaxCharges"/>
<testcase time="0.018" classname="com.gmail.spraetz.ChargeSpellbookTest" name="testChargeSpellbookTooManySpells"/>
<testcase time="0.472" classname="com.gmail.spraetz.ChargeSpellbookTest" name="testChargeSpellAtMaxCharges"/>
<testcase time="0.019" classname="com.gmail.spraetz.ChargeSpellbookTest" name="testChargeSpellbookTooManySpells"/>
<testcase time="0.016" classname="com.gmail.spraetz.ChargeSpellbookTest" name="testChargeNewSpellbook"/>
<testcase time="0.068" classname="com.gmail.spraetz.ChargeSpellbookTest" name="testRechargeSpellbook"/>
<testcase time="0.012" classname="com.gmail.spraetz.ChargeSpellbookTest" name="testChargeSpellbookNoReagents"/>
<testcase time="0.063" classname="com.gmail.spraetz.ChargeSpellbookTest" name="testRechargeSpellbook"/>
<testcase time="0.014" classname="com.gmail.spraetz.ChargeSpellbookTest" name="testChargeSpellbookNoReagents"/>
<testcase time="0.117" classname="com.gmail.spraetz.ChargeSpellbookTest" name="testChargeSpellbook"/>
</testsuite>

0 comments on commit 09e6a1a

Please sign in to comment.