Search in sources :

Example 1 with Town

use of xyz.derkades.ublisk.Town in project Ublisk by Derkades.

the class SongEnd method musicStopped.

@EventHandler
public void musicStopped(SongEndEvent event) {
    try {
        SongPlayer songPlayer = event.getSongPlayer();
        for (String playername : songPlayer.getPlayerList()) {
            UPlayer player = new UPlayer(playername);
            if (player.getSetting(Setting.PLAY_MUSIC)) {
                Town town = player.getTown();
                if (town != null) {
                    town.playThemeToPlayer(player);
                }
            }
        }
        songPlayer.destroy();
    } catch (PlayerNotFoundException e) {
        Logger.log(LogLevel.WARNING, "Music", "Tried to play new song but player has already logged out");
    }
}
Also used : UPlayer(xyz.derkades.ublisk.utils.UPlayer) SongPlayer(xyz.derkades.ublisk.ext.com.xxmicloxx.noteblockapi.SongPlayer) Town(xyz.derkades.ublisk.Town) PlayerNotFoundException(xyz.derkades.ublisk.utils.exception.PlayerNotFoundException) EventHandler(org.bukkit.event.EventHandler)

Example 2 with Town

use of xyz.derkades.ublisk.Town in project Ublisk by Derkades.

the class UPlayer method getLastTown.

/**
 * @return Current town, or last town if the player is no longer in a town.
 */
public Town getLastTown() {
    String s = DataFile.TOWN.getConfig().getString("last-town." + this.getUniqueId());
    if (s == null) {
        return Town.INTRODUCTION;
    }
    Town town = Town.fromString(s);
    if (town == null) {
        return Town.INTRODUCTION;
    }
    return town;
}
Also used : Town(xyz.derkades.ublisk.Town)

Example 3 with Town

use of xyz.derkades.ublisk.Town in project Ublisk by Derkades.

the class Roy method talk.

@Override
public void talk(UPlayer player) {
    QuestParticipant qp = player.getQuestParticipant(Quest.UNKNOWN, this);
    qp.sendMessage("Hoi " + player.getName() + ", ik ben Roy");
    Town town = player.getLastTown();
    String townNaam = town.getName();
    qp.sendMessage("Je bent in: " + townNaam);
}
Also used : QuestParticipant(xyz.derkades.ublisk.quest.QuestParticipant) Town(xyz.derkades.ublisk.Town)

Example 4 with Town

use of xyz.derkades.ublisk.Town 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);
				}
			}
		});*/
}
Also used : URunnable(xyz.derkades.ublisk.utils.URunnable) UPlayer(xyz.derkades.ublisk.utils.UPlayer) Town(xyz.derkades.ublisk.Town) UUID(java.util.UUID) EventHandler(org.bukkit.event.EventHandler)

Example 5 with Town

use of xyz.derkades.ublisk.Town in project Ublisk by Derkades.

the class TownCommand method onCommand.

@Override
protected void onCommand(UPlayer player, String[] args) {
    List<BaseComponent> list = new ArrayList<BaseComponent>();
    for (Town town : Town.values()) {
        TextComponent component = new TextComponent(town.getName() + "   ");
        double x = town.getSpawnLocation().getX();
        double y = town.getSpawnLocation().getY();
        double z = town.getSpawnLocation().getZ();
        component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tp @p " + x + " " + y + " " + z));
        list.add(component);
    }
    BaseComponent[] components = list.toArray(new BaseComponent[] {});
    player.sendMessage(components);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) BaseComponent(net.md_5.bungee.api.chat.BaseComponent) Town(xyz.derkades.ublisk.Town) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) ArrayList(java.util.ArrayList)

Aggregations

Town (xyz.derkades.ublisk.Town)6 UPlayer (xyz.derkades.ublisk.utils.UPlayer)3 EventHandler (org.bukkit.event.EventHandler)2 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 BaseComponent (net.md_5.bungee.api.chat.BaseComponent)1 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)1 TextComponent (net.md_5.bungee.api.chat.TextComponent)1 SongPlayer (xyz.derkades.ublisk.ext.com.xxmicloxx.noteblockapi.SongPlayer)1 QuestParticipant (xyz.derkades.ublisk.quest.QuestParticipant)1 URunnable (xyz.derkades.ublisk.utils.URunnable)1 PlayerNotFoundException (xyz.derkades.ublisk.utils.exception.PlayerNotFoundException)1