Search in sources :

Example 6 with ComponentBuilder

use of net.md_5.bungee.api.chat.ComponentBuilder in project Ublisk by Derkades.

the class FriendsMenu method onOptionClick.

@Override
public boolean onOptionClick(OptionClickEvent event) {
    UPlayer player = new UPlayer(event);
    Material item = event.getItemStack().getType();
    if (item == Material.SPECKLED_MELON) {
        if (player.getSetting(Setting.FRIENDS_SHOW_HEALTH)) {
            player.setSetting(Setting.FRIENDS_SHOW_HEALTH, false);
            player.sendMessage(Message.FRIEND_HEALTH_DISABLED);
        } else {
            player.setSetting(Setting.FRIENDS_SHOW_HEALTH, true);
            player.sendMessage(Message.FRIEND_HEALTH_ENABLED);
        }
        return false;
    } else if (player.getFriends().isEmpty()) {
        return false;
    } else {
        // Clicked item is a player
        // OfflinePlayer friend = Ublisk.getOfflinePlayer(event.getName());
        OfflinePlayer offlineFriend = player.getFriends().get(event.getPosition());
        if (offlineFriend == null)
            player.sendMessage("error");
        UPlayer friend = new UPlayer(offlineFriend);
        player.sendMessage(friend.getDisplayName(ChatColor.DARK_AQUA, true), new ComponentBuilder(" - ").color(ChatColor.DARK_GRAY).bold(true).create(), new ComponentBuilder("Remove friend").color(ChatColor.RED).italic(true).event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/friend remove " + friend.getName())).create());
        return true;
    }
}
Also used : UPlayer(xyz.derkades.ublisk.utils.UPlayer) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) OfflinePlayer(org.bukkit.OfflinePlayer) Material(org.bukkit.Material) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder)

Example 7 with ComponentBuilder

use of net.md_5.bungee.api.chat.ComponentBuilder in project Ublisk by Derkades.

the class Guild method invitePlayer.

public synchronized void invitePlayer(final UPlayer source, final UPlayer target) {
    if (!this.exists())
        throw new UnsupportedOperationException("Cannot invite player to non-existent guild.");
    final GuildInvite invite = new GuildInvite(this, source);
    // Add invite to list of invites, and remove it after 60 seconds (if it hasn't been accepted)
    GUILD_INVITES.put(target.getName(), invite);
    new BukkitRunnable() {

        public void run() {
            if (GUILD_INVITES.containsKey(target.getName())) {
                GUILD_INVITES.remove(target.getName());
            }
        }
    }.runTaskLater(Main.getInstance(), 60 * 20);
    TextComponent inviteMessage = new TextComponent(source.getName() + " has invited you to join " + this.getName() + ". ");
    inviteMessage.setColor(ChatColor.DARK_AQUA);
    inviteMessage.setBold(true);
    BaseComponent[] hoverText = new ComponentBuilder("Click me!").color(ChatColor.YELLOW).create();
    TextComponent clickToAccept = new TextComponent("Click here to accept.");
    clickToAccept.setColor(ChatColor.AQUA);
    clickToAccept.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText));
    clickToAccept.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/guild accept"));
    BaseComponent[] components = new BaseComponent[] { inviteMessage, clickToAccept };
    target.sendMessage(components);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) HoverEvent(net.md_5.bungee.api.chat.HoverEvent) BaseComponent(net.md_5.bungee.api.chat.BaseComponent) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder)

Example 8 with ComponentBuilder

use of net.md_5.bungee.api.chat.ComponentBuilder in project VehiclesPlus2.0 by legofreak107.

the class Car method Car.

public static void Car(PacketPlayInSteerVehicle ppisv, Player p) {
    ArmorStand a2 = (ArmorStand) p.getVehicle();
    Seat s = plugin.seatInfo.get(a2);
    ArmorStand a = (ArmorStand) s.parent;
    Vehicle v = plugin.vehicleInfo.get(a);
    if (v.running) {
        if (v.curSpeed > 0)
            v.mileAge += 0.005 * v.curSpeed;
        if (v.curSpeed < 0)
            v.mileAge -= 0.005 * v.curSpeed;
        if (p.getOpenInventory() != null && p.getOpenInventory() instanceof PlayerInventory) {
            p.openInventory(v.inv);
        }
        float forward = ppisv.b();
        float side = ppisv.a();
        if (v.fuelbar == null) {
            BossBar b = Bukkit.createBossBar("fuel" + v.owner, BarColor.GREEN, BarStyle.SOLID);
            v.fuelbar = b;
        }
        Location tloc = a2.getLocation().clone();
        Location smoke = tloc.add(tloc.getDirection().setY(0).normalize().multiply(-1.5));
        smoke.getWorld().spawnParticle(Particle.SMOKE_LARGE, smoke.getX(), smoke.getY() + 1, smoke.getZ(), 1, 0, 0, 0, 0);
        v.fuelbar.setTitle("�2Fuel: " + (int) (v.fuel / v.maxFuel * 100) + "%");
        v.fuelbar.setProgress((v.fuel / v.maxFuel));
        p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new ComponentBuilder("�6Mileage: " + (int) v.mileAge).create());
        if (!v.parts.ENGINE) {
        } else {
            if (v.fuelbar.getPlayers().contains(p)) {
            } else {
                v.fuelbar.addPlayer(p);
                v.fuelbar.setVisible(true);
            }
            if (v.fuel <= 0.5) {
                v.fuelbar.setTitle("Out of fuel!");
                v.running = false;
            } else {
                v.fuel -= v.fualUsage / 2;
                if (forward > 0) {
                    // Forward[W]
                    int broken = randInt(0, (int) (20000));
                    int brokenEngine = randInt(0, (int) (5000000 / (v.mileAge + 1)));
                    int oil = randInt(0, 100);
                    if (brokenEngine == 0) {
                        v.parts.ENGINE = false;
                        p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 10, 10);
                        p.sendMessage("�2It looks like you have blown up your engine...");
                    } else if (broken == 1) {
                        v.parts.WHEELFL = false;
                        p.sendMessage("�2It looks like your front left tire is flat.");
                    } else if (broken == 2) {
                        v.parts.WHEELFR = false;
                        p.sendMessage("�2It looks like your front right tire is flat.");
                    } else if (broken == 3) {
                        v.parts.WHEELRL = false;
                        p.sendMessage("�2It looks like your rear left tire is flat.");
                    } else if (broken == 4) {
                        v.parts.WHEELRR = false;
                        p.sendMessage("�2It looks like your rear right tire is flat.");
                    }
                    v.fuel -= v.fualUsage / 2;
                    if (v.curSpeed <= v.fspeed || v.curSpeed == 0) {
                        v.curSpeed = v.curSpeed += v.acceleration / 2;
                    }
                    if (!v.parts.WHEELFL || !v.parts.WHEELFR || !v.parts.WHEELRL || !v.parts.WHEELRR) {
                        a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -v.curSpeed, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed / 4));
                    } else {
                        a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -v.curSpeed, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
                    }
                    if (side > 0) {
                        // Side[A]
                        EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
                        a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() - v.turnSpeed, a.getLocation().getPitch());
                        v.steering = (int) (v.turnSpeed / 2);
                    } else if (side < 0) {
                        // Side[D]
                        EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
                        a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() + v.turnSpeed, a.getLocation().getPitch());
                        v.steering = -(int) (v.turnSpeed / 2);
                    } else {
                        v.steering = 0;
                    }
                } else if (forward < 0) {
                    // Reverse[S]
                    v.fuel -= v.fualUsage / 2;
                    Location loc1 = new Location(a.getWorld(), a.getLocation().getBlockX() + 1, a.getLocation().getBlockY(), a.getLocation().getBlockZ());
                    Location loc2 = new Location(a.getWorld(), a.getLocation().getBlockX() - 1, a.getLocation().getBlockY(), a.getLocation().getBlockZ());
                    Location loc3 = new Location(a.getWorld(), a.getLocation().getBlockX(), a.getLocation().getBlockY(), a.getLocation().getBlockZ() + 1);
                    Location loc4 = new Location(a.getWorld(), a.getLocation().getBlockX(), a.getLocation().getBlockY(), a.getLocation().getBlockZ() - 1);
                    Location loc5 = new Location(a.getWorld(), a.getLocation().getBlockX() - 1, a.getLocation().getBlockY(), a.getLocation().getBlockZ());
                    if (v.curSpeed >= -v.bspeed || v.curSpeed == 0) {
                        v.curSpeed = v.curSpeed -= v.acceleration * 2;
                    }
                    if ((loc1.getBlock().getType() != Material.AIR && loc1.getBlock().getType() != Material.LONG_GRASS && loc1.getBlock().getType() != Material.CHORUS_FLOWER && loc1.getBlock().getType() != Material.YELLOW_FLOWER && loc1.getBlock().getType() != Material.RED_ROSE && loc1.getBlock().getType() != Material.WHEAT) || (loc2.getBlock().getType() != Material.AIR && loc2.getBlock().getType() != Material.LONG_GRASS && loc2.getBlock().getType() != Material.CHORUS_FLOWER && loc2.getBlock().getType() != Material.YELLOW_FLOWER && loc2.getBlock().getType() != Material.RED_ROSE && loc2.getBlock().getType() != Material.WHEAT) || (loc3.getBlock().getType() != Material.AIR && loc3.getBlock().getType() != Material.LONG_GRASS && loc3.getBlock().getType() != Material.CHORUS_FLOWER && loc3.getBlock().getType() != Material.YELLOW_FLOWER && loc3.getBlock().getType() != Material.RED_ROSE && loc3.getBlock().getType() != Material.WHEAT) || (loc4.getBlock().getType() != Material.AIR && loc4.getBlock().getType() != Material.LONG_GRASS && loc4.getBlock().getType() != Material.CHORUS_FLOWER && loc4.getBlock().getType() != Material.YELLOW_FLOWER && loc4.getBlock().getType() != Material.RED_ROSE && loc4.getBlock().getType() != Material.WHEAT) && loc5.getBlock().getType() != Material.AIR) {
                        a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -v.curSpeed, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
                    // a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -1, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(- BwdDriveSpeed.get(a.getUniqueId())));
                    } else {
                        a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -v.curSpeed, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
                    }
                    if (side > 0) {
                        // Side[A]
                        EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
                        a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() + v.turnSpeed, a.getLocation().getPitch());
                        v.steering = (int) (v.turnSpeed / 2);
                    } else if (side < 0) {
                        // Side[D]
                        EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
                        a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() - v.turnSpeed, a.getLocation().getPitch());
                        v.steering = -(int) (v.turnSpeed / 2);
                    } else {
                        v.steering = 0;
                    }
                } else {
                    v.steering = 0;
                    if (v.curSpeed > v.acceleration) {
                        v.curSpeed = v.curSpeed -= v.acceleration;
                    } else if (v.curSpeed < -v.acceleration) {
                        v.curSpeed = v.curSpeed += v.acceleration;
                    } else {
                        v.curSpeed = 0;
                    }
                    a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -v.curSpeed, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
                }
            }
        }
    }
}
Also used : Vehicle(me.legofreak107.vehicles.objects.Vehicle) PacketPlayInSteerVehicle(net.minecraft.server.v1_12_R1.PacketPlayInSteerVehicle) Seat(me.legofreak107.vehicles.objects.Seat) CraftArmorStand(org.bukkit.craftbukkit.v1_12_R1.entity.CraftArmorStand) ArmorStand(org.bukkit.entity.ArmorStand) EntityArmorStand(net.minecraft.server.v1_12_R1.EntityArmorStand) CraftArmorStand(org.bukkit.craftbukkit.v1_12_R1.entity.CraftArmorStand) BossBar(org.bukkit.boss.BossBar) EntityArmorStand(net.minecraft.server.v1_12_R1.EntityArmorStand) PlayerInventory(org.bukkit.inventory.PlayerInventory) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Example 9 with ComponentBuilder

use of net.md_5.bungee.api.chat.ComponentBuilder in project FireAPI by FireBlade-Serv.

the class Discord method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    TextComponent comp = new TextComponent("§aCliquez ICI");
    comp.setClickEvent(new ClickEvent(Action.OPEN_URL, "https://discordapp.com/invite/H7acUcX"));
    comp.setHoverEvent(new HoverEvent(net.md_5.bungee.api.chat.HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Cliquez ici pour acceder au discord !").color(ChatColor.GREEN).create()));
    TextComponent base = new TextComponent("§b[Discord] ");
    base.addExtra(comp);
    sender.sendMessage(base);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) HoverEvent(net.md_5.bungee.api.chat.HoverEvent) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder)

Example 10 with ComponentBuilder

use of net.md_5.bungee.api.chat.ComponentBuilder in project FireAPI by FireBlade-Serv.

the class Website method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    TextComponent comp = new TextComponent("§aCliquez ICI");
    comp.setClickEvent(new ClickEvent(Action.OPEN_URL, "http://www.fireblade-serv.eu/"));
    comp.setHoverEvent(new HoverEvent(net.md_5.bungee.api.chat.HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Cliquez ici pour acceder au site internet !").color(ChatColor.GREEN).create()));
    TextComponent base = new TextComponent("§c[Site] ");
    base.addExtra(comp);
    sender.sendMessage(base);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) HoverEvent(net.md_5.bungee.api.chat.HoverEvent) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder)

Aggregations

ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)24 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)13 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)12 TextComponent (net.md_5.bungee.api.chat.TextComponent)9 Player (org.bukkit.entity.Player)9 BaseComponent (net.md_5.bungee.api.chat.BaseComponent)6 UPlayer (xyz.derkades.ublisk.utils.UPlayer)5 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)4 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)4 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)3 EventHandler (org.bukkit.event.EventHandler)3 OwnedLand (biz.princeps.landlord.util.OwnedLand)2 ConfirmationGUI (biz.princeps.lib.gui.ConfirmationGUI)2 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)2 UUID (java.util.UUID)2 Material (org.bukkit.Material)2 OfflinePlayer (org.bukkit.OfflinePlayer)2 World (org.bukkit.World)2 ArmorStand (org.bukkit.entity.ArmorStand)2 ItemStack (org.bukkit.inventory.ItemStack)2