@Listener public void onPlayerLogin(ClientConnectionEvent.Login event) { CoreBan ban = CoreDatabase.getBan(event.getProfile().getUniqueId().toString()); if (ban != null) { if (ban.getDuration() != 0 && ban.getDuration() <= System.currentTimeMillis()) { CoreDatabase.removeBan(event.getProfile().getUniqueId().toString()); ban.delete(); } else { String time = TimeUtils.toString(ban.getDuration() - System.currentTimeMillis()); event.setMessage( Texts.of( TextColors.GRAY, "Banned for another: ", TextColors.RED, time, "\n\n", TextColors.RED, "Reason: ", TextColors.GRAY, ban.getReason())); event.setCancelled(true); return; } } }
public CommandCoreDatabase(CommandSource sender, String[] args) { if (!PermissionsUtils.has(sender, "core.core.database")) { sender.sendMessage( Texts.builder("You do not have permissions!").color(TextColors.RED).build()); return; } int homes = 0; for (Entry<String, CorePlayer> e : CoreDatabase.getPlayers().entrySet()) { CorePlayer p = e.getValue(); homes += p.getHomes().size(); } sender.sendMessage(Texts.of(TextColors.GOLD, "Core Database:")); sender.sendMessage( Texts.of( TextColors.GRAY, "Players: ", TextColors.YELLOW, CoreDatabase.getPlayers().size())); sender.sendMessage( Texts.of(TextColors.GRAY, "Bans: ", TextColors.YELLOW, CoreDatabase.getBans().size())); sender.sendMessage( Texts.of(TextColors.GRAY, "Mutes: ", TextColors.YELLOW, CoreDatabase.getMutes().size())); sender.sendMessage( Texts.of(TextColors.GRAY, "Spawns: ", TextColors.YELLOW, CoreDatabase.getSpawns().size())); sender.sendMessage(Texts.of(TextColors.GRAY, "Homes: ", TextColors.YELLOW, homes)); sender.sendMessage( Texts.of(TextColors.GRAY, "Warps: ", TextColors.YELLOW, CoreDatabase.getWarps().size())); sender.sendMessage( Texts.of( TextColors.GRAY, "Tickets: ", TextColors.YELLOW, CoreDatabase.getTickets().size())); }
public CommandTicketCreate(CommandSource sender, String[] args) { if (sender instanceof Player == false) { sender.sendMessage( Texts.builder("Cannot be run by the console!").color(TextColors.RED).build()); return; } if (args.length < 2) { sender.sendMessage( Texts.of(TextColors.YELLOW, "Usage: ", TextColors.GRAY, "/ticket create <message>")); return; } Player player = (Player) sender; String message = CommandUtils.combineArgs(1, args); int tickets = 0; for (Entry<Integer, CoreTicket> e : CoreDatabase.getTickets().entrySet()) { CoreTicket ticket = e.getValue(); if (!ticket.getStatus().equalsIgnoreCase("open")) continue; if (!ticket.getUUID().equalsIgnoreCase(player.getUniqueId().toString())) continue; tickets += 1; } int possible = 0; for (int i = 1; i <= 100; i++) { if (PermissionsUtils.has(player, "core.ticket.create." + i)) possible = i; } if (!PermissionsUtils.has(player, "core.ticket.create-unlimited") && possible <= tickets) { if (possible == 1) sender.sendMessage( Texts.builder("You are only allowed to own " + possible + " open tickets!") .color(TextColors.RED) .build()); else sender.sendMessage( Texts.builder("You are only allowed to own " + possible + " open tickets!") .color(TextColors.RED) .build()); return; } int id = CoreDatabase.getTickets().size() + 1; String world = player.getWorld().getName(); double x = player.getLocation().getX(); double y = player.getLocation().getY(); double z = player.getLocation().getZ(); double yaw = player.getRotation().getX(); double pitch = player.getRotation().getY(); double time = System.currentTimeMillis(); CoreTicket ticket = new CoreTicket( id, player.getUniqueId().toString(), message, time, new ArrayList<String>(), world, x, y, z, yaw, pitch, "", "medium", "open"); ticket.insert(); sender.sendMessage( Texts.of( TextColors.GRAY, "Ticket ", TextColors.GREEN, "#", id, TextColors.GRAY, " has been created!")); }
public CommandWarpTeleport(CommandSource sender, String[] args) { if (sender instanceof Player == false) { sender.sendMessage( Texts.builder("Cannot be run by the console!").color(TextColors.RED).build()); return; } if (!PermissionsUtils.has(sender, "core.warp.teleport")) { sender.sendMessage( Texts.builder("You do not have permissions!").color(TextColors.RED).build()); return; } if (args.length != 1) { sender.sendMessage(Texts.of(TextColors.YELLOW, "Usage: ", TextColors.GRAY, "/warp <name>")); return; } Player player = (Player) sender; String name = args[0].toLowerCase(); CoreWarp warp = CoreDatabase.getWarp(name); if (warp == null) { sender.sendMessage(Texts.builder("Warp does not exist!").color(TextColors.RED).build()); return; } if (PermissionsUtils.has(sender, "core.warp.teleport-unlimited")) { if (!player.transferToWorld( warp.getWorld(), new Vector3d(warp.getX(), warp.getY(), warp.getZ()))) { sender.sendMessage( Texts.builder("Target world does not exist anymore!").color(TextColors.RED).build()); return; } sender.sendMessage( Texts.of(TextColors.GRAY, "Teleported to warp: ", TextColors.YELLOW, name)); return; } if (!warp.getOwner().equalsIgnoreCase(sender.getName().toLowerCase())) { if (warp.getPrivate().equalsIgnoreCase("yes") && !PermissionsUtils.has(sender, "core.warp.teleport-invited")) { sender.sendMessage( Texts.of(TextColors.RED, "You do not have permissions to teleport to private warps!")); return; } if (warp.getPrivate().equalsIgnoreCase("yes") && !warp.getInvited().contains(sender.getName().toLowerCase())) { sender.sendMessage(Texts.of(TextColors.RED, "You are not invited to this warp!")); return; } } Location<World> loc = new Location<World>( Controller.getServer().getWorld(warp.getWorld()).get(), warp.getX(), warp.getY(), warp.getZ()); player.setLocation(loc); sender.sendMessage(Texts.of(TextColors.GRAY, "Teleported to warp: ", TextColors.YELLOW, name)); }
@Override public CommandResult process(CommandSource sender, String arguments) throws CommandException { String[] args = arguments.split(" "); if (sender instanceof Player == false) { sender.sendMessage( Texts.builder("Cannot be run by the console!").color(TextColors.RED).build()); return CommandResult.success(); } if (!PermissionsUtils.has(sender, "core.tpa")) { sender.sendMessage( Texts.builder("You do not have permissions!").color(TextColors.RED).build()); return CommandResult.success(); } if (arguments.equalsIgnoreCase("")) { sender.sendMessage(Texts.of(TextColors.YELLOW, "Usage: ", TextColors.GRAY, "/tpa <player>")); return CommandResult.success(); } if (args.length < 1 || args.length > 1) { sender.sendMessage(Texts.of(TextColors.YELLOW, "Usage: ", TextColors.GRAY, "/tpa <player>")); return CommandResult.success(); } Player s = (Player) sender; String uuid = s.getUniqueId().toString(); Player player = CoreServer.getPlayer(args[0]); if (player == null) { sender.sendMessage(Texts.builder("Player not found!").color(TextColors.RED).build()); return CommandResult.success(); } CorePlayer p = CoreDatabase.getPlayer(player.getUniqueId().toString()); HashMap<String, Double> tpa = p.getTPA(); HashMap<String, Double> tpahere = p.getTPAHere(); double duration = 0; if (tpa.containsKey(uuid)) duration = tpa.get(uuid); if (duration != 0) { if (duration <= System.currentTimeMillis()) { tpa.remove(uuid); p.setTPA(tpa); } else { sender.sendMessage( Texts.builder("You already requested a teleport from that player!") .color(TextColors.RED) .build()); return CommandResult.success(); } } duration = 0; if (tpahere.containsKey(uuid)) duration = tpahere.get(uuid); if (duration != 0) { if (duration <= System.currentTimeMillis()) { tpahere.remove(uuid); p.setTPAHere(tpahere); } else { sender.sendMessage( Texts.builder("You already requested a teleport from that player!") .color(TextColors.RED) .build()); return CommandResult.success(); } } duration = System.currentTimeMillis() + 30 * 1000; tpa.put(uuid, duration); p.setTPA(tpa); sender.sendMessage( Texts.of( TextColors.GRAY, "Teleport request has been sent to ", TextColors.YELLOW, player.getName())); player.sendMessage( Texts.of( TextColors.YELLOW, sender.getName(), TextColors.GRAY, " requested to teleport to you.")); player.sendMessage( Texts.of( TextColors.GRAY, "Type ", TextColors.YELLOW, "/tpaccept ", sender.getName(), TextColors.GRAY, " or", TextColors.YELLOW, " /tpdeny ", sender.getName())); player.sendMessage(Texts.of(TextColors.GRAY, "to accept/decline the request.")); return CommandResult.success(); }