On peut maintenant voir la sélection WorldEdit d'un autre joueur (quadrillage de flamme) + ajout d'une fonctionnalité dans le projet permettant d'empaqueter le .jar en quelques clics, avec la config toute faite

This commit is contained in:
Marc Baloup 2014-11-23 00:28:17 +01:00
parent f7c9962e89
commit dd11a55497
6 changed files with 113 additions and 26 deletions

View File

@ -2,11 +2,11 @@
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="resources"/> <classpathentry kind="src" path="resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/bukkit-1.7.2-R0.3.jar"/> <classpathentry kind="lib" path="lib/bukkit-1.7.2-R0.3.jar"/>
<classpathentry kind="lib" path="lib/craftbukkit-1.7.2-R0.3.jar"/> <classpathentry kind="lib" path="lib/craftbukkit-1.7.2-R0.3.jar"/>
<classpathentry kind="lib" path="lib/fanciful-0.1.5.jar"/> <classpathentry kind="lib" path="lib/fanciful-0.1.5.jar"/>
<classpathentry kind="lib" path="lib/ProtocolLib-3.2.0.jar"/> <classpathentry kind="lib" path="lib/ProtocolLib-3.2.0.jar"/>
<classpathentry kind="lib" path="lib/WorldEdit-5.6.jar"/> <classpathentry kind="lib" path="lib/WorldEdit-5.6.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_67"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -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

17
make_jar.jardesc Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jardesc>
<jar path="PandacraftUtils/jar_export/PandacraftUtils-2.2.jar"/>
<options buildIfNeeded="true" compress="true" descriptionLocation="/PandacraftUtils/make_jar.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
<selectedProjects/>
<manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
<sealing sealJar="false">
<packagesToSeal/>
<packagesToUnSeal/>
</sealing>
</manifest>
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
<javaElement handleIdentifier="=PandacraftUtils/resources"/>
<javaElement handleIdentifier="=PandacraftUtils/src"/>
</selectedElements>
</jardesc>

View File

@ -1,6 +1,6 @@
name: PandacraftUtils name: PandacraftUtils
main: net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils main: net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils
version: 2.1 version: 2.2

View File

@ -14,7 +14,7 @@ public class ConfigManager {
public static ConfigManager getInstance() { return instance; } public static ConfigManager getInstance() { return instance; }
@SuppressWarnings("unused")
private PandacraftUtils plugin; private PandacraftUtils plugin;
public ConfigManager(File f, PandacraftUtils pl) { public ConfigManager(File f, PandacraftUtils pl) {

View File

@ -1,9 +1,10 @@
package net.mc_pandacraft.java.plugin.pandacraftutils.survival_cuboid; package net.mc_pandacraft.java.plugin.pandacraftutils.survival_cuboid;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.HashMap;
import java.util.LinkedList;
import java.util.List; 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.PandacraftUtils;
import net.mc_pandacraft.java.plugin.pandacraftutils.protocol.ParticleEffect; import net.mc_pandacraft.java.plugin.pandacraftutils.protocol.ParticleEffect;
@ -28,7 +29,7 @@ public class CommandWandSelection extends BukkitRunnable implements CommandExecu
private PandacraftUtils plugin; private PandacraftUtils plugin;
private List<Player> players = new LinkedList<Player>(); private Map<Player, List<Player>> players = new HashMap<Player, List<Player>>();
@ -40,7 +41,8 @@ public class CommandWandSelection extends BukkitRunnable implements CommandExecu
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 20L, 20L); plugin.getServer().getScheduler().runTaskTimer(plugin, this, 20L, 20L);
plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getServer().getPluginManager().registerEvents(this, plugin);
players.addAll(Arrays.asList(plugin.getServer().getOnlinePlayers())); for (Player p : plugin.getServer().getOnlinePlayers())
players.put(p, new ArrayList<Player>());
} }
@ -69,15 +71,47 @@ public class CommandWandSelection extends BukkitRunnable implements CommandExecu
} }
Player p = (Player) sender; 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); players.remove(p);
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection désactivé."); 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 else
{ {
players.add(p); players.put(p, new ArrayList<Player>());
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection activé. Si vous ne voyez pas les particules, activez les dans vos options Minecraft."); 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; return true;
@ -88,7 +122,7 @@ public class CommandWandSelection extends BukkitRunnable implements CommandExecu
@EventHandler @EventHandler
public void onPlayerQuit(PlayerQuitEvent event) public void onPlayerQuit(PlayerQuitEvent event)
{ {
if (players.contains(event.getPlayer())) if (players.containsKey(event.getPlayer()))
players.remove(event.getPlayer()); players.remove(event.getPlayer());
} }
@ -96,8 +130,8 @@ public class CommandWandSelection extends BukkitRunnable implements CommandExecu
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) public void onPlayerJoin(PlayerJoinEvent event)
{ {
if (!players.contains(event.getPlayer())) if (!players.containsKey(event.getPlayer()))
players.add(event.getPlayer()); players.put(event.getPlayer(), new ArrayList<Player>());
} }
@ -106,29 +140,35 @@ public class CommandWandSelection extends BukkitRunnable implements CommandExecu
@Override @Override
public void run() { public void run() {
WorldEditPlugin wePlugin = (WorldEditPlugin) plugin.getServer().getPluginManager().getPlugin("WorldEdit");
if (wePlugin == null) return;
try try
{ {
for (Player p : players) for (Entry<Player, List<Player>> pl : players.entrySet())
{ {
Player p = pl.getKey();
// on vérifie que le joueur soit en ligne // on vérifie que le joueur soit en ligne
if (p == null || !p.isOnline()) if (p == null || !p.isOnline())
continue; continue;
Selection sel = wePlugin.getSelection(p); CuboidSelection cubo = getPlayerCuboSelection(p);
// on garde que les cuboïdes (pas les autres formes)
if (!(sel instanceof CuboidSelection))
continue;
CuboidSelection cubo = (CuboidSelection) sel;
// le joueur doit être dans le même monde que sa propre sélection // 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; 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(); } 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<Player> pls = new ArrayList<Player>(1); List<Player> pls = new ArrayList<Player>(1);
pls.add(p); 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)) if (!(i == x1 || i == x2 || j == y1 || j == y2 || k == z1 || k == z2))
continue; continue;
Location l = new Location(p1.getWorld(), i, j, k); Location l = new Location(p1.getWorld(), i, j, k);
if (l.distanceSquared(p.getLocation()) < distance*distance) if (l.distanceSquared(p.getLocation()) < distance*distance){
ParticleEffect.HAPPY_VILLAGER if (self)
.display(offset, offset, offset, 0F, 1, l, pls); ParticleEffect.HAPPY_VILLAGER.display(offset, offset, offset, 0F, 1, l, pls);
else
ParticleEffect.FLAME.display(offset, offset, offset, 0F, 5, l, pls);
}
} }
} }