mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-07-03 12:31:22 +00:00
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:
parent
2a97972f96
commit
22957cf14e
6 changed files with 100 additions and 97 deletions
|
@ -1,5 +1,7 @@
|
||||||
== UPDATING WILL DELETE YOUR CONFIG.YML ==
|
== UPDATING WILL DELETE YOUR CONFIG.YML ==
|
||||||
* Create a backup of your config.yml if you wish to import all your old settings!
|
* 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 ===
|
=== v5 ===
|
||||||
+ Added a GUI. Opens with /pp or /pp gui. Icons and messages are completely customizable from the config.
|
+ 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
|
+ Added a way to disable the GUI, because I know somebody will ask
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: v5.1
|
* TODO: v5.2
|
||||||
* + Command to force set an effect/style for a player
|
* + Command to force set an effect/style for a player
|
||||||
* + Tab completion for fixed effects
|
* + Tab completion for fixed effects
|
||||||
* + Add new style 'tornado'
|
* + Add new style 'tornado'
|
||||||
|
|
|
@ -337,21 +337,21 @@ public class ConfigManager {
|
||||||
* @param particleEffect The effect that is being saved
|
* @param particleEffect The effect that is being saved
|
||||||
*/
|
*/
|
||||||
public void savePPlayer(UUID playerUUID, ParticleEffect particleEffect) {
|
public void savePPlayer(UUID playerUUID, ParticleEffect particleEffect) {
|
||||||
if (!PlayerParticles.useMySQL) {
|
|
||||||
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".effect");
|
|
||||||
section.set("name", particleEffect.getName());
|
|
||||||
save();
|
|
||||||
} else {
|
|
||||||
async(() -> {
|
|
||||||
try {
|
|
||||||
PlayerParticles.mySQL.updateSQL("UPDATE pp_users SET effect = '" + particleEffect.getName() + "' WHERE player_uuid = '" + playerUUID + "';");
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getPPlayer(playerUUID, (pplayer) -> {
|
getPPlayer(playerUUID, (pplayer) -> {
|
||||||
|
if (!PlayerParticles.useMySQL) {
|
||||||
|
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".effect");
|
||||||
|
section.set("name", particleEffect.getName());
|
||||||
|
save();
|
||||||
|
} else {
|
||||||
|
async(() -> {
|
||||||
|
try {
|
||||||
|
PlayerParticles.mySQL.updateSQL("UPDATE pp_users SET effect = '" + particleEffect.getName() + "' WHERE player_uuid = '" + playerUUID + "';");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
pplayer.setParticleEffect(particleEffect);
|
pplayer.setParticleEffect(particleEffect);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -363,21 +363,21 @@ public class ConfigManager {
|
||||||
* @param particleStyle The style that is being saved
|
* @param particleStyle The style that is being saved
|
||||||
*/
|
*/
|
||||||
public void savePPlayer(UUID playerUUID, ParticleStyle particleStyle) {
|
public void savePPlayer(UUID playerUUID, ParticleStyle particleStyle) {
|
||||||
if (!PlayerParticles.useMySQL) {
|
|
||||||
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".style");
|
|
||||||
section.set("name", particleStyle.getName());
|
|
||||||
save();
|
|
||||||
} else {
|
|
||||||
async(() -> {
|
|
||||||
try {
|
|
||||||
PlayerParticles.mySQL.updateSQL("UPDATE pp_users SET style = '" + particleStyle.getName() + "' WHERE player_uuid = '" + playerUUID + "';");
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getPPlayer(playerUUID, (pplayer) -> {
|
getPPlayer(playerUUID, (pplayer) -> {
|
||||||
|
if (!PlayerParticles.useMySQL) {
|
||||||
|
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".style");
|
||||||
|
section.set("name", particleStyle.getName());
|
||||||
|
save();
|
||||||
|
} else {
|
||||||
|
async(() -> {
|
||||||
|
try {
|
||||||
|
PlayerParticles.mySQL.updateSQL("UPDATE pp_users SET style = '" + particleStyle.getName() + "' WHERE player_uuid = '" + playerUUID + "';");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
pplayer.setParticleStyle(particleStyle);
|
pplayer.setParticleStyle(particleStyle);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -389,22 +389,22 @@ public class ConfigManager {
|
||||||
* @param particleItemData The data that is being saved
|
* @param particleItemData The data that is being saved
|
||||||
*/
|
*/
|
||||||
public void savePPlayer(UUID playerUUID, ItemData particleItemData) {
|
public void savePPlayer(UUID playerUUID, ItemData particleItemData) {
|
||||||
if (!PlayerParticles.useMySQL) {
|
|
||||||
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".itemData");
|
|
||||||
section.set("material", particleItemData.getMaterial().name());
|
|
||||||
section.set("data", particleItemData.getData());
|
|
||||||
save();
|
|
||||||
} else {
|
|
||||||
async(() -> {
|
|
||||||
try {
|
|
||||||
PlayerParticles.mySQL.updateSQL("UPDATE pp_data_item SET material = '" + particleItemData.getMaterial().name() + "', data = '" + particleItemData.getData() + "' WHERE uuid = '" + playerUUID + "';");
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getPPlayer(playerUUID, (pplayer) -> {
|
getPPlayer(playerUUID, (pplayer) -> {
|
||||||
|
if (!PlayerParticles.useMySQL) {
|
||||||
|
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".itemData");
|
||||||
|
section.set("material", particleItemData.getMaterial().name());
|
||||||
|
section.set("data", particleItemData.getData());
|
||||||
|
save();
|
||||||
|
} else {
|
||||||
|
async(() -> {
|
||||||
|
try {
|
||||||
|
PlayerParticles.mySQL.updateSQL("UPDATE pp_data_item SET material = '" + particleItemData.getMaterial().name() + "', data = '" + particleItemData.getData() + "' WHERE uuid = '" + playerUUID + "';");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
pplayer.setItemData(particleItemData);
|
pplayer.setItemData(particleItemData);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -416,22 +416,22 @@ public class ConfigManager {
|
||||||
* @param particleBlockData The data that is being saved
|
* @param particleBlockData The data that is being saved
|
||||||
*/
|
*/
|
||||||
public void savePPlayer(UUID playerUUID, BlockData particleBlockData) {
|
public void savePPlayer(UUID playerUUID, BlockData particleBlockData) {
|
||||||
if (!PlayerParticles.useMySQL) {
|
|
||||||
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".blockData");
|
|
||||||
section.set("material", particleBlockData.getMaterial().name());
|
|
||||||
section.set("data", particleBlockData.getData());
|
|
||||||
save();
|
|
||||||
} else {
|
|
||||||
async(() -> {
|
|
||||||
try {
|
|
||||||
PlayerParticles.mySQL.updateSQL("UPDATE pp_data_block SET material = '" + particleBlockData.getMaterial().name() + "', data = '" + particleBlockData.getData() + "' WHERE uuid = '" + playerUUID + "';");
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getPPlayer(playerUUID, (pplayer) -> {
|
getPPlayer(playerUUID, (pplayer) -> {
|
||||||
|
if (!PlayerParticles.useMySQL) {
|
||||||
|
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".blockData");
|
||||||
|
section.set("material", particleBlockData.getMaterial().name());
|
||||||
|
section.set("data", particleBlockData.getData());
|
||||||
|
save();
|
||||||
|
} else {
|
||||||
|
async(() -> {
|
||||||
|
try {
|
||||||
|
PlayerParticles.mySQL.updateSQL("UPDATE pp_data_block SET material = '" + particleBlockData.getMaterial().name() + "', data = '" + particleBlockData.getData() + "' WHERE uuid = '" + playerUUID + "';");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
pplayer.setBlockData(particleBlockData);
|
pplayer.setBlockData(particleBlockData);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -443,23 +443,23 @@ public class ConfigManager {
|
||||||
* @param particleColorData The data that is being saved
|
* @param particleColorData The data that is being saved
|
||||||
*/
|
*/
|
||||||
public void savePPlayer(UUID playerUUID, OrdinaryColor particleColorData) {
|
public void savePPlayer(UUID playerUUID, OrdinaryColor particleColorData) {
|
||||||
if (!PlayerParticles.useMySQL) {
|
|
||||||
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".colorData");
|
|
||||||
section.set("r", particleColorData.getRed());
|
|
||||||
section.set("g", particleColorData.getGreen());
|
|
||||||
section.set("b", particleColorData.getBlue());
|
|
||||||
save();
|
|
||||||
} else {
|
|
||||||
async(() -> {
|
|
||||||
try {
|
|
||||||
PlayerParticles.mySQL.updateSQL("UPDATE pp_data_color SET r = " + particleColorData.getRed() + ", g = " + particleColorData.getGreen() + ", b = " + particleColorData.getBlue() + " WHERE uuid = '" + playerUUID + "';");
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getPPlayer(playerUUID, (pplayer) -> {
|
getPPlayer(playerUUID, (pplayer) -> {
|
||||||
|
if (!PlayerParticles.useMySQL) {
|
||||||
|
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".colorData");
|
||||||
|
section.set("r", particleColorData.getRed());
|
||||||
|
section.set("g", particleColorData.getGreen());
|
||||||
|
section.set("b", particleColorData.getBlue());
|
||||||
|
save();
|
||||||
|
} else {
|
||||||
|
async(() -> {
|
||||||
|
try {
|
||||||
|
PlayerParticles.mySQL.updateSQL("UPDATE pp_data_color SET r = " + particleColorData.getRed() + ", g = " + particleColorData.getGreen() + ", b = " + particleColorData.getBlue() + " WHERE uuid = '" + playerUUID + "';");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
pplayer.setColorData(particleColorData);
|
pplayer.setColorData(particleColorData);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -471,21 +471,21 @@ public class ConfigManager {
|
||||||
* @param particleNoteColorData The data that is being saved
|
* @param particleNoteColorData The data that is being saved
|
||||||
*/
|
*/
|
||||||
public void savePPlayer(UUID playerUUID, NoteColor particleNoteColorData) {
|
public void savePPlayer(UUID playerUUID, NoteColor particleNoteColorData) {
|
||||||
if (!PlayerParticles.useMySQL) {
|
|
||||||
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".noteColorData");
|
|
||||||
section.set("note", (byte) (particleNoteColorData.getValueX() * 24));
|
|
||||||
save();
|
|
||||||
} else {
|
|
||||||
async(() -> {
|
|
||||||
try {
|
|
||||||
PlayerParticles.mySQL.updateSQL("UPDATE pp_data_note SET note = " + (byte) (particleNoteColorData.getValueX() * 24) + " WHERE uuid = '" + playerUUID + "';");
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getPPlayer(playerUUID, (pplayer) -> {
|
getPPlayer(playerUUID, (pplayer) -> {
|
||||||
|
if (!PlayerParticles.useMySQL) {
|
||||||
|
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".noteColorData");
|
||||||
|
section.set("note", (byte) (particleNoteColorData.getValueX() * 24));
|
||||||
|
save();
|
||||||
|
} else {
|
||||||
|
async(() -> {
|
||||||
|
try {
|
||||||
|
PlayerParticles.mySQL.updateSQL("UPDATE pp_data_note SET note = " + (byte) (particleNoteColorData.getValueX() * 24) + " WHERE uuid = '" + playerUUID + "';");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
pplayer.setNoteColorData(particleNoteColorData);
|
pplayer.setNoteColorData(particleNoteColorData);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,11 @@ import java.util.ArrayList;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
@ -55,7 +57,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
|
||||||
*
|
*
|
||||||
* @param e The event
|
* @param e The event
|
||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||||
ConfigManager.getInstance().loadPPlayer(e.getPlayer().getUniqueId());
|
ConfigManager.getInstance().loadPPlayer(e.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
|
@ -65,7 +67,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
|
||||||
*
|
*
|
||||||
* @param e The event
|
* @param e The event
|
||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerQuit(PlayerQuitEvent e) {
|
public void onPlayerQuit(PlayerQuitEvent e) {
|
||||||
PPlayer pplayer = ConfigManager.getInstance().getPPlayer(e.getPlayer().getUniqueId());
|
PPlayer pplayer = ConfigManager.getInstance().getPPlayer(e.getPlayer().getUniqueId());
|
||||||
if (pplayer != null)
|
if (pplayer != null)
|
||||||
|
@ -191,9 +193,8 @@ public class ParticleManager extends BukkitRunnable implements Listener {
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for the string matching to maintain support for 1.7
|
// Don't show their particles if they are in spectator mode
|
||||||
// This was checking GameMode.SPECTATOR before and was throwing errors
|
if (player.getGameMode() == GameMode.SPECTATOR) {
|
||||||
if (player.getGameMode().name().equalsIgnoreCase("spectator")) {
|
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
# I don't recommend changing it
|
# I don't recommend changing it
|
||||||
# NOTE: Updating to a new version of the plugin will change this number and delete your config.
|
# 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!
|
# Make sure you create a backup each time before you update!
|
||||||
version: 5.0
|
version: 5.1
|
||||||
|
|
||||||
# Check for new versions of the plugin
|
# Check for new versions of the plugin
|
||||||
# Default: true
|
# Default: true
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
name: PlayerParticles
|
name: PlayerParticles
|
||||||
main: com.esophose.playerparticles.PlayerParticles
|
main: com.esophose.playerparticles.PlayerParticles
|
||||||
version: 5.0
|
version: 5.1
|
||||||
description: Make particles around players in fancy ways.
|
description: Make particles around players in fancy ways.
|
||||||
author: Esophose
|
author: Esophose
|
||||||
website: http://dev.bukkit.org/bukkit-plugins/playerparticles/
|
website: https://dev.bukkit.org/projects/playerparticles
|
||||||
commands:
|
commands:
|
||||||
pp:
|
pp:
|
||||||
description: The main PlayerParticles command.
|
description: The main PlayerParticles command.
|
Loading…
Add table
Add a link
Reference in a new issue