Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.LobbyTest.src;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.block.Block;
- import org.bukkit.block.Sign;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.block.SignChangeEvent;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.plugin.PluginManager;
- import org.bukkit.plugin.java.JavaPlugin;
- public class MainClass extends JavaPlugin implements Listener {
- @Override
- public void onEnable()
- {
- getConfig().createSection("Lobby");
- getConfig().createSection("Lobby.x");
- getConfig().createSection("Lobby.y");
- getConfig().createSection("Lobby.z");
- saveConfig();
- PluginManager pm = getServer().getPluginManager();
- pm.registerEvents(this, this);
- }
- @Override
- public void onDisable()
- {
- }
- //Commande de définition du Lobby
- public void goTo(Player p){
- if(!getConfig().get("Lobby").equals(null)){
- int x = getConfig().getConfigurationSection("Lobby").getInt("Lobby"+".x");
- int y = getConfig().getConfigurationSection("Lobby").getInt("Lobby"+".y");
- int z = getConfig().getConfigurationSection("Lobby").getInt("Lobby"+".z");
- String world = getConfig().getConfigurationSection("Lobby").getString("Lobby"+".world");
- Location loc = new Location(Bukkit.getWorld(world), x, y, z);
- p.teleport(loc);
- }else{
- p.sendMessage("Aucun lieu ne porte ce nom");
- }
- }
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[]args)
- {
- Player p = (Player) sender;
- if(cmd.getName().equalsIgnoreCase("setlobby"))
- {
- int locX = p.getLocation().getBlockX();
- int locY = p.getLocation().getBlockY();
- int locZ = p.getLocation().getBlockZ();
- String world = p.getWorld().getName();
- getConfig().createSection("Lobby");
- getConfig().getConfigurationSection("Lobby").set("Lobby"+".x", locX);
- getConfig().getConfigurationSection("Lobby").set("Lobby"+".y", locY);
- getConfig().getConfigurationSection("Lobby").set("Lobby"+".z", locZ);
- getConfig().getConfigurationSection("Lobby").set("Lobby"+"world", world);
- saveConfig();
- }
- return true;
- }
- //@EventHandler
- public void LobbySign(PlayerInteractEvent e)
- {
- Player p = e.getPlayer();
- Block b = e.getClickedBlock();
- if(e.getAction() == Action.RIGHT_CLICK_BLOCK)
- {
- p.sendMessage("A");
- if(b.getType() == Material.SIGN)
- {
- p.sendMessage("B");
- }
- Sign s = (Sign) b.getState();
- if(s.getLine(0).contains(ChatColor.GREEN+"Lobby"))
- {
- p.sendMessage("C");
- s.update();
- goTo(p);
- }
- }
- }
- @EventHandler
- public void ChangeLobbySign(SignChangeEvent e)
- {
- if(e.getLine(0).contains("Lobby"))
- {
- e.setLine(0, ChatColor.GREEN+"Lobby");
- e.setLine(1, ChatColor.RED+"Joueurs:");
- }
- }
- }
- package fr.test3.src;
- import java.util.ArrayList;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.block.Block;
- import org.bukkit.block.Sign;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.block.SignChangeEvent;
- import org.bukkit.event.entity.PlayerDeathEvent;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.plugin.java.JavaPlugin;
- public class MainClass extends JavaPlugin implements Listener {
- // < >
- public static ArrayList<String> blue = new ArrayList<>(); // TEAM BLUE LIST
- public static ArrayList<String> red = new ArrayList<>(); // TEAM RED LIST
- public void onEnable()
- {
- getServer().getPluginManager().registerEvents(this, this);
- System.out.println("TEST3 ENABLED.");
- getConfig().createSection("Lobby");
- getConfig().createSection("Lobby.x");
- getConfig().createSection("Lobby.z");
- getConfig().createSection("Lobby.z");
- saveConfig();
- }
- public void onDisable()
- {
- System.out.println("TEST3 DISABLED");
- }
- public void goTo(Player p, String lieu)
- {
- int x = getConfig().getConfigurationSection("Lobby").getInt("Lobby"+".x");
- int y = getConfig().getConfigurationSection("Lobby").getInt("Lobby"+".y");
- int z = getConfig().getConfigurationSection("Lobby").getInt("Lobby"+".z");
- String world = getConfig().getConfigurationSection("Lobby").getString("Lobby"+".world");
- Location loc = new Location(Bukkit.getWorld(world),x ,y ,z);
- p.teleport(loc);
- }
- //TOUTE LES COMMANDES -------------------------------------------------------------------//
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[]args)
- {
- Player p = (Player) sender;
- if(cmd.getName().equalsIgnoreCase("blue")) // JOIN TEAM BLUE
- {
- if(blue.size() < 3)
- {
- red.remove(p.getName());
- blue.remove(p.getName());
- blue.add(p.getName());
- p.sendMessage(ChatColor.GREEN+"Vous avez bien rejoins l'équipe §9bleue !");
- p.setCustomName(ChatColor.RED+p.getName());
- }
- }
- if(cmd.getName().equalsIgnoreCase("red")) // JOIN TEAM RED
- {
- if(red.size() < 3)
- {
- blue.remove(p.getName());
- red.remove(p.getName());
- red.add(p.getName());
- p.sendMessage(ChatColor.GREEN+"Vous avez bien rejoins l'équipe §crouge !");
- p.setCustomName(ChatColor.RED+p.getName());
- }
- }
- if(cmd.getName().equalsIgnoreCase("setlobby"))
- {
- int locX = p.getLocation().getBlockX();
- int locY = p.getLocation().getBlockY();
- int locZ = p.getLocation().getBlockZ();
- String world = p.getWorld().getName();
- getConfig().getConfigurationSection("Lobby").set(".x", locX);
- getConfig().getConfigurationSection("Lobby").set(".y", locY);
- getConfig().getConfigurationSection("Lobby").set(".z", locZ);
- getConfig().getConfigurationSection("Lobby").set("world", world);
- saveConfig();
- p.sendMessage(ChatColor.GOLD+"Le lobby a été défini avec succés !");
- ///////////////////////////////////////////////////////////////////////// FIN DES COMMANDES //////////////////////////////////////////////////////////////////////////////////////////
- }
- return true;
- }
- ////////////////////////////////////////EVENTS/////////////////////////////////////////////////
- @EventHandler
- public static void mort(PlayerDeathEvent e)
- {
- Player p = e.getEntity().getPlayer();
- if(blue.contains(p.getName()))
- {
- Bukkit.broadcastMessage(ChatColor.YELLOW+"Le joueur de l'équipe §9 bleue : "+p.getName()+ " §e est mort.");
- blue.remove(p.getName());
- if(blue.size() == 0)
- {
- Bukkit.broadcastMessage(ChatColor.RED+"§eL'équipe §9bleue §ea été exterminé !");
- }
- }
- if(red.contains(p.getName()))
- {
- Bukkit.broadcastMessage("§eLe joueur de l'équipe §c rouge : "+p.getName()+ " §e est mort.");
- red.remove(p.getName());
- if(red.size() == 0)
- {
- Bukkit.broadcastMessage("§eL'équipe §crouge §ea été exterminé !");
- }
- }
- }
- @EventHandler
- public void LobbySign(PlayerInteractEvent e)
- {
- Player p = e.getPlayer();
- Block b = e.getClickedBlock();
- if(e.getAction() == Action.RIGHT_CLICK_BLOCK)
- {
- if(b.getType() == Material.SIGN)
- {
- Sign s = (Sign) b.getState();
- if(s.getLine(0).contains(ChatColor.GREEN+"Lobby"))
- {
- goTo(p, "Lobby");
- p.sendMessage(ChatColor.YELLOW+"Vous avez été téléporté au lobby.");
- }
- }
- }
- }
- @EventHandler
- public void ChangeLobbySign(SignChangeEvent e)
- {
- if(e.getLine(0).contains("Lobby"))
- {
- e.setLine(0, ChatColor.GREEN+"Lobby");
- e.setLine(1, ChatColor.BLUE+"JOUEURS:");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement