Development Assistance Protect Zone Around a block

Discussion in 'Plugin Help/Development/Requests' started by lordkrypton, Jun 22, 2015.

Thread Status:
Not open for further replies.
  1. Offline


    Hi guys,

    i'm looking for some help and advice.

    My plugins : When players but the block, for exemple GLASS. If the lore of the object contains somethings, like range = 16 (what is Getflat(), i don't get it ? ). A square zone appear and protect the block from getting break. And something appear on the screen of the player who placed the block and something appear in the tchat.
    I also want to create something like clans, and a clan can manager who can build in the square zone.

    Look at my code :


    package com.lordkrypton.shieldgenerator;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.HashMap;
    import java.util.Map;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    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.BlockPlaceEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import com.lordkrypton.shieldgenerator.TitleManager;
    public class Main extends JavaPlugin implements Listener{
      Map<String, Integer> stats = new HashMap<String, Integer>();
      ArrayList<Material> blocks = new ArrayList<Material>();
       public void onEnable(){
         getLogger().info("Le plugin ShieldGenerator est démarré !");
         getServer().getPluginManager().registerEvents(this, this);
       public void onBlock(BlockPlaceEvent event){
         Player player = event.getPlayer();
         if (event.getBlockPlaced().getType() == Material.BEACON){
         TitleManager.sendTitle(player, "§bFélicitations", "§fVous venez de placer un générateur de bouclier.", 100);
         this.getServer().broadcastMessage("§b[INFO] Un joueur vient de poser un générateur de bouclier.");
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
         Player player = (Player) sender;
         if (sender instanceof Player){
             ItemStack generateur = new ItemStack(Material.BEACON, 1); 
             ItemMeta sm = (ItemMeta) generateur.getItemMeta();
             sm.setDisplayName(ChatColor.YELLOW + "Générateur de bouclier");
             sm.setLore(Arrays.asList(ChatColor.BLUE + "Portée : 32 blocs !",  ChatColor.WHITE + "Permet de générer un bouclier qui protège vos constructions sur un certain rayon."));
         } else {
           sender.sendMessage("&4Vous ne pouvez pas faire cette commande depuis la console.");
         return false;
    I've found it on internet :

    package com.lordkrypton.shieldgenerator;
    import net.minecraft.server.v1_8_R1.ChatSerializer;
    import net.minecraft.server.v1_8_R1.EnumTitleAction;
    import net.minecraft.server.v1_8_R1.IChatBaseComponent;
    import net.minecraft.server.v1_8_R1.PacketPlayOutChat;
    import net.minecraft.server.v1_8_R1.PacketPlayOutTitle;
    import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
    import org.bukkit.entity.Player;
    public class TitleManager {
       public static void sendTitle(Player player, String msgTitle, String msgSubTitle, int ticks){
      IChatBaseComponent chatTitle = ChatSerializer.a("{\"text\": \"" + msgTitle + "\"}");
      IChatBaseComponent chatSubTitle = ChatSerializer.a("{\"text\": \"" + msgSubTitle + "\"}");
      PacketPlayOutTitle p = new PacketPlayOutTitle(EnumTitleAction.TITLE, chatTitle);
      PacketPlayOutTitle p2 = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, chatSubTitle);
      sendTime(player, ticks);
    private static void sendTime(Player player, int ticks){
      PacketPlayOutTitle p = new PacketPlayOutTitle(EnumTitleAction.TIMES, null, 20, ticks, 20);
    public static void sendActionBar(Player player, String message){
      IChatBaseComponent cbc = ChatSerializer.a("{\"text\": \"" + message + "\"}");
      PacketPlayOutChat ppoc = new PacketPlayOutChat(cbc, (byte) 2);

      description: Description de la commande.
      usage: /getgen [arg1] [arg2]
      permission: shieldgenerator.getgen
    Can anyone can help me about how finish my plugin ? give me advice please.

    Thank you
    Last edited: Jun 22, 2015
  2. Online

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives
    Removed very offtopic poll.
    Used code blocks instead of spoilers
Thread Status:
Not open for further replies.

Share This Page