Ajout des particules dans /ghost

This commit is contained in:
Marc Baloup 2015-04-05 03:14:11 -04:00
parent 3212fe297d
commit a3300a9834
3 changed files with 123 additions and 11 deletions

View File

@ -5,6 +5,9 @@ import java.util.Random;
import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager;
import net.mc_pandacraft.java.plugin.pandacraftutils.config.elements.WorldBorderConfigEntry;
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer;
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
import net.mc_pandacraft.java.util.TimeUtil;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -14,11 +17,16 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class CommandGhost extends AbstractCommandExecutor {
private static final long timeBetweenThorCommand = 5000;
private long timeLastThorCommand = System.currentTimeMillis();
public CommandGhost() {
super("ghost");
}
@ -37,11 +45,15 @@ public class CommandGhost extends AbstractCommandExecutor {
showHelp(player);
return true;
}
if (args.length >= 1 && args[0].equalsIgnoreCase("thor")) {
onCommandThor(player);
return true;
}
if (args.length >= 1 && args[0].equalsIgnoreCase("particle")) {
onCommandParticle(player);
return true;
}
@ -59,10 +71,13 @@ public class CommandGhost extends AbstractCommandExecutor {
private void showHelp(Player player) {
player.sendMessage(new String[] {
ChatColor.GOLD+"---------- Commande /ghost ----------",
ChatColor.GRAY+"/ghost thor "+ChatColor.GOLD+" produire de l'orage sur l'intégralité du serveur",
ChatColor.GRAY+"/ghost thor"+ChatColor.GOLD+" produire de l'orage sur l'intégralité du serveur",
ChatColor.GRAY+"/ghost particle"+ChatColor.GOLD+" produit un effet de potion autour de vous",
ChatColor.GOLD+"------------------------------------------"
});
@ -79,6 +94,15 @@ public class CommandGhost extends AbstractCommandExecutor {
private void onCommandThor(Player player) {
long timeSinceLastThorCommand = System.currentTimeMillis() - timeLastThorCommand;
if (timeSinceLastThorCommand < timeBetweenThorCommand) {
player.sendMessage(ChatColor.RED+"Veuillez patienter "+TimeUtil.durationToString(timeBetweenThorCommand - timeSinceLastThorCommand)+" avant de refaire cette commande");
}
List<World> worlds = plugin.getServer().getWorlds();
Random r = new Random();
@ -118,11 +142,30 @@ public class CommandGhost extends AbstractCommandExecutor {
}
}
player.sendMessage(ChatColor.GREEN+"L'orage vient de gronder sur tout le serveur.");
}
private void onCommandParticle(Player player) {
OnlinePlayer op = OnlinePlayerManager.get(player);
boolean activated = op.toggleGhostParticle();
if (activated)
player.sendMessage(ChatColor.GREEN+"Activation des effets de particules");
else
player.sendMessage(ChatColor.GREEN+"Désactivation des effets de particules");
}

View File

@ -1,20 +1,25 @@
package net.mc_pandacraft.java.plugin.pandacraftutils.modules.fun;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer;
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
import net.mc_pandacraft.java.util.bukkit.protocol.ParticleEffect;
public class GhostManager {
@SuppressWarnings("unused")
private PandacraftUtils plugin = PandacraftUtils.getInstance();
public GhostManager() {
plugin.getServer().getScheduler().runTaskTimer(plugin, new GhostParticleRunnable(), 0, 10);
}
@ -44,5 +49,50 @@ public class GhostManager {
public class GhostParticleRunnable implements Runnable {
private GhostParticleRunnable() { }
@Override
public void run() {
for (OnlinePlayer op : OnlinePlayerManager.getAll()) {
if (!op.hasPermission("pandacraft.ghost")) return;
if (!op.getGhostParticleEnabled()) return;
drawParticleForPlayer(op.getPlayer());
}
}
private void drawParticleForPlayer(Player p) {
Location center = p.getLocation().add(0, 0.9, 0);
ParticleEffect.MOB_SPELL.display(0.5F, 0.9F, 0.5F, 0, 5, center, 16);
}
}
}

View File

@ -263,12 +263,36 @@ public class OnlinePlayer extends OffPlayer {
/*
* Particules ghost
*/
private boolean enableGhostParticle = false;
public boolean getGhostParticleEnabled() { return enableGhostParticle; }
public boolean toggleGhostParticle() {
enableGhostParticle = !enableGhostParticle;
return enableGhostParticle;
}
/*
* Spécial st valentin : apparition de coeur autour du joueur
*/
private boolean enableHeartThrow = false;
public boolean getHeartThrowEnabled() { return enableHeartThrow; }
@ -289,11 +313,6 @@ public class OnlinePlayer extends OffPlayer {
/*
* Utils
*/