Skip to content

Instantly share code, notes, and snippets.

@97WaterPolo
Created February 28, 2014 22:40
Show Gist options
  • Save 97WaterPolo/9281550 to your computer and use it in GitHub Desktop.
Save 97WaterPolo/9281550 to your computer and use it in GitHub Desktop.
package com.rebelempiremc.sigler.resource;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
@SuppressWarnings("unused")
public class RemcAPI
{
public static Boolean isPlayerOnline(Player player)
{
if (player.isOnline())
{
return true;
}else
{
return false;
}
}
public static ItemStack coloredArmor(Material material, Color color, String name)
{
ItemStack leatherArmor = new ItemStack(material);
LeatherArmorMeta meta = (LeatherArmorMeta) leatherArmor.getItemMeta();
meta.setColor(color);
if ( name != null )
{
meta.setDisplayName(name);
}
leatherArmor.setItemMeta(meta);
return leatherArmor;
}
public static String rainbow(String string)
{
int lastColor = 0;
int currColor = 0;
String newMessage = "";
String colors = "123456789abcde";
for ( int i = 0; i < string.length(); i++ )
{
do
{
currColor = new Random().nextInt(colors.length() - 1) + 1;
}
while (currColor == lastColor);
newMessage += ChatColor.RESET.toString() + ChatColor.getByChar(colors.charAt(currColor)) + "" + string.charAt(i);
}
return newMessage;
}
public static void resetInv(Player player, Boolean normal, Double health)
{
if (normal != false)
{
player.getInventory().setHelmet(null);
player.getInventory().setChestplate(null);
player.getInventory().setLeggings(null);
player.getInventory().setBoots(null);
player.getInventory().clear();
}else
{
player.getInventory().setHelmet(null);
player.getInventory().setChestplate(null);
player.getInventory().setLeggings(null);
player.getInventory().setBoots(null);
player.getInventory().clear();
player.setExp(0);
player.setLevel(0);
player.setMaxHealth(health);
player.setHealth(player.getMaxHealth());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment