Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.ByteArrayOutputStream;
- import java.io.DataOutputStream;
- import java.io.File;
- import java.io.IOException;
- import java.util.List;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Difficulty;
- import org.bukkit.Material;
- import org.bukkit.Sound;
- import org.bukkit.World;
- import org.bukkit.WorldCreator;
- import org.bukkit.entity.Entity;
- import org.bukkit.entity.EntityType;
- import org.bukkit.entity.Item;
- import org.bukkit.entity.Player;
- import org.bukkit.inventory.ItemStack;
- public class Functions {
- public static void clearItem(){
- World world = Main.plugin.getServer().getWorld("world");
- List<Entity> entList = world.getEntities();
- for(Entity current : entList){
- if (current instanceof Item) current.remove();
- }
- }
- public static void clearInv(Player p){
- p.getInventory().clear();
- p.getInventory().setHelmet(new ItemStack (Material.AIR));
- p.getInventory().setChestplate(new ItemStack (Material.AIR));
- p.getInventory().setLeggings(new ItemStack (Material.AIR));
- p.getInventory().setBoots(new ItemStack (Material.AIR));
- }
- static void xpLevel(int level) {
- for(Player p : Bukkit.getOnlinePlayers()){
- p.setLevel(level);
- }
- }
- static void xpSound() {
- for(Player p : Bukkit.getOnlinePlayers()){
- p.playSound(p.getLocation(), Sound.ORB_PICKUP, 1, 0);
- }
- }
- static void witherSound(){
- for(Player p : Bukkit.getOnlinePlayers()){
- p.playSound(p.getLocation(), Sound.WITHER_SPAWN, 1, 1);
- }
- }
- static void noteboxSound(){
- for(Player p : Bukkit.getOnlinePlayers()){
- p.playSound(p.getLocation(), Sound.NOTE_PLING, 1, 0);
- }
- }
- static void CountDown(){
- if(Main.CountDown == 0) {
- Bukkit.broadcastMessage(Main.prefix + ChatColor.RED + "Le jeux commence");
- }
- else if(Main.CountDown > 60){
- Bukkit.broadcastMessage(Main.prefix + ChatColor.GOLD + ""+ Main.CountDown + " seconde(s) avant que le jeu commence");
- }
- else if (Main.CountDown > 5 && Main.CountDown < 60){
- Bukkit.broadcastMessage(Main.prefix + ChatColor.GOLD + "" + Main.CountDown + " seconde(s) avant que le jeu commence");
- xpSound();
- }
- else{
- Bukkit.broadcastMessage(Main.prefix + ChatColor.GOLD + "" + Main.CountDown + " seconde(s) avant que le jeu commence");
- noteboxSound();
- }
- }
- public static void gotohub(Player p){
- Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "BungeeCord");
- ByteArrayOutputStream b = new ByteArrayOutputStream();
- DataOutputStream out = new DataOutputStream(b);
- try {
- out.writeUTF("Connect");
- out.writeUTF("lobby");
- } catch (IOException ex) {}
- p.sendPluginMessage(Main.plugin, "BungeeCord", b.toByteArray());
- }
- public static void ClearDrops(){
- World w = Bukkit.getServer().getWorld("world");
- if (w == null) return;
- for (Entity e : w.getEntities()){
- if (e.getType() == EntityType.DROPPED_ITEM) e.remove();
- }
- }
- public static void resetMap() {
- // On désactive la map
- Bukkit.unloadWorld("map", false);
- File src = new File("plugins/MgCore/map");
- File dest = new File("map/");
- FilesFunctions.deleteDirectory(dest);
- try {
- FilesFunctions.copyFolder(src, dest);
- } catch (IOException e) { e.printStackTrace(); Bukkit.shutdown(); }
- Bukkit.getServer().createWorld(new WorldCreator("map"));
- Bukkit.getWorld("map").setKeepSpawnInMemory(false);
- Bukkit.getWorld("map").setDifficulty(Difficulty.EASY);
- Bukkit.getWorld("map").setAnimalSpawnLimit(0);
- Bukkit.getWorld("map").setMonsterSpawnLimit(0);
- Bukkit.getServer().getWorld("map").setGameRuleValue("doDaylightCycle", "false");
- Bukkit.getServer().getWorld("map").setTime(Main.doDaylightCycleStart);
- if(Main.hardcore) Bukkit.getServer().getWorld("map").setGameRuleValue("naturalRegeneration", "false");
- else Bukkit.getServer().getWorld("map").setGameRuleValue("naturalRegeneration", "true");
- Bukkit.getWorld("map").setPVP(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement