2014-06-12 23:21:20 +00:00
package com.projectkorra.ProjectKorra ;
2014-07-12 03:34:03 +00:00
import java.io.File ;
2014-06-12 23:21:20 +00:00
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.HashMap ;
2014-07-12 03:34:03 +00:00
import java.util.LinkedList ;
2014-06-12 23:21:20 +00:00
import java.util.List ;
2014-07-12 03:34:03 +00:00
import java.util.UUID ;
2014-06-12 23:21:20 +00:00
import org.bukkit.Bukkit ;
2014-06-13 04:30:43 +00:00
import org.bukkit.ChatColor ;
2014-06-12 23:21:20 +00:00
import org.bukkit.command.Command ;
import org.bukkit.command.CommandExecutor ;
import org.bukkit.command.CommandSender ;
import org.bukkit.command.PluginCommand ;
2014-07-12 03:34:03 +00:00
import org.bukkit.configuration.file.FileConfiguration ;
import org.bukkit.configuration.file.YamlConfiguration ;
2014-06-12 23:21:20 +00:00
import org.bukkit.entity.Player ;
2014-07-12 14:17:26 +00:00
import org.bukkit.scheduler.BukkitTask ;
2014-06-12 23:21:20 +00:00
import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager ;
2014-07-12 14:17:26 +00:00
import com.projectkorra.ProjectKorra.Ability.StockAbilities ;
2014-06-12 23:21:20 +00:00
public class Commands {
ProjectKorra plugin ;
public Commands ( ProjectKorra plugin ) {
this . plugin = plugin ;
init ( ) ;
}
String [ ] airaliases = { " air " , " a " , " airbending " , " airbender " } ;
String [ ] wateraliases = { " water " , " w " , " waterbending " , " waterbender " } ;
String [ ] earthaliases = { " earth " , " e " , " earthbending " , " earthbender " } ;
String [ ] firealiases = { " fire " , " f " , " firebending " , " firebender " } ;
String [ ] chialiases = { " chi " , " c " , " chiblocking " , " chiblocker " } ;
String [ ] helpaliases = { " help " , " h " } ;
String [ ] versionaliases = { " version " , " v " } ;
String [ ] permaremovealiases = { " permaremove " , " premove " , " permremove " , " pr " } ;
String [ ] choosealiases = { " choose " , " ch " } ;
String [ ] removealiases = { " remove " , " rm " } ;
String [ ] togglealiases = { " toggle " , " t " } ;
String [ ] displayaliases = { " display " , " d " } ;
String [ ] bindaliases = { " bind " , " b " } ;
String [ ] clearaliases = { " clear " , " cl " , " c " } ;
String [ ] reloadaliases = { " reload " , " r " } ;
2014-07-01 00:42:32 +00:00
String [ ] addaliases = { " add " , " a " } ;
String [ ] whoaliases = { " who " , " w " } ;
2014-07-12 11:55:55 +00:00
String [ ] importaliases = { " import " , " i " } ;
2014-07-01 00:45:50 +00:00
2014-07-12 14:17:26 +00:00
private static BukkitTask importTask ;
2014-06-12 23:21:20 +00:00
private void init ( ) {
PluginCommand projectkorra = plugin . getCommand ( " projectkorra " ) ;
CommandExecutor exe ;
exe = new CommandExecutor ( ) {
@Override
public boolean onCommand ( CommandSender s , Command c , String label , String [ ] args ) {
if ( args . length = = 0 ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " /bending help [Ability/Command] " + ChatColor . YELLOW + " Display help. " ) ;
s . sendMessage ( ChatColor . RED + " /bending choose [Element] " + ChatColor . YELLOW + " Choose an element. " ) ;
s . sendMessage ( ChatColor . RED + " /bending bind [Ability] # " + ChatColor . YELLOW + " Bind an ability. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( Arrays . asList ( reloadaliases ) . contains ( args [ 0 ] . toLowerCase ( ) ) ) {
if ( args . length ! = 1 ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: /bending reload " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( ! s . hasPermission ( " bending.command.reload " ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
plugin . reloadConfig ( ) ;
2014-07-05 14:39:08 +00:00
Methods . stopBending ( ) ;
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . AQUA + " Bending config reloaded. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( Arrays . asList ( clearaliases ) . contains ( args [ 0 ] . toLowerCase ( ) ) ) {
if ( args . length > 2 ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: /bending clear <#> " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( ! s . hasPermission ( " bending.command.clear " ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( ! ( s instanceof Player ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " This command is only usable by players. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
BendingPlayer bPlayer = Methods . getBendingPlayer ( s . getName ( ) ) ;
if ( args . length = = 1 ) {
bPlayer . abilities . clear ( ) ;
s . sendMessage ( " Your bound abilities have been cleared. " ) ;
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( args . length = = 2 ) {
int slot = Integer . parseInt ( args [ 1 ] ) ;
if ( slot < 1 | | slot > 9 ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " The slot must be an integer between 0 and 9. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( bPlayer . abilities . get ( slot ) ! = null ) {
bPlayer . abilities . remove ( slot ) ;
}
s . sendMessage ( " You have cleared slot # " + slot ) ;
return true ;
}
}
if ( Arrays . asList ( bindaliases ) . contains ( args [ 0 ] . toLowerCase ( ) ) ) {
if ( args . length > 3 | | args . length = = 1 ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: /bending bind [Ability] <#> " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( ! s . hasPermission ( " bending.command.bind " ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( ! ( s instanceof Player ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( args . length = = 2 ) {
// We bind the ability to the slot they have selected..
// bending bind [Ability]
String abil = args [ 1 ] ;
if ( ! Methods . abilityExists ( abil ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " That is not an ability. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
String ability = Methods . getAbility ( abil ) ;
2014-07-01 00:45:50 +00:00
2014-07-04 02:29:30 +00:00
if ( ! Methods . hasPermission ( ( Player ) s , ability ) ) {
2014-07-01 00:49:44 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
return true ;
}
2014-06-12 23:21:20 +00:00
if ( Methods . isAirAbility ( ability ) & & ! Methods . isBender ( s . getName ( ) , Element . Air ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getAirColor ( ) + " You must be an Airbender to bind this ability. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( Methods . isWaterAbility ( ability ) & & ! Methods . isBender ( s . getName ( ) , Element . Water ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getWaterColor ( ) + " You must be a Waterbender to bind this ability. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( Methods . isEarthAbility ( ability ) & & ! Methods . isBender ( s . getName ( ) , Element . Earth ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getEarthColor ( ) + " You must be an Earthbender to bind this ability. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( Methods . isFireAbility ( ability ) & & ! Methods . isBender ( s . getName ( ) , Element . Fire ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getFireColor ( ) + " You must be a Firebender to bind this ability. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( Methods . isChiAbility ( ability ) & & ! Methods . isBender ( s . getName ( ) , Element . Chi ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getChiColor ( ) + " You must be a ChiBlocker to bind this ability. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
Methods . bindAbility ( ( Player ) s , ability ) ;
2014-07-01 00:45:50 +00:00
// s.sendMessage("Ability Bound to slot");
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( args . length = = 3 ) {
// bending bind ability [Slot]
String abil = args [ 1 ] ;
if ( ! Methods . abilityExists ( abil ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " That ability doesn't exist. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
String ability = Methods . getAbility ( abil ) ;
2014-07-08 01:17:36 +00:00
int slot = 0 ;
try {
slot = Integer . parseInt ( args [ 2 ] ) ;
} catch ( NumberFormatException e ) {
s . sendMessage ( ChatColor . RED + " Slot must be an integer between 1 and 9. " ) ;
return true ;
}
2014-06-12 23:21:20 +00:00
if ( slot < 1 | | slot > 9 ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " Slot must be an integer between 1 and 9. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-08 01:17:36 +00:00
2014-07-04 02:29:30 +00:00
if ( ! Methods . hasPermission ( ( Player ) s , ability ) ) {
2014-07-01 00:49:44 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( Methods . isAirAbility ( ability ) & & ! Methods . isBender ( s . getName ( ) , Element . Air ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getAirColor ( ) + " You must be an Airbender to bind this ability. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( Methods . isWaterAbility ( ability ) & & ! Methods . isBender ( s . getName ( ) , Element . Water ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getWaterColor ( ) + " You must be a Waterbender to bind this ability. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( Methods . isEarthAbility ( ability ) & & ! Methods . isBender ( s . getName ( ) , Element . Earth ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getEarthColor ( ) + " You must be an Earthbender to bind this ability. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( Methods . isFireAbility ( ability ) & & ! Methods . isBender ( s . getName ( ) , Element . Fire ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getFireColor ( ) + " You must be a Firebender to bind this ability. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-06-28 23:51:31 +00:00
if ( Methods . isChiAbility ( ability ) & & ! Methods . isBender ( s . getName ( ) , Element . Chi ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getChiColor ( ) + " You must be a ChiBlocker to bind this ability. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
Methods . bindAbility ( ( Player ) s , ability , slot ) ;
2014-07-01 00:45:50 +00:00
// s.sendMessage("Ability Bound");
2014-06-12 23:21:20 +00:00
return true ;
}
}
2014-07-12 11:55:55 +00:00
if ( Arrays . asList ( importaliases ) . contains ( args [ 0 ] . toLowerCase ( ) ) ) {
2014-07-12 03:34:03 +00:00
if ( ! s . hasPermission ( " bending.command.import " ) ) {
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
return true ;
}
s . sendMessage ( ChatColor . GREEN + " Preparing data for import. " ) ;
File bendingPlayersFile = new File ( " . " , " converted.yml " ) ;
FileConfiguration bendingPlayers = YamlConfiguration . loadConfiguration ( bendingPlayersFile ) ;
final LinkedList < BendingPlayer > bPlayers = new LinkedList < BendingPlayer > ( ) ;
for ( String string : bendingPlayers . getConfigurationSection ( " " ) . getKeys ( false ) ) {
if ( string . equalsIgnoreCase ( " version " ) ) continue ;
String playername = string ;
UUID uuid = Bukkit . getOfflinePlayer ( playername ) . getUniqueId ( ) ;
ArrayList < Element > element = new ArrayList < Element > ( ) ;
List < Integer > oe = bendingPlayers . getIntegerList ( string + " .BendingTypes " ) ;
2014-07-12 14:17:26 +00:00
HashMap < Integer , String > abilities = new HashMap < Integer , String > ( ) ;
List < Integer > oa = bendingPlayers . getIntegerList ( string + " .SlotAbilities " ) ;
boolean permaremoved = bendingPlayers . getBoolean ( string + " .Permaremoved " ) ;
2014-07-12 03:34:03 +00:00
2014-07-12 14:17:26 +00:00
int slot = 1 ;
for ( int i : oa ) {
if ( StockAbilities . getAbility ( i ) ! = null ) {
abilities . put ( slot , StockAbilities . getAbility ( i ) . toString ( ) ) ;
slot + + ;
} else {
abilities . put ( slot , null ) ;
slot + + ;
}
}
2014-07-12 11:55:55 +00:00
for ( int i : oe ) {
if ( Element . getType ( i ) ! = null ) {
element . add ( Element . getType ( i ) ) ;
}
2014-07-12 03:34:03 +00:00
}
2014-07-12 14:17:26 +00:00
BendingPlayer bPlayer = new BendingPlayer ( uuid , playername , element , abilities , permaremoved ) ;
2014-07-12 03:34:03 +00:00
bPlayers . add ( bPlayer ) ;
}
final int total = bPlayers . size ( ) ;
final CommandSender sender = s ;
s . sendMessage ( ChatColor . GREEN + " Import of data started. Do NOT stop / reload your server. " ) ;
2014-07-12 14:17:26 +00:00
importTask = Bukkit . getServer ( ) . getScheduler ( ) . runTaskTimerAsynchronously ( plugin , new Runnable ( ) {
2014-07-12 03:34:03 +00:00
public void run ( ) {
int i = 0 ;
if ( i > = 10 ) {
sender . sendMessage ( ChatColor . GREEN + " 10 / " + total + " players converted thus far! " ) ;
return ;
}
while ( i < 10 ) {
if ( bPlayers . isEmpty ( ) ) {
sender . sendMessage ( ChatColor . GREEN + " Import complete, it may be best to reload your server. " ) ;
2014-07-12 14:17:26 +00:00
Bukkit . getServer ( ) . getScheduler ( ) . cancelTask ( importTask . getTaskId ( ) ) ;
2014-07-12 03:34:03 +00:00
for ( Player player : Bukkit . getOnlinePlayers ( ) ) {
Methods . createBendingPlayer ( player . getUniqueId ( ) , player . getName ( ) ) ;
}
return ;
}
StringBuilder elements = new StringBuilder ( ) ;
BendingPlayer bPlayer = bPlayers . pop ( ) ;
if ( bPlayer . hasElement ( Element . Air ) ) elements . append ( " a " ) ;
if ( bPlayer . hasElement ( Element . Water ) ) elements . append ( " w " ) ;
if ( bPlayer . hasElement ( Element . Earth ) ) elements . append ( " e " ) ;
if ( bPlayer . hasElement ( Element . Fire ) ) elements . append ( " f " ) ;
if ( bPlayer . hasElement ( Element . Chi ) ) elements . append ( " c " ) ;
2014-07-12 14:17:26 +00:00
HashMap < Integer , String > abilities = bPlayer . abilities ;
DBConnection . sql . modifyQuery ( " INSERT INTO pk_players (uuid, player, element, permaremoved) VALUES (' " + bPlayer . uuid . toString ( ) + " ', ' " + bPlayer . player + " ', ' " + elements + " ', ' " + bPlayer . isPermaRemoved ( ) + " ') " ) ;
for ( int slot = 1 ; slot < 10 ; slot + + ) {
DBConnection . sql . modifyQuery ( " UPDATE pk_players SET slot " + slot + " = ' " + abilities . get ( slot ) + " ' WHERE player = ' " + bPlayer . getPlayerName ( ) + " ' " ) ;
}
2014-07-12 03:34:03 +00:00
// ResultSet rs2 = DBConnection.sql.readQuery("SELECT * FROM pk_players WHERE uuid = '" + bPlayer.uuid.toString() + "'");
// try {
// if (rs2.next()) { // SQL Data already exists for player.
// DBConnection.sql.modifyQuery("UPDATE pk_players SET player = '" + bPlayer.player + "' WHERE uuid = '" + bPlayer.uuid.toString());
// DBConnection.sql.modifyQuery("UPDATE pk_players SET element = '" + elements + "' WHERE uuid = '" + bPlayer.uuid.toString());
// DBConnection.sql.modifyQuery("UPDATE pk_players SET permaremoved = 'false' WHERE uuid = '" + bPlayer.uuid.toString());
// } else {
// }
// } catch (SQLException ex) {
// ex.printStackTrace();
// }
i + + ;
}
}
} , 0 , 40 ) ;
return true ;
}
2014-06-12 23:21:20 +00:00
if ( Arrays . asList ( displayaliases ) . contains ( args [ 0 ] . toLowerCase ( ) ) ) {
if ( args . length > 2 ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: /bending display <Element> " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( ! s . hasPermission ( " bending.command.display " ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( args . length = = 2 ) {
//bending display [Element]
2014-06-13 02:17:59 +00:00
if ( Arrays . asList ( airaliases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
2014-06-12 23:21:20 +00:00
if ( AbilityModuleManager . airbendingabilities . isEmpty ( ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getAirColor ( ) + " There are no airbending abilities available. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
for ( String st : AbilityModuleManager . airbendingabilities ) {
2014-07-01 00:48:07 +00:00
if ( Methods . hasPermission ( ( Player ) s , st ) ) {
2014-07-01 00:45:50 +00:00
s . sendMessage ( Methods . getAirColor ( ) + st ) ;
}
2014-06-12 23:21:20 +00:00
}
return true ;
}
2014-06-13 02:17:59 +00:00
if ( Arrays . asList ( wateraliases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
2014-06-12 23:21:20 +00:00
if ( AbilityModuleManager . waterbendingabilities . isEmpty ( ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getWaterColor ( ) + " There are no waterbending abilities available. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
for ( String st : AbilityModuleManager . waterbendingabilities ) {
2014-07-01 00:48:07 +00:00
if ( Methods . hasPermission ( ( Player ) s , st ) ) {
2014-07-01 00:45:50 +00:00
s . sendMessage ( Methods . getWaterColor ( ) + st ) ;
}
2014-06-12 23:21:20 +00:00
}
return true ;
}
2014-06-13 02:17:59 +00:00
if ( Arrays . asList ( earthaliases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
2014-06-12 23:21:20 +00:00
if ( AbilityModuleManager . earthbendingabilities . isEmpty ( ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getEarthColor ( ) + " There are no earthbending abilities available. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
for ( String st : AbilityModuleManager . earthbendingabilities ) {
2014-07-01 00:48:07 +00:00
if ( Methods . hasPermission ( ( Player ) s , st ) ) {
2014-07-10 14:38:26 +00:00
if ( Methods . isMetalbendingAbility ( st ) ) {
s . sendMessage ( Methods . getMetalbendingColor ( ) + st ) ;
} else {
s . sendMessage ( Methods . getEarthColor ( ) + st ) ;
}
2014-07-01 00:45:50 +00:00
}
2014-06-12 23:21:20 +00:00
}
return true ;
}
2014-06-13 02:17:59 +00:00
if ( Arrays . asList ( firealiases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
2014-06-12 23:21:20 +00:00
if ( AbilityModuleManager . firebendingabilities . isEmpty ( ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getFireColor ( ) + " There are no firebending abilities available. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
for ( String st : AbilityModuleManager . firebendingabilities ) {
2014-07-01 00:48:07 +00:00
if ( Methods . hasPermission ( ( Player ) s , st ) ) {
2014-07-01 00:45:50 +00:00
s . sendMessage ( Methods . getFireColor ( ) + st ) ;
}
2014-06-12 23:21:20 +00:00
}
return true ;
}
2014-06-13 02:17:59 +00:00
if ( Arrays . asList ( chialiases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
2014-06-12 23:21:20 +00:00
if ( AbilityModuleManager . chiabilities . isEmpty ( ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getChiColor ( ) + " There are no chiblocking abilities available. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
for ( String st : AbilityModuleManager . chiabilities ) {
2014-07-01 00:48:07 +00:00
if ( Methods . hasPermission ( ( Player ) s , st ) ) {
2014-07-01 00:45:50 +00:00
s . sendMessage ( Methods . getChiColor ( ) + st ) ;
}
2014-06-12 23:21:20 +00:00
}
return true ;
}
}
if ( args . length = = 1 ) {
//bending display
if ( ! ( s instanceof Player ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " This command is only usable by players. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
BendingPlayer bPlayer = Methods . getBendingPlayer ( s . getName ( ) ) ;
HashMap < Integer , String > abilities = bPlayer . abilities ;
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( abilities . isEmpty ( ) ) {
s . sendMessage ( " You don't have any bound abilities. " ) ;
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-13 04:30:43 +00:00
for ( int i = 1 ; i < = 9 ; i + + ) {
String ability = abilities . get ( i ) ;
if ( ability ! = null ) s . sendMessage ( i + " - " + Methods . getAbilityColor ( ability ) + ability ) ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
return true ;
}
}
if ( Arrays . asList ( togglealiases ) . contains ( args [ 0 ] . toLowerCase ( ) ) ) {
if ( args . length ! = 1 ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: /bending toggle " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( ! s . hasPermission ( " bending.command.toggle " ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( ! ( s instanceof Player ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " This command is only usable by players. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
BendingPlayer bPlayer = Methods . getBendingPlayer ( s . getName ( ) ) ;
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( bPlayer . isToggled ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " Your bending has been toggled off. You will not be able to use most abilities until you toggle it back. " ) ;
2014-06-12 23:21:20 +00:00
bPlayer . isToggled = false ;
return true ;
} else {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GREEN + " You have turned your Bending back on. " ) ;
2014-06-12 23:21:20 +00:00
bPlayer . isToggled = true ;
return true ;
}
}
2014-07-01 00:42:32 +00:00
if ( Arrays . asList ( whoaliases ) . contains ( args [ 0 ] . toLowerCase ( ) ) ) {
2014-06-12 23:21:20 +00:00
if ( args . length > 2 ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: /bending who <Player> " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( ! s . hasPermission ( " bending.command.who " ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( args . length = = 2 ) {
Player p = Bukkit . getPlayer ( args [ 1 ] ) ;
if ( p = = null ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " That player is not online. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
String un = p . getName ( ) ;
s . sendMessage ( un + " - " ) ;
if ( Methods . isBender ( un , Element . Air ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getAirColor ( ) + " - Airbender " ) ;
2014-06-12 23:21:20 +00:00
}
if ( Methods . isBender ( un , Element . Water ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getWaterColor ( ) + " - Waterbender " ) ;
2014-06-12 23:21:20 +00:00
}
if ( Methods . isBender ( un , Element . Earth ) ) {
2014-07-10 14:38:26 +00:00
if ( Methods . canMetalbend ( p ) ) {
s . sendMessage ( Methods . getEarthColor ( ) + " - Earthbender " + Methods . getMetalbendingColor ( ) + " (Can Metalbend) " ) ;
2014-07-11 17:57:11 +00:00
} else {
s . sendMessage ( Methods . getEarthColor ( ) + " - Earthbender " ) ;
2014-07-10 14:38:26 +00:00
}
2014-06-12 23:21:20 +00:00
}
if ( Methods . isBender ( un , Element . Fire ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getFireColor ( ) + " - Firebender " ) ;
2014-06-12 23:21:20 +00:00
}
if ( Methods . isBender ( un , Element . Chi ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getChiColor ( ) + " - ChiBlocker " ) ;
2014-06-12 23:21:20 +00:00
}
return true ;
}
if ( args . length = = 1 ) {
List < String > players = new ArrayList < String > ( ) ;
for ( Player player : Bukkit . getOnlinePlayers ( ) ) {
String un = player . getName ( ) ;
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
BendingPlayer bp = Methods . getBendingPlayer ( un ) ;
if ( bp . elements . size ( ) > 1 ) {
2014-06-28 23:31:26 +00:00
players . add ( Methods . getAvatarColor ( ) + un ) ;
2014-06-12 23:21:20 +00:00
continue ;
}
if ( bp . elements . size ( ) = = 0 ) {
players . add ( un ) ;
continue ;
}
if ( Methods . isBender ( un , Element . Air ) ) {
2014-06-28 23:31:26 +00:00
players . add ( Methods . getAirColor ( ) + un ) ;
2014-06-12 23:21:20 +00:00
continue ;
}
if ( Methods . isBender ( un , Element . Water ) ) {
2014-06-28 23:31:26 +00:00
players . add ( Methods . getWaterColor ( ) + un ) ;
2014-06-12 23:21:20 +00:00
continue ;
}
if ( Methods . isBender ( un , Element . Earth ) ) {
2014-06-28 23:31:26 +00:00
players . add ( Methods . getEarthColor ( ) + un ) ;
2014-06-12 23:21:20 +00:00
continue ;
}
if ( Methods . isBender ( un , Element . Chi ) ) {
2014-06-28 23:31:26 +00:00
players . add ( Methods . getChiColor ( ) + un ) ;
2014-06-12 23:21:20 +00:00
continue ;
}
if ( Methods . isBender ( un , Element . Fire ) ) {
2014-06-28 23:31:26 +00:00
players . add ( Methods . getFireColor ( ) + un ) ;
2014-06-12 23:21:20 +00:00
continue ;
}
}
for ( String st : players ) {
s . sendMessage ( st ) ;
}
return true ;
}
}
if ( Arrays . asList ( versionaliases ) . contains ( args [ 0 ] . toLowerCase ( ) ) ) {
if ( args . length ! = 1 ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: /bending version " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( ! s . hasPermission ( " bending.command.version " ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GREEN + " This server is running " + ChatColor . RED + " ProjectKorra v " + plugin . getDescription ( ) . getVersion ( ) ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( Arrays . asList ( removealiases ) . contains ( args [ 0 ] . toLowerCase ( ) ) ) {
//bending remove [Player]
if ( args . length ! = 2 ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: /bending remove [Player] " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( ! s . hasPermission ( " bending.admin.remove " ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
Player player = Bukkit . getPlayer ( args [ 1 ] ) ;
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( player = = null ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " That player is not online. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
BendingPlayer bPlayer = Methods . getBendingPlayer ( player . getName ( ) ) ;
2014-06-29 01:56:10 +00:00
Methods . removeUnusableAbilities ( player . getName ( ) ) ;
2014-06-12 23:21:20 +00:00
bPlayer . elements . clear ( ) ;
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GREEN + " You have removed the bending of " + ChatColor . DARK_AQUA + player . getName ( ) ) ;
player . sendMessage ( ChatColor . GREEN + " Your bending has been removed by " + ChatColor . DARK_AQUA + s . getName ( ) ) ;
2014-06-12 23:21:20 +00:00
return true ;
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
}
if ( Arrays . asList ( permaremovealiases ) . contains ( args [ 0 ] . toLowerCase ( ) ) ) {
//bending permaremove [Player]
if ( args . length ! = 2 ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: " + ChatColor . DARK_AQUA + " /bending permaremove [Player] " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( ! s . hasPermission ( " bending.admin.permaremove " ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
Player player = Bukkit . getPlayer ( args [ 1 ] ) ;
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( player = = null ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " That player is not online. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
BendingPlayer bPlayer = Methods . getBendingPlayer ( player . getName ( ) ) ;
bPlayer . elements . clear ( ) ;
2014-06-29 01:56:10 +00:00
Methods . removeUnusableAbilities ( player . getName ( ) ) ;
2014-06-12 23:21:20 +00:00
bPlayer . permaRemoved = true ;
2014-06-13 04:30:43 +00:00
player . sendMessage ( ChatColor . RED + " Your bending has been permanently removed. " ) ;
s . sendMessage ( ChatColor . RED + " You have permanently removed the bending of: " + ChatColor . DARK_AQUA + player . getName ( ) ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:42:32 +00:00
if ( Arrays . asList ( addaliases ) . contains ( args [ 0 ] . toLowerCase ( ) ) ) {
2014-06-12 23:21:20 +00:00
//bending add [Player] [Element]
if ( args . length > 3 ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: " + ChatColor . DARK_AQUA + " /bending add [Player] [Element] " ) ;
s . sendMessage ( ChatColor . GOLD + " Applicable Elements: " + ChatColor . DARK_AQUA + " Air, Water, Earth, Fire, Chi " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( args . length = = 3 ) {
if ( ! s . hasPermission ( " bending.command.add.others " ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
Player player = Bukkit . getPlayer ( args [ 1 ] ) ;
if ( player = = null ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " That player is not online. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
BendingPlayer bPlayer = Methods . getBendingPlayer ( player . getName ( ) ) ;
2014-06-29 00:16:01 +00:00
if ( Arrays . asList ( airaliases ) . contains ( args [ 2 ] . toLowerCase ( ) ) ) {
2014-06-12 23:21:20 +00:00
bPlayer . addElement ( Element . Air ) ;
2014-06-28 23:31:26 +00:00
player . sendMessage ( Methods . getAirColor ( ) + " You are also an airbender. " ) ;
s . sendMessage ( ChatColor . DARK_AQUA + player . getName ( ) + Methods . getAirColor ( ) + " is also an airbender. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-29 00:16:01 +00:00
if ( Arrays . asList ( wateraliases ) . contains ( args [ 2 ] . toLowerCase ( ) ) ) {
2014-06-12 23:21:20 +00:00
bPlayer . addElement ( Element . Water ) ;
2014-06-28 23:31:26 +00:00
player . sendMessage ( Methods . getWaterColor ( ) + " You are also a waterbender. " ) ;
s . sendMessage ( ChatColor . DARK_AQUA + player . getName ( ) + Methods . getWaterColor ( ) + " is also a waterbender. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-29 00:16:01 +00:00
if ( Arrays . asList ( earthaliases ) . contains ( args [ 2 ] . toLowerCase ( ) ) ) {
2014-06-12 23:21:20 +00:00
bPlayer . addElement ( Element . Earth ) ;
2014-06-28 23:31:26 +00:00
player . sendMessage ( Methods . getEarthColor ( ) + " You are also an Earthbender. " ) ;
s . sendMessage ( ChatColor . DARK_AQUA + player . getName ( ) + Methods . getEarthColor ( ) + " is also an Earthbender. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-29 00:16:01 +00:00
if ( Arrays . asList ( firealiases ) . contains ( args [ 2 ] . toLowerCase ( ) ) ) {
2014-06-12 23:21:20 +00:00
bPlayer . addElement ( Element . Fire ) ;
2014-06-28 23:31:26 +00:00
player . sendMessage ( Methods . getFireColor ( ) + " You are also a Firebender. " ) ;
s . sendMessage ( ChatColor . DARK_AQUA + player . getName ( ) + Methods . getFireColor ( ) + " is also a Firebender " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-06-29 00:16:01 +00:00
if ( Arrays . asList ( chialiases ) . contains ( args [ 2 ] . toLowerCase ( ) ) ) {
2014-06-12 23:21:20 +00:00
bPlayer . addElement ( Element . Chi ) ;
2014-06-28 23:31:26 +00:00
player . sendMessage ( Methods . getChiColor ( ) + " You are also a ChiBlocker. " ) ;
s . sendMessage ( ChatColor . DARK_AQUA + player . getName ( ) + Methods . getChiColor ( ) + " is also a ChiBlocker " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You must specify an element. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( args . length = = 2 ) {
// Target = Self
if ( ! s . hasPermission ( " bending.command.add " ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( ! ( s instanceof Player ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " This command is only usable by Players. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
BendingPlayer bPlayer = Methods . getBendingPlayer ( s . getName ( ) ) ;
if ( Arrays . asList ( airaliases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
bPlayer . addElement ( Element . Air ) ;
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getAirColor ( ) + " You are also an airbender. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( Arrays . asList ( wateraliases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
bPlayer . addElement ( Element . Water ) ;
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getWaterColor ( ) + " You are also a waterbender. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( Arrays . asList ( earthaliases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
bPlayer . addElement ( Element . Earth ) ;
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getEarthColor ( ) + " You are also an Earthbender. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( Arrays . asList ( firealiases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
bPlayer . addElement ( Element . Fire ) ;
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getFireColor ( ) + " You are also a Firebender. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( Arrays . asList ( chialiases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
bPlayer . addElement ( Element . Chi ) ;
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getChiColor ( ) + " You are also a ChiBlocker. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You must specify an element. " ) ;
2014-06-12 23:21:20 +00:00
}
}
if ( Arrays . asList ( choosealiases ) . contains ( args [ 0 ] . toLowerCase ( ) ) ) {
// /bending choose [Player] [Element]
if ( args . length > 3 ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: " + ChatColor . DARK_AQUA + " /bending choose [Player] [Element] " ) ;
s . sendMessage ( ChatColor . GOLD + " Applicable Elements: " + ChatColor . DARK_AQUA + " Air, Water, Earth, Fire, and Chi " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( args . length = = 2 ) {
if ( ! s . hasPermission ( " bending.command.choose " ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( ! ( s instanceof Player ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " This command is only usable by players. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
BendingPlayer bPlayer = Methods . getBendingPlayer ( s . getName ( ) ) ;
if ( bPlayer . isPermaRemoved ( ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " Your bending was permanently removed. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( ! bPlayer . getElements ( ) . isEmpty ( ) ) {
if ( ! s . hasPermission ( " bending.command.rechoose " ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
}
if ( Arrays . asList ( airaliases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
bPlayer . setElement ( Element . Air ) ;
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getAirColor ( ) + " You are now an Airbender. " ) ;
2014-06-29 01:56:10 +00:00
Methods . removeUnusableAbilities ( s . getName ( ) ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( Arrays . asList ( wateraliases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
bPlayer . setElement ( Element . Water ) ;
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getWaterColor ( ) + " You are now a waterbender. " ) ;
2014-06-29 01:56:10 +00:00
Methods . removeUnusableAbilities ( s . getName ( ) ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( Arrays . asList ( earthaliases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
bPlayer . setElement ( Element . Earth ) ;
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getEarthColor ( ) + " You are now an Earthbender. " ) ;
2014-06-29 01:56:10 +00:00
Methods . removeUnusableAbilities ( s . getName ( ) ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( Arrays . asList ( firealiases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
bPlayer . setElement ( Element . Fire ) ;
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getFireColor ( ) + " You are now a Firebender. " ) ;
2014-06-29 01:56:10 +00:00
Methods . removeUnusableAbilities ( s . getName ( ) ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( Arrays . asList ( chialiases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
bPlayer . setElement ( Element . Chi ) ;
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getChiColor ( ) + " You are now a ChiBlocker. " ) ;
2014-06-29 01:56:10 +00:00
Methods . removeUnusableAbilities ( s . getName ( ) ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: " + ChatColor . DARK_AQUA + " /bending choose [Element] " ) ;
2014-07-05 01:27:05 +00:00
s . sendMessage ( ChatColor . GOLD + " Applicable Elements: " + ChatColor . DARK_AQUA + " Air, Water, Earth, Fire, Chi " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( args . length = = 3 ) {
if ( ! s . hasPermission ( " bending.admin.choose " ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
Player target = Bukkit . getPlayer ( args [ 1 ] ) ;
if ( target = = null ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " That player is not online. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
BendingPlayer bTarget = Methods . getBendingPlayer ( target . getName ( ) ) ;
if ( bTarget . isPermaRemoved ( ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " That player's bending was permanently removed. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
Element e = null ;
if ( Arrays . asList ( airaliases ) . contains ( args [ 2 ] ) ) e = Element . Air ;
if ( Arrays . asList ( wateraliases ) . contains ( args [ 2 ] ) ) e = Element . Water ;
if ( Arrays . asList ( earthaliases ) . contains ( args [ 2 ] ) ) e = Element . Earth ;
if ( Arrays . asList ( firealiases ) . contains ( args [ 2 ] ) ) e = Element . Fire ;
if ( Arrays . asList ( chialiases ) . contains ( args [ 2 ] ) ) e = Element . Chi ;
if ( e = = null ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You must specify an element. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
} else {
bTarget . setElement ( e ) ;
2014-06-29 01:56:10 +00:00
Methods . removeUnusableAbilities ( target . getName ( ) ) ;
2014-06-13 04:30:43 +00:00
target . sendMessage ( ChatColor . RED + " Your bending has been changed to " + ChatColor . DARK_AQUA + e . toString ( ) + ChatColor . RED + " by " + ChatColor . DARK_AQUA + s . getName ( ) ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
}
}
if ( Arrays . asList ( helpaliases ) . contains ( args [ 0 ] . toLowerCase ( ) ) ) {
if ( args . length ! = 2 ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: /bending help Command/Ability " ) ;
2014-07-12 11:55:55 +00:00
s . sendMessage ( ChatColor . YELLOW + " /bending add <Player> [Element] " ) ;
s . sendMessage ( ChatColor . YELLOW + " /bending bind [Ability] <Slot> " ) ;
s . sendMessage ( ChatColor . YELLOW + " /bending clear <slot> " ) ;
s . sendMessage ( ChatColor . YELLOW + " /bending choose <Player> [Element] " ) ;
s . sendMessage ( ChatColor . YELLOW + " /bending display <Element> " ) ;
s . sendMessage ( ChatColor . YELLOW + " /bending import " ) ;
s . sendMessage ( ChatColor . YELLOW + " /bending permaremove <Player> " ) ;
s . sendMessage ( ChatColor . YELLOW + " /bending remove [Player] " ) ;
s . sendMessage ( ChatColor . YELLOW + " /bending toggle " ) ;
s . sendMessage ( ChatColor . YELLOW + " /bending version " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( ! s . hasPermission ( " bending.command.help " ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . RED + " You don't have permission to do that. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-12 11:55:55 +00:00
if ( Arrays . asList ( importaliases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
s . sendMessage ( ChatColor . GOLD + " Proper Usage: " + ChatColor . DARK_AQUA + " /bending import " ) ;
s . sendMessage ( ChatColor . YELLOW + " This command will import your old bendingPlayers.yml from the Bending plugin. "
+ " It will generate a convert.yml file to convert the data to be used with this plugin. "
+ " You can delete the file once the complete message is displayed "
+ " This command should only be used ONCE. " ) ;
}
2014-06-12 23:21:20 +00:00
if ( Arrays . asList ( displayaliases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: " + ChatColor . DARK_AQUA + " /bending display <Element> " ) ;
s . sendMessage ( ChatColor . YELLOW + " This command will show you all of the elements you have bound if you do not specify an element. "
2014-06-12 23:21:20 +00:00
+ " If you do specify an element (Air, Water, Earth, Fire, or Chi), it will show you all of the available "
+ " abilities of that element installed on the server. " ) ;
}
if ( Arrays . asList ( choosealiases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: " + ChatColor . DARK_AQUA + " /bending choose <Player> [Element] " ) ;
s . sendMessage ( ChatColor . GOLD + " Applicable Elements: " + ChatColor . DARK_AQUA + " Air, Water, Earth, Fire, Chi " ) ;
s . sendMessage ( ChatColor . YELLOW + " This command will allow the user to choose a player either for himself or <Player> if specified. "
2014-06-12 23:21:20 +00:00
+ " This command can only be used once per player unless they have permission to rechoose their element. " ) ;
return true ;
}
if ( args [ 1 ] . equalsIgnoreCase ( " add " ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: " + ChatColor . DARK_AQUA + " /bending add <Player> [Element] " ) ;
s . sendMessage ( ChatColor . GOLD + " Applicable Elements: " + ChatColor . DARK_AQUA + " Air, Water, Earth, Fire, Chi " ) ;
s . sendMessage ( ChatColor . YELLOW + " This command will allow the user to add an element to the targeted <Player>, or themselves if the target "
2014-06-12 23:21:20 +00:00
+ " is not specified. This command is typically reserved for server administrators. " ) ;
return true ;
}
if ( Arrays . asList ( permaremovealiases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: " + ChatColor . DARK_AQUA + " /bending permaremove <Player> " ) ;
s . sendMessage ( ChatColor . YELLOW + " This command will permanently remove the Bending of the targeted <Player>. Once removed, a player "
2014-06-12 23:21:20 +00:00
+ " may only receive Bending again if this command is run on them again. This command is typically reserved for "
+ " administrators. " ) ;
return true ;
}
if ( Arrays . asList ( versionaliases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: " + ChatColor . DARK_AQUA + " /bending version " ) ;
s . sendMessage ( ChatColor . YELLOW + " This command will print out the version of ProjectKorra this server is running. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( Arrays . asList ( removealiases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: " + ChatColor . DARK_AQUA + " /bending remove [Player] " ) ;
s . sendMessage ( ChatColor . YELLOW + " This command will remove the element of the targeted [Player]. The player will be able to re-pick "
2014-06-12 23:21:20 +00:00
+ " their element after this command is run on them, assuming their Bending was not permaremoved. " ) ;
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( Arrays . asList ( togglealiases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: " + ChatColor . DARK_AQUA + " /bending toggle " ) ;
s . sendMessage ( ChatColor . YELLOW + " This command will toggle a player's own Bending on or off. If toggled off, all abilities should stop "
2014-06-12 23:21:20 +00:00
+ " working until it is toggled back on. Logging off will automatically toggle your Bending back on. " ) ;
return true ;
}
if ( args [ 1 ] . equalsIgnoreCase ( " who " ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: " + ChatColor . DARK_AQUA + " /bending who <Player> " ) ;
s . sendMessage ( ChatColor . YELLOW + " This command will tell you what element all players that are online are (If you don't specify a player) "
2014-06-12 23:21:20 +00:00
+ " or give you information about the player that you specify. " ) ;
return true ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( Arrays . asList ( clearaliases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: " + ChatColor . DARK_AQUA + " /bending clear <slot> " ) ;
s . sendMessage ( ChatColor . YELLOW + " This command will clear the bound ability from the slot you specify (if you specify one. "
2014-06-12 23:21:20 +00:00
+ " If you choose not to specify a slot, all of your abilities will be cleared. " ) ;
}
if ( Arrays . asList ( reloadaliases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: " + ChatColor . DARK_AQUA + " /bending reload " ) ;
s . sendMessage ( ChatColor . YELLOW + " This command will reload the Bending config file. " ) ;
2014-06-12 23:21:20 +00:00
return true ;
}
if ( Arrays . asList ( bindaliases ) . contains ( args [ 1 ] . toLowerCase ( ) ) ) {
2014-06-13 04:30:43 +00:00
s . sendMessage ( ChatColor . GOLD + " Proper Usage: " + ChatColor . DARK_AQUA + " /bending bind [Ability] <Slot> " ) ;
s . sendMessage ( ChatColor . YELLOW + " This command will bind an ability to the slot you specify (if you specify one), or the slot currently "
2014-06-12 23:21:20 +00:00
+ " selected in your hotbar (If you do not specify a Slot #). " ) ;
}
2014-07-01 00:45:50 +00:00
2014-06-12 23:21:20 +00:00
if ( Methods . abilityExists ( args [ 1 ] ) ) {
String ability = Methods . getAbility ( args [ 1 ] ) ;
if ( Methods . isAirAbility ( ability ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getAirColor ( ) + ability + " - " ) ;
s . sendMessage ( Methods . getAirColor ( ) + AbilityModuleManager . descriptions . get ( ability ) ) ;
2014-06-12 23:21:20 +00:00
}
2014-06-24 22:01:55 +00:00
else if ( Methods . isWaterAbility ( ability ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getWaterColor ( ) + ability + " - " ) ;
s . sendMessage ( Methods . getWaterColor ( ) + AbilityModuleManager . descriptions . get ( ability ) ) ;
2014-06-12 23:21:20 +00:00
}
2014-06-24 22:01:55 +00:00
else if ( Methods . isEarthAbility ( ability ) ) {
2014-07-10 14:38:26 +00:00
if ( Methods . isMetalbendingAbility ( ability ) ) {
s . sendMessage ( Methods . getMetalbendingColor ( ) + ability + " - " ) ;
s . sendMessage ( Methods . getMetalbendingColor ( ) + AbilityModuleManager . descriptions . get ( ability ) ) ;
} else {
s . sendMessage ( Methods . getEarthColor ( ) + ability + " - " ) ;
s . sendMessage ( Methods . getEarthColor ( ) + AbilityModuleManager . descriptions . get ( ability ) ) ;
}
2014-06-12 23:21:20 +00:00
}
2014-06-24 22:01:55 +00:00
else if ( Methods . isFireAbility ( ability ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getFireColor ( ) + ability + " - " ) ;
s . sendMessage ( Methods . getFireColor ( ) + AbilityModuleManager . descriptions . get ( ability ) ) ;
2014-06-12 23:21:20 +00:00
}
2014-06-24 22:01:55 +00:00
else if ( Methods . isChiAbility ( ability ) ) {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getChiColor ( ) + ability + " - " ) ;
s . sendMessage ( Methods . getChiColor ( ) + AbilityModuleManager . descriptions . get ( ability ) ) ;
2014-06-12 23:21:20 +00:00
}
2014-06-24 22:01:55 +00:00
else {
2014-06-28 23:31:26 +00:00
s . sendMessage ( Methods . getAvatarColor ( ) + ability + " - " ) ;
s . sendMessage ( Methods . getAvatarColor ( ) + AbilityModuleManager . descriptions . get ( ability ) ) ;
2014-06-24 22:01:55 +00:00
}
2014-06-12 23:21:20 +00:00
}
}
return true ;
}
} ; projectkorra . setExecutor ( exe ) ;
}
}