Création de la commande /ghost + Correction de bugs relatifs aux évènements + amélioration de l'efficacité du vanish

This commit is contained in:
Marc Baloup 2015-03-29 22:22:07 -04:00
parent 093a1f619a
commit e2be425513
5 changed files with 156 additions and 13 deletions

View File

@ -0,0 +1,125 @@
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
import java.util.List;
import java.util.Random;
import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager;
import net.mc_pandacraft.java.plugin.pandacraftutils.config.elements.WorldBorderConfigEntry;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class CommandGhost extends AbstractCommandExecutor {
public CommandGhost() {
super("ghost");
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label,
String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED+"Vous devez être en ligne pour faire cette commande");
return true;
}
Player player = (Player) sender;
if (args.length == 0) {
showHelp(player);
return true;
}
if (args.length >= 1 && args[0].equalsIgnoreCase("thor")) {
onCommandThor(player);
return true;
}
// on arrive ici si aucune des sous commandes correspond à celle tapée
sender.sendMessage(ChatColor.RED+"Mauvaise utilisation de la commande. Faites "+ChatColor.GRAY+"/ghost"+ChatColor.RED+" pour connaitre l'utilisation");
return true;
}
private void showHelp(Player player) {
}
private void onCommandThor(Player player) {
List<World> worlds = plugin.getServer().getWorlds();
Random r = new Random();
for (World w : worlds) {
int nbStrike = r.nextInt(2)+1;
for (int i=0; i<nbStrike; i++) {
WorldBorderConfigEntry config = ConfigManager.getInstance().worldBorderConfig.getEntry(w);
if (config == null)
continue;
// l'orage sera localisé à un endroit aléatoire à l'intérieur des WorldBorders
double locX = r.nextDouble()*(config.getMaxX()-config.getMinX())+config.getMinX();
double locY = r.nextDouble()*255;
double locZ = r.nextDouble()*(config.getMaxZ()-config.getMinZ())+config.getMinZ();
int nbTickBeforeStrike = r.nextInt(20);
Location loc = new Location(w, locX, locY, locZ);
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
Location loc;
@Override
public void run() {
loc.getWorld().strikeLightningEffect(loc);
}
public Runnable init(Location l) {
loc = l;
return this;
}
}.init(loc), nbTickBeforeStrike);
}
}
}
}

View File

@ -93,12 +93,17 @@ public class PlayerListener implements Listener {
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
plugin.afkManager.onAsyncPlayerChat(event);
}
@EventHandler(ignoreCancelled=true,priority=EventPriority.HIGH)
public void onAsyncPlayerChat_High_IgnoreCancelled(AsyncPlayerChatEvent event) {
plugin.chatAnalysisManager.onAsyncPlayerChat(event);
}
@EventHandler(ignoreCancelled=true,priority=EventPriority.HIGHEST)
public void onAsyncPlayerChat_Highest_IgnoreCancelled(AsyncPlayerChatEvent event) {
plugin.ghostManager.onAsyncPlayerChat(event);
}
@ -109,18 +114,23 @@ public class PlayerListener implements Listener {
@EventHandler(ignoreCancelled=false,priority=EventPriority.LOWEST)
public void onPlayerCommandPreprocess_Lowest(PlayerCommandPreprocessEvent event) {
OnlinePlayerManager.get(event.getPlayer()).getEssentialsUser().setDisplayNick();
}
@EventHandler(ignoreCancelled=false,priority=EventPriority.NORMAL)
public void onPlayerCommandPreprocess (PlayerCommandPreprocessEvent event) {
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
plugin.afkManager.onPlayerCommandPreprocess(event);
}
@EventHandler(ignoreCancelled=false,priority=EventPriority.HIGHEST)
public void onPlayerCommandPreprocess_Highest (PlayerCommandPreprocessEvent event) {
public void onPlayerCommandPreprocess_Highest(PlayerCommandPreprocessEvent event) {
plugin.commandAliasManager.onPlayerCommandPreprocess(event);
}
@EventHandler(ignoreCancelled=true,priority=EventPriority.HIGHEST)
public void onPlayerCommandPreprocess_Highest_IgnoreCancelled (PlayerCommandPreprocessEvent event) {
public void onPlayerCommandPreprocess_Highest_IgnoreCancelled(PlayerCommandPreprocessEvent event) {
plugin.chatAnalysisManager.onPlayerCommandPreprocess(event);
}

View File

@ -1,5 +1,7 @@
package net.mc_pandacraft.java.plugin.pandacraftutils.modules.fun;
import org.bukkit.ChatColor;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
@ -31,6 +33,15 @@ public class GhostManager {
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
if (!event.getPlayer().hasPermission("pandacraft.ghost")) return;
event.setFormat("<"+ChatColor.ITALIC+"%1$s"+ChatColor.RESET+"> "+ChatColor.ITALIC+"%2$s");
}

View File

@ -77,7 +77,7 @@ public class NoPvpProtectManager {
for (Player pl : pls)
{
// on ne compte pas le poseur (sinon, on y arrivera pas x) )
if (pl == p || pl.getGameMode() == GameMode.CREATIVE)
if (pl == p || !pl.isOnline() || pl.getGameMode() == GameMode.CREATIVE)
continue;
if (OnlinePlayerManager.get(pl).isVanished())
@ -119,7 +119,7 @@ public class NoPvpProtectManager {
for (Player pl : pls)
{
// on ne compte pas le poseur (sinon, on y arrivera pas x) )
if (pl == p || pl.getGameMode() == GameMode.CREATIVE)
if (pl == p || !pl.isOnline() || pl.getGameMode() == GameMode.CREATIVE)
continue;
if (OnlinePlayerManager.get(pl).isVanished())
@ -164,7 +164,7 @@ public class NoPvpProtectManager {
for (Player pl : pls)
{
// on ne compte pas le poseur (sinon, on y arrivera pas x) )
if (pl == p || pl.getGameMode() == GameMode.CREATIVE)
if (pl == p || !pl.isOnline() || pl.getGameMode() == GameMode.CREATIVE)
continue;
if (OnlinePlayerManager.get(pl).isVanished())
@ -204,7 +204,7 @@ public class NoPvpProtectManager {
for (Player pl : pls)
{
// on ne compte pas le poseur (sinon, on y arrivera pas x) ) et on ignorent ceux qui fly
if (pl == p || pl.isFlying())
if (pl == p || !pl.isOnline() || pl.isFlying())
continue;
if (OnlinePlayerManager.get(pl).isVanished())
@ -250,7 +250,7 @@ public class NoPvpProtectManager {
for (Player pl : pls)
{
// on ignore ceux en créatif
if (pl.getGameMode() == GameMode.CREATIVE)
if (pl == null || !pl.isOnline() || pl.getGameMode() == GameMode.CREATIVE)
continue;
if (OnlinePlayerManager.get(pl).isVanished())

View File

@ -94,10 +94,7 @@ public class OffPlayer {
* @return l'instance xAuth du joueur, ou null si aucune donnée n'est présente à propos du joueur
*/
public xAuthPlayer getXAuthPlayer() {
xAuthPlayer xAP = xAuth.getPlugin().getPlayerManager().getPlayer(playerName);
if (xAP.getAccountId() == -1)
return null;
return xAP;
return xAuth.getPlugin().getPlayerManager().getPlayer(playerName);
}