mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 11:40:40 +00:00
Rewrite commands to use command executor objects
- New executor class for each command, extends new abstract PKCommand - Rewrote Commands to use the new objects - Update references to old Commands class
This commit is contained in:
parent
75f1d0f437
commit
07e61a19b8
38 changed files with 2091 additions and 2174 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,61 +1,11 @@
|
||||||
package com.projectkorra.projectkorra;
|
package com.projectkorra.projectkorra;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||||
import java.io.BufferedWriter;
|
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
||||||
import java.io.DataInputStream;
|
import me.ryanhamshire.GriefPrevention.Claim;
|
||||||
import java.io.DataOutputStream;
|
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||||
import java.io.File;
|
import net.sacredlabyrinth.Phaed.PreciousStones.FieldFlag;
|
||||||
import java.io.FileInputStream;
|
import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.FallingBlock;
|
|
||||||
import org.bukkit.entity.FallingSand;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.TNTPrimed;
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.plugin.PluginManager;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import com.griefcraft.lwc.LWC;
|
import com.griefcraft.lwc.LWC;
|
||||||
import com.griefcraft.lwc.LWCPlugin;
|
import com.griefcraft.lwc.LWCPlugin;
|
||||||
|
@ -92,6 +42,7 @@ import com.projectkorra.projectkorra.airbending.AirSpout;
|
||||||
import com.projectkorra.projectkorra.airbending.AirSwipe;
|
import com.projectkorra.projectkorra.airbending.AirSwipe;
|
||||||
import com.projectkorra.projectkorra.chiblocking.ChiMethods;
|
import com.projectkorra.projectkorra.chiblocking.ChiMethods;
|
||||||
import com.projectkorra.projectkorra.chiblocking.Paralyze;
|
import com.projectkorra.projectkorra.chiblocking.Paralyze;
|
||||||
|
import com.projectkorra.projectkorra.command.Commands;
|
||||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||||
import com.projectkorra.projectkorra.earthbending.EarthBlast;
|
import com.projectkorra.projectkorra.earthbending.EarthBlast;
|
||||||
import com.projectkorra.projectkorra.earthbending.EarthMethods;
|
import com.projectkorra.projectkorra.earthbending.EarthMethods;
|
||||||
|
@ -118,12 +69,61 @@ import com.projectkorra.projectkorra.waterbending.WaterSpout;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
import org.bukkit.Bukkit;
|
||||||
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
import org.bukkit.ChatColor;
|
||||||
import me.ryanhamshire.GriefPrevention.Claim;
|
import org.bukkit.GameMode;
|
||||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
import org.bukkit.Location;
|
||||||
import net.sacredlabyrinth.Phaed.PreciousStones.FieldFlag;
|
import org.bukkit.Material;
|
||||||
import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.FallingBlock;
|
||||||
|
import org.bukkit.entity.FallingSand;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.TNTPrimed;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class GeneralMethods {
|
public class GeneralMethods {
|
||||||
|
@ -381,8 +381,11 @@ public class GeneralMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean comboExists(String string) {
|
public static boolean comboExists(String string) {
|
||||||
/*Previous method only returned non-stock combos. Reason we use descriptions is because that
|
/*
|
||||||
* contains all valid combos. Not technical ones like IceBulletLeftClick, etc.*/
|
* Previous method only returned non-stock combos. Reason we use
|
||||||
|
* descriptions is because that contains all valid combos. Not technical
|
||||||
|
* ones like IceBulletLeftClick, etc.
|
||||||
|
*/
|
||||||
for (String s : ComboManager.descriptions.keySet()) {
|
for (String s : ComboManager.descriptions.keySet()) {
|
||||||
if (s.equalsIgnoreCase(string))
|
if (s.equalsIgnoreCase(string))
|
||||||
return true;
|
return true;
|
||||||
|
@ -518,13 +521,9 @@ public class GeneralMethods {
|
||||||
File readFile = new File(".", "bendingPlayers.yml");
|
File readFile = new File(".", "bendingPlayers.yml");
|
||||||
File writeFile = new File(".", "converted.yml");
|
File writeFile = new File(".", "converted.yml");
|
||||||
if (readFile.exists()) {
|
if (readFile.exists()) {
|
||||||
try (
|
try (DataInputStream input = new DataInputStream(new FileInputStream(readFile)); BufferedReader reader = new BufferedReader(new InputStreamReader(input));
|
||||||
DataInputStream input = new DataInputStream(new FileInputStream(readFile));
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(input));
|
|
||||||
|
|
||||||
DataOutputStream output = new DataOutputStream(new FileOutputStream(writeFile));
|
DataOutputStream output = new DataOutputStream(new FileOutputStream(writeFile)); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output))) {
|
||||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output))
|
|
||||||
) {
|
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
|
@ -728,25 +727,35 @@ public class GeneralMethods {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the subelement of the ability if applicable.
|
* Returns the subelement of the ability if applicable.
|
||||||
*
|
*
|
||||||
* @param ability
|
* @param ability
|
||||||
* @return SubElement
|
* @return SubElement
|
||||||
* */
|
*/
|
||||||
public static SubElement getAbilitySubElement(String ability) {
|
public static SubElement getAbilitySubElement(String ability) {
|
||||||
if (AbilityModuleManager.bloodabilities.contains(ability)) return SubElement.Bloodbending;
|
if (AbilityModuleManager.bloodabilities.contains(ability))
|
||||||
if (AbilityModuleManager.iceabilities.contains(ability)) return SubElement.Icebending;
|
return SubElement.Bloodbending;
|
||||||
if (AbilityModuleManager.plantabilities.contains(ability)) return SubElement.Plantbending;
|
if (AbilityModuleManager.iceabilities.contains(ability))
|
||||||
if (AbilityModuleManager.healingabilities.contains(ability)) return SubElement.Healing;
|
return SubElement.Icebending;
|
||||||
if (AbilityModuleManager.sandabilities.contains(ability)) return SubElement.Sandbending;
|
if (AbilityModuleManager.plantabilities.contains(ability))
|
||||||
if (AbilityModuleManager.metalabilities.contains(ability)) return SubElement.Metalbending;
|
return SubElement.Plantbending;
|
||||||
if (AbilityModuleManager.lavaabilities.contains(ability)) return SubElement.Lavabending;
|
if (AbilityModuleManager.healingabilities.contains(ability))
|
||||||
if (AbilityModuleManager.lightningabilities.contains(ability)) return SubElement.Lightning;
|
return SubElement.Healing;
|
||||||
if (AbilityModuleManager.combustionabilities.contains(ability)) return SubElement.Combustion;
|
if (AbilityModuleManager.sandabilities.contains(ability))
|
||||||
if (AbilityModuleManager.spiritualprojectionabilities.contains(ability)) return SubElement.SpiritualProjection;
|
return SubElement.Sandbending;
|
||||||
if (AbilityModuleManager.flightabilities.contains(ability)) return SubElement.Flight;
|
if (AbilityModuleManager.metalabilities.contains(ability))
|
||||||
|
return SubElement.Metalbending;
|
||||||
|
if (AbilityModuleManager.lavaabilities.contains(ability))
|
||||||
|
return SubElement.Lavabending;
|
||||||
|
if (AbilityModuleManager.lightningabilities.contains(ability))
|
||||||
|
return SubElement.Lightning;
|
||||||
|
if (AbilityModuleManager.combustionabilities.contains(ability))
|
||||||
|
return SubElement.Combustion;
|
||||||
|
if (AbilityModuleManager.spiritualprojectionabilities.contains(ability))
|
||||||
|
return SubElement.SpiritualProjection;
|
||||||
|
if (AbilityModuleManager.flightabilities.contains(ability))
|
||||||
|
return SubElement.Flight;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -938,9 +947,12 @@ public class GeneralMethods {
|
||||||
return circleblocks;
|
return circleblocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Returns the ChatColor that should be associated with the combo name.
|
/**
|
||||||
|
* Returns the ChatColor that should be associated with the combo name.
|
||||||
|
*
|
||||||
* @param combo
|
* @param combo
|
||||||
* @return The ChatColor to be used*/
|
* @return The ChatColor to be used
|
||||||
|
*/
|
||||||
public static ChatColor getComboColor(String combo) {
|
public static ChatColor getComboColor(String combo) {
|
||||||
for (ComboAbility comboability : ComboManager.comboAbilityList) {
|
for (ComboAbility comboability : ComboManager.comboAbilityList) {
|
||||||
if (!comboability.getName().equalsIgnoreCase(combo)) {
|
if (!comboability.getName().equalsIgnoreCase(combo)) {
|
||||||
|
@ -963,31 +975,34 @@ public class GeneralMethods {
|
||||||
else if (module.getSubElement() == SubElement.Flight || module.getSubElement() == SubElement.SpiritualProjection)
|
else if (module.getSubElement() == SubElement.Flight || module.getSubElement() == SubElement.SpiritualProjection)
|
||||||
return AirMethods.getAirSubColor();
|
return AirMethods.getAirSubColor();
|
||||||
}
|
}
|
||||||
if (module.getElement().equalsIgnoreCase(Element.Water.toString())) return WaterMethods.getWaterColor();
|
if (module.getElement().equalsIgnoreCase(Element.Water.toString()))
|
||||||
else if (module.getElement().equalsIgnoreCase(Element.Earth.toString())) return EarthMethods.getEarthColor();
|
|
||||||
else if (module.getElement().equalsIgnoreCase(Element.Fire.toString())) return FireMethods.getFireColor();
|
|
||||||
else if (module.getElement().equalsIgnoreCase(Element.Air.toString())) return AirMethods.getAirColor();
|
|
||||||
else if (module.getElement().equalsIgnoreCase(Element.Chi.toString())) return ChiMethods.getChiColor();
|
|
||||||
else return getAvatarColor();
|
|
||||||
}
|
|
||||||
else if (combo.equalsIgnoreCase("IceBullet") || combo.equalsIgnoreCase("IceWave")) {
|
|
||||||
return WaterMethods.getWaterSubColor();
|
|
||||||
}
|
|
||||||
else if (comboability.getComboType().equals(WaterCombo.class)){
|
|
||||||
return WaterMethods.getWaterColor();
|
return WaterMethods.getWaterColor();
|
||||||
}
|
else if (module.getElement().equalsIgnoreCase(Element.Earth.toString()))
|
||||||
else if (comboability.getComboType().equals(FireCombo.class)){
|
return EarthMethods.getEarthColor();
|
||||||
|
else if (module.getElement().equalsIgnoreCase(Element.Fire.toString()))
|
||||||
return FireMethods.getFireColor();
|
return FireMethods.getFireColor();
|
||||||
}
|
else if (module.getElement().equalsIgnoreCase(Element.Air.toString()))
|
||||||
else if (comboability.getComboType().equals(AirCombo.class)){
|
|
||||||
return AirMethods.getAirColor();
|
return AirMethods.getAirColor();
|
||||||
}
|
else if (module.getElement().equalsIgnoreCase(Element.Chi.toString()))
|
||||||
else {
|
return ChiMethods.getChiColor();
|
||||||
|
else
|
||||||
|
return getAvatarColor();
|
||||||
|
} else if (combo.equalsIgnoreCase("IceBullet") || combo.equalsIgnoreCase("IceWave")) {
|
||||||
|
return WaterMethods.getWaterSubColor();
|
||||||
|
} else if (comboability.getComboType().equals(WaterCombo.class)) {
|
||||||
|
return WaterMethods.getWaterColor();
|
||||||
|
} else if (comboability.getComboType().equals(FireCombo.class)) {
|
||||||
|
return FireMethods.getFireColor();
|
||||||
|
} else if (comboability.getComboType().equals(AirCombo.class)) {
|
||||||
|
return AirMethods.getAirColor();
|
||||||
|
} else {
|
||||||
Element element = null;
|
Element element = null;
|
||||||
for (AbilityInformation abilityinfo : comboability.getAbilities()) {
|
for (AbilityInformation abilityinfo : comboability.getAbilities()) {
|
||||||
Element currElement = getAbilityElement(abilityinfo.getAbilityName());
|
Element currElement = getAbilityElement(abilityinfo.getAbilityName());
|
||||||
if (currElement == null) return getAvatarColor();
|
if (currElement == null)
|
||||||
else if (element == null) element = currElement;
|
return getAvatarColor();
|
||||||
|
else if (element == null)
|
||||||
|
element = currElement;
|
||||||
if (getAbilitySubElement(abilityinfo.getAbilityName()) != null) {
|
if (getAbilitySubElement(abilityinfo.getAbilityName()) != null) {
|
||||||
SubElement sub = getAbilitySubElement(abilityinfo.getAbilityName());
|
SubElement sub = getAbilitySubElement(abilityinfo.getAbilityName());
|
||||||
if (sub == SubElement.Bloodbending || sub == SubElement.Icebending || sub == SubElement.Plantbending || sub == SubElement.Healing)
|
if (sub == SubElement.Bloodbending || sub == SubElement.Icebending || sub == SubElement.Plantbending || sub == SubElement.Healing)
|
||||||
|
@ -1000,11 +1015,16 @@ public class GeneralMethods {
|
||||||
return AirMethods.getAirSubColor();
|
return AirMethods.getAirSubColor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (element == Element.Air) return AirMethods.getAirColor();
|
if (element == Element.Air)
|
||||||
if (element == Element.Earth) return EarthMethods.getEarthColor();
|
return AirMethods.getAirColor();
|
||||||
if (element == Element.Fire) return FireMethods.getFireColor();
|
if (element == Element.Earth)
|
||||||
if (element == Element.Water) return WaterMethods.getWaterColor();
|
return EarthMethods.getEarthColor();
|
||||||
if (element == Element.Chi) return ChiMethods.getChiColor();
|
if (element == Element.Fire)
|
||||||
|
return FireMethods.getFireColor();
|
||||||
|
if (element == Element.Water)
|
||||||
|
return WaterMethods.getWaterColor();
|
||||||
|
if (element == Element.Chi)
|
||||||
|
return ChiMethods.getChiColor();
|
||||||
return getAvatarColor();
|
return getAvatarColor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1585,37 +1605,11 @@ public class GeneralMethods {
|
||||||
|
|
||||||
/** Checks if an entity is Undead **/
|
/** Checks if an entity is Undead **/
|
||||||
public static boolean isUndead(Entity entity) {
|
public static boolean isUndead(Entity entity) {
|
||||||
return entity != null
|
return entity != null && (entity.getType() == EntityType.ZOMBIE || entity.getType() == EntityType.BLAZE || entity.getType() == EntityType.GIANT || entity.getType() == EntityType.IRON_GOLEM || entity.getType() == EntityType.MAGMA_CUBE || entity.getType() == EntityType.PIG_ZOMBIE || entity.getType() == EntityType.SKELETON || entity.getType() == EntityType.SLIME || entity.getType() == EntityType.SNOWMAN || entity.getType() == EntityType.ZOMBIE);
|
||||||
&& (entity.getType() == EntityType.ZOMBIE
|
|
||||||
|| entity.getType() == EntityType.BLAZE
|
|
||||||
|| entity.getType() == EntityType.GIANT
|
|
||||||
|| entity.getType() == EntityType.IRON_GOLEM
|
|
||||||
|| entity.getType() == EntityType.MAGMA_CUBE
|
|
||||||
|| entity.getType() == EntityType.PIG_ZOMBIE
|
|
||||||
|| entity.getType() == EntityType.SKELETON
|
|
||||||
|| entity.getType() == EntityType.SLIME
|
|
||||||
|| entity.getType() == EntityType.SNOWMAN
|
|
||||||
|| entity.getType() == EntityType.ZOMBIE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isWeapon(Material mat) {
|
public static boolean isWeapon(Material mat) {
|
||||||
return mat != null
|
return mat != null && (mat == Material.WOOD_AXE || mat == Material.WOOD_PICKAXE || mat == Material.WOOD_SPADE || mat == Material.WOOD_SWORD || mat == Material.STONE_AXE || mat == Material.STONE_PICKAXE || mat == Material.STONE_SPADE || mat == Material.STONE_SWORD || mat == Material.IRON_AXE || mat == Material.IRON_PICKAXE || mat == Material.IRON_SWORD || mat == Material.IRON_SPADE || mat == Material.DIAMOND_AXE || mat == Material.DIAMOND_PICKAXE || mat == Material.DIAMOND_SWORD || mat == Material.DIAMOND_SPADE);
|
||||||
&& (mat == Material.WOOD_AXE
|
|
||||||
|| mat == Material.WOOD_PICKAXE
|
|
||||||
|| mat == Material.WOOD_SPADE
|
|
||||||
|| mat == Material.WOOD_SWORD
|
|
||||||
|| mat == Material.STONE_AXE
|
|
||||||
|| mat == Material.STONE_PICKAXE
|
|
||||||
|| mat == Material.STONE_SPADE
|
|
||||||
|| mat == Material.STONE_SWORD
|
|
||||||
|| mat == Material.IRON_AXE
|
|
||||||
|| mat == Material.IRON_PICKAXE
|
|
||||||
|| mat == Material.IRON_SWORD
|
|
||||||
|| mat == Material.IRON_SPADE
|
|
||||||
|| mat == Material.DIAMOND_AXE
|
|
||||||
|| mat == Material.DIAMOND_PICKAXE
|
|
||||||
|| mat == Material.DIAMOND_SWORD
|
|
||||||
|| mat == Material.DIAMOND_SPADE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void playAvatarSound(Location loc) {
|
public static void playAvatarSound(Location loc) {
|
||||||
|
@ -2004,4 +1998,20 @@ public class GeneralMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ChatColor getElementColor(Element element) {
|
||||||
|
switch (element) {
|
||||||
|
case Air:
|
||||||
|
return AirMethods.getAirColor();
|
||||||
|
case Fire:
|
||||||
|
return FireMethods.getFireColor();
|
||||||
|
case Earth:
|
||||||
|
return EarthMethods.getEarthColor();
|
||||||
|
case Water:
|
||||||
|
return WaterMethods.getWaterColor();
|
||||||
|
case Chi:
|
||||||
|
return ChiMethods.getChiColor();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.projectkorra.projectkorra;
|
package com.projectkorra.projectkorra;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||||
|
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||||
import com.projectkorra.projectkorra.ability.combo.ComboManager;
|
import com.projectkorra.projectkorra.ability.combo.ComboManager;
|
||||||
import com.projectkorra.projectkorra.ability.multiability.MultiAbilityManager;
|
import com.projectkorra.projectkorra.ability.multiability.MultiAbilityManager;
|
||||||
import com.projectkorra.projectkorra.airbending.AirBlast;
|
import com.projectkorra.projectkorra.airbending.AirBlast;
|
||||||
|
@ -26,6 +27,7 @@ import com.projectkorra.projectkorra.chiblocking.RapidPunch;
|
||||||
import com.projectkorra.projectkorra.chiblocking.Smokescreen;
|
import com.projectkorra.projectkorra.chiblocking.Smokescreen;
|
||||||
import com.projectkorra.projectkorra.chiblocking.SwiftKick;
|
import com.projectkorra.projectkorra.chiblocking.SwiftKick;
|
||||||
import com.projectkorra.projectkorra.chiblocking.WarriorStance;
|
import com.projectkorra.projectkorra.chiblocking.WarriorStance;
|
||||||
|
import com.projectkorra.projectkorra.command.Commands;
|
||||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||||
import com.projectkorra.projectkorra.earthbending.Catapult;
|
import com.projectkorra.projectkorra.earthbending.Catapult;
|
||||||
import com.projectkorra.projectkorra.earthbending.Collapse;
|
import com.projectkorra.projectkorra.earthbending.Collapse;
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.projectkorra.projectkorra.ability.multiability.MultiAbilityManager;
|
||||||
import com.projectkorra.projectkorra.ability.multiability.MultiAbilityModuleManager;
|
import com.projectkorra.projectkorra.ability.multiability.MultiAbilityModuleManager;
|
||||||
import com.projectkorra.projectkorra.airbending.AirbendingManager;
|
import com.projectkorra.projectkorra.airbending.AirbendingManager;
|
||||||
import com.projectkorra.projectkorra.chiblocking.ChiblockingManager;
|
import com.projectkorra.projectkorra.chiblocking.ChiblockingManager;
|
||||||
|
import com.projectkorra.projectkorra.command.Commands;
|
||||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||||
import com.projectkorra.projectkorra.earthbending.EarthbendingManager;
|
import com.projectkorra.projectkorra.earthbending.EarthbendingManager;
|
||||||
import com.projectkorra.projectkorra.firebending.FirebendingManager;
|
import com.projectkorra.projectkorra.firebending.FirebendingManager;
|
||||||
|
@ -33,7 +34,7 @@ public class ProjectKorra extends JavaPlugin {
|
||||||
public static PKLogHandler handler;
|
public static PKLogHandler handler;
|
||||||
public static long time_step = 1;
|
public static long time_step = 1;
|
||||||
public Updater updater;
|
public Updater updater;
|
||||||
|
public AbilityModuleManager abManager;
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
plugin = this;
|
plugin = this;
|
||||||
|
@ -53,7 +54,7 @@ public class ProjectKorra extends JavaPlugin {
|
||||||
new GeneralMethods(this);
|
new GeneralMethods(this);
|
||||||
updater = new Updater(this, "http://projectkorra.com/forum/forums/dev-builds.16/index.rss");
|
updater = new Updater(this, "http://projectkorra.com/forum/forums/dev-builds.16/index.rss");
|
||||||
new Commands(this);
|
new Commands(this);
|
||||||
new AbilityModuleManager(this);
|
abManager = new AbilityModuleManager(this);
|
||||||
new MultiAbilityModuleManager();
|
new MultiAbilityModuleManager();
|
||||||
new MultiAbilityManager();
|
new MultiAbilityManager();
|
||||||
new ComboModuleManager();
|
new ComboModuleManager();
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
package com.projectkorra.projectkorra.ability;
|
package com.projectkorra.projectkorra.ability;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.Element;
|
||||||
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
|
import com.projectkorra.projectkorra.command.Commands;
|
||||||
|
import com.projectkorra.projectkorra.util.AbilityLoader;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
|
||||||
import com.projectkorra.projectkorra.ProjectKorra;
|
|
||||||
import com.projectkorra.projectkorra.util.AbilityLoader;
|
|
||||||
|
|
||||||
public class AbilityModuleManager {
|
public class AbilityModuleManager {
|
||||||
|
|
||||||
|
@ -355,7 +356,9 @@ public class AbilityModuleManager {
|
||||||
}
|
}
|
||||||
catch (AbstractMethodError /* pre 1.6 BETA 8 */ | NoSuchMethodError /*
|
catch (AbstractMethodError /* pre 1.6 BETA 8 */ | NoSuchMethodError /*
|
||||||
* pre
|
* pre
|
||||||
* 1.7
|
* 1
|
||||||
|
* .
|
||||||
|
* 7
|
||||||
* BETA
|
* BETA
|
||||||
* 2
|
* 2
|
||||||
*/ e) { //If triggered means ability was made before commented versions
|
*/ e) { //If triggered means ability was made before commented versions
|
||||||
|
@ -374,16 +377,52 @@ public class AbilityModuleManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (Field field : this.getClass().getDeclaredFields()) {
|
for (Field field : this.getClass().getDeclaredFields()) {
|
||||||
if (List.class.isAssignableFrom(field.getType())) {
|
if (List.class.isAssignableFrom(field.getType())) {
|
||||||
try {
|
try {
|
||||||
Collections.sort((List) field.get(this));
|
Collections.sort((List) field.get(this));
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getAbilities(String element) {
|
||||||
|
element = element.toLowerCase();
|
||||||
|
if (Arrays.asList(Commands.wateraliases).contains(element))
|
||||||
|
return waterbendingabilities;
|
||||||
|
else if (Arrays.asList(Commands.icealiases).contains(element))
|
||||||
|
return iceabilities;
|
||||||
|
else if (Arrays.asList(Commands.plantaliases).contains(element))
|
||||||
|
return plantabilities;
|
||||||
|
else if (Arrays.asList(Commands.healingaliases).contains(element))
|
||||||
|
return healingabilities;
|
||||||
|
else if (Arrays.asList(Commands.bloodaliases).contains(element))
|
||||||
|
return bloodabilities;
|
||||||
|
else if (Arrays.asList(Commands.airaliases).contains(element))
|
||||||
|
return airbendingabilities;
|
||||||
|
else if (Arrays.asList(Commands.flightaliases).contains(element))
|
||||||
|
return flightabilities;
|
||||||
|
else if (Arrays.asList(Commands.spiritualprojectionaliases).contains(element))
|
||||||
|
return spiritualprojectionabilities;
|
||||||
|
else if (Arrays.asList(Commands.earthaliases).contains(element))
|
||||||
|
return earthbendingabilities;
|
||||||
|
else if (Arrays.asList(Commands.lavabendingaliases).contains(element))
|
||||||
|
return lavaabilities;
|
||||||
|
else if (Arrays.asList(Commands.metalbendingaliases).contains(element))
|
||||||
|
return metalabilities;
|
||||||
|
else if (Arrays.asList(Commands.sandbendingaliases).contains(element))
|
||||||
|
return sandabilities;
|
||||||
|
else if (Arrays.asList(Commands.firealiases).contains(element))
|
||||||
|
return firebendingabilities;
|
||||||
|
else if (Arrays.asList(Commands.combustionaliases).contains(element))
|
||||||
|
return combustionabilities;
|
||||||
|
else if (Arrays.asList(Commands.lightningaliases).contains(element))
|
||||||
|
return lightningabilities;
|
||||||
|
else if (Arrays.asList(Commands.chialiases).contains(element))
|
||||||
|
return chiabilities;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import com.projectkorra.projectkorra.ProjectKorra;
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
import com.projectkorra.projectkorra.airbending.AirCombo;
|
import com.projectkorra.projectkorra.airbending.AirCombo;
|
||||||
import com.projectkorra.projectkorra.chiblocking.ChiCombo;
|
import com.projectkorra.projectkorra.chiblocking.ChiCombo;
|
||||||
|
import com.projectkorra.projectkorra.earthbending.EarthCombo;
|
||||||
import com.projectkorra.projectkorra.firebending.FireCombo;
|
import com.projectkorra.projectkorra.firebending.FireCombo;
|
||||||
import com.projectkorra.projectkorra.util.ClickType;
|
import com.projectkorra.projectkorra.util.ClickType;
|
||||||
import com.projectkorra.projectkorra.waterbending.WaterCombo;
|
import com.projectkorra.projectkorra.waterbending.WaterCombo;
|
||||||
|
@ -157,9 +158,16 @@ public class ComboManager {
|
||||||
immobilize.add(new AbilityInformation("QuickStrike", ClickType.LEFT_CLICK));
|
immobilize.add(new AbilityInformation("QuickStrike", ClickType.LEFT_CLICK));
|
||||||
immobilize.add(new AbilityInformation("QuickStrike", ClickType.LEFT_CLICK));
|
immobilize.add(new AbilityInformation("QuickStrike", ClickType.LEFT_CLICK));
|
||||||
comboAbilityList.add(new ComboAbility("Immobilize", immobilize, ChiCombo.class));
|
comboAbilityList.add(new ComboAbility("Immobilize", immobilize, ChiCombo.class));
|
||||||
descriptions.put("Immobilize", "Does stuff to people.");
|
descriptions.put("Immobilize", "Immobilizes the opponent for several seconds.");
|
||||||
instructions.put("Immobilize", "QuickStrike (Left Click) > SwiftKick (Left Click) > QuickStrike (Left Click) > QuickStrike (Left Click)");
|
instructions.put("Immobilize", "QuickStrike (Left Click) > SwiftKick (Left Click) > QuickStrike (Left Click) > QuickStrike (Left Click)");
|
||||||
|
|
||||||
|
ArrayList<AbilityInformation> earthBurrow = new ArrayList<AbilityInformation>();
|
||||||
|
earthBurrow.add(new AbilityInformation("EarthTunnel", ClickType.LEFT_CLICK));
|
||||||
|
earthBurrow.add(new AbilityInformation("Collapse", ClickType.SHIFT_DOWN));
|
||||||
|
comboAbilityList.add(new ComboAbility("EarthBurrow", earthBurrow, EarthCombo.class));
|
||||||
|
descriptions.put("EarthBurrow", "Sink into the ground to avoid attacks and confuse foes.");
|
||||||
|
instructions.put("EarthBurrow", "EarthTunnel (Left Click) > Collapse (Shift)");
|
||||||
|
|
||||||
startCleanupTask();
|
startCleanupTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,6 +193,8 @@ public class ComboManager {
|
||||||
new WaterCombo(player, comboAbil.getName());
|
new WaterCombo(player, comboAbil.getName());
|
||||||
else if (comboAbil.getComboType().equals(ChiCombo.class))
|
else if (comboAbil.getComboType().equals(ChiCombo.class))
|
||||||
new ChiCombo(player, comboAbil.getName());
|
new ChiCombo(player, comboAbil.getName());
|
||||||
|
else if (comboAbil.getComboType().equals(EarthCombo.class))
|
||||||
|
new EarthCombo(player, comboAbil.getName());
|
||||||
else {
|
else {
|
||||||
for (ComboAbility ca : comboAbilityList) {
|
for (ComboAbility ca : comboAbilityList) {
|
||||||
if (comboAbil.getName().equals(ca.getName())) {
|
if (comboAbil.getName().equals(ca.getName())) {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package com.projectkorra.projectkorra.airbending;
|
package com.projectkorra.projectkorra.airbending;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.BendingPlayer;
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
import com.projectkorra.projectkorra.Commands;
|
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import com.projectkorra.projectkorra.ProjectKorra;
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||||
|
import com.projectkorra.projectkorra.command.Commands;
|
||||||
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
|
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
|
||||||
import com.projectkorra.projectkorra.util.Flight;
|
import com.projectkorra.projectkorra.util.Flight;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package com.projectkorra.projectkorra.airbending;
|
package com.projectkorra.projectkorra.airbending;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.BendingPlayer;
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
import com.projectkorra.projectkorra.Commands;
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
import com.projectkorra.projectkorra.Element;
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import com.projectkorra.projectkorra.ProjectKorra;
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||||
|
import com.projectkorra.projectkorra.command.Commands;
|
||||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||||
import com.projectkorra.projectkorra.earthbending.EarthMethods;
|
import com.projectkorra.projectkorra.earthbending.EarthMethods;
|
||||||
import com.projectkorra.projectkorra.firebending.FireCombo;
|
import com.projectkorra.projectkorra.firebending.FireCombo;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package com.projectkorra.projectkorra.airbending;
|
package com.projectkorra.projectkorra.airbending;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Commands;
|
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||||
|
import com.projectkorra.projectkorra.command.Commands;
|
||||||
import com.projectkorra.projectkorra.earthbending.EarthBlast;
|
import com.projectkorra.projectkorra.earthbending.EarthBlast;
|
||||||
import com.projectkorra.projectkorra.firebending.Combustion;
|
import com.projectkorra.projectkorra.firebending.Combustion;
|
||||||
import com.projectkorra.projectkorra.firebending.FireBlast;
|
import com.projectkorra.projectkorra.firebending.FireBlast;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package com.projectkorra.projectkorra.airbending;
|
package com.projectkorra.projectkorra.airbending;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.BendingPlayer;
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
import com.projectkorra.projectkorra.Commands;
|
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import com.projectkorra.projectkorra.ProjectKorra;
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||||
|
import com.projectkorra.projectkorra.command.Commands;
|
||||||
import com.projectkorra.projectkorra.earthbending.EarthMethods;
|
import com.projectkorra.projectkorra.earthbending.EarthMethods;
|
||||||
import com.projectkorra.projectkorra.util.Flight;
|
import com.projectkorra.projectkorra.util.Flight;
|
||||||
import com.projectkorra.projectkorra.waterbending.WaterSpout;
|
import com.projectkorra.projectkorra.waterbending.WaterSpout;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package com.projectkorra.projectkorra.airbending;
|
package com.projectkorra.projectkorra.airbending;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.BendingPlayer;
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
import com.projectkorra.projectkorra.Commands;
|
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import com.projectkorra.projectkorra.ProjectKorra;
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||||
|
import com.projectkorra.projectkorra.command.Commands;
|
||||||
import com.projectkorra.projectkorra.earthbending.EarthBlast;
|
import com.projectkorra.projectkorra.earthbending.EarthBlast;
|
||||||
import com.projectkorra.projectkorra.firebending.Combustion;
|
import com.projectkorra.projectkorra.firebending.Combustion;
|
||||||
import com.projectkorra.projectkorra.firebending.FireBlast;
|
import com.projectkorra.projectkorra.firebending.FireBlast;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.projectkorra.projectkorra.airbending;
|
package com.projectkorra.projectkorra.airbending;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Commands;
|
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||||
|
import com.projectkorra.projectkorra.command.Commands;
|
||||||
import com.projectkorra.projectkorra.util.Flight;
|
import com.projectkorra.projectkorra.util.Flight;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package com.projectkorra.projectkorra.chiblocking;
|
package com.projectkorra.projectkorra.chiblocking;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Commands;
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
import com.projectkorra.projectkorra.Element;
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import com.projectkorra.projectkorra.ProjectKorra;
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||||
import com.projectkorra.projectkorra.airbending.Suffocate;
|
import com.projectkorra.projectkorra.airbending.Suffocate;
|
||||||
|
import com.projectkorra.projectkorra.command.Commands;
|
||||||
|
|
||||||
import org.bukkit.entity.Creature;
|
import org.bukkit.entity.Creature;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.projectkorra.projectkorra.chiblocking;
|
package com.projectkorra.projectkorra.chiblocking;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.BendingPlayer;
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
import com.projectkorra.projectkorra.Commands;
|
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import com.projectkorra.projectkorra.ProjectKorra;
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
|
import com.projectkorra.projectkorra.command.Commands;
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
87
src/com/projectkorra/projectkorra/command/AddCommand.java
Normal file
87
src/com/projectkorra/projectkorra/command/AddCommand.java
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
|
import com.projectkorra.projectkorra.Element;
|
||||||
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
|
||||||
|
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executor for /bending add. Extends {@link PKCommand}.
|
||||||
|
*/
|
||||||
|
public class AddCommand extends PKCommand {
|
||||||
|
|
||||||
|
public AddCommand() {
|
||||||
|
super("add", "/bending add <Player> [Element]", "This command will allow the user to add an element to the targeted <Player>, or themselves if the target is not specified. This command is typically reserved for server administrators.", new String[] { "add", "a" });
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
if (!correctLength(sender, args.size(), 1, 2)) {
|
||||||
|
return;
|
||||||
|
} else if (args.size() == 1) { //bending add element
|
||||||
|
if (!hasPermission(sender) || !isPlayer(sender)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
add(sender, (Player) sender, args.get(0));
|
||||||
|
} else if (args.size() == 2) { //bending add element combo
|
||||||
|
if (!hasPermission(sender, "others")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Player player = Bukkit.getPlayer(args.get(0));
|
||||||
|
if (player == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "That player is not online.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
add(sender, player, args.get(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the ability to bend an element to a player.
|
||||||
|
*
|
||||||
|
* @param sender The CommandSender who issued the add command
|
||||||
|
* @param target The player to add the element to
|
||||||
|
* @param element The element to add
|
||||||
|
*/
|
||||||
|
private void add(CommandSender sender, Player target, String element) {
|
||||||
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(target.getName());
|
||||||
|
if (bPlayer == null) {
|
||||||
|
GeneralMethods.createBendingPlayer(target.getUniqueId(), target.getName());
|
||||||
|
bPlayer = GeneralMethods.getBendingPlayer(target);
|
||||||
|
}
|
||||||
|
if (bPlayer.isPermaRemoved()) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "That player's bending was permanently removed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Arrays.asList(Commands.elementaliases).contains(element)) {
|
||||||
|
element = getElement(element);
|
||||||
|
Element type = Element.getType(element);
|
||||||
|
bPlayer.addElement(type);
|
||||||
|
ChatColor color = GeneralMethods.getElementColor(type);
|
||||||
|
if (element.charAt(0) == 'w' || element.charAt(0) == 'f' || element.charAt(0) == 'c') {
|
||||||
|
target.sendMessage(color + "You are also a " + Character.toString(element.charAt(0)).toUpperCase() + element.substring(1) + "bender.");
|
||||||
|
} else if (element.charAt(0) == 'e' || element.charAt(0) == 'a') {
|
||||||
|
target.sendMessage(color + "You are also an " + Character.toString(element.charAt(0)).toUpperCase() + element.substring(1) + "bender.");
|
||||||
|
}
|
||||||
|
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
|
||||||
|
if (element.charAt(0) == 'w' || element.charAt(0) == 'f' || element.charAt(0) == 'c') {
|
||||||
|
sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + color + " is also a " + Character.toString(element.charAt(0)).toUpperCase() + element.substring(1) + "bender.");
|
||||||
|
} else if (element.charAt(0) == 'e' || element.charAt(0) == 'a') {
|
||||||
|
sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + color + " is also an " + Character.toString(element.charAt(0)).toUpperCase() + element.substring(1) + "bender.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, type, Result.ADD));
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You must specify a valid element.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
55
src/com/projectkorra/projectkorra/command/BindCommand.java
Normal file
55
src/com/projectkorra/projectkorra/command/BindCommand.java
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executor for /bending bind. Extends {@link PKCommand}.
|
||||||
|
*/
|
||||||
|
public class BindCommand extends PKCommand {
|
||||||
|
|
||||||
|
public BindCommand() {
|
||||||
|
super("bind", "/bending bind [Ability] <#>", "This command will bind an ability to the slot you specify (if you specify one), or the slot currently selected in your hotbar (If you do not specify a Slot #).", new String[]{ "bind", "b" });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
if (!hasPermission(sender) || !correctLength(sender, args.size(), 1, 2) || !isPlayer(sender)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GeneralMethods.abilityExists(args.get(0))) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "That ability doesn't exist.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String ability = GeneralMethods.getAbility(args.get(0));
|
||||||
|
// bending bind [Ability]
|
||||||
|
if (args.size() == 1) {
|
||||||
|
bind(sender, ability, ((Player) sender).getInventory().getHeldItemSlot()+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// bending bind [ability] [#]
|
||||||
|
if (args.size() == 2) {
|
||||||
|
bind(sender, ability, Integer.parseInt(args.get(1)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bind(CommandSender sender, String ability, int slot) {
|
||||||
|
if (slot < 1 || slot > 9) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Slot must be an integer between 1 and 9.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GeneralMethods.canBind(((Player) sender).getName(), ability)) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You don't have permission to bend this element.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GeneralMethods.bindAbility((Player) sender, GeneralMethods.getAbility(ability), slot);
|
||||||
|
}
|
||||||
|
}
|
36
src/com/projectkorra/projectkorra/command/CheckCommand.java
Normal file
36
src/com/projectkorra/projectkorra/command/CheckCommand.java
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executor for /bending check. Extends {@link PKCommand}.
|
||||||
|
*/
|
||||||
|
public class CheckCommand extends PKCommand {
|
||||||
|
|
||||||
|
public CheckCommand() {
|
||||||
|
super("check", "/bending check", "Checks if ProjectKorra is up to date.", new String[] { "check", "chk" });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
if (!hasPermission(sender)) {
|
||||||
|
return;
|
||||||
|
} else if (args.size() > 0) {
|
||||||
|
help(sender, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ProjectKorra.plugin.updater.updateAvailable()) {
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "There is a new version of " + ChatColor.GOLD + "ProjectKorra" + ChatColor.GREEN + " available!");
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "Current version: " + ChatColor.RED + ProjectKorra.plugin.updater.getCurrentVersion());
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "Latest version: " + ChatColor.GOLD + ProjectKorra.plugin.updater.getCurrentVersion());
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "You have the latest version of " + ChatColor.GOLD + "ProjectKorra");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
110
src/com/projectkorra/projectkorra/command/ChooseCommand.java
Normal file
110
src/com/projectkorra/projectkorra/command/ChooseCommand.java
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
|
import com.projectkorra.projectkorra.Element;
|
||||||
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
|
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
|
||||||
|
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executor for /bending choose. Extends {@link PKCommand}.
|
||||||
|
*/
|
||||||
|
public class ChooseCommand extends PKCommand {
|
||||||
|
|
||||||
|
public ChooseCommand() {
|
||||||
|
super("choose", "/bending choose [Element] <player>", "This command will allow the user to choose a player either for himself or <Player> if specified. This command can only be used once per player unless they have permission to rechoose their element.", new String[] { "choose", "ch" });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
if (!correctLength(sender, args.size(), 1, 2)) {
|
||||||
|
return;
|
||||||
|
} else if (args.size() == 1) {
|
||||||
|
if (!hasPermission(sender) || !isPlayer(sender)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(sender.getName());
|
||||||
|
if (bPlayer == null) {
|
||||||
|
GeneralMethods.createBendingPlayer(((Player) sender).getUniqueId(), sender.getName());
|
||||||
|
bPlayer = GeneralMethods.getBendingPlayer(sender.getName());
|
||||||
|
}
|
||||||
|
if (bPlayer.isPermaRemoved()) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Your bending was permanently removed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bPlayer.getElements().isEmpty() && !sender.hasPermission("bending.command.rechoose")) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You don't have permission to do that.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String element = args.get(0);
|
||||||
|
if (Arrays.asList(Commands.elementaliases).contains(element)) {
|
||||||
|
if (!hasPermission(sender, element)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
add(sender, (Player) sender, element);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(ChatColor.RED + "That is not a valid element.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (args.size() == 2) {
|
||||||
|
if (!sender.hasPermission("bending.admin.choose")) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You don't have permission to do that.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Player target = ProjectKorra.plugin.getServer().getPlayer(args.get(1));
|
||||||
|
if (!target.isOnline()) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "That player is not online.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String element = args.get(0);
|
||||||
|
if (Arrays.asList(Commands.elementaliases).contains(element)) {
|
||||||
|
add(sender, target, element);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(ChatColor.RED + "That is not a valid element.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the ability to bend the given element to the specified Player.
|
||||||
|
*
|
||||||
|
* @param sender The CommandSender who issued the command
|
||||||
|
* @param target The Player to add the element to
|
||||||
|
* @param element The element to add to the Player
|
||||||
|
*/
|
||||||
|
private void add(CommandSender sender, Player target, String element) {
|
||||||
|
element = getElement(element);
|
||||||
|
Element e = Element.getType(element);
|
||||||
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(target);
|
||||||
|
bPlayer.setElement(e);
|
||||||
|
ChatColor color = GeneralMethods.getElementColor(e);
|
||||||
|
if (element.charAt(0) == 'w' || element.charAt(0) == 'f' || element.charAt(0) == 'c') {
|
||||||
|
target.sendMessage(color + "You are now a " + Character.toString(element.charAt(0)).toUpperCase() + element.substring(1) + "bender.");
|
||||||
|
} else if (element.charAt(0) == 'e' || element.charAt(0) == 'a') {
|
||||||
|
target.sendMessage(color + "You are now an " + Character.toString(element.charAt(0)).toUpperCase() + element.substring(1) + "bender.");
|
||||||
|
}
|
||||||
|
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
|
||||||
|
if (element.charAt(0) == 'w' || element.charAt(0) == 'f' || element.charAt(0) == 'c') {
|
||||||
|
sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + color + " is now a " + Character.toString(element.charAt(0)).toUpperCase() + element.substring(1) + "bender.");
|
||||||
|
} else if (element.charAt(0) == 'e' || element.charAt(0) == 'a') {
|
||||||
|
sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + color + " is now an " + Character.toString(element.charAt(0)).toUpperCase() + element.substring(1) + "bender.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GeneralMethods.removeUnusableAbilities(sender.getName());
|
||||||
|
GeneralMethods.saveElements(bPlayer);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, e, Result.CHOOSE));
|
||||||
|
}
|
||||||
|
}
|
61
src/com/projectkorra/projectkorra/command/ClearCommand.java
Normal file
61
src/com/projectkorra/projectkorra/command/ClearCommand.java
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
import com.projectkorra.projectkorra.ability.multiability.MultiAbilityManager;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executor for /bending clear. Extends {@link PKCommand}.
|
||||||
|
*/
|
||||||
|
public class ClearCommand extends PKCommand {
|
||||||
|
|
||||||
|
public ClearCommand() {
|
||||||
|
super("clear", "/bending clear", "This command will clear the bound ability from the slot you specify (if you specify one). If you choose not to specify a slot, all of your abilities will be cleared.", new String[] { "clear", "cl", "c" });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
if (!hasPermission(sender) || !correctLength(sender, args.size(), 0, 0) || !isPlayer(sender)) {
|
||||||
|
return;
|
||||||
|
} else if (MultiAbilityManager.hasMultiAbilityBound((Player) sender)) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You can't edit your binds right now!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(sender.getName());
|
||||||
|
if (bPlayer == null) {
|
||||||
|
GeneralMethods.createBendingPlayer(((Player) sender).getUniqueId(), sender.getName());
|
||||||
|
bPlayer = GeneralMethods.getBendingPlayer(sender.getName());
|
||||||
|
}
|
||||||
|
if (args.size() == 0) {
|
||||||
|
bPlayer.getAbilities().clear();
|
||||||
|
for (int i = 1; i <= 9; i++) {
|
||||||
|
GeneralMethods.saveAbility(bPlayer, i, null);
|
||||||
|
}
|
||||||
|
sender.sendMessage("Your bound abilities have been cleared.");
|
||||||
|
} else if (args.size() == 1) {
|
||||||
|
try {
|
||||||
|
int slot = Integer.parseInt(args.get(0));
|
||||||
|
if (slot < 1 || slot > 9) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "The slot must be an integer between 1 and 9.");
|
||||||
|
}
|
||||||
|
if (bPlayer.getAbilities().get(slot) != null) {
|
||||||
|
bPlayer.getAbilities().remove(slot);
|
||||||
|
GeneralMethods.saveAbility(bPlayer, slot, null);
|
||||||
|
sender.sendMessage("You have cleared slot #" + slot);
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("That slot was already empty.");
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "The slot must be an integer between 1 and 9.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
127
src/com/projectkorra/projectkorra/command/Commands.java
Normal file
127
src/com/projectkorra/projectkorra/command/Commands.java
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.PluginCommand;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class Commands {
|
||||||
|
|
||||||
|
private ProjectKorra plugin;
|
||||||
|
|
||||||
|
public static Set<String> invincible = new HashSet<String>();
|
||||||
|
public static boolean debugEnabled = false;
|
||||||
|
public static boolean isToggledForAll = false;
|
||||||
|
|
||||||
|
public Commands(ProjectKorra plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
debugEnabled = ProjectKorra.plugin.getConfig().getBoolean("debug");
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Element Aliases
|
||||||
|
*/
|
||||||
|
public static String[] airaliases = { "air", "a", "airbending", "airbender" };
|
||||||
|
public static String[] chialiases = { "chi", "c", "chiblocking", "chiblocker" };
|
||||||
|
public static String[] earthaliases = { "earth", "e", "earthbending", "earthbender" };
|
||||||
|
public static String[] firealiases = { "fire", "f", "firebending", "firebender" };
|
||||||
|
public static String[] wateraliases = { "water", "w", "waterbending", "waterbender" };
|
||||||
|
public static String[] elementaliases = { "air", "a", "airbending", "airbender", "chi", "c", "chiblocking", "chiblocker", "earth", "e", "earthbending", "earthbender", "fire", "f", "firebending", "firebender", "water", "w", "waterbending", "waterbender" };
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Combo Aliases
|
||||||
|
*/
|
||||||
|
public static String[] aircomboaliases = { "aircombo", "ac", "aircombos", "airbendingcombos" };
|
||||||
|
public static String[] chicomboaliases = { "chicombo", "cc", "chicombos", "chiblockingcombos", "chiblockercombos" };
|
||||||
|
public static String[] earthcomboaliases = { "earthcombo", "ec", "earthcombos", "earthbendingcombos" };
|
||||||
|
public static String[] firecomboaliases = { "firecombo", "fc", "firecombos", "firebendingcombos" };
|
||||||
|
public static String[] watercomboaliases = { "watercombo", "wc", "watercombos", "waterbendingcombos" };
|
||||||
|
|
||||||
|
public static String[] comboaliases = { "aircombo", "ac", "aircombos", "airbendingcombos", "chicombo", "cc", "chicombos", "chiblockingcombos", "chiblockercombos", "earthcombo", "ec", "earthcombos", "earthbendingcombos", "firecombo", "fc", "firecombos", "firebendingcombos", "watercombo", "wc", "watercombos", "waterbendingcombos" };
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Subelement Aliases
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static String[] subelementaliases = { "flight", "fl", "spiritualprojection", "sp", "spiritual", "bloodbending", "bb", "healing", "heal", "icebending", "ice", "ib", "plantbending", "plant", "metalbending", "mb", "metal", "lavabending", "lb", "lava", "sandbending", "sb", "sand", "combustionbending", "combustion", "cb", "lightningbending", "lightning" };
|
||||||
|
//Air
|
||||||
|
public static String[] flightaliases = { "flight", "fl" };
|
||||||
|
public static String[] spiritualprojectionaliases = { "spiritualprojection", "sp", "spiritual" };
|
||||||
|
|
||||||
|
//Water
|
||||||
|
public static String[] bloodaliases = { "bloodbending", "bb" };
|
||||||
|
public static String[] healingaliases = { "healing", "heal" };
|
||||||
|
public static String[] icealiases = { "icebending", "ice", "ib" };
|
||||||
|
public static String[] plantaliases = { "plantbending", "plant" };
|
||||||
|
|
||||||
|
//Earth
|
||||||
|
public static String[] metalbendingaliases = { "metalbending", "mb", "metal" };
|
||||||
|
public static String[] lavabendingaliases = { "lavabending", "lb", "lava" };
|
||||||
|
public static String[] sandbendingaliases = { "sandbending", "sb", "sand" };
|
||||||
|
|
||||||
|
//Firebending
|
||||||
|
public static String[] combustionaliases = { "combustionbending", "combustion", "cb" };
|
||||||
|
public static String[] lightningaliases = { "lightningbending", "lightning" };
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
PluginCommand projectkorra = plugin.getCommand("projectkorra");
|
||||||
|
new AddCommand();
|
||||||
|
new BindCommand();
|
||||||
|
new CheckCommand();
|
||||||
|
new ChooseCommand();
|
||||||
|
new ClearCommand();
|
||||||
|
new DebugCommand();
|
||||||
|
new DisplayCommand();
|
||||||
|
new HelpCommand();
|
||||||
|
new ImportCommand();
|
||||||
|
new InvincibleCommand();
|
||||||
|
new PermaremoveCommand();
|
||||||
|
new PresetCommand();
|
||||||
|
new ReloadCommand();
|
||||||
|
new RemoveCommand();
|
||||||
|
new ToggleCommand();
|
||||||
|
new VersionCommand();
|
||||||
|
new WhoCommand();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set of all of the Classes which extend Command
|
||||||
|
*/
|
||||||
|
|
||||||
|
CommandExecutor exe;
|
||||||
|
|
||||||
|
exe = new CommandExecutor() {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
|
||||||
|
for (int i = 0; i < args.length; i++) {
|
||||||
|
args[i] = args[i].toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 0) {
|
||||||
|
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.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> sendingArgs = Arrays.asList(args).subList(1, args.length);
|
||||||
|
for (PKCommand command : PKCommand.instances.values()) {
|
||||||
|
if (Arrays.asList(command.getAliases()).contains(args[0])) {
|
||||||
|
command.execute(s, sendingArgs);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
projectkorra.setExecutor(exe);
|
||||||
|
}
|
||||||
|
}
|
47
src/com/projectkorra/projectkorra/command/DebugCommand.java
Normal file
47
src/com/projectkorra/projectkorra/command/DebugCommand.java
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executor for /bending debug. Extends {@link PKCommand}.
|
||||||
|
*/
|
||||||
|
public class DebugCommand extends PKCommand {
|
||||||
|
|
||||||
|
public DebugCommand() {
|
||||||
|
super("debug", "/bending debug", "Outputs information on the current ProjectKorra installation to /plugins/ProjectKorra/debug.txt", new String[] { "debug", "de" });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
if (!hasPermission(sender)) {
|
||||||
|
return;
|
||||||
|
} else if (args.size() != 0) {
|
||||||
|
help(sender, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GeneralMethods.runDebug();
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Debug File Created as debug.txt in the ProjectKorra plugin folder.");
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Put contents on pastie.org and create a bug report on the ProjectKorra forum if you need to.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the CommandSender has the permission 'bending.admin.debug'. If
|
||||||
|
* not, it tells them they don't have permission.
|
||||||
|
*
|
||||||
|
* @return True if they have permission, false otherwise.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSender sender) {
|
||||||
|
if (sender.hasPermission("bending.admin." + getName())) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You don't have permission to use this command.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
147
src/com/projectkorra/projectkorra/command/DisplayCommand.java
Normal file
147
src/com/projectkorra/projectkorra/command/DisplayCommand.java
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
|
import com.projectkorra.projectkorra.Element;
|
||||||
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
|
import com.projectkorra.projectkorra.ability.combo.ComboManager;
|
||||||
|
import com.projectkorra.projectkorra.airbending.AirMethods;
|
||||||
|
import com.projectkorra.projectkorra.chiblocking.ChiMethods;
|
||||||
|
import com.projectkorra.projectkorra.earthbending.EarthMethods;
|
||||||
|
import com.projectkorra.projectkorra.firebending.FireMethods;
|
||||||
|
import com.projectkorra.projectkorra.waterbending.WaterMethods;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executor for /bending display. Extends {@link PKCommand}.
|
||||||
|
*/
|
||||||
|
public class DisplayCommand extends PKCommand {
|
||||||
|
|
||||||
|
public DisplayCommand() {
|
||||||
|
super("display", "/bending display <Element>", "This command will show you all of the elements you have bound if you do not specify an element. 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.", new String[] { "display", "dis", "d" });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
if (!hasPermission(sender) || !correctLength(sender, args.size(), 0, 1)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//bending display [Element]
|
||||||
|
if (args.size() == 1) {
|
||||||
|
String element = args.get(0);
|
||||||
|
//combos
|
||||||
|
if (Arrays.asList(Commands.comboaliases).contains(element)) {
|
||||||
|
element = getElement(element);
|
||||||
|
Element e = Element.getType(element);
|
||||||
|
ArrayList<String> combos = ComboManager.getCombosForElement(e);
|
||||||
|
if (combos.isEmpty()) {
|
||||||
|
sender.sendMessage(GeneralMethods.getElementColor(e) + "There are no " + element + " combos avaliable.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (String combomove : combos) {
|
||||||
|
if (!sender.hasPermission("bending.ability." + combomove))
|
||||||
|
continue;
|
||||||
|
ChatColor color = GeneralMethods.getComboColor(combomove);
|
||||||
|
sender.sendMessage(color + combomove);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//normal elements
|
||||||
|
else if (Arrays.asList(Commands.elementaliases).contains(element)) {
|
||||||
|
element = getElement(element);
|
||||||
|
displayElement(sender, element);
|
||||||
|
}
|
||||||
|
|
||||||
|
//subelements
|
||||||
|
else if (Arrays.asList(Commands.subelementaliases).contains(element)) {
|
||||||
|
displaySubElement(sender, element);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Not a valid Element." + ChatColor.WHITE + " Elements: " + AirMethods.getAirColor() + "Air" + ChatColor.WHITE + " | " + WaterMethods.getWaterColor() + "Water" + ChatColor.WHITE + " | " + EarthMethods.getEarthColor() + "Earth" + ChatColor.WHITE + " | " + FireMethods.getFireColor() + "Fire" + ChatColor.WHITE + " | " + ChiMethods.getChiColor() + "Chi");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args.size() == 0) {
|
||||||
|
//bending display
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "This command is only usable by players.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
displayBinds(sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the enabled moves for the given element to the CommandSender.
|
||||||
|
*
|
||||||
|
* @param sender The CommandSender to show the moves to
|
||||||
|
* @param element The element to show the moves for
|
||||||
|
*/
|
||||||
|
private void displayElement(CommandSender sender, String element) {
|
||||||
|
List<String> abilities = ProjectKorra.plugin.abManager.getAbilities(element);
|
||||||
|
if (abilities == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You must select a valid element.");
|
||||||
|
return;
|
||||||
|
} else if (abilities.isEmpty()) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "There are no " + element + " abilities enabled on the server.");
|
||||||
|
}
|
||||||
|
for (String ability : abilities) {
|
||||||
|
if (GeneralMethods.isSubAbility(ability))
|
||||||
|
continue;
|
||||||
|
if (!(sender instanceof Player) || GeneralMethods.canView((Player) sender, ability)) {
|
||||||
|
sender.sendMessage(GeneralMethods.getElementColor(Element.getType(element)) + ability);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the enabled moves for the given subelement to the CommandSender.
|
||||||
|
*
|
||||||
|
* @param sender The CommandSender to show the moves to
|
||||||
|
* @param element The subelement to show the moves for
|
||||||
|
*/
|
||||||
|
private void displaySubElement(CommandSender sender, String element) {
|
||||||
|
List<String> abilities = ProjectKorra.plugin.abManager.getAbilities(element);
|
||||||
|
for (String ability : abilities) {
|
||||||
|
if (!(sender instanceof Player) || GeneralMethods.canView((Player) sender, ability)) {
|
||||||
|
sender.sendMessage(GeneralMethods.getSubBendingColor(Element.getType(getElement(getElement(element)))) + ability);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a Player's bound abilities.
|
||||||
|
*
|
||||||
|
* @param sender The CommandSender to output the bound abilities to
|
||||||
|
*/
|
||||||
|
private void displayBinds(CommandSender sender) {
|
||||||
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(sender.getName());
|
||||||
|
if (bPlayer == null) {
|
||||||
|
GeneralMethods.createBendingPlayer(((Player) sender).getUniqueId(), sender.getName());
|
||||||
|
bPlayer = GeneralMethods.getBendingPlayer(sender.getName());
|
||||||
|
}
|
||||||
|
HashMap<Integer, String> abilities = bPlayer.getAbilities();
|
||||||
|
|
||||||
|
if (abilities.isEmpty()) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You don't have any bound abilities.");
|
||||||
|
sender.sendMessage("If you would like to see a list of available abilities, please use the /bending display [Element] command. Use /bending help for more information.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= 9; i++) {
|
||||||
|
String ability = abilities.get(i);
|
||||||
|
if (ability != null && !ability.equalsIgnoreCase("null"))
|
||||||
|
sender.sendMessage(i + " - " + GeneralMethods.getAbilityColor(ability) + ability);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
77
src/com/projectkorra/projectkorra/command/HelpCommand.java
Normal file
77
src/com/projectkorra/projectkorra/command/HelpCommand.java
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
import com.projectkorra.projectkorra.ability.AbilityModuleManager;
|
||||||
|
import com.projectkorra.projectkorra.ability.combo.ComboManager;
|
||||||
|
import com.projectkorra.projectkorra.airbending.AirMethods;
|
||||||
|
import com.projectkorra.projectkorra.chiblocking.ChiMethods;
|
||||||
|
import com.projectkorra.projectkorra.earthbending.EarthMethods;
|
||||||
|
import com.projectkorra.projectkorra.firebending.FireMethods;
|
||||||
|
import com.projectkorra.projectkorra.waterbending.WaterMethods;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executor for /bending help. Extends {@link PKCommand}.
|
||||||
|
*/
|
||||||
|
public class HelpCommand extends PKCommand {
|
||||||
|
public HelpCommand() {
|
||||||
|
super("help", "/bending help", "This command provides information on how to use other commands in ProjectKorra.", new String[] { "help", "h" });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
if (!hasPermission(sender) || !correctLength(sender, args.size(), 0, 1))
|
||||||
|
return;
|
||||||
|
else if (args.size() == 0) {
|
||||||
|
for (PKCommand command : instances.values()) {
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + command.getProperUse());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String arg = args.get(0);
|
||||||
|
|
||||||
|
if (instances.keySet().contains(arg)) {//bending help command
|
||||||
|
instances.get(arg).help(sender, true);
|
||||||
|
} else if (Arrays.asList(Commands.comboaliases).contains(arg)) { //bending help elementcombo
|
||||||
|
sender.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.RED + "/bending display " + arg + ChatColor.GOLD + " or " + ChatColor.RED + "/bending help <comboname>");
|
||||||
|
} else if (GeneralMethods.abilityExists(arg)) { //bending help ability
|
||||||
|
ChatColor color = GeneralMethods.getAbilityColor(arg);
|
||||||
|
sender.sendMessage(color + arg + " - ");
|
||||||
|
sender.sendMessage(AbilityModuleManager.descriptions.get(GeneralMethods.getAbility(arg)));
|
||||||
|
} else if (Arrays.asList(Commands.airaliases).contains(args.get(0))) {
|
||||||
|
sender.sendMessage(AirMethods.getAirColor() + "Air is the element of freedom. Airbenders are natural pacifists and " + "great explorers. There is nothing stopping them from scaling the tallest of mountains and walls easily. They specialize in redirection, " + "from blasting things away with gusts of winds, to forming a shield around them to prevent damage. Easy to get across flat terrains, " + "such as oceans, there is practically no terrain off limits to Airbenders. They lack much raw damage output, but make up for it with " + "with their ridiculous amounts of utility and speed.");
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "Learn More: " + ChatColor.DARK_AQUA + "http://tinyurl.com/qffg9m3");
|
||||||
|
} else if (Arrays.asList(Commands.wateraliases).contains(args.get(0))) {
|
||||||
|
sender.sendMessage(WaterMethods.getWaterColor() + "Water is the element of change. Waterbending focuses on using your " + "opponents own force against them. Using redirection and various dodging tactics, you can be made " + "practically untouchable by an opponent. Waterbending provides agility, along with strong offensive " + "skills while in or near water.");
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "Learn More: " + ChatColor.DARK_AQUA + "http://tinyurl.com/lod3plv");
|
||||||
|
} else if (Arrays.asList(Commands.earthaliases).contains(args.get(0))) {
|
||||||
|
sender.sendMessage(EarthMethods.getEarthColor() + "Earth is the element of substance. Earthbenders share many of the " + "same fundamental techniques as Waterbenders, but their domain is quite different and more readily " + "accessible. Earthbenders dominate the ground and subterranean, having abilities to pull columns " + "of rock straight up from the earth or drill their way through the mountain. They can also launch " + "themselves through the air using pillars of rock, and will not hurt themselves assuming they land " + "on something they can bend. The more skilled Earthbenders can even bend metal.");
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "Learn More: " + ChatColor.DARK_AQUA + "http://tinyurl.com/qaudl42");
|
||||||
|
} else if (Arrays.asList(Commands.firealiases).contains(args.get(0))) {
|
||||||
|
sender.sendMessage(FireMethods.getFireColor() + "Fire is the element of power. Firebenders focus on destruction and " + "incineration. Their abilities are pretty straight forward: set things on fire. They do have a bit " + "of utility however, being able to make themselves un-ignitable, extinguish large areas, cook food " + "in their hands, extinguish large areas, small bursts of flight, and then comes the abilities to shoot " + "fire from your hands.");
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "Firebenders can chain their abilities into combos, type " + FireMethods.getFireColor() + "/b help FireCombo" + ChatColor.YELLOW + " for more information.");
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "Learn More: " + ChatColor.DARK_AQUA + "http://tinyurl.com/k4fkjhb");
|
||||||
|
} else if (Arrays.asList(Commands.chialiases).contains(args.get(0))) {
|
||||||
|
sender.sendMessage(ChiMethods.getChiColor() + "Chiblockers focus on bare handed combat, utilizing their agility and " + "speed to stop any bender right in their path. Although they lack the ability to bend any of the " + "other elements, they are great in combat, and a serious threat to any bender. Chiblocking was " + "first shown to be used by Ty Lee in Avatar: The Last Airbender, then later by members of the " + "Equalists in The Legend of Korra.");
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "Learn More: " + ChatColor.DARK_AQUA + "http://tinyurl.com/mkp9n6y");
|
||||||
|
} else {
|
||||||
|
//combos - handled differently because they're stored in CamelCase in ComboManager
|
||||||
|
for (String combo : ComboManager.descriptions.keySet()) {
|
||||||
|
if (combo.equalsIgnoreCase(arg)) {
|
||||||
|
ChatColor color = GeneralMethods.getComboColor(combo);
|
||||||
|
sender.sendMessage(color + combo + " (Combo) - ");
|
||||||
|
sender.sendMessage(color + ComboManager.descriptions.get(combo));
|
||||||
|
sender.sendMessage(ChatColor.GOLD + "Usage: " + ComboManager.instructions.get(combo));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sender.sendMessage(ChatColor.RED + "That isn't a valid help topic. Use /bending help for more information.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
152
src/com/projectkorra/projectkorra/command/ImportCommand.java
Normal file
152
src/com/projectkorra/projectkorra/command/ImportCommand.java
Normal file
|
@ -0,0 +1,152 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
|
import com.projectkorra.projectkorra.Element;
|
||||||
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
|
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||||
|
import com.projectkorra.projectkorra.storage.DBConnection;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executor for /bending import. Extends {@link PKCommand}.
|
||||||
|
*/
|
||||||
|
public class ImportCommand extends PKCommand {
|
||||||
|
|
||||||
|
boolean debugEnabled = ProjectKorra.plugin.getConfig().getBoolean("debug");
|
||||||
|
BukkitTask importTask;
|
||||||
|
|
||||||
|
public ImportCommand() {
|
||||||
|
super("import", "/bending import", "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.", new String[] { "import", "i" });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
if (!hasPermission(sender) || !correctLength(sender, args.size(), 0, 0)) {
|
||||||
|
return;
|
||||||
|
} else if (!GeneralMethods.isImportEnabled()) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Importing has been disabled in the config");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.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 = ProjectKorra.plugin.getServer().getOfflinePlayer(playername).getUniqueId();
|
||||||
|
ArrayList<Element> element = new ArrayList<Element>();
|
||||||
|
List<Integer> oe = bendingPlayers.getIntegerList(string + ".BendingTypes");
|
||||||
|
HashMap<Integer, String> abilities = new HashMap<Integer, String>();
|
||||||
|
List<Integer> oa = bendingPlayers.getIntegerList(string + ".SlotAbilities");
|
||||||
|
boolean permaremoved = bendingPlayers.getBoolean(string + ".Permaremoved");
|
||||||
|
|
||||||
|
int slot = 1;
|
||||||
|
for (int i : oa) {
|
||||||
|
if (StockAbility.getAbility(i) != null) {
|
||||||
|
abilities.put(slot, StockAbility.getAbility(i).toString());
|
||||||
|
slot++;
|
||||||
|
} else {
|
||||||
|
abilities.put(slot, null);
|
||||||
|
slot++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i : oe) {
|
||||||
|
if (Element.getType(i) != null) {
|
||||||
|
element.add(Element.getType(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BendingPlayer bPlayer = new BendingPlayer(uuid, playername, element, abilities, permaremoved);
|
||||||
|
bPlayers.add(bPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
final int total = bPlayers.size();
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Import of data started. Do NOT stop / reload your server.");
|
||||||
|
if (debugEnabled) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Console will print out all of the players that are imported if debug mode is enabled as they import.");
|
||||||
|
}
|
||||||
|
importTask = Bukkit.getServer().getScheduler().runTaskTimerAsynchronously(ProjectKorra.plugin, new Runnable() {
|
||||||
|
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 + "All data has been queued up, please allow up to 5 minutes for the data to complete, then reboot your server.");
|
||||||
|
Bukkit.getServer().getScheduler().cancelTask(importTask.getTaskId());
|
||||||
|
ProjectKorra.plugin.getConfig().set("Properties.ImportEnabled", false);
|
||||||
|
ProjectKorra.plugin.saveConfig();
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
GeneralMethods.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");
|
||||||
|
|
||||||
|
HashMap<Integer, String> abilities = bPlayer.getAbilities();
|
||||||
|
|
||||||
|
ResultSet rs2 = DBConnection.sql.readQuery("SELECT * FROM pk_players WHERE uuid = '" + bPlayer.getUUIDString() + "'");
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (rs2.next()) { // SQL Data already exists for player.
|
||||||
|
DBConnection.sql.modifyQuery("UPDATE pk_players SET player = '" + bPlayer.getName() + "' WHERE uuid = '" + bPlayer.getUUIDString());
|
||||||
|
DBConnection.sql.modifyQuery("UPDATE pk_players SET element = '" + elements + "' WHERE uuid = '" + bPlayer.getUUIDString());
|
||||||
|
DBConnection.sql.modifyQuery("UPDATE pk_players SET permaremoved = '" + bPlayer.isPermaRemoved() + "' WHERE uuid = '" + bPlayer.getUUIDString());
|
||||||
|
for (int slot = 1; slot < 10; slot++) {
|
||||||
|
DBConnection.sql.modifyQuery("UPDATE pk_players SET slot" + slot + " = '" + abilities.get(slot) + "' WHERE player = '" + bPlayer.getName() + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DBConnection.sql.modifyQuery("INSERT INTO pk_players (uuid, player, element, permaremoved) VALUES ('" + bPlayer.getUUIDString() + "', '" + bPlayer.getName() + "', '" + 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.getName() + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
if (debugEnabled) {
|
||||||
|
System.out.println("[ProjectKorra] Successfully imported " + bPlayer.getName() + ". " + bPlayers.size() + " players left to import.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 40);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executor for /bending invincible. Extends {@link PKCommand}.
|
||||||
|
*/
|
||||||
|
public class InvincibleCommand extends PKCommand {
|
||||||
|
|
||||||
|
public InvincibleCommand() {
|
||||||
|
super("invincible", "/bending invincible", "This command will make you impervious to all Bending damage. Once you use this command, you will stay invincible until you log off or use this command again.", new String[] { "invincible", "inv" });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
if (!hasPermission(sender) || !isPlayer(sender) || !correctLength(sender, args.size(), 0, 0)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Commands.invincible.contains(sender.getName())) {
|
||||||
|
Commands.invincible.add(sender.getName());
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "You are now invincible to all bending damage and effects. Use this command again to disable this.");
|
||||||
|
} else {
|
||||||
|
Commands.invincible.remove(sender.getName());
|
||||||
|
sender.sendMessage(ChatColor.RED + "You are no longer invincible to all bending damage and effects.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
164
src/com/projectkorra/projectkorra/command/PKCommand.java
Normal file
164
src/com/projectkorra/projectkorra/command/PKCommand.java
Normal file
|
@ -0,0 +1,164 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract representation of a command executor. Implements
|
||||||
|
* {@link PKCommandInterface}.
|
||||||
|
*
|
||||||
|
* @author kingbirdy
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class PKCommand implements PKCommandInterface {
|
||||||
|
/**
|
||||||
|
* The full name of the command.
|
||||||
|
*/
|
||||||
|
private final String name;
|
||||||
|
/**
|
||||||
|
* The proper use of the command, in the form '/b {@link PKCommand#name
|
||||||
|
* name} arg1 arg2 ... '
|
||||||
|
*/
|
||||||
|
private final String properUse;
|
||||||
|
/**
|
||||||
|
* A description of what the command does.
|
||||||
|
*/
|
||||||
|
private final String description;
|
||||||
|
/**
|
||||||
|
* String[] of all possible aliases of the command.
|
||||||
|
*/
|
||||||
|
private final String[] aliases;
|
||||||
|
/**
|
||||||
|
* List of all command executors which extends PKCommand
|
||||||
|
*/
|
||||||
|
public static Map<String, PKCommand> instances = new HashMap<String, PKCommand>();
|
||||||
|
|
||||||
|
public PKCommand(String name, String properUse, String description, String[] aliases) {
|
||||||
|
this.name = name;
|
||||||
|
this.properUse = properUse;
|
||||||
|
this.description = description;
|
||||||
|
this.aliases = aliases;
|
||||||
|
instances.put(name, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProperUse() {
|
||||||
|
return properUse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getAliases() {
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void help(CommandSender sender, boolean description) {
|
||||||
|
sender.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + properUse);
|
||||||
|
if (description)
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + this.description);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the {@link CommandSender} has permission to execute the
|
||||||
|
* command. The permission is in the format 'bending.command.
|
||||||
|
* {@link PKCommand#name name}'. If not, they are told so.
|
||||||
|
*
|
||||||
|
* @param sender The CommandSender to check
|
||||||
|
* @return True if they have permission, false otherwise
|
||||||
|
*/
|
||||||
|
protected boolean hasPermission(CommandSender sender) {
|
||||||
|
if (sender.hasPermission("bending.command." + name))
|
||||||
|
return true;
|
||||||
|
else {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You don't have permission to do that.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the {@link CommandSender} has permission to execute the
|
||||||
|
* command. The permission is in the format 'bending.command.
|
||||||
|
* {@link PKCommand#name name}.extra'. If not, they are told so.
|
||||||
|
*
|
||||||
|
* @param sender The CommandSender to check
|
||||||
|
* @param extra The additional node to check
|
||||||
|
* @return True if they have permission, false otherwise
|
||||||
|
*/
|
||||||
|
protected boolean hasPermission(CommandSender sender, String extra) {
|
||||||
|
if (sender.hasPermission("bending.command." + name + "." + extra))
|
||||||
|
return true;
|
||||||
|
else {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You don't have permission to do that.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the argument length is within certain parameters, and if not,
|
||||||
|
* informs the CommandSender of how to correctly use the command.
|
||||||
|
*
|
||||||
|
* @param sender The CommandSender who issued the command
|
||||||
|
* @param size The length of the arguments list
|
||||||
|
* @param min The minimum acceptable number of arguments
|
||||||
|
* @param max The maximum acceptable number of arguments
|
||||||
|
* @return True if min < size < max, false otherwise
|
||||||
|
*/
|
||||||
|
protected boolean correctLength(CommandSender sender, int size, int min, int max) {
|
||||||
|
if (size < min || size > max) {
|
||||||
|
help(sender, false);
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the CommandSender is an instance of a Player. If not, it tells
|
||||||
|
* them they must be a Player to use the command.
|
||||||
|
*
|
||||||
|
* @param sender The CommandSender to check
|
||||||
|
* @return True if sender instanceof Player, false otherwise
|
||||||
|
*/
|
||||||
|
protected boolean isPlayer(CommandSender sender) {
|
||||||
|
if (sender instanceof Player)
|
||||||
|
return true;
|
||||||
|
else {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You must be a player to use that command.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string representation of one of the five base elements,
|
||||||
|
* converted from any possible alias of that element, its combos, or its
|
||||||
|
* subelements.
|
||||||
|
*
|
||||||
|
* @param element The string to try and determine an element for
|
||||||
|
* @return The element associated with the input string, if found, or null
|
||||||
|
* otherwise
|
||||||
|
*/
|
||||||
|
public String getElement(String element) {
|
||||||
|
if (Arrays.asList(Commands.firealiases).contains(element) || Arrays.asList(Commands.firecomboaliases).contains(element) || Arrays.asList(Commands.combustionaliases).contains(element) || Arrays.asList(Commands.lightningaliases).contains(element))
|
||||||
|
return "fire";
|
||||||
|
else if (Arrays.asList(Commands.earthaliases).contains(element) || Arrays.asList(Commands.earthcomboaliases).contains(element) || Arrays.asList(Commands.metalbendingaliases).contains(element) || Arrays.asList(Commands.sandbendingaliases).contains(element) || Arrays.asList(Commands.lavabendingaliases).contains(element))
|
||||||
|
return "earth";
|
||||||
|
else if (Arrays.asList(Commands.airaliases).contains(element) || Arrays.asList(Commands.aircomboaliases).contains(element) || Arrays.asList(Commands.spiritualprojectionaliases).contains(element) || Arrays.asList(Commands.flightaliases).contains(element))
|
||||||
|
return "air";
|
||||||
|
else if (Arrays.asList(Commands.wateraliases).contains(element) || Arrays.asList(Commands.watercomboaliases).contains(element) || Arrays.asList(Commands.healingaliases).contains(element) || Arrays.asList(Commands.bloodaliases).contains(element) || Arrays.asList(Commands.icealiases).contains(element) || Arrays.asList(Commands.plantaliases).contains(element))
|
||||||
|
return "water";
|
||||||
|
else if (Arrays.asList(Commands.chialiases).contains(element) || Arrays.asList(Commands.chicomboaliases).contains(element))
|
||||||
|
return "chi";
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface representation of a command executor.
|
||||||
|
*/
|
||||||
|
public interface PKCommandInterface {
|
||||||
|
/**
|
||||||
|
* Gets the name of the command.
|
||||||
|
*
|
||||||
|
* @return The command's name
|
||||||
|
*/
|
||||||
|
public String getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the aliases for the command.
|
||||||
|
*
|
||||||
|
* @return All aliases for the command
|
||||||
|
*/
|
||||||
|
public String[] getAliases();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the proper use of the command, in the format '/b
|
||||||
|
* {@link PKCommand#name name} arg1 arg2 ... '
|
||||||
|
*
|
||||||
|
* @return the proper use of the command
|
||||||
|
*/
|
||||||
|
public String getProperUse();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the description of the command.
|
||||||
|
*
|
||||||
|
* @return the description
|
||||||
|
*/
|
||||||
|
public String getDescription();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Outputs the correct usage, and optionally the description, of a command
|
||||||
|
* to the given {@link CommandSender}.
|
||||||
|
*
|
||||||
|
* @param sender The CommandSender to output the help to
|
||||||
|
* @param description Whether or not to output the description of the
|
||||||
|
* command
|
||||||
|
*/
|
||||||
|
public void help(CommandSender sender, boolean description);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes the command.
|
||||||
|
*
|
||||||
|
* @param sender The CommandSender who issued the command
|
||||||
|
* @param args the command's arguments
|
||||||
|
*/
|
||||||
|
public void execute(CommandSender sender, List<String> args);
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
|
||||||
|
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executor for /bending permaremove. Extends {@link PKCommand}.
|
||||||
|
*/
|
||||||
|
public class PermaremoveCommand extends PKCommand {
|
||||||
|
|
||||||
|
public PermaremoveCommand() {
|
||||||
|
super("permaremove", "/bending permaremove [Player]", "This command will permanently remove the Bending of the targeted <Player>. Once removed, a player may only receive Bending again if this command is run on them again. This command is typically reserved for administrators.", new String[] { "permaremove", "premove", "permremove", "pr" });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
if (!hasPermission(sender) || !correctLength(sender, args.size(), 0, 1)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (args.size() == 1) {
|
||||||
|
permaremove(sender, args.get(0));
|
||||||
|
} else if (args.size() == 0 && isPlayer(sender))
|
||||||
|
permaremove(sender, sender.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permanently removes a player's bending, or restores it if it had already
|
||||||
|
* been permaremoved.
|
||||||
|
*
|
||||||
|
* @param sender The CommandSender who issued the permaremove command
|
||||||
|
* @param target The Player who's bending should be permaremoved
|
||||||
|
*/
|
||||||
|
private void permaremove(CommandSender sender, String target) {
|
||||||
|
Player player = Bukkit.getPlayer(target);
|
||||||
|
if (player == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "That player is not online.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||||
|
if (bPlayer == null) {
|
||||||
|
GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName());
|
||||||
|
bPlayer = GeneralMethods.getBendingPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bPlayer.isPermaRemoved()) {
|
||||||
|
bPlayer.setPermaRemoved(false);
|
||||||
|
GeneralMethods.savePermaRemoved(bPlayer);
|
||||||
|
player.sendMessage(ChatColor.GREEN + "Your bending has been restored.");
|
||||||
|
if (!(sender instanceof Player) || sender.getName().equals(target))
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "You have restored the bending of: " + ChatColor.DARK_AQUA + player.getName());
|
||||||
|
} else {
|
||||||
|
bPlayer.getElements().clear();
|
||||||
|
GeneralMethods.removeUnusableAbilities(player.getName());
|
||||||
|
GeneralMethods.saveElements(bPlayer);
|
||||||
|
bPlayer.setPermaRemoved(true);
|
||||||
|
GeneralMethods.savePermaRemoved(bPlayer);
|
||||||
|
player.sendMessage(ChatColor.RED + "Your bending has been permanently removed.");
|
||||||
|
if (!(sender instanceof Player) || sender.getName().equals(target))
|
||||||
|
sender.sendMessage(ChatColor.RED + "You have permenantly removed the bending of: " + ChatColor.DARK_AQUA + player.getName());
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, null, Result.PERMAREMOVE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the sender has the permission 'bending.admin.permremove'. If
|
||||||
|
* not, it tells them they don't have permission to use the command.
|
||||||
|
*
|
||||||
|
* @return True if they have the permission, false otherwise
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSender sender) {
|
||||||
|
if (sender.hasPermission("bending.admin.permremove")) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You don't have permission to use this command.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
108
src/com/projectkorra/projectkorra/command/PresetCommand.java
Normal file
108
src/com/projectkorra/projectkorra/command/PresetCommand.java
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
import com.projectkorra.projectkorra.ability.multiability.MultiAbilityManager;
|
||||||
|
import com.projectkorra.projectkorra.object.Preset;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executor for /bending preset. Extends {@link PKCommand}.
|
||||||
|
*/
|
||||||
|
public class PresetCommand extends PKCommand {
|
||||||
|
|
||||||
|
private static final String[] createaliases = { "create", "c", "save" };
|
||||||
|
private static final String[] deletealiases = { "delete", "d", "del" };
|
||||||
|
private static final String[] listaliases = { "list", "l" };
|
||||||
|
private static final String[] bindaliases = { "bind", "b" };
|
||||||
|
|
||||||
|
public PresetCommand() {
|
||||||
|
super("preset", "/bending preset create|bind|list|delete [name]", "This command manages Presets, which are saved bindings. Use /bending preset list to view your existing presets, use /bending [create|delete] [name] to manage your presets, and use /bending bind [name] to bind an existing preset.", new String[] { "preset", "presets", "pre", "set", "p" });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
if (!isPlayer(sender) || !correctLength(sender, args.size(), 1, 2)) {
|
||||||
|
return;
|
||||||
|
} else if (MultiAbilityManager.hasMultiAbilityBound((Player) sender)) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You can't edit your binds right now!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
//bending preset list
|
||||||
|
if (args.size() == 1) {
|
||||||
|
if (Arrays.asList(listaliases).contains(args.get(0)) && hasPermission(sender, "list")) {
|
||||||
|
List<Preset> presets = Preset.presets.get(player.getUniqueId());
|
||||||
|
List<String> presetNames = new ArrayList<String>();
|
||||||
|
|
||||||
|
if (presets == null || presets.isEmpty()) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You don't have any presets.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Preset preset : presets) {
|
||||||
|
presetNames.add(preset.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Your Presets: " + ChatColor.DARK_AQUA + presetNames.toString());
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
help(sender, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String name = args.get(1);
|
||||||
|
if (Arrays.asList(deletealiases).contains(args.get(0)) && hasPermission(sender, "delete")) { //bending preset delete name
|
||||||
|
if (!Preset.presetExists(player, name)) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You don't have a preset with that name.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Preset preset = Preset.getPreset(player, name);
|
||||||
|
preset.delete();
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "You have deleted your preset named: " + ChatColor.YELLOW + name);
|
||||||
|
return;
|
||||||
|
} else if (Arrays.asList(bindaliases).contains(args.get(0)) && hasPermission(sender, "bind")) { //bending preset bind name
|
||||||
|
if (!Preset.presetExists(player, name)) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You don't have a preset with that name.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Preset.bindPreset(player, name);
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Your bound slots have been set to match the " + ChatColor.YELLOW + name + ChatColor.GREEN + " preset.");
|
||||||
|
return;
|
||||||
|
} else if (Arrays.asList(createaliases).contains(args.get(0)) && hasPermission(sender, "create")) { //bending preset create name
|
||||||
|
int limit = GeneralMethods.getMaxPresets(player);
|
||||||
|
|
||||||
|
if (Preset.presets.get(player) != null && Preset.presets.get(player).size() >= limit) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You have reached your max number of Presets.");
|
||||||
|
return;
|
||||||
|
} else if (Preset.presetExists(player, name)) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "A preset with that name already exists.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||||
|
if (bPlayer == null)
|
||||||
|
return;
|
||||||
|
HashMap<Integer, String> abilities = bPlayer.getAbilities();
|
||||||
|
Preset preset = new Preset(player.getUniqueId(), name, abilities);
|
||||||
|
preset.save();
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Created preset with the name: " + ChatColor.YELLOW + name);
|
||||||
|
} else {
|
||||||
|
help(sender, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
28
src/com/projectkorra/projectkorra/command/ReloadCommand.java
Normal file
28
src/com/projectkorra/projectkorra/command/ReloadCommand.java
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executor for /bending reload. Extends {@link PKCommand}.
|
||||||
|
*/
|
||||||
|
public class ReloadCommand extends PKCommand {
|
||||||
|
|
||||||
|
public ReloadCommand() {
|
||||||
|
super("reload", "/bending reload", "This command will reload the Bending config file.", new String[] { "reload", "r" });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
if (!hasPermission(sender) || !correctLength(sender, args.size(), 0, 0)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GeneralMethods.reloadPlugin();
|
||||||
|
sender.sendMessage(ChatColor.AQUA + "Bending config reloaded.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
63
src/com/projectkorra/projectkorra/command/RemoveCommand.java
Normal file
63
src/com/projectkorra/projectkorra/command/RemoveCommand.java
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
|
||||||
|
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executor for /bending remove. Extends {@link PKCommand}.
|
||||||
|
*/
|
||||||
|
public class RemoveCommand extends PKCommand {
|
||||||
|
|
||||||
|
public RemoveCommand() {
|
||||||
|
super("remove", "/bending remove [Player]", "This command will remove the element of the targeted [Player]. The player will be able to re-pick their element after this command is run on them, assuming their Bending was not permaremoved.", new String[] { "remove", "rm" });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
if (!hasPermission(sender) || !correctLength(sender, args.size(), 1, 1)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = Bukkit.getPlayer(args.get(0));
|
||||||
|
if (player == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "That player is not online.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||||
|
if (bPlayer == null) {
|
||||||
|
GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName());
|
||||||
|
bPlayer = GeneralMethods.getBendingPlayer(player);
|
||||||
|
}
|
||||||
|
GeneralMethods.removeUnusableAbilities(player.getName());
|
||||||
|
bPlayer.getElements().clear();
|
||||||
|
GeneralMethods.saveElements(bPlayer);
|
||||||
|
sender.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 + sender.getName());
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, null, Result.REMOVE));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the CommandSender has the permission 'bending.admin.remove'. If
|
||||||
|
* not, it tells them they don't have permission to use the command.
|
||||||
|
*
|
||||||
|
* @return True if they have the permission, false otherwise
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSender sender) {
|
||||||
|
if (sender.hasPermission("bending.admin." + getName())) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You don't have permission to use this command.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
67
src/com/projectkorra/projectkorra/command/ToggleCommand.java
Normal file
67
src/com/projectkorra/projectkorra/command/ToggleCommand.java
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executor for /bending toggle. Extends {@link PKCommand}.
|
||||||
|
*/
|
||||||
|
public class ToggleCommand extends PKCommand {
|
||||||
|
|
||||||
|
public ToggleCommand() {
|
||||||
|
super("toggle", "/bending toggle <all>", "This command will toggle a player's own Bending on or off. If toggled off, all abilities should stop working until it is toggled back on. Logging off will automatically toggle your Bending back on. If you run the command /bending toggle all, Bending will be turned off for all players and cannot be turned back on until the command is run again.", new String[] { "toggle", "t" });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
if (!correctLength(sender, args.size(), 0, 1)) {
|
||||||
|
return;
|
||||||
|
} else if (args.size() == 0) { //bending toggle
|
||||||
|
if (!hasPermission(sender) || !isPlayer(sender)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Commands.isToggledForAll) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Bending is currently toggled off for all players.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(sender.getName());
|
||||||
|
if (bPlayer == null) {
|
||||||
|
GeneralMethods.createBendingPlayer(((Player) sender).getUniqueId(), sender.getName());
|
||||||
|
bPlayer = GeneralMethods.getBendingPlayer(sender.getName());
|
||||||
|
}
|
||||||
|
if (bPlayer.isToggled()) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Your bending has been toggled off. You will not be able to use most abilities until you toggle it back.");
|
||||||
|
bPlayer.toggleBending();
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "You have turned your Bending back on.");
|
||||||
|
bPlayer.toggleBending();
|
||||||
|
}
|
||||||
|
} else if (args.size() == 1 && args.get(0).equalsIgnoreCase("all") && hasPermission(sender, "all")) { //bending toggle all
|
||||||
|
if (Commands.isToggledForAll) { // Bending is toggled off for all players.
|
||||||
|
Commands.isToggledForAll = false;
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
player.sendMessage(ChatColor.GREEN + "Bending has been toggled back on for all players.");
|
||||||
|
}
|
||||||
|
if (!(sender instanceof Player))
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Bending has been toggled back on for all players.");
|
||||||
|
} else {
|
||||||
|
Commands.isToggledForAll = true;
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
player.sendMessage(ChatColor.RED + "Bending has been toggled off for all players.");
|
||||||
|
}
|
||||||
|
if (!(sender instanceof Player))
|
||||||
|
sender.sendMessage(ChatColor.RED + "Bending has been toggled off for all players.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
help(sender, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executor for /bending version. Extends {@link PKCommand}.
|
||||||
|
*/
|
||||||
|
public class VersionCommand extends PKCommand {
|
||||||
|
|
||||||
|
public VersionCommand() {
|
||||||
|
super("version", "/bending version", "Displays the installed version of ProjectKorra.", new String[] { "version", "v" });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
if (!hasPermission(sender) || !correctLength(sender, args.size(), 0, 0)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Core Version: " + ChatColor.RED + ProjectKorra.plugin.getDescription().getVersion());
|
||||||
|
if (GeneralMethods.hasRPG()) {
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "RPG Version: " + ChatColor.RED + GeneralMethods.getRPG().getDescription().getVersion());
|
||||||
|
}
|
||||||
|
if (GeneralMethods.hasItems()) {
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Items Version: " + ChatColor.RED + GeneralMethods.getItems().getDescription().getVersion());
|
||||||
|
}
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Founded by: " + ChatColor.RED + "MistPhizzle");
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Learn More: " + ChatColor.RED + "http://projectkorra.com");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
262
src/com/projectkorra/projectkorra/command/WhoCommand.java
Normal file
262
src/com/projectkorra/projectkorra/command/WhoCommand.java
Normal file
|
@ -0,0 +1,262 @@
|
||||||
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
|
import com.projectkorra.projectkorra.Element;
|
||||||
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
|
import com.projectkorra.projectkorra.airbending.AirMethods;
|
||||||
|
import com.projectkorra.projectkorra.chiblocking.ChiMethods;
|
||||||
|
import com.projectkorra.projectkorra.earthbending.EarthMethods;
|
||||||
|
import com.projectkorra.projectkorra.firebending.FireMethods;
|
||||||
|
import com.projectkorra.projectkorra.storage.DBConnection;
|
||||||
|
import com.projectkorra.projectkorra.waterbending.WaterMethods;
|
||||||
|
import com.projectkorra.rpg.RPGMethods;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executor for /bending who. Extends {@link PKCommand}.
|
||||||
|
*/
|
||||||
|
public class WhoCommand extends PKCommand {
|
||||||
|
/**
|
||||||
|
* Map storage of all ProjectKorra staffs' UUIDs and titles
|
||||||
|
*/
|
||||||
|
Map<String, String> staff = new HashMap<String, String>();
|
||||||
|
|
||||||
|
public WhoCommand() {
|
||||||
|
super("who", "/bending who <Player>", "This command will tell you what element all players that are online are (If you don't specify a player) or give you information about the player that you specify.", new String[] { "who", "w" });
|
||||||
|
|
||||||
|
staff.put("8621211e-283b-46f5-87bc-95a66d68880e", ChatColor.RED + "ProjectKorra Founder"); // MistPhizzle
|
||||||
|
|
||||||
|
staff.put("a197291a-cd78-43bb-aa38-52b7c82bc68c", ChatColor.DARK_PURPLE + "ProjectKorra Lead Developer"); // OmniCypher
|
||||||
|
|
||||||
|
staff.put("929b14fc-aaf1-4f0f-84c2-f20c55493f53", ChatColor.GREEN + "ProjectKorra Head Concept Designer"); // Vidcom
|
||||||
|
|
||||||
|
staff.put("15d1a5a7-76ef-49c3-b193-039b27c47e30", ChatColor.GREEN + "ProjectKorra Digital Director"); // Kiam
|
||||||
|
|
||||||
|
staff.put("96f40c81-dd5d-46b6-9afe-365114d4a082", ChatColor.DARK_PURPLE + "ProjectKorra Developer"); // Coolade
|
||||||
|
staff.put("833a7132-a9ec-4f0a-ad9c-c3d6b8a1c7eb", ChatColor.DARK_PURPLE + "ProjectKorra Developer"); // Jacklin213
|
||||||
|
staff.put("4eb6315e-9dd1-49f7-b582-c1170e497ab0", ChatColor.DARK_PURPLE + "ProjectKorra Developer"); // jedk1
|
||||||
|
staff.put("5031c4e3-8103-49ea-b531-0d6ae71bad69", ChatColor.DARK_PURPLE + "ProjectKorra Developer"); // Simplicitee
|
||||||
|
staff.put("d7757be8-86de-4898-ab4f-2b1b2fbc3dfa", ChatColor.DARK_PURPLE + "ProjectKorra Developer"); // StrangeOne101
|
||||||
|
staff.put("a9673c93-9186-367a-96c4-e111a3bbd1b1", ChatColor.DARK_PURPLE + "ProjectKorra Developer"); // kingbirdy
|
||||||
|
|
||||||
|
staff.put("623df34e-9cd4-438d-b07c-1905e1fc46b6", ChatColor.GREEN + "ProjectKorra Concept Designer"); // Loony
|
||||||
|
staff.put("80f9072f-e37e-4adc-8675-1ba6af87d63b", ChatColor.GREEN + "ProjectKorra Concept Designer"); // Cross
|
||||||
|
staff.put("ce889d32-c2a0-4765-969f-9ca54d0bd34a", ChatColor.GREEN + "ProjectKorra Concept Designer"); // ashe36
|
||||||
|
staff.put("7daead36-d285-4640-848a-2f105334b792", ChatColor.GREEN + "ProjectKorra Concept Designer"); // Fuzzy
|
||||||
|
staff.put("f30c871e-cd60-446b-b219-e31e00e16857", ChatColor.GREEN + "ProjectKorra Concept Designer"); // Gangksta
|
||||||
|
staff.put("38217173-8a32-4ba7-9fe1-dd4fed031a74", ChatColor.GREEN + "ProjectKorra Concept Designer"); // Fly
|
||||||
|
|
||||||
|
staff.put("1553482a-5e86-4270-9262-b57c11151074", ChatColor.GOLD + "ProjectKorra Community Moderator"); // Pickle9775
|
||||||
|
staff.put("3d5bc713-ab8b-4125-b5ba-a1c1c2400b2c", ChatColor.GOLD + "ProjectKorra Community Moderator"); // Gold
|
||||||
|
|
||||||
|
staff.put("2ab334d1-9691-4994-a624-209c7b4f220b", ChatColor.BLUE + "ProjectKorra Digital Team"); // Austygen
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
if (!hasPermission(sender) || !correctLength(sender, args.size(), 0, 1)) {
|
||||||
|
return;
|
||||||
|
} else if (args.size() == 1) {
|
||||||
|
whoPlayer(sender, args.get(0));
|
||||||
|
} else if (args.size() == 0) {
|
||||||
|
List<String> players = new ArrayList<String>();
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
String playerName = player.getName();
|
||||||
|
|
||||||
|
BendingPlayer bp = GeneralMethods.getBendingPlayer(playerName);
|
||||||
|
if (bp == null) {
|
||||||
|
GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName());
|
||||||
|
bp = GeneralMethods.getBendingPlayer(player);
|
||||||
|
}
|
||||||
|
if (bp.getElements().size() > 1) {
|
||||||
|
players.add(GeneralMethods.getAvatarColor() + playerName);
|
||||||
|
continue;
|
||||||
|
} else if (bp.getElements().size() == 0) {
|
||||||
|
players.add(playerName);
|
||||||
|
continue;
|
||||||
|
} else if (GeneralMethods.isBender(playerName, Element.Air)) {
|
||||||
|
players.add(AirMethods.getAirColor() + playerName);
|
||||||
|
continue;
|
||||||
|
} else if (GeneralMethods.isBender(playerName, Element.Water)) {
|
||||||
|
players.add(WaterMethods.getWaterColor() + playerName);
|
||||||
|
continue;
|
||||||
|
} else if (GeneralMethods.isBender(playerName, Element.Earth)) {
|
||||||
|
players.add(EarthMethods.getEarthColor() + playerName);
|
||||||
|
continue;
|
||||||
|
} else if (GeneralMethods.isBender(playerName, Element.Chi)) {
|
||||||
|
players.add(ChiMethods.getChiColor() + playerName);
|
||||||
|
continue;
|
||||||
|
} else if (GeneralMethods.isBender(playerName, Element.Fire)) {
|
||||||
|
players.add(FireMethods.getFireColor() + playerName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (players.isEmpty()) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "There is no one online.");
|
||||||
|
} else {
|
||||||
|
for (String st : players) {
|
||||||
|
sender.sendMessage(st);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends information on the given player to the CommandSender.
|
||||||
|
*
|
||||||
|
* @param sender The CommandSender to display the information to
|
||||||
|
* @param playerName The Player to look up
|
||||||
|
*/
|
||||||
|
private void whoPlayer(CommandSender sender, String playerName) {
|
||||||
|
Player player = Bukkit.getPlayer(playerName);
|
||||||
|
if (player != null) {
|
||||||
|
sender.sendMessage(playerName + " - ");
|
||||||
|
if (GeneralMethods.isBender(playerName, Element.Air)) {
|
||||||
|
sender.sendMessage(AirMethods.getAirColor() + "- Airbender");
|
||||||
|
if (AirMethods.canAirFlight(player)) {
|
||||||
|
sender.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + " Can Fly");
|
||||||
|
}
|
||||||
|
if (AirMethods.canUseSpiritualProjection(player)) {
|
||||||
|
sender.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + " Can use Spiritual Projection");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (GeneralMethods.isBender(playerName, Element.Water)) {
|
||||||
|
sender.sendMessage(WaterMethods.getWaterColor() + "- Waterbender");
|
||||||
|
if (WaterMethods.canPlantbend(player)) {
|
||||||
|
sender.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + " Can Plantbend");
|
||||||
|
}
|
||||||
|
if (WaterMethods.canBloodbend(player)) {
|
||||||
|
if (WaterMethods.canBloodbendAtAnytime(player)) {
|
||||||
|
sender.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + " Can Bloodbend anytime, on any day");
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + " Can Bloodbend");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (WaterMethods.canIcebend(player)) {
|
||||||
|
sender.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + " Can Icebend");
|
||||||
|
}
|
||||||
|
if (WaterMethods.canWaterHeal(player)) {
|
||||||
|
sender.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + " Can Heal");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (GeneralMethods.isBender(playerName, Element.Earth)) {
|
||||||
|
sender.sendMessage(EarthMethods.getEarthColor() + "- Earthbender");
|
||||||
|
if (EarthMethods.canMetalbend(player)) {
|
||||||
|
sender.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + " Can Metalbend");
|
||||||
|
}
|
||||||
|
if (EarthMethods.canLavabend(player)) {
|
||||||
|
sender.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + " Can Lavabend");
|
||||||
|
}
|
||||||
|
if (EarthMethods.canSandbend(player)) {
|
||||||
|
sender.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + " Can Sandbend");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (GeneralMethods.isBender(playerName, Element.Fire)) {
|
||||||
|
sender.sendMessage(FireMethods.getFireColor() + "- Firebender");
|
||||||
|
if (FireMethods.canCombustionbend(player)) {
|
||||||
|
sender.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + " Can Combustionbend");
|
||||||
|
}
|
||||||
|
if (FireMethods.canLightningbend(player)) {
|
||||||
|
sender.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + " Can Lightningbend");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (GeneralMethods.isBender(playerName, Element.Chi)) {
|
||||||
|
sender.sendMessage(ChiMethods.getChiColor() + "- ChiBlocker");
|
||||||
|
}
|
||||||
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(playerName);
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
if (bPlayer != null) {
|
||||||
|
sender.sendMessage("Abilities: ");
|
||||||
|
for (int i = 1; i <= 9; i++) {
|
||||||
|
String ability = bPlayer.getAbilities().get(i);
|
||||||
|
if (ability == null || ability.equalsIgnoreCase("null")) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(i + " - " + GeneralMethods.getAbilityColor(ability) + ability);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GeneralMethods.hasRPG()) {
|
||||||
|
if (RPGMethods.isCurrentAvatar(player.getUniqueId())) {
|
||||||
|
sender.sendMessage(GeneralMethods.getAvatarColor() + "Current Avatar");
|
||||||
|
} else if (RPGMethods.hasBeenAvatar(player.getUniqueId())) {
|
||||||
|
sender.sendMessage(GeneralMethods.getAvatarColor() + "Former Avatar");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (staff.containsKey(uuid)) {
|
||||||
|
sender.sendMessage(staff.get(uuid));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "You are running a lookup of an offline player, this may take a second.");
|
||||||
|
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ResultSet rs2 = DBConnection.sql.readQuery("SELECT * FROM pk_players WHERE player = '" + playerName + "'");
|
||||||
|
try {
|
||||||
|
final List<String> messages = new ArrayList<String>();
|
||||||
|
|
||||||
|
if (rs2.next()) {
|
||||||
|
UUID uuid = UUID.fromString(rs2.getString("uuid"));
|
||||||
|
String element = rs2.getString("element");
|
||||||
|
|
||||||
|
messages.add(playerName + " - ");
|
||||||
|
if (element.contains("a"))
|
||||||
|
messages.add(AirMethods.getAirColor() + "- Airbender");
|
||||||
|
if (element.contains("w"))
|
||||||
|
messages.add(WaterMethods.getWaterColor() + "- Waterbender");
|
||||||
|
if (element.contains("e"))
|
||||||
|
messages.add(EarthMethods.getEarthColor() + "- Earthbender");
|
||||||
|
if (element.contains("f"))
|
||||||
|
messages.add(FireMethods.getFireColor() + "- Firebender");
|
||||||
|
if (element.contains("c"))
|
||||||
|
messages.add(ChiMethods.getChiColor() + "- Chiblocker");
|
||||||
|
|
||||||
|
if (GeneralMethods.hasRPG()) {
|
||||||
|
if (RPGMethods.isCurrentAvatar(uuid)) {
|
||||||
|
messages.add(GeneralMethods.getAvatarColor() + "Current Avatar");
|
||||||
|
} else if (RPGMethods.hasBeenAvatar(uuid)) {
|
||||||
|
messages.add(GeneralMethods.getAvatarColor() + "Former Avatar");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (staff.containsKey(uuid)) {
|
||||||
|
messages.add(staff.get(uuid));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
messages.add(ChatColor.RED + "We could not find any player in your database with that username. Are you sure it is typed correctly?");
|
||||||
|
}
|
||||||
|
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (String message : messages) {
|
||||||
|
sender.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTask(ProjectKorra.plugin);
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskAsynchronously(ProjectKorra.plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -602,6 +602,8 @@ public class ConfigManager {
|
||||||
config.addDefault("Abilities.Earth.Tremorsense.LightThreshold", 7);
|
config.addDefault("Abilities.Earth.Tremorsense.LightThreshold", 7);
|
||||||
config.addDefault("Abilities.Earth.Tremorsense.Cooldown", 1000);
|
config.addDefault("Abilities.Earth.Tremorsense.Cooldown", 1000);
|
||||||
|
|
||||||
|
config.addDefault("Abilities.Earth.EarthCombo.Enabled", true);
|
||||||
|
|
||||||
config.addDefault("Abilities.Fire.Blaze.Enabled", true);
|
config.addDefault("Abilities.Fire.Blaze.Enabled", true);
|
||||||
config.addDefault("Abilities.Fire.Blaze.Description", "To use, simply left-click in any direction. An arc of fire will flow from your location, igniting anything in its path. Additionally, tap sneak to engulf the area around you in roaring flames.");
|
config.addDefault("Abilities.Fire.Blaze.Description", "To use, simply left-click in any direction. An arc of fire will flow from your location, igniting anything in its path. Additionally, tap sneak to engulf the area around you in roaring flames.");
|
||||||
config.addDefault("Abilities.Fire.Blaze.ArcOfFire.Arc", 16);
|
config.addDefault("Abilities.Fire.Blaze.ArcOfFire.Arc", 16);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package com.projectkorra.projectkorra.firebending;
|
package com.projectkorra.projectkorra.firebending;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.BendingPlayer;
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
import com.projectkorra.projectkorra.Commands;
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
import com.projectkorra.projectkorra.Element;
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import com.projectkorra.projectkorra.ProjectKorra;
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||||
import com.projectkorra.projectkorra.airbending.AirMethods;
|
import com.projectkorra.projectkorra.airbending.AirMethods;
|
||||||
|
import com.projectkorra.projectkorra.command.Commands;
|
||||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||||
import com.projectkorra.projectkorra.util.ClickType;
|
import com.projectkorra.projectkorra.util.ClickType;
|
||||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||||
|
|
|
@ -2,10 +2,10 @@ package com.projectkorra.projectkorra.waterbending;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.BendingManager;
|
import com.projectkorra.projectkorra.BendingManager;
|
||||||
import com.projectkorra.projectkorra.BendingPlayer;
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
import com.projectkorra.projectkorra.Commands;
|
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import com.projectkorra.projectkorra.ProjectKorra;
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
import com.projectkorra.projectkorra.ability.multiability.MultiAbilityManager;
|
import com.projectkorra.projectkorra.ability.multiability.MultiAbilityManager;
|
||||||
|
import com.projectkorra.projectkorra.command.Commands;
|
||||||
import com.projectkorra.projectkorra.earthbending.EarthMethods;
|
import com.projectkorra.projectkorra.earthbending.EarthMethods;
|
||||||
import com.projectkorra.projectkorra.util.TempBlock;
|
import com.projectkorra.projectkorra.util.TempBlock;
|
||||||
import com.projectkorra.projectkorra.waterbending.WaterArms.Arm;
|
import com.projectkorra.projectkorra.waterbending.WaterArms.Arm;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package com.projectkorra.projectkorra.waterbending;
|
package com.projectkorra.projectkorra.waterbending;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.BendingPlayer;
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
import com.projectkorra.projectkorra.Commands;
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
import com.projectkorra.projectkorra.Element;
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import com.projectkorra.projectkorra.ProjectKorra;
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||||
|
import com.projectkorra.projectkorra.command.Commands;
|
||||||
import com.projectkorra.projectkorra.earthbending.EarthMethods;
|
import com.projectkorra.projectkorra.earthbending.EarthMethods;
|
||||||
import com.projectkorra.projectkorra.firebending.FireCombo;
|
import com.projectkorra.projectkorra.firebending.FireCombo;
|
||||||
import com.projectkorra.projectkorra.firebending.FireCombo.FireComboStream;
|
import com.projectkorra.projectkorra.firebending.FireCombo.FireComboStream;
|
||||||
|
|
Loading…
Reference in a new issue