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

This commit is contained in:
Jonathan Williams 2015-02-09 00:19:15 -08:00
commit 51e1798d8a
88 changed files with 2561 additions and 1310 deletions

View File

@ -0,0 +1,157 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package net.minecraft.server.v1_7_R4;
import java.io.IOException;
import java.util.Iterator;
import org.bukkit.craftbukkit.v1_7_R4.scoreboard.CraftScoreboard;
import org.bukkit.craftbukkit.v1_7_R4.util.CraftChatMessage;
import org.bukkit.scoreboard.Team;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import net.minecraft.util.com.mojang.authlib.properties.Property;
import net.minecraft.util.com.mojang.authlib.properties.PropertyMap;
public class PacketPlayOutPlayerInfo extends Packet {
public static final int ADD_PLAYER = 0;
public static final int UPDATE_GAMEMODE = 1;
public static final int UPDATE_LATENCY = 2;
public static final int UPDATE_DISPLAY_NAME = 3;
public static final int REMOVE_PLAYER = 4;
public int action;
public GameProfile player;
public int gamemode;
public int ping;
public String username;
public String _tabName;
public PacketPlayOutPlayerInfo() {
}
public static PacketPlayOutPlayerInfo addPlayer(EntityPlayer player) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
packet.action = 0;
packet.username = player.listName;
packet.player = player.getProfile();
packet.ping = player.ping;
packet.gamemode = player.playerInteractManager.getGameMode().getId();
packet._tabName = getFormattedName(player);
return packet;
}
public static PacketPlayOutPlayerInfo updatePing(EntityPlayer player) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
packet.action = 2;
packet.username = player.listName;
packet.player = player.getProfile();
packet.ping = player.ping;
return packet;
}
public static PacketPlayOutPlayerInfo updateGamemode(EntityPlayer player) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
packet.action = 1;
packet.username = player.listName;
packet.player = player.getProfile();
packet.gamemode = player.playerInteractManager.getGameMode().getId();
return packet;
}
public static PacketPlayOutPlayerInfo updateDisplayName(EntityPlayer player) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
packet.action = 3;
packet.username = player.listName;
packet.player = player.getProfile();
packet._tabName = getFormattedName(player);
return packet;
}
public static PacketPlayOutPlayerInfo removePlayer(EntityPlayer player) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
packet.action = 4;
packet.username = player.listName;
packet.player = player.getProfile();
return packet;
}
public void a(PacketDataSerializer packetdataserializer) throws IOException {
}
public void b(PacketDataSerializer packetdataserializer) throws IOException {
if(packetdataserializer.version >= 20) {
packetdataserializer.b(this.action);
packetdataserializer.b(1);
packetdataserializer.writeUUID(this.player.getId());
switch(this.action) {
case 0:
packetdataserializer.a(this.player.getName());
PropertyMap properties = this.player.getProperties();
packetdataserializer.b(properties.size());
Iterator var3 = properties.values().iterator();
while(var3.hasNext()) {
Property property = (Property)var3.next();
packetdataserializer.a(property.getName());
packetdataserializer.a(property.getValue());
packetdataserializer.writeBoolean(property.hasSignature());
if(property.hasSignature()) {
packetdataserializer.a(property.getSignature());
}
}
packetdataserializer.b(this.gamemode);
packetdataserializer.b(this.ping);
packetdataserializer.writeBoolean(this.username != null);
if(this.username != null) {
// packetdataserializer.a(ChatSerializer.a(CraftChatMessage.fromString(this.username)[0]));
packetdataserializer.a(ChatSerializer.a(CraftChatMessage.fromString(this._tabName)[0]));
}
break;
case 1:
packetdataserializer.b(this.gamemode);
break;
case 2:
packetdataserializer.b(this.ping);
break;
case 3:
packetdataserializer.writeBoolean(this.username != null);
if(this.username != null) {
// packetdataserializer.a(ChatSerializer.a(CraftChatMessage.fromString(this.username)[0]));
packetdataserializer.a(ChatSerializer.a(CraftChatMessage.fromString(this._tabName)[0]));
}
case 4:
}
} else {
packetdataserializer.a(this.username);
packetdataserializer.writeBoolean(this.action != 4);
packetdataserializer.writeShort(this.ping);
}
}
public void a(PacketPlayOutListener packetplayoutlistener) {
packetplayoutlistener.a(this);
}
public void handle(PacketListener packetlistener) {
this.a((PacketPlayOutListener)((PacketPlayOutListener)packetlistener));
}
private static String getFormattedName(EntityPlayer player)
{
String name = player.getName();
CraftScoreboard scoreboard = player.getBukkitEntity().getScoreboard();
if (scoreboard != null)
{
Team team = scoreboard.getPlayerTeam(player.getBukkitEntity());
if (team != null)
name = team.getPrefix() + name + team.getSuffix();
}
return name;
}
}

View File

@ -11,6 +11,7 @@
<orderEntry type="library" name="commons-codec" level="project" />
<orderEntry type="library" name="commons-io" level="project" />
<orderEntry type="module" module-name="Mineplex.ServerData" />
<orderEntry type="library" name="httpcore" level="project" />
<orderEntry type="library" name="httpclient" level="project" />
</component>
</module>
</module>

View File

@ -3,7 +3,7 @@ package mineplex.bungee.playerTracker;
import java.io.File;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.ServerSwitchEvent;
import net.md_5.bungee.api.event.ServerConnectedEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.event.EventHandler;
@ -26,7 +26,7 @@ public class PlayerTracker implements Listener
}
@EventHandler
public void playerConnect(final ServerSwitchEvent event)
public void playerConnect(final ServerConnectedEvent event)
{
_plugin.getProxy().getScheduler().runAsync(_plugin, new Runnable()
{

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -16,6 +16,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import net.minecraft.server.v1_7_R4.Packet;
public class UtilPlayer
{
@ -569,6 +570,11 @@ public class UtilPlayer
return ((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion() >= 47;
}
public static void sendPacket(Player player, Packet packet)
{
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
/*
public void setListName(Player player, CoreClient client)
{

View File

@ -46,7 +46,7 @@ public class UtilTextBottom
amount = 1 - amount;
//Generate Bar
int bars = 24;
int bars = 52;
String progressBar = C.cGreen + "";
boolean colorChange = false;
for (int i=0 ; i<bars ; i++)
@ -57,7 +57,7 @@ public class UtilTextBottom
colorChange = true;
}
progressBar += "";
progressBar += "|";
}
//Send to Player

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpcore-4.2.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpclient-4.2.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/commons-codec-1.6.jar"/>

View File

@ -0,0 +1,53 @@
package mineplex.core;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
public class TablistFix extends MiniPlugin
{
public TablistFix(JavaPlugin plugin)
{
super("Tablist Fix", plugin);
}
// This is sort of experimental!
@EventHandler(priority = EventPriority.MONITOR)
public void onJoin(PlayerJoinEvent event)
{
final Player player = event.getPlayer();
runSyncLater(new Runnable()
{
@Override
public void run()
{
if (!player.isOnline())
return;
PacketPlayOutPlayerInfo packet = PacketPlayOutPlayerInfo.updateDisplayName(((CraftPlayer) player).getHandle());
if (UtilPlayer.is1_8(player))
{
UtilPlayer.sendPacket(player, packet);
}
for (Player other : UtilServer.getPlayers())
{
if (other.equals(player) || !other.canSee(player))
continue;
if (UtilPlayer.is1_8(other))
UtilPlayer.sendPacket(other, packet);
}
}
}, 20L);
}
}

View File

@ -637,9 +637,12 @@ public enum Achievement
public static String getExperienceString(int level)
{
if (level < 0)
return C.cPurple + level;
if (level < 20)
return C.cGray + level;
if (level < 40)
return C.cBlue + level;

View File

@ -202,8 +202,10 @@ public class AchievementManager extends MiniPlugin
public String getMineplexLevel(Player sender, Rank rank)
{
int level = get(sender, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel();
if (rank.Has(Rank.OWNER))
if (sender.getName().equalsIgnoreCase("Phinary"))
level = -level;
else if (rank.Has(Rank.OWNER))
level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
else if (rank.Has(Rank.ADMIN))
level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());

View File

@ -1,44 +0,0 @@
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.shop.item.IButton;
public class TreasureButton implements IButton
{
private Menu _menu;
private boolean _hasEnoughChests;
private boolean _hasEnoughKeys;
private boolean _canPurchaseKey;
public TreasureButton(Menu menu, boolean hasEnoughChests, boolean hasEnoughKeys, boolean canPurchaseKey)
{
_menu = menu;
_hasEnoughChests = hasEnoughChests;
_hasEnoughKeys = hasEnoughKeys;
_canPurchaseKey = canPurchaseKey;
}
public void onClick(Player player, ClickType clickType)
{
if (clickType.isLeftClick())
{
if (_hasEnoughChests && _hasEnoughKeys)
{
_menu.openTreasure(player);
player.closeInventory();
}
else if (_hasEnoughChests && _canPurchaseKey)
{
_menu.attemptPurchaseKey(player);
}
}
else if (clickType.isRightClick())
{
if (_canPurchaseKey)
_menu.attemptPurchaseKey(player);
}
}
}

View File

@ -1,7 +1,5 @@
package mineplex.core.cosmetic.ui.page;
import java.util.ArrayList;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Creature;
@ -12,8 +10,6 @@ import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.button.OpenCostumes;
@ -23,7 +19,6 @@ import mineplex.core.cosmetic.ui.button.OpenMounts;
import mineplex.core.cosmetic.ui.button.OpenMusic;
import mineplex.core.cosmetic.ui.button.OpenParticles;
import mineplex.core.cosmetic.ui.button.OpenPets;
import mineplex.core.cosmetic.ui.button.TreasureButton;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
@ -33,7 +28,6 @@ import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ConfirmationPage;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.treasure.TreasureKey;
import mineplex.core.treasure.TreasureManager;
public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
{
@ -47,7 +41,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
@Override
protected void BuildPage()
{
AddItem(2, new ShopItem(175, DonationManager.Get(Player.getName()).getCoins() + " Coins", new String[]
AddItem(4, new ShopItem(175, DonationManager.Get(Player.getName()).getCoins() + " Coins", new String[]
{
" ",
ChatColor.RESET + C.cYellow + "Purchase Coins",
@ -60,54 +54,6 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
ChatColor.RESET + "Receives 15000 Coins per Month",
}, 1, false));
int treasureChestCount = Plugin.getInventoryManager().Get(Player).getItemCount("Treasure Chest");
int treasureKeyCount = Plugin.getInventoryManager().Get(Player).getItemCount("Treasure Key");
boolean canPurchaseKey = DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Coins) >= 1000;
ArrayList<String> lore = new ArrayList<String>();
lore.add(ChatColor.RESET + "You can find all kinds of rare");
lore.add(ChatColor.RESET + "and exciting loot inside!");
lore.add(" ");
lore.add(ChatColor.RESET + C.cYellow + "Treasure Chests: " + ChatColor.RESET + treasureChestCount);
lore.add(ChatColor.RESET + C.cYellow + "Treasure Keys: " + ChatColor.RESET + treasureKeyCount);
lore.add(" ");
if (treasureChestCount > 0 && treasureKeyCount > 0)
{
lore.add(ChatColor.RESET + C.cGreen + "Left-Click to open Treasure Chest");
lore.add(ChatColor.RESET + " Uses 1 Treasure Chest");
lore.add(ChatColor.RESET + " Uses 1 Treasure Key");
}
else if (treasureChestCount > 0)
{
lore.add(ChatColor.RESET + C.cRed + "Left-Click to open Treasure Chest");
lore.add(ChatColor.RESET + " This requires 1 Treasure Key");
lore.add(ChatColor.RESET + " You do not have any Treasure Keys");
}
else
{
lore.add(ChatColor.RESET + C.cRed + "Left-Click to open Treasure Chest");
lore.add(ChatColor.RESET + " This requires 1 Treasure Chest");
lore.add(ChatColor.RESET + " Find Treasure Chests by playing games");
}
lore.add(" ");
if (canPurchaseKey)
{
lore.add(ChatColor.RESET + C.cGreen + "Right-Click to purchase Treasure Key");
lore.add(ChatColor.RESET + " Costs 1000 Coins");
}
else
{
lore.add(ChatColor.RESET + C.cRed + "Right-Click to purchase Treasure Key");
lore.add(ChatColor.RESET + " Costs 1000 Coins");
lore.add(ChatColor.RESET + " You cannot afford a Treasure Key");
}
AddButton(4, new ShopItem(Material.CHEST, ChatColor.RESET + C.cGreen + C.Bold + "Treasure Chest", lore.toArray(new String[0]), 1, false), new TreasureButton(this, treasureChestCount > 0, treasureKeyCount > 0, canPurchaseKey));
AddButton(18, new ShopItem(Material.NETHER_STAR, "Particle Effects", 1, false), new OpenParticles(this));
AddButton(20, new ShopItem(Material.BOW, "Gadgets", 1, false), new OpenGadgets(this));
AddButton(22, new ShopItem(Material.LEATHER, "Morphs", 1, false), new OpenMorphs(this));
@ -212,19 +158,6 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
Shop.OpenPageForPlayer(player, new MusicPage(Plugin, Shop, ClientManager, DonationManager, "Music", player));
}
public void openTreasure(Player player)
{
TreasureManager treasureManager = Plugin.getTreasureManager();
if (treasureManager == null)
{
UtilPlayer.message(player, F.main("Treasure", "You cannot open Treasure Chests on this server"));
}
else
{
treasureManager.attemptOpenTreasure(player);
}
}
public void attemptPurchaseKey(Player player)
{
Shop.OpenPageForPlayer(player, new ConfirmationPage<CosmeticManager, CosmeticShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()

View File

@ -25,6 +25,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.friend.command.AddFriend;
import mineplex.core.friend.command.DeleteFriend;
import mineplex.core.friend.command.FriendsDisplay;
import mineplex.core.friend.data.FriendData;
import mineplex.core.friend.data.FriendRepository;
import mineplex.core.friend.data.FriendStatus;
@ -49,7 +50,12 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
_repository = new FriendRepository(plugin);
_portal = portal;
}
public PreferencesManager getPreferenceManager()
{
return _preferenceManager;
}
public Portal getPortal()
{
return _portal;
@ -60,6 +66,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
{
addCommand(new AddFriend(this));
addCommand(new DeleteFriend(this));
addCommand(new FriendsDisplay(this));
}
@Override
@ -107,8 +114,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
{
if (caller.getName().equalsIgnoreCase(name))
{
caller.sendMessage(F.main(getName(), ChatColor.GRAY
+ "You cannot add yourself as a friend"));
caller.sendMessage(F.main(getName(), ChatColor.GRAY + "You cannot add yourself as a friend"));
return;
}
@ -243,7 +249,6 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
});
}
@Deprecated
public void showFriends(Player caller)
{
boolean isStaff = ClientManager.Get(caller).GetRank().Has(Rank.HELPER);
@ -369,7 +374,15 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
caller.sendMessage(" ");
}
caller.sendMessage(C.cAqua + C.Strike + "=====================================================");
ChildJsonMessage message = new JsonMessage("").extra(C.cAqua + C.Strike + "======================");
message.add(C.cDAqua + "Toggle GUI").click("run_command", "/friendsdisplay");
message.hover("show_text", C.cAqua + "Toggle friends to display in a inventory");
message.add(C.cAqua + C.Strike + "======================");
message.sendToPlayer(caller);
}
@Override

View File

@ -20,7 +20,14 @@ public class AddFriend extends CommandBase<FriendManager>
{
if (args == null)
{
new FriendsGUI(Plugin, caller);
if (Plugin.getPreferenceManager().Get(caller).friendDisplayInventoryUI)
{
new FriendsGUI(Plugin, caller);
}
else
{
Plugin.showFriends(caller);
}
}
else
{

View File

@ -0,0 +1,39 @@
package mineplex.core.friend.command;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.friend.FriendManager;
import mineplex.core.friend.ui.FriendsGUI;
import mineplex.core.preferences.UserPreferences;
public class FriendsDisplay extends CommandBase<FriendManager>
{
public FriendsDisplay(FriendManager plugin)
{
super(plugin, Rank.ALL, "friendsdisplay");
}
@Override
public void Execute(Player caller, final String[] args)
{
UserPreferences preferences = Plugin.getPreferenceManager().Get(caller);
preferences.friendDisplayInventoryUI = !preferences.friendDisplayInventoryUI;
Plugin.getPreferenceManager().savePreferences(caller);
caller.playSound(caller.getLocation(), Sound.NOTE_PLING, 1, 1.6f);
if (preferences.friendDisplayInventoryUI)
{
new FriendsGUI(Plugin, caller);
}
else
{
Plugin.showFriends(caller);
}
}
}

View File

@ -1,5 +1,6 @@
package mineplex.core.friend.ui;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import org.bukkit.Material;
@ -13,7 +14,10 @@ public enum FriendPage
DELETE_FRIENDS(new ItemBuilder(Material.TNT).setTitle("Delete Friends").build(), "Delete Friends"),
SEND_REQUEST(new ItemBuilder(Material.BOOK_AND_QUILL).setTitle("Send Friend Request").build(), "Send Friend Request");
SEND_REQUEST(new ItemBuilder(Material.BOOK_AND_QUILL).setTitle("Send Friend Request").build(), "Send Friend Request"),
TOGGLE_DISPLAY(new ItemBuilder(Material.SIGN).setTitle(C.cGray + "Toggle friends to display in chat").build(),
"Toggle Display");
private ItemStack _icon;
private String _name;

View File

@ -5,20 +5,6 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilTime;
import mineplex.core.friend.FriendManager;
import mineplex.core.friend.FriendStatusType;
import mineplex.core.friend.data.FriendData;
import mineplex.core.friend.data.FriendStatus;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.itemstack.ItemLayout;
import mineplex.core.shop.item.IButton;
import net.minecraft.server.v1_7_R4.EntityPlayer;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -34,6 +20,20 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import net.minecraft.server.v1_7_R4.EntityPlayer;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilTime;
import mineplex.core.friend.FriendManager;
import mineplex.core.friend.FriendStatusType;
import mineplex.core.friend.data.FriendData;
import mineplex.core.friend.data.FriendStatus;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.itemstack.ItemLayout;
import mineplex.core.shop.item.IButton;
public class FriendsGUI implements Listener
{
@ -119,6 +119,7 @@ public class FriendsGUI implements Listener
ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0));
builder.setTitle(C.cWhite + C.Bold + friend.Name);
builder.setPlayerHead(friend.Name);
builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline"));
@ -252,12 +253,13 @@ public class FriendsGUI implements Listener
ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0));
builder.setTitle(C.cWhite + C.Bold + friend.Name);
builder.setPlayerHead(friend.Name);
builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline"));
if (friend.Online)
{
builder.addLore(C.cDGray + C.Bold + "Server: " + C.cGray + friend.ServerName);
builder.addLore(C.cGray + C.Bold + "Server: " + C.cYellow + friend.ServerName);
}
else
{
@ -320,7 +322,7 @@ public class FriendsGUI implements Listener
_page = 0;
_buttonMap.clear();
ArrayList<Integer> itemSlots = new ItemLayout("XOXOXOXOX").getItemSlots();
ArrayList<Integer> itemSlots = new ItemLayout("OXOXOXOXO").getItemSlots();
for (int i = 0; i < FriendPage.values().length; i++)
{
@ -370,6 +372,14 @@ public class FriendsGUI implements Listener
return;
}
else if (_currentPage == FriendPage.TOGGLE_DISPLAY)
{
_player.closeInventory();
CommandCenter.Instance.OnPlayerCommandPreprocess(new PlayerCommandPreprocessEvent(_player, "/friendsdisplay"));
return;
}
if (_previousPage != _currentPage)
{

View File

@ -14,6 +14,7 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.potion.Potion;
public class ItemBuilder
@ -48,6 +49,7 @@ public class ItemBuilder
// private Potion potion;
private String _title = null;
private boolean _unbreakable;
private String _playerHeadName = null;
public ItemBuilder(ItemStack item)
{
@ -172,6 +174,10 @@ public class ItemBuilder
{
((LeatherArmorMeta) meta).setColor(this._color);
}
else if (meta instanceof SkullMeta && _playerHeadName != null)
{
((SkullMeta) meta).setOwner(_playerHeadName);
}
meta.spigot().setUnbreakable(isUnbreakable());
item.setItemMeta(meta);
}
@ -357,4 +363,10 @@ public class ItemBuilder
this._unbreakable = setUnbreakable;return this;
}
public ItemBuilder setPlayerHead(String playerName)
{
_playerHeadName = playerName;
return this;
}
}

View File

@ -0,0 +1,30 @@
package mineplex.core.map;
import java.awt.Image;
import java.awt.image.BufferedImage;
import org.bukkit.entity.Player;
import org.bukkit.map.MapCanvas;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
public class ImageMapRenderer extends MapRenderer
{
private Image _image;
private boolean _first = true;
public ImageMapRenderer(BufferedImage image)
{
_image = image;
}
@Override
public void render(MapView view, MapCanvas canvas, Player player)
{
if (_image != null && _first)
{
canvas.drawImage(0, 0, _image);
_first = false;
}
}
}

View File

@ -1,46 +0,0 @@
package mineplex.core.map;
import java.awt.Image;
import java.net.URI;
import javax.imageio.ImageIO;
import org.bukkit.entity.Player;
import org.bukkit.map.MapCanvas;
import org.bukkit.map.MapPalette;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
public class ImageRenderer extends MapRenderer
{
private boolean hasRendered;
private final Image theImg;
private Thread renderImageThread;
public final String theUrl;
public ImageRenderer(String url) throws Exception
{
hasRendered = false;
theImg = ImageIO.read(URI.create(url).toURL().openStream());
theUrl = url;
}
@Override
public void render(MapView view, final MapCanvas canvas, Player plyr)
{
if(!hasRendered && theImg != null && renderImageThread == null)
{
renderImageThread = new Thread()
{
@Override
public void run()
{
canvas.drawImage(0, 0, MapPalette.resizeImage(theImg));
}
};
renderImageThread.start();
hasRendered = true;
}
}
}

View File

@ -1,138 +1,388 @@
package mineplex.core.map;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.map.commands.MapImage;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.net.URI;
import java.util.HashMap;
import javax.imageio.ImageIO;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilServer;
import net.minecraft.server.v1_7_R4.EntityItemFrame;
import net.minecraft.server.v1_7_R4.PersistentCollection;
import net.minecraft.server.v1_7_R4.WorldServer;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.entity.Hanging;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.server.MapInitializeEvent;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
import org.bukkit.plugin.java.JavaPlugin;
public class Map extends MiniPlugin
public class Map implements Listener
{
JavaPlugin Plugin;
//Private
private Player _caller = null;
private String _url = "http://chivebox.com/img/mc/news.png";
private String _defaultUrl = null;
private HashMap<ItemFrame, MapView> _maps = new HashMap<ItemFrame, MapView>();
public Map(JavaPlugin plugin)
{
super("Map", plugin);
public Map(MiniPlugin plugin, String location, Block corner1, Block corner2)
{
this(plugin, location, corner1, corner2, null);
}
Plugin = plugin;
}
public Map(MiniPlugin plugin, String location, Block corner1, Block corner2, BlockFace facingDirection)
{
@Override
public void AddCommands()
{
addCommand(new MapImage(this));
}
public ItemStack GetMap()
{
return ItemStackFactory.Instance.CreateStack(Material.MAP, (byte)127, 1, C.cAqua + C.Bold + "iMap 3.0");
}
try
{
// Make sure the world doesn't change the mapcount information
PersistentCollection collection = ((CraftWorld) corner1.getWorld()).getHandle().worldMaps;
Field f = collection.getClass().getDeclaredField("a");
f.setAccessible(true);
f.set(collection, null);
}
catch (Exception ex)
{
ex.printStackTrace();
}
public void SpawnMap(Player caller, String[] args)
{
if (args == null || args.length == 0)
{
UtilPlayer.message(_caller, F.main("Map Image", "Missing Image URL!"));
return;
}
plugin.RegisterEvents(this);
_caller = caller;
_url = args[0];
caller.getInventory().addItem(GetMap());
if (args.length > 1)
{
if (args[1].equals("all"))
{
for (Player player : UtilServer.getPlayers())
{
if (player.equals(caller))
continue;
player.getInventory().remove(Material.MAP);
// Clear out the area to make room for the picture
{
int bX = Math.min(corner1.getX(), corner2.getX());
int bY = Math.min(corner1.getY(), corner2.getY());
int bZ = Math.min(corner1.getZ(), corner2.getZ());
int tX = Math.max(corner1.getX(), corner2.getX());
int tY = Math.max(corner1.getY(), corner2.getY());
int tZ = Math.max(corner1.getZ(), corner2.getZ());
player.getInventory().addItem(GetMap());
}
}
else
{
Player target = UtilPlayer.searchOnline(caller, args[1], true);
if (target != null)
{
target.getInventory().remove(Material.MAP);
target.getInventory().addItem(GetMap());
}
}
}
}
for (int x = bX; x <= tX; x++)
{
for (int y = bY; y <= tY; y++)
{
for (int z = bZ; z <= tZ; z++)
{
Block b = corner1.getWorld().getBlockAt(x, y, z);
@EventHandler
public void MapInit(MapInitializeEvent event)
{
//Map Setup
final MapView map = event.getMap();
if (!UtilBlock.airFoliage(b))
{
b.setType(Material.AIR);
}
}
}
}
for (MapRenderer rend : map.getRenderers())
map.removeRenderer(rend);
// Remove offending hanging pictures.
for (Hanging hanging : corner1.getWorld().getEntitiesByClass(Hanging.class))
{
Location loc = hanging.getLocation();
if (_defaultUrl != null)
{
Plugin.getServer().getScheduler().runTaskAsynchronously(Plugin, new Runnable()
{
public void run()
{
try
{
map.addRenderer(new ImageRenderer(_defaultUrl));
}
catch (Exception e)
{
System.out.println("Invalid Default Image: " + _defaultUrl);
}
if (loc.getX() >= bX && loc.getX() <= tX)
{
if (loc.getY() >= bY && loc.getY() <= tY)
{
if (loc.getZ() >= bZ && loc.getZ() <= tZ)
{
hanging.remove();
}
}
}
}
}
_defaultUrl = null;
}
});
if (facingDirection == null)
{
facingDirection = getImageFace(corner1, corner2);
}
}
else if (_url != null)
{
Plugin.getServer().getScheduler().runTaskAsynchronously(Plugin, new Runnable()
{
public void run()
{
try
{
map.addRenderer(new ImageRenderer(_url));
UtilPlayer.message(_caller, F.main("Map Image", "Loaded Image: " + _url));
}
catch (Exception e)
{
UtilPlayer.message(_caller, F.main("Map Image", "Invalid Image URL: " + _url));
}
}
});
}
}
// Get the very corner of the image
Block corner = new Location(
public void SetDefaultUrl(String string)
{
_defaultUrl = string;
}
corner1.getWorld(),
Math.min(corner1.getX(), corner2.getX()),
Math.min(corner1.getY(), corner2.getY()),
Math.min(corner1.getZ(), corner2.getZ()))
.getBlock();
// Find the dimensions of the image width
int x = corner2.getX() - corner1.getX();
int z = corner2.getZ() - corner1.getZ();
// Turn it into the single largest number. If there is a 0, we are going to have a problem.
int width = Math.max(Math.abs(x), Math.abs(z)) + 1;
// Get the image height
int height = Math.abs(corner1.getY() - corner2.getY()) + 1;
corner = corner.getRelative(facingDirection.getOppositeFace());
// Load image
BufferedImage image = loadImage(location);
if (image == null)
{
throw new IllegalArgumentException("Cannot load image at '" + location + "'");
}
// Resize image to fit into the dimensions
image = toBufferedImage(image.getScaledInstance(width * 128, height * 128, Image.SCALE_SMOOTH), image.getType());
// Find out the direction to cutup the picture
boolean reversed = facingDirection.getModZ() > 0 || facingDirection.getModX() < 0;
// Cut image into 128 pixels images
BufferedImage[] imgs = cutIntoPieces(image, width, height, !reversed);
drawImage(imgs, corner, Math.abs(x), height - 1, Math.abs(z), facingDirection);
}
private BufferedImage[] cutIntoPieces(BufferedImage image, int width, int height, boolean reversed)
{
BufferedImage[] pieces = new BufferedImage[width * height]; // Image array to hold image chunks
int count = 0;
for (int x1 = 0; x1 < width; x1++)
{
int x = reversed ? (width - 1) - x1 : x1;
for (int y = 0; y < height; y++)
{
// Initialize the image array with image chunks
pieces[count] = new BufferedImage(128, 128, image.getType());
// draws the image chunk
Graphics2D gr = pieces[count++].createGraphics();
gr.drawImage(image, 0, 0, 128, 128, x * 128, y * 128, (x * 128) + 128, (y * 128) + 128, null);
gr.dispose();
}
}
return pieces;
}
private void drawImage(BufferedImage[] images, Block cornerBlock, int xSize, int ySize, int zSize, BlockFace direction)
{
int count = 0;
// Turn each subimage into a map file
for (int x = 0; x <= xSize; x++)
{
for (int z = 0; z <= zSize; z++)
{
for (int y = ySize; y >= 0; y--)
{
// Create a itemframe and set the map inside
Block b = cornerBlock.getRelative(x, y, z);
setItemFrame(b, direction, images[count++]);
}
}
}
}
/**
* Get the direction the image needs to face
*/
private BlockFace getImageFace(Block c1, Block c2)
{
// Get the center block between the two locations
Block b = c1.getWorld().getBlockAt(
Math.min(c1.getX(), c2.getX()) + ((c1.getX() + c2.getX()) / 2),
Math.min(c1.getY(), c2.getY()) + ((c1.getY() + c2.getY()) / 2),
Math.min(c1.getZ(), c2.getZ()) + ((c1.getZ() + c2.getZ()) / 2));
// Using the block as a indicator on how the rest of the blocks look, lets scan the four directions to see what blocks are
// solid.
boolean xOk = c1.getX() == c2.getX();
boolean zOk = c1.getZ() == c2.getZ();
for (int x = -1; x <= 1; x++)
{
for (int z = -1; z <= 1; z++)
{
if (x != z && (x == 0 || z == 0))
{
Block b1 = b.getRelative(x, 0, z);
if (UtilBlock.solid(b1))
{
BlockFace face = b1.getFace(b);
if ((face.getModX() != 0 && xOk) || (face.getModZ() != 0 && zOk))
{
return face;
}
}
}
}
}
return xOk ? BlockFace.EAST : BlockFace.NORTH;
}
private MapView getMap(World world, BufferedImage image)
{
MapView map = Bukkit.createMap(world);
for (MapRenderer r : map.getRenderers())
{
map.removeRenderer(r);
}
map.addRenderer(new ImageMapRenderer(image));
return map;
}
private ItemStack getMapItem(MapView map)
{
ItemStack item = new ItemStack(Material.MAP);
item.setDurability(map.getId());
return item;
}
private BufferedImage loadImage(String file)
{
File f = new File(file);
BufferedImage image = null;
try
{
if (!f.exists())
{
image = ImageIO.read(URI.create(file).toURL().openStream());
}
else
{
image = ImageIO.read(f);
}
}
catch (IOException e)
{
e.printStackTrace();
}
return image;
}
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
for (MapView map : _maps.values())
{
event.getPlayer().sendMap(map);
}
}
public void remove()
{
HandlerList.unregisterAll(this);
for (ItemFrame itemFrame : _maps.keySet())
{
itemFrame.remove();
}
}
private void setItemFrame(Block block, BlockFace face, BufferedImage image)
{
if (!UtilBlock.solid(block))
{
block.setType(Material.QUARTZ_BLOCK);
}
ItemFrame itemFrame = spawnItemFrame(block, face);
MapView map = getMap(block.getWorld(), image);
_maps.put(itemFrame, map);
ItemStack mapItem = getMapItem(map);
itemFrame.setItem(mapItem);
for (Player player : UtilServer.getPlayers())
{
player.sendMap(map);
}
}
private ItemFrame spawnItemFrame(Block block, BlockFace bf)
{
int dir;
switch (bf)
{
default:
case SOUTH:
dir = 0;
break;
case WEST:
dir = 1;
break;
case NORTH:
dir = 2;
break;
case EAST:
dir = 3;
break;
}
WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
EntityItemFrame entity = new EntityItemFrame(world, block.getX(), block.getY(), block.getZ(), dir);
entity.setDirection(dir);
world.addEntity(entity);
return (ItemFrame) entity.getBukkitEntity();
}
private BufferedImage toBufferedImage(Image img, int imageType)
{
if (img instanceof BufferedImage)
{
return (BufferedImage) img;
}
// Create a buffered image with transparency
BufferedImage bimage = new BufferedImage(img.getWidth(null), img.getHeight(null), imageType);
// Draw the image on to the buffered image
Graphics2D bGr = bimage.createGraphics();
bGr.drawImage(img, 0, 0, null);
bGr.dispose();
// Return the buffered image
return bimage;
}
}

View File

@ -1,21 +0,0 @@
package mineplex.core.map.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.map.Map;
public class MapImage extends CommandBase<Map>
{
public MapImage(Map plugin)
{
super(plugin, Rank.OWNER, new String[] {"mi"});
}
@Override
public void Execute(Player caller, String[] args)
{
Plugin.SpawnMap(caller, args);
}
}

View File

@ -6,7 +6,10 @@ import java.io.IOException;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
@ -16,7 +19,9 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.portal.Commands.*;
import mineplex.core.common.util.UtilTabTitle;
import mineplex.core.portal.Commands.SendCommand;
import mineplex.core.portal.Commands.ServerCommand;
import mineplex.serverdata.MinecraftServer;
import mineplex.serverdata.Region;
import mineplex.serverdata.ServerCommandManager;
@ -52,6 +57,15 @@ public class Portal extends MiniPlugin
// Register the server command type for future use
ServerCommandManager.getInstance().registerCommandType("TransferCommand", TransferCommand.class, new TransferHandler());
}
@EventHandler
public void join(PlayerJoinEvent event)
{
Player player = event.getPlayer();
//Player List
String serverName = _plugin.getConfig().getString("serverstatus.name");
UtilTabTitle.setHeaderAndFooter(player, C.Bold + "Mineplex Network " + C.cGreen + serverName, "Visit " + C.cGreen + "www.mineplex.com" + ChatColor.RESET + " for News, Forums and Shop");
}
public void sendAllPlayers(String serverName)
{

View File

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

View File

@ -15,7 +15,7 @@ public class PreferencesRepository extends RepositoryBase
{
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL 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 UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ? WHERE uuid=?;";
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ? WHERE uuid=?;";
public PreferencesRepository(JavaPlugin plugin, String connectionString)
{
@ -53,8 +53,9 @@ public class PreferencesRepository extends RepositoryBase
preparedStatement.setBoolean(8, entry.getValue().HubForcefield);
preparedStatement.setBoolean(9, entry.getValue().ShowMacReports);
preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity);
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
preparedStatement.setString(12, entry.getKey());
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI);
preparedStatement.setString(13, entry.getKey());
preparedStatement.addBatch();
}
@ -79,7 +80,8 @@ public class PreferencesRepository extends RepositoryBase
preparedStatement.setBoolean(9, entry.getValue().ShowMacReports);
preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity);
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
preparedStatement.setString(12, entry.getKey());
preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI);
preparedStatement.setString(13, entry.getKey());
preparedStatement.execute();
}
@ -123,6 +125,7 @@ public class PreferencesRepository extends RepositoryBase
preferences.ShowMacReports = resultSet.getBoolean(9);
preferences.IgnoreVelocity = resultSet.getBoolean(10);
preferences.PendingFriendRequests = resultSet.getBoolean(11);
preferences.friendDisplayInventoryUI = resultSet.getBoolean(12);
}
return preferences;

View File

@ -14,4 +14,5 @@ public class UserPreferences
public boolean ShowMacReports = false;
public boolean IgnoreVelocity = false;
public boolean PendingFriendRequests = true;
public boolean friendDisplayInventoryUI = true;
}

View File

@ -12,12 +12,15 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.pet.PetManager;
import mineplex.core.reward.rewards.CoinReward;
import mineplex.core.reward.rewards.InventoryReward;
import mineplex.core.reward.rewards.PetReward;
import mineplex.core.reward.rewards.RankReward;
import mineplex.core.reward.rewards.UnknownPackageReward;
public class RewardManager
@ -26,9 +29,11 @@ public class RewardManager
private HashMap<RewardRarity, List<Reward>> _treasureMap;
private Random _random;
private CoreClientManager _clientManager;
private boolean _doubleGadgetValue;
public RewardManager(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager,
public RewardManager(CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager,
int commonValueMin, int commonValueMax,
int uncommonValueMin, int uncommonValueMax,
int rareValueMin, int rareValueMax,
@ -44,6 +49,8 @@ public class RewardManager
_treasureMap.put(rarity, new ArrayList<Reward>());
}
_clientManager = clientManager;
_doubleGadgetValue = doubleGadgetValue;
addCommon(donationManager, inventoryManager, petManager, commonValueMin, commonValueMax);
@ -325,6 +332,19 @@ public class RewardManager
{
RewardRarity rarity = type.generateRarity(requiresUncommon);
//Dont give Rank Upgrade if already has Legend
if (rarity == RewardRarity.MYTHICAL)
{
if (_clientManager.Get(player).GetRank().Has(Rank.LEGEND))
{
rarity = RewardRarity.LEGENDARY;
}
else
{
return new RankReward(_clientManager, 0, rarity);
}
}
List<Reward> treasureList = _treasureMap.get(rarity);
int totalWeight = 0;

View File

@ -15,11 +15,11 @@ public enum RewardRarity
*/
OTHER("Other", cWhite),
COMMON("Common", cAqua),
UNCOMMON("Uncommon", cGreen),
RARE("Rare", cGold),
LEGENDARY("Legendary", cRed),
MYTHICAL("Mythical", C.cBlack);
COMMON("Common", cWhite),
UNCOMMON("Uncommon", cAqua),
RARE("Rare", cPurple),
LEGENDARY("Legendary", cGreen),
MYTHICAL("Mythical", cRed);
private String _name;
private String _color;

View File

@ -6,7 +6,7 @@ public enum RewardType
GameLoot( 0.000001, 0.001, 0.004, 3),
BasicChest( 0, 0.01, 0.04, 5),
HeroicChest( 0, 1, 4, 25),
LegendaryChest( 1, 2, 8, 40);
LegendaryChest( 0.5, 2.5, 10, 40);
private double _mythicalChance;
private double _legendaryChance;

View File

@ -0,0 +1,56 @@
package mineplex.core.reward.rewards;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
public class RankReward extends Reward
{
private CoreClientManager _clientManager;
public RankReward(CoreClientManager clientManager, int weight, RewardRarity rarity)
{
super(rarity, weight);
_clientManager = clientManager;
}
@Override
public RewardData giveRewardCustom(Player player)
{
Rank rank = null;
if (_clientManager.Get(player).GetRank() == Rank.ALL) rank = Rank.ULTRA;
else if (_clientManager.Get(player).GetRank() == Rank.ULTRA) rank = Rank.HERO;
else if (_clientManager.Get(player).GetRank() == Rank.HERO) rank = Rank.LEGEND;
if (rank == null)
return new RewardData(getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER));
_clientManager.Get(player).SetRank(rank);
_clientManager.getRepository().saveRank(null, player.getName(), rank, true);
return new RewardData(getRarity().getColor() + rank.Name + " Rank", new ItemStack(Material.NETHER_STAR));
}
@Override
public boolean canGiveReward(Player player)
{
return !_clientManager.Get(player).GetRank().Has(Rank.LEGEND);
}
@Override
public boolean equals(Object obj)
{
if (obj instanceof RankReward)
return true;
return false;
}
}

View File

@ -33,16 +33,4 @@ public class BlockInfo
{
return _data;
}
@Override
public int hashCode()
{
return _block.hashCode();
}
@Override
public boolean equals(Object obj)
{
return _block.equals(obj);
}
}

View File

@ -2,22 +2,15 @@ package mineplex.core.treasure;
import org.bukkit.block.Block;
import mineplex.core.reward.Reward;
/**
* Created by Shaun on 8/29/2014.
*/
public class ChestData
{
private Block _block;
private Reward _reward;
private boolean _opened;
public ChestData(Block block, Reward reward)
public ChestData(Block block)
{
_block = block;
_opened = false;
_reward = reward;
}
public boolean isOpened()
@ -35,9 +28,4 @@ public class ChestData
return _block;
}
public Reward getReward()
{
return _reward;
}
}

View File

@ -1,21 +1,20 @@
package mineplex.core.treasure;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -25,12 +24,14 @@ import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.treasure.animation.Animation;
import mineplex.core.treasure.animation.BlockChangeAnimation;
import mineplex.core.treasure.animation.ChestOpenAnimation;
import mineplex.core.treasure.animation.ChestSpawnAnimation;
import mineplex.core.treasure.animation.LegendaryAnimation;
import mineplex.core.treasure.animation.RareAnimation;
import mineplex.core.treasure.animation.LootLegendaryAnimation;
import mineplex.core.treasure.animation.LootMythicalAnimation;
import mineplex.core.treasure.animation.LootRareAnimation;
import mineplex.core.treasure.animation.TreasureRemoveAnimation;
import mineplex.core.treasure.animation.UncommonAnimation;
import mineplex.core.treasure.animation.LootUncommonAnimation;
/**
* Created by Shaun on 8/27/2014.
@ -39,135 +40,59 @@ public class Treasure
{
private BlockRestore _blockRestore;
// Decay Sets
private HashSet<BlockInfo> _wallsBlockInfo = new HashSet<>();
private HashSet<BlockInfo> _outerRingBlockInfo = new HashSet<>();
private HashSet<BlockInfo> _centerBlockInfo = new HashSet<>();
private HashSet<BlockInfo> _chestBlockInfo = new HashSet<>();
private List<BlockInfo> _chestBlockInfo = new ArrayList<BlockInfo>();
private List<BlockInfo> _openedChestBlockInfo = new ArrayList<BlockInfo>();
private List<BlockInfo> _otherBlockInfo = new ArrayList<BlockInfo>();
private Player _player;
private Random _random;
private Block _centerBlock;
private int _tickCount;
private TreasureType _treasureType;
private ChestData[] _chestData;
private int _currentChest;
private Reward[] _rewards;
private int _currentReward;
private boolean _finished;
private int _finishedTickCount;
private LinkedList<Animation> _animations;
private TreasureStyle _style;
private HologramManager _hologramManager;
public Treasure(Player player, Reward[] rewards, BlockRestore blockRestore, HologramManager hologramManager)
public Treasure(Player player, Reward[] rewards, Block centerBlock, Block[] chestBlocks, TreasureType treasureType, BlockRestore blockRestore, HologramManager hologramManager)
{
this(player, new Random(), rewards, hologramManager);
this(player, new Random(), rewards, centerBlock, chestBlocks, treasureType, hologramManager);
_blockRestore = blockRestore;
}
public Treasure(Player player, Random seed, Reward[] rewards, HologramManager hologramManager)
public Treasure(Player player, Random seed, Reward[] rewards, Block centerBlock, Block[] chestBlocks, TreasureType treasureType, HologramManager hologramManager)
{
_player = player;
_random = seed;
_style = TreasureStyle.values()[_random.nextInt(TreasureStyle.values().length)];
_treasureType = treasureType;
_centerBlock = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
_centerBlock = centerBlock;
_animations = new LinkedList<Animation>();
_hologramManager = hologramManager;
// _animations.add(new ParticleAnimation(this));
_currentChest = 0;
_currentReward = 0;
_rewards = rewards;
_chestData = new ChestData[4];
_chestData[0] = new ChestData(_centerBlock.getRelative(2, 1, 0), rewards[0]);
_chestData[1] = new ChestData(_centerBlock.getRelative(-2, 1, 0), rewards[1]);
_chestData[2] = new ChestData(_centerBlock.getRelative(0, 1, 2), rewards[2]);
_chestData[3] = new ChestData(_centerBlock.getRelative(0, 1, -2), rewards[3]);
}
private void createCenterClay()
{
for (int x = -1; x <= 1; x++)
_chestData = new ChestData[chestBlocks.length];
for (int i = 0; i < _chestData.length; i++)
{
for (int z = -1; z <= 1; z++)
{
if (Math.abs(x) == 1 || Math.abs(z) == 1)
{
Block block = _centerBlock.getRelative(x, 0, z);
_blockRestore.Restore(block);
_centerBlockInfo.add(new BlockInfo(block));
setBlock(block, _style.getPrimaryMaterial(), _style.getPrimaryData());
}
}
}
}
private void createOuterClay()
{
for (int x = -2; x <= 2; x++)
{
{
Block block = _centerBlock.getRelative(x, 0, -2);
_blockRestore.Restore(block);
_outerRingBlockInfo.add(new BlockInfo(block));
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
}
{
Block block = _centerBlock.getRelative(x, 0, 2);
_blockRestore.Restore(block);
_outerRingBlockInfo.add(new BlockInfo(block));
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
}
_chestData[i] = new ChestData(chestBlocks[i]);
}
for (int z = -1; z <= 1; z++)
{
{
Block block = _centerBlock.getRelative(-2, 0, z);
_blockRestore.Restore(block);
_outerRingBlockInfo.add(new BlockInfo(block));
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
}
{
Block block = _centerBlock.getRelative(2, 0, z);
_blockRestore.Restore(block);
_outerRingBlockInfo.add(new BlockInfo(block));
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
}
}
}
private void createWalls()
{
for (int z = -2; z <= 2; z++)
{
for (int x = -2; x <= 2; x++)
{
if ((Math.abs(x) == 2 || Math.abs(z) == 2) && (x != 0 && z != 0))
{
Block playerBlock = getPlayerBlock();
Block block = playerBlock.getRelative(x, 0, z);
_blockRestore.Restore(block);
_wallsBlockInfo.add(new BlockInfo(block));
setBlock(block, _style.getWallMaterial(), _style.getWallData());
}
}
}
if (_treasureType == TreasureType.HEROIC || _treasureType == TreasureType.LEGENDARY)
_animations.add(new BlockChangeAnimation(this, _otherBlockInfo));
}
public int getFinishedTickCount()
@ -182,59 +107,20 @@ public class Treasure
_finishedTickCount++;
}
if (_tickCount == 5)
if (_tickCount % 10 == 0 && _currentChest < _chestData.length)
{
Block block = _centerBlock;
_blockRestore.Restore(block);
_centerBlockInfo.add(new BlockInfo(block));
_centerBlockInfo.add(new BlockInfo(block.getRelative(BlockFace.DOWN)));
setBlock(block, Material.REDSTONE_LAMP_ON, (byte) 0);
setBlock(block.getRelative(BlockFace.DOWN), Material.REDSTONE_TORCH_ON, (byte) 0);
ChestSpawnAnimation chestSpawn = new ChestSpawnAnimation(this,_chestData[_currentChest].getBlock(), _chestBlockInfo, _centerBlock, _currentChest);
_animations.add(chestSpawn);
_currentChest++;
}
else if (_tickCount == 10)
{
createCenterClay();
}
else if (_tickCount == 20)
{
createOuterClay();
}
else if (_tickCount == 30)
{
createWalls();
}
else if (_tickCount == 50)
{
Block block = getPlayerBlock().getRelative(2, 0, 0);
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)4, _chestBlockInfo);
_animations.add(task);
}
else if (_tickCount == 80)
{
Block block = getPlayerBlock().getRelative(-2, 0, 0);
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)5, _chestBlockInfo);
_animations.add(task);
}
else if (_tickCount == 110)
{
Block block = getPlayerBlock().getRelative(0, 0, 2);
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)2, _chestBlockInfo);
_animations.add(task);
}
else if (_tickCount == 140)
{
Block block = getPlayerBlock().getRelative(0, 0, -2);
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)3, _chestBlockInfo);
_animations.add(task);
}
else if (_tickCount == 60 * 20)
//Auto-open after 1 minute
if (_tickCount == 60 * 20)
{
for (BlockInfo blockInfo : _chestBlockInfo)
{
Block block = blockInfo.getBlock();
openChest(block);
openChest(block, false);
}
}
@ -271,11 +157,6 @@ public class Treasure
return _centerBlock;
}
public Block getPlayerBlock()
{
return _centerBlock.getRelative(BlockFace.UP);
}
public void setBlock(Block block, Material material, byte data)
{
block.setType(material);
@ -284,41 +165,70 @@ public class Treasure
}
public void openChest(Block block)
{
openChest(block, true);
}
public void openChest(Block block, boolean swapList)
{
ChestData data = getChestData(block);
if (data != null && !data.isOpened())
if (data != null && !data.isOpened() && _currentReward < _rewards.length)
{
RewardData rewardData = data.getReward().giveReward("Treasure", _player);
Reward reward = _rewards[_currentReward];
RewardData rewardData = reward.giveReward("Treasure", _player);
_currentReward++;
if (swapList)
{
BlockInfo info = getBlockInfo(block);
_chestBlockInfo.remove(info);
_openedChestBlockInfo.add(info);
}
data.setOpened(true);
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data, rewardData, _hologramManager);
_animations.add(chestOpenTask);
// Extra effects based off the rarity of the treasure
if (data.getReward().getRarity() == RewardRarity.UNCOMMON)
if (reward.getRarity() == RewardRarity.UNCOMMON)
{
_animations.add(new UncommonAnimation(this, data.getBlock()));
_animations.add(new LootUncommonAnimation(this, data.getBlock()));
}
else if (data.getReward().getRarity() == RewardRarity.RARE)
else if (reward.getRarity() == RewardRarity.RARE)
{
_animations.add(new RareAnimation(this, data.getBlock().getLocation().add(0.5, 1.5, 0.5)));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cGold + "Rare " + rewardData.getFriendlyName()));
_animations.add(new LootRareAnimation(this, data.getBlock().getLocation().add(0.5, 1.5, 0.5)));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cPurple + "Rare " + rewardData.getFriendlyName()));
}
else if (data.getReward().getRarity() == RewardRarity.LEGENDARY)
else if (reward.getRarity() == RewardRarity.LEGENDARY)
{
_animations.add(new LegendaryAnimation(this, data.getBlock()));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cRed + "Legendary " + rewardData.getFriendlyName()));
_animations.add(new LootLegendaryAnimation(this, data.getBlock()));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cGreen + "Legendary " + rewardData.getFriendlyName()));
}
else if (reward.getRarity() == RewardRarity.MYTHICAL)
{
_animations.add(new LootMythicalAnimation(this, data.getBlock()));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cRed + "Mythical " + rewardData.getFriendlyName()));
}
if (isFinished())
{
TreasureRemoveAnimation animation = new TreasureRemoveAnimation(this, _centerBlockInfo, _outerRingBlockInfo, _wallsBlockInfo);
TreasureRemoveAnimation animation = new TreasureRemoveAnimation(this, _openedChestBlockInfo, _chestBlockInfo);
_animations.add(animation);
_finished = true;
}
}
}
public BlockInfo getBlockInfo(Block block)
{
for (BlockInfo blockInfo : _chestBlockInfo)
{
if (blockInfo.getBlock().equals(block))
return blockInfo;
}
return null;
}
public void sendChestOpenPackets(Player... players)
{
for (ChestData data : _chestData)
@ -357,35 +267,21 @@ public class Treasure
public boolean isFinished()
{
boolean allOpened = true;
for (int i = 0; i < _chestData.length; i++)
{
if (!_chestData[i].isOpened())
allOpened = false;
}
return allOpened;
return _currentReward == _rewards.length;
}
public void cleanup()
{
for (ChestData chestData : _chestData)
for (int i = _currentReward; i < _rewards.length; i++)
{
// Give any unopened rewards to the player
// This only applies if they leave the server
// while opening a treasure
if (!chestData.isOpened())
{
chestData.setOpened(true);
chestData.getReward().giveReward("Treasure", _player);
}
_rewards[_currentReward].giveReward("Treasure", _player);
}
// Remove any extra blocks
resetBlockInfo(_wallsBlockInfo);
resetBlockInfo(_centerBlockInfo);
resetBlockInfo(_outerRingBlockInfo);
resetBlockInfo(_chestBlockInfo);
resetBlockInfo(_openedChestBlockInfo);
resetBlockInfo(_otherBlockInfo);
for (Animation animation : _animations)
{
@ -394,40 +290,33 @@ public class Treasure
_animations.clear();
}
public void resetBlockInfo(Set<BlockInfo> blockInfoSet)
public void resetBlockInfo(List<BlockInfo> blockInfoSet)
{
for (BlockInfo blockInfo : blockInfoSet)
{
Block block = blockInfo.getBlock();
if (block.getType().equals(Material.CHEST))
{
UtilParticle.PlayParticle(UtilParticle.ParticleType.LARGE_SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.1F, 10);
// block.getLocation().getWorld().createExplosion(block.getLocation().add(0.5, 0.5, 0.5), 0F);
}
block.getLocation().getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
block.setTypeId(blockInfo.getId());
block.setData(blockInfo.getData());
resetBlockInfo(blockInfo);
}
blockInfoSet.clear();
}
public void resetBlockInfo(BlockInfo blockInfo)
{
Block block = blockInfo.getBlock();
if (block.getType().equals(Material.CHEST))
{
UtilParticle.PlayParticle(UtilParticle.ParticleType.LARGE_SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.1F, 10);
// block.getLocation().getWorld().createExplosion(block.getLocation().add(0.5, 0.5, 0.5), 0F);
}
block.getLocation().getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
block.setTypeId(blockInfo.getId());
block.setData(blockInfo.getData());
}
public boolean containsBlock(Block block)
{
for (BlockInfo info : _wallsBlockInfo)
if (info.getBlock().equals(block))
return true;
for (BlockInfo info : _outerRingBlockInfo)
if (info.getBlock().equals(block))
return true;
for (BlockInfo info : _centerBlockInfo)
if (info.getBlock().equals(block))
return true;
for (BlockInfo info : _chestBlockInfo)
if (info.getBlock().equals(block))
return true;
@ -435,9 +324,8 @@ public class Treasure
return false;
}
public TreasureStyle getStyle()
public TreasureType getTreasureType()
{
return _style;
return _treasureType;
}
}

View File

@ -0,0 +1,322 @@
package mineplex.core.treasure;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.event.GadgetBlockEvent;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.reward.Reward;
import mineplex.core.treasure.event.TreasureFinishEvent;
import mineplex.core.treasure.event.TreasureStartEvent;
import mineplex.core.treasure.gui.TreasureShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class TreasureLocation implements Listener
{
private TreasureManager _treasureManager;
private InventoryManager _inventoryManager;
private Hologram _hologram;
private HologramManager _hologramManager;
private Treasure _currentTreasure;
private Block _chestBlock;
private byte _chestBlockData;
private Block[] _chestSpawns;
private TreasureShop _shop;
private Location _resetLocation;
public TreasureLocation(TreasureManager treasureManager, InventoryManager inventoryManager, CoreClientManager clientManager, DonationManager donationManager, Block chestBlock, Block[] chestSpawns, Location resetLocation, HologramManager hologramManager)
{
_treasureManager = treasureManager;
_resetLocation = resetLocation;
_inventoryManager = inventoryManager;
_chestBlock = chestBlock;
_chestBlockData = _chestBlock.getData();
_chestSpawns = chestSpawns;
_hologramManager = hologramManager;
_currentTreasure = null;
_hologram = new Hologram(_hologramManager, chestBlock.getLocation().add(0.5, 2.5, 0.5), C.cGreen + C.Bold + "Open Treasure");
setHoloChestVisible(true);
_shop = new TreasureShop(treasureManager, _inventoryManager, clientManager, donationManager, this);
}
@EventHandler
public void onInteract(PlayerInteractEvent event)
{
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().equals(_chestBlock))
{
openShop(event.getPlayer());
event.setCancelled(true);
}
}
public void attemptOpenTreasure(Player player, TreasureType treasureType)
{
if (isTreasureInProgress())
{
player.sendMessage(F.main("Treasure", "Please wait for the current chest to be opened"));
return;
}
if (!chargeAccount(player, treasureType))
{
player.sendMessage(F.main("Treasure", "You dont have any chests to open!"));
return;
}
TreasureStartEvent event = new TreasureStartEvent(player);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
setHoloChestVisible(false);
if (treasureType == TreasureType.HEROIC || treasureType == TreasureType.LEGENDARY)
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + treasureType.getName()));
Reward[] rewards = _treasureManager.getRewards(player, treasureType.getRewardType());
Treasure treasure = new Treasure(player, rewards, _chestBlock, _chestSpawns, treasureType, _treasureManager.getBlockRestore(), _hologramManager);
_currentTreasure = treasure;
UtilTextMiddle.display(treasureType.getName(), "Choose 4 Chests To Open", 20, 180, 20, player);
UtilPlayer.message(player, F.main("Treasure", "Choose 4 Chests To Open"));
Location teleportLocation = treasure.getCenterBlock().getLocation().add(0.5, 0, 0.5);
teleportLocation.setPitch(player.getLocation().getPitch());
teleportLocation.setYaw(player.getLocation().getYaw());
for (Entity entity : player.getNearbyEntities(3, 3, 3))
{
UtilAction.velocity(entity, UtilAlg.getTrajectory(entity.getLocation(), treasure.getCenterBlock().getLocation()).multiply(-1), 1.5, true, 0.8, 0, 1.0, true);
}
player.teleport(teleportLocation);
}
private boolean chargeAccount(Player player, TreasureType treasureType)
{
int itemCount = _inventoryManager.Get(player).getItemCount(treasureType.getItemName());
if (itemCount > 0)
{
_inventoryManager.addItemToInventory(player, "Item", treasureType.getItemName(), -1);
return true;
}
return false;
}
private void setHoloChestVisible(boolean visible)
{
if (visible)
{
_hologram.start();
_chestBlock.setType(Material.CHEST);
_chestBlock.setData(_chestBlockData);
}
else
{
_hologram.stop();
_chestBlock.setType(Material.AIR);
}
}
public void cleanup()
{
if (_currentTreasure != null)
{
_currentTreasure.cleanup();
_currentTreasure = null;
}
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (isTreasureInProgress())
{
Treasure treasure = _currentTreasure;
treasure.update();
if (treasure.isFinished() && treasure.getFinishedTickCount() >= 80)
{
treasure.cleanup();
TreasureFinishEvent finishEvent = new TreasureFinishEvent(treasure.getPlayer(), treasure);
Bukkit.getPluginManager().callEvent(finishEvent);
}
}
}
@EventHandler
public void onTreasureFinish(TreasureFinishEvent event)
{
if (event.getTreasure().equals(_currentTreasure))
{
Player player = _currentTreasure.getPlayer();
player.teleport(_resetLocation);
_currentTreasure = null;
setHoloChestVisible(true);
}
}
@EventHandler
public void preventGadgetBlockEvent(GadgetBlockEvent event)
{
if (isTreasureInProgress())
{
List<Block> blocks = event.getBlocks();
for (Block block : blocks)
{
if (_currentTreasure.containsBlock(block))
{
event.setCancelled(true);
return;
}
}
}
}
@EventHandler(priority = EventPriority.HIGH)
public void interact(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (isTreasureInProgress())
{
if (_currentTreasure.getPlayer().equals(player))
{
if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
{
_currentTreasure.openChest(event.getClickedBlock());
}
event.setCancelled(true);
}
else if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
{
ChestData chestData = _currentTreasure.getChestData(event.getClickedBlock());
if (chestData != null)
{
event.setCancelled(true);
}
}
}
}
@EventHandler
public void inventoryOpen(InventoryOpenEvent event)
{
if (isTreasureInProgress() && event.getPlayer().equals(_currentTreasure.getPlayer()))
{
event.setCancelled(true);
}
}
@EventHandler
public void cancelMove(PlayerMoveEvent event)
{
Player player = event.getPlayer();
if (isTreasureInProgress())
{
if (_currentTreasure.getPlayer().equals(player))
{
Treasure treasure = _currentTreasure;
Location centerLocation = treasure.getCenterBlock().getLocation().add(0.5, 0.5, 0.5);
if (event.getTo().distanceSquared(centerLocation) > 9)
{
Location newTo = event.getFrom();
newTo.setPitch(event.getTo().getPitch());
newTo.setYaw(event.getTo().getYaw());
event.setTo(newTo);
}
}
else
{
Location fromLocation = event.getFrom();
Location toLocation = event.getTo();
Location centerLocation = _currentTreasure.getCenterBlock().getLocation().add(0.5, 1.5, 0.5);
double toDistanceFromCenter = centerLocation.distanceSquared(toLocation);
if (toDistanceFromCenter <= 16 && player.getVelocity().lengthSquared() < 10)
{
// Only cancel movement if they are moving towards the center
double fromDistanceFromCenter = centerLocation.distanceSquared(fromLocation);
if (toDistanceFromCenter < fromDistanceFromCenter)
{
Location spawnLocation = new Location(player.getWorld(), 0, 64, 0);
UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), spawnLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true);
event.setTo(event.getFrom());
}
}
}
}
}
@EventHandler
public void cancelVelocity(PlayerVelocityEvent event)
{
Player player = event.getPlayer();
if (isTreasureInProgress() && _currentTreasure.getPlayer().equals(player))
{
event.setCancelled(true);
}
}
@EventHandler
public void quit(PlayerQuitEvent event)
{
if (isTreasureInProgress() && _currentTreasure.getPlayer().equals(event.getPlayer()))
{
reset();
}
}
public boolean isTreasureInProgress()
{
return _currentTreasure != null;
}
public void reset()
{
cleanup();
_chestBlock.setType(Material.CHEST);
_chestBlock.setData(_chestBlockData);
_hologram.start();
}
public void openShop(Player player)
{
_shop.attemptShopOpen(player);
}
}

View File

@ -1,462 +1,132 @@
package mineplex.core.treasure;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
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.donation.DonationManager;
import mineplex.core.event.StackerEvent;
import mineplex.core.gadget.event.GadgetBlockEvent;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.pet.PetManager;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardManager;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
import mineplex.core.treasure.event.TreasureFinishEvent;
import mineplex.core.treasure.event.TreasureStartEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
/**
* Created by Shaun on 8/27/2014.
*/
public class TreasureManager extends MiniPlugin
{
private NautHashMap<Player, Treasure> _playerTreasureMap;
private RewardManager _rewardManager;
private InventoryManager _inventoryManager;
private BlockRestore _blockRestore;
private HologramManager _hologramManager;
private List<TreasureLocation> _treasureLocations;
public TreasureManager(JavaPlugin plugin, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager)
public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager)
{
super("Treasure", plugin);
_playerTreasureMap = new NautHashMap<Player, Treasure>();
_inventoryManager = inventoryManager;
_blockRestore = blockRestore;
_hologramManager = hologramManager;
_rewardManager = new RewardManager(donationManager, inventoryManager, petManager,
_rewardManager = new RewardManager(clientManager, donationManager, inventoryManager, petManager,
100, 250,
500, 1000,
1500, 2500,
6000, 12000,
true);
World world = Bukkit.getWorlds().get(0);
_treasureLocations = new ArrayList<TreasureLocation>();
{
Block chestBlock = world.getBlockAt(-19, 72, -19);
Block chestLoc1 = world.getBlockAt(-16, 72, -20);
Block chestLoc2 = world.getBlockAt(-18, 72, -22);
Block chestLoc3 = world.getBlockAt(-20, 72, -22);
Block chestLoc4 = world.getBlockAt(-22, 72, -20);
Block chestLoc5 = world.getBlockAt(-22, 72, -18);
Block chestLoc6 = world.getBlockAt(-20, 72, -16);
Block chestLoc7 = world.getBlockAt(-18, 72, -16);
Block chestLoc8 = world.getBlockAt(-16, 72, -18);
Location resetLocation = new Location(world, -23.5, 72, -23.5);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager));
}
{
Block chestBlock = world.getBlockAt(19, 72, 19);
Block chestLoc1 = world.getBlockAt(16, 72, 20);
Block chestLoc2 = world.getBlockAt(18, 72, 22);
Block chestLoc3 = world.getBlockAt(20, 72, 22);
Block chestLoc4 = world.getBlockAt(22, 72, 20);
Block chestLoc5 = world.getBlockAt(22, 72, 18);
Block chestLoc6 = world.getBlockAt(20, 72, 16);
Block chestLoc7 = world.getBlockAt(18, 72, 16);
Block chestLoc8 = world.getBlockAt(16, 72, 18);
Location resetLocation = new Location(world, 23.5, 72, 23.5);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager));
}
{
Block chestBlock = world.getBlockAt(19, 72, -19);
Block chestLoc1 = world.getBlockAt(16, 72, -20);
Block chestLoc2 = world.getBlockAt(18, 72, -22);
Block chestLoc3 = world.getBlockAt(20, 72, -22);
Block chestLoc4 = world.getBlockAt(22, 72, -20);
Block chestLoc5 = world.getBlockAt(22, 72, -18);
Block chestLoc6 = world.getBlockAt(20, 72, -16);
Block chestLoc7 = world.getBlockAt(18, 72, -16);
Block chestLoc8 = world.getBlockAt(16, 72, -18);
Location resetLocation = new Location(world, 23.5, 72, -23.5);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager));
}
{
Block chestBlock = world.getBlockAt(-19, 72, 19);
Block chestLoc1 = world.getBlockAt(-16, 72, 20);
Block chestLoc2 = world.getBlockAt(-18, 72, 22);
Block chestLoc3 = world.getBlockAt(-20, 72, 22);
Block chestLoc4 = world.getBlockAt(-22, 72, 20);
Block chestLoc5 = world.getBlockAt(-22, 72, 18);
Block chestLoc6 = world.getBlockAt(-20, 72, 16);
Block chestLoc7 = world.getBlockAt(-18, 72, 16);
Block chestLoc8 = world.getBlockAt(-16, 72, 18);
Location resetLocation = new Location(world, -23.5, 72, 23.5);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager));
}
for (TreasureLocation treasureLocation : _treasureLocations)
{
_plugin.getServer().getPluginManager().registerEvents(treasureLocation, _plugin);
}
}
@Override
public void Disable()
{
for (Treasure treasure : _playerTreasureMap.values())
for (TreasureLocation treasureLocation : _treasureLocations)
{
treasure.cleanup();
treasureLocation.cleanup();
}
}
public void attemptOpenTreasure(Player player)
public Reward[] getRewards(Player player, RewardType rewardType)
{
attemptOpenTreasure(player, false);
return _rewardManager.getRewards(player, rewardType);
}
private void attemptOpenTreasure(Player player, boolean ignoreKey)
public BlockRestore getBlockRestore()
{
if (checkNearbyBlocks(player) || checkNearSpawn(player) || checkInAir(player) || checkNearbyTreasure(player) || (!ignoreKey && checkNoTreasureAndKey(player)))
return;
TreasureStartEvent event = new TreasureStartEvent(player);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
if (!ignoreKey)
{
// Remove a treasure and a key
_inventoryManager.addItemToInventory(player, "Treasure", "Treasure Key", -1);
_inventoryManager.addItemToInventory(player, "Utility", "Treasure Chest", -1);
}
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + C.cGreen + "Treasure Chest"));
Reward[] rewards = _rewardManager.getRewards(player, RewardType.HeroicChest);
Treasure treasure = new Treasure(player, rewards, _blockRestore, _hologramManager);
_playerTreasureMap.put(player, treasure);
Location teleportLocation = treasure.getPlayerBlock().getLocation().add(0.5, 0, 0.5);
teleportLocation.setPitch(player.getLocation().getPitch());
teleportLocation.setYaw(player.getLocation().getYaw());
for (Entity entity : player.getNearbyEntities(3, 3, 3))
{
UtilAction.velocity(entity, UtilAlg.getTrajectory(entity.getLocation(), treasure.getCenterBlock().getLocation()).multiply(-1), 1.5, true, 0.8, 0, 1.0, true);
}
player.teleport(teleportLocation);
return _blockRestore;
}
private boolean checkNoTreasureAndKey(Player player)
{
int treasureCount = _inventoryManager.Get(player).getItemCount("Treasure Chest");
int treasureKeyCount = _inventoryManager.Get(player).getItemCount("Treasure Key");
if (treasureCount < 1)
{
UtilPlayer.message(player, F.main("Treasure", "You don't have any treasure chests."));
}
else if (treasureKeyCount < 1)
{
UtilPlayer.message(player, F.main("Treasure", "You don't have any treasure keys."));
}
return (treasureCount < 1 || treasureKeyCount < 1);
}
private boolean checkNearbyTreasure(Player player)
{
boolean nearTreasure = false;
for (Treasure treasure : _playerTreasureMap.values())
{
if (UtilMath.offset2d(treasure.getCenterBlock().getLocation(), player.getLocation()) <= 10)
nearTreasure = true;
}
if (nearTreasure)
UtilPlayer.message(player, F.main("Treasure", "You are too close to another players treasure."));
return nearTreasure;
}
private boolean checkNearbyBlocks(Player player)
{
//todo improve this
Block centerBlock = player.getLocation().getBlock();
for (int y = 0; y <= 3; y++)
{
for (int x = -3; x <= 3; x++)
{
for (int z = -3; z <= 3; z++)
{
Block block = centerBlock.getRelative(x, y, z);
if (UtilBlock.solid(block))
{
UtilPlayer.message(player, F.main("Treasure", "You need a clear area to open Treasure Chests."));
return true;
}
}
}
}
// Check for blocks that may disappear if modifying them
for (int y = -3; y <= 0; y++)
{
for (int x = -2; x <= 2; x++)
{
for (int z = -2; z <= 2; z++)
{
Material mat = centerBlock.getRelative(x, y, z).getType();
if (mat == Material.LADDER || mat == Material.TRAP_DOOR || mat == Material.TRIPWIRE_HOOK || mat == Material.PORTAL || mat == Material.ENDER_PORTAL)
{
UtilPlayer.message(player, F.main("Treasure", "You need a clear area to open Treasure Chests."));
return true;
}
}
}
}
// Could now check if the redstone torch can be placed on something, but its not a large deal.
return false;
}
private boolean checkInAir(Player player)
{
boolean grounded = UtilEnt.isGrounded(player);
if (!grounded)
UtilPlayer.message(player, F.main("Treasure", "You can't open chests while in the air."));
return !grounded;
}
private boolean checkNearSpawn(Player player)
{
boolean nearSpawn = UtilMath.offset2d(new Location(player.getWorld(), 0, 0, 0), player.getLocation()) < 10;
if (nearSpawn)
UtilPlayer.message(player, F.main("Treasure", "You can't open chests near spawn."));
return nearSpawn;
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<Treasure> iterator = _playerTreasureMap.values().iterator();
while(iterator.hasNext())
{
Treasure treasure = iterator.next();
treasure.update();
if (treasure.isFinished() && treasure.getFinishedTickCount() >= 80)
{
treasure.cleanup();
iterator.remove();
TreasureFinishEvent finishEvent = new TreasureFinishEvent(treasure.getPlayer(), treasure);
Bukkit.getPluginManager().callEvent(finishEvent);
}
}
}
@EventHandler
public void join(PlayerJoinEvent event)
{
final Player player = event.getPlayer();
_plugin.getServer().getScheduler().runTaskLater(_plugin, new Runnable()
{
@Override
public void run()
{
if (!player.isOnline())
return;
for (Treasure treasure : _playerTreasureMap.values())
{
treasure.sendChestOpenPackets(player);
}
}
}, 10L);
}
@EventHandler
public void quit(PlayerQuitEvent event)
{
if (_playerTreasureMap.containsKey(event.getPlayer()))
{
Treasure treasure = _playerTreasureMap.remove(event.getPlayer());
treasure.cleanup();
}
}
@EventHandler
public void cancelMove(PlayerMoveEvent event)
{
Player player = event.getPlayer();
if (_playerTreasureMap.containsKey(player))
{
Treasure treasure = _playerTreasureMap.get(player);
if (!event.getTo().getBlock().getRelative(BlockFace.DOWN).equals(treasure.getCenterBlock()))
{
Location newTo = treasure.getCenterBlock().getLocation().add(0.5, 1.1, 0.5);
newTo.setPitch(event.getTo().getPitch());
newTo.setYaw(event.getTo().getYaw());
event.setTo(newTo);
}
}
else
{
for (Treasure treasure : _playerTreasureMap.values())
{
Location fromLocation = event.getFrom();
Location toLocation = event.getTo();
Location centerLocation = treasure.getCenterBlock().getLocation().add(0.5, 1.5, 0.5);
double toDistanceFromCenter = centerLocation.distanceSquared(toLocation);
if (toDistanceFromCenter <= 9)
{
// Only cancel movement if they are moving towards the center
double fromDistanceFromCenter = centerLocation.distanceSquared(fromLocation);
if (toDistanceFromCenter < fromDistanceFromCenter)
{
UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), centerLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true);
event.setTo(event.getFrom());
}
}
}
}
}
@EventHandler
public void cancelVelocity(PlayerVelocityEvent event)
{
// Need to prevent players
Player player = event.getPlayer();
if (_playerTreasureMap.containsKey(player))
{
event.setCancelled(true);
}
}
@EventHandler
public void cancelStacker(StackerEvent event)
{
if (event.getEntity() instanceof Player)
{
Player player = ((Player) event.getEntity());
if (_playerTreasureMap.containsKey(player))
{
event.setCancelled(true);
}
}
}
@EventHandler
public void inventoryOpen(InventoryOpenEvent event)
{
// Prevent players in treasures from opening inventories
if (event.getPlayer() instanceof Player)
{
if (_playerTreasureMap.containsKey(((Player) event.getPlayer())))
{
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.HIGH)
public void interact(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (_playerTreasureMap.containsKey(player))
{
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST)
{
Treasure treasure = _playerTreasureMap.get(player);
treasure.openChest(event.getClickedBlock());
}
// Always cancel interact for treasure players, prevents players from being able to open up cosmetic menu and other menus
event.setCancelled(true);
}
else if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST)
{
for (Treasure treasure : _playerTreasureMap.values())
{
ChestData data = treasure.getChestData(event.getClickedBlock());
if (data != null)
{
event.setCancelled(true);
}
}
}
}
@EventHandler
public void preventGadgetBlockEvent(GadgetBlockEvent event)
{
List<Block> blocks = event.getBlocks();
for (Block block : blocks)
{
for (Treasure treasure : _playerTreasureMap.values())
{
if (treasure.containsBlock(block))
{
event.setCancelled(true);
return;
}
}
}
}
@EventHandler
public void treasureFinish(TreasureFinishEvent event)
{
_playerTreasureMap.remove(event.getPlayer());
}
@EventHandler
public void command(PlayerCommandPreprocessEvent event)
{
if (!event.getPlayer().isOp())
return;
if (event.getMessage().startsWith("/treasurechest"))
{
event.getPlayer().sendMessage(C.cGreen + C.Bold + "Received 10 Treasure Chest...");
_inventoryManager.addItemToInventory(event.getPlayer(), "Utility", "Treasure Chest", 10);
event.setCancelled(true);
}
if (event.getMessage().startsWith("/treasuredebug"))
{
event.getPlayer().sendMessage(C.cGreen + C.Bold + "Treasure Debug...");
attemptOpenTreasure(event.getPlayer(), true);
event.setCancelled(true);
}
if (event.getMessage().startsWith("/rewardchest") || event.getMessage().startsWith("/rewardgame"))
{
int common = 0;
int uncommon = 0;
int rare = 0;
int legend = 0;
int toTest = 10000000;
for (int i=0 ; i<toTest ; i++)
{
Reward reward = _rewardManager.nextReward(null, null, false, event.getMessage().startsWith("/rewardchest") ? RewardType.HeroicChest : RewardType.GameLoot);
if (reward.getRarity() == RewardRarity.COMMON) common++;
if (reward.getRarity() == RewardRarity.UNCOMMON) uncommon++;
if (reward.getRarity() == RewardRarity.RARE) rare++;
if (reward.getRarity() == RewardRarity.LEGENDARY) legend++;
}
event.getPlayer().sendMessage(C.cGreen + C.Bold + (event.getMessage().startsWith("/rewardchest") ? "Chest Rewards" : "Post-Game Rewards"));
event.getPlayer().sendMessage("Common: " + common + " " + UtilMath.trim(3, (double)common/(double)toTest*100d) + "%");
event.getPlayer().sendMessage("Uncommon: " + uncommon + " " + UtilMath.trim(3, (double)uncommon/(double)toTest*100d) + "%");
event.getPlayer().sendMessage("Rare: " + rare + " " + UtilMath.trim(3, (double)rare/(double)toTest*100d) + "%");
event.getPlayer().sendMessage("Legendary: " + legend + " " + UtilMath.trim(3, (double)legend/(double)toTest*100d) + "%");
event.setCancelled(true);
}
}
}

View File

@ -1,6 +1,7 @@
package mineplex.core.treasure;
import org.bukkit.Material;
import org.bukkit.Sound;
import mineplex.core.common.util.UtilParticle.ParticleType;
@ -12,103 +13,37 @@ public enum TreasureStyle
/**
* These are examples, not final!
*/
NETHER(Material.NETHERRACK, (byte) 0,
Material.NETHER_BRICK, (byte) 0,
Material.NETHER_FENCE, (byte) 0,
null,
BASIC(
ParticleType.EXPLODE,
ParticleType.EXPLODE,
Sound.FIZZ,
Sound.HORSE_ARMOR),
HEROIC(
ParticleType.FLAME,
ParticleType.LAVA),
NATURE(Material.GRASS, (byte) 0,
Material.LOG, (byte) 0,
Material.LEAVES, (byte) 0,
null,
ParticleType.LAVA,
Sound.LAVA_POP,
Sound.EXPLODE),
LEGENDARY(
ParticleType.HAPPY_VILLAGER,
ParticleType.SLIME),
ParticleType.LARGE_EXPLODE,
Sound.PORTAL_TRAVEL,
Sound.ANVIL_LAND);
WATER(Material.ICE,(byte) 9,
Material.PACKED_ICE, (byte) 5,
Material.STAINED_GLASS_PANE, (byte) 8,
null,
ParticleType.SNOW_SHOVEL,
ParticleType.SNOWBALL_POOF);
// FANCY(Material.DIAMOND_BLOCK,(byte) 0,
// Material.GOLD_BLOCK, (byte) 0,
// Material.AIR, (byte) 0,
// ParticleType.FLAME,
// ParticleType.CLOUD,
// ParticleType.LAVA),
//
// FANCY_2(Material.IRON_BLOCK,(byte) 0,
// Material.EMERALD_BLOCK, (byte) 0,
// Material.AIR, (byte) 0,
// ParticleType.FLAME,
// ParticleType.HAPPY_VILLAGER,
// null);
private Material _primaryMaterial;
private byte _primaryData;
private Material _secondaryMaterial;
private byte _secondaryData;
private Material _wallMaterial;
private byte _wallData;
private ParticleType _primaryParticle;
private ParticleType _secondaryParticle;
private ParticleType _chestSpawnParticle;
TreasureStyle(Material primaryMaterial, byte primaryData, Material secondaryMaterial, byte secondaryData, Material wallMaterial, byte wallData, ParticleType primaryParticle, ParticleType secondaryParticle, ParticleType chestSpawnParticle)
private Sound _sound;
private Sound _chestSpawnSound;
TreasureStyle(ParticleType secondaryParticle, ParticleType chestSpawnParticle, Sound sound, Sound chestSpawnSound)
{
_primaryMaterial = primaryMaterial;
_primaryData = primaryData;
_secondaryMaterial = secondaryMaterial;
_secondaryData = secondaryData;
_wallMaterial = wallMaterial;
_wallData = wallData;
_primaryParticle = primaryParticle;
_secondaryParticle = secondaryParticle;
_chestSpawnParticle = chestSpawnParticle;
}
public Material getPrimaryMaterial()
{
return _primaryMaterial;
}
public byte getPrimaryData()
{
return _primaryData;
}
public Material getSecondaryMaterial()
{
return _secondaryMaterial;
}
public byte getSecondaryData()
{
return _secondaryData;
}
public Material getWallMaterial()
{
return _wallMaterial;
}
public byte getWallData()
{
return _wallData;
}
public ParticleType getPrimaryParticle()
{
return _primaryParticle;
_sound = sound;
_chestSpawnSound = chestSpawnSound;
}
public ParticleType getSecondaryParticle()
@ -120,4 +55,14 @@ public enum TreasureStyle
{
return _chestSpawnParticle;
}
public Sound getSound()
{
return _sound;
}
public Sound getChestSpawnSound()
{
return _chestSpawnSound;
}
}

View File

@ -0,0 +1,55 @@
package mineplex.core.treasure;
import org.bukkit.Material;
import mineplex.core.common.util.C;
import mineplex.core.reward.RewardType;
public enum TreasureType
{
BASIC(C.cYellow + "Basic Chest", "Basic Chest", RewardType.BasicChest, Material.CHEST, TreasureStyle.BASIC),
HEROIC(C.cGold + "Heroic Chest", "Heroic Chest", RewardType.HeroicChest, Material.TRAPPED_CHEST, TreasureStyle.HEROIC),
LEGENDARY(C.cRed + "Legendary Chest", "Legendary Chest", RewardType.LegendaryChest, Material.ENDER_CHEST, TreasureStyle.LEGENDARY);
private final String _name;
private final RewardType _rewardType;
private final Material _material;
private final TreasureStyle _treasureStyle;
private final String _itemName;
TreasureType(String name, String itemName, RewardType rewardType, Material material, TreasureStyle treasureStyle)
{
_name = name;
_itemName = itemName;
_rewardType = rewardType;
_material = material;
_treasureStyle = treasureStyle;
}
public RewardType getRewardType()
{
return _rewardType;
}
public String getName()
{
return _name;
}
public Material getMaterial()
{
return _material;
}
public TreasureStyle getStyle()
{
return _treasureStyle;
}
public String getItemName()
{
return _itemName;
}
}

View File

@ -0,0 +1,76 @@
package mineplex.core.treasure.animation;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import mineplex.core.treasure.BlockInfo;
import mineplex.core.treasure.Treasure;
import mineplex.core.treasure.TreasureType;
public class BlockChangeAnimation extends Animation
{
private static final int MAX_RADIUS = 4;
private int _currentRadius;
private List<BlockInfo> _blockInfoList;
public BlockChangeAnimation(Treasure treasure, List<BlockInfo> blockInfoList)
{
super(treasure);
_currentRadius = 0;
_blockInfoList = blockInfoList;
}
@Override
protected void tick()
{
if (_currentRadius == MAX_RADIUS)
{
finish();
return;
}
else if (getTicks() % 10 == 0)
{
Block centerBlock = getTreasure().getCenterBlock().getRelative(BlockFace.DOWN);
for (int x = -_currentRadius; x <= _currentRadius; x++)
{
for (int y = 0; y <= _currentRadius; y++)
{
for (int z = -_currentRadius; z <= _currentRadius; z++)
{
Block b = centerBlock.getRelative(x, y, z);
if (y > 0 && (b.getType() == Material.SMOOTH_BRICK || b.getType() == Material.STEP || b.getType() == Material.SMOOTH_STAIRS))
{
_blockInfoList.add(new BlockInfo(b));
b.setType(Material.AIR);
}
else if (b.getType() == Material.SMOOTH_BRICK)
{
Material newMaterial = getTreasure().getTreasureType() == TreasureType.HEROIC ? Material.NETHER_BRICK : Material.QUARTZ_BLOCK;
_blockInfoList.add(new BlockInfo(b));
b.setType(newMaterial);
}
else if (b.getType() == Material.SMOOTH_STAIRS || b.getType() == Material.COBBLESTONE_STAIRS)
{
Material newMaterial = getTreasure().getTreasureType() == TreasureType.HEROIC ? Material.NETHER_BRICK_STAIRS : Material.QUARTZ_STAIRS;
_blockInfoList.add(new BlockInfo(b));
b.setType(newMaterial);
}
}
}
}
_currentRadius++;
}
}
@Override
protected void onFinish()
{
}
}

View File

@ -1,21 +1,25 @@
package mineplex.core.treasure.animation;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
import net.minecraft.server.v1_7_R4.TileEntity;
import net.minecraft.server.v1_7_R4.TileEntityEnderChest;
import mineplex.core.common.util.UtilServer;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager;
import mineplex.core.reward.RewardData;
import mineplex.core.treasure.ChestData;
import mineplex.core.treasure.Treasure;
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
/**
* Created by Shaun on 8/29/2014.
@ -43,6 +47,15 @@ public class ChestOpenAnimation extends Animation
for (Player other : UtilServer.getPlayers())
{
((CraftPlayer) other).getHandle().playerConnection.sendPacket(packet);
if (block.getType() == Material.ENDER_CHEST)
{
// Fix for Ender Chests closing as soon as they are opened
TileEntity tileEntity = ((CraftWorld) block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ());
if (tileEntity instanceof TileEntityEnderChest)
((TileEntityEnderChest)tileEntity).j = 1;
}
other.playSound(block.getLocation(), Sound.CHEST_OPEN, 1, 1);
}
}

View File

@ -1,39 +1,74 @@
package mineplex.core.treasure.animation;
import java.util.HashSet;
import java.util.List;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.util.Vector;
import net.minecraft.server.v1_7_R4.MathHelper;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.treasure.BlockInfo;
import mineplex.core.treasure.Treasure;
import mineplex.core.treasure.TreasureType;
/**
* Created by Shaun on 8/29/2014.
*/
public class ChestSpawnAnimation extends Animation
{
private static final int ANIMATION_DURATION = 30;
private static final int ANIMATION_DURATION = 80;
private Block _block;
private byte _direction;
private Location _centerLocation;
private Location _particleLocation;
private Vector _particleDirection;
private HashSet<BlockInfo> _chestBlockInfo;
private List<BlockInfo> _chestBlockInfo;
private double _radialOffset;
public ChestSpawnAnimation(Treasure tresure, Block block, byte direction, HashSet<BlockInfo> chestBlockInfo)
public ChestSpawnAnimation(Treasure tresure, Block block, List<BlockInfo> chestBlockInfo, Block openingCenter, double radialOffset)
{
super(tresure);
_block = block;
_direction = direction;
int relX = getTreasure().getCenterBlock().getX() - block.getX();
int relZ = getTreasure().getCenterBlock().getZ() - block.getZ();
if (Math.abs(relX) > Math.abs(relZ))
{
if (relX > 0)
_direction = (byte) 5;
else
_direction = (byte) 4;
}
else
{
if (relZ > 0)
_direction = (byte) 3;
else
_direction = (byte) 2;
}
_centerLocation = block.getLocation().clone().add(0.5, 0.5, 0.5);
_centerLocation.getWorld().playSound(_centerLocation, Sound.LAVA, 1, 1);
_chestBlockInfo = chestBlockInfo;
_particleLocation = openingCenter.getLocation().add(0.5, 4, 0.5);
_particleDirection = UtilAlg.getTrajectory(_particleLocation, _centerLocation);
_particleDirection.multiply(UtilMath.offset(_particleLocation, _centerLocation) / (double)ANIMATION_DURATION);
_radialOffset = radialOffset;
}
@Override
@ -41,24 +76,49 @@ public class ChestSpawnAnimation extends Animation
{
float scale = (float)((double)(ANIMATION_DURATION - getTicks()) / (double)ANIMATION_DURATION);
float y = 5 * scale;
double width = 1.4 * ((double) getTicks() / (double) ANIMATION_DURATION);
for (int i=0 ; i < 2 ; i++)
//Move Paticle Forwards
_particleLocation.add(_particleDirection);
//Play Particels
if (getTreasure().getTreasureType() == TreasureType.BASIC)
{
double lead = i * ((2d * Math.PI)/2);
float x = (float) (Math.sin(getTicks()/4D + lead));
float z = (float) (Math.cos(getTicks()/4D + lead));
UtilParticle.PlayParticle(getTreasure().getStyle().getSecondaryParticle(), _centerLocation.clone().add(x * width, y, z * width), 0f, 0f, 0f, 0, 1);
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation, 0.1f, 0.1f, 0.1f, 0, 1);
}
else if (getTreasure().getTreasureType() == TreasureType.HEROIC)
{
float x = (float) (Math.sin(getTicks()/4D));
float z = (float) (Math.cos(getTicks()/4D));
Location newLoc = _particleLocation.clone();
newLoc.add(UtilAlg.getLeft(_particleDirection).multiply(x * scale));
newLoc.add(UtilAlg.getUp(_particleDirection).multiply(z * scale));
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), newLoc, 0f, 0f, 0f, 0, 1);
}
else if (getTreasure().getTreasureType() == TreasureType.LEGENDARY)
{
float y = 5 * scale;
double width = 0.7 * ((double) getTicks() / (double) ANIMATION_DURATION);
for (int i=0 ; i < 2 ; i++)
{
double lead = i * ((2d * Math.PI)/2);
float x = (float) (Math.sin(getTicks()/4D + lead));
float z = (float) (Math.cos(getTicks()/4D + lead));
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation.clone().add(x * width, y, z * width), 0f, 0f, 0f, 0, 1);
}
}
//Spawn Chest
if (getTicks() >= ANIMATION_DURATION)
{
_chestBlockInfo.add(new BlockInfo(_block));
getTreasure().setBlock(_block, Material.CHEST, _direction);
_block.getLocation().getWorld().playSound(_centerLocation, Sound.ANVIL_LAND, 0.5f, 1f);
getTreasure().setBlock(_block, getTreasure().getTreasureType().getMaterial(), _direction);
_block.getLocation().getWorld().playSound(_centerLocation, getTreasure().getTreasureType().getStyle().getChestSpawnSound(), 0.5f, 1f);
UtilParticle.ParticleType particleType = getTreasure().getStyle().getChestSpawnParticle();
UtilParticle.ParticleType particleType = getTreasure().getTreasureType().getStyle().getChestSpawnParticle();
if (particleType != null)
{

View File

@ -6,6 +6,7 @@ import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import mineplex.core.common.util.UtilFirework;
@ -15,7 +16,7 @@ import mineplex.core.treasure.Treasure;
/**
* Created by shaun on 14-09-12.
*/
public class LegendaryAnimation extends Animation
public class LootLegendaryAnimation extends Animation
{
/**
* Played when a "Very Rare" chest is opened
@ -24,7 +25,7 @@ public class LegendaryAnimation extends Animation
private Random _random = new Random();
private Block _chestBlock;
public LegendaryAnimation(Treasure treasure, Block chestBlock)
public LootLegendaryAnimation(Treasure treasure, Block chestBlock)
{
super(treasure);
@ -34,18 +35,16 @@ public class LegendaryAnimation extends Animation
@Override
protected void tick()
{
if (getTicks() < 12 && getTicks() % 3 == 0)
{
UtilFirework.playFirework(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.LIME, true, true);
}
if (getTicks() == 1)
{
// _chestBlock.getLocation().getWorld().playSound(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Sound.WITHER_SPAWN, 10F, 1.2F);
_chestBlock.getLocation().getWorld().playSound(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F);
}
if (getTicks() == 20)
{
FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.RED).withFade(Color.BLACK).build();
UtilFirework.playFirework(_chestBlock.getLocation().add(0.5, 0.5, 0.5), effect);
// ((CraftWorld) _chestBlock.getWorld()).getHandle().triggerEffect(1005, _chestBlock.getX(), _chestBlock.getY(), _chestBlock.getZ(), 2257);
}
else if (getTicks() < 15)
else if (getTicks() < 35)
{
double radius = 2 - (getTicks() / 10D * 2);
int particleAmount = 20 - (getTicks() * 2);
@ -56,10 +55,10 @@ public class LegendaryAnimation extends Animation
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
Location location = _centerLocation.clone().add(xDiff, 0, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.CLOUD, location, 0, 0, 0, 0, 1);
UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0, 1);
}
}
else if (getTicks() < 20)
else if (getTicks() < 40)
{
double xDif = _random.nextGaussian() * 0.5;
double zDif = _random.nextGaussian() * 0.5;

View File

@ -0,0 +1,65 @@
package mineplex.core.treasure.animation;
import java.util.Random;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.treasure.Treasure;
/**
* Created by shaun on 14-09-12.
*/
public class LootMythicalAnimation extends Animation
{
/**
* Played when a "Very Rare" chest is opened
*/
private Random _random = new Random();
private Block _chestBlock;
public LootMythicalAnimation(Treasure treasure, Block chestBlock)
{
super(treasure);
_chestBlock = chestBlock;
}
@Override
protected void tick()
{
if (getTicks() < 30 && getTicks() % 3 == 0)
{
UtilFirework.playFirework(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true);
}
if (getTicks() == 1)
{
_chestBlock.getLocation().getWorld().playSound(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Sound.PORTAL_TRAVEL, 10F, 2.0F);
_chestBlock.getLocation().getWorld().playSound(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Sound.ZOMBIE_UNFECT, 10F, 0.1F);
}
else if (getTicks() < 60)
{
UtilFirework.launchFirework(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true,
new Vector((Math.random()-0.5)*0.05, 0.1, (Math.random()-0.5)*0.05), 1);
}
else
{
finish();
}
}
@Override
protected void onFinish()
{
}
}

View File

@ -4,6 +4,7 @@ import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
@ -12,7 +13,7 @@ import mineplex.core.treasure.Treasure;
/**
* Created by shaun on 2014-09-09.
*/
public class RareAnimation extends Animation
public class LootRareAnimation extends Animation
{
/**
* Played when a "Rare" chest is opened
@ -20,7 +21,7 @@ public class RareAnimation extends Animation
private Location _centerLocation;
public RareAnimation(Treasure treasure, Location centerLocation)
public LootRareAnimation(Treasure treasure, Location centerLocation)
{
super(treasure);
@ -32,7 +33,8 @@ public class RareAnimation extends Animation
{
if (getTicks() == 2)
{
UtilFirework.playFirework(_centerLocation, FireworkEffect.builder().withColor(Color.ORANGE).with(FireworkEffect.Type.BURST).build());
UtilFirework.playFirework(_centerLocation, Type.BALL, Color.FUCHSIA, false, false);
_centerLocation.getWorld().playSound(_centerLocation, Sound.WITHER_SPAWN, 10F, 1.2F);
}
else if (getTicks() >= 60)
@ -40,6 +42,7 @@ public class RareAnimation extends Animation
finish();
}
//Particle Ground
{
double currentRotation = getTicks() / 20D;
double radius = currentRotation;
@ -49,9 +52,10 @@ public class RareAnimation extends Animation
Location location = _centerLocation.clone().add(xDiff, yDiff, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, location, 0, 0, 0, 0, 1);
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1);
}
//Particle Spiral Up
double radius = getTicks() / 20D;
int particleAmount = getTicks() / 2;
for (int i = 0; i < particleAmount; i++)
@ -60,7 +64,7 @@ public class RareAnimation extends Animation
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
Location location = _centerLocation.clone().add(xDiff, -1.3, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, location, 0, 0, 0, 0, 1);
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1);
}
}

View File

@ -4,6 +4,7 @@ import java.util.Random;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import mineplex.core.common.util.UtilFirework;
@ -13,7 +14,7 @@ import mineplex.core.treasure.Treasure;
/**
* Created by shaun on 2014-09-09.
*/
public class UncommonAnimation extends Animation
public class LootUncommonAnimation extends Animation
{
/**
* Played when an "Uncommon" chest is opened
@ -22,7 +23,7 @@ public class UncommonAnimation extends Animation
private Random _random = new Random();
private Block _block;
public UncommonAnimation(Treasure treasure, Block block)
public LootUncommonAnimation(Treasure treasure, Block block)
{
super(treasure);
@ -37,22 +38,12 @@ public class UncommonAnimation extends Animation
if (getTicks() == 10)
{
double xDif = 0;//_random.nextGaussian() * 1;
double zDif = 0;//_random.nextGaussian() * 1;
double yDif = 2;//(_random.nextInt(3) * _random.nextDouble()) + 2;
FireworkEffect effect = FireworkEffect.builder().withColor(Color.RED)
.withFade(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255)))
.with(FireworkEffect.Type.STAR)
.build();
UtilFirework.playFirework(_block.getLocation().add(0.5, 0.5, 0.5).add(xDif, yDif, zDif), effect);
UtilFirework.playFirework(_block.getLocation().add(0.5, 0.5, 0.5), Type.BURST, Color.AQUA, false, false);
}
else if (getTicks() % 2 == 0)
{
UtilParticle.PlayParticle(UtilParticle.ParticleType.HEART, _block.getLocation().add(0.5, 1.2, 0.5), 0.5F, 0.2F, 0.5F, 0, 1);
}
}
@Override

View File

@ -54,7 +54,7 @@ public class ParticleAnimation extends Animation
{
Vector position = PATH.get(pathPosition);
UtilParticle.PlayParticle(getTreasure().getStyle().getPrimaryParticle(), getTreasure().getCenterBlock().getLocation().add(0.5, 0, 0.5).add(position), 0, 0, 0, 0, 1);
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), getTreasure().getCenterBlock().getLocation().add(0.5, 0, 0.5).add(position), 0, 0, 0, 0, 1);
pathPosition = (pathPosition + 1) % PATH.size();
}

View File

@ -1,6 +1,6 @@
package mineplex.core.treasure.animation;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import mineplex.core.treasure.BlockInfo;
@ -12,66 +12,38 @@ import mineplex.core.treasure.Treasure;
public class TreasureRemoveAnimation extends Animation
{
private Random _random = new Random();
private List<BlockInfo> _openedChests;
private List<BlockInfo> _otherChests;
private HashSet<BlockInfo> _wallsBlockInfo;
private HashSet<BlockInfo> _outerRingBlockInfo;
private HashSet<BlockInfo> _centerBlockInfo;
public TreasureRemoveAnimation(Treasure treasure, HashSet<BlockInfo> centerBlockInfo, HashSet<BlockInfo> outerRingBlockInfo, HashSet<BlockInfo> wallsBlockInfo)
public TreasureRemoveAnimation(Treasure treasure, List<BlockInfo> openedChests, List<BlockInfo> otherChests)
{
super(treasure);
_wallsBlockInfo = wallsBlockInfo;
_centerBlockInfo = centerBlockInfo;
_outerRingBlockInfo = outerRingBlockInfo;
_openedChests = openedChests;
_otherChests = otherChests;
}
@Override
protected void tick()
{
// Chests go away at 100 ticks
HashSet<BlockInfo> blockInfoSet = null;
if (getTicks() == 40)
if (getTicks() >= 20 && getTicks() % 10 == 0)
{
blockInfoSet = _wallsBlockInfo;
}
else if (getTicks() == 50)
{
blockInfoSet = _outerRingBlockInfo;
}
else if (getTicks() == 60)
{
blockInfoSet = _centerBlockInfo;
}
if (blockInfoSet != null)
{
getTreasure().resetBlockInfo(blockInfoSet);
}
/*
if (getTicks() % 2 == 0)
{
if (_blockRestoreMap.size() > 4)
if (!_otherChests.isEmpty())
{
Block block;
do
{
Block[] keyArray = _blockRestoreMap.keySet().toArray(new Block[0]);
block = keyArray[_random.nextInt(keyArray.length)];
}
while (block.getType() == Material.CHEST);
BlockInfo blockInfo = _blockRestoreMap.remove(block);
getTreasure().setBlock(block, Material.getMaterial(blockInfo.getId()), blockInfo.getData(), false);
BlockInfo info = _otherChests.remove(_random.nextInt(_otherChests.size()));
getTreasure().resetBlockInfo(info);
// System.out.println("otherchests");
}
// else if (!_openedChests.isEmpty())
// {
// System.out.println("openchests");
// BlockInfo info = _openedChests.remove(_random.nextInt(_openedChests.size()));
// getTreasure().resetBlockInfo(info);
// }
else
{
finish();
}
}
*/
}
@Override

View File

@ -0,0 +1,30 @@
package mineplex.core.treasure.gui;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.shop.item.IButton;
import mineplex.core.treasure.TreasureLocation;
import mineplex.core.treasure.TreasureType;
public class OpenTreasureButton implements IButton
{
private Player _player;
private TreasureLocation _treasureLocation;
private TreasureType _treasureType;
public OpenTreasureButton(Player player, TreasureLocation treasureLocation, TreasureType treasureType)
{
_player = player;
_treasureLocation = treasureLocation;
_treasureType = treasureType;
}
@Override
public void onClick(Player player, ClickType clickType)
{
_treasureLocation.attemptOpenTreasure(player, _treasureType);
player.closeInventory();
}
}

View File

@ -0,0 +1,73 @@
package mineplex.core.treasure.gui;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.treasure.TreasureLocation;
import mineplex.core.treasure.TreasureManager;
import mineplex.core.treasure.TreasureType;
public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
{
private TreasureLocation _treasureLocation;
private InventoryManager _inventoryManager;
public TreasurePage(TreasureManager plugin, TreasureShop shop, TreasureLocation treasureLocation, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, Player player)
{
super(plugin, shop, clientManager, donationManager, "Open Treasure", player, 9);
_treasureLocation = treasureLocation;
_inventoryManager = inventoryManager;
BuildPage();
}
@Override
protected void BuildPage()
{
int basicCount = _inventoryManager.Get(Player).getItemCount(TreasureType.BASIC.getItemName());
int heroicCount = _inventoryManager.Get(Player).getItemCount(TreasureType.HEROIC.getItemName());
int legendaryCount = _inventoryManager.Get(Player).getItemCount(TreasureType.LEGENDARY.getItemName());
List<String> basicLore = new ArrayList<String>();
basicLore.add(" ");
basicLore.add(F.value("Basic Chests Owned", "" + basicCount));
basicLore.add(" ");
if (basicCount > 0)
basicLore.add(ChatColor.RESET + "Click to open!");
List<String> heroicLore = new ArrayList<String>();
heroicLore.add(" ");
heroicLore.add(F.value("Heroic Chests Owned", "" + heroicCount));
heroicLore.add(" ");
if (heroicCount > 0)
heroicLore.add(ChatColor.RESET + "Click to open!");
List<String> legendaryLore = new ArrayList<String>();
legendaryLore.add(" ");
legendaryLore.add(F.value("Legendary Chests Owned", "" + legendaryCount));
legendaryLore.add(" ");
if (legendaryCount > 0)
legendaryLore.add(ChatColor.RESET + "Click to open!");
ShopItem basic = new ShopItem(Material.CHEST, C.cGreen + C.Bold + "Basic Chest", basicLore.toArray(new String[0]), 0, false, false);
ShopItem heroic = new ShopItem(Material.TRAPPED_CHEST, C.cGold + C.Bold + "Heroic Chest", heroicLore.toArray(new String[0]), 0, false, false);
ShopItem legendary = new ShopItem(Material.ENDER_CHEST, C.cRed + C.Bold + "Legendary Chest", legendaryLore.toArray(new String[0]), 0, false, false);
AddButton(2, basic, new OpenTreasureButton(Player, _treasureLocation, TreasureType.BASIC));
AddButton(4, heroic, new OpenTreasureButton(Player, _treasureLocation, TreasureType.HEROIC));
AddButton(6, legendary, new OpenTreasureButton(Player, _treasureLocation, TreasureType.LEGENDARY));
}
}

View File

@ -0,0 +1,30 @@
package mineplex.core.treasure.gui;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.treasure.TreasureLocation;
import mineplex.core.treasure.TreasureManager;
public class TreasureShop extends ShopBase<TreasureManager>
{
private TreasureLocation _treasureLocation;
private InventoryManager _inventoryManager;
public TreasureShop(TreasureManager plugin, InventoryManager inventoryManager, CoreClientManager clientManager, DonationManager donationManager, TreasureLocation treasureLocation)
{
super(plugin, clientManager, donationManager, "Treasure Shop");
_treasureLocation = treasureLocation;
_inventoryManager = inventoryManager;
}
@Override
protected ShopPageBase<TreasureManager, ? extends ShopBase<TreasureManager>> BuildPagesFor(Player player)
{
return new TreasurePage(Plugin, this, _treasureLocation, ClientManager, DonationManager, _inventoryManager, player);
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.ServerData"/>

View File

@ -11,6 +11,7 @@
<orderEntry type="module" module-name="Mineplex.Core.Common" />
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.ClassCombat" />
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.Core" />
<orderEntry type="module" module-name="Mineplex.ServerData" />
<orderEntry type="library" name="craftbukkit" level="project" />
</component>
</module>

View File

@ -1,5 +1,8 @@
package mineplex.game.clans;
import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_7_R4.MinecraftServer;
import mineplex.core.account.CoreClientManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.blockrestore.BlockRestore;
@ -25,9 +28,6 @@ import mineplex.core.updater.Updater;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.shop.building.BuildingShop;
import mineplex.game.clans.shop.pvp.PvpShop;
import net.minecraft.server.v1_7_R4.MinecraftServer;
import org.bukkit.plugin.java.JavaPlugin;
public class Clans extends JavaPlugin
{

View File

@ -1,8 +1,6 @@
package mineplex.game.clans.clans;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
@ -71,13 +69,12 @@ public class ClanEnergyManager extends MiniPlugin implements Runnable
_shop.attemptShopOpen(player);
}
// TODO DEBUG
@EventHandler
public void command(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().startsWith("/energyshop"))
{
openShop(event.getPlayer());
}
}
// @EventHandler
// public void command(PlayerCommandPreprocessEvent event)
// {
// if (event.getMessage().startsWith("/energyshop"))
// {
// openShop(event.getPlayer());
// }
// }
}

View File

@ -20,6 +20,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken;
import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken;
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
import mineplex.game.clans.clans.repository.tokens.ClanToken;
@ -54,11 +55,11 @@ public class ClanInfo
private long _dateCreated = 0;
private long _lastOnline = 0;
private NautHashMap<String, Boolean> _allyMap = new NautHashMap<String, Boolean>();
// Loaded from Client
private NautHashMap<String, Role> _memberMap = new NautHashMap<String, Role>();
private NautHashMap<String, Boolean> _allyMap = new NautHashMap<String, Boolean>();
private HashSet<String> _claimSet = new HashSet<String>();
private EnemyData _enemyData;
// Temporary
private NautHashMap<String, Long> _inviteeMap = new NautHashMap<String, Long>();
@ -106,6 +107,16 @@ public class ClanInfo
{
_allyMap.put(allianceToken.ClanName, allianceToken.Trusted);
}
updateEnemy(token.EnemyToken);
}
public void updateEnemy(ClanEnemyToken enemyToken)
{
if (enemyToken != null)
{
_enemyData = new EnemyData(enemyToken.EnemyName, enemyToken.Initiator, enemyToken.Score, enemyToken.Kills, enemyToken.TimeFormed);
}
}
public int getClaims()
@ -215,7 +226,8 @@ public class ClanInfo
stringList.add(F.value("Clan Energy", "" + energy));
// stringList.add(F.value("Max Energy", "" + getEnergyMax()));
stringList.add(F.value("Energy Drain/Hour", "" + costPerHour));
stringList.add(F.value("Hours Left", "" + energy / costPerHour));
if (costPerHour > 0)
stringList.add(F.value("Hours Left", "" + energy / costPerHour));
stringList.add(" ");
// Ally String
@ -259,6 +271,27 @@ public class ClanInfo
return stringList;
}
public LinkedList<String> mEnemy()
{
LinkedList<String> stringList = new LinkedList<String>();
if (_enemyData == null)
{
stringList.add(F.main("Clans", "You do not have an enemy!"));
}
else
{
stringList.add(F.main("Clans", "Enemy Details"));
String enemyName = _enemyData.getEnemyName();
EnemyData otherEnemyData = Clans.getClanUtility().getClanByClanName(enemyName).getEnemyData();
stringList.add(F.value("Enemy", _enemyData.getEnemyName()));
stringList.add(F.value("Formed", _enemyData.getRelativeTimeFormed()));
stringList.add(F.value("War Score", _enemyData.getScore() + " : " + otherEnemyData.getScore()));
}
return stringList;
}
public LinkedList<String> mTerritory()
{
LinkedList<String> stringList = new LinkedList<String>();
@ -422,6 +455,16 @@ public class ClanInfo
{
return _energy;
}
public EnemyData getEnemyData()
{
return _enemyData;
}
public boolean hasEnemy()
{
return _enemyData != null;
}
public void adjustEnergy(int energy)
{
@ -440,7 +483,6 @@ public class ClanInfo
public int getEnergyMax()
{
// TODO
// 10080 = 7 days of minutes
return 1440 + (getEnergyCostPerMinute() * 10080);
}

View File

@ -1,5 +1,7 @@
package mineplex.game.clans.clans;
import java.util.Date;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.block.Block;
@ -10,6 +12,7 @@ import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.ClanInfo.Role;
import mineplex.game.clans.clans.repository.ClanRepository;
import mineplex.game.clans.clans.repository.ClanTerritory;
import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken;
import mineplex.game.clans.clans.repository.tokens.ClanToken;
public class ClansDataAccessLayer
@ -152,6 +155,26 @@ public class ClansDataAccessLayer
_manager.log("Added Ally for [" + cB.getName() + "] and [" + cA.getName() + "] by [" + player + "].");
}
public void enemy(ClanInfo clan, ClanInfo otherClan, String player)
{
_repository.addEnemy(clan.getId(), otherClan.getId());
Date currDate = new Date();
ClanEnemyToken clanEnemyToken = new ClanEnemyToken();
clanEnemyToken.Initiator = true;
clanEnemyToken.TimeFormed = currDate;
clanEnemyToken.EnemyName = otherClan.getName();
clan.updateEnemy(clanEnemyToken);
ClanEnemyToken otherClanEnemyToken = new ClanEnemyToken();
otherClanEnemyToken.Initiator = false;
otherClanEnemyToken.TimeFormed = currDate;
otherClanEnemyToken.EnemyName = clan.getName();
otherClan.updateEnemy(otherClanEnemyToken);
_manager.log("Added Enemy for [" + clan.getName() + "] and [" + otherClan.getName() + "] by [" + player + "].");
}
public boolean trust(ClanInfo ownerClan, ClanInfo otherClan, String player)
{
if (!ownerClan.getAllyMap().containsKey(otherClan.getName()))
@ -277,6 +300,21 @@ public class ClansDataAccessLayer
//Log
_manager.log("Set Home for [" + clan.getName() + "] to " + UtilWorld.locToStrClean(loc) + " by [" + player + "].");
}
public void updateEnemy(ClanInfo clan, ClanInfo otherClan)
{
assert clan.getEnemyData() != null && otherClan.getEnemyData() != null;
assert clan.getEnemyData().getEnemyName() == otherClan.getName() && otherClan.getEnemyData().getEnemyName() == clan.getName();
ClanInfo initiator = clan.getEnemyData().isInitiator() ? clan : otherClan;
EnemyData iData = initiator.getEnemyData();
ClanInfo other = clan == initiator ? otherClan : clan;
EnemyData oData = other.getEnemyData();
_repository.updateEnemy(initiator.getId(), other.getId(), iData.getScore(), oData.getScore(), iData.getKills(), oData.getKills());
//Log
_manager.log("Updated Enemy Data for [" + clan.getName() + ", " + otherClan.getName() + "]");
}
public void updateEnergy(ClanInfo clan)
{

View File

@ -23,9 +23,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.blockrestore.BlockRestoreData;
import mineplex.core.common.util.C;
@ -38,12 +35,14 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.creature.event.CreatureSpawnCustomEvent;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo.Role;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class ClansGame extends MiniPlugin
{
@ -172,7 +171,7 @@ public class ClansGame extends MiniPlugin
@EventHandler(priority = EventPriority.LOW)
public void BlockBreak(BlockBreakEvent event)
{
if (event.isCancelled() || event.getPlayer().getWorld().getEnvironment() != Environment.NORMAL)
if (event.isCancelled() || event.getPlayer().getWorld().getEnvironment() != Environment.NORMAL || event.getPlayer().getGameMode() == GameMode.CREATIVE)
return;
String mimic = Clans.Get(event.getPlayer()).getMimic();

View File

@ -1,6 +1,7 @@
package mineplex.game.clans.clans;
import java.util.HashSet;
import java.util.TimeZone;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -34,10 +35,12 @@ import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
import mineplex.game.clans.clans.commands.ClansChatCommand;
import mineplex.game.clans.clans.commands.ClansCommand;
import mineplex.game.clans.clans.commands.ServerTimeCommand;
import mineplex.game.clans.clans.repository.ClanTerritory;
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
import mineplex.game.clans.clans.repository.tokens.ClanToken;
import mineplex.game.clans.clans.war.WarManager;
import mineplex.game.clans.fields.Field;
import mineplex.game.clans.gameplay.Gameplay;
import mineplex.minecraft.game.classcombat.Class.ClassManager;
@ -56,6 +59,8 @@ import mineplex.minecraft.game.core.mechanics.Weapon;
public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelation
{
private static final TimeZone TIME_ZONE = TimeZone.getDefault();
private String _serverName;
private CoreClientManager _clientManager;
@ -71,6 +76,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
private ConditionManager _condition;
private ClassCombatShop _classShop;
private ClassManager _classManager;
private WarManager _warManager;
private int _inviteExpire = 2;
private int _nameMin = 3;
@ -135,6 +141,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager);
_classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop");
_warManager = new WarManager(plugin, this);
ClanEnergyManager clanEnergyManager = new ClanEnergyManager(plugin, this, clientManager, donationManager);
for (ClanToken token : _clanDataAccess.getRepository().retrieveClans())
@ -156,6 +164,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
addCommand(new ClansCommand(this));
addCommand(new ClansChatCommand(this));
addCommand(new ClansAllyChatCommand(this));
addCommand(new ServerTimeCommand(this));
}
public int getInviteExpire()
@ -484,6 +493,11 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
return _classShop;
}
public WarManager getWarManager()
{
return _warManager;
}
public int convertGoldToEnergy(int gold)
{
return gold * 4;
@ -493,4 +507,15 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
{
return (energy / 4) + (energy % 4 == 0 ? 0 : 1);
}
/**
* Get the timezone for this server.
* This may be used in the future if we have
* clans servers with varying timezones.
* @return {@link java.util.TimeZone} that this server should run at
*/
public TimeZone getServerTimeZone()
{
return TIME_ZONE;
}
}

View File

@ -0,0 +1,65 @@
package mineplex.game.clans.clans;
import java.util.Date;
import mineplex.core.common.util.UtilTime;
public class EnemyData
{
private String _enemy;
private boolean _initiator;
private int _score;
private int _kills;
private Date _timeFormed;
public EnemyData(String enemy, boolean initiator, int score, int kills, Date timeFormed)
{
_enemy = enemy;
_initiator = initiator;
_score = score;
_kills = kills;
_timeFormed = timeFormed;
}
public String getEnemyName()
{
return _enemy;
}
public int getScore()
{
return _score;
}
public int getKills()
{
return _kills;
}
public void addScore(int add)
{
_score = Math.max(0, Math.min(_score + add, 40));
}
public void addKill()
{
_kills++;
}
public boolean isInitiator()
{
return _initiator;
}
public Date getTimeFormed()
{
return _timeFormed;
}
public String getRelativeTimeFormed()
{
long timeFormed = _timeFormed.getTime();
long currentTime = System.currentTimeMillis();
return UtilTime.convertString(System.currentTimeMillis() - timeFormed, 1, UtilTime.TimeUnit.FIT);
}
}

View File

@ -14,8 +14,8 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.recharge.Recharge;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClanInfo.Role;
@ -97,6 +97,9 @@ public class ClansCommand extends CommandBase<ClansManager>
else if (args[0].equalsIgnoreCase("sethome"))
homeSet(caller);
else if (args[0].equalsIgnoreCase("enemy") || args[0].equals("e"))
enemy(caller, args);
else if (args[0].equalsIgnoreCase("territory") || args[0].equalsIgnoreCase("t"))
infoTerritory(caller, args);
@ -110,6 +113,43 @@ public class ClansCommand extends CommandBase<ClansManager>
infoClan(caller, args[0]);
}
public void enemy(Player caller, String[] args)
{
if (args.length == 2)
{
ClanInfo playerClan = Plugin.getClanUtility().getClanByPlayer(caller);
ClanInfo otherClan = Plugin.getClanUtility().searchClan(caller, args[1], true);
if (playerClan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return;
}
else if (otherClan == null)
{
return;
}
attemptEnemy(caller, playerClan, otherClan);
}
else
{
infoEnemy(caller);
}
}
private void attemptEnemy(Player caller, ClanInfo initiatorClan, ClanInfo otherClan)
{
Plugin.getWarManager().attemptEnemy(caller, initiatorClan, otherClan);
}
private void infoEnemy(Player caller)
{
ClanInfo playerClan = Plugin.getClanUtility().getClanByPlayer(caller);
UtilPlayer.message(caller, playerClan.mEnemy());
}
public void commandChat(Player caller, String[] args)
{
if (args.length == 0)

View File

@ -0,0 +1,22 @@
package mineplex.game.clans.clans.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.ClansManager;
public class ServerTimeCommand extends CommandBase<ClansManager>
{
public ServerTimeCommand(ClansManager plugin)
{
super(plugin, Rank.ALL, "servertime", "t");
}
@Override
public void Execute(Player caller, String[] args)
{
UtilPlayer.message(caller, Plugin.getWarManager().mServerTime());
}
}

View File

@ -3,6 +3,7 @@ package mineplex.game.clans.clans.repository;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Date;
import java.util.UUID;
import org.bukkit.plugin.java.JavaPlugin;
@ -16,6 +17,7 @@ import mineplex.core.database.column.ColumnLong;
import mineplex.core.database.column.ColumnVarChar;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken;
import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken;
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
import mineplex.game.clans.clans.repository.tokens.ClanToken;
@ -30,6 +32,7 @@ public class ClanRepository extends RepositoryBase
private static String RETRIEVE_START_CLAN_INFO = "SELECT c.id, c.name, c.description, c.home, c.admin, c.energy, c.dateCreated, c.lastOnline, ct.chunk, ct.safe FROM clans AS c LEFT JOIN clanTerritory AS ct ON ct.clanId = c.id WHERE c.serverName = ?;";
private static String RETRIEVE_CLAN_MEMBER_INFO = "SELECT c.name, a.name, a.uuid, clanRole FROM accountClan AS ac INNER JOIN accounts AS a ON a.id = ac.accountId INNER JOIN clans AS c on c.id = ac.clanId WHERE c.serverName = ?;";
private static String RETRIEVE_CLAN_ALLIANCE_INFO = "SELECT c.name, cOther.name, ca.trusted FROM clanAlliances AS ca INNER JOIN clans AS c ON c.id = ca.clanId INNER JOIN clans as cOther ON cOther.id = ca.otherClanId WHERE c.serverName = ?;";
private static String RETRIEVE_CLAN_ENEMY_INFO = "SELECT c.name, cOther.name, clanScore, otherClanScore, clanKills, otherClanKills, timeFormed FROM clanEnemies AS ce INNER JOIN clans AS c ON c.id = ce.clanId INNER JOIN clans as cOther ON cOther.id = ce.otherClanId WHERE c.serverName = ?;";
private static String DELETE_CLAN_MEMBER = "DELETE aC FROM accountClan AS aC INNER JOIN accounts ON accounts.id = aC.accountId WHERE aC.clanId = ? AND accounts.name = ?;";
private static String DELETE_CLAN_MEMBERS = "DELETE FROM accountClan WHERE clanId = ?;";
@ -37,16 +40,19 @@ public class ClanRepository extends RepositoryBase
private static String DELETE_CLAN_TERRITORIES = "DELETE FROM clanTerritory WHERE clanId = ?;";
private static String DELETE_CLAN_ALLIANCE = "DELETE FROM clanAlliances WHERE clanId = ? AND otherClanId = ?;";
private static String DELETE_CLAN_ALLIANCES = "DELETE FROM clanAlliances WHERE clanId = ? OR otherClanId = ?;";
private static String DELETE_CLAN_ENEMY = "DELETE FROM clanEnemies WHERE clanId = ? OR otherClanId = ?;";
private static String DELETE_CLAN = "DELETE FROM clans WHERE id = ?;";
private static String ADD_CLAN = "INSERT INTO clans (serverName, name, description, home, admin, dateCreated, energy, lastOnline) VALUES (?, ?, ?, ?, ?, now(), ?, now());";
private static String ADD_CLAN_MEMBER = "INSERT INTO accountClan (accountId, clanId, clanRole) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.name = ?;";
private static String ADD_CLAN_ALLIANCE = "INSERT INTO clanAlliances (clanId, otherClanId, trusted) VALUES (?, ?, ?);";
private static String ADD_CLAN_ENEMY = "INSERT INTO clanEnemies (clanId, otherClanId, timeFormed) VALUES (?, ?, now());";
private static String ADD_CLAN_TERRITORY = "INSERT INTO clanTerritory (clanId, serverName, chunk, safe) VALUES (?, ?, ?, ?);";
private static String UPDATE_CLAN = "UPDATE clans SET name = ?, description = ?, home = ?, admin = ?, energy = ?, lastOnline = ? WHERE id = ?;";
private static String UPDATE_CLAN_MEMBER = "UPDATE accountClan AS AC INNER JOIN accounts ON accounts.id = AC.accountId SET AC.clanRole = ? WHERE AC.clanId = ? AND accounts.name = ?;";
private static String UPDATE_CLAN_ALLIANCE = "UPDATE clanAlliances SET trusted = ? WHERE clanId = ? AND otherClanId = ?;";
private static String UPDATE_CLAN_ENEMY = "UPDATE clanEnemies SET clanScore = ?, otherClanScore = ?, clanKills = ?, otherClanKills = ? WHERE clanId = ? AND otherClanId = ?;";
private static String UPDATE_CLAN_TERRITORY = "UPDATE clanTerritory SET safe = ? WHERE serverName = ? AND chunk = ?;";
private String _serverName;
@ -149,6 +155,44 @@ public class ClanRepository extends RepositoryBase
}
}, new ColumnVarChar("serverName", 100, _serverName));
executeQuery(RETRIEVE_CLAN_ENEMY_INFO, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
while (resultSet.next())
{
ClanEnemyToken clanToken = new ClanEnemyToken();
ClanEnemyToken otherClanToken = new ClanEnemyToken();
//c.name, cOther.name, clanScore, otherClanScore, clanKills, otherClanKills
String clanName = resultSet.getString(1);
String otherClanName = resultSet.getString(2);
int clanScore = resultSet.getInt(3);
int otherClanScore = resultSet.getInt(4);
int clanKills = resultSet.getInt(5);
int otherClanKills = resultSet.getInt(6);
Date timeFormed = resultSet.getTimestamp(7);
clanToken.EnemyName = otherClanName;
clanToken.Score = clanScore;
clanToken.Kills = clanKills;
clanToken.Initiator = true;
clanToken.TimeFormed = timeFormed;
otherClanToken.EnemyName = clanName;
otherClanToken.Score = otherClanScore;
otherClanToken.Kills = otherClanKills;
otherClanToken.Initiator = false;
otherClanToken.TimeFormed = timeFormed;
clans.get(clanName).EnemyToken = clanToken;
clans.get(otherClanName).EnemyToken = otherClanToken;
}
}
}, new ColumnVarChar("serverName", 100, _serverName));
return clans.values();
}
@ -163,6 +207,7 @@ public class ClanRepository extends RepositoryBase
executeUpdate(DELETE_CLAN_MEMBERS, new ColumnInt("clanid", clanId));
executeUpdate(DELETE_CLAN_TERRITORIES, new ColumnInt("clanid", clanId));
executeUpdate(DELETE_CLAN_ALLIANCES, new ColumnInt("clanid", clanId), new ColumnInt("clanid", clanId));
executeUpdate(DELETE_CLAN_ENEMY, new ColumnInt("clanid", clanId));
executeUpdate(DELETE_CLAN, new ColumnInt("clanid", clanId));
}
@ -218,6 +263,11 @@ public class ClanRepository extends RepositoryBase
executeUpdate(ADD_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("chunk", 100, chunk), new ColumnBoolean("safe", safe));
}
public void addEnemy(int clanId, int otherClanId)
{
executeUpdate(ADD_CLAN_ENEMY, new ColumnInt("clanId", clanId), new ColumnInt("otherClanId", otherClanId));
}
public void removeTerritoryClaim(int clanId, String chunk)
{
executeUpdate(DELETE_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("chunk", 100, chunk));
@ -228,6 +278,13 @@ public class ClanRepository extends RepositoryBase
executeUpdate(UPDATE_CLAN, new ColumnVarChar("name", 100, name), new ColumnVarChar("desc", 100, desc), new ColumnVarChar("home", 100, home), new ColumnBoolean("admin", admin), new ColumnInt("energy", energy), new ColumnLong("lastOnline", lastOnline), new ColumnInt("clanId", clanId));
}
public void updateEnemy(int clanId, int otherClanId, int clanScore, int otherClanScore, int clanKills, int otherClanKills)
{
executeUpdate(UPDATE_CLAN_ENEMY, new ColumnInt("clanId", clanId), new ColumnInt("otherClanId", otherClanId),
new ColumnInt("clanScore", clanScore), new ColumnInt("otherClanScore", otherClanScore), new ColumnInt("clanKills", clanKills),
new ColumnInt("otherClanKills", otherClanKills), new ColumnInt("clanId", clanId), new ColumnInt("otherClanId", otherClanId));
}
public void updateTerritoryClaim(String chunk, boolean safe)
{
executeUpdate(UPDATE_CLAN_TERRITORY, new ColumnBoolean("safe", safe), new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("chunk", 100, chunk));

View File

@ -0,0 +1,12 @@
package mineplex.game.clans.clans.repository.tokens;
import java.util.Date;
public class ClanEnemyToken
{
public boolean Initiator;
public String EnemyName;
public int Score;
public int Kills;
public Date TimeFormed;
}

View File

@ -13,6 +13,8 @@ public class ClanToken
public int Energy;
public long DateCreated;
public long LastOnline;
public ClanEnemyToken EnemyToken;
public List<ClanMemberToken> Members = new ArrayList<ClanMemberToken>();
public List<ClanTerritoryToken> Territories = new ArrayList<ClanTerritoryToken>();

View File

@ -0,0 +1,258 @@
package mineplex.game.clans.clans.war;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.LinkedList;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
public class WarManager extends MiniPlugin
{
private static final int INVADE_ENEMY_DATE = Calendar.SATURDAY;
private static final int CREATE_ENEMY_DATE = Calendar.SUNDAY;
private final ClansManager _clansManager;
private WarState _warState;
public WarManager(JavaPlugin plugin, ClansManager clansManager)
{
super("War Manager", plugin);
_clansManager = clansManager;
_warState = calculateWarState();
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOWEST)
return;
WarState currentState = calculateWarState();
if (currentState != _warState)
{
WarStateChangeEvent warEvent = new WarStateChangeEvent(_warState, currentState);
UtilServer.getServer().getPluginManager().callEvent(warEvent);
_warState = currentState;
}
}
private WarState calculateWarState()
{
// Get a calendar snapshot of the current time using server timezone
Calendar calendar = Calendar.getInstance(_clansManager.getServerTimeZone());
WarState warState = WarState.WAR;
if (isEnemyTime(calendar))
warState = WarState.FORM_ENEMIES;
else if (isInvadeTime(calendar))
warState = WarState.INVADE;
return warState;
}
public void attemptEnemy(Player player, ClanInfo initiatingClan, ClanInfo otherClan)
{
attemptEnemy(player, initiatingClan, otherClan, true);
}
public void attemptEnemy(Player player, ClanInfo initiatingClan, ClanInfo otherClan, boolean notify)
{
String notifyMessage = null;
if (_warState != WarState.FORM_ENEMIES)
{
notifyMessage = "Enemies cannot be formed at this time. Please see mineplex.com/clans for info";
}
else if (initiatingClan.getEnemyData() != null)
{
notifyMessage = "Your clan already has an enemy.";
}
else if (otherClan.getEnemyData() != null)
{
notifyMessage = "The clan " + F.elem(otherClan.getName()) + " already has an enemy.";
}
else
{
_clansManager.getClanDataAccess().enemy(initiatingClan, otherClan, player.getName());
_clansManager.messageClan(initiatingClan, F.main("Clans", "Your clan is now enemies with " + F.elem(otherClan.getName())));
_clansManager.messageClan(otherClan, F.main("Clans", "Your clan is now enemies with " + F.elem(initiatingClan.getName())));
}
if (notify && notifyMessage != null)
UtilPlayer.message(player, F.main("Clans", notifyMessage));
}
@EventHandler
public void handleDeath(PlayerDeathEvent event)
{
Player player = event.getEntity();
Player killer = player.getKiller();
ClanInfo playerClan = _clansManager.getClan(player);
ClanInfo killerClan = _clansManager.getClan(killer);
if (playerClan != null && killerClan != null)
{
if (playerClan.getEnemyData() != null && playerClan.getEnemyData().getEnemyName().equalsIgnoreCase(killerClan.getName()))
{
// Only adjust score if we are in WAR or FORM ENEMIES state. Once invasion begins score should never change
// Adjust kill stats no matter what war state we are in (so we track kills during invasion)
if (_warState == WarState.WAR || _warState == WarState.FORM_ENEMIES)
{
playerClan.getEnemyData().addScore(-1);
killerClan.getEnemyData().addScore(1);
}
killerClan.getEnemyData().addKill();
}
}
}
/**
* Check if a specific Calendar is currently in enemy time
* If this returns true, isInvadeTime should always return false for the same Calendar
*
* @param c {@link java.util.Calendar} instance that should be checked
*/
private boolean isEnemyTime(Calendar c)
{
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
if (dayOfWeek == CREATE_ENEMY_DATE)
{
return true;
}
return false;
}
/**
* Check if a specific Calendar is currently in invade time
* If this returns true, isEnemyTime should always return false for the same Calendar
*
* @param c {@link java.util.Calendar} instance that should be checked
*/
private boolean isInvadeTime(Calendar c)
{
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
if (dayOfWeek == INVADE_ENEMY_DATE)
{
return true;
}
return false;
}
/**
* Get the starting time of when enemies can be formed next
* @return The enemy start time in the form of {@link java.util.Date}
*/
private Date getNextEnemyTime()
{
Calendar c = Calendar.getInstance(_clansManager.getServerTimeZone());
int currDayOfWeek = c.get(Calendar.DAY_OF_WEEK);
c.set(Calendar.DAY_OF_WEEK, CREATE_ENEMY_DATE);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
if (currDayOfWeek >= CREATE_ENEMY_DATE)
c.add(Calendar.DATE, 7);
return c.getTime();
}
/**
* Get the starting time of the next enemy invasion
* @return The invasion start time in the form of {@link java.util.Date}
*/
private Date getNextInvadeTime()
{
Calendar c = Calendar.getInstance(_clansManager.getServerTimeZone());
int currDayOfWeek = c.get(Calendar.DAY_OF_WEEK);
c.set(Calendar.DAY_OF_WEEK, INVADE_ENEMY_DATE);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
if (currDayOfWeek >= INVADE_ENEMY_DATE)
c.add(Calendar.DATE, 7);
return c.getTime();
}
/**
* Get the current War State of the server
* War state determines what events are going on
* with respect to the current war.
*/
public WarState getWarState()
{
return _warState;
}
@EventHandler
public void stateChange(WarStateChangeEvent event)
{
WarState state = event.getNewState();
Bukkit.broadcastMessage(F.main("Clans", "War state changed: " + F.elem(state.getDescription())));
}
/**
* Send the current server time information to the player
*/
public LinkedList<String> mServerTime()
{
LinkedList<String> messageList = new LinkedList<String>();
messageList.add(F.main("Clans", "Server Time"));
Date currDate = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy");
dateFormat.setTimeZone(_clansManager.getServerTimeZone());
messageList.add(F.value("Server Time", dateFormat.format(currDate)));
messageList.add(F.value("Status", _warState.getDescription()));
if (_warState != WarState.INVADE)
{
long next = getNextInvadeTime().getTime();
long currTime = System.currentTimeMillis();
messageList.add(F.value("Invasion", UtilTime.convertString(next - currTime, 1, UtilTime.TimeUnit.FIT)));
}
if (_warState != WarState.FORM_ENEMIES)
{
long next = getNextEnemyTime().getTime();
long currTime = System.currentTimeMillis();
messageList.add(F.value("Enemy Reset", UtilTime.convertString(next - currTime, 1, UtilTime.TimeUnit.FIT)));
}
return messageList;
}
}

View File

@ -0,0 +1,20 @@
package mineplex.game.clans.clans.war;
public enum WarState
{
FORM_ENEMIES("Enemies can now be formed"),
WAR("War is in progress"),
INVADE("Winning teams can invade enemies");
private String _description;
WarState(String description)
{
_description = description;
}
public String getDescription()
{
return _description;
}
}

View File

@ -0,0 +1,39 @@
package mineplex.game.clans.clans.war;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class WarStateChangeEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private WarState _oldState;
private WarState _newState;
public WarStateChangeEvent(WarState oldState, WarState newState)
{
_oldState = oldState;
_newState = newState;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public WarState getOldState()
{
return _oldState;
}
public WarState getNewState()
{
return _newState;
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar" sourcepath="/REPO_DIR/GitHubLibraries/CraftBukkit/src"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.Core"/>

View File

@ -12,6 +12,7 @@
<orderEntry type="module" module-name="Mineplex.Core" />
<orderEntry type="module" module-name="Mineplex.Core.Common" />
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.ClassCombat" />
<orderEntry type="library" name="gson" level="project" />
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.Core" />
<orderEntry type="library" name="craftbukkit" level="project" />
<orderEntry type="module" module-name="Mineplex.ServerData" />
@ -19,5 +20,6 @@
<orderEntry type="library" name="commons-pool2" level="project" />
<orderEntry type="module" module-name="Mineplex.Database" />
<orderEntry type="library" name="jooq" level="project" />
<orderEntry type="library" name="jedis" level="project" />
</component>
</module>

View File

@ -4,6 +4,7 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.CustomTagFix;
import mineplex.core.TablistFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack;
@ -111,6 +112,7 @@ public class Hub extends JavaPlugin implements IRelation
new MemoryFix(this);
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
new CustomTagFix(this, packetHandler);
new TablistFix(this);
//new Replay(this, packetHandler);
new PersonalServerManager(this, clientManager);

View File

@ -45,7 +45,6 @@ import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.benefit.BenefitManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
@ -57,7 +56,6 @@ import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTabTitle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.cosmetic.CosmeticManager;
@ -76,6 +74,7 @@ import mineplex.core.pet.PetManager;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager;
import mineplex.core.recharge.Recharge;
import mineplex.core.stats.StatsManager;
import mineplex.core.task.TaskManager;
import mineplex.core.treasure.TreasureManager;
@ -85,17 +84,14 @@ import mineplex.hub.commands.ForcefieldRadius;
import mineplex.hub.commands.GadgetToggle;
import mineplex.hub.commands.GameModeCommand;
import mineplex.hub.commands.NewsCommand;
import mineplex.hub.mail.MailManager;
import mineplex.hub.modules.ForcefieldManager;
import mineplex.hub.modules.JumpManager;
import mineplex.hub.modules.MapManager;
import mineplex.hub.modules.NewsManager;
import mineplex.hub.modules.ParkourManager;
import mineplex.hub.modules.TextManager;
import mineplex.hub.modules.UHCManager;
import mineplex.hub.modules.VisibilityManager;
import mineplex.hub.modules.WorldManager;
import mineplex.hub.notification.NotificationManager;
import mineplex.hub.party.Party;
import mineplex.hub.party.PartyManager;
import mineplex.hub.poll.PollManager;
@ -170,7 +166,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
_textCreator = new TextManager(this);
_parkour = new ParkourManager(this, donationManager, taskManager);
new MapManager(this);
new WorldManager(this);
new JumpManager(this);
new UHCManager(this);
@ -182,7 +177,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
_inventoryManager = new InventoryManager(plugin, clientManager);
//new BenefitManager(plugin, clientManager, _inventoryManager);
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin));
_treasureManager = new TreasureManager(_plugin, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager);
_treasureManager = new TreasureManager(_plugin, clientManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager);
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager);
_petManager = petManager;
@ -516,10 +511,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
public void PlayerJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
//Player List
UtilTabTitle.setHeaderAndFooter(player, " ", "Visit " + C.cGreen + "www.mineplex.com" + ChatColor.RESET + " for News, Forums and Shop");
//Public Message
if (_clientManager.Get(player).GetRank() != Rank.LEGEND)
event.setJoinMessage(null);

View File

@ -1,61 +0,0 @@
package mineplex.hub.modules;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.entity.ItemFrame;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.map.Map;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilGear;
import mineplex.hub.HubManager;
public class MapManager extends MiniPlugin
{
private HubManager Manager;
private Map Map;
public MapManager(HubManager manager)
{
super("Map Manager", manager.GetPlugin());
Map = new Map(manager.GetPlugin());
Manager = manager;
}
//@EventHandler
public void PlayerJoin(PlayerJoinEvent event)
{
try
{
Map.SetDefaultUrl("http://chivebox.com/img/mc/news.png");
event.getPlayer().setItemInHand(Map.GetMap());
}
catch (Exception ex)
{
System.out.println("[MapManager] Player Join exception");
throw ex;
}
}
@EventHandler
public void FrameInteract(PlayerInteractEntityEvent event)
{
if (!(event.getRightClicked() instanceof ItemFrame))
return;
if (!Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.OWNER))
{
event.setCancelled(true);
return;
}
if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.DIAMOND_AXE))
return;
event.getRightClicked().getWorld().playEffect(event.getRightClicked().getLocation(), Effect.STEP_SOUND, 5);
event.getRightClicked().remove();
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar"/>
<classpathentry kind="output" path="bin"/>

View File

@ -167,7 +167,7 @@ public class MapParser extends JavaPlugin implements Listener
public void DisplayHelp(Player player)
{
UtilPlayer.message(player, F.main("Parser", "Listing Commands;"));
UtilPlayer.message(player, F.value("Parameters", "Parameters: <?> = Required, [?] = Optional"));
UtilPlayer.message(player, F.value("Parameters", "Parameters: <?> = Required, [?] = Optional"));
UtilPlayer.message(player, F.value("/hub", "Return to hub world"));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, F.value("/name <name>", "Set name for current map"));

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar"/>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar" sourcepath="/REPO_DIR/GitHubLibraries/CraftBukkit/src"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/gson-2.2.1.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpclient-4.2.jar"/>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jedis-2.4.2.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/gson-2.2.1.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/commons-pool2-2.2.jar"/>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/gson-2.2.1.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpclient-4.2.jar"/>

View File

@ -7,6 +7,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_7_R4.MinecraftServer;
import mineplex.core.CustomTagFix;
import mineplex.core.TablistFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.blockrestore.BlockRestore;
@ -122,6 +123,7 @@ public class Arcade extends JavaPlugin
new MemoryFix(this);
new CustomTagFix(this, packetHandler);
new TablistFix(this);
new FriendManager(this, _clientManager, preferenceManager, portal);

View File

@ -10,7 +10,7 @@ public class GameCommand extends MultiCommandBase<ArcadeManager>
{
public GameCommand(ArcadeManager plugin)
{
super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPDEV}, "game");
super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPLEAD}, "game");
AddCommand(new StartCommand(Plugin));
AddCommand(new StopCommand(Plugin));

View File

@ -17,7 +17,7 @@ public class SetCommand extends CommandBase<ArcadeManager>
{
public SetCommand(ArcadeManager plugin)
{
super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPDEV}, "set");
super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPLEAD}, "set");
}
@Override

View File

@ -12,7 +12,7 @@ public class StartCommand extends CommandBase<ArcadeManager>
{
public StartCommand(ArcadeManager plugin)
{
super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPDEV}, "start");
super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPLEAD}, "start");
}
@Override

View File

@ -142,7 +142,7 @@ public class SuperSmash extends SoloGame
for (Player player : GetPlayers(true))
_lives.put(player, 4);
_nextPowerup = (long) (System.currentTimeMillis() + 120000 + 180000 * Math.random());
_nextPowerup = (long) (System.currentTimeMillis() + 240000 + 360000 * Math.random());
}
@EventHandler
@ -333,7 +333,7 @@ public class SuperSmash extends SoloGame
best.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.NETHER_STAR, (byte)0, ((SmashKit)GetKit(best)).getSuperCharges(),
C.cYellow + C.Bold + "Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + ((SmashKit)GetKit(best)).getSuperName()));
_nextPowerup = (long) (System.currentTimeMillis() + 120000 + 180000 * Math.random());
_nextPowerup = (long) (System.currentTimeMillis() + 240000 + 360000 * Math.random());
Manager.GetGame().Announce(C.Bold + best.getName() + " collected " + C.cGreen + C.Bold + "Smash Crystal" + ChatColor.RESET + C.Bold + "!");
}

View File

@ -461,7 +461,7 @@ public class Wizards extends SoloGame
private void displayProgress(String progressColor, String prefix, double amount, String suffix, Player... players)
{
// Generate Bar
int bars = 12;
int bars = 52;
String progressBar = C.cGreen + "";
boolean colorChange = false;
for (int i = 0; i < bars; i++)
@ -472,7 +472,7 @@ public class Wizards extends SoloGame
colorChange = true;
}
progressBar += "";
progressBar += "|";
}
// Send to Player

View File

@ -98,7 +98,7 @@ public class PerkDoubleJump extends Perk
Recharge.Instance.setDisplayForce(player, GetName(), true);
}
}
}
}
@EventHandler
public void FlightUpdate(UpdateEvent event)

View File

@ -71,7 +71,7 @@ public class PerkSpiderLeap extends Perk
for (Block block : UtilBlock.getSurrounding(player.getLocation().getBlock(), true))
{
if (!UtilBlock.airFoliage(block))
if (!UtilBlock.airFoliage(block) && !block.isLiquid())
{
player.setVelocity(new Vector(0,0.2,0));

View File

@ -11,13 +11,14 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@ -31,11 +32,15 @@ import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R4.WatchableObject;
import mineplex.core.account.CoreClient;
import mineplex.core.common.Rank;
@ -43,13 +48,13 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlockText;
import mineplex.core.common.util.UtilBlockText.TextAlign;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilBlockText;
import mineplex.core.common.util.UtilBlockText.TextAlign;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
@ -57,8 +62,8 @@ import mineplex.core.donation.Donor;
import mineplex.core.event.CustomTagEvent;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -71,10 +76,6 @@ import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.KitSorter;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.WatchableObject;
public class GameLobbyManager implements Listener, IPacketHandler
{
@ -1301,4 +1302,30 @@ public class GameLobbyManager implements Listener, IPacketHandler
event.setCancelled(true);
}
/**
* DEBUG
*/
@EventHandler
public void command(PlayerCommandPreprocessEvent event)
{
Player player = event.getPlayer();
if (event.getMessage().startsWith("/enable"))
{
player.setGameMode(GameMode.CREATIVE);
player.setFlying(true);
player.setFlySpeed(0.1f);
((CraftPlayer) player).getHandle().spectating = true;
((CraftPlayer) player).getHandle().k = false;
}
else if (event.getMessage().startsWith("/disable"))
{
player.setGameMode(GameMode.SURVIVAL);
player.setFlying(false);
player.setFlySpeed(0.1f);
((CraftPlayer) player).getHandle().spectating = false;
((CraftPlayer) player).getHandle().k = true;
}
}
}

View File

@ -21,7 +21,6 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.pet.PetManager;
@ -51,7 +50,7 @@ public class GameLootManager implements Listener
Manager.GetPluginManager().registerEvents(this, Manager.GetPlugin());
_rewardManager = new RewardManager(Manager.GetDonation(), Manager.getInventoryManager(), petManager,
_rewardManager = new RewardManager(Manager.GetClients(), Manager.GetDonation(), Manager.getInventoryManager(), petManager,
100, 250,
500, 1000,
1500, 2500,
@ -59,15 +58,14 @@ public class GameLootManager implements Listener
false);
//Chest
_rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Treasure Chest", "Treasure Chest", 1, 1,
new ItemStack(Material.CHEST), RewardRarity.COMMON, 4));
_rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Treasure Chest", "Treasure Chest", 1, 2,
new ItemStack(Material.CHEST), RewardRarity.COMMON, 1));
_rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Basic Chest", "Basic Chest", 1, 1,
new ItemStack(Material.CHEST), RewardRarity.UNCOMMON, 1000));
//Key
_rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Treasure Key", "Treasure Key", 1, 1,
new ItemStack(Material.DIAMOND), RewardRarity.UNCOMMON, 1000));
_rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Heroic Chest", "Heroic Chest", 1, 1,
new ItemStack(Material.CHEST), RewardRarity.UNCOMMON, 40));
_rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Legendary Chest", "Legendary Chest", 1, 1,
new ItemStack(Material.CHEST), RewardRarity.UNCOMMON, 1));
}
@EventHandler