Search in sources :

Example 1 with Island

use of pixelssky.objects.Island in project PixelsSkyblock by dudullle.

the class EventListener method interactEvent.

@EventHandler
public void interactEvent(PlayerInteractEvent event) {
    Player p = event.getPlayer();
    try {
        Island is = Locations.getIslandAt(event.getClickedBlock().getLocation());
        if (!is.getMembers().contains(PlayersManager.getSPlayer(p).getID())) {
            event.setCancelled(true);
            p.sendTitle("§c⚠§4§lAccès refusé§c⚠", "§eVous ne faites pas partie de cette île", 10, 25, 10);
            p.playSound(p.getLocation(), Sound.ENTITY_ENDERDRAGON_GROWL, 100, 100);
        }
    } catch (Exception ex) {
        try {
            // Si clic dans le vide
            // -> Go Catch
            event.getClickedBlock().getLocation();
            // Si pas d'ile
            event.setCancelled(true);
            p.sendTitle("§c⚠§4§lAccès refusé§c⚠", "§eVous ne faites pas partie de cette île", 10, 25, 10);
            p.playSound(p.getLocation(), Sound.ENTITY_ENDERDRAGON_GROWL, 100, 100);
        } catch (Exception ex2) {
        }
    }
// 
}
Also used : Player(org.bukkit.entity.Player) SPlayer(pixelssky.objects.SPlayer) Island(pixelssky.objects.Island) EventHandler(org.bukkit.event.EventHandler)

Example 2 with Island

use of pixelssky.objects.Island in project PixelsSkyblock by dudullle.

the class DatabaseManager method loadIslands.

public static void loadIslands() {
    // TODO : renvoyer les donn�es de l'�le � partir d'un joueur
    System.out.println("PixelsSkyblock : Loading Islands !");
    try {
        conn = DriverManager.getConnection(BDD_host, BDD_username, BDD_password);
        stmt = conn.createStatement();
        // Request
        ResultSet res = stmt.executeQuery("SELECT * FROM `island`; ");
        while (res.next()) {
            System.out.println("Chargement... ");
            IslandsManager.setIsland(new Island(res.getInt("ID"), res.getString("PLAYERS_ID"), res.getString("ISLAND_CENTER"), res.getString("ISLAND_SPAWN"), res.getDouble("ISLAND_LEVEL")));
        }
        conn.close();
        for (Island i : IslandsManager.islands) {
            readIslandData(i);
        }
    } catch (Exception ex) {
        System.out.println("EX_LOADING_ISLAND" + ex.toString());
    }
}
Also used : ResultSet(java.sql.ResultSet) Island(pixelssky.objects.Island) SQLException(java.sql.SQLException)

Example 3 with Island

use of pixelssky.objects.Island in project PixelsSkyblock by dudullle.

the class Classement method getTop.

public static ArrayList<String> getTop() {
    ArrayList<String> classes = new ArrayList<String>();
    TreeMap<Double, Island> map = new TreeMap<Double, Island>();
    for (Island i : IslandsManager.islands) {
        if (i.getDifficulty().equals(Island.DIFFICULTY_HARD)) {
            map.put(i.getLevel(), i);
        } else if (i.getDifficulty().equals(Island.DIFFICULTY_NORMAL)) {
            map.put(i.getLevel() - 50000, i);
        } else if (i.getDifficulty().equals(Island.DIFFICULTY_EASY)) {
            map.put(i.getLevel() - 100000, i);
        }
    }
    for (Entry<Double, Island> e : map.entrySet()) {
        classes.add(e.getValue().getID() + "");
    }
    return reverseList(classes);
}
Also used : ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) Island(pixelssky.objects.Island)

Example 4 with Island

use of pixelssky.objects.Island in project PixelsSkyblock by dudullle.

the class Inventories method getPlayersInventory_invite.

public static Inventory getPlayersInventory_invite(SPlayer pl) {
    Island i = pl.getIsland();
    Inventory inv = Bukkit.createInventory(null, ((Bukkit.getOnlinePlayers().size()) / 9 + 1) * 9, "§6✉ §3Inviter des joueurs");
    for (Player p : Bukkit.getOnlinePlayers()) {
        if (!i.getMembers().contains(PlayersManager.getSPlayer(p).getID())) {
            inv.addItem(Items.getHead(p));
        }
    }
    return inv;
}
Also used : Player(org.bukkit.entity.Player) SPlayer(pixelssky.objects.SPlayer) Island(pixelssky.objects.Island) Inventory(org.bukkit.inventory.Inventory)

Example 5 with Island

use of pixelssky.objects.Island in project PixelsSkyblock by dudullle.

the class DatabaseManager method createIsland.

/**
 * creates an island and delete if one already exist
 */
public static void createIsland(SPlayer p) {
    try {
        conn = DriverManager.getConnection(BDD_host, BDD_username, BDD_password);
        stmt = conn.createStatement();
        // Request
        Island island = new Island(0, p.getID() + ",", "world,0,0,0,0,0", "world,0,100,0,0,0", 0);
        stmt.executeUpdate("INSERT INTO `ISLAND` (`PLAYERS_ID`, `ISLAND_CENTER`, `ISLAND_SPAWN`, `ISLAND_LEVEL`) VALUES ('" + island.getMembersToString() + "', '" + Locations.toString(island.getCenter()) + "', '" + Locations.toString(island.getSpawn()) + "', '" + island.getLevel() + "'); ");
        ResultSet res = stmt.executeQuery("SELECT `ID` FROM `ISLAND` WHERE  `ISLAND_CENTER` = '" + Locations.toString(island.getCenter()) + "';");
        while (res.next()) {
            island.setID(res.getInt("ID"));
            island.setCenter(Locations.getIsCenterByID(island.getID()));
            island.setHome(Locations.getIsCenterByID(island.getID()));
        }
        conn.close();
        p.setIsland(island);
        IslandsManager.setIsland(island);
        updatePlayer(p);
    } catch (Exception ex) {
        System.out.println(ex.toString());
    }
}
Also used : ResultSet(java.sql.ResultSet) Island(pixelssky.objects.Island) SQLException(java.sql.SQLException)

Aggregations

Island (pixelssky.objects.Island)6 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 Player (org.bukkit.entity.Player)2 Inventory (org.bukkit.inventory.Inventory)2 SPlayer (pixelssky.objects.SPlayer)2 Random (java.util.Random)1 TreeMap (java.util.TreeMap)1 EventHandler (org.bukkit.event.EventHandler)1