org.bukkit.SkullType Java Examples

The following examples show how to use org.bukkit.SkullType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CraftSkull.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
static SkullType getSkullType(int id) {
    switch (id) {
        case 0:
            return SkullType.SKELETON;
        case 1:
            return SkullType.WITHER;
        case 2:
            return SkullType.ZOMBIE;
        case 3:
            return SkullType.PLAYER;
        case 4:
            return SkullType.CREEPER;
        default:
            throw new AssertionError(id);
    }
}
 
Example #2
Source File: Utils.java    From Shopkeepers with GNU General Public License v3.0 6 votes vote down vote up
public static boolean isCustomHeadItem(ItemStack item) {
	if (item == null) return false;
	if (item.getType() != Material.SKULL_ITEM) {
		return false;
	}
	if (item.getDurability() != SkullType.PLAYER.ordinal()) {
		return false;
	}

	ItemMeta meta = item.getItemMeta();
	if (meta instanceof SkullMeta) {
		SkullMeta skullMeta = (SkullMeta) meta;
		if (skullMeta.hasOwner() && skullMeta.getOwner() == null) {
			// custom head items usually don't have a valid owner
			return true;
		}
	}
	return false;
}
 
Example #3
Source File: CraftSkull.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean update(boolean force, boolean applyPhysics) {
    boolean result = super.update(force, applyPhysics);

    if (result) {
        if (skullType == SkullType.PLAYER) {
            skull.func_152106_a(profile);
        } else {
            skull.func_152107_a(getSkullType(skullType));
        }

        skull.func_145903_a(rotation);
        skull.markDirty();
    }

    return result;
}
 
Example #4
Source File: CraftSkull.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
public boolean setOwner(String name) {
    if (name == null || name.length() > MAX_OWNER_LENGTH) {
        return false;
    }

    GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a (name);
    if (profile == null) {
        return false;
    }

    if (skullType != SkullType.PLAYER) {
        skullType = SkullType.PLAYER;
    }

    this.profile = profile;
    return true;
}
 
Example #5
Source File: CraftSkull.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
static int getSkullType(SkullType type) {
    switch(type) {
        case SKELETON:
            return 0;
        case WITHER:
            return 1;
        case ZOMBIE:
            return 2;
        case PLAYER:
            return 3;
        case CREEPER:
            return 4;
        default:
            throw new AssertionError(type);
    }
}
 
Example #6
Source File: CraftSkull.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean setOwner(String name) {
    if (name == null || name.length() > MAX_OWNER_LENGTH) {
        return false;
    }

    GameProfile profile = MinecraftServer.getServerCB().getPlayerProfileCache().getGameProfileForUsername(name);
    if (profile == null) {
        return false;
    }

    if (skullType != SkullType.PLAYER) {
        skullType = SkullType.PLAYER;
    }

    this.profile = profile;
    return true;
}
 
Example #7
Source File: CraftSkull.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
static int getSkullType(SkullType type) {
    switch (type) {
        default:
        case SKELETON:
            return 0;
        case WITHER:
            return 1;
        case ZOMBIE:
            return 2;
        case PLAYER:
            return 3;
        case CREEPER:
            return 4;
        case DRAGON:
            return 5;
    }
}
 
Example #8
Source File: CraftSkull.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
static SkullType getSkullType(int id) {
    switch (id) {
        default:
        case 0:
            return SkullType.SKELETON;
        case 1:
            return SkullType.WITHER;
        case 2:
            return SkullType.ZOMBIE;
        case 3:
            return SkullType.PLAYER;
        case 4:
            return SkullType.CREEPER;
        case 5:
            return SkullType.DRAGON;
    }
}
 
Example #9
Source File: CraftSkull.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setOwningPlayer(OfflinePlayer player) {
    Preconditions.checkNotNull(player, "player");

    if (skullType != SkullType.PLAYER) {
        skullType = SkullType.PLAYER;
    }

    this.profile = new GameProfile(player.getUniqueId(), player.getName());
}
 
Example #10
Source File: CraftSkull.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setSkullType(SkullType skullType) {
    this.skullType = skullType;

    if (skullType != SkullType.PLAYER) {
        profile = null;
    }
}
 
Example #11
Source File: CraftSkull.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void applyTo(TileEntitySkull skull) {
    super.applyTo(skull);

    if (skullType == SkullType.PLAYER) {
        skull.setPlayerProfile(profile);
    } else {
        skull.setType(getSkullType(skullType));
    }

    skull.setSkullRotation(rotation);
}
 
Example #12
Source File: CraftSkull.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public void setSkullType(SkullType skullType) {
    this.skullType = skullType;

    if (skullType != SkullType.PLAYER) {
        profile = null;
    }
}
 
Example #13
Source File: PlayerHeadProvider.java    From UHC with MIT License 5 votes vote down vote up
public void setBlockAsHead(String name, Block headBlock, BlockFaceXZ direction) {
    // set the type to skull
    headBlock.setType(Material.SKULL);
    headBlock.setData((byte) 1);

    final Skull state = (Skull) headBlock.getState();

    state.setSkullType(SkullType.PLAYER);
    state.setOwner(name);
    state.setRotation(direction.getBlockFace());
    state.update();
}
 
Example #14
Source File: FlagTrackingSpectate.java    From HeavySpleef with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Subscribe
public void onPlayerJoinGame(PlayerJoinGameEvent event) {
	SpleefPlayer player = event.getPlayer();
	GuiInventory trackerInventory = getTrackerInventory();
	
	//Insert the player's head somewhere in the tracker inventory
	for (int y = 0; y < trackerInventory.getLines(); y++) {
		for (int x = 0; x < GuiInventory.SLOTS_PER_LINE; x++) {
			trackerInventory.getSlot(x, y);
			
			GuiInventorySlot slot = trackerInventory.getSlot(x, y);
			if (slot.getItem() != null) {
				continue;
			}
			
			MaterialData data = new MaterialData(Material.SKULL_ITEM, (byte)SkullType.PLAYER.ordinal());
			ItemStack skull = data.toItemStack(1);
			SkullMeta meta = (SkullMeta) skull.getItemMeta();
			meta.setDisplayName(getI18N().getVarString(Messages.Player.TRACKER_SKULL_TITLE)
					.setVariable("tracking", player.getDisplayName())
					.toString());
			meta.setOwner(player.getName());
			skull.setItemMeta(meta);
			
			slot.setItem(skull);
			slot.setValue(player);
			break;
		}
	}
	
	trackerInventory.updateViews();
}
 
Example #15
Source File: UHPluginListener.java    From KTP with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onPlayerDeath(final PlayerDeathEvent ev) {
	Location l = ev.getEntity().getLocation();
	for (Player ps : Bukkit.getOnlinePlayers()) {
		ps.playSound(ps.getLocation(), Sound.ENTITY_WITHER_SPAWN, 1F, 1F);
	}
	this.p.addDead(ev.getEntity().getName());
	Bukkit.getScheduler().runTaskLater(this.p, new BukkitRunnable() {
		
		@Override
		public void run() {
			p.setLife((Player)ev.getEntity(), 0);
		}
	}, 1L);
	if (this.p.getConfig().getBoolean("kick-on-death.kick", true)) {
		Bukkit.getScheduler().runTaskLater(this.p, new BukkitRunnable() {
			
			@Override
			public void run() {
				ev.getEntity().kickPlayer("jayjay");
			}
		}, 20L*this.p.getConfig().getInt("kick-on-death.time", 30));
	}
	
	try { 
		ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
		SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
		skullMeta.setOwner(((Player)ev.getEntity()).getName());
		skullMeta.setDisplayName(ChatColor.RESET + ((Player)ev.getEntity()).getName());
		skull.setItemMeta(skullMeta);
		l.getWorld().dropItem(l, skull);
	} catch (Exception e) {
		e.printStackTrace();
	}

}
 
Example #16
Source File: CraftSkull.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public SkullType getSkullType() {
    return skullType;
}
 
Example #17
Source File: ItemConfigurationParser.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public ItemStack needSkull(ConfigurationSection section, String key) throws InvalidConfigurationException {
    final ItemStack stack = new ItemStack(Material.SKULL_ITEM);
    stack.setDurability((short) SkullType.PLAYER.ordinal());
    needSkull(stack, section, key);
    return stack;
}
 
Example #18
Source File: CraftSkull.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public SkullType getSkullType() {
    return skullType;
}
 
Example #19
Source File: Skull.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Gets the type of skull
 *
 * @return the type of skull
 */
public SkullType getSkullType();
 
Example #20
Source File: Skull.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Sets the type of skull
 *
 * @param skullType the type of skull
 */
public void setSkullType(SkullType skullType);