Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex

# Conflicts:
#	Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java
This commit is contained in:
Jonathan Williams 2015-12-11 01:26:20 -05:00
commit 95a81ef368
154 changed files with 6484 additions and 2255 deletions

View File

@ -28,7 +28,7 @@
<processorPath useClasspath="true" /> <processorPath useClasspath="true" />
</profile> </profile>
</annotationProcessing> </annotationProcessing>
<bytecodeTargetLevel target="1.7" /> <bytecodeTargetLevel target="1.8" />
</component> </component>
<component name="JavacSettings"> <component name="JavacSettings">
<option name="GENERATE_NO_WARNINGS" value="true" /> <option name="GENERATE_NO_WARNINGS" value="true" />

View File

@ -16,7 +16,7 @@
</set> </set>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

View File

@ -66,10 +66,10 @@
</fileset> </fileset>
<fileset dir="../Mineplex.Core/bin"> <fileset dir="../Mineplex.Core/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
<include name="**/*.png"/>
</fileset> </fileset>
<fileset dir="../Mineplex.Core.Common/bin"> <fileset dir="../Mineplex.Core.Common/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
<include name="**/*.png"/>
</fileset> </fileset>
<fileset dir="../Mineplex.Minecraft.Game.ClassCombat/bin"> <fileset dir="../Mineplex.Minecraft.Game.ClassCombat/bin">
<include name="**/*.class"/> <include name="**/*.class"/>

View File

@ -56,11 +56,11 @@ public class MotdManager implements Listener, Runnable
//String motdLine = "§f§l◄ §c§lMaintenance§f§l ►"; //String motdLine = "§f§l◄ §c§lMaintenance§f§l ►";
//String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►"; //String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►";
// String motdLine = " §2§l§n M O N S T E R M A Z E B E T A §f"; // String motdLine = " §2§l§n M O N S T E R M A Z E B E T A §f";
String motdLine = " §f§l◄ §b§lNew Game§f§l ▬ §3§lChampions CTF§f§l ►"; String motdLine = " §f❄ §2§lWinter Update §f❄ §2§lSnow Fight §f❄";
//String motdLine = " §d§lRank Sale §a§l40% Off"); //String motdLine = " §d§lRank Sale §a§l40% Off");
//String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►"); //String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►");
updateMainMotd(" §f§l§m §8§l§m[ §r §6§lMineplex§r §f§lGames§r §8§l§m ]§f§l§m §r", motdLine); updateMainMotd(" §c§m §f§m §c§m §f§m §2§l§m[ §r §c§lMineplex§r §f§lGames§r §2§l§m ]§f§m §c§m §f§m §c§m §r", motdLine);
System.out.println("Updated Bungee MOTD"); System.out.println("Updated Bungee MOTD");
} }
} }

View File

@ -26,7 +26,7 @@ public enum Rank
//Media //Media
YOUTUBE("YouTube", ChatColor.RED), YOUTUBE("YouTube", ChatColor.RED),
YOUTUBE_SMALL("MooTube", ChatColor.DARK_PURPLE), YOUTUBE_SMALL("YT", ChatColor.DARK_PURPLE),
TWITCH("Twitch", ChatColor.DARK_PURPLE), TWITCH("Twitch", ChatColor.DARK_PURPLE),
//Player //Player

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1,18 @@
package mineplex.core.common.util;
public enum LineFormat
{
LORE(200), CHAT(319);
private int _length;
private LineFormat(int length)
{
_length = length;
}
public int getLength()
{
return _length;
}
}

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.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Banner;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; 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.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.material.Bed; import org.bukkit.material.Bed;
import net.minecraft.server.v1_8_R3.BlockPosition; import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Blocks; import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.EnumDirection; 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.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; import net.minecraft.server.v1_8_R3.WorldServer;
public class UtilBlock public class UtilBlock
@ -535,8 +552,8 @@ public class UtilBlock
if (diagonals) if (diagonals)
{ {
for (int x = -1; x <= 1; x++) for (int x = -1; x <= 1; x++)
for (int y = -1; y <= 1; y++) for (int z = -1; z <= 1; z++)
for (int z = -1; z <= 1; z++) for (int y = 1; y >= -1; y--)
{ {
if (x == 0 && y == 0 && z == 0) continue; if (x == 0 && y == 0 && z == 0) continue;
@ -546,11 +563,11 @@ public class UtilBlock
else else
{ {
blocks.add(block.getRelative(BlockFace.UP)); blocks.add(block.getRelative(BlockFace.UP));
blocks.add(block.getRelative(BlockFace.DOWN));
blocks.add(block.getRelative(BlockFace.NORTH)); blocks.add(block.getRelative(BlockFace.NORTH));
blocks.add(block.getRelative(BlockFace.SOUTH)); blocks.add(block.getRelative(BlockFace.SOUTH));
blocks.add(block.getRelative(BlockFace.EAST)); blocks.add(block.getRelative(BlockFace.EAST));
blocks.add(block.getRelative(BlockFace.WEST)); blocks.add(block.getRelative(BlockFace.WEST));
blocks.add(block.getRelative(BlockFace.DOWN));
} }
return blocks; return blocks;
@ -818,7 +835,7 @@ public class UtilBlock
return getBedHead(bed.getBlock()) != null && getBedFoot(bed.getBlock()) != null; return getBedHead(bed.getBlock()) != null && getBedFoot(bed.getBlock()) != null;
} }
public static HashSet<Block> findConnectedBlocks(Block block, HashSet<Block> blocks, int limit) public static HashSet<Block> findConnectedBlocks(Block source, Block block, HashSet<Block> blocks, int limit, double range)
{ {
if (blocks == null) if (blocks == null)
blocks = new HashSet<Block>(); blocks = new HashSet<Block>();
@ -836,17 +853,22 @@ public class UtilBlock
if (neighbour.getType() == Material.AIR) if (neighbour.getType() == Material.AIR)
continue; continue;
if (UtilMath.offset(source.getLocation(), neighbour.getLocation()) > range)
continue;
//If neighbour hasn't been searched, recursively search it! //If neighbour hasn't been searched, recursively search it!
if (!blocks.contains(neighbour)) if (!blocks.contains(neighbour))
findConnectedBlocks(neighbour, blocks, limit); findConnectedBlocks(source, neighbour, blocks, limit, range);
} }
return blocks; return blocks;
} }
public static ItemStack blockToInventoryItemStack(Block block) public static ArrayList<ItemStack> blockToInventoryItemStacks(Block block)
{ {
ItemStack itemStack = new ItemStack(block.getType(), 1, block.getData()); ItemStack itemStack = new ItemStack(block.getType(), 1, block.getData());
ArrayList<ItemStack> itemStacks = new ArrayList<ItemStack>();
itemStacks.add(itemStack);
switch (block.getType()) switch (block.getType())
{ {
@ -877,6 +899,17 @@ public class UtilBlock
break; break;
case DISPENSER: case DISPENSER:
itemStack.setDurability((short) 0); itemStack.setDurability((short) 0);
Dispenser dispenser = (Dispenser) block.getState();
for (ItemStack is : dispenser.getInventory().getContents())
{
if (is == null)
continue;
itemStacks.add(is);
}
break; break;
case BED_BLOCK: case BED_BLOCK:
itemStack.setType(Material.BED); itemStack.setType(Material.BED);
@ -921,6 +954,17 @@ public class UtilBlock
break; break;
case CHEST: case CHEST:
itemStack.setDurability((short) 0); itemStack.setDurability((short) 0);
Chest chest = (Chest) block.getState();
for (ItemStack is : chest.getBlockInventory().getContents())
{
if (is == null)
continue;
itemStacks.add(is);
}
break; break;
case REDSTONE_WIRE: case REDSTONE_WIRE:
itemStack.setType(Material.REDSTONE); itemStack.setType(Material.REDSTONE);
@ -936,10 +980,32 @@ public class UtilBlock
break; break;
case FURNACE: case FURNACE:
itemStack.setDurability((short) 0); itemStack.setDurability((short) 0);
Furnace furnace = (Furnace) block.getState();
for (ItemStack is : furnace.getInventory().getContents())
{
if (is == null)
continue;
itemStacks.add(is);
}
break; break;
case BURNING_FURNACE: case BURNING_FURNACE:
itemStack.setType(Material.FURNACE); itemStack.setType(Material.FURNACE);
itemStack.setDurability((short) 0); itemStack.setDurability((short) 0);
Furnace burningFurnace = (Furnace) block.getState();
for (ItemStack is : burningFurnace.getInventory().getContents())
{
if (is == null)
continue;
itemStacks.add(is);
}
break; break;
case SIGN_POST: case SIGN_POST:
itemStack.setType(Material.SIGN); itemStack.setType(Material.SIGN);
@ -1001,6 +1067,12 @@ public class UtilBlock
break; break;
case JUKEBOX: case JUKEBOX:
itemStack.setDurability((short) 0); itemStack.setDurability((short) 0);
Jukebox jukebox = (Jukebox) block.getState();
if (jukebox.getPlaying() != Material.AIR)
itemStacks.add(new ItemStack(jukebox.getPlaying()));
break; break;
case PORTAL: case PORTAL:
itemStack.setType(Material.AIR); itemStack.setType(Material.AIR);
@ -1057,10 +1129,25 @@ public class UtilBlock
case BREWING_STAND: case BREWING_STAND:
itemStack.setType(Material.BREWING_STAND_ITEM); itemStack.setType(Material.BREWING_STAND_ITEM);
itemStack.setDurability((short) 0); itemStack.setDurability((short) 0);
BrewingStand brewingStand = (BrewingStand) block.getState();
for (ItemStack is : brewingStand.getInventory().getContents())
{
if (is == null)
continue;
itemStacks.add(is);
}
break; break;
case CAULDRON: case CAULDRON:
itemStack.setType(Material.CAULDRON_ITEM); itemStack.setType(Material.CAULDRON_ITEM);
itemStack.setDurability((short) 0); itemStack.setDurability((short) 0);
if (block.getData() != 0)
itemStacks.add(new ItemStack(Material.WATER_BUCKET));
break; break;
case ENDER_PORTAL: case ENDER_PORTAL:
itemStack.setType(Material.AIR); itemStack.setType(Material.AIR);
@ -1068,6 +1155,10 @@ public class UtilBlock
break; break;
case ENDER_PORTAL_FRAME: case ENDER_PORTAL_FRAME:
itemStack.setDurability((short) 0); itemStack.setDurability((short) 0);
if ((block.getData() & 0x4) != 0)
itemStacks.add(new ItemStack(Material.EYE_OF_ENDER));
break; break;
case REDSTONE_LAMP_ON: case REDSTONE_LAMP_ON:
itemStack.setType(Material.REDSTONE_LAMP_OFF); itemStack.setType(Material.REDSTONE_LAMP_OFF);
@ -1111,6 +1202,27 @@ public class UtilBlock
case FLOWER_POT: case FLOWER_POT:
itemStack.setType(Material.FLOWER_POT_ITEM); itemStack.setType(Material.FLOWER_POT_ITEM);
itemStack.setDurability((short) 0); 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; break;
case CARROT: case CARROT:
itemStack.setType(Material.CARROT_ITEM); itemStack.setType(Material.CARROT_ITEM);
@ -1125,9 +1237,31 @@ public class UtilBlock
break; break;
case SKULL: case SKULL:
itemStack.setType(Material.SKULL_ITEM); 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; break;
case TRAPPED_CHEST: case TRAPPED_CHEST:
itemStack.setDurability((short) 0); itemStack.setDurability((short) 0);
Chest trappedChest = (Chest) block.getState();
for (ItemStack is : trappedChest.getBlockInventory().getContents())
{
if (is == null)
continue;
itemStacks.add(is);
}
break; break;
case GOLD_PLATE: case GOLD_PLATE:
itemStack.setDurability((short) 0); itemStack.setDurability((short) 0);
@ -1148,6 +1282,17 @@ public class UtilBlock
break; break;
case HOPPER: case HOPPER:
itemStack.setDurability((short) 0); itemStack.setDurability((short) 0);
Hopper hopper = (Hopper) block.getState();
for (ItemStack is : hopper.getInventory().getContents())
{
if (is == null)
continue;
itemStacks.add(is);
}
break; break;
case QUARTZ_STAIRS: case QUARTZ_STAIRS:
itemStack.setDurability((short) 0); itemStack.setDurability((short) 0);
@ -1157,6 +1302,17 @@ public class UtilBlock
break; break;
case DROPPER: case DROPPER:
itemStack.setDurability((short) 0); itemStack.setDurability((short) 0);
Dropper dropper = (Dropper) block.getState();
for (ItemStack is : dropper.getInventory().getContents())
{
if (is == null)
continue;
itemStacks.add(is);
}
break; break;
case LEAVES_2: case LEAVES_2:
itemStack.setDurability((short) (itemStack.getDurability() % 4)); itemStack.setDurability((short) (itemStack.getDurability() % 4));
@ -1178,11 +1334,27 @@ public class UtilBlock
break; break;
case STANDING_BANNER: case STANDING_BANNER:
itemStack.setType(Material.BANNER); itemStack.setType(Material.BANNER);
itemStack.setDurability((short) 0);
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; break;
case WALL_BANNER: case WALL_BANNER:
itemStack.setType(Material.BANNER); itemStack.setType(Material.BANNER);
itemStack.setDurability((short) 0);
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; break;
case DAYLIGHT_DETECTOR_INVERTED: case DAYLIGHT_DETECTOR_INVERTED:
itemStack.setType(Material.DAYLIGHT_DETECTOR); itemStack.setType(Material.DAYLIGHT_DETECTOR);
@ -1235,6 +1407,6 @@ public class UtilBlock
break; break;
} }
return itemStack; 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.CraftCreature;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -804,6 +805,20 @@ public class UtilEnt
return null; 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) public static boolean inWater(LivingEntity ent)
{ {
return ent.getLocation().getBlock().getTypeId() == 8 || ent.getLocation().getBlock().getTypeId() == 9; return ent.getLocation().getBlock().getTypeId() == 8 || ent.getLocation().getBlock().getTypeId() == 9;

View File

@ -25,8 +25,8 @@ public class UtilItem
_materials.put(Material.AIR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS)); _materials.put(Material.AIR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
_materials.put(Material.STONE, EnumSet.of(ItemCategory.BLOCK)); _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.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.COBBLESTONE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.STONE));
_materials.put(Material.WOOD, EnumSet.of(ItemCategory.BLOCK, ItemCategory.WOOD)); _materials.put(Material.WOOD, EnumSet.of(ItemCategory.BLOCK, ItemCategory.WOOD));
_materials.put(Material.SAPLING, EnumSet.of(ItemCategory.BLOCK)); _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.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.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 // 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_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_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)); _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

@ -1,5 +1,7 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
@ -509,13 +511,21 @@ public class UtilPlayer
if (cur.isDead()) if (cur.isDead())
continue; continue;
//Ignore Check
if (ignore != null) if (ignore != null)
{ {
for (int i = 0; i < ignore.length; i++) boolean shouldIgnore = false;
for (Entity ent : ignore)
{ {
if (cur.equals(ignore[i])) if (cur.equals(ent))
continue; {
shouldIgnore = true;
break;
}
} }
if (shouldIgnore)
continue;
} }
double dist = UtilMath.offset(cur.getLocation(), loc); double dist = UtilMath.offset(cur.getLocation(), loc);

View File

@ -1,10 +1,12 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.stream.Stream;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Server; import org.bukkit.Server;
@ -18,6 +20,11 @@ public class UtilServer
return getServer().getOnlinePlayers().toArray(new Player[0]); return getServer().getOnlinePlayers().toArray(new Player[0]);
} }
public static Collection<? extends Player> getPlayersCollection()
{
return getServer().getOnlinePlayers();
}
public static List<Player> getSortedPlayers() public static List<Player> getSortedPlayers()
{ {
return getSortedPlayers(new Comparator<Player>() return getSortedPlayers(new Comparator<Player>()

View File

@ -1,52 +1,452 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import javax.imageio.ImageIO;
import mineplex.core.common.CurrencyType;
import org.apache.commons.lang.WordUtils; import org.apache.commons.lang.WordUtils;
import org.bukkit.Material; import org.bukkit.ChatColor;
public class UtilText { public class UtilText
public static <T> String listToString(Collection<T> inputList, boolean comma) { {
String out = ""; private static HashMap<Character, Integer> _characters = new HashMap<Character, Integer>();
for (T cur : inputList) { static
out += cur.toString() + (comma ? ", " : " "); {
try
{
InputStream inputStream = CurrencyType.class.getResourceAsStream("ascii.png");
BufferedImage image = ImageIO.read(inputStream);
char[] text = new char[]
{
' ',
'!',
'"',
'#',
'$',
'%',
'&',
'\'',
'(',
')',
'*',
'+',
',',
'-',
'.',
'/',
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
':',
';',
'<',
'=',
'>',
'?',
'@',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'[',
'\\',
']',
'^',
'_',
'`',
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
'{',
'|',
'}',
'~'
};
int x = 0;
int y = 16;
for (char c : text)
{
grab(c, image, x, y);
if (x < 15 * 8)
{
x += 8;
}
else
{
x = 0;
y += 8;
}
}
inputStream.close();
} }
catch (IOException e)
if (out.length() > 0) { {
out = out.substring(0, out.length() - (comma ? 2 : 1)); e.printStackTrace();
} }
return out;
} }
public static int upperCaseCount(String input) { public static String center(String string, LineFormat lineFormat)
int count = 0; {
int length = getLength(string);
for (int k = 0; k < input.length(); k++) {
char ch = input.charAt(k);
if (Character.isUpperCase(ch))
count++;
if (length > lineFormat.getLength())
{
return string;
} }
return count; // Get the number of empty pixels on both sides of the string
int div = (int) Math.floor((lineFormat.getLength() - length) / 2D);
div -= 2; // For the gap between the strings
return fillLine(" ", div) + string + fillLine(" ", div);
} }
public static int lowerCaseCount(String input) {
int count = 0;
for (int k = 0; k < input.length(); k++) { public static String alignRight(String string, LineFormat lineFormat)
{
int length = getLength(string);
char ch = input.charAt(k);
if (Character.isLowerCase(ch))
count++;
if (length > lineFormat.getLength())
{
return string;
} }
return count; // Get the number of empty pixels on both sides of the string
int div = lineFormat.getLength() - length;
div -= 1; // For the gap between the strings
return fillLine(" ", div) + string;
}
public static String centerChat(String string, LineFormat lineFormat)
{
int length = getLength(string);
if (length > lineFormat.getLength())
{
return string;
}
// Get the number of empty pixels on both sides of the string
int div = (int) Math.floor(((lineFormat.getLength() + 10) - length) / 2D);
div -= 2; // For the gap between the strings
return fillLine(" ", div) + string;
}
public static String substringPixels(String string, int cutoff)
{
int len = 0;
char[] array = string.toCharArray();
boolean bold = false;
for (int i = 0; i < array.length; i++)
{
char c = array[i];
if (c == '<27>')
{
if (++i < array.length)
{
ChatColor color = ChatColor.getByChar(array[i]);
if (color != null)
{
if (color.equals(ChatColor.BOLD))
{
bold = true;
}
else if (color.equals(ChatColor.RESET) || color.isColor())
{
bold = false;
}
}
}
continue;
}
if (!_characters.containsKey(c))
{
continue;
}
int toAdd = _characters.get(c);
if (bold)
{
toAdd++;
}
if (len + toAdd > cutoff)
{
return string.substring(0, Math.max(0, i - 1));
}
if (i + 1 < array.length)
{
len++;
}
}
return string;
}
public static ArrayList<String> splitLines(String[] strings, LineFormat lineFormat)
{
ArrayList<String> lines = new ArrayList<String>();
for (String s : strings)
{
lines.addAll(splitLine(s, lineFormat));
}
return lines;
}
public static ArrayList<String> splitLine(String string, LineFormat lineFormat)
{
ArrayList<String> strings = new ArrayList<String>();
String current = "";
int currentLength = 0;
String[] split = string.split(" ");
String colors = "";
for (int i = 0; i < split.length; i++)
{
String word = split[i];
int wordLength = getLength(colors + word);
if (currentLength + wordLength + 4 > lineFormat.getLength() && !current.isEmpty())
{
strings.add(current);
current = colors + word;
currentLength = wordLength + 1;
continue;
}
if (i != 0)
{
current += " ";
currentLength += 4;
}
current += word;
currentLength += wordLength;
colors = ChatColor.getLastColors(current);
}
if (!current.isEmpty())
{
strings.add(current);
}
return strings;
}
public static String fillLine(String filler, int maxPixels)
{
int pixels = getLength(filler);
if (pixels <= 0)
{
return "";
}
String toReturn = "";
int currentLen = 0;
int offset = maxPixels % 4;
boolean isOffset = false;
if (offset > 0)
{
toReturn += C.Bold;
}
while (currentLen + pixels <= maxPixels)
{
currentLen += pixels + 1;
toReturn += filler;
if (offset-- > 0)
{
currentLen++;
if (offset == 0)
{
isOffset = false;
toReturn += ChatColor.RESET;
}
}
}
if (isOffset)
{
toReturn += ChatColor.RESET;
}
return toReturn;
}
public static boolean fitsOneLine(String string, LineFormat lineFormat)
{
return getLength(string) <= lineFormat.getLength();
}
public static int getLength(String string)
{
int len = 0;
char[] array = string.toCharArray();
boolean bold = false;
for (int i = 0; i < array.length; i++)
{
char c = array[i];
if (c == '<27>')
{
if (++i < array.length)
{
ChatColor color = ChatColor.getByChar(array[i]);
if (color != null)
{
if (color.equals(ChatColor.BOLD))
{
bold = true;
}
else if (color.equals(ChatColor.RESET) || color.isColor())
{
bold = false;
}
}
}
continue;
}
if (!_characters.containsKey(c))
{
continue;
}
len += _characters.get(c);
if (bold)
{
len++;
}
if (i + 1 < array.length)
{
len++;
}
}
return len;
}
private static void grab(Character character, BufferedImage image, int imageX, int imageY)
{
if (character == ' ')
{
_characters.put(character, 3);
return;
}
for (int x = 0; x < 8; x++)
{
boolean isTransparentLine = true;
for (int y = 0; y < 8; y++)
{
int pixel = image.getRGB(imageX + x, imageY + y);
if ((pixel >> 24) != 0x00)
{
isTransparentLine = false;
break;
}
}
if (isTransparentLine)
{
_characters.put(character, x);
return;
}
}
_characters.put(character, 8);
} }
public static boolean isStringSimilar(String newString, String oldString, float matchRequirement) public static boolean isStringSimilar(String newString, String oldString, float matchRequirement)
@ -56,28 +456,28 @@ public class UtilText {
return newString.toLowerCase().equals(oldString.toLowerCase()); return newString.toLowerCase().equals(oldString.toLowerCase());
} }
for (int i=0 ; i < newString.length() * matchRequirement ; i++) for (int i = 0; i < newString.length() * matchRequirement; i++)
{ {
int matchFromIndex = 0; int matchFromIndex = 0;
//Look for substrings starting at i // Look for substrings starting at i
for (int j=0 ; j < oldString.length() ; j++) for (int j = 0; j < oldString.length(); j++)
{ {
//End of newString // End of newString
if (i+j >= newString.length()) if (i + j >= newString.length())
{ {
break; break;
} }
//Matched // Matched
if (newString.charAt(i+j) == oldString.charAt(j)) if (newString.charAt(i + j) == oldString.charAt(j))
{ {
matchFromIndex++; matchFromIndex++;
if (matchFromIndex >= newString.length() * matchRequirement) if (matchFromIndex >= newString.length() * matchRequirement)
return true; return true;
} }
//No Match > Reset // No Match > Reset
else else
{ {
break; break;
@ -88,12 +488,62 @@ public class UtilText {
return false; return false;
} }
public static <T> String listToString(Collection<T> inputList, boolean comma)
{
String out = "";
for (T cur : inputList)
{
out += cur.toString() + (comma ? ", " : " ");
}
if (out.length() > 0)
{
out = out.substring(0, out.length() - (comma ? 2 : 1));
}
return out;
}
public static int lowerCaseCount(String input)
{
int count = 0;
for (int k = 0; k < input.length(); k++)
{
char ch = input.charAt(k);
if (Character.isLowerCase(ch))
count++;
}
return count;
}
public static int upperCaseCount(String input)
{
int count = 0;
for (int k = 0; k < input.length(); k++)
{
char ch = input.charAt(k);
if (Character.isUpperCase(ch))
count++;
}
return count;
}
public static String[] wrap(String text, int lineLength) public static String[] wrap(String text, int lineLength)
{ {
return wrap(text, lineLength, true); return wrap(text, lineLength, true);
} }
public static String[] wrap(String text, int lineLength, boolean wrapLongerWords) { public static String[] wrap(String text, int lineLength, boolean wrapLongerWords)
{
return WordUtils.wrap(text, lineLength, "\00D0", wrapLongerWords).split("\00D0"); return WordUtils.wrap(text, lineLength, "\00D0", wrapLongerWords).split("\00D0");
} }
@ -102,12 +552,39 @@ public class UtilText {
return new String(new byte[times]).replace("\0", txt); return new String(new byte[times]).replace("\0", txt);
} }
public static boolean plural(int x){ public static boolean plural(int x)
{
return x <= 0 ? true : x > 1; return x <= 0 ? true : x > 1;
} }
public static String trim(int maxLength, String s) { public static String trim(int maxLength, String s)
{
return s.length() <= maxLength ? s : s.substring(0, maxLength); return s.length() <= maxLength ? s : s.substring(0, maxLength);
} }
public static <X> String arrayToString(X[] array, String delimiter)
{
StringBuilder string = new StringBuilder();
int index = 0;
for (X x : array)
{
string.append(x.toString());
if (index != array.length - 1)
{
string.append(delimiter);
}
index++;
}
return string.toString();
}
public static <X> String arrayToString(X[] array)
{
return arrayToString(array, null);
}
} }

View File

@ -19,13 +19,13 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.EnumEntityUseAction; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.EnumEntityUseAction;
import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity; import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
@ -49,8 +49,10 @@ import fr.neatmonster.nocheatplus.hooks.NCPHookManager;
public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
private NautHashMap<String, NautHashMap<Integer, Integer>> _entityMap = new NautHashMap<String, NautHashMap<Integer, Integer>>(); private NautHashMap<String, NautHashMap<Integer, Integer[]>> _entityMap = new NautHashMap<String, NautHashMap<Integer, Integer[]>>();
private NautHashMap<String, NautHashMap<Integer, String>> _entityNameMap = new NautHashMap<String, NautHashMap<Integer, String>>(); private NautHashMap<String, NautHashMap<Integer, String>> _entityNameMap = new NautHashMap<String, NautHashMap<Integer, String>>();
private NautHashMap<String, NautHashMap<Integer, Integer>> _entityRiding = new NautHashMap<String, NautHashMap<Integer, Integer>>();
private HashSet<String> _loggedIn = new HashSet<String>(); private HashSet<String> _loggedIn = new HashSet<String>();
private HashSet<Integer> _ignoreSkulls = new HashSet<Integer>(); private HashSet<Integer> _ignoreSkulls = new HashSet<Integer>();
@ -63,7 +65,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
packetHandler.addPacketHandler(this, true, PacketPlayOutAttachEntity.class, PacketPlayOutEntityDestroy.class, packetHandler.addPacketHandler(this, true, PacketPlayOutAttachEntity.class, PacketPlayOutEntityDestroy.class,
PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class,
PacketPlayInUseEntity.class); PacketPlayOutNamedEntitySpawn.class, PacketPlayInUseEntity.class, PacketPlayOutAttachEntity.class);
NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this); NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this);
NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this); NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this);
@ -75,6 +77,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
_entityMap.remove(event.getPlayer().getName()); _entityMap.remove(event.getPlayer().getName());
_entityNameMap.remove(event.getPlayer().getName()); _entityNameMap.remove(event.getPlayer().getName());
_entityRiding.remove(event.getPlayer().getName());
_loggedIn.remove(event.getPlayer()); _loggedIn.remove(event.getPlayer());
} }
@ -167,6 +170,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
iterator.remove(); iterator.remove();
_entityMap.remove(player); _entityMap.remove(player);
_entityNameMap.remove(player); _entityNameMap.remove(player);
_entityRiding.remove(player);
} }
} }
@ -190,7 +194,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
if (owner.isOnline() && !_entityMap.containsKey(owner.getName())) if (owner.isOnline() && !_entityMap.containsKey(owner.getName()))
{ {
_entityMap.put(owner.getName(), new NautHashMap<Integer, Integer>()); _entityMap.put(owner.getName(), new NautHashMap<Integer, Integer[]>());
_entityNameMap.put(owner.getName(), new NautHashMap<Integer, String>()); _entityNameMap.put(owner.getName(), new NautHashMap<Integer, String>());
_loggedIn.add(owner.getName()); _loggedIn.add(owner.getName());
} }
@ -217,10 +221,15 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a)) if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a))
{ {
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(new int[] Integer[] ids = _entityMap.get(owner.getName()).get(spawnPacket.a);
{ int[] newIds = new int[ids.length];
_entityMap.get(owner.getName()).get(spawnPacket.a)
})); for (int a = 0; a < ids.length; a++)
{
newIds[a] = ids[a];
}
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds));
_entityNameMap.get(owner.getName()).remove(spawnPacket.a); _entityNameMap.get(owner.getName()).remove(spawnPacket.a);
_entityMap.get(owner.getName()).remove(spawnPacket.a); _entityMap.get(owner.getName()).remove(spawnPacket.a);
@ -236,9 +245,59 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
int newId = UtilEnt.getNewEntityId(); int newId = UtilEnt.getNewEntityId();
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName); _entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
_entityMap.get(owner.getName()).put(spawnPacket.a, newId); _entityMap.get(owner.getName()).put(spawnPacket.a, new Integer[]
{
newId
});
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier, true); sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier, true, -1);
break;
}
}
}
else if (packet instanceof PacketPlayOutNamedEntitySpawn)
{
PacketPlayOutNamedEntitySpawn spawnPacket = (PacketPlayOutNamedEntitySpawn) packet;
for (WatchableObject watchable : (List<WatchableObject>) spawnPacket.i.c())
{
if (watchable.a() == 3 && watchable.b() instanceof Byte && ((Byte) watchable.b()) == 1)
{
if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a))
{
Integer[] ids = _entityMap.get(owner.getName()).get(spawnPacket.a);
int[] newIds = new int[ids.length];
for (int a = 0; a < ids.length; a++)
{
newIds[a] = ids[a];
}
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds));
_entityNameMap.get(owner.getName()).remove(spawnPacket.a);
_entityMap.get(owner.getName()).remove(spawnPacket.a);
}
final String entityName = spawnPacket.i.getString(2);
if (entityName.isEmpty())
{
return;
}
int newId = UtilEnt.getNewEntityId();
int newId2 = UtilEnt.getNewEntityId();
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
_entityMap.get(owner.getName()).put(spawnPacket.a, new Integer[]
{
newId,
newId2
});
sendProtocolPackets(owner, spawnPacket.a, newId2, entityName, verifier, true, newId);
break; break;
} }
} }
@ -247,7 +306,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata) packet; PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata) packet;
if (metaPacket.a != 777777 && !_ignoreSkulls.contains(metaPacket.a)) if (metaPacket.a != 777777 && !_ignoreSkulls.contains(metaPacket.a) && metaPacket.a != owner.getEntityId())
{ {
boolean isDisplaying = _entityMap.get(owner.getName()).containsKey(metaPacket.a); boolean isDisplaying = _entityMap.get(owner.getName()).containsKey(metaPacket.a);
String currentName = _entityNameMap.get(owner.getName()).get(metaPacket.a); String currentName = _entityNameMap.get(owner.getName()).get(metaPacket.a);
@ -279,7 +338,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
// If name is still being displayed // If name is still being displayed
if (newDisplay) if (newDisplay)
{ {
int newId; Integer[] newId;
if (isDisplaying) // Sending metadata if (isDisplaying) // Sending metadata
{ {
@ -288,22 +347,28 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
else else
// Spawning new entity // Spawning new entity
{ {
newId = UtilEnt.getNewEntityId(); newId = new Integer[]
{
UtilEnt.getNewEntityId()
};
_entityMap.get(owner.getName()).put(metaPacket.a, newId); _entityMap.get(owner.getName()).put(metaPacket.a, newId);
} }
sendProtocolPackets(owner, metaPacket.a, newId, newName, verifier, !isDisplaying);
_entityNameMap.get(owner.getName()).put(metaPacket.a, newName); _entityNameMap.get(owner.getName()).put(metaPacket.a, newName);
sendProtocolPackets(owner, metaPacket.a, newId[0], newName, verifier, !isDisplaying, -1);
} }
else else
{ // Lets delete it { // Lets delete it
int id = _entityMap.get(owner.getName()).get(metaPacket.a); Integer[] ids = _entityMap.get(owner.getName()).get(metaPacket.a);
int[] newIds = new int[ids.length];
verifier.bypassProcess(new PacketPlayOutEntityDestroy(new int[] for (int a = 0; a < ids.length; a++)
{ {
id newIds[a] = ids[a];
})); }
verifier.bypassProcess(new PacketPlayOutEntityDestroy(newIds));
_entityMap.get(owner.getName()).remove(metaPacket.a); _entityMap.get(owner.getName()).remove(metaPacket.a);
_entityNameMap.get(owner.getName()).remove(metaPacket.a); _entityNameMap.get(owner.getName()).remove(metaPacket.a);
@ -319,10 +384,15 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
if (_entityMap.get(owner.getName()).containsKey(id)) if (_entityMap.get(owner.getName()).containsKey(id))
{ {
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(new int[] Integer[] ids = _entityMap.get(owner.getName()).get(id);
{ int[] newIds = new int[ids.length];
_entityMap.get(owner.getName()).get(id)
})); for (int a = 0; a < ids.length; a++)
{
newIds[a] = ids[a];
}
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds));
_entityMap.get(owner.getName()).remove(id); _entityMap.get(owner.getName()).remove(id);
_entityNameMap.get(owner.getName()).remove(id); _entityNameMap.get(owner.getName()).remove(id);
} }
@ -345,19 +415,79 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
PacketPlayInUseEntity usePacket = (PacketPlayInUseEntity) packet; PacketPlayInUseEntity usePacket = (PacketPlayInUseEntity) packet;
for (Entry<Integer, Integer> entry : _entityMap.get(owner.getName()).entrySet()) loop:
{
if (entry.getValue() == usePacket.a)
{
PacketPlayInUseEntity newPacket = new PacketPlayInUseEntity();
newPacket.a = entry.getKey();
newPacket.action = usePacket.action == EnumEntityUseAction.ATTACK ? EnumEntityUseAction.ATTACK
: EnumEntityUseAction.INTERACT;
for (Entry<Integer, Integer[]> entry : _entityMap.get(owner.getName()).entrySet())
{
for (int id : entry.getValue())
{
if (id == usePacket.a)
{ {
((CraftPlayer) owner).getHandle().playerConnection.a(newPacket); PacketPlayInUseEntity newPacket = new PacketPlayInUseEntity();
newPacket.a = entry.getKey();
newPacket.action = usePacket.action == EnumEntityUseAction.ATTACK ? EnumEntityUseAction.ATTACK
: EnumEntityUseAction.INTERACT;
{
((CraftPlayer) owner).getHandle().playerConnection.a(newPacket);
}
break loop;
} }
break; }
}
}
else if (packet instanceof PacketPlayOutAttachEntity)
{
PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity) packet;
// c = rider, b = ridden
// When detaching, c is sent, b is -1
// If this attach packet is for a player that has the fix
// If the attach packet isn't ordained by me
if (!_entityMap.containsKey(owner.getName()))
{
return;
}
if (!_entityRiding.containsKey(owner.getName()))
{
_entityRiding.put(owner.getName(), new NautHashMap<Integer, Integer>());
}
int vehicleId = -1;
if (_entityRiding.get(owner.getName()).containsKey(attachPacket.b))
{
vehicleId = _entityRiding.get(owner.getName()).get(attachPacket.b);
}
if (attachPacket.c == -1 && _entityMap.get(owner.getName()).containsKey(vehicleId))
{
Integer[] ids = _entityMap.get(owner.getName()).get(vehicleId);
_entityRiding.get(owner.getName()).remove(attachPacket.b);
sendProtocolPackets(owner, vehicleId, ids[ids.length - 1],
_entityNameMap.get(owner.getName()).get(vehicleId), verifier, true, ids.length > 1 ? ids[0] : -1);
}
else
{
Integer[] ids = _entityMap.get(owner.getName()).get(attachPacket.c);
if (ids != null && ids[0] != attachPacket.b)
{
_entityRiding.get(owner.getName()).put(attachPacket.b, attachPacket.c);
int[] newIds = new int[ids.length];
for (int a = 0; a < ids.length; a++)
{
newIds[a] = ids[a];
}
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds));
} }
} }
} }
@ -365,7 +495,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
} }
private void sendProtocolPackets(final Player owner, final int entityId, final int newEntityId, String entityName, private void sendProtocolPackets(final Player owner, final int entityId, final int newEntityId, String entityName,
final PacketVerifier packetList, final boolean newPacket) final PacketVerifier packetList, final boolean newPacket, final int squidId)
{ {
CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName); CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName);
_plugin.getServer().getPluginManager().callEvent(event); _plugin.getServer().getPluginManager().callEvent(event);
@ -375,82 +505,47 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
public void run() public void run()
{ {
final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle())); DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle()));
watcher.a(0, Byte.valueOf((byte) 0)); watcher.a(0, (byte) (0 | 1 << 5)); // Invisible
watcher.a(1, Short.valueOf((short) 300)); watcher.a(1, Short.valueOf((short) 300));
watcher.a(2, ""); watcher.a(2, finalEntityName);
watcher.a(3, Byte.valueOf((byte) 0)); watcher.a(3, (byte) 1);
watcher.a(4, Byte.valueOf((byte) 0)); watcher.a(4, Byte.valueOf((byte) 0));
watcher.a(7, Integer.valueOf(0)); watcher.a(7, Integer.valueOf(0));
watcher.a(8, Byte.valueOf((byte) 0)); watcher.a(8, Byte.valueOf((byte) 0));
watcher.a(9, Byte.valueOf((byte) 0)); watcher.a(9, Byte.valueOf((byte) 0));
watcher.a(6, Float.valueOf(1.0F)); watcher.a(6, Float.valueOf(1.0F));
watcher.a(10, Byte.valueOf((byte) 0)); watcher.a(10, (byte) (0 | 0x1)); // Small
// Set invisible
int i1 = watcher.getByte(0);
watcher.watch(0, Byte.valueOf((byte) (i1 | 1 << 5)));
// Set small
byte b1 = watcher.getByte(10);
b1 = (byte) (b1 | 0x1);
watcher.watch(10, Byte.valueOf(b1));
watcher.watch(2, finalEntityName);
watcher.watch(3, Byte.valueOf((byte) 1));
if (newPacket) if (newPacket)
{ {
if (squidId >= 0)
{
watcher.watch(10, (byte) 16);
DataWatcher squidWatcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle()));
squidWatcher.a(0, (byte) (0 | 1 << 5));
final PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving();
spawnPacket.a = squidId;
spawnPacket.b = (byte) EntityType.SQUID.getTypeId();
spawnPacket.l = squidWatcher;
UtilPlayer.sendPacket(owner, spawnPacket);
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = spawnPacket.a;
vehiclePacket.c = entityId;
UtilPlayer.sendPacket(owner, vehiclePacket);
}
final PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving(); final PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving();
spawnPacket.a = newEntityId; spawnPacket.a = newEntityId;
spawnPacket.b = (byte) 30; spawnPacket.b = (byte) 30;
spawnPacket.c = (int) MathHelper.floor(100 * 32);
spawnPacket.d = (int) MathHelper.floor(64 * 32.0D);
spawnPacket.e = (int) MathHelper.floor(100 * 32);
spawnPacket.i = (byte) ((int) (0 * 256.0F / 360.0F));
spawnPacket.j = (byte) ((int) (0 * 256.0F / 360.0F));
spawnPacket.k = (byte) ((int) (0 * 256.0F / 360.0F));
double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
if (var4 < -var2)
{
var4 = -var2;
}
if (var6 < -var2)
{
var6 = -var2;
}
if (var8 < -var2)
{
var8 = -var2;
}
if (var4 > var2)
{
var4 = var2;
}
if (var6 > var2)
{
var6 = var2;
}
if (var8 > var2)
{
var8 = var2;
}
spawnPacket.f = (int) (var4 * 8000.0D);
spawnPacket.g = (int) (var6 * 8000.0D);
spawnPacket.h = (int) (var8 * 8000.0D);
spawnPacket.l = watcher; spawnPacket.l = watcher;
@ -459,7 +554,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity(); PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0; vehiclePacket.a = 0;
vehiclePacket.b = spawnPacket.a; vehiclePacket.b = spawnPacket.a;
vehiclePacket.c = entityId; vehiclePacket.c = squidId >= 0 ? squidId : entityId;
UtilPlayer.sendPacket(owner, vehiclePacket); UtilPlayer.sendPacket(owner, vehiclePacket);
} }

View File

@ -345,7 +345,10 @@ public class AntiHack extends MiniPlugin
} }
//Auto-Kick //Auto-Kick
if (!handled && _clientManager.Get(player).GetRank() != Rank.YOUTUBE && _clientManager.Get(player).GetRank() != Rank.TWITCH) if (!handled &&
_clientManager.Get(player).GetRank() != Rank.YOUTUBE &&
_clientManager.Get(player).GetRank() != Rank.YOUTUBE_SMALL &&
_clientManager.Get(player).GetRank() != Rank.TWITCH)
{ {
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 2f, 0.5f); player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 2f, 0.5f);

View File

@ -7,29 +7,21 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.sql.Types; import java.sql.Types;
import java.util.Map;
import com.sun.org.apache.xpath.internal.operations.Bool;
import mineplex.core.bonuses.gui.SpinGui;
import mineplex.core.common.Pair; import mineplex.core.common.Pair;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.database.DBPool; import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase; import mineplex.core.database.RepositoryBase;
import mineplex.core.database.ResultSetCallable; import mineplex.core.database.ResultSetCallable;
import mineplex.core.database.column.ColumnInt;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.database.Tables; import mineplex.database.Tables;
import mineplex.database.tables.records.BonusRecord; import mineplex.database.tables.records.BonusRecord;
import org.jooq.Configuration;
import org.jooq.DSLContext; import org.jooq.DSLContext;
import org.jooq.Record2; import org.jooq.Record2;
import org.jooq.SQLDialect; import org.jooq.SQLDialect;
import org.jooq.TableField; import org.jooq.TableField;
import org.jooq.impl.DSL; import org.jooq.impl.DSL;
import org.jooq.impl.DefaultConfiguration;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -43,6 +43,14 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
if (slot == 26) if (slot == 26)
slot = 28; 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) 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)); 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

@ -14,6 +14,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.event.GadgetActivateEvent;
import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.gadget.gadgets.ItemBatGun; import mineplex.core.gadget.gadgets.ItemBatGun;
import mineplex.core.gadget.gadgets.ItemCoinBomb; import mineplex.core.gadget.gadgets.ItemCoinBomb;
@ -63,6 +64,7 @@ import mineplex.core.gadget.types.OutfitGadget.ArmorSlot;
import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.inventory.InventoryManager; import mineplex.core.inventory.InventoryManager;
import mineplex.core.mount.MountManager; import mineplex.core.mount.MountManager;
import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.pet.PetManager; import mineplex.core.pet.PetManager;
import mineplex.core.preferences.PreferencesManager; import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager; import mineplex.core.projectile.ProjectileManager;
@ -91,6 +93,7 @@ public class GadgetManager extends MiniPlugin
private BlockRestore _blockRestore; private BlockRestore _blockRestore;
private ProjectileManager _projectileManager; private ProjectileManager _projectileManager;
private AchievementManager _achievementManager; private AchievementManager _achievementManager;
private MountManager _mountManager;
private NautHashMap<GadgetType, List<Gadget>> _gadgets; private NautHashMap<GadgetType, List<Gadget>> _gadgets;
@ -99,6 +102,7 @@ public class GadgetManager extends MiniPlugin
private boolean _hideParticles = false; private boolean _hideParticles = false;
private int _activeItemSlot = 3; private int _activeItemSlot = 3;
private boolean _gadgetsEnabled = true;
public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager,
MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager, MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager,
@ -115,6 +119,7 @@ public class GadgetManager extends MiniPlugin
_blockRestore = blockRestore; _blockRestore = blockRestore;
_projectileManager = projectileManager; _projectileManager = projectileManager;
_achievementManager = achievementManager; _achievementManager = achievementManager;
_mountManager = mountManager;
CreateGadgets(); CreateGadgets();
} }
@ -492,6 +497,40 @@ public class GadgetManager extends MiniPlugin
return true; return true;
} }
public boolean isGadgetEnabled()
{
return _gadgetsEnabled;
}
public void toggleGadgetEnabled()
{
setGadgetEnabled(!_gadgetsEnabled);
}
public void setGadgetEnabled(boolean enabled)
{
if (_gadgetsEnabled != enabled)
{
_gadgetsEnabled = enabled;
DisableAll();
_mountManager.DisableAll();
}
}
@EventHandler
public void GadgetActivate(GadgetActivateEvent event)
{
if (!_gadgetsEnabled)
event.setCancelled(true);
}
@EventHandler
public void MountActivate(MountActivateEvent event)
{
if (!_gadgetsEnabled)
event.setCancelled(true);
}
@EventHandler @EventHandler
public void chissMeow(PlayerToggleSneakEvent event) public void chissMeow(PlayerToggleSneakEvent event)
{ {

View File

@ -19,10 +19,10 @@ public enum GameDisplay
DragonEscapeTeams("Dragon Escape Teams", Material.DRAGON_EGG, (byte)0, GameCategory.TEAM_VARIANT, 11), DragonEscapeTeams("Dragon Escape Teams", Material.DRAGON_EGG, (byte)0, GameCategory.TEAM_VARIANT, 11),
DragonRiders("Dragon Riders", Material.DRAGON_EGG, (byte)0, GameCategory.ARCADE, 12), DragonRiders("Dragon Riders", Material.DRAGON_EGG, (byte)0, GameCategory.ARCADE, 12),
Dragons("Dragons", Material.ENDER_STONE, (byte)0, GameCategory.ARCADE, 13), Dragons("Dragons", Material.ENDER_STONE, (byte)0, GameCategory.ARCADE, 13),
DragonsTeams("Dragons Teams", Material.ENDER_STONE, (byte)0, GameCategory.TEAM_VARIANT, 14), DragonsTeams("Dragons Teams", Material.DRAGON_EGG, (byte)0, GameCategory.TEAM_VARIANT, 14),
Draw("Draw My Thing", Material.BOOK_AND_QUILL, (byte)0, GameCategory.CLASSICS, 15), Draw("Draw My Thing", Material.BOOK_AND_QUILL, (byte)0, GameCategory.CLASSICS, 15),
Evolution("Evolution", Material.EMERALD, (byte)0, GameCategory.ARCADE, 16), Evolution("Evolution", Material.EMERALD, (byte)0, GameCategory.ARCADE, 16),
Gravity("Gravity", Material.ENDER_PORTAL, (byte)0, GameCategory.EXTRA, 18), Gravity("Gravity", Material.ENDER_PORTAL_FRAME, (byte)0, GameCategory.EXTRA, 18),
Halloween("Halloween Horror", Material.PUMPKIN, (byte)0, GameCategory.CLASSICS, 19), Halloween("Halloween Horror", Material.PUMPKIN, (byte)0, GameCategory.CLASSICS, 19),
HideSeek("Block Hunt", Material.GRASS, (byte)0, GameCategory.CLASSICS, 20), HideSeek("Block Hunt", Material.GRASS, (byte)0, GameCategory.CLASSICS, 20),
HoleInTheWall("Hole in the Wall", Material.STAINED_GLASS, (byte) 2, GameCategory.ARCADE, 52), HoleInTheWall("Hole in the Wall", Material.STAINED_GLASS, (byte) 2, GameCategory.ARCADE, 52),
@ -64,11 +64,14 @@ public enum GameDisplay
Skywars("Skywars", Material.FEATHER, (byte) 0, GameCategory.SURVIVAL, 52), Skywars("Skywars", Material.FEATHER, (byte) 0, GameCategory.SURVIVAL, 52),
SkywarsTeams("Skywars Teams", "Skywars", Material.FEATHER, (byte)0, GameCategory.TEAM_VARIANT, 53), SkywarsTeams("Skywars Teams", "Skywars", Material.FEATHER, (byte)0, GameCategory.TEAM_VARIANT, 53),
MonsterMaze("Monster Maze", Material.ROTTEN_FLESH, (byte)0, GameCategory.ARCADE, 55), MonsterMaze("Monster Maze", Material.ROTTEN_FLESH, (byte)0, GameCategory.ARCADE, 55),
MonsterLeague("Monster League", Material.MINECART, (byte)0, GameCategory.ARCADE, 56),
Lobbers("Bomb Lobbers", Material.FIREBALL, (byte) 0, GameCategory.ARCADE, 54), Lobbers("Bomb Lobbers", Material.FIREBALL, (byte) 0, GameCategory.ARCADE, 54),
ChampionsCTF("Champions CTF", "Champions", Material.BANNER, DyeColor.RED.getDyeData(), GameCategory.CHAMPIONS, 56), ChampionsCTF("Champions CTF", "Champions", Material.BANNER, DyeColor.RED.getDyeData(), GameCategory.CHAMPIONS, 56),
BouncyBalls("Bouncy Balls", Material.SLIME_BALL, (byte)0, GameCategory.ARCADE, 57),
Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999); Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999);
String _name; String _name;

View File

@ -67,7 +67,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
MessageHandler messageHandler = new MessageHandler(this); MessageHandler messageHandler = new MessageHandler(this);
ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class, ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class,
new AnnouncementHandler()); new AnnouncementHandler(clientManager));
ServerCommandManager.getInstance().registerCommandType("RedisMessage", RedisMessage.class, messageHandler); ServerCommandManager.getInstance().registerCommandType("RedisMessage", RedisMessage.class, messageHandler);
ServerCommandManager.getInstance() ServerCommandManager.getInstance()

View File

@ -10,6 +10,7 @@ import mineplex.core.message.MessageManager;
import mineplex.serverdata.commands.AnnouncementCommand; import mineplex.serverdata.commands.AnnouncementCommand;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class AnnounceCommand extends CommandBase<MessageManager> public class AnnounceCommand extends CommandBase<MessageManager>
@ -22,13 +23,25 @@ public class AnnounceCommand extends CommandBase<MessageManager>
@Override @Override
public void Execute(Player caller, String[] args) public void Execute(Player caller, String[] args)
{ {
if (args == null || args.length == 0) if (args == null || args.length <= 1)
{ {
Plugin.Help(caller); Plugin.Help(caller);
} }
else else
{ {
new AnnouncementCommand(true, F.combine(args, 0, null, false)).publish(); Rank rank = Rank.ALL;
try
{
rank = Rank.valueOf(args[0]);
}
catch (IllegalArgumentException ex)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Invalid rank!"));
return;
}
new AnnouncementCommand(true, rank.toString(), F.combine(args, 1, null, false)).publish();
} }
} }
} }

View File

@ -1,5 +1,7 @@
package mineplex.core.message.redis; package mineplex.core.message.redis;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
@ -13,20 +15,41 @@ import org.bukkit.entity.Player;
public class AnnouncementHandler implements CommandCallback public class AnnouncementHandler implements CommandCallback
{ {
private CoreClientManager _clientManager;
public AnnouncementHandler(CoreClientManager clientManager)
{
_clientManager = clientManager;
}
public void run(ServerCommand command) public void run(ServerCommand command)
{ {
if (command instanceof AnnouncementCommand) if (command instanceof AnnouncementCommand)
{ {
AnnouncementCommand announcementCommand = (AnnouncementCommand)command; AnnouncementCommand announcementCommand = (AnnouncementCommand)command;
String message = announcementCommand.getMessage(); Rank rank;
try
{
rank = Rank.valueOf(announcementCommand.getRank());
}
catch (Exception e)
{
e.printStackTrace();
return;
}
if (announcementCommand.getDisplayTitle()) String message = announcementCommand.getMessage();
UtilTextMiddle.display(C.cYellow + "Announcement", message, 10, 120, 10);
for (Player player : Bukkit.getOnlinePlayers()) for (Player player : Bukkit.getOnlinePlayers())
{ {
UtilPlayer.message(player, F.main("Announcement", C.cAqua + message)); if (_clientManager.hasRank(player, rank))
{
if (announcementCommand.getDisplayTitle())
UtilTextMiddle.display(C.cYellow + "Announcement", message, 10, 120, 10, player);
UtilPlayer.message(player, F.main("Announcement", C.cAqua + message));
}
} }
} }
} }

View File

@ -5,6 +5,7 @@ import java.util.HashSet;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -18,6 +19,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_8_R3.MinecraftServer;
public class LagMeter extends MiniPlugin public class LagMeter extends MiniPlugin
{ {
@ -129,8 +131,26 @@ public class LagMeter extends MiniPlugin
} }
} }
private String getPrefix(double value)
{
if (value >= 18.0)
return C.cGreen;
else if (value >= 15)
return C.cYellow;
else
return C.cRed;
}
private void sendUpdate(Player player) private void sendUpdate(Player player)
{ {
double[] tps = MinecraftServer.getServer().recentTps;
String mcString = "";
for (int i = 0; i < tps.length; i++)
{
mcString += getPrefix(tps[i]) + (double)Math.round(tps[i] * 100.0D) / 100.0D;
if (i < tps.length - 1) mcString += C.cWhite + ", ";
}
player.sendMessage(" "); player.sendMessage(" ");
player.sendMessage(" "); player.sendMessage(" ");
player.sendMessage(" "); player.sendMessage(" ");
@ -138,6 +158,8 @@ public class LagMeter extends MiniPlugin
player.sendMessage(" "); player.sendMessage(" ");
player.sendMessage(F.main(getName(), ChatColor.GRAY + "Live-------" + ChatColor.YELLOW + String.format("%.00f", _ticksPerSecond))); player.sendMessage(F.main(getName(), ChatColor.GRAY + "Live-------" + ChatColor.YELLOW + String.format("%.00f", _ticksPerSecond)));
player.sendMessage(F.main(getName(), ChatColor.GRAY + "Avg--------" + ChatColor.YELLOW + String.format("%.00f", _ticksPerSecondAverage * 20))); player.sendMessage(F.main(getName(), ChatColor.GRAY + "Avg--------" + ChatColor.YELLOW + String.format("%.00f", _ticksPerSecondAverage * 20)));
player.sendMessage(F.main(getName(), ChatColor.YELLOW + "MC Timings (5,10,15 min avg)"));
player.sendMessage(F.main(getName(), ChatColor.GRAY + mcString));
player.sendMessage(F.main(getName(), ChatColor.YELLOW + "MEM")); player.sendMessage(F.main(getName(), ChatColor.YELLOW + "MEM"));
player.sendMessage(F.main(getName(), ChatColor.GRAY + "Free-------" + ChatColor.YELLOW + (Runtime.getRuntime().freeMemory() / 1048576) + "MB")); player.sendMessage(F.main(getName(), ChatColor.GRAY + "Free-------" + ChatColor.YELLOW + (Runtime.getRuntime().freeMemory() / 1048576) + "MB"));
player.sendMessage(F.main(getName(), ChatColor.GRAY + "Max--------" + ChatColor.YELLOW + (Runtime.getRuntime().maxMemory() / 1048576)) + "MB"); player.sendMessage(F.main(getName(), ChatColor.GRAY + "Max--------" + ChatColor.YELLOW + (Runtime.getRuntime().maxMemory() / 1048576)) + "MB");

View File

@ -1,7 +1,7 @@
package mineplex.core.mount; package mineplex.core.mount;
import mineplex.core.common.util.UtilAlg; import java.util.ArrayList;
import mineplex.core.common.util.UtilEnt; import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -13,12 +13,14 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; 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; DragonMount Host;
public EnderDragon Dragon; public EnderDragon Dragon;
public Player Rider;
public Entity TargetEntity = null; public Entity TargetEntity = null;
@ -31,10 +33,9 @@ public class DragonData
public DragonData(DragonMount dragonMount, Player rider) public DragonData(DragonMount dragonMount, Player rider)
{ {
super(rider);
Host = dragonMount; Host = dragonMount;
Rider = rider;
Velocity = rider.getLocation().getDirection().setY(0).normalize(); Velocity = rider.getLocation().getDirection().setY(0).normalize();
Pitch = UtilAlg.GetPitch(rider.getLocation().getDirection()); Pitch = UtilAlg.GetPitch(rider.getLocation().getDirection());
@ -51,25 +52,34 @@ public class DragonData
Chicken = rider.getWorld().spawn(rider.getLocation(), Chicken.class); Chicken = rider.getWorld().spawn(rider.getLocation(), Chicken.class);
Dragon.setPassenger(Chicken); Dragon.setPassenger(Chicken);
Chicken.setPassenger(Rider); Chicken.setPassenger(getOwner());
Bukkit.getServer().getScheduler().runTaskLater(Host.Manager.getPlugin(), new Runnable() Bukkit.getServer().getScheduler().runTaskLater(Host.Manager.getPlugin(), new Runnable()
{ {
public void run() public void run()
{ {
Chicken.setPassenger(Rider); Chicken.setPassenger(getOwner());
} }
}, 10L); }, 10L);
} }
public void Move() public void Move()
{ {
Rider.eject(); getOwner().eject();
((CraftEnderDragon)Dragon).getHandle().setTargetBlock(GetTarget().getBlockX(), GetTarget().getBlockY(), GetTarget().getBlockZ()); ((CraftEnderDragon)Dragon).getHandle().setTargetBlock(GetTarget().getBlockX(), GetTarget().getBlockY(), GetTarget().getBlockZ());
} }
public Location GetTarget() 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.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseChicken;
public class DragonMount extends Mount<DragonData> 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.event.EventHandler;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class HorseMount extends Mount<Horse> public class HorseMount extends Mount<SingleEntityMountData<Horse>>
{ {
protected Color _color; protected Color _color;
protected Style _style; protected Style _style;
@ -53,7 +53,7 @@ public class HorseMount extends Mount<Horse>
while (activeIterator.hasNext()) while (activeIterator.hasNext())
{ {
Player player = activeIterator.next(); Player player = activeIterator.next();
Horse horse = _active.get(player); Horse horse = _active.get(player).getEntity();
//Invalid (dead) //Invalid (dead)
if (!horse.isValid()) if (!horse.isValid())
@ -113,15 +113,16 @@ public class HorseMount extends Mount<Horse>
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
//Store //Store
_active.put(player, horse); SingleEntityMountData<Horse> mount = new SingleEntityMountData<Horse>(player, horse);
_active.put(player, mount);
} }
public void Disable(Player player) public void Disable(Player player)
{ {
Horse horse = _active.remove(player); SingleEntityMountData<Horse> mount = _active.remove(player);
if (horse != null) if (mount != null)
{ {
horse.remove(); mount.remove();
//Inform //Inform
UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(GetName()) + ".")); 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.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -18,7 +19,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.mount.event.MountActivateEvent; import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.shop.item.SalesPackageBase; 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 HashSet<Player> _owners = new HashSet<Player>();
protected HashMap<Player, T> _active = new HashMap<Player, T>(); protected HashMap<Player, T> _active = new HashMap<Player, T>();
@ -51,8 +52,8 @@ public abstract class Mount<T> extends SalesPackageBase implements Listener
return; return;
} }
Manager.setActive(player, this);
EnableCustom(player); EnableCustom(player);
Manager.setActive(player, this);
} }
public abstract void EnableCustom(Player player); public abstract void EnableCustom(Player player);
@ -97,4 +98,13 @@ public abstract class Mount<T> extends SalesPackageBase implements Listener
{ {
return _owners.contains(player); 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.ArrayList;
import java.util.List; 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.MiniPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.blockrestore.BlockRestore; 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.MountUndead;
import mineplex.core.mount.types.MountZombie; 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 public class MountManager extends MiniPlugin
{ {
private CoreClientManager _clientManager; private CoreClientManager _clientManager;
@ -84,32 +84,30 @@ public class MountManager extends MiniPlugin
} }
@EventHandler @EventHandler
public void HorseInteract(PlayerInteractEntityEvent event) public void mountInteract(PlayerInteractAtEntityEvent event)
{ {
if (!(event.getRightClicked() instanceof Horse)) MountData mount = getMountData(event.getRightClicked());
return;
boolean found = false; if(mount == null) return;
for (Mount mount : _playerActiveMountMap.values())
{
if (mount.GetActive().containsValue(event.getRightClicked()))
{
found = true;
break;
}
}
if (!found) if(mount.ownsMount(event.getPlayer())) return;
return;
Player player = event.getPlayer(); event.setCancelled(true);
Horse horse = (Horse)event.getRightClicked();
}
@EventHandler
public void mountInteract(PlayerInteractEntityEvent event)
{
MountData mount = getMountData(event.getRightClicked());
if(mount == null) return;
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 @EventHandler
@ -179,15 +177,27 @@ public class MountManager extends MiniPlugin
return _disguiseManager; return _disguiseManager;
} }
public boolean isMount(Entity ent) public MountData getMountData(Entity ent)
{ {
for (Mount<?> mount : _playerActiveMountMap.values()) for (Mount<?> mount : _playerActiveMountMap.values())
{ {
if (mount.GetActive().values().contains(ent)) MountData data = mount.getMountData(ent);
{ if(data != null) return data;
return true;
}
} }
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; package mineplex.core.mount.types;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -18,23 +19,12 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.mount.Mount; import mineplex.core.mount.Mount;
import mineplex.core.mount.MountManager; import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
public class MountCart extends Mount<SingleEntityMountData<Minecart>>
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 MountCart(MountManager manager) public MountCart(MountManager manager)
{ {
@ -56,7 +46,7 @@ public class MountCart extends Mount<Minecart>
//Remove other mounts //Remove other mounts
Manager.DeregisterAll(player); 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 //Inform
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); 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) public void Disable(Player player)
{ {
Minecart mount = _active.remove(player); SingleEntityMountData<Minecart> mount = _active.remove(player);
if (mount != null) if (mount != null)
{ {
mount.remove(); mount.remove();
@ -85,14 +75,11 @@ public class MountCart extends Mount<Minecart>
if (event.getRightClicked() == null) if (event.getRightClicked() == null)
return; return;
if (!GetActive().containsKey(event.getPlayer())) SingleEntityMountData<Minecart> mount = getMountData(event.getRightClicked());
return;
if (!GetActive().get(event.getPlayer()).equals(event.getRightClicked())) if(mount == null) return;
{
UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!")); if(!mount.ownsMount(event.getPlayer())) return;
return;
}
event.getPlayer().leaveVehicle(); event.getPlayer().leaveVehicle();
event.getPlayer().eject(); event.getPlayer().eject();
@ -117,8 +104,10 @@ public class MountCart extends Mount<Minecart>
return; return;
//Bounce //Bounce
for (Minecart cart : GetActive().values()) for (SingleEntityMountData<Minecart> cartData : GetActive().values())
{ {
Minecart cart = cartData.getEntity();
if (cart.getPassenger() == null) if (cart.getPassenger() == null)
continue; continue;
@ -137,8 +126,10 @@ public class MountCart extends Mount<Minecart>
} }
//Collide //Collide
for (Minecart cart : GetActive().values()) for (SingleEntityMountData<Minecart> cartData : GetActive().values())
{ {
Minecart cart = cartData.getEntity();
if (cart.getPassenger() == null) if (cart.getPassenger() == null)
continue; continue;
@ -150,8 +141,9 @@ public class MountCart extends Mount<Minecart>
if (!Recharge.Instance.usable(player, GetName() + " Collide")) if (!Recharge.Instance.usable(player, GetName() + " Collide"))
continue; continue;
for (Minecart other : GetActive().values()) for (SingleEntityMountData<Minecart> otherData : GetActive().values())
{ {
Minecart other = otherData.getEntity();
if (other.equals(cart)) if (other.equals(cart))
continue; continue;

View File

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

View File

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

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.Slime;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
@ -18,18 +19,19 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.mount.Mount; import mineplex.core.mount.Mount;
import mineplex.core.mount.MountManager; import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
public class MountSlime extends Mount<Slime> public class MountSlime extends Mount<SingleEntityMountData<Slime>>
{ {
public MountSlime(MountManager manager) public MountSlime(MountManager manager)
{ {
super(manager, "Slime Mount", Material.SLIME_BALL, (byte)0, new String[] super(manager, "Slime Mount", Material.SLIME_BALL, (byte)0, new String[]
{ {
ChatColor.RESET + "Bounce around on your very", ChatColor.RESET + "Bounce around on your very",
ChatColor.RESET + "own personal slime friend!", ChatColor.RESET + "own personal slime friend!",
}, },
15000); 15000);
@ -44,10 +46,10 @@ public class MountSlime extends Mount<Slime>
//Remove other mounts //Remove other mounts
Manager.DeregisterAll(player); Manager.DeregisterAll(player);
Slime mount = player.getWorld().spawn(player.getLocation(), Slime.class); SingleEntityMountData<Slime> mount = new SingleEntityMountData<Slime>(player, player.getWorld().spawn(player.getLocation(), Slime.class));
mount.setSize(2); mount.getEntity().setSize(2);
mount.setCustomName(player.getName() + "'s " + GetName()); mount.getEntity().setCustomName(player.getName() + "'s " + GetName());
//Inform //Inform
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); 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) public void Disable(Player player)
{ {
Slime mount = _active.remove(player); SingleEntityMountData<Slime> mount = _active.remove(player);
if (mount != null) if (mount != null)
{ {
mount.remove(); mount.remove();
@ -76,14 +78,13 @@ public class MountSlime extends Mount<Slime>
if (event.getRightClicked() == null) if (event.getRightClicked() == null)
return; return;
if (!GetActive().containsKey(event.getPlayer())) SingleEntityMountData<Slime> data = GetActive().get(event.getPlayer());
return;
if (!GetActive().get(event.getPlayer()).equals(event.getRightClicked())) if(data == null) return;
{
UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!")); if(!data.ownsMount(event.getPlayer())) return;
return;
} if(!data.isPartOfMount(event.getRightClicked())) return;
event.getPlayer().leaveVehicle(); event.getPlayer().leaveVehicle();
event.getPlayer().eject(); event.getPlayer().eject();
@ -108,10 +109,15 @@ public class MountSlime extends Mount<Slime>
return; return;
//Bounce //Bounce
for (Slime slime : GetActive().values()) for (SingleEntityMountData<Slime> slimeData : GetActive().values())
{ {
Slime slime = slimeData.getEntity();
if (slime.getPassenger() == null) if (slime.getPassenger() == null)
{
UtilEnt.setFakeHead(slime, false);
continue; continue;
}
if (!UtilEnt.isGrounded(slime)) if (!UtilEnt.isGrounded(slime))
continue; continue;
@ -124,14 +130,19 @@ public class MountSlime extends Mount<Slime>
if (!Recharge.Instance.use(player, GetName(), 200, false, false)) if (!Recharge.Instance.use(player, GetName(), 200, false, false))
continue; 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); slime.getWorld().playSound(slime.getLocation(), Sound.SLIME_WALK, 1f, 0.75f);
} }
//Collide //Collide
for (Slime slime : GetActive().values()) for (SingleEntityMountData<Slime> slimeData : GetActive().values())
{ {
Slime slime = slimeData.getEntity();
if (slime.getPassenger() == null) if (slime.getPassenger() == null)
continue; continue;
@ -143,8 +154,10 @@ public class MountSlime extends Mount<Slime>
if (!Recharge.Instance.usable(player, GetName() + " Collide")) if (!Recharge.Instance.usable(player, GetName() + " Collide"))
continue; continue;
for (Slime other : GetActive().values()) for (SingleEntityMountData<Slime> otherSlime : GetActive().values())
{ {
Slime other = otherSlime.getEntity();
if (other.equals(slime)) if (other.equals(slime))
continue; continue;

View File

@ -4,21 +4,6 @@ import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map.Entry; 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.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -32,6 +17,22 @@ import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; 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 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()) + ".")); UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
//Store //Store
_active.put(player, horse); SingleEntityMountData<Horse> mount = new SingleEntityMountData<Horse>(player, horse);
_active.put(player, mount);
DisguiseSpider spider = new DisguiseSpider(horse); DisguiseSpider spider = new DisguiseSpider(horse);
spider.setName(player.getName() + "'s Spider Mount"); spider.setName(player.getName() + "'s Spider Mount");
@ -105,7 +107,7 @@ public class MountSpider extends HorseMount
ArrayList<Horse> used = new ArrayList<Horse>(); ArrayList<Horse> used = new ArrayList<Horse>();
for (Player player : GetActive().keySet()) for (Player player : GetActive().keySet())
{ {
Horse horse = GetActive().get(player); Horse horse = GetActive().get(player).getEntity();
used.add(horse); used.add(horse);
@ -126,21 +128,24 @@ public class MountSpider extends HorseMount
if (event.getType() != UpdateType.TICK) if (event.getType() != UpdateType.TICK)
return; 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; continue;
//If player is looking up //If player is looking up
if (horse.getKey().getEyeLocation().getPitch() > -45) if (player.getEyeLocation().getPitch() > -45)
continue; 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()) if (UtilBlock.airFoliage(block) || block.isLiquid())
continue; 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; continue;
} }
} }
@ -191,7 +196,7 @@ public class MountSpider extends HorseMount
for (Player player : GetActive().keySet()) for (Player player : GetActive().keySet())
{ {
final Horse horse = GetActive().get(player); final Horse horse = GetActive().get(player).getEntity();
if (horse.getPassenger() != player) if (horse.getPassenger() != player)
continue; continue;

View File

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

View File

@ -3,11 +3,7 @@
package mineplex.core.mount.types; package mineplex.core.mount.types;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
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 org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -20,9 +16,13 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector; 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; private Slime _head;
@ -30,7 +30,7 @@ public class MountTitanData
public MountTitanData(Player player, String name) public MountTitanData(Player player, String name)
{ {
_owner = player.getName(); super(player);
Location loc = player.getLocation(); Location loc = player.getLocation();
loc.setPitch(0); loc.setPitch(0);
@ -72,7 +72,11 @@ public class MountTitanData
{ {
//Head //Head
if (_head.getPassenger() != null) 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); Location infront = _head.getLocation().add(0, -1.5, 0);
@ -134,13 +138,12 @@ public class MountTitanData
stand.remove(); stand.remove();
} }
public boolean ownsMount(Player player) @Override
public List<Entity> getEntityParts()
{ {
return _owner.equals(player.getName()); List<Entity> entities = new ArrayList<Entity>();
} entities.addAll(_nodes);
entities.add(_head);
public boolean ownsEntity(Entity ent) return entities;
{
return (_head.equals(ent) || _nodes.contains(ent));
} }
} }

View File

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

View File

@ -0,0 +1,10 @@
package mineplex.core.noteblock;
import org.bukkit.entity.Player;
public interface INoteVerifier
{
public boolean shouldPlay(Player player);
}

View File

@ -0,0 +1,134 @@
package mineplex.core.noteblock;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
/**
* Information about the NBS Format was taken from
* http://www.stuffbydavid.com/mcnbs/format
*/
public class NBSReader
{
public static NoteSong loadSong(String fileName) throws FileNotFoundException
{
return loadSong(new DataInputStream(new FileInputStream(new File(fileName))), fileName);
}
public static NoteSong loadSong(DataInputStream stream, String defaultName)
{
try
{
// Header Information
short length = readShort(stream);
short height = readShort(stream);
String name = readString(stream);
String author = readString(stream);
String originalAuthor = readString(stream);
String description = readString(stream);
short tempo = readShort(stream); // Tempo multiplied by 1000
boolean autosave = stream.readBoolean();
byte autosaveDuration = stream.readByte();
byte timeSignature = stream.readByte();
int minutesSpent = readInt(stream);
int leftClicks = readInt(stream);
int rightClicks = readInt(stream);
int blocksAdded = readInt(stream);
int blocksRemoved = readInt(stream);
String midiFileName = readString(stream);
if ((name == null || name.length() == 0) && defaultName != null)
name = defaultName;
HashMap<Integer, NoteLayer> layerMap = new HashMap<Integer, NoteLayer>();
// Note Block Information
int tick = -1;
int jumps = 0;
while (true)
{
jumps = readShort(stream);
if (jumps == 0)
break;
tick += jumps;
int layer = -1;
while (true)
{
jumps = readShort(stream);
if (jumps == 0)
break;
layer += jumps;
byte instrument = stream.readByte();
byte key = stream.readByte();
Note note = new Note(instrument, key);
NoteLayer noteLayer = layerMap.get(layer);
if (noteLayer == null)
{
noteLayer = new NoteLayer();
layerMap.put(layer, noteLayer);
}
noteLayer.setNote(tick, note);
}
}
// Layer Information
for (int i = 0; i < height; i++)
{
NoteLayer layer = layerMap.get(i);
if (layer != null)
{
layer.setName(readString(stream));
layer.setVolume(stream.readByte());
}
}
System.out.println("[NBSReader] Successfully loaded song " + name + "");
System.out.println("Tempo: " + tempo);
return new NoteSong(length, height, name, tempo, timeSignature, layerMap);
}
catch (IOException e)
{
e.printStackTrace();
}
return null;
}
private static int readInt(DataInputStream stream) throws IOException
{
// For some reason the bytes are in reverse order from stream.readInt()
int ch1 = stream.read();
int ch2 = stream.read();
int ch3 = stream.read();
int ch4 = stream.read();
if ((ch1 | ch2 | ch3 | ch4) < 0)
throw new EOFException();
return ((ch4 << 24) + (ch3 << 16) + (ch2 << 8) + ch1);
}
private static short readShort(DataInputStream stream) throws IOException
{
// For some reason the bytes are in reverse order from stream.readShort()
int ch1 = stream.read();
int ch2 = stream.read();
if ((ch1 | ch2) < 0)
throw new EOFException();
return (short)((ch2 << 8) + ch1);
}
private static String readString(DataInputStream stream) throws IOException
{
int length = readInt(stream);
char[] string = new char[length];
for (int i = 0; i < length; i++)
{
string[i] = (char) stream.readByte();
}
return new String(string);
}
}

View File

@ -0,0 +1,26 @@
package mineplex.core.noteblock;
/**
* Represents a single note to be played
*/
public class Note
{
private byte _instrument;
private byte _note;
public Note(byte instrument, byte note)
{
_instrument = instrument;
_note = note;
}
public byte getInstrument()
{
return _instrument;
}
public byte getNote()
{
return _note;
}
}

View File

@ -0,0 +1,50 @@
package mineplex.core.noteblock;
import java.util.HashMap;
/**
* Represents a layer of notes in Note Block Studio
*/
public class NoteLayer
{
private HashMap<Integer, Note> _noteMap; // Notes indexed by ticks
private int _volume; // Volume as a percentage 1-100
private String _name;
public NoteLayer()
{
_noteMap = new HashMap<Integer, Note>();
_volume = 100;
_name = "";
}
public int getVolume()
{
return _volume;
}
public void setVolume(int volume)
{
_volume = volume;
}
public String getName()
{
return _name;
}
public void setName(String name)
{
_name = name;
}
public void setNote(int ticks, Note note)
{
_noteMap.put(ticks, note);
}
public Note getNote(int ticks)
{
return _noteMap.get(ticks);
}
}

View File

@ -0,0 +1,122 @@
package mineplex.core.noteblock;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.UtilServer;
import mineplex.core.noteblock.event.SongFinishEvent;
import mineplex.core.noteblock.event.SongStartEvent;
public class NotePlayer
{
private final JavaPlugin _plugin;
private final NoteSong _song;
private final INoteVerifier _verifier;
private final long _sleepMs;
private volatile float _volumeMult;
private volatile boolean _loop;
private volatile int _tick;
private volatile boolean _finished;
public NotePlayer(JavaPlugin plugin, NoteSong song, INoteVerifier verifier, float volumeMult, boolean loop)
{
_plugin = plugin;
_song = song;
_verifier = verifier;
_sleepMs = (long) (1000 / (song.getTempo() / 100D));
_loop = loop;
_tick = 0;
_volumeMult = volumeMult;
_finished = false;
startThread();
SongStartEvent event = new SongStartEvent(_song);
_plugin.getServer().getPluginManager().callEvent(event);
}
private void startThread()
{
Thread thread = new Thread(new Runnable()
{
@Override
public void run()
{
long startTime = System.currentTimeMillis();
while (!_finished)
{
_tick++;
if (_tick > _song.getLength())
{
if (_loop)
{
_tick = 1;
}
else
{
_finished = true;
_plugin.getServer().getScheduler().runTask(_plugin, new Runnable()
{
@Override
public void run()
{
SongFinishEvent event = new SongFinishEvent(_song);
_plugin.getServer().getPluginManager().callEvent(event);
}
});
return;
}
}
playTick(_tick);
try
{
Thread.sleep(_sleepMs);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
});
thread.start();
}
private void playTick(int tick)
{
Player[] playerArray = UtilServer.getPlayers();
List<Player> players = new ArrayList<>(playerArray.length);
for (Player player : playerArray)
{
if (_verifier.shouldPlay(player))
players.add(player);
}
for (NoteLayer layer : _song.getLayers())
{
Note note = layer.getNote(tick);
if (note != null)
{
float volume = _volumeMult * (layer.getVolume() / 100F);
for (Player player : players)
{
player.playSound(player.getEyeLocation(), UtilNote.getInstrumentSound(note.getInstrument()), volume, (float) UtilNote.getPitch(note.getNote() - 33));
}
}
}
}
public void cancel()
{
_finished = true;
}
}

View File

@ -0,0 +1,57 @@
package mineplex.core.noteblock;
import java.util.Collection;
import java.util.HashMap;
public class NoteSong
{
// Song Data
private short _length;
private short _height;
private String _name;
private short _tempo;
private byte _timeSignature;
// Layer Data
private HashMap<Integer, NoteLayer> _layerMap;
public NoteSong(short length, short height, String name, short tempo, byte timeSignature, HashMap<Integer, NoteLayer> layerMap)
{
_length = length;
_height = height;
_name = name;
_tempo = tempo;
_timeSignature = timeSignature;
_layerMap = layerMap;
}
public short getLength()
{
return _length;
}
public short getHeight()
{
return _height;
}
public String getName()
{
return _name;
}
public short getTempo()
{
return _tempo;
}
public byte getTimeSignature()
{
return _timeSignature;
}
public Collection<NoteLayer> getLayers()
{
return _layerMap.values();
}
}

View File

@ -0,0 +1,42 @@
package mineplex.core.noteblock;
import org.bukkit.Sound;
/**
* See http://minecraft.gamepedia.com/Note_Block for information about pitches
*/
public class UtilNote
{
private static final double[] PITCH = { 0.5, 0.53, 0.56, 0.6, 0.63, 0.67, 0.7, 0.76, 0.8, 0.84, 0.9, 0.94, 1.0,
1.06, 1.12, 1.18, 1.26, 1.34, 1.42, 1.5, 1.6, 1.68, 1.78, 1.88, 2.0 };
public static Sound getInstrumentSound(byte instrument)
{
switch (instrument)
{
case 0:
return Sound.NOTE_PIANO;
case 1:
return Sound.NOTE_BASS_GUITAR;
case 2:
return Sound.NOTE_BASS_DRUM;
case 3:
return Sound.NOTE_SNARE_DRUM;
case 4:
return Sound.NOTE_STICKS;
default:
return Sound.NOTE_PIANO;
}
}
public static double getPitch(int note)
{
if (note >= 0 && note < PITCH.length)
{
return PITCH[note];
}
return 0.0;
}
}

View File

@ -0,0 +1,25 @@
package mineplex.core.noteblock.event;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.core.noteblock.NoteSong;
public class SongFinishEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList() { return handlers; }
public HandlerList getHandlers() { return handlers; }
private NoteSong _song;
public SongFinishEvent(NoteSong song)
{
_song = song;
}
public NoteSong getSong()
{
return _song;
}
}

View File

@ -0,0 +1,25 @@
package mineplex.core.noteblock.event;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.core.noteblock.NoteSong;
public class SongStartEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList() { return handlers; }
public HandlerList getHandlers() { return handlers; }
private NoteSong _song;
public SongStartEvent(NoteSong song)
{
_song = song;
}
public NoteSong getSong()
{
return _song;
}
}

View File

@ -1,5 +1,6 @@
package mineplex.core.notifier; package mineplex.core.notifier;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -12,14 +13,16 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
public class NotificationManager extends MiniPlugin public class NotificationManager extends MiniPlugin
{ {
private boolean _enabled = false; private boolean _enabled = true;
private CoreClientManager _clientManager; private CoreClientManager _clientManager;
private PreferencesManager _preferencesManager;
private String _summerLine = private String _summerLine =
C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" +
@ -29,11 +32,12 @@ public class NotificationManager extends MiniPlugin
C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" +
C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + ""; C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "";
public NotificationManager(JavaPlugin plugin, CoreClientManager client) public NotificationManager(JavaPlugin plugin, CoreClientManager client, PreferencesManager preferencesManager)
{ {
super("Notification Manager", plugin); super("Notification Manager", plugin);
_clientManager = client; _clientManager = client;
_preferencesManager = preferencesManager;
} }
@EventHandler @EventHandler
@ -48,6 +52,23 @@ public class NotificationManager extends MiniPlugin
// if (event.getType() == UpdateType.MIN_16) // if (event.getType() == UpdateType.MIN_16)
// sale(); // sale();
if (event.getType() == UpdateType.MIN_08)
christmasSale();
}
private void christmasSale()
{
for (Player player : UtilServer.getPlayers())
{
if (!_preferencesManager.Get(player).DisableAds)
{
player.sendMessage(C.cWhite + " ");
player.sendMessage(C.cRedB + " MASSIVE WINTER SALE");
player.sendMessage(C.cWhiteB + " 50% OFF ALL RANKS");
player.sendMessage(" " + C.cGreen + C.Line + "www.mineplex.com/shop");
player.sendMessage(C.cWhite + " ");
}
}
} }
private void sale() private void sale()

View File

@ -0,0 +1,73 @@
package mineplex.core.playerCount;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.serverdata.Region;
import mineplex.serverdata.data.BungeeServer;
import mineplex.serverdata.data.DataRepository;
import mineplex.serverdata.redis.RedisDataRepository;
import mineplex.serverdata.servers.ConnectionData;
import mineplex.serverdata.servers.ServerManager;
public class PlayerCountManager extends MiniPlugin
{
private Region _region;
private DataRepository<BungeeServer> _repository;
private DataRepository<BungeeServer> _secondRepository;
private volatile int _playerCount;
public PlayerCountManager(JavaPlugin plugin)
{
super("PlayerCount", plugin);
_region = plugin.getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU;
_repository = new RedisDataRepository<BungeeServer>(ServerManager.getConnection(true, ServerManager.SERVER_STATUS_LABEL), ServerManager.getConnection(false, ServerManager.SERVER_STATUS_LABEL),
Region.ALL, BungeeServer.class, "bungeeServers");
if (_region == Region.US)
_secondRepository = new RedisDataRepository<BungeeServer>(new ConnectionData("10.81.1.156", 6379, ConnectionData.ConnectionType.MASTER, "ServerStatus"), new ConnectionData("10.81.1.156", 6377, ConnectionData.ConnectionType.SLAVE, "ServerStatus"),
Region.ALL, BungeeServer.class, "bungeeServers");
else
_secondRepository = new RedisDataRepository<BungeeServer>(new ConnectionData("10.33.53.16", 6379, ConnectionData.ConnectionType.MASTER, "ServerStatus"), new ConnectionData("10.33.53.16", 6377, ConnectionData.ConnectionType.SLAVE, "ServerStatus"),
Region.ALL, BungeeServer.class, "bungeeServers");
updatePlayerCount();
}
private void updatePlayerCount()
{
int totalPlayers = 0;
for (BungeeServer server : _repository.getElements())
{
totalPlayers += server.getPlayerCount();
}
for (BungeeServer server : _secondRepository.getElements())
{
totalPlayers += server.getPlayerCount();
}
_playerCount = totalPlayers;
}
public int getPlayerCount()
{
return _playerCount;
}
@EventHandler
public void refresh(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
runAsync(this::updatePlayerCount);
}
}

View File

@ -84,19 +84,6 @@ public class ServerCommand extends CommandBase<Portal>
else else
deniedAccess = true; deniedAccess = true;
} }
else if (servUp.contains("CLANS-"))
{
if (playerRank.has(Rank.MODERATOR))
{
Plugin.sendPlayerToServer(player, args[0]);
}
else
{
UtilPlayer.message(player,
F.main(Plugin.getName(), C.cRed + "You must join clans through the hub! Join " + C.cGold + "ClansHub-1"
+ C.cRed + "!"));
}
}
else else
{ {
Plugin.sendPlayerToServer(player, args[0]); Plugin.sendPlayerToServer(player, args[0]);

View File

@ -136,6 +136,6 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
@Override @Override
public String getQuery(int accountId, String uuid, String name) public String getQuery(int accountId, String uuid, String name)
{ {
return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;"; return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips, hubMusic, disableAds FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;";
} }
} }

View File

@ -24,7 +24,7 @@ public class PreferencesRepository extends RepositoryBase
// DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL // DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL
// NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));"; // NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;"; private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;";
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ?, clanTips = ? WHERE uuid=?;"; private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ?, clanTips = ?, hubMusic = ?, disableAds = ? WHERE uuid=?;";
public PreferencesRepository(JavaPlugin plugin) public PreferencesRepository(JavaPlugin plugin)
{ {
@ -61,8 +61,10 @@ public class PreferencesRepository extends RepositoryBase
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests); preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI); preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI);
preparedStatement.setBoolean(13, entry.getValue().ClanTips); preparedStatement.setBoolean(13, entry.getValue().ClanTips);
preparedStatement.setBoolean(14, entry.getValue().HubMusic);
preparedStatement.setBoolean(15, entry.getValue().DisableAds);
System.out.println(">> " + entry.getValue().ClanTips); System.out.println(">> " + entry.getValue().ClanTips);
preparedStatement.setString(14, entry.getKey()); preparedStatement.setString(16, entry.getKey());
preparedStatement.addBatch(); preparedStatement.addBatch();
} }
@ -89,8 +91,10 @@ public class PreferencesRepository extends RepositoryBase
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests); preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI); preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI);
preparedStatement.setBoolean(13, entry.getValue().ClanTips); preparedStatement.setBoolean(13, entry.getValue().ClanTips);
preparedStatement.setBoolean(14, entry.getValue().HubMusic);
preparedStatement.setBoolean(15, entry.getValue().DisableAds);
System.out.println(">> " + entry.getValue().ClanTips); System.out.println(">> " + entry.getValue().ClanTips);
preparedStatement.setString(14, entry.getKey()); preparedStatement.setString(16, entry.getKey());
preparedStatement.execute(); preparedStatement.execute();
} }
@ -122,6 +126,8 @@ public class PreferencesRepository extends RepositoryBase
preferences.PendingFriendRequests = resultSet.getBoolean(11); preferences.PendingFriendRequests = resultSet.getBoolean(11);
preferences.friendDisplayInventoryUI = resultSet.getBoolean(12); preferences.friendDisplayInventoryUI = resultSet.getBoolean(12);
preferences.ClanTips = resultSet.getBoolean(13); preferences.ClanTips = resultSet.getBoolean(13);
preferences.HubMusic = resultSet.getBoolean(14);
preferences.DisableAds = resultSet.getBoolean(15);
} }
return preferences; return preferences;

View File

@ -16,4 +16,6 @@ public class UserPreferences
public boolean PendingFriendRequests = true; public boolean PendingFriendRequests = true;
public boolean friendDisplayInventoryUI = true; public boolean friendDisplayInventoryUI = true;
public boolean ClanTips = true; public boolean ClanTips = true;
public volatile boolean HubMusic = true;
public boolean DisableAds = false;
} }

View File

@ -189,6 +189,6 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
public boolean preferencesChanged() public boolean preferencesChanged()
{ {
return _hubInvisibilityToggled || _macReportsToggled || _hubInvisibilityToggled || _hubForcefieldToggled; return _hubInvisibilityToggled || _macReportsToggled || _hubIgnoreVelocityToggled || _hubForcefieldToggled;
} }
} }

View File

@ -25,6 +25,8 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
private IButton _toggleHubPartyRequests; private IButton _toggleHubPartyRequests;
private IButton _togglePendingFriendRequests; private IButton _togglePendingFriendRequests;
private IButton _toggleClanTips; private IButton _toggleClanTips;
private IButton _toggleHubMusic;
private IButton _toggleDisableAds;
private boolean _hubGamesToggled; private boolean _hubGamesToggled;
private boolean _hubPlayersToggled; private boolean _hubPlayersToggled;
@ -33,6 +35,8 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
private boolean _hubPartyRequestsToggled; private boolean _hubPartyRequestsToggled;
private boolean _pendingFriendRequestsToggled; private boolean _pendingFriendRequestsToggled;
private boolean _clanTipsToggled; private boolean _clanTipsToggled;
private boolean _hubMusicToggled;
private boolean _disableAdsToggled;
private ExclusivePreferencesShop _exclusiveShop; private ExclusivePreferencesShop _exclusiveShop;
@ -109,8 +113,41 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
togglePendingFriendRequests(player); togglePendingFriendRequests(player);
} }
}; };
_toggleHubMusic = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
toggleHubMusic(player);
}
};
_toggleDisableAds = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
toggleDisableAds(player);
}
};
} }
private void toggleHubMusic(Player player)
{
getPlugin().Get(player).HubMusic = !getPlugin().Get(player).HubMusic;
_hubMusicToggled = !_hubMusicToggled;
buildPage();
}
private void toggleDisableAds(Player player)
{
getPlugin().Get(player).DisableAds = !getPlugin().Get(player).DisableAds;
_disableAdsToggled = !_disableAdsToggled;
buildPage();
}
private void toggleHubPartyRequests(Player player) private void toggleHubPartyRequests(Player player)
{ {
getPlugin().Get(player).PartyRequests = !getPlugin().Get(player).PartyRequests; getPlugin().Get(player).PartyRequests = !getPlugin().Get(player).PartyRequests;
@ -180,7 +217,8 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
UserPreferences userPreferences = getPlugin().Get(getPlayer()); UserPreferences userPreferences = getPlugin().Get(getPlayer());
Rank rank = getClientManager().Get(getPlayer()).GetRank(); Rank rank = getClientManager().Get(getPlayer()).GetRank();
int[] indices = UtilUI.getIndicesFor(7, 0, 2); int amount = rank.has(Rank.ULTRA) ? 9 : 8;
int[] indices = UtilUI.getIndicesFor(amount, 0, 2);
buildPreference(indices[0], Material.FIREBALL, "Hub Player Stacker", userPreferences.HubGames, _toggleHubGames); buildPreference(indices[0], Material.FIREBALL, "Hub Player Stacker", userPreferences.HubGames, _toggleHubGames);
buildPreference(indices[1], Material.EYE_OF_ENDER, "Hub Player Visibility", userPreferences.ShowPlayers, _toggleHubPlayers); buildPreference(indices[1], Material.EYE_OF_ENDER, "Hub Player Visibility", userPreferences.ShowPlayers, _toggleHubPlayers);
@ -189,6 +227,9 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
buildPreference(indices[4], Material.SKULL_ITEM, (byte) 3, "Hub Party Requests", userPreferences.PartyRequests, _toggleHubPartyRequests); buildPreference(indices[4], Material.SKULL_ITEM, (byte) 3, "Hub Party Requests", userPreferences.PartyRequests, _toggleHubPartyRequests);
buildPreference(indices[5], Material.RED_ROSE, "Show Pending Friend Requests", userPreferences.PendingFriendRequests, _togglePendingFriendRequests); buildPreference(indices[5], Material.RED_ROSE, "Show Pending Friend Requests", userPreferences.PendingFriendRequests, _togglePendingFriendRequests);
buildPreference(indices[6], Material.IRON_SWORD, "Show Clan Tips", userPreferences.ClanTips, _toggleClanTips); buildPreference(indices[6], Material.IRON_SWORD, "Show Clan Tips", userPreferences.ClanTips, _toggleClanTips);
buildPreference(indices[7], Material.NOTE_BLOCK, "Hub Music", userPreferences.HubMusic, _toggleHubMusic);
if (rank.has(Rank.ULTRA))
buildPreference(indices[8], Material.BARRIER, "Disable Ads", userPreferences.DisableAds, _toggleDisableAds);
if (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH) if (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)
{ {
@ -219,6 +260,6 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
public boolean preferencesChanged() public boolean preferencesChanged()
{ {
return _hubGamesToggled || _hubPlayersToggled || _hubChatToggled || _hubPrivateChatToggled || _hubPartyRequestsToggled || _pendingFriendRequestsToggled || _clanTipsToggled; return _hubGamesToggled || _hubPlayersToggled || _hubChatToggled || _hubPrivateChatToggled || _hubPartyRequestsToggled || _pendingFriendRequestsToggled || _clanTipsToggled || _hubMusicToggled || _disableAdsToggled;
} }
} }

View File

@ -106,6 +106,10 @@ public class PlayerScoreboard
continue; continue;
} }
// Ignore extra lines
if (i >= _teamNames.length)
continue;
//Update //Update
Team team = _scoreboard.getTeam(_teamNames[i]); Team team = _scoreboard.getTeam(_teamNames[i]);
if (team == null) if (team == null)

View File

@ -91,41 +91,14 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
UtilServer.getServer().getPluginManager().callEvent(new StatChangeEvent(player.getName(), statName, newValue - value, newValue)); UtilServer.getServer().getPluginManager().callEvent(new StatChangeEvent(player.getName(), statName, newValue - value, newValue));
// Verify stat is in our local cache, if not add it remotely. // Verify stat is in our local cache, if not add it remotely.
if (!_stats.containsKey(statName)) registerNewStat(statName, new Runnable()
{ {
runAsync(new Runnable() @Override
public void run()
{ {
public void run() addToQueue(statName, player, value);
{ }
synchronized (_statSync) });
{
// If many players come in for a new stat, when the first add finishes the others are queued to add again
// This makes a second check for the stat name (already added before lock was released)
// Then it pops into queue and forgets adding the new stat to db.
if (_stats.containsKey(statName))
{
addToQueue(statName, player, value);
return;
}
_repository.addStat(statName);
_stats.clear();
for (Stat stat : _repository.retrieveStats())
{
_stats.put(stat.Name, stat.Id);
}
addToQueue(statName, player, value);
}
}
});
}
else
{
addToQueue(statName, player, value);
}
} }
private void addToQueue(String statName, Player player, long value) private void addToQueue(String statName, Player player, long value)
@ -192,17 +165,16 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
public boolean incrementStat(final int accountId, final String statName, final long value) public boolean incrementStat(final int accountId, final String statName, final long value)
{ {
if (_stats.containsKey(statName)) // This will register a new stat if we don't have one, otherwise it will just run the callback
return false; registerNewStat(statName, new Runnable()
final NautHashMap<Integer, NautHashMap<Integer, Long>> uploadQueue = new NautHashMap<Integer, NautHashMap<Integer, Long>>();
uploadQueue.put(accountId, new NautHashMap<Integer, Long>());
uploadQueue.get(accountId).put(_stats.get(statName), value);
runAsync(new Runnable()
{ {
@Override
public void run() public void run()
{ {
final NautHashMap<Integer, NautHashMap<Integer, Long>> uploadQueue = new NautHashMap<Integer, NautHashMap<Integer, Long>>();
uploadQueue.put(accountId, new NautHashMap<Integer, Long>());
uploadQueue.get(accountId).put(_stats.get(statName), value);
_repository.saveStats(uploadQueue); _repository.saveStats(uploadQueue);
} }
}); });
@ -210,6 +182,35 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
return true; return true;
} }
private void registerNewStat(final String statName, final Runnable callback)
{
runAsync(new Runnable()
{
public void run()
{
synchronized (_statSync)
{
if (_stats.containsKey(statName))
{
if (callback != null) callback.run();
return;
}
_repository.addStat(statName);
_stats.clear();
for (Stat stat : _repository.retrieveStats())
{
_stats.put(stat.Name, stat.Id);
}
if (callback != null) callback.run();
}
}
});
}
public int getStatId(String statName) public int getStatId(String statName)
{ {
return _stats.get(statName); return _stats.get(statName);

View File

@ -32,7 +32,7 @@ public class GiveawayMessageHandler implements CommandCallback
String playerName = message.getPlayerName(); String playerName = message.getPlayerName();
int count = message.getTitanCount(); int count = message.getTitanCount();
String countString = count + UtilTime.getDayOfMonthSuffix(count); String countString = count + UtilTime.getDayOfMonthSuffix(count);
String chatMessage = C.cRed + playerName + C.cWhite + " found Titan in a " + C.cRed + "Flaming Pumpkin"; String chatMessage = C.cRed + playerName + C.cWhite + " found Titan in a " + C.cRed + "Christmas Present";
UtilTextMiddle.display(C.cDRed + C.Bold + "TITAN", chatMessage, 20, 80, 20, UtilServer.getPlayers()); UtilTextMiddle.display(C.cDRed + C.Bold + "TITAN", chatMessage, 20, 80, 20, UtilServer.getPlayers());
World world = UtilServer.getPlayers().length > 0 ? UtilServer.getPlayers()[0].getWorld() : Bukkit.getWorlds().get(0); World world = UtilServer.getPlayers().length > 0 ? UtilServer.getPlayers()[0].getWorld() : Bukkit.getWorlds().get(0);
LightFlicker lightFlicker = new LightFlicker(world); LightFlicker lightFlicker = new LightFlicker(world);

View File

@ -16,18 +16,20 @@ public class TitanChestGiveawayHandler implements CommandCallback
private ServerStatusManager _statusManager; private ServerStatusManager _statusManager;
private long _lastTimer; private long _lastTimer;
private boolean _enabled;
public TitanChestGiveawayHandler(ServerStatusManager statusManager) public TitanChestGiveawayHandler(ServerStatusManager statusManager)
{ {
_statusManager = statusManager; _statusManager = statusManager;
_lastTimer = 0; _lastTimer = 0;
_enabled = false;
} }
@Override @Override
public void run(ServerCommand command) public void run(ServerCommand command)
{ {
if (command instanceof TitanChestGiveawayMessage) if (command instanceof TitanChestGiveawayMessage && _enabled)
{ {
TitanChestGiveawayMessage chestCommand = ((TitanChestGiveawayMessage) command); TitanChestGiveawayMessage chestCommand = ((TitanChestGiveawayMessage) command);
if (chestCommand.getServer().equals(_statusManager.getCurrentServerName()) || System.currentTimeMillis() >= _lastTimer + COOLDOWN) if (chestCommand.getServer().equals(_statusManager.getCurrentServerName()) || System.currentTimeMillis() >= _lastTimer + COOLDOWN)

View File

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

View File

@ -462,7 +462,7 @@ public class ClanInfo
public boolean isOnline() public boolean isOnline()
{ {
return isOnlineNow() || System.currentTimeMillis() - _lastOnline.getTime() < Clans.getOnlineTime(); return isOnlineNow();// || System.currentTimeMillis() - _lastOnline.getTime() < Clans.getOnlineTime();
} }
public String getProtected() public String getProtected()

View File

@ -17,13 +17,15 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.event.ClanCreatedEvent; import mineplex.game.clans.clans.event.ClanCreatedEvent;
import mineplex.game.clans.clans.event.ClanDeleteEvent; import mineplex.game.clans.clans.event.ClanDeleteEvent;
import mineplex.game.clans.clans.event.ClanJoinEvent;
import mineplex.game.clans.clans.event.ClanLeaveEvent;
import mineplex.game.clans.clans.event.ClanSetHomeEvent; import mineplex.game.clans.clans.event.ClanSetHomeEvent;
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
import mineplex.game.clans.clans.tntGenerator.TntGenerator; import mineplex.game.clans.clans.tntGenerator.TntGenerator;
import mineplex.game.clans.core.war.ClanWarData;
import mineplex.game.clans.core.repository.ClanRepository; import mineplex.game.clans.core.repository.ClanRepository;
import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.game.clans.core.repository.tokens.ClanToken; import mineplex.game.clans.core.repository.tokens.ClanToken;
import mineplex.game.clans.core.war.ClanWarData;
public class ClansDataAccessLayer public class ClansDataAccessLayer
{ {
@ -201,6 +203,15 @@ public class ClansDataAccessLayer
public void join(final ClanInfo clan, final Player player, final ClanRole role, final Callback<Boolean> callback) public void join(final ClanInfo clan, final Player player, final ClanRole role, final Callback<Boolean> callback)
{ {
ClanJoinEvent event = new ClanJoinEvent(clan, player);
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
runAsync(new Runnable() runAsync(new Runnable()
{ {
@Override @Override
@ -259,6 +270,15 @@ public class ClansDataAccessLayer
{ {
if (clan == null) return; if (clan == null) return;
ClanLeaveEvent event = new ClanLeaveEvent(clan, clansPlayer);
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
runAsync(new Runnable() runAsync(new Runnable()
{ {
@Override @Override
@ -637,6 +657,10 @@ public class ClansDataAccessLayer
final Timestamp currentTime = new Timestamp(System.currentTimeMillis()); final Timestamp currentTime = new Timestamp(System.currentTimeMillis());
final ClanWarData war = new ClanWarData(clanA.getName(), clanB.getName(), score, currentTime, currentTime, 0); final ClanWarData war = new ClanWarData(clanA.getName(), clanB.getName(), score, currentTime, currentTime, 0);
// Memory
clanA.addWar(war);
clanB.addWar(war);
runAsync(new Runnable() runAsync(new Runnable()
{ {
@Override @Override
@ -649,10 +673,6 @@ public class ClansDataAccessLayer
@Override @Override
public void run() public void run()
{ {
// Memory
clanA.addWar(war);
clanB.addWar(war);
_manager.log("Initiator war for [" + clanA.getName() + "] against [" + clanB.getName() + "]."); _manager.log("Initiator war for [" + clanA.getName() + "] against [" + clanB.getName() + "].");
if (warCallback != null) warCallback.run(war); if (warCallback != null) warCallback.run(war);

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) @EventHandler(priority = EventPriority.LOWEST)
public void Piston(BlockPistonExtendEvent event) 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 @EventHandler
public void Quit(PlayerQuitEvent event) public void Quit(PlayerQuitEvent event)
{ {

View File

@ -66,6 +66,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.claimview.ClaimVisualizer;
import mineplex.game.clans.clans.commands.ClanManagementCommand; import mineplex.game.clans.clans.commands.ClanManagementCommand;
import mineplex.game.clans.clans.commands.ClansAllyChatCommand; import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
import mineplex.game.clans.clans.commands.ClansChatCommand; import mineplex.game.clans.clans.commands.ClansChatCommand;
@ -227,7 +228,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
TaskManager taskManager = new TaskManager(plugin, _clientManager, webServerAddress); 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); ClanTips = new ClanTips(plugin, this, preferencesManager);
@ -304,6 +305,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
loadClan(token); loadClan(token);
} }
// new ClaimVisualizer(plugin, this);
// RedisDataRepository(ConnectionData writeConn, ConnectionData // RedisDataRepository(ConnectionData writeConn, ConnectionData
// readConn, Region region, Class<T> elementType, String elementLabel) // readConn, Region region, Class<T> elementType, String elementLabel)
// Initialize default region factions and territory // Initialize default region factions and territory
@ -402,6 +405,11 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
return _disguiseManager; return _disguiseManager;
} }
public TutorialManager getTutorials()
{
return _tutorialManager;
}
public NpcManager getNPCManager() public NpcManager getNPCManager()
{ {
return _npcManager; return _npcManager;
@ -667,7 +675,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
if (clan == null) if (clan == null)
{ {
event.setFormat(rank + C.cYellow + "%1$s " + C.cWhite + "%2$s"); event.setFormat(rank + C.cYellow + "%1$s " + C.cWhite + "%2$s");
System.out.println(_clientManager.Get(event.getPlayer()).GetRank().name() + " " + event.getPlayer().getName() + " " + (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) ? C.cRed + "Creative " : " ") + event.getMessage()); System.out.println(_clientManager.Get(event.getPlayer()).GetRank().name() + " " + event.getPlayer().getName() + " " + event.getMessage());
return; return;
} }
@ -687,7 +695,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
String message = event.getMessage(); String message = event.getMessage();
message = _chat.getFilteredMessage(event.getPlayer(), message); message = _chat.getFilteredMessage(event.getPlayer(), message);
ClanRelation rel = _clanUtility.rel(clan, otherClan); ClanRelation rel = _clanUtility.rel(clan, otherClan);
String formatted = rank + rel.getColor(true) + clan.getName() + " " + rel.getColor(false) + event.getPlayer().getName() + " " + (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) ? C.cRed + "Creative " : " ") + C.cWhite + message; String formatted = rank + rel.getColor(true) + clan.getName() + " " + rel.getColor(false) + event.getPlayer().getName() + " " + C.cWhite + message;
other.sendMessage(formatted); other.sendMessage(formatted);
} }
} }

View File

@ -19,9 +19,9 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilWorld;
import mineplex.core.recharge.Recharge;
import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.ClanDisbandedEvent;
import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; 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.clans.event.PlayerUnClaimTerritoryEvent;
import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.ClanTerritory;
@ -157,10 +157,10 @@ public class ClansUtility
if (inform) 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); Clans.getTutorials().sendTutorialMsg(caller, F.desc("Matches via Clan", clanMatchString));
UtilPlayer.message(caller, F.desc("Matches via Player", playerMatchString), false);; Clans.getTutorials().sendTutorialMsg(caller, F.desc("Matches via Player", playerMatchString));
} }
return null; return null;
@ -183,7 +183,7 @@ public class ClansUtility
if (!inform) return null; if (!inform) return null;
// Inform // 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) if (matchList.size() > 0)
{ {
@ -191,7 +191,7 @@ public class ClansUtility
for (ClanInfo cur : matchList) for (ClanInfo cur : matchList)
matchString += cur.getName() + " "; 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; return null;
@ -554,31 +554,31 @@ public class ClansUtility
{ {
if (Clans.getClanMemberUuidMap().containsKey(caller.getUniqueId())) 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; return;
} }
if (!Clans.Get(caller).canJoin()) 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; return;
} }
if (clanInfo == null) 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; return;
} }
if (!clanInfo.isInvited(caller.getName())) 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; return;
} }
if (clanInfo.getSize() >= clanInfo.getMaxSize()) 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; return;
} }
@ -591,12 +591,12 @@ public class ClansUtility
if (data) if (data)
{ {
// Inform // 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()); clanInfo.inform(F.name(caller.getName()) + " has joined your Clan.", caller.getName());
} }
else 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) 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; return;
} }
if (clan.getMembers().get(caller.getUniqueId()).getRole() == ClanRole.LEADER && clan.getMembers().size() > 1) 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; return;
} }
@ -629,7 +629,7 @@ public class ClansUtility
public void run(Boolean data) public void run(Boolean data)
{ {
// Inform // 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); clan.inform(F.name(caller.getName()) + " has left your Clan.", null);
} }
}); });
@ -646,13 +646,13 @@ public class ClansUtility
if (clan == null) 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; return;
} }
if (getRole(caller) != ClanRole.LEADER) 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; return;
} }
@ -665,6 +665,8 @@ public class ClansUtility
return; return;
} }
Clans.messageClan(clan, C.cYellow + caller.getName() + C.cGray + " has disbanded the Clan.");
// Task // Task
Clans.getClanDataAccess().delete(clan, new Callback<Boolean>() Clans.getClanDataAccess().delete(clan, new Callback<Boolean>()
{ {
@ -673,10 +675,11 @@ public class ClansUtility
{ {
if (!data) 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 }else
{ {
UtilPlayer.message(caller, F.main("Clans", "You disbanded your Clan.")); Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You disbanded your Clan."));
} }
} }
}); });
@ -686,29 +689,39 @@ public class ClansUtility
{ {
ClanInfo clan = getClanByPlayer(caller); 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) 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; return false;
} }
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) 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; return false;
} }
if (!ClansManager.isClaimable(caller.getLocation())) 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; return false;
} }
// if (clan.getEnergy() == 0) 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; return false;
// } }
String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk()); String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk());
ClanInfo ownerClan = getOwner(caller.getLocation()); ClanInfo ownerClan = getOwner(caller.getLocation());
@ -722,16 +735,16 @@ public class ClansUtility
} }
else 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; return false;
} }
} }
// if (clan.getClaims() >= clan.getClaimsMax()) 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; return false;
// } }
// Adjacent // Adjacent
boolean selfAdj = false; boolean selfAdj = false;
@ -755,8 +768,8 @@ public class ClansUtility
if (checkBox(caller.getWorld().getChunkAt(caller.getLocation().getChunk().getX() + x, caller.getLocation().getChunk().getZ() + z), 3)) 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.")); Clans.getTutorials().sendTutorialMsg(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", "This means a Territory has all sides claimed."));
return false; return false;
} }
@ -766,7 +779,7 @@ public class ClansUtility
} }
else if (rel(clan, adjClan) != ClanRelation.SELF) 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; return false;
} }
} }
@ -775,21 +788,21 @@ public class ClansUtility
// Boxed // Boxed
if (checkBox(caller.getLocation().getChunk(), 4)) if (checkBox(caller.getLocation().getChunk(), 4))
{ {
UtilPlayer.message(caller, F.main("Clans", "You cannot claim this Territory, it causes a box.")); Clans.getTutorials().sendTutorialMsg(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", "This means a Territory has all sides claimed."));
return false; return false;
} }
if (isNearAdminClaim(caller.getLocation())) 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; return false;
} }
// Not Next to Self // Not Next to Self
if (!selfAdj && !clan.getClaimSet().isEmpty()) 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; return false;
} }
@ -798,7 +811,7 @@ public class ClansUtility
{ {
if (!UtilTime.elapsed(Clans.getUnclaimMap().get(chunk), Clans.getReclaimTime())) 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; return false;
} }
@ -813,7 +826,7 @@ public class ClansUtility
{ {
if (UtilMath.offset(cur, caller) < 16) if (playerEnemy(caller, cur)) 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; return false;
} }
} }
@ -835,7 +848,7 @@ public class ClansUtility
Clans.getClanDataAccess().claim(clan.getName(), chunk, caller.getName(), false); Clans.getClanDataAccess().claim(clan.getName(), chunk, caller.getName(), false);
// Inform // 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()); clan.inform(F.name(caller.getName()) + " claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".", caller.getName());
return true; return true;
@ -872,7 +885,7 @@ public class ClansUtility
} }
// Change Inform // 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 // Inform
UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".")); 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) 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; return;
} }
@ -900,13 +913,13 @@ public class ClansUtility
if (target.equals(caller.getName())) 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; return;
} }
if (self.getRole().ordinal() <= target.getRole().ordinal()) 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; return;
} }
@ -941,7 +954,7 @@ public class ClansUtility
if (clan == null) 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; return;
} }
@ -952,19 +965,19 @@ public class ClansUtility
if (target.equals(caller.getName())) 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; return;
} }
if (self.getRole().ordinal() <= target.getRole().ordinal()) 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; return;
} }
if (target.getRole() == ClanRole.RECRUIT) 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; return;
} }
@ -991,7 +1004,7 @@ public class ClansUtility
if (clan == null) 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; return;
} }
@ -1002,20 +1015,20 @@ public class ClansUtility
if (self.getRole() != ClanRole.LEADER && self.getRole() != ClanRole.ADMIN) 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; return;
} }
if (clansPlayer.getRole() == ClanRole.LEADER) if (clansPlayer.getRole() == ClanRole.LEADER)
{ {
UtilPlayer.message(caller, F.main("Clans", "Clan leaders cannot be kicked.")); Clans.getTutorials().sendTutorialMsg(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", "To disband a clan, use /c disband"));
return; return;
} }
if ((clansPlayer.getRole() == ClanRole.LEADER && self.getRole() == ClanRole.ADMIN) || (clansPlayer.getRole() == ClanRole.ADMIN && self.getRole() == ClanRole.ADMIN)) 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; return;
} }
@ -1027,8 +1040,8 @@ public class ClansUtility
public void run(Boolean data) public void run(Boolean data)
{ {
// Inform // Inform
if (player != null) UtilPlayer.message(player, F.main("Clans", F.name(caller.getName()) + " kicked you from " + F.elem("Clan " + clan.getName()) + ".")); if (player != null) Clans.getTutorials().sendTutorialMsg(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.")); 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()); 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) 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; return false;
} }
@ -1059,19 +1072,19 @@ public class ClansUtility
// Role // Role
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) 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; return false;
} }
// Not Claimed // Not Claimed
if (ownerClan == null || !ownerClan.equals(clan)) 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; return false;
} }
// Event // Event
PlayerUnClaimTerritoryEvent event = new PlayerUnClaimTerritoryEvent(caller, caller.getLocation().getChunk()); PlayerUnClaimTerritoryEvent event = new PlayerUnClaimTerritoryEvent(caller, caller.getLocation().getChunk(), ownerClan);
UtilServer.getServer().getPluginManager().callEvent(event); UtilServer.getServer().getPluginManager().callEvent(event);
@ -1084,7 +1097,7 @@ public class ClansUtility
Clans.getClanDataAccess().unclaim(chunk, caller.getName(), true); Clans.getClanDataAccess().unclaim(chunk, caller.getName(), true);
// Inform // 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()); clan.inform(F.name(caller.getName()) + " unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".", caller.getName());
return true; return true;
@ -1096,13 +1109,13 @@ public class ClansUtility
if (clan == null) 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; return false;
} }
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER) 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; return false;
} }
@ -1120,7 +1133,7 @@ public class ClansUtility
} }
// Inform // 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()); clan.inform(F.name(caller.getName()) + " unclaimed all your Clans Territory.", caller.getName());
return true; 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) 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; return;
} }
if (target.getName().equals(caller.getName())) 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; return;
} }
// Inform // Inform
clan.inform(F.name(caller.getName()) + " invited " + F.name(target.getName()) + " to join your Clan.", caller.getName()); 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.")); Clans.getTutorials().sendTutorialMsg(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()) + ".")); Clans.getTutorials().sendTutorialMsg(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(target, F.main("Clans", "Type " + F.elem("/c join " + clan.getName()) + " to accept!"));
// Task // Task
Clans.getClanDataAccess().invite(clan, target.getName(), caller.getName()); Clans.getClanDataAccess().invite(clan, target.getName(), caller.getName());

View File

@ -0,0 +1,351 @@
package mineplex.game.clans.clans.claimview;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
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.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.claimview.commands.ClaimVisualizeCommand;
import mineplex.game.clans.clans.event.ClanDisbandedEvent;
import mineplex.game.clans.clans.event.ClanLeaveEvent;
import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent;
import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent;
import net.minecraft.server.v1_8_R3.EnumDirection;
public class ClaimVisualizer extends MiniPlugin
{
private ClansManager _clansManager;
private List<String> _visualizing;
private NautHashMap<ClanInfo, NautHashMap<String, VisualizedChunkData>> _calculated;
public ClaimVisualizer(JavaPlugin plugin, ClansManager clansManager)
{
super("Claim Visualizer", plugin);
_clansManager = clansManager;
_visualizing = new ArrayList<>();
_calculated = new NautHashMap<>();
for (ClanInfo clan : _clansManager.getClanMap().values())
{
_calculated.put(clan, new NautHashMap<String, VisualizedChunkData>());
}
}
@Override
public void addCommands()
{
addCommand(new ClaimVisualizeCommand(this));
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOWER)
{
return;
}
_calculated.clear();
for (ClanInfo clan : _clansManager.getClanMap().values())
{
_calculated.put(clan, new NautHashMap<String, VisualizedChunkData>());
for (String serialized : clan.getClaimSet())
{
calculate(clan, serialized);
}
}
}
@EventHandler
public void runVisualization(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
for (String name : _visualizing)
{
Player player = Bukkit.getPlayer(name);
if (player != null && _clansManager.isInClan(player))
{
visualize(player);
}
}
}
private void visualize(Player player)
{
for (String serialized : _clansManager.getClan(player).getClaimSet())
{
if (!_calculated.get(_clansManager.getClan(player)).containsKey(serialized))
{
calculate(_clansManager.getClan(player), serialized);
}
}
draw(player, _calculated.get(_clansManager.getClan(player)).values());
}
private void draw(Player player, Collection<VisualizedChunkData> chunks)
{
for (VisualizedChunkData chunk : chunks)
{
if (!chunk.getChunk().getWorld().equals(player.getWorld()))
{
// return not break because a clan can't have claims in different worlds.
return;
}
if (UtilMath.offset2d(chunk.getChunk().getBlock(0, 0, 0).getLocation(), player.getLocation()) > 36)
{
break;
}
for (int x = 0; x < 16; x++)
{
for (int z = 0; z < 16; z++)
{
if (chunk.shouldDisplayEdge(x, z) && (z == 0 || z == 15 || x == 0 || x == 15))
{
Block block = chunk.getChunk().getBlock(x, 0, z);
UtilParticle.PlayParticle(ParticleType.RED_DUST,
new Location(
chunk.getChunk().getWorld(),
block.getX() + .5,
UtilBlock.getHighest(player.getWorld(), block.getX(), block.getZ()).getY() + .5,
block.getZ() + .5),
new Vector(0f, 0f, 0f), 0f, 1, ViewDist.NORMAL, player);
}
}
}
}
}
private void calculate(ClanInfo clan, String serialized)
{
Chunk chunk = UtilWorld.strToChunk(serialized);
List<EnumDirection> dirs = new ArrayList<>();
if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() - 1))))
{
dirs.add(EnumDirection.NORTH);
}
if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() + 1, chunk.getZ()))))
{
dirs.add(EnumDirection.EAST);
}
if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() + 1))))
{
dirs.add(EnumDirection.SOUTH);
}
if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() - 1, chunk.getZ()))))
{
dirs.add(EnumDirection.WEST);
}
VisualizedChunkData cached = new VisualizedChunkData(chunk, dirs);
_calculated.get(clan).put(serialized, cached);
}
@EventHandler
public void onQuit(PlayerQuitEvent event)
{
if (isVisualizing(event.getPlayer()))
{
disableVisualizer(event.getPlayer());
}
}
@EventHandler
public void onKick(PlayerKickEvent event)
{
if (isVisualizing(event.getPlayer()))
{
disableVisualizer(event.getPlayer());
}
}
@EventHandler
public void onLeave(ClanLeaveEvent event)
{
if (isVisualizing(event.getPlayer().getPlayerName()))
{
disableVisualizer(event.getPlayer().getPlayerName());
}
}
@EventHandler
public void onClanDisband(ClanDisbandedEvent event)
{
for (Player player : event.getClan().getOnlinePlayers())
{
if (isVisualizing(player))
{
disableVisualizer(player);
}
}
}
@EventHandler
public void update(ClanInfo clan)
{
_calculated.clear();
for (String serialized : clan.getClaimSet())
{
calculate(clan, serialized);
}
}
@EventHandler
public void onUnclaim(PlayerUnClaimTerritoryEvent event)
{
if (event.getClan().getClaimCount() == 1)
{
for (Player player : event.getClan().getOnlinePlayers())
{
if (isVisualizing(player))
{
disableVisualizer(player);
}
}
}
}
public boolean isVisualizing(Player player)
{
return _visualizing.contains(player.getName());
}
public boolean isVisualizing(String name)
{
return _visualizing.contains(name);
}
public void enableVisualizer(String name)
{
enableVisualizer(UtilServer.getServer().getPlayer(name));
}
public void disableVisualizer(String name)
{
disableVisualizer(UtilServer.getServer().getPlayer(name));
}
public void toggleVisualizer(Player player)
{
if (_visualizing.contains(player.getName()))
{
disableVisualizer(player);
}
else
{
enableVisualizer(player);
}
}
public void enableVisualizer(Player player)
{
if (player == null)
{
return;
}
if (!_clansManager.isInClan(player))
{
UtilPlayer.message(player, F.main("Clans", "You must be in a clan to visualize claims."));
return;
}
ClanInfo clan = _clansManager.getClan(player);
if (clan.getClaimCount() == 0)
{
UtilPlayer.message(player, F.main("Clans", "Your Clan does not have any claims!"));
return;
}
_visualizing.add(player.getName());
UtilPlayer.message(player, F.main("Clans", "You are now visualizing your claims."));
for (VisualizedChunkData chunk : _calculated.get(clan).values())
{
if (!chunk.getChunk().getWorld().equals(player.getWorld()))
{
// return not break because a clan can't have claims in different worlds.
return;
}
if (UtilMath.offset2d(chunk.getChunk().getBlock(0, 0, 0).getLocation(), player.getLocation()) > 36)
{
break;
}
for (int x = 0; x < 16; x++)
{
for (int z = 0; z < 16; z++)
{
if (chunk.shouldDisplayEdge(x, z) && (z == 0 || z == 15 || x == 0 || x == 15))
{
Block block = chunk.getChunk().getBlock(x, 0, z);
}
}
}
}
}
public void disableVisualizer(Player player)
{
if (player == null)
{
return;
}
if (!_visualizing.contains(player.getName()))
{
UtilPlayer.message(player, F.main("Clans", "You are anot visualizing your claims."));
return;
}
_visualizing.remove(player.getName());
UtilPlayer.message(player, F.main("Clans", "You are no longer visualizing your claims."));
}
}

View File

@ -0,0 +1,57 @@
package mineplex.game.clans.clans.claimview;
import java.util.List;
import org.bukkit.Chunk;
import net.minecraft.server.v1_8_R3.EnumDirection;
public class VisualizedChunkData
{
private List<EnumDirection> _displayableEdges;
private Chunk _chunk;
public long _start;
public VisualizedChunkData(Chunk chunk, List<EnumDirection> dir)
{
_chunk = chunk;
_displayableEdges = dir;
_start = System.currentTimeMillis();
}
public double getLife()
{
return (double) (System.currentTimeMillis() - _start);
}
public boolean shouldDisplayEdge(int x, int z)
{
if (z == 15 && !_displayableEdges.contains(EnumDirection.SOUTH))
{
return false;
}
if (x == 15 && !_displayableEdges.contains(EnumDirection.EAST))
{
return false;
}
if (x == 0 && !_displayableEdges.contains(EnumDirection.WEST))
{
return false;
}
if (z == 0 && !_displayableEdges.contains(EnumDirection.NORTH))
{
return false;
}
return true;
}
public Chunk getChunk()
{
return _chunk;
}
}

View File

@ -0,0 +1,22 @@
package mineplex.game.clans.clans.claimview.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.game.clans.clans.claimview.ClaimVisualizer;
public class ClaimVisualizeCommand extends CommandBase<ClaimVisualizer>
{
public ClaimVisualizeCommand(ClaimVisualizer plugin)
{
super(plugin, Rank.ALL, "showclaims");
}
@Override
public void Execute(Player caller, String[] args)
{
Plugin.toggleVisualizer(caller);
}
}

View File

@ -38,7 +38,6 @@ import mineplex.game.clans.items.legendaries.WindBlade;
public class ClanManagementCommand extends CommandBase<ClansManager> public class ClanManagementCommand extends CommandBase<ClansManager>
{ {
private ClansManager _clansManager; private ClansManager _clansManager;
public ClanManagementCommand(ClansManager plugin) public ClanManagementCommand(ClansManager plugin)

View File

@ -1,5 +1,6 @@
package mineplex.game.clans.clans.commands; package mineplex.game.clans.clans.commands;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -24,7 +25,9 @@ import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.ClansBlacklist; import mineplex.game.clans.clans.ClansBlacklist;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClientClan; import mineplex.game.clans.clans.ClientClan;
import mineplex.game.clans.clans.event.ClanJoinEvent;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.tutorials.Tutorial;
import mineplex.game.clans.tutorials.TutorialManager; import mineplex.game.clans.tutorials.TutorialManager;
import net.minecraft.server.v1_8_R3.EnumDirection; import net.minecraft.server.v1_8_R3.EnumDirection;
@ -65,7 +68,8 @@ public class ClansCommand extends CommandBase<ClansManager>
else if (args[0].equalsIgnoreCase("promote") || args[0].equalsIgnoreCase("+")) else if (args[0].equalsIgnoreCase("promote") || args[0].equalsIgnoreCase("+"))
promote(caller, args); 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("-")) else if (args[0].equalsIgnoreCase("demote") || args[0].equalsIgnoreCase("-"))
demote(caller, args); demote(caller, args);
@ -121,12 +125,41 @@ public class ClansCommand extends CommandBase<ClansManager>
infoClan(caller, args[0]); 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) public void commandChat(Player caller, String[] args)
{ {
if (args.length == 0) if (args.length == 0)
{ {
Plugin.Get(caller).setClanChat(!Plugin.Get(caller).isClanChat()); 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; return;
} }
@ -135,7 +168,7 @@ public class ClansCommand extends CommandBase<ClansManager>
{ {
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller); ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
if (clan == null) 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 else
Plugin.chatClan(clan, caller, F.combine(args, 0, null, false)); Plugin.chatClan(clan, caller, F.combine(args, 0, null, false));
} }
@ -146,7 +179,7 @@ public class ClansCommand extends CommandBase<ClansManager>
if (args.length == 0) if (args.length == 0)
{ {
Plugin.Get(caller).setAllyChat(!Plugin.Get(caller).isAllyChat()); 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; return;
} }
@ -155,7 +188,7 @@ public class ClansCommand extends CommandBase<ClansManager>
{ {
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller); ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
if (clan == null) 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 else
Plugin.chatAlly(clan, caller, F.combine(args, 0, null, false)); Plugin.chatAlly(clan, caller, F.combine(args, 0, null, false));
} }
@ -171,30 +204,30 @@ public class ClansCommand extends CommandBase<ClansManager>
return; return;
} }
UtilPlayer.message(caller, F.main("Clans", "Commands List;")); _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Commands List;"));
UtilPlayer.message(caller, F.help("/c create <clan>", "Create new Clan", Rank.ALL)); _manager.getTutorials().sendTutorialMsg(caller, F.help("/c create <clan>", "Create new Clan", Rank.ALL));
UtilPlayer.message(caller, F.help("/c join <clan>", "Join a Clan", Rank.ALL)); _manager.getTutorials().sendTutorialMsg(caller, F.help("/c join <clan>", "Join a Clan", Rank.ALL));
UtilPlayer.message(caller, F.help("/c leave <clan>", "Leave your Clan", Rank.ALL)); _manager.getTutorials().sendTutorialMsg(caller, F.help("/c leave <clan>", "Leave your Clan", Rank.ALL));
UtilPlayer.message(caller, F.help("/c map <toggle>", "View Clan Map", Rank.ALL)); _manager.getTutorials().sendTutorialMsg(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.help("/cc (Message)", "Clan Chat (Toggle)", Rank.ALL));
UtilPlayer.message(caller, F.help("/c promote <player>", "Promote Player in Clan", Rank.MODERATOR)); _manager.getTutorials().sendTutorialMsg(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 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)); _manager.getTutorials().sendTutorialMsg(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)); _manager.getTutorials().sendTutorialMsg(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)); _manager.getTutorials().sendTutorialMsg(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)); _manager.getTutorials().sendTutorialMsg(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)); _manager.getTutorials().sendTutorialMsg(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)); _manager.getTutorials().sendTutorialMsg(caller, F.help("/c trust <clan>", "Give Trust to Clan", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c claim", "Claim Territory", Rank.ADMIN)); _manager.getTutorials().sendTutorialMsg(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 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) public void create(final Player caller, final String[] args)
@ -205,12 +238,12 @@ public class ClansCommand extends CommandBase<ClansManager>
if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId())) 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; 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 + * F.main("Clans", "You cannot join a Clan for " + C.mTime +
* UtilTime.convertString(System.currentTimeMillis() - * UtilTime.convertString(System.currentTimeMillis() -
* client.getDelay(), 1, TimeUnit.FIT) + C.mBody + ".")); return; } * client.getDelay(), 1, TimeUnit.FIT) + C.mBody + ".")); return; }
@ -218,37 +251,37 @@ public class ClansCommand extends CommandBase<ClansManager>
if (args.length < 2) 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; return;
} }
if (!UtilInput.valid(args[1])) 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; return;
} }
if (args[1].length() < Plugin.getNameMin()) 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; return;
} }
if (args[1].length() > Plugin.getNameMax()) 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; return;
} }
if (Plugin.getChat().getFilteredMessage(caller, args[1]).contains("*")) 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; return;
} }
if (!ClansBlacklist.isValidClanName(args[1])) 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; return;
} }
@ -259,7 +292,7 @@ public class ClansCommand extends CommandBase<ClansManager>
{ {
if (clanExists) 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 else
{ {
@ -271,11 +304,11 @@ public class ClansCommand extends CommandBase<ClansManager>
if (data == null) if (data == null)
{ {
// Hopefully shouldn't happen! // 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 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 +328,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null) 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; return;
} }
if (args.length < 2) 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; return;
} }
@ -315,25 +348,25 @@ public class ClansCommand extends CommandBase<ClansManager>
{ {
if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId())) 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; return;
} }
if (!Plugin.Get(caller).canJoin()) 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; return;
} }
if (args.length < 2) 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; return;
} }
if (!UtilInput.valid(args[1])) 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; return;
} }
@ -342,16 +375,20 @@ public class ClansCommand extends CommandBase<ClansManager>
if (!clan.isInvited(caller.getName())) 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; return;
} }
if (clan.getSize() >= clan.getMaxSize()) 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; return;
} }
ClanJoinEvent event = new ClanJoinEvent(clan, caller);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) return;
// Task // Task
Plugin.getClanDataAccess().join(clan, caller, ClanRole.RECRUIT, new Callback<Boolean>() Plugin.getClanDataAccess().join(clan, caller, ClanRole.RECRUIT, new Callback<Boolean>()
{ {
@ -361,12 +398,12 @@ public class ClansCommand extends CommandBase<ClansManager>
if (data) if (data)
{ {
// Inform // 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()); clan.inform(F.name(caller.getName()) + " has joined your Clan.", caller.getName());
} }
else 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 +416,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null) 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; return;
} }
if (clan.getMembers().get(caller.getUniqueId()).getRole() == ClanRole.LEADER && clan.getMembers().size() > 1) 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; return;
} }
@ -399,7 +436,7 @@ public class ClansCommand extends CommandBase<ClansManager>
public void run(Boolean data) public void run(Boolean data)
{ {
// Inform // 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); clan.inform(F.name(caller.getName()) + " has left your Clan.", null);
} }
}); });
@ -416,13 +453,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null) 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; return;
} }
if (args.length < 2) 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; return;
} }
@ -437,13 +474,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null) 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; return;
} }
if (args.length < 2) 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; return;
} }
@ -458,13 +495,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null) 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; return;
} }
if (args.length < 2) 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; return;
} }
@ -479,19 +516,19 @@ public class ClansCommand extends CommandBase<ClansManager>
if (cA == null) 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; return;
} }
if (cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) 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; return;
} }
if (args.length < 2) 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; return;
} }
@ -501,31 +538,31 @@ public class ClansCommand extends CommandBase<ClansManager>
if (cA.isSelf(cB.getName())) 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; return;
} }
if (cA.isAlly(cB.getName())) 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; return;
} }
if (cA.getAllies() >= cA.getAlliesMax()) 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; return;
} }
if (cB.getAllies() >= cB.getAlliesMax()) 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; return;
} }
if (!Recharge.Instance.usable(caller, "AllyReq" + cB.getName())) 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; return;
} }
@ -535,7 +572,7 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.getClanDataAccess().ally(cA, cB, caller.getName()); Plugin.getClanDataAccess().ally(cA, cB, caller.getName());
// Inform // 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()); 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); cB.inform("Clan " + F.elem(cA.getName()) + " has accepted alliance with you.", null);
} }
@ -545,7 +582,7 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.getClanDataAccess().requestAlly(cA, cB, caller.getName()); Plugin.getClanDataAccess().requestAlly(cA, cB, caller.getName());
// Inform // 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()); 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); cB.inform("Clan " + F.elem(cA.getName()) + " has requested alliance with you.", null);
@ -559,19 +596,19 @@ public class ClansCommand extends CommandBase<ClansManager>
// //
// if (cA == null) // 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; // return;
// } // }
// //
// if (cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) // 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; // return;
// } // }
// //
// if (args.length < 2) // 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; // return;
// } // }
// //
@ -581,7 +618,7 @@ public class ClansCommand extends CommandBase<ClansManager>
// //
// if (!cA.isAlly(cB.getName())) // 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; // return;
// } // }
// //
@ -589,14 +626,14 @@ public class ClansCommand extends CommandBase<ClansManager>
// if (Plugin.getClanDataAccess().trust(cA, cB, caller.getName())) // if (Plugin.getClanDataAccess().trust(cA, cB, caller.getName()))
// { // {
// // Inform // // 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()); // 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); // cB.inform(F.elem("Clan " + cA.getName()) + " has given trust to you.", null);
// } // }
// else // else
// { // {
// // Inform // // 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()); // 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); // cB.inform(F.elem("Clan " + cA.getName()) + " has revoked trust to you.", null);
// } // }
@ -608,19 +645,19 @@ public class ClansCommand extends CommandBase<ClansManager>
if (cA == null) 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; return;
} }
if (cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) 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; return;
} }
if (args.length < 2) 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; return;
} }
@ -630,11 +667,11 @@ public class ClansCommand extends CommandBase<ClansManager>
if (cB.isSelf(cA.getName())) 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())) 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())) else if (cB.isAlly(cA.getName()))
{ {
@ -642,7 +679,7 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.getClanDataAccess().neutral(cA, cB, caller.getName(), true); Plugin.getClanDataAccess().neutral(cA, cB, caller.getName(), true);
// Inform // 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()); 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); cB.inform(F.elem("Clan " + cA.getName()) + " has revoked alliance with you.", null);
} }
@ -683,7 +720,7 @@ public class ClansCommand extends CommandBase<ClansManager>
} }
// Change Inform // 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 // Inform
UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".")); UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + "."));
@ -719,31 +756,31 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null) 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; return;
} }
if (clan.getHome() == null) 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; return;
} }
if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(clan.getHome().getChunk()))) 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; return;
} }
if (!Plugin.getClanUtility().isSafe(caller.getLocation())) 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; return;
} }
if (!Plugin.getClanUtility().isSpecial(caller.getLocation(), "Spawn")) 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; return;
} }
@ -751,7 +788,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)) 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; return;
} }
@ -760,7 +797,7 @@ public class ClansCommand extends CommandBase<ClansManager>
* (Player cur : clan.GetHome().getWorld().getPlayers()) if * (Player cur : clan.GetHome().getWorld().getPlayers()) if
* (client.Clan().GetRelation(cur.getName()) == ClanRelation.NEUTRAL) if * (client.Clan().GetRelation(cur.getName()) == ClanRelation.NEUTRAL) if
* (clan.GetClaimSet().contains(UtilWorld.chunkToStr(cur.getLocation(). * (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; * "You cannot use Clan Home with enemies in your Territory.")); return;
* } * }
*/ */
@ -772,7 +809,7 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.getTeleport().TP(caller, clan.getHome().add(0, 1, 0)); Plugin.getTeleport().TP(caller, clan.getHome().add(0, 1, 0));
// Inform // 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) public void homeSet(Player caller)
@ -790,31 +827,31 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null) 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; return;
} }
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) 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; return;
} }
if (Plugin.getClanUtility().getOwner(caller.getLocation()) == null) 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; return;
} }
if (!Plugin.getClanUtility().getOwner(caller.getLocation()).isSelf(clan.getName())) 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; return;
} }
if (!(caller.getLocation().add(0, 1, 0).getBlock().getType().equals(Material.AIR) && caller.getLocation().add(0, 2, 0).getBlock().getType().equals(Material.AIR))) 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; return;
} }
@ -823,7 +860,7 @@ public class ClansCommand extends CommandBase<ClansManager>
if (!bedPlaced) 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; return;
} }
@ -839,7 +876,7 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.ClanTips.displayTip(TipType.SETHOME, caller); Plugin.ClanTips.displayTip(TipType.SETHOME, caller);
// Inform // 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()); clan.inform(caller.getName() + " set Clan Home to " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".", caller.getName());
} }
@ -847,7 +884,7 @@ public class ClansCommand extends CommandBase<ClansManager>
{System.out.println(search); {System.out.println(search);
if (search == null) 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; return;
} }
@ -869,13 +906,13 @@ public class ClansCommand extends CommandBase<ClansManager>
{ {
if (_manager.getClientManager().hasRank(caller, Rank.ADMIN)) 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; return;
} }
if (search == null) 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; return;
} }
@ -904,7 +941,7 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null) 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; return;
} }
} }
@ -914,6 +951,6 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null) return; 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) public RegionsCommand(ClansManager plugin)
{ {
super(plugin, Rank.ADMIN, new Rank[]{Rank.JNR_DEV},"region-reset"); super(plugin, Rank.ADMIN,"region-reset");
_manager = plugin; _manager = plugin;
} }

View File

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

View File

@ -0,0 +1,56 @@
package mineplex.game.clans.clans.event;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansPlayer;
public class ClanLeaveEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private ClansPlayer _player;
private ClanInfo _clan;
private boolean _cancelled;
public ClanLeaveEvent(ClanInfo clan, ClansPlayer clansPlayer)
{
_player = clansPlayer;
_clan = clan;
}
public ClansPlayer getPlayer()
{
return _player;
}
public ClanInfo getClan()
{
return _clan;
}
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

@ -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

@ -5,19 +5,23 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import mineplex.game.clans.clans.ClanInfo;
public class PlayerUnClaimTerritoryEvent extends Event public class PlayerUnClaimTerritoryEvent extends Event
{ {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private Player _unClaimer; private Player _unClaimer;
private Chunk _unClaimedChunk; private Chunk _unClaimedChunk;
private ClanInfo _clan;
private boolean _cancelled; private boolean _cancelled;
public PlayerUnClaimTerritoryEvent(Player unClaimer, Chunk unClaimedChunk) public PlayerUnClaimTerritoryEvent(Player unClaimer, Chunk unClaimedChunk, ClanInfo clan)
{ {
_unClaimer = unClaimer; _unClaimer = unClaimer;
_unClaimedChunk = unClaimedChunk; _unClaimedChunk = unClaimedChunk;
_clan = clan;
} }
public Player getUnClaimer() public Player getUnClaimer()
@ -35,6 +39,11 @@ public class PlayerUnClaimTerritoryEvent extends Event
_cancelled = cancelled; _cancelled = cancelled;
} }
public ClanInfo getClan()
{
return _clan;
}
public boolean isCancelled() public boolean isCancelled()
{ {
return _cancelled; return _cancelled;

View File

@ -42,18 +42,16 @@ public class ClansScoreboardManager extends ScoreboardManager
private void init(TutorialManager tutorialManager) private void init(TutorialManager tutorialManager)
{ {
setTitle(" MINEPLEX CLANS "); setTitle("Clans Alpha " + Clans.VERSION);
ScoreboardData data = getData("default", true); ScoreboardData data = getData("default", true);
data.write(C.cGreen + "Clans Alpha " + Clans.VERSION);
data.writeEmpty();
data.writeElement(new ScoreboardElementClan(_clansManager)); data.writeElement(new ScoreboardElementClan(_clansManager));
data.writeElement(new ScoreboardElementPlayer(_clansManager)); data.writeElement(new ScoreboardElementPlayer(_clansManager));
data.writeElement(new ScoreboardElementPlayerCount(_clansManager)); // data.writeElement(new ScoreboardElementPlayerCount(_clansManager));
data.writeElement(_worldEvent);
data.writeElement(_warManager); data.writeElement(_warManager);
data.writeElement(_worldEvent);
for (Tutorial tutorial : tutorialManager.getTutorials().values()) for (Tutorial tutorial : tutorialManager.getTutorials().values())
{ {

View File

@ -35,8 +35,7 @@ public class ScoreboardElementClan implements ScoreboardElement
// Energy // Energy
if (clanInfo.getEnergyCostPerMinute() > 0) if (clanInfo.getEnergyCostPerMinute() > 0)
output.add(C.cYellow + "Energy " + C.cWhite + UtilTime.convertString((clanInfo.getEnergy() / clanInfo.getEnergyCostPerMinute()) * 60000L, 1, UtilTime.TimeUnit.FIT)); output.add(C.cYellow + "Energy " + C.cWhite + UtilTime.convertString((clanInfo.getEnergy() / clanInfo.getEnergyCostPerMinute()) * 60000L, 1, UtilTime.TimeUnit.FIT));
output.add(C.cYellow + "Home " + C.cWhite + clanInfo.getBedStatusStr());
} }
else else
{ {

View File

@ -27,10 +27,9 @@ public class ScoreboardElementPlayer implements ScoreboardElement
{ {
List<String> output = new ArrayList<String>(); List<String> output = new ArrayList<String>();
output.add(C.cYellow + "Gold " + C.cWhite + manager.getDonation().Get(player).GetBalance(CurrencyType.Gold) + ""); output.add(C.cYellow + "Gold " + C.cWhite + manager.getDonation().Get(player).GetBalance(CurrencyType.Gold) + "");
output.add("");
String regionString = C.xWilderness + "Wilderness"; String regionString = C.xWilderness + "Wilderness";
output.add(" ");
ClanTerritory claim = _clansManager.getClanUtility().getClaim(player.getLocation()); ClanTerritory claim = _clansManager.getClanUtility().getClaim(player.getLocation());
if (claim != null) if (claim != null)
{ {

View File

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

View File

@ -97,7 +97,7 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
{ {
for (WarInvasion invasion : invasions) for (WarInvasion invasion : invasions)
{ {
if (invasion.getInvaderClan().equals(playerClan)) if (invasion.getInvaderClan().equals(playerClan.getName()))
return true; return true;
} }
} }
@ -125,15 +125,24 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
final ClanInfo killerClan = event.getKiller().getClan(); final ClanInfo killerClan = event.getKiller().getClan();
ClanWarData war = clan.getWarData(killerClan); ClanWarData war = clan.getWarData(killerClan);
if (war != null && !war.isOnCooldown()) if (war != null)
{ {
if (war.isOnCooldown())
{
// Ignore!
return;
}
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_RIP, event.getPlayer().getPlayer());
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_NOOICE, event.getKiller().getPlayer());
// War already exists // War already exists
war.increment(killerClan.getName());
ClansUtility.ClanRelation rel = _clansManager.getClanUtility().rel(clan, killerClan); ClansUtility.ClanRelation rel = _clansManager.getClanUtility().rel(clan, killerClan);
_clansManager.messageClan(killerClan, F.main("Clans", "Your clan gained 1 War Point against " + rel.getColor(false) + _clansManager.messageClan(killerClan, F.main("Clans", "Your clan gained 1 War Point against " + rel.getColor(false) +
clan.getName() + " " + C.Reset + "(" + killerClan.getFormattedWarPoints(clan) + C.Reset + ")")); clan.getName() + " " + C.Reset + "(" + killerClan.getFormattedWarPoints(clan) + C.Reset + ")"));
_clansManager.messageClan(clan, F.main("Clans", "Your clan lost 1 War Point against " + rel.getColor(false) + _clansManager.messageClan(clan, F.main("Clans", "Your clan lost 1 War Point against " + rel.getColor(false) +
killerClan.getName() + " " + C.Reset + "(" + clan.getFormattedWarPoints(killerClan) + C.Reset + ")")); killerClan.getName() + " " + C.Reset + "(" + clan.getFormattedWarPoints(killerClan) + C.Reset + ")"));
war.increment(killerClan.getName());
checkWarComplete(war); checkWarComplete(war);
ClanInfo clanA = clan.getName().equals(war.getClanA()) ? clan : killerClan; ClanInfo clanA = clan.getName().equals(war.getClanA()) ? clan : killerClan;
@ -142,9 +151,6 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
_clansManager.getScoreboard().refresh(killerClan); _clansManager.getScoreboard().refresh(killerClan);
_clansManager.getScoreboard().refresh(clan); _clansManager.getScoreboard().refresh(clan);
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_RIP, event.getPlayer().getPlayer());
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_NOOICE, event.getKiller().getPlayer());
} }
else else
{ {
@ -155,14 +161,13 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
public void run(ClanWarData data) public void run(ClanWarData data)
{ {
ClansUtility.ClanRelation rel = _clansManager.getClanUtility().rel(clan, killerClan); ClansUtility.ClanRelation rel = _clansManager.getClanUtility().rel(clan, killerClan);
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_RIP, event.getPlayer().getPlayer());
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_NOOICE, event.getKiller().getPlayer());
_clansManager.messageClan(killerClan, F.main("Clans", "Your clan gained 1 War Point against " + rel.getColor(false) + clan.getName())); _clansManager.messageClan(killerClan, F.main("Clans", "Your clan gained 1 War Point against " + rel.getColor(false) + clan.getName()));
_clansManager.messageClan(clan, F.main("Clans", "Your clan lost 1 War Point against " + rel.getColor(false) + killerClan.getName())); _clansManager.messageClan(clan, F.main("Clans", "Your clan lost 1 War Point against " + rel.getColor(false) + killerClan.getName()));
_clansManager.getScoreboard().refresh(killerClan); _clansManager.getScoreboard().refresh(killerClan);
_clansManager.getScoreboard().refresh(clan); _clansManager.getScoreboard().refresh(clan);
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_RIP, event.getPlayer().getPlayer());
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_NOOICE, event.getKiller().getPlayer());
} }
}); });
} }
@ -271,7 +276,7 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
@EventHandler @EventHandler
public void onInvasionEnd(WarInvasionEndEvent event) public void onInvasionEnd(WarInvasionEndEvent event)
{ {
Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarInvasion().getInvaderClan()) + "'s invasion against " + F.elem(event.getWarInvasion().getInvaderClan() + " has ended."))); Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarInvasion().getInvaderClan()) + "'s invasion against " + F.elem(event.getWarInvasion().getInvadedClan()) + " has ended."));
} }
@ -301,13 +306,14 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
if (clan != null) if (clan != null)
{ {
List<WarInvasion> invadedList = _invadedMap.get(clan); List<WarInvasion> invadedList = _invadedMap.get(clan.getName());
List<WarInvasion> invaderList = _invaderMap.get(clan); List<WarInvasion> invaderList = _invaderMap.get(clan.getName());
if (invaderList != null && !invaderList.isEmpty()) if (invaderList != null && !invaderList.isEmpty())
{ {
for (WarInvasion invasion : invaderList) for (WarInvasion invasion : invaderList)
{ {
element.add(" ");
element.add(C.cPurpleB + "Invading"); element.add(C.cPurpleB + "Invading");
element.add(" " + invasion.getInvadedClan()); element.add(" " + invasion.getInvadedClan());
element.add(" " + UtilTime.convertString(invasion.getTimeLeft(), 1, UtilTime.TimeUnit.FIT)); element.add(" " + UtilTime.convertString(invasion.getTimeLeft(), 1, UtilTime.TimeUnit.FIT));
@ -318,6 +324,7 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
{ {
for (WarInvasion invasion : invadedList) for (WarInvasion invasion : invadedList)
{ {
element.add(" ");
element.add(C.cRedB + "Invaded"); element.add(C.cRedB + "Invaded");
element.add(" " + invasion.getInvaderClan()); element.add(" " + invasion.getInvaderClan());
element.add(" " + UtilTime.convertString(invasion.getTimeLeft(), 1, UtilTime.TimeUnit.FIT)); element.add(" " + UtilTime.convertString(invasion.getTimeLeft(), 1, UtilTime.TimeUnit.FIT));

View File

@ -12,7 +12,7 @@ import mineplex.minecraft.game.core.boss.WorldEvent;
public enum WorldEventType public enum WorldEventType
{ {
// SLIME_KING("Slime King", SlimeBoss.class, 30), // 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);// , UNDEAD_CAMP("Undead Camp", UndeadCamp.class, 30);// ,
// Golem("Iron Wizard", GolemBoss.class, 30); // Golem("Iron Wizard", GolemBoss.class, 30);

View File

@ -41,7 +41,7 @@ public class HillData
public boolean isOnHill(Location location, Location eventLocation) 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) public Location getHillCenter(Location eventLocation)

View File

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

View File

@ -35,6 +35,7 @@ public class HeavyArrowsAttribute extends ItemAttribute
@Override @Override
public void onAttack(CustomDamageEvent event) public void onAttack(CustomDamageEvent event)
{ {
event.AddKnockback("HeavyAttribute", _knockbackPercent); double knockback = (_knockbackPercent / 100d) * 6;
event.AddKnockback("Heavy Attribute", knockback);
} }
} }

View File

@ -12,7 +12,7 @@ public class GearCommand extends CommandBase<GearManager>
public GearCommand(GearManager plugin) 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; _gearManager = plugin;
} }

View File

@ -248,7 +248,7 @@ public class Spawn extends MiniPlugin
if (isInSpawn(player)) if (isInSpawn(player))
{ {
UtilPlayer.message(event.GetPlayer(), F.main("Safe Zone", "You cannot use " + F.skill(event.GetSkillName() + " in " + F.elem("Safe Zone") + "."))); UtilPlayer.message(event.GetPlayer(), F.main("Safe Zone", "You cannot use " + F.skill(event.GetSkillName()) + " in " + F.elem("Safe Zone") + "."));
event.SetCancelled(true); event.SetCancelled(true);
} }
} }

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

@ -8,6 +8,7 @@ import java.util.Map;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type; import org.bukkit.FireworkEffect.Type;
import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -19,6 +20,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.ClickEvent;
@ -27,17 +29,25 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager; 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.ScoreboardManager;
import mineplex.core.scoreboard.elements.ScoreboardElement; import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.core.task.TaskManager; import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClanJoinEvent;
import mineplex.game.clans.clans.event.ClanTipEvent; import mineplex.game.clans.clans.event.ClanTipEvent;
import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.economy.GoldManager;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
/** /**
* *
@ -53,13 +63,17 @@ public abstract class Tutorial implements ScoreboardElement, Listener
public static String TUTORIAL_REWARD_TASK = "tatatatatat%sRewardGiven"; //do not change public static String TUTORIAL_REWARD_TASK = "tatatatatat%sRewardGiven"; //do not change
public static String SKIPPED_TASK = "tatatatata%sSkip"; public static String SKIPPED_TASK = "tatatatata%sSkip";
public static String AllowedMessage = C.cGold + "TutorialAllowedMessage" + C.Reset;
public static String AllowedBypass = C.cBlue + "Tutorial>";
protected final TutorialManager _manager; protected final TutorialManager _manager;
protected final GoldManager _goldManager; protected final GoldManager _goldManager;
protected final ClansManager _clansManager; protected final ClansManager _clansManager;
protected final TaskManager _taskManager; protected final TaskManager _taskManager;
protected final DonationManager _donationManager; protected final DonationManager _donationManager;
protected final LinkedHashMap<Integer, TutorialTask<?>> _tasks; // protected final LinkedHashMap<Integer, TutorialTask<?>> _tasks;
private final ArrayList<TutorialTask<?>> _tasks;
protected final LinkedHashMap<String, TutorialTask<?>> _nameToTask; protected final LinkedHashMap<String, TutorialTask<?>> _nameToTask;
protected final LinkedHashMap<String, TutorialClient> _inTutorial; protected final LinkedHashMap<String, TutorialClient> _inTutorial;
@ -75,14 +89,14 @@ public abstract class Tutorial implements ScoreboardElement, Listener
protected int _gemReward = -1; protected int _gemReward = -1;
protected int _coinReward = -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; _clansManager = clansManager;
_goldManager = goldManager; _goldManager = goldManager;
_donationManager = donationManager; _donationManager = donationManager;
_taskManager = taskManager; _taskManager = taskManager;
_manager = manager; _manager = manager;
_tasks = new LinkedHashMap<>(); _tasks = new ArrayList<TutorialTask<?>>();
_inTutorial = new LinkedHashMap<>(); _inTutorial = new LinkedHashMap<>();
_nameToTask = new LinkedHashMap<>(); _nameToTask = new LinkedHashMap<>();
@ -115,7 +129,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
lines.add(C.cAqua + "Tutorial"); lines.add(C.cAqua + "Tutorial");
for (final TutorialTask<?> task : _tasks.values()) for (final TutorialTask<?> task : _tasks)
{ {
if (get(player).CurrentTask.equals(task)) if (get(player).CurrentTask.equals(task))
{ {
@ -136,48 +150,84 @@ public abstract class Tutorial implements ScoreboardElement, Listener
return lines; return lines;
} }
public TutorialTask<?> getTask(int index)
{
return _tasks.get(index);
}
protected void addTask(TutorialTask<?> task) protected void addTask(TutorialTask<?> task)
{ {
_tasks.put(_tasks.size() + 1, task); _tasks.add(task);
_nameToTask.put(task.getTechnicalName(), task); _nameToTask.put(task.getTechnicalName(), task);
} }
protected boolean hasFinishedTask(Player player, TutorialTask<?> task) protected boolean hasFinishedTask(Player player, TutorialTask<?> task)
{ {
if (get(player).QueuedFinish)
{
return true;
}
return get(player).CurrentTask.getID() < task.getID(); return get(player).CurrentTask.getID() < task.getID();
} }
private TutorialTask<?> getLastTask()
{
return _tasks.get(_tasks.size() - 1);
}
protected void finishTask(final Player player, final TutorialTask<?> task) protected void finishTask(final Player player, final TutorialTask<?> task)
{ {
if (player == null)
{
return;
}
get(player).LastDescriptionSentTime = 0; get(player).LastDescriptionSentTime = 0;
get(player).CurrentTask.visibleFinish(player); 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) final TutorialTask<?> lastTask = getLastTask();
{ // Cycle to next task, or null if last task.
if (task.equals(_tasks.get(_tasks.size()))) get(player).CurrentTask = task.equals(lastTask) ? null : _tasks.get(task.getDataId() + 1);
{ System.out.println("Next Task: " + get(player).CurrentTask);
finishFor(player);
}
else
{
_manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
{
public void run()
{
get(player).CurrentTask.deploy(player);
}
}, 10L);
}
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); if (!_taskManager.hasCompletedTask(player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName())))
{
_taskManager.completedTask(new Callback<Boolean>()
{
public void run(final Boolean completed)
{
// If last task, end tutorial.
if (task.equals(lastTask))
{
finishFor(player);
}
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()
{
System.out.println("STARTING NEXT TASK!");
get(player).CurrentTask.startFor(player);
get(player).CurrentTaskStartTime = System.currentTimeMillis();
}
}, 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) public TutorialTask<?> getTask(final String technicalName)
@ -223,77 +273,113 @@ public abstract class Tutorial implements ScoreboardElement, Listener
private void finishFor(final Player player) private void finishFor(final Player player)
{ {
// if (player.getOpenInventory() != null)
// {
// _inTutorial.get(player.getName()).QueuedFinish = true;
// return;
// }
_manager.finishTutorial(player);
_inTutorial.remove(player.getName()); _inTutorial.remove(player.getName());
UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, Color.LIME, false, false, new Vector(0, 0, 0), 1);
onFinished(player); onFinished(player);
if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_REWARD_TASK, _technicalName))) _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
{ {
_taskManager.completedTask(new Callback<Boolean>() public void run()
{ {
@Override UtilTextMiddle.display(C.cWhite + "Clans Tutorial", C.cGreen + "You have completed the Clans Tutorial!", 20, 20 * 3, 20, player);
public void run(Boolean data) onFinishedDelay(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); @Override
UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gold") + ".")); public void run(Boolean data)
}
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())
{ {
other.showPlayer(player); if (_goldReward != -1)
player.showPlayer(other); {
_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);
}
}
}, player, String.format(TUTORIAL_REWARD_TASK, _technicalName));
}
else
{
UtilInv.remove(player, Material.IRON_AXE, (byte) 0, 1);
UtilInv.remove(player, Material.IRON_HELMET, (byte) 0, 1);
UtilInv.remove(player, Material.IRON_CHESTPLATE, (byte) 0, 1);
UtilInv.remove(player, Material.IRON_LEGGINGS, (byte) 0, 1);
UtilInv.remove(player, Material.IRON_BOOTS, (byte) 0, 1);
ItemStack[] armor = player.getInventory().getArmorContents();
for (int i = 0 ; i < armor.length; i++)
{
if (UtilItem.isIronProduct(armor[i]))
{
armor[i] = null;
} }
} }
player.getInventory().setArmorContents(armor);
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));
} _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 * 2);
} }
// Implementation left to sub classes. // Implementation left to sub classes.
@ -301,6 +387,10 @@ public abstract class Tutorial implements ScoreboardElement, Listener
{ {
} }
protected void onFinishedDelay(final Player player)
{
}
// Implementation left to sub classes. // Implementation left to sub classes.
protected void onBegin(final Player player) protected void onBegin(final Player player)
{ {
@ -310,12 +400,12 @@ public abstract class Tutorial implements ScoreboardElement, Listener
{ {
if (!_manager.isInTutorial(player)) if (!_manager.isInTutorial(player))
{ {
_manager._playerTutorials.put(player.getName(), this); _manager.setTutorial(player, this);
} }
_inTutorial.put(player.getName(), new TutorialClient(player, this)); _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); player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
@ -333,8 +423,12 @@ public abstract class Tutorial implements ScoreboardElement, Listener
public void cancelFor(final Player player) public void cancelFor(final Player player)
{ {
get(player).CurrentTask.cleanup(player);
get(player).CurrentTaskStartTime = -1;
_inTutorial.remove(player.getName()); _inTutorial.remove(player.getName());
_manager.finishTutorial(player);
if (_ghostMode) if (_ghostMode)
{ {
for (Player other : UtilServer.getPlayers()) for (Player other : UtilServer.getPlayers())
@ -355,11 +449,6 @@ public abstract class Tutorial implements ScoreboardElement, Listener
return _inTutorial.containsKey(player); return _inTutorial.containsKey(player);
} }
public Map<Integer, TutorialTask<?>> getTasks()
{
return _tasks;
}
public boolean hasCompleted(final Player player) public boolean hasCompleted(final Player player)
{ {
return _taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName)); return _taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName));
@ -372,7 +461,8 @@ public abstract class Tutorial implements ScoreboardElement, Listener
public void skip(final Player player) public void skip(final Player player)
{ {
new JsonMessage( new JsonMessage("")
.extra(
F.main( F.main(
"Tutorial", "Tutorial",
"Are you sure you want to skip the tutorial? We " "Are you sure you want to skip the tutorial? We "
@ -385,9 +475,11 @@ public abstract class Tutorial implements ScoreboardElement, Listener
.color("yellow") .color("yellow")
.extra("!") .extra("!")
.color("gray") .color("gray")
.sendToPlayer(player); .sendToPlayer(player);
new JsonMessage( new JsonMessage("")
.extra(
F.main( F.main(
"Tutorial", "Tutorial",
"Click " "Click "
@ -443,7 +535,20 @@ public abstract class Tutorial implements ScoreboardElement, Listener
{ {
if (isInTutorial(player)) if (isInTutorial(player))
{ {
get(player).CurrentTask.trySendDescription(player); if (get(player).QueuedFinish)
{
if (player.getOpenInventory() == null)
{
get(player).QueuedFinish = false;
finishFor(player);
}
else
{
continue;
}
}
get(player).CurrentTask.trySendDescription(player, false);
} }
} }
} }
@ -469,6 +574,15 @@ public abstract class Tutorial implements ScoreboardElement, Listener
evt.setCancelled(true); evt.setCancelled(true);
} }
@EventHandler
public void onJoinClan(ClanJoinEvent event)
{
if (isInTutorial(event.getPlayer()))
{
event.setCancelled(true);
}
}
@EventHandler @EventHandler
public void onPlayerJoin(final PlayerJoinEvent evt) public void onPlayerJoin(final PlayerJoinEvent evt)
{ {
@ -489,9 +603,15 @@ public abstract class Tutorial implements ScoreboardElement, Listener
public void cleanup(Player player) public void cleanup(Player player)
{ {
if (get(player) != null && get(player).CurrentTask != null) System.out.println("Cleaning up Player in " + getClass().getName());
get(player).CurrentTask.cleanup(player);
if (get(player) != null && get(player).CurrentTask != null)
{
System.out.println("Cleaning up current task: " + get(player).CurrentTask.getClass().getName());
get(player).CurrentTask.cleanup(player);
}
System.out.println("removing from in tutorial");
_inTutorial.remove(player.getName()); _inTutorial.remove(player.getName());
} }
} }

View File

@ -9,18 +9,27 @@ public class TutorialClient
public Player Player; public Player Player;
public TutorialTask<?> CurrentTask; public TutorialTask<?> CurrentTask;
public long LastDescriptionSentTime = System.currentTimeMillis() - 3000; public long LastDescriptionSentTime = System.currentTimeMillis() - 3000;
public boolean InClanOnStart;
public boolean QueuedFinish;
public long CurrentTaskStartTime;
public TutorialClient(Player player, Tutorial tutorial) public TutorialClient(Player player, Tutorial tutorial)
{ {
Player = player; Player = player;
CurrentTask = tutorial._tasks.get(1); CurrentTask = tutorial.getTask(0);
CurrentTaskStartTime = System.currentTimeMillis();
InClanOnStart = tutorial._clansManager.isInClan(player);
/*
for (TutorialTask<?> task : tutorial._tasks.values()) for (TutorialTask<?> task : tutorial._tasks.values())
{ {
if (TaskManager.Instance.hasCompletedTask(player, String.format( if (TaskManager.Instance.hasCompletedTask(player, String.format(
Tutorial.TASK_COMPLETE_TASK, Tutorial.TASK_COMPLETE_TASK,
task.getTutorial().getTechnicalName(), task.getTechnicalName()))) task.getTutorial().getTechnicalName(),
task.getTechnicalName()
)))
{ {
if (CurrentTask.getID() <= task.getID()) if (CurrentTask.getID() <= task.getID())
{ {
@ -28,5 +37,6 @@ public class TutorialClient
} }
} }
} }
*/
} }
} }

View File

@ -1,6 +1,7 @@
package mineplex.game.clans.tutorials; package mineplex.game.clans.tutorials;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -12,6 +13,9 @@ import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager; 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.preferences.PreferencesManager;
import mineplex.core.task.TaskManager; import mineplex.core.task.TaskManager;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
@ -20,17 +24,20 @@ import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.tutorials.commands.DoSkipTutorialCommand; import mineplex.game.clans.tutorials.commands.DoSkipTutorialCommand;
import mineplex.game.clans.tutorials.commands.SkipTutorialCommand; import mineplex.game.clans.tutorials.commands.SkipTutorialCommand;
import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted; import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted;
import net.md_5.bungee.api.ChatColor;
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
public class TutorialManager extends MiniPlugin public class TutorialManager extends MiniPlugin
{ {
public static TutorialManager Instance; public static TutorialManager Instance;
private final Map<Class<? extends Tutorial>, Tutorial> _tutorials = new HashMap<>(); private final Map<Class<? extends Tutorial>, Tutorial> _tutorials = new HashMap<>();
protected final Map<String, Tutorial> _playerTutorials = new HashMap<>(); private final Map<String, Tutorial> _playerTutorials = new HashMap<>();
private final TaskManager _taskManager; 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); super("Tutorials", plugin);
@ -38,7 +45,37 @@ public class TutorialManager extends MiniPlugin
_taskManager = taskManager; _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 (!chat.a.a().get(0).c().contains(Tutorial.AllowedBypass))
{
if (isInTutorial(packet.getPlayer()))
{
packet.setCancelled(true);
}
}
}
}
}
}, PacketPlayOutChat.class);
} }
public void addCommands() public void addCommands()
@ -58,7 +95,6 @@ public class TutorialManager extends MiniPlugin
if (_tutorials.containsKey(tutorial)) if (_tutorials.containsKey(tutorial))
{ {
_tutorials.get(tutorial).startFor(player); _tutorials.get(tutorial).startFor(player);
_playerTutorials.put(player.getName(), _tutorials.get(tutorial));
return isInTutorial(player); return isInTutorial(player);
} }
@ -78,7 +114,7 @@ public class TutorialManager extends MiniPlugin
getTutorial(player).cancelFor(player); 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()); _playerTutorials.remove(player.getName());
} }
} }
@ -95,7 +131,7 @@ public class TutorialManager extends MiniPlugin
{ {
if (isInTutorial(player)) 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); getTutorial(player).doSkip(player);
} }
} }
@ -103,10 +139,36 @@ public class TutorialManager extends MiniPlugin
@EventHandler @EventHandler
public void quit(PlayerQuitEvent event) public void quit(PlayerQuitEvent event)
{ {
System.out.println("Player Quit. In Tutorial: " + isInTutorial(event.getPlayer()));
if (!isInTutorial(event.getPlayer())) if (!isInTutorial(event.getPlayer()))
return; return;
getTutorial(event.getPlayer()).cleanup(event.getPlayer()); getTutorial(event.getPlayer()).cleanup(event.getPlayer());
_playerTutorials.remove(event.getPlayer().getName());
}
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 void finishTutorial(Player player)
{
_playerTutorials.remove(player.getName());
}
public void setTutorial(Player player, Tutorial tutorial)
{
_playerTutorials.put(player.getName(), tutorial);
} }
public Tutorial getTutorial(final Player player) public Tutorial getTutorial(final Player player)
@ -123,4 +185,72 @@ public class TutorialManager extends MiniPlugin
{ {
return _taskManager; return _taskManager;
} }
// Stolen from UtilTabTitle
private static class TextConverter
{
public static String convert(String text)
{
if (text == null || text.length() == 0)
{
return "\"\"";
}
char c;
int i;
int len = text.length();
StringBuilder sb = new StringBuilder(len + 4);
String t;
sb.append('"');
for (i = 0; i < len; i += 1)
{
c = text.charAt(i);
switch (c)
{
case '\\':
case '"':
sb.append('\\');
sb.append(c);
break;
case '/':
sb.append('\\');
sb.append(c);
break;
case '\b':
sb.append("\\b");
break;
case '\t':
sb.append("\\t");
break;
case '\n':
sb.append("\\n");
break;
case '\f':
sb.append("\\f");
break;
case '\r':
sb.append("\\r");
break;
default:
if (c < ' ')
{
t = "000" + Integer.toHexString(c);
sb.append("\\u").append(t.substring(t.length() - 4));
}
else
{
sb.append(c);
}
}
}
sb.append('"');
return sb.toString();
}
public static String setPlayerName(Player player, String text)
{
return text.replaceAll("(?i)\\{PLAYER\\}", player.getName());
}
}
} }

View File

@ -1,25 +1,26 @@
package mineplex.game.clans.tutorials; package mineplex.game.clans.tutorials;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import mineplex.core.common.util.C; 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.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
public class TutorialTask<T extends Tutorial> implements Listener public class TutorialTask<T extends Tutorial> implements Listener
{ {
private T _tutorial; protected T _tutorial;
protected long _autoCompleteTime = -1; protected long _autoCompleteTime = -1;
@ -29,13 +30,18 @@ public class TutorialTask<T extends Tutorial> implements Listener
protected String _description; protected String _description;
protected String _finishMessage; protected String _finishMessage;
protected String[] _subtasks;
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; protected long _descriptionWaitTime = 30000;
private List<String> _playersFinished = new ArrayList<>(); protected NautArrayList<String> _inTask = new NautArrayList<>();
private Map<String, DeployedTask> _deployedInstances = new HashMap<>();
private List<DeployedTask> _toCull = new ArrayList<>();
private long _lastTaskTp;
private int _id; private int _id;
public TutorialTask(T tutorial, int id) public TutorialTask(T tutorial, int id)
@ -46,35 +52,90 @@ public class TutorialTask<T extends Tutorial> implements Listener
UtilServer.getServer().getPluginManager().registerEvents(this, _tutorial._manager.getPlugin()); 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); protected void customEndFor(final Player player)
{
}
UtilServer.getServer().getPluginManager().registerEvents(task, _tutorial._manager.getPlugin()); protected final void startFor(final Player player)
{
_inTask.add(player.getName());
trySendDescription(player); trySendDescription(player, true);
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) if (_autoCompleteTime != -1)
{ {
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_tutorial._manager.getPlugin(), new Runnable(){ UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_tutorial._manager.getPlugin(), new Runnable(){
public void run() public void run()
{ {
if (_deployedInstances.containsKey(player.getName())) if (isDoing(player))
{ {
finishFor(player); finishFor(player);
} }
} }
}, _autoCompleteTime); }, _autoCompleteTime);
} }
task.postDeploy();
return task;
} }
public void trySendDescription(Player player) //@EventHandler
//todo: fix the multiline subtitles
public void displaySubtasks(UpdateEvent event)
{
if (!event.getType().equals(UpdateType.SEC))
{
return;
}
if (_subtasks == null || _subtasks.length == 0)
{
return;
}
Iterator<String> iterator = _inTask.iterator();
while (iterator.hasNext())
{
Player player = Bukkit.getPlayer(iterator.next());
if ((System.currentTimeMillis() - _tutorial.get(player).CurrentTaskStartTime) >= 15000)
{
if (isDoing(player))
{
UtilTextMiddle.display("", UtilText.arrayToString(_subtasks, "\n"), 1, 25, 25, player);
}
}
}
}
public boolean isDoing(Player player)
{
return _inTask != null && player != null && _inTask.contains(player.getName());
}
public void trySendDescription(Player player, boolean force)
{ {
if (!_tutorial.isInTutorial(player)) if (!_tutorial.isInTutorial(player))
{ {
@ -83,34 +144,43 @@ public class TutorialTask<T extends Tutorial> implements Listener
TutorialClient client = _tutorial.get(player); TutorialClient client = _tutorial.get(player);
if (System.currentTimeMillis() - client.LastDescriptionSentTime > client.CurrentTask.getDescriptionWaitTime()) if (client.QueuedFinish)
{ {
UtilPlayer.message(player, " "); return;
UtilPlayer.message(player, " "); }
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); if (force || System.currentTimeMillis() - client.LastDescriptionSentTime > client.CurrentTask.getDescriptionWaitTime())
UtilPlayer.message(player, " "); {
UtilPlayer.message(player, C.cYellowB + "Part " + _id + ": " + _displayName); String description = _description;
UtilPlayer.message(player, C.cWhite + _description.replace("{", C.cAqua).replace("}", C.cWhite)); ClanInfo clan = getClans().getClan(player);
UtilPlayer.message(player, " "); if (clan != null) description = description.replace("(clan)", clan.getName());
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); description = description.replace("{", C.cAqua).replace("}", C.cWhite);
_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 + 1) + ": " + _displayName);
_tutorial._manager.sendTutorialMsg(player, C.cWhite + " " + description);
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilTextMiddle.display("", getDisplayName(), player);
client.LastDescriptionSentTime = System.currentTimeMillis(); 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) 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() public String getDisplayName()
@ -133,60 +203,56 @@ public class TutorialTask<T extends Tutorial> implements Listener
return _technicalName; return _technicalName;
} }
public int getID() public TutorialManager getManager()
{
return _tutorial._manager;
}
public ClansManager getClans()
{
return _tutorial._clansManager;
}
public int getDataId()
{ {
return _id; return _id;
} }
public int getID()
{
return _id + 1;
}
public void finishFor(Player player) public void finishFor(Player player)
{ {
customEndFor(player);
cleanup(player);
_tutorial.finishTask(player, this); _tutorial.finishTask(player, this);
} }
public void visibleFinish(Player player) public void visibleFinish(Player player)
{ {
_deployedInstances.get(player.getName()).kill();
_toCull.add(_deployedInstances.get(player.getName()));
_deployedInstances.remove(player.getName());
if (_finishMessage != null) if (_finishMessage != null)
{ {
UtilPlayer.message(player, " "); String finishMessage = _finishMessage;
UtilPlayer.message(player, " "); ClanInfo clan = getClans().getClan(player);
UtilPlayer.message(player, " "); if (clan != null) finishMessage = finishMessage.replace("(clan)", clan.getName());
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); finishMessage = finishMessage.replace("{", C.cAqua).replace("}", C.cWhite);
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 _tutorial._manager.sendTutorialMsg(player, " ");
public void update(UpdateEvent event) _tutorial._manager.sendTutorialMsg(player, " ");
{ _tutorial._manager.sendTutorialMsg(player, " ");
if (event.getType() != UpdateType.SEC) _tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
{ _tutorial._manager.sendTutorialMsg(player, " ");
return; _tutorial._manager.sendTutorialMsg(player, C.cWhite + finishMessage);
} _tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
Iterator<DeployedTask> iterator = _toCull.iterator();
while(iterator.hasNext())
{
DeployedTask task = iterator.next();
task.kill();
HandlerList.unregisterAll(task);
iterator.remove();
} }
} }
public void cleanup(Player player) public void cleanup(Player player)
{ {
_deployedInstances.get(player.getName()).kill(); _inTask.remove(player.getName());
_toCull.add(_deployedInstances.get(player.getName()));
_playersFinished.remove(player.getName());
} }
public long getDescriptionWaitTime() public long getDescriptionWaitTime()

View File

@ -24,7 +24,7 @@ public class SkipTutorialCommand extends CommandBase<TutorialManager>
} }
else 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; package mineplex.game.clans.tutorials.gettingstarted;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; 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; import mineplex.game.clans.tutorials.TutorialTask;
public class TaskClaim extends TutorialTask<TutorialGettingStarted> public class TaskClaim extends TutorialTask<TutorialGettingStarted>
@ -21,42 +20,24 @@ public class TaskClaim extends TutorialTask<TutorialGettingStarted>
_description = "Clans can claim 16x16 areas of Territory! " _description = "Clans can claim 16x16 areas of Territory! "
+ "Once claimed, only your Clan can break/place blocks here. " + "Once claimed, only your Clan can break/place blocks here. "
+ "This is the perfect place to build a base and stash your items! " + "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. " + "You can only claim in the Wilderness, and not next to other Clan's Territory. "
+ "Claim some Territory now, by typing {/c claim}!"; + "To claim some territory, go into the Clans GUI by typing {/c} and {Left-Clicking} the Territory button. (Looks like a flag)";
} }
@Override @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public DeployedTask customDeploy(Player player) public void onClansCommand(PlayerPreClaimTerritoryEvent event)
{ {
return new Deployed(player, this); if (!isDoing(event.getClaimer()))
}
class Deployed extends DeployedTask
{
public Deployed(Player player, TutorialTask<?> task)
{ {
super(player, task); return;
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) if (!ClansManager.getInstance().isInClan(event.getClaimer()))
public void onClansCommand(ClansCommandExecutedEvent event)
{ {
if (!_player.equals(event.getPlayer())) return;
{
return;
}
if (!ClansManager.getInstance().isInClan(event.getPlayer()))
{
return;
}
if (event.getCommand().equals("claim"))
{
_task.finishFor(_player);
event.setCancelled(true);
}
} }
}
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.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import mineplex.core.common.util.UtilServer;
import mineplex.game.clans.clans.event.ClanCreatedEvent; import mineplex.game.clans.clans.event.ClanCreatedEvent;
import mineplex.game.clans.tutorials.DeployedTask;
import mineplex.game.clans.tutorials.TutorialTask; import mineplex.game.clans.tutorials.TutorialTask;
public class TaskCreateClan extends TutorialTask<TutorialGettingStarted> public class TaskCreateClan extends TutorialTask<TutorialGettingStarted>
@ -17,32 +17,36 @@ public class TaskCreateClan extends TutorialTask<TutorialGettingStarted>
_displayName = "Create a Clan"; _displayName = "Create a Clan";
_technicalName = "ClanCreation"; _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 @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) finishFor(event.getFounder());
public void onClanCreated(ClanCreatedEvent event)
{
if (!_player.equals(event.getFounder()))
{
return;
}
_task.finishFor(_player);
}
} }
} }

View File

@ -1,5 +1,8 @@
package mineplex.game.clans.tutorials.gettingstarted; package mineplex.game.clans.tutorials.gettingstarted;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -9,7 +12,6 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.spawn.Spawn;
import mineplex.game.clans.tutorials.DeployedTask;
import mineplex.game.clans.tutorials.TutorialTask; import mineplex.game.clans.tutorials.TutorialTask;
import mineplex.minecraft.game.classcombat.Class.ClientClass; import mineplex.minecraft.game.classcombat.Class.ClientClass;
@ -23,47 +25,37 @@ public class TaskCustomizeClass extends TutorialTask<TutorialGettingStarted>
_technicalName = "CustomizeKlass"; _technicalName = "CustomizeKlass";
_description = "Now that you have equipped a class, use this enchantment table to customize your class builds. " _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);
}
@EventHandler(priority = EventPriority.MONITOR)
public void onUpdate(final UpdateEvent event)
{
if (!event.getType().equals(UpdateType.SEC))
{
return;
}
Iterator<String> iterator = _inTask.iterator();
while (iterator.hasNext())
{
Player player = Bukkit.getPlayer(iterator.next());
final ClientClass clientclass = ClansManager.getInstance().getClassManager().Get(player);
if (clientclass != null && clientclass.GetSavingCustomBuild() != null && clientclass.GetSavingCustomBuild().AxeSkill != null)
{
finishFor(player);
iterator.remove();
}
}
} }
@Override @Override
public DeployedTask customDeploy(Player player) public void cleanup(Player player)
{ {
return new Deployed(player, this); // handled in onUpdate
}
class Deployed extends DeployedTask
{
public Deployed(Player player, TutorialTask<?> task)
{
super(player, task);
}
@Override
public void postDeploy()
{
_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;
}
if (checkForDeath())
{
return;
}
final ClientClass clientclass = ClansManager.getInstance().getClassManager().Get(_player);
if (clientclass != null && clientclass.GetSavingCustomBuild() != null)
{
_task.finishFor(_player);
}
}
} }
} }

View File

@ -3,8 +3,8 @@ package mineplex.game.clans.tutorials.gettingstarted;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import mineplex.core.common.util.UtilServer;
import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.ClanDisbandedEvent;
import mineplex.game.clans.tutorials.DeployedTask;
import mineplex.game.clans.tutorials.TutorialTask; import mineplex.game.clans.tutorials.TutorialTask;
public class TaskDisbandClan extends TutorialTask<TutorialGettingStarted> public class TaskDisbandClan extends TutorialTask<TutorialGettingStarted>
@ -18,31 +18,25 @@ public class TaskDisbandClan extends TutorialTask<TutorialGettingStarted>
_description = "Finally, let's disband your Clan to end the Tutorial. " _description = "Finally, let's disband your Clan to end the Tutorial. "
+ "Simply type {/c disband} to do this. " + "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 @Override
public DeployedTask customDeploy(Player player) public void customStartFor(final Player player)
{ {
return new Deployed(player, this);
} }
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 System.out.println("COMPLETE DISBAND CLAN!");
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; package mineplex.game.clans.tutorials.gettingstarted;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import mineplex.core.common.util.Callback; 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.common.util.UtilItem;
import mineplex.core.task.TaskManager; import mineplex.core.task.TaskManager;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; import mineplex.game.clans.clans.event.ClansShopAddButtonEvent;
import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.spawn.Spawn;
import mineplex.game.clans.tutorials.DeployedTask;
import mineplex.game.clans.tutorials.TutorialTask; import mineplex.game.clans.tutorials.TutorialTask;
import mineplex.minecraft.game.classcombat.Class.event.ClassEquipEvent; import mineplex.minecraft.game.classcombat.Class.event.ClassEquipEvent;
@ -30,87 +27,94 @@ public class TaskEquipClass extends TutorialTask<TutorialGettingStarted>
_description = "Use the PvP Gear shop, and right-click the Villager. " _description = "Use the PvP Gear shop, and right-click the Villager. "
+ "Purchase Iron Armor from the PvP Shop. " + "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.";
// _subtasks = new String[] {
// "Open the PvP Shop",
// "Buy Iron Armor Set",
// "Equip Iron Armor"
// };
_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 @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<>(); _bought.put(player.getName(), new NautArrayList<Material>());
public Deployed(Player player, TutorialTask<?> task) if (getClans().getClassManager().Get(player).GetGameClass() != null)
{ {
super(player, task); finishFor(player);
}
}
@EventHandler
public void button(ClansShopAddButtonEvent event)
{
if (!isDoing(event.getPlayer()))
{
return;
} }
@Override if (!(UtilItem.isArmor(event.getMaterial()) && UtilItem.isIronProduct(event.getMaterial())))
public void postDeploy()
{ {
_player.teleport(new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f)); return;
} }
@EventHandler if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tuttoooooe" + event.getMaterial().name()) && !_bought.get(event.getPlayer().getName()).contains(event.getMaterial()))
public void onClassEquipped(ClassEquipEvent event)
{ {
if (!ClansManager.getInstance().getClassManager().Get(_player).equals(event.getPlayer())) event.setBuyPrice(0);
{ event.setSellPrice(0);
return; }
} }
_task.finishFor(_player); @EventHandler
public void buy(final ClansPlayerBuyItemEvent event)
{
if (!isDoing(event.getPlayer()))
{
return;
} }
@EventHandler if (!(UtilItem.isArmor(event.getItem().getType()) && UtilItem.isIronProduct(event.getItem().getType())))
public void button(ClansShopAddButtonEvent event)
{ {
if (!_player.equals(event.getPlayer())) return;
{
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 if (event.getCost() == 0 && _bought.get(event.getPlayer().getName()).contains(event.getItem().getType()))
public void buy(final ClansPlayerBuyItemEvent event)
{ {
if (!_player.equals(event.getPlayer())) event.setCancelled(true);
{ return;
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());
} }
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; package mineplex.game.clans.tutorials.gettingstarted;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; 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.ClansManager;
import mineplex.game.clans.clans.event.EnergyPageBuildEvent; import mineplex.game.clans.clans.event.EnergyPageBuildEvent;
import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.spawn.Spawn;
import mineplex.game.clans.tutorials.DeployedTask;
import mineplex.game.clans.tutorials.TutorialTask; import mineplex.game.clans.tutorials.TutorialTask;
public class TaskExploreShops extends TutorialTask<TutorialGettingStarted> public class TaskExploreShops extends TutorialTask<TutorialGettingStarted>
@ -23,65 +25,68 @@ 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. " _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. " + "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)"; + "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 @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 if (!ClansManager.getInstance().isInClan(event.getPlayer()))
public void postDeploy()
{ {
_player.teleport(new Location(Spawn.getSpawnWorld(), 17, 66.5, -330, -180f, 0f)); return;
ClansManager.getInstance().getClan(_player).adjustEnergy(-(ClansManager.getInstance().getClan(_player).getEnergyCostPerMinute() * 60));
} }
@EventHandler if (ClansManager.getInstance().getClan(event.getPlayer()).getEnergyPurchasable() == 0)
public void onItemPut(EnergyPageBuildEvent event)
{ {
if (!_player.equals(event.getPlayer())) finishFor(event.getPlayer());
{ _inTask.remove(event.getPlayer().getName());
return; return;
}
if (!ClansManager.getInstance().isInClan(_player))
{
return;
}
if (ClansManager.getInstance().getClan(_player).getEnergyPurchasable() == 0)
{
_task.finishFor(_player);
return;
}
event.setFree(true);
} }
@EventHandler event.setFree(true);
public void onUpdate(UpdateEvent event) }
{
if (event.getType() != UpdateType.TWOSEC)
{
return;
}
if (ClansManager.getInstance().getClan(_player).getEnergy() == ClansManager.getInstance().getClan(_player).getEnergyMax()) @Override
public void cleanup(Player player)
{
// handled in on update
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
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())
{ {
_task.finishFor(_player); finishFor(player);
iterator.remove();
} }
} }
} }
} }

Some files were not shown because too many files have changed in this diff Show More