Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated /listworlds, Fixed /reply (wrong copy-paste code), Added 2 extra commands : /enchant and /addexperience Updated items.csv
- Loading branch information
Showing
17 changed files
with
456 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/com/guntherdw/bukkit/tweakcraft/Commands/General/CommandAddExperience.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,82 @@ | |||
/* | |||
* Copyright (c) 2011 GuntherDW | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License | |||
* as published by the Free Software Foundation; either version 2 | |||
* of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
|
|||
package com.guntherdw.bukkit.tweakcraft.Commands.General; | |||
|
|||
import com.guntherdw.bukkit.tweakcraft.Commands.iCommand; | |||
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandException; | |||
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandSenderException; | |||
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandUsageException; | |||
import com.guntherdw.bukkit.tweakcraft.Exceptions.PermissionsException; | |||
import com.guntherdw.bukkit.tweakcraft.Tools.ArgumentParser; | |||
import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils; | |||
import org.bukkit.ChatColor; | |||
import org.bukkit.command.CommandSender; | |||
import org.bukkit.entity.Player; | |||
|
|||
import java.util.List; | |||
|
|||
/** | |||
* @author GuntherDW | |||
*/ | |||
public class CommandAddExperience implements iCommand { | |||
|
|||
@Override | |||
public boolean executeCommand(CommandSender sender, String command, String[] args, TweakcraftUtils plugin) | |||
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException { | |||
if(sender instanceof Player) | |||
if(!plugin.check((Player)sender, getPermissionSuffix())) | |||
throw new PermissionsException(command); | |||
|
|||
ArgumentParser ap = new ArgumentParser(args); | |||
String playerString = ap.getString("p", null); | |||
String[] ars = ap.getUnusedArgs(); | |||
|
|||
if(playerString==null) { | |||
if(!(sender instanceof Player)) | |||
throw new CommandUsageException("Who do i have to give experience to?"); | |||
else | |||
playerString = ((Player) sender).getName(); | |||
} | |||
|
|||
List<Player> p = plugin.findPlayerasPlayerList(playerString); | |||
if(p.size()!=1) | |||
throw new CommandException("Player not found!"); | |||
if(ars.length<1) | |||
throw new CommandException("No amount given"); | |||
int amount = 0; | |||
try{ | |||
amount = Integer.parseInt(ars[0]); | |||
} catch(NumberFormatException ex) { | |||
throw new CommandException("Number expected, garbage given"); | |||
} | |||
|
|||
Player player = p.get(0); | |||
sender.sendMessage(player.getDisplayName()+ChatColor.YELLOW+" had "+player.getTotalExperience()+ " experience, adding "+amount); | |||
player.sendMessage(ChatColor.YELLOW+"Adding "+amount+" to your total experience!"); | |||
player.setTotalExperience(player.getTotalExperience()+amount); | |||
|
|||
return true; | |||
} | |||
|
|||
@Override | |||
public String getPermissionSuffix() { | |||
return "addexp"; | |||
} | |||
|
|||
} |
105 changes: 105 additions & 0 deletions
105
src/com/guntherdw/bukkit/tweakcraft/Commands/General/CommandEnchant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,105 @@ | |||
/* | |||
* Copyright (c) 2011 GuntherDW | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License | |||
* as published by the Free Software Foundation; either version 2 | |||
* of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
|
|||
package com.guntherdw.bukkit.tweakcraft.Commands.General; | |||
|
|||
import com.guntherdw.bukkit.tweakcraft.Commands.iCommand; | |||
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandException; | |||
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandSenderException; | |||
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandUsageException; | |||
import com.guntherdw.bukkit.tweakcraft.Exceptions.PermissionsException; | |||
import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils; | |||
import org.bukkit.ChatColor; | |||
import org.bukkit.Enchantment; | |||
import org.bukkit.command.CommandSender; | |||
import org.bukkit.entity.Player; | |||
import org.bukkit.inventory.ItemStack; | |||
|
|||
import java.util.Map; | |||
|
|||
/** | |||
* @author GuntherDW | |||
*/ | |||
public class CommandEnchant implements iCommand { | |||
@Override | |||
public boolean executeCommand(CommandSender sender, String command, String[] args, TweakcraftUtils plugin) | |||
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException { | |||
if(sender instanceof Player) { | |||
if(!plugin.check((Player)sender, getPermissionSuffix())) | |||
throw new PermissionsException(command); | |||
} else { | |||
throw new CommandSenderException("What do you want to enchant today?"); | |||
} | |||
|
|||
if(args.length==0) { | |||
ItemStack is = ((Player)sender).getItemInHand(); | |||
if(is!=null) { | |||
sender.sendMessage(ChatColor.YELLOW+"Enchantments for this item :"); | |||
Map<Enchantment, Integer> enchantments = is.getEnchantments(); | |||
if(enchantments==null) { | |||
sender.sendMessage(ChatColor.YELLOW+"This item doesn't have any enchantments!"); | |||
} else { | |||
for(Enchantment ench : enchantments.keySet()) { | |||
sender.sendMessage(ChatColor.YELLOW+ench.name()+" at level "+enchantments.get(ench)); | |||
} | |||
} | |||
} else { | |||
sender.sendMessage(ChatColor.YELLOW+"You're not holding anything"); | |||
} | |||
return true; | |||
} else if(args.length==1 && args[0].equalsIgnoreCase("disenchant")) { | |||
ItemStack is = ((Player)sender).getItemInHand(); | |||
if(is!=null) { | |||
sender.sendMessage(ChatColor.YELLOW+"Clearing any enchantments this item had"); | |||
is.clearEnchantments(); | |||
} else { | |||
sender.sendMessage(ChatColor.YELLOW+"You're not holding anything"); | |||
} | |||
} else if(args.length!=2) | |||
throw new CommandUsageException("I need exactly 2 values, an ID and a level!"); | |||
|
|||
Integer enchantmentId = null; | |||
Integer enchantmentLevel = null; | |||
|
|||
try{ | |||
enchantmentId = Integer.parseInt(args[0]); | |||
enchantmentLevel = Integer.parseInt(args[1]); | |||
} catch(NumberFormatException ex) { | |||
throw new CommandUsageException("I need numbers, not garbage!"); | |||
} | |||
|
|||
Enchantment enchantment = Enchantment.byId(enchantmentId); | |||
|
|||
if(enchantment!=null) { | |||
ItemStack is = ((Player)sender).getItemInHand(); | |||
is.clearEnchantments(); | |||
is.addEnchantment(enchantment, enchantmentLevel); | |||
sender.sendMessage(ChatColor.YELLOW+"Adding "+enchantment.name()+" level "+enchantmentLevel); | |||
} else { | |||
sender.sendMessage(ChatColor.YELLOW+"Couldn't find Enchantment with id "+enchantmentId+"!"); | |||
} | |||
|
|||
return true; | |||
|
|||
} | |||
|
|||
@Override | |||
public String getPermissionSuffix() { | |||
return "enchant"; | |||
} | |||
} |
Oops, something went wrong.