Re-structure TwosideKeeper project such that it builds properly and has
a proper build file.
This commit is contained in:
commit
4bc6abfef8
BIN
TwosideKeeper.jar
Normal file
BIN
TwosideKeeper.jar
Normal file
Binary file not shown.
6
projectBuilder.xml
Normal file
6
projectBuilder.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project name="TwosideKeeper.makejar" default="makejar" basedir=".">
|
||||||
|
<target name ="makejar" description="Create a jar for the TwosideKeeper project">
|
||||||
|
<jar jarfile="TwosideKeeper.jar" includes="**/*.class,**/*.yml" basedir="bin"/>
|
||||||
|
</target>
|
||||||
|
</project>
|
39
src/plugin.yml
Normal file
39
src/plugin.yml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
name: TwosideKeeper
|
||||||
|
main: sig.plugin.TwosideKeeper.TwosideKeeper
|
||||||
|
version: 3.3.4
|
||||||
|
commands:
|
||||||
|
money:
|
||||||
|
description: Tells the player the amount of money they are holding.
|
||||||
|
usage: /money
|
||||||
|
permission: TwosideKeeper.money
|
||||||
|
permission-message: You don't have permission to check your balance!
|
||||||
|
enchant_advanced:
|
||||||
|
description: Enchants items with more properties.
|
||||||
|
usage: /enchant_advanced <enchantment> <level>
|
||||||
|
permission: TwosideKeeper.enchant
|
||||||
|
permission-message: No permissions!
|
||||||
|
harden_armor:
|
||||||
|
description: Hardens a piece of armor.
|
||||||
|
usage: /harden_armor <breaks>
|
||||||
|
permission: TwosideKeeper.harden
|
||||||
|
permission-message: No permissions!
|
||||||
|
item_cube:
|
||||||
|
description: Sets this item as an item cube.
|
||||||
|
usage: /item_cube <id>
|
||||||
|
permission: TwosideKeeper.item_cube
|
||||||
|
permission-message: No permissions!
|
||||||
|
artifact:
|
||||||
|
description: Gives the player an artifact.
|
||||||
|
usage: /artifact <ArtifactType>
|
||||||
|
permission: TwosideKeeper.artifact
|
||||||
|
permission-message: No permissions!
|
||||||
|
recyclingcenter:
|
||||||
|
description: Defines a new container for a Recycling Center.
|
||||||
|
usage: /recyclingcenter
|
||||||
|
permission: TwosideKeeper.recyclingcenter
|
||||||
|
permission-message: No permissions!
|
||||||
|
sound:
|
||||||
|
description: Toggle sound message notifications.
|
||||||
|
usage: /sound
|
||||||
|
permission: TwosideKeeper.sound
|
||||||
|
permission-message: No permissions!
|
176
src/sig/plugin/TwosideKeeper/Artifact.java
Normal file
176
src/sig/plugin/TwosideKeeper/Artifact.java
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
package sig.plugin.TwosideKeeper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItem;
|
||||||
|
|
||||||
|
public class Artifact {
|
||||||
|
public static ItemStack createArtifactItem(ArtifactItem type) {
|
||||||
|
ItemStack i = null;
|
||||||
|
switch (type) {
|
||||||
|
case ANCIENT_BASE:
|
||||||
|
i=new ItemStack(Material.CLAY_BALL);
|
||||||
|
break;
|
||||||
|
case ANCIENT_CORE:
|
||||||
|
i=new ItemStack(Material.MAGMA_CREAM);
|
||||||
|
break;
|
||||||
|
case ANCIENT_ESSENCE:
|
||||||
|
i=new ItemStack(Material.SUGAR);
|
||||||
|
break;
|
||||||
|
case ARTIFACT_BASE:
|
||||||
|
i=new ItemStack(Material.CLAY_BALL);
|
||||||
|
break;
|
||||||
|
case ARTIFACT_CORE:
|
||||||
|
i=new ItemStack(Material.MAGMA_CREAM);
|
||||||
|
break;
|
||||||
|
case ARTIFACT_ESSENCE:
|
||||||
|
i=new ItemStack(Material.SUGAR);
|
||||||
|
break;
|
||||||
|
case DIVINE_BASE:
|
||||||
|
i=new ItemStack(Material.CLAY_BALL);
|
||||||
|
break;
|
||||||
|
case DIVINE_CORE:
|
||||||
|
i=new ItemStack(Material.MAGMA_CREAM);
|
||||||
|
break;
|
||||||
|
case DIVINE_ESSENCE:
|
||||||
|
i=new ItemStack(Material.SUGAR);
|
||||||
|
break;
|
||||||
|
case LOST_BASE:
|
||||||
|
i=new ItemStack(Material.CLAY_BALL);
|
||||||
|
break;
|
||||||
|
case LOST_CORE:
|
||||||
|
i=new ItemStack(Material.MAGMA_CREAM);
|
||||||
|
break;
|
||||||
|
case LOST_ESSENCE:
|
||||||
|
i=new ItemStack(Material.SUGAR);
|
||||||
|
break;
|
||||||
|
case MALLEABLE_BASE:
|
||||||
|
i=new ItemStack(Material.INK_SACK,1,(short) 7);
|
||||||
|
break;
|
||||||
|
case MYSTERIOUS_ESSENCE:
|
||||||
|
i=new ItemStack(Material.PUMPKIN_SEEDS);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
i=new ItemStack(Material.AIR);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return convert(setName(i,type),type,true);
|
||||||
|
}
|
||||||
|
public static ItemStack setName(ItemStack i, ArtifactItem type) {
|
||||||
|
ItemMeta m = i.getItemMeta();
|
||||||
|
switch (type) {
|
||||||
|
case ANCIENT_BASE:
|
||||||
|
m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Ancient Base");
|
||||||
|
break;
|
||||||
|
case ANCIENT_CORE:
|
||||||
|
m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Ancient Core");
|
||||||
|
break;
|
||||||
|
case ANCIENT_ESSENCE:
|
||||||
|
m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Ancient Essence");
|
||||||
|
break;
|
||||||
|
case ARTIFACT_BASE:
|
||||||
|
m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Artifact Base");
|
||||||
|
break;
|
||||||
|
case ARTIFACT_CORE:
|
||||||
|
m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Artifact Core");
|
||||||
|
break;
|
||||||
|
case ARTIFACT_ESSENCE:
|
||||||
|
m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Artifact Essence");
|
||||||
|
break;
|
||||||
|
case DIVINE_BASE:
|
||||||
|
m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Divine Base");
|
||||||
|
break;
|
||||||
|
case DIVINE_CORE:
|
||||||
|
m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Divine Core");
|
||||||
|
break;
|
||||||
|
case DIVINE_ESSENCE:
|
||||||
|
m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Divine Essence");
|
||||||
|
break;
|
||||||
|
case LOST_BASE:
|
||||||
|
m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Lost Base");
|
||||||
|
break;
|
||||||
|
case LOST_CORE:
|
||||||
|
m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Lost Core");
|
||||||
|
break;
|
||||||
|
case LOST_ESSENCE:
|
||||||
|
m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Lost Essence");
|
||||||
|
break;
|
||||||
|
case MALLEABLE_BASE:
|
||||||
|
m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Malleable Base");
|
||||||
|
break;
|
||||||
|
case MYSTERIOUS_ESSENCE:
|
||||||
|
m.setDisplayName(ChatColor.BOLD+""+ChatColor.LIGHT_PURPLE+"Mysterious Essence");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i.setItemMeta(m);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
public static ItemStack convert(ItemStack item, ArtifactItem type, boolean reprint_lore) {
|
||||||
|
//Converts an item to an artifact.
|
||||||
|
ItemMeta m = item.getItemMeta();
|
||||||
|
List<String> l = new ArrayList<String>();
|
||||||
|
if (item.getItemMeta().hasLore()) {
|
||||||
|
l = item.getItemMeta().getLore();
|
||||||
|
}
|
||||||
|
if (reprint_lore) {
|
||||||
|
l.add(ChatColor.GOLD+""+ChatColor.ITALIC+"Artifact Crafting Item");
|
||||||
|
if (type==ArtifactItem.MALLEABLE_BASE) {
|
||||||
|
l.add(ChatColor.YELLOW+" Right-click to activate");
|
||||||
|
l.add(ChatColor.YELLOW+" this base.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m.setLore(l);
|
||||||
|
item.setItemMeta(m);
|
||||||
|
if (type.toString().contains("ARTIFACT")) {
|
||||||
|
item.addUnsafeEnchantment(Enchantment.LUCK, 1);
|
||||||
|
} else
|
||||||
|
if (type.toString().contains("ANCIENT")) {
|
||||||
|
item.addUnsafeEnchantment(Enchantment.LUCK, 2);
|
||||||
|
} else
|
||||||
|
if (type.toString().contains("LOST")) {
|
||||||
|
item.addUnsafeEnchantment(Enchantment.LUCK, 3);
|
||||||
|
} else
|
||||||
|
if (type.toString().contains("DIVINE")) {
|
||||||
|
item.addUnsafeEnchantment(Enchantment.LUCK, 4);
|
||||||
|
} else {
|
||||||
|
item.addUnsafeEnchantment(Enchantment.LUCK, 10);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
public static ItemStack convert(ItemStack item, boolean reprint_lore) {
|
||||||
|
//Converts an item to an artifact.
|
||||||
|
return convert(item, ArtifactItem.ARTIFACT_ESSENCE, reprint_lore);
|
||||||
|
}
|
||||||
|
public static ItemStack convert(ItemStack item) {
|
||||||
|
//Converts an item to an artifact.
|
||||||
|
return convert(item, ArtifactItem.ARTIFACT_ESSENCE, true);
|
||||||
|
}
|
||||||
|
public static boolean isArtifact(ItemStack item) {
|
||||||
|
if (item.hasItemMeta() &&
|
||||||
|
item.getItemMeta().hasLore() &&
|
||||||
|
item.getItemMeta().getLore().contains(ChatColor.GOLD+""+ChatColor.ITALIC+"Artifact Crafting Item")) {
|
||||||
|
//This is an artifact.
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static boolean isMalleableBase(ItemStack item) {
|
||||||
|
//Check for type of item, and if it's an artifact.
|
||||||
|
if (isArtifact(item) &&
|
||||||
|
item.getType()==Material.INK_SACK &&
|
||||||
|
item.getDurability()==7) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
155
src/sig/plugin/TwosideKeeper/DeathManager.java
Normal file
155
src/sig/plugin/TwosideKeeper/DeathManager.java
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
package sig.plugin.TwosideKeeper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryView;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.DeathStructure;
|
||||||
|
|
||||||
|
public class DeathManager {
|
||||||
|
static String Pick5Text = "Mercy (Pick 5 Lost Items)";
|
||||||
|
static String Pick20Text = "Mercy (Pick 20 Lost Items Randomly)";
|
||||||
|
static String BuybackText = "Buyback (Pay for Lost Items)";
|
||||||
|
static String DropText = "Drop Items (At death point)";
|
||||||
|
public static List<DeathStructure> ds = new ArrayList<DeathStructure>();
|
||||||
|
|
||||||
|
public static void addNewDeathStructure(List<ItemStack> deathinv, Location deathloc, Player p) {
|
||||||
|
ds.add(new DeathStructure(deathinv,deathloc,p));
|
||||||
|
}
|
||||||
|
public static void removeDeathStructure(Player p) {
|
||||||
|
ds.remove(getDeathStructure(p));
|
||||||
|
}
|
||||||
|
public static boolean deathStructureExists(Player p) {
|
||||||
|
if (getDeathStructure(p)!=null) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
public static void givePlayerDeathChoices(Player p) {
|
||||||
|
//Also stop the player from moving.
|
||||||
|
ItemStack pick_five = new ItemStack(Material.COMMAND);
|
||||||
|
ItemMeta meta = pick_five.getItemMeta();
|
||||||
|
meta.setDisplayName(Pick5Text);
|
||||||
|
pick_five.setItemMeta(meta);
|
||||||
|
pick_five.addUnsafeEnchantment(Enchantment.LUCK, 1);
|
||||||
|
ItemStack pick_twenty = new ItemStack(Material.COMMAND_CHAIN);
|
||||||
|
meta = pick_twenty.getItemMeta();
|
||||||
|
meta.setDisplayName(Pick20Text);
|
||||||
|
pick_twenty.setItemMeta(meta);
|
||||||
|
pick_twenty.addUnsafeEnchantment(Enchantment.LUCK, 1);
|
||||||
|
ItemStack buyback = new ItemStack(Material.COMMAND_REPEATING);
|
||||||
|
meta = buyback.getItemMeta();
|
||||||
|
meta.setDisplayName(BuybackText);
|
||||||
|
buyback.setItemMeta(meta);
|
||||||
|
buyback.addUnsafeEnchantment(Enchantment.LUCK, 1);
|
||||||
|
ItemStack normaldrop = new ItemStack(Material.BARRIER);
|
||||||
|
meta = normaldrop.getItemMeta();
|
||||||
|
meta.setDisplayName(DropText);
|
||||||
|
normaldrop.setItemMeta(meta);
|
||||||
|
normaldrop.addUnsafeEnchantment(Enchantment.LUCK, 1);
|
||||||
|
|
||||||
|
|
||||||
|
p.getInventory().addItem(pick_five);
|
||||||
|
p.getInventory().addItem(pick_twenty);
|
||||||
|
p.getInventory().addItem(buyback);
|
||||||
|
p.getInventory().addItem(normaldrop);
|
||||||
|
|
||||||
|
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,999999999,10));
|
||||||
|
p.sendMessage(ChatColor.AQUA+"Place down the block indicating how you want to retrieve your lost items.");
|
||||||
|
}*/
|
||||||
|
public static boolean isDeathBlock(ItemStack b) {
|
||||||
|
if (b.hasItemMeta() &&
|
||||||
|
b.getItemMeta().hasDisplayName() &&
|
||||||
|
b.containsEnchantment(Enchantment.LUCK)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DeathStructure getDeathStructure(Player p) {
|
||||||
|
for (int i=0;i<ds.size();i++) {
|
||||||
|
if (ds.get(i).p.equalsIgnoreCase(p.getName())) {
|
||||||
|
return ds.get(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void continueAction(Player p) {
|
||||||
|
//Pick 5
|
||||||
|
|
||||||
|
DeathStructure structure = getDeathStructure(p);
|
||||||
|
|
||||||
|
Inventory deathinv = Bukkit.getServer().createInventory(p, 45, "Death Loot");
|
||||||
|
for (int i=0;i<structure.deathinventory.size();i++) {
|
||||||
|
/*
|
||||||
|
if (i>=36) {
|
||||||
|
if (pd.deathinventory.get(i).getType().toString().contains("BOOTS")) {
|
||||||
|
p.getInventory().setBoots(pd.deathinventory.get(i));
|
||||||
|
} else
|
||||||
|
if (pd.deathinventory.get(i).getType().toString().contains("SHIELD")) {
|
||||||
|
p.getInventory().setItemInOffHand(pd.deathinventory.get(i));
|
||||||
|
} else
|
||||||
|
if (pd.deathinventory.get(i).getType().toString().contains("LEGGINGS")) {
|
||||||
|
p.getInventory().setLeggings(pd.deathinventory.get(i));
|
||||||
|
} else
|
||||||
|
if (pd.deathinventory.get(i).getType().toString().contains("CHESTPLATE")) {
|
||||||
|
p.getInventory().setChestplate(pd.deathinventory.get(i));
|
||||||
|
} else
|
||||||
|
if (pd.deathinventory.get(i).getType().toString().contains("HELMET")) {
|
||||||
|
p.getInventory().setHelmet(pd.deathinventory.get(i));
|
||||||
|
} else {
|
||||||
|
//What is this? Just drop it.
|
||||||
|
p.getLocation().getWorld().dropItem(p.getLocation(), pd.deathinventory.get(i));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p.getInventory().addItem(pd.deathinventory.get(i));
|
||||||
|
}*/
|
||||||
|
if (structure.deathinventory.get(i)!=null &&
|
||||||
|
structure.deathinventory.get(i).getType()!=Material.AIR) {
|
||||||
|
deathinv.addItem(structure.deathinventory.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
double totalmoney = TwosideKeeper.getPlayerMoney(p)+TwosideKeeper.getPlayerBankMoney(p);
|
||||||
|
int price = 1;
|
||||||
|
if (structure.deathloc.getBlockY()<=60) {
|
||||||
|
price += 24-(structure.deathloc.getBlockY()/2.5);
|
||||||
|
}
|
||||||
|
p.openInventory(deathinv);
|
||||||
|
p.sendMessage(ChatColor.AQUA+"You can buy back up to "+ChatColor.YELLOW+(int)(totalmoney/price)+ChatColor.AQUA+" items, costing $"+ChatColor.GREEN+price+ChatColor.WHITE+" per item.");
|
||||||
|
p.sendMessage(" The rest will drop at your death location.");
|
||||||
|
p.sendMessage(ChatColor.GRAY+"Close your inventory once you've picked your items.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int CalculateDeathPrice(Player p) {
|
||||||
|
DeathStructure ds = getDeathStructure(p);
|
||||||
|
return (int)(1+((ds.deathloc.getBlockY()<=60)?(24-(ds.deathloc.getBlockY()/2.5)):0));
|
||||||
|
}
|
||||||
|
public static int CountOccupiedSlots(Inventory inv) {
|
||||||
|
int occupiedslots = 0;
|
||||||
|
for (int i=0;i<inv.getSize();i++) {
|
||||||
|
if (inv.getItem(i)!=null &&
|
||||||
|
inv.getItem(i).getType()!=Material.AIR) {
|
||||||
|
occupiedslots++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return occupiedslots;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package sig.plugin.TwosideKeeper.HelperStructures;
|
||||||
|
|
||||||
|
public enum ArtifactItem {
|
||||||
|
MYSTERIOUS_ESSENCE,
|
||||||
|
ARTIFACT_ESSENCE,
|
||||||
|
ARTIFACT_CORE,
|
||||||
|
ARTIFACT_BASE,
|
||||||
|
ANCIENT_ESSENCE,
|
||||||
|
ANCIENT_CORE,
|
||||||
|
ANCIENT_BASE,
|
||||||
|
LOST_ESSENCE,
|
||||||
|
LOST_CORE,
|
||||||
|
LOST_BASE,
|
||||||
|
DIVINE_ESSENCE,
|
||||||
|
DIVINE_CORE,
|
||||||
|
DIVINE_BASE,
|
||||||
|
MALLEABLE_BASE
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package sig.plugin.TwosideKeeper.HelperStructures;
|
||||||
|
|
||||||
|
public enum CubeType {
|
||||||
|
NORMAL,LARGE,ENDER
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package sig.plugin.TwosideKeeper.HelperStructures;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class DeathStructure {
|
||||||
|
|
||||||
|
public List<ItemStack> deathinventory;
|
||||||
|
public Location deathloc;
|
||||||
|
public String p;
|
||||||
|
|
||||||
|
public DeathStructure(List<ItemStack> di, Location dl, Player p) {
|
||||||
|
this.deathinventory=di;
|
||||||
|
this.deathloc=dl;
|
||||||
|
this.p=p.getName();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package sig.plugin.TwosideKeeper.HelperStructures;
|
||||||
|
|
||||||
|
public enum ItemRarity {
|
||||||
|
VANILLA, RARE, EPIC, LEGENDARY;
|
||||||
|
}
|
@ -0,0 +1,288 @@
|
|||||||
|
package sig.plugin.TwosideKeeper.HelperStructures;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import sig.plugin.TwosideKeeper.Artifact;
|
||||||
|
import sig.plugin.TwosideKeeper.TwosideKeeper;
|
||||||
|
|
||||||
|
public class MalleableBaseQuest {
|
||||||
|
|
||||||
|
/*LORE FORMAT:
|
||||||
|
* FORMING IN PROGRESS
|
||||||
|
* Base requires 'ITEM_NAME' to
|
||||||
|
* continue forming... (5/30)
|
||||||
|
* 4893210801 <--Server Tick Time
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static ItemStack startQuest(ItemStack base) {
|
||||||
|
//Formats the item lore in preparation for the quest.
|
||||||
|
ItemMeta m = base.getItemMeta();
|
||||||
|
List<String> lore = new ArrayList<String>();
|
||||||
|
lore.add(ChatColor.RED+"FORMING IN PROGRESS");
|
||||||
|
lore.add(ChatColor.BLUE+"Base requires "+ChatColor.AQUA+"'"+TwosideKeeper.UserFriendlyMaterialName(new ItemStack(selectItem()))+"'"+ChatColor.BLUE+" to");
|
||||||
|
lore.add(ChatColor.BLUE+"continue forming... "+ChatColor.GREEN+"(0/30)");
|
||||||
|
lore.add(ChatColor.BLUE+""+TwosideKeeper.getServerTickTime());
|
||||||
|
m.setLore(lore);
|
||||||
|
base.setItemMeta(m);
|
||||||
|
return Artifact.convert(base);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack setTimeStarted(ItemStack base, long time) {
|
||||||
|
//The time started is always on the third line.
|
||||||
|
ItemMeta m = base.getItemMeta();
|
||||||
|
List<String> lore = m.getLore();
|
||||||
|
lore.remove(2);
|
||||||
|
lore.add(2,ChatColor.BLUE+""+TwosideKeeper.getServerTickTime());
|
||||||
|
m.setLore(lore);
|
||||||
|
base.setItemMeta(m);
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
public static ItemStack setItem(ItemStack base, Material mat) {
|
||||||
|
//Sets the material to this item instead.
|
||||||
|
ItemMeta m = base.getItemMeta();
|
||||||
|
List<String> lore = m.getLore();
|
||||||
|
lore.remove(1);
|
||||||
|
lore.add(1,ChatColor.BLUE+"Base requires "+ChatColor.AQUA+"'"+mat.toString()+"'"+ChatColor.BLUE+" to");
|
||||||
|
m.setLore(lore);
|
||||||
|
base.setItemMeta(m);
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
public static ItemStack advanceQuestProgress(ItemStack base) {
|
||||||
|
//This should occur when the base quest is ready to proceed.
|
||||||
|
//Advance the progress by one.
|
||||||
|
//Choose the next item randomly.
|
||||||
|
ItemMeta m = base.getItemMeta();
|
||||||
|
List<String> lore = m.getLore();
|
||||||
|
lore.remove(1);
|
||||||
|
lore.add(1,ChatColor.BLUE+"Base requires "+ChatColor.AQUA+"'"+TwosideKeeper.UserFriendlyMaterialName(new ItemStack(selectItem()))+"'"+ChatColor.BLUE+" to");
|
||||||
|
//Get the old quest progress.
|
||||||
|
int progress = getCurrentProgress(base);
|
||||||
|
lore.remove(2);
|
||||||
|
lore.add(2,ChatColor.BLUE+"continue forming... "+ChatColor.GREEN+"("+(progress+1)+"/30)");
|
||||||
|
m.setLore(lore);
|
||||||
|
base.setItemMeta(m);
|
||||||
|
return Artifact.convert(base,false);
|
||||||
|
}
|
||||||
|
public static ItemStack completeQuest(ItemStack base) {
|
||||||
|
//Triggered when the quest is done. Turn into a base.
|
||||||
|
//Get the time now, and the time when we started the quest.
|
||||||
|
long starttime = getTimeStarted(base);
|
||||||
|
long currenttime = TwosideKeeper.getServerTickTime();
|
||||||
|
|
||||||
|
if (currenttime-starttime<=36000) { //30 min passed. Divine tier.
|
||||||
|
return Artifact.createArtifactItem(ArtifactItem.DIVINE_BASE);
|
||||||
|
} else
|
||||||
|
if (currenttime-starttime<=72000) { //1 hour passed. Lost tier.
|
||||||
|
return Artifact.createArtifactItem(ArtifactItem.LOST_BASE);
|
||||||
|
} else
|
||||||
|
if (currenttime-starttime<=144000) { //2 hours passed. Ancient tier.
|
||||||
|
return Artifact.createArtifactItem(ArtifactItem.ANCIENT_BASE);
|
||||||
|
} else
|
||||||
|
{ //>2 hours passed. Artifact tier.
|
||||||
|
return Artifact.createArtifactItem(ArtifactItem.ARTIFACT_BASE);
|
||||||
|
}/* else //Too harsh. We are not going to make the player start all over.
|
||||||
|
{
|
||||||
|
//This failed. Turn it back into a Malleable base.
|
||||||
|
return Artifact.createArtifactItem(ArtifactItem.MALLEABLE_BASE);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getItem(ItemStack base) {
|
||||||
|
//Get current item for this Base.
|
||||||
|
ItemMeta m = base.getItemMeta();
|
||||||
|
List<String> lore = m.getLore();
|
||||||
|
String material_name = lore.get(1).split("'")[1];
|
||||||
|
return material_name;
|
||||||
|
}
|
||||||
|
public static int getCurrentProgress(ItemStack base) {
|
||||||
|
//How many quest items have been completed already?
|
||||||
|
ItemMeta m = base.getItemMeta();
|
||||||
|
List<String> lore = m.getLore();
|
||||||
|
String progress = lore.get(2).substring(lore.get(2).indexOf("(", 0)+1,lore.get(2).indexOf("/", 0));
|
||||||
|
return Integer.parseInt(progress);
|
||||||
|
}
|
||||||
|
public static long getTimeStarted(ItemStack base) {
|
||||||
|
//Returns the server tick time this quest was started on.
|
||||||
|
ItemMeta m = base.getItemMeta();
|
||||||
|
List<String> lore = m.getLore();
|
||||||
|
String timelore = lore.get(3).replace(ChatColor.BLUE+"", "");
|
||||||
|
return Long.parseLong(timelore);
|
||||||
|
|
||||||
|
}
|
||||||
|
public static QuestStatus getStatus(ItemStack base) {
|
||||||
|
ItemMeta m = base.getItemMeta();
|
||||||
|
if (m.getLore().contains(ChatColor.RED+"FORMING IN PROGRESS")) {
|
||||||
|
return QuestStatus.IN_PROGRESS;
|
||||||
|
} else {
|
||||||
|
return QuestStatus.UNFORMED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void announceQuestItem(Plugin plug, final Player p, final ItemStack i) {
|
||||||
|
/*Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
setPlayerMaxHealth(player);
|
||||||
|
}
|
||||||
|
},1);*/
|
||||||
|
p.sendMessage(ChatColor.AQUA+"The item you must obtain...");
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plug, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
p.sendMessage(ChatColor.AQUA+"is "+ChatColor.GREEN+getItem(i));
|
||||||
|
}
|
||||||
|
},40);
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plug, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
p.sendMessage(ChatColor.AQUA+"Right-click the base again once you have the item in your hotbar!");
|
||||||
|
}
|
||||||
|
},80);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Material selectItem() {
|
||||||
|
//Material.values().
|
||||||
|
List<Material> blacklisted_items = new ArrayList<Material>();
|
||||||
|
blacklisted_items.add(Material.ACACIA_DOOR);
|
||||||
|
blacklisted_items.add(Material.AIR);
|
||||||
|
blacklisted_items.add(Material.BARRIER);
|
||||||
|
blacklisted_items.add(Material.BED_BLOCK);
|
||||||
|
blacklisted_items.add(Material.BEDROCK);
|
||||||
|
blacklisted_items.add(Material.BEETROOT_BLOCK);
|
||||||
|
blacklisted_items.add(Material.BEETROOT);
|
||||||
|
blacklisted_items.add(Material.BIRCH_DOOR);
|
||||||
|
blacklisted_items.add(Material.BREWING_STAND);
|
||||||
|
blacklisted_items.add(Material.BURNING_FURNACE);
|
||||||
|
blacklisted_items.add(Material.CAKE_BLOCK);
|
||||||
|
blacklisted_items.add(Material.CARROT);
|
||||||
|
blacklisted_items.add(Material.CAULDRON);
|
||||||
|
blacklisted_items.add(Material.CHAINMAIL_BOOTS);
|
||||||
|
blacklisted_items.add(Material.CHAINMAIL_CHESTPLATE);
|
||||||
|
blacklisted_items.add(Material.CHAINMAIL_HELMET);
|
||||||
|
blacklisted_items.add(Material.CHAINMAIL_LEGGINGS);
|
||||||
|
blacklisted_items.add(Material.CHAINMAIL_BOOTS);
|
||||||
|
blacklisted_items.add(Material.CHORUS_PLANT);
|
||||||
|
blacklisted_items.add(Material.COCOA);
|
||||||
|
blacklisted_items.add(Material.COMMAND);
|
||||||
|
blacklisted_items.add(Material.COMMAND_CHAIN);
|
||||||
|
blacklisted_items.add(Material.COMMAND_MINECART);
|
||||||
|
blacklisted_items.add(Material.COMMAND_REPEATING);
|
||||||
|
blacklisted_items.add(Material.CROPS);
|
||||||
|
blacklisted_items.add(Material.DARK_OAK_DOOR);
|
||||||
|
blacklisted_items.add(Material.DAYLIGHT_DETECTOR_INVERTED);
|
||||||
|
blacklisted_items.add(Material.DEAD_BUSH);
|
||||||
|
blacklisted_items.add(Material.DIODE_BLOCK_OFF);
|
||||||
|
blacklisted_items.add(Material.DIODE_BLOCK_ON);
|
||||||
|
blacklisted_items.add(Material.DOUBLE_PLANT);
|
||||||
|
blacklisted_items.add(Material.DOUBLE_STEP);
|
||||||
|
blacklisted_items.add(Material.DOUBLE_STONE_SLAB2);
|
||||||
|
blacklisted_items.add(Material.DRAGON_EGG);
|
||||||
|
blacklisted_items.add(Material.DRAGONS_BREATH);
|
||||||
|
blacklisted_items.add(Material.EMERALD_ORE);
|
||||||
|
blacklisted_items.add(Material.COAL_ORE);
|
||||||
|
blacklisted_items.add(Material.END_CRYSTAL);
|
||||||
|
blacklisted_items.add(Material.END_GATEWAY);
|
||||||
|
blacklisted_items.add(Material.ENDER_PORTAL);
|
||||||
|
blacklisted_items.add(Material.ENDER_PORTAL_FRAME);
|
||||||
|
blacklisted_items.add(Material.EXP_BOTTLE);
|
||||||
|
blacklisted_items.add(Material.FIRE);
|
||||||
|
blacklisted_items.add(Material.FIREBALL);
|
||||||
|
blacklisted_items.add(Material.FLOWER_POT);
|
||||||
|
blacklisted_items.add(Material.FROSTED_ICE);
|
||||||
|
blacklisted_items.add(Material.GLOWING_REDSTONE_ORE);
|
||||||
|
blacklisted_items.add(Material.GOLD_RECORD);
|
||||||
|
blacklisted_items.add(Material.GRASS);
|
||||||
|
blacklisted_items.add(Material.GRASS_PATH);
|
||||||
|
blacklisted_items.add(Material.GREEN_RECORD);
|
||||||
|
blacklisted_items.add(Material.HUGE_MUSHROOM_1);
|
||||||
|
blacklisted_items.add(Material.HUGE_MUSHROOM_2);
|
||||||
|
blacklisted_items.add(Material.JUNGLE_DOOR);
|
||||||
|
blacklisted_items.add(Material.LAVA);
|
||||||
|
blacklisted_items.add(Material.LEAVES);
|
||||||
|
blacklisted_items.add(Material.LEAVES_2);
|
||||||
|
blacklisted_items.add(Material.LINGERING_POTION);
|
||||||
|
blacklisted_items.add(Material.LOG);
|
||||||
|
blacklisted_items.add(Material.LOG_2);
|
||||||
|
blacklisted_items.add(Material.LONG_GRASS);
|
||||||
|
blacklisted_items.add(Material.MAP);
|
||||||
|
blacklisted_items.add(Material.MELON_BLOCK);
|
||||||
|
blacklisted_items.add(Material.MELON_STEM);
|
||||||
|
blacklisted_items.add(Material.MOB_SPAWNER);
|
||||||
|
blacklisted_items.add(Material.MONSTER_EGG);
|
||||||
|
blacklisted_items.add(Material.MONSTER_EGGS);
|
||||||
|
blacklisted_items.add(Material.MYCEL);
|
||||||
|
blacklisted_items.add(Material.NAME_TAG);
|
||||||
|
blacklisted_items.add(Material.NETHER_STALK);
|
||||||
|
blacklisted_items.add(Material.NETHER_WARTS);
|
||||||
|
blacklisted_items.add(Material.MYCEL);
|
||||||
|
blacklisted_items.add(Material.PISTON_EXTENSION);
|
||||||
|
blacklisted_items.add(Material.PISTON_MOVING_PIECE);
|
||||||
|
blacklisted_items.add(Material.POISONOUS_POTATO);
|
||||||
|
blacklisted_items.add(Material.PORTAL);
|
||||||
|
blacklisted_items.add(Material.POTATO);
|
||||||
|
blacklisted_items.add(Material.PUMPKIN_STEM);
|
||||||
|
blacklisted_items.add(Material.PURPUR_DOUBLE_SLAB);
|
||||||
|
blacklisted_items.add(Material.QUARTZ_ORE);
|
||||||
|
blacklisted_items.add(Material.RECORD_10);
|
||||||
|
blacklisted_items.add(Material.RECORD_11);
|
||||||
|
blacklisted_items.add(Material.RECORD_12);
|
||||||
|
blacklisted_items.add(Material.RECORD_3);
|
||||||
|
blacklisted_items.add(Material.RECORD_4);
|
||||||
|
blacklisted_items.add(Material.RECORD_5);
|
||||||
|
blacklisted_items.add(Material.RECORD_6);
|
||||||
|
blacklisted_items.add(Material.RECORD_7);
|
||||||
|
blacklisted_items.add(Material.RECORD_8);
|
||||||
|
blacklisted_items.add(Material.RECORD_9);
|
||||||
|
blacklisted_items.add(Material.RED_ROSE);
|
||||||
|
blacklisted_items.add(Material.REDSTONE_COMPARATOR_OFF);
|
||||||
|
blacklisted_items.add(Material.REDSTONE_COMPARATOR_ON);
|
||||||
|
blacklisted_items.add(Material.REDSTONE_LAMP_OFF);
|
||||||
|
blacklisted_items.add(Material.REDSTONE_LAMP_ON);
|
||||||
|
blacklisted_items.add(Material.REDSTONE_ORE);
|
||||||
|
blacklisted_items.add(Material.REDSTONE_TORCH_OFF);
|
||||||
|
blacklisted_items.add(Material.REDSTONE_WIRE);
|
||||||
|
blacklisted_items.add(Material.SAPLING);
|
||||||
|
blacklisted_items.add(Material.SIGN_POST);
|
||||||
|
blacklisted_items.add(Material.WALL_SIGN);
|
||||||
|
blacklisted_items.add(Material.SKULL);
|
||||||
|
blacklisted_items.add(Material.SKULL_ITEM);
|
||||||
|
blacklisted_items.add(Material.SNOW);
|
||||||
|
blacklisted_items.add(Material.SOIL);
|
||||||
|
blacklisted_items.add(Material.SPONGE);
|
||||||
|
blacklisted_items.add(Material.SPRUCE_DOOR);
|
||||||
|
blacklisted_items.add(Material.STANDING_BANNER);
|
||||||
|
blacklisted_items.add(Material.STATIONARY_LAVA);
|
||||||
|
blacklisted_items.add(Material.STATIONARY_WATER);
|
||||||
|
blacklisted_items.add(Material.STEP);
|
||||||
|
blacklisted_items.add(Material.STONE_SLAB2);
|
||||||
|
blacklisted_items.add(Material.STRUCTURE_BLOCK);
|
||||||
|
blacklisted_items.add(Material.SUGAR_CANE_BLOCK);
|
||||||
|
blacklisted_items.add(Material.TRIPWIRE);
|
||||||
|
blacklisted_items.add(Material.VINE);
|
||||||
|
blacklisted_items.add(Material.WALL_BANNER);
|
||||||
|
blacklisted_items.add(Material.WATCH);
|
||||||
|
blacklisted_items.add(Material.WATER);
|
||||||
|
blacklisted_items.add(Material.WOOD_DOUBLE_STEP);
|
||||||
|
blacklisted_items.add(Material.WOODEN_DOOR);
|
||||||
|
blacklisted_items.add(Material.WOOD_DOOR);
|
||||||
|
blacklisted_items.add(Material.YELLOW_FLOWER);
|
||||||
|
Material selectedMat = Material.values()[(int)(Math.random()*Material.values().length)];
|
||||||
|
while (blacklisted_items.contains(selectedMat)) {
|
||||||
|
//RE-roll if it's a black-listed item.
|
||||||
|
selectedMat = Material.values()[(int)(Math.random()*Material.values().length)];
|
||||||
|
}
|
||||||
|
return selectedMat;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package sig.plugin.TwosideKeeper.HelperStructures;
|
||||||
|
|
||||||
|
public enum MonsterDifficulty {
|
||||||
|
NORMAL,
|
||||||
|
DANGEROUS,
|
||||||
|
DEADLY,
|
||||||
|
HELLFIRE
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package sig.plugin.TwosideKeeper.HelperStructures;
|
||||||
|
|
||||||
|
public enum MonsterType {
|
||||||
|
BLAZE,
|
||||||
|
CAVESPIDER,
|
||||||
|
CREEPER,
|
||||||
|
ENDERMAN,
|
||||||
|
GIANT,
|
||||||
|
GUARDIAN,
|
||||||
|
PIGZOMBIE,
|
||||||
|
SILVERFISH,
|
||||||
|
SKELETON,
|
||||||
|
SPIDER,
|
||||||
|
WITCH,
|
||||||
|
WITHER,
|
||||||
|
ZOMBIE
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
package sig.plugin.TwosideKeeper.HelperStructures;
|
||||||
|
|
||||||
|
public enum QuestStatus {
|
||||||
|
UNFORMED,
|
||||||
|
IN_PROGRESS
|
||||||
|
}
|
37
src/sig/plugin/TwosideKeeper/HelperStructures/Rank.java
Normal file
37
src/sig/plugin/TwosideKeeper/HelperStructures/Rank.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package sig.plugin.TwosideKeeper.HelperStructures;
|
||||||
|
|
||||||
|
import org.bukkit.Color;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rank structure
|
||||||
|
*
|
||||||
|
* Defines a rank a player can be on the server.
|
||||||
|
* Each rank has a color and a "canX" permission
|
||||||
|
* for each permission they can do.
|
||||||
|
*
|
||||||
|
* @author Joshua Sigona
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Rank {
|
||||||
|
public String name;
|
||||||
|
public Color color;
|
||||||
|
public boolean
|
||||||
|
canBreak,
|
||||||
|
canBuild,
|
||||||
|
canChat,
|
||||||
|
canFly,
|
||||||
|
canItemGive;
|
||||||
|
/**
|
||||||
|
* Rank sets up a rank. You have to define specific permissions with 'true' and 'false' separately.
|
||||||
|
* @param name
|
||||||
|
* @param color
|
||||||
|
*/
|
||||||
|
public Rank(String name, Color color) {
|
||||||
|
this.name = name;
|
||||||
|
this.color = color;
|
||||||
|
|
||||||
|
//Set default permissions.
|
||||||
|
this.canBreak=this.canBuild=this.canChat=true;
|
||||||
|
this.canFly=this.canItemGive=false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package sig.plugin.TwosideKeeper.HelperStructures;
|
||||||
|
|
||||||
|
public enum SessionState {
|
||||||
|
CREATE, //Creating a shop. Asks for amount to put in.
|
||||||
|
PRICE, //Creating a shop. Asks for price of each unit.
|
||||||
|
EDIT, //Editing a shop. Asks for amount to put in or take out.
|
||||||
|
UPDATE, //Editing a shop. Asks for new price of each unit.
|
||||||
|
PURCHASE
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package sig.plugin.TwosideKeeper.HelperStructures;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import sig.plugin.TwosideKeeper.TwosideKeeper;
|
||||||
|
|
||||||
|
public class ShopPurchase {
|
||||||
|
String player;
|
||||||
|
String customer;
|
||||||
|
String itemname;
|
||||||
|
double money;
|
||||||
|
int amt;
|
||||||
|
|
||||||
|
public ShopPurchase(String p, Player customer, ItemStack item, double money, int amt) {
|
||||||
|
player = p;
|
||||||
|
this.customer=customer.getName();
|
||||||
|
itemname = TwosideKeeper.GetItemName(item);
|
||||||
|
this.money = money;
|
||||||
|
this.amt=amt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
public String getCustomer() {
|
||||||
|
return customer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String announcementString() {
|
||||||
|
DecimalFormat df = new DecimalFormat("0.00");
|
||||||
|
return "Player "+ChatColor.BLUE+customer+ChatColor.WHITE+" has purchased "+ChatColor.YELLOW+amt+ChatColor.WHITE+" of your "+ChatColor.YELLOW+itemname+". You have earned $"+df.format(money)+". "+ChatColor.GRAY+""+ChatColor.ITALIC+"(See /money)";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
package sig.plugin.TwosideKeeper.HelperStructures;
|
||||||
|
|
||||||
|
public enum SpleefArena {
|
||||||
|
//Three constants.
|
||||||
|
SMALL, LARGE, LAYERED
|
||||||
|
}
|
258
src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java
Normal file
258
src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java
Normal file
@ -0,0 +1,258 @@
|
|||||||
|
package sig.plugin.TwosideKeeper.HelperStructures;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
|
import org.bukkit.potion.PotionType;
|
||||||
|
|
||||||
|
import sig.plugin.TwosideKeeper.TwosideKeeper;
|
||||||
|
|
||||||
|
public class WorldShop {
|
||||||
|
ItemStack item;
|
||||||
|
String owner;
|
||||||
|
double price;
|
||||||
|
int amt;
|
||||||
|
int id;
|
||||||
|
|
||||||
|
public WorldShop (ItemStack i, int amt, double p, String player, int shopID) {
|
||||||
|
this.item=i;
|
||||||
|
this.price=p;
|
||||||
|
this.owner=player;
|
||||||
|
this.amt = amt;
|
||||||
|
this.id = shopID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String GetItemName() {
|
||||||
|
if (this.item.hasItemMeta() &&
|
||||||
|
this.item.getItemMeta().hasDisplayName()) {
|
||||||
|
return this.item.getItemMeta().getDisplayName();
|
||||||
|
} else {
|
||||||
|
return TwosideKeeper.UserFriendlyMaterialName(this.item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void UpdateAmount(int amt) {
|
||||||
|
this.amt=amt;
|
||||||
|
}
|
||||||
|
public void UpdateUnitPrice(double price) {
|
||||||
|
this.price=price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack GetItem() {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
public double GetUnitPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
public int getID() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public int GetAmount() {
|
||||||
|
if (owner.equalsIgnoreCase("admin")) {
|
||||||
|
return 10000;
|
||||||
|
} else {
|
||||||
|
return amt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public String GetOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "WorldShop:{Item:"+item.toString()+",Price:"+price+",Amount:"+amt+",Owner:"+owner+"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetItemInfo(ItemStack item) {
|
||||||
|
//Gets all the info about this item in one gigantic string. (Separated by new lines. Useful for tellraw()).
|
||||||
|
String message = "";
|
||||||
|
for (int i=0;i<Enchantment.values().length;i++) {
|
||||||
|
if (item.containsEnchantment(Enchantment.values()[i])) {
|
||||||
|
message+=((message.equals(""))?"":"\n")+ChatColor.GRAY+getRealName(Enchantment.values()[i])+" "+toRomanNumeral(item.getEnchantmentLevel(Enchantment.getByName(Enchantment.values()[i].getName()))); //This is an enchantment we have.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.getType()==Material.ENCHANTED_BOOK) {
|
||||||
|
if (item.getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||||
|
EnchantmentStorageMeta e = (EnchantmentStorageMeta)item.getItemMeta();
|
||||||
|
for (int i=0;i<Enchantment.values().length;i++) {
|
||||||
|
if (e.hasStoredEnchant((Enchantment.values()[i]))) {
|
||||||
|
message+="\n"+ChatColor.GRAY+getRealName(Enchantment.values()[i])+" "+toRomanNumeral(e.getStoredEnchantLevel(Enchantment.getByName(Enchantment.values()[i].getName()))); //This is an enchantment we have.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.hasItemMeta() &&
|
||||||
|
item.getItemMeta().hasLore()) {
|
||||||
|
for (int i=0;i<item.getItemMeta().getLore().size();i++) {
|
||||||
|
message+="\n"+item.getItemMeta().getLore().get(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getType().toString().contains("HELMET") ||
|
||||||
|
item.getType().toString().contains("CHESTPLATE") ||
|
||||||
|
item.getType().toString().contains("LEGGINGS") ||
|
||||||
|
item.getType().toString().contains("BOOTS") ||
|
||||||
|
item.getType().toString().contains("SHIELD")) {
|
||||||
|
//Display the durability for these items.
|
||||||
|
int maxdura = 0;
|
||||||
|
switch (item.getType()) {
|
||||||
|
case LEATHER_HELMET:{
|
||||||
|
maxdura = 56;
|
||||||
|
}break;
|
||||||
|
case GOLD_HELMET:{
|
||||||
|
maxdura = 78;
|
||||||
|
}break;
|
||||||
|
case IRON_HELMET:{
|
||||||
|
maxdura = 166;
|
||||||
|
}break;
|
||||||
|
case CHAINMAIL_HELMET:{
|
||||||
|
maxdura = 166;
|
||||||
|
}break;
|
||||||
|
case DIAMOND_HELMET:{
|
||||||
|
maxdura = 364;
|
||||||
|
}break;
|
||||||
|
case LEATHER_CHESTPLATE:{
|
||||||
|
maxdura = 81;
|
||||||
|
}break;
|
||||||
|
case GOLD_CHESTPLATE:{
|
||||||
|
maxdura = 113;
|
||||||
|
}break;
|
||||||
|
case IRON_CHESTPLATE:{
|
||||||
|
maxdura = 241;
|
||||||
|
}break;
|
||||||
|
case CHAINMAIL_CHESTPLATE:{
|
||||||
|
maxdura = 241;
|
||||||
|
}break;
|
||||||
|
case DIAMOND_CHESTPLATE:{
|
||||||
|
maxdura = 529;
|
||||||
|
}break;
|
||||||
|
case LEATHER_LEGGINGS:{
|
||||||
|
maxdura = 76;
|
||||||
|
}break;
|
||||||
|
case GOLD_LEGGINGS:{
|
||||||
|
maxdura = 106;
|
||||||
|
}break;
|
||||||
|
case IRON_LEGGINGS:{
|
||||||
|
maxdura = 226;
|
||||||
|
}break;
|
||||||
|
case CHAINMAIL_LEGGINGS:{
|
||||||
|
maxdura = 226;
|
||||||
|
}break;
|
||||||
|
case DIAMOND_LEGGINGS:{
|
||||||
|
maxdura = 496;
|
||||||
|
}break;
|
||||||
|
case LEATHER_BOOTS:{
|
||||||
|
maxdura = 66;
|
||||||
|
}break;
|
||||||
|
case GOLD_BOOTS:{
|
||||||
|
maxdura = 92;
|
||||||
|
}break;
|
||||||
|
case IRON_BOOTS:{
|
||||||
|
maxdura = 196;
|
||||||
|
}break;
|
||||||
|
case CHAINMAIL_BOOTS:{
|
||||||
|
maxdura = 196;
|
||||||
|
}break;
|
||||||
|
case DIAMOND_BOOTS:{
|
||||||
|
maxdura = 430;
|
||||||
|
}break;
|
||||||
|
case SHIELD:{
|
||||||
|
maxdura = 430;
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
message+="\n\n"+ChatColor.GRAY+"Durability: "+(maxdura-item.getDurability()-1)+"/"+(maxdura-1);
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendItemInfo(Player player) {
|
||||||
|
//Returns all the lore and enchantments for this particular item to the player, so they know what this item is.
|
||||||
|
String[] temp = GetItemInfo(item).split("\n");
|
||||||
|
for (int i=0;i<temp.length;i++) {
|
||||||
|
player.sendMessage(" "+temp[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static String getRealName(Enchantment enchant) {
|
||||||
|
if (enchant.getName().equalsIgnoreCase("arrow_damage")) {return "Power";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("arrow_fire")) {return "Flame";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("arrow_infinite")) {return "Infinity";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("arrow_knockback")) {return "Punch";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("damage_all")) {return "Sharpness";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("damage_arthropods")) {return "Bane of Arthropods";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("damage_undead")) {return "Smite";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("depth_strider")) {return "Depth Strider";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("dig_speed")) {return "Efficiency";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("durability")) {return "Unbreaking";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("fire_aspect")) {return "Fire Aspect";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("frost_walker")) {return "Frost Walker";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("knockback")) {return "Knockback";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("loot_bonus_blocks")) {return "Fortune";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("loot_bonus_mobs")) {return "Looting";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("luck")) {return "Luck of the Sea";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("lure")) {return "Lure";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("mending")) {return "Mending";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("oxygen")) {return "Respiration";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("protection_environmental")) {return "Protection";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("protection_explosions")) {return "Blast Protection";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("protection_fall")) {return "Feather Falling";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("protection_fire")) {return "Fire Protection";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("protection_projectile")) {return "Projectile Protection";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("silk_touch")) {return "Silk Touch";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("thorns")) {return "Thorns";}
|
||||||
|
if (enchant.getName().equalsIgnoreCase("water_worker")) {return "Aqua Affinity";}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
static String toRomanNumeral(int val) {
|
||||||
|
switch (val) {
|
||||||
|
case 1:{
|
||||||
|
return "I";
|
||||||
|
}
|
||||||
|
case 2:{
|
||||||
|
return "II";
|
||||||
|
}
|
||||||
|
case 3:{
|
||||||
|
return "III";
|
||||||
|
}
|
||||||
|
case 4:{
|
||||||
|
return "IV";
|
||||||
|
}
|
||||||
|
case 5:{
|
||||||
|
return "V";
|
||||||
|
}
|
||||||
|
case 6:{
|
||||||
|
return "VI";
|
||||||
|
}
|
||||||
|
case 7:{
|
||||||
|
return "VII";
|
||||||
|
}
|
||||||
|
case 8:{
|
||||||
|
return "VIII";
|
||||||
|
}
|
||||||
|
case 9:{
|
||||||
|
return "IX";
|
||||||
|
}
|
||||||
|
case 10:{
|
||||||
|
return "X";
|
||||||
|
}
|
||||||
|
default:{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean IsWorldSign(Sign s) {
|
||||||
|
if (s.getLine(0).equalsIgnoreCase(ChatColor.BLUE+"-- SHOP --")) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
package sig.plugin.TwosideKeeper.HelperStructures;
|
||||||
|
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import sig.plugin.TwosideKeeper.TwosideKeeper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a world shop transaction.
|
||||||
|
* Has a 'state' it is in. Such as
|
||||||
|
* "CREATE" - Asks how many of the item to put in the shop?
|
||||||
|
* "PRICE" - How much each of the item will cost?
|
||||||
|
* "EDIT" - Modify the price.
|
||||||
|
* "PURCHASE" - Type in how many to purchase.
|
||||||
|
*
|
||||||
|
* Holds the player performing the transaction.
|
||||||
|
* Time the player started the transaction. Cancels out after nothing is said after 15 seconds.
|
||||||
|
*
|
||||||
|
* Has methods to handle session checking. Such as
|
||||||
|
* GetSessionType()
|
||||||
|
* GetPlayer()
|
||||||
|
* GetTime()
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class WorldShopSession {
|
||||||
|
Player p;
|
||||||
|
long time;
|
||||||
|
SessionState status;
|
||||||
|
Sign s;
|
||||||
|
int amt;
|
||||||
|
ItemStack item;
|
||||||
|
public WorldShopSession(Player p, long server_time, SessionState status, Sign s) {
|
||||||
|
this.p=p;
|
||||||
|
this.time=server_time;
|
||||||
|
this.status=status;
|
||||||
|
this.s=s;
|
||||||
|
this.amt=0;
|
||||||
|
this.item = null;
|
||||||
|
}
|
||||||
|
public SessionState GetSessionType() {
|
||||||
|
return this.status;
|
||||||
|
}
|
||||||
|
public Player GetPlayer() {
|
||||||
|
return this.p;
|
||||||
|
}
|
||||||
|
public long GetTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
public Sign GetSign() {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
public int getAmt() {
|
||||||
|
return amt;
|
||||||
|
}
|
||||||
|
public ItemStack getItem() {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
public void SetItem(ItemStack item) {
|
||||||
|
this.item=item;
|
||||||
|
}
|
||||||
|
public void SetAmt(int amt) {
|
||||||
|
this.amt=amt;
|
||||||
|
}
|
||||||
|
public void SetSession(SessionState type) {
|
||||||
|
status = type;
|
||||||
|
}
|
||||||
|
public void UpdateTime() {
|
||||||
|
time = TwosideKeeper.getServerTickTime();
|
||||||
|
}
|
||||||
|
public boolean IsTimeExpired() {
|
||||||
|
if (time+TwosideKeeper.TERMINALTIME<=TwosideKeeper.getServerTickTime()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "WorldShop:{STATUS:"+status+",Item:"+item.toString()+",Time:"+time+",Sign:"+s.toString()+",Amount:"+amt+"}";
|
||||||
|
}
|
||||||
|
}
|
686
src/sig/plugin/TwosideKeeper/MonsterController.java
Normal file
686
src/sig/plugin/TwosideKeeper/MonsterController.java
Normal file
@ -0,0 +1,686 @@
|
|||||||
|
package sig.plugin.TwosideKeeper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Monster;
|
||||||
|
import org.bukkit.entity.Skeleton;
|
||||||
|
import org.bukkit.entity.Zombie;
|
||||||
|
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.ItemRarity;
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.MonsterDifficulty;
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.MonsterType;
|
||||||
|
|
||||||
|
public class MonsterController {
|
||||||
|
/**
|
||||||
|
* @return Returns false if this spawn is not allowed.
|
||||||
|
*/
|
||||||
|
public static boolean MobHeightControl(LivingEntity ent) {
|
||||||
|
//Modify spawning algorithm.
|
||||||
|
int ylv = ent.getLocation().getBlockY();
|
||||||
|
if (isZombieLeader(ent)) {
|
||||||
|
//Zombie leaders have faster movement.
|
||||||
|
ent.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,999999,1));
|
||||||
|
}
|
||||||
|
if (ylv>=128) {
|
||||||
|
//This is a 95% chance this will despawn.
|
||||||
|
if (Math.random()<=0.95) {
|
||||||
|
ent.remove();
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if (isZombieLeader(ent)) {
|
||||||
|
Monster m = (Monster)ent;
|
||||||
|
m.setCustomName(ChatColor.WHITE+"Zombie Leader");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (ylv>=64) {
|
||||||
|
//This is a 90% chance this will despawn.
|
||||||
|
if (Math.random()<=0.90) {
|
||||||
|
ent.remove();
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if (isZombieLeader(ent)) {
|
||||||
|
Monster m = (Monster)ent;
|
||||||
|
m.setCustomName(ChatColor.WHITE+"Zombie Leader");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (ylv>=48) {
|
||||||
|
//"Normal" spawn rate. We're going to decrease it a bit for the time being.
|
||||||
|
//This is a 50% chance this will despawn.
|
||||||
|
if (Math.random()<=0.50) {
|
||||||
|
ent.remove();
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if (isZombieLeader(ent)) {
|
||||||
|
Monster m = (Monster)ent;
|
||||||
|
m.setCustomName(ChatColor.WHITE+"Zombie Leader");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (ylv>=32) {
|
||||||
|
//Change mobs in this range to 'Dangerous' versions. Zombies and skeletons also get armor.
|
||||||
|
Monster m = (Monster)(ent);
|
||||||
|
MonsterDifficulty md = MonsterDifficulty.DANGEROUS;
|
||||||
|
convertMonster(m,md);
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
if (ylv>=16) {
|
||||||
|
MonsterDifficulty md = MonsterDifficulty.DEADLY;
|
||||||
|
//Change mobs in this range to 'Dangerous' versions. Zombies and skeletons also get armor.
|
||||||
|
Monster m = (Monster)(ent);
|
||||||
|
convertMonster(m,md);
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
//Change mobs in this range to 'Dangerous' versions. Zombies and skeletons also get armor.
|
||||||
|
MonsterDifficulty md = MonsterDifficulty.HELLFIRE;
|
||||||
|
Monster m = (Monster)(ent);
|
||||||
|
convertMonster(m,md);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static void RandomizeEquipment(Monster m, int lv) {
|
||||||
|
/*
|
||||||
|
* Lv1: Leather/Iron Armor.
|
||||||
|
* Lv2: Iron/Diamond Armor.
|
||||||
|
* Lv3: Diamond Armor.
|
||||||
|
*/
|
||||||
|
switch (lv) {
|
||||||
|
case 1:{
|
||||||
|
if (Math.random()<0.5) {
|
||||||
|
m.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET));
|
||||||
|
m.getEquipment().getHelmet().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
} else {
|
||||||
|
m.getEquipment().setHelmet(new ItemStack(Material.IRON_HELMET));
|
||||||
|
m.getEquipment().getHelmet().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
}
|
||||||
|
if (Math.random()<0.5) {
|
||||||
|
m.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
|
||||||
|
m.getEquipment().getChestplate().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
} else {
|
||||||
|
m.getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
|
||||||
|
m.getEquipment().getChestplate().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
}
|
||||||
|
if (Math.random()<0.5) {
|
||||||
|
m.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
|
||||||
|
m.getEquipment().getLeggings().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
} else {
|
||||||
|
m.getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS));
|
||||||
|
m.getEquipment().getLeggings().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
}
|
||||||
|
if (Math.random()<0.5) {
|
||||||
|
m.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS));
|
||||||
|
m.getEquipment().getBoots().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
} else {
|
||||||
|
m.getEquipment().setBoots(new ItemStack(Material.IRON_BOOTS));
|
||||||
|
m.getEquipment().getBoots().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
}
|
||||||
|
if (m.getEquipment().getHelmet()!=null && Math.random()<0.3) {
|
||||||
|
m.getEquipment().setHelmet(RandomizeEnchantments(m.getEquipment().getHelmet(),ItemRarity.RARE));
|
||||||
|
if (Math.random()<TwosideKeeper.RARE_DROP_RATE && m.getEquipment().getHelmet().getType()==Material.IRON_HELMET) {
|
||||||
|
ItemStack helm = m.getEquipment().getHelmet();
|
||||||
|
m.getEquipment().setHelmet(TwosideKeeper.convertToHardenedPiece(helm, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m.getEquipment().getChestplate()!=null && Math.random()<0.3) {
|
||||||
|
m.getEquipment().setChestplate(RandomizeEnchantments(m.getEquipment().getChestplate(),ItemRarity.RARE));
|
||||||
|
if (Math.random()<TwosideKeeper.RARE_DROP_RATE && m.getEquipment().getChestplate().getType()==Material.IRON_CHESTPLATE) {
|
||||||
|
ItemStack helm = m.getEquipment().getChestplate();
|
||||||
|
m.getEquipment().setChestplate(TwosideKeeper.convertToHardenedPiece(helm, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m.getEquipment().getLeggings()!=null && Math.random()<0.3) {
|
||||||
|
m.getEquipment().setLeggings(RandomizeEnchantments(m.getEquipment().getLeggings(),ItemRarity.RARE));
|
||||||
|
if (Math.random()<TwosideKeeper.RARE_DROP_RATE && m.getEquipment().getLeggings().getType()==Material.IRON_LEGGINGS) {
|
||||||
|
ItemStack helm = m.getEquipment().getLeggings();
|
||||||
|
m.getEquipment().setLeggings(TwosideKeeper.convertToHardenedPiece(helm, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m.getEquipment().getBoots()!=null && Math.random()<0.3) {
|
||||||
|
m.getEquipment().setBoots(RandomizeEnchantments(m.getEquipment().getBoots(),ItemRarity.RARE));
|
||||||
|
if (Math.random()<TwosideKeeper.RARE_DROP_RATE && m.getEquipment().getBoots().getType()==Material.IRON_BOOTS) {
|
||||||
|
ItemStack helm = m.getEquipment().getBoots();
|
||||||
|
m.getEquipment().setBoots(TwosideKeeper.convertToHardenedPiece(helm, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m.getEquipment().setBootsDropChance(0.3f);
|
||||||
|
m.getEquipment().setChestplateDropChance(0.3f);
|
||||||
|
m.getEquipment().setLeggingsDropChance(0.3f);
|
||||||
|
m.getEquipment().setHelmetDropChance(0.3f);
|
||||||
|
if ((m.getType()==EntityType.ZOMBIE &&
|
||||||
|
!((Zombie)m).isBaby()) ||
|
||||||
|
m.getType()==EntityType.GIANT ||
|
||||||
|
(m.getType()==EntityType.SKELETON &&
|
||||||
|
((Skeleton)m).getSkeletonType()==SkeletonType.WITHER)) {
|
||||||
|
//Equip a sword or rarely, an axe.
|
||||||
|
ItemStack weapon;
|
||||||
|
if (Math.random()<0.03) {
|
||||||
|
if (Math.random()<0.5) {
|
||||||
|
weapon = new ItemStack(Material.WOOD_AXE);
|
||||||
|
} else {
|
||||||
|
weapon = new ItemStack(Material.STONE_AXE);
|
||||||
|
}
|
||||||
|
m.getEquipment().setItemInMainHand(weapon);
|
||||||
|
} else {
|
||||||
|
if (Math.random()<0.5) {
|
||||||
|
weapon = new ItemStack(Material.WOOD_SWORD);
|
||||||
|
} else {
|
||||||
|
weapon = new ItemStack(Material.STONE_SWORD);
|
||||||
|
}
|
||||||
|
m.getEquipment().setItemInMainHand(weapon);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ItemStack weapon = new ItemStack(Material.BOW);
|
||||||
|
m.getEquipment().setItemInMainHand(weapon);
|
||||||
|
}
|
||||||
|
if (m.getType()==EntityType.PIG_ZOMBIE) {
|
||||||
|
ItemStack weapon = new ItemStack(Material.GOLD_SWORD);
|
||||||
|
m.getEquipment().setItemInMainHand(weapon);
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case 2:{
|
||||||
|
if (Math.random()<0.5) {
|
||||||
|
m.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
|
||||||
|
m.getEquipment().getHelmet().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
} else {
|
||||||
|
m.getEquipment().setHelmet(new ItemStack(Material.IRON_HELMET));
|
||||||
|
m.getEquipment().getHelmet().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
}
|
||||||
|
if (Math.random()<0.5) {
|
||||||
|
m.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
|
||||||
|
m.getEquipment().getChestplate().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
} else {
|
||||||
|
m.getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
|
||||||
|
m.getEquipment().getChestplate().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
}
|
||||||
|
if (Math.random()<0.5) {
|
||||||
|
m.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
|
||||||
|
m.getEquipment().getLeggings().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
} else {
|
||||||
|
m.getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS));
|
||||||
|
m.getEquipment().getLeggings().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
}
|
||||||
|
if (Math.random()<0.5) {
|
||||||
|
m.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS));
|
||||||
|
m.getEquipment().getBoots().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
} else {
|
||||||
|
m.getEquipment().setBoots(new ItemStack(Material.IRON_BOOTS));
|
||||||
|
m.getEquipment().getBoots().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m.getEquipment().getHelmet()!=null && Math.random()<0.3) {
|
||||||
|
m.getEquipment().setHelmet(RandomizeEnchantments(m.getEquipment().getHelmet(),ItemRarity.EPIC));
|
||||||
|
if (Math.random()<TwosideKeeper.RARE_DROP_RATE) {
|
||||||
|
ItemStack helm = m.getEquipment().getHelmet();
|
||||||
|
m.getEquipment().setHelmet(TwosideKeeper.convertToHardenedPiece(helm, (int)(Math.random()*4)+2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m.getEquipment().getChestplate()!=null && Math.random()<0.3) {
|
||||||
|
m.getEquipment().setChestplate(RandomizeEnchantments(m.getEquipment().getChestplate(),ItemRarity.EPIC));
|
||||||
|
if (Math.random()<TwosideKeeper.RARE_DROP_RATE) {
|
||||||
|
ItemStack helm = m.getEquipment().getChestplate();
|
||||||
|
m.getEquipment().setChestplate(TwosideKeeper.convertToHardenedPiece(helm, (int)(Math.random()*4)+2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m.getEquipment().getLeggings()!=null && Math.random()<0.3) {
|
||||||
|
m.getEquipment().setLeggings(RandomizeEnchantments(m.getEquipment().getLeggings(),ItemRarity.EPIC));
|
||||||
|
if (Math.random()<TwosideKeeper.RARE_DROP_RATE) {
|
||||||
|
ItemStack helm = m.getEquipment().getLeggings();
|
||||||
|
m.getEquipment().setLeggings(TwosideKeeper.convertToHardenedPiece(helm, (int)(Math.random()*4)+2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m.getEquipment().getBoots()!=null && Math.random()<0.3) {
|
||||||
|
m.getEquipment().setBoots(RandomizeEnchantments(m.getEquipment().getBoots(),ItemRarity.EPIC));
|
||||||
|
if (Math.random()<TwosideKeeper.RARE_DROP_RATE) {
|
||||||
|
ItemStack helm = m.getEquipment().getBoots();
|
||||||
|
m.getEquipment().setBoots(TwosideKeeper.convertToHardenedPiece(helm, (int)(Math.random()*4)+2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((m.getType()==EntityType.ZOMBIE &&
|
||||||
|
!((Zombie)m).isBaby()) ||
|
||||||
|
m.getType()==EntityType.GIANT ||
|
||||||
|
(m.getType()==EntityType.SKELETON &&
|
||||||
|
((Skeleton)m).getSkeletonType()==SkeletonType.WITHER)) {
|
||||||
|
//Equip a sword or rarely, an axe.
|
||||||
|
ItemStack weapon;
|
||||||
|
if (Math.random()<0.03) {
|
||||||
|
if (Math.random()<0.4) {
|
||||||
|
weapon = new ItemStack(Material.STONE_AXE);
|
||||||
|
} if (Math.random()<0.4) {
|
||||||
|
weapon = new ItemStack(Material.IRON_AXE);
|
||||||
|
} else {
|
||||||
|
weapon = new ItemStack(Material.DIAMOND_AXE);
|
||||||
|
}
|
||||||
|
m.getEquipment().setItemInMainHand(weapon);
|
||||||
|
} else {
|
||||||
|
if (Math.random()<0.4) {
|
||||||
|
weapon = new ItemStack(Material.STONE_SWORD);
|
||||||
|
} if (Math.random()<0.4) {
|
||||||
|
weapon = new ItemStack(Material.IRON_SWORD);
|
||||||
|
} else {
|
||||||
|
weapon = new ItemStack(Material.DIAMOND_SWORD);
|
||||||
|
}
|
||||||
|
m.getEquipment().setItemInMainHand(weapon);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ItemStack weapon = new ItemStack(Material.BOW);
|
||||||
|
m.getEquipment().setItemInMainHand(weapon);
|
||||||
|
}
|
||||||
|
if (m.getType()==EntityType.PIG_ZOMBIE) {
|
||||||
|
ItemStack weapon = new ItemStack(Material.GOLD_SWORD);
|
||||||
|
m.getEquipment().setItemInMainHand(weapon);
|
||||||
|
}
|
||||||
|
m.getEquipment().setBootsDropChance(0.3f);
|
||||||
|
m.getEquipment().setChestplateDropChance(0.3f);
|
||||||
|
m.getEquipment().setLeggingsDropChance(0.3f);
|
||||||
|
m.getEquipment().setHelmetDropChance(0.3f);
|
||||||
|
}break;
|
||||||
|
case 3:{
|
||||||
|
if (Math.random()<0.5) {
|
||||||
|
m.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
|
||||||
|
m.getEquipment().getHelmet().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
} else {
|
||||||
|
m.getEquipment().setHelmet(new ItemStack(Material.GOLD_HELMET));
|
||||||
|
m.getEquipment().getHelmet().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
}
|
||||||
|
if (Math.random()<0.5) {
|
||||||
|
m.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
|
||||||
|
m.getEquipment().getChestplate().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
} else {
|
||||||
|
m.getEquipment().setChestplate(new ItemStack(Material.GOLD_CHESTPLATE));
|
||||||
|
m.getEquipment().getChestplate().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
}
|
||||||
|
if (Math.random()<0.5) {
|
||||||
|
m.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
|
||||||
|
m.getEquipment().getLeggings().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
} else {
|
||||||
|
m.getEquipment().setLeggings(new ItemStack(Material.GOLD_LEGGINGS));
|
||||||
|
m.getEquipment().getLeggings().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
}
|
||||||
|
if (Math.random()<0.5) {
|
||||||
|
m.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS));
|
||||||
|
m.getEquipment().getBoots().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
} else {
|
||||||
|
m.getEquipment().setBoots(new ItemStack(Material.GOLD_BOOTS));
|
||||||
|
m.getEquipment().getBoots().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m.getEquipment().getHelmet()!=null && Math.random()<0.3) {
|
||||||
|
m.getEquipment().setHelmet(RandomizeEnchantments(m.getEquipment().getHelmet(),ItemRarity.LEGENDARY));
|
||||||
|
if (Math.random()<TwosideKeeper.RARE_DROP_RATE) {
|
||||||
|
ItemStack helm = m.getEquipment().getHelmet();
|
||||||
|
m.getEquipment().setHelmet(TwosideKeeper.convertToHardenedPiece(helm, (int)(Math.random()*8)+3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m.getEquipment().getChestplate()!=null && Math.random()<0.3) {
|
||||||
|
m.getEquipment().setChestplate(RandomizeEnchantments(m.getEquipment().getChestplate(),ItemRarity.LEGENDARY));
|
||||||
|
if (Math.random()<TwosideKeeper.RARE_DROP_RATE) {
|
||||||
|
ItemStack helm = m.getEquipment().getChestplate();
|
||||||
|
m.getEquipment().setChestplate(TwosideKeeper.convertToHardenedPiece(helm, (int)(Math.random()*8)+3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m.getEquipment().getLeggings()!=null && Math.random()<0.3) {
|
||||||
|
m.getEquipment().setLeggings(RandomizeEnchantments(m.getEquipment().getLeggings(),ItemRarity.LEGENDARY));
|
||||||
|
if (Math.random()<TwosideKeeper.RARE_DROP_RATE) {
|
||||||
|
ItemStack helm = m.getEquipment().getLeggings();
|
||||||
|
m.getEquipment().setLeggings(TwosideKeeper.convertToHardenedPiece(helm, (int)(Math.random()*8)+3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m.getEquipment().getBoots()!=null && Math.random()<0.3) {
|
||||||
|
m.getEquipment().setBoots(RandomizeEnchantments(m.getEquipment().getBoots(),ItemRarity.LEGENDARY));
|
||||||
|
if (Math.random()<TwosideKeeper.RARE_DROP_RATE) {
|
||||||
|
ItemStack helm = m.getEquipment().getBoots();
|
||||||
|
m.getEquipment().setBoots(TwosideKeeper.convertToHardenedPiece(helm, (int)(Math.random()*8)+3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((m.getType()==EntityType.ZOMBIE &&
|
||||||
|
!((Zombie)m).isBaby()) ||
|
||||||
|
m.getType()==EntityType.GIANT ||
|
||||||
|
(m.getType()==EntityType.SKELETON &&
|
||||||
|
((Skeleton)m).getSkeletonType()==SkeletonType.WITHER)) {
|
||||||
|
//Equip a sword or rarely, an axe.
|
||||||
|
ItemStack weapon;
|
||||||
|
if (Math.random()<0.03) {
|
||||||
|
if (Math.random()<0.6) {
|
||||||
|
weapon = new ItemStack(Material.DIAMOND_AXE);
|
||||||
|
} else {
|
||||||
|
weapon = new ItemStack(Material.GOLD_AXE);
|
||||||
|
}
|
||||||
|
m.getEquipment().setItemInMainHand(weapon);
|
||||||
|
} else {
|
||||||
|
if (Math.random()<0.6) {
|
||||||
|
weapon = new ItemStack(Material.DIAMOND_SWORD);
|
||||||
|
} else {
|
||||||
|
weapon = new ItemStack(Material.GOLD_SWORD);
|
||||||
|
}
|
||||||
|
m.getEquipment().setItemInMainHand(weapon);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ItemStack weapon = new ItemStack(Material.BOW);
|
||||||
|
m.getEquipment().setItemInMainHand(weapon);
|
||||||
|
}
|
||||||
|
if (m.getType()==EntityType.PIG_ZOMBIE) {
|
||||||
|
ItemStack weapon = new ItemStack(Material.GOLD_SWORD);
|
||||||
|
m.getEquipment().setItemInMainHand(weapon);
|
||||||
|
}
|
||||||
|
m.getEquipment().setBootsDropChance(0.3f);
|
||||||
|
m.getEquipment().setChestplateDropChance(0.3f);
|
||||||
|
m.getEquipment().setLeggingsDropChance(0.3f);
|
||||||
|
m.getEquipment().setHelmetDropChance(0.3f);
|
||||||
|
}break;
|
||||||
|
default:{
|
||||||
|
if (Math.random()<0.1) {
|
||||||
|
if (Math.random()<0.5) {
|
||||||
|
m.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET));
|
||||||
|
m.getEquipment().getHelmet().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
m.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
|
||||||
|
m.getEquipment().getChestplate().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
m.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
|
||||||
|
m.getEquipment().getLeggings().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
m.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS));
|
||||||
|
m.getEquipment().getBoots().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
} else {
|
||||||
|
m.getEquipment().setHelmet(new ItemStack(Material.IRON_HELMET));
|
||||||
|
m.getEquipment().getHelmet().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
m.getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
|
||||||
|
m.getEquipment().getChestplate().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
m.getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS));
|
||||||
|
m.getEquipment().getLeggings().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
m.getEquipment().setBoots(new ItemStack(Material.IRON_BOOTS));
|
||||||
|
m.getEquipment().getBoots().setDurability((short)Math.round(Math.random()*128));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((m.getType()==EntityType.ZOMBIE &&
|
||||||
|
!((Zombie)m).isBaby()) ||
|
||||||
|
m.getType()==EntityType.GIANT ||
|
||||||
|
(m.getType()==EntityType.SKELETON &&
|
||||||
|
((Skeleton)m).getSkeletonType()==SkeletonType.WITHER)) {
|
||||||
|
//Equip a sword or rarely, an axe.
|
||||||
|
ItemStack weapon;
|
||||||
|
if (Math.random()<0.03) {
|
||||||
|
if (Math.random()<0.5) {
|
||||||
|
weapon = new ItemStack(Material.WOOD_AXE);
|
||||||
|
} else {
|
||||||
|
weapon = new ItemStack(Material.STONE_AXE);
|
||||||
|
}
|
||||||
|
m.getEquipment().setItemInMainHand(weapon);
|
||||||
|
} else {
|
||||||
|
if (Math.random()<0.5) {
|
||||||
|
weapon = new ItemStack(Material.WOOD_SWORD);
|
||||||
|
} else {
|
||||||
|
weapon = new ItemStack(Material.STONE_SWORD);
|
||||||
|
}
|
||||||
|
m.getEquipment().setItemInMainHand(weapon);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ItemStack weapon = new ItemStack(Material.BOW);
|
||||||
|
m.getEquipment().setItemInMainHand(weapon);
|
||||||
|
}
|
||||||
|
if (m.getType()==EntityType.PIG_ZOMBIE) {
|
||||||
|
ItemStack weapon = new ItemStack(Material.GOLD_SWORD);
|
||||||
|
m.getEquipment().setItemInMainHand(weapon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static ItemStack RandomizeEnchantments(ItemStack item) {
|
||||||
|
//Have a small chance to randomize every enchant with a random value too.
|
||||||
|
return RandomizeEnchantments(item, ItemRarity.VANILLA);
|
||||||
|
}
|
||||||
|
private static ItemStack RandomizeEnchantments(ItemStack item, ItemRarity rarity) {
|
||||||
|
//Have a small chance to randomize every enchant with a random value too.
|
||||||
|
switch (rarity) {
|
||||||
|
case RARE:
|
||||||
|
{
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*4)+2);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*4)+2);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*4)+2);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, (int)(Math.random()*4)+2);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*4)+2);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.OXYGEN, (int)(Math.random()*2)+2);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.WATER_WORKER, (int)(Math.random()*1)+1);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*2)+2);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.DEPTH_STRIDER, (int)(Math.random()*2)+2);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.FROST_WALKER, (int)(Math.random()*1)+2);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.DURABILITY, (int)(Math.random()*2)+2);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.MENDING, (int)(Math.random()*1)+1);}
|
||||||
|
}break;
|
||||||
|
case EPIC:
|
||||||
|
{
|
||||||
|
if (Math.random()<=0.12) {item.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*7)+2);}
|
||||||
|
if (Math.random()<=0.12) {item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*7)+2);}
|
||||||
|
if (Math.random()<=0.12) {item.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*7)+2);}
|
||||||
|
if (Math.random()<=0.12) {item.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, (int)(Math.random()*7)+2);}
|
||||||
|
if (Math.random()<=0.12) {item.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*7)+2);}
|
||||||
|
if (Math.random()<=0.12) {item.addUnsafeEnchantment(Enchantment.OXYGEN, (int)(Math.random()*7)+2);}
|
||||||
|
if (Math.random()<=0.12) {item.addUnsafeEnchantment(Enchantment.WATER_WORKER, (int)(Math.random()*7)+2);}
|
||||||
|
if (Math.random()<=0.12) {item.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*7)+2);}
|
||||||
|
if (Math.random()<=0.12) {item.addUnsafeEnchantment(Enchantment.DEPTH_STRIDER, (int)(Math.random()*7)+2);}
|
||||||
|
if (Math.random()<=0.12) {item.addUnsafeEnchantment(Enchantment.FROST_WALKER, (int)(Math.random()*7)+2);}
|
||||||
|
if (Math.random()<=0.12) {item.addUnsafeEnchantment(Enchantment.DURABILITY, (int)(Math.random()*7)+2);}
|
||||||
|
if (Math.random()<=0.12) {item.addUnsafeEnchantment(Enchantment.MENDING, (int)(Math.random()*1)+1);}
|
||||||
|
}break;
|
||||||
|
case LEGENDARY:
|
||||||
|
{
|
||||||
|
if (Math.random()<=0.16) {item.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*6)+5);}
|
||||||
|
if (Math.random()<=0.16) {item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*6)+5);}
|
||||||
|
if (Math.random()<=0.16) {item.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*6)+5);}
|
||||||
|
if (Math.random()<=0.16) {item.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, (int)(Math.random()*6)+5);}
|
||||||
|
if (Math.random()<=0.16) {item.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*6)+5);}
|
||||||
|
if (Math.random()<=0.16) {item.addUnsafeEnchantment(Enchantment.OXYGEN, (int)(Math.random()*6)+5);}
|
||||||
|
if (Math.random()<=0.16) {item.addUnsafeEnchantment(Enchantment.WATER_WORKER, (int)(Math.random()*6)+5);}
|
||||||
|
if (Math.random()<=0.16) {item.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*6)+5);}
|
||||||
|
if (Math.random()<=0.16) {item.addUnsafeEnchantment(Enchantment.DEPTH_STRIDER, (int)(Math.random()*6)+5);}
|
||||||
|
if (Math.random()<=0.16) {item.addUnsafeEnchantment(Enchantment.FROST_WALKER, (int)(Math.random()*6)+5);}
|
||||||
|
if (Math.random()<=0.16) {item.addUnsafeEnchantment(Enchantment.DURABILITY, (int)(Math.random()*6)+5);}
|
||||||
|
if (Math.random()<=0.16) {item.addUnsafeEnchantment(Enchantment.MENDING, (int)(Math.random()*1)+1);}
|
||||||
|
}break;
|
||||||
|
default: //Vanilla.
|
||||||
|
{
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, (int)(Math.random()*5)+1);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, (int)(Math.random()*5)+1);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, (int)(Math.random()*5)+1);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, (int)(Math.random()*5)+1);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, (int)(Math.random()*5)+1);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.OXYGEN, (int)(Math.random()*3)+1);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.WATER_WORKER, (int)(Math.random()*1)+1);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.THORNS, (int)(Math.random()*3)+1);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.DEPTH_STRIDER, (int)(Math.random()*3)+1);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.FROST_WALKER, (int)(Math.random()*2)+1);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.DURABILITY, (int)(Math.random()*3)+1);}
|
||||||
|
if (Math.random()<=0.08) {item.addUnsafeEnchantment(Enchantment.MENDING, (int)(Math.random()*1)+1);}
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isZombieLeader(LivingEntity ent) {
|
||||||
|
if (ent instanceof Zombie) {
|
||||||
|
MonsterDifficulty md = getMonsterDifficulty((Monster)ent);
|
||||||
|
if
|
||||||
|
(
|
||||||
|
(md==MonsterDifficulty.NORMAL && ent.getMaxHealth()>20) ||
|
||||||
|
(md==MonsterDifficulty.DANGEROUS && ent.getMaxHealth()>20*2) ||
|
||||||
|
(md==MonsterDifficulty.NORMAL && ent.getMaxHealth()>20*2) ||
|
||||||
|
(md==MonsterDifficulty.NORMAL && ent.getMaxHealth()>20*4)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Monster convertMonster(Monster m) {
|
||||||
|
if (m.getLocation().getY()<48) {
|
||||||
|
if (m.getLocation().getY()>=32)
|
||||||
|
return convertMonster(m,MonsterDifficulty.DANGEROUS);
|
||||||
|
else if (m.getLocation().getY()>=16)
|
||||||
|
return convertMonster(m,MonsterDifficulty.DEADLY);
|
||||||
|
else
|
||||||
|
return convertMonster(m,MonsterDifficulty.HELLFIRE);
|
||||||
|
} else {
|
||||||
|
return convertMonster(m,MonsterDifficulty.NORMAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MonsterDifficulty getMonsterDifficulty(Monster m) {
|
||||||
|
if (m.getCustomName()!=null) {
|
||||||
|
if (m.getCustomName().contains("Dangerous")) {
|
||||||
|
return MonsterDifficulty.DANGEROUS;
|
||||||
|
} else
|
||||||
|
if (m.getCustomName().contains("Deadly")) {
|
||||||
|
return MonsterDifficulty.DEADLY;
|
||||||
|
} else
|
||||||
|
if (m.getCustomName().contains("Hellfire")) {
|
||||||
|
return MonsterDifficulty.HELLFIRE;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
return MonsterDifficulty.NORMAL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return MonsterDifficulty.NORMAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Monster convertMonster(Monster m, MonsterDifficulty md) {
|
||||||
|
switch (md) {
|
||||||
|
case DANGEROUS: {
|
||||||
|
String MonsterName = m.getType().toString().toLowerCase();
|
||||||
|
m.setCustomName(ChatColor.DARK_AQUA+"Dangerous "+TwosideKeeper.CapitalizeFirstLetters(MonsterName.replaceAll("_", " ")+(isZombieLeader(m)?" Leader":"")));
|
||||||
|
m.setMaxHealth(m.getMaxHealth()*2.0);
|
||||||
|
m.setHealth(m.getMaxHealth());
|
||||||
|
if (isAllowedToEquipItems(m)) {
|
||||||
|
m.getEquipment().clear();
|
||||||
|
RandomizeEquipment(m,1);
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case DEADLY: {
|
||||||
|
String MonsterName = m.getType().toString().toLowerCase();
|
||||||
|
m.setCustomName(ChatColor.GOLD+"Deadly "+TwosideKeeper.CapitalizeFirstLetters(MonsterName.replaceAll("_", " ")+(isZombieLeader(m)?" Leader":"")));
|
||||||
|
m.setMaxHealth(m.getMaxHealth()*2.0);
|
||||||
|
m.setHealth(m.getMaxHealth());
|
||||||
|
if (isAllowedToEquipItems(m)) {
|
||||||
|
m.getEquipment().clear();
|
||||||
|
RandomizeEquipment(m,2);
|
||||||
|
}
|
||||||
|
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,1));
|
||||||
|
}break;
|
||||||
|
case HELLFIRE:{
|
||||||
|
String MonsterName = m.getType().toString().toLowerCase();
|
||||||
|
m.setCustomName(ChatColor.DARK_RED+"Hellfire "+TwosideKeeper.CapitalizeFirstLetters(MonsterName.replaceAll("_", " ")+(isZombieLeader(m)?" Leader":"")));
|
||||||
|
//m.setCustomName(ChatColor.DARK_AQUA+"Dangerous Mob");
|
||||||
|
//m.setCustomNameVisible(true);
|
||||||
|
m.setMaxHealth(m.getMaxHealth()*4.0);
|
||||||
|
m.setHealth(m.getMaxHealth());
|
||||||
|
m.setFireTicks(999999);
|
||||||
|
if (isAllowedToEquipItems(m)) {
|
||||||
|
m.getEquipment().clear();
|
||||||
|
RandomizeEquipment(m,3);
|
||||||
|
}
|
||||||
|
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,1));
|
||||||
|
m.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,99999,1));
|
||||||
|
if (Math.random()<=0.2) {m.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,99999,1));}
|
||||||
|
}break;
|
||||||
|
default: {
|
||||||
|
if (isAllowedToEquipItems(m)) {
|
||||||
|
m.getEquipment().clear();
|
||||||
|
RandomizeEquipment(m,0);
|
||||||
|
}
|
||||||
|
if (isZombieLeader(m)) {
|
||||||
|
m.setCustomName(ChatColor.WHITE+"Zombie Leader");
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isAllowedToEquipItems(Monster m) {
|
||||||
|
if (m.getType()==EntityType.ZOMBIE ||
|
||||||
|
m.getType()==EntityType.PIG_ZOMBIE ||
|
||||||
|
m.getType()==EntityType.SKELETON ||
|
||||||
|
m.getType()==EntityType.GIANT) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Monster spawnAdjustedMonster(MonsterType mt,Location loc) {
|
||||||
|
EntityType et;
|
||||||
|
switch(mt) {
|
||||||
|
case BLAZE:
|
||||||
|
et=EntityType.BLAZE;
|
||||||
|
break;
|
||||||
|
case CAVESPIDER:
|
||||||
|
et=EntityType.CAVE_SPIDER;
|
||||||
|
break;
|
||||||
|
case CREEPER:
|
||||||
|
et=EntityType.CREEPER;
|
||||||
|
break;
|
||||||
|
case ENDERMAN:
|
||||||
|
et=EntityType.ENDERMAN;
|
||||||
|
break;
|
||||||
|
case GIANT:
|
||||||
|
et=EntityType.GIANT;
|
||||||
|
break;
|
||||||
|
case GUARDIAN:
|
||||||
|
et=EntityType.GUARDIAN;
|
||||||
|
break;
|
||||||
|
case PIGZOMBIE:
|
||||||
|
et=EntityType.PIG_ZOMBIE;
|
||||||
|
break;
|
||||||
|
case SILVERFISH:
|
||||||
|
et=EntityType.SILVERFISH;
|
||||||
|
break;
|
||||||
|
case SKELETON:
|
||||||
|
et=EntityType.SKELETON;
|
||||||
|
break;
|
||||||
|
case SPIDER:
|
||||||
|
et=EntityType.SPIDER;
|
||||||
|
break;
|
||||||
|
case WITCH:
|
||||||
|
et=EntityType.WITCH;
|
||||||
|
break;
|
||||||
|
case WITHER:
|
||||||
|
et=EntityType.WITHER;
|
||||||
|
break;
|
||||||
|
case ZOMBIE:
|
||||||
|
et=EntityType.ZOMBIE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
et=EntityType.ZOMBIE;
|
||||||
|
}
|
||||||
|
Monster m = (Monster)loc.getWorld().spawnEntity(loc, et);
|
||||||
|
return MonsterController.convertMonster(m);
|
||||||
|
}
|
||||||
|
}
|
211
src/sig/plugin/TwosideKeeper/Party.java
Normal file
211
src/sig/plugin/TwosideKeeper/Party.java
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
package sig.plugin.TwosideKeeper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
|
|
||||||
|
public class Party {
|
||||||
|
public List<Player> partyplayers;
|
||||||
|
int color;
|
||||||
|
Location region;
|
||||||
|
|
||||||
|
Party(int color, Location rawPos) {
|
||||||
|
partyplayers = new ArrayList<Player>();
|
||||||
|
rawPos.setX((int)(rawPos.getX()/(16*TwosideKeeper.PARTY_CHUNK_SIZE))*(16*TwosideKeeper.PARTY_CHUNK_SIZE));
|
||||||
|
rawPos.setZ((int)(rawPos.getZ()/(16*TwosideKeeper.PARTY_CHUNK_SIZE))*(16*TwosideKeeper.PARTY_CHUNK_SIZE));
|
||||||
|
region=rawPos;
|
||||||
|
Bukkit.getLogger().info(region.toString());
|
||||||
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives remove Party"+color); //Make sure the party is cleared out if it was used for something before...
|
||||||
|
//Bukkit.getScoreboardManager().getMainScoreboard().registerNewObjective("Party"+color, "dummy");
|
||||||
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives add Party"+color+" dummy Your Party");
|
||||||
|
//Bukkit.getScoreboardManager().getMainScoreboard().getObjective("Party"+color).setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
|
String color_txt = "";
|
||||||
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives setdisplay sidebar.team."+ConvertColor(color)+" Party"+color);
|
||||||
|
this.color=color;
|
||||||
|
}
|
||||||
|
|
||||||
|
String ConvertColor(int val) {
|
||||||
|
|
||||||
|
switch (val%16) {
|
||||||
|
case 0:{
|
||||||
|
return "white";
|
||||||
|
}
|
||||||
|
case 1:{
|
||||||
|
return "yellow";
|
||||||
|
}
|
||||||
|
case 2:{
|
||||||
|
return "light_purple";
|
||||||
|
}
|
||||||
|
case 3:{
|
||||||
|
return "red";
|
||||||
|
}
|
||||||
|
case 4:{
|
||||||
|
return "aqua";
|
||||||
|
}
|
||||||
|
case 5:{
|
||||||
|
return "green";
|
||||||
|
}
|
||||||
|
case 6:{
|
||||||
|
return "blue";
|
||||||
|
}
|
||||||
|
case 7:{
|
||||||
|
return "dark_gray";
|
||||||
|
}
|
||||||
|
case 8:{
|
||||||
|
return "gray";
|
||||||
|
}
|
||||||
|
case 9:{
|
||||||
|
return "gold";
|
||||||
|
}
|
||||||
|
case 10:{
|
||||||
|
return "dark_purple";
|
||||||
|
}
|
||||||
|
case 11:{
|
||||||
|
return "dark_red";
|
||||||
|
}
|
||||||
|
case 12:{
|
||||||
|
return "dark_aqua";
|
||||||
|
}
|
||||||
|
case 13:{
|
||||||
|
return "dark_green";
|
||||||
|
}
|
||||||
|
case 14:{
|
||||||
|
return "dark_blue";
|
||||||
|
}
|
||||||
|
case 15:{
|
||||||
|
return "black";
|
||||||
|
}
|
||||||
|
default:{
|
||||||
|
return "white";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPlayer(Player p) {
|
||||||
|
partyplayers.add(p);
|
||||||
|
for (int l=0;l<partyplayers.size();l++) {
|
||||||
|
for (int k=0;k<TwosideKeeper.playerdata.size();k++) {
|
||||||
|
//Bukkit.getLogger().info("Looking at playerdata structure... "+k+","+l+". Party size is "+partyplayers.size());
|
||||||
|
if (TwosideKeeper.playerdata.get(k).name.equalsIgnoreCase(partyplayers.get(l).getName())) {
|
||||||
|
TwosideKeeper.playerdata.get(k).currentparty=TeamNumber();
|
||||||
|
TwosideKeeper.playerdata.get(k).partybonus=partyplayers.size()-1;
|
||||||
|
//TwosideKeeper.playerdata.get(k).partybonus=10; //JUST FOR TESTING PURPOSES.
|
||||||
|
if (partyplayers.size()>=2) {
|
||||||
|
//partyplayers.get(l).sendMessage(ChatColor.ITALIC+""+ChatColor.GOLD+"Party Bonuses Applied: "+ChatColor.BLUE+"+"+(partyplayers.size()-1)+"0% damage + defense for "+partyplayers.size()+" party members. Drop Rate +"+(partyplayers.size()-1)+"0%");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), "scoreboard players set "+p.getName().toLowerCase()+" Party"+color+" "+partyplayers.size()*-1);
|
||||||
|
Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), "scoreboard teams option "+p.getName().toLowerCase()+" color "+ConvertColor(color));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sortPlayers() {
|
||||||
|
//Sorts the players on the scoreboard by proper health values.
|
||||||
|
List<Player> sortedorder = new ArrayList<Player>();
|
||||||
|
int lasti=-1; //The last player that had less health than you did.
|
||||||
|
for (int i=0;i<partyplayers.size();i++) {
|
||||||
|
for (int j=0;j<sortedorder.size();j++) {
|
||||||
|
if (sortedorder.get(j).getHealth()>partyplayers.get(i).getHealth()) {
|
||||||
|
lasti=-1;
|
||||||
|
} else {
|
||||||
|
lasti=j; //This means our health is bigger. We go here.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (lasti==-1) {
|
||||||
|
//This just gets inserted.
|
||||||
|
sortedorder.add(partyplayers.get(i));
|
||||||
|
} else {
|
||||||
|
sortedorder.add(lasti,partyplayers.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i=0;i<sortedorder.size();i++) {
|
||||||
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard players set "+sortedorder.get(i).getName().toLowerCase()+" Party"+color+" "+(i+1)*-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getRegion() {
|
||||||
|
return region;
|
||||||
|
}
|
||||||
|
public boolean IsInParty(Player p) {
|
||||||
|
if (partyplayers.contains(p)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public boolean IsInSameRegion(Player p) {
|
||||||
|
if (((int)(p.getLocation().getX()/(16*TwosideKeeper.PARTY_CHUNK_SIZE))*(16*TwosideKeeper.PARTY_CHUNK_SIZE)) == (int)region.getX() &&
|
||||||
|
((int)(p.getLocation().getZ()/(16*TwosideKeeper.PARTY_CHUNK_SIZE))*(16*TwosideKeeper.PARTY_CHUNK_SIZE)) == (int)region.getZ() &&
|
||||||
|
p.getLocation().getWorld() == region.getWorld()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int PlayerCountInParty() {
|
||||||
|
return partyplayers.size();
|
||||||
|
}
|
||||||
|
public int TeamNumber() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
public void UpdateRegion(Location newloc) {
|
||||||
|
newloc.setX((int)(newloc.getX()/(16*TwosideKeeper.PARTY_CHUNK_SIZE))*(16*TwosideKeeper.PARTY_CHUNK_SIZE));
|
||||||
|
newloc.setZ((int)(newloc.getZ()/(16*TwosideKeeper.PARTY_CHUNK_SIZE))*(16*TwosideKeeper.PARTY_CHUNK_SIZE));
|
||||||
|
region = newloc;
|
||||||
|
Bukkit.getLogger().info(region.toString());
|
||||||
|
}
|
||||||
|
public void RemoveStrayMembers() {
|
||||||
|
int prevsiz=partyplayers.size();
|
||||||
|
for (int i=0;i<partyplayers.size();i++) {
|
||||||
|
if (partyplayers.get(i)==null ||
|
||||||
|
!partyplayers.get(i).isOnline() ||
|
||||||
|
partyplayers.get(i).getWorld() != region.getWorld() ||
|
||||||
|
((int)(partyplayers.get(i).getLocation().getX()/(16*TwosideKeeper.PARTY_CHUNK_SIZE))*(16*TwosideKeeper.PARTY_CHUNK_SIZE)) != (int)region.getX() ||
|
||||||
|
((int)(partyplayers.get(i).getLocation().getZ()/(16*TwosideKeeper.PARTY_CHUNK_SIZE))*(16*TwosideKeeper.PARTY_CHUNK_SIZE)) != (int)region.getZ()) {
|
||||||
|
//Bukkit.getLogger().info(((int)(partyplayers.get(i).getLocation().getX()/(16*TwosideKeeper.PARTY_CHUNK_SIZE))*(16*TwosideKeeper.PARTY_CHUNK_SIZE))+" ;; "+((int)(partyplayers.get(i).getLocation().getZ()/(16*TwosideKeeper.PARTY_CHUNK_SIZE))*(16*TwosideKeeper.PARTY_CHUNK_SIZE))+" - DID NOT MATCH");
|
||||||
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard players reset "+partyplayers.get(i).getName().toLowerCase()+" Party"+color);
|
||||||
|
|
||||||
|
for (int l=0;l<partyplayers.size();l++) {
|
||||||
|
for (int k=0;k<TwosideKeeper.playerdata.size();k++) {
|
||||||
|
if (TwosideKeeper.playerdata.get(k).name.equalsIgnoreCase(partyplayers.get(l).getName()) &&
|
||||||
|
TwosideKeeper.playerdata.get(k).currentparty == TeamNumber()) {
|
||||||
|
if (partyplayers.size()-2<0) {
|
||||||
|
TwosideKeeper.playerdata.get(k).partybonus=0;
|
||||||
|
} else {
|
||||||
|
TwosideKeeper.playerdata.get(k).partybonus=partyplayers.size()-2;
|
||||||
|
}
|
||||||
|
TwosideKeeper.playerdata.get(k).currentparty=-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (partyplayers.size()>=2) {
|
||||||
|
//partyplayers.get(i).sendMessage(ChatColor.DARK_GRAY+""+ChatColor.ITALIC+"Party buffs removed.");
|
||||||
|
}
|
||||||
|
partyplayers.remove(i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (prevsiz!=partyplayers.size()) {
|
||||||
|
for (int i=0;i<partyplayers.size();i++) {
|
||||||
|
if (partyplayers.size()==1) {
|
||||||
|
//partyplayers.get(i).sendMessage(ChatColor.DARK_GRAY+""+ChatColor.ITALIC+"Party buffs removed.");
|
||||||
|
} else {
|
||||||
|
for (int j=0;j<TwosideKeeper.playerdata.size();j++) {
|
||||||
|
if (TwosideKeeper.playerdata.get(j).name.equalsIgnoreCase(partyplayers.get(i).getName())) {
|
||||||
|
TwosideKeeper.playerdata.get(j).partybonus=partyplayers.size()-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//partyplayers.get(i).sendMessage(ChatColor.ITALIC+""+ChatColor.GOLD+"Party Bonuses Applied: "+ChatColor.BLUE+"+"+(partyplayers.size()-1)+"0% damage + defense for "+partyplayers.size()+" party members. Drop Rate +"+(partyplayers.size()-1)+"0%");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
178
src/sig/plugin/TwosideKeeper/PlayerStructure.java
Normal file
178
src/sig/plugin/TwosideKeeper/PlayerStructure.java
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
package sig.plugin.TwosideKeeper;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
/*PLAYER STRUCTURE
|
||||||
|
*
|
||||||
|
* Keeps external data and info about the player
|
||||||
|
* and provides a format that can save this data
|
||||||
|
* to a file when it's time. Updates the visual
|
||||||
|
* healthbar on-screen and such.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PlayerStructure {
|
||||||
|
public String name;
|
||||||
|
//public String displayName;
|
||||||
|
public long joined; //When the player logged in today. Can track how long played, etc.
|
||||||
|
public long firstjoined; //The first server tick the player joined the game.
|
||||||
|
|
||||||
|
public double money; //Money stored on the player.
|
||||||
|
public double bank_money; //Money in the bank.
|
||||||
|
|
||||||
|
public boolean opened_inventory;
|
||||||
|
|
||||||
|
public int saturation; //We will now track saturation manually to remove health healing from saturation.
|
||||||
|
public long last_regen_time; //Last time a health regen took place.
|
||||||
|
public double damagereduction;
|
||||||
|
public int insertItem=-1; //The position in the chat message to insert an item to.
|
||||||
|
//public double basedmg;
|
||||||
|
public LivingEntity target; //The current entity this player is looking at.
|
||||||
|
public boolean enderdragon_spawned; //Whether or not an Ender Dragon has been spawned for this player.
|
||||||
|
public int partybonus; //Holds how many players are in the party, to account for party bonuses.
|
||||||
|
public int currentparty; //Which party we are in.
|
||||||
|
public int spleef_pts;
|
||||||
|
public int spleef_wins;
|
||||||
|
public int title_task; //Keeps track of the task last identified for updating titles.
|
||||||
|
public int pickeditems=-1;
|
||||||
|
public boolean sounds_enabled=true;
|
||||||
|
|
||||||
|
//Needs the instance of the player object to get all other info. Only to be called at the beginning.
|
||||||
|
public PlayerStructure(Player p, long serverTickTime) {
|
||||||
|
if (p!=null) {
|
||||||
|
this.name = p.getName();
|
||||||
|
this.joined = serverTickTime;
|
||||||
|
this.firstjoined=serverTickTime;
|
||||||
|
this.money=100;
|
||||||
|
this.bank_money=0;
|
||||||
|
this.opened_inventory=false;
|
||||||
|
this.saturation=20;
|
||||||
|
this.last_regen_time=TwosideKeeper.SERVERTICK;
|
||||||
|
this.target=null;
|
||||||
|
this.damagereduction=1.0;
|
||||||
|
//this.basedmg=0.0;
|
||||||
|
this.partybonus=0;
|
||||||
|
this.enderdragon_spawned=false;
|
||||||
|
this.currentparty=-1;
|
||||||
|
this.spleef_pts=0;
|
||||||
|
this.spleef_wins=0;
|
||||||
|
this.title_task=-1;
|
||||||
|
this.sounds_enabled=true;
|
||||||
|
//Set defaults first, in case this is a new user.
|
||||||
|
loadConfig();
|
||||||
|
|
||||||
|
p.getInventory().addItem(new ItemStack(Material.PORTAL));
|
||||||
|
|
||||||
|
//Check if new player.
|
||||||
|
if (this.firstjoined == serverTickTime) {
|
||||||
|
//This is a new player! Let the whole world know!
|
||||||
|
//Give the player free tools and items.
|
||||||
|
Bukkit.getServer().broadcastMessage(ChatColor.GOLD+"Welcome to new player "+ChatColor.WHITE+""+this.name+"!");
|
||||||
|
p.sendMessage(ChatColor.GREEN+"Welcome to the server! Thanks for joining us.");
|
||||||
|
p.sendMessage(ChatColor.GOLD+" Here's some tools to get you started.");
|
||||||
|
|
||||||
|
//Give starter pack.
|
||||||
|
p.getInventory().addItem(new ItemStack(Material.STONE_SWORD,1));
|
||||||
|
p.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE,1));
|
||||||
|
p.getInventory().addItem(new ItemStack(Material.STONE_AXE,1));
|
||||||
|
p.getInventory().addItem(new ItemStack(Material.STONE_SPADE,1));
|
||||||
|
p.getInventory().addItem(new ItemStack(Material.MINECART,1));
|
||||||
|
p.getInventory().addItem(new ItemStack(Material.LEATHER_CHESTPLATE,1));
|
||||||
|
p.getInventory().addItem(new ItemStack(Material.LEATHER_LEGGINGS,1));
|
||||||
|
p.getInventory().addItem(new ItemStack(Material.TORCH,8));
|
||||||
|
p.getInventory().addItem(new ItemStack(Material.BREAD,16));
|
||||||
|
|
||||||
|
//Make sure it's not already there...?
|
||||||
|
if (Bukkit.getServer().getScoreboardManager().getMainScoreboard().getTeam(this.name.toLowerCase())==null) {
|
||||||
|
Bukkit.getServer().getScoreboardManager().getMainScoreboard().registerNewTeam(this.name.toLowerCase()).addPlayer(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Joined always gets set to new time.
|
||||||
|
this.joined = serverTickTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Save the configuration.
|
||||||
|
public void saveConfig() {
|
||||||
|
File config;
|
||||||
|
config = new File(TwosideKeeper.filesave,"users/"+name+".data");
|
||||||
|
FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
|
||||||
|
|
||||||
|
workable.set("name", name);
|
||||||
|
//workable.set("displayName", displayName);
|
||||||
|
workable.set("joined", joined);
|
||||||
|
workable.set("firstjoined", firstjoined);
|
||||||
|
workable.set("money", money);
|
||||||
|
workable.set("bank_money", bank_money);
|
||||||
|
workable.set("saturation", saturation);
|
||||||
|
workable.set("damagereduction", damagereduction);
|
||||||
|
workable.set("enderdragon_spawned", enderdragon_spawned);
|
||||||
|
workable.set("spleef_pts", spleef_pts);
|
||||||
|
workable.set("spleef_wins", spleef_wins);
|
||||||
|
workable.set("sounds_enabled", sounds_enabled);
|
||||||
|
|
||||||
|
try {
|
||||||
|
workable.save(config);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create a config for the player.
|
||||||
|
public void loadConfig(){
|
||||||
|
File config;
|
||||||
|
config = new File(TwosideKeeper.filesave,"users/"+name+".data");
|
||||||
|
FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
|
||||||
|
|
||||||
|
//Add all our default settings here.
|
||||||
|
workable.addDefault("name", name);
|
||||||
|
//workable.addDefault("displayName", displayName);
|
||||||
|
workable.addDefault("joined", joined);
|
||||||
|
workable.addDefault("firstjoined", firstjoined);
|
||||||
|
workable.addDefault("money", money);
|
||||||
|
workable.addDefault("bank_money", bank_money);
|
||||||
|
workable.addDefault("saturation", saturation);
|
||||||
|
workable.addDefault("damagereduction", damagereduction);
|
||||||
|
workable.addDefault("enderdragon_spawned", enderdragon_spawned);
|
||||||
|
workable.addDefault("spleef_pts", spleef_pts);
|
||||||
|
workable.addDefault("spleef_wins", spleef_wins);
|
||||||
|
workable.addDefault("sounds_enabled", sounds_enabled);
|
||||||
|
|
||||||
|
workable.options().copyDefaults();
|
||||||
|
|
||||||
|
//Set all variables.
|
||||||
|
|
||||||
|
this.name = workable.getString("name");
|
||||||
|
//this.displayName = workable.getString("displayName");
|
||||||
|
this.joined = workable.getLong("joined");
|
||||||
|
this.firstjoined = workable.getLong("firstjoined");
|
||||||
|
this.money = workable.getDouble("money");
|
||||||
|
this.bank_money = workable.getDouble("bank_money");
|
||||||
|
this.saturation = workable.getInt("saturation");
|
||||||
|
this.damagereduction = workable.getDouble("damagereduction");
|
||||||
|
this.enderdragon_spawned = workable.getBoolean("enderdragon_spawned");
|
||||||
|
this.spleef_pts = workable.getInt("spleef_pts");
|
||||||
|
this.spleef_wins = workable.getInt("spleef_wins");
|
||||||
|
this.sounds_enabled = workable.getBoolean("sounds_enabled");
|
||||||
|
|
||||||
|
try {
|
||||||
|
workable.save(config);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
475
src/sig/plugin/TwosideKeeper/Recipes.java
Normal file
475
src/sig/plugin/TwosideKeeper/Recipes.java
Normal file
@ -0,0 +1,475 @@
|
|||||||
|
package sig.plugin.TwosideKeeper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.ShapedRecipe;
|
||||||
|
import org.bukkit.inventory.ShapelessRecipe;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.material.Dye;
|
||||||
|
|
||||||
|
public class Recipes {
|
||||||
|
public static void Initialize_ItemCube_Recipes() {
|
||||||
|
ItemStack item_ItemCube = new ItemStack(Material.CHEST);
|
||||||
|
|
||||||
|
List<String> item_ItemCube_lore = new ArrayList<String>();
|
||||||
|
item_ItemCube_lore.add("A storage container that can");
|
||||||
|
item_ItemCube_lore.add("be carried around. "+ChatColor.GOLD+"Open by");
|
||||||
|
item_ItemCube_lore.add(ChatColor.GOLD+"right-clicking.");
|
||||||
|
ItemMeta item_ItemCube_meta=item_ItemCube.getItemMeta();
|
||||||
|
item_ItemCube_meta.setLore(item_ItemCube_lore);
|
||||||
|
item_ItemCube_meta.setDisplayName("Item Cube");
|
||||||
|
item_ItemCube.setItemMeta(item_ItemCube_meta);
|
||||||
|
|
||||||
|
ShapedRecipe ItemCube = new ShapedRecipe(item_ItemCube);
|
||||||
|
ItemCube.shape("ppp","pcp","ppp");
|
||||||
|
ItemCube.setIngredient('p', Material.WOOD, -1);
|
||||||
|
ItemCube.setIngredient('c', Material.CHEST);
|
||||||
|
|
||||||
|
Bukkit.addRecipe(ItemCube);
|
||||||
|
//------------------------------
|
||||||
|
item_ItemCube = new ItemStack(Material.STORAGE_MINECART);
|
||||||
|
item_ItemCube_meta=item_ItemCube.getItemMeta();
|
||||||
|
item_ItemCube_meta.setLore(item_ItemCube_lore);
|
||||||
|
item_ItemCube_meta.setDisplayName("Large Item Cube");
|
||||||
|
item_ItemCube.setItemMeta(item_ItemCube_meta);
|
||||||
|
|
||||||
|
ItemCube = new ShapedRecipe(item_ItemCube);
|
||||||
|
ItemCube.shape("ppp","gcg","ppp");
|
||||||
|
ItemCube.setIngredient('p', Material.WOOD, -1);
|
||||||
|
ItemCube.setIngredient('g', Material.GOLD_BLOCK);
|
||||||
|
ItemCube.setIngredient('c', Material.CHEST);
|
||||||
|
|
||||||
|
Bukkit.addRecipe(ItemCube);
|
||||||
|
//------------------------------
|
||||||
|
item_ItemCube = new ItemStack(Material.ENDER_CHEST);
|
||||||
|
item_ItemCube_meta=item_ItemCube.getItemMeta();
|
||||||
|
item_ItemCube_meta.setLore(item_ItemCube_lore);
|
||||||
|
item_ItemCube_meta.setDisplayName("Ender Item Cube");
|
||||||
|
item_ItemCube.setItemMeta(item_ItemCube_meta);
|
||||||
|
|
||||||
|
ItemCube = new ShapedRecipe(item_ItemCube);
|
||||||
|
ItemCube.shape("ooo","ece","ooo");
|
||||||
|
ItemCube.setIngredient('o', Material.OBSIDIAN);
|
||||||
|
ItemCube.setIngredient('e', Material.EMERALD);
|
||||||
|
ItemCube.setIngredient('c', Material.ENDER_CHEST);
|
||||||
|
|
||||||
|
Bukkit.addRecipe(ItemCube);
|
||||||
|
//------------------------------
|
||||||
|
}
|
||||||
|
public static void Initialize_ArrowQuiver_Recipe() {
|
||||||
|
ItemStack arrow_quiver = new ItemStack(Material.TIPPED_ARROW);
|
||||||
|
|
||||||
|
List<String> arrow_quiver_lore = new ArrayList<String>();
|
||||||
|
arrow_quiver_lore.add("A quiver that holds many arrows.");
|
||||||
|
arrow_quiver_lore.add(ChatColor.GRAY+"Arrows Remaining: "+ChatColor.YELLOW+"5");
|
||||||
|
ItemMeta arrow_quiver_meta=arrow_quiver.getItemMeta();
|
||||||
|
arrow_quiver_meta.setLore(arrow_quiver_lore);
|
||||||
|
arrow_quiver_meta.setDisplayName(ChatColor.BLUE+"Arrow Quiver");
|
||||||
|
arrow_quiver.setItemMeta(arrow_quiver_meta);
|
||||||
|
|
||||||
|
arrow_quiver.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 5);
|
||||||
|
|
||||||
|
arrow_quiver.setAmount(1);
|
||||||
|
|
||||||
|
ShapedRecipe ArrowQuiver = new ShapedRecipe(arrow_quiver);
|
||||||
|
ArrowQuiver.shape("xle","lsl","xlx");
|
||||||
|
ArrowQuiver.setIngredient('s', Material.SPECTRAL_ARROW);
|
||||||
|
ArrowQuiver.setIngredient('l', Material.LEATHER);
|
||||||
|
ArrowQuiver.setIngredient('e', Material.EMERALD_BLOCK);
|
||||||
|
|
||||||
|
Bukkit.addRecipe(ArrowQuiver);
|
||||||
|
}
|
||||||
|
public static void Initialize_BlockArmor_Recipes() {
|
||||||
|
ItemStack blockarmorpc = new ItemStack(Material.IRON_HELMET);
|
||||||
|
|
||||||
|
List<String> blockarmorpc_lore = new ArrayList<String>();
|
||||||
|
blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4");
|
||||||
|
ItemMeta blockarmorpc_meta=blockarmorpc.getItemMeta();
|
||||||
|
blockarmorpc_meta.setLore(blockarmorpc_lore);
|
||||||
|
blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Iron Helmet");
|
||||||
|
blockarmorpc.setItemMeta(blockarmorpc_meta);
|
||||||
|
|
||||||
|
ShapedRecipe BlockArmor = new ShapedRecipe(blockarmorpc);
|
||||||
|
BlockArmor.shape("aaa","axa","xxx");
|
||||||
|
BlockArmor.setIngredient('a', Material.IRON_BLOCK);
|
||||||
|
|
||||||
|
Bukkit.addRecipe(BlockArmor);
|
||||||
|
//--------------------------------------------
|
||||||
|
blockarmorpc = new ItemStack(Material.IRON_CHESTPLATE);
|
||||||
|
|
||||||
|
blockarmorpc_lore = new ArrayList<String>();
|
||||||
|
blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4");
|
||||||
|
blockarmorpc_meta=blockarmorpc.getItemMeta();
|
||||||
|
blockarmorpc_meta.setLore(blockarmorpc_lore);
|
||||||
|
blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Iron Chestplate");
|
||||||
|
blockarmorpc.setItemMeta(blockarmorpc_meta);
|
||||||
|
|
||||||
|
BlockArmor = new ShapedRecipe(blockarmorpc);
|
||||||
|
BlockArmor.shape("axa","aaa","aaa");
|
||||||
|
BlockArmor.setIngredient('a', Material.IRON_BLOCK);
|
||||||
|
|
||||||
|
Bukkit.addRecipe(BlockArmor);
|
||||||
|
//--------------------------------------------
|
||||||
|
blockarmorpc = new ItemStack(Material.IRON_LEGGINGS);
|
||||||
|
|
||||||
|
blockarmorpc_lore = new ArrayList<String>();
|
||||||
|
blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4");
|
||||||
|
blockarmorpc_meta=blockarmorpc.getItemMeta();
|
||||||
|
blockarmorpc_meta.setLore(blockarmorpc_lore);
|
||||||
|
blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Iron Leggings");
|
||||||
|
blockarmorpc.setItemMeta(blockarmorpc_meta);
|
||||||
|
|
||||||
|
BlockArmor = new ShapedRecipe(blockarmorpc);
|
||||||
|
BlockArmor.shape("aaa","axa","axa");
|
||||||
|
BlockArmor.setIngredient('a', Material.IRON_BLOCK);
|
||||||
|
|
||||||
|
Bukkit.addRecipe(BlockArmor);
|
||||||
|
//--------------------------------------------
|
||||||
|
blockarmorpc = new ItemStack(Material.IRON_BOOTS);
|
||||||
|
|
||||||
|
blockarmorpc_lore = new ArrayList<String>();
|
||||||
|
blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4");
|
||||||
|
blockarmorpc_meta=blockarmorpc.getItemMeta();
|
||||||
|
blockarmorpc_meta.setLore(blockarmorpc_lore);
|
||||||
|
blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Iron Boots");
|
||||||
|
blockarmorpc.setItemMeta(blockarmorpc_meta);
|
||||||
|
|
||||||
|
BlockArmor = new ShapedRecipe(blockarmorpc);
|
||||||
|
BlockArmor.shape("axa","axa");
|
||||||
|
BlockArmor.setIngredient('a', Material.IRON_BLOCK);
|
||||||
|
|
||||||
|
Bukkit.addRecipe(BlockArmor);
|
||||||
|
//--------------------------------------------
|
||||||
|
blockarmorpc = new ItemStack(Material.GOLD_HELMET);
|
||||||
|
|
||||||
|
blockarmorpc_lore = new ArrayList<String>();
|
||||||
|
blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4");
|
||||||
|
blockarmorpc_meta=blockarmorpc.getItemMeta();
|
||||||
|
blockarmorpc_meta.setLore(blockarmorpc_lore);
|
||||||
|
blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Gold Helmet");
|
||||||
|
blockarmorpc.setItemMeta(blockarmorpc_meta);
|
||||||
|
|
||||||
|
BlockArmor = new ShapedRecipe(blockarmorpc);
|
||||||
|
BlockArmor.shape("aaa","axa","xxx");
|
||||||
|
BlockArmor.setIngredient('a', Material.GOLD_BLOCK);
|
||||||
|
|
||||||
|
Bukkit.addRecipe(BlockArmor);
|
||||||
|
//--------------------------------------------
|
||||||
|
blockarmorpc = new ItemStack(Material.GOLD_CHESTPLATE);
|
||||||
|
|
||||||
|
blockarmorpc_lore = new ArrayList<String>();
|
||||||
|
blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4");
|
||||||
|
blockarmorpc_meta=blockarmorpc.getItemMeta();
|
||||||
|
blockarmorpc_meta.setLore(blockarmorpc_lore);
|
||||||
|
blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Gold Chestplate");
|
||||||
|
blockarmorpc.setItemMeta(blockarmorpc_meta);
|
||||||
|
|
||||||
|
BlockArmor = new ShapedRecipe(blockarmorpc);
|
||||||
|
BlockArmor.shape("axa","aaa","aaa");
|
||||||
|
BlockArmor.setIngredient('a', Material.GOLD_BLOCK);
|
||||||
|
|
||||||
|
Bukkit.addRecipe(BlockArmor);
|
||||||
|
//--------------------------------------------
|
||||||
|
blockarmorpc = new ItemStack(Material.GOLD_LEGGINGS);
|
||||||
|
|
||||||
|
blockarmorpc_lore = new ArrayList<String>();
|
||||||
|
blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4");
|
||||||
|
blockarmorpc_meta=blockarmorpc.getItemMeta();
|
||||||
|
blockarmorpc_meta.setLore(blockarmorpc_lore);
|
||||||
|
blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Gold Leggings");
|
||||||
|
blockarmorpc.setItemMeta(blockarmorpc_meta);
|
||||||
|
|
||||||
|
BlockArmor = new ShapedRecipe(blockarmorpc);
|
||||||
|
BlockArmor.shape("aaa","axa","axa");
|
||||||
|
BlockArmor.setIngredient('a', Material.GOLD_BLOCK);
|
||||||
|
|
||||||
|
Bukkit.addRecipe(BlockArmor);
|
||||||
|
//--------------------------------------------
|
||||||
|
blockarmorpc = new ItemStack(Material.GOLD_BOOTS);
|
||||||
|
|
||||||
|
blockarmorpc_lore = new ArrayList<String>();
|
||||||
|
blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4");
|
||||||
|
blockarmorpc_meta=blockarmorpc.getItemMeta();
|
||||||
|
blockarmorpc_meta.setLore(blockarmorpc_lore);
|
||||||
|
blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Gold Boots");
|
||||||
|
blockarmorpc.setItemMeta(blockarmorpc_meta);
|
||||||
|
|
||||||
|
BlockArmor = new ShapedRecipe(blockarmorpc);
|
||||||
|
BlockArmor.shape("axa","axa");
|
||||||
|
BlockArmor.setIngredient('a', Material.GOLD_BLOCK);
|
||||||
|
|
||||||
|
Bukkit.addRecipe(BlockArmor);
|
||||||
|
//--------------------------------------------
|
||||||
|
blockarmorpc = new ItemStack(Material.DIAMOND_HELMET);
|
||||||
|
|
||||||
|
blockarmorpc_lore = new ArrayList<String>();
|
||||||
|
blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4");
|
||||||
|
blockarmorpc_meta=blockarmorpc.getItemMeta();
|
||||||
|
blockarmorpc_meta.setLore(blockarmorpc_lore);
|
||||||
|
blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Diamond Helmet");
|
||||||
|
blockarmorpc.setItemMeta(blockarmorpc_meta);
|
||||||
|
|
||||||
|
BlockArmor = new ShapedRecipe(blockarmorpc);
|
||||||
|
BlockArmor.shape("aaa","axa","xxx");
|
||||||
|
BlockArmor.setIngredient('a', Material.DIAMOND_BLOCK);
|
||||||
|
|
||||||
|
Bukkit.addRecipe(BlockArmor);
|
||||||
|
//--------------------------------------------
|
||||||
|
blockarmorpc = new ItemStack(Material.DIAMOND_CHESTPLATE);
|
||||||
|
|
||||||
|
blockarmorpc_lore = new ArrayList<String>();
|
||||||
|
blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4");
|
||||||
|
blockarmorpc_meta=blockarmorpc.getItemMeta();
|
||||||
|
blockarmorpc_meta.setLore(blockarmorpc_lore);
|
||||||
|
blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Diamond Chestplate");
|
||||||
|
blockarmorpc.setItemMeta(blockarmorpc_meta);
|
||||||
|
|
||||||
|
BlockArmor = new ShapedRecipe(blockarmorpc);
|
||||||
|
BlockArmor.shape("axa","aaa","aaa");
|
||||||
|
BlockArmor.setIngredient('a', Material.DIAMOND_BLOCK);
|
||||||
|
|
||||||
|
Bukkit.addRecipe(BlockArmor);
|
||||||
|
//--------------------------------------------
|
||||||
|
blockarmorpc = new ItemStack(Material.DIAMOND_LEGGINGS);
|
||||||
|
|
||||||
|
blockarmorpc_lore = new ArrayList<String>();
|
||||||
|
blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4");
|
||||||
|
blockarmorpc_meta=blockarmorpc.getItemMeta();
|
||||||
|
blockarmorpc_meta.setLore(blockarmorpc_lore);
|
||||||
|
blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Diamond Leggings");
|
||||||
|
blockarmorpc.setItemMeta(blockarmorpc_meta);
|
||||||
|
|
||||||
|
BlockArmor = new ShapedRecipe(blockarmorpc);
|
||||||
|
BlockArmor.shape("aaa","axa","axa");
|
||||||
|
BlockArmor.setIngredient('a', Material.DIAMOND_BLOCK);
|
||||||
|
|
||||||
|
Bukkit.addRecipe(BlockArmor);
|
||||||
|
//--------------------------------------------
|
||||||
|
blockarmorpc = new ItemStack(Material.DIAMOND_BOOTS);
|
||||||
|
|
||||||
|
blockarmorpc_lore = new ArrayList<String>();
|
||||||
|
blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong");
|
||||||
|
blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4");
|
||||||
|
blockarmorpc_meta=blockarmorpc.getItemMeta();
|
||||||
|
blockarmorpc_meta.setLore(blockarmorpc_lore);
|
||||||
|
blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Diamond Boots");
|
||||||
|
blockarmorpc.setItemMeta(blockarmorpc_meta);
|
||||||
|
|
||||||
|
BlockArmor = new ShapedRecipe(blockarmorpc);
|
||||||
|
BlockArmor.shape("axa","axa");
|
||||||
|
BlockArmor.setIngredient('a', Material.DIAMOND_BLOCK);
|
||||||
|
|
||||||
|
Bukkit.addRecipe(BlockArmor);
|
||||||
|
//--------------------------------------------
|
||||||
|
}
|
||||||
|
public static void Initialize_ItemDeconstruction_Recipes() {
|
||||||
|
ShapelessRecipe decons_recipe = new ShapelessRecipe(new ItemStack(Material.LEATHER,4));
|
||||||
|
decons_recipe.addIngredient(Material.LEATHER_BOOTS);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.LEATHER,7));
|
||||||
|
decons_recipe.addIngredient(Material.LEATHER_LEGGINGS);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.LEATHER,8));
|
||||||
|
decons_recipe.addIngredient(Material.LEATHER_CHESTPLATE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.LEATHER,5));
|
||||||
|
decons_recipe.addIngredient(Material.LEATHER_HELMET);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.WOOD,2));
|
||||||
|
decons_recipe.addIngredient(Material.WOOD_SWORD);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.WOOD,3));
|
||||||
|
decons_recipe.addIngredient(Material.WOOD_AXE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.WOOD,3));
|
||||||
|
decons_recipe.addIngredient(Material.WOOD_PICKAXE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.WOOD,2));
|
||||||
|
decons_recipe.addIngredient(Material.WOOD_HOE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.WOOD,1));
|
||||||
|
decons_recipe.addIngredient(Material.WOOD_SPADE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.COBBLESTONE,2));
|
||||||
|
decons_recipe.addIngredient(Material.STONE_SWORD);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.COBBLESTONE,3));
|
||||||
|
decons_recipe.addIngredient(Material.STONE_AXE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.COBBLESTONE,3));
|
||||||
|
decons_recipe.addIngredient(Material.STONE_PICKAXE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.COBBLESTONE,2));
|
||||||
|
decons_recipe.addIngredient(Material.STONE_HOE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.COBBLESTONE,1));
|
||||||
|
decons_recipe.addIngredient(Material.STONE_SPADE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,4));
|
||||||
|
decons_recipe.addIngredient(Material.IRON_BOOTS);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,7));
|
||||||
|
decons_recipe.addIngredient(Material.IRON_LEGGINGS);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,8));
|
||||||
|
decons_recipe.addIngredient(Material.IRON_CHESTPLATE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,5));
|
||||||
|
decons_recipe.addIngredient(Material.IRON_HELMET);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,2));
|
||||||
|
decons_recipe.addIngredient(Material.IRON_SWORD);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,3));
|
||||||
|
decons_recipe.addIngredient(Material.IRON_AXE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,3));
|
||||||
|
decons_recipe.addIngredient(Material.IRON_PICKAXE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,2));
|
||||||
|
decons_recipe.addIngredient(Material.IRON_HOE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,1));
|
||||||
|
decons_recipe.addIngredient(Material.IRON_SPADE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,4));
|
||||||
|
decons_recipe.addIngredient(Material.GOLD_BOOTS);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,7));
|
||||||
|
decons_recipe.addIngredient(Material.GOLD_LEGGINGS);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,8));
|
||||||
|
decons_recipe.addIngredient(Material.GOLD_CHESTPLATE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,5));
|
||||||
|
decons_recipe.addIngredient(Material.GOLD_HELMET);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,2));
|
||||||
|
decons_recipe.addIngredient(Material.GOLD_SWORD);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,3));
|
||||||
|
decons_recipe.addIngredient(Material.GOLD_AXE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,3));
|
||||||
|
decons_recipe.addIngredient(Material.GOLD_PICKAXE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,2));
|
||||||
|
decons_recipe.addIngredient(Material.GOLD_HOE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,1));
|
||||||
|
decons_recipe.addIngredient(Material.GOLD_SPADE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,4));
|
||||||
|
decons_recipe.addIngredient(Material.DIAMOND_BOOTS);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,7));
|
||||||
|
decons_recipe.addIngredient(Material.DIAMOND_LEGGINGS);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,8));
|
||||||
|
decons_recipe.addIngredient(Material.DIAMOND_CHESTPLATE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,5));
|
||||||
|
decons_recipe.addIngredient(Material.DIAMOND_HELMET);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,2));
|
||||||
|
decons_recipe.addIngredient(Material.DIAMOND_SWORD);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,3));
|
||||||
|
decons_recipe.addIngredient(Material.DIAMOND_AXE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,3));
|
||||||
|
decons_recipe.addIngredient(Material.DIAMOND_PICKAXE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,2));
|
||||||
|
decons_recipe.addIngredient(Material.DIAMOND_HOE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,1));
|
||||||
|
decons_recipe.addIngredient(Material.DIAMOND_SPADE);
|
||||||
|
Bukkit.addRecipe(decons_recipe);
|
||||||
|
}
|
||||||
|
public static void Initialize_WoolRecolor_Recipes() {
|
||||||
|
for (int i=0;i<16;i++) {
|
||||||
|
ShapedRecipe wool_recolor_recipe = new ShapedRecipe(new ItemStack(Material.WOOL,8,(byte)(15-i)));
|
||||||
|
wool_recolor_recipe.shape("www","wdw","www");
|
||||||
|
wool_recolor_recipe.setIngredient('w', Material.WOOL, -1);
|
||||||
|
wool_recolor_recipe.setIngredient('d', Material.getMaterial(351), i);
|
||||||
|
Bukkit.addRecipe(wool_recolor_recipe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void Initialize_SlabReconstruction_Recipes() {
|
||||||
|
for (int i=0;i<=5;i++) {
|
||||||
|
ShapelessRecipe plank_construction_recipe = new ShapelessRecipe(new ItemStack(Material.WOOD,1,(byte)i));
|
||||||
|
plank_construction_recipe.addIngredient(2, Material.getMaterial(126), i);
|
||||||
|
Bukkit.addRecipe(plank_construction_recipe);
|
||||||
|
}
|
||||||
|
ShapelessRecipe sandstone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.RED_SANDSTONE,1));
|
||||||
|
sandstone_construction_recipe.addIngredient(2, Material.getMaterial(182));
|
||||||
|
Bukkit.addRecipe(sandstone_construction_recipe);
|
||||||
|
ShapelessRecipe stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.STONE,1));
|
||||||
|
stone_construction_recipe.addIngredient(2, Material.getMaterial(44), 0);
|
||||||
|
Bukkit.addRecipe(stone_construction_recipe);
|
||||||
|
stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.SANDSTONE,1));
|
||||||
|
stone_construction_recipe.addIngredient(2, Material.getMaterial(44), 1);
|
||||||
|
Bukkit.addRecipe(stone_construction_recipe);
|
||||||
|
stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.WOOD,1));
|
||||||
|
stone_construction_recipe.addIngredient(2, Material.getMaterial(44), 2);
|
||||||
|
Bukkit.addRecipe(stone_construction_recipe);
|
||||||
|
stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.COBBLESTONE,1));
|
||||||
|
stone_construction_recipe.addIngredient(2, Material.getMaterial(44), 3);
|
||||||
|
Bukkit.addRecipe(stone_construction_recipe);
|
||||||
|
stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.BRICK,1));
|
||||||
|
stone_construction_recipe.addIngredient(2, Material.getMaterial(44), 4);
|
||||||
|
Bukkit.addRecipe(stone_construction_recipe);
|
||||||
|
stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.getMaterial(98),1));
|
||||||
|
stone_construction_recipe.addIngredient(2, Material.getMaterial(44), 5);
|
||||||
|
Bukkit.addRecipe(stone_construction_recipe);
|
||||||
|
stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.NETHER_BRICK,1));
|
||||||
|
stone_construction_recipe.addIngredient(2, Material.getMaterial(44), 6);
|
||||||
|
Bukkit.addRecipe(stone_construction_recipe);
|
||||||
|
stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.QUARTZ_BLOCK,1));
|
||||||
|
stone_construction_recipe.addIngredient(2, Material.getMaterial(44), 7);
|
||||||
|
Bukkit.addRecipe(stone_construction_recipe);
|
||||||
|
stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.PURPUR_BLOCK,1));
|
||||||
|
stone_construction_recipe.addIngredient(2, Material.PURPUR_SLAB);
|
||||||
|
Bukkit.addRecipe(stone_construction_recipe);
|
||||||
|
ItemStack modded_plank = new ItemStack(Material.STEP,1);
|
||||||
|
modded_plank.setDurability((short)2);
|
||||||
|
ItemMeta m = modded_plank.getItemMeta();
|
||||||
|
m.setDisplayName("Fireproof Oak Wood Slab");
|
||||||
|
modded_plank.setItemMeta(m);
|
||||||
|
stone_construction_recipe = new ShapelessRecipe(modded_plank);
|
||||||
|
stone_construction_recipe.addIngredient(1, Material.WOOD_STEP);
|
||||||
|
stone_construction_recipe.addIngredient(1, Material.SLIME_BALL);
|
||||||
|
Bukkit.addRecipe(stone_construction_recipe);
|
||||||
|
}
|
||||||
|
}
|
100
src/sig/plugin/TwosideKeeper/RecyclingCenter.java
Normal file
100
src/sig/plugin/TwosideKeeper/RecyclingCenter.java
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
package sig.plugin.TwosideKeeper;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class RecyclingCenter {
|
||||||
|
//Each Recycling center has nodes which contain all the chests.
|
||||||
|
List<Location> nodes;
|
||||||
|
|
||||||
|
boolean choosing = false;
|
||||||
|
|
||||||
|
public RecyclingCenter() {
|
||||||
|
nodes = new ArrayList<Location>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddNode(World world, int locx,int locy,int locz) {
|
||||||
|
nodes.add(new Location(world,locx,locy,locz));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param numb The number in the list of the node you want.
|
||||||
|
* @return The Location of the node requested.
|
||||||
|
*/
|
||||||
|
public Location getNodeLocation(int numb) {
|
||||||
|
return nodes.get(numb);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getRandomNode() {
|
||||||
|
return nodes.get((int)(Math.floor(Math.random()*nodes.size())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumberOfNodes() {
|
||||||
|
return nodes.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean IsItemAllowed(ItemStack item) {
|
||||||
|
//Artifact type of items are not allowed to be sent to the Recycling Center.
|
||||||
|
if (Artifact.isArtifact(item)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadConfig() {
|
||||||
|
File config= new File(TwosideKeeper.filesave,"recyclingcenters.data");
|
||||||
|
if (config.exists()) {
|
||||||
|
Bukkit.getLogger().info("Config exists. Entering.");
|
||||||
|
FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
|
||||||
|
|
||||||
|
/*workable.addDefault("recyclingcenter.count", 0);
|
||||||
|
|
||||||
|
int total = workable.getInt("recyclingcenter.count");*/
|
||||||
|
//Bukkit.getLogger().info("Recycling center count: "+total+" ("+workable.getKeys(false).size()+")");
|
||||||
|
for (int i=0;i<workable.getKeys(false).size()/4;i++) {
|
||||||
|
this.AddNode(Bukkit.getWorld(workable.getString("world"+i)), workable.getInt("blockx"+i), workable.getInt("blocky"+i), workable.getInt("blockz"+1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChoosingRecyclingCenter(boolean choosing) {
|
||||||
|
this.choosing=choosing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isChoosingRecyclingCenter() {
|
||||||
|
return choosing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveConfig() {
|
||||||
|
File config;
|
||||||
|
config = new File(TwosideKeeper.filesave,"recyclingcenters.data");
|
||||||
|
FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
|
||||||
|
|
||||||
|
//workable.set("recycling_center.count", nodes.size());
|
||||||
|
|
||||||
|
for (int i=0;i<nodes.size();i++) {
|
||||||
|
workable.set("world"+i, nodes.get(i).getWorld().getName());
|
||||||
|
workable.set("blockx"+i, nodes.get(i).getBlockX());
|
||||||
|
workable.set("blocky"+i, nodes.get(i).getBlockY());
|
||||||
|
workable.set("blockz"+i, nodes.get(i).getBlockZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
workable.save(config);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
585
src/sig/plugin/TwosideKeeper/SpleefGame.java
Normal file
585
src/sig/plugin/TwosideKeeper/SpleefGame.java
Normal file
@ -0,0 +1,585 @@
|
|||||||
|
package sig.plugin.TwosideKeeper;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.StandardOpenOption;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.SpleefArena;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Chest;
|
||||||
|
|
||||||
|
public class SpleefGame implements Listener {
|
||||||
|
/*
|
||||||
|
* Contains information about a spleef game.
|
||||||
|
*/
|
||||||
|
boolean active = false; //Whether or not a game is on-going.
|
||||||
|
List<SpleefPlayerData> players = new ArrayList<SpleefPlayerData>(); //The players involved with this spleef game.
|
||||||
|
List<SpleefPlayerData> registered_players = new ArrayList<SpleefPlayerData>(); //The players involved with this spleef game.
|
||||||
|
TwosideKeeper plugin;
|
||||||
|
SpleefArena id; //The ID of this spleef game.
|
||||||
|
Location corner1; //The location of the first corner of the arena.
|
||||||
|
//Going outside it automatically terminates the game.
|
||||||
|
Location corner2; //The location of the second corner of the arena.
|
||||||
|
//Going outside it automatically terminates the game.
|
||||||
|
Location shovel_chest; //The location of the chest the spleef shovel is supposed to be in.
|
||||||
|
Location shovel_chest2; //The location of the chest the spleef shovel is supposed to be in.
|
||||||
|
Location sign; //The location of the sign to register for this spleef arena.
|
||||||
|
long registrationtime; //If it takes more than 60 seconds for players to register for a spleef game, the registration will be cancelled.
|
||||||
|
long starttime; //The starting time of the match.
|
||||||
|
long last_destroyed; //Time the last block was destroyed.
|
||||||
|
|
||||||
|
public SpleefGame(TwosideKeeper plug, SpleefArena id, Location corner1, Location corner2, Location shovel_chest, Location sign) {
|
||||||
|
this.plugin=plug;
|
||||||
|
this.id=id;
|
||||||
|
this.corner1=corner1;
|
||||||
|
this.corner2=corner2;
|
||||||
|
this.shovel_chest=shovel_chest;
|
||||||
|
this.sign=sign;
|
||||||
|
|
||||||
|
this.registrationtime=0;
|
||||||
|
}
|
||||||
|
public SpleefGame(TwosideKeeper plug, SpleefArena id, Location corner1, Location corner2, Location shovel_chest, Location shovel_chest2, Location sign) {
|
||||||
|
this.plugin=plug;
|
||||||
|
this.id=id;
|
||||||
|
this.corner1=corner1;
|
||||||
|
this.corner2=corner2;
|
||||||
|
this.shovel_chest=shovel_chest;
|
||||||
|
this.shovel_chest2=shovel_chest2;
|
||||||
|
this.sign=sign;
|
||||||
|
|
||||||
|
this.registrationtime=0;
|
||||||
|
}
|
||||||
|
public String toString() {
|
||||||
|
return "SpleefGame: "+id.toString()+" From "+this.corner1.toString()+" to "+this.corner2.toString()+".\n"
|
||||||
|
+ "Shovel Chest Loc: "+shovel_chest.toString()+";"+((shovel_chest2!=null)?"Shovel Chest 2 Loc: "+shovel_chest2.toString()+";":"")+ " Registration Sign Loc: "+sign.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EventListener(Event e) {
|
||||||
|
|
||||||
|
//A listener for all events passed here.
|
||||||
|
|
||||||
|
if (e instanceof BlockBreakEvent) {
|
||||||
|
BlockBreakEvent ev = (BlockBreakEvent)e;
|
||||||
|
|
||||||
|
if (active) {
|
||||||
|
|
||||||
|
if (ev.getBlock().getLocation().getBlockX()==corner1.getBlockX() ||
|
||||||
|
ev.getBlock().getLocation().getBlockX()==corner2.getBlockX() ||
|
||||||
|
ev.getBlock().getLocation().getBlockZ()==corner1.getBlockZ() ||
|
||||||
|
ev.getBlock().getLocation().getBlockZ()==corner2.getBlockZ()) {
|
||||||
|
//We are not allowed to break blocks on the borders.
|
||||||
|
//This is a border block. Prevent destruction.
|
||||||
|
ev.setCancelled(true);
|
||||||
|
}
|
||||||
|
if (BlockIsInside(ev.getBlock().getLocation(),corner1,corner2)) {
|
||||||
|
//This is a block inside the field. Now see if it's a registered player.
|
||||||
|
boolean not_allowed=true;
|
||||||
|
for (int i=0;i<registered_players.size();i++) {
|
||||||
|
if (ev.getPlayer().getName().equalsIgnoreCase(registered_players.get(i).player)) {
|
||||||
|
//This is allowed.
|
||||||
|
not_allowed=false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (not_allowed) {
|
||||||
|
ev.setCancelled(true); //Deny it, since they are not an actual participant!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!ev.isCancelled()) {
|
||||||
|
for (int i=0;i<players.size();i++) {
|
||||||
|
if (players.get(i).player.equalsIgnoreCase(ev.getPlayer().getName())) {
|
||||||
|
players.get(i).blocks_destroyed++;
|
||||||
|
last_destroyed=TwosideKeeper.getServerTickTime();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (e instanceof BlockPlaceEvent) {
|
||||||
|
BlockPlaceEvent ev = (BlockPlaceEvent)e;
|
||||||
|
|
||||||
|
if (active) {
|
||||||
|
if (BlockIsInside(ev.getBlock().getLocation(),corner1,corner2)) {
|
||||||
|
ev.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (e instanceof PlayerInteractEvent) {
|
||||||
|
PlayerInteractEvent ev = (PlayerInteractEvent)e;
|
||||||
|
//plugin.getLogger().info("Interact Event received, checking...");
|
||||||
|
if (ev.getAction()==Action.RIGHT_CLICK_BLOCK &&
|
||||||
|
ev.getClickedBlock()!=null &&
|
||||||
|
(ev.getClickedBlock().getType()==Material.SIGN ||
|
||||||
|
ev.getClickedBlock().getType()==Material.WALL_SIGN ||
|
||||||
|
ev.getClickedBlock().getType()==Material.SIGN_POST) && //Great, it's a sign. Make sure it's the correct sign.
|
||||||
|
ev.getClickedBlock().getLocation().getBlockX()==sign.getBlockX() &&
|
||||||
|
ev.getClickedBlock().getLocation().getBlockY()==sign.getBlockY() &&
|
||||||
|
ev.getClickedBlock().getLocation().getBlockZ()==sign.getBlockZ() ) {
|
||||||
|
//plugin.getLogger().info("This is a sign event.");
|
||||||
|
Block b = ev.getClickedBlock();
|
||||||
|
if (!active) {
|
||||||
|
//We are going to register this player to this spleef arena.
|
||||||
|
if (!IsSpleefPlayerRegistered(ev.getPlayer())) {
|
||||||
|
registrationtime=TwosideKeeper.getServerTickTime();
|
||||||
|
players.add(new SpleefPlayerData(plugin,ev.getPlayer()));
|
||||||
|
registered_players.add(new SpleefPlayerData(plugin,ev.getPlayer()));
|
||||||
|
//Determine if we are ready to play or not.
|
||||||
|
if (players.size()>=2) {
|
||||||
|
plugin.getServer().broadcastMessage(ChatColor.GOLD+"Player "+ChatColor.GREEN+ev.getPlayer().getName()+ChatColor.GOLD+" has registered to play in the "+ChatColor.AQUA+id.toString()+ChatColor.GOLD+" Spleef Arena!");
|
||||||
|
plugin.getServer().broadcastMessage(ChatColor.BLUE+" 10 seconds left to register!");
|
||||||
|
starttime=TwosideKeeper.getServerTickTime()+200;
|
||||||
|
} else { //We only have one player. Wait for more.
|
||||||
|
plugin.getServer().broadcastMessage(ChatColor.GOLD+"Player "+ChatColor.GREEN+ev.getPlayer().getName()+ChatColor.GOLD+" has registered to play in the "+ChatColor.AQUA+id.toString()+ChatColor.GOLD+" Spleef Arena!");
|
||||||
|
plugin.getServer().broadcastMessage(ChatColor.BLUE+" Looking for at least one more player!");
|
||||||
|
//De-register from other Spleef Arenas.
|
||||||
|
for (int i=0;i<TwosideKeeper.TwosideSpleefGames.GetSpleefGames().size();i++) {
|
||||||
|
if (TwosideKeeper.TwosideSpleefGames.GetSpleefGames().get(i).id!=id) {
|
||||||
|
//This is not ours. See if this player is registered here. De-register him/her.
|
||||||
|
for (int j=0;j<TwosideKeeper.TwosideSpleefGames.GetSpleefGames().get(i).players.size();j++) {
|
||||||
|
if (TwosideKeeper.TwosideSpleefGames.GetSpleefGames().get(i).players.get(j).player.equalsIgnoreCase(ev.getPlayer().getName())) {
|
||||||
|
TwosideKeeper.TwosideSpleefGames.GetSpleefGames().get(i).players.remove(j);
|
||||||
|
TwosideKeeper.TwosideSpleefGames.GetSpleefGames().get(i).registered_players.remove(j);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ev.getPlayer().sendMessage(ChatColor.GOLD+"Sorry! There is a game currently in progress. Registrations are closed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (e instanceof PlayerQuitEvent) {
|
||||||
|
PlayerQuitEvent ev = (PlayerQuitEvent)e;
|
||||||
|
//If this player leaves in the middle of a Spleef game, we have to resolve the game's winner.
|
||||||
|
//Give this player back their stuff.
|
||||||
|
if (active) {
|
||||||
|
RemovePlayer(ev.getPlayer(), RemovePlayerReason.QUIT);
|
||||||
|
if (players.size()==1) {
|
||||||
|
//This means there's not enough players to continue the match. End the match, passing the remaining player.
|
||||||
|
EndMatch(players.get(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Tick() {
|
||||||
|
//A tick that occurs once every second.
|
||||||
|
if (!active && players.size()>=2 && starttime<=TwosideKeeper.getServerTickTime())
|
||||||
|
{ //Start the game!
|
||||||
|
//Teleport players to the arena at a random position, clear their inventories,
|
||||||
|
//set their health, and their hunger.
|
||||||
|
//Setup the arena with the proper blocks, if the dirt blocks are not filled in already.
|
||||||
|
if (corner1.getBlockX()>corner2.getBlockX()) {
|
||||||
|
if (corner1.getBlockZ()>corner2.getBlockZ()) {
|
||||||
|
for (int i=corner2.getBlockX();i<=corner1.getBlockX();i++) {
|
||||||
|
for (int j=corner2.getBlockZ();j<=corner1.getBlockZ();j++) {
|
||||||
|
if (Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j)!=null &&
|
||||||
|
Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j).getType()==Material.AIR) {
|
||||||
|
Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j).setType(Material.DIRT);
|
||||||
|
}
|
||||||
|
if (id==SpleefArena.LAYERED &&
|
||||||
|
i!=corner2.getBlockX() &&
|
||||||
|
i!=corner1.getBlockX() &&
|
||||||
|
j!=corner1.getBlockZ() &&
|
||||||
|
j!=corner2.getBlockZ()) {
|
||||||
|
for (int k=0;k<3;k++) {
|
||||||
|
Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY()+k+1,j).setType(Material.GRAVEL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i=corner2.getBlockX();i<=corner1.getBlockX();i++) {
|
||||||
|
for (int j=corner1.getBlockZ();j<=corner2.getBlockZ();j++) {
|
||||||
|
if (Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j)!=null &&
|
||||||
|
Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j).getType()==Material.AIR) {
|
||||||
|
Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j).setType(Material.DIRT);
|
||||||
|
}
|
||||||
|
if (id==SpleefArena.LAYERED &&
|
||||||
|
i!=corner2.getBlockX() &&
|
||||||
|
i!=corner1.getBlockX() &&
|
||||||
|
j!=corner1.getBlockZ() &&
|
||||||
|
j!=corner2.getBlockZ()) {
|
||||||
|
for (int k=0;k<3;k++) {
|
||||||
|
Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY()+k+1,j).setType(Material.GRAVEL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (corner1.getBlockZ()>corner2.getBlockZ()) {
|
||||||
|
for (int i=corner1.getBlockX();i<=corner2.getBlockX();i++) {
|
||||||
|
for (int j=corner2.getBlockZ();j<=corner1.getBlockZ();j++) {
|
||||||
|
if (Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j)!=null &&
|
||||||
|
Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j).getType()==Material.AIR) {
|
||||||
|
Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j).setType(Material.DIRT);
|
||||||
|
}
|
||||||
|
if (id==SpleefArena.LAYERED &&
|
||||||
|
i!=corner2.getBlockX() &&
|
||||||
|
i!=corner1.getBlockX() &&
|
||||||
|
j!=corner1.getBlockZ() &&
|
||||||
|
j!=corner2.getBlockZ()) {
|
||||||
|
for (int k=0;k<3;k++) {
|
||||||
|
Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY()+k+1,j).setType(Material.GRAVEL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i=corner1.getBlockX();i<=corner2.getBlockX();i++) {
|
||||||
|
for (int j=corner1.getBlockZ();j<=corner2.getBlockZ();j++) {
|
||||||
|
if (Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j)!=null &&
|
||||||
|
Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j).getType()==Material.AIR) {
|
||||||
|
Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j).setType(Material.DIRT);
|
||||||
|
}
|
||||||
|
if (id==SpleefArena.LAYERED &&
|
||||||
|
i!=corner2.getBlockX() &&
|
||||||
|
i!=corner1.getBlockX() &&
|
||||||
|
j!=corner1.getBlockZ() &&
|
||||||
|
j!=corner2.getBlockZ()) {
|
||||||
|
for (int k=0;k<3;k++) {
|
||||||
|
Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY()+k+1,j).setType(Material.GRAVEL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//For the block above the chest, turn it into a wooden plank.
|
||||||
|
Bukkit.getWorld("world").getBlockAt(shovel_chest.clone().add(0,1,0)).setType(Material.WOOD);
|
||||||
|
//Insert a Spleef shovel in the chest.
|
||||||
|
//We will clear out the contents first.
|
||||||
|
if (Bukkit.getWorld("world").getBlockAt(shovel_chest).getState() instanceof Chest) {
|
||||||
|
Chest spleef_chest = (Chest)Bukkit.getWorld("world").getBlockAt(shovel_chest).getState();
|
||||||
|
spleef_chest.getInventory().clear();
|
||||||
|
spleef_chest.getInventory().setItem((int)(Math.random()*27), new ItemStack(Material.WOOD_SPADE));
|
||||||
|
}
|
||||||
|
//And a second one if it exists.
|
||||||
|
if (shovel_chest2!=null) {
|
||||||
|
Bukkit.getWorld("world").getBlockAt(shovel_chest2.clone().add(0,1,0)).setType(Material.WOOD);
|
||||||
|
if (Bukkit.getWorld("world").getBlockAt(shovel_chest2).getState() instanceof Chest) {
|
||||||
|
Chest spleef_chest2 = (Chest)Bukkit.getWorld("world").getBlockAt(shovel_chest2).getState();
|
||||||
|
spleef_chest2.getInventory().clear();
|
||||||
|
spleef_chest2.getInventory().setItem((int)(Math.random()*27), new ItemStack(Material.WOOD_SPADE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Insert spleef shovel into the chest~!
|
||||||
|
|
||||||
|
String matchup=""; //Set the string for the match-up.
|
||||||
|
for (int i=0;i<players.size();i++) {
|
||||||
|
players.get(i).SaveInventory();
|
||||||
|
players.get(i).ClearInventory();
|
||||||
|
|
||||||
|
if (matchup.equalsIgnoreCase("")) {
|
||||||
|
matchup+=players.get(i).player;
|
||||||
|
} else {
|
||||||
|
if (players.size()==2) {
|
||||||
|
matchup+=" and "+players.get(i).player;
|
||||||
|
} else {
|
||||||
|
matchup+=", "+players.get(i).player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Heal the player.
|
||||||
|
Bukkit.getServer().getPlayer(players.get(i).player).setHealth(Bukkit.getServer().getPlayer(players.get(i).player).getMaxHealth());
|
||||||
|
Bukkit.getServer().getPlayer(players.get(i).player).setFoodLevel(20);
|
||||||
|
//Teleport to a random location inside the arena.
|
||||||
|
Bukkit.getServer().getPlayer(players.get(i).player).teleport(new Location(
|
||||||
|
Bukkit.getWorld("world"),
|
||||||
|
(corner1.getBlockX()>corner2.getBlockX())?(corner1.getBlockX()-2-(Math.random()*(corner1.getBlockX()-corner2.getBlockX()-4))):(corner2.getBlockX()-2-(Math.random()*(corner2.getBlockX()-corner1.getBlockX()-4))),
|
||||||
|
(corner1.getBlockY()>corner2.getBlockY())?(corner1.getBlockY()+4):(corner2.getBlockY()+4),
|
||||||
|
(corner1.getBlockZ()>corner2.getBlockZ())?(corner1.getBlockZ()-2-(Math.random()*(corner1.getBlockZ()-corner2.getBlockZ()-4))):(corner2.getBlockZ()-2-(Math.random()*(corner2.getBlockZ()-corner1.getBlockZ()-4)))
|
||||||
|
), TeleportCause.PLUGIN);
|
||||||
|
//Give players Resistance 100 so they can never die.
|
||||||
|
Bukkit.getServer().getPlayer(players.get(i).player).addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,100));
|
||||||
|
}
|
||||||
|
active=true;
|
||||||
|
starttime=TwosideKeeper.getServerTickTime();
|
||||||
|
//registered_players=players; //Registered players include every single player that joined in. This is to manage ranking and
|
||||||
|
//who is allowed to help break blocks after losing.
|
||||||
|
last_destroyed=TwosideKeeper.getServerTickTime();
|
||||||
|
|
||||||
|
Bukkit.getServer().broadcastMessage(ChatColor.GOLD+"The spleef matchup between "+ChatColor.GREEN+matchup+ChatColor.GOLD+" has begun!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (active && starttime+100<TwosideKeeper.getServerTickTime()) {
|
||||||
|
for (int i=0;i<players.size();i++) {
|
||||||
|
if (players.get(i).IsOutOfBounds(corner1, corner2)) {
|
||||||
|
RemovePlayer(players.get(i), RemovePlayerReason.OUTOFBOUNDS);
|
||||||
|
if (players.size()==1) {
|
||||||
|
//This means there's not enough players to continue the match. End the match, passing the remaining player.
|
||||||
|
EndMatch(players.get(0));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (active && last_destroyed+600<TwosideKeeper.getServerTickTime()) {
|
||||||
|
//This match has come to a stall, determine the winner based on block destruction count.
|
||||||
|
SpleefPlayerData winner = null;
|
||||||
|
int highest_count=-1;
|
||||||
|
for (int i=0;i<players.size();i++) {
|
||||||
|
if (players.get(i).blocks_destroyed>highest_count) {
|
||||||
|
highest_count=players.get(i).blocks_destroyed;
|
||||||
|
winner=players.get(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getServer().broadcastMessage(ChatColor.GOLD+"The Spleef Match has stalled, and the winner has been decided!");
|
||||||
|
Bukkit.getServer().broadcastMessage(ChatColor.BLUE+""+ChatColor.ITALIC+" With "+ChatColor.GREEN+highest_count+ChatColor.BLUE+" blocks destroyed...");
|
||||||
|
//We will have the winner. End the Match.
|
||||||
|
if (winner!=null) {
|
||||||
|
EndMatch(winner);
|
||||||
|
} else {
|
||||||
|
EndMatch(players.get(0)); //Something went wrong??
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemovePlayer(Player p, RemovePlayerReason rs) {
|
||||||
|
for (int i=0;i<players.size();i++) {
|
||||||
|
if (players.get(i).player.equalsIgnoreCase(p.getName())) {
|
||||||
|
//Give this player their inventory contents back.
|
||||||
|
RemovePlayer(players.get(i), rs);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void RemovePlayer(SpleefPlayerData p, RemovePlayerReason rs) {
|
||||||
|
p.ClearInventory();
|
||||||
|
p.RestoreInventory();
|
||||||
|
Bukkit.getServer().getPlayer(p.player).removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
|
||||||
|
for (int i=0;i<players.size();i++) {
|
||||||
|
if (players.get(i).player.equalsIgnoreCase(p.player)) {
|
||||||
|
players.remove(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Bukkit.getServer().getPlayer(p.player).teleport(new Location(
|
||||||
|
Bukkit.getWorld("world"),
|
||||||
|
(corner1.getBlockX()>corner2.getBlockX())?(corner1.getBlockX()-(Math.random()*(corner1.getBlockX()-corner2.getBlockX()))):(corner2.getBlockX()-(Math.random()*(corner2.getBlockX()-corner1.getBlockX()))),
|
||||||
|
(corner1.getBlockY()>corner2.getBlockY())?(corner1.getBlockY()-2):(corner2.getBlockY()-2),
|
||||||
|
(corner1.getBlockZ()>corner2.getBlockZ())?(corner1.getBlockZ()-(Math.random()*(corner1.getBlockZ()-corner2.getBlockZ()))):(corner2.getBlockZ()-(Math.random()*(corner2.getBlockZ()-corner1.getBlockZ())))
|
||||||
|
), TeleportCause.PLUGIN);
|
||||||
|
if (rs==RemovePlayerReason.OUTOFBOUNDS ||
|
||||||
|
rs==RemovePlayerReason.QUIT) {
|
||||||
|
for (int i=0;i<TwosideKeeper.playerdata.size();i++) {
|
||||||
|
PlayerStructure pd = TwosideKeeper.playerdata.get(i);
|
||||||
|
if (pd.name.equalsIgnoreCase(p.player)) {
|
||||||
|
pd.spleef_pts+=registered_players.size()-players.size()-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Bukkit.getServer().broadcastMessage(ChatColor.GREEN+p.player+ChatColor.GOLD+" "+ChatColor.ITALIC+"has been knocked out of this round of Spleef!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndMatch(SpleefPlayerData winner) {
|
||||||
|
//Ends the match, resolving all players, winners, and giving everything back.
|
||||||
|
//Bukkit.getServer().getLogger().info("There are "+players.size()+" players in the registered player list.");
|
||||||
|
for (int i=0;i<players.size();i++) {
|
||||||
|
//Give all players' items back. Remove the damage resistance buff.
|
||||||
|
RemovePlayer(players.get(i), RemovePlayerReason.GENERAL);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
for (int i=0;i<TwosideKeeper.playerdata.size();i++) {
|
||||||
|
PlayerStructure pd = TwosideKeeper.playerdata.get(i);
|
||||||
|
if (pd.name.equalsIgnoreCase(winner.player)) {
|
||||||
|
pd.spleef_pts+=registered_players.size();
|
||||||
|
pd.spleef_wins+=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
registered_players.clear();
|
||||||
|
Bukkit.getServer().broadcastMessage(ChatColor.GOLD+"Congratulations to Player "+ChatColor.GREEN+winner.player+ChatColor.GOLD+" for winning this round of Spleef!");
|
||||||
|
active=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean IsSpleefPlayerRegistered(Player p) {
|
||||||
|
//Returns if the player specified is already registered to the Spleef Game or not.
|
||||||
|
for (int i=0;i<players.size();i++) {
|
||||||
|
if (players.get(i).player.equalsIgnoreCase(p.getName())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean BlockIsInside(Location l, Location b1, Location b2) {
|
||||||
|
if (b1.getBlockX()>b2.getBlockX()) {
|
||||||
|
if (b1.getBlockZ()>b2.getBlockZ()) {
|
||||||
|
if (l.getBlockX()>b2.getBlockX() &&
|
||||||
|
l.getBlockX()<b1.getBlockX() &&
|
||||||
|
l.getBlockZ()>b2.getBlockZ() &&
|
||||||
|
l.getBlockZ()<b1.getBlockZ()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (l.getBlockX()>b2.getBlockX() &&
|
||||||
|
l.getBlockX()<b1.getBlockX() &&
|
||||||
|
l.getBlockZ()<b2.getBlockZ() &&
|
||||||
|
l.getBlockZ()>b1.getBlockZ()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (b1.getBlockZ()>b2.getBlockZ()) {
|
||||||
|
if (l.getBlockX()<b2.getBlockX() &&
|
||||||
|
l.getBlockX()>b1.getBlockX() &&
|
||||||
|
l.getBlockZ()>b2.getBlockZ() &&
|
||||||
|
l.getBlockZ()<b1.getBlockZ()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (l.getBlockX()<b2.getBlockX() &&
|
||||||
|
l.getBlockX()>b1.getBlockX() &&
|
||||||
|
l.getBlockZ()<b2.getBlockZ() &&
|
||||||
|
l.getBlockZ()>b1.getBlockZ()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum RemovePlayerReason {
|
||||||
|
QUIT,OUTOFBOUNDS,GENERAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SpleefPlayerData {
|
||||||
|
String player; //The name of the player.
|
||||||
|
ItemStack player_equipment_helmet;
|
||||||
|
ItemStack player_equipment_chestplate;
|
||||||
|
ItemStack player_equipment_leggings;
|
||||||
|
ItemStack player_equipment_boots;
|
||||||
|
ItemStack player_equipment_shield;
|
||||||
|
List<ItemStack> player_inventory = new ArrayList<ItemStack>();
|
||||||
|
TwosideKeeper plug;
|
||||||
|
int blocks_destroyed;
|
||||||
|
SpleefPlayerData(TwosideKeeper plug, Player player) {
|
||||||
|
this.plug=plug;
|
||||||
|
this.player=player.getName();
|
||||||
|
this.blocks_destroyed=0;
|
||||||
|
/*
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
public void RestoreInventory() {
|
||||||
|
//Gives the player back their inventory.
|
||||||
|
for (int i=0;i<player_inventory.size();i++) {
|
||||||
|
if (player_inventory.get(i)!=null) {
|
||||||
|
plug.getServer().getPlayer(this.player).getInventory().setItem(i, player_inventory.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
plug.getServer().getPlayer(this.player).getInventory().setExtraContents(player_inven2);
|
||||||
|
plug.getServer().getPlayer(this.player).getInventory().setStorageContents(player_inven1);
|
||||||
|
plug.getServer().getPlayer(this.player).getInventory().setArmorContents(player_equipment);*/
|
||||||
|
|
||||||
|
}
|
||||||
|
public void SaveInventory() {
|
||||||
|
/*
|
||||||
|
for (int i=0;i<plug.getServer().getPlayer(this.player).getInventory().getContents().length;i++) {
|
||||||
|
if (plug.getServer().getPlayer(this.player).getInventory().getContents()[i]!=null &&
|
||||||
|
plug.getServer().getPlayer(this.player).getInventory().getExtr) {
|
||||||
|
player_inventory.add(plug.getServer().getPlayer(this.player).getInventory().getContents()[i]);
|
||||||
|
plug.getLogger().info("Store item "+plug.getServer().getPlayer(this.player).getInventory().getContents()[i].toString());
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
File file = new File(this.plug.getDataFolder()+"/inventorybackup/inventory"+plug.getServer().getPlayer(this.player).getName()+".txt");
|
||||||
|
|
||||||
|
// if file doesnt exists, then create it
|
||||||
|
if (!file.exists()) {
|
||||||
|
try {
|
||||||
|
file.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try(
|
||||||
|
FileWriter fw = new FileWriter(this.plug.getDataFolder()+"/inventorybackup/inventory"+plug.getServer().getPlayer(this.player).getName()+".txt", true);
|
||||||
|
BufferedWriter bw = new BufferedWriter(fw);)
|
||||||
|
{
|
||||||
|
for (int i=0;i<plug.getServer().getPlayer(this.player).getInventory().getSize();i++) {
|
||||||
|
player_inventory.add(plug.getServer().getPlayer(this.player).getInventory().getItem(i));
|
||||||
|
if (plug.getServer().getPlayer(this.player).getInventory().getItem(i)!=null) {
|
||||||
|
bw.write(plug.getServer().getPlayer(this.player).getInventory().getItem(i).toString());
|
||||||
|
bw.newLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bw.newLine();
|
||||||
|
bw.write("---"+plug.getServerTickTime());
|
||||||
|
bw.newLine();bw.newLine();
|
||||||
|
bw.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
//exception handling left as an exercise for the reader
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void ClearInventory() {
|
||||||
|
plug.getServer().getPlayer(this.player).getInventory().clear();
|
||||||
|
}
|
||||||
|
public boolean IsOutOfBounds(Location corner1, Location corner2) {
|
||||||
|
Player p = plug.getServer().getPlayer(this.player);
|
||||||
|
int xbound1=(corner1.getBlockX()>corner2.getBlockX())?corner2.getBlockX():corner1.getBlockX(),
|
||||||
|
xbound2=(corner1.getBlockX()>corner2.getBlockX())?corner1.getBlockX():corner2.getBlockX(),
|
||||||
|
zbound1=(corner1.getBlockZ()>corner2.getBlockZ())?corner2.getBlockZ():corner1.getBlockZ(),
|
||||||
|
zbound2=(corner1.getBlockZ()>corner2.getBlockZ())?corner1.getBlockZ():corner2.getBlockZ();
|
||||||
|
if (p.getLocation().getBlockX()<=xbound1 ||
|
||||||
|
p.getLocation().getBlockX()>=xbound2 ||
|
||||||
|
p.getLocation().getBlockZ()<=zbound1 ||
|
||||||
|
p.getLocation().getBlockZ()>=zbound2 ||
|
||||||
|
p.getLocation().getBlockY()<corner1.getBlockY()+0.5) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
58
src/sig/plugin/TwosideKeeper/SpleefManager.java
Normal file
58
src/sig/plugin/TwosideKeeper/SpleefManager.java
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package sig.plugin.TwosideKeeper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.SpleefArena;
|
||||||
|
|
||||||
|
public class SpleefManager {
|
||||||
|
/*
|
||||||
|
* Manages all spleef games.
|
||||||
|
* Contains an array for every type of spleef game available
|
||||||
|
* along with a SpleefGame structure.
|
||||||
|
*/
|
||||||
|
List<SpleefGame> spleef_game_list;
|
||||||
|
TwosideKeeper plugin;
|
||||||
|
public SpleefManager(TwosideKeeper plug) {
|
||||||
|
plugin = plug;
|
||||||
|
spleef_game_list = new ArrayList<SpleefGame>();
|
||||||
|
}
|
||||||
|
public List<SpleefGame> GetSpleefGames() {
|
||||||
|
return spleef_game_list;
|
||||||
|
}
|
||||||
|
public List<SpleefGame> GetActiveSpleefGames() {
|
||||||
|
List<SpleefGame> active_spleef_game_list = new ArrayList<SpleefGame>();
|
||||||
|
for (int i=0;i<spleef_game_list.size();i++) {
|
||||||
|
if (spleef_game_list.get(i).isActive()) {
|
||||||
|
active_spleef_game_list.add(spleef_game_list.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return active_spleef_game_list;
|
||||||
|
}
|
||||||
|
public void SetupSpleefArena(SpleefArena id,Location corner1,Location corner2,Location shovel_block, Location register_sign) {
|
||||||
|
SpleefGame newGame = new SpleefGame(plugin, id, corner1,corner2,shovel_block,register_sign);
|
||||||
|
spleef_game_list.add(newGame);
|
||||||
|
plugin.getLogger().info("Added new SpleefGame: "+newGame.toString());
|
||||||
|
}
|
||||||
|
public void SetupSpleefArena(SpleefArena id, Location corner1, Location corner2, Location shovel_block, Location shovel_block2, Location register_sign) {
|
||||||
|
SpleefGame newGame = new SpleefGame(plugin, id, corner1,corner2,shovel_block,shovel_block2,register_sign);
|
||||||
|
spleef_game_list.add(newGame);
|
||||||
|
plugin.getLogger().info("Added new SpleefGame: "+newGame.toString());
|
||||||
|
}
|
||||||
|
public void PassEvent(Event e) {
|
||||||
|
//Passes events in the world to all Spleef Games.
|
||||||
|
for (int i=0;i<spleef_game_list.size();i++) {
|
||||||
|
spleef_game_list.get(i).EventListener(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void TickEvent() {
|
||||||
|
//Indicates a tick event from the server (once per second)
|
||||||
|
for (int i=0;i<spleef_game_list.size();i++) {
|
||||||
|
spleef_game_list.get(i).Tick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5776
src/sig/plugin/TwosideKeeper/TwosideKeeper.java
Normal file
5776
src/sig/plugin/TwosideKeeper/TwosideKeeper.java
Normal file
File diff suppressed because it is too large
Load Diff
73
src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java
Normal file
73
src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package sig.plugin.TwosideKeeper;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Monster;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.MonsterDifficulty;
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.MonsterType;
|
||||||
|
|
||||||
|
public final class TwosideKeeperAPI {
|
||||||
|
//MONEY COMMANDS.
|
||||||
|
public static void givePlayerMoney(Player p, double amt) {
|
||||||
|
TwosideKeeper.givePlayerMoney(p, amt);
|
||||||
|
}
|
||||||
|
public static void givePlayerMoney(String p, double amt) {
|
||||||
|
TwosideKeeper.givePlayerMoney(p, amt);
|
||||||
|
}
|
||||||
|
public static double getPlayerMoney(Player p) {
|
||||||
|
return TwosideKeeper.getPlayerMoney(p);
|
||||||
|
}
|
||||||
|
public static double getPlayerMoney(String p) {
|
||||||
|
return TwosideKeeper.getPlayerMoney(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
//BANK COMMANDS.
|
||||||
|
public static void givePlayerBankMoney(Player p, double amt) {
|
||||||
|
TwosideKeeper.givePlayerBankMoney(p, amt);
|
||||||
|
}
|
||||||
|
public static void givePlayerBankMoney(String p, double amt) {
|
||||||
|
TwosideKeeper.givePlayerBankMoney(p, amt);
|
||||||
|
}
|
||||||
|
public static double getPlayerBankMoney(Player p) {
|
||||||
|
return TwosideKeeper.getPlayerBankMoney(p);
|
||||||
|
}
|
||||||
|
public static double getPlayerBankMoney(String p) {
|
||||||
|
return TwosideKeeper.getPlayerBankMoney(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
//MONSTER COMMANDS.
|
||||||
|
public static Monster spawnAdjustedMonster(MonsterType mt,Location loc) {
|
||||||
|
return MonsterController.spawnAdjustedMonster(mt,loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Monster autoAdjustMonster(Monster m) {
|
||||||
|
return MonsterController.convertMonster(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Monster adjustMonsterDifficulty(Monster m, MonsterDifficulty newdiff) {
|
||||||
|
return MonsterController.convertMonster(m,newdiff);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MonsterDifficulty getMonsterDifficulty(Monster m) {
|
||||||
|
return MonsterController.getMonsterDifficulty(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Hardened Item Commands.
|
||||||
|
public static boolean isHardenedItem(ItemStack i) {
|
||||||
|
return TwosideKeeper.isHardenedItem(i);
|
||||||
|
}
|
||||||
|
public static int getHardenedItemBreaks(ItemStack i) {
|
||||||
|
return TwosideKeeper.getHardenedItemBreaks(i);
|
||||||
|
}
|
||||||
|
public static ItemStack breakHardenedItem(ItemStack i) {
|
||||||
|
return TwosideKeeper.breakHardenedItem(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Friendly Name COMMANDS.
|
||||||
|
public static String getLocalizedItemName(ItemStack i) {
|
||||||
|
return TwosideKeeper.UserFriendlyMaterialName(i);
|
||||||
|
}
|
||||||
|
}
|
179
src/sig/plugin/TwosideKeeper/WorldShopManager.java
Normal file
179
src/sig/plugin/TwosideKeeper/WorldShopManager.java
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
package sig.plugin.TwosideKeeper;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.SessionState;
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.ShopPurchase;
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.WorldShop;
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.WorldShopSession;
|
||||||
|
|
||||||
|
public class WorldShopManager {
|
||||||
|
List<WorldShopSession> sessions = new ArrayList<WorldShopSession>();
|
||||||
|
List<ShopPurchase> purchases = new ArrayList<ShopPurchase>();
|
||||||
|
|
||||||
|
//Save itemstack in file.
|
||||||
|
//Reference an ID.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a World shop.
|
||||||
|
* @param s The sign the shop is created on.
|
||||||
|
* @param item The item being sold.
|
||||||
|
* @param price The unit price of the item.
|
||||||
|
* @param owner Owner of the shop.
|
||||||
|
*/
|
||||||
|
public WorldShop CreateWorldShop(Sign s, ItemStack item, int amt, double price, String owner) {
|
||||||
|
//Convert the sign.
|
||||||
|
String[] lines = s.getLines();
|
||||||
|
List<String> sign_lines = new ArrayList<String>();
|
||||||
|
WorldShop newshop = new WorldShop(item, amt, price, owner, TwosideKeeper.WORLD_SHOP_ID);
|
||||||
|
if (lines[0].equalsIgnoreCase("shop")) {
|
||||||
|
UpdateSign(newshop, TwosideKeeper.WORLD_SHOP_ID, s);
|
||||||
|
}
|
||||||
|
TwosideKeeper.WORLD_SHOP_ID++;
|
||||||
|
return newshop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateSign(WorldShop shop, int id, Sign s) {
|
||||||
|
//Convert the sign.
|
||||||
|
String[] lines = s.getLines();
|
||||||
|
List<String> sign_lines = new ArrayList<String>();
|
||||||
|
//Create a shop out of this.
|
||||||
|
sign_lines.add(ChatColor.BLUE+"-- SHOP --");
|
||||||
|
if (shop.GetItem().hasItemMeta() &&
|
||||||
|
shop.GetItem().getItemMeta().hasDisplayName()) {
|
||||||
|
sign_lines.add(shop.GetItem().getItemMeta().getDisplayName());
|
||||||
|
} else {
|
||||||
|
sign_lines.add(TwosideKeeper.UserFriendlyMaterialName(shop.GetItem()));
|
||||||
|
}
|
||||||
|
DecimalFormat df = new DecimalFormat("0.00");
|
||||||
|
sign_lines.add("$"+df.format(shop.GetUnitPrice())+ChatColor.DARK_BLUE+" [x"+shop.GetAmount()+"]");
|
||||||
|
DecimalFormat df2 = new DecimalFormat("000000");
|
||||||
|
sign_lines.add(ChatColor.DARK_GRAY+df2.format(id));
|
||||||
|
for (int i=0;i<4;i++) {
|
||||||
|
s.setLine(i, sign_lines.get(i));
|
||||||
|
}
|
||||||
|
s.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetShopID(Sign s) {
|
||||||
|
return Integer.parseInt(s.getLines()[3].replace(ChatColor.DARK_GRAY+"", ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldShop LoadWorldShopData(int id) {
|
||||||
|
File config;
|
||||||
|
config = new File(TwosideKeeper.filesave,"worldshop.data");
|
||||||
|
FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
|
||||||
|
|
||||||
|
return new WorldShop(workable.getItemStack("item"+id),workable.getInt("amt"+id),workable.getDouble("item_price"+id),workable.getString("owner"+id),id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveWorldShopData(WorldShop shop) {
|
||||||
|
File config;
|
||||||
|
config = new File(TwosideKeeper.filesave,"worldshop.data");
|
||||||
|
FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
|
||||||
|
|
||||||
|
int id = shop.getID();
|
||||||
|
|
||||||
|
workable.set("item"+id,shop.GetItem());
|
||||||
|
workable.set("item_price"+id,shop.GetUnitPrice());
|
||||||
|
workable.set("amt"+id,shop.GetAmount());
|
||||||
|
workable.set("owner"+id,shop.GetOwner());
|
||||||
|
|
||||||
|
try {
|
||||||
|
workable.save(config);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public List<WorldShopSession> GetSessions() {
|
||||||
|
return sessions;
|
||||||
|
}
|
||||||
|
public WorldShopSession GetSession(int session) {
|
||||||
|
return sessions.get(session);
|
||||||
|
}
|
||||||
|
public WorldShopSession GetSession(Player p) {
|
||||||
|
return sessions.get(GetPlayerTerminal(p));
|
||||||
|
}
|
||||||
|
public boolean IsPlayerUsingTerminal(Player p) {
|
||||||
|
for (int i=0;i<sessions.size();i++) {
|
||||||
|
if (sessions.get(i).GetPlayer().equals(p)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int GetPlayerTerminal(Player p) {
|
||||||
|
if (p!=null) {
|
||||||
|
for (int i=0;i<sessions.size();i++) {
|
||||||
|
if (sessions.get(i).GetPlayer().equals(p)) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
public WorldShopSession AddSession(SessionState type, Player p, Sign s) {
|
||||||
|
WorldShopSession sss = new WorldShopSession(p, TwosideKeeper.getServerTickTime(), type, s);
|
||||||
|
sessions.add(sss);
|
||||||
|
return sss;
|
||||||
|
}
|
||||||
|
public void UpdateSession(SessionState type, Player p) {
|
||||||
|
int term = GetPlayerTerminal(p);
|
||||||
|
if (term!=-1) {
|
||||||
|
WorldShopSession ss = sessions.get(term);
|
||||||
|
ss.SetSession(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void UpdateSession(WorldShopSession ss, SessionState type) {
|
||||||
|
ss.SetSession(type);
|
||||||
|
}
|
||||||
|
public void RemoveSession(Player p) {
|
||||||
|
int term = GetPlayerTerminal(p);
|
||||||
|
if (term!=-1) {
|
||||||
|
sessions.remove(term);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void RemoveSession(WorldShopSession ss) {
|
||||||
|
sessions.remove(ss);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddNewPurchase(String owner, Player purchaser, ItemStack item, double price, int amt) {
|
||||||
|
purchases.add(new ShopPurchase(owner, purchaser, item, price, amt));
|
||||||
|
}
|
||||||
|
public boolean PlayerHasPurchases(Player p) {
|
||||||
|
for (int i=0;i<purchases.size();i++) {
|
||||||
|
if (p.getName().equalsIgnoreCase(purchases.get(i).getPlayer())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public void PlayerSendPurchases(Player p) {
|
||||||
|
for (int i=0;i<purchases.size();i++) {
|
||||||
|
if (p.getName().equalsIgnoreCase(purchases.get(i).getPlayer())) {
|
||||||
|
p.sendMessage(purchases.get(i).announcementString());
|
||||||
|
purchases.remove(i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Cleanup() {
|
||||||
|
//Removes all shop sessions.
|
||||||
|
sessions.clear();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user