Search in sources :

Example 36 with Material

use of org.bukkit.Material in project PixelsSkyblock by dudullle.

the class ChallengesManager method init_subChallenges.

public static void init_subChallenges() {
    for (Challenge categ : challenges) {
        File folder = new File("plugins/PixelsSky/Challenges/" + categ.getName());
        for (File f : folder.listFiles()) {
            if (!f.isDirectory()) {
                ArrayList<String> lines = FileManager.ReadAllText(f.getAbsolutePath());
                ArrayList<Objective> obj = new ArrayList<Objective>();
                ArrayList<Reward> rewards = new ArrayList<Reward>();
                String c_name = null;
                int type = -1;
                boolean can_redo = false;
                Material m = null;
                int subid = 0;
                boolean isUnlocked = false;
                for (String l : lines) {
                    if (l.split("=")[0].equals("name")) {
                        c_name = l.split("=")[1];
                    } else if (l.split("=")[0].equals("unlocked_by_default")) {
                        isUnlocked = Boolean.parseBoolean(l.split("=")[1]);
                    } else if (l.split("=")[0].equals("type")) {
                        type = Integer.parseInt(l.split("=")[1]);
                    } else if (l.split("=")[0].equals("material")) {
                        m = Material.getMaterial(Integer.parseInt(l.split("=")[1]));
                    } else if (l.split("=")[0].equals("subid")) {
                        subid = Integer.parseInt(l.split("=")[1]);
                    } else if (l.split("=")[0].equals("can_redo")) {
                        can_redo = Boolean.parseBoolean((l.split("=")[1]));
                    } else if (l.split("=")[0].equals("objective")) {
                        String[] s = l.split("=")[1].split(",");
                        if (s[0].equals("inventory")) {
                            obj.add(new InventoryObjective(Integer.parseInt(s[1]), Integer.parseInt(s[2]), Integer.parseInt(s[3]), s[4].equals("take")));
                        } else if (s[0].equals("onisland")) {
                            if (s[1].equals("block")) {
                                obj.add(new OnislandObjective(s[1].equals("entity"), Integer.parseInt(s[2]), Integer.parseInt(s[3]), Integer.parseInt(s[4])));
                            } else {
                                obj.add(new OnislandObjective(s[1].equals("entity"), s[2], Integer.parseInt(s[3]), Integer.parseInt(s[4])));
                            }
                        } else if (s[0].equals("stats")) {
                            obj.add(new StatsObjective(s[1], s[2], s[3]));
                        }
                    } else if (l.split("=")[0].equals("reward")) {
                        String[] s = l.split("=")[1].split(",");
                        if (s[0].equals("give")) {
                            if (s[4].split(":").length > 1) {
                                TreeMap<String, Integer> e = new TreeMap<String, Integer>();
                                for (String ench : s[4].split(":")[1].split(";")) {
                                    e.put(ench.split("/")[0], Integer.parseInt(ench.split("/")[1]));
                                }
                                rewards.add(new GiveReward(Integer.parseInt(s[1]), Integer.parseInt(s[2]), Integer.parseInt(s[3]), e));
                            } else {
                                rewards.add(new GiveReward(Integer.parseInt(s[1]), Integer.parseInt(s[2]), Integer.parseInt(s[3])));
                            }
                        } else if (s[0].equals("command")) {
                            rewards.add(new CommandReward(s[1], s[2]));
                        } else if (s[0].equals("stats")) {
                            rewards.add(new StatsReward(s[1], s[2], s[3]));
                        }
                    }
                }
                categ.getSubChallenges().add(new Challenge(type, c_name, obj, rewards, can_redo, m, subid, isUnlocked));
            }
        }
    }
}
Also used : StatsObjective(pixelssky.objects.objectives.StatsObjective) GiveReward(pixelssky.rewards.GiveReward) ArrayList(java.util.ArrayList) OnislandObjective(pixelssky.objects.objectives.OnislandObjective) Material(org.bukkit.Material) StatsReward(pixelssky.rewards.StatsReward) TreeMap(java.util.TreeMap) Challenge(pixelssky.objects.Challenge) InventoryObjective(pixelssky.objects.objectives.InventoryObjective) Objective(pixelssky.objects.objectives.Objective) OnislandObjective(pixelssky.objects.objectives.OnislandObjective) InventoryObjective(pixelssky.objects.objectives.InventoryObjective) StatsObjective(pixelssky.objects.objectives.StatsObjective) CommandReward(pixelssky.rewards.CommandReward) CommandReward(pixelssky.rewards.CommandReward) StatsReward(pixelssky.rewards.StatsReward) GiveReward(pixelssky.rewards.GiveReward) Reward(pixelssky.rewards.Reward) File(java.io.File)

Example 37 with Material

use of org.bukkit.Material in project CitizensAPI by CitizensDev.

the class FlyingBlockExaminer method getCost.

@Override
public float getCost(BlockSource source, PathPoint point) {
    Vector pos = point.getVector();
    Material above = source.getMaterialAt(pos.clone().add(UP));
    Material in = source.getMaterialAt(pos);
    if (above == Material.WEB || in == Material.WEB) {
        return 0.5F;
    }
    return 0F;
}
Also used : Material(org.bukkit.Material) Vector(org.bukkit.util.Vector)

Example 38 with Material

use of org.bukkit.Material in project CitizensAPI by CitizensDev.

the class MinecraftBlockExaminer method getCost.

@Override
public float getCost(BlockSource source, PathPoint point) {
    Vector pos = point.getVector();
    Material above = source.getMaterialAt(pos.clone().add(UP));
    Material below = source.getMaterialAt(pos.clone().add(DOWN));
    Material in = source.getMaterialAt(pos);
    if (above == Material.WEB || in == Material.WEB)
        return 1F;
    if (below == Material.SOUL_SAND || below == Material.ICE)
        return 1F;
    if (isLiquid(above, below, in))
        return 0.5F;
    // TODO: add light level-specific costs
    return 0F;
}
Also used : Material(org.bukkit.Material) Vector(org.bukkit.util.Vector)

Example 39 with Material

use of org.bukkit.Material in project Bukkit_Bungee_PluginLib by GeorgH93.

the class ItemNameResolver method load.

private int load() {
    int translationCount = 0;
    for (String key : langReader.getLang().getKeys(true)) {
        String material = key, suffix = "";
        short dataValue = -1;
        if (key.contains(".")) {
            String[] components = key.split("\\.");
            material = components[0];
            if (components[1].equals("appendDefault"))
                continue;
            try {
                dataValue = Short.parseShort(components[1]);
            } catch (NumberFormatException ignored) {
            }
            if (langReader.getLang().getBoolean(material + ".appendDefault", false)) {
                suffix = langReader.getLang().getString(material, "");
            }
        }
        if (material.contains(":")) {
            String[] components = material.split(":");
            material = components[0];
            if (components[1].equals("appendDefault"))
                continue;
            try {
                dataValue = Short.parseShort(components[1]);
            } catch (NumberFormatException ignored) {
            }
            if (langReader.getLang().getBoolean(material + ".appendDefault", false)) {
                suffix = langReader.getLang().getString(material, langReader.getLang().getString(material + ".default", ""));
            }
        }
        Material mat = Material.matchMaterial(material);
        if (!names.containsKey(mat)) {
            names.put(mat, new HashMap<Short, String>());
        }
        names.get(mat).put(dataValue, langReader.get(key) + suffix);
        translationCount++;
    }
    return translationCount;
}
Also used : MinecraftMaterial(at.pcgamingfreaks.Bukkit.MinecraftMaterial) Material(org.bukkit.Material)

Example 40 with Material

use of org.bukkit.Material in project AreaShop by NLthijs48.

the class TeleportFeature method isSafe.

/**
 * Checks if a certain location is safe to teleport to.
 * @param location The location to check
 * @return true if it is safe, otherwise false
 */
private boolean isSafe(Location location) {
    Block feet = location.getBlock();
    Block head = feet.getRelative(BlockFace.UP);
    Block below = feet.getRelative(BlockFace.DOWN);
    Block above = head.getRelative(BlockFace.UP);
    // Check the block at the feet and head of the player
    if ((feet.getType().isSolid() && !canSpawnIn.contains(feet.getType())) || feet.isLiquid()) {
        return false;
    } else if ((head.getType().isSolid() && !canSpawnIn.contains(head.getType())) || head.isLiquid()) {
        return false;
    } else if (!below.getType().isSolid() || cannotSpawnOn.contains(below.getType()) || below.isLiquid()) {
        return false;
    } else if (above.isLiquid() || cannotSpawnBeside.contains(above.getType())) {
        return false;
    }
    // Get all blocks around the player (below foot level, foot level, head level and above head level)
    Set<Material> around = new HashSet<>();
    for (int y = 0; y <= 3; y++) {
        for (int x = -1; x <= 1; x++) {
            for (int z = -1; z <= 1; z++) {
                // Skip blocks in the column of the player
                if (x == 0 && z == 0) {
                    continue;
                }
                around.add(below.getRelative(x, y, z).getType());
            }
        }
    }
    // Check the blocks around the player
    for (Material material : around) {
        if (cannotSpawnBeside.contains(material)) {
            return false;
        }
    }
    return true;
}
Also used : Block(org.bukkit.block.Block) Material(org.bukkit.Material) HashSet(java.util.HashSet)

Aggregations

Material (org.bukkit.Material)427 ItemStack (org.bukkit.inventory.ItemStack)99 Block (org.bukkit.block.Block)87 EventHandler (org.bukkit.event.EventHandler)51 ArrayList (java.util.ArrayList)46 Player (org.bukkit.entity.Player)44 Location (org.bukkit.Location)42 Vector (org.bukkit.util.Vector)27 EntityType (org.bukkit.entity.EntityType)26 GlowBlock (net.glowstone.block.GlowBlock)24 Test (org.junit.Test)24 BlockFace (org.bukkit.block.BlockFace)23 Entity (org.bukkit.entity.Entity)22 MaterialData (org.bukkit.material.MaterialData)22 World (org.bukkit.World)20 HashMap (java.util.HashMap)19 IOException (java.io.IOException)17 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)16 File (java.io.File)15 HashSet (java.util.HashSet)13