Fix Exception

Fix an exception that occurred when a user who isn't saved in data tries
to use any /pp commands besides gui.
This commit is contained in:
Esophose 2018-04-05 17:48:33 -06:00
parent 2a97972f96
commit 22957cf14e
6 changed files with 100 additions and 97 deletions

View file

@ -1,5 +1,7 @@
== UPDATING WILL DELETE YOUR CONFIG.YML ==
* Create a backup of your config.yml if you wish to import all your old settings!
=== v5.1 ===
* Fix bug preventing the use of /pp effect, style, data, and reset from being used before a player has opened the GUI
=== v5 ===
+ Added a GUI. Opens with /pp or /pp gui. Icons and messages are completely customizable from the config.
+ Added a way to disable the GUI, because I know somebody will ask

View file

@ -7,7 +7,7 @@
*/
/*
* TODO: v5.1
* TODO: v5.2
* + Command to force set an effect/style for a player
* + Tab completion for fixed effects
* + Add new style 'tornado'

View file

@ -337,6 +337,7 @@ public class ConfigManager {
* @param particleEffect The effect that is being saved
*/
public void savePPlayer(UUID playerUUID, ParticleEffect particleEffect) {
getPPlayer(playerUUID, (pplayer) -> {
if (!PlayerParticles.useMySQL) {
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".effect");
section.set("name", particleEffect.getName());
@ -351,7 +352,6 @@ public class ConfigManager {
});
}
getPPlayer(playerUUID, (pplayer) -> {
pplayer.setParticleEffect(particleEffect);
});
}
@ -363,6 +363,7 @@ public class ConfigManager {
* @param particleStyle The style that is being saved
*/
public void savePPlayer(UUID playerUUID, ParticleStyle particleStyle) {
getPPlayer(playerUUID, (pplayer) -> {
if (!PlayerParticles.useMySQL) {
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".style");
section.set("name", particleStyle.getName());
@ -377,7 +378,6 @@ public class ConfigManager {
});
}
getPPlayer(playerUUID, (pplayer) -> {
pplayer.setParticleStyle(particleStyle);
});
}
@ -389,6 +389,7 @@ public class ConfigManager {
* @param particleItemData The data that is being saved
*/
public void savePPlayer(UUID playerUUID, ItemData particleItemData) {
getPPlayer(playerUUID, (pplayer) -> {
if (!PlayerParticles.useMySQL) {
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".itemData");
section.set("material", particleItemData.getMaterial().name());
@ -404,7 +405,6 @@ public class ConfigManager {
});
}
getPPlayer(playerUUID, (pplayer) -> {
pplayer.setItemData(particleItemData);
});
}
@ -416,6 +416,7 @@ public class ConfigManager {
* @param particleBlockData The data that is being saved
*/
public void savePPlayer(UUID playerUUID, BlockData particleBlockData) {
getPPlayer(playerUUID, (pplayer) -> {
if (!PlayerParticles.useMySQL) {
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".blockData");
section.set("material", particleBlockData.getMaterial().name());
@ -431,7 +432,6 @@ public class ConfigManager {
});
}
getPPlayer(playerUUID, (pplayer) -> {
pplayer.setBlockData(particleBlockData);
});
}
@ -443,6 +443,7 @@ public class ConfigManager {
* @param particleColorData The data that is being saved
*/
public void savePPlayer(UUID playerUUID, OrdinaryColor particleColorData) {
getPPlayer(playerUUID, (pplayer) -> {
if (!PlayerParticles.useMySQL) {
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".colorData");
section.set("r", particleColorData.getRed());
@ -459,7 +460,6 @@ public class ConfigManager {
});
}
getPPlayer(playerUUID, (pplayer) -> {
pplayer.setColorData(particleColorData);
});
}
@ -471,6 +471,7 @@ public class ConfigManager {
* @param particleNoteColorData The data that is being saved
*/
public void savePPlayer(UUID playerUUID, NoteColor particleNoteColorData) {
getPPlayer(playerUUID, (pplayer) -> {
if (!PlayerParticles.useMySQL) {
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".noteColorData");
section.set("note", (byte) (particleNoteColorData.getValueX() * 24));
@ -485,7 +486,6 @@ public class ConfigManager {
});
}
getPPlayer(playerUUID, (pplayer) -> {
pplayer.setNoteColorData(particleNoteColorData);
});
}

View file

@ -13,9 +13,11 @@ import java.util.ArrayList;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -55,7 +57,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
*
* @param e The event
*/
@EventHandler
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent e) {
ConfigManager.getInstance().loadPPlayer(e.getPlayer().getUniqueId());
}
@ -65,7 +67,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
*
* @param e The event
*/
@EventHandler
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent e) {
PPlayer pplayer = ConfigManager.getInstance().getPPlayer(e.getPlayer().getUniqueId());
if (pplayer != null)
@ -191,9 +193,8 @@ public class ParticleManager extends BukkitRunnable implements Listener {
valid = false;
}
// Check for the string matching to maintain support for 1.7
// This was checking GameMode.SPECTATOR before and was throwing errors
if (player.getGameMode().name().equalsIgnoreCase("spectator")) {
// Don't show their particles if they are in spectator mode
if (player.getGameMode() == GameMode.SPECTATOR) {
valid = false;
}

View file

@ -14,7 +14,7 @@
# I don't recommend changing it
# NOTE: Updating to a new version of the plugin will change this number and delete your config.
# Make sure you create a backup each time before you update!
version: 5.0
version: 5.1
# Check for new versions of the plugin
# Default: true

View file

@ -1,9 +1,9 @@
name: PlayerParticles
main: com.esophose.playerparticles.PlayerParticles
version: 5.0
version: 5.1
description: Make particles around players in fancy ways.
author: Esophose
website: http://dev.bukkit.org/bukkit-plugins/playerparticles/
website: https://dev.bukkit.org/projects/playerparticles
commands:
pp:
description: The main PlayerParticles command.