Fixed: NPE on dconnect with cdown & /b not working on first load (#563)

This commit is contained in:
Sobki 2016-08-28 10:24:33 +10:00 committed by OmniCypher
parent 7530e0bae1
commit beec447bb1
3 changed files with 22 additions and 15 deletions

View file

@ -624,6 +624,9 @@ public class BendingPlayer {
* @param ability The ability's cooldown to remove
*/
public void removeCooldown(String ability) {
if (Bukkit.getPlayer(uuid) == null) {
return;
}
PlayerCooldownChangeEvent event = new PlayerCooldownChangeEvent(Bukkit.getPlayer(uuid), ability, 0, Result.REMOVED);
Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {

View file

@ -1,7 +1,9 @@
package com.projectkorra.projectkorra.command;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@ -9,10 +11,8 @@ 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;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.configuration.ConfigManager;
public class Commands {
@ -76,7 +76,7 @@ public class Commands {
//Miscellaneous
public static String[] commandaliases = { "b", "pk", "projectkorra", "bending", "mtla", "tla", "korra", "bend" };
private List<String> help;
private void init() {
@ -99,7 +99,7 @@ public class Commands {
new ToggleCommand();
new VersionCommand();
new WhoCommand();
help = ConfigManager.languageConfig.get().getStringList("Commands.GeneralHelpLines");
/**
@ -111,10 +111,7 @@ public class Commands {
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];
}
if (args.length == 0 && Arrays.asList(commandaliases).contains(label.toLowerCase())) {
for (String line : help)
s.sendMessage(ChatColor.translateAlternateColorCodes('&', line));
@ -128,6 +125,10 @@ public class Commands {
return true;
}
}
for (String line : help)
s.sendMessage(ChatColor.translateAlternateColorCodes('&', line));
return true;
}
};

View file

@ -42,6 +42,11 @@ public class ConfigManager {
} else if (type == ConfigType.LANGUAGE) {
config = languageConfig.get();
ArrayList<String> helpLines = new ArrayList<String>();
helpLines.add("&c/bending help [Ability/Command] &eDisplay help.");
helpLines.add("&c/bending choose [Element] &eChoose an element.");
helpLines.add("&c/bending bind [Ability] # &eBind an ability.");
config.addDefault("Chat.Enable", true);
config.addDefault("Chat.Format", "<name>: <message>");
config.addDefault("Chat.Colors.Avatar", "DARK_PURPLE");
@ -70,9 +75,7 @@ public class ConfigManager {
config.addDefault("Commands.NoPermission", "You do not have permission to do that.");
config.addDefault("Commands.MustBePlayer", "You must be a player to perform this action.");
config.addDefault("Commands.GeneralHelpLines", new String[] {"&c/bending help [Ability/Command] &eDisplay help.",
"&c/bending choose [Element] &eChoose an element.",
"&c/bending bind [Ability] # &eBind an ability."});
config.addDefault("Commands.GeneralHelpLines", helpLines);
config.addDefault("Commands.Who.Description", "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.");
config.addDefault("Commands.Who.NoPlayersOnline", "There is no one online.");