SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package fr.wyrix.gui.template;
  2.  
  3. import java.util.Arrays;
  4.  
  5. import org.bukkit.ChatColor;
  6. import org.bukkit.Material;
  7. import org.bukkit.Statistic;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.event.inventory.ClickType;
  10. import org.bukkit.inventory.ItemStack;
  11. import org.bukkit.inventory.meta.ItemMeta;
  12.  
  13. import fr.wyrix.Main;
  14. import fr.wyrix.gui.AbstractGui;
  15.  
  16. public class GuiCustom extends AbstractGui {
  17.  
  18.     private final Main plugin;
  19.     private Player target;
  20.     private int topluck;
  21.    
  22.     public GuiCustom(Main plugin, Player target) {
  23.         super(plugin);
  24.         this.plugin = plugin;
  25.         this.target = target;
  26.     }
  27.  
  28.    
  29.     @Override
  30.     public void display(Player player) {
  31.        
  32.         this.inventory = this.plugin.getServer().createInventory(null, 6*9, "" + target.getName());
  33.        
  34.         topluck = target.getStatistic(Statistic.MINE_BLOCK, Material.DIAMOND_ORE)*100 / target.getStatistic(Statistic.MINE_BLOCK, Material.STONE);
  35.    
  36.         if(topluck == 0) {
  37.             player.sendMessage("0");
  38.             return;
  39.         }
  40.        
  41.         if(topluck >=1) {
  42.             player.sendMessage("1");
  43.         }
  44.        
  45.         ItemStack customSta = new ItemStack(Material.DIAMOND_PICKAXE, 1);
  46.         ItemMeta customS = customSta.getItemMeta();
  47.         customS.setDisplayName(ChatColor.DARK_PURPLE + "Statistiques");
  48.         customS.setLore(Arrays.asList(""+ topluck));
  49.         customSta.setItemMeta(customS);
  50.  
  51.        
  52.         this.setSlotData(ChatColor.GOLD + "Teleport Vers", Material.ENDER_PEARL, 1, null, "tp");
  53.         this.setSlotData(ChatColor.GOLD + "Teleport Ici", Material.ENDER_CHEST, 7, null, "tphere");
  54.         this.setSlotData(ChatColor.AQUA + "Fermer", Material.WOOD_DOOR, 49, null, "close");
  55.         this.setSlotData(ChatColor.RED + "Kill", Material.DEAD_BUSH, 13, null, "Mort");
  56.         this.setSlotData(ChatColor.DARK_GREEN + "Inventaire", Material.BOOK, 31, null, "Inventaire");
  57.         this.setSlotData(ChatColor.DARK_RED + "Ban", Material.LAVA_BUCKET, 20, null, "Ban");
  58.         this.setSlotData(ChatColor.DARK_RED + "Dé-Ban", Material.WATER_BUCKET, 24, null, "UnBan");
  59.         this.setSlotData(ChatColor.YELLOW + "Kick", Material.ANVIL, 43, null, "Kick");
  60.         this.setSlotData(ChatColor.BLUE + "Freez", Material.ICE, 37, null, "Freez");
  61.         this.setSlotData(customSta,4, "");
  62.        
  63.         player.openInventory(this.inventory);  
  64.     }
  65.    
  66.    
  67.  
  68.     @SuppressWarnings("deprecation")
  69.     @Override
  70.     public void onClick(Player player, ItemStack stack, String action, ClickType clickType) {
  71.         if(action.equalsIgnoreCase("close")){
  72.             this.plugin.getGuiManager().closeGui(player);
  73.         } else if(action.equalsIgnoreCase("tp")) {
  74.             player.teleport(target.getLocation());
  75.             player.sendMessage("Teleport succefull");
  76.         }
  77.         if(action.equalsIgnoreCase("Mort")) {
  78.         target.setHealth(0);
  79.         player.sendMessage("Joueur Mort");
  80.     }
  81.         else if(action.equalsIgnoreCase("Inventaire")) {
  82.             player.openInventory(target.getInventory());
  83.             //player.sendMessage("test");
  84.         }
  85.         if(action.equalsIgnoreCase("Ban")) {
  86.             target.kickPlayer("§8You have been banned by " + "§4" + player.getName());
  87.             target.setBanned(true);
  88.             }
  89.         else if(action.equalsIgnoreCase("UnBan")) {
  90.             target.setBanned(false);
  91.         }
  92.         if(action.equalsIgnoreCase("Kick")) {
  93.            
  94.             target.kickPlayer(ChatColor.GOLD +"Kick Par " + ChatColor.RED + player.getName());
  95.            
  96.         }
  97.         else if(action.equalsIgnoreCase("tphere")) {
  98.             target.teleport(player);
  99.         }
  100.  
  101.     }
  102.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top