mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-07-26 15:33:41 +00:00
Update to v3.8
Clean up a bunch of stuff and update to new version
This commit is contained in:
parent
a851ee037d
commit
3a730281f9
10 changed files with 94 additions and 53 deletions
|
@ -10,14 +10,19 @@ package com.esophose.playerparticles;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import com.esophose.playerparticles.libraries.particles.ParticleEffect.ParticleType;
|
import com.esophose.playerparticles.libraries.particles.ParticleEffect.ParticleType;
|
||||||
|
|
||||||
|
@ -183,4 +188,51 @@ public class ConfigManager {
|
||||||
}else return null;
|
}else return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateConfig(JavaPlugin plugin) {
|
||||||
|
HashMap<String, Object> newConfig = getConfigVals();
|
||||||
|
FileConfiguration c = plugin.getConfig();
|
||||||
|
for (String var : c.getKeys(false)) {
|
||||||
|
newConfig.remove(var);
|
||||||
|
}
|
||||||
|
if (newConfig.size() != 0) {
|
||||||
|
for (String key : newConfig.keySet()) {
|
||||||
|
c.set(key, newConfig.get(key));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
|
||||||
|
c.set("version", getVersion());
|
||||||
|
c.save(new File(plugin.getDataFolder(), "config.yml"));
|
||||||
|
} catch (IOException e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, Object> getConfigVals() {
|
||||||
|
HashMap<String, Object> var = new HashMap<>();
|
||||||
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
|
try {
|
||||||
|
config.loadFromString(stringFromInputStream(PlayerParticles.class.getResourceAsStream("/config.yml")));
|
||||||
|
} catch (InvalidConfigurationException e) {}
|
||||||
|
for (String key : config.getKeys(false)) {
|
||||||
|
var.put(key, config.get(key));
|
||||||
|
}
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getVersion() {
|
||||||
|
double version = -1;
|
||||||
|
try {
|
||||||
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
|
config.loadFromString(stringFromInputStream(PlayerParticles.class.getResourceAsStream("/config.yml")));
|
||||||
|
version = config.getDouble("version");
|
||||||
|
}catch(InvalidConfigurationException e) { }
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String stringFromInputStream(InputStream in) {
|
||||||
|
Scanner scanner = new Scanner(in);
|
||||||
|
String string = scanner.useDelimiter("\\A").next();
|
||||||
|
scanner.close();
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.bukkit.entity.Player;
|
||||||
public class MessageManager {
|
public class MessageManager {
|
||||||
|
|
||||||
private static MessageManager instance = new MessageManager();
|
private static MessageManager instance = new MessageManager();
|
||||||
private boolean messagesEnabled, prefix, checkForUpdates;
|
private boolean messagesEnabled, prefix;
|
||||||
private String messagePrefix;
|
private String messagePrefix;
|
||||||
|
|
||||||
private MessageManager() {
|
private MessageManager() {
|
||||||
|
@ -22,25 +22,12 @@ public class MessageManager {
|
||||||
prefix = PlayerParticles.getPlugin().getConfig().getBoolean("use-message-prefix");
|
prefix = PlayerParticles.getPlugin().getConfig().getBoolean("use-message-prefix");
|
||||||
messagePrefix = PlayerParticles.getPlugin().getConfig().getString("message-prefix");
|
messagePrefix = PlayerParticles.getPlugin().getConfig().getString("message-prefix");
|
||||||
messagePrefix = messagePrefix.replace("&", "§");
|
messagePrefix = messagePrefix.replace("&", "§");
|
||||||
checkForUpdates = PlayerParticles.getPlugin().getConfig().getBoolean("check-updates");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reload() {
|
|
||||||
messagesEnabled = PlayerParticles.getPlugin().getConfig().getBoolean("messages-enabled");
|
|
||||||
prefix = PlayerParticles.getPlugin().getConfig().getBoolean("use-message-prefix");
|
|
||||||
messagePrefix = PlayerParticles.getPlugin().getConfig().getString("message-prefix");
|
|
||||||
messagePrefix = messagePrefix.replace("&", "§");
|
|
||||||
checkForUpdates = PlayerParticles.getPlugin().getConfig().getBoolean("check-updates");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MessageManager getInstance() {
|
public static MessageManager getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldCheckUpdates() {
|
|
||||||
return checkForUpdates;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendMessage(Player player, String message, ChatColor color) {
|
public void sendMessage(Player player, String message, ChatColor color) {
|
||||||
if(!messagesEnabled) return;
|
if(!messagesEnabled) return;
|
||||||
if(this.prefix){
|
if(this.prefix){
|
||||||
|
|
|
@ -19,13 +19,9 @@ public class ParticleCommandCompleter implements TabCompleter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||||
|
|
||||||
if(cmd.getName().equalsIgnoreCase("pp")) {
|
if(cmd.getName().equalsIgnoreCase("pp")) {
|
||||||
|
|
||||||
if(args.length == 1) {
|
if(args.length == 1) {
|
||||||
|
|
||||||
List<String> list = PermissionHandler.getParticlesUserHasPermissionFor((Player)sender);
|
List<String> list = PermissionHandler.getParticlesUserHasPermissionFor((Player)sender);
|
||||||
if(PermissionHandler.canReload((Player)sender)) list.add("reload");
|
|
||||||
list.add("list");
|
list.add("list");
|
||||||
list.add("styles");
|
list.add("styles");
|
||||||
list.add("style");
|
list.add("style");
|
||||||
|
@ -33,17 +29,9 @@ public class ParticleCommandCompleter implements TabCompleter {
|
||||||
list.add("worlds");
|
list.add("worlds");
|
||||||
list.add("help");
|
list.add("help");
|
||||||
return list;
|
return list;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if(args.length == 2) return PermissionHandler.getStylesUserHasPermissionFor((Player)sender);
|
||||||
if(args.length == 2) {
|
|
||||||
|
|
||||||
return PermissionHandler.getStylesUserHasPermissionFor((Player)sender);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,11 +80,13 @@ public class ParticleCreator extends BukkitRunnable implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMove(PlayerMoveEvent e) {
|
public void onPlayerMove(PlayerMoveEvent e) {
|
||||||
if(map.containsKey(e.getPlayer().getName()) && styleMap.get(e.getPlayer().getName()) == ParticleStyle.MOVE) {
|
if(map.containsKey(e.getPlayer().getName()) && styleMap.get(e.getPlayer().getName()) == ParticleStyle.MOVE) {
|
||||||
|
if(PermissionHandler.hasStylePermission(e.getPlayer(), ParticleStyle.MOVE)) {
|
||||||
Location loc = e.getPlayer().getLocation();
|
Location loc = e.getPlayer().getLocation();
|
||||||
loc.setY(loc.getY() + 1);
|
loc.setY(loc.getY() + 1);
|
||||||
handleStyleNone(map.get(e.getPlayer().getName()), loc);
|
handleStyleNone(map.get(e.getPlayer().getName()), loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void addMap(Player player, ParticleType effect){
|
public static void addMap(Player player, ParticleType effect){
|
||||||
map.remove(player.getName());
|
map.remove(player.getName());
|
||||||
|
@ -188,7 +190,6 @@ public class ParticleCreator extends BukkitRunnable implements Listener {
|
||||||
Location newLocation = new Location(location.getWorld(), newX, newY, newZ);
|
Location newLocation = new Location(location.getWorld(), newX, newY, newZ);
|
||||||
particle.display(newLocation);
|
particle.display(newLocation);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}else if(style == ParticleStyle.HALO) {
|
}else if(style == ParticleStyle.HALO) {
|
||||||
if(step % 2 == 0) return;
|
if(step % 2 == 0) return;
|
||||||
ParticleEffect particle = null;
|
ParticleEffect particle = null;
|
||||||
|
@ -205,13 +206,11 @@ public class ParticleCreator extends BukkitRunnable implements Listener {
|
||||||
Location newLocation = new Location(location.getWorld(), newX, newY, newZ);
|
Location newLocation = new Location(location.getWorld(), newX, newY, newZ);
|
||||||
particle.display(newLocation);
|
particle.display(newLocation);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}else if(style == ParticleStyle.POINT) {
|
}else if(style == ParticleStyle.POINT) {
|
||||||
ParticleEffect particle = null;
|
ParticleEffect particle = null;
|
||||||
if(effect == ParticleType.RAINBOW || effect == ParticleType.NOTE) particle = new ParticleEffect(effect, 0.0F, 0.0F, 0.0F, 1.0F, 1);
|
if(effect == ParticleType.RAINBOW || effect == ParticleType.NOTE) particle = new ParticleEffect(effect, 0.0F, 0.0F, 0.0F, 1.0F, 1);
|
||||||
else particle = new ParticleEffect(effect, 0.0F, 0.0F, 0.0F, 0.0F, 1);
|
else particle = new ParticleEffect(effect, 0.0F, 0.0F, 0.0F, 0.0F, 1);
|
||||||
particle.display(location.add(0.0, 1.5, 0.0));
|
particle.display(location.add(0.0, 1.5, 0.0));
|
||||||
return;
|
|
||||||
}else if(style == ParticleStyle.SPIN) {
|
}else if(style == ParticleStyle.SPIN) {
|
||||||
ParticleEffect particle = null;
|
ParticleEffect particle = null;
|
||||||
if(effect == ParticleType.RAINBOW || effect == ParticleType.NOTE) particle = new ParticleEffect(effect, 0.0F, 0.0F, 0.0F, 1.0F, 1);
|
if(effect == ParticleType.RAINBOW || effect == ParticleType.NOTE) particle = new ParticleEffect(effect, 0.0F, 0.0F, 0.0F, 1.0F, 1);
|
||||||
|
@ -235,7 +234,15 @@ public class ParticleCreator extends BukkitRunnable implements Listener {
|
||||||
double dz = -(Math.sin((helixStep / 90) * (Math.PI * 2) + ((Math.PI / 2) * i))) * ((60 - Math.abs(helixYStep)) / 60);
|
double dz = -(Math.sin((helixStep / 90) * (Math.PI * 2) + ((Math.PI / 2) * i))) * ((60 - Math.abs(helixYStep)) / 60);
|
||||||
particle.display(new Location(location.getWorld(), location.getX() + dx, location.getY() + dy, location.getZ() + dz));
|
particle.display(new Location(location.getWorld(), location.getX() + dx, location.getY() + dy, location.getZ() + dz));
|
||||||
}
|
}
|
||||||
return;
|
}else if(style == ParticleStyle.ORB) {
|
||||||
|
ParticleEffect particle = null;
|
||||||
|
if(effect == ParticleType.RAINBOW || effect == ParticleType.NOTE) particle = new ParticleEffect(effect, 0.0F, 0.0F, 0.0F, 1.0F, 1);
|
||||||
|
else particle = new ParticleEffect(effect, 0.0F, 0.0F, 0.0F, 0.0F, 1);
|
||||||
|
for(int i = 0; i < 4; i++) {
|
||||||
|
double dx = -(Math.cos((helixStep / 90) * (Math.PI * 2) + ((Math.PI / 2) * i)));
|
||||||
|
double dz = -(Math.sin((helixStep / 90) * (Math.PI * 2) + ((Math.PI / 2) * i)));
|
||||||
|
particle.display(new Location(location.getWorld(), location.getX() + dx, location.getY(), location.getZ() + dz));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ public enum ParticleStyle {
|
||||||
POINT,
|
POINT,
|
||||||
MOVE,
|
MOVE,
|
||||||
SPIN,
|
SPIN,
|
||||||
QUADHELIX;
|
QUADHELIX,
|
||||||
|
ORB;
|
||||||
|
|
||||||
public static ParticleStyle styleFromString(String particle){
|
public static ParticleStyle styleFromString(String particle){
|
||||||
for(ParticleStyle style : ParticleStyle.values()){
|
for(ParticleStyle style : ParticleStyle.values()){
|
||||||
|
|
|
@ -67,11 +67,4 @@ public class PermissionHandler {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canReload(Player p) {
|
|
||||||
if(p.hasPermission("playerparticles.reload") || p.hasPermission("playerparticles.*")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,20 +56,23 @@ public class PlayerParticles extends JavaPlugin {
|
||||||
startTasks();
|
startTasks();
|
||||||
|
|
||||||
// Check for an update
|
// Check for an update
|
||||||
if(MessageManager.getInstance().shouldCheckUpdates()) {
|
if(shouldCheckUpdates()) {
|
||||||
Updater updater = new Updater(this, 82823, this.getFile(), Updater.UpdateType.NO_DOWNLOAD, false);
|
Updater updater = new Updater(this, 82823, this.getFile(), Updater.UpdateType.NO_DOWNLOAD, false);
|
||||||
if(Double.parseDouble(updater.getLatestName().replaceAll("PlayerParticles v", "")) > Double.parseDouble(getPlugin().getDescription().getVersion())) {
|
if(Double.parseDouble(updater.getLatestName().replaceAll("PlayerParticles v", "")) > Double.parseDouble(getPlugin().getDescription().getVersion())) {
|
||||||
updateVersion = updater.getLatestName().replaceAll("PlayerParticles v", "");
|
updateVersion = updater.getLatestName().replaceAll("PlayerParticles v", "");
|
||||||
System.out.println("[PlayerParticles] An update (v" + updateVersion + ") is available! You are running v" + getPlugin().getDescription().getVersion());
|
getLogger().info("[PlayerParticles] An update (v" + updateVersion + ") is available! You are running v" + getPlugin().getDescription().getVersion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Plugin getPlugin(){
|
public static Plugin getPlugin(){
|
||||||
return Bukkit.getPluginManager().getPlugin("PlayerParticles");
|
return Bukkit.getPluginManager().getPlugin("PlayerParticles");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean shouldCheckUpdates() {
|
||||||
|
return getConfig().getBoolean("check-updates");
|
||||||
|
}
|
||||||
|
|
||||||
private void checkDatabase() {
|
private void checkDatabase() {
|
||||||
if(getConfig().getBoolean("database-enable")) {
|
if(getConfig().getBoolean("database-enable")) {
|
||||||
String hostname = getConfig().getString("database-hostname");
|
String hostname = getConfig().getString("database-hostname");
|
||||||
|
@ -85,13 +88,13 @@ public class PlayerParticles extends JavaPlugin {
|
||||||
useMySQL = true;
|
useMySQL = true;
|
||||||
} catch (ClassNotFoundException | SQLException e) {
|
} catch (ClassNotFoundException | SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("Failed to connect to MySQL Database! Check to see if your config is correct!");
|
getLogger().info("Failed to connect to MySQL Database! Check to see if your config is correct!");
|
||||||
useMySQL = false;
|
useMySQL = false;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
useMySQL = false;
|
useMySQL = false;
|
||||||
}
|
}
|
||||||
System.out.println("[PlayerParticles] Using mySQL for data storage: " + useMySQL);
|
getLogger().info("[PlayerParticles] Using mySQL for data storage: " + useMySQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startTasks() {
|
private void startTasks() {
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
/**
|
||||||
|
* Copyright Esophose 2016
|
||||||
|
* While using any of the code provided by this plugin
|
||||||
|
* you must not claim it as your own. This plugin may
|
||||||
|
* be modified and installed on a server, but may not
|
||||||
|
* be distributed to any person by any means.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.esophose.playerparticles.updater;
|
package com.esophose.playerparticles.updater;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
# ====================================================#
|
# ====================================================#
|
||||||
|
|
||||||
# DO NOT CHANGE THIS UNDER ANY CIRCUMSTANCE (Will reset your config)
|
# DO NOT CHANGE THIS UNDER ANY CIRCUMSTANCE (Will reset your config)
|
||||||
version: 3.7
|
version: 3.8
|
||||||
|
|
||||||
# There are 20 minecraft ticks per second
|
# There are 20 minecraft ticks per second
|
||||||
# The default value of 20 means a particle will be displayed every tick
|
# The default value of 1 means a particle will be displayed once every tick
|
||||||
# That means 20 particles will be displayed per second
|
# That means 20 particles will be displayed per second
|
||||||
# If ticks-per-particle was set to 5, then 4 particles would be displayed per second since 20/5 is 4
|
# If ticks-per-particle was set to 5, then 4 particles would be displayed per second since 20/5 is 4
|
||||||
# If your server is experiencing lag after installing this plugin, raising this value should help
|
# If your server is experiencing lag after installing this plugin, raising this value should help
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
name: PlayerParticles
|
name: PlayerParticles
|
||||||
main: com.esophose.playerparticles.PlayerParticles
|
main: com.esophose.playerparticles.PlayerParticles
|
||||||
version: 3.7
|
version: 3.8
|
||||||
description: Make Particles Around Players
|
description: Make particles around players.
|
||||||
|
author: Esophose
|
||||||
|
website: http://dev.bukkit.org/bukkit-plugins/playerparticles/
|
||||||
commands:
|
commands:
|
||||||
pp:
|
pp:
|
||||||
description: Particles Command.
|
description: Particles Command.
|
Loading…
Add table
Add a link
Reference in a new issue