Ajout du gestionnaire de protection de la map survie (/cubo)
This commit is contained in:
parent
f9a49ff2ee
commit
2681c3a47f
@ -2,7 +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="lib" path="lib/bukkit-1.7.2-R0.3.jar"/>
|
<classpathentry kind="lib" path="lib/bukkit-1.7.2-R0.3.jar">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="javadoc_location" value="http://jd.bukkit.org/beta/apidocs/"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<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"/>
|
||||||
@ -10,5 +14,6 @@
|
|||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
<classpathentry kind="lib" path="lib/PandacraftAuth.jar" sourcepath="R:/Dropbox/wspace_java_minecraft/xAuth.src"/>
|
<classpathentry kind="lib" path="lib/PandacraftAuth.jar" sourcepath="R:/Dropbox/wspace_java_minecraft/xAuth.src"/>
|
||||||
<classpathentry kind="lib" path="lib/Essentials-Pre2.13.1.2.jar"/>
|
<classpathentry kind="lib" path="lib/Essentials-Pre2.13.1.2.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/worldguard-5.9.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
BIN
lib/worldguard-5.9.jar
Normal file
BIN
lib/worldguard-5.9.jar
Normal file
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<jardesc>
|
<jardesc>
|
||||||
<jar path="PandacraftUtils/jar_export/PandacraftUtils-2.8.jar"/>
|
<jar path="PandacraftUtils/jar_export/PandacraftUtils-2.9.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"/>
|
<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"/>
|
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
|
||||||
<selectedProjects/>
|
<selectedProjects/>
|
||||||
|
@ -26,3 +26,10 @@ chatAnalysis:
|
|||||||
maxViolationLevel: 20
|
maxViolationLevel: 20
|
||||||
nbSecondForOneVLDown: 10
|
nbSecondForOneVLDown: 10
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cubos:
|
||||||
|
# séparé avec des point-virgules
|
||||||
|
worlds: Survival
|
||||||
|
|
||||||
|
@ -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.8
|
version: 2.9
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -50,6 +50,10 @@ commands:
|
|||||||
description: Gère la file d'attente de joueurs qui ont besoin de l'assitance du staff
|
description: Gère la file d'attente de joueurs qui ont besoin de l'assitance du staff
|
||||||
usage: /staff [annuler|<Message>]
|
usage: /staff [annuler|<Message>]
|
||||||
permission: pandacraft.staff
|
permission: pandacraft.staff
|
||||||
|
cubo:
|
||||||
|
description: Gère les protections de la map Survie
|
||||||
|
usage: /cubo
|
||||||
|
permission: pandacraft.cubo
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -93,6 +97,12 @@ permissions:
|
|||||||
description: Utiliser la commande staff
|
description: Utiliser la commande staff
|
||||||
default: true
|
default: true
|
||||||
|
|
||||||
|
pandacraft.cubo:
|
||||||
|
description: Utiliser la commande cubo
|
||||||
|
default: true
|
||||||
|
pandacraft.cubo.staff:
|
||||||
|
description: Donne le droit de gérer tout les cubos des joueurs
|
||||||
|
|
||||||
pandacraft.afk:
|
pandacraft.afk:
|
||||||
description: Utiliser la commande afk
|
description: Utiliser la commande afk
|
||||||
default: true
|
default: true
|
||||||
|
@ -2,6 +2,7 @@ package net.mc_pandacraft.java.plugin.pandacraftutils;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -28,6 +29,8 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static void reloadConfig() {
|
public synchronized static void reloadConfig() {
|
||||||
|
if (instance != null)
|
||||||
|
PandacraftUtils.getInstance().reloadConfig();
|
||||||
instance = null;
|
instance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +79,7 @@ public class ConfigManager {
|
|||||||
ChatAnalysis_maxViolationLevel = configFile.getInt("chatAnalysis.maxViolationLevel");
|
ChatAnalysis_maxViolationLevel = configFile.getInt("chatAnalysis.maxViolationLevel");
|
||||||
ChatAnalysis_nbSecondForOneVLDown = configFile.getInt("chatAnalysis.nbSecondForOneVLDown");
|
ChatAnalysis_nbSecondForOneVLDown = configFile.getInt("chatAnalysis.nbSecondForOneVLDown");
|
||||||
|
|
||||||
|
CuboCommand_worlds = Arrays.asList(configFile.getString("cubos.worlds").split(";"));
|
||||||
|
|
||||||
|
|
||||||
initChatAnalysisBadWord();
|
initChatAnalysisBadWord();
|
||||||
@ -223,4 +226,19 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public List<String> CuboCommand_worlds = new ArrayList<String>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.setblock.Co
|
|||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.speed_message.CommandSpeedMessage;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.speed_message.CommandSpeedMessage;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.staff_player_help.CommandStaff;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.staff_player_help.CommandStaff;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.spawntime.SpawnTimeManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.spawntime.SpawnTimeManager;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.survival_cuboid.CommandCubo;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.survival_cuboid.CommandWandSelection;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.survival_cuboid.CommandWandSelection;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.system_analyzer.CommandSystem;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.system_analyzer.CommandSystem;
|
||||||
import net.mc_pandacraft.java.util.mysql.DBConnection;
|
import net.mc_pandacraft.java.util.mysql.DBConnection;
|
||||||
@ -40,6 +41,7 @@ public class PandacraftUtils extends JavaPlugin {
|
|||||||
public CommandSpeedMessage commandSpeedMessage;
|
public CommandSpeedMessage commandSpeedMessage;
|
||||||
public CommandWandSelection commandWandSelection;
|
public CommandWandSelection commandWandSelection;
|
||||||
public CommandStaff commandStaff;
|
public CommandStaff commandStaff;
|
||||||
|
public CommandCubo commandCubo;
|
||||||
|
|
||||||
public CommandAliasManager commandAliasManager;
|
public CommandAliasManager commandAliasManager;
|
||||||
public SpawnTimeManager spawnTimeManager;
|
public SpawnTimeManager spawnTimeManager;
|
||||||
@ -77,6 +79,7 @@ public class PandacraftUtils extends JavaPlugin {
|
|||||||
commandSpeedMessage = new CommandSpeedMessage(this); // messages rapides
|
commandSpeedMessage = new CommandSpeedMessage(this); // messages rapides
|
||||||
commandWandSelection = new CommandWandSelection(this);
|
commandWandSelection = new CommandWandSelection(this);
|
||||||
commandStaff = new CommandStaff(this);
|
commandStaff = new CommandStaff(this);
|
||||||
|
commandCubo = new CommandCubo(this);
|
||||||
|
|
||||||
commandAliasManager = new CommandAliasManager(this);
|
commandAliasManager = new CommandAliasManager(this);
|
||||||
spawnTimeManager = new SpawnTimeManager(this);
|
spawnTimeManager = new SpawnTimeManager(this);
|
||||||
@ -109,6 +112,8 @@ public class PandacraftUtils extends JavaPlugin {
|
|||||||
|
|
||||||
serverPingListener = null;
|
serverPingListener = null;
|
||||||
|
|
||||||
|
ConfigManager.reloadConfig();
|
||||||
|
|
||||||
|
|
||||||
try { databaseConnection.getConnection().close(); } catch (SQLException e) { }
|
try { databaseConnection.getConnection().close(); } catch (SQLException e) { }
|
||||||
}
|
}
|
||||||
|
@ -5,31 +5,50 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.earth2me.essentials.Essentials;
|
import com.earth2me.essentials.Essentials;
|
||||||
|
import com.earth2me.essentials.User;
|
||||||
|
|
||||||
public class EssentialsInterface {
|
public class EssentialsInterface {
|
||||||
|
|
||||||
|
public static Essentials getPlugin() {
|
||||||
|
try {
|
||||||
|
return (Essentials) PandacraftUtils.getInstance().getServer().getPluginManager().getPlugin("Essentials");
|
||||||
|
} catch (Exception e) { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static User getPlayer(Player p) {
|
||||||
|
try {
|
||||||
|
return getPlugin().getUser(p);
|
||||||
|
} catch (Exception e) { }
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isPlayerVanished(Player p) {
|
public static boolean isPlayerVanished(Player p) {
|
||||||
try {
|
try {
|
||||||
return ((Essentials)PandacraftUtils.getInstance().getServer().getPluginManager().getPlugin("Essentials")).getUser(p).isVanished();
|
return getPlayer(p).isVanished();
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) { }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canPlayerSeeVanishedPlayer(Player p, Player hiddenP) {
|
public static boolean canPlayerSeeVanishedPlayer(Player p, Player hiddenP) {
|
||||||
try {
|
try {
|
||||||
Essentials ess = (Essentials)PandacraftUtils.getInstance().getServer().getPluginManager().getPlugin("Essentials");
|
return getPlugin().getUser(p).canSee(hiddenP);
|
||||||
|
|
||||||
return ess.getUser(p).canSee(hiddenP);
|
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) { }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPlayerMuted(Player p) {
|
public static boolean isPlayerMuted(Player p) {
|
||||||
try {
|
try {
|
||||||
return ((Essentials)PandacraftUtils.getInstance().getServer().getPluginManager().getPlugin("Essentials")).getUser(p).isMuted();
|
return getPlugin().getUser(p).isMuted();
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) { }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static double getPlayerMoney(Player p) {
|
||||||
|
try {
|
||||||
|
return getPlugin().getUser(p).getMoney().doubleValue();
|
||||||
|
} catch (Exception e) { }
|
||||||
|
return Double.NaN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
package net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface;
|
||||||
|
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||||
|
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||||
|
|
||||||
|
public class WorldEditInterface {
|
||||||
|
|
||||||
|
public static WorldEditPlugin getPlugin() {
|
||||||
|
try {
|
||||||
|
return (WorldEditPlugin) PandacraftUtils.getInstance().getServer().getPluginManager().getPlugin("WorldEdit");
|
||||||
|
} catch (Exception e) { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static CuboidSelection getPlayerCuboSelection(Player p) {
|
||||||
|
WorldEditPlugin wePlugin = getPlugin();
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,794 @@
|
|||||||
|
package net.mc_pandacraft.java.plugin.pandacraftutils.survival_cuboid;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.WorldEditInterface;
|
||||||
|
import net.mc_pandacraft.java.util.StringUtil;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||||
|
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||||
|
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
|
||||||
|
import com.sk89q.worldguard.protection.databases.ProtectionDatabaseException;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
|
public class CommandCubo implements CommandExecutor {
|
||||||
|
|
||||||
|
private PandacraftUtils plugin;
|
||||||
|
|
||||||
|
private WorldGuardPlugin wgPlugin;
|
||||||
|
|
||||||
|
private String regex_cubo_id = "cubo[0-9]+-[0-9A-Za-z_]+-[0-9A-Za-z_]+";
|
||||||
|
|
||||||
|
public CommandCubo(PandacraftUtils pl) {
|
||||||
|
plugin = pl;
|
||||||
|
|
||||||
|
|
||||||
|
Plugin wg = plugin.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||||
|
|
||||||
|
// WorldGuard may not be loaded
|
||||||
|
if (wg == null || !(wg instanceof WorldGuardPlugin)) {
|
||||||
|
try { throw new Exception("Impossible de récupérer l'instance du plugin WorldGuard");
|
||||||
|
} catch (Exception e) { e.printStackTrace(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
wgPlugin = (WorldGuardPlugin) wg;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command,
|
||||||
|
String label, String[] args) {
|
||||||
|
|
||||||
|
if (args.length == 0 || !(sender instanceof Player))
|
||||||
|
{
|
||||||
|
showHelp(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// la commande contient au moins un paramètre et la personne qui fait la commande est un Joueur
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
// on vérifie que le joueur se trouve bien dans un monde dans lequel on peut cubo
|
||||||
|
if (!ConfigManager.getInstance().CuboCommand_worlds.contains(player.getWorld().getName()))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Les cubos ne se font pas sur cette map");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("devis"))
|
||||||
|
{
|
||||||
|
CuboidSelection selection = WorldEditInterface.getPlayerCuboSelection(player);
|
||||||
|
if (selection == null)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Vous devez faire une sélection WorldEdit : faites "+ChatColor.GRAY+"//wand");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasStaffPermission(player) && args.length >= 3 && plugin.getServer().getPlayer(args[2]) == null)
|
||||||
|
{ // un joueur est indiqué mais il n'est pas connecté
|
||||||
|
player.sendMessage(ChatColor.RED+"Le joueur concerné n'est pas en ligne");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// on cherche si on traite un autre joueur
|
||||||
|
Player player_cubo;
|
||||||
|
if (!hasStaffPermission(player) || args.length < 2 || (player_cubo = plugin.getServer().getPlayer(args[1])) == null)
|
||||||
|
player_cubo = player;
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.GOLD+"----- Devis pour la création d'un cubo -----");
|
||||||
|
if (player != player_cubo)
|
||||||
|
player_cubo.sendMessage(ChatColor.GOLD+"----- Devis pour la création d'un cubo -----");
|
||||||
|
|
||||||
|
// vérifie si la sélection interfère avec un cubo existant
|
||||||
|
// on crée un cubo factice (qui ne sera pas enregistré)
|
||||||
|
ProtectedCuboidRegion cubo = new ProtectedCuboidRegion("null", selection.getNativeMinimumPoint().toBlockVector(), selection.getNativeMaximumPoint().toBlockVector());
|
||||||
|
// on récupère les cubos de la map pour les comparer
|
||||||
|
Collection<ProtectedRegion> regions = wgPlugin.getRegionManager(selection.getWorld()).getRegions().values();
|
||||||
|
boolean intersect = true;
|
||||||
|
List<ProtectedRegion> intersect_region = null;
|
||||||
|
try {
|
||||||
|
intersect_region = ((ProtectedRegion)cubo).getIntersectingRegions(Arrays.asList(regions.toArray(new ProtectedRegion[1])));
|
||||||
|
if (intersect_region.size()==0) intersect = false;
|
||||||
|
} catch (UnsupportedIntersectionException e) { }
|
||||||
|
|
||||||
|
if (intersect)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"La sélection rentre en contact avec au moins un cubo existant");
|
||||||
|
if (player != player_cubo)
|
||||||
|
player_cubo.sendMessage(ChatColor.RED+"La sélection rentre en contact avec au moins un cubo existant");
|
||||||
|
if (intersect_region != null)
|
||||||
|
{
|
||||||
|
for(ProtectedRegion region : intersect_region)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"- "+ChatColor.GRAY+region.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player != player_cubo)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GOLD+"Pour le joueur "+ChatColor.RESET+player_cubo.getDisplayName());
|
||||||
|
player_cubo.sendMessage(ChatColor.GOLD+"Devis fait par "+ChatColor.RESET+player.getDisplayName());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// on vérifie si le joueur peut payer
|
||||||
|
double actual_money = EssentialsInterface.getPlayerMoney(player_cubo);
|
||||||
|
|
||||||
|
int volume_actuel_cubo = getPlayerActualBlockCount(player_cubo, selection.getWorld());
|
||||||
|
int volume_apres_cubo = volume_actuel_cubo + cubo.volume();
|
||||||
|
double prix_actuel_cubo = getVolumePrice(volume_actuel_cubo);
|
||||||
|
double prix_apres_cubo = getVolumePrice(volume_apres_cubo);
|
||||||
|
double prix_a_payer = prix_apres_cubo - prix_actuel_cubo;
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.GOLD+"Solde actuel : "+StringUtil.formatDouble(actual_money));
|
||||||
|
player.sendMessage(ChatColor.GOLD+"Prix à payer : "+StringUtil.formatDouble(prix_a_payer));
|
||||||
|
player.sendMessage(ChatColor.GOLD+"Solde futur : "+StringUtil.formatDouble(actual_money - prix_a_payer));
|
||||||
|
|
||||||
|
if (player != player_cubo)
|
||||||
|
{
|
||||||
|
player_cubo.sendMessage(ChatColor.GOLD+"Solde actuel : "+StringUtil.formatDouble(actual_money));
|
||||||
|
player_cubo.sendMessage(ChatColor.GOLD+"Prix à payer : "+StringUtil.formatDouble(prix_a_payer));
|
||||||
|
player_cubo.sendMessage(ChatColor.GOLD+"Futur solde : "+StringUtil.formatDouble(actual_money - prix_a_payer));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (actual_money - prix_a_payer < 0)
|
||||||
|
{
|
||||||
|
// le joueur ne peut pas payer
|
||||||
|
if (player == player_cubo)
|
||||||
|
player.sendMessage(ChatColor.RED+"Vous ne pouvez pas payer");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
player.sendMessage(player_cubo.getDisplayName()+ChatColor.RED+" ne peut pas payer");
|
||||||
|
player_cubo.sendMessage(ChatColor.RED+"Vous ne pouvez pas payer");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("creer") && args.length >= 2)
|
||||||
|
{
|
||||||
|
String nom_cubo = args[1];
|
||||||
|
|
||||||
|
if (!nom_cubo.matches("[0-9a-zA-Z_]+"))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Le nom du cubo n'est pas valide : il doit contenir des lettres/chiffres et tiret du bas "+ChatColor.GRAY+"_");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CuboidSelection selection = WorldEditInterface.getPlayerCuboSelection(player);
|
||||||
|
if (selection == null)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Vous devez faire une sélection WorldEdit : faites "+ChatColor.GRAY+"//wand");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (hasStaffPermission(player) && args.length >= 3 && plugin.getServer().getPlayer(args[2]) == null)
|
||||||
|
{ // un joueur est indiqué mais il n'est pas connecté
|
||||||
|
player.sendMessage(ChatColor.RED+"Le joueur concerné n'est pas en ligne");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// on cherche si on traite un autre joueur
|
||||||
|
Player player_cubo;
|
||||||
|
if (!hasStaffPermission(player) || args.length < 3 || (player_cubo = plugin.getServer().getPlayer(args[2])) == null)
|
||||||
|
player_cubo = player;
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.GOLD+"----- Création d'un cubo -----");
|
||||||
|
if (player != player_cubo)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GOLD+"Pour le joueur "+ChatColor.RESET+player_cubo.getDisplayName());
|
||||||
|
|
||||||
|
player_cubo.sendMessage(ChatColor.GOLD+"----- Création d'un cubo -----");
|
||||||
|
player_cubo.sendMessage(ChatColor.GOLD+"Protection faite par "+ChatColor.RESET+player.getDisplayName());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// vérifie si la sélection interfère avec un cubo existant
|
||||||
|
|
||||||
|
// on crée le cubo
|
||||||
|
String id_cubo;
|
||||||
|
do
|
||||||
|
id_cubo = "cubo"+(new Random()).nextInt(1000000000)+"-"+player_cubo.getName()+"-"+nom_cubo;
|
||||||
|
while(wgPlugin.getRegionManager(selection.getWorld()).hasRegion(id_cubo));
|
||||||
|
ProtectedCuboidRegion cubo = new ProtectedCuboidRegion(id_cubo, selection.getNativeMinimumPoint().toBlockVector(), selection.getNativeMaximumPoint().toBlockVector());
|
||||||
|
DefaultDomain owners = new DefaultDomain();
|
||||||
|
owners.addPlayer(player_cubo.getName());
|
||||||
|
cubo.setOwners(owners);
|
||||||
|
|
||||||
|
|
||||||
|
// on récupère les cubos de la map pour les comparer
|
||||||
|
Collection<ProtectedRegion> regions = wgPlugin.getRegionManager(selection.getWorld()).getRegions().values();
|
||||||
|
boolean intersect = true;
|
||||||
|
List<ProtectedRegion> intersect_region = null;
|
||||||
|
try {
|
||||||
|
intersect_region = ((ProtectedRegion)cubo).getIntersectingRegions(Arrays.asList(regions.toArray(new ProtectedRegion[1])));
|
||||||
|
if (intersect_region.size()==0) intersect = false;
|
||||||
|
} catch (UnsupportedIntersectionException e) { }
|
||||||
|
|
||||||
|
if (intersect)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"La protection ne peut pas se faire");
|
||||||
|
player.sendMessage(ChatColor.RED+"Faites "+ChatColor.GRAY+"/cubo devis"+ChatColor.RED+" pour en connaitre la raison");
|
||||||
|
if (player != player_cubo)
|
||||||
|
player_cubo.sendMessage(ChatColor.RED+"La protection ne peut pas se faire");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// on vérifie si le joueur peut payer
|
||||||
|
double actual_money = EssentialsInterface.getPlayerMoney(player_cubo);
|
||||||
|
|
||||||
|
int volume_actuel_cubo = getPlayerActualBlockCount(player_cubo, selection.getWorld());
|
||||||
|
int volume_apres_cubo = volume_actuel_cubo + cubo.volume();
|
||||||
|
double prix_actuel_cubo = getVolumePrice(volume_actuel_cubo);
|
||||||
|
double prix_apres_cubo = getVolumePrice(volume_apres_cubo);
|
||||||
|
double prix_a_payer = prix_apres_cubo - prix_actuel_cubo;
|
||||||
|
|
||||||
|
|
||||||
|
if (actual_money - prix_a_payer < 0)
|
||||||
|
{
|
||||||
|
// le joueur ne peut pas payer
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.RED+"La protection ne peut pas se faire");
|
||||||
|
player.sendMessage(ChatColor.RED+"Faites "+ChatColor.GRAY+"/cubo devis"+ChatColor.RED+" pour en connaitre la raison");
|
||||||
|
if (player != player_cubo)
|
||||||
|
player_cubo.sendMessage(ChatColor.RED+"La protection ne peut pas se faire");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
player_cubo.sendMessage(ChatColor.GOLD+"Ancien solde : "+StringUtil.formatDouble(actual_money));
|
||||||
|
player_cubo.sendMessage(ChatColor.GOLD+"Prix à payer : "+StringUtil.formatDouble(prix_a_payer));
|
||||||
|
player_cubo.sendMessage(ChatColor.GOLD+"Nouveau solde : "+StringUtil.formatDouble(actual_money - prix_a_payer));
|
||||||
|
player_cubo.sendMessage(ChatColor.GREEN+"L'argent est automatiquement retiré de votre compte");
|
||||||
|
if (player != player_cubo)
|
||||||
|
player.sendMessage(ChatColor.GREEN+"L'argent est automatiquement retiré du compte de "+ChatColor.RESET+player_cubo.getDisplayName());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// on crée le cubo :
|
||||||
|
wgPlugin.getRegionManager(selection.getWorld()).addRegion(cubo);
|
||||||
|
player.sendMessage(ChatColor.GREEN+"La protection "+ChatColor.GRAY+cubo.getId()+ChatColor.GREEN+" a bien été réalisée");
|
||||||
|
if (player != player_cubo)
|
||||||
|
player_cubo.sendMessage(ChatColor.GREEN+"La protection "+ChatColor.GRAY+cubo.getId()+ChatColor.GREEN+" a bien été réalisée");
|
||||||
|
|
||||||
|
// on retire l'argent
|
||||||
|
EssentialsInterface.getPlayer(player_cubo).setMoney(new BigDecimal(actual_money - prix_a_payer));
|
||||||
|
EssentialsInterface.getPlayer(player_cubo).save();
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("liste"))
|
||||||
|
{
|
||||||
|
int num_page = 1;
|
||||||
|
try {
|
||||||
|
if (args.length >= 2)
|
||||||
|
num_page = Integer.parseInt(args[1]);
|
||||||
|
} catch (NumberFormatException e) { }
|
||||||
|
|
||||||
|
// on cherche si on traite un autre joueur
|
||||||
|
String player_cubo = player.getName();
|
||||||
|
if (hasStaffPermission(player) && args.length >= 3)
|
||||||
|
player_cubo = args[2];
|
||||||
|
|
||||||
|
|
||||||
|
List<ProtectedCuboidRegion> cubos = getPlayerCubo(player_cubo, player.getWorld());
|
||||||
|
|
||||||
|
int nb_page = (int)Math.ceil(cubos.size()/5D);
|
||||||
|
if (num_page > nb_page) num_page = nb_page;
|
||||||
|
if (num_page < 1) num_page = 1;
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.GOLD+"----- Liste des cubos de "+ChatColor.GRAY+player_cubo+ChatColor.GOLD+" -----");
|
||||||
|
if (cubos.size() == 0)
|
||||||
|
player.sendMessage(ChatColor.GOLD+"Aucun cubo à afficher");
|
||||||
|
|
||||||
|
for (int i=(num_page-1)*5; i<num_page*5 && i<cubos.size(); i++)
|
||||||
|
{
|
||||||
|
ProtectedCuboidRegion cubo = cubos.get(i);
|
||||||
|
// TODO afficher plus d'infos sur ces cubos
|
||||||
|
player.sendMessage(ChatColor.GOLD+cubo.getId()+" : "+cubo.volume()+" cubes");
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.GOLD+"---------- Page "+num_page+"/"+nb_page+" ----------");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Dans la suite des sous-commandes, on a besoin de la protection dans le quel se trouve le joueur
|
||||||
|
*
|
||||||
|
* Si ce cubo n'existe pas, le reste des sous-commandes n'est pas exécutable
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// on parcours les cubos dans lesquels on se trouve, on garde le premier valide, si il existe
|
||||||
|
ProtectedCuboidRegion inside_cubo = null;
|
||||||
|
for(ProtectedRegion cubo : wgPlugin.getRegionManager(player.getWorld()).getApplicableRegions(player.getLocation()))
|
||||||
|
{
|
||||||
|
if (!(cubo instanceof ProtectedCuboidRegion)) continue;
|
||||||
|
if (!cubo.getId().matches(regex_cubo_id)) continue;
|
||||||
|
inside_cubo = (ProtectedCuboidRegion) cubo;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("info"))
|
||||||
|
{
|
||||||
|
if (inside_cubo == null)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Vous ne vous trouvez dans aucun cubo");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dim_x = inside_cubo.getMinimumPoint().getBlockX() + inside_cubo.getMaximumPoint().getBlockX() + 1;
|
||||||
|
int dim_y = inside_cubo.getMinimumPoint().getBlockY() + inside_cubo.getMaximumPoint().getBlockY() + 1;
|
||||||
|
int dim_z = inside_cubo.getMinimumPoint().getBlockZ() + inside_cubo.getMaximumPoint().getBlockZ() + 1;
|
||||||
|
Vector midpoint = Vector.getMidpoint(inside_cubo.getMinimumPoint(), inside_cubo.getMaximumPoint());
|
||||||
|
String proprio = inside_cubo.getOwners().toUserFriendlyString();
|
||||||
|
String membres = inside_cubo.getMembers().toUserFriendlyString();
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.GOLD+"----- Information sur la protection -----");
|
||||||
|
player.sendMessage(ChatColor.GOLD+"Identifiant : "+ChatColor.GRAY+inside_cubo.getId());
|
||||||
|
player.sendMessage(ChatColor.GOLD+"Dimensions : "+ChatColor.GRAY+"x="+dim_x+" y="+dim_y+" z="+dim_z);
|
||||||
|
player.sendMessage(ChatColor.GOLD+"Localisation : "+ChatColor.GRAY+"x="+midpoint.getBlockX()+" y="+midpoint.getBlockY()+" z="+midpoint.getBlockZ());
|
||||||
|
player.sendMessage(ChatColor.GOLD+"Volume : "+ChatColor.GRAY+inside_cubo.volume());
|
||||||
|
player.sendMessage(ChatColor.GOLD+"Propriétaire : "+ChatColor.GRAY+proprio);
|
||||||
|
player.sendMessage(ChatColor.GOLD+"Usagers : "+ChatColor.GRAY+membres);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("selectionner"))
|
||||||
|
{
|
||||||
|
if (inside_cubo == null)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Vous ne vous trouvez dans aucun cubo");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!inside_cubo.isOwner(player.getName()) && !hasStaffPermission(player))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de faire cette action pour ce cubo");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
WorldEditPlugin wePlugin = WorldEditInterface.getPlugin();
|
||||||
|
Selection sel = new CuboidSelection(player.getWorld(), inside_cubo.getMinimumPoint(), inside_cubo.getMaximumPoint());
|
||||||
|
wePlugin.setSelection(player, sel);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("supprimer") && args.length == 1)
|
||||||
|
{
|
||||||
|
if (inside_cubo == null)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Vous ne vous trouvez dans aucun cubo");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!inside_cubo.isOwner(player.getName()) && !hasStaffPermission(player))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de faire cette action pour ce cubo");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> player_name = inside_cubo.getOwners().getPlayers();
|
||||||
|
if (player_name == null || player_name.isEmpty())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Ce cubo n'a aucun propriétaire");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
String proprio_cubo = player_name.toArray(new String[1])[0];
|
||||||
|
|
||||||
|
double actu_money = EssentialsInterface.getPlugin().getUser(proprio_cubo).getMoney().doubleValue();
|
||||||
|
|
||||||
|
int actu_volume_cubo = getPlayerActualBlockCount(proprio_cubo, player.getWorld());
|
||||||
|
int new_volume_cubo = actu_volume_cubo - inside_cubo.volume();
|
||||||
|
double money_win = getVolumePrice(actu_volume_cubo) - getVolumePrice(new_volume_cubo);
|
||||||
|
|
||||||
|
|
||||||
|
wgPlugin.getRegionManager(player.getWorld()).removeRegion(inside_cubo.getId());
|
||||||
|
EssentialsInterface.getPlugin().getUser(proprio_cubo).setMoney(new BigDecimal(actu_money + money_win));
|
||||||
|
|
||||||
|
Player player_cubo = plugin.getServer().getPlayerExact(proprio_cubo);
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.GREEN+"Le cubo "+ChatColor.GRAY+inside_cubo.getId()+ChatColor.GREEN+" a été supprimé");
|
||||||
|
if (player_cubo != null && player_cubo != player)
|
||||||
|
{
|
||||||
|
player_cubo.sendMessage(ChatColor.GREEN+"Le cubo "+ChatColor.GRAY+inside_cubo.getId()+ChatColor.GREEN+" a été supprimé");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player_cubo != player)
|
||||||
|
{ // le joueur gère le cubo d'un autre joueur (en ligne ou non)
|
||||||
|
player.sendMessage(ChatColor.GREEN+"L'argent a été restauré sur le compte de "+ChatColor.GRAY+((player_cubo == null)?proprio_cubo:player_cubo.getName()));
|
||||||
|
if (player_cubo != null)
|
||||||
|
player_cubo.sendMessage(ChatColor.GREEN+"L'argent a été restauré sur votre compte");
|
||||||
|
}
|
||||||
|
else // le joueur gère son propre cubo
|
||||||
|
player.sendMessage(ChatColor.GREEN+"L'argent a été restauré sur votre compte");
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("ajouter") && args.length >= 2)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (inside_cubo == null)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Vous ne vous trouvez dans aucun cubo");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!inside_cubo.isOwner(player.getName()) && !hasStaffPermission(player))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de faire cette action pour ce cubo");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String new_user = args[1];
|
||||||
|
|
||||||
|
if (!new_user.matches("[0-9a-azA-Z_]{2,16}"))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Le pseudo indiqué n'est pas valide");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inside_cubo.getMembers().addPlayer(new_user);
|
||||||
|
try {
|
||||||
|
wgPlugin.getRegionManager(player.getWorld()).save();
|
||||||
|
} catch (ProtectionDatabaseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.GREEN+"Vous venez d'ajouter "+ChatColor.GRAY+new_user+ChatColor.GREEN+" dans le cubo");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("enlever") && args.length >= 2)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (inside_cubo == null)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Vous ne vous trouvez dans aucun cubo");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!inside_cubo.isOwner(player.getName()) && !hasStaffPermission(player))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de faire cette action pour ce cubo");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String old_user = args[1];
|
||||||
|
|
||||||
|
if (!old_user.matches("[0-9a-azA-Z_]{2,16}"))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Le pseudo indiqué n'est pas valide");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inside_cubo.getMembers().removePlayer(old_user);
|
||||||
|
try {
|
||||||
|
wgPlugin.getRegionManager(player.getWorld()).save();
|
||||||
|
} catch (ProtectionDatabaseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
player.sendMessage(ChatColor.GREEN+"Vous venez de retirer "+ChatColor.GRAY+old_user+ChatColor.GREEN+" du cubo");
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("donner") && args.length >= 2)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (inside_cubo == null)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Vous ne vous trouvez dans aucun cubo");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!inside_cubo.isOwner(player.getName()) && !hasStaffPermission(player))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de faire cette action pour ce cubo");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String new_user = args[1];
|
||||||
|
|
||||||
|
if (plugin.getServer().getPlayer(new_user) == null)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED+"Le joueur indiqué n'est pas connecté");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player new_proprio = plugin.getServer().getPlayer(new_user);
|
||||||
|
|
||||||
|
|
||||||
|
inside_cubo.setOwners(new DefaultDomain());
|
||||||
|
inside_cubo.getOwners().addPlayer(new_proprio.getName());
|
||||||
|
inside_cubo.setMembers(new DefaultDomain());
|
||||||
|
try {
|
||||||
|
wgPlugin.getRegionManager(player.getWorld()).save();
|
||||||
|
} catch (ProtectionDatabaseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.GREEN+"Vous venez de donner la parcelle courante à "+ChatColor.RESET+new_proprio.getDisplayName());
|
||||||
|
player.sendMessage(player.getDisplayName()+ChatColor.GREEN+" viens de vous donner la parcelle "+ChatColor.GRAY+inside_cubo.getId());
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// on arrive ici si aucune des sous commandes correspond à celle tapée
|
||||||
|
sender.sendMessage(ChatColor.RED+"Mauvaise utilisation de la commande "+ChatColor.GRAY+"/cubo"+ChatColor.RED+". Faites "+ChatColor.GRAY+"/cubo"+ChatColor.RED+" pour connaitre l'utilisation");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void showHelp(CommandSender sender) {
|
||||||
|
|
||||||
|
String[] messages = null;
|
||||||
|
if ((sender instanceof Player) && hasStaffPermission((Player)sender))
|
||||||
|
{ // pour le staff connecté
|
||||||
|
String[] m = {
|
||||||
|
ChatColor.GOLD+"----- Assistant de protection en Survie -----",
|
||||||
|
ChatColor.GRAY+"/cubo devis [Pseudo]"+ChatColor.GOLD+" pour calculer le prix du cubo et estimer sa faisabilité. Précisez le pseudo si ce n'est pas pour vous",
|
||||||
|
ChatColor.GRAY+"/cubo creer <NomDuCubo> [Pseudo]"+ChatColor.GOLD+" pour créer le cubo. Précisez le pseudo si ce n'est pas pour vous",
|
||||||
|
ChatColor.GRAY+"/cubo info"+ChatColor.GOLD+" pour afficher les infos du cubo dans lequel vous êtes",
|
||||||
|
ChatColor.GRAY+"/cubo selectionner"+ChatColor.GOLD+" pour faire une sélection WorldEdit du cubo dans lequel vous êtes",
|
||||||
|
ChatColor.GRAY+"/cubo supprimer"+ChatColor.GOLD+" pour supprimer le cubo dans lequel vous êtes",
|
||||||
|
ChatColor.GRAY+"/cubo ajouter <Pseudo>"+ChatColor.GOLD+" pour ajouter un usager dans le cubo dans lequel vous êtes",
|
||||||
|
ChatColor.GRAY+"/cubo enlever <Pseudo>"+ChatColor.GOLD+" pour enlever un usager du cubo dans lequel vous êtes",
|
||||||
|
ChatColor.GRAY+"/cubo liste <Page> [Pseudo]"+ChatColor.GOLD+" pour lister vos cubos. Précisez le pseudo si vous voulez lister les cubos d'un autre joueur",
|
||||||
|
ChatColor.GRAY+"/cubo donner <Pseudo>"+ChatColor.GOLD+" pour donner le cubo dans lequel vous êtes à un joueur",
|
||||||
|
ChatColor.GOLD+"------------------------------------------"
|
||||||
|
};
|
||||||
|
messages = m;
|
||||||
|
}
|
||||||
|
else if (sender instanceof Player)
|
||||||
|
{ // pour les joueurs
|
||||||
|
String[] m = {
|
||||||
|
ChatColor.GOLD+"----- Assistant de protection en Survie -----",
|
||||||
|
ChatColor.GRAY+"/cubo devis"+ChatColor.GOLD+" pour calculer le prix du cubo et estimer sa faisabilité",
|
||||||
|
ChatColor.GRAY+"/cubo creer <NomDuCubo>"+ChatColor.GOLD+" pour créer le cubo si il est faisable.",
|
||||||
|
ChatColor.GRAY+"/cubo info"+ChatColor.GOLD+" pour afficher les infos du cubo dans lequel vous êtes",
|
||||||
|
ChatColor.GRAY+"/cubo selectionner"+ChatColor.GOLD+" pour faire une sélection WorldEdit du cubo dans lequel vous êtes",
|
||||||
|
ChatColor.GRAY+"/cubo supprimer"+ChatColor.GOLD+" pour supprimer le cubo dans lequel vous êtes",
|
||||||
|
ChatColor.GRAY+"/cubo ajouter <Pseudo>"+ChatColor.GOLD+" pour ajouter un usager dans le cubo dans lequel vous êtes",
|
||||||
|
ChatColor.GRAY+"/cubo enlever <Pseudo>"+ChatColor.GOLD+" pour enlever un usager du cubo dans lequel vous êtes",
|
||||||
|
ChatColor.GRAY+"/cubo liste <Page>"+ChatColor.GOLD+" pour lister vos cubos",
|
||||||
|
ChatColor.GRAY+"/cubo donner <Pseudo>"+ChatColor.GOLD+" pour donner le cubo dans lequel vous êtes à un joueur",
|
||||||
|
ChatColor.GOLD+"------------------------------------------"
|
||||||
|
};
|
||||||
|
messages = m;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // pour la console et le reste (pas les joueurs)
|
||||||
|
String[] m = {
|
||||||
|
ChatColor.GOLD+"----- Assistant de protection en Survie -----",
|
||||||
|
ChatColor.GOLD+"Vous devez être connecté pour exécuter les commandes de cubo",
|
||||||
|
ChatColor.GOLD+"---------------------------------------------"
|
||||||
|
};
|
||||||
|
messages = m;
|
||||||
|
}
|
||||||
|
sender.sendMessage(messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param p le joueur
|
||||||
|
* @param w le monde
|
||||||
|
* @return tout les cubos d'un joueur donné sur un monde donné
|
||||||
|
*/
|
||||||
|
public List<ProtectedCuboidRegion> getPlayerCubo(Player p, World w) {
|
||||||
|
return getPlayerCubo(p.getName(), w);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param p le pseudo du joueur
|
||||||
|
* @param w le monde
|
||||||
|
* @return tout les cubos d'un joueur donné sur un monde donné
|
||||||
|
*/
|
||||||
|
public List<ProtectedCuboidRegion> getPlayerCubo(String p, World w) {
|
||||||
|
|
||||||
|
Map<String, ProtectedRegion> regions = wgPlugin.getRegionManager(w).getRegions();
|
||||||
|
List<ProtectedCuboidRegion> playerRegions = new ArrayList<ProtectedCuboidRegion>();
|
||||||
|
|
||||||
|
for (Map.Entry<String, ProtectedRegion> region : regions.entrySet()) {
|
||||||
|
// on ne prend en charge que les cuboides
|
||||||
|
if (!(region instanceof ProtectedCuboidRegion))
|
||||||
|
continue;
|
||||||
|
// on garde les régions gérés par la commande
|
||||||
|
if (!region.getKey().matches(regex_cubo_id))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!region.getValue().isOwner(p))
|
||||||
|
continue;
|
||||||
|
playerRegions.add((ProtectedCuboidRegion)region.getValue());
|
||||||
|
}
|
||||||
|
return playerRegions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param p le joueur
|
||||||
|
* @param w le monde
|
||||||
|
* @return le volume total des cubos d'un joueur donné sur un monde donné
|
||||||
|
*/
|
||||||
|
public int getPlayerActualBlockCount(Player p, World w) {
|
||||||
|
return getPlayerActualBlockCount(p.getName(), w);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param p le joueur
|
||||||
|
* @param w le monde
|
||||||
|
* @return le volume total des cubos d'un joueur donné sur un monde donné
|
||||||
|
*/
|
||||||
|
public int getPlayerActualBlockCount(String p, World w) {
|
||||||
|
List<ProtectedCuboidRegion> regions = getPlayerCubo(p, w);
|
||||||
|
int nb = 0;
|
||||||
|
for (ProtectedCuboidRegion region : regions){
|
||||||
|
nb += region.volume();
|
||||||
|
}
|
||||||
|
return nb;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param nb le volume
|
||||||
|
* @return le prix pour le volume donné
|
||||||
|
*/
|
||||||
|
public double getVolumePrice(int nb) {
|
||||||
|
if (nb <= 2000)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (nb<= 100000)
|
||||||
|
return nb-2000D;
|
||||||
|
|
||||||
|
return Math.pow(((nb-2000D)/98000D),1.5)*98000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasStaffPermission(Player p) {
|
||||||
|
return p.hasPermission("pandacraft.cubo.staff");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -7,6 +7,7 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
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.plugin_interface.WorldEditInterface;
|
||||||
import net.mc_pandacraft.java.util.bukkit.protocol.ParticleEffect;
|
import net.mc_pandacraft.java.util.bukkit.protocol.ParticleEffect;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -21,9 +22,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|
||||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
|
||||||
|
|
||||||
public class CommandWandSelection extends BukkitRunnable implements CommandExecutor, Listener {
|
public class CommandWandSelection extends BukkitRunnable implements CommandExecutor, Listener {
|
||||||
|
|
||||||
@ -151,7 +150,7 @@ public class CommandWandSelection extends BukkitRunnable implements CommandExecu
|
|||||||
if (p == null || !p.isOnline())
|
if (p == null || !p.isOnline())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CuboidSelection cubo = getPlayerCuboSelection(p);
|
CuboidSelection cubo = WorldEditInterface.getPlayerCuboSelection(p);
|
||||||
|
|
||||||
// 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 != null && cubo.getWorld() == p.getWorld())
|
if (cubo != null && cubo.getWorld() == p.getWorld())
|
||||||
@ -163,7 +162,7 @@ public class CommandWandSelection extends BukkitRunnable implements CommandExecu
|
|||||||
for (Player po : pl.getValue()){
|
for (Player po : pl.getValue()){
|
||||||
if (po == null || !po.isOnline()) continue;
|
if (po == null || !po.isOnline()) continue;
|
||||||
|
|
||||||
cubo = getPlayerCuboSelection(po);
|
cubo = WorldEditInterface.getPlayerCuboSelection(po);
|
||||||
|
|
||||||
if (cubo != null && cubo.getWorld() == p.getWorld())
|
if (cubo != null && cubo.getWorld() == p.getWorld())
|
||||||
drawCuboid(cubo, p, false);
|
drawCuboid(cubo, p, false);
|
||||||
@ -180,19 +179,6 @@ public class CommandWandSelection extends BukkitRunnable implements CommandExecu
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
private void drawCuboid(CuboidSelection cubo, Player p, boolean self)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user