Ir para conteúdo

[Código Java] Kit '-'


Guest » MickCraft » xKizame »

Posts Recomendados

Guest » MickCraft » xKizame »

Eu tava fazendo um plugin de kit para meu servidor mais fiquei sem vontade de termina então ai pra vcs '-'

Obs: MrPowerGamerBR ajudou a colocar o new ItemStack.

Não e um KIT de MiniGame/HunterGames.. e um kit de tipo CraftLandia.. pra servidor fullpvp.

 

Código:

package me.erinaldo.com;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

public class Kit extends JavaPlugin implements Listener{
	
	public void onEnable(){
		System.out.println("§bIniciando o plugin");
	}
	
	public void onDisable(){
		System.out.println("§cFinalizando o plugin");
	}
	
	public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
		if(command.getName().equalsIgnoreCase("kit"));
		Player p = (Player)sender;
		if (!p.hasPermission("SrKit.usar")){
			p.sendMessage("§aVocê recebeu o kit especial §6VIP§a.");
			if (p.getInventory().getContents() == null) {
				if (p.getInventory().getArmorContents() == null) {
			        p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 80, 1));
			        p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 80, 1));
					p.getInventory().setHelmet(new ItemStack (Material.DIAMOND_HELMET));
					p.getInventory().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
					p.getInventory().setLeggings(new ItemStack (Material.DIAMOND_LEGGINGS));
					p.getInventory().setBoots(new ItemStack(Material.DIAMOND_BOOTS));
					new ItemStack(Material.DIAMOND_SWORD, 1, (short) 1);
					new ItemStack(Material.GOLDEN_APPLE, 1, (short) 1);
					new ItemStack(Material.BREAD, 1, (short) 1);
		              Location loc = p.getLocation();
		              World w = loc.getWorld();
		              double x = loc.getX();
		              double y = loc.getY();
		              double z = loc.getZ();
		              p.getWorld().strikeLightningEffect(new Location(w, x, y, z));
		              
		              String data = "["+getSystemDataEditFormat("dd/MM/yyyy")+"]";
		              String hora = "["+getSystemDataEditFormat("HH:mm")+"]";
		              File f = new File(getDataFolder(), "Players.yml");
		              FileConfiguration fc = YamlConfiguration.loadConfiguration(f);
		              fc.set("LOGs. "+data+" "+hora,p.getName()+" usou o comando /kit e pegou um kit especial");
		              try{
		                  fc.save(f);
		              }catch (Exception e1){}
		              
			return true;
		}
			}
			p.sendMessage("§cVocê não tem permissão para ultilizar esse comando!");
		}
		return true;
	}
	
    public static String getSystemDataEditFormat(String formato){
        Calendar c = Calendar.getInstance();
        Date d = c.getTime();
        SimpleDateFormat sdf = new SimpleDateFormat(formato);
        return sdf.format(d);
}
}

Códigozinho com logzinha pro servidorzinho :D

 

Link para o comentário
Compartilhar em outros sites

Guest » MickCraft » xKizame »

Sou viado, e gosto de assumir que queimo.

"CraftLandia" no sentido que e um kit se eu anunciasse outro servidor vocês não ia conhecer

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...