From dd11a5549731f36c7bcff6602c7ef131bbbf3b28 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Sun, 23 Nov 2014 00:28:17 +0100 Subject: [PATCH] =?UTF-8?q?On=20peut=20maintenant=20voir=20la=20s=C3=A9lec?= =?UTF-8?q?tion=20WorldEdit=20d'un=20autre=20joueur=20(quadrillage=20de=20?= =?UTF-8?q?flamme)=20+=20ajout=20d'une=20fonctionnalit=C3=A9=20dans=20le?= =?UTF-8?q?=20projet=20permettant=20d'empaqueter=20le=20.jar=20en=20quelqu?= =?UTF-8?q?es=20clics,=20avec=20la=20config=20toute=20faite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .classpath | 2 +- .settings/org.eclipse.jdt.core.prefs | 12 ++ make_jar.jardesc | 17 +++ resources/plugin.yml | 2 +- .../plugin/pandacraftutils/ConfigManager.java | 2 +- .../survival_cuboid/CommandWandSelection.java | 104 ++++++++++++++---- 6 files changed, 113 insertions(+), 26 deletions(-) create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 make_jar.jardesc diff --git a/.classpath b/.classpath index b5367d3..49ce456 100644 --- a/.classpath +++ b/.classpath @@ -2,11 +2,11 @@ - + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..d17b672 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/make_jar.jardesc b/make_jar.jardesc new file mode 100644 index 0000000..210127e --- /dev/null +++ b/make_jar.jardesc @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/resources/plugin.yml b/resources/plugin.yml index 6fe3efb..df56482 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: PandacraftUtils main: net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils -version: 2.1 +version: 2.2 diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java index 3ece9d1..6d8e501 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java @@ -14,7 +14,7 @@ public class ConfigManager { public static ConfigManager getInstance() { return instance; } - + @SuppressWarnings("unused") private PandacraftUtils plugin; public ConfigManager(File f, PandacraftUtils pl) { diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/survival_cuboid/CommandWandSelection.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/survival_cuboid/CommandWandSelection.java index e506974..0321808 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/survival_cuboid/CommandWandSelection.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/survival_cuboid/CommandWandSelection.java @@ -1,9 +1,10 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.survival_cuboid; import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; import net.mc_pandacraft.java.plugin.pandacraftutils.protocol.ParticleEffect; @@ -28,7 +29,7 @@ public class CommandWandSelection extends BukkitRunnable implements CommandExecu private PandacraftUtils plugin; - private List players = new LinkedList(); + private Map> players = new HashMap>(); @@ -40,7 +41,8 @@ public class CommandWandSelection extends BukkitRunnable implements CommandExecu plugin.getServer().getScheduler().runTaskTimer(plugin, this, 20L, 20L); plugin.getServer().getPluginManager().registerEvents(this, plugin); - players.addAll(Arrays.asList(plugin.getServer().getOnlinePlayers())); + for (Player p : plugin.getServer().getOnlinePlayers()) + players.put(p, new ArrayList()); } @@ -69,15 +71,47 @@ public class CommandWandSelection extends BukkitRunnable implements CommandExecu } Player p = (Player) sender; - if (players.contains(p)) + + + Player otherP = null; + if (args.length > 0) { + otherP = plugin.getServer().getPlayer(args[0]); + if (otherP == null) + { + sender.sendMessage(ChatColor.RED+"Le joueur indiqué n'existe pas"); + return true; + } + } + + + if (players.containsKey(p) && otherP == null) + { // le joueur ne veut plus voir de cubo players.remove(p); sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection désactivé."); } + else if (players.containsKey(p)) + { + if (players.get(p).contains(otherP)) + { + players.get(p).remove(otherP); + sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection de "+ChatColor.GRAY+otherP.getName()+ChatColor.GREEN+" désactivé."); + } + else + { + players.get(p).add(otherP); + sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection de "+ChatColor.GRAY+otherP.getName()+ChatColor.GREEN+" activé."); + } + + } else { - players.add(p); + players.put(p, new ArrayList()); sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection activé. Si vous ne voyez pas les particules, activez les dans vos options Minecraft."); + if (otherP != null) { + players.get(p).add(otherP); + sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection de "+ChatColor.GRAY+otherP.getName()+ChatColor.GREEN+" activé."); + } } return true; @@ -88,7 +122,7 @@ public class CommandWandSelection extends BukkitRunnable implements CommandExecu @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { - if (players.contains(event.getPlayer())) + if (players.containsKey(event.getPlayer())) players.remove(event.getPlayer()); } @@ -96,8 +130,8 @@ public class CommandWandSelection extends BukkitRunnable implements CommandExecu @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { - if (!players.contains(event.getPlayer())) - players.add(event.getPlayer()); + if (!players.containsKey(event.getPlayer())) + players.put(event.getPlayer(), new ArrayList()); } @@ -106,29 +140,35 @@ public class CommandWandSelection extends BukkitRunnable implements CommandExecu @Override public void run() { - WorldEditPlugin wePlugin = (WorldEditPlugin) plugin.getServer().getPluginManager().getPlugin("WorldEdit"); - if (wePlugin == null) return; try { - for (Player p : players) + for (Entry> pl : players.entrySet()) { + Player p = pl.getKey(); // on vérifie que le joueur soit en ligne if (p == null || !p.isOnline()) continue; - Selection sel = wePlugin.getSelection(p); - // on garde que les cuboïdes (pas les autres formes) - if (!(sel instanceof CuboidSelection)) - continue; - CuboidSelection cubo = (CuboidSelection) sel; + CuboidSelection cubo = getPlayerCuboSelection(p); // le joueur doit être dans le même monde que sa propre sélection - if (cubo.getWorld() != p.getWorld()) + if (cubo != null && cubo.getWorld() == p.getWorld()) + drawCuboid(cubo, p, true); + + if (pl.getValue() == null) continue; - drawCuboid(cubo, p); + for (Player po : pl.getValue()){ + if (po == null || !po.isOnline()) continue; + + cubo = getPlayerCuboSelection(po); + + if (cubo != null && cubo.getWorld() == p.getWorld()) + drawCuboid(cubo, p, false); + } + } } catch (Exception e) { e.printStackTrace(); } @@ -140,7 +180,21 @@ public class CommandWandSelection extends BukkitRunnable implements CommandExecu - private void drawCuboid(CuboidSelection cubo, Player p) + private CuboidSelection getPlayerCuboSelection(Player p) { + WorldEditPlugin wePlugin = (WorldEditPlugin) plugin.getServer().getPluginManager().getPlugin("WorldEdit"); + if (wePlugin == null) return null; + Selection sel = wePlugin.getSelection(p); + if (sel == null) return null; + // on garde que les cuboïdes (pas les autres formes) + if (!(sel instanceof CuboidSelection)) + return null; + return (CuboidSelection) sel; + + } + + + + private void drawCuboid(CuboidSelection cubo, Player p, boolean self) { List pls = new ArrayList(1); pls.add(p); @@ -166,9 +220,13 @@ public class CommandWandSelection extends BukkitRunnable implements CommandExecu if (!(i == x1 || i == x2 || j == y1 || j == y2 || k == z1 || k == z2)) continue; Location l = new Location(p1.getWorld(), i, j, k); - if (l.distanceSquared(p.getLocation()) < distance*distance) - ParticleEffect.HAPPY_VILLAGER - .display(offset, offset, offset, 0F, 1, l, pls); + if (l.distanceSquared(p.getLocation()) < distance*distance){ + if (self) + ParticleEffect.HAPPY_VILLAGER.display(offset, offset, offset, 0F, 1, l, pls); + else + ParticleEffect.FLAME.display(offset, offset, offset, 0F, 5, l, pls); + } + } }