Merge remote-tracking branch 'origin/master' into foo

This commit is contained in:
fooify 2015-12-03 16:31:16 -08:00
commit 348f2d8e4c
78 changed files with 2253 additions and 1162 deletions

View File

@ -0,0 +1,132 @@
package mineplex.core.common.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
public class NautArrayList<Elem>
{
private ArrayList<Elem> _wrappedArrayList = new ArrayList<Elem>();
public boolean add(Elem elem)
{
return _wrappedArrayList.add(elem);
}
public void add(int index, Elem elem)
{
_wrappedArrayList.add(index, elem);
}
public boolean addAll(Collection<? extends Elem> elements)
{
return _wrappedArrayList.addAll(elements);
}
public boolean addAll(int index, Collection<? extends Elem> elements)
{
return _wrappedArrayList.addAll(index, elements);
}
public void clear()
{
_wrappedArrayList.clear();
}
public boolean contains(Elem elem)
{
return _wrappedArrayList.contains(elem);
}
public boolean containsAll(Collection<? extends Elem> elements)
{
return _wrappedArrayList.containsAll(elements);
}
public Elem get(int index)
{
return _wrappedArrayList.get(index);
}
public boolean equals(Object o)
{
return _wrappedArrayList.equals(o);
}
public int hashCode()
{
return _wrappedArrayList.hashCode();
}
public int indexOf(Elem elem)
{
return _wrappedArrayList.indexOf(elem);
}
public boolean isEmpty()
{
return _wrappedArrayList.isEmpty();
}
public Iterator<Elem> iterator()
{
return _wrappedArrayList.iterator();
}
public int lastIndexOf(Elem elem)
{
return _wrappedArrayList.lastIndexOf(elem);
}
public ListIterator<Elem> listIterator()
{
return _wrappedArrayList.listIterator();
}
public ListIterator<Elem> listIterator(int index)
{
return _wrappedArrayList.listIterator(index);
}
public Elem remove(int index)
{
return _wrappedArrayList.remove(index);
}
public boolean remove(Elem element)
{
return _wrappedArrayList.remove(element);
}
public boolean removeAll(Collection<? extends Elem> elements)
{
return _wrappedArrayList.removeAll(elements);
}
public boolean retainAll(Collection<? extends Elem> elements)
{
return _wrappedArrayList.retainAll(elements);
}
public Elem set(int index, Elem element)
{
return _wrappedArrayList.set(index, element);
}
public int size()
{
return _wrappedArrayList.size();
}
public List<Elem> subList(int begin, int end)
{
return _wrappedArrayList.subList(begin, end);
}
public Object[] toArray()
{
return _wrappedArrayList.toArray();
}
}

View File

@ -6,18 +6,35 @@ import java.util.HashSet;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.World;
import org.bukkit.block.Banner;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.BrewingStand;
import org.bukkit.block.Chest;
import org.bukkit.block.Dispenser;
import org.bukkit.block.Dropper;
import org.bukkit.block.Furnace;
import org.bukkit.block.Hopper;
import org.bukkit.block.Jukebox;
import org.bukkit.block.Skull;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.material.Bed;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.EnumDirection;
import net.minecraft.server.v1_8_R3.Item;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.MinecraftKey;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.TileEntityFlowerPot;
import net.minecraft.server.v1_8_R3.WorldServer;
public class UtilBlock
@ -843,4 +860,550 @@ public class UtilBlock
return blocks;
}
public static ArrayList<ItemStack> blockToInventoryItemStacks(Block block)
{
ItemStack itemStack = new ItemStack(block.getType(), 1, block.getData());
ArrayList<ItemStack> itemStacks = new ArrayList<ItemStack>();
itemStacks.add(itemStack);
switch (block.getType())
{
case SAPLING:
itemStack.setDurability((short) 0);
break;
case WATER:
itemStack.setType(Material.WATER_BUCKET);
itemStack.setDurability((short) 0);
break;
case STATIONARY_WATER:
itemStack.setType(Material.WATER_BUCKET);
itemStack.setDurability((short) 0);
break;
case LAVA:
itemStack.setType(Material.LAVA_BUCKET);
itemStack.setDurability((short) 0);
break;
case STATIONARY_LAVA:
itemStack.setType(Material.LAVA_BUCKET);
itemStack.setDurability((short) 0);
break;
case LOG:
itemStack.setDurability((short) (itemStack.getDurability() % 4));
break;
case LEAVES:
itemStack.setDurability((short) (itemStack.getDurability() % 4));
break;
case DISPENSER:
itemStack.setDurability((short) 0);
Dispenser dispenser = (Dispenser) block.getState();
for (ItemStack is : dispenser.getInventory().getContents())
{
if (is == null)
continue;
itemStacks.add(is);
}
break;
case BED_BLOCK:
itemStack.setType(Material.BED);
itemStack.setDurability((short) 0);
break;
case POWERED_RAIL:
itemStack.setDurability((short) 0);
break;
case DETECTOR_RAIL:
itemStack.setDurability((short) 0);
break;
case PISTON_STICKY_BASE:
itemStack.setDurability((short) 0);
break;
case PISTON_BASE:
itemStack.setDurability((short) 0);
break;
case PISTON_EXTENSION:
itemStack.setType(Material.AIR);
itemStack.setDurability((short) 0);
break;
case PISTON_MOVING_PIECE:
itemStack.setType(Material.AIR);
itemStack.setDurability((short) 0);
break;
case DOUBLE_STEP:
itemStack.setType(Material.STEP);
itemStack.setAmount(2);
break;
case STEP:
itemStack.setDurability((short) (itemStack.getDurability() % 8));
break;
case TORCH:
itemStack.setDurability((short) 0);
break;
case FIRE:
itemStack.setType(Material.FIREBALL);
itemStack.setDurability((short) 0);
break;
case WOOD_STAIRS:
itemStack.setDurability((short) 0);
break;
case CHEST:
itemStack.setDurability((short) 0);
Chest chest = (Chest) block.getState();
for (ItemStack is : chest.getBlockInventory().getContents())
{
if (is == null)
continue;
itemStacks.add(is);
}
break;
case REDSTONE_WIRE:
itemStack.setType(Material.REDSTONE);
itemStack.setDurability((short) 0);
break;
case CROPS:
itemStack.setType(Material.SEEDS);
itemStack.setDurability((short) 0);
break;
case SOIL:
itemStack.setType(Material.DIRT);
itemStack.setDurability((short) 0);
break;
case FURNACE:
itemStack.setDurability((short) 0);
Furnace furnace = (Furnace) block.getState();
for (ItemStack is : furnace.getInventory().getContents())
{
if (is == null)
continue;
itemStacks.add(is);
}
break;
case BURNING_FURNACE:
itemStack.setType(Material.FURNACE);
itemStack.setDurability((short) 0);
Furnace burningFurnace = (Furnace) block.getState();
for (ItemStack is : burningFurnace.getInventory().getContents())
{
if (is == null)
continue;
itemStacks.add(is);
}
break;
case SIGN_POST:
itemStack.setType(Material.SIGN);
itemStack.setDurability((short) 0);
break;
case WOODEN_DOOR:
itemStack.setType(Material.WOOD_DOOR);
itemStack.setDurability((short) 0);
break;
case LADDER:
itemStack.setDurability((short) 0);
break;
case RAILS:
itemStack.setDurability((short) 0);
break;
case COBBLESTONE_STAIRS:
itemStack.setDurability((short) 0);
break;
case WALL_SIGN:
itemStack.setType(Material.SIGN);
itemStack.setDurability((short) 0);
break;
case LEVER:
itemStack.setDurability((short) 0);
break;
case STONE_PLATE:
itemStack.setDurability((short) 0);
break;
case IRON_DOOR_BLOCK:
itemStack.setType(Material.IRON_DOOR);
itemStack.setDurability((short) 0);
break;
case WOOD_PLATE:
itemStack.setDurability((short) 0);
break;
case GLOWING_REDSTONE_ORE:
itemStack.setType(Material.REDSTONE_ORE);
break;
case REDSTONE_TORCH_OFF:
itemStack.setType(Material.REDSTONE_TORCH_ON);
itemStack.setDurability((short) 0);
break;
case REDSTONE_TORCH_ON:
itemStack.setDurability((short) 0);
break;
case STONE_BUTTON:
itemStack.setDurability((short) 0);
break;
case SNOW:
itemStack.setAmount(1 + itemStack.getDurability());
itemStack.setDurability((short) 0);
break;
case CACTUS:
itemStack.setDurability((short) 0);
break;
case SUGAR_CANE_BLOCK:
itemStack.setType(Material.SUGAR_CANE);
itemStack.setDurability((short) 0);
break;
case JUKEBOX:
itemStack.setDurability((short) 0);
Jukebox jukebox = (Jukebox) block.getState();
if (jukebox.getPlaying() != Material.AIR)
itemStacks.add(new ItemStack(jukebox.getPlaying()));
break;
case PORTAL:
itemStack.setType(Material.AIR);
itemStack.setDurability((short) 0);
break;
case CAKE_BLOCK:
itemStack.setType(Material.CAKE);
itemStack.setDurability((short) 0);
break;
case DIODE_BLOCK_OFF:
itemStack.setType(Material.DIODE);
itemStack.setDurability((short) 0);
break;
case DIODE_BLOCK_ON:
itemStack.setType(Material.DIODE);
itemStack.setDurability((short) 0);
break;
case TRAP_DOOR:
itemStack.setDurability((short) 0);
break;
case HUGE_MUSHROOM_1:
itemStack.setDurability((short) 0);
break;
case HUGE_MUSHROOM_2:
itemStack.setDurability((short) 0);
break;
case PUMPKIN_STEM:
itemStack.setType(Material.PUMPKIN_SEEDS);
itemStack.setDurability((short) 0);
break;
case MELON_STEM:
itemStack.setType(Material.MELON_SEEDS);
itemStack.setDurability((short) 0);
break;
case VINE:
itemStack.setDurability((short) 0);
break;
case FENCE_GATE:
itemStack.setDurability((short) 0);
break;
case BRICK_STAIRS:
itemStack.setDurability((short) 0);
break;
case SMOOTH_STAIRS:
itemStack.setDurability((short) 0);
break;
case NETHER_BRICK_STAIRS:
itemStack.setDurability((short) 0);
break;
case NETHER_WARTS:
itemStack.setType(Material.NETHER_STALK);
itemStack.setDurability((short) 0);
break;
case BREWING_STAND:
itemStack.setType(Material.BREWING_STAND_ITEM);
itemStack.setDurability((short) 0);
BrewingStand brewingStand = (BrewingStand) block.getState();
for (ItemStack is : brewingStand.getInventory().getContents())
{
if (is == null)
continue;
itemStacks.add(is);
}
break;
case CAULDRON:
itemStack.setType(Material.CAULDRON_ITEM);
itemStack.setDurability((short) 0);
if (block.getData() != 0)
itemStacks.add(new ItemStack(Material.WATER_BUCKET));
break;
case ENDER_PORTAL:
itemStack.setType(Material.AIR);
itemStack.setDurability((short) 0);
break;
case ENDER_PORTAL_FRAME:
itemStack.setDurability((short) 0);
if ((block.getData() & 0x4) != 0)
itemStacks.add(new ItemStack(Material.EYE_OF_ENDER));
break;
case REDSTONE_LAMP_ON:
itemStack.setType(Material.REDSTONE_LAMP_OFF);
break;
case WOOD_DOUBLE_STEP:
itemStack.setType(Material.WOOD_STEP);
itemStack.setAmount(2);
break;
case WOOD_STEP:
itemStack.setDurability((short) (itemStack.getDurability() % 8));
break;
case COCOA:
itemStack.setType(Material.INK_SACK);
itemStack.setDurability((short) 3);
break;
case SANDSTONE_STAIRS:
itemStack.setDurability((short) 0);
break;
case ENDER_CHEST:
itemStack.setDurability((short) 0);
break;
case TRIPWIRE_HOOK:
itemStack.setDurability((short) 0);
break;
case TRIPWIRE:
itemStack.setType(Material.STRING);
itemStack.setDurability((short) 0);
break;
case SPRUCE_WOOD_STAIRS:
itemStack.setDurability((short) 0);
break;
case BIRCH_WOOD_STAIRS:
itemStack.setDurability((short) 0);
break;
case JUNGLE_WOOD_STAIRS:
itemStack.setDurability((short) 0);
break;
case COMMAND:
itemStack.setDurability((short) 0);
break;
case FLOWER_POT:
itemStack.setType(Material.FLOWER_POT_ITEM);
itemStack.setDurability((short) 0);
//The FlowerPot class is outdated and doesn't work so we do some NBT checking
TileEntityFlowerPot tefp = (TileEntityFlowerPot) ((CraftWorld) block.getWorld()).getHandle().getTileEntity(new BlockPosition(block.getX(), block.getY(), block.getZ()));
NBTTagCompound c = new NBTTagCompound();
tefp.b(c);
ItemStack blockInPot = new ItemStack(Material.AIR);
if (c.hasKey("Item"))
{
MinecraftKey mk = new MinecraftKey(c.getString("Item"));
blockInPot = CraftItemStack.asNewCraftStack(Item.REGISTRY.get(mk));
}
if (c.hasKey("Data"))
blockInPot.setDurability(c.getShort("Data"));
if (blockInPot.getType() != Material.AIR)
itemStacks.add(blockInPot);
break;
case CARROT:
itemStack.setType(Material.CARROT_ITEM);
itemStack.setDurability((short) 0);
break;
case POTATO:
itemStack.setType(Material.POTATO_ITEM);
itemStack.setDurability((short) 0);
break;
case WOOD_BUTTON:
itemStack.setDurability((short) 0);
break;
case SKULL:
itemStack.setType(Material.SKULL_ITEM);
Skull skull = (Skull) block.getState();
itemStack.setDurability((short) skull.getSkullType().ordinal());
if (skull.getSkullType() == SkullType.PLAYER && skull.hasOwner())
{
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
skullMeta.setOwner(skull.getOwner());
itemStack.setItemMeta(skullMeta);
}
break;
case TRAPPED_CHEST:
itemStack.setDurability((short) 0);
Chest trappedChest = (Chest) block.getState();
for (ItemStack is : trappedChest.getBlockInventory().getContents())
{
if (is == null)
continue;
itemStacks.add(is);
}
break;
case GOLD_PLATE:
itemStack.setDurability((short) 0);
break;
case IRON_PLATE:
itemStack.setDurability((short) 0);
break;
case REDSTONE_COMPARATOR_OFF:
itemStack.setType(Material.REDSTONE_COMPARATOR);
itemStack.setDurability((short) 0);
break;
case REDSTONE_COMPARATOR_ON:
itemStack.setType(Material.REDSTONE_COMPARATOR);
itemStack.setDurability((short) 0);
break;
case DAYLIGHT_DETECTOR:
itemStack.setDurability((short) 0);
break;
case HOPPER:
itemStack.setDurability((short) 0);
Hopper hopper = (Hopper) block.getState();
for (ItemStack is : hopper.getInventory().getContents())
{
if (is == null)
continue;
itemStacks.add(is);
}
break;
case QUARTZ_STAIRS:
itemStack.setDurability((short) 0);
break;
case ACTIVATOR_RAIL:
itemStack.setDurability((short) 0);
break;
case DROPPER:
itemStack.setDurability((short) 0);
Dropper dropper = (Dropper) block.getState();
for (ItemStack is : dropper.getInventory().getContents())
{
if (is == null)
continue;
itemStacks.add(is);
}
break;
case LEAVES_2:
itemStack.setDurability((short) (itemStack.getDurability() % 4));
break;
case LOG_2:
itemStack.setDurability((short) (itemStack.getDurability() % 4));
break;
case ACACIA_STAIRS:
itemStack.setDurability((short) 0);
break;
case DARK_OAK_STAIRS:
itemStack.setDurability((short) 0);
break;
case IRON_TRAPDOOR:
itemStack.setDurability((short) 0);
break;
case HAY_BLOCK:
itemStack.setDurability((short) 0);
break;
case STANDING_BANNER:
itemStack.setType(Material.BANNER);
Banner banner = (Banner) block.getState();
itemStack.setDurability(banner.getBaseColor().getDyeData());
BannerMeta bannerMeta = (BannerMeta) itemStack.getItemMeta();
bannerMeta.setBaseColor(bannerMeta.getBaseColor());
bannerMeta.setPatterns(banner.getPatterns());
itemStack.setItemMeta(bannerMeta);
break;
case WALL_BANNER:
itemStack.setType(Material.BANNER);
Banner wallBanner = (Banner) block.getState();
itemStack.setDurability(wallBanner.getBaseColor().getDyeData());
BannerMeta wallBannerMeta = (BannerMeta) itemStack.getItemMeta();
wallBannerMeta.setBaseColor(wallBannerMeta.getBaseColor());
wallBannerMeta.setPatterns(wallBanner.getPatterns());
itemStack.setItemMeta(wallBannerMeta);
break;
case DAYLIGHT_DETECTOR_INVERTED:
itemStack.setType(Material.DAYLIGHT_DETECTOR);
itemStack.setDurability((short) 0);
break;
case RED_SANDSTONE_STAIRS:
itemStack.setDurability((short) 0);
break;
case DOUBLE_STONE_SLAB2:
itemStack.setType(Material.STONE_SLAB2);
itemStack.setAmount(2);
break;
case STONE_SLAB2:
itemStack.setDurability((short) (itemStack.getDurability() % 8));
break;
case SPRUCE_FENCE_GATE:
itemStack.setDurability((short) 0);
break;
case BIRCH_FENCE_GATE:
itemStack.setDurability((short) 0);
break;
case JUNGLE_FENCE_GATE:
itemStack.setDurability((short) 0);
break;
case DARK_OAK_FENCE_GATE:
itemStack.setDurability((short) 0);
break;
case ACACIA_FENCE_GATE:
itemStack.setDurability((short) 0);
break;
case SPRUCE_DOOR:
itemStack.setType(Material.SPRUCE_DOOR_ITEM);
itemStack.setDurability((short) 0);
break;
case BIRCH_DOOR:
itemStack.setType(Material.BIRCH_DOOR_ITEM);
itemStack.setDurability((short) 0);
break;
case JUNGLE_DOOR:
itemStack.setType(Material.JUNGLE_DOOR_ITEM);
itemStack.setDurability((short) 0);
break;
case ACACIA_DOOR:
itemStack.setType(Material.ACACIA_DOOR_ITEM);
itemStack.setDurability((short) 0);
break;
case DARK_OAK_DOOR:
itemStack.setType(Material.DARK_OAK_DOOR_ITEM);
itemStack.setDurability((short) 0);
break;
}
return itemStacks;
}
}

View File

@ -33,6 +33,7 @@ import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@ -803,6 +804,20 @@ public class UtilEnt
return null;
}
public static void setAI(LivingEntity entity, boolean ai)
{
if(entity instanceof ArmorStand)
{
((ArmorStand)entity).setGravity(ai);
return;
}
CraftEntity e = (CraftEntity)entity;
if(e.getHandle() instanceof EntityInsentient)
{
((EntityInsentient)e.getHandle()).k(!ai);
}
}
public static boolean inWater(LivingEntity ent)
{

View File

@ -25,8 +25,8 @@ public class UtilItem
_materials.put(Material.AIR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
_materials.put(Material.STONE, EnumSet.of(ItemCategory.BLOCK));
_materials.put(Material.DIRT, EnumSet.of(ItemCategory.BLOCK));
_materials.put(Material.GRASS, EnumSet.of(ItemCategory.BLOCK));
_materials.put(Material.DIRT, EnumSet.of(ItemCategory.BLOCK));
_materials.put(Material.COBBLESTONE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.STONE));
_materials.put(Material.WOOD, EnumSet.of(ItemCategory.BLOCK, ItemCategory.WOOD));
_materials.put(Material.SAPLING, EnumSet.of(ItemCategory.BLOCK));
@ -196,8 +196,56 @@ public class UtilItem
_materials.put(Material.PACKED_ICE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.MOVEMENT_MODIFYING));
_materials.put(Material.DOUBLE_PLANT, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
_materials.put(Material.SLIME_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
_materials.put(Material.BARRIER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
_materials.put(Material.IRON_TRAPDOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
_materials.put(Material.PRISMARINE, EnumSet.of(ItemCategory.BLOCK));
_materials.put(Material.SEA_LANTERN, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.LIGHT_EMITTING));
_materials.put(Material.STANDING_BANNER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
_materials.put(Material.WALL_BANNER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
_materials.put(Material.DAYLIGHT_DETECTOR_INVERTED, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
_materials.put(Material.RED_SANDSTONE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.STONE));
_materials.put(Material.RED_SANDSTONE_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.STONE, ItemCategory.TRANSLUCENT));
_materials.put(Material.DOUBLE_STONE_SLAB2, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.STONE));
_materials.put(Material.STONE_SLAB2, EnumSet.of(ItemCategory.BLOCK, ItemCategory.STONE, ItemCategory.TRANSLUCENT));
_materials.put(Material.SPRUCE_FENCE_GATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.BIRCH_FENCE_GATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.JUNGLE_FENCE_GATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.DARK_OAK_FENCE_GATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.ACACIA_FENCE_GATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.SPRUCE_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.BIRCH_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.JUNGLE_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.SPRUCE_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.BIRCH_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.JUNGLE_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.ACACIA_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.DARK_OAK_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.DARK_OAK_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.ACACIA_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.DARK_OAK_DOOR_ITEM, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
// Items
_materials.put(Material.PRISMARINE_SHARD, EnumSet.of(ItemCategory.ITEM));
_materials.put(Material.PRISMARINE_CRYSTALS, EnumSet.of(ItemCategory.ITEM));
_materials.put(Material.RABBIT, EnumSet.of(ItemCategory.ITEM, ItemCategory.RAW_FOOD, ItemCategory.EDIBLE));
_materials.put(Material.COOKED_RABBIT, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
_materials.put(Material.RABBIT_STEW, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
_materials.put(Material.RABBIT_FOOT, EnumSet.of(ItemCategory.ITEM));
_materials.put(Material.RABBIT_HIDE, EnumSet.of(ItemCategory.ITEM));
_materials.put(Material.ARMOR_STAND, EnumSet.of(ItemCategory.ITEM));
_materials.put(Material.MUTTON, EnumSet.of(ItemCategory.ITEM, ItemCategory.RAW_FOOD, ItemCategory.EDIBLE));
_materials.put(Material.COOKED_MUTTON, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
_materials.put(Material.BANNER, EnumSet.of(ItemCategory.ITEM));
_materials.put(Material.SPRUCE_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD));
_materials.put(Material.BIRCH_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD));
_materials.put(Material.JUNGLE_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD));
_materials.put(Material.ACACIA_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD));
_materials.put(Material.IRON_SPADE, EnumSet.of(ItemCategory.ITEM, ItemCategory.IRON, ItemCategory.TOOL, ItemCategory.SHOVEL));
_materials.put(Material.IRON_PICKAXE, EnumSet.of(ItemCategory.ITEM, ItemCategory.IRON, ItemCategory.TOOL, ItemCategory.PICKAXE));
_materials.put(Material.IRON_AXE, EnumSet.of(ItemCategory.AXE, ItemCategory.ITEM, ItemCategory.IRON, ItemCategory.WEAPON, ItemCategory.TOOL));
@ -1063,4 +1111,9 @@ public class UtilItem
}
}
}
public static boolean isIndexed(Material material)
{
return _materials.containsKey(material);
}
}

View File

@ -43,6 +43,14 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
if (slot == 26)
slot = 28;
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()
{
public void onClick(Player player, ClickType clickType)
{
getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player));
}
});
}
protected void addMount(Mount<?> mount, int slot)
@ -76,12 +84,5 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
setItem(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), (mount.GetCost(CurrencyType.Coins) < 0 ? "" : "Purchase ") + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()
{
public void onClick(Player player, ClickType clickType)
{
getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player));
}
});
}
}

View File

@ -880,8 +880,6 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
@EventHandler
public void PlayerQuit(PlayerQuitEvent event)
{
undisguise(event.getPlayer());
for (DisguiseBase disguise : _disguisePlayerMap.keySet())
{
_disguisePlayerMap.get(disguise).remove(event.getPlayer());
@ -891,6 +889,8 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
{
_lastRabbitHop.get(disguise).remove(event.getPlayer().getEntityId());
}
undisguise(event.getPlayer());
}
private void prepareChunk(Location loc)

View File

@ -30,7 +30,7 @@ public class ItemFirework extends ItemGadget
},
-1,
Material.FIREWORK, (byte)0,
250, new Ammo("Fireworks", "50 Fireworks", Material.FIREWORK, (byte)0, new String[] { C.cWhite + "50 Fireworks for you to launch!" }, 500, 50));
500, new Ammo("Fireworks", "50 Fireworks", Material.FIREWORK, (byte)0, new String[] { C.cWhite + "50 Fireworks for you to launch!" }, 500, 50));
}
@Override

View File

@ -140,7 +140,7 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown
{
Item melon = melonIterator.next();
if (melon.isDead() || !melon.isValid() || melon.getTicksLived() > 400)
if (melon.isDead() || !melon.isValid() || melon.getTicksLived() > 100)
{
melonIterator.remove();
melon.remove();

View File

@ -70,7 +70,7 @@ public class ItemTNT extends ItemGadget
double mult = players.get(player);
//Knockback
UtilAction.velocity(player, UtilAlg.getTrajectory(event.getLocation(), player.getLocation()), 2 * mult, false, 0, 0.5 + 1 * mult, 10, true);
UtilAction.velocity(player, UtilAlg.getTrajectory(event.getLocation(), player.getLocation()), 1 * mult, false, 0, 0.5 + 0.5 * mult, 10, true);
}
// Simulating explosion to prevent water from being evaporated.

View File

@ -85,7 +85,7 @@ public class MorphBat extends MorphGadget implements IThrown
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, GetName(), 100, false, false))
if (!Recharge.Instance.use(player, GetName(), 100, false, false, "Cosmetics"))
return;
//Effect
@ -106,7 +106,7 @@ public class MorphBat extends MorphGadget implements IThrown
if (!IsActive(player))
return;
if (!Recharge.Instance.use(player, "Poop", 4000, true, false))
if (!Recharge.Instance.use(player, "Poop", 4000, true, false, "Cosmetics"))
return;
//Action

View File

@ -76,7 +76,7 @@ public class MorphChicken extends MorphGadget
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, GetName(), 100, false, false))
if (!Recharge.Instance.use(player, GetName(), 100, false, false, "Cosmetics"))
return;
Vector offset = player.getLocation().getDirection();

View File

@ -57,7 +57,7 @@ public class MorphCow extends MorphGadget
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, GetName(), 2500, false, false))
if (!Recharge.Instance.use(player, GetName(), 2500, false, false, "Cosmetics"))
return;
player.getWorld().playSound(player.getLocation(), Sound.COW_IDLE, 1f, 1f);

View File

@ -119,7 +119,7 @@ public class MorphCreeper extends MorphGadget
double mult = players.get(other);
//Knockback
UtilAction.velocity(other, UtilAlg.getTrajectory(player.getLocation(), other.getLocation()), 1 + 1.5 * mult, false, 0, 0.5 + 1 * mult, 3, true);
UtilAction.velocity(other, UtilAlg.getTrajectory(player.getLocation(), other.getLocation()), 1 + 1 * mult, false, 0, 0.6 + 0.6 * mult, 3, true);
}
}
}

View File

@ -78,7 +78,7 @@ public class MorphEnderman extends MorphGadget
player.setAllowFlight(false);
//Set Recharge
Recharge.Instance.use(player, GetName(), 2000, false, false);
Recharge.Instance.use(player, GetName(), 2000, false, false, "Cosmetics");
//Smoke Trail
Block lastSmoke = player.getLocation().getBlock();

View File

@ -73,7 +73,7 @@ public class MorphPig extends MorphGadget
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, GetName(), 400, false, false))
if (!Recharge.Instance.use(player, GetName(), 400, false, false, "Cosmetics"))
return;
player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, 1f, (float)(0.75 + Math.random() * 0.5));

View File

@ -83,7 +83,7 @@ public class MorphSlime extends MorphGadget
if (!UtilEnt.isGrounded(player))
return;
if (!Recharge.Instance.use(player, GetName(), 1000, false, false))
if (!Recharge.Instance.use(player, GetName(), 1000, false, false, "Cosmetics"))
return;
player.getWorld().playSound(player.getLocation(), Sound.SLIME_ATTACK, 1f, 1f);

View File

@ -94,7 +94,7 @@ public class MorphTitan extends MorphGadget
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, "Guardians Laser", 4000, true, false))
if (!Recharge.Instance.use(player, "Guardians Laser", 6000, true, false, "Cosmetics"))
return;
DisguiseBase base = Manager.getDisguiseManager().getDisguise(player);
@ -148,7 +148,7 @@ public class MorphTitan extends MorphGadget
double mult = players.get(ent);
//Knockback
UtilAction.velocity(ent, UtilAlg.getTrajectory(stand.getLocation(), ent.getLocation()), 3 * mult, false, 0, 1 + 2 * mult, 10, true);
UtilAction.velocity(ent, UtilAlg.getTrajectory(stand.getLocation(), ent.getLocation()), 2 * mult, false, 0, 1 + 1 * mult, 10, true);
}
//Sound

View File

@ -87,7 +87,7 @@ public class MorphVillager extends MorphGadget implements IThrown
return;
}
if (!Recharge.Instance.use(player, GetName(), 800, false, false))
if (!Recharge.Instance.use(player, GetName(), 800, false, false, "Cosmetics"))
return;
player.getWorld().playSound(player.getLocation(), Sound.VILLAGER_IDLE, 1f, 1f);

View File

@ -96,7 +96,7 @@ public class MorphWither extends MorphGadget
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, GetName(), 1600, false, false))
if (!Recharge.Instance.use(player, GetName(), 2500, false, false, "Cosmetics"))
return;
Vector offset = player.getLocation().getDirection();

View File

@ -153,7 +153,7 @@ public abstract class ItemGadget extends Gadget
}
//Recharge
if (!Recharge.Instance.use(player, GetName(), _recharge, _recharge > 1000, false))
if (!Recharge.Instance.use(player, GetName(), GetName(), _recharge, _recharge > 1000, true, false, true, "Cosmetics"))
{
UtilInv.Update(player);
return;

View File

@ -1,7 +1,7 @@
package mineplex.core.mount;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -13,12 +13,14 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class DragonData
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
public class DragonData extends MountData
{
DragonMount Host;
public EnderDragon Dragon;
public Player Rider;
public Entity TargetEntity = null;
@ -31,9 +33,8 @@ public class DragonData
public DragonData(DragonMount dragonMount, Player rider)
{
Host = dragonMount;
Rider = rider;
super(rider);
Host = dragonMount;
Velocity = rider.getLocation().getDirection().setY(0).normalize();
Pitch = UtilAlg.GetPitch(rider.getLocation().getDirection());
@ -51,25 +52,34 @@ public class DragonData
Chicken = rider.getWorld().spawn(rider.getLocation(), Chicken.class);
Dragon.setPassenger(Chicken);
Chicken.setPassenger(Rider);
Chicken.setPassenger(getOwner());
Bukkit.getServer().getScheduler().runTaskLater(Host.Manager.getPlugin(), new Runnable()
{
public void run()
{
Chicken.setPassenger(Rider);
Chicken.setPassenger(getOwner());
}
}, 10L);
}
public void Move()
{
Rider.eject();
getOwner().eject();
((CraftEnderDragon)Dragon).getHandle().setTargetBlock(GetTarget().getBlockX(), GetTarget().getBlockY(), GetTarget().getBlockZ());
}
public Location GetTarget()
{
return Rider.getLocation().add(Rider.getLocation().getDirection().multiply(40));
return getOwner().getLocation().add(getOwner().getLocation().getDirection().multiply(40));
}
@Override
public List<Entity> getEntityParts()
{
List<Entity> list = new ArrayList<Entity>();
list.add(Dragon);
list.add(Chicken);
return list;
}
}

View File

@ -5,7 +5,6 @@ import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseChicken;
public class DragonMount extends Mount<DragonData>
{

View File

@ -22,7 +22,7 @@ import org.bukkit.entity.Horse.Style;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
public class HorseMount extends Mount<Horse>
public class HorseMount extends Mount<SingleEntityMountData<Horse>>
{
protected Color _color;
protected Style _style;
@ -53,7 +53,7 @@ public class HorseMount extends Mount<Horse>
while (activeIterator.hasNext())
{
Player player = activeIterator.next();
Horse horse = _active.get(player);
Horse horse = _active.get(player).getEntity();
//Invalid (dead)
if (!horse.isValid())
@ -113,15 +113,16 @@ public class HorseMount extends Mount<Horse>
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
//Store
_active.put(player, horse);
SingleEntityMountData<Horse> mount = new SingleEntityMountData<Horse>(player, horse);
_active.put(player, mount);
}
public void Disable(Player player)
{
Horse horse = _active.remove(player);
if (horse != null)
SingleEntityMountData<Horse> mount = _active.remove(player);
if (mount != null)
{
horse.remove();
mount.remove();
//Inform
UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(GetName()) + "."));

View File

@ -5,6 +5,7 @@ import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -18,7 +19,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.shop.item.SalesPackageBase;
public abstract class Mount<T> extends SalesPackageBase implements Listener
public abstract class Mount<T extends MountData> extends SalesPackageBase implements Listener
{
protected HashSet<Player> _owners = new HashSet<Player>();
protected HashMap<Player, T> _active = new HashMap<Player, T>();
@ -51,8 +52,8 @@ public abstract class Mount<T> extends SalesPackageBase implements Listener
return;
}
Manager.setActive(player, this);
EnableCustom(player);
Manager.setActive(player, this);
}
public abstract void EnableCustom(Player player);
@ -97,4 +98,13 @@ public abstract class Mount<T> extends SalesPackageBase implements Listener
{
return _owners.contains(player);
}
public T getMountData(Entity ent)
{
for(T data : GetActive().values())
{
if(data.isPartOfMount(ent)) return data;
}
return null;
}
}

View File

@ -0,0 +1,43 @@
package mineplex.core.mount;
import java.util.List;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public abstract class MountData
{
protected Player _owner;
public MountData(Player player)
{
_owner = player;
}
public boolean isPartOfMount(Entity ent)
{
return getEntityParts().contains(ent);
}
public abstract List<Entity> getEntityParts();
public boolean ownsMount(Player p)
{
return _owner.equals(p);
}
public Player getOwner()
{
return _owner;
}
public void remove()
{
for(Entity e : getEntityParts())
{
e.remove();
}
}
}

View File

@ -3,6 +3,17 @@ package mineplex.core.mount;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.blockrestore.BlockRestore;
@ -22,17 +33,6 @@ import mineplex.core.mount.types.MountTitan;
import mineplex.core.mount.types.MountUndead;
import mineplex.core.mount.types.MountZombie;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class MountManager extends MiniPlugin
{
private CoreClientManager _clientManager;
@ -84,32 +84,30 @@ public class MountManager extends MiniPlugin
}
@EventHandler
public void HorseInteract(PlayerInteractEntityEvent event)
public void mountInteract(PlayerInteractAtEntityEvent event)
{
MountData mount = getMountData(event.getRightClicked());
if(mount == null) return;
if(mount.ownsMount(event.getPlayer())) return;
event.setCancelled(true);
}
@EventHandler
public void mountInteract(PlayerInteractEntityEvent event)
{
if (!(event.getRightClicked() instanceof Horse))
return;
MountData mount = getMountData(event.getRightClicked());
boolean found = false;
for (Mount mount : _playerActiveMountMap.values())
{
if (mount.GetActive().containsValue(event.getRightClicked()))
{
found = true;
break;
}
}
if(mount == null) return;
if (!found)
return;
Player player = event.getPlayer();
Horse horse = (Horse)event.getRightClicked();
if(mount.ownsMount(event.getPlayer())) return;
UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!"));
event.setCancelled(true);
if (horse.getOwner() == null || !horse.getOwner().equals(player))
{
UtilPlayer.message(player, F.main("Mount", "This is not your Mount!"));
event.setCancelled(true);
}
}
@EventHandler
@ -178,16 +176,28 @@ public class MountManager extends MiniPlugin
{
return _disguiseManager;
}
public boolean isMount(Entity ent)
public MountData getMountData(Entity ent)
{
for (Mount<?> mount : _playerActiveMountMap.values())
{
if (mount.GetActive().values().contains(ent))
{
return true;
}
MountData data = mount.getMountData(ent);
if(data != null) return data;
}
return false;
return null;
}
public Mount<?> getMount(Entity ent)
{
for (Mount<?> mount : _playerActiveMountMap.values())
{
if(mount.getMountData(ent) != null) return mount;
}
return null;
}
public boolean isMount(Entity ent)
{
return getMount(ent) != null;
}
}

View File

@ -0,0 +1,35 @@
package mineplex.core.mount;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class SingleEntityMountData<T extends Entity> extends MountData
{
protected T Entity;
public SingleEntityMountData(Player player, T ent)
{
super(player);
Entity = ent;
}
@Override
public List<Entity> getEntityParts()
{
List<Entity> list = new ArrayList<Entity>();
list.add(Entity);
return list;
}
public T getEntity()
{
return Entity;
}
}

View File

@ -1,5 +1,6 @@
package mineplex.core.mount.types;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -18,23 +19,12 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.mount.Mount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftMinecart;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.vehicle.VehicleDamageEvent;
public class MountCart extends Mount<Minecart>
public class MountCart extends Mount<SingleEntityMountData<Minecart>>
{
public MountCart(MountManager manager)
{
@ -56,7 +46,7 @@ public class MountCart extends Mount<Minecart>
//Remove other mounts
Manager.DeregisterAll(player);
Minecart mount = player.getWorld().spawn(player.getLocation().add(0, 2, 0), Minecart.class);
SingleEntityMountData<Minecart> mount = new SingleEntityMountData<Minecart>(player, player.getWorld().spawn(player.getLocation().add(0, 2, 0), Minecart.class));
//Inform
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
@ -67,7 +57,7 @@ public class MountCart extends Mount<Minecart>
public void Disable(Player player)
{
Minecart mount = _active.remove(player);
SingleEntityMountData<Minecart> mount = _active.remove(player);
if (mount != null)
{
mount.remove();
@ -85,14 +75,11 @@ public class MountCart extends Mount<Minecart>
if (event.getRightClicked() == null)
return;
if (!GetActive().containsKey(event.getPlayer()))
return;
SingleEntityMountData<Minecart> mount = GetActive().get(event.getPlayer());
if (!GetActive().get(event.getPlayer()).equals(event.getRightClicked()))
{
UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!"));
return;
}
if(mount == null) return;
if(!mount.ownsMount(event.getPlayer())) return;
event.getPlayer().leaveVehicle();
event.getPlayer().eject();
@ -117,8 +104,10 @@ public class MountCart extends Mount<Minecart>
return;
//Bounce
for (Minecart cart : GetActive().values())
for (SingleEntityMountData<Minecart> cartData : GetActive().values())
{
Minecart cart = cartData.getEntity();
if (cart.getPassenger() == null)
continue;
@ -137,8 +126,10 @@ public class MountCart extends Mount<Minecart>
}
//Collide
for (Minecart cart : GetActive().values())
for (SingleEntityMountData<Minecart> cartData : GetActive().values())
{
Minecart cart = cartData.getEntity();
if (cart.getPassenger() == null)
continue;
@ -150,8 +141,9 @@ public class MountCart extends Mount<Minecart>
if (!Recharge.Instance.usable(player, GetName() + " Collide"))
continue;
for (Minecart other : GetActive().values())
for (SingleEntityMountData<Minecart> otherData : GetActive().values())
{
Minecart other = otherData.getEntity();
if (other.equals(cart))
continue;

View File

@ -9,11 +9,11 @@ import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -38,10 +38,12 @@ public class MountFrost extends HorseMount
public void Trail(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK)
for (Horse horse : GetActive().values())
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, horse.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0.1f, 4,
ViewDist.NORMAL, UtilServer.getPlayers());
for (SingleEntityMountData<Horse> horseData : GetActive().values())
{
Horse horse = horseData.getEntity();
UtilParticle.PlayParticleToAll(ParticleType.SNOW_SHOVEL, horse.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0.1f, 4, ViewDist.NORMAL);
}
}
// @EventHandler

View File

@ -5,19 +5,19 @@ import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Player;
import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguisePig;
import mineplex.core.disguise.disguises.DisguiseSheep;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -45,6 +45,7 @@ public class MountSheep extends HorseMount
Manager.DeregisterAll(player);
Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class);
SingleEntityMountData<Horse> mount = new SingleEntityMountData<Horse>(player, horse);
horse.setOwner(player);
horse.setMaxDomestication(1);
@ -59,7 +60,7 @@ public class MountSheep extends HorseMount
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
//Store
_active.put(player, horse);
_active.put(player, mount);
}
@EventHandler
@ -68,8 +69,10 @@ public class MountSheep extends HorseMount
if (event.getType() != UpdateType.TICK)
return;
for (Horse horse : GetActive().values())
for (SingleEntityMountData<Horse> horseData : GetActive().values())
{
Horse horse = horseData.getEntity();
DisguiseBase base = Manager.getDisguiseManager().getDisguise(horse);
if (base == null || !(base instanceof DisguiseSheep))
continue;

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.Slime;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
@ -18,11 +19,12 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.mount.Mount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class MountSlime extends Mount<Slime>
public class MountSlime extends Mount<SingleEntityMountData<Slime>>
{
public MountSlime(MountManager manager)
{
@ -44,10 +46,10 @@ public class MountSlime extends Mount<Slime>
//Remove other mounts
Manager.DeregisterAll(player);
Slime mount = player.getWorld().spawn(player.getLocation(), Slime.class);
mount.setSize(2);
SingleEntityMountData<Slime> mount = new SingleEntityMountData<Slime>(player, player.getWorld().spawn(player.getLocation(), Slime.class));
mount.getEntity().setSize(2);
mount.setCustomName(player.getName() + "'s " + GetName());
mount.getEntity().setCustomName(player.getName() + "'s " + GetName());
//Inform
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
@ -58,7 +60,7 @@ public class MountSlime extends Mount<Slime>
public void Disable(Player player)
{
Slime mount = _active.remove(player);
SingleEntityMountData<Slime> mount = _active.remove(player);
if (mount != null)
{
mount.remove();
@ -79,11 +81,8 @@ public class MountSlime extends Mount<Slime>
if (!GetActive().containsKey(event.getPlayer()))
return;
if (!GetActive().get(event.getPlayer()).equals(event.getRightClicked()))
{
UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!"));
if(!GetActive().get(event.getPlayer()).ownsMount(event.getPlayer()))
return;
}
event.getPlayer().leaveVehicle();
event.getPlayer().eject();
@ -108,10 +107,15 @@ public class MountSlime extends Mount<Slime>
return;
//Bounce
for (Slime slime : GetActive().values())
for (SingleEntityMountData<Slime> slimeData : GetActive().values())
{
Slime slime = slimeData.getEntity();
if (slime.getPassenger() == null)
{
UtilEnt.setFakeHead(slime, false);
continue;
}
if (!UtilEnt.isGrounded(slime))
continue;
@ -124,14 +128,19 @@ public class MountSlime extends Mount<Slime>
if (!Recharge.Instance.use(player, GetName(), 200, false, false))
continue;
UtilAction.velocity(slime, slime.getPassenger().getLocation().getDirection(), 1, true, 0, 0.4, 1, true);
Vector dir = slime.getPassenger().getLocation().getDirection();
UtilAction.velocity(slime, dir, 1, true, 0, 0.4, 1, true);
UtilEnt.CreatureForceLook(slime, 0, UtilAlg.GetYaw(dir));
slime.getWorld().playSound(slime.getLocation(), Sound.SLIME_WALK, 1f, 0.75f);
}
//Collide
for (Slime slime : GetActive().values())
for (SingleEntityMountData<Slime> slimeData : GetActive().values())
{
Slime slime = slimeData.getEntity();
if (slime.getPassenger() == null)
continue;
@ -143,8 +152,10 @@ public class MountSlime extends Mount<Slime>
if (!Recharge.Instance.usable(player, GetName() + " Collide"))
continue;
for (Slime other : GetActive().values())
for (SingleEntityMountData<Slime> otherSlime : GetActive().values())
{
Slime other = otherSlime.getEntity();
if (other.equals(slime))
continue;

View File

@ -4,21 +4,6 @@ import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Map.Entry;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseSpider;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_8_R3.EntityLiving;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
@ -32,6 +17,22 @@ import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseSpider;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_8_R3.EntityLiving;
public class MountSpider extends HorseMount
{
/**
@ -87,7 +88,8 @@ public class MountSpider extends HorseMount
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
//Store
_active.put(player, horse);
SingleEntityMountData<Horse> mount = new SingleEntityMountData<Horse>(player, horse);
_active.put(player, mount);
DisguiseSpider spider = new DisguiseSpider(horse);
spider.setName(player.getName() + "'s Spider Mount");
@ -105,7 +107,7 @@ public class MountSpider extends HorseMount
ArrayList<Horse> used = new ArrayList<Horse>();
for (Player player : GetActive().keySet())
{
Horse horse = GetActive().get(player);
Horse horse = GetActive().get(player).getEntity();
used.add(horse);
@ -126,21 +128,24 @@ public class MountSpider extends HorseMount
if (event.getType() != UpdateType.TICK)
return;
for (Entry<Player, Horse> horse : GetActive().entrySet())
for (Entry<Player, SingleEntityMountData<Horse>> entry : GetActive().entrySet())
{
if (horse.getValue().getPassenger() != horse.getKey())
Player player = entry.getKey();
Horse horse = entry.getValue().getEntity();
if (horse.getPassenger() != player)
continue;
//If player is looking up
if (horse.getKey().getEyeLocation().getPitch() > -45)
if (player.getEyeLocation().getPitch() > -45)
continue;
for (Block block : UtilBlock.getSurrounding(horse.getValue().getLocation().getBlock(), true))
for (Block block : UtilBlock.getSurrounding(horse.getLocation().getBlock(), true))
{
if (UtilBlock.airFoliage(block) || block.isLiquid())
continue;
UtilAction.velocity(horse.getValue(), new Vector(horse.getValue().getVelocity().getX(), 0.2, horse.getValue().getVelocity().getZ()));
UtilAction.velocity(horse, new Vector(horse.getVelocity().getX(), 0.2, horse.getVelocity().getZ()));
continue;
}
}
@ -191,7 +196,7 @@ public class MountSpider extends HorseMount
for (Player player : GetActive().keySet())
{
final Horse horse = GetActive().get(player);
final Horse horse = GetActive().get(player).getEntity();
if (horse.getPassenger() != player)
continue;

View File

@ -1,27 +1,19 @@
package mineplex.core.mount.types;
import java.util.HashMap;
import org.bukkit.Material;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.Mount;
import mineplex.core.mount.MountManager;
import mineplex.core.updater.UpdateType;
@ -85,11 +77,20 @@ public class MountTitan extends Mount<MountTitanData>
}
@EventHandler
public void interactMount(PlayerInteractEntityEvent event)
public void interactMount(PlayerInteractAtEntityEvent event)
{
if (event.getRightClicked() == null)
return;
for(MountTitanData mount : GetActive().values())
{
if(mount.isPartOfMount(event.getRightClicked()))
{
event.setCancelled(true);
if(event.getRightClicked().getType() == EntityType.ARMOR_STAND) return;
}
}
if (!GetActive().containsKey(event.getPlayer()))
return;
@ -123,7 +124,7 @@ public class MountTitan extends Mount<MountTitanData>
{
for (MountTitanData data : _active.values())
{
if (data.ownsEntity(event.getEntity()))
if (data.isPartOfMount(event.getEntity()))
event.setCancelled(true);
}
}

View File

@ -3,11 +3,7 @@
package mineplex.core.mount.types;
import java.util.ArrayList;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
@ -20,9 +16,13 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
public class MountTitanData
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.mount.MountData;
public class MountTitanData extends MountData
{
private String _owner;
private Slime _head;
@ -30,7 +30,7 @@ public class MountTitanData
public MountTitanData(Player player, String name)
{
_owner = player.getName();
super(player);
Location loc = player.getLocation();
loc.setPitch(0);
@ -72,7 +72,11 @@ public class MountTitanData
{
//Head
if (_head.getPassenger() != null)
_head.setVelocity(_head.getPassenger().getLocation().getDirection().multiply(0.8).add(new Vector(0,0.2,0)));
{
Vector dir = _head.getPassenger().getLocation().getDirection().multiply(0.8).add(new Vector(0,0.2,0));
_head.setVelocity(dir);
UtilEnt.CreatureLook(_head, dir);
}
Location infront = _head.getLocation().add(0, -1.5, 0);
@ -133,14 +137,13 @@ public class MountTitanData
for (ArmorStand stand : _nodes)
stand.remove();
}
public boolean ownsMount(Player player)
{
return _owner.equals(player.getName());
}
public boolean ownsEntity(Entity ent)
@Override
public List<Entity> getEntityParts()
{
return (_head.equals(ent) || _nodes.contains(ent));
List<Entity> entities = new ArrayList<Entity>();
entities.addAll(_nodes);
entities.add(_head);
return entities;
}
}

View File

@ -1,15 +1,5 @@
package mineplex.core.mount.types;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Material;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Color;
@ -17,6 +7,16 @@ import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class MountUndead extends HorseMount
{
public MountUndead(MountManager manager)
@ -37,16 +37,20 @@ public class MountUndead extends HorseMount
public void Trail(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK)
for (Horse horse : GetActive().values())
UtilParticle.PlayParticle(ParticleType.FLAME, horse.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0, 2,
ViewDist.NORMAL, UtilServer.getPlayers());
for (SingleEntityMountData<Horse> horseData : GetActive().values())
{
Horse horse = horseData.getEntity();
UtilParticle.PlayParticleToAll(ParticleType.FLAME, horse.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0, 2,ViewDist.NORMAL);
}
if (event.getType() == UpdateType.FAST)
for (Horse horse : GetActive().values())
UtilParticle.PlayParticle(ParticleType.LAVA, horse.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
for (SingleEntityMountData<Horse> horseData : GetActive().values())
{
Horse horse = horseData.getEntity();
UtilParticle.PlayParticleToAll(ParticleType.LAVA, horse.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0, 1, ViewDist.NORMAL);
}
}
}

View File

@ -29,6 +29,9 @@ public class Recharge extends MiniPlugin
public HashSet<String> informSet = new HashSet<String>();
public NautHashMap<String, NautHashMap<String, RechargeData>> _recharge = new NautHashMap<String, NautHashMap<String, RechargeData>>();
//Used to increase cooldown when gadgets are being spammed
public NautHashMap<String, ArrayList<Long>> _gadgetSlow = new NautHashMap<String, ArrayList<Long>>();
protected Recharge(JavaPlugin plugin)
{
super("Recharge", plugin);
@ -76,10 +79,22 @@ public class Recharge extends MiniPlugin
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (event.getType() == UpdateType.TICK)
recharge();
recharge();
if (event.getType() == UpdateType.SLOW)
for (ArrayList<Long> times : _gadgetSlow.values())
{
Iterator<Long> timeIter = times.iterator();
while (timeIter.hasNext())
{
long time = timeIter.next();
if (UtilTime.elapsed(time, 20000))
timeIter.remove();
}
}
}
public void recharge()
@ -112,24 +127,40 @@ public class Recharge extends MiniPlugin
public boolean use(Player player, String ability, long recharge, boolean inform, boolean attachItem)
{
return use(player, ability, ability, recharge, inform, attachItem);
return use(player, ability, ability, recharge, inform, attachItem, false, true, null);
}
public boolean use(Player player, String ability, long recharge, boolean inform, boolean attachItem, String cooldownPool)
{
return use(player, ability, ability, recharge, inform, attachItem, false, true, cooldownPool);
}
public boolean use(Player player, String ability, String abilityFull, long recharge, boolean inform, boolean attachItem)
{
return use(player, ability, abilityFull, recharge, inform, attachItem, false, true);
return use(player, ability, abilityFull, recharge, inform, attachItem, false, true, null);
}
public boolean use(Player player, String ability, long recharge, boolean inform, boolean attachItem, boolean attachDurability)
{
return use(player, ability, ability, recharge, inform, attachItem, attachDurability, true);
return use(player, ability, ability, recharge, inform, attachItem, attachDurability, true, null);
}
public boolean use(Player player, String ability, String abilityFull, long recharge, boolean inform,
boolean attachItem, boolean attachDurability, boolean clearOnDeath)
boolean attachItem, boolean attachDurability, boolean clearOnDeath, String cooldownPool)
{
if (recharge == 0)
return true;
//Cooldown Pool
if (cooldownPool != null)
{
if (!_gadgetSlow.containsKey(cooldownPool))
_gadgetSlow.put(cooldownPool, new ArrayList<Long>());
int count = _gadgetSlow.get(cooldownPool).size();
recharge += count * 40;
}
//Ensure Expirey
recharge();
@ -149,6 +180,10 @@ public class Recharge extends MiniPlugin
return false;
}
//Add Slow
if (cooldownPool != null)
_gadgetSlow.get(cooldownPool).add(System.currentTimeMillis());
//Insert
UseRecharge(player, ability, recharge, attachItem, attachDurability, clearOnDeath);

View File

@ -113,7 +113,7 @@ public class PlayerScoreboard
System.out.println("Scoreboard Error: Line Team Not Found!");
return;
}
//Set Line Prefix/Suffix
team.setPrefix(newLine.substring(0, Math.min(newLine.length(), 16)));
team.setSuffix(ChatColor.getLastColors(team.getPrefix()) + newLine.substring(team.getPrefix().length(), Math.min(newLine.length(), 32)));

View File

@ -49,7 +49,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer;
public class Clans extends JavaPlugin
{
public static final String VERSION = "0.14";
public static final String VERSION = "0.16";
private String WEB_CONFIG = "webServer";
// Modules

View File

@ -459,6 +459,27 @@ public class ClansGame extends MiniPlugin
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void doorPlaced(BlockPlaceEvent event)
{
if (event.getBlockPlaced().getType().equals(Material.ACACIA_DOOR)
|| event.getBlockPlaced().getType().equals(Material.WOODEN_DOOR)
|| event.getBlockPlaced().getType().equals(Material.BIRCH_DOOR)
|| event.getBlockPlaced().getType().equals(Material.DARK_OAK_DOOR)
|| event.getBlockPlaced().getType().equals(Material.JUNGLE_DOOR)
|| event.getBlockPlaced().getType().equals(Material.SPRUCE_DOOR)
|| event.getBlockPlaced().getType().equals(Material.WOOD_DOOR)
|| event.getBlockPlaced().getType().equals(Material.IRON_DOOR_BLOCK))
{
ClanTerritory claim = _clans.getClanUtility().getClaim(event.getBlockPlaced().getLocation());
if (claim != null && (claim.Owner.equals("Spawn") || claim.Owner.equals("Shops")))
{
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void Piston(BlockPistonExtendEvent event)
{
@ -494,16 +515,6 @@ public class ClansGame extends MiniPlugin
}
}
@EventHandler
public void TURTLEZ(PlayerCommandPreprocessEvent event)
{
if (event.getPlayer().getName().equals("SamitoD") && event.getMessage().equals("/gear"))
{
UtilPlayer.message(event.getPlayer(), "UR SPECIAL!!!");
_clans.getGearManager().openShop(event.getPlayer());
}
}
@EventHandler
public void Quit(PlayerQuitEvent event)
{

View File

@ -227,7 +227,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
TaskManager taskManager = new TaskManager(plugin, _clientManager, webServerAddress);
_tutorialManager = new TutorialManager(plugin, _goldManager, taskManager, donationManager, preferencesManager, this);
_tutorialManager = new TutorialManager(plugin, _goldManager, taskManager, donationManager, preferencesManager, this, packetHandler);
ClanTips = new ClanTips(plugin, this, preferencesManager);
@ -402,6 +402,11 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
return _disguiseManager;
}
public TutorialManager getTutorials()
{
return _tutorialManager;
}
public NpcManager getNPCManager()
{
return _npcManager;

View File

@ -19,9 +19,9 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.recharge.Recharge;
import mineplex.game.clans.clans.event.ClanDisbandedEvent;
import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent;
import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent;
import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent;
import mineplex.game.clans.core.repository.ClanTerritory;
@ -157,10 +157,10 @@ public class ClansUtility
if (inform)
{
UtilPlayer.message(caller, F.main("Clan Search", "" + C.mCount + (clanMatchList.size() + playerMatchList.size()) + C.mBody + " matches for [" + C.mElem + name + C.mBody + "]."), false);
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clan Search", "" + C.mCount + (clanMatchList.size() + playerMatchList.size()) + C.mBody + " matches for [" + C.mElem + name + C.mBody + "]."));
UtilPlayer.message(caller, F.desc("Matches via Clan", clanMatchString), false);
UtilPlayer.message(caller, F.desc("Matches via Player", playerMatchString), false);;
Clans.getTutorials().sendTutorialMsg(caller, F.desc("Matches via Clan", clanMatchString));
Clans.getTutorials().sendTutorialMsg(caller, F.desc("Matches via Player", playerMatchString));
}
return null;
@ -183,7 +183,7 @@ public class ClansUtility
if (!inform) return null;
// Inform
UtilPlayer.message(caller, F.main("Clan Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem + name + C.mBody + "]."), false);
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clan Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem + name + C.mBody + "]."));
if (matchList.size() > 0)
{
@ -191,7 +191,7 @@ public class ClansUtility
for (ClanInfo cur : matchList)
matchString += cur.getName() + " ";
UtilPlayer.message(caller, F.main("Clan Search", "" + C.mBody + " Matches [" + C.mElem + matchString + C.mBody + "]."), false);
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clan Search", "" + C.mBody + " Matches [" + C.mElem + matchString + C.mBody + "]."));
}
return null;
@ -554,31 +554,31 @@ public class ClansUtility
{
if (Clans.getClanMemberUuidMap().containsKey(caller.getUniqueId()))
{
UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already in a Clan."));
return;
}
if (!Clans.Get(caller).canJoin())
{
UtilPlayer.message(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - Clans.Get(caller).getDelay(), 1, UtilTime.TimeUnit.FIT) + C.mBody + "."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - Clans.Get(caller).getDelay(), 1, UtilTime.TimeUnit.FIT) + C.mBody + "."));
return;
}
if (clanInfo == null)
{
UtilPlayer.message(caller, F.main("Clans", "Error: Clan does not exist"));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Error: Clan does not exist"));
return;
}
if (!clanInfo.isInvited(caller.getName()))
{
UtilPlayer.message(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clanInfo.getName()) + "."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clanInfo.getName()) + "."));
return;
}
if (clanInfo.getSize() >= clanInfo.getMaxSize())
{
UtilPlayer.message(caller, F.main("Clans", "The clan " + F.elem("Clan " + clanInfo.getName()) + " is full and cannot be joined!"));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "The clan " + F.elem("Clan " + clanInfo.getName()) + " is full and cannot be joined!"));
return;
}
@ -591,12 +591,12 @@ public class ClansUtility
if (data)
{
// Inform
UtilPlayer.message(caller, F.main("Clans", "You joined " + F.elem("Clan " + clanInfo.getName()) + "."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You joined " + F.elem("Clan " + clanInfo.getName()) + "."));
clanInfo.inform(F.name(caller.getName()) + " has joined your Clan.", caller.getName());
}
else
{
UtilPlayer.message(caller, F.main("Clans", "There was an error processing your request"));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request"));
}
}
});
@ -609,13 +609,13 @@ public class ClansUtility
if (clan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (clan.getMembers().get(caller.getUniqueId()).getRole() == ClanRole.LEADER && clan.getMembers().size() > 1)
{
UtilPlayer.message(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving."));
return;
}
@ -629,7 +629,7 @@ public class ClansUtility
public void run(Boolean data)
{
// Inform
UtilPlayer.message(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + "."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + "."));
clan.inform(F.name(caller.getName()) + " has left your Clan.", null);
}
});
@ -646,13 +646,13 @@ public class ClansUtility
if (clan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (getRole(caller) != ClanRole.LEADER)
{
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader can disband the Clan."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader can disband the Clan."));
return;
}
@ -665,6 +665,8 @@ public class ClansUtility
return;
}
Clans.messageClan(clan, C.cYellow + caller.getName() + C.cGray + " has disbanded the Clan.");
// Task
Clans.getClanDataAccess().delete(clan, new Callback<Boolean>()
{
@ -673,10 +675,11 @@ public class ClansUtility
{
if (!data)
{
UtilPlayer.message(caller, F.main("Clans", "There was an error processing your request. Try again later"));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request. Try again later"));
}else
{
UtilPlayer.message(caller, F.main("Clans", "You disbanded your Clan."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You disbanded your Clan."));
}
}
});
@ -686,27 +689,37 @@ public class ClansUtility
{
ClanInfo clan = getClanByPlayer(caller);
// Pre Event
PlayerPreClaimTerritoryEvent preEvent = new PlayerPreClaimTerritoryEvent(caller, caller.getLocation().getChunk(), clan);
UtilServer.getServer().getPluginManager().callEvent(preEvent);
if (preEvent.isCancelled())
{
return false;
}
if (clan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return false;
}
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
{
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can claim Territory."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can claim Territory."));
return false;
}
if (!ClansManager.isClaimable(caller.getLocation()))
{
UtilPlayer.message(caller, F.main("Clans", "You cannot claim territory at this location!"));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim territory at this location!"));
return false;
}
// if (clan.getEnergy() == 0)
// {
// UtilPlayer.message(caller, F.main("Clans", "You must purchase energy at a shop before you can claim land."));
// Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must purchase energy at a shop before you can claim land."));
// return false;
// }
@ -722,14 +735,14 @@ public class ClansUtility
}
else
{
UtilPlayer.message(caller, F.main("Clans", "This Territory is owned by " + mRel(Clans.getClanUtility().relPC(caller, ownerClan), ownerClan.getName(), true) + "."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This Territory is owned by " + mRel(Clans.getClanUtility().relPC(caller, ownerClan), ownerClan.getName(), true) + "."));
return false;
}
}
// if (clan.getClaims() >= clan.getClaimsMax())
// {
// UtilPlayer.message(caller, F.main("Clans", "Your Clan cannot claim more Territory."));
// Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan cannot claim more Territory."));
// return false;
// }
@ -755,8 +768,8 @@ public class ClansUtility
if (checkBox(caller.getWorld().getChunkAt(caller.getLocation().getChunk().getX() + x, caller.getLocation().getChunk().getZ() + z), 3))
{
UtilPlayer.message(caller, F.main("Clans", "You cannot claim this Territory, it causes a box."));
UtilPlayer.message(caller, F.main("Clans", "This means a Territory has all sides claimed."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim this Territory, it causes a box."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This means a Territory has all sides claimed."));
return false;
}
@ -766,7 +779,7 @@ public class ClansUtility
}
else if (rel(clan, adjClan) != ClanRelation.SELF)
{
UtilPlayer.message(caller, F.main("Clans", "You cannot claim Territory next to " + mRel(rel(ownerClan, adjClan), adjClan.getName(), true) + "."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim Territory next to " + mRel(rel(ownerClan, adjClan), adjClan.getName(), true) + "."));
return false;
}
}
@ -775,21 +788,21 @@ public class ClansUtility
// Boxed
if (checkBox(caller.getLocation().getChunk(), 4))
{
UtilPlayer.message(caller, F.main("Clans", "You cannot claim this Territory, it causes a box."));
UtilPlayer.message(caller, F.main("Clans", "This means a Territory has all sides claimed."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim this Territory, it causes a box."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This means a Territory has all sides claimed."));
return false;
}
if (isNearAdminClaim(caller.getLocation()))
{
UtilPlayer.message(caller, F.main("Clans", "You cannot claim so close to administrative territory!"));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim so close to administrative territory!"));
return false;
}
// Not Next to Self
if (!selfAdj && !clan.getClaimSet().isEmpty())
{
UtilPlayer.message(caller, F.main("Clans", "You must claim next to your other Territory."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must claim next to your other Territory."));
return false;
}
@ -798,7 +811,7 @@ public class ClansUtility
{
if (!UtilTime.elapsed(Clans.getUnclaimMap().get(chunk), Clans.getReclaimTime()))
{
UtilPlayer.message(caller, F.main("Clans", "This Territory cannot be claimed for " + F.time(UtilTime.convertString(Clans.getReclaimTime() - (System.currentTimeMillis() - Clans.getUnclaimMap().get(chunk)), 1, UtilTime.TimeUnit.FIT)) + "."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This Territory cannot be claimed for " + F.time(UtilTime.convertString(Clans.getReclaimTime() - (System.currentTimeMillis() - Clans.getUnclaimMap().get(chunk)), 1, UtilTime.TimeUnit.FIT)) + "."));
return false;
}
@ -813,7 +826,7 @@ public class ClansUtility
{
if (UtilMath.offset(cur, caller) < 16) if (playerEnemy(caller, cur))
{
UtilPlayer.message(caller, F.main("Clans", "You cannot claim while enemies are nearby."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim while enemies are nearby."));
return false;
}
}
@ -835,7 +848,7 @@ public class ClansUtility
Clans.getClanDataAccess().claim(clan.getName(), chunk, caller.getName(), false);
// Inform
UtilPlayer.message(caller, F.main("Clans", "You claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + "."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + "."));
clan.inform(F.name(caller.getName()) + " claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".", caller.getName());
return true;
@ -872,7 +885,7 @@ public class ClansUtility
}
// Change Inform
UtilPlayer.message(caller, F.main("Clans", "You can no longer 'steal' territory. " + "You simply unclaim it and it can not be reclaimed by anyone for 30 mintes." + "This was done to improve gameplay. Enjoy!"));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can no longer 'steal' territory. " + "You simply unclaim it and it can not be reclaimed by anyone for 30 mintes." + "This was done to improve gameplay. Enjoy!"));
// Inform
UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + "."));
@ -889,7 +902,7 @@ public class ClansUtility
if (clan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return;
}
@ -900,13 +913,13 @@ public class ClansUtility
if (target.equals(caller.getName()))
{
UtilPlayer.message(caller, F.main("Clans", "You cannot promote yourself."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot promote yourself."));
return;
}
if (self.getRole().ordinal() <= target.getRole().ordinal())
{
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(other) + "."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You do not outrank " + F.name(other) + "."));
return;
}
@ -941,7 +954,7 @@ public class ClansUtility
if (clan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return;
}
@ -952,19 +965,19 @@ public class ClansUtility
if (target.equals(caller.getName()))
{
UtilPlayer.message(caller, F.main("Clans", "You cannot demote yourself."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot demote yourself."));
return;
}
if (self.getRole().ordinal() <= target.getRole().ordinal())
{
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(other) + "."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You do not outrank " + F.name(other) + "."));
return;
}
if (target.getRole() == ClanRole.RECRUIT)
{
UtilPlayer.message(caller, F.main("Clans", "You cannot demote " + F.name(other) + " any further."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot demote " + F.name(other) + " any further."));
return;
}
@ -991,7 +1004,7 @@ public class ClansUtility
if (clan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return;
}
@ -1002,20 +1015,20 @@ public class ClansUtility
if (self.getRole() != ClanRole.LEADER && self.getRole() != ClanRole.ADMIN)
{
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can kick members."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can kick members."));
return;
}
if (clansPlayer.getRole() == ClanRole.LEADER)
{
UtilPlayer.message(caller, F.main("Clans", "Clan leaders cannot be kicked."));
UtilPlayer.message(caller, F.main("Clans", "To disband a clan, use /c disband"));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan leaders cannot be kicked."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "To disband a clan, use /c disband"));
return;
}
if ((clansPlayer.getRole() == ClanRole.LEADER && self.getRole() == ClanRole.ADMIN) || (clansPlayer.getRole() == ClanRole.ADMIN && self.getRole() == ClanRole.ADMIN))
{
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(other) + "."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You do not outrank " + F.name(other) + "."));
return;
}
@ -1027,8 +1040,8 @@ public class ClansUtility
public void run(Boolean data)
{
// Inform
if (player != null) UtilPlayer.message(player, F.main("Clans", F.name(caller.getName()) + " kicked you from " + F.elem("Clan " + clan.getName()) + "."));
UtilPlayer.message(caller, F.main("Clans", "You kicked " + F.name(other) + " from your Clan."));
if (player != null) Clans.getTutorials().sendTutorialMsg(player, F.main("Clans", F.name(caller.getName()) + " kicked you from " + F.elem("Clan " + clan.getName()) + "."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You kicked " + F.name(other) + " from your Clan."));
clan.inform(F.main("Clans", F.name(caller.getName()) + " kicked " + F.name(other) + " from your Clan."), caller.getName());
}
};
@ -1046,7 +1059,7 @@ public class ClansUtility
if (clan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return false;
}
@ -1059,14 +1072,14 @@ public class ClansUtility
// Role
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
{
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can unclaim Territory."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can unclaim Territory."));
return false;
}
// Not Claimed
if (ownerClan == null || !ownerClan.equals(clan))
{
UtilPlayer.message(caller, F.main("Clans", "This Territory is not owned by you."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This Territory is not owned by you."));
return false;
}
@ -1084,7 +1097,7 @@ public class ClansUtility
Clans.getClanDataAccess().unclaim(chunk, caller.getName(), true);
// Inform
UtilPlayer.message(caller, F.main("Clans", "You unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + "."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + "."));
clan.inform(F.name(caller.getName()) + " unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".", caller.getName());
return true;
@ -1096,13 +1109,13 @@ public class ClansUtility
if (clan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return false;
}
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER)
{
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader can unclaim all Territory."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader can unclaim all Territory."));
return false;
}
@ -1120,7 +1133,7 @@ public class ClansUtility
}
// Inform
UtilPlayer.message(caller, F.main("Clans", "You unclaimed all your Clans Territory."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You unclaimed all your Clans Territory."));
clan.inform(F.name(caller.getName()) + " unclaimed all your Clans Territory.", caller.getName());
return true;
@ -1130,21 +1143,21 @@ public class ClansUtility
{
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
{
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can send invites."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can send invites."));
return;
}
if (target.getName().equals(caller.getName()))
{
UtilPlayer.message(caller, F.main("Clans", "You cannot invite yourself."));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot invite yourself."));
return;
}
// Inform
clan.inform(F.name(caller.getName()) + " invited " + F.name(target.getName()) + " to join your Clan.", caller.getName());
UtilPlayer.message(caller, F.main("Clans", "You invited " + F.name(target.getName()) + " to join your Clan."));
UtilPlayer.message(target, F.main("Clans", F.name(caller.getName()) + " invited you to join " + F.elem("Clan " + clan.getName()) + "."));
UtilPlayer.message(target, F.main("Clans", "Type " + F.elem("/c join " + clan.getName()) + " to accept!"));
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You invited " + F.name(target.getName()) + " to join your Clan."));
Clans.getTutorials().sendTutorialMsg(target, F.main("Clans", F.name(caller.getName()) + " invited you to join " + F.elem("Clan " + clan.getName()) + "."));
Clans.getTutorials().sendTutorialMsg(target, F.main("Clans", "Type " + F.elem("/c join " + clan.getName()) + " to accept!"));
// Task
Clans.getClanDataAccess().invite(clan, target.getName(), caller.getName());

View File

@ -25,6 +25,7 @@ import mineplex.game.clans.clans.ClansBlacklist;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClientClan;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.tutorials.Tutorial;
import mineplex.game.clans.tutorials.TutorialManager;
import net.minecraft.server.v1_8_R3.EnumDirection;
@ -65,7 +66,8 @@ public class ClansCommand extends CommandBase<ClansManager>
else if (args[0].equalsIgnoreCase("promote") || args[0].equalsIgnoreCase("+"))
promote(caller, args);
else if (args[0].equalsIgnoreCase("forcejoin") || args[0].equalsIgnoreCase("fj"))
forceJoin(caller, args);
else if (args[0].equalsIgnoreCase("demote") || args[0].equalsIgnoreCase("-"))
demote(caller, args);
@ -121,12 +123,41 @@ public class ClansCommand extends CommandBase<ClansManager>
infoClan(caller, args[0]);
}
private void forceJoin(Player caller, String[] args)
{
if (!Plugin.getClientManager().hasRank(caller, Rank.ADMIN) && !caller.getName().equals("NewGarbo"))
{
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This requires ADMIN+ permission."));
return;
}
if (args.length > 1)
{
ClanInfo clan = Plugin.getClan(args[1]);
if (clan != null)
{
_manager.getClanUtility().join(caller, clan);
_manager.getClanDataAccess().role(clan, caller.getUniqueId(), ClanRole.LEADER);
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You have successfully joined " + F.elem(clan.getName()) + " and are now Leader Role."));
}
else
{
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan provided does not exist."));
}
}
else
{
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "No clan provided."));
}
}
public void commandChat(Player caller, String[] args)
{
if (args.length == 0)
{
Plugin.Get(caller).setClanChat(!Plugin.Get(caller).isClanChat());
UtilPlayer.message(caller, F.main("Clans", "Clan Chat: " + F.oo(Plugin.Get(caller).isClanChat())));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan Chat: " + F.oo(Plugin.Get(caller).isClanChat())));
return;
}
@ -135,7 +166,7 @@ public class ClansCommand extends CommandBase<ClansManager>
{
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
if (clan == null)
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
else
Plugin.chatClan(clan, caller, F.combine(args, 0, null, false));
}
@ -146,7 +177,7 @@ public class ClansCommand extends CommandBase<ClansManager>
if (args.length == 0)
{
Plugin.Get(caller).setAllyChat(!Plugin.Get(caller).isAllyChat());
UtilPlayer.message(caller, F.main("Clans", "Ally Chat: " + F.oo(Plugin.Get(caller).isAllyChat())));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Ally Chat: " + F.oo(Plugin.Get(caller).isAllyChat())));
return;
}
@ -155,7 +186,7 @@ public class ClansCommand extends CommandBase<ClansManager>
{
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
if (clan == null)
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
else
Plugin.chatAlly(clan, caller, F.combine(args, 0, null, false));
}
@ -171,30 +202,30 @@ public class ClansCommand extends CommandBase<ClansManager>
return;
}
UtilPlayer.message(caller, F.main("Clans", "Commands List;"));
UtilPlayer.message(caller, F.help("/c create <clan>", "Create new Clan", Rank.ALL));
UtilPlayer.message(caller, F.help("/c join <clan>", "Join a Clan", Rank.ALL));
UtilPlayer.message(caller, F.help("/c leave <clan>", "Leave your Clan", Rank.ALL));
UtilPlayer.message(caller, F.help("/c map <toggle>", "View Clan Map", Rank.ALL));
UtilPlayer.message(caller, F.help("/cc (Message)", "Clan Chat (Toggle)", Rank.ALL));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Commands List;"));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c create <clan>", "Create new Clan", Rank.ALL));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c join <clan>", "Join a Clan", Rank.ALL));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c leave <clan>", "Leave your Clan", Rank.ALL));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c map <toggle>", "View Clan Map", Rank.ALL));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/cc (Message)", "Clan Chat (Toggle)", Rank.ALL));
UtilPlayer.message(caller, F.help("/c promote <player>", "Promote Player in Clan", Rank.MODERATOR));
UtilPlayer.message(caller, F.help("/c demote <player>", "Demote Player in Clan", Rank.MODERATOR));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c promote <player>", "Promote Player in Clan", Rank.MODERATOR));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c demote <player>", "Demote Player in Clan", Rank.MODERATOR));
UtilPlayer.message(caller, F.help("/c home (set)", "Teleport to Clan Home", Rank.MODERATOR));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c home (set)", "Teleport to Clan Home", Rank.MODERATOR));
UtilPlayer.message(caller, F.help("/c invite <player>", "Invite Player to Clan", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c kick <player>", "Kick Player from Clan", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c neutral <clan>", "Request Neutrality with Clan", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c enemy <clan>", "Declare ClanWar with Clan", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c ally <clan>", "Send Alliance to Clan", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c trust <clan>", "Give Trust to Clan", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c claim", "Claim Territory", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c unclaim (all)", "Unclaim Territory", Rank.ADMIN));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c invite <player>", "Invite Player to Clan", Rank.ADMIN));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c kick <player>", "Kick Player from Clan", Rank.ADMIN));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c neutral <clan>", "Request Neutrality with Clan", Rank.ADMIN));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c enemy <clan>", "Declare ClanWar with Clan", Rank.ADMIN));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c ally <clan>", "Send Alliance to Clan", Rank.ADMIN));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c trust <clan>", "Give Trust to Clan", Rank.ADMIN));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c claim", "Claim Territory", Rank.ADMIN));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c unclaim (all)", "Unclaim Territory", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c delete", "Delete your Clan", Rank.OWNER));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c delete", "Delete your Clan", Rank.OWNER));
UtilPlayer.message(caller, F.help("/c <clan>", "View Clan Information", Rank.ALL));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c <clan>", "View Clan Information", Rank.ALL));
}
public void create(final Player caller, final String[] args)
@ -205,12 +236,12 @@ public class ClansCommand extends CommandBase<ClansManager>
if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId()))
{
UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already in a Clan."));
return;
}
/*
* TODO if (!client.canJoin()) { UtilPlayer.message(caller,
* TODO if (!client.canJoin()) { _manager.getTutorials().sendTutorialMsg(caller,
* F.main("Clans", "You cannot join a Clan for " + C.mTime +
* UtilTime.convertString(System.currentTimeMillis() -
* client.getDelay(), 1, TimeUnit.FIT) + C.mBody + ".")); return; }
@ -218,37 +249,37 @@ public class ClansCommand extends CommandBase<ClansManager>
if (args.length < 2)
{
UtilPlayer.message(caller, F.main("Clans", "You did not input a Clan name."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan name."));
return;
}
if (!UtilInput.valid(args[1]))
{
UtilPlayer.message(caller, F.main("Clans", "Invalid characters in Clan name."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Invalid characters in Clan name."));
return;
}
if (args[1].length() < Plugin.getNameMin())
{
UtilPlayer.message(caller, F.main("Clans", "Clan name too short. Minimum length is " + (Plugin.getNameMin()) + "."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name too short. Minimum length is " + (Plugin.getNameMin()) + "."));
return;
}
if (args[1].length() > Plugin.getNameMax())
{
UtilPlayer.message(caller, F.main("Clans", "Clan name too long. Maximum length is " + (Plugin.getNameMax()) + "."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name too long. Maximum length is " + (Plugin.getNameMax()) + "."));
return;
}
if (Plugin.getChat().getFilteredMessage(caller, args[1]).contains("*"))
{
UtilPlayer.message(caller, F.main("Clans", "Clan name inappropriate. Please try a different name"));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name inappropriate. Please try a different name"));
return;
}
if (!ClansBlacklist.isValidClanName(args[1]))
{
UtilPlayer.message(caller, F.main("Clans", "Clan name is blacklisted! Please try a different name."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name is blacklisted! Please try a different name."));
return;
}
@ -259,7 +290,7 @@ public class ClansCommand extends CommandBase<ClansManager>
{
if (clanExists)
{
UtilPlayer.message(caller, F.main("Clans", "Clan name is already in use by another Clan."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name is already in use by another Clan."));
}
else
{
@ -271,11 +302,11 @@ public class ClansCommand extends CommandBase<ClansManager>
if (data == null)
{
// Hopefully shouldn't happen!
UtilPlayer.message(caller, F.main("Clans", "There was an error creating the clan. Please try again"));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error creating the clan. Please try again"));
}
else
{
UtilPlayer.message(caller, F.main("Clans", "You created Clan " + C.cYellow + data.getName() + C.cGray + "."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You created Clan " + C.cYellow + data.getName() + C.cGray + "."));
}
}
});
@ -295,13 +326,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (args.length < 2)
{
UtilPlayer.message(caller, F.main("Clans", "You did not input an invitee."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input an invitee."));
return;
}
@ -315,25 +346,25 @@ public class ClansCommand extends CommandBase<ClansManager>
{
if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId()))
{
UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already in a Clan."));
return;
}
if (!Plugin.Get(caller).canJoin())
{
UtilPlayer.message(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - Plugin.Get(caller).getDelay(), 1, TimeUnit.FIT) + C.mBody + "."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - Plugin.Get(caller).getDelay(), 1, TimeUnit.FIT) + C.mBody + "."));
return;
}
if (args.length < 2)
{
UtilPlayer.message(caller, F.main("Clans", "You did not input a Clan name."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan name."));
return;
}
if (!UtilInput.valid(args[1]))
{
UtilPlayer.message(caller, F.main("Clans", "Invalid characters in Clan name."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Invalid characters in Clan name."));
return;
}
@ -342,13 +373,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (!clan.isInvited(caller.getName()))
{
UtilPlayer.message(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clan.getName()) + "."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clan.getName()) + "."));
return;
}
if (clan.getSize() >= clan.getMaxSize())
{
UtilPlayer.message(caller, F.main("Clans", "The clan " + F.elem("Clan " + clan.getName()) + " is full and cannot be joined!"));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "The clan " + F.elem("Clan " + clan.getName()) + " is full and cannot be joined!"));
return;
}
@ -361,12 +392,12 @@ public class ClansCommand extends CommandBase<ClansManager>
if (data)
{
// Inform
UtilPlayer.message(caller, F.main("Clans", "You joined " + F.elem("Clan " + clan.getName()) + "."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You joined " + F.elem("Clan " + clan.getName()) + "."));
clan.inform(F.name(caller.getName()) + " has joined your Clan.", caller.getName());
}
else
{
UtilPlayer.message(caller, F.main("Clans", "There was an error processing your request"));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request"));
}
}
});
@ -379,13 +410,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (clan.getMembers().get(caller.getUniqueId()).getRole() == ClanRole.LEADER && clan.getMembers().size() > 1)
{
UtilPlayer.message(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving."));
return;
}
@ -399,7 +430,7 @@ public class ClansCommand extends CommandBase<ClansManager>
public void run(Boolean data)
{
// Inform
UtilPlayer.message(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + "."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + "."));
clan.inform(F.name(caller.getName()) + " has left your Clan.", null);
}
});
@ -416,13 +447,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (args.length < 2)
{
UtilPlayer.message(caller, F.main("Clans", "You did not input a Player to kick."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Player to kick."));
return;
}
@ -437,13 +468,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (args.length < 2)
{
UtilPlayer.message(caller, F.main("Clans", "You did not input player to promote."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input player to promote."));
return;
}
@ -458,13 +489,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (args.length < 2)
{
UtilPlayer.message(caller, F.main("Clans", "You did not input player to demote."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input player to demote."));
return;
}
@ -479,19 +510,19 @@ public class ClansCommand extends CommandBase<ClansManager>
if (cA == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
{
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Alliances."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Alliances."));
return;
}
if (args.length < 2)
{
UtilPlayer.message(caller, F.main("Clans", "You did not input a Clan to ally."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan to ally."));
return;
}
@ -501,31 +532,31 @@ public class ClansCommand extends CommandBase<ClansManager>
if (cA.isSelf(cB.getName()))
{
UtilPlayer.message(caller, F.main("Clans", "You cannot ally with yourself."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot ally with yourself."));
return;
}
if (cA.isAlly(cB.getName()))
{
UtilPlayer.message(caller, F.main("Clans", "You are already allies with Clan" + F.elem(cB.getName())) + ".");
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already allies with Clan" + F.elem(cB.getName())) + ".");
return;
}
if (cA.getAllies() >= cA.getAlliesMax())
{
UtilPlayer.message(caller, F.main("Clans", "You cannot have any more allies."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot have any more allies."));
return;
}
if (cB.getAllies() >= cB.getAlliesMax())
{
UtilPlayer.message(caller, F.main("Clans", "Clan " + F.elem(cB.getName()) + " cannot have any more allies."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan " + F.elem(cB.getName()) + " cannot have any more allies."));
return;
}
if (!Recharge.Instance.usable(caller, "AllyReq" + cB.getName()))
{
UtilPlayer.message(caller, F.main("Clans", "Please do not spam alliance requests."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Please do not spam alliance requests."));
return;
}
@ -535,7 +566,7 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.getClanDataAccess().ally(cA, cB, caller.getName());
// Inform
UtilPlayer.message(caller, F.main("Clans", "You accepted alliance with Clan " + F.elem(cB.getName()) + "."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You accepted alliance with Clan " + F.elem(cB.getName()) + "."));
cA.inform(F.name(caller.getName()) + " accepted alliance with Clan " + F.elem(cB.getName()) + ".", caller.getName());
cB.inform("Clan " + F.elem(cA.getName()) + " has accepted alliance with you.", null);
}
@ -545,7 +576,7 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.getClanDataAccess().requestAlly(cA, cB, caller.getName());
// Inform
UtilPlayer.message(caller, F.main("Clans", "You requested alliance with Clan " + F.elem(cB.getName()) + "."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You requested alliance with Clan " + F.elem(cB.getName()) + "."));
cA.inform(F.name(caller.getName()) + " has requested alliance with Clan " + F.elem(cB.getName()) + ".", caller.getName());
cB.inform("Clan " + F.elem(cA.getName()) + " has requested alliance with you.", null);
@ -559,19 +590,19 @@ public class ClansCommand extends CommandBase<ClansManager>
//
// if (cA == null)
// {
// UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
// _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
// return;
// }
//
// if (cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
// {
// UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Trust."));
// _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Trust."));
// return;
// }
//
// if (args.length < 2)
// {
// UtilPlayer.message(caller, F.main("Clans", "You did not input a Clan to enemy."));
// _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan to enemy."));
// return;
// }
//
@ -581,7 +612,7 @@ public class ClansCommand extends CommandBase<ClansManager>
//
// if (!cA.isAlly(cB.getName()))
// {
// UtilPlayer.message(caller, F.main("Clans", "You must be allied to trust a clan!"));
// _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must be allied to trust a clan!"));
// return;
// }
//
@ -589,14 +620,14 @@ public class ClansCommand extends CommandBase<ClansManager>
// if (Plugin.getClanDataAccess().trust(cA, cB, caller.getName()))
// {
// // Inform
// UtilPlayer.message(caller, F.main("Clans", "You gave trust to " + F.elem("Clan " + cB.getName()) + "."));
// _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You gave trust to " + F.elem("Clan " + cB.getName()) + "."));
// cA.inform(F.name(caller.getName()) + " has given trust to " + F.elem("Clan " + cB.getName()) + ".", caller.getName());
// cB.inform(F.elem("Clan " + cA.getName()) + " has given trust to you.", null);
// }
// else
// {
// // Inform
// UtilPlayer.message(caller, F.main("Clans", "You revoked trust to " + F.elem("Clan " + cB.getName()) + "."));
// _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You revoked trust to " + F.elem("Clan " + cB.getName()) + "."));
// cA.inform(F.name(caller.getName()) + " has revoked trust to " + F.elem("Clan " + cB.getName()) + ".", caller.getName());
// cB.inform(F.elem("Clan " + cA.getName()) + " has revoked trust to you.", null);
// }
@ -608,19 +639,19 @@ public class ClansCommand extends CommandBase<ClansManager>
if (cA == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
{
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage relationships."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can manage relationships."));
return;
}
if (args.length < 2)
{
UtilPlayer.message(caller, F.main("Clans", "You did not input a Clan to set neutrality with."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan to set neutrality with."));
return;
}
@ -630,11 +661,11 @@ public class ClansCommand extends CommandBase<ClansManager>
if (cB.isSelf(cA.getName()))
{
UtilPlayer.message(caller, F.main("Clans", "You prefer to think of yourself positively..."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You prefer to think of yourself positively..."));
}
else if (cB.isNeutral(cA.getName()))
{
UtilPlayer.message(caller, F.main("Clans", "You are already neutral with " + F.elem("Clan " + cB.getName()) + "."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already neutral with " + F.elem("Clan " + cB.getName()) + "."));
}
else if (cB.isAlly(cA.getName()))
{
@ -642,7 +673,7 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.getClanDataAccess().neutral(cA, cB, caller.getName(), true);
// Inform
UtilPlayer.message(caller, F.main("Clans", "You revoked alliance with " + F.elem("Clan " + cB.getName()) + "."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You revoked alliance with " + F.elem("Clan " + cB.getName()) + "."));
cA.inform(F.name(caller.getName()) + " revoked alliance with " + F.elem("Clan " + cB.getName()) + ".", caller.getName());
cB.inform(F.elem("Clan " + cA.getName()) + " has revoked alliance with you.", null);
}
@ -683,7 +714,7 @@ public class ClansCommand extends CommandBase<ClansManager>
}
// Change Inform
UtilPlayer.message(caller, F.main("Clans", "You can no longer 'steal' territory. " + "You simply unclaim it and it can not be reclaimed by anyone for 30 mintes." + "This was done to improve gameplay. Enjoy!"));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can no longer 'steal' territory. " + "You simply unclaim it and it can not be reclaimed by anyone for 30 mintes." + "This was done to improve gameplay. Enjoy!"));
// Inform
UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + "."));
@ -719,31 +750,31 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (clan.getHome() == null)
{
UtilPlayer.message(caller, F.main("Clans", "Your Clan has not set a Home"));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan has not set a Home"));
return;
}
if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(clan.getHome().getChunk())))
{
UtilPlayer.message(caller, F.main("Clans", "Your Clan has lost its Home Territory."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan has lost its Home Territory."));
return;
}
if (!Plugin.getClanUtility().isSafe(caller.getLocation()))
{
UtilPlayer.message(caller, F.main("Clans", "You can only use Clan Home from Spawn."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can only use Clan Home from Spawn."));
return;
}
if (!Plugin.getClanUtility().isSpecial(caller.getLocation(), "Spawn"))
{
UtilPlayer.message(caller, F.main("Clans", "You can only use Clan Home from Spawn."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can only use Clan Home from Spawn."));
return;
}
@ -751,7 +782,7 @@ public class ClansCommand extends CommandBase<ClansManager>
if (!(home.getBlock().getType().equals(Material.BED_BLOCK) && home.add(0, 1, 0).getBlock().getType().equals(Material.AIR)) && home.add(0, 2, 0).getBlock().getType().equals(Material.AIR))
{
UtilPlayer.message(caller, F.main("Clans", "Your Clan's bed has been destroyed, or is obstructed."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan's bed has been destroyed, or is obstructed."));
return;
}
@ -760,7 +791,7 @@ public class ClansCommand extends CommandBase<ClansManager>
* (Player cur : clan.GetHome().getWorld().getPlayers()) if
* (client.Clan().GetRelation(cur.getName()) == ClanRelation.NEUTRAL) if
* (clan.GetClaimSet().contains(UtilWorld.chunkToStr(cur.getLocation().
* getChunk()))) { UtilPlayer.message(caller, F.main("Clans",
* getChunk()))) { _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans",
* "You cannot use Clan Home with enemies in your Territory.")); return;
* }
*/
@ -772,7 +803,7 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.getTeleport().TP(caller, clan.getHome().add(0, 1, 0));
// Inform
UtilPlayer.message(caller, F.main("Clans", "You teleported to your Clan Home " + UtilWorld.locToStrClean(caller.getLocation()) + "."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You teleported to your Clan Home " + UtilWorld.locToStrClean(caller.getLocation()) + "."));
}
public void homeSet(Player caller)
@ -790,31 +821,31 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
{
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Clan Home."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Clan Home."));
return;
}
if (Plugin.getClanUtility().getOwner(caller.getLocation()) == null)
{
UtilPlayer.message(caller, F.main("Clans", "You must set your Clan Home in your own Territory."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must set your Clan Home in your own Territory."));
return;
}
if (!Plugin.getClanUtility().getOwner(caller.getLocation()).isSelf(clan.getName()))
{
UtilPlayer.message(caller, F.main("Clans", "You must set your Clan Home in your own Territory."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must set your Clan Home in your own Territory."));
return;
}
if (!(caller.getLocation().add(0, 1, 0).getBlock().getType().equals(Material.AIR) && caller.getLocation().add(0, 2, 0).getBlock().getType().equals(Material.AIR)))
{
UtilPlayer.message(caller, F.main("Clans", "This is not a suitable place for a bed."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This is not a suitable place for a bed."));
return;
}
@ -823,7 +854,7 @@ public class ClansCommand extends CommandBase<ClansManager>
if (!bedPlaced)
{
UtilPlayer.message(caller, F.main("Clans", "This is not a suitable place for a bed."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This is not a suitable place for a bed."));
return;
}
@ -839,7 +870,7 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.ClanTips.displayTip(TipType.SETHOME, caller);
// Inform
UtilPlayer.message(caller, F.main("Clans", "You set Clan Home to " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + "."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You set Clan Home to " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + "."));
clan.inform(caller.getName() + " set Clan Home to " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".", caller.getName());
}
@ -847,7 +878,7 @@ public class ClansCommand extends CommandBase<ClansManager>
{System.out.println(search);
if (search == null)
{
UtilPlayer.message(caller, F.main("Clans", "You did not input a search parameter."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a search parameter."));
return;
}
@ -869,13 +900,13 @@ public class ClansCommand extends CommandBase<ClansManager>
{
if (_manager.getClientManager().hasRank(caller, Rank.ADMIN))
{
UtilPlayer.message(caller, F.main("Clans", "No no no, this command is not for you ;-)"));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "No no no, this command is not for you ;-)"));
return;
}
if (search == null)
{
UtilPlayer.message(caller, F.main("Clans", "You did not input a search parameter."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a search parameter."));
return;
}
@ -904,7 +935,7 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
return;
}
}
@ -914,6 +945,6 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null) return;
UtilPlayer.message(caller, clan.mTerritory());
_manager.getTutorials().sendTutorialMsg(caller, clan.mTerritory());
}
}

View File

@ -16,7 +16,7 @@ public class RegionsCommand extends CommandBase<ClansManager>
public RegionsCommand(ClansManager plugin)
{
super(plugin, Rank.ADMIN, new Rank[]{Rank.JNR_DEV},"region-reset");
super(plugin, Rank.ADMIN,"region-reset");
_manager = plugin;
}

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.task.TaskManager;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.tutorials.Tutorial;
import mineplex.game.clans.tutorials.TutorialManager;
import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted;
@ -15,26 +16,34 @@ public class RestartTutCommand extends CommandBase<TutorialManager>
{
public RestartTutCommand(TutorialManager plugin)
{
super(plugin, Rank.ALL, "rst", "rstut");
super(plugin, Rank.ALL, "rst", "rstut", "reset");
}
@Override
public void Execute(Player caller, String[] args)
{
String ignoreString = String.format(Tutorial.TUTORIAL_REWARD_TASK, "GettingStartedTutorial");
Integer ignoreInt = TaskManager.Instance.getTaskId(ignoreString);
Iterator<Integer> it = TaskManager.Instance.Get(caller).TasksCompleted.iterator();
while (it.hasNext())
if (ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()) != null
&& ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).isSafe(caller.getLocation()))
{
Integer i = it.next();
if (i != null && (ignoreInt == null || i.intValue() != ignoreInt.intValue()))
String ignoreString = String.format(Tutorial.TUTORIAL_REWARD_TASK, "GettingStartedTutorial");
Integer ignoreInt = TaskManager.Instance.getTaskId(ignoreString);
Iterator<Integer> it = TaskManager.Instance.Get(caller).TasksCompleted.iterator();
while (it.hasNext())
{
it.remove();
Integer i = it.next();
if (i != null && (ignoreInt == null || i.intValue() != ignoreInt.intValue()))
{
it.remove();
}
}
TutorialManager.Instance.cancelTutorial(caller);
TutorialManager.Instance.startTutorial(TutorialGettingStarted.class, caller);
}
else
{
TutorialManager.Instance.sendTutorialMsg(caller, "You must be in a safezone to restart the tutorial.");
}
TutorialManager.Instance.cancelTutorial(caller);
TutorialManager.Instance.startTutorial(TutorialGettingStarted.class, caller);
}
}

View File

@ -0,0 +1,63 @@
package mineplex.game.clans.clans.event;
import org.bukkit.Chunk;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.game.clans.clans.ClanInfo;
public class PlayerPreClaimTerritoryEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _claimer;
private Chunk _claimedChunk;
private boolean _cancelled;
private ClanInfo _clan;
public PlayerPreClaimTerritoryEvent(Player claimer, Chunk claimedChunk, ClanInfo clan)
{
_claimer = claimer;
_claimedChunk = claimedChunk;
_clan = clan;
}
public Player getClaimer()
{
return _claimer;
}
public ClanInfo getClan()
{
return _clan;
}
public Chunk getClaimedChunk()
{
return _claimedChunk;
}
public void setCancelled(boolean cancelled)
{
_cancelled = cancelled;
}
public boolean isCancelled()
{
return _cancelled;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -740,16 +740,13 @@ public class ItemMapManager extends MiniPlugin
boolean outsideMap = startingZ < -_halfMapSize;
TimingManager.start("renderMap.scanWorldMap");
scanWorldMap(startingX, startingZ, !outsideMap);
TimingManager.stop("renderMap.scanWorldMap");
if (outsideMap)
{
return;
}
TimingManager.start("renderMap.scale loop");
for (int scale = 1; scale < _scale.size(); scale++)
{
if (scale == 3 && _loadWorld)
@ -762,11 +759,8 @@ public class ItemMapManager extends MiniPlugin
colorWorldHeight(scale, startingX, startingZ);
}
TimingManager.stop("renderMap.scale loop");
TimingManager.start("renderMap.colorWorldHeight 0");
colorWorldHeight(0, startingX, startingZ);
TimingManager.stop("renderMap.colorWorldHeight 0");
}
public void scanWorldMap(int startingX, int startingZ, boolean setColors)

View File

@ -86,7 +86,8 @@ public class ItemMapRenderer extends MapRenderer
{
boolean colorAll = scale > 0;
Color clanColor = null;
Color clanColor2 = null;
if (owningClan == clan)
{
clanColor = Color.CYAN;
@ -94,18 +95,33 @@ public class ItemMapRenderer extends MapRenderer
else
{
ClansUtility.ClanRelation relation = _manager.getClansUtility().rel(clan, owningClan);
if (owningClan.isAdmin())
{
colorAll = false;
if (owningClan.getName().equals("Shops") || owningClan.getName().equals("Spawn"))
if (owningClan.getName().equals("Shops"))
{
clanColor = Color.WHITE;
clanColor2 = new Color(50, 150, 255);
if (_manager.getClansUtility().relPT(player, chunk) == ClansUtility.ClanRelation.SAFE)
clanColor2 = new Color(50, 150, 255);
}
else if (owningClan.getName().equals("Spawn"))
{
clanColor = Color.WHITE;
clanColor2 = new Color(0, 255, 100);
}
else if (owningClan.getName().equals("Fields"))
{
clanColor = Color.WHITE;
clanColor2 = new Color(255, 120, 0);
}
else
{
clanColor = Color.GRAY;
clanColor = Color.WHITE;
clanColor2 = Color.GRAY;
}
}
else if (relation == ClansUtility.ClanRelation.WAR_LOSING)
@ -138,44 +154,68 @@ public class ItemMapRenderer extends MapRenderer
int chunkX1 = (int) Math.floor(blockX / 16D);
int chunkZ1 = (int) Math.floor(blockZ / 16D);
//Border
if (colorAll ||
((chunkBX == 0 || zoom == 13) &&
owningClan != _manager.getClansUtility().getOwner("world," + (chunkX1 - 1) + "," + chunkZ1))
|| ((chunkBZ == 0 || zoom == 13) &&
owningClan != _manager.getClansUtility().getOwner("world," + chunkX1 + "," + (chunkZ1 - 1)))
|| ((chunkBX + zoom > 15 || zoom == 13) &&
owningClan != _manager.getClansUtility().getOwner("world," + (chunkX1 + 1) + "," + chunkZ1))
|| ((chunkBZ + zoom > 15 || zoom == 13) &&
owningClan != _manager.getClansUtility().getOwner("world," + chunkX1 + "," + (chunkZ1 + 1))))
((chunkBX == 0 || zoom == 13) &&
owningClan != _manager.getClansUtility().getOwner("world," + (chunkX1 - 1) + "," + chunkZ1))
|| ((chunkBZ == 0 || zoom == 13) &&
owningClan != _manager.getClansUtility().getOwner("world," + chunkX1 + "," + (chunkZ1 - 1)))
|| ((chunkBX + zoom > 15 || zoom == 13) &&
owningClan != _manager.getClansUtility().getOwner("world," + (chunkX1 + 1) + "," + chunkZ1))
|| ((chunkBZ + zoom > 15 || zoom == 13) &&
owningClan != _manager.getClansUtility().getOwner("world," + chunkX1 + "," + (chunkZ1 + 1))))
{
Color cColor = MapPalette.getColor(color);
double clans = colorAll ? 1 : 0.8;// 0.65;
//Use clanColor2 no matter what for admins
Color drawColor = clanColor;
if (owningClan.isAdmin() && clanColor2 != null)
{
drawColor = clanColor2;
clans = 1;
}
double base = 1 - clans;
int r = (int) ((cColor.getRed() * base) + (clanColor.getRed() * clans));
int b = (int) ((cColor.getBlue() * base) + (clanColor.getBlue() * clans));
int g = (int) ((cColor.getGreen() * base) + (clanColor.getGreen() * clans));
int r = (int) ((cColor.getRed() * base) + (drawColor.getRed() * clans));
int b = (int) ((cColor.getBlue() * base) + (drawColor.getBlue() * clans));
int g = (int) ((cColor.getGreen() * base) + (drawColor.getGreen() * clans));
color = MapPalette.matchColor(r, g, b);
}
//Inside
else
{
Color cColor = MapPalette.getColor(color);
double clans = 0.65;// 0.4;
double clans = 0.065;
//Stripes
boolean checker = (mapX + (mapZ % 4)) % 4 == 0;
Color drawColor = clanColor;
if (checker && owningClan.isAdmin() && clanColor2 != null)
{
drawColor = clanColor2;
clans = 1;
}
double base = 1 - clans;
int r = (int) ((cColor.getRed() * base) + (clanColor.getRed() * clans));
int b = (int) ((cColor.getBlue() * base) + (clanColor.getBlue() * clans));
int g = (int) ((cColor.getGreen() * base) + (clanColor.getGreen() * clans));
int r = (int) ((cColor.getRed() * base) + (drawColor.getRed() * clans));
int b = (int) ((cColor.getBlue() * base) + (drawColor.getBlue() * clans));
int g = (int) ((cColor.getGreen() * base) + (drawColor.getGreen() * clans));
color = MapPalette.matchColor(r, g, b);
}

View File

@ -27,8 +27,9 @@ public class ScoreboardElementPlayerCount implements ScoreboardElement
public List<String> getLines(ScoreboardManager manager, Player player, List<String> out)
{
List<String> output = new ArrayList<String>();
output.add(C.cYellow + "Players Online: " + UtilServer.getPlayers().length + "/100");
output.add("");
output.add(C.cYellow + "Players Online " + UtilServer.getPlayers().length + "/100");
return output;
}

View File

@ -12,7 +12,7 @@ import mineplex.minecraft.game.core.boss.WorldEvent;
public enum WorldEventType
{
// SLIME_KING("Slime King", SlimeBoss.class, 30),
KING_HILL("King of The Hill", KingHill.class, 30),
// KING_HILL("King of The Hill", KingHill.class, 30),
UNDEAD_CAMP("Undead Camp", UndeadCamp.class, 30);// ,
// Golem("Iron Wizard", GolemBoss.class, 30);

View File

@ -41,7 +41,7 @@ public class HillData
public boolean isOnHill(Location location, Location eventLocation)
{
return location.getWorld().equals(eventLocation.getWorld()) && UtilMath.offset(location, eventLocation) <= 36;
return location.getWorld().equals(eventLocation.getWorld()) && UtilMath.offset(location, eventLocation.clone().add(0, 12, 0)) <= 7.5;
}
public Location getHillCenter(Location eventLocation)

View File

@ -117,7 +117,7 @@ public class KingHill extends WorldEvent
if (_hill.isOnHill(player.getLocation(), getCenterLocation()))
{
ClanInfo playerClan = _clansManager.getClan(player);
if (playerClan != null)
if (playerClan != null && !playerClan.equals(lastClan))
{
clanCount++;
lastClan = playerClan;

View File

@ -55,6 +55,7 @@ import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
@ -433,7 +434,7 @@ public class Gameplay extends MiniPlugin
@EventHandler(priority = EventPriority.LOWEST)
public void replantTree(BlockBreakEvent event)
{
Block block = event.getBlock();
final Block block = event.getBlock();
if (!UtilItem.isLog(block.getType()))
{
@ -455,22 +456,15 @@ public class Gameplay extends MiniPlugin
return;
}
Location saplingArea = null;
final byte data = block.getData();
for (Block otherBlock : UtilBlock.getInRadius(event.getBlock().getLocation(), 4.5).keySet())
{
if (!otherBlock.equals(UtilBlock.getHighest(otherBlock.getLocation().getWorld(), otherBlock.getX(), otherBlock.getZ())))
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() {
public void run()
{
saplingArea = otherBlock.getLocation();
if (Math.random() > .75)
{
break;
}
block.setType(Material.SAPLING);
block.setData(data);
}
}
saplingArea.add(0, 1, 0).getBlock().setType(Material.SAPLING);
saplingArea.getBlock().setData(block.getData());
}, 20 * 5);
}
@EventHandler

View File

@ -12,7 +12,7 @@ public class GearCommand extends CommandBase<GearManager>
public GearCommand(GearManager plugin)
{
super(plugin, Rank.ADMIN, new Rank[]{Rank.JNR_DEV}, "gear", "custom-gear");
super(plugin, Rank.ADMIN, "gear", "custom-gear");
_gearManager = plugin;
}

View File

@ -1,46 +0,0 @@
package mineplex.game.clans.tutorials;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
public class DeployedTask implements Listener
{
protected Player _player;
protected boolean _finished;
protected TutorialTask<?> _task;
protected boolean _dead;
public DeployedTask(Player player, TutorialTask<?> task)
{
_player = player;
_task = task;
}
public void postDeploy()
{
}
public boolean checkForDeath()
{
return _dead || _player == null;
}
public void finish()
{
onFinish();
_task.finishFor(_player);
}
public void kill()
{
_dead = true;
_player = null;
}
public void onFinish() {
}
}

View File

@ -29,7 +29,11 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.scoreboard.ScoreboardManager;
import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.core.task.TaskManager;
@ -38,6 +42,7 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClanTipEvent;
import mineplex.game.clans.economy.GoldManager;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
/**
*
@ -53,6 +58,8 @@ public abstract class Tutorial implements ScoreboardElement, Listener
public static String TUTORIAL_REWARD_TASK = "tatatatatat%sRewardGiven"; //do not change
public static String SKIPPED_TASK = "tatatatata%sSkip";
public static String AllowedMessage = C.cGold + "TutorialAllowedMessage" + C.Reset;
protected final TutorialManager _manager;
protected final GoldManager _goldManager;
protected final ClansManager _clansManager;
@ -75,7 +82,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
protected int _gemReward = -1;
protected int _coinReward = -1;
public Tutorial(final GoldManager goldManager, final TaskManager taskManager, final ClansManager clansManager, final DonationManager donationManager, final TutorialManager manager)
public Tutorial(final GoldManager goldManager, final TaskManager taskManager, final ClansManager clansManager, final DonationManager donationManager, final TutorialManager manager, final PacketHandler packetHandler)
{
_clansManager = clansManager;
_goldManager = goldManager;
@ -144,40 +151,62 @@ public abstract class Tutorial implements ScoreboardElement, Listener
protected boolean hasFinishedTask(Player player, TutorialTask<?> task)
{
if (get(player).QueuedFinish)
{
return true;
}
return get(player).CurrentTask.getID() < task.getID();
}
protected void finishTask(final Player player, final TutorialTask<?> task)
{
if (player == null)
{
return;
}
get(player).LastDescriptionSentTime = 0;
get(player).CurrentTask.visibleFinish(player);
get(player).CurrentTask = task.equals(_tasks.get(_tasks.size())) ? null : _tasks.get(task.getID() + 1);
if (!_taskManager.hasCompletedTask(player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName())))
// 6 Seconds for player to read the finish message (sent by the line above)
// (will be instant if get(player).CurrentTask.getFinishMessage() is null).
_manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
{
_taskManager.completedTask(new Callback<Boolean>()
public void run()
{
public void run(final Boolean completed)
// Cycle to next task, or null if last task.
get(player).CurrentTask = task.equals(_tasks.get(_tasks.size())) ? null : _tasks.get(task.getID() + 1);
if (!_taskManager.hasCompletedTask(player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName())))
{
if (task.equals(_tasks.get(_tasks.size())))
_taskManager.completedTask(new Callback<Boolean>()
{
finishFor(player);
}
else
{
_manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
public void run(final Boolean completed)
{
public void run()
// If last task, end tutorial.
if (task.equals(_tasks.get(_tasks.size())))
{
get(player).CurrentTask.deploy(player);
finishFor(player);
}
}, 10L);
}
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
else
{
// Start next task in 1.5 Seconds (just to give a more smooth feel to the tutorial)
_manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
{
public void run()
{
get(player).CurrentTask.startFor(player);
}
}, 30L);
}
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
}
}, player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName()));
}
}, player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName()));
}
}
}, get(player).CurrentTask._finishMessage == null ? 1L : 6 * 20L);
}
public TutorialTask<?> getTask(final String technicalName)
@ -223,77 +252,95 @@ public abstract class Tutorial implements ScoreboardElement, Listener
private void finishFor(final Player player)
{
if (player.getOpenInventory() != null)
{
_inTutorial.get(player.getName()).QueuedFinish = true;
return;
}
_inTutorial.remove(player.getName());
UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, Color.LIME, false, false, new Vector(0, 0, 0), 1);
onFinished(player);
if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_REWARD_TASK, _technicalName)))
UtilTextMiddle.display(C.cWhite + "Clans Tutorial", C.cGreen + "You have completed the Clans Tutorial!", 20, 20 * 3, 20);
_manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
{
_taskManager.completedTask(new Callback<Boolean>()
public void run()
{
@Override
public void run(Boolean data)
// Custom Finish Method (usually messages)
onFinished(player);
// Do Reward
if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_REWARD_TASK, _technicalName)))
{
if (_goldReward != -1)
_taskManager.completedTask(new Callback<Boolean>()
{
_goldManager.addGold(player, _goldReward);
UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gold") + "."));
}
if (_gemReward != -1)
{
_donationManager.RewardGems(new Callback<Boolean>() {
public void run(Boolean data)
{
UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gems") + "."));
}
}, "Clans", player.getName(), player.getUniqueId(), _gemReward);
}
if (_coinReward != -1)
{
_donationManager.RewardCoins(new Callback<Boolean>() {
public void run(Boolean data)
{
UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_coinReward + " Coins") + "."));
}
}, "Clans", player.getName(), _clansManager.getClientManager().getAccountId(player), _coinReward);
}
}
}, player, String.format(TUTORIAL_REWARD_TASK, _technicalName));
}
if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName)))
{
_taskManager.completedTask(new Callback<Boolean>()
{
public void run(final Boolean completed)
{
if (_ghostMode)
{
for (Player other : UtilServer.getPlayers())
@Override
public void run(Boolean data)
{
other.showPlayer(player);
player.showPlayer(other);
if (_goldReward != -1)
{
_goldManager.addGold(player, _goldReward);
_manager.sendTutorialMsg(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gold") + "."));
}
if (_gemReward != -1)
{
_donationManager.RewardGems(new Callback<Boolean>() {
public void run(Boolean data)
{
_manager.sendTutorialMsg(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gems") + "."));
}
}, "Clans", player.getName(), player.getUniqueId(), _gemReward);
}
if (_coinReward != -1)
{
_donationManager.RewardCoins(new Callback<Boolean>() {
public void run(Boolean data)
{
_manager.sendTutorialMsg(player, F.main("Tutorials", "You have been awarded " + F.elem(_coinReward + " Coins") + "."));
}
}, "Clans", player.getName(), _clansManager.getClientManager().getAccountId(player), _coinReward);
}
}
}
for (int i = 0; i < 8; i++)
{
final int index = i;
_manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
{
public void run()
{
UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, (index % 2 == 0) ? Color.RED : Color.LIME, false, false, new Vector(0, 0, 0), 0);
}
}, i * 10);
}
}, player, String.format(TUTORIAL_REWARD_TASK, _technicalName));
}
}, player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName));
}
_manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
{
public void run()
{
// Sets the tutorial as complete in the TaskManager and effects.
_taskManager.completedTask(new Callback<Boolean>()
{
public void run(final Boolean completed)
{
if (_ghostMode)
{
for (Player other : UtilServer.getPlayers())
{
other.showPlayer(player);
player.showPlayer(other);
}
}
for (int i = 0; i < 8; i++)
{
final int index = i;
_manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
{
public void run()
{
UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, (index % 2 == 0) ? Color.RED : Color.LIME, false, false, new Vector(0, 0, 0), 0);
}
}, i * 10);
}
}
}, player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName));
}
}, 20 * 2);
}
}, 20 * 4);
}
// Implementation left to sub classes.
@ -315,7 +362,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
_inTutorial.put(player.getName(), new TutorialClient(player, this));
get(player).CurrentTask.deploy(player);
get(player).CurrentTask.startFor(player);
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
@ -373,6 +420,9 @@ public abstract class Tutorial implements ScoreboardElement, Listener
public void skip(final Player player)
{
new JsonMessage(
AllowedMessage
)
.extra(
F.main(
"Tutorial",
"Are you sure you want to skip the tutorial? We "
@ -443,6 +493,19 @@ public abstract class Tutorial implements ScoreboardElement, Listener
{
if (isInTutorial(player))
{
if (get(player).QueuedFinish)
{
if (player.getOpenInventory() == null)
{
get(player).QueuedFinish = false;
finishFor(player);
}
else
{
continue;
}
}
get(player).CurrentTask.trySendDescription(player);
}
}

View File

@ -9,6 +9,8 @@ public class TutorialClient
public Player Player;
public TutorialTask<?> CurrentTask;
public long LastDescriptionSentTime = System.currentTimeMillis() - 3000;
public boolean InClanOnStart;
public boolean QueuedFinish;
public TutorialClient(Player player, Tutorial tutorial)
{
@ -16,11 +18,15 @@ public class TutorialClient
CurrentTask = tutorial._tasks.get(1);
InClanOnStart = tutorial._clansManager.isInClan(player);
for (TutorialTask<?> task : tutorial._tasks.values())
{
if (TaskManager.Instance.hasCompletedTask(player, String.format(
Tutorial.TASK_COMPLETE_TASK,
task.getTutorial().getTechnicalName(), task.getTechnicalName())))
task.getTutorial().getTechnicalName(),
task.getTechnicalName()
)))
{
if (CurrentTask.getID() <= task.getID())
{

View File

@ -1,6 +1,7 @@
package mineplex.game.clans.tutorials;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import org.bukkit.entity.Player;
@ -12,6 +13,9 @@ import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.task.TaskManager;
import mineplex.game.clans.clans.ClansManager;
@ -20,6 +24,8 @@ import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.tutorials.commands.DoSkipTutorialCommand;
import mineplex.game.clans.tutorials.commands.SkipTutorialCommand;
import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted;
import net.md_5.bungee.api.ChatColor;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
public class TutorialManager extends MiniPlugin
{
@ -30,7 +36,7 @@ public class TutorialManager extends MiniPlugin
private final TaskManager _taskManager;
public TutorialManager(final JavaPlugin plugin, final GoldManager goldManager, final TaskManager taskManager, final DonationManager donationManager, final PreferencesManager preferencesManager, final ClansManager clansManager)
public TutorialManager(final JavaPlugin plugin, final GoldManager goldManager, final TaskManager taskManager, final DonationManager donationManager, final PreferencesManager preferencesManager, final ClansManager clansManager, final PacketHandler packetHandler)
{
super("Tutorials", plugin);
@ -38,7 +44,37 @@ public class TutorialManager extends MiniPlugin
_taskManager = taskManager;
_tutorials.put(TutorialGettingStarted.class, new TutorialGettingStarted(this, clansManager, donationManager, goldManager,taskManager));
_tutorials.put(TutorialGettingStarted.class, new TutorialGettingStarted(this, clansManager, donationManager, goldManager, taskManager, packetHandler));
packetHandler.addPacketHandler(new IPacketHandler() {
public void handle(PacketInfo packet)
{
if (packet.getPacket() instanceof PacketPlayOutChat)
{
PacketPlayOutChat chat = (PacketPlayOutChat) packet.getPacket();
if (chat.b == 1)
{
if (chat.a.a().isEmpty())
{
return;
}
if (chat.a.a().get(0).c().equals(ChatColor.stripColor(Tutorial.AllowedMessage)))
{
chat.a.a().remove(0);
}
else
{
if (isInTutorial(packet.getPlayer()))
{
packet.setCancelled(true);
}
}
}
}
}
}, PacketPlayOutChat.class);
}
public void addCommands()
@ -58,7 +94,6 @@ public class TutorialManager extends MiniPlugin
if (_tutorials.containsKey(tutorial))
{
_tutorials.get(tutorial).startFor(player);
_playerTutorials.put(player.getName(), _tutorials.get(tutorial));
return isInTutorial(player);
}
@ -78,7 +113,7 @@ public class TutorialManager extends MiniPlugin
getTutorial(player).cancelFor(player);
UtilPlayer.message(player, F.main("Tutorials", "You have cancelled the " + F.elem(getTutorial(player)._displayName + " Tutorial") + "."));
sendTutorialMsg(player, F.main("Tutorials", "You have cancelled the " + F.elem(getTutorial(player)._displayName + " Tutorial") + "."));
_playerTutorials.remove(player.getName());
}
}
@ -95,7 +130,7 @@ public class TutorialManager extends MiniPlugin
{
if (isInTutorial(player))
{
UtilPlayer.message(player, F.main("Tutorials", "You have skipped the " + F.elem(getTutorial(player)._displayName + " Tutorial") + "."));
sendTutorialMsg(player, F.main("Tutorials", "You have skipped the " + F.elem(getTutorial(player)._displayName + " Tutorial") + "."));
getTutorial(player).doSkip(player);
}
}
@ -109,6 +144,19 @@ public class TutorialManager extends MiniPlugin
getTutorial(event.getPlayer()).cleanup(event.getPlayer());
}
public void sendTutorialMsg(Player player, String message)
{
player.sendMessage(Tutorial.AllowedMessage + message);
}
public void sendTutorialMsg(Player player, LinkedList<String> messages)
{
for (String message : messages)
{
sendTutorialMsg(player, message);
}
}
public Tutorial getTutorial(final Player player)
{
return _playerTutorials.get(player.getName());

View File

@ -1,25 +1,18 @@
package mineplex.game.clans.tutorials;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.NautArrayList;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.game.clans.clans.ClansManager;
public class TutorialTask<T extends Tutorial> implements Listener
{
private T _tutorial;
protected T _tutorial;
protected long _autoCompleteTime = -1;
@ -29,13 +22,17 @@ public class TutorialTask<T extends Tutorial> implements Listener
protected String _description;
protected String _finishMessage;
protected Location _taskPos;
// How much time after the beginning the task/last teleport it should take to teleport back to _taskPos.
protected int _taskTpDelay = 2 * 60 * 20;
protected long _descriptionWaitTime = 30000;
private List<String> _playersFinished = new ArrayList<>();
private Map<String, DeployedTask> _deployedInstances = new HashMap<>();
private List<DeployedTask> _toCull = new ArrayList<>();
protected NautArrayList<String> _playersFinished = new NautArrayList<>();
protected NautArrayList<String> _inTask = new NautArrayList<>();
private long _lastTaskTp;
private int _id;
public TutorialTask(T tutorial, int id)
@ -46,32 +43,58 @@ public class TutorialTask<T extends Tutorial> implements Listener
UtilServer.getServer().getPluginManager().registerEvents(this, _tutorial._manager.getPlugin());
}
protected DeployedTask deploy(final Player player)
protected void customStartFor(final Player player)
{
DeployedTask task = customDeploy(player);
_deployedInstances.put(player.getName(), task);
UtilServer.getServer().getPluginManager().registerEvents(task, _tutorial._manager.getPlugin());
}
protected void customEndFor(final Player player)
{
}
protected final void startFor(final Player player)
{
_inTask.add(player.getName());
trySendDescription(player);
customStartFor(player);
if (_taskPos != null)
{
player.teleport(_taskPos);
_lastTaskTp = System.currentTimeMillis();
if (_taskTpDelay != -1)
{
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_tutorial._manager.getPlugin(), new Runnable(){
public void run()
{
if (isDoing(player))
{
player.teleport(_taskPos);
_lastTaskTp = System.currentTimeMillis();
}
}
}, _taskTpDelay);
}
}
if (_autoCompleteTime != -1)
{
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_tutorial._manager.getPlugin(), new Runnable(){
public void run()
{
if (_deployedInstances.containsKey(player.getName()))
if (isDoing(player))
{
finishFor(player);
}
}
}, _autoCompleteTime);
}
task.postDeploy();
return task;
}
public boolean isDoing(Player player)
{
return _inTask != null && player != null && _inTask.contains(player.getName());
}
public void trySendDescription(Player player)
@ -83,34 +106,38 @@ public class TutorialTask<T extends Tutorial> implements Listener
TutorialClient client = _tutorial.get(player);
if (client.QueuedFinish)
{
return;
}
if (System.currentTimeMillis() - client.LastDescriptionSentTime > client.CurrentTask.getDescriptionWaitTime())
{
UtilPlayer.message(player, " ");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cYellowB + "Part " + _id + ": " + _displayName);
UtilPlayer.message(player, C.cWhite + _description.replace("{", C.cAqua).replace("}", C.cWhite));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cYellowB + "Part " + _id + ": " + _displayName);
_tutorial._manager.sendTutorialMsg(player, C.cWhite + " " + _description.replace("{", C.cAqua).replace("}", C.cWhite));
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilTextMiddle.display("", getDisplayName());
client.LastDescriptionSentTime = System.currentTimeMillis();
}
}
protected DeployedTask customDeploy(final Player player)
{
return new DeployedTask(player, this);
}
public final void startFor(Player player)
{
deploy(player);
}
public final boolean hasFinished(final Player player)
{
return _playersFinished.contains(player.getName());
if (_tutorial.get(player).QueuedFinish)
{
return true;
}
// CurrentTask will be null if player has finished tutorial
return _tutorial.get(player).CurrentTask == null || _tutorial.get(player).CurrentTask.getID() < getID();
}
public String getDisplayName()
@ -133,6 +160,16 @@ public class TutorialTask<T extends Tutorial> implements Listener
return _technicalName;
}
public TutorialManager getManager()
{
return _tutorial._manager;
}
public ClansManager getClans()
{
return _tutorial._clansManager;
}
public int getID()
{
return _id;
@ -140,52 +177,30 @@ public class TutorialTask<T extends Tutorial> implements Listener
public void finishFor(Player player)
{
customEndFor(player);
_tutorial.finishTask(player, this);
}
public void visibleFinish(Player player)
{
_deployedInstances.get(player.getName()).kill();
_toCull.add(_deployedInstances.get(player.getName()));
_deployedInstances.remove(player.getName());
_inTask.remove(player.getName());
if (_finishMessage != null)
{
UtilPlayer.message(player, " ");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cWhite + _finishMessage.replace("{", C.cAqua).replace("}", C.cWhite));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
}
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
Iterator<DeployedTask> iterator = _toCull.iterator();
while(iterator.hasNext())
{
DeployedTask task = iterator.next();
task.kill();
HandlerList.unregisterAll(task);
iterator.remove();
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cWhite + _finishMessage.replace("{", C.cAqua).replace("}", C.cWhite));
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
}
}
public void cleanup(Player player)
{
_deployedInstances.get(player.getName()).kill();
_toCull.add(_deployedInstances.get(player.getName()));
_inTask.remove(player.getName());
_playersFinished.remove(player.getName());
}

View File

@ -24,7 +24,7 @@ public class SkipTutorialCommand extends CommandBase<TutorialManager>
}
else
{
UtilPlayer.message(caller, F.main("Tutorials", "You are not currently in a tutorial."));
Plugin.sendTutorialMsg(caller, F.main("Tutorials", "You are not currently in a tutorial."));
}
}

View File

@ -1,12 +1,11 @@
package mineplex.game.clans.tutorials.gettingstarted;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.tutorials.DeployedTask;
import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent;
import mineplex.game.clans.tutorials.TutorialTask;
public class TaskClaim extends TutorialTask<TutorialGettingStarted>
@ -21,42 +20,24 @@ public class TaskClaim extends TutorialTask<TutorialGettingStarted>
_description = "Clans can claim 16x16 areas of Territory! "
+ "Once claimed, only your Clan can break/place blocks here. "
+ "This is the perfect place to build a base and stash your items! "
+ "You can only claim in the Wilderness, and not next to other Clans Territory. "
+ "Claim some Territory now, by typing {/c claim}!";
+ "You can only claim in the Wilderness, and not next to other Clan's Territory. "
+ "To claim some territory, go into the Clans GUI by typing {/c} and {Left-Clicking}";
}
@Override
public DeployedTask customDeploy(Player player)
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onClansCommand(PlayerPreClaimTerritoryEvent event)
{
return new Deployed(player, this);
}
class Deployed extends DeployedTask
{
public Deployed(Player player, TutorialTask<?> task)
if (!isDoing(event.getClaimer()))
{
super(player, task);
return;
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onClansCommand(ClansCommandExecutedEvent event)
if (!ClansManager.getInstance().isInClan(event.getClaimer()))
{
if (!_player.equals(event.getPlayer()))
{
return;
}
if (!ClansManager.getInstance().isInClan(event.getPlayer()))
{
return;
}
if (event.getCommand().equals("claim"))
{
_task.finishFor(_player);
event.setCancelled(true);
}
return;
}
finishFor(event.getClaimer());
event.setCancelled(true);
}
}

View File

@ -4,8 +4,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.core.common.util.UtilServer;
import mineplex.game.clans.clans.event.ClanCreatedEvent;
import mineplex.game.clans.tutorials.DeployedTask;
import mineplex.game.clans.tutorials.TutorialTask;
public class TaskCreateClan extends TutorialTask<TutorialGettingStarted>
@ -17,32 +17,36 @@ public class TaskCreateClan extends TutorialTask<TutorialGettingStarted>
_displayName = "Create a Clan";
_technicalName = "ClanCreation";
_description = "Before beginning, use the {/c create <ClanName>} command to start up your own Clan! ";
_description = "Before beginning, use the {/c create <ClanName>} command to start up your own Clan! "
+ "If you are already in a Clan, don't worry, you will automatically skip this part.";
}
@Override
public DeployedTask customDeploy(Player player)
public void customStartFor(final Player player)
{
return new Deployed(player, this);
if (_tutorial.get(player).InClanOnStart)
{
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getManager().getPlugin(), new Runnable(){
public void run()
{
if (isDoing(player))
{
finishFor(player);
}
}
}, 6 * 20);
}
}
class Deployed extends DeployedTask
@EventHandler(priority = EventPriority.MONITOR)
public void onClanCreated(ClanCreatedEvent event)
{
public Deployed(Player player, TutorialTask<?> task)
if (!isDoing(event.getFounder()))
{
super(player, task);
return;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onClanCreated(ClanCreatedEvent event)
{
if (!_player.equals(event.getFounder()))
{
return;
}
_task.finishFor(_player);
}
finishFor(event.getFounder());
}
}

View File

@ -1,5 +1,8 @@
package mineplex.game.clans.tutorials.gettingstarted;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -9,7 +12,6 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.spawn.Spawn;
import mineplex.game.clans.tutorials.DeployedTask;
import mineplex.game.clans.tutorials.TutorialTask;
import mineplex.minecraft.game.classcombat.Class.ClientClass;
@ -23,46 +25,29 @@ public class TaskCustomizeClass extends TutorialTask<TutorialGettingStarted>
_technicalName = "CustomizeKlass";
_description = "Now that you have equipped a class, use this enchantment table to customize your class builds. "
+ "Click on the enchantment table, and click the edit build button.";
+ "Click on the enchantment table, and click the edit build button. "
+ "Make sure to select an axe ability to try out in the next task!";
_taskPos = new Location(Spawn.getSpawnWorld(), 6, 66, -300, -180f, 0f);
}
@Override
public DeployedTask customDeploy(Player player)
@EventHandler(priority = EventPriority.MONITOR)
public void onUpdate(final UpdateEvent event)
{
return new Deployed(player, this);
}
class Deployed extends DeployedTask
{
public Deployed(Player player, TutorialTask<?> task)
if (!event.getType().equals(UpdateType.SEC))
{
super(player, task);
return;
}
@Override
public void postDeploy()
Iterator<String> iterator = _inTask.iterator();
while (iterator.hasNext())
{
_player.teleport(new Location(Spawn.getSpawnWorld(), 6, 66, -300, -180f, 0f));
}
@EventHandler(priority = EventPriority.MONITOR)
public void onUpdate(final UpdateEvent event)
{
if (!event.getType().equals(UpdateType.SEC))
{
return;
}
Player player = Bukkit.getPlayer(iterator.next());
final ClientClass clientclass = ClansManager.getInstance().getClassManager().Get(player);
if (checkForDeath())
if (clientclass != null && clientclass.GetSavingCustomBuild() != null && clientclass.GetSavingCustomBuild().AxeSkill != null)
{
return;
}
final ClientClass clientclass = ClansManager.getInstance().getClassManager().Get(_player);
if (clientclass != null && clientclass.GetSavingCustomBuild() != null)
{
_task.finishFor(_player);
finishFor(player);
}
}
}

View File

@ -3,8 +3,8 @@ package mineplex.game.clans.tutorials.gettingstarted;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.UtilServer;
import mineplex.game.clans.clans.event.ClanDisbandedEvent;
import mineplex.game.clans.tutorials.DeployedTask;
import mineplex.game.clans.tutorials.TutorialTask;
public class TaskDisbandClan extends TutorialTask<TutorialGettingStarted>
@ -18,31 +18,35 @@ public class TaskDisbandClan extends TutorialTask<TutorialGettingStarted>
_description = "Finally, let's disband your Clan to end the Tutorial. "
+ "Simply type {/c disband} to do this. "
+ "This will delete your Clan, and you'll be able to create or join a new one!";
+ "This will delete your Clan, and you'll be able to create or join a new one! "
+ "If you were already in a Clan before you originally begun the Tutorial, you will automatically skip this part.";
}
@Override
public DeployedTask customDeploy(Player player)
public void customStartFor(final Player player)
{
return new Deployed(player, this);
if (_tutorial.get(player).InClanOnStart)
{
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getManager().getPlugin(), new Runnable(){
public void run()
{
if (isDoing(player))
{
finishFor(player);
}
}
}, 6 * 20);
}
}
class Deployed extends DeployedTask
@EventHandler
public void sell(ClanDisbandedEvent event)
{
public Deployed(Player player, TutorialTask<?> task)
if (!isDoing(event.getDisbander()))
{
super(player, task);
return;
}
@EventHandler
public void sell(ClanDisbandedEvent event)
{
if (!_player.equals(event.getDisbander()))
{
return;
}
_task.finishFor(_player);
}
finishFor(event.getDisbander());
}
}

View File

@ -1,21 +1,18 @@
package mineplex.game.clans.tutorials.gettingstarted;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.NautArrayList;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilItem;
import mineplex.core.task.TaskManager;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
import mineplex.game.clans.clans.event.ClansShopAddButtonEvent;
import mineplex.game.clans.spawn.Spawn;
import mineplex.game.clans.tutorials.DeployedTask;
import mineplex.game.clans.tutorials.TutorialTask;
import mineplex.minecraft.game.classcombat.Class.event.ClassEquipEvent;
@ -30,87 +27,83 @@ public class TaskEquipClass extends TutorialTask<TutorialGettingStarted>
_description = "Use the PvP Gear shop, and right-click the Villager. "
+ "Purchase Iron Armor from the PvP Shop. "
+ "Then put on your armor to equip a Champions Class.";
+ "Then put on your armor to equip the Knight Class.";
_taskPos = new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f);
}
private NautHashMap<String, NautArrayList<Material>> _bought = new NautHashMap<>();
@EventHandler
public void onClassEquipped(ClassEquipEvent event)
{
if (!isDoing(event.getUser()))
{
return;
}
finishFor(event.getUser());
}
@Override
public DeployedTask customDeploy(Player player)
public void customEndFor(Player player)
{
return new Deployed(player, this);
_bought.get(player.getName()).clear();
_bought.remove(player.getName());
}
class Deployed extends DeployedTask
@Override
public void customStartFor(Player player)
{
private List<Material> _bought = new ArrayList<>();
public Deployed(Player player, TutorialTask<?> task)
_bought.put(player.getName(), new NautArrayList<Material>());
}
@EventHandler
public void button(ClansShopAddButtonEvent event)
{
if (!isDoing(event.getPlayer()))
{
super(player, task);
return;
}
if (!(UtilItem.isArmor(event.getMaterial()) && UtilItem.isIronProduct(event.getMaterial())))
{
return;
}
@Override
public void postDeploy()
if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tuttoooooe" + event.getMaterial().name()) && !_bought.get(event.getPlayer().getName()).contains(event.getMaterial()))
{
_player.teleport(new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f));
}
@EventHandler
public void onClassEquipped(ClassEquipEvent event)
{
if (!ClansManager.getInstance().getClassManager().Get(_player).equals(event.getPlayer()))
{
return;
}
_task.finishFor(_player);
}
@EventHandler
public void button(ClansShopAddButtonEvent event)
{
if (!_player.equals(event.getPlayer()))
{
return;
}
if (!(UtilItem.isArmor(event.getMaterial()) && UtilItem.isIronProduct(event.getMaterial())))
{
return;
}
if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tuttoooooe" + event.getMaterial().name()) && !_bought.contains(event.getMaterial()))
{
event.setBuyPrice(0);
event.setSellPrice(0);
}
}
@EventHandler
public void buy(final ClansPlayerBuyItemEvent event)
{
if (!_player.equals(event.getPlayer()))
{
return;
}
if (!(UtilItem.isArmor(event.getItem().getType()) && UtilItem.isIronProduct(event.getItem().getType())))
{
return;
}
if (event.getCost() == 0 && _bought.contains(event.getItem().getType()))
{
event.setCancelled(true);
return;
}
TaskManager.Instance.completedTask(new Callback<Boolean>() {
@Override
public void run(Boolean data)
{
}
}, event.getPlayer(), "tuttoooooe" + event.getItem().getType().name());
_bought.add(event.getItem().getType());
event.setBuyPrice(0);
event.setSellPrice(0);
}
}
@EventHandler
public void buy(final ClansPlayerBuyItemEvent event)
{
if (!isDoing(event.getPlayer()))
{
return;
}
if (!(UtilItem.isArmor(event.getItem().getType()) && UtilItem.isIronProduct(event.getItem().getType())))
{
return;
}
if (event.getCost() == 0 && _bought.get(event.getPlayer().getName()).contains(event.getItem().getType()))
{
event.setCancelled(true);
return;
}
TaskManager.Instance.completedTask(new Callback<Boolean>() {
@Override
public void run(Boolean data)
{
}
}, event.getPlayer(), "tuttoooooe" + event.getItem().getType().name());
_bought.get(event.getPlayer().getName()).add(event.getItem().getType());
}
}

View File

@ -1,5 +1,8 @@
package mineplex.game.clans.tutorials.gettingstarted;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -9,7 +12,6 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.EnergyPageBuildEvent;
import mineplex.game.clans.spawn.Spawn;
import mineplex.game.clans.tutorials.DeployedTask;
import mineplex.game.clans.tutorials.TutorialTask;
public class TaskExploreShops extends TutorialTask<TutorialGettingStarted>
@ -23,65 +25,60 @@ public class TaskExploreShops extends TutorialTask<TutorialGettingStarted>
_description = "Welcome to the Shops! Here you can buy all kinds of things that you may require during your adventure. "
+ "You can also sell certain items to the Villagers to make a bit of extra Gold. "
+ "Clan Energy is required to maintain the clan, without it, you will lose all claimed Territory! "
+ "Go to the Energy Shop and buy {Max Energy}. (FREE)";
_finishMessage = "Great! "
+ "Clans use energy to control Territory. "
+ "More territory will cause your energy to drain faster, so make sure you remember to refill it regularly!";
}
@Override
public DeployedTask customDeploy(Player player)
public void customStartFor(Player player)
{
return new Deployed(player, this);
player.teleport(new Location(Spawn.getSpawnWorld(), 17, 66.5, -330, -180f, 0f));
ClansManager.getInstance().getClan(player).adjustEnergy(-(ClansManager.getInstance().getClan(player).getEnergyCostPerMinute() * 60));
}
class Deployed extends DeployedTask
@EventHandler
public void onItemPut(EnergyPageBuildEvent event)
{
public Deployed(Player player, TutorialTask<?> task)
if (!isDoing(event.getPlayer()))
{
super(player, task);
return;
}
@Override
public void postDeploy()
if (!ClansManager.getInstance().isInClan(event.getPlayer()))
{
_player.teleport(new Location(Spawn.getSpawnWorld(), 17, 66.5, -330, -180f, 0f));
ClansManager.getInstance().getClan(_player).adjustEnergy(-(ClansManager.getInstance().getClan(_player).getEnergyCostPerMinute() * 60));
return;
}
@EventHandler
public void onItemPut(EnergyPageBuildEvent event)
if (ClansManager.getInstance().getClan(event.getPlayer()).getEnergyPurchasable() == 0)
{
if (!_player.equals(event.getPlayer()))
{
return;
}
if (!ClansManager.getInstance().isInClan(_player))
{
return;
}
if (ClansManager.getInstance().getClan(_player).getEnergyPurchasable() == 0)
{
_task.finishFor(_player);
return;
}
event.setFree(true);
finishFor(event.getPlayer());
return;
}
@EventHandler
public void onUpdate(UpdateEvent event)
event.setFree(true);
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TWOSEC)
{
if (event.getType() != UpdateType.TWOSEC)
return;
}
Iterator<String> iterator = _inTask.iterator();
while (iterator.hasNext())
{
Player player = Bukkit.getPlayer(iterator.next());
if (ClansManager.getInstance().getClan(player).getEnergy() == ClansManager.getInstance().getClan(player).getEnergyMax())
{
return;
}
if (ClansManager.getInstance().getClan(_player).getEnergy() == ClansManager.getInstance().getClan(_player).getEnergyMax())
{
_task.finishFor(_player);
finishFor(player);
}
}
}
}

View File

@ -1,55 +0,0 @@
package mineplex.game.clans.tutorials.gettingstarted;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent;
import mineplex.game.clans.tutorials.DeployedTask;
import mineplex.game.clans.tutorials.TutorialTask;
public class TaskGoToWilderness extends TutorialTask<TutorialGettingStarted>
{
public TaskGoToWilderness(TutorialGettingStarted tutorial, int id)
{
super(tutorial, id);
_displayName = "Go To The Wilderness";
_technicalName = "GoToWildy";
_description = "Use your Map (Slot 9) to help find your way to the Wilderness. "
+ "The Wilderness is anywhere that is not colored on the Map. "
+ "If you don't have a map, you can get one at any time by typing {/map}. "
+ "You can zoom in/out on our map by left and right clicking!";
}
@Override
public DeployedTask customDeploy(Player player)
{
return new Deployed(player, this);
}
class Deployed extends DeployedTask
{
public Deployed(Player player, TutorialTask<?> task)
{
super(player, task);
}
@EventHandler(priority = EventPriority.MONITOR)
public void onTerritory(final PlayerEnterTerritoryEvent event)
{
if (!_player.equals(event.getPlayer()))
{
return;
}
if (event.getNewTerritory().contains("Wilderness"))
{
_task.finishFor(_player);
}
}
}
}

View File

@ -1,14 +1,13 @@
package mineplex.game.clans.tutorials.gettingstarted;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent;
import mineplex.game.clans.tutorials.DeployedTask;
import mineplex.game.clans.tutorials.TutorialTask;
public class TaskLeaveSpawn extends TutorialTask<TutorialGettingStarted>
@ -22,48 +21,36 @@ public class TaskLeaveSpawn extends TutorialTask<TutorialGettingStarted>
_description = "Now you can leave the Spawn Island. "
+ "Don't worry, you won't get hurt from the fall! "
+ "Once you end the tutorial, PvP will be enabled down there, so be careful!";
+ "Once you're down there, run out a couple of blocks to get to the Wilderness. "
+ "When you finish the tutorial, you will be vulnerable to player attacks out there, so be careful!";
}
@Override
public DeployedTask customDeploy(Player player)
public void customStartFor(Player player)
{
return new Deployed(player, this);
}
class Deployed extends DeployedTask
{
public Deployed(Player player, TutorialTask<?> task)
if (player.getLocation().getY() < 100)
{
super(player, task);
}
@Override
public void postDeploy()
{
if (_player.getLocation().getY() < 100)
{
_task.finishFor(_player);
}
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
if (checkForDeath())
{
return;
}
if (_player.getLocation().getY() < 100){
_task.finishFor(_player);
}
finishFor(player);
}
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
Iterator<String> iterator = _inTask.iterator();
while (iterator.hasNext())
{
Player player = Bukkit.getPlayer(iterator.next());
if (player.getLocation().getY() < 100 && getClans().getClanUtility().getClaim(player.getLocation()) == null)
{
finishFor(player);
}
}
}
}

View File

@ -4,12 +4,12 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent;
import mineplex.game.clans.spawn.Spawn;
import mineplex.game.clans.tutorials.DeployedTask;
import mineplex.game.clans.tutorials.TutorialTask;
public class TaskMakingMoney extends TutorialTask<TutorialGettingStarted>
@ -23,49 +23,54 @@ public class TaskMakingMoney extends TutorialTask<TutorialGettingStarted>
_description = "We have given you a carrot to sell in the Organic Produce Shop. "
+ "Click on the Villager, and {Right-Click} the carrot to sell your carrots in exchange for Gold.";
_finishMessage = "Good job! "
+ "Farming and selling foods like carrots and potatoes are great ways to make money. "
+ "You can also sell blocks, ores, and many other items that a Shop may be interested in buying.";
_taskPos = new Location(Spawn.getSpawnWorld(), 25.536, 66, -316.844, -100f, 0f);
}
@Override
public DeployedTask customDeploy(Player player)
public void customStartFor(Player player)
{
return new Deployed(player, this);
player.getInventory().addItem(new ItemStack(Material.CARROT, 1));
}
class Deployed extends DeployedTask
@EventHandler
public void eat(PlayerItemConsumeEvent event)
{
private int _carrotsSold;
public Deployed(Player player, TutorialTask<?> task)
if (!isDoing(event.getPlayer()))
{
super(player, task);
player.getInventory().addItem(new ItemStack(Material.CARROT_ITEM, 1));
return;
}
@Override
public void postDeploy()
if (!event.getItem().getType().equals(Material.CARROT))
{
_player.teleport(new Location(Spawn.getSpawnWorld(), 25.536, 66, -316.844, -100f, 0f));
return;
}
@EventHandler
public void button(ClansPlayerSellItemEvent event)
event.setCancelled(true);
}
@EventHandler
public void button(ClansPlayerSellItemEvent event)
{
if (!isDoing(event.getPlayer()))
{
if (!_player.equals(event.getPlayer()))
{
return;
}
if (!ClansManager.getInstance().isInClan(_player))
{
return;
}
if (!event.getItem().getType().equals(Material.CARROT_ITEM))
{
return;
}
_task.finishFor(_player);
return;
}
if (!ClansManager.getInstance().isInClan(event.getPlayer()))
{
return;
}
if (!event.getItem().getType().equals(Material.CARROT_ITEM))
{
return;
}
finishFor(event.getPlayer());
}
}

View File

@ -1,12 +1,10 @@
package mineplex.game.clans.tutorials.gettingstarted;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.tutorials.DeployedTask;
import mineplex.game.clans.tutorials.TutorialTask;
public class TaskSetHome extends TutorialTask<TutorialGettingStarted>
@ -19,42 +17,28 @@ public class TaskSetHome extends TutorialTask<TutorialGettingStarted>
_technicalName = "SetClanHome";
_description = "You are now ready to set a Clan Home. "
+ "To do this, use the {/c sethome} command.";
+ "To do this, use the {/c sethome} command. "
+ "After you set a Clan Home, you or any of your Clan mates will be able to teleport back to the Clan Home by typing {/c home} whenever they are at Spawn.";
}
@Override
public DeployedTask customDeploy(Player player)
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSetHome(ClansCommandExecutedEvent event)
{
return new Deployed(player, this);
}
class Deployed extends DeployedTask
{
public Deployed(Player player, TutorialTask<?> task)
if (!isDoing(event.getPlayer()))
{
super(player, task);
return;
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSetHome(ClansCommandExecutedEvent event)
if (!ClansManager.getInstance().isInClan(event.getPlayer()))
{
if (!_player.equals(event.getPlayer()))
{
return;
}
if (!ClansManager.getInstance().isInClan(event.getPlayer()))
{
return;
}
if (!event.getCommand().equals("homeset"))
{
return;
}
_task.finishFor(_player);
return;
}
if (!event.getCommand().equals("homeset"))
{
return;
}
finishFor(event.getPlayer());
}
}

View File

@ -1,8 +1,10 @@
package mineplex.game.clans.tutorials.gettingstarted;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -13,13 +15,14 @@ import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.PlayerInventory;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.NautArrayList;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
import mineplex.game.clans.clans.event.ClansShopAddButtonEvent;
import mineplex.game.clans.spawn.Spawn;
import mineplex.game.clans.tutorials.DeployedTask;
import mineplex.game.clans.tutorials.TutorialTask;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
@ -35,95 +38,103 @@ public class TaskUseAbility extends TutorialTask<TutorialGettingStarted>
_description = "Now that you have equipped a class, you can start using abilities. "
+ "Purchase an Iron Axe from the PvP Shop. "
+ "Right-Click with your Iron Axe to use your Axe Ability!";
_taskPos = new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f);
}
private NautHashMap<String, NautArrayList<Material>> _bought = new NautHashMap<>();
private NautHashMap<String, Boolean> _teleported = new NautHashMap<>();
@Override
public void customStartFor(Player player)
{
_bought.put(player.getName(), new NautArrayList<Material>());
_teleported.put(player.getName(), false);
}
@Override
public DeployedTask customDeploy(Player player)
public void customEndFor(Player player)
{
return new Deployed(player, this);
_bought.get(player.getName()).clear();
_bought.remove(player.getName());
_teleported.remove(player.getName());
}
class Deployed extends DeployedTask
@EventHandler
public void teleportPlayer(UpdateEvent event)
{
private List<Material> _bought = new ArrayList<>();
private boolean _teleported = false;
if (event.getType() != UpdateType.SEC) return;
public Deployed(Player player, TutorialTask<?> task)
Iterator<String> iterator = _inTask.iterator();
while (iterator.hasNext())
{
super(player, task);
}
@EventHandler
public void teleportPlayer(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC) return;
if (!_teleported && _player != null && _player.isOnline() && _player.getOpenInventory().getType() == InventoryType.CRAFTING)
Player _player = Bukkit.getPlayer(iterator.next());
if (!_teleported.get(_player.getName()) && _player != null && _player.isOnline() && _player.getOpenInventory().getType() == InventoryType.CRAFTING)
{
_player.teleport(new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f));
_teleported = true;
_teleported.put(_player.getName(), true);
}
}
@EventHandler
public void onAbilityUesd(SkillTriggerEvent event)
{
if (_player == null || !_player.equals(event.GetPlayer()))
{
return;
}
_task.finishFor(_player);
}
@EventHandler
public void button(ClansShopAddButtonEvent event)
{
if (!_player.equals(event.getPlayer()))
{
return;
}
System.out.println(event.getDisplayName());
if (!event.getMaterial().equals(Material.IRON_AXE))
{
return;
}
if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tuttoooooe" + event.getMaterial().name()) && !_bought.contains(event.getMaterial()))
{
event.setBuyPrice(0);
event.setSellPrice(0);
}
}
@EventHandler
public void buy(final ClansPlayerBuyItemEvent event)
{
if (!_player.equals(event.getPlayer()))
{
return;
}
if (!event.getItem().getType().equals(Material.IRON_AXE))
{
return;
}
if (event.getCost() == 0 && _bought.contains(event.getItem().getType()))
{
event.setCancelled(true);
return;
}
TaskManager.Instance.completedTask(new Callback<Boolean>() {
@Override
public void run(Boolean data)
{
}
}, event.getPlayer(), "tuttoooooe" + event.getItem().getType().name());
_bought.add(event.getItem().getType());
}
}
@EventHandler
public void onAbilityUesd(SkillTriggerEvent event)
{
if (!isDoing(event.GetPlayer()))
{
return;
}
finishFor(event.GetPlayer());
}
@EventHandler
public void button(ClansShopAddButtonEvent event)
{
if (!isDoing(event.getPlayer()))
{
return;
}
if (!event.getMaterial().equals(Material.IRON_AXE))
{
return;
}
if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tuttoooooe" + event.getMaterial().name())
&& !_bought.get(event.getPlayer().getName()).contains(event.getMaterial()))
{
event.setBuyPrice(0);
event.setSellPrice(0);
}
}
@EventHandler
public void buy(final ClansPlayerBuyItemEvent event)
{
if (!isDoing(event.getPlayer()))
{
return;
}
if (!event.getItem().getType().equals(Material.IRON_AXE))
{
return;
}
if (event.getCost() == 0 && _bought.get(event.getPlayer().getName()).contains(event.getItem().getType()))
{
event.setCancelled(true);
return;
}
TaskManager.Instance.completedTask(new Callback<Boolean>() {
@Override
public void run(Boolean data)
{
}
}, event.getPlayer(), "tuttoooooe" + event.getItem().getType().name());
_bought.get(event.getPlayer().getName()).add(event.getItem().getType());
}
}

View File

@ -1,11 +1,9 @@
package mineplex.game.clans.tutorials.gettingstarted;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.tutorials.DeployedTask;
import mineplex.game.clans.tutorials.TutorialTask;
public class TaskViewClanDetails extends TutorialTask<TutorialGettingStarted>
@ -22,32 +20,19 @@ public class TaskViewClanDetails extends TutorialTask<TutorialGettingStarted>
+ "You can also use any clan's name to get some information about them as well.";
}
@Override
public DeployedTask customDeploy(Player player)
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onClansCommand(ClansCommandExecutedEvent event)
{
return new Deployed(player, this);
}
class Deployed extends DeployedTask
{
public Deployed(Player player, TutorialTask<?> task)
if (!isDoing(event.getPlayer()))
{
super(player, task);
return;
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onClansCommand(ClansCommandExecutedEvent event)
System.out.println(event.getCommand());
if (event.getCommand().equals("info"))
{
if (!_player.equals(event.getPlayer()))
{
return;
}
if (event.getCommand().equals("info"))
{
_task.finishFor(_player);
}
finishFor(event.getPlayer());
}
}
}

View File

@ -5,10 +5,9 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.donation.DonationManager;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -20,9 +19,9 @@ import mineplex.game.clans.tutorials.TutorialManager;
public class TutorialGettingStarted extends Tutorial
{
public TutorialGettingStarted(final TutorialManager manager, final ClansManager clansManager, final DonationManager donationManager, final GoldManager goldManager, final TaskManager taskManager)
public TutorialGettingStarted(final TutorialManager manager, final ClansManager clansManager, final DonationManager donationManager, final GoldManager goldManager, final TaskManager taskManager, final PacketHandler packetHandler)
{
super(goldManager, taskManager, clansManager, donationManager, manager);
super(goldManager, taskManager, clansManager, donationManager, manager, packetHandler);
// addTask(new TaskWelcome(this, 1));
@ -30,7 +29,6 @@ public class TutorialGettingStarted extends Tutorial
addTask(new TaskCreateClan(this, ++id));
addTask(new TaskViewClanDetails(this, ++id));
addTask(new TaskLeaveSpawn(this, ++id));
addTask(new TaskGoToWilderness(this, ++id));
addTask(new TaskClaim(this, ++id));
addTask(new TaskSetHome(this, ++id));
addTask(new TaskExploreShops(this, ++id));
@ -40,8 +38,6 @@ public class TutorialGettingStarted extends Tutorial
addTask(new TaskMakingMoney(this, ++id));
addTask(new TaskDisbandClan(this, ++id));
_doScoreboard = true;
_ghostMode = true;
_startOnJoin = true;
@ -54,12 +50,12 @@ public class TutorialGettingStarted extends Tutorial
@Override
public void onFinished(final Player player)
{
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, C.cYellowB + "CONGRATULATIONS");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cWhite + "You have completed the Clans basic tutorial and have been awarded " + C.cAqua + "30,000 Gold");
UtilPlayer.message(player, C.cWhite + "You can now begin your adventure, but do take a moment to read the signs around spawn for more information!");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
_manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
_manager.sendTutorialMsg(player, C.cYellowB + "CONGRATULATIONS");
_manager.sendTutorialMsg(player, " ");
_manager.sendTutorialMsg(player, C.cWhite + "You have completed the Clans basic tutorial and have been awarded " + C.cAqua + "30,000 Gold");
_manager.sendTutorialMsg(player, C.cWhite + "You can now begin your adventure, but do take a moment to read the signs around spawn for more information!");
_manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
player.resetPlayerTime();
player.teleport(Spawn.getEastSpawn());
@ -68,17 +64,17 @@ public class TutorialGettingStarted extends Tutorial
@Override
public void onBegin(final Player player)
{
UtilPlayer.message(player, " ");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cYellowB + "Getting Started");
UtilPlayer.message(player, C.cWhite + "Welcome to Clans! "
_manager.sendTutorialMsg(player, " ");
_manager.sendTutorialMsg(player, " ");
_manager.sendTutorialMsg(player, " ");
_manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
_manager.sendTutorialMsg(player, " ");
_manager.sendTutorialMsg(player, C.cYellowB + "Getting Started");
_manager.sendTutorialMsg(player, C.cWhite + " Welcome to Clans! "
+ "In this game mode you are able to create a clan, invite your friends to play with you, build a base, and wage war against others! "
+ "When you finish the tutorial, you will be awarded " + C.cAqua + "30,000 Gold");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
_manager.sendTutorialMsg(player, " ");
_manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
}

View File

@ -14,7 +14,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wither;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
@ -24,9 +24,9 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.event.StackerEvent;
import mineplex.core.gadget.gadgets.MorphBlock;
import mineplex.core.gadget.types.GadgetType;
@ -54,7 +54,7 @@ public class StackerManager extends MiniPlugin implements IThrown
}
@EventHandler
public void GrabEntity(PlayerInteractEntityEvent event)
public void GrabEntity(PlayerInteractAtEntityEvent event)
{
if (event.isCancelled())
return;
@ -62,7 +62,10 @@ public class StackerManager extends MiniPlugin implements IThrown
Entity stackee = event.getRightClicked();
if (stackee == null)
return;
if(Manager.GetMount().isMount(stackee))
return;
if (!(stackee instanceof LivingEntity))
return;

View File

@ -347,7 +347,7 @@ public class ClientClass
ResetToDefaults(!skillsOnly, !skillsOnly);
// Event
ClassEquipEvent event = new ClassEquipEvent(this, customBuild);
ClassEquipEvent event = new ClassEquipEvent(this, customBuild, _client.GetPlayer());
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())

View File

@ -5,7 +5,6 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.minecraft.game.classcombat.Class.ClientClass;
import mineplex.minecraft.game.classcombat.Class.PvpClass;
import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken;
public class ClassEquipEvent extends Event
@ -13,15 +12,16 @@ public class ClassEquipEvent extends Event
private static final HandlerList handlers = new HandlerList();
private ClientClass _client;
private Player _user;
private CustomBuildToken _build;
private boolean _cancelled;
public ClassEquipEvent(ClientClass client, CustomBuildToken build)
public ClassEquipEvent(ClientClass client, CustomBuildToken build, Player user)
{
_client = client;
_build = build;
_user = user;
}
public ClientClass getPlayer()
@ -34,6 +34,11 @@ public class ClassEquipEvent extends Event
return _build;
}
public Player getUser()
{
return _user;
}
public void setCancelled(boolean cancelled)
{
_cancelled = cancelled;

View File

@ -197,6 +197,30 @@ public class MarkedForDeath extends SkillActive
if (arrow.isDead() || !arrow.isValid() || arrow.isOnGround())
arrowIterator.remove();
}
for (Iterator<Player> activeIterator = _active.iterator(); activeIterator.hasNext();)
{
Player player = activeIterator.next();
if (!player.isOnline())
activeIterator.remove();
}
for (Iterator<LivingEntity> markedTimeIterator = _markedTime.keySet().iterator(); markedTimeIterator.hasNext();)
{
LivingEntity markedTime = markedTimeIterator.next();
if (markedTime.isDead() || !markedTime.isValid())
markedTimeIterator.remove();
}
for (Iterator<LivingEntity> markedDamageIterator = _markedDamage.keySet().iterator(); markedDamageIterator.hasNext();)
{
LivingEntity markedDamage = markedDamageIterator.next();
if (markedDamage.isDead() || !markedDamage.isValid())
markedDamageIterator.remove();
}
}
@Override

View File

@ -146,5 +146,6 @@ public class Recall extends Skill
public void Reset(Player player)
{
_locMap.remove(player);
_healthMap.remove(player);
}
}

View File

@ -66,6 +66,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.util.Vector;
public class GameFlagManager implements Listener
@ -676,6 +677,11 @@ public class GameFlagManager implements Listener
final Player player = event.getEntity();
//Remove all conditions
Manager.GetCondition().EndCondition(player, null, null);
for (PotionEffect potion : player.getActivePotionEffects())
player.removePotionEffect(potion.getType());
//Visual
Manager.GetCondition().Factory().Blind("Ghost", player, player, 2.5, 0, false, false, false);