Unification des classes gérant l'exécution des commandes + retructuration complètes des packages et des classes
This commit is contained in:
parent
5e7b129c2e
commit
2f2ad0974b
@ -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.11.jar"/>
|
<jar path="PandacraftUtils/jar_export/PandacraftUtils-3.0.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/>
|
||||||
|
@ -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.11
|
version: 3.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,26 +1,20 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils;
|
package net.mc_pandacraft.java.plugin.pandacraftutils;
|
||||||
|
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.commands.CommandsManager;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.AfkManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.afk.CommandAfk;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.CalculatorManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.calculator.CalculatorManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.ChatAnalysisManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.chat_analyzer.ChatAnalysisManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.CommandAliasManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.cheat_protect.creative.CreativCheatManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.LoginLogoutMessageManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.cheat_protect.no_pvp.NoPvpProtectManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.PacketOutServerInfoListener;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.login_message.LoginLogoutManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.SpawnTimeManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.player_count_list.PacketOutServerInfoListener;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.StaffQueueManager;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.SurvivalCuboManager;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.TPSAnalysisManager;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.WESelectionDisplayManager;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.cheat_protect.CreativCheatManager;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.cheat_protect.NoPvpProtectManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands._command_alias.CommandAliasManager;
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.broadcast.CommandBroadcast;
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.list.CommandList;
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.me.CommandMe;
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.ping.CommandPing;
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.setblock.CommandSetblock;
|
|
||||||
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.survival_cuboid.CommandCubo;
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.survival_cuboid.CommandWandSelection;
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.system_analyzer.CommandSystem;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -37,24 +31,20 @@ public class PandacraftUtils extends JavaPlugin {
|
|||||||
|
|
||||||
//public DBConnection databaseConnection;
|
//public DBConnection databaseConnection;
|
||||||
|
|
||||||
public CommandAfk commandAfk;
|
public AfkManager afkManager;
|
||||||
public CommandList commandPlayers;
|
public WESelectionDisplayManager wESelectionDisplayManager;
|
||||||
public CommandSetblock commandSetblock;
|
|
||||||
public CommandSystem commandSystem;
|
|
||||||
public CommandPing commandPing;
|
|
||||||
public CommandMe commandMe;
|
|
||||||
public CommandWandSelection commandWandSelection;
|
|
||||||
public CommandStaff commandStaff;
|
|
||||||
public CommandCubo commandCubo;
|
|
||||||
public CommandBroadcast commandBroadcast;
|
|
||||||
|
|
||||||
public CommandAliasManager commandAliasManager;
|
public CommandAliasManager commandAliasManager;
|
||||||
public SpawnTimeManager spawnTimeManager;
|
public SpawnTimeManager spawnTimeManager;
|
||||||
public ChatAnalysisManager chatAnalysisManager;
|
public ChatAnalysisManager chatAnalysisManager;
|
||||||
public CreativCheatManager creativCheatManager;
|
public CreativCheatManager creativCheatManager;
|
||||||
public NoPvpProtectManager noPvpProtectManager;
|
public NoPvpProtectManager noPvpProtectManager;
|
||||||
public LoginLogoutManager loginLogoutManager;
|
public LoginLogoutMessageManager loginLogoutMessageManager;
|
||||||
public CalculatorManager calculatorManager;
|
public CalculatorManager calculatorManager;
|
||||||
|
public SurvivalCuboManager survivalCuboManager;
|
||||||
|
public StaffQueueManager staffQueueManager;
|
||||||
|
public TPSAnalysisManager tpsAnalysisManager;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public PacketOutServerInfoListener serverPingListener;
|
public PacketOutServerInfoListener serverPingListener;
|
||||||
|
|
||||||
@ -76,27 +66,26 @@ public class PandacraftUtils extends JavaPlugin {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}*/
|
}*/
|
||||||
OnlinePlayerManager.loadNewInstance();
|
OnlinePlayerManager.loadNewInstance();
|
||||||
|
CommandsManager.loadNewInstance();
|
||||||
|
|
||||||
commandPlayers = new CommandList(this);
|
|
||||||
commandSetblock = new CommandSetblock(this);
|
|
||||||
commandAfk = new CommandAfk();
|
|
||||||
commandSystem = new CommandSystem(this);
|
|
||||||
commandPing = new CommandPing(this);
|
|
||||||
commandMe = new CommandMe(this);
|
|
||||||
commandWandSelection = new CommandWandSelection(this);
|
|
||||||
commandStaff = new CommandStaff(this);
|
|
||||||
commandCubo = new CommandCubo(this);
|
|
||||||
commandBroadcast = new CommandBroadcast(this);
|
|
||||||
|
|
||||||
|
afkManager = new AfkManager();
|
||||||
|
wESelectionDisplayManager = new WESelectionDisplayManager();
|
||||||
commandAliasManager = new CommandAliasManager(this);
|
commandAliasManager = new CommandAliasManager(this);
|
||||||
spawnTimeManager = new SpawnTimeManager(this);
|
spawnTimeManager = new SpawnTimeManager(this);
|
||||||
chatAnalysisManager = new ChatAnalysisManager();
|
chatAnalysisManager = new ChatAnalysisManager();
|
||||||
creativCheatManager = new CreativCheatManager(this);
|
creativCheatManager = new CreativCheatManager(this);
|
||||||
noPvpProtectManager = new NoPvpProtectManager(this);
|
noPvpProtectManager = new NoPvpProtectManager(this);
|
||||||
loginLogoutManager = new LoginLogoutManager(this);
|
loginLogoutMessageManager = new LoginLogoutMessageManager(this);
|
||||||
calculatorManager = new CalculatorManager(this);
|
calculatorManager = new CalculatorManager(this);
|
||||||
|
survivalCuboManager = new SurvivalCuboManager();
|
||||||
serverPingListener = new PacketOutServerInfoListener(this);
|
serverPingListener = new PacketOutServerInfoListener(this);
|
||||||
|
staffQueueManager = new StaffQueueManager();
|
||||||
|
tpsAnalysisManager = new TPSAnalysisManager();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
getServer().getScheduler().runTaskLater(this, new Runnable() {
|
getServer().getScheduler().runTaskLater(this, new Runnable() {
|
||||||
@ -109,25 +98,20 @@ public class PandacraftUtils extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable(){
|
public void onDisable(){
|
||||||
commandPlayers = null;
|
|
||||||
commandSetblock = null;
|
|
||||||
commandAfk = null;
|
|
||||||
commandSystem = null;
|
|
||||||
commandPing = null;
|
|
||||||
commandMe = null;
|
|
||||||
commandWandSelection = null;
|
|
||||||
commandStaff = null;
|
|
||||||
commandCubo = null;
|
|
||||||
commandBroadcast = null;
|
|
||||||
|
|
||||||
|
afkManager = null;
|
||||||
|
wESelectionDisplayManager = null;
|
||||||
commandAliasManager = null;
|
commandAliasManager = null;
|
||||||
spawnTimeManager = null;
|
spawnTimeManager = null;
|
||||||
chatAnalysisManager = null;
|
chatAnalysisManager = null;
|
||||||
creativCheatManager = null;
|
creativCheatManager = null;
|
||||||
noPvpProtectManager = null;
|
noPvpProtectManager = null;
|
||||||
calculatorManager = null;
|
calculatorManager = null;
|
||||||
|
survivalCuboManager = null;
|
||||||
serverPingListener = null;
|
serverPingListener = null;
|
||||||
|
staffQueueManager = null;
|
||||||
|
tpsAnalysisManager = null;
|
||||||
|
|
||||||
|
|
||||||
ConfigManager.reloadConfig();
|
ConfigManager.reloadConfig();
|
||||||
|
|
||||||
@ -141,6 +125,21 @@ public class PandacraftUtils extends JavaPlugin {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Envoi d'un message groupé à plusieurs ou à tout les joueurs et peut-être à la console
|
* Envoi d'un message groupé à plusieurs ou à tout les joueurs et peut-être à la console
|
||||||
* @param message message à envoyer
|
* @param message message à envoyer
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classe parente de toutes les classes devant prendre en charge l'exécution d'une commande Minecraft
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* package */ abstract class AbstractCommandExecutor implements CommandExecutor {
|
||||||
|
|
||||||
|
protected PandacraftUtils plugin = PandacraftUtils.getInstance();
|
||||||
|
|
||||||
|
protected final String commandName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param cName (ne peut être null) nom de la commande tel que défini dans le fichier plugin.yml
|
||||||
|
*/
|
||||||
|
public AbstractCommandExecutor(String cName) {
|
||||||
|
if (cName == null) throw new IllegalArgumentException("La commande doit avoir un nom");
|
||||||
|
commandName = cName;
|
||||||
|
|
||||||
|
plugin.getCommand(commandName).setExecutor(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCommandName() { return commandName; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class CommandAfk extends AbstractCommandExecutor {
|
||||||
|
|
||||||
|
public CommandAfk() {
|
||||||
|
super("afk");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
||||||
|
{
|
||||||
|
boolean execute_self = false;
|
||||||
|
boolean execute_other = false;
|
||||||
|
Player other_player = null;
|
||||||
|
|
||||||
|
if(sender instanceof Player)
|
||||||
|
{
|
||||||
|
if (args.length > 0)
|
||||||
|
{
|
||||||
|
if (((Player)sender).hasPermission("pandacraft.afk.other"))
|
||||||
|
{
|
||||||
|
if (plugin.getServer().getPlayer(args[0]) != null)
|
||||||
|
{
|
||||||
|
other_player = plugin.getServer().getPlayer(args[0]);
|
||||||
|
execute_other = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sender.sendMessage("§cLe joueur n'existe pas.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage("§cVous n'avez pas la permission d'effectuer cette action sur un autre joueur.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
execute_self = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (args.length > 0)
|
||||||
|
{
|
||||||
|
if (plugin.getServer().getPlayer(args[0]) != null)
|
||||||
|
{
|
||||||
|
other_player = plugin.getServer().getPlayer(args[0]);
|
||||||
|
execute_other = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sender.sendMessage("§cLe joueur n'existe pas.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sender.sendMessage("§cVeuillez indiquer un joueur.");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (execute_self)
|
||||||
|
{
|
||||||
|
Player p = (Player)sender;
|
||||||
|
OnlinePlayer ap = OnlinePlayerManager.getInstance().get(p);
|
||||||
|
if (ap == null)
|
||||||
|
plugin.getLogger().severe("Cant find AfkPlayer with name "+p.getName()+" when performing command /afk");
|
||||||
|
else
|
||||||
|
ap.performAfkCommand();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (execute_other && other_player != null)
|
||||||
|
{
|
||||||
|
OnlinePlayer ap = OnlinePlayerManager.getInstance().get(other_player);
|
||||||
|
if (ap == null)
|
||||||
|
plugin.getLogger().severe("Cant find AfkPlayer with name "+other_player.getName()+" when performing command /afk <player>");
|
||||||
|
ap.adminToggleAfk();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,20 +1,15 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.broadcast;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class CommandBroadcast implements CommandExecutor {
|
public class CommandBroadcast extends AbstractCommandExecutor {
|
||||||
|
public CommandBroadcast() {
|
||||||
|
super("broadcast");
|
||||||
|
|
||||||
private PandacraftUtils plugin;
|
// classe qui gère deux commandes (presque identiques)
|
||||||
|
|
||||||
public CommandBroadcast(PandacraftUtils pl) {
|
|
||||||
plugin = pl;
|
|
||||||
plugin.getCommand("broadcast").setExecutor(this);
|
|
||||||
plugin.getCommand("broadcastperm").setExecutor(this);
|
plugin.getCommand("broadcastperm").setExecutor(this);
|
||||||
}
|
}
|
||||||
|
|
@ -1,25 +1,21 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.survival_cuboid;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager;
|
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.EssentialsInterface;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.WorldEditInterface;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.WorldEditInterface;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.WorldGuardInterface;
|
||||||
import net.mc_pandacraft.java.util.StringUtil;
|
import net.mc_pandacraft.java.util.StringUtil;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
@ -32,41 +28,21 @@ import com.sk89q.worldguard.protection.databases.ProtectionDatabaseException;
|
|||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
public class CommandCubo implements CommandExecutor {
|
public class CommandCubo extends AbstractCommandExecutor {
|
||||||
|
|
||||||
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.getCommand("cubo").setExecutor(this);
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
|
public CommandCubo() {
|
||||||
|
super("cubo");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command,
|
public boolean onCommand(CommandSender sender, Command command,
|
||||||
String label, String[] args) {
|
String label, String[] args) {
|
||||||
|
|
||||||
|
WorldGuardPlugin wgPlugin = WorldGuardInterface.getPlugin();
|
||||||
|
|
||||||
if (args.length == 0 || !(sender instanceof Player))
|
if (args.length == 0 || !(sender instanceof Player))
|
||||||
{
|
{
|
||||||
showHelp(sender);
|
showHelp(sender);
|
||||||
@ -93,7 +69,7 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasStaffPermission(player) && args.length >= 2 && plugin.getServer().getPlayer(args[1]) == null)
|
if (plugin.survivalCuboManager.hasStaffPermission(player) && args.length >= 2 && plugin.getServer().getPlayer(args[1]) == null)
|
||||||
{ // un joueur est indiqué mais il n'est pas connecté
|
{ // un joueur est indiqué mais il n'est pas connecté
|
||||||
player.sendMessage(ChatColor.RED+"Le joueur concerné n'est pas en ligne");
|
player.sendMessage(ChatColor.RED+"Le joueur concerné n'est pas en ligne");
|
||||||
return true;
|
return true;
|
||||||
@ -102,7 +78,7 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
|
|
||||||
// on cherche si on traite un autre joueur
|
// on cherche si on traite un autre joueur
|
||||||
Player player_cubo;
|
Player player_cubo;
|
||||||
if (!hasStaffPermission(player) || args.length < 2 || (player_cubo = plugin.getServer().getPlayer(args[1])) == null)
|
if (!plugin.survivalCuboManager.hasStaffPermission(player) || args.length < 2 || (player_cubo = plugin.getServer().getPlayer(args[1])) == null)
|
||||||
player_cubo = player;
|
player_cubo = player;
|
||||||
|
|
||||||
player.sendMessage(ChatColor.GOLD+"----- Devis pour la création d'un cubo -----");
|
player.sendMessage(ChatColor.GOLD+"----- Devis pour la création d'un cubo -----");
|
||||||
@ -150,10 +126,10 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
// on vérifie si le joueur peut payer
|
// on vérifie si le joueur peut payer
|
||||||
double actual_money = EssentialsInterface.getPlayerMoney(player_cubo);
|
double actual_money = EssentialsInterface.getPlayerMoney(player_cubo);
|
||||||
|
|
||||||
int volume_actuel_cubo = getPlayerActualBlockCount(player_cubo, selection.getWorld());
|
int volume_actuel_cubo = plugin.survivalCuboManager.getPlayerActualBlockCount(player_cubo, selection.getWorld());
|
||||||
int volume_apres_cubo = volume_actuel_cubo + cubo.volume();
|
int volume_apres_cubo = volume_actuel_cubo + cubo.volume();
|
||||||
double prix_actuel_cubo = getVolumePrice(volume_actuel_cubo);
|
double prix_actuel_cubo = plugin.survivalCuboManager.getVolumePrice(volume_actuel_cubo);
|
||||||
double prix_apres_cubo = getVolumePrice(volume_apres_cubo);
|
double prix_apres_cubo = plugin.survivalCuboManager.getVolumePrice(volume_apres_cubo);
|
||||||
double prix_a_payer = prix_apres_cubo - prix_actuel_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+"Solde actuel : "+StringUtil.formatDouble(actual_money));
|
||||||
@ -201,7 +177,7 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
player.sendMessage(ChatColor.RED+"Vous devez faire une sélection WorldEdit : faites "+ChatColor.GRAY+"//wand");
|
player.sendMessage(ChatColor.RED+"Vous devez faire une sélection WorldEdit : faites "+ChatColor.GRAY+"//wand");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (hasStaffPermission(player) && args.length >= 3 && plugin.getServer().getPlayer(args[2]) == null)
|
if (plugin.survivalCuboManager.hasStaffPermission(player) && args.length >= 3 && plugin.getServer().getPlayer(args[2]) == null)
|
||||||
{ // un joueur est indiqué mais il n'est pas connecté
|
{ // un joueur est indiqué mais il n'est pas connecté
|
||||||
player.sendMessage(ChatColor.RED+"Le joueur concerné n'est pas en ligne");
|
player.sendMessage(ChatColor.RED+"Le joueur concerné n'est pas en ligne");
|
||||||
return true;
|
return true;
|
||||||
@ -209,7 +185,7 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
|
|
||||||
// on cherche si on traite un autre joueur
|
// on cherche si on traite un autre joueur
|
||||||
Player player_cubo;
|
Player player_cubo;
|
||||||
if (!hasStaffPermission(player) || args.length < 3 || (player_cubo = plugin.getServer().getPlayer(args[2])) == null)
|
if (!plugin.survivalCuboManager.hasStaffPermission(player) || args.length < 3 || (player_cubo = plugin.getServer().getPlayer(args[2])) == null)
|
||||||
player_cubo = player;
|
player_cubo = player;
|
||||||
|
|
||||||
player.sendMessage(ChatColor.GOLD+"----- Création d'un cubo -----");
|
player.sendMessage(ChatColor.GOLD+"----- Création d'un cubo -----");
|
||||||
@ -262,10 +238,10 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
// on vérifie si le joueur peut payer
|
// on vérifie si le joueur peut payer
|
||||||
double actual_money = EssentialsInterface.getPlayerMoney(player_cubo);
|
double actual_money = EssentialsInterface.getPlayerMoney(player_cubo);
|
||||||
|
|
||||||
int volume_actuel_cubo = getPlayerActualBlockCount(player_cubo, selection.getWorld());
|
int volume_actuel_cubo = plugin.survivalCuboManager.getPlayerActualBlockCount(player_cubo, selection.getWorld());
|
||||||
int volume_apres_cubo = volume_actuel_cubo + cubo.volume();
|
int volume_apres_cubo = volume_actuel_cubo + cubo.volume();
|
||||||
double prix_actuel_cubo = getVolumePrice(volume_actuel_cubo);
|
double prix_actuel_cubo = plugin.survivalCuboManager.getVolumePrice(volume_actuel_cubo);
|
||||||
double prix_apres_cubo = getVolumePrice(volume_apres_cubo);
|
double prix_apres_cubo = plugin.survivalCuboManager.getVolumePrice(volume_apres_cubo);
|
||||||
double prix_a_payer = prix_apres_cubo - prix_actuel_cubo;
|
double prix_a_payer = prix_apres_cubo - prix_actuel_cubo;
|
||||||
|
|
||||||
|
|
||||||
@ -330,11 +306,11 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
|
|
||||||
// on cherche si on traite un autre joueur
|
// on cherche si on traite un autre joueur
|
||||||
String player_cubo = player.getName();
|
String player_cubo = player.getName();
|
||||||
if (hasStaffPermission(player) && args.length >= 3)
|
if (plugin.survivalCuboManager.hasStaffPermission(player) && args.length >= 3)
|
||||||
player_cubo = args[2];
|
player_cubo = args[2];
|
||||||
|
|
||||||
|
|
||||||
List<ProtectedCuboidRegion> cubos = getPlayerCubo(player_cubo, player.getWorld());
|
List<ProtectedCuboidRegion> cubos = plugin.survivalCuboManager.getPlayerCubo(player_cubo, player.getWorld());
|
||||||
|
|
||||||
int nb_page = (int)Math.ceil(cubos.size()/5D);
|
int nb_page = (int)Math.ceil(cubos.size()/5D);
|
||||||
if (num_page > nb_page) num_page = nb_page;
|
if (num_page > nb_page) num_page = nb_page;
|
||||||
@ -372,7 +348,7 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
for(ProtectedRegion cubo : wgPlugin.getRegionManager(player.getWorld()).getApplicableRegions(player.getLocation()))
|
for(ProtectedRegion cubo : wgPlugin.getRegionManager(player.getWorld()).getApplicableRegions(player.getLocation()))
|
||||||
{
|
{
|
||||||
if (!(cubo instanceof ProtectedCuboidRegion)) continue;
|
if (!(cubo instanceof ProtectedCuboidRegion)) continue;
|
||||||
if (!cubo.getId().matches(regex_cubo_id)) continue;
|
if (!cubo.getId().matches(plugin.survivalCuboManager.regex_cubo_id)) continue;
|
||||||
inside_cubo = (ProtectedCuboidRegion) cubo;
|
inside_cubo = (ProtectedCuboidRegion) cubo;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -418,7 +394,7 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
player.sendMessage(ChatColor.RED+"Vous ne vous trouvez dans aucun cubo");
|
player.sendMessage(ChatColor.RED+"Vous ne vous trouvez dans aucun cubo");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!inside_cubo.isOwner(player.getName()) && !hasStaffPermission(player))
|
if (!inside_cubo.isOwner(player.getName()) && !plugin.survivalCuboManager.hasStaffPermission(player))
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de faire cette action pour ce cubo");
|
player.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de faire cette action pour ce cubo");
|
||||||
return true;
|
return true;
|
||||||
@ -439,7 +415,7 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
player.sendMessage(ChatColor.RED+"Vous ne vous trouvez dans aucun cubo");
|
player.sendMessage(ChatColor.RED+"Vous ne vous trouvez dans aucun cubo");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!inside_cubo.isOwner(player.getName()) && !hasStaffPermission(player))
|
if (!inside_cubo.isOwner(player.getName()) && !plugin.survivalCuboManager.hasStaffPermission(player))
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de faire cette action pour ce cubo");
|
player.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de faire cette action pour ce cubo");
|
||||||
return true;
|
return true;
|
||||||
@ -455,9 +431,10 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
|
|
||||||
double actu_money = EssentialsInterface.getPlugin().getUser(proprio_cubo).getMoney().doubleValue();
|
double actu_money = EssentialsInterface.getPlugin().getUser(proprio_cubo).getMoney().doubleValue();
|
||||||
|
|
||||||
int actu_volume_cubo = getPlayerActualBlockCount(proprio_cubo, player.getWorld());
|
int actu_volume_cubo = plugin.survivalCuboManager.getPlayerActualBlockCount(proprio_cubo, player.getWorld());
|
||||||
int new_volume_cubo = actu_volume_cubo - inside_cubo.volume();
|
int new_volume_cubo = actu_volume_cubo - inside_cubo.volume();
|
||||||
double money_win = getVolumePrice(actu_volume_cubo) - getVolumePrice(new_volume_cubo);
|
double money_win = plugin.survivalCuboManager.getVolumePrice(actu_volume_cubo)
|
||||||
|
- plugin.survivalCuboManager.getVolumePrice(new_volume_cubo);
|
||||||
|
|
||||||
|
|
||||||
wgPlugin.getRegionManager(player.getWorld()).removeRegion(inside_cubo.getId());
|
wgPlugin.getRegionManager(player.getWorld()).removeRegion(inside_cubo.getId());
|
||||||
@ -495,7 +472,7 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
player.sendMessage(ChatColor.RED+"Vous ne vous trouvez dans aucun cubo");
|
player.sendMessage(ChatColor.RED+"Vous ne vous trouvez dans aucun cubo");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!inside_cubo.isOwner(player.getName()) && !hasStaffPermission(player))
|
if (!inside_cubo.isOwner(player.getName()) && !plugin.survivalCuboManager.hasStaffPermission(player))
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de faire cette action pour ce cubo");
|
player.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de faire cette action pour ce cubo");
|
||||||
return true;
|
return true;
|
||||||
@ -534,7 +511,7 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
player.sendMessage(ChatColor.RED+"Vous ne vous trouvez dans aucun cubo");
|
player.sendMessage(ChatColor.RED+"Vous ne vous trouvez dans aucun cubo");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!inside_cubo.isOwner(player.getName()) && !hasStaffPermission(player))
|
if (!inside_cubo.isOwner(player.getName()) && !plugin.survivalCuboManager.hasStaffPermission(player))
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de faire cette action pour ce cubo");
|
player.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de faire cette action pour ce cubo");
|
||||||
return true;
|
return true;
|
||||||
@ -573,7 +550,7 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
player.sendMessage(ChatColor.RED+"Vous ne vous trouvez dans aucun cubo");
|
player.sendMessage(ChatColor.RED+"Vous ne vous trouvez dans aucun cubo");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!inside_cubo.isOwner(player.getName()) && !hasStaffPermission(player))
|
if (!inside_cubo.isOwner(player.getName()) && !plugin.survivalCuboManager.hasStaffPermission(player))
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de faire cette action pour ce cubo");
|
player.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de faire cette action pour ce cubo");
|
||||||
return true;
|
return true;
|
||||||
@ -614,7 +591,7 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
if (args[0].equalsIgnoreCase("convert"))
|
if (args[0].equalsIgnoreCase("convert"))
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!hasStaffPermission(player))
|
if (!plugin.survivalCuboManager.hasStaffPermission(player))
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de faire cette action");
|
player.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de faire cette action");
|
||||||
return true;
|
return true;
|
||||||
@ -646,7 +623,7 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
// on ignore les cubos dans le bon format
|
// on ignore les cubos dans le bon format
|
||||||
if (region_to_convert.getId().matches(regex_cubo_id))
|
if (region_to_convert.getId().matches(plugin.survivalCuboManager.regex_cubo_id))
|
||||||
{
|
{
|
||||||
nb_converted++;
|
nb_converted++;
|
||||||
continue;
|
continue;
|
||||||
@ -790,10 +767,10 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void showHelp(CommandSender sender) {
|
private void showHelp(CommandSender sender) {
|
||||||
|
|
||||||
String[] messages = null;
|
String[] messages = null;
|
||||||
if ((sender instanceof Player) && hasStaffPermission((Player)sender))
|
if ((sender instanceof Player) && plugin.survivalCuboManager.hasStaffPermission((Player)sender))
|
||||||
{ // pour le staff connecté
|
{ // pour le staff connecté
|
||||||
String[] m = {
|
String[] m = {
|
||||||
ChatColor.GOLD+"----- Assistant de protection en Survie -----",
|
ChatColor.GOLD+"----- Assistant de protection en Survie -----",
|
||||||
@ -849,102 +826,4 @@ public class CommandCubo implements CommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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.getValue() instanceof ProtectedCuboidRegion))
|
|
||||||
continue;
|
|
||||||
// on garde les régions gérés par la commande
|
|
||||||
if (!region.getValue().getId().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");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,30 +1,26 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.list;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager;
|
||||||
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.OnlinePlayer;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface;
|
||||||
|
import net.mc_pandacraft.java.util.StringUtil;
|
||||||
import net.mc_pandacraft.java.util.TimeUtil;
|
import net.mc_pandacraft.java.util.TimeUtil;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class CommandList implements CommandExecutor {
|
public class CommandList extends AbstractCommandExecutor {
|
||||||
private PandacraftUtils plugin;
|
public CommandList()
|
||||||
|
|
||||||
public CommandList(PandacraftUtils pl)
|
|
||||||
{
|
{
|
||||||
plugin = pl;
|
super("list");
|
||||||
plugin.getCommand("list").setExecutor(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
||||||
@ -233,17 +229,17 @@ public class CommandList implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int max_length = (header.length()-2*char_count(header, '§')) + 2;
|
int max_length = (header.length()-2*StringUtil.char_count(header, '§')) + 2;
|
||||||
max_length += 2; // évite le décalage de l'entête si il n'y a aucun trait à gauche
|
max_length += 2; // évite le décalage de l'entête si il n'y a aucun trait à gauche
|
||||||
for (String line : aff_list)
|
for (String line : aff_list)
|
||||||
max_length = (line != null && (line.length()-2*char_count(line, '§')) > max_length) ? (line.length()-2*char_count(line, '§')) : max_length;
|
max_length = (line != null && (line.length()-2*StringUtil.char_count(line, '§')) > max_length) ? (line.length()-2*StringUtil.char_count(line, '§')) : max_length;
|
||||||
|
|
||||||
if (max_length > 70) max_length = 70;
|
if (max_length > 70) max_length = 70;
|
||||||
|
|
||||||
|
|
||||||
long header_left_aff = Math.round(Math.floor((max_length - (header.length()-2*char_count(header, '§')) - 2)/2D));
|
long header_left_aff = Math.round(Math.floor((max_length - (header.length()-2*StringUtil.char_count(header, '§')) - 2)/2D));
|
||||||
if (header_left_aff < 0) header_left_aff = 0;
|
if (header_left_aff < 0) header_left_aff = 0;
|
||||||
long header_right_aff = Math.round(Math.ceil((max_length - (header.length()-2*char_count(header, '§')) - 2)/2D));
|
long header_right_aff = Math.round(Math.ceil((max_length - (header.length()-2*StringUtil.char_count(header, '§')) - 2)/2D));
|
||||||
if (header_right_aff < 0) header_right_aff = 0;
|
if (header_right_aff < 0) header_right_aff = 0;
|
||||||
|
|
||||||
String final_header = decoration_color;
|
String final_header = decoration_color;
|
||||||
@ -277,23 +273,4 @@ public class CommandList implements CommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private int char_count(String s, char c_match)
|
|
||||||
{
|
|
||||||
char[] chars = s.toCharArray();
|
|
||||||
int count = 0;
|
|
||||||
for (char c : chars)
|
|
||||||
if (c == c_match)
|
|
||||||
count++;
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,26 +1,22 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.me;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
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.EssentialsInterface;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.command.RemoteConsoleCommandSender;
|
import org.bukkit.command.RemoteConsoleCommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class CommandMe implements CommandExecutor {
|
public class CommandMe extends AbstractCommandExecutor {
|
||||||
|
|
||||||
private PandacraftUtils plugin;
|
public CommandMe() {
|
||||||
|
super("me");
|
||||||
public CommandMe(PandacraftUtils pl) {
|
|
||||||
plugin = pl;
|
|
||||||
plugin.getCommand("me").setExecutor(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
if (args.length == 0) return false;
|
if (args.length == 0) return false;
|
@ -1,25 +1,17 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.ping;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class CommandPing implements CommandExecutor {
|
public class CommandPing extends AbstractCommandExecutor {
|
||||||
|
|
||||||
private PandacraftUtils plugin;
|
public CommandPing()
|
||||||
|
|
||||||
public CommandPing(PandacraftUtils pl)
|
|
||||||
{
|
{
|
||||||
plugin = pl;
|
super("ping");
|
||||||
|
|
||||||
plugin.getCommand("ping").setExecutor(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -1,24 +1,18 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.setblock;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.BlockCommandSender;
|
import org.bukkit.command.BlockCommandSender;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class CommandSetblock implements CommandExecutor {
|
public class CommandSetblock extends AbstractCommandExecutor {
|
||||||
private PandacraftUtils plugin;
|
public CommandSetblock()
|
||||||
|
|
||||||
public CommandSetblock(PandacraftUtils pl)
|
|
||||||
{
|
{
|
||||||
plugin = pl;
|
super("setblock");
|
||||||
plugin.getCommand("setblock").setExecutor(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,72 +1,43 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.staff_player_help;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.Queue;
|
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.StaffQueueManager;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.StaffQueueManager.WaitingPlayer;
|
||||||
import net.mc_pandacraft.java.util.TimeUtil;
|
import net.mc_pandacraft.java.util.TimeUtil;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.scoreboard.DisplaySlot;
|
|
||||||
import org.bukkit.scoreboard.Objective;
|
|
||||||
import org.bukkit.scoreboard.Score;
|
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
|
||||||
|
|
||||||
public class CommandStaff implements CommandExecutor, Listener {
|
public class CommandStaff extends AbstractCommandExecutor {
|
||||||
|
|
||||||
private PandacraftUtils plugin;
|
public CommandStaff() {
|
||||||
|
super("staff");
|
||||||
|
|
||||||
private Queue<WaitingPlayer> playerQueue = new LinkedList<WaitingPlayer>();
|
|
||||||
|
|
||||||
private Scoreboard scoreboardPlayerQueue;
|
|
||||||
|
|
||||||
|
|
||||||
public CommandStaff(PandacraftUtils pl) {
|
|
||||||
plugin = pl;
|
|
||||||
plugin.getCommand("staff").setExecutor(this);
|
|
||||||
|
|
||||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
|
||||||
|
|
||||||
|
|
||||||
scoreboardPlayerQueue = Bukkit.getScoreboardManager().getNewScoreboard();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String alias,
|
public boolean onCommand(CommandSender sender, Command cmd, String alias,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
|
|
||||||
|
StaffQueueManager staffManager = plugin.staffQueueManager;
|
||||||
|
|
||||||
|
|
||||||
if (sender instanceof Player && !((Player)sender).hasPermission("pandacraft.grade.staff"))
|
if (sender instanceof Player && !((Player)sender).hasPermission("pandacraft.grade.staff"))
|
||||||
{ // un joueur qui n'est pas du staff
|
{ // un joueur qui n'est pas du staff
|
||||||
|
|
||||||
// le joueur est-il déjà en file d'attente ?
|
// le joueur est-il déjà en file d'attente ?
|
||||||
if (getWaitingPlayer((Player)sender) != null) {
|
if (staffManager.getWaitingPlayer((Player)sender) != null) {
|
||||||
if (args.length > 0 && args[0].equalsIgnoreCase("annuler")) {
|
if (args.length > 0 && args[0].equalsIgnoreCase("annuler")) {
|
||||||
removePlayer((Player)sender);
|
staffManager.removePlayer((Player)sender);
|
||||||
updateScoreBoardWaitingList();
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"Vous avez été retiré de la file d'attente");
|
sender.sendMessage(ChatColor.GREEN+"Vous avez été retiré de la file d'attente");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (args.length > 0 && args[0].equalsIgnoreCase("position")) {
|
else if (args.length > 0 && args[0].equalsIgnoreCase("position")) {
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"Vous êtes à la position "+getPlayerPosition((Player)sender)+" de la file d'attente");
|
sender.sendMessage(ChatColor.GREEN+"Vous êtes à la position "+staffManager.getPlayerPosition((Player)sender)+" de la file d'attente");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
sender.sendMessage(ChatColor.GREEN+"Vous êtes déjà dans la file d'attente");
|
sender.sendMessage(ChatColor.GREEN+"Vous êtes déjà dans la file d'attente");
|
||||||
@ -84,10 +55,10 @@ public class CommandStaff implements CommandExecutor, Listener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerQueue.add(new WaitingPlayer(((Player)sender).getName(), StringUtils.join(args, " "), ((Player)sender).getLocation()));
|
staffManager.playerQueue.add(staffManager.new WaitingPlayer(((Player)sender).getName(), StringUtils.join(args, " "), ((Player)sender).getLocation()));
|
||||||
updateScoreBoardWaitingList();
|
staffManager.updateScoreBoardWaitingList();
|
||||||
sender.sendMessage(ChatColor.GREEN+"Veuillez maintenant patienter quelques instant, le temps que le staff traite le début de la file d'attente ;)");
|
sender.sendMessage(ChatColor.GREEN+"Veuillez maintenant patienter quelques instant, le temps que le staff traite le début de la file d'attente ;)");
|
||||||
sender.sendMessage(ChatColor.GREEN+"Vous êtes à la position "+getPlayerPosition((Player)sender)+" de la file d'attente");
|
sender.sendMessage(ChatColor.GREEN+"Vous êtes à la position "+staffManager.getPlayerPosition((Player)sender)+" de la file d'attente");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (sender instanceof Player)
|
else if (sender instanceof Player)
|
||||||
@ -127,6 +98,9 @@ public class CommandStaff implements CommandExecutor, Listener {
|
|||||||
|
|
||||||
|
|
||||||
private boolean onCommand_admin_commands(CommandSender sender, String[] args) {
|
private boolean onCommand_admin_commands(CommandSender sender, String[] args) {
|
||||||
|
|
||||||
|
StaffQueueManager staffManager = plugin.staffQueueManager;
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("?"))
|
if (args[0].equalsIgnoreCase("?"))
|
||||||
{ // affichage de l'aide
|
{ // affichage de l'aide
|
||||||
sender.sendMessage(ChatColor.GOLD+"--- Commandes administratives pour gérer la file d'attente ---");
|
sender.sendMessage(ChatColor.GOLD+"--- Commandes administratives pour gérer la file d'attente ---");
|
||||||
@ -138,15 +112,14 @@ public class CommandStaff implements CommandExecutor, Listener {
|
|||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("select") && args.length > 1 && sender instanceof Player)
|
else if (args[0].equalsIgnoreCase("select") && args.length > 1 && sender instanceof Player)
|
||||||
{
|
{
|
||||||
WaitingPlayer wp = getWaitingPlayer(args[1]);
|
WaitingPlayer wp = staffManager.getWaitingPlayer(args[1]);
|
||||||
if (wp == null) {
|
if (wp == null) {
|
||||||
sender.sendMessage(ChatColor.RED+"Le joueur n'est pas dans la liste");
|
sender.sendMessage(ChatColor.RED+"Le joueur n'est pas dans la liste");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
removePlayer(args[1]);
|
staffManager.removePlayer(args[1]);
|
||||||
updateScoreBoardWaitingList();
|
|
||||||
|
|
||||||
|
|
||||||
Player p = plugin.getServer().getPlayerExact(wp.getPlayerName());
|
Player p = plugin.getServer().getPlayerExact(wp.getPlayerName());
|
||||||
@ -181,14 +154,13 @@ public class CommandStaff implements CommandExecutor, Listener {
|
|||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("remove") && args.length > 1)
|
else if (args[0].equalsIgnoreCase("remove") && args.length > 1)
|
||||||
{
|
{
|
||||||
WaitingPlayer wp = getWaitingPlayer(args[1]);
|
WaitingPlayer wp = staffManager.getWaitingPlayer(args[1]);
|
||||||
if (wp == null) {
|
if (wp == null) {
|
||||||
sender.sendMessage(ChatColor.RED+"Le joueur n'est pas dans la liste");
|
sender.sendMessage(ChatColor.RED+"Le joueur n'est pas dans la liste");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
removePlayer(args[1]);
|
staffManager.removePlayer(args[1]);
|
||||||
updateScoreBoardWaitingList();
|
|
||||||
Player p = plugin.getServer().getPlayerExact(wp.getPlayerName());
|
Player p = plugin.getServer().getPlayerExact(wp.getPlayerName());
|
||||||
if (p != null && p.isOnline()) {
|
if (p != null && p.isOnline()) {
|
||||||
p.sendMessage(ChatColor.RED+"Vous avez été retiré de la liste des joueurs en attente");
|
p.sendMessage(ChatColor.RED+"Vous avez été retiré de la liste des joueurs en attente");
|
||||||
@ -209,7 +181,7 @@ public class CommandStaff implements CommandExecutor, Listener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WaitingPlayer wp = getWaitingPlayer(p.getName());
|
WaitingPlayer wp = staffManager.getWaitingPlayer(p.getName());
|
||||||
if (wp != null) {
|
if (wp != null) {
|
||||||
sender.sendMessage(ChatColor.RED+"Le joueur est déjà dans la liste");
|
sender.sendMessage(ChatColor.RED+"Le joueur est déjà dans la liste");
|
||||||
return true;
|
return true;
|
||||||
@ -224,9 +196,8 @@ public class CommandStaff implements CommandExecutor, Listener {
|
|||||||
String message = StringUtils.join(args, " ");
|
String message = StringUtils.join(args, " ");
|
||||||
|
|
||||||
|
|
||||||
playerQueue.add(new WaitingPlayer(p.getName(),message, p.getLocation()));
|
staffManager.playerQueue.add(staffManager.new WaitingPlayer(p.getName(),message, p.getLocation()));
|
||||||
|
staffManager.updateScoreBoardWaitingList();
|
||||||
updateScoreBoardWaitingList();
|
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"Vous venez d'ajouter "+p.getDisplayName()+ChatColor.RESET+ChatColor.GREEN+" dans la file d'attente");
|
sender.sendMessage(ChatColor.GREEN+"Vous venez d'ajouter "+p.getDisplayName()+ChatColor.RESET+ChatColor.GREEN+" dans la file d'attente");
|
||||||
|
|
||||||
@ -245,64 +216,11 @@ public class CommandStaff implements CommandExecutor, Listener {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private WaitingPlayer getWaitingPlayer(String p) {
|
|
||||||
for (WaitingPlayer wp : playerQueue)
|
|
||||||
{
|
|
||||||
if (wp != null && wp.getPlayerName().equalsIgnoreCase(p))
|
|
||||||
return wp;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private WaitingPlayer getWaitingPlayer(OfflinePlayer p) {
|
|
||||||
return getWaitingPlayer(p.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private int getPlayerPosition(OfflinePlayer p) {
|
|
||||||
int i = 0;
|
|
||||||
for (WaitingPlayer wp : playerQueue)
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
if (wp != null && wp.getPlayerName().equalsIgnoreCase(p.getName()))
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void removePlayer(String p) {
|
|
||||||
WaitingPlayer wp = getWaitingPlayer(p);
|
|
||||||
if (wp != null)
|
|
||||||
playerQueue.remove(wp);
|
|
||||||
}
|
|
||||||
private void removePlayer(OfflinePlayer p) {
|
|
||||||
removePlayer(p.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void showWaintingList(CommandSender sender) {
|
private void showWaintingList(CommandSender sender) {
|
||||||
sender.sendMessage(ChatColor.BOLD+"-- File d'attente des joueurs pour le staff --");
|
sender.sendMessage(ChatColor.BOLD+"-- File d'attente des joueurs pour le staff --");
|
||||||
|
|
||||||
int i=0;
|
int i=0;
|
||||||
for (WaitingPlayer wp : playerQueue) {
|
for (WaitingPlayer wp : plugin.staffQueueManager.playerQueue) {
|
||||||
i++;
|
i++;
|
||||||
Player p = plugin.getServer().getPlayerExact(wp.getPlayerName());
|
Player p = plugin.getServer().getPlayerExact(wp.getPlayerName());
|
||||||
String name;
|
String name;
|
||||||
@ -325,104 +243,9 @@ public class CommandStaff implements CommandExecutor, Listener {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void updateScoreBoardWaitingList() {
|
|
||||||
Objective obj = scoreboardPlayerQueue.getObjective("file_attente");
|
|
||||||
if (obj != null)
|
|
||||||
obj.unregister();
|
|
||||||
|
|
||||||
|
|
||||||
obj = scoreboardPlayerQueue.registerNewObjective("file_attente", "dummy");
|
|
||||||
obj.setDisplayName(ChatColor.GOLD+"File d'attente staff");
|
|
||||||
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
|
||||||
|
|
||||||
int i=0;
|
|
||||||
for (WaitingPlayer wp : playerQueue) {
|
|
||||||
i++;
|
|
||||||
|
|
||||||
Player p = plugin.getServer().getPlayerExact(wp.getPlayerName());
|
|
||||||
String name;
|
|
||||||
if (p == null || !p.isOnline())
|
|
||||||
name = wp.getPlayerName();
|
|
||||||
else
|
|
||||||
name = p.getPlayerListName();
|
|
||||||
|
|
||||||
String line = i+"."+name;
|
|
||||||
int boardPos = playerQueue.size()-i+1;
|
|
||||||
|
|
||||||
|
|
||||||
Score score = obj.getScore(plugin.getServer().getOfflinePlayer(line.substring(0, (line.length()>16)?16:line.length())));
|
|
||||||
|
|
||||||
score.setScore(boardPos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
Player p = event.getPlayer();
|
|
||||||
if (p.hasPermission("pandacraft.grade.staff"))
|
|
||||||
p.setScoreboard(scoreboardPlayerQueue);
|
|
||||||
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
|
|
||||||
@Override public void run() { updateScoreBoardWaitingList(); }
|
|
||||||
}, 2L);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
||||||
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
|
|
||||||
@Override public void run() { updateScoreBoardWaitingList(); }
|
|
||||||
}, 2L);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private class WaitingPlayer {
|
|
||||||
|
|
||||||
private String player;
|
|
||||||
private String message;
|
|
||||||
private Date creationDate;
|
|
||||||
private Location location;
|
|
||||||
|
|
||||||
|
|
||||||
public WaitingPlayer(String p, String m, Location l) {
|
|
||||||
|
|
||||||
player = p;
|
|
||||||
message = m;
|
|
||||||
creationDate = new Date();
|
|
||||||
location = l;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getPlayerName() { return player; }
|
|
||||||
|
|
||||||
public String getMessage() { return message; }
|
|
||||||
|
|
||||||
public Date getDate() { return creationDate; }
|
|
||||||
|
|
||||||
public Location getLocation() { return location; }
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.system_analyzer;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.lang.management.ThreadInfo;
|
import java.lang.management.ThreadInfo;
|
||||||
@ -10,7 +10,6 @@ import java.util.Map.Entry;
|
|||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
|
||||||
import net.mc_pandacraft.java.util.MemoryUtil;
|
import net.mc_pandacraft.java.util.MemoryUtil;
|
||||||
import net.mc_pandacraft.java.util.TimeUtil;
|
import net.mc_pandacraft.java.util.TimeUtil;
|
||||||
import net.mc_pandacraft.java.util.bukkit.TextProgressBar;
|
import net.mc_pandacraft.java.util.bukkit.TextProgressBar;
|
||||||
@ -18,25 +17,16 @@ import net.mc_pandacraft.java.util.bukkit.TextProgressBar;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class CommandSystem implements CommandExecutor {
|
public class CommandSystem extends AbstractCommandExecutor {
|
||||||
private PandacraftUtils plugin;
|
public CommandSystem()
|
||||||
private TPSAnalyser tpsAnalyser;
|
|
||||||
|
|
||||||
public CommandSystem(PandacraftUtils pl)
|
|
||||||
{
|
{
|
||||||
plugin = pl;
|
super("system");
|
||||||
|
|
||||||
plugin.getCommand("system").setExecutor(this);
|
|
||||||
|
|
||||||
tpsAnalyser = new TPSAnalyser(plugin);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -150,7 +140,7 @@ public class CommandSystem implements CommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
ConsoleCommandSender console = plugin.getServer().getConsoleSender();
|
ConsoleCommandSender console = plugin.getServer().getConsoleSender();
|
||||||
console.sendMessage(tpsAnalyser.getStringTPSHistory(20*20));
|
console.sendMessage(plugin.tpsAnalysisManager.getStringTPSHistory(20*20));
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -173,7 +163,7 @@ public class CommandSystem implements CommandExecutor {
|
|||||||
sender.sendMessage(TextProgressBar.progressBar(values_bar, colors_bar, maxMem, ((sender instanceof Player)?155:43)));
|
sender.sendMessage(TextProgressBar.progressBar(values_bar, colors_bar, maxMem, ((sender instanceof Player)?155:43)));
|
||||||
|
|
||||||
// tps
|
// tps
|
||||||
double tps = tpsAnalyser.getTPS();
|
double tps = plugin.tpsAnalysisManager.getTPS();
|
||||||
String val_tps;
|
String val_tps;
|
||||||
if (Double.isNaN(tps))
|
if (Double.isNaN(tps))
|
||||||
{
|
{
|
@ -0,0 +1,87 @@
|
|||||||
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class Command_Selection extends AbstractCommandExecutor {
|
||||||
|
|
||||||
|
public Command_Selection() {
|
||||||
|
super("/selection");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// permet d'activer / désactiver l'affichage du cubo
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
|
||||||
|
if (! (sender instanceof Player))
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.RED+"Seul un joueur en ligne peut effectuer cette commande");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.getServer().getPluginManager().getPlugin("WorldEdit") == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.RED+"Plugin WorldEdit non installé");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player p = (Player) sender;
|
||||||
|
OnlinePlayer op = OnlinePlayerManager.getInstance().get(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 (op.canViewWESelection() && otherP == null)
|
||||||
|
{ // le joueur ne veut plus voir de cubo
|
||||||
|
op.disableViewingWESelection();
|
||||||
|
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection désactivé.");
|
||||||
|
}
|
||||||
|
else if (op.canViewWESelection())
|
||||||
|
{
|
||||||
|
if (op.hasPlayerForWiewingHisWESelection(otherP))
|
||||||
|
{
|
||||||
|
op.removePlayerForWiewingHisWESelection(otherP);
|
||||||
|
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection de "+ChatColor.GRAY+otherP.getName()+ChatColor.GREEN+" désactivé.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
op.addPlayerForWiewingHisWESelection(otherP);
|
||||||
|
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection de "+ChatColor.GRAY+otherP.getName()+ChatColor.GREEN+" activé.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
op.enableViewingWESelection();
|
||||||
|
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) {
|
||||||
|
op.addPlayerForWiewingHisWESelection(otherP);
|
||||||
|
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection de "+ChatColor.GRAY+otherP.getName()+ChatColor.GREEN+" activé.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise et stoque toutes les instances des classes exécutant les commandes Minecraft, géré par le plugin
|
||||||
|
*/
|
||||||
|
public class CommandsManager {
|
||||||
|
|
||||||
|
private static CommandsManager instance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne l'unique instance de la classe. Si elle n'existe pas, on tente de créer
|
||||||
|
* @return L'unique instance de la classe
|
||||||
|
*/
|
||||||
|
public synchronized static CommandsManager getInstance() {
|
||||||
|
if (instance == null)
|
||||||
|
loadNewInstance();
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized static void loadNewInstance() {
|
||||||
|
instance = new CommandsManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private HashMap<String, AbstractCommandExecutor> commandExecutors = new HashMap<String, AbstractCommandExecutor>();
|
||||||
|
|
||||||
|
private CommandsManager() {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialisation des commandes
|
||||||
|
*/
|
||||||
|
add(new Command_Selection());
|
||||||
|
add(new CommandAfk());
|
||||||
|
add(new CommandBroadcast());
|
||||||
|
add(new CommandCubo());
|
||||||
|
add(new CommandList());
|
||||||
|
add(new CommandMe());
|
||||||
|
add(new CommandPing());
|
||||||
|
add(new CommandSetblock());
|
||||||
|
add(new CommandStaff());
|
||||||
|
add(new CommandSystem());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void add(AbstractCommandExecutor ace) {
|
||||||
|
commandExecutors.put(ace.getCommandName(), ace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbstractCommandExecutor get(String cmdName) {
|
||||||
|
return commandExecutors.get(cmdName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.afk;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules;
|
||||||
|
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager;
|
||||||
@ -7,9 +7,6 @@ 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 org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -26,18 +23,16 @@ import org.bukkit.event.player.PlayerToggleSneakEvent;
|
|||||||
import org.bukkit.event.player.PlayerToggleSprintEvent;
|
import org.bukkit.event.player.PlayerToggleSprintEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
public class CommandAfk extends BukkitRunnable implements CommandExecutor, Listener {
|
public class AfkManager extends BukkitRunnable implements Listener {
|
||||||
private PandacraftUtils plugin = PandacraftUtils.getInstance();
|
private PandacraftUtils plugin = PandacraftUtils.getInstance();
|
||||||
|
|
||||||
private int timeoutAutoAfkMessage = ConfigManager.getInstance().AFK_timeoutAutoAfkMessage;
|
private int timeoutAutoAfkMessage = ConfigManager.getInstance().AFK_timeoutAutoAfkMessage;
|
||||||
private int timeoutAutoAfkKick = ConfigManager.getInstance().AFK_timeoutAutoAfkKick;
|
private int timeoutAutoAfkKick = ConfigManager.getInstance().AFK_timeoutAutoAfkKick;
|
||||||
|
|
||||||
|
|
||||||
public CommandAfk()
|
public AfkManager()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
plugin.getCommand("afk").setExecutor(this);
|
|
||||||
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 5*20L, 20L);
|
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 5*20L, 20L);
|
||||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
|
|
||||||
@ -49,95 +44,6 @@ public class CommandAfk extends BukkitRunnable implements CommandExecutor, Liste
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------
|
|
||||||
// ------------ Commande /AFK -------------
|
|
||||||
// ----------------------------------------
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
|
||||||
{
|
|
||||||
boolean execute_self = false;
|
|
||||||
boolean execute_other = false;
|
|
||||||
Player other_player = null;
|
|
||||||
|
|
||||||
if(sender instanceof Player)
|
|
||||||
{
|
|
||||||
if (args.length > 0)
|
|
||||||
{
|
|
||||||
if (((Player)sender).hasPermission("pandacraft.afk.other"))
|
|
||||||
{
|
|
||||||
if (plugin.getServer().getPlayer(args[0]) != null)
|
|
||||||
{
|
|
||||||
other_player = plugin.getServer().getPlayer(args[0]);
|
|
||||||
execute_other = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
sender.sendMessage("§cLe joueur n'existe pas.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sender.sendMessage("§cVous n'avez pas la permission d'effectuer cette action sur un autre joueur.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
execute_self = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (args.length > 0)
|
|
||||||
{
|
|
||||||
if (plugin.getServer().getPlayer(args[0]) != null)
|
|
||||||
{
|
|
||||||
other_player = plugin.getServer().getPlayer(args[0]);
|
|
||||||
execute_other = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
sender.sendMessage("§cLe joueur n'existe pas.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
sender.sendMessage("§cVeuillez indiquer un joueur.");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (execute_self)
|
|
||||||
{
|
|
||||||
Player p = (Player)sender;
|
|
||||||
OnlinePlayer ap = OnlinePlayerManager.getInstance().get(p);
|
|
||||||
if (ap == null)
|
|
||||||
plugin.getLogger().severe("Cant find AfkPlayer with name "+p.getName()+" when performing command /afk");
|
|
||||||
else
|
|
||||||
ap.performAfkCommand();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (execute_other && other_player != null)
|
|
||||||
{
|
|
||||||
OnlinePlayer ap = OnlinePlayerManager.getInstance().get(other_player);
|
|
||||||
if (ap == null)
|
|
||||||
plugin.getLogger().severe("Cant find AfkPlayer with name "+other_player.getName()+" when performing command /afk <player>");
|
|
||||||
ap.adminToggleAfk();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
// ----------- Analyse Auto-AFK -----------
|
// ----------- Analyse Auto-AFK -----------
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
@ -1,4 +1,4 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.calculator;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
@ -1,4 +1,4 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.chat_analyzer;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
@ -1,4 +1,4 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands._command_alias;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
@ -1,4 +1,4 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.login_message;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -16,14 +16,14 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
|
|
||||||
import de.luricos.bukkit.xAuth.events.xAuthLoginEvent;
|
import de.luricos.bukkit.xAuth.events.xAuthLoginEvent;
|
||||||
|
|
||||||
public class LoginLogoutManager implements Listener {
|
public class LoginLogoutMessageManager implements Listener {
|
||||||
|
|
||||||
private PandacraftUtils plugin;
|
private PandacraftUtils plugin;
|
||||||
|
|
||||||
private List<Player> loggedInPlayer = new ArrayList<Player>();
|
private List<Player> loggedInPlayer = new ArrayList<Player>();
|
||||||
|
|
||||||
|
|
||||||
public LoginLogoutManager(PandacraftUtils pl) {
|
public LoginLogoutMessageManager(PandacraftUtils pl) {
|
||||||
plugin = pl;
|
plugin = pl;
|
||||||
|
|
||||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
@ -1,4 +1,4 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.player_count_list;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
@ -1,4 +1,4 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.spawntime;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
@ -0,0 +1,191 @@
|
|||||||
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Queue;
|
||||||
|
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
|
import org.bukkit.scoreboard.Objective;
|
||||||
|
import org.bukkit.scoreboard.Score;
|
||||||
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
|
||||||
|
public class StaffQueueManager implements Listener {
|
||||||
|
|
||||||
|
private PandacraftUtils plugin = PandacraftUtils.getInstance();
|
||||||
|
|
||||||
|
|
||||||
|
public Queue<WaitingPlayer> playerQueue = new LinkedList<WaitingPlayer>();
|
||||||
|
|
||||||
|
private Scoreboard scoreboardPlayerQueue = Bukkit.getScoreboardManager().getNewScoreboard();
|
||||||
|
|
||||||
|
|
||||||
|
public StaffQueueManager() {
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public WaitingPlayer getWaitingPlayer(String p) {
|
||||||
|
for (WaitingPlayer wp : playerQueue)
|
||||||
|
{
|
||||||
|
if (wp != null && wp.getPlayerName().equalsIgnoreCase(p))
|
||||||
|
return wp;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public WaitingPlayer getWaitingPlayer(OfflinePlayer p) {
|
||||||
|
return getWaitingPlayer(p.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public int getPlayerPosition(OfflinePlayer p) {
|
||||||
|
int i = 0;
|
||||||
|
for (WaitingPlayer wp : playerQueue)
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
if (wp != null && wp.getPlayerName().equalsIgnoreCase(p.getName()))
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void removePlayer(String p) {
|
||||||
|
WaitingPlayer wp = getWaitingPlayer(p);
|
||||||
|
if (wp != null)
|
||||||
|
{
|
||||||
|
playerQueue.remove(wp);
|
||||||
|
updateScoreBoardWaitingList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void removePlayer(OfflinePlayer p) {
|
||||||
|
removePlayer(p.getName());
|
||||||
|
updateScoreBoardWaitingList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void updateScoreBoardWaitingList() {
|
||||||
|
Objective obj = scoreboardPlayerQueue.getObjective("file_attente");
|
||||||
|
if (obj != null)
|
||||||
|
obj.unregister();
|
||||||
|
|
||||||
|
|
||||||
|
obj = scoreboardPlayerQueue.registerNewObjective("file_attente", "dummy");
|
||||||
|
obj.setDisplayName(ChatColor.GOLD+"File d'attente staff");
|
||||||
|
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
|
|
||||||
|
int i=0;
|
||||||
|
for (WaitingPlayer wp : playerQueue) {
|
||||||
|
i++;
|
||||||
|
|
||||||
|
Player p = plugin.getServer().getPlayerExact(wp.getPlayerName());
|
||||||
|
String name;
|
||||||
|
if (p == null || !p.isOnline())
|
||||||
|
name = wp.getPlayerName();
|
||||||
|
else
|
||||||
|
name = p.getPlayerListName();
|
||||||
|
|
||||||
|
String line = i+"."+name;
|
||||||
|
int boardPos = playerQueue.size()-i+1;
|
||||||
|
|
||||||
|
|
||||||
|
Score score = obj.getScore(plugin.getServer().getOfflinePlayer(line.substring(0, (line.length()>16)?16:line.length())));
|
||||||
|
|
||||||
|
score.setScore(boardPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
Player p = event.getPlayer();
|
||||||
|
if (p.hasPermission("pandacraft.grade.staff"))
|
||||||
|
p.setScoreboard(scoreboardPlayerQueue);
|
||||||
|
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
|
||||||
|
@Override public void run() { updateScoreBoardWaitingList(); }
|
||||||
|
}, 2L);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
|
||||||
|
@Override public void run() { updateScoreBoardWaitingList(); }
|
||||||
|
}, 2L);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class WaitingPlayer {
|
||||||
|
|
||||||
|
private String player;
|
||||||
|
private String message;
|
||||||
|
private Date creationDate;
|
||||||
|
private Location location;
|
||||||
|
|
||||||
|
|
||||||
|
public WaitingPlayer(String p, String m, Location l) {
|
||||||
|
|
||||||
|
player = p;
|
||||||
|
message = m;
|
||||||
|
creationDate = new Date();
|
||||||
|
location = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getPlayerName() { return player; }
|
||||||
|
|
||||||
|
public String getMessage() { return message; }
|
||||||
|
|
||||||
|
public Date getDate() { return creationDate; }
|
||||||
|
|
||||||
|
public Location getLocation() { return location; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,107 @@
|
|||||||
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.WorldGuardInterface;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
|
public class SurvivalCuboManager {
|
||||||
|
public WorldGuardPlugin wgPlugin = WorldGuardInterface.getPlugin();
|
||||||
|
|
||||||
|
public final String regex_cubo_id = "cubo[0-9]+-[0-9A-Za-z_]+-[0-9A-Za-z_]+";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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.getValue() instanceof ProtectedCuboidRegion))
|
||||||
|
continue;
|
||||||
|
// on garde les régions gérés par la commande
|
||||||
|
if (!region.getValue().getId().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");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,20 +1,19 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.system_analyzer;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||||
|
|
||||||
public class TPSAnalyser implements Runnable {
|
public class TPSAnalysisManager implements Runnable {
|
||||||
private static int nb_tick_history = 20 * 20; // 20 secondes;
|
private static int nb_tick_history = 20 * 20; // 20 secondes;
|
||||||
|
|
||||||
private PandacraftUtils plugin;
|
private PandacraftUtils plugin = PandacraftUtils.getInstance();
|
||||||
|
|
||||||
private LinkedList<Long> tps_times = new LinkedList<Long>();
|
private LinkedList<Long> tps_times = new LinkedList<Long>();
|
||||||
|
|
||||||
|
|
||||||
public TPSAnalyser(PandacraftUtils pl)
|
public TPSAnalysisManager()
|
||||||
{
|
{
|
||||||
plugin = pl;
|
|
||||||
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 1L, 1L);
|
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 1L, 1L);
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.survival_cuboid;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -9,101 +9,23 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager
|
|||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.WorldEditInterface;
|
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.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||||
|
|
||||||
public class CommandWandSelection extends BukkitRunnable implements CommandExecutor {
|
public class WESelectionDisplayManager extends BukkitRunnable {
|
||||||
|
|
||||||
private PandacraftUtils plugin;
|
private PandacraftUtils plugin = PandacraftUtils.getInstance();
|
||||||
|
|
||||||
|
|
||||||
public CommandWandSelection(PandacraftUtils pl)
|
public WESelectionDisplayManager()
|
||||||
{
|
{
|
||||||
plugin = pl;
|
|
||||||
|
|
||||||
plugin.getCommand("/selection").setExecutor(this);
|
|
||||||
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 20L, 20L);
|
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 20L, 20L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Commande //selection
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// permet d'activer / désactiver l'affichage du cubo
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
|
||||||
|
|
||||||
if (! (sender instanceof Player))
|
|
||||||
{
|
|
||||||
sender.sendMessage(ChatColor.RED+"Seul un joueur en ligne peut effectuer cette commande");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin.getServer().getPluginManager().getPlugin("WorldEdit") == null)
|
|
||||||
{
|
|
||||||
sender.sendMessage(ChatColor.RED+"Plugin WorldEdit non installé");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player p = (Player) sender;
|
|
||||||
OnlinePlayer op = OnlinePlayerManager.getInstance().get(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 (op.canViewWESelection() && otherP == null)
|
|
||||||
{ // le joueur ne veut plus voir de cubo
|
|
||||||
op.disableViewingWESelection();
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection désactivé.");
|
|
||||||
}
|
|
||||||
else if (op.canViewWESelection())
|
|
||||||
{
|
|
||||||
if (op.hasPlayerForWiewingHisWESelection(otherP))
|
|
||||||
{
|
|
||||||
op.removePlayerForWiewingHisWESelection(otherP);
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection de "+ChatColor.GRAY+otherP.getName()+ChatColor.GREEN+" désactivé.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
op.addPlayerForWiewingHisWESelection(otherP);
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection de "+ChatColor.GRAY+otherP.getName()+ChatColor.GREEN+" activé.");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
op.enableViewingWESelection();
|
|
||||||
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) {
|
|
||||||
op.addPlayerForWiewingHisWESelection(otherP);
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection de "+ChatColor.GRAY+otherP.getName()+ChatColor.GREEN+" activé.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// pour mettre à jour l'affichage du cubo
|
// pour mettre à jour l'affichage du cubo
|
@ -1,4 +1,4 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.cheat_protect.creative;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules.cheat_protect;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.cheat_protect.no_pvp;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules.cheat_protect;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -26,7 +26,7 @@ public final class OnlinePlayerManager implements Listener {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadNewInstance() {
|
public synchronized static void loadNewInstance() {
|
||||||
instance = new OnlinePlayerManager();
|
instance = new OnlinePlayerManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface;
|
||||||
|
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||||
|
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
|
||||||
|
public class WorldGuardInterface {
|
||||||
|
|
||||||
|
public static WorldGuardPlugin getPlugin() {
|
||||||
|
try {
|
||||||
|
return (WorldGuardPlugin) PandacraftUtils.getInstance().getServer().getPluginManager().getPlugin("WorldGuard");
|
||||||
|
} catch (Exception e) { return null; }
|
||||||
|
}
|
||||||
|
}
|
@ -8,4 +8,19 @@ public class StringUtil {
|
|||||||
else
|
else
|
||||||
return String.valueOf((float)d);
|
return String.valueOf((float)d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param s Chaine de caractère à parcourir
|
||||||
|
* @param c_match le caractère dont on doit retourner le nombre d'occurence
|
||||||
|
* @return nombre d'occurence de <b>c_match</b> dans <b>s</b>
|
||||||
|
*/
|
||||||
|
public static int char_count(CharSequence s, char c_match)
|
||||||
|
{
|
||||||
|
char[] chars = s.toString().toCharArray();
|
||||||
|
int count = 0;
|
||||||
|
for (char c : chars)
|
||||||
|
if (c == c_match)
|
||||||
|
count++;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user