use of org.bukkit.entity.EntityType in project Essentials by drtshock.
the class EssentialsAntiBuildListener method onHangingBreak.
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onHangingBreak(final HangingBreakByEntityEvent event) {
final Entity entity = event.getRemover();
if (entity instanceof Player) {
final User user = ess.getUser((Player) entity);
final EntityType type = event.getEntity().getType();
final boolean warn = ess.getSettings().warnOnBuildDisallow();
if (prot.getSettingBool(AntiBuildConfig.disable_build) && !user.canBuild() && !user.isAuthorized("essentials.build")) {
if (type == EntityType.PAINTING && !metaPermCheck(user, "break", Material.PAINTING.getId())) {
if (warn) {
user.sendMessage(tl("antiBuildBreak", Material.PAINTING.toString()));
}
event.setCancelled(true);
} else if (type == EntityType.ITEM_FRAME && !metaPermCheck(user, "break", Material.ITEM_FRAME.getId())) {
if (warn) {
user.sendMessage(tl("antiBuildBreak", Material.ITEM_FRAME.toString()));
}
event.setCancelled(true);
}
}
}
}
use of org.bukkit.entity.EntityType in project Essentials by drtshock.
the class SpawnerProvider method tryProvider.
@Override
public boolean tryProvider() {
try {
EntityType type = EntityType.CREEPER;
ItemStack is = setEntityType(new ItemStack(Material.MOB_SPAWNER), type);
EntityType readType = getEntityType(is);
return type == readType;
} catch (Throwable t) {
return false;
}
}
use of org.bukkit.entity.EntityType in project StackMob-2 by Nathat23.
the class Commands method onCommand.
@Override
public // the nest of doom.
boolean onCommand(CommandSender sender, Command cmd, String name, String[] args) {
if (args.length == 0) {
if (sender.hasPermission("StackMob.*") || sender.hasPermission("StackMob.Admin")) {
sender.sendMessage(pluginTag + ChatColor.GOLD + "Plugin commands:");
sender.sendMessage(ChatColor.AQUA + "/sm spawnstack [size] [entity type] " + ChatColor.GREEN + "Spawns a new pre-stacked entity.");
sender.sendMessage(ChatColor.AQUA + "/sm removeall " + ChatColor.GREEN + "Removes all of the stacked entities loaded.");
sender.sendMessage(ChatColor.AQUA + "/sm remove [radius] " + ChatColor.GREEN + "Removes all of the stacked entities loaded in the specified radius.");
sender.sendMessage(ChatColor.AQUA + "/sm stats " + ChatColor.GREEN + "Displays entity statistics.");
sender.sendMessage(ChatColor.AQUA + "/sm reload " + ChatColor.GREEN + "Reloads the configuration file.");
sender.sendMessage(ChatColor.AQUA + "/sm reset " + ChatColor.GREEN + "Resets the configuration file.");
sender.sendMessage(ChatColor.AQUA + "/sm check " + ChatColor.GREEN + "Checks for version updates.");
sender.sendMessage(ChatColor.AQUA + "/sm update " + ChatColor.GREEN + "Downloads the latest version.");
sender.sendMessage(ChatColor.AQUA + "/sm about " + ChatColor.GREEN + "Shows plugin information.");
} else {
sender.sendMessage(noPerm);
}
} else if (args.length == 1) {
if (sender.hasPermission("StackMob.*") || sender.hasPermission("StackMob.Admin")) {
if (args[0].equalsIgnoreCase("about")) {
sender.sendMessage(pluginTag + ChatColor.GOLD + "StackMob v" + sm.getDescription().getVersion() + " by antiPerson and contributors.");
sender.sendMessage(pluginTag + ChatColor.YELLOW + "Find out more at " + sm.getDescription().getWebsite());
sender.sendMessage(pluginTag + ChatColor.YELLOW + "Find the source code at " + GlobalValues.GITHUB);
sender.sendMessage(pluginTag + ChatColor.YELLOW + "Has this plugin helped your server? Please leave a review!");
} else if (args[0].equalsIgnoreCase("reset")) {
sm.config.getF().delete();
sm.config.reloadCustomConfig();
sender.sendMessage(pluginTag + ChatColor.GREEN + "The configuration has been reset and reloaded.");
} else if (args[0].equalsIgnoreCase("reload")) {
sm.config.reloadCustomConfig();
sender.sendMessage(pluginTag + ChatColor.GREEN + "The configuration has been reloaded.");
} else if (args[0].equalsIgnoreCase("removeall")) {
int counter = 0;
for (World world : Bukkit.getWorlds()) {
for (Entity entity : world.getLivingEntities()) {
if (entity.hasMetadata(GlobalValues.METATAG)) {
counter++;
entity.remove();
}
}
}
sender.sendMessage(pluginTag + ChatColor.GREEN + "A total of " + counter + " entities were removed.");
} else if (args[0].equalsIgnoreCase("check")) {
sender.sendMessage(pluginTag + ChatColor.GOLD + sm.updater.updateString());
} else if (args[0].equalsIgnoreCase("update")) {
sender.sendMessage(pluginTag + ChatColor.GOLD + sm.updater.update());
} else if (args[0].equalsIgnoreCase("stats")) {
int stackedCount = 0;
int stackedTotal = 0;
for (World world : Bukkit.getWorlds()) {
for (Entity entity : world.getLivingEntities()) {
if (entity.hasMetadata(GlobalValues.METATAG)) {
stackedCount = stackedCount + 1;
stackedTotal = stackedTotal + entity.getMetadata(GlobalValues.METATAG).get(0).asInt();
}
}
}
int stackedCount1 = 0;
int stackedTotal1 = 0;
if (sender instanceof Player) {
for (Entity entity : ((Player) sender).getLocation().getChunk().getEntities()) {
if (entity.hasMetadata(GlobalValues.METATAG)) {
stackedCount1 = stackedCount1 + 1;
stackedTotal1 = stackedTotal1 + entity.getMetadata(GlobalValues.METATAG).get(0).asInt();
}
}
}
int cacheTotal = 0;
for (UUID uuid : sm.cache.amountCache.keySet()) {
if (sm.cache.amountCache.get(uuid) > 0) {
cacheTotal = cacheTotal + sm.cache.amountCache.get(uuid);
}
}
sender.sendMessage(pluginTag + ChatColor.GOLD + "Entity stacking statistics:");
sender.sendMessage(ChatColor.YELLOW + "Loaded entities: " + ChatColor.GREEN + stackedCount + " (" + stackedTotal + " stacked.) " + ChatColor.YELLOW + "Loaded entities (this chunk): " + ChatColor.GREEN + stackedCount1 + " (" + stackedTotal1 + " stacked.) ");
sender.sendMessage(ChatColor.YELLOW + "Cached entities: " + ChatColor.GREEN + sm.cache.amountCache.size() + " (" + cacheTotal + " stacked.) ");
} else {
sender.sendMessage(pluginTag + errorTag + "Incorrect command parameters!");
}
} else {
if (args[0].equalsIgnoreCase("nick")) {
sender.sendMessage("england is my city");
} else {
sender.sendMessage(noPerm);
}
}
} else if (args.length == 2) {
if (args[0].equalsIgnoreCase("remove")) {
if (sender.hasPermission("StackMob.*") || sender.hasPermission("StackMob.Admin")) {
if (sender instanceof Player) {
Integer numb = Integer.valueOf(args[1]);
if (numb != null) {
int counter = 0;
for (Entity entity : ((Player) sender).getNearbyEntities(numb, numb, numb)) {
if (entity.hasMetadata(GlobalValues.METATAG)) {
entity.remove();
counter++;
}
}
sender.sendMessage(pluginTag + ChatColor.GREEN + "A total of " + counter + " entities were removed.");
} else {
sender.sendMessage(pluginTag + errorTag + "Invalid number format!");
}
} else {
sender.sendMessage(pluginTag + errorTag + "You need to be a player to do this!");
}
} else {
sender.sendMessage(noPerm);
}
} else {
sender.sendMessage(pluginTag + errorTag + "Incorrect command parameters!");
}
} else if (args.length == 3) {
if (args[0].equalsIgnoreCase("spawnstack")) {
if (sender.hasPermission("StackMob.*") || sender.hasPermission("StackMob.Admin")) {
if (sender instanceof Player) {
Integer numb;
try {
numb = Integer.valueOf(args[1]);
} catch (NumberFormatException e) {
sender.sendMessage(pluginTag + errorTag + "Invalid number format!");
return false;
}
boolean contains = false;
for (EntityType type : EntityType.values()) {
if (args[2].equalsIgnoreCase(type.toString())) {
contains = true;
}
}
if (contains) {
Entity newEntity = ((Player) sender).getWorld().spawnEntity(((Player) sender).getLocation(), EntityType.valueOf(args[2].toUpperCase()));
newEntity.setMetadata(GlobalValues.NO_SPAWN_STACK, new FixedMetadataValue(sm, true));
newEntity.setMetadata(GlobalValues.METATAG, new FixedMetadataValue(sm, numb));
sender.sendMessage(pluginTag + ChatColor.GREEN + "Spawned a " + args[2].toUpperCase() + " with a stack size of " + numb + " at your location.");
} else {
sender.sendMessage(pluginTag + errorTag + "Invalid entity type!");
}
} else {
sender.sendMessage(pluginTag + errorTag + "You need to be a player to do this!");
}
} else {
sender.sendMessage(noPerm);
}
} else {
sender.sendMessage(pluginTag + errorTag + "Incorrect command parameters!");
}
} else {
sender.sendMessage(pluginTag + errorTag + "Incorrect command parameters!");
}
return false;
}
use of org.bukkit.entity.EntityType in project CloudNet by Dytanic.
the class CommandCloudServer method onCommand.
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
if (!(commandSender instanceof Player))
return false;
Player player = (Player) commandSender;
if (args.length > 5) {
if (args[0].equalsIgnoreCase("createMob")) {
if (MobSelector.getInstance() == null) {
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The Module \"MobSelector\" isn't enabled!");
return false;
}
try {
EntityType entityType = EntityType.valueOf(args[1].toUpperCase());
if (!entityType.isAlive() || !entityType.isSpawnable())
return false;
if (CollectionWrapper.filter(MobSelector.getInstance().getMobs().values(), new Acceptable<MobSelector.MobImpl>() {
@Override
public boolean isAccepted(MobSelector.MobImpl value) {
return value.getMob().getName().equalsIgnoreCase(args[2]);
}
}) == null) {
StringBuilder stringBuilder = new StringBuilder();
for (short i = 6; i < args.length; i++) {
stringBuilder.append(args[i]).append(NetworkUtils.SPACE_STRING);
}
if (stringBuilder.length() > 32) {
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The display cannot be longe then 32 characters");
return false;
}
ServerMob serverMob = new ServerMob(UUID.randomUUID(), stringBuilder.substring(0, stringBuilder.length() - 1), args[2], entityType.name(), args[3], NetworkUtils.checkIsNumber(args[4]) ? (Integer.parseInt(args[4]) != 0 ? Integer.parseInt(args[4]) : 138) : 138, args[5].equalsIgnoreCase("true"), MobSelector.getInstance().toPosition(CloudAPI.getInstance().getGroup(), player.getLocation()), "§8#§c%group% &bPlayers online §8|§7 %group_online% of %max_players%", new Document());
CloudAPI.getInstance().getNetworkConnection().sendPacket(new PacketOutAddMob(serverMob));
player.sendMessage(CloudAPI.getInstance().getPrefix() + "The mob will be created, please wait...");
} else {
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The mob with the name " + args[2] + " already exists!");
return false;
}
} catch (Exception ex) {
for (EntityType entityType : EntityType.values()) commandSender.sendMessage("- " + entityType.name());
}
}
}
if (args.length > 2) {
if (args[0].equalsIgnoreCase("editMobLine")) {
if (MobSelector.getInstance() == null) {
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The Module \"MobSelector\" isn't enabled!");
return false;
}
MobSelector.MobImpl mob = CollectionWrapper.filter(MobSelector.getInstance().getMobs().values(), new Acceptable<MobSelector.MobImpl>() {
@Override
public boolean isAccepted(MobSelector.MobImpl value) {
return value.getMob().getName().equalsIgnoreCase(args[1]);
}
});
if (mob != null) {
StringBuilder stringBuilder = new StringBuilder();
for (short i = 2; i < args.length; i++) stringBuilder.append(args[i]).append(NetworkUtils.SPACE_STRING);
mob.getMob().setDisplayMessage(stringBuilder.substring(0, stringBuilder.length() - 1));
CloudAPI.getInstance().getNetworkConnection().sendPacket(new PacketOutAddMob(mob.getMob()));
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "You set the mobline for \"" + args[1] + "\" the line \"" + stringBuilder.substring(0, stringBuilder.length() - 1) + "\"");
return false;
}
}
if (args[0].equalsIgnoreCase("setDisplay")) {
MobSelector.MobImpl mob = CollectionWrapper.filter(MobSelector.getInstance().getMobs().values(), new Acceptable<MobSelector.MobImpl>() {
@Override
public boolean isAccepted(MobSelector.MobImpl value) {
return value.getMob().getName().equalsIgnoreCase(args[1]);
}
});
if (mob != null) {
StringBuilder stringBuilder = new StringBuilder();
for (short i = 2; i < args.length; i++) stringBuilder.append(args[i]).append(NetworkUtils.SPACE_STRING);
mob.getMob().setDisplay(stringBuilder.substring(0, stringBuilder.length() - 1));
CloudAPI.getInstance().getNetworkConnection().sendPacket(new PacketOutAddMob(mob.getMob()));
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "You set the display for \"" + args[1] + "\" the line \"" + stringBuilder.substring(0, stringBuilder.length() - 1) + "\"");
return false;
}
}
}
switch(args.length) {
case 2:
if (args[0].equalsIgnoreCase("createSign")) {
if (SignSelector.getInstance() == null) {
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The Module \"SignSelector\" isn't enabled!");
return false;
}
Block block = player.getTargetBlock((HashSet<Material>) null, 15);
if (block.getState() instanceof org.bukkit.block.Sign)
if (!SignSelector.getInstance().containsPosition(block.getLocation())) {
if (CloudAPI.getInstance().getServerGroupMap().containsKey(args[1])) {
Sign sign = new Sign(args[1], SignSelector.getInstance().toPosition(block.getLocation()));
CloudAPI.getInstance().getNetworkConnection().sendPacket(new PacketOutAddSign(sign));
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The sign was successfully created!");
} else
commandSender.sendMessage("The group doesn't exist");
} else
commandSender.sendMessage("The sign already exists!");
return false;
}
if (args[0].equalsIgnoreCase("removeSigns")) {
if (SignSelector.getInstance() == null) {
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The Module \"SignSelector\" isn't enabled!");
return false;
}
for (Sign sign : SignSelector.getInstance().getSigns().values()) if (sign.getTargetGroup() != null && sign.getTargetGroup().equalsIgnoreCase(args[1]))
CloudAPI.getInstance().getNetworkConnection().sendPacket(new PacketOutRemoveSign(sign));
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "§7You deleted all signs from the group \"§6" + args[1] + "§7\"");
}
if (args[0].equalsIgnoreCase("removeMob")) {
if (MobSelector.getInstance() == null) {
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The Module \"MobSelector\" isn't enabled!");
return false;
}
MobSelector.MobImpl mob = CollectionWrapper.filter(MobSelector.getInstance().getMobs().values(), new Acceptable<MobSelector.MobImpl>() {
@Override
public boolean isAccepted(MobSelector.MobImpl value) {
return value.getMob().getName().equalsIgnoreCase(args[1]);
}
});
if (mob != null) {
CloudAPI.getInstance().getNetworkConnection().sendPacket(new PacketOutRemoveMob(mob.getMob()));
player.sendMessage(CloudAPI.getInstance().getPrefix() + "The mob has been removed");
} else
player.sendMessage(CloudAPI.getInstance().getPrefix() + "The Mob doesn't exist on this group");
}
break;
case 1:
if (args[0].equalsIgnoreCase("removeSign")) {
if (SignSelector.getInstance() == null) {
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The Module \"SignSelector\" isn't enabled!");
return false;
}
Block block = player.getTargetBlock((HashSet<Byte>) null, 15);
if (block.getState() instanceof org.bukkit.block.Sign) {
if (SignSelector.getInstance().containsPosition(block.getLocation())) {
Sign sign = SignSelector.getInstance().getSignByPosition(block.getLocation());
if (sign != null) {
CloudAPI.getInstance().getNetworkConnection().sendPacket(new PacketOutRemoveSign(sign));
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The sign has been removed");
}
}
}
}
if (args[0].equalsIgnoreCase("listMobs")) {
if (MobSelector.getInstance() == null) {
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The Module \"MobSelector\" isn't enabled!");
return false;
}
CollectionWrapper.iterator(MobSelector.getInstance().getMobs().values(), new Runnabled<MobSelector.MobImpl>() {
@Override
public void run(MobSelector.MobImpl obj) {
commandSender.sendMessage("- " + obj.getMob().getName());
}
});
}
if (args[0].equalsIgnoreCase("moblist")) {
if (MobSelector.getInstance() == null) {
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The Module \"MobSelector\" isn't enabled!");
return false;
}
for (EntityType entityType : EntityType.values()) {
if (entityType.isAlive() && entityType.isSpawnable())
commandSender.sendMessage("- " + entityType.name());
}
}
break;
case 3:
if (args[0].equalsIgnoreCase("setItem")) {
if (MobSelector.getInstance() == null) {
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The Module \"MobSelector\" isn't enabled!");
return false;
}
MobSelector.MobImpl mob = CollectionWrapper.filter(MobSelector.getInstance().getMobs().values(), new Acceptable<MobSelector.MobImpl>() {
@Override
public boolean isAccepted(MobSelector.MobImpl value) {
return value.getMob().getName().equalsIgnoreCase(args[1]);
}
});
if (mob != null) {
int itemId = NetworkUtils.checkIsNumber(args[2]) ? Integer.parseInt(args[2]) : 138;
mob.getMob().setItemId(itemId);
CloudAPI.getInstance().getNetworkConnection().sendPacket(new PacketOutAddMob(mob.getMob()));
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "You set the item for \"" + args[1] + "\" the itemId \"" + itemId + "\"");
return false;
}
}
break;
default:
if (SignSelector.getInstance() != null) {
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver createSign <targetGroup>");
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver removeSign");
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver removeSigns <targetGroup>");
}
if (MobSelector.getInstance() != null) {
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver createMob <entityType> <name> <targetGroup> <itemId> <autoJoin> <displayName>");
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver removeMob <name>");
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver listMobs");
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver moblist");
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver setDisplay <name> <display>");
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver setItem <name> <itemId>");
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver editMobLine <name> <display>");
}
break;
}
return false;
}
use of org.bukkit.entity.EntityType in project CommandHelper by EngineHub.
the class BukkitMCBlockProjectileSource method launchProjectile.
@Override
public MCProjectile launchProjectile(MCProjectileType projectile) {
EntityType et = EntityType.valueOf(projectile.name());
Class<? extends Entity> c = et.getEntityClass();
Projectile proj = bps.launchProjectile(c.asSubclass(Projectile.class));
MCEntity e = BukkitConvertor.BukkitGetCorrectEntity(proj);
if (e instanceof MCProjectile) {
return (MCProjectile) e;
} else {
return null;
}
}
Aggregations