daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest Feb 15th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.styplex.chests.enderchest.commands;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.Sound;
  5. import org.bukkit.command.CommandSender;
  6. import org.bukkit.entity.Player;
  7. import com.styplex.chests.StyplexChests;
  8. import com.styplex.chests.enderchest.module.PlayerEnderchest;
  9.  
  10. import styplex.utils.util.CommandBase;
  11.  
  12. public class CommandEnderchest extends CommandBase {
  13.  
  14.     public CommandEnderchest() {
  15.         super("enderchest");
  16.     }
  17.  
  18.     @Override
  19.     public boolean execute(CommandSender sender, String label, String[] args) {
  20.         if (sender instanceof Player) {
  21.             Player player = (Player) sender;
  22.            
  23.             if (args.length == 0) {
  24.                 this.openYourEnderchest(player);
  25.             } else {
  26.                 if (!player.hasPermission("styplex.command.enderchest.admin")) {
  27.                     this.openYourEnderchest(player);
  28.                     return true;
  29.                 }
  30.                
  31.                 String username = args[0];
  32.                
  33.                 if (!StyplexChests.get().getEnderchestManager().existPlayerEnderchest(username) &&
  34.                         !StyplexChests.get().getEnderchestManager().getPlayerEnderchestData().getEnderchest().contains("Enderchests." + username)) {
  35.                     sender.sendMessage("§cEste usuário não possui enderchest.");
  36.                     return true;
  37.                 }
  38.                
  39.                 if (StyplexChests.get().getEnderchestManager().isEnderchestOpen(username)) {
  40.                     Player player2 = Bukkit.getPlayer(username);
  41.                     if (player2 != null) {
  42.                         player2.closeInventory();
  43.                         player2.sendMessage("§cUm membro da equipe abriu seu enderchest.");
  44.                     }
  45.                 }
  46.                
  47.                 if (!StyplexChests.get().getEnderchestManager().existPlayerEnderchest(username)) {
  48.                     StyplexChests.get().getEnderchestManager().loadPlayerEnderchest(username);
  49.                 }
  50.                 PlayerEnderchest playerEnderchest = StyplexChests.get().getEnderchestManager().getPlayerEnderchest(username);
  51.                 player.openInventory(playerEnderchest.getEnderchest());
  52.                 player.playSound(player.getLocation(), Sound.CHEST_OPEN, 5.0f, 5.0f);
  53.             }
  54.             return true;
  55.         }
  56.         sender.sendMessage("§cApenas jogadores in-game.");
  57.         return false;
  58.     }
  59.    
  60.     private void openYourEnderchest(Player player) {
  61.         if (StyplexChests.get().getEnderchestManager().isEnderchestOpen(player.getName())) {
  62.             player.sendMessage("§cUm membro da equipe está com visualizando seu enderchest.");
  63.             return;
  64.         }
  65.        
  66.         if (!StyplexChests.get().getEnderchestManager().existPlayerEnderchest(player.getName())) {
  67.             StyplexChests.get().getEnderchestManager().loadPlayerEnderchest(player.getName());
  68.         }
  69.         PlayerEnderchest playerEnderchest = StyplexChests.get().getEnderchestManager().getPlayerEnderchest(player.getName());
  70.         player.openInventory(playerEnderchest.getEnderchest());
  71.         player.playSound(player.getLocation(), Sound.CHEST_OPEN, 5.0f, 5.0f);
  72.     }
  73.  
  74. }
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
 
Top