mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 11:40:40 +00:00
Merge pull request #1 from jacklin213/master
Updated importer to add SlotAbilites. Added commandlist to help command.
This commit is contained in:
commit
96c649bbe1
11 changed files with 97 additions and 67 deletions
|
@ -1,10 +1,13 @@
|
|||
package com.projectkorra.ProjectKorra.Ability;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public enum StockAbilities {
|
||||
|
||||
// Old Bending
|
||||
AirBlast, AirBubble, AirShield, AirSuction, AirSwipe, Tornado, AirScooter, AirSpout, AirBurst,
|
||||
|
||||
Catapult, RaiseEarth, EarthGrab, EarthTunnel, EarthBlast, Collapse, Tremorsense, EarthArmor, Shockwave, Extraction,
|
||||
Catapult, RaiseEarth, EarthGrab, EarthTunnel, EarthBlast, Collapse, Tremorsense, EarthArmor, Shockwave,
|
||||
|
||||
HeatControl, Blaze, FireJet, Illumination, WallOfFire, FireBlast, Lightning, FireBurst, FireShield,
|
||||
|
||||
|
@ -12,7 +15,10 @@ public enum StockAbilities {
|
|||
|
||||
HighJump, RapidPunch, Paralyze,
|
||||
|
||||
AvatarState;
|
||||
AvatarState,
|
||||
|
||||
// Project Korra
|
||||
Extraction;
|
||||
|
||||
private enum AirbendingAbilities {
|
||||
AirBlast, AirBubble, AirShield, AirSuction, AirSwipe, Tornado, AirScooter, AirSpout, AirBurst;
|
||||
|
@ -69,4 +75,10 @@ public enum StockAbilities {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static StockAbilities getAbility(int index) {
|
||||
if (index == -1)
|
||||
return null;
|
||||
return (StockAbilities)Arrays.asList(values()).get(index);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.projectkorra.ProjectKorra;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package com.projectkorra.ProjectKorra;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
@ -19,9 +17,10 @@ import org.bukkit.command.PluginCommand;
|
|||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager;
|
||||
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
|
||||
|
||||
public class Commands {
|
||||
|
||||
|
@ -49,8 +48,9 @@ public class Commands {
|
|||
String[] reloadaliases = {"reload", "r"};
|
||||
String[] addaliases = {"add", "a"};
|
||||
String[] whoaliases = {"who", "w"};
|
||||
String[] importaliases = {"import", "i"};
|
||||
|
||||
private static int importTask;
|
||||
private static BukkitTask importTask;
|
||||
private void init() {
|
||||
PluginCommand projectkorra = plugin.getCommand("projectkorra");
|
||||
CommandExecutor exe;
|
||||
|
@ -221,7 +221,7 @@ public class Commands {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("import")) {
|
||||
if (Arrays.asList(importaliases).contains(args[0].toLowerCase())) {
|
||||
if (!s.hasPermission("bending.command.import")) {
|
||||
s.sendMessage(ChatColor.RED + "You don't have permission to do that.");
|
||||
return true;
|
||||
|
@ -238,31 +238,35 @@ public class Commands {
|
|||
UUID uuid = Bukkit.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");
|
||||
|
||||
if (oe.contains(0)) {
|
||||
element.add(Element.Air);
|
||||
}
|
||||
if (oe.contains(1)) {
|
||||
element.add(Element.Water);
|
||||
}
|
||||
if (oe.contains(2)) {
|
||||
element.add(Element.Earth);
|
||||
}
|
||||
if (oe.contains(3)) {
|
||||
element.add(Element.Fire);
|
||||
}
|
||||
if (oe.contains(4)) {
|
||||
element.add(Element.Chi);
|
||||
int slot = 1;
|
||||
for (int i : oa) {
|
||||
if (StockAbilities.getAbility(i) != null) {
|
||||
abilities.put(slot, StockAbilities.getAbility(i).toString());
|
||||
slot++;
|
||||
} else {
|
||||
abilities.put(slot, null);
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
BendingPlayer bPlayer = new BendingPlayer(uuid, playername, element, new HashMap<Integer, String>(), false);
|
||||
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();
|
||||
final CommandSender sender = s;
|
||||
s.sendMessage(ChatColor.GREEN + "Import of data started. Do NOT stop / reload your server.");
|
||||
importTask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||
importTask = Bukkit.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||
public void run() {
|
||||
int i = 0;
|
||||
if (i >= 10) {
|
||||
|
@ -273,7 +277,7 @@ public class Commands {
|
|||
while (i < 10) {
|
||||
if (bPlayers.isEmpty()) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Import complete, it may be best to reload your server.");
|
||||
Bukkit.getServer().getScheduler().cancelTask(importTask);
|
||||
Bukkit.getServer().getScheduler().cancelTask(importTask.getTaskId());
|
||||
for (Player player: Bukkit.getOnlinePlayers()) {
|
||||
Methods.createBendingPlayer(player.getUniqueId(), player.getName());
|
||||
}
|
||||
|
@ -287,7 +291,12 @@ public class Commands {
|
|||
if (bPlayer.hasElement(Element.Fire)) elements.append("f");
|
||||
if (bPlayer.hasElement(Element.Chi)) elements.append("c");
|
||||
|
||||
DBConnection.sql.modifyQuery("INSERT INTO pk_players (uuid, player, element, permaremoved) VALUES ('" + bPlayer.uuid.toString() + "', '" + bPlayer.player + "', '" + elements + "', 'false')");
|
||||
HashMap<Integer, String> abilities = bPlayer.abilities;
|
||||
|
||||
DBConnection.sql.modifyQuery("INSERT INTO pk_players (uuid, player, element, permaremoved) VALUES ('" + bPlayer.uuid.toString() + "', '" + bPlayer.player + "', '" + elements + "', '" + bPlayer.isPermaRemoved() +"')");
|
||||
for (int slot = 1; slot < 10; slot++) {
|
||||
DBConnection.sql.modifyQuery("UPDATE pk_players SET slot" + slot + " = '" + abilities.get(slot) + "' WHERE player = '" + bPlayer.getPlayerName() + "'");
|
||||
}
|
||||
// ResultSet rs2 = DBConnection.sql.readQuery("SELECT * FROM pk_players WHERE uuid = '" + bPlayer.uuid.toString() + "'");
|
||||
|
||||
// try {
|
||||
|
@ -788,12 +797,29 @@ public class Commands {
|
|||
if (Arrays.asList(helpaliases).contains(args[0].toLowerCase())) {
|
||||
if (args.length != 2) {
|
||||
s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending help Command/Ability");
|
||||
s.sendMessage(ChatColor.YELLOW + "/bending add <Player> [Element]");
|
||||
s.sendMessage(ChatColor.YELLOW + "/bending bind [Ability] <Slot>");
|
||||
s.sendMessage(ChatColor.YELLOW + "/bending clear <slot>");
|
||||
s.sendMessage(ChatColor.YELLOW + "/bending choose <Player> [Element]");
|
||||
s.sendMessage(ChatColor.YELLOW + "/bending display <Element>");
|
||||
s.sendMessage(ChatColor.YELLOW + "/bending import");
|
||||
s.sendMessage(ChatColor.YELLOW + "/bending permaremove <Player>");
|
||||
s.sendMessage(ChatColor.YELLOW + "/bending remove [Player]");
|
||||
s.sendMessage(ChatColor.YELLOW + "/bending toggle");
|
||||
s.sendMessage(ChatColor.YELLOW + "/bending version");
|
||||
return true;
|
||||
}
|
||||
if (!s.hasPermission("bending.command.help")) {
|
||||
s.sendMessage(ChatColor.RED + "You don't have permission to do that.");
|
||||
return true;
|
||||
}
|
||||
if (Arrays.asList(importaliases).contains(args[1].toLowerCase())) {
|
||||
s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending import");
|
||||
s.sendMessage(ChatColor.YELLOW + "This command will import your old bendingPlayers.yml from the Bending plugin."
|
||||
+ " It will generate a convert.yml file to convert the data to be used with this plugin."
|
||||
+ " You can delete the file once the complete message is displayed"
|
||||
+ " This command should only be used ONCE.");
|
||||
}
|
||||
if (Arrays.asList(displayaliases).contains(args[1].toLowerCase())) {
|
||||
s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending display <Element>");
|
||||
s.sendMessage(ChatColor.YELLOW + "This command will show you all of the elements you have bound if you do not specify an element."
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.projectkorra.ProjectKorra;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public enum Element {
|
||||
|
||||
Air, Water, Earth, Fire, Chi;
|
||||
|
@ -12,4 +14,10 @@ public enum Element {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Element getType(int index) {
|
||||
if (index == -1)
|
||||
return null;
|
||||
return (Element)Arrays.asList(values()).get(index);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,36 +232,33 @@ public class Methods {
|
|||
|
||||
|
||||
|
||||
public static void deserializeFile() {
|
||||
File readFile = new File(".", "bendingPlayers.yml");
|
||||
public static void deserializeFile() {
|
||||
File readFile = new File(".", "bendingPlayers.yml");
|
||||
File writeFile = new File(".", "converted.yml");
|
||||
if (readFile.exists()) {
|
||||
// plugin.log.info("File exists");
|
||||
try
|
||||
{
|
||||
DataInputStream input = new DataInputStream(new FileInputStream(readFile));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(input));
|
||||
// plugin.log.info("File exists");
|
||||
try {
|
||||
DataInputStream input = new DataInputStream(new FileInputStream(readFile));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(input));
|
||||
|
||||
DataOutputStream output = new DataOutputStream(new FileOutputStream(writeFile));
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null)
|
||||
{
|
||||
if (!line.trim().contains("==: BendingPlayer"))
|
||||
{
|
||||
writer.write(line + "\n");
|
||||
}
|
||||
}
|
||||
DataOutputStream output = new DataOutputStream(new FileOutputStream(writeFile));
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (!line.trim().contains("==: BendingPlayer")) {
|
||||
writer.write(line + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
reader.close();
|
||||
input.close();
|
||||
writer.close();
|
||||
output.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
reader.close();
|
||||
input.close();
|
||||
writer.close();
|
||||
output.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.projectkorra.ProjectKorra;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
|
@ -907,7 +906,7 @@ public class PKListener implements Listener {
|
|||
player.setAllowFlight(true);
|
||||
AirBurst.fallBurst(player);
|
||||
player.setFallDistance(0);
|
||||
event.setDamage(0);
|
||||
event.setDamage(0D);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -916,7 +915,7 @@ public class PKListener implements Listener {
|
|||
new Flight(player);
|
||||
player.setAllowFlight(true);
|
||||
player.setFallDistance(0);
|
||||
event.setDamage(0);
|
||||
event.setDamage(0D);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -929,7 +928,7 @@ public class PKListener implements Listener {
|
|||
new Flight(player);
|
||||
player.setAllowFlight(true);
|
||||
player.setFallDistance(0);
|
||||
event.setDamage(0);
|
||||
event.setDamage(0D);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -960,7 +959,7 @@ public class PKListener implements Listener {
|
|||
|
||||
if (Methods.isBender(player.getName(), Element.Earth)
|
||||
&& event.getCause() == DamageCause.SUFFOCATION && TempBlock.isTempBlock(player.getEyeLocation().getBlock())) {
|
||||
event.setDamage(0);
|
||||
event.setDamage(0D);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,11 @@ package com.projectkorra.ProjectKorra.earthbending;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.material.Door;
|
||||
|
||||
import com.projectkorra.ProjectKorra.Element;
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package com.projectkorra.ProjectKorra.earthbending;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
|
|
@ -6,11 +6,9 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package com.projectkorra.ProjectKorra.waterbending;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
|
Loading…
Reference in a new issue