use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class PlayerCommandPreprocess method onCommand.
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onCommand(PlayerCommandPreprocessEvent event) {
String cmd = event.getMessage();
UPlayer sender = new UPlayer(event);
if (cmd.startsWith("/time set")) {
sender.sendMessage("Please do not use /time set. The command has been cancelled");
event.setCancelled(true);
return;
}
if (cmd.length() >= 4) {
if (cmd.substring(0, 4).equalsIgnoreCase("/op ")) {
sender.sendMessage(ChatColor.AQUA + "oygnuonaiysgdcoauisgcdoauighscdoauismh");
event.setCancelled(true);
return;
}
}
if (cmd.contains("gamemode")) {
sender.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "Use /builder for building or /u spec to go into spectator mode.");
event.setCancelled(true);
return;
}
if (cmd.contains("gamerule")) {
sender.sendMessage("no no no.");
event.setCancelled(true);
return;
}
if ((cmd.startsWith("/kill") || cmd.startsWith("/kick")) && !sender.getName().equals("Derkades")) {
sender.teleport(0, 1000, 0);
sender.clearInventory();
event.setCancelled(true);
}
if ((cmd.equalsIgnoreCase("/rl") || cmd.equalsIgnoreCase("/reload")) && !Var.DEBUG) {
sender.sendMessage("You can't reload when the server is in debug mode");
event.setCancelled(true);
}
}
use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class PlayerDropItem method onItemDrop.
@EventHandler(priority = EventPriority.LOW)
public void onItemDrop(PlayerDropItemEvent event) {
UPlayer player = new UPlayer(event);
if (player.isInBuilderMode()) {
return;
}
Item item = new Item(event.getItemDrop());
event.setCancelled(!item.isDroppable());
}
use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class PlayerInteract method onInteract.
@EventHandler(ignoreCancelled = false)
public void onInteract(PlayerInteractEvent event) {
UPlayer player = new UPlayer(event);
Action action = event.getAction();
if (action == Action.RIGHT_CLICK_BLOCK || action == Action.RIGHT_CLICK_AIR) {
UInventory inv = player.getInventory();
Material item = inv.getItemInMainHand().getType();
if (item == Material.CHEST && !player.isInBuilderMode()) {
new MainMenu(player).open();
event.setCancelled(true);
} else if (item == Material.END_CRYSTAL) {
player.openEnderchest();
event.setCancelled(true);
}
}
}
use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class PlayerItemConsume method eat.
@EventHandler
public void eat(PlayerItemConsumeEvent event) {
if (event.isCancelled()) {
return;
}
UPlayer player = new UPlayer(event);
player.sendMessage(Message.CANT_EAT);
event.setCancelled(true);
}
use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class PlayerJoin method onJoin.
@EventHandler
public void onJoin(PlayerJoinEvent event) {
final UPlayer player = new UPlayer(event);
String pn = player.getName();
UUID uuid = player.getUniqueId();
PlayerInfo.resetHashMaps(player);
player.setCollidable(false);
event.setJoinMessage(DARK_AQUA + "" + BOLD + pn + RESET + AQUA + " has joined");
player.givePotionEffect(PotionEffectType.BLINDNESS, 1 * 20, 0);
player.givePotionEffect(PotionEffectType.NIGHT_VISION, 1 * 20, 0);
player.sendTitle(ChatColor.DARK_AQUA + "" + ChatColor.BOLD + "Ublisk", ChatColor.YELLOW + "Welcome back, " + pn + "!");
if (player.getSetting(Setting.PLAY_MUSIC)) {
Town town = player.getTown();
if (town != null)
town.playThemeToPlayer(player);
}
player.tracker(PlayerInfo.JOIN_COUNT);
// String ip = player.getPlayer().getAddress().toString();
// ip = ip.replace("/", "");
String ip = player.getIP();
DataFile.IP.getConfig().set("ip." + uuid, ip);
player.updateXPBar();
// Disable builder mode if the player no longer has permission
if (!player.hasPermission(Permission.BUILDER_MODE)) {
player.setBuilderModeEnabled(false);
}
if (player.isInBuilderMode()) {
player.setGameMode(GameMode.CREATIVE);
} else {
player.setGameMode(GameMode.ADVENTURE);
}
player.setFlying(false);
player.setAttribute(Attribute.GENERIC_ATTACK_SPEED, 0.7);
new URunnable() {
public void run() {
player.sendSpacers(10);
final String[] fancyStrings = new String[] { " ", " # # ## # # ### # # ", " # # # # # # # # # ", " # # ## # # ### ## ", " # # # # # # # ## ", " ### ## ### # ### # # ", " " };
for (String string : fancyStrings) {
player.sendMessage(string.replace("#", ChatColor.AQUA + "" + ChatColor.BOLD + ImageChar.DARK_SHADE.getChar()).replace(" ", ChatColor.DARK_AQUA + "" + ChatColor.BOLD + ImageChar.DARK_SHADE.getChar()));
}
player.sendMessage(ChatColor.GRAY + "Welcome to Ublisk! If you find any bugs, please report them using /bug [description].");
}
}.runLater(4);
/*Ublisk.runAsync(() -> {
Connection connection = null;
PreparedStatement check = null;
ResultSet checkResult = null;
PreparedStatement insert = null;
try {
connection = Ublisk.getDatabaseConnection("Player join insert");
check = connection.prepareStatement("SELECT EXISTS(SELECT * FROM player_info_2 WHERE uuid=?) AS `exists`");
check.setString(1, uuid.toString());
checkResult = check.executeQuery();
checkResult.next();
boolean exists = checkResult.getBoolean("exists");
Logger.log(LogLevel.DEBUG, "Exists: " + exists);
if (!exists) {
insert = connection.prepareStatement("INSERT INTO `player_info_2) (uuid, name, xp) VALUES (?, ?, ?)");
insert.setString(1, uuid.toString());
insert.setString(2, pn);
insert.setInt(3, 0);
insert.execute();
}
} catch (SQLException e) {
Ublisk.exception(e, PlayerJoin.class);
} finally {
try {
if (check != null) check.close();
if (checkResult != null) checkResult.close();
if (insert != null) insert.close();
} catch (SQLException e) {
Ublisk.exception(e, PlayerJoin.class);
}
}
});*/
}
Aggregations