Ajout des particules dans /ghost
This commit is contained in:
parent
3212fe297d
commit
a3300a9834
@ -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.ConfigManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.config.elements.WorldBorderConfigEntry;
|
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.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -14,6 +17,10 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class CommandGhost extends AbstractCommandExecutor {
|
public class CommandGhost extends AbstractCommandExecutor {
|
||||||
|
private static final long timeBetweenThorCommand = 5000;
|
||||||
|
private long timeLastThorCommand = System.currentTimeMillis();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public CommandGhost() {
|
public CommandGhost() {
|
||||||
super("ghost");
|
super("ghost");
|
||||||
@ -22,6 +29,7 @@ public class CommandGhost extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label,
|
public boolean onCommand(CommandSender sender, Command cmd, String label,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
@ -42,6 +50,10 @@ public class CommandGhost extends AbstractCommandExecutor {
|
|||||||
onCommandThor(player);
|
onCommandThor(player);
|
||||||
return true;
|
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) {
|
private void showHelp(Player player) {
|
||||||
player.sendMessage(new String[] {
|
player.sendMessage(new String[] {
|
||||||
ChatColor.GOLD+"---------- Commande /ghost ----------",
|
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+"------------------------------------------"
|
ChatColor.GOLD+"------------------------------------------"
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -79,6 +94,15 @@ public class CommandGhost extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
private void onCommandThor(Player player) {
|
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();
|
List<World> worlds = plugin.getServer().getWorlds();
|
||||||
|
|
||||||
Random r = new Random();
|
Random r = new Random();
|
||||||
@ -118,6 +142,8 @@ public class CommandGhost extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.GREEN+"L'orage vient de gronder sur tout le serveur.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -125,6 +151,23 @@ public class CommandGhost extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,25 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.modules.fun;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules.fun;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
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.plugin.pandacraftutils.players.OnlinePlayerManager;
|
||||||
|
import net.mc_pandacraft.java.util.bukkit.protocol.ParticleEffect;
|
||||||
|
|
||||||
public class GhostManager {
|
public class GhostManager {
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private PandacraftUtils plugin = PandacraftUtils.getInstance();
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -264,11 +264,35 @@ 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
|
* Spécial st valentin : apparition de coeur autour du joueur
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private boolean enableHeartThrow = false;
|
private boolean enableHeartThrow = false;
|
||||||
|
|
||||||
public boolean getHeartThrowEnabled() { return enableHeartThrow; }
|
public boolean getHeartThrowEnabled() { return enableHeartThrow; }
|
||||||
@ -289,11 +313,6 @@ public class OnlinePlayer extends OffPlayer {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Utils
|
* Utils
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user