Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.tke.admin;
- import java.util.ArrayList;
- import java.util.List;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.enchantments.Enchantment;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.entity.PlayerDeathEvent;
- import org.bukkit.event.player.PlayerInteractEntityEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.util.Vector;
- public class Admin implements Listener , CommandExecutor{
- private static List<String> modo = new ArrayList<String>();
- private static List<String> nofall = new ArrayList<String>();
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String lb, String[] args) {
- if (!(sender instanceof Player)) return true;
- Player p = (Player)sender;
- if (cmd.getName().equalsIgnoreCase("admin")){
- if (!(p.isOp())) {
- p.sendMessage("§cVocê não tem OP!");
- return true;
- }
- if (modo.contains(p.getName())){
- modo.remove(p.getName());
- p.sendMessage("§cVocê saiu do modo Admin!");
- p.getInventory().clear();
- p.getEquipment().setArmorContents(null);
- for (Player players : Bukkit.getOnlinePlayers()){
- players.showPlayer(p);
- }
- } else {
- for (Player players : Bukkit.getOnlinePlayers()){
- if (players.isOp()){
- players.showPlayer(p);
- } else {
- players.hidePlayer(p);
- }
- }
- modo.add(p.getName());
- p.sendMessage("§aVocê entrou no modo Admin!");
- p.getInventory().clear();
- p.getEquipment().setArmorContents(null);
- ItemStack prisao = Criar.add(Material.IRON_FENCE, "§7Prisao");
- ItemStack fall = Criar.add(Material.BEACON, "§6Teste de No-Fall");
- ItemStack knock = Criar.add(Material.DIAMOND_PICKAXE, "§5Teste de Anti-KnockBack", Enchantment.KNOCKBACK, 10);
- p.getInventory().setItem(1, prisao);
- p.getInventory().setItem(4, fall);
- p.getInventory().setItem(7, knock);
- }
- }
- return false;
- }
- @EventHandler
- public void onFall(PlayerDeathEvent e){
- if (e.getEntity() instanceof Player){
- Player p = (Player)e.getEntity();
- if (nofall.contains(p.getName())){
- nofall.remove(p.getName());
- }
- }
- }
- @EventHandler
- public void onInteract(PlayerInteractEntityEvent e){
- if (!(e.getRightClicked() instanceof Player)){
- return;
- }
- final Player p = (Player)e.getPlayer();
- final Player target = (Player)e.getRightClicked();
- if (modo.contains(p.getName()) && p.getItemInHand().getItemMeta().getDisplayName().equals("§7Prisao")){
- double x = target.getLocation().getX();
- double y = target.getLocation().getY() + 7;
- double z = target.getLocation().getZ();
- World world = target.getWorld();
- Material tipo = Material.BEDROCK;
- Location loc1 = new Location(world, x + 1, y, z);
- Location loc2 = new Location(world, x - 1, y, z);
- Location loc3 = new Location(world, x, y, z + 1);
- Location loc4 = new Location(world, x, y, z - 1);
- Location loc5 = new Location(world, x, y - 1, z);
- Location loc6 = new Location(world, x, y + 2, z);
- world.getBlockAt(loc1).setType(tipo);
- world.getBlockAt(loc2).setType(tipo);
- world.getBlockAt(loc3).setType(tipo);
- world.getBlockAt(loc4).setType(tipo);
- world.getBlockAt(loc5).setType(tipo);
- world.getBlockAt(loc6).setType(tipo);
- target.teleport(new Location(world, x, y, z));
- p.sendMessage("§aVocê prendeu o jogador: §f" + target.getName());
- }
- if (modo.contains(p.getName()) && p.getItemInHand().getItemMeta().getDisplayName().equals("§6Teste de No-Fall")){
- target.setVelocity(new Vector(target.getVelocity().getX(), target.getVelocity().getY() + 10, target.getVelocity().getZ()));
- nofall.add(target.getName());
- Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getPlugin(Main.class), new Runnable() {
- public void run() {
- if (nofall.contains(target.getName())){
- p.sendMessage("§cJogador: §f" + target.getName() + "§c Está de No-Fall");
- } else {
- p.sendMessage("§aJogador: §f" + target.getName() + "§a não está de No-Fall");
- }
- }
- }, 8*20);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement