Finalize Titles
This commit is contained in:
parent
4641ed828b
commit
fd00644eb8
@ -28,7 +28,6 @@ public class PlayerStats implements Listener, Runnable
|
||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
||||
|
||||
_repository = new PlayerStatsRepository();
|
||||
_repository.initialize();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -1,14 +1,17 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EnumParticle;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EnumParticle;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles;
|
||||
|
||||
public class UtilParticle
|
||||
{
|
||||
public enum ViewDist
|
||||
@ -52,22 +55,22 @@ public class UtilParticle
|
||||
ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY, "angryVillager", "Lightning Cloud", Material.INK_SACK, (byte) 11),
|
||||
|
||||
BLOCK_CRACK(EnumParticle.BLOCK_CRACK, "blockcrack")
|
||||
{
|
||||
@Override
|
||||
public String getParticle(Material type, int data)
|
||||
{
|
||||
return "blockcrack_" + type.getId() + "_" + data;
|
||||
}
|
||||
},
|
||||
{
|
||||
@Override
|
||||
public String getParticle(Material type, int data)
|
||||
{
|
||||
return "blockcrack_" + type.getId() + "_" + data;
|
||||
}
|
||||
},
|
||||
|
||||
BLOCK_DUST(EnumParticle.BLOCK_DUST, "blockdust")
|
||||
{
|
||||
@Override
|
||||
public String getParticle(Material type, int data)
|
||||
{
|
||||
return "blockdust_" + type.getId() + "_" + data;
|
||||
}
|
||||
},
|
||||
{
|
||||
@Override
|
||||
public String getParticle(Material type, int data)
|
||||
{
|
||||
return "blockdust_" + type.getId() + "_" + data;
|
||||
}
|
||||
},
|
||||
|
||||
BUBBLE(EnumParticle.WATER_BUBBLE, "bubble"),
|
||||
|
||||
@ -100,20 +103,20 @@ public class UtilParticle
|
||||
HUGE_EXPLOSION(EnumParticle.EXPLOSION_HUGE, "hugeexplosion", "Huge Explosion", Material.TNT, (byte) 0),
|
||||
|
||||
ICON_CRACK(EnumParticle.ITEM_CRACK, "iconcrack")
|
||||
{
|
||||
@Override
|
||||
public String getParticle(Material type, int data)
|
||||
{
|
||||
return "iconcrack_" + type.getId() + "_" + data;
|
||||
}
|
||||
},
|
||||
{
|
||||
@Override
|
||||
public String getParticle(Material type, int data)
|
||||
{
|
||||
return "iconcrack_" + type.getId() + "_" + data;
|
||||
}
|
||||
},
|
||||
|
||||
INSTANT_SPELL(EnumParticle.SPELL_INSTANT, "instantSpell"),
|
||||
|
||||
LARGE_EXPLODE(EnumParticle.EXPLOSION_LARGE, "largeexplode", "Explosion", Material.FIREBALL, (byte) 0),
|
||||
|
||||
LARGE_SMOKE(EnumParticle.SMOKE_LARGE, "largesmoke", "Black Smoke", Material.INK_SACK, (byte) 0),
|
||||
|
||||
|
||||
SMOKE(EnumParticle.SMOKE_NORMAL, "smoke", "Smoke", Material.INK_SACK, (byte) 0),
|
||||
|
||||
LAVA(EnumParticle.LAVA, "lava", "Lava Debris", Material.LAVA, (byte) 0),
|
||||
@ -132,8 +135,8 @@ public class UtilParticle
|
||||
.getMaterial(2266), (byte) 0),
|
||||
|
||||
/**
|
||||
* To do certain colors, use "no / 24F" for the random X value, 1 for speed. 0 for count.
|
||||
*/
|
||||
* To do certain colors, use "no / 24F" for the random X value, 1 for speed. 0 for count.
|
||||
*/
|
||||
NOTE(EnumParticle.NOTE, "note", "Musical Note", Material.JUKEBOX, (byte) 0),
|
||||
|
||||
PORTAL(EnumParticle.PORTAL, "portal", "Portal Effect", Material.INK_SACK, (byte) 5),
|
||||
@ -234,7 +237,7 @@ public class UtilParticle
|
||||
}
|
||||
|
||||
private static PacketPlayOutWorldParticles getPacket(String particleName, Location location, float offsetX, float offsetY,
|
||||
float offsetZ, float speed, int count, boolean displayFar)
|
||||
float offsetZ, float speed, int count, boolean displayFar)
|
||||
{
|
||||
String[] parts = particleName.split("_");
|
||||
int[] details = new int[parts.length - 1];
|
||||
@ -260,19 +263,67 @@ public class UtilParticle
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static void PlayParticle(ParticleType type,Location location, float offsetX, float offsetY,
|
||||
|
||||
public static void PlayParticle(ParticleType type, Location location, float offsetX, float offsetY,
|
||||
float offsetZ, float speed, int count, ViewDist dist)
|
||||
{
|
||||
PlayParticle(type, location, offsetX, offsetY, offsetZ, speed, count, dist, UtilServer.getPlayers());
|
||||
}
|
||||
|
||||
public static void playParticleFor(Player player, ParticleType type, Location location, Vector offset, float speed, int count, ViewDist dist)
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float z = 0;
|
||||
if (offset != null)
|
||||
{
|
||||
x = (float) offset.getX();
|
||||
y = (float) offset.getY();
|
||||
z = (float) offset.getZ();
|
||||
}
|
||||
List<Player> players = new ArrayList<>(UtilServer.getPlayersCollection());
|
||||
players.removeIf(other -> !other.canSee(player));
|
||||
PlayParticle(type, location, x, y, z, speed, count, dist, players.toArray(new Player[0]));
|
||||
}
|
||||
|
||||
public static void playParticleFor(Player player, ParticleType type, Location location, float offsetX, float offsetY, float offsetZ,
|
||||
float speed, int count, ViewDist dist)
|
||||
{
|
||||
List<Player> players = new ArrayList<>(UtilServer.getPlayersCollection());
|
||||
players.removeIf(other -> !other.canSee(player));
|
||||
PlayParticle(type.particleName, location, offsetX, offsetY, offsetZ, speed, count, dist, players.toArray(new Player[0]));
|
||||
}
|
||||
|
||||
public static void playParticleFor(Player player, String particle, Location location, Vector offset, float speed, int count, ViewDist dist)
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float z = 0;
|
||||
if (offset != null)
|
||||
{
|
||||
x = (float) offset.getX();
|
||||
y = (float) offset.getY();
|
||||
z = (float) offset.getZ();
|
||||
}
|
||||
List<Player> players = new ArrayList<>(UtilServer.getPlayersCollection());
|
||||
players.removeIf(other -> !other.canSee(player));
|
||||
PlayParticle(particle, location, x, y, z, speed, count, dist, players.toArray(new Player[0]));
|
||||
}
|
||||
|
||||
public static void playParticleFor(Player player, String particle, Location location, float offsetX, float offsetY, float offsetZ,
|
||||
float speed, int count, ViewDist dist)
|
||||
{
|
||||
List<Player> players = new ArrayList<>(UtilServer.getPlayersCollection());
|
||||
players.removeIf(other -> !other.canSee(player));
|
||||
PlayParticle(particle, location, offsetX, offsetY, offsetZ, speed, count, dist, players.toArray(new Player[0]));
|
||||
}
|
||||
|
||||
public static void PlayParticleToAll(ParticleType type, Location location, Vector offset, float speed, int count, ViewDist dist)
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float z = 0;
|
||||
if(offset != null)
|
||||
if (offset != null)
|
||||
{
|
||||
x = (float) offset.getX();
|
||||
y = (float) offset.getY();
|
||||
@ -280,13 +331,14 @@ public class UtilParticle
|
||||
}
|
||||
PlayParticle(type, location, x, y, z, speed, count, dist, UtilServer.getPlayers());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void PlayParticle(ParticleType type, Location location, Vector offset, float speed, int count, ViewDist dist, Player... players)
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float z = 0;
|
||||
if(offset != null)
|
||||
if (offset != null)
|
||||
{
|
||||
x = (float) offset.getX();
|
||||
y = (float) offset.getY();
|
||||
@ -294,21 +346,21 @@ public class UtilParticle
|
||||
}
|
||||
PlayParticle(type, location, x, y, z, speed, count, dist, players);
|
||||
}
|
||||
|
||||
|
||||
public static void PlayParticleToAll(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ,
|
||||
float speed, int count, ViewDist dist)
|
||||
float speed, int count, ViewDist dist)
|
||||
{
|
||||
PlayParticle(type.particleName, location, offsetX, offsetY, offsetZ, speed, count, dist, UtilServer.getPlayers());
|
||||
}
|
||||
|
||||
|
||||
public static void PlayParticle(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ,
|
||||
float speed, int count, ViewDist dist, Player... players)
|
||||
float speed, int count, ViewDist dist, Player... players)
|
||||
{
|
||||
PlayParticle(type.particleName, location, offsetX, offsetY, offsetZ, speed, count, dist, players);
|
||||
}
|
||||
|
||||
public static void PlayParticle(String particle, Location location, float offsetX, float offsetY, float offsetZ, float speed,
|
||||
int count, ViewDist dist, Player... players)
|
||||
int count, ViewDist dist, Player... players)
|
||||
{
|
||||
PacketPlayOutWorldParticles packet = getPacket(particle, location, offsetX, offsetY, offsetZ, speed, count, true);
|
||||
|
||||
@ -321,13 +373,13 @@ public class UtilParticle
|
||||
UtilPlayer.sendPacket(player, packet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void PlayParticleToAll(String particle, Location location, Vector offset, float speed, int count, ViewDist dist)
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float z = 0;
|
||||
if(offset != null)
|
||||
if (offset != null)
|
||||
{
|
||||
x = (float) offset.getX();
|
||||
y = (float) offset.getY();
|
||||
@ -335,9 +387,9 @@ public class UtilParticle
|
||||
}
|
||||
PlayParticle(particle, location, x, y, z, speed, count, dist, UtilServer.getPlayers());
|
||||
}
|
||||
|
||||
|
||||
public static void PlayParticleToAll(String particle, Location location, float offsetX, float offsetY, float offsetZ,
|
||||
float speed, int count, ViewDist dist)
|
||||
float speed, int count, ViewDist dist)
|
||||
{
|
||||
PlayParticle(particle, location, offsetX, offsetY, offsetZ, speed, count, dist, UtilServer.getPlayers());
|
||||
}
|
||||
@ -357,5 +409,5 @@ public class UtilParticle
|
||||
return;
|
||||
PlayParticleToAll(particleType, location, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1f, count, dist);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -36,7 +36,7 @@ public class UtilTasks
|
||||
onMainThread(() ->
|
||||
{
|
||||
original.accept(t);
|
||||
});
|
||||
}).run();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1,11 @@
|
||||
package mineplex.core.achievement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
|
||||
public enum Achievement
|
||||
@ -1264,4 +1270,24 @@ public enum Achievement
|
||||
{
|
||||
return _gems;
|
||||
}
|
||||
|
||||
private static final Map<AchievementCategory, List<Achievement>> BY_CATEGORY;
|
||||
|
||||
static
|
||||
{
|
||||
Map<AchievementCategory, List<Achievement>> byCategory = new HashMap<>();
|
||||
for (Achievement achievement : values())
|
||||
{
|
||||
byCategory.computeIfAbsent(achievement.getCategory(), key -> new ArrayList<>()).add(achievement);
|
||||
}
|
||||
Map<AchievementCategory, List<Achievement>> immutableByCategory = new HashMap<>();
|
||||
byCategory.forEach((key, value) -> immutableByCategory.put(key, Collections.unmodifiableList(value)));
|
||||
|
||||
BY_CATEGORY = Collections.unmodifiableMap(immutableByCategory);
|
||||
}
|
||||
|
||||
public static List<Achievement> getByCategory(AchievementCategory category)
|
||||
{
|
||||
return BY_CATEGORY.get(category);
|
||||
}
|
||||
}
|
||||
|
@ -81,9 +81,7 @@ public class AchievementManager extends MiniPlugin
|
||||
@EventHandler
|
||||
public void informLevelUp(StatChangeEvent event)
|
||||
{
|
||||
Player player = UtilPlayer.searchExact(event.getPlayerName());
|
||||
if (player == null)
|
||||
return;
|
||||
Player player = event.getPlayer();
|
||||
|
||||
for (Achievement type : Achievement.values())
|
||||
{
|
||||
|
@ -3,16 +3,13 @@ package mineplex.core.book;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.chat.ComponentSerializer;
|
||||
import net.minecraft.server.v1_8_R3.Items;
|
||||
import net.minecraft.server.v1_8_R3.NBTTagCompound;
|
||||
import net.minecraft.server.v1_8_R3.NBTTagList;
|
||||
import net.minecraft.server.v1_8_R3.NBTTagString;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -57,7 +54,6 @@ public class BookBuilder
|
||||
public BookBuilder title(String title)
|
||||
{
|
||||
Validate.notNull(title, "Title cannot be null");
|
||||
Validate.isTrue(title.length() < 32, "Title cannot be longer than 32 characters");
|
||||
this._title = title;
|
||||
return this;
|
||||
}
|
||||
@ -91,8 +87,22 @@ public class BookBuilder
|
||||
public NBTTagCompound toCompound()
|
||||
{
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setString("author", _author);
|
||||
compound.setString("title", _title);
|
||||
if (_author != null)
|
||||
compound.setString("author", _author);
|
||||
if (_title != null)
|
||||
{
|
||||
if (_title.length() < 32)
|
||||
{
|
||||
compound.setString("title", _title);
|
||||
}
|
||||
else
|
||||
{
|
||||
NBTTagCompound display = new NBTTagCompound();
|
||||
|
||||
display.set("Name", new NBTTagString(ChatColor.RESET + _title));
|
||||
compound.set("display", display);
|
||||
}
|
||||
}
|
||||
compound.setInt("generation", _generation);
|
||||
compound.setBoolean("resolved", _resolved);
|
||||
|
||||
|
@ -278,7 +278,9 @@ public class DonationManager extends MiniClientPlugin<Donor>
|
||||
|
||||
/**
|
||||
* Rewards the {@link Player} with {@code amount} of {@code currency} because of {@code reason}
|
||||
* This method will retry the transaction for up to {@link DonationManager#MAX_GIVE_ATTEMPTS} attempts
|
||||
* This method will retry the transaction for up to {@link DonationManager#MAX_GIVE_ATTEMPTS} attempts.
|
||||
*
|
||||
* This method is <b>not</b> thread safe, and should be called on the main thread
|
||||
*/
|
||||
public void rewardCurrencyUntilSuccess(GlobalCurrency currency, Player player, String reason, int amount)
|
||||
{
|
||||
@ -290,6 +292,8 @@ public class DonationManager extends MiniClientPlugin<Donor>
|
||||
* Rewards the {@link Player} with {@code amount} of {@code currency} because of {@code reason}
|
||||
* This method will retry the transaction for up to {@link DonationManager#MAX_GIVE_ATTEMPTS} attempts
|
||||
*
|
||||
* This method is <b>not</b> thread safe, and should be called on the main thread
|
||||
*
|
||||
* @param callback The callback which will be called on the main thread. Possible responses are:
|
||||
* {@link Boolean#TRUE} if the transaction succeeded
|
||||
* {@link Boolean#FALSE} if the transaction failed, either during incrementation or sanity-checking
|
||||
|
@ -785,17 +785,23 @@ public class GadgetManager extends MiniPlugin
|
||||
|
||||
public void disableAll(Player player, boolean winRooms)
|
||||
{
|
||||
for (GadgetType gadgetType : _gadgets.keySet())
|
||||
if (winRooms)
|
||||
{
|
||||
if (gadgetType == GadgetType.WIN_EFFECT && winRooms)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (Gadget gadget : _gadgets.get(gadgetType))
|
||||
for (Gadget gadget : _gadgets.get(GadgetType.PARTICLE))
|
||||
{
|
||||
gadget.disable(player, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (GadgetType gadgetType : _gadgets.keySet())
|
||||
{
|
||||
for (Gadget gadget : _gadgets.get(gadgetType))
|
||||
{
|
||||
gadget.disable(player, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disableAll(Player player, List<String> dontDisable)
|
||||
|
@ -0,0 +1,25 @@
|
||||
package mineplex.core.gadget.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
public class PlayerConsumeMelonEvent extends PlayerEvent
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public PlayerConsumeMelonEvent(Player player)
|
||||
{
|
||||
super(player);
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package mineplex.core.gadget.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
|
||||
public class PlayerUseCoalEvent extends PlayerEvent
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final CoalReward _prize;
|
||||
private final int _cost;
|
||||
|
||||
public PlayerUseCoalEvent(Player player, CoalReward reward, int cost)
|
||||
{
|
||||
super(player);
|
||||
this._prize = reward;
|
||||
this._cost = cost;
|
||||
}
|
||||
|
||||
public CoalReward getPrize()
|
||||
{
|
||||
return this._prize;
|
||||
}
|
||||
|
||||
public int getCost()
|
||||
{
|
||||
return this._cost;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public enum CoalReward
|
||||
{
|
||||
HAT,
|
||||
PET,
|
||||
PARTICLE
|
||||
}
|
||||
}
|
@ -21,9 +21,11 @@ import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent;
|
||||
import mineplex.core.gadget.event.PlayerUseCoalEvent;
|
||||
import mineplex.core.gadget.gadgets.Ammo;
|
||||
import mineplex.core.gadget.gadgets.hat.HatType;
|
||||
import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes;
|
||||
@ -106,6 +108,8 @@ public class ItemCoal extends ItemGadget
|
||||
player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(getDisplayMaterial(), getDisplayData(), 1, F.item(Manager.getInventoryManager().Get(player).getItemCount(getName()) + " " + getName())));
|
||||
|
||||
Manager.getDonationManager().Get(player).addOwnedUnknownSalesPackage("Lump of Coal Hat");
|
||||
|
||||
UtilServer.CallEvent(new PlayerUseCoalEvent(player, PlayerUseCoalEvent.CoalReward.HAT, _particle));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -118,7 +122,7 @@ public class ItemCoal extends ItemGadget
|
||||
}
|
||||
|
||||
//Coal Apparition
|
||||
if (!Manager.getPetManager().Get(player).getPets().containsKey(EntityType.PIG_ZOMBIE))
|
||||
if (!Manager.getPetManager().Get(player).getPets().containsKey(PetType.PIG_ZOMBIE))
|
||||
{
|
||||
goal = _pet;
|
||||
|
||||
@ -148,6 +152,8 @@ public class ItemCoal extends ItemGadget
|
||||
player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(getDisplayMaterial(), getDisplayData(), 1, F.item(Manager.getInventoryManager().Get(player).getItemCount(getName()) + " " + getName())));
|
||||
|
||||
Manager.getDonationManager().Get(player).addOwnedUnknownSalesPackage("Coal Apparition");
|
||||
|
||||
UtilServer.CallEvent(new PlayerUseCoalEvent(player, PlayerUseCoalEvent.CoalReward.PET, _particle));
|
||||
}
|
||||
});
|
||||
|
||||
@ -181,6 +187,8 @@ public class ItemCoal extends ItemGadget
|
||||
player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(getDisplayMaterial(), getDisplayData(), 1, F.item(Manager.getInventoryManager().Get(player).getItemCount(getName()) + " " + getName())));
|
||||
|
||||
Manager.getDonationManager().Get(player).addOwnedUnknownSalesPackage("Coal Fumes");
|
||||
|
||||
UtilServer.CallEvent(new PlayerUseCoalEvent(player, PlayerUseCoalEvent.CoalReward.PARTICLE, _particle));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -25,8 +25,10 @@ import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.event.PlayerConsumeMelonEvent;
|
||||
import mineplex.core.gadget.gadgets.Ammo;
|
||||
import mineplex.core.gadget.types.ItemGadget;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
@ -119,6 +121,8 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown
|
||||
if (!_melon.remove(event.getItem()))
|
||||
return;
|
||||
|
||||
UtilServer.CallEvent(new PlayerConsumeMelonEvent(event.getPlayer()));
|
||||
|
||||
event.getItem().remove();
|
||||
|
||||
event.setCancelled(true);
|
||||
|
@ -116,7 +116,7 @@ public class MorphSanta extends MorphGadget
|
||||
SkinData.PRESENT.getSkull("Hidden Present " + System.currentTimeMillis(), new ArrayList<>()));
|
||||
UtilAction.velocity(present, player.getLocation().getDirection(), 0.2, false, 0, 0.2, 1, false);
|
||||
|
||||
Manager.getDonationManager().RewardCoinsLater(this.getName() + " Present Hide", player, -(shards + SHARD_CHARGE));
|
||||
Manager.getDonationManager().rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, this.getName() + " Present Hide", -(shards + SHARD_CHARGE));
|
||||
|
||||
present.setPickupDelay(40);
|
||||
|
||||
@ -189,7 +189,7 @@ public class MorphSanta extends MorphGadget
|
||||
|
||||
if (santaPresent.getPresentType().equals(SantaPresent.PresentType.PRESENT))
|
||||
{
|
||||
Manager.getDonationManager().RewardCoinsLater(getName() + " Present Pickup", event.getPlayer(), santaPresent.getAmmo());
|
||||
Manager.getDonationManager().rewardCurrency(GlobalCurrency.TREASURE_SHARD, event.getPlayer(), getName() + " Present Pickup", santaPresent.getAmmo());
|
||||
|
||||
//Announce
|
||||
Bukkit.broadcastMessage(C.cGold + C.Bold + event.getPlayer().getName() +
|
||||
|
@ -39,6 +39,6 @@ public class ParticleCoalFumes extends ParticleGadget
|
||||
amount = 2;
|
||||
}
|
||||
|
||||
UtilParticle.PlayParticleToAll(type, player.getLocation(), xz, 0, xz, 0, amount, ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, type, player.getLocation(), xz, 0, xz, 0, amount, ViewDist.NORMAL);
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class ParticleWingsDemons extends ParticleGadget
|
||||
if (Manager.isMoving(player))
|
||||
{
|
||||
if (event.getType() == UpdateType.FASTEST)
|
||||
UtilParticle.PlayParticleToAll(ParticleType.SMOKE, loc, 0.3f, 0.2f, 0.3f, 0, 10, ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, ParticleType.SMOKE, loc, 0.3f, 0.2f, 0.3f, 0, 10, ViewDist.NORMAL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -64,8 +64,8 @@ public class ParticleYinYang extends ParticleGadget
|
||||
z *= 0.1 + ((1-d) * 0.9);
|
||||
}
|
||||
|
||||
UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, loc, new Vector(x, y, z), 1, 0, ViewDist.NORMAL);
|
||||
UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, loc, new Vector(-x, y, -z), 1, 0, ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, ParticleType.FIREWORKS_SPARK, loc, new Vector(x, y, z), 1, 0, ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, ParticleType.FIREWORKS_SPARK, loc, new Vector(-x, y, -z), 1, 0, ViewDist.NORMAL);
|
||||
|
||||
if(y == 0)
|
||||
{
|
||||
@ -78,9 +78,9 @@ public class ParticleYinYang extends ParticleGadget
|
||||
|
||||
for(int i = 0; i < a; i++)
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, loc.clone().add(v),
|
||||
UtilParticle.playParticleFor(player, ParticleType.RED_DUST, loc.clone().add(v),
|
||||
UtilColor.colorToVector(Color.BLACK), 1, 0, ViewDist.NORMAL);
|
||||
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, loc.clone().subtract(v),
|
||||
UtilParticle.playParticleFor(player, ParticleType.RED_DUST, loc.clone().subtract(v),
|
||||
UtilColor.colorToVector(Color.BLACK), 1, 0, ViewDist.NORMAL);
|
||||
}
|
||||
}
|
||||
|
@ -61,9 +61,9 @@ public class ParticleCandyCane extends ParticleGadget
|
||||
loc.add(v);
|
||||
}
|
||||
|
||||
UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL);
|
||||
UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 1), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL);
|
||||
UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 2), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 1), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 2), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -37,11 +37,11 @@ public class ParticleHeart extends ParticleGadget
|
||||
{
|
||||
if(getSet() == null || !getSet().isActive(player)) return;
|
||||
|
||||
UtilParticle.PlayParticleToAll(ParticleType.HEART, player.getLocation().add(0, 1, 0), null, 0, 1, ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, ParticleType.HEART, player.getLocation().add(0, 1, 0), null, 0, 1, ViewDist.NORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.HEART, player.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1, ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, ParticleType.HEART, player.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1, ViewDist.NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class ParticleRain extends ParticleGadget
|
||||
|
||||
if (Manager.isMoving(player))
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.SPLASH, player.getLocation(), 0.2f, 0, 0.2f, 0, 6, ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, ParticleType.SPLASH, player.getLocation(), 0.2f, 0, 0.2f, 0, 6, ViewDist.NORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -49,7 +49,7 @@ public class ParticleRain extends ParticleGadget
|
||||
others.remove(player);
|
||||
UtilParticle.PlayParticle(ParticleType.CLOUD, loc, 0.6f, 0.1f, 0.6f, 0, 8, ViewDist.NORMAL);
|
||||
|
||||
UtilParticle.PlayParticleToAll(ParticleType.DRIP_WATER, loc, 0.4f, 0.1f, 0.4f, 0, 2, ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, ParticleType.DRIP_WATER, loc, 0.4f, 0.1f, 0.4f, 0, 2, ViewDist.NORMAL);
|
||||
|
||||
// Sound
|
||||
player.getWorld().playSound(player.getLocation(), Sound.AMBIENCE_RAIN, 0.1f, 1f);
|
||||
|
@ -49,7 +49,7 @@ public class ParticleMusic extends ParticleGadget
|
||||
|
||||
if (moving)
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.NOTE, player.getLocation(), d, 0, 0, 1, 0, ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, ParticleType.NOTE, player.getLocation(), d, 0, 0, 1, 0, ViewDist.NORMAL);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ public class ParticleMusic extends ParticleGadget
|
||||
|
||||
Location loc = player.getLocation().add(x, y, z);
|
||||
|
||||
UtilParticle.PlayParticleToAll(ParticleType.NOTE, loc, d, 0, 0, 1, 0, ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, ParticleType.NOTE, loc, d, 0, 0, 1, 0, ViewDist.NORMAL);
|
||||
}
|
||||
|
||||
if (getSet() != null && getSet().isActive(player))
|
||||
@ -84,7 +84,7 @@ public class ParticleMusic extends ParticleGadget
|
||||
double z = Math.cos(rad2 + step) * r;
|
||||
|
||||
Location loc = player.getLocation().add(x, 1.25, z);
|
||||
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, loc, new Vector(red, green, blue), 1, 0, ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, ParticleType.RED_DUST, loc, new Vector(red, green, blue), 1, 0, ViewDist.NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,18 +2,18 @@ package mineplex.core.gadget.gadgets.particle.party;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.ItemDespawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@ -33,78 +33,91 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class ParticlePartyTime extends ParticleGadget
|
||||
{
|
||||
|
||||
private Set<Item> _hiddenDrops = new HashSet<>();
|
||||
|
||||
private Byte[] _data = new Byte[]{1,2,4,5,6,9,10,11,12,13,14,15};
|
||||
|
||||
private Map<Player, Set<Item>> _hiddenDrops = new HashMap<>();
|
||||
|
||||
private Byte[] _data = new Byte[]{1, 2, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15};
|
||||
|
||||
public ParticlePartyTime(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Party Time",
|
||||
super(manager, "Party Time",
|
||||
UtilText.splitLineToArray(C.cGray + "It is " + C.cPurple + "PARTY TIME!", LineFormat.LORE),
|
||||
-3, Material.FIREWORK, (byte)-1);
|
||||
-3, Material.FIREWORK, (byte) -1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void playParticle(Player player, UpdateEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.TICK) return;
|
||||
|
||||
Location loc = player.getLocation().add(Math.random()*2-1, 2.3 + Math.random()*0.7, Math.random()*2-1);
|
||||
|
||||
if (event.getType() != UpdateType.TICK) return;
|
||||
|
||||
Location loc = player.getLocation().add(Math.random() * 2 - 1, 2.3 + Math.random() * 0.7, Math.random() * 2 - 1);
|
||||
|
||||
List<Byte> list = Arrays.asList(_data);
|
||||
Collections.shuffle(list);
|
||||
for(int i = 0; i < 1; i++)
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
String particle = ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, list.get(i));
|
||||
if(Manager.isMoving(player)) {
|
||||
UtilParticle.PlayParticleToAll(particle, player.getLocation().add(0, 1, 0), null, 0.08f, 1, ViewDist.NORMAL);
|
||||
} else {
|
||||
UtilParticle.PlayParticleToAll(particle, loc, null, 0.08f, 10, ViewDist.NORMAL);
|
||||
if (Manager.isMoving(player))
|
||||
{
|
||||
UtilParticle.playParticleFor(player, particle, player.getLocation().add(0, 1, 0), null, 0.08f, 1, ViewDist.NORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilParticle.playParticleFor(player, particle, loc, null, 0.08f, 10, ViewDist.NORMAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(getSet() != null && getSet().isActive(player))
|
||||
|
||||
if (getSet() != null && getSet().isActive(player))
|
||||
{
|
||||
if(player.getTicksLived()%10 == 0)
|
||||
if (player.getTicksLived() % 10 == 0)
|
||||
{
|
||||
Location spawnLoc = player.getLocation().add(0, 2.5, 0);
|
||||
Vector v = Vector.getRandom().subtract(Vector.getRandom()).setY(0).normalize().multiply(0.3).setY(0.3+0.3*Math.random());
|
||||
Vector v = Vector.getRandom().subtract(Vector.getRandom()).setY(0).normalize().multiply(0.3).setY(0.3 + 0.3 * Math.random());
|
||||
byte data = _data[UtilMath.r(_data.length)];
|
||||
ItemStack stack = new ItemStack(Material.INK_SACK, 1, (short)0, data);
|
||||
ItemStack stack = new ItemStack(Material.INK_SACK, 1, (short) 0, data);
|
||||
Item item = UtilItem.dropItem(stack, spawnLoc, false, false, 10, true);
|
||||
item.setVelocity(v);
|
||||
|
||||
_hiddenDrops.add(item);
|
||||
|
||||
_hiddenDrops.computeIfAbsent(player, key -> new HashSet<>()).add(item);
|
||||
DisguiseArmorStand stand = new DisguiseArmorStand(item);
|
||||
stand.setInvisible(true);
|
||||
Manager.getDisguiseManager().disguise(stand);
|
||||
|
||||
|
||||
String particle = ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, data);
|
||||
UtilParticle.PlayParticleToAll(particle, spawnLoc, null, 0.08f, 30, ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, particle, spawnLoc, null, 0.08f, 30, ViewDist.NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.TICK) return;
|
||||
|
||||
for(Iterator<Item> it = _hiddenDrops.iterator(); it.hasNext();)
|
||||
{
|
||||
Item item = it.next();
|
||||
if(!item.isValid()) {
|
||||
it.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
// Bukkit.broadcastMessage("Item still alive: " + item.getTicksLived());
|
||||
|
||||
String particle = ParticleType.ICON_CRACK.getParticle(item.getItemStack().getType(), item.getItemStack().getData().getData());
|
||||
UtilParticle.PlayParticleToAll(particle, item.getLocation(), null, 0, 3, ViewDist.NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopEffect(Player player)
|
||||
{
|
||||
_hiddenDrops.remove(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK) return;
|
||||
|
||||
_hiddenDrops.forEach((key, value) ->
|
||||
{
|
||||
for (Iterator<Item> it = value.iterator(); it.hasNext(); )
|
||||
{
|
||||
Item item = it.next();
|
||||
if (!item.isValid())
|
||||
{
|
||||
it.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
// Bukkit.broadcastMessage("Item still alive: " + item.getTicksLived());
|
||||
|
||||
String particle = ParticleType.ICON_CRACK.getParticle(item.getItemStack().getType(), item.getItemStack().getData().getData());
|
||||
UtilParticle.playParticleFor(key, particle, item.getLocation(), null, 0, 3, ViewDist.NORMAL);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class ParticleTitan extends ParticleGadget
|
||||
|
||||
if (Manager.isMoving(player))
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.FLAME, player.getLocation().add(0, 0.1, 0), 0.2f, 0.1f, 0.2f, 0.015f, 3, ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, ParticleType.FLAME, player.getLocation().add(0, 0.1, 0), 0.2f, 0.1f, 0.2f, 0.015f, 3, ViewDist.NORMAL);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -70,9 +70,9 @@ public class ParticleTitan extends ParticleGadget
|
||||
|
||||
loc.add(v);
|
||||
|
||||
if (redstone) UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, loc, 1, 0, 0, 1, 0, ViewDist.NORMAL);
|
||||
if (redstone) UtilParticle.playParticleFor(player, ParticleType.RED_DUST, loc, 1, 0, 0, 1, 0, ViewDist.NORMAL);
|
||||
v.multiply(-1);
|
||||
UtilParticle.PlayParticleToAll(ParticleType.FLAME, loc, v, 0.05f, 0, ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, ParticleType.FLAME, loc, v, 0.05f, 0, ViewDist.NORMAL);
|
||||
|
||||
rad = -(step * i + offset2);
|
||||
x = Math.sin(rad);
|
||||
@ -85,9 +85,9 @@ public class ParticleTitan extends ParticleGadget
|
||||
|
||||
loc.add(v);
|
||||
|
||||
if (redstone) UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, loc, 1, 0, 0, 1, 0, ViewDist.NORMAL);
|
||||
if (redstone) UtilParticle.playParticleFor(player, ParticleType.RED_DUST, loc, 1, 0, 0, 1, 0, ViewDist.NORMAL);
|
||||
v.multiply(-1);
|
||||
UtilParticle.PlayParticleToAll(ParticleType.FLAME, loc, v, 0.05f, 0, ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, ParticleType.FLAME, loc, v, 0.05f, 0, ViewDist.NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class ParticleBlood extends ParticleGadget
|
||||
|
||||
if (Manager.isMoving(player))
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 2, ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, ParticleType.RED_DUST, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 2, ViewDist.NORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -55,7 +55,7 @@ public class ParticleBlood extends ParticleGadget
|
||||
|
||||
Location lloc = loc.clone().add(v);
|
||||
|
||||
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, lloc, null, 0f, 2, ViewDist.NORMAL);
|
||||
UtilParticle.playParticleFor(player, ParticleType.RED_DUST, lloc, null, 0f, 2, ViewDist.NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class SetCandyCane extends GadgetSet
|
||||
|
||||
public SetCandyCane(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Candy Cane", "Coming Soon...",
|
||||
super(manager, "Candy Cane", "2x Sweet Points while active (Titles)",
|
||||
manager.getGadget(ArrowTrailCandyCane.class),
|
||||
manager.getGadget(DeathCandyCane.class),
|
||||
manager.getGadget(DoubleJumpCandyCane.class),
|
||||
|
@ -12,7 +12,7 @@ public class SetCupidsLove extends GadgetSet
|
||||
|
||||
public SetCupidsLove(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Cupid's Love", /*"Running into other players gives them hearts for 5 seconds."*/ "Coming soon...",
|
||||
super(manager, "Cupid's Love", /*"Running into other players gives them hearts for 5 seconds."*/ "2x Holiday Points while active (Titles)",
|
||||
manager.getGadget(ArrowTrailCupid.class),
|
||||
manager.getGadget(DeathCupidsBrokenHeart.class),
|
||||
manager.getGadget(DoubleJumpCupidsWings.class),
|
||||
|
@ -12,7 +12,7 @@ public class SetEmerald extends GadgetSet
|
||||
|
||||
public SetEmerald(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Emerald", /*"Press Shift to summon a Gem Party Bomb. 24 hour cooldown."*/ "Coming soon...",
|
||||
super(manager, "Emerald", /*"Press Shift to summon a Gem Party Bomb. 24 hour cooldown."*/ "2x Gem Points while active (Titles)",
|
||||
manager.getGadget(ArrowTrailEmerald.class),
|
||||
manager.getGadget(DeathEmerald.class),
|
||||
manager.getGadget(DoubleJumpEmerald.class),
|
||||
|
@ -12,7 +12,7 @@ public class SetFreedom extends GadgetSet
|
||||
|
||||
public SetFreedom(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Freedom Set", "Coming soon...",
|
||||
super(manager, "Freedom", "2x Holiday Points while active (Titles)",
|
||||
manager.getGadget(ArrowTrailFreedom.class),
|
||||
manager.getGadget(DeathFreedom.class),
|
||||
manager.getGadget(DoubleJumpFreedom.class),
|
||||
|
@ -12,7 +12,7 @@ public class SetFrostLord extends GadgetSet
|
||||
|
||||
public SetFrostLord(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Frost Lord", /*"Improved Wind of the Frost Lord"*/ "Coming soon...",
|
||||
super(manager, "Frost Lord", /*"Improved Wind of the Frost Lord"*/ "2x Holiday Points while active (Titles)",
|
||||
manager.getGadget(ArrowTrailFrostLord.class),
|
||||
manager.getGadget(DeathFrostLord.class),
|
||||
manager.getGadget(DoubleJumpFrostLord.class),
|
||||
|
@ -12,7 +12,7 @@ public class SetMusic extends GadgetSet
|
||||
|
||||
public SetMusic(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Ultimate Music Collection", /*"Press Shift to shoot a blast of music particles. People hit by the blast hear music for 15 seconds. 5 minute cooldown."*/ "Coming soon...",
|
||||
super(manager, "Ultimate Music Collection", /*"Press Shift to shoot a blast of music particles. People hit by the blast hear music for 15 seconds. 5 minute cooldown."*/ "2x Peaceful Points while active (Titles)",
|
||||
manager.getGadget(ArrowTrailMusic.class),
|
||||
manager.getGadget(DeathMusic.class),
|
||||
manager.getGadget(DoubleJumpMusic.class),
|
||||
|
@ -12,7 +12,7 @@ public class SetParty extends GadgetSet
|
||||
|
||||
public SetParty(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Party", /*"Improved Party Time"*/ "Coming soon...",
|
||||
super(manager, "Party", /*"Improved Party Time"*/ "2x Party Points while active (Titles)",
|
||||
manager.getGadget(ArrowTrailConfetti.class),
|
||||
manager.getGadget(DeathPinataBurst.class),
|
||||
manager.getGadget(DoubleJumpFirecracker.class),
|
||||
|
@ -12,7 +12,7 @@ public class SetVampire extends GadgetSet
|
||||
|
||||
public SetVampire(GadgetManager manager)
|
||||
{
|
||||
super(manager, "The Vampire 2000", /*"Press Shift to turn into a bat and be able to fly for 10 seconds. 5 Minute cooldown."*/ "Coming soon...",
|
||||
super(manager, "Blood", /*"Press Shift to turn into a bat and be able to fly for 10 seconds. 5 Minute cooldown."*/ "2x Warrior Points while active (Titles)",
|
||||
manager.getGadget(ArrowTrailBlood.class),
|
||||
manager.getGadget(DeathBlood.class),
|
||||
manager.getGadget(DoubleJumpBlood.class),
|
||||
|
@ -12,7 +12,7 @@ public class SetWisdom extends GadgetSet
|
||||
|
||||
public SetWisdom(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Wisdom", /*"Wearing the full Wisdom set when opening a chest slightly increases your chest roll %."*/ "Coming soon...",
|
||||
super(manager, "Wisdom", /*"Wearing the full Wisdom set when opening a chest slightly increases your chest roll %."*/ "2x Treasure Points while active (Titles)",
|
||||
manager.getGadget(ArrowTrailEnchant.class),
|
||||
manager.getGadget(DeathEnchant.class),
|
||||
manager.getGadget(DoubleJumpEnchant.class),
|
||||
|
@ -238,7 +238,6 @@ public abstract class WinEffectGadget extends Gadget
|
||||
p.setAllowFlight(false);
|
||||
p.setHealth(p.getMaxHealth());
|
||||
p.setFoodLevel(20);
|
||||
Manager.disableAll(p, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,5 +1,9 @@
|
||||
package mineplex.core.game;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
|
||||
@ -163,4 +167,21 @@ public enum GameDisplay
|
||||
return _lobbyName;
|
||||
}
|
||||
|
||||
private static final Map<Integer, GameDisplay> BY_ID;
|
||||
|
||||
static
|
||||
{
|
||||
Map<Integer, GameDisplay> byId = new HashMap<>();
|
||||
for (GameDisplay gameDisplay : values())
|
||||
{
|
||||
byId.put(gameDisplay.getGameId(), gameDisplay);
|
||||
}
|
||||
BY_ID = Collections.unmodifiableMap(byId);
|
||||
}
|
||||
|
||||
public static GameDisplay getById(int id)
|
||||
{
|
||||
return BY_ID.get(id);
|
||||
}
|
||||
|
||||
}
|
@ -20,7 +20,7 @@ import java.util.Map;
|
||||
public enum Preference
|
||||
{
|
||||
|
||||
HUB_GAMES(true, PreferenceCategory.USER, Material.FIREBALL, "Hub Player Stacker"),
|
||||
HUB_GAMES(true, PreferenceCategory.USER, Material.FIREBALL, "Hub Games"),
|
||||
SHOW_PLAYERS(true, PreferenceCategory.USER, Material.EYE_OF_ENDER, "Hub Player Visibility"),
|
||||
SHOW_CHAT(true, PreferenceCategory.USER, Material.PAPER, "Player Chat"),
|
||||
PRIVATE_MESSAGING(true, PreferenceCategory.USER, Material.MAP, "Private Messaging"),
|
||||
|
@ -1,10 +1,13 @@
|
||||
package mineplex.core.rankGiveaway.eternal;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
public class EternalCommand extends CommandBase<EternalGiveawayManager>
|
||||
{
|
||||
@ -16,10 +19,28 @@ public class EternalCommand extends CommandBase<EternalGiveawayManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
Plugin.attemptToGiveEternal(caller, () ->
|
||||
if (args.length == 0)
|
||||
{
|
||||
Location location = caller.getLocation().add(0.5, 0.5, 0.5);
|
||||
new EternalGiveawayAnimation(Plugin, location, 3000L);
|
||||
});
|
||||
Plugin.attemptToGiveEternal(caller, () ->
|
||||
{
|
||||
Location location = caller.getLocation().add(0.5, 0.5, 0.5);
|
||||
new EternalGiveawayAnimation(Plugin, location, 3000L);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
String target = args[1];
|
||||
Player player = Bukkit.getPlayer(target);
|
||||
if (player == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Eternal", "That player is not online"));
|
||||
return;
|
||||
}
|
||||
Plugin.attemptToGiveEternal(player, () ->
|
||||
{
|
||||
Location location = caller.getLocation().add(0.5, 0.5, 0.5);
|
||||
new EternalGiveawayAnimation(Plugin, location, 3000L);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
|
||||
public class EternalGiveawayManager extends MiniPlugin
|
||||
public class EternalGiveawayManager extends MiniPlugin
|
||||
{
|
||||
|
||||
private static final double RANK_FIND_CHANCE = 0.001;
|
||||
|
@ -20,7 +20,7 @@ public class EternalGiveawayRepository extends MinecraftRepository
|
||||
|
||||
public EternalGiveawayRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.getAccount());
|
||||
super(DBPool.getAccount());
|
||||
_eternalCount = 0;
|
||||
}
|
||||
|
||||
|
@ -38,9 +38,9 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
|
||||
private CoreClientManager _clientManager;
|
||||
private DonationManager _donationManager;
|
||||
private String _name;
|
||||
private Map<String, ShopPageBase<PluginType, ? extends ShopBase<PluginType>>> _playerPageMap = new HashMap<>();
|
||||
private Map<UUID, ShopPageBase<PluginType, ? extends ShopBase<PluginType>>> _playerPageMap = new HashMap<>();
|
||||
|
||||
private Set<String> _openedShop = new HashSet<>();
|
||||
private Set<UUID> _openedShop = new HashSet<>();
|
||||
|
||||
public ShopBase(PluginType plugin, CoreClientManager clientManager, DonationManager donationManager, String name)
|
||||
{
|
||||
@ -150,14 +150,14 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
|
||||
{
|
||||
if (_playerPageMap.containsKey(event.getPlayer().getUniqueId()) && _playerPageMap.get(event.getPlayer().getUniqueId()).getTitle() != null && _playerPageMap.get(event.getPlayer().getUniqueId()).getTitle().equalsIgnoreCase(event.getInventory().getTitle()))
|
||||
{
|
||||
_playerPageMap.get(event.getPlayer().getName()).playerClosed();
|
||||
_playerPageMap.get(event.getPlayer().getName()).dispose();
|
||||
_playerPageMap.get(event.getPlayer().getUniqueId()).playerClosed();
|
||||
_playerPageMap.get(event.getPlayer().getUniqueId()).dispose();
|
||||
|
||||
_playerPageMap.remove(event.getPlayer().getName());
|
||||
_playerPageMap.remove(event.getPlayer().getUniqueId());
|
||||
|
||||
closeShopForPlayer((Player) event.getPlayer());
|
||||
|
||||
_openedShop.remove(event.getPlayer().getName());
|
||||
_openedShop.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,14 +169,14 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
|
||||
|
||||
if (_playerPageMap.containsKey(event.getPlayer().getUniqueId()) && _playerPageMap.get(event.getPlayer().getUniqueId()).getTitle() != null && _playerPageMap.get(event.getPlayer().getUniqueId()).getTitle().equalsIgnoreCase(event.getInventory().getTitle()))
|
||||
{
|
||||
_playerPageMap.get(event.getPlayer().getName()).playerClosed();
|
||||
_playerPageMap.get(event.getPlayer().getName()).dispose();
|
||||
_playerPageMap.get(event.getPlayer().getUniqueId()).playerClosed();
|
||||
_playerPageMap.get(event.getPlayer().getUniqueId()).dispose();
|
||||
|
||||
_playerPageMap.remove(event.getPlayer().getName());
|
||||
_playerPageMap.remove(event.getPlayer().getUniqueId());
|
||||
|
||||
closeShopForPlayer((Player) event.getPlayer());
|
||||
|
||||
_openedShop.remove(event.getPlayer().getName());
|
||||
_openedShop.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,15 +194,15 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
|
||||
{
|
||||
if (_playerPageMap.containsKey(event.getPlayer().getUniqueId()))
|
||||
{
|
||||
_playerPageMap.get(event.getPlayer().getName()).playerClosed();
|
||||
_playerPageMap.get(event.getPlayer().getName()).dispose();
|
||||
_playerPageMap.get(event.getPlayer().getUniqueId()).playerClosed();
|
||||
_playerPageMap.get(event.getPlayer().getUniqueId()).dispose();
|
||||
|
||||
event.getPlayer().closeInventory();
|
||||
closeShopForPlayer(event.getPlayer());
|
||||
|
||||
_playerPageMap.remove(event.getPlayer().getName());
|
||||
_playerPageMap.remove(event.getPlayer().getUniqueId());
|
||||
|
||||
_openedShop.remove(event.getPlayer().getName());
|
||||
_openedShop.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTasks;
|
||||
import mineplex.core.stats.command.GiveStatCommand;
|
||||
import mineplex.core.stats.command.MasterBuilderUnban;
|
||||
import mineplex.core.stats.command.SetLevelCommand;
|
||||
import mineplex.core.stats.command.TimeCommand;
|
||||
import mineplex.core.stats.event.StatChangeEvent;
|
||||
import mineplex.core.thread.ThreadPool;
|
||||
@ -52,7 +53,7 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
|
||||
UtilScheduler.runAsyncEvery(UpdateType.SEC, () ->
|
||||
{
|
||||
save(_statUploadQueue, _repository::saveStats, "normal");
|
||||
save(_statUploadQueue, _repository::saveStats, "increment");
|
||||
save(_statUploadQueueOverRidable, map -> _repository.saveStats(map, true), "override");
|
||||
});
|
||||
|
||||
@ -99,11 +100,13 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
if (value < 0)
|
||||
return;
|
||||
|
||||
CoreClient client = _coreClientManager.Get(player);
|
||||
|
||||
long oldValue = Get(player).getStat(statName);
|
||||
long newValue = Get(player).addStat(statName, value);
|
||||
|
||||
UtilServer.getServer().getPluginManager().callEvent(new StatChangeEvent(player.getName(), statName, oldValue, newValue));
|
||||
registerNewStat(statName, () -> addToQueue(statName, player, value));
|
||||
UtilServer.getServer().getPluginManager().callEvent(new StatChangeEvent(player, statName, oldValue, newValue));
|
||||
registerNewStat(statName, () -> addToQueue(statName, client, value));
|
||||
}
|
||||
|
||||
|
||||
@ -117,11 +120,13 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
if (value < 0)
|
||||
return;
|
||||
|
||||
CoreClient client = _coreClientManager.Get(player);
|
||||
|
||||
long oldValue = Get(player).getStat(statName);
|
||||
Get(player).setStat(statName, value);
|
||||
|
||||
UtilServer.getServer().getPluginManager().callEvent(new StatChangeEvent(player.getName(), statName, oldValue, value));
|
||||
registerNewStat(statName, () -> addToOverRidableQueue(statName, player, value));
|
||||
UtilServer.getServer().getPluginManager().callEvent(new StatChangeEvent(player, statName, oldValue, value));
|
||||
registerNewStat(statName, () -> addToOverRidableQueue(statName, client, value));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,22 +162,34 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
});
|
||||
}
|
||||
|
||||
private void addToOverRidableQueue(String statName, Player player, long value)
|
||||
private void addToOverRidableQueue(String statName, CoreClient client, long value)
|
||||
{
|
||||
if (client.getAccountId() == -1)
|
||||
{
|
||||
System.out.println(String.format("Error: Tried to add %s/%s to overridable queue with -1 account id", client.getName(), client.getUniqueId()));
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (STATS_LOCK)
|
||||
{
|
||||
_statUploadQueueOverRidable
|
||||
.computeIfAbsent(_coreClientManager.Get(player), key -> new HashMap<>())
|
||||
.computeIfAbsent(client, key -> new HashMap<>())
|
||||
.put(statName, value);
|
||||
}
|
||||
}
|
||||
|
||||
private void addToQueue(String statName, Player player, long value)
|
||||
private void addToQueue(String statName, CoreClient client, long value)
|
||||
{
|
||||
if (client.getAccountId() == -1)
|
||||
{
|
||||
System.out.println(String.format("Error: Tried to add %s/%s to increment queue with -1 account id", client.getName(), client.getUniqueId()));
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (STATS_LOCK)
|
||||
{
|
||||
_statUploadQueue
|
||||
.computeIfAbsent(_coreClientManager.Get(player), key -> new HashMap<>())
|
||||
.computeIfAbsent(client, key -> new HashMap<>())
|
||||
.merge(statName, value, Long::sum);
|
||||
}
|
||||
}
|
||||
@ -196,13 +213,16 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
|
||||
Map<Integer, Long> uploadStats = uploadQueue.computeIfAbsent(client.getAccountId(), key -> new HashMap<>());
|
||||
|
||||
entry.getValue().forEach((statName, amount) ->
|
||||
entry.getValue().entrySet()
|
||||
.stream()
|
||||
.sorted(Map.Entry.comparingByKey())
|
||||
.forEach(ent ->
|
||||
{
|
||||
// Sanity check
|
||||
if (_stats.containsKey(statName))
|
||||
if (_stats.containsKey(ent.getKey()))
|
||||
{
|
||||
uploadStats.merge(_stats.get(statName), amount, Long::sum);
|
||||
System.out.println(String.format("Saving stat '%s' for '%s', value '%s', type '%s'", statName, client.getName(), uploadStats.get(_stats.get(statName)), type));
|
||||
uploadStats.merge(_stats.get(ent.getKey()), ent.getValue(), Long::sum);
|
||||
System.out.println(String.format("Saving stat '%s' for '%s', value '%s', type '%s'", ent.getKey(), client.getName() == null ? client.getUniqueId().toString() : client.getName(), uploadStats.get(_stats.get(ent.getKey())), type));
|
||||
}
|
||||
});
|
||||
|
||||
@ -273,6 +293,7 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
{
|
||||
addCommand(new TimeCommand(this));
|
||||
addCommand(new GiveStatCommand(this));
|
||||
addCommand(new SetLevelCommand(this));
|
||||
addCommand(new MasterBuilderUnban(this));
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Insert;
|
||||
@ -125,12 +126,13 @@ public class StatsRepository extends MinecraftRepository
|
||||
inserts.set(i, null);
|
||||
}
|
||||
|
||||
inserts.removeAll(Collections.singleton(null));
|
||||
inserts.removeIf(Objects::isNull);
|
||||
|
||||
context.batch(inserts).execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("Failed to save stats: " + uploadQueue);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package mineplex.core.stats.command;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -21,43 +21,45 @@ public class GiveStatCommand extends CommandBase<StatsManager>
|
||||
{
|
||||
if (args.length < 3)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Stats", "/givestat <Target> <Name> <Amount>"));
|
||||
UtilPlayer.message(caller, F.main("Stats", "/givestat [player] [amount] [stat name]"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Player player = UtilPlayer.searchOnline(caller, args[0], true);
|
||||
|
||||
int amount;
|
||||
|
||||
try
|
||||
{
|
||||
Player player = UtilPlayer.searchOnline(caller, args[0], true);
|
||||
|
||||
String tempStatName = args[1];
|
||||
|
||||
for (int i = 2; i < args.length - 1; i++)
|
||||
{
|
||||
tempStatName += " " + args[i];
|
||||
}
|
||||
|
||||
final String statName = tempStatName;
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
Plugin.getClientManager().loadClientByName(args[0], client ->
|
||||
{
|
||||
if (client != null)
|
||||
Plugin.incrementStat(client.getAccountId(), statName, Long.parseLong(args[args.length - 1]));
|
||||
else
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + args[0] + "'s account!"));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.incrementStat(player, statName, Integer.parseInt(args[args.length - 1]));
|
||||
}
|
||||
|
||||
UtilPlayer.message(caller, F.main("Stats", "Applied " + F.elem(Integer.parseInt(args[args.length - 1]) + " " + statName) + " to " + F.elem(player == null ? args[0] : player.getName()) + "."));
|
||||
amount = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Stats", "/givestat <Name> <Amount>"));
|
||||
UtilPlayer.message(caller, F.main("Stats", F.elem(args[1]) + " is not a number"));
|
||||
return;
|
||||
}
|
||||
|
||||
String statName = StringUtils.join(args, " ", 2, args.length);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
Plugin.getClientManager().loadClientByName(args[0], client ->
|
||||
{
|
||||
if (client != null)
|
||||
{
|
||||
Plugin.incrementStat(client.getAccountId(), statName, amount);
|
||||
UtilPlayer.message(caller, F.main("Stats", "Applied " + F.elem(amount + " " + statName) + " to " + F.elem(args[0]) + "."));
|
||||
}
|
||||
else
|
||||
{
|
||||
caller.sendMessage(F.main("Stats", "Couldn't find " + args[0] + "'s account!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.incrementStat(player, statName, amount);
|
||||
UtilPlayer.message(caller, F.main("Stats", "Applied " + F.elem(amount + " " + statName) + " to " + F.elem(player.getName()) + "."));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +1,15 @@
|
||||
package mineplex.core.stats.command;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MasterBuilderUnban extends CommandBase<StatsManager>
|
||||
{
|
||||
|
||||
public MasterBuilderUnban(StatsManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "buildunban");
|
||||
@ -24,75 +18,50 @@ public class MasterBuilderUnban extends CommandBase<StatsManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if(args.length != 1)
|
||||
if (args.length != 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("MasterBuilder Unban", "/buildunban <Target>"));
|
||||
UtilPlayer.message(caller, F.main("MasterBuilder Unban", "/buildunban [player]"));
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
Plugin.getClientManager().getRepository().matchPlayerName(matches ->
|
||||
{
|
||||
Plugin.getClientManager().getRepository().matchPlayerName(new Callback<List<String>>()
|
||||
boolean matchedExact = false;
|
||||
|
||||
for (String match : matches)
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run(List<String> matches)
|
||||
if (match.equalsIgnoreCase(args[0]))
|
||||
{
|
||||
boolean matchedExact = false;
|
||||
|
||||
for (String match : matches)
|
||||
{
|
||||
if (match.equalsIgnoreCase(args[0]))
|
||||
{
|
||||
matchedExact = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedExact)
|
||||
{
|
||||
for (Iterator<String> matchIterator = matches.iterator(); matchIterator.hasNext();)
|
||||
{
|
||||
if (!matchIterator.next().equalsIgnoreCase(args[0]))
|
||||
{
|
||||
matchIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
UtilPlayer.searchOffline(matches, new Callback<String>()
|
||||
{
|
||||
@Override
|
||||
public void run(String target)
|
||||
{
|
||||
if(target == null)
|
||||
{
|
||||
caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + args[0] + "'s account!"));
|
||||
return;
|
||||
}
|
||||
Plugin.getClientManager().loadClientByName(target, theClient ->
|
||||
{
|
||||
if(theClient != null)
|
||||
{
|
||||
Plugin.setStat(theClient.getAccountId(), "Global.Build Draw Abuse", 0);
|
||||
caller.sendMessage(F.main("MasterBuilder Unban", "The user " + target + " has been unbanned from Master Builders"));
|
||||
}
|
||||
else
|
||||
{
|
||||
caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + target + "'s client!"));
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
}, caller, args[0], false);
|
||||
matchedExact = true;
|
||||
}
|
||||
|
||||
}, args[0]);
|
||||
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
caller.sendMessage(F.main("MasterBuilder Unban", "Exception caught! Please contact Morten and explain what happened."));
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedExact)
|
||||
{
|
||||
matches.removeIf(s -> !s.equalsIgnoreCase(args[0]));
|
||||
}
|
||||
|
||||
UtilPlayer.searchOffline(matches, target ->
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + F.elem(args[0]) + "'s account!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.getClientManager().loadClientByName(target, theClient ->
|
||||
{
|
||||
if (theClient == null)
|
||||
{
|
||||
caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + F.elem(target) + "'s client!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.setStat(theClient.getAccountId(), "Global.Build Draw Abuse", 0);
|
||||
caller.sendMessage(F.main("MasterBuilder Unban", "The user " + F.elem(target) + " has been unbanned from Master Builders"));
|
||||
});
|
||||
}, caller, args[0], false);
|
||||
}, args[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,63 @@
|
||||
package mineplex.core.stats.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.achievement.Achievement;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
|
||||
public class SetLevelCommand extends CommandBase<StatsManager>
|
||||
{
|
||||
public SetLevelCommand(StatsManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "setlevel");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length != 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Stats", "/setlevel [player] [level]"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player target = UtilPlayer.searchOnline(caller, args[0], true);
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int level;
|
||||
|
||||
try
|
||||
{
|
||||
level = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Stats", F.elem(args[1]) + " is not a number"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (level < 0 || level > 100)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Stats", "That level is invalid"));
|
||||
return;
|
||||
}
|
||||
|
||||
int amountNeeded = 0;
|
||||
|
||||
for (int i = 0; i < level; i++)
|
||||
{
|
||||
amountNeeded += Achievement.GLOBAL_MINEPLEX_LEVEL.getLevels()[i];
|
||||
}
|
||||
|
||||
Plugin.setStat(target, Achievement.GLOBAL_MINEPLEX_LEVEL.getStats()[0], amountNeeded);
|
||||
UtilPlayer.message(caller, F.main("Stats", "Updated " + F.elem(target.getName()) + "'s level to " + F.elem(level)));
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package mineplex.core.stats.command;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -12,9 +12,6 @@ import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 10/2/2014.
|
||||
*/
|
||||
public class TimeCommand extends CommandBase<StatsManager>
|
||||
{
|
||||
public TimeCommand(StatsManager plugin)
|
||||
@ -25,34 +22,34 @@ public class TimeCommand extends CommandBase<StatsManager>
|
||||
@Override
|
||||
public void Execute(final Player caller, final String[] args)
|
||||
{
|
||||
if (args == null || args.length == 0)
|
||||
if (args.length == 0)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Time", "Usage: /time <playerName>"));
|
||||
UtilPlayer.message(caller, F.main("Time", "/time [player]"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Player target = UtilPlayer.searchOnline(caller, args[0], false);
|
||||
|
||||
if (target == null)
|
||||
Player target = UtilPlayer.searchOnline(caller, args[0], true);
|
||||
|
||||
Consumer<PlayerStats> statsConsumer = stats ->
|
||||
{
|
||||
if (stats == null)
|
||||
{
|
||||
Plugin.getOfflinePlayerStats(args[0], stats ->
|
||||
{
|
||||
if (stats == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Time", "Player " + F.elem(args[0]) + " not found!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
long time = stats.getStat("Global.TimeInGame");
|
||||
UtilPlayer.message(caller, F.main("Time", F.name(args[0]) + " has spent " + F.elem(UtilTime.convertString(time * 1000L, 1, UtilTime.TimeUnit.FIT)) + " in game"));
|
||||
}
|
||||
});
|
||||
UtilPlayer.message(caller, F.main("Time", "Player " + F.elem(args[0]) + " not found!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
long time = Plugin.Get(target).getStat("Global.TimeInGame");
|
||||
UtilPlayer.message(caller, F.main("Time", F.name(target.getName()) + " has spent " + F.elem(UtilTime.convertString(time * 1000L, 1, UtilTime.TimeUnit.FIT)) + " in game"));
|
||||
long time = stats.getStat("Global.TimeInGame");
|
||||
UtilPlayer.message(caller, F.main("Time", F.name(args[0]) + " has spent " + F.elem(UtilTime.convertString(time * 1000L, 1, UtilTime.TimeUnit.FIT)) + " in game"));
|
||||
}
|
||||
};
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
Plugin.getOfflinePlayerStats(args[0], statsConsumer);
|
||||
}
|
||||
else
|
||||
{
|
||||
statsConsumer.accept(Plugin.Get(target));
|
||||
}
|
||||
}
|
||||
}
|
@ -2,53 +2,47 @@ package mineplex.core.stats.event;
|
||||
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
public class StatChangeEvent extends Event
|
||||
public class StatChangeEvent extends PlayerEvent
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private String _player;
|
||||
private String _statName;
|
||||
private long _valueBefore;
|
||||
private long _valueAfter;
|
||||
|
||||
public StatChangeEvent(String player, String statName, long valueBefore, long valueAfter)
|
||||
{
|
||||
_player = player;
|
||||
_statName = statName;
|
||||
_valueBefore = valueBefore;
|
||||
_valueAfter = valueAfter;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public String getPlayerName()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public String getStatName()
|
||||
{
|
||||
return _statName;
|
||||
}
|
||||
|
||||
public long getValueBefore()
|
||||
{
|
||||
return _valueBefore;
|
||||
}
|
||||
|
||||
public long getValueAfter()
|
||||
{
|
||||
return _valueAfter;
|
||||
}
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private String _statName;
|
||||
private long _valueBefore;
|
||||
private long _valueAfter;
|
||||
|
||||
public StatChangeEvent(Player player, String statName, long valueBefore, long valueAfter)
|
||||
{
|
||||
super(player);
|
||||
_statName = statName;
|
||||
_valueBefore = valueBefore;
|
||||
_valueAfter = valueAfter;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public String getStatName()
|
||||
{
|
||||
return _statName;
|
||||
}
|
||||
|
||||
public long getValueBefore()
|
||||
{
|
||||
return _valueBefore;
|
||||
}
|
||||
|
||||
public long getValueAfter()
|
||||
{
|
||||
return _valueAfter;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
package mineplex.core.titles;
|
||||
|
||||
public class TitleData
|
||||
{
|
||||
private final String _selectedTitle;
|
||||
|
||||
public TitleData(String selectedTitle)
|
||||
{
|
||||
this._selectedTitle = selectedTitle;
|
||||
}
|
||||
|
||||
public String getTrackId()
|
||||
{
|
||||
return _selectedTitle;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package mineplex.core.titles;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@ -10,6 +11,7 @@ import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
@ -18,6 +20,7 @@ import net.minecraft.server.v1_8_R3.EntityArmorStand;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R3.EntitySlime;
|
||||
import net.minecraft.server.v1_8_R3.Items;
|
||||
import net.minecraft.server.v1_8_R3.MathHelper;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutHeldItemSlot;
|
||||
@ -25,6 +28,7 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutNewAttachEntity;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems;
|
||||
import net.minecraft.server.v1_8_R3.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -40,18 +44,20 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.book.BookBuilder;
|
||||
import mineplex.core.book.PageBuilder;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.DummyEntity;
|
||||
import mineplex.core.common.MinecraftVersion;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
@ -61,44 +67,98 @@ import mineplex.core.titles.tracks.Track;
|
||||
import mineplex.core.titles.tracks.TrackManager;
|
||||
import mineplex.core.titles.tracks.TrackTier;
|
||||
|
||||
/**
|
||||
* This manager handles displaying titles above a player's head, as well as their tracks
|
||||
*/
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class Titles extends MiniPlugin implements IPacketHandler
|
||||
public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHandler
|
||||
{
|
||||
private static final int BOOK_SLOT = 2;
|
||||
public static int BOOK_SLOT = 7;
|
||||
|
||||
private Map<Integer, Map<UUID, Integer>> _ids = new HashMap<>();
|
||||
private Map<Integer, Map<UUID, List<Integer>>> _remove = new HashMap<>();
|
||||
private Map<Integer, Track> _titles = new HashMap<>();
|
||||
// Maps player to their selected track
|
||||
private final Map<UUID, Track> _selectedTrack = new HashMap<>();
|
||||
|
||||
private final TrackManager _trackManager;
|
||||
// Maps player to map of player and the id for the armorstand nametag
|
||||
private final Map<Integer, Map<UUID, Integer>> _armorStandIds = new HashMap<>();
|
||||
// Maps player to map of player and all ids that it owns
|
||||
private final Map<Integer, Map<UUID, List<Integer>>> _allIds = new HashMap<>();
|
||||
|
||||
private final TrackManager _trackManager = require(TrackManager.class);
|
||||
private final TitlesRepository _titlesRepository = new TitlesRepository();
|
||||
|
||||
private final BaseComponent[] CLICK_ENABLE_TRACK = new ComponentBuilder("")
|
||||
.append("Click to enable this track")
|
||||
.color(ChatColor.GREEN)
|
||||
.create();
|
||||
|
||||
private final BaseComponent[] CLICK_DISABLE_TRACK = new ComponentBuilder("")
|
||||
.append("Click to disable this track")
|
||||
.color(ChatColor.RED)
|
||||
.create();
|
||||
|
||||
private static final BaseComponent[] RETURN_TO_TABLE_OF_CONTENTS = new ComponentBuilder("")
|
||||
.append("Click to return to Table of Contents")
|
||||
.color(ChatColor.YELLOW)
|
||||
.create();
|
||||
|
||||
private boolean _disabled;
|
||||
|
||||
private Titles()
|
||||
{
|
||||
super("Titles");
|
||||
require(PacketHandler.class).addPacketHandler(this, PacketHandler.ListenerPriority.LOW, PacketPlayOutNamedEntitySpawn.class, PacketPlayOutEntityDestroy.class);
|
||||
super("Titles", UtilServer.getPlugin(), Managers.require(CoreClientManager.class));
|
||||
|
||||
_trackManager = require(TrackManager.class);
|
||||
require(PacketHandler.class).addPacketHandler(this, PacketHandler.ListenerPriority.LOW, PacketPlayOutNamedEntitySpawn.class, PacketPlayOutEntityDestroy.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException
|
||||
{
|
||||
if (resultSet.next())
|
||||
{
|
||||
Set(uuid, new TitleData(resultSet.getString(1)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery(int accountId, String uuid, String name)
|
||||
{
|
||||
return "SELECT trackName FROM accountTitle WHERE accountId = '" + accountId + "';";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TitleData addPlayer(UUID uuid)
|
||||
{
|
||||
return new TitleData(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new TrackCommand(this));
|
||||
|
||||
}
|
||||
|
||||
public void setTrackForPlayer(Player player, Track track)
|
||||
{
|
||||
setTitle(player, track);
|
||||
giveBook(player, true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event)
|
||||
private void onJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (Get(event.getPlayer()) != null)
|
||||
{
|
||||
Track track = _trackManager.getTrackById(Get(event.getPlayer()).getTrackId());
|
||||
if (track != null)
|
||||
{
|
||||
setActiveTrack(event.getPlayer(), track);
|
||||
}
|
||||
}
|
||||
giveBook(event.getPlayer(), false);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onQuit(PlayerQuitEvent event)
|
||||
{
|
||||
_armorStandIds.values().forEach(map -> map.keySet().removeIf(key -> key.equals(event.getPlayer().getUniqueId())));
|
||||
_allIds.values().forEach(map -> map.keySet().removeIf(key -> key.equals(event.getPlayer().getUniqueId())));
|
||||
_selectedTrack.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onInteract(PlayerInteractEvent event)
|
||||
{
|
||||
@ -113,16 +173,56 @@ public class Titles extends MiniPlugin implements IPacketHandler
|
||||
{
|
||||
if (event.isSneaking())
|
||||
{
|
||||
Track type = _titles.remove(event.getPlayer().getEntityId());
|
||||
updateTitle(event.getPlayer());
|
||||
_titles.put(event.getPlayer().getEntityId(), type);
|
||||
updateTitle(event.getPlayer(), null);
|
||||
}
|
||||
else
|
||||
{
|
||||
updateTitle(event.getPlayer());
|
||||
updateTitle(event.getPlayer(), getActiveTrack(event.getPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
public void setOrToggleTrackForPlayer(Player player, Track track, boolean clickedBook)
|
||||
{
|
||||
if (_disabled)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Track", "Tracks are disabled right now!"));
|
||||
return;
|
||||
}
|
||||
|
||||
setActiveTrack(player, track);
|
||||
|
||||
if (getActiveTrack(player) != null)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Track", "Your active track has been updated to " + track.getColor() + track.getLongName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Track", "Your have disabled your active track"));
|
||||
}
|
||||
|
||||
giveBook(player, clickedBook);
|
||||
|
||||
runAsync(() ->
|
||||
{
|
||||
_titlesRepository.savePlayerSelection(player, getActiveTrack(player));
|
||||
});
|
||||
}
|
||||
|
||||
public Track getActiveTrack(Player player)
|
||||
{
|
||||
return _selectedTrack.get(player.getUniqueId());
|
||||
}
|
||||
|
||||
public void giveBookIfNotExists(Player player, boolean open)
|
||||
{
|
||||
if (player.getInventory().getItem(BOOK_SLOT) != null && player.getInventory().getItem(BOOK_SLOT).getType() == Material.WRITTEN_BOOK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
giveBook(player, open);
|
||||
}
|
||||
|
||||
public void giveBook(Player player, boolean open)
|
||||
{
|
||||
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
||||
@ -136,82 +236,138 @@ public class Titles extends MiniPlugin implements IPacketHandler
|
||||
book = new net.minecraft.server.v1_8_R3.ItemStack(Items.WRITTEN_BOOK);
|
||||
((CraftPlayer) player).getHandle().inventory.setItem(BOOK_SLOT, book);
|
||||
}
|
||||
BookBuilder bookBuilder = BookBuilder.newBuilder()
|
||||
.title("Titles")
|
||||
.author("Mineplex Games");
|
||||
|
||||
List<PageBuilder> pages = new ArrayList<>();
|
||||
List<Track> tracks = _trackManager.getAllTracks();
|
||||
|
||||
for (Track track : tracks)
|
||||
tracks.removeIf(track -> track.getRequirements().getTier(player) == null && track.hideIfUnowned());
|
||||
|
||||
tracks.sort((a, b) ->
|
||||
{
|
||||
ComponentBuilder trackHover = new ComponentBuilder("")
|
||||
.append(track.getLongName())
|
||||
.color(track.getColor())
|
||||
.bold(true)
|
||||
.append("\n\n", ComponentBuilder.FormatRetention.NONE)
|
||||
.append(
|
||||
Arrays.stream(
|
||||
UtilText.splitLineToArray(track.getDescription(), LineFormat.LORE)
|
||||
).collect(Collectors.joining("\n")),
|
||||
ComponentBuilder.FormatRetention.NONE
|
||||
)
|
||||
.color(ChatColor.WHITE)
|
||||
.append("\n\n", ComponentBuilder.FormatRetention.NONE);
|
||||
if (track.getRequirements().getTier(player) != null)
|
||||
if (a.hideIfUnowned() && !b.hideIfUnowned())
|
||||
{
|
||||
if (_titles.get(player.getEntityId()) == track)
|
||||
{
|
||||
trackHover
|
||||
.append("Click to disable: ", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
trackHover
|
||||
.append("Click to enable: ", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.GREEN);
|
||||
}
|
||||
TrackTier tier = track.getRequirements().getTier(player);
|
||||
trackHover.append(tier.getTitle())
|
||||
.color(tier.getColor());
|
||||
return -1;
|
||||
}
|
||||
else if (!a.hideIfUnowned() && b.hideIfUnowned())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
trackHover
|
||||
.append("You have not unlocked any tiers in this track!", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.GRAY);
|
||||
return a.getShortName().compareTo(b.getShortName());
|
||||
}
|
||||
trackHover
|
||||
.append("\n\n", ComponentBuilder.FormatRetention.NONE)
|
||||
.append("ID: ")
|
||||
.color(ChatColor.YELLOW)
|
||||
.append(track.getId(), ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.WHITE);
|
||||
});
|
||||
|
||||
PageBuilder page = bookBuilder.newPage();
|
||||
String bookTitle = C.cGreen + "Titles";
|
||||
|
||||
if (getActiveTrack(player) != null)
|
||||
{
|
||||
Track track = getActiveTrack(player);
|
||||
if (track.getRequirements().getTier(player) != null)
|
||||
{
|
||||
TrackTier tier = track.getRequirements().getTier(player);
|
||||
bookTitle += ChatColor.RESET + " - " + ChatColor.RESET + track.getRequirements().getTier(player).getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
BookBuilder bookBuilder = BookBuilder.newBuilder()
|
||||
.title(bookTitle)
|
||||
.author("Mineplex Games");
|
||||
|
||||
// Build Table of Contents
|
||||
{
|
||||
int pagesRequired = (int) Math.ceil(tracks.size() / 10.0);
|
||||
int currentPage = 1;
|
||||
int current = 0;
|
||||
int trackPage = pagesRequired + 1;
|
||||
while (current < tracks.size())
|
||||
{
|
||||
List<Track> subList = tracks.subList(current, Math.min(current + 10, tracks.size()));
|
||||
|
||||
ComponentBuilder tableOfContentsComponents = new ComponentBuilder("")
|
||||
.append("Table of Contents")
|
||||
.color(ChatColor.DARK_RED)
|
||||
.bold(true)
|
||||
.append("\n", ComponentBuilder.FormatRetention.NONE)
|
||||
.append("Page " + currentPage + "/" + pagesRequired, ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.RED)
|
||||
.append("\n\n", ComponentBuilder.FormatRetention.NONE);
|
||||
|
||||
for (Track track : subList)
|
||||
{
|
||||
if (track.getRequirements().getTier(player) != null)
|
||||
{
|
||||
if (getActiveTrack(player) == track)
|
||||
{
|
||||
tableOfContentsComponents
|
||||
.append("[+]", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.DARK_GREEN)
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, CLICK_DISABLE_TRACK))
|
||||
.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/track " + track.getId() + " open"));
|
||||
}
|
||||
else
|
||||
{
|
||||
tableOfContentsComponents
|
||||
.append("[-]", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.RED)
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, CLICK_ENABLE_TRACK))
|
||||
.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/track " + track.getId() + " open"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tableOfContentsComponents
|
||||
.append("[x]", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.GRAY);
|
||||
}
|
||||
tableOfContentsComponents
|
||||
.append(" ", ComponentBuilder.FormatRetention.NONE)
|
||||
.append(track.getShortName())
|
||||
.color(ChatColor.BLACK)
|
||||
.event(new ClickEvent(ClickEvent.Action.CHANGE_PAGE, String.valueOf(trackPage++)))
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, createTrackHover(player, track, true)));
|
||||
|
||||
if (track.getRequirements().getNextTier(player) == null)
|
||||
{
|
||||
tableOfContentsComponents
|
||||
.append(" ", ComponentBuilder.FormatRetention.NONE)
|
||||
.append("★", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.DARK_AQUA);
|
||||
}
|
||||
tableOfContentsComponents
|
||||
.append("\n", ComponentBuilder.FormatRetention.NONE);
|
||||
}
|
||||
|
||||
bookBuilder.newPage().component(tableOfContentsComponents.create());
|
||||
|
||||
current += 10;
|
||||
currentPage++;
|
||||
}
|
||||
}
|
||||
|
||||
for (Track track : tracks)
|
||||
{
|
||||
ComponentBuilder pageContent = new ComponentBuilder("");
|
||||
pageContent
|
||||
.append("☰")
|
||||
.event(new ClickEvent(ClickEvent.Action.CHANGE_PAGE, "1"))
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, RETURN_TO_TABLE_OF_CONTENTS))
|
||||
.append(" ", ComponentBuilder.FormatRetention.NONE)
|
||||
.append(track.getShortName())
|
||||
.bold(true)
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, trackHover.create()));
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, createTrackHover(player, track, false)));
|
||||
if (track.getRequirements().getTier(player) != null)
|
||||
{
|
||||
if (_titles.get(player.getEntityId()) == track)
|
||||
if (getActiveTrack(player) == track)
|
||||
{
|
||||
pageContent
|
||||
.color(ChatColor.DARK_GREEN)
|
||||
.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/titles " + track.getId()));
|
||||
.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/track " + track.getId() + " open"));
|
||||
}
|
||||
else
|
||||
{
|
||||
pageContent
|
||||
.color(ChatColor.BLACK)
|
||||
.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/titles " + track.getId()));
|
||||
.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/track " + track.getId() + " open"));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -229,8 +385,17 @@ public class Titles extends MiniPlugin implements IPacketHandler
|
||||
TrackTier nextTier = track.getRequirements().getNextTier(player);
|
||||
if (nextTier != null)
|
||||
{
|
||||
ComponentBuilder progressHover = new ComponentBuilder("")
|
||||
.append("Progress: ")
|
||||
.color(ChatColor.YELLOW)
|
||||
.append(String.valueOf(nextTier.get(player)), ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.WHITE)
|
||||
.append("/")
|
||||
.append(String.valueOf(nextTier.getGoal()));
|
||||
|
||||
|
||||
int totalTicks = 20;
|
||||
double progress = nextTier.getProgress(track, player);
|
||||
double progress = nextTier.getProgress(player);
|
||||
String percent = ((int) (progress * 100.0)) + "%";
|
||||
int ticks = ((int) (progress * totalTicks * 1.0));
|
||||
pageContent.append("[", ComponentBuilder.FormatRetention.NONE);
|
||||
@ -239,9 +404,12 @@ public class Titles extends MiniPlugin implements IPacketHandler
|
||||
{
|
||||
pipes.append("|");
|
||||
}
|
||||
BaseComponent[] components = progressHover.create();
|
||||
|
||||
pageContent
|
||||
.append(pipes.toString(), ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.DARK_GREEN);
|
||||
.color(ChatColor.DARK_GREEN)
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, components));
|
||||
pipes.setLength(0);
|
||||
for (int i = ticks; i < totalTicks; i++)
|
||||
{
|
||||
@ -250,6 +418,7 @@ public class Titles extends MiniPlugin implements IPacketHandler
|
||||
pageContent
|
||||
.append(pipes.toString(), ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.GRAY)
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, components))
|
||||
.append("] (" + percent + ")", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.BLACK);
|
||||
}
|
||||
@ -275,26 +444,38 @@ public class Titles extends MiniPlugin implements IPacketHandler
|
||||
.color(track.getColor())
|
||||
.bold(true)
|
||||
.append(" Tier " + rank, ComponentBuilder.FormatRetention.NONE)
|
||||
.color(tier.getColor())
|
||||
.append("\n\n", ComponentBuilder.FormatRetention.NONE)
|
||||
.append(
|
||||
Arrays.stream(
|
||||
UtilText.splitLineToArray(tier.getDescription(), LineFormat.LORE)
|
||||
).collect(Collectors.joining("\n")),
|
||||
ComponentBuilder.FormatRetention.NONE
|
||||
)
|
||||
.append("\n\n", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(tier.getFormat().getColor())
|
||||
.append("\n\n", ComponentBuilder.FormatRetention.NONE);
|
||||
|
||||
if (tier.getDescription() != null)
|
||||
{
|
||||
tierHover
|
||||
.append(
|
||||
Arrays.stream(
|
||||
UtilText.splitLineToArray(tier.getDescription(), LineFormat.LORE)
|
||||
).collect(Collectors.joining("\n")),
|
||||
ComponentBuilder.FormatRetention.NONE
|
||||
)
|
||||
.append("\n\n", ComponentBuilder.FormatRetention.NONE);
|
||||
}
|
||||
tierHover
|
||||
.append("Title: ")
|
||||
.color(ChatColor.YELLOW)
|
||||
.append(tier.getTitle())
|
||||
.color(tier.getColor())
|
||||
.append("\n", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.YELLOW);
|
||||
|
||||
tierHover.append("", ComponentBuilder.FormatRetention.NONE);
|
||||
tier.getFormat().preFormat(tierHover);
|
||||
tierHover.append(tier.getTitle(), ComponentBuilder.FormatRetention.NONE);
|
||||
tier.getFormat().format(tierHover);
|
||||
tierHover.append("", ComponentBuilder.FormatRetention.NONE);
|
||||
tier.getFormat().postFormat(tierHover);
|
||||
|
||||
tierHover.append("\n", ComponentBuilder.FormatRetention.NONE)
|
||||
.append("Progress: ")
|
||||
.color(ChatColor.YELLOW)
|
||||
.append(Math.min(tier.get(track, player), tier.getGoal()) + "/" + tier.getGoal(), ComponentBuilder.FormatRetention.NONE)
|
||||
.append(Math.min(tier.get(player), tier.getGoal()) + "/" + tier.getGoal(), ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.WHITE);
|
||||
|
||||
if (tier.getProgress(track, player) >= 1.0)
|
||||
if (tier.getProgress(player) >= 1.0)
|
||||
{
|
||||
tierHover
|
||||
.append("\n\n", ComponentBuilder.FormatRetention.NONE)
|
||||
@ -304,61 +485,12 @@ public class Titles extends MiniPlugin implements IPacketHandler
|
||||
|
||||
pageContent
|
||||
.append(track.getShortName() + " " + UtilText.toRomanNumeral(rank), ComponentBuilder.FormatRetention.NONE)
|
||||
.color(tier.getProgress(track, player) >= 1.0 ? ChatColor.DARK_GREEN : ChatColor.GRAY)
|
||||
.color(tier.getProgress(player) >= 1.0 ? ChatColor.DARK_GREEN : ChatColor.GRAY)
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, tierHover.create()))
|
||||
.append("\n", ComponentBuilder.FormatRetention.NONE);
|
||||
}
|
||||
|
||||
page.component(pageContent.create());
|
||||
|
||||
pages.add(page);
|
||||
}
|
||||
|
||||
{
|
||||
ComponentBuilder componentBuilder1 = new ComponentBuilder("")
|
||||
.append("Table of Contents")
|
||||
.color(ChatColor.DARK_RED)
|
||||
.bold(true)
|
||||
.append("\n\n", ComponentBuilder.FormatRetention.NONE);
|
||||
|
||||
int pageId = 2;
|
||||
|
||||
for (Track track : tracks.subList(0, Math.min(tracks.size(), 12)))
|
||||
{
|
||||
if (track.getRequirements().getTier(player) != null)
|
||||
{
|
||||
if (_titles.get(player.getEntityId()) == track)
|
||||
{
|
||||
componentBuilder1
|
||||
.append("[✔]", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.DARK_GREEN)
|
||||
.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/titles " + track.getId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
componentBuilder1
|
||||
.append("[✘]", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.RED)
|
||||
.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/titles " + track.getId()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
componentBuilder1
|
||||
.append("[✘]", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.GRAY);
|
||||
}
|
||||
componentBuilder1
|
||||
.append(" ", ComponentBuilder.FormatRetention.NONE)
|
||||
.append(track.getShortName())
|
||||
.color(ChatColor.BLACK)
|
||||
.event(new ClickEvent(ClickEvent.Action.CHANGE_PAGE, String.valueOf(pageId++)))
|
||||
.append("\n", ComponentBuilder.FormatRetention.NONE);
|
||||
}
|
||||
// todo handle more than 13 titles
|
||||
|
||||
PageBuilder tableOfContents = bookBuilder.newPage(0);
|
||||
tableOfContents.component(componentBuilder1.create());
|
||||
bookBuilder.newPage().component(pageContent.create());
|
||||
}
|
||||
|
||||
book.setTag(bookBuilder.toCompound());
|
||||
@ -380,31 +512,116 @@ public class Titles extends MiniPlugin implements IPacketHandler
|
||||
}
|
||||
}
|
||||
|
||||
public void setTitle(Player player, Track type)
|
||||
private BaseComponent[] createTrackHover(Player player, Track track, boolean isMainPage)
|
||||
{
|
||||
if (_titles.get(player.getEntityId()) != type)
|
||||
ComponentBuilder trackHover = new ComponentBuilder("")
|
||||
.append(track.getLongName())
|
||||
.color(track.getColor())
|
||||
.bold(true)
|
||||
.append("\n\n", ComponentBuilder.FormatRetention.NONE)
|
||||
.append(
|
||||
Arrays.stream(
|
||||
UtilText.splitLineToArray(track.getDescription(), LineFormat.LORE)
|
||||
).collect(Collectors.joining("\n")),
|
||||
ComponentBuilder.FormatRetention.NONE
|
||||
)
|
||||
.color(ChatColor.WHITE)
|
||||
.append("\n\n", ComponentBuilder.FormatRetention.NONE);
|
||||
|
||||
if (!isMainPage)
|
||||
{
|
||||
_titles.put(player.getEntityId(), type);
|
||||
track.getRequirements().appendLore(trackHover);
|
||||
|
||||
if (track.getRequirements().getTier(player) != null)
|
||||
{
|
||||
if (getActiveTrack(player) == track)
|
||||
{
|
||||
trackHover
|
||||
.append("Click to disable: ", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
trackHover
|
||||
.append("Click to enable: ", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.GREEN);
|
||||
}
|
||||
TrackTier tier = track.getRequirements().getTier(player);
|
||||
trackHover.append("", ComponentBuilder.FormatRetention.NONE);
|
||||
tier.getFormat().preFormat(trackHover);
|
||||
trackHover.append(tier.getTitle(), ComponentBuilder.FormatRetention.NONE);
|
||||
tier.getFormat().format(trackHover);
|
||||
trackHover.append("", ComponentBuilder.FormatRetention.NONE);
|
||||
tier.getFormat().postFormat(trackHover);
|
||||
}
|
||||
else
|
||||
{
|
||||
trackHover
|
||||
.append("You have not unlocked any tiers in this track!", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.GRAY);
|
||||
}
|
||||
trackHover
|
||||
.append("\n\n", ComponentBuilder.FormatRetention.NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
_titles.remove(player.getEntityId());
|
||||
if (track.getRequirements().getNextTier(player) != null)
|
||||
{
|
||||
TrackTier nextTier = track.getRequirements().getNextTier(player);
|
||||
|
||||
trackHover
|
||||
.append("Progress: ")
|
||||
.color(ChatColor.YELLOW)
|
||||
.append(String.valueOf(nextTier.get(player)), ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.WHITE)
|
||||
.append("/")
|
||||
.append(String.valueOf(nextTier.getGoal()))
|
||||
.append("\n\n");
|
||||
}
|
||||
trackHover
|
||||
.append("Click to view this track", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.GREEN)
|
||||
.append("\n\n", ComponentBuilder.FormatRetention.NONE);
|
||||
}
|
||||
updateTitle(player);
|
||||
trackHover
|
||||
.append("ID: ")
|
||||
.color(ChatColor.YELLOW)
|
||||
.append(track.getId(), ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.WHITE);
|
||||
|
||||
return trackHover.create();
|
||||
}
|
||||
|
||||
private void updateTitle(Player player)
|
||||
public void setActiveTrack(Player player, Track track)
|
||||
{
|
||||
Track type = _titles.get(player.getEntityId());
|
||||
_ids.getOrDefault(player.getEntityId(), Collections.emptyMap()).forEach((uuid, entityId) ->
|
||||
if (track.getRequirements().getTier(player) != null)
|
||||
{
|
||||
if (getActiveTrack(player) != track)
|
||||
{
|
||||
_selectedTrack.put(player.getUniqueId(), track);
|
||||
}
|
||||
else
|
||||
{
|
||||
_selectedTrack.remove(player.getUniqueId());
|
||||
}
|
||||
updateTitle(player, getActiveTrack(player));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTitle(Player player, Track track)
|
||||
{
|
||||
if (_disabled)
|
||||
return;
|
||||
|
||||
_armorStandIds.getOrDefault(player.getEntityId(), Collections.emptyMap()).forEach((uuid, entityId) ->
|
||||
{
|
||||
DataWatcher armorStandWatcher = new DataWatcher(new DummyEntity(((CraftWorld) player.getWorld()).getHandle()));
|
||||
armorStandWatcher.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
|
||||
armorStandWatcher.a(1, (short) 300, net.minecraft.server.v1_8_R3.Entity.META_AIR, 0);
|
||||
if (type != null && type.getRequirements().getTier(player) != null)
|
||||
if (track != null && track.getRequirements().getTier(player) != null)
|
||||
{
|
||||
TrackTier currentTier = type.getRequirements().getTier(player);
|
||||
armorStandWatcher.a(2, currentTier.getColor().toString() + currentTier.getTitle(), net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME, currentTier.getColor().toString() + currentTier.getTitle());
|
||||
TrackTier currentTier = track.getRequirements().getTier(player);
|
||||
armorStandWatcher.a(2, currentTier.getDisplayName(), net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME, currentTier.getDisplayName());
|
||||
armorStandWatcher.a(3, (byte) 1, net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME_VISIBLE, true);
|
||||
}
|
||||
else
|
||||
@ -422,108 +639,23 @@ public class Titles extends MiniPlugin implements IPacketHandler
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event)
|
||||
{
|
||||
_ids.values().forEach(map -> map.keySet().removeIf(key -> key.equals(event.getPlayer().getUniqueId())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketInfo packetInfo)
|
||||
{
|
||||
if (packetInfo.isCancelled())
|
||||
return;
|
||||
|
||||
if (_disabled)
|
||||
return;
|
||||
|
||||
if (packetInfo.getPacket() instanceof PacketPlayOutNamedEntitySpawn)
|
||||
{
|
||||
PacketPlayOutNamedEntitySpawn packet = (PacketPlayOutNamedEntitySpawn) packetInfo.getPacket();
|
||||
|
||||
if (UtilPlayer.getVersion(packetInfo.getPlayer()) != MinecraftVersion.Version1_8)
|
||||
{
|
||||
Track existingTitle = _titles.get(packet.a);
|
||||
|
||||
DataWatcher squidWatcher = new DataWatcher(new DummyEntity(((CraftWorld) packetInfo.getPlayer().getWorld()).getHandle()));
|
||||
squidWatcher.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
|
||||
|
||||
DataWatcher slimeWatcher = new DataWatcher(new DummyEntity(((CraftWorld) packetInfo.getPlayer().getWorld()).getHandle()));
|
||||
slimeWatcher.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
|
||||
slimeWatcher.a(16, -1, EntitySlime.META_SIZE, -1);
|
||||
|
||||
DataWatcher armorStandWatcher = new DataWatcher(new DummyEntity(((CraftWorld) packetInfo.getPlayer().getWorld()).getHandle()));
|
||||
armorStandWatcher.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
|
||||
armorStandWatcher.a(1, (short) 300, net.minecraft.server.v1_8_R3.Entity.META_AIR, 0);
|
||||
if (existingTitle != null)
|
||||
{
|
||||
TrackTier currentTier = existingTitle.getRequirements().getTier((Player) UtilEnt.getEntityById(packet.a));
|
||||
if (currentTier != null)
|
||||
{
|
||||
armorStandWatcher.a(2, currentTier.getColor().toString() + currentTier.getTitle(), net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME, currentTier.getColor().toString() + currentTier.getTitle());
|
||||
armorStandWatcher.a(3, (byte) 1, net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME_VISIBLE, true);
|
||||
}
|
||||
}
|
||||
armorStandWatcher.a(10, (byte) 0x10, EntityArmorStand.META_ARMOR_OPTION, (byte) 0x10); // Small
|
||||
|
||||
PacketPlayOutSpawnEntityLiving spawnSlime = new PacketPlayOutSpawnEntityLiving();
|
||||
spawnSlime.a = UtilEnt.getNewEntityId();
|
||||
spawnSlime.b = EntityType.SLIME.getTypeId();
|
||||
spawnSlime.c = packet.c;
|
||||
spawnSlime.d = -150;
|
||||
spawnSlime.e = packet.e;
|
||||
spawnSlime.i = 0;
|
||||
spawnSlime.j = 0;
|
||||
spawnSlime.k = 0;
|
||||
spawnSlime.f = 0;
|
||||
spawnSlime.g = 0;
|
||||
spawnSlime.h = 0;
|
||||
spawnSlime.uuid = UUID.randomUUID();
|
||||
spawnSlime.l = slimeWatcher;
|
||||
|
||||
PacketPlayOutSpawnEntityLiving spawnSquid = new PacketPlayOutSpawnEntityLiving();
|
||||
spawnSquid.a = UtilEnt.getNewEntityId();
|
||||
spawnSquid.b = EntityType.SQUID.getTypeId();
|
||||
spawnSquid.c = packet.c;
|
||||
spawnSquid.d = -150;
|
||||
spawnSquid.e = packet.e;
|
||||
spawnSquid.i = 0;
|
||||
spawnSquid.j = 0;
|
||||
spawnSquid.k = 0;
|
||||
spawnSquid.f = 0;
|
||||
spawnSquid.g = 0;
|
||||
spawnSquid.h = 0;
|
||||
spawnSquid.uuid = UUID.randomUUID();
|
||||
spawnSquid.l = squidWatcher;
|
||||
|
||||
PacketPlayOutSpawnEntityLiving spawnArmorStand = new PacketPlayOutSpawnEntityLiving();
|
||||
spawnArmorStand.a = UtilEnt.getNewEntityId();
|
||||
spawnArmorStand.b = EntityType.ARMOR_STAND.getTypeId();
|
||||
spawnArmorStand.c = packet.c;
|
||||
spawnArmorStand.d = -150;
|
||||
spawnArmorStand.e = packet.e;
|
||||
spawnArmorStand.i = 0;
|
||||
spawnArmorStand.j = 0;
|
||||
spawnArmorStand.k = 0;
|
||||
spawnArmorStand.f = 0;
|
||||
spawnArmorStand.g = 0;
|
||||
spawnArmorStand.h = 0;
|
||||
spawnArmorStand.uuid = UUID.randomUUID();
|
||||
spawnArmorStand.l = armorStandWatcher;
|
||||
|
||||
PacketPlayOutNewAttachEntity attachSlimeToPlayer = new PacketPlayOutNewAttachEntity(packet.a, new int[]{spawnSlime.a});
|
||||
PacketPlayOutNewAttachEntity attachSquidtoSlime = new PacketPlayOutNewAttachEntity(spawnSlime.a, new int[]{spawnSquid.a});
|
||||
PacketPlayOutNewAttachEntity attachArmorStandToSquid = new PacketPlayOutNewAttachEntity(spawnSquid.a, new int[]{spawnArmorStand.a});
|
||||
|
||||
_ids.computeIfAbsent(packet.a, key -> new HashMap<>()).put(packetInfo.getPlayer().getUniqueId(), spawnArmorStand.a);
|
||||
_remove.computeIfAbsent(packet.a, key -> new HashMap<>()).put(packetInfo.getPlayer().getUniqueId(), Arrays.asList(spawnSlime.a, spawnSquid.a, spawnArmorStand.a));
|
||||
|
||||
runSync(() ->
|
||||
{
|
||||
packetInfo.getVerifier().bypassProcess(spawnSlime);
|
||||
packetInfo.getVerifier().bypassProcess(spawnSquid);
|
||||
packetInfo.getVerifier().bypassProcess(spawnArmorStand);
|
||||
packetInfo.getVerifier().bypassProcess(attachSlimeToPlayer);
|
||||
packetInfo.getVerifier().bypassProcess(attachSquidtoSlime);
|
||||
packetInfo.getVerifier().bypassProcess(attachArmorStandToSquid);
|
||||
});
|
||||
Player player = (Player) UtilEnt.getEntityById(packet.a);
|
||||
summonForEntity(packetInfo.getPlayer(), player);
|
||||
}
|
||||
}
|
||||
else if (packetInfo.getPacket() instanceof PacketPlayOutEntityDestroy)
|
||||
@ -531,19 +663,166 @@ public class Titles extends MiniPlugin implements IPacketHandler
|
||||
PacketPlayOutEntityDestroy packet = (PacketPlayOutEntityDestroy) packetInfo.getPacket();
|
||||
for (int id : packet.a)
|
||||
{
|
||||
Map<UUID, Integer> innerMap = _ids.getOrDefault(id, Collections.emptyMap());
|
||||
innerMap.remove(packetInfo.getPlayer().getUniqueId());
|
||||
int[] remove = _remove.getOrDefault(id, Collections.emptyMap()).getOrDefault(packetInfo.getPlayer().getUniqueId(), Collections.emptyList()).stream().mapToInt(Integer::intValue).toArray();
|
||||
destroyForEntity(packetInfo.getPlayer(), id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_remove.getOrDefault(id, Collections.emptyMap()).isEmpty())
|
||||
_remove.remove(id);
|
||||
private void summonForEntity(Player receiver, Player player)
|
||||
{
|
||||
World world = ((CraftWorld) receiver.getWorld()).getHandle();
|
||||
Track existingTitle = getActiveTrack(player);
|
||||
|
||||
PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(remove);
|
||||
packetInfo.getVerifier().bypassProcess(destroy);
|
||||
DataWatcher squidWatcher = new DataWatcher(new DummyEntity(world));
|
||||
squidWatcher.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
|
||||
|
||||
if (innerMap.isEmpty())
|
||||
DataWatcher slimeWatcher = new DataWatcher(new DummyEntity(world));
|
||||
slimeWatcher.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
|
||||
slimeWatcher.a(16, -1, EntitySlime.META_SIZE, -1);
|
||||
|
||||
DataWatcher armorStandWatcher = new DataWatcher(new DummyEntity(world));
|
||||
armorStandWatcher.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
|
||||
armorStandWatcher.a(1, (short) 300, net.minecraft.server.v1_8_R3.Entity.META_AIR, 0);
|
||||
if (existingTitle != null)
|
||||
{
|
||||
TrackTier currentTier = existingTitle.getRequirements().getTier(player);
|
||||
if (currentTier != null)
|
||||
{
|
||||
armorStandWatcher.a(2, currentTier.getDisplayName(), net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME, currentTier.getDisplayName());
|
||||
armorStandWatcher.a(3, (byte) 1, net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME_VISIBLE, true);
|
||||
}
|
||||
}
|
||||
armorStandWatcher.a(10, (byte) 0x10, EntityArmorStand.META_ARMOR_OPTION, (byte) 0x10); // Small
|
||||
|
||||
PacketPlayOutSpawnEntityLiving spawnSlime = new PacketPlayOutSpawnEntityLiving();
|
||||
spawnSlime.a = UtilEnt.getNewEntityId();
|
||||
spawnSlime.b = EntityType.SLIME.getTypeId();
|
||||
spawnSlime.c = MathHelper.floor(player.getLocation().getX() * 32.0D);
|
||||
spawnSlime.d = -150;
|
||||
spawnSlime.e = MathHelper.floor(player.getLocation().getZ() * 32.0D);
|
||||
spawnSlime.i = 0;
|
||||
spawnSlime.j = 0;
|
||||
spawnSlime.k = 0;
|
||||
spawnSlime.f = 0;
|
||||
spawnSlime.g = 0;
|
||||
spawnSlime.h = 0;
|
||||
spawnSlime.uuid = UUID.randomUUID();
|
||||
spawnSlime.l = slimeWatcher;
|
||||
|
||||
PacketPlayOutSpawnEntityLiving spawnSquid = new PacketPlayOutSpawnEntityLiving();
|
||||
spawnSquid.a = UtilEnt.getNewEntityId();
|
||||
spawnSquid.b = EntityType.SQUID.getTypeId();
|
||||
spawnSquid.c = MathHelper.floor(player.getLocation().getX() * 32.0D);
|
||||
spawnSquid.d = -150;
|
||||
spawnSquid.e = MathHelper.floor(player.getLocation().getZ() * 32.0D);
|
||||
spawnSquid.i = 0;
|
||||
spawnSquid.j = 0;
|
||||
spawnSquid.k = 0;
|
||||
spawnSquid.f = 0;
|
||||
spawnSquid.g = 0;
|
||||
spawnSquid.h = 0;
|
||||
spawnSquid.uuid = UUID.randomUUID();
|
||||
spawnSquid.l = squidWatcher;
|
||||
|
||||
PacketPlayOutSpawnEntityLiving spawnArmorStand = new PacketPlayOutSpawnEntityLiving();
|
||||
spawnArmorStand.a = UtilEnt.getNewEntityId();
|
||||
spawnArmorStand.b = EntityType.ARMOR_STAND.getTypeId();
|
||||
spawnArmorStand.c = MathHelper.floor(player.getLocation().getX() * 32.0D);
|
||||
spawnArmorStand.d = -150;
|
||||
spawnArmorStand.e = MathHelper.floor(player.getLocation().getZ() * 32.0D);
|
||||
spawnArmorStand.i = 0;
|
||||
spawnArmorStand.j = 0;
|
||||
spawnArmorStand.k = 0;
|
||||
spawnArmorStand.f = 0;
|
||||
spawnArmorStand.g = 0;
|
||||
spawnArmorStand.h = 0;
|
||||
spawnArmorStand.uuid = UUID.randomUUID();
|
||||
spawnArmorStand.l = armorStandWatcher;
|
||||
|
||||
PacketPlayOutNewAttachEntity attachSlimeToPlayer = new PacketPlayOutNewAttachEntity(player.getEntityId(), new int[]{spawnSlime.a});
|
||||
PacketPlayOutNewAttachEntity attachSquidtoSlime = new PacketPlayOutNewAttachEntity(spawnSlime.a, new int[]{spawnSquid.a});
|
||||
PacketPlayOutNewAttachEntity attachArmorStandToSquid = new PacketPlayOutNewAttachEntity(spawnSquid.a, new int[]{spawnArmorStand.a});
|
||||
|
||||
_armorStandIds.computeIfAbsent(player.getEntityId(), key -> new HashMap<>()).put(receiver.getUniqueId(), spawnArmorStand.a);
|
||||
_allIds.computeIfAbsent(player.getEntityId(), key -> new HashMap<>()).put(receiver.getUniqueId(), Arrays.asList(spawnSlime.a, spawnSquid.a, spawnArmorStand.a));
|
||||
|
||||
runSync(() ->
|
||||
{
|
||||
((CraftPlayer) receiver).getHandle().playerConnection.networkManager.handle(spawnSlime);
|
||||
((CraftPlayer) receiver).getHandle().playerConnection.networkManager.handle(spawnSquid);
|
||||
((CraftPlayer) receiver).getHandle().playerConnection.networkManager.handle(spawnArmorStand);
|
||||
((CraftPlayer) receiver).getHandle().playerConnection.networkManager.handle(attachSlimeToPlayer);
|
||||
((CraftPlayer) receiver).getHandle().playerConnection.networkManager.handle(attachSquidtoSlime);
|
||||
((CraftPlayer) receiver).getHandle().playerConnection.networkManager.handle(attachArmorStandToSquid);
|
||||
});
|
||||
}
|
||||
|
||||
private void destroyForEntity(Player receiver, int id)
|
||||
{
|
||||
Map<UUID, Integer> innerMap = _armorStandIds.get(id);
|
||||
if (innerMap != null)
|
||||
{
|
||||
innerMap.remove(receiver.getUniqueId());
|
||||
|
||||
if (innerMap.isEmpty())
|
||||
{
|
||||
_armorStandIds.remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
Map<UUID, List<Integer>> allIdsMap = _allIds.get(id);
|
||||
|
||||
if (allIdsMap != null)
|
||||
{
|
||||
List<Integer> ids = allIdsMap.remove(receiver.getUniqueId());
|
||||
if (ids != null)
|
||||
{
|
||||
int[] idsArr = ids.stream().mapToInt(Integer::intValue).toArray();
|
||||
|
||||
PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(idsArr);
|
||||
((CraftPlayer) receiver).getHandle().playerConnection.networkManager.handle(destroy);
|
||||
}
|
||||
|
||||
if (allIdsMap.isEmpty())
|
||||
{
|
||||
_allIds.remove(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void forceEnable()
|
||||
{
|
||||
if (_disabled)
|
||||
{
|
||||
_disabled = false;
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
for (Player player1 : UtilServer.getPlayers())
|
||||
{
|
||||
_ids.remove(id);
|
||||
if (player != player1)
|
||||
{
|
||||
summonForEntity(player, player1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void forceDisable()
|
||||
{
|
||||
if (!_disabled)
|
||||
{
|
||||
_disabled = true;
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
for (Player player1 : UtilServer.getPlayers())
|
||||
{
|
||||
if (player != player1)
|
||||
{
|
||||
destroyForEntity(player, player1.getEntityId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,65 @@
|
||||
package mineplex.core.titles;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.titles.tracks.Track;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
|
||||
public class TitlesRepository extends RepositoryBase
|
||||
{
|
||||
/*
|
||||
CREATE TABLE `accountTitle` (
|
||||
`accountId` int(11) NOT NULL,
|
||||
`trackName` VARCHAR(16) NOT NULL,
|
||||
PRIMARY KEY (`accountId`),
|
||||
CONSTRAINT `accountTitle_account` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
*/
|
||||
private static final String UPSERT_TITLE = "INSERT INTO accountTitle (accountId, trackName) VALUES (?, ?) ON DUPLICATE KEY UPDATE trackName = ?;";
|
||||
private static final String DELETE_TITLE = "DELETE FROM accountTitle WHERE accountId = ?;";
|
||||
|
||||
private final CoreClientManager _coreClientManager = Managers.require(CoreClientManager.class);
|
||||
|
||||
public TitlesRepository()
|
||||
{
|
||||
super(DBPool.getAccount());
|
||||
}
|
||||
|
||||
void savePlayerSelection(Player player, Track track)
|
||||
{
|
||||
int accountId = this._coreClientManager.getAccountId(player);
|
||||
if (accountId == -1)
|
||||
{
|
||||
System.err.print("Got account id -1 for player " + player.getName() + ". Aborting track saving");
|
||||
return;
|
||||
}
|
||||
try (Connection connection = getConnection())
|
||||
{
|
||||
if (track != null)
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement(UPSERT_TITLE);
|
||||
statement.setInt(1, accountId);
|
||||
statement.setString(2, track.getId());
|
||||
statement.setString(3, track.getId());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement(DELETE_TITLE);
|
||||
statement.setInt(1, accountId);
|
||||
statement.executeUpdate();
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package mineplex.core.titles.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.titles.Titles;
|
||||
|
||||
public class TitleBoostCommand extends CommandBase<Titles>
|
||||
{
|
||||
public TitleBoostCommand(Titles plugin, Rank requiredRank, String... aliases)
|
||||
{
|
||||
super(plugin, requiredRank, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -27,7 +27,14 @@ public class TrackCommand extends CommandBase<Titles>
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Track", "You must specify the ID of a track"));
|
||||
if (Plugin.getActiveTrack(caller) == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Track", "You must specify the ID of a track to enable"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.setOrToggleTrackForPlayer(caller, Plugin.getActiveTrack(caller), false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Track track = _trackManager.getTrackById(args[0]);
|
||||
@ -41,6 +48,6 @@ public class TrackCommand extends CommandBase<Titles>
|
||||
UtilPlayer.message(caller, F.main("Track", "You have not unlocked any tiers on that track"));
|
||||
return;
|
||||
}
|
||||
Plugin.setTrackForPlayer(caller, track);
|
||||
Plugin.setOrToggleTrackForPlayer(caller, track, args.length > 1);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
public class DongerTrack extends Track
|
||||
{
|
||||
private static final Set<String> OWNERS = Sets.newHashSet(
|
||||
"b86b54da-93dd-46f9-be33-27bd92aa36d7",
|
||||
"a20d59d1-cfd8-4116-ac27-45d9c7eb4a97"
|
||||
);
|
||||
|
||||
protected DongerTrack()
|
||||
{
|
||||
super("donger", ChatColor.AQUA, "Donger", "Donger", "ヽ༼ຈل͜ຈ༽ノ", true);
|
||||
special();
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"ヽ༼ຈل͜ຈ༽ノ",
|
||||
null,
|
||||
player -> OWNERS.contains(player.getUniqueId().toString().toLowerCase()),
|
||||
new TrackFormat(ChatColor.AQUA, ChatColor.BLUE)
|
||||
));
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.ILoginProcessor;
|
||||
|
||||
public class EarlyBirdTrack extends Track
|
||||
{
|
||||
private final Set<UUID> _wonEternal = Sets.newConcurrentHashSet();
|
||||
|
||||
protected EarlyBirdTrack()
|
||||
{
|
||||
super("early-bird", ChatColor.AQUA, "Early Bird", "Early Bird", "This track is unlocked by receiving the Eternal rank from chickens in the 2016 Thanksgiving Event", true);
|
||||
special();
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"Early Bird",
|
||||
null,
|
||||
player -> _wonEternal.contains(player.getUniqueId()),
|
||||
new TrackFormat(ChatColor.AQUA, ChatColor.AQUA)
|
||||
));
|
||||
|
||||
Managers.require(CoreClientManager.class).addStoredProcedureLoginProcessor(new ILoginProcessor()
|
||||
{
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "eternal-fetcher";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException
|
||||
{
|
||||
if (resultSet.next())
|
||||
{
|
||||
_wonEternal.add(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery(int accountId, String uuid, String name)
|
||||
{
|
||||
return "SELECT * FROM eternalGiveaway WHERE accountId = '" + accountId + "';";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event)
|
||||
{
|
||||
_wonEternal.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.gadget.set.SetEmerald;
|
||||
|
||||
public class GemCollectorTrack extends Track
|
||||
{
|
||||
public GemCollectorTrack()
|
||||
{
|
||||
super("gem-collector", "Gem Collector", "This track is unlocked by earning gems in games");
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"Gem Beggar",
|
||||
"Gain 1,000 Gem Points",
|
||||
this::getStat,
|
||||
1000,
|
||||
new TrackFormat(ChatColor.GRAY)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Respectable Gem Miner",
|
||||
"Gain 25,000 Gem Points",
|
||||
this::getStat,
|
||||
25000,
|
||||
new TrackFormat(ChatColor.LIGHT_PURPLE)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Middle Class",
|
||||
"Gain 50,000 Gem Points",
|
||||
this::getStat,
|
||||
50000,
|
||||
new TrackFormat(ChatColor.BLUE, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Gems, Gems, Gems",
|
||||
"Gain 75,000 Gem Points",
|
||||
this::getStat,
|
||||
75000,
|
||||
new TrackFormat(ChatColor.GREEN, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Gem McScrooge",
|
||||
"Gain 100,000 Gem Points",
|
||||
this::getStat,
|
||||
100000,
|
||||
new TrackFormat(ChatColor.RED, ChatColor.RED)
|
||||
));
|
||||
|
||||
getRequirements()
|
||||
.withRequirement(1, "Gem Earned in games")
|
||||
.withSetBonus(SetEmerald.class, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this method when the specified Player has earned gems
|
||||
*/
|
||||
public void earnedGems(Player player, int gems)
|
||||
{
|
||||
if (gems <= 0) return;
|
||||
|
||||
if (isSetActive(player, SetEmerald.class))
|
||||
gems *= 2;
|
||||
|
||||
incrementFor(player, gems);
|
||||
}
|
||||
}
|
@ -0,0 +1,202 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.gadget.event.ItemGadgetUseEvent;
|
||||
import mineplex.core.gadget.event.PlayerUseCoalEvent;
|
||||
import mineplex.core.gadget.gadgets.item.ItemBow;
|
||||
import mineplex.core.gadget.gadgets.item.ItemCoal;
|
||||
import mineplex.core.gadget.gadgets.item.ItemFlowerGift;
|
||||
import mineplex.core.gadget.gadgets.item.ItemFreezeCannon;
|
||||
import mineplex.core.gadget.gadgets.item.ItemLovePotion;
|
||||
import mineplex.core.gadget.gadgets.item.ItemSnowball;
|
||||
import mineplex.core.gadget.set.SetCandyCane;
|
||||
import mineplex.core.gadget.set.SetCupidsLove;
|
||||
import mineplex.core.gadget.set.SetFreedom;
|
||||
import mineplex.core.gadget.set.SetFrostLord;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetSet;
|
||||
import mineplex.core.treasure.TreasureType;
|
||||
import mineplex.core.treasure.event.TreasureStartEvent;
|
||||
|
||||
public class HolidayCheerTrack extends Track
|
||||
{
|
||||
private static final Set<TreasureType> HOLIDAY_CHESTS = new HashSet<>();
|
||||
private static final Set<Class<? extends GadgetSet>> HOLIDAY_SETS = new HashSet<>();
|
||||
private static final Map<Class<? extends Gadget>, Integer> POINTS = new HashMap<>();
|
||||
|
||||
static
|
||||
{
|
||||
POINTS.put(ItemFlowerGift.class, 1);
|
||||
POINTS.put(ItemBow.class, 1);
|
||||
POINTS.put(ItemSnowball.class, 1);
|
||||
POINTS.put(ItemFreezeCannon.class, 1);
|
||||
POINTS.put(ItemLovePotion.class, 10);
|
||||
|
||||
HOLIDAY_CHESTS.add(TreasureType.CHRISTMAS);
|
||||
HOLIDAY_CHESTS.add(TreasureType.FREEDOM);
|
||||
HOLIDAY_CHESTS.add(TreasureType.HAUNTED);
|
||||
HOLIDAY_CHESTS.add(TreasureType.THANKFUL);
|
||||
HOLIDAY_CHESTS.add(TreasureType.TRICK_OR_TREAT);
|
||||
|
||||
HOLIDAY_SETS.add(SetFreedom.class);
|
||||
HOLIDAY_SETS.add(SetCupidsLove.class);
|
||||
HOLIDAY_SETS.add(SetFrostLord.class);
|
||||
}
|
||||
|
||||
public HolidayCheerTrack()
|
||||
{
|
||||
super("holiday-cheer", "Holiday Cheer", "This track is unlocked by participating in Holiday Events");
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"School's Out",
|
||||
"Gain 1,000 Holiday Points",
|
||||
this::getStat,
|
||||
1000,
|
||||
new TrackFormat(ChatColor.GRAY)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Every Day's a Holiday",
|
||||
"Gain 2,000 Holiday Points",
|
||||
this::getStat,
|
||||
2000,
|
||||
new TrackFormat(ChatColor.LIGHT_PURPLE)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"I Party With Pumplings",
|
||||
"Gain 3,000 Holiday Points",
|
||||
this::getStat,
|
||||
3000,
|
||||
new TrackFormat(ChatColor.BLUE, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Celebration Addict",
|
||||
"Gain 5,000 Holiday Points",
|
||||
this::getStat,
|
||||
5000,
|
||||
new TrackFormat(ChatColor.GREEN, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Has Santa's Number",
|
||||
"Gain 10,000 Holiday Points",
|
||||
this::getStat,
|
||||
10000,
|
||||
new TrackFormat(ChatColor.RED, ChatColor.RED)
|
||||
));
|
||||
|
||||
getRequirements()
|
||||
.withRequirement(5, "game played in Holiday Games")
|
||||
.withRequirement(25, "win in Holiday Games");
|
||||
|
||||
HOLIDAY_SETS.forEach(clazz -> getRequirements().withSetBonus(clazz, 2));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUseCosmetic(TreasureStartEvent event)
|
||||
{
|
||||
if (!HOLIDAY_CHESTS.contains(event.getTreasureType()))
|
||||
return;
|
||||
|
||||
int points = 100;
|
||||
|
||||
for (Class<? extends GadgetSet> set : HOLIDAY_SETS)
|
||||
{
|
||||
if (isSetActive(event.getPlayer(), set))
|
||||
{
|
||||
points *= 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
incrementFor(event.getPlayer(), points);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUseCosmetic(ItemGadgetUseEvent event)
|
||||
{
|
||||
if (!POINTS.containsKey(event.getGadget().getClass()))
|
||||
return;
|
||||
|
||||
int basePoints = POINTS.get(event.getGadget().getClass());
|
||||
|
||||
for (Class<? extends GadgetSet> set : HOLIDAY_SETS)
|
||||
{
|
||||
if (isSetActive(event.getPlayer(), set))
|
||||
{
|
||||
basePoints *= 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (basePoints != 0)
|
||||
{
|
||||
incrementFor(event.getPlayer(), basePoints);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUseCosmetic(PlayerUseCoalEvent event)
|
||||
{
|
||||
int basePoints = event.getCost();
|
||||
|
||||
for (Class<? extends GadgetSet> set : HOLIDAY_SETS)
|
||||
{
|
||||
if (isSetActive(event.getPlayer(), set))
|
||||
{
|
||||
basePoints *= 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (basePoints != 0)
|
||||
{
|
||||
incrementFor(event.getPlayer(), basePoints);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this method when the specified Player has won a holiday-themed game
|
||||
*/
|
||||
public void wonGame(Player player)
|
||||
{
|
||||
int basePoints = 25;
|
||||
|
||||
for (Class<? extends GadgetSet> set : HOLIDAY_SETS)
|
||||
{
|
||||
if (isSetActive(player, set))
|
||||
{
|
||||
basePoints *= 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
incrementFor(player, basePoints);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this method when the specified Player has won a round in a holiday-themed game
|
||||
*/
|
||||
public void wonRound(Player player)
|
||||
{
|
||||
int basePoints = 5;
|
||||
|
||||
for (Class<? extends GadgetSet> set : HOLIDAY_SETS)
|
||||
{
|
||||
if (isSetActive(player, set))
|
||||
{
|
||||
basePoints *= 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
incrementFor(player, basePoints);
|
||||
}
|
||||
}
|
@ -1,21 +1,22 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.treasure.TreasureType;
|
||||
import mineplex.core.treasure.event.TreasureStartEvent;
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.achievement.AchievementCategory;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.game.GameDisplay;
|
||||
|
||||
public class KitCollectorTrack extends Track
|
||||
{
|
||||
private static final int ACHIEVEMENT_KIT_BONUS = 5;
|
||||
|
||||
// private static final Map<GameDisplay, AchievementCategory>
|
||||
|
||||
private final DonationManager _donationManager = Managers.require(DonationManager.class);
|
||||
|
||||
public KitCollectorTrack()
|
||||
{
|
||||
super("kit-collector", "Kit Collector", "The Kit Collector tree is unlocked by having kits unlocked");
|
||||
@ -23,28 +24,58 @@ public class KitCollectorTrack extends Track
|
||||
.addTier(new TrackTier(
|
||||
"Kit Collector",
|
||||
"Gain 25 Kit Collector Points",
|
||||
ChatColor.GRAY,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
20
|
||||
this::getStat,
|
||||
20,
|
||||
new TrackFormat(ChatColor.GRAY)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Kit Hoarder",
|
||||
"Gain 50 Kit Collector Points",
|
||||
ChatColor.BLUE,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
50
|
||||
this::getStat,
|
||||
50,
|
||||
new TrackFormat(ChatColor.BLUE, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"I Have Too Many Kits",
|
||||
"Gain 100 Kit Collector Points",
|
||||
ChatColor.RED,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
100
|
||||
this::getStat,
|
||||
100,
|
||||
new TrackFormat(ChatColor.RED, ChatColor.RED)
|
||||
));
|
||||
}
|
||||
|
||||
private int getUnlockedKits(Player player)
|
||||
{
|
||||
int ownedKits = 0;
|
||||
|
||||
for (String unknownPackage : _donationManager.Get(player).getOwnedUnknownSalesPackages())
|
||||
{
|
||||
for (GameDisplay gameDisplay : GameDisplay.values())
|
||||
{
|
||||
if (unknownPackage.startsWith(gameDisplay.getKitGameName() + " "))
|
||||
{
|
||||
ownedKits++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (AchievementCategory category : AchievementCategory.values())
|
||||
{
|
||||
int[] gameIDs = category.GameId;
|
||||
if (gameIDs != null)
|
||||
{
|
||||
for (int id : gameIDs)
|
||||
{
|
||||
GameDisplay display = GameDisplay.getById(id);
|
||||
if (display != null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ownedKits;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
|
||||
public class LeaderTrack extends Track
|
||||
{
|
||||
private final CoreClientManager _coreClientManager = Managers.require(CoreClientManager.class);
|
||||
|
||||
protected LeaderTrack()
|
||||
{
|
||||
super("leader", ChatColor.DARK_RED, "Leader", "What's a Leader?", "also wat does dev mean", true);
|
||||
special();
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"What's a Leader?",
|
||||
null,
|
||||
player -> _coreClientManager.Get(player).GetRank().has(Rank.LT),
|
||||
new TrackFormat(ChatColor.DARK_RED, ChatColor.RED)
|
||||
));
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.achievement.Achievement;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
|
||||
public class LevelerTrack extends Track
|
||||
{
|
||||
private final AchievementManager _achievementManager = Managers.require(AchievementManager.class);
|
||||
|
||||
public LevelerTrack()
|
||||
{
|
||||
super("leveler", "Leveler", "This track is unlocked by earning Mineplex levels");
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"Mineplex Sophomore",
|
||||
"Reach level 20",
|
||||
player -> (long) _achievementManager.get(player, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel(),
|
||||
20,
|
||||
new TrackFormat(ChatColor.GRAY)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Tree Climber",
|
||||
"Reach level 40",
|
||||
player -> (long) _achievementManager.get(player, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel(),
|
||||
40,
|
||||
new TrackFormat(ChatColor.LIGHT_PURPLE)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Chiss's Cat",
|
||||
"Reach level 60",
|
||||
player -> (long) _achievementManager.get(player, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel(),
|
||||
60,
|
||||
new TrackFormat(ChatColor.BLUE, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Honorary Guardian",
|
||||
"Reach level 80",
|
||||
player -> (long) _achievementManager.get(player, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel(),
|
||||
80,
|
||||
new TrackFormat(ChatColor.GREEN, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Friend of Douglas",
|
||||
"Reach level 100",
|
||||
player -> (long) _achievementManager.get(player, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel(),
|
||||
100,
|
||||
new TrackFormat(ChatColor.RED, ChatColor.RED)
|
||||
));
|
||||
}
|
||||
}
|
@ -1,10 +1,16 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
@ -15,6 +21,8 @@ public class LuckyTrack extends Track
|
||||
{
|
||||
private static final EnumMap<TreasureType, Integer> MULTIPLIER = new EnumMap<>(TreasureType.class);
|
||||
private static final EnumMap<RewardRarity, Integer> POINTS = new EnumMap<>(RewardRarity.class);
|
||||
private static final Set<Material> IRON = new HashSet<>();
|
||||
private static final Set<Material> DIAMOND = new HashSet<>();
|
||||
|
||||
static
|
||||
{
|
||||
@ -27,48 +35,80 @@ public class LuckyTrack extends Track
|
||||
MULTIPLIER.put(TreasureType.CHRISTMAS, 2);
|
||||
MULTIPLIER.put(TreasureType.TRICK_OR_TREAT, 2);
|
||||
MULTIPLIER.put(TreasureType.OMEGA, 3);
|
||||
|
||||
IRON.add(Material.IRON_SPADE);
|
||||
IRON.add(Material.IRON_PICKAXE);
|
||||
IRON.add(Material.IRON_AXE);
|
||||
IRON.add(Material.IRON_SWORD);
|
||||
IRON.add(Material.IRON_HOE);
|
||||
IRON.add(Material.IRON_INGOT);
|
||||
IRON.add(Material.IRON_HELMET);
|
||||
IRON.add(Material.IRON_CHESTPLATE);
|
||||
IRON.add(Material.IRON_LEGGINGS);
|
||||
IRON.add(Material.IRON_BOOTS);
|
||||
|
||||
DIAMOND.add(Material.DIAMOND_SPADE);
|
||||
DIAMOND.add(Material.DIAMOND_PICKAXE);
|
||||
DIAMOND.add(Material.DIAMOND_AXE);
|
||||
DIAMOND.add(Material.DIAMOND_SWORD);
|
||||
DIAMOND.add(Material.DIAMOND_HOE);
|
||||
DIAMOND.add(Material.DIAMOND);
|
||||
DIAMOND.add(Material.DIAMOND_HELMET);
|
||||
DIAMOND.add(Material.DIAMOND_CHESTPLATE);
|
||||
DIAMOND.add(Material.DIAMOND_LEGGINGS);
|
||||
DIAMOND.add(Material.DIAMOND_BOOTS);
|
||||
}
|
||||
|
||||
public LuckyTrack()
|
||||
{
|
||||
super("lucky", "Lucky", "This tree is unlocked by getting fortunate chest drops");
|
||||
super("lucky", "Lucky", "This track is unlocked by getting fortunate chest drops");
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"Lucky",
|
||||
"Gain 1,000 Lucky Points",
|
||||
ChatColor.GRAY,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
1000
|
||||
this::getStat,
|
||||
1000,
|
||||
new TrackFormat(ChatColor.GRAY)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Charmed",
|
||||
"Gain 2,000 Lucky Points",
|
||||
ChatColor.WHITE,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
2000
|
||||
this::getStat,
|
||||
2000,
|
||||
new TrackFormat(ChatColor.LIGHT_PURPLE)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Fortune Favored",
|
||||
"Gain 3,000 Lucky Points",
|
||||
ChatColor.BLUE,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
3000
|
||||
)).addTier(new TrackTier(
|
||||
this::getStat,
|
||||
3000,
|
||||
new TrackFormat(ChatColor.BLUE, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Golden",
|
||||
"Gain 5,000 Lucky Points",
|
||||
ChatColor.GREEN,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
5000
|
||||
)).addTier(new TrackTier(
|
||||
this::getStat,
|
||||
5000,
|
||||
new TrackFormat(ChatColor.GREEN, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Hashtag Blessed",
|
||||
"Gain 10,000 Lucky Points",
|
||||
ChatColor.RED,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
10000
|
||||
this::getStat,
|
||||
10000,
|
||||
new TrackFormat(ChatColor.RED, ChatColor.RED)
|
||||
));
|
||||
|
||||
getRequirements()
|
||||
.withRequirement(1, "Rare Item")
|
||||
.withRequirement(5, "Legendary Item")
|
||||
.withRequirement(50, "Mythical Item")
|
||||
.withRequirement(1, "per game chest with", "Iron Item")
|
||||
.withRequirement(3, "per game chest with", "Diamond Item")
|
||||
.withBonus("Event Chests", "from", 2)
|
||||
.withBonus("Omega Chests", "from", 3);
|
||||
}
|
||||
|
||||
// todo: handle chest loot in games
|
||||
@EventHandler
|
||||
public void onUseCosmetic(TreasureStartEvent event)
|
||||
{
|
||||
@ -85,4 +125,24 @@ public class LuckyTrack extends Track
|
||||
incrementFor(event.getPlayer(), basePoints);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleLoot(Player player, Inventory inventory)
|
||||
{
|
||||
boolean foundIron = false;
|
||||
boolean foundDiamond = false;
|
||||
boolean foundBow = false;
|
||||
for (ItemStack item : inventory)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
if (IRON.contains(item.getType())) foundIron = true;
|
||||
if (DIAMOND.contains(item.getType())) foundDiamond = true;
|
||||
if (item.getType() == Material.BOW) foundBow = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundIron) incrementFor(player, 1);
|
||||
if (foundDiamond) incrementFor(player, 3);
|
||||
if (foundBow) incrementFor(player, 1);
|
||||
}
|
||||
}
|
||||
|
@ -14,38 +14,38 @@ public class MineplexMasteryTrack extends Track
|
||||
|
||||
protected MineplexMasteryTrack()
|
||||
{
|
||||
super("mineplex-mastery", "Mineplex Mastery", "This tree is unlocked by winning different games on Mineplex");
|
||||
super("mineplex-mastery", "Mineplex Mastery", "This track is unlocked by winning different games on Mineplex");
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"Mineplex Initiate",
|
||||
"Win at least one game in 10 different Mineplex Games",
|
||||
ChatColor.GRAY,
|
||||
(track, player) -> getGames(player),
|
||||
10
|
||||
this::getGames,
|
||||
10,
|
||||
new TrackFormat(ChatColor.GRAY)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Mineplex Veteran",
|
||||
"Win at least one game in 20 different Mineplex Games",
|
||||
ChatColor.BLUE,
|
||||
(track, player) -> getGames(player),
|
||||
20
|
||||
this::getGames,
|
||||
20,
|
||||
new TrackFormat(ChatColor.BLUE, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Mineplex Master",
|
||||
"Win at least one game in 30 different Mineplex Games",
|
||||
ChatColor.RED,
|
||||
(track, player) -> getGames(player),
|
||||
30
|
||||
this::getGames,
|
||||
30,
|
||||
new TrackFormat(ChatColor.RED, ChatColor.RED)
|
||||
));
|
||||
_statsManager = Managers.require(StatsManager.class);
|
||||
}
|
||||
|
||||
private int getGames(Player player)
|
||||
private long getGames(Player player)
|
||||
{
|
||||
int count = 0;
|
||||
for (GameDisplay display : GameDisplay.values())
|
||||
{
|
||||
if (_statsManager.Get(player).getStat(display.getName() + ".Wins") > 0)
|
||||
if (_statsManager.Get(player).getStat(display.getName() + ".TrackWins") > 0)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -9,53 +12,59 @@ import mineplex.core.gadget.gadgets.item.ItemCoinBomb;
|
||||
import mineplex.core.gadget.gadgets.item.ItemFirework;
|
||||
import mineplex.core.gadget.gadgets.item.ItemPartyPopper;
|
||||
import mineplex.core.gadget.set.SetParty;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
|
||||
public class PartyAnimalTrack extends Track
|
||||
{
|
||||
private static final Map<Class<? extends Gadget>, Integer> POINTS = new HashMap<>();
|
||||
|
||||
static
|
||||
{
|
||||
POINTS.put(ItemFirework.class, 1);
|
||||
POINTS.put(ItemPartyPopper.class, 20);
|
||||
POINTS.put(ItemCoinBomb.class, 50);
|
||||
}
|
||||
|
||||
public PartyAnimalTrack()
|
||||
{
|
||||
super("party-animal", "Party Animal", "This tree is unlocked by partying with your friends and celebrating!");
|
||||
super("party-animal", "Party Animal", "This track is unlocked by partying with your friends and celebrating!");
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"Party Animal",
|
||||
"Gain 10,000 Party Points",
|
||||
ChatColor.GRAY,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
10000
|
||||
this::getStat,
|
||||
10000,
|
||||
new TrackFormat(ChatColor.GRAY)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Can't Stop Won't Stop",
|
||||
"Gain 25,000 Party Points",
|
||||
ChatColor.BLUE,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
25000
|
||||
this::getStat,
|
||||
25000,
|
||||
new TrackFormat(ChatColor.BLUE, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Life is a Party",
|
||||
"Gain 50,000 Party Points",
|
||||
ChatColor.RED,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
50000
|
||||
this::getStat,
|
||||
50000,
|
||||
new TrackFormat(ChatColor.RED, ChatColor.RED)
|
||||
));
|
||||
|
||||
getRequirements()
|
||||
.withRequirement(1, "for using", "Fireworks")
|
||||
.withRequirement(20, "for using" ,"Party Poppers")
|
||||
.withRequirement(50, "for using", "Treasure Party Bombs")
|
||||
.withSetBonus(SetParty.class, 2);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUseCosmetic(ItemGadgetUseEvent event)
|
||||
{
|
||||
int basePoints = 0;
|
||||
if (!POINTS.containsKey(event.getGadget().getClass()))
|
||||
return;
|
||||
|
||||
if (event.getGadget() instanceof ItemPartyPopper)
|
||||
{
|
||||
basePoints = 20;
|
||||
}
|
||||
else if (event.getGadget() instanceof ItemFirework)
|
||||
{
|
||||
basePoints = 1;
|
||||
}
|
||||
else if (event.getGadget() instanceof ItemCoinBomb)
|
||||
{
|
||||
basePoints = 50;
|
||||
}
|
||||
int basePoints = POINTS.get(event.getGadget().getClass());
|
||||
|
||||
if (isSetActive(event.getPlayer(), SetParty.class))
|
||||
{
|
||||
|
@ -0,0 +1,77 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.gadget.set.SetMusic;
|
||||
import mineplex.core.game.GameDisplay;
|
||||
|
||||
public class PeacefulTrack extends Track
|
||||
{
|
||||
private static final Set<GameDisplay> PEACEFUL_GAMES = new HashSet<>();
|
||||
|
||||
static
|
||||
{
|
||||
PEACEFUL_GAMES.add(GameDisplay.SpeedBuilders);
|
||||
PEACEFUL_GAMES.add(GameDisplay.Build);
|
||||
PEACEFUL_GAMES.add(GameDisplay.Draw);
|
||||
PEACEFUL_GAMES.add(GameDisplay.DragonEscape);
|
||||
PEACEFUL_GAMES.add(GameDisplay.DragonEscapeTeams);
|
||||
PEACEFUL_GAMES.add(GameDisplay.Dragons);
|
||||
PEACEFUL_GAMES.add(GameDisplay.DragonsTeams);
|
||||
PEACEFUL_GAMES.add(GameDisplay.MonsterMaze);
|
||||
}
|
||||
|
||||
public PeacefulTrack()
|
||||
{
|
||||
super("peaceful", "Peaceful", "This track is unlocked by winning games that do not require PvP to win");
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"Peaceful",
|
||||
"Gain 100 Peaceful Points",
|
||||
this::getStat,
|
||||
100,
|
||||
new TrackFormat(ChatColor.GRAY)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Tranquil",
|
||||
"Gain 500 Peaceful Points",
|
||||
this::getStat,
|
||||
500,
|
||||
new TrackFormat(ChatColor.BLUE, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Pacifist",
|
||||
"Gain 1,000 Peaceful Points",
|
||||
this::getStat,
|
||||
1000,
|
||||
new TrackFormat(ChatColor.RED, ChatColor.RED)
|
||||
));
|
||||
|
||||
getRequirements()
|
||||
.withRequirement(1, "per win in a", "Peaceful Game")
|
||||
.withSetBonus(SetMusic.class, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this method when the specified Player has won a game
|
||||
*/
|
||||
public void wonGame(Player player, GameDisplay gameDisplay)
|
||||
{
|
||||
if (!PEACEFUL_GAMES.contains(gameDisplay))
|
||||
return;
|
||||
|
||||
int points = 1;
|
||||
|
||||
if (isSetActive(player, SetMusic.class))
|
||||
{
|
||||
points *= 2;
|
||||
}
|
||||
|
||||
incrementFor(player, points);
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
|
||||
public class PerfectionistTrack extends Track
|
||||
{
|
||||
private final TrackManager _trackManager = Managers.require(TrackManager.class);
|
||||
|
||||
public PerfectionistTrack()
|
||||
{
|
||||
super("perfectionist", "Perfectionist", "This track is unlocked by completing other title lines");
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"A Bold Journey",
|
||||
"Complete 2 title track",
|
||||
this::getCompletedTracks,
|
||||
2,
|
||||
new TrackFormat(ChatColor.GRAY)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Endurer",
|
||||
"Complete 5 title tracks",
|
||||
this::getCompletedTracks,
|
||||
5,
|
||||
new TrackFormat(ChatColor.BLUE, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"You've Probably Heard of Me",
|
||||
"Complete 10 title tracks",
|
||||
this::getCompletedTracks,
|
||||
10,
|
||||
new TrackFormat(ChatColor.GREEN, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Doer of Things",
|
||||
"Complete 15 title tracks",
|
||||
this::getCompletedTracks,
|
||||
15,
|
||||
new TrackFormat(ChatColor.RED, ChatColor.RED)
|
||||
));
|
||||
}
|
||||
|
||||
private long getCompletedTracks(Player player)
|
||||
{
|
||||
int completed = 0;
|
||||
|
||||
for (Track track : _trackManager.getAllTracks())
|
||||
{
|
||||
if (track == this)
|
||||
continue;
|
||||
if (track.isSpecial())
|
||||
continue;
|
||||
if (track.getRequirements().getNextTier(player) == null)
|
||||
{
|
||||
completed++;
|
||||
}
|
||||
}
|
||||
|
||||
return completed;
|
||||
}
|
||||
}
|
@ -8,19 +8,18 @@ import mineplex.core.powerplayclub.PowerPlayClubRepository;
|
||||
|
||||
public class PowerPlayTrack extends Track
|
||||
{
|
||||
private final PowerPlayClubRepository _powerPlayClubRepository = Managers.require(BonusManager.class).getPowerPlayClubRepository();
|
||||
|
||||
protected PowerPlayTrack()
|
||||
{
|
||||
super("power-play", ChatColor.AQUA, "Power Play", "Power Play VIP", "This is Binary; you either have it 100% or you do not");
|
||||
|
||||
PowerPlayClubRepository ppc = Managers.require(BonusManager.class).getPowerPlayClubRepository();
|
||||
|
||||
super("power-play", ChatColor.AQUA, "Power Play", "Power Play VIP", "This track is unlocked by subscribing to the Power Play Club");
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"Power Play Club",
|
||||
"Currently subscribed to Power Play Club",
|
||||
ChatColor.AQUA,
|
||||
(track, player) -> ppc.getCachedData(player).getUnclaimedMonths().isEmpty() ? 0 : 1,
|
||||
1
|
||||
null,
|
||||
player -> _powerPlayClubRepository.getCachedData(player).getUnclaimedMonths().isEmpty() ? 0L : 1L,
|
||||
1,
|
||||
new TrackFormat(ChatColor.AQUA, ChatColor.AQUA)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
public class SnekTrack extends Track
|
||||
{
|
||||
private static final Set<String> OWNERS = Sets.newHashSet(
|
||||
"b86b54da-93dd-46f9-be33-27bd92aa36d7"
|
||||
);
|
||||
|
||||
protected SnekTrack()
|
||||
{
|
||||
super("snek", ChatColor.DARK_GREEN, "Snek", "Snek", "oh you have do me a frighten", true);
|
||||
special();
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"Snek",
|
||||
"hiss",
|
||||
player -> OWNERS.contains(player.getUniqueId().toString().toLowerCase()),
|
||||
new TrackFormat(ChatColor.DARK_GREEN, ChatColor.GREEN)
|
||||
));
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public class SurvivorTrack extends Track
|
||||
{
|
||||
public SurvivorTrack()
|
||||
{
|
||||
super("survivor", "Survivor", "This track is unlocked by playing consecutive games without dying");
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"Survivor",
|
||||
"Survive 5 consecutive games without dying",
|
||||
this::getStat,
|
||||
5,
|
||||
new TrackFormat(ChatColor.GRAY)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Endurer",
|
||||
"Survive 10 consecutive games without dying",
|
||||
this::getStat,
|
||||
10,
|
||||
new TrackFormat(ChatColor.BLUE, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Unkillable",
|
||||
"Survive 20 consecutive games without dying",
|
||||
this::getStat,
|
||||
20,
|
||||
new TrackFormat(ChatColor.RED, ChatColor.RED)
|
||||
));
|
||||
}
|
||||
}
|
@ -1,64 +1,75 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.event.ItemGadgetUseEvent;
|
||||
import mineplex.core.gadget.event.PlayerConsumeMelonEvent;
|
||||
import mineplex.core.gadget.gadgets.item.ItemLovePotion;
|
||||
import mineplex.core.gadget.gadgets.item.ItemMelonLauncher;
|
||||
|
||||
import static mineplex.core.Managers.require;
|
||||
import mineplex.core.gadget.set.SetCandyCane;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
|
||||
public class SweetToothTrack extends Track
|
||||
{
|
||||
private final GadgetManager _gadgetManager = require(GadgetManager.class);
|
||||
private static final Map<Class<? extends Gadget>, Integer> POINTS = new HashMap<>();
|
||||
|
||||
static
|
||||
{
|
||||
POINTS.put(ItemLovePotion.class, 75);
|
||||
}
|
||||
|
||||
public SweetToothTrack()
|
||||
{
|
||||
super("sweet-tooth", "Sweet Tooth", "This tree is unlocked by consuming Watermelon and other Sweets!");
|
||||
super("sweet-tooth", "Sweet Tooth", "This track is unlocked by consuming Watermelon and other Sweets!");
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"Sweet Tooth",
|
||||
"Consume 10,000 Sweet Points",
|
||||
ChatColor.GRAY,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
10000
|
||||
this::getStat,
|
||||
10000,
|
||||
new TrackFormat(ChatColor.GRAY)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Cavity Prone",
|
||||
"Consume 25,000 Sweet Points",
|
||||
ChatColor.BLUE,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
25000
|
||||
this::getStat,
|
||||
25000,
|
||||
new TrackFormat(ChatColor.BLUE, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Candy Addict",
|
||||
"Consume 50,000 Sweet Points",
|
||||
ChatColor.RED,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
50000
|
||||
this::getStat,
|
||||
50000,
|
||||
new TrackFormat(ChatColor.RED, ChatColor.RED)
|
||||
));
|
||||
|
||||
getRequirements()
|
||||
.withRequirement(1, "Watermelon consumed")
|
||||
.withRequirement(75, "Love Potion consumed")
|
||||
.withSetBonus(SetCandyCane.class, 2);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUseCosmetic(ItemGadgetUseEvent event)
|
||||
{
|
||||
int basePoints = 0;
|
||||
int basePoints = POINTS.getOrDefault(event.getGadget().getClass(), 0);
|
||||
|
||||
if (event.getGadget() instanceof ItemMelonLauncher)
|
||||
{
|
||||
basePoints = 1;
|
||||
}
|
||||
else if (event.getGadget() instanceof ItemLovePotion)
|
||||
{
|
||||
basePoints = 10;
|
||||
}
|
||||
if (isSetActive(event.getPlayer(), SetCandyCane.class)) basePoints *= 2;
|
||||
|
||||
if (basePoints != 0)
|
||||
{
|
||||
incrementFor(event.getPlayer(), basePoints);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onConsumeMelon(PlayerConsumeMelonEvent event)
|
||||
{
|
||||
incrementFor(event.getPlayer(), 1);
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.GadgetSet;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.database.tables.Stats;
|
||||
|
||||
import static mineplex.core.Managers.require;
|
||||
|
||||
@ -21,20 +22,35 @@ public class Track implements Listener
|
||||
private final String _longName;
|
||||
private final String _desc;
|
||||
private final ChatColor _color;
|
||||
private final boolean _hideIfUnowned;
|
||||
|
||||
private final TrackRequirements _trackRequirements;
|
||||
|
||||
private final GadgetManager _gadgetManager = require(GadgetManager.class);
|
||||
private final StatsManager _statsManager = require(StatsManager.class);
|
||||
|
||||
private boolean _special = false;
|
||||
|
||||
protected Track(String trackId, String shortName, String description)
|
||||
{
|
||||
this(trackId, ChatColor.DARK_AQUA, shortName, shortName, description);
|
||||
}
|
||||
|
||||
protected Track(String trackId, String shortName, String description, boolean hideIfUnowned)
|
||||
{
|
||||
this(trackId, ChatColor.DARK_AQUA, shortName, shortName, description, hideIfUnowned);
|
||||
}
|
||||
|
||||
protected Track(String trackId, ChatColor color, String shortName, String longName, String description)
|
||||
{
|
||||
this(trackId, color, shortName, longName, description, false);
|
||||
}
|
||||
|
||||
protected Track(String trackId, ChatColor color, String shortName, String longName, String description, boolean hideIfUnowned)
|
||||
{
|
||||
// Book limits
|
||||
Validate.isTrue(shortName.length() <= 16, "Short name cannot be longer than 16 characters");
|
||||
Validate.isTrue(trackId.length() <= 16, "ID cannot be longer than 16 characters");
|
||||
|
||||
this._id = trackId;
|
||||
this._shortName = shortName;
|
||||
@ -42,10 +58,20 @@ public class Track implements Listener
|
||||
this._desc = description;
|
||||
this._color = color;
|
||||
this._trackRequirements = new TrackRequirements(this);
|
||||
this._hideIfUnowned = hideIfUnowned;
|
||||
|
||||
UtilServer.RegisterEvents(this);
|
||||
}
|
||||
|
||||
|
||||
protected void special()
|
||||
{
|
||||
this._special = true;
|
||||
}
|
||||
|
||||
public boolean isSpecial()
|
||||
{
|
||||
return this._special;
|
||||
}
|
||||
|
||||
public final TrackRequirements getRequirements()
|
||||
{
|
||||
@ -59,12 +85,12 @@ public class Track implements Listener
|
||||
|
||||
public final void incrementFor(Player player, int amount)
|
||||
{
|
||||
Managers.require(StatsManager.class).incrementStat(player, getStatName(), amount);
|
||||
_statsManager.incrementStat(player, getStatName(), amount);
|
||||
}
|
||||
|
||||
public final long getStat(Player player)
|
||||
{
|
||||
return Managers.require(StatsManager.class).Get(player).getStat(getStatName());
|
||||
return _statsManager.Get(player).getStat(getStatName());
|
||||
}
|
||||
|
||||
public final boolean isSetActive(Player player, Class<? extends GadgetSet> setClass)
|
||||
@ -96,4 +122,9 @@ public class Track implements Listener
|
||||
{
|
||||
return this._color;
|
||||
}
|
||||
|
||||
public boolean hideIfUnowned()
|
||||
{
|
||||
return this._hideIfUnowned;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
|
||||
public class TrackFormat
|
||||
{
|
||||
private final ChatColor _chatColor;
|
||||
private final ChatColor _magicPrefixSuffix;
|
||||
|
||||
public TrackFormat(ChatColor color)
|
||||
{
|
||||
this(color, null);
|
||||
}
|
||||
|
||||
public TrackFormat(ChatColor color, ChatColor prefixSuffixColor)
|
||||
{
|
||||
this._chatColor = color;
|
||||
this._magicPrefixSuffix = prefixSuffixColor;
|
||||
}
|
||||
|
||||
public void preFormat(ComponentBuilder component)
|
||||
{
|
||||
if (_magicPrefixSuffix != null)
|
||||
{
|
||||
component
|
||||
.append("A", ComponentBuilder.FormatRetention.NONE)
|
||||
.obfuscated(true)
|
||||
.color(_magicPrefixSuffix)
|
||||
.append(" ", ComponentBuilder.FormatRetention.NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
component
|
||||
.append("", ComponentBuilder.FormatRetention.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void postFormat(ComponentBuilder component)
|
||||
{
|
||||
if (_magicPrefixSuffix != null)
|
||||
{
|
||||
component
|
||||
.append(" ", ComponentBuilder.FormatRetention.NONE)
|
||||
.append("A", ComponentBuilder.FormatRetention.NONE)
|
||||
.obfuscated(true)
|
||||
.color(_magicPrefixSuffix)
|
||||
.append("", ComponentBuilder.FormatRetention.NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
component
|
||||
.append("", ComponentBuilder.FormatRetention.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void format(ComponentBuilder component)
|
||||
{
|
||||
component
|
||||
.color(_chatColor);
|
||||
}
|
||||
|
||||
public ChatColor getColor()
|
||||
{
|
||||
return this._chatColor;
|
||||
}
|
||||
}
|
@ -19,6 +19,11 @@ public class TrackManager extends MiniPlugin
|
||||
{
|
||||
super("Track Manager");
|
||||
|
||||
registerTrack(new LeaderTrack());
|
||||
registerTrack(new EarlyBirdTrack());
|
||||
registerTrack(new SnekTrack());
|
||||
registerTrack(new DongerTrack());
|
||||
|
||||
registerTrack(new PowerPlayTrack());
|
||||
registerTrack(new MineplexMasteryTrack());
|
||||
registerTrack(new SweetToothTrack());
|
||||
@ -26,6 +31,14 @@ public class TrackManager extends MiniPlugin
|
||||
registerTrack(new TreasureHunterTrack());
|
||||
registerTrack(new LuckyTrack());
|
||||
registerTrack(new UnluckyTrack());
|
||||
registerTrack(new HolidayCheerTrack());
|
||||
// registerTrack(new KitCollectorTrack());
|
||||
registerTrack(new GemCollectorTrack());
|
||||
registerTrack(new WarriorTrack());
|
||||
registerTrack(new PeacefulTrack());
|
||||
// registerTrack(new SurvivorTrack());
|
||||
registerTrack(new LevelerTrack());
|
||||
registerTrack(new PerfectionistTrack());
|
||||
}
|
||||
|
||||
private void registerTrack(Track track)
|
||||
@ -34,9 +47,9 @@ public class TrackManager extends MiniPlugin
|
||||
_trackById.put(track.getId(), track);
|
||||
}
|
||||
|
||||
public final Track getTrack(Class<? extends Track> clazz)
|
||||
public final <T extends Track> T getTrack(Class<T> clazz)
|
||||
{
|
||||
return _registeredTracks.get(clazz);
|
||||
return clazz.cast(_registeredTracks.get(clazz));
|
||||
}
|
||||
|
||||
public final Track getTrackById(String id)
|
||||
|
@ -3,14 +3,28 @@ package mineplex.core.titles.tracks;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.GadgetSet;
|
||||
|
||||
public class TrackRequirements
|
||||
{
|
||||
private final Track _track;
|
||||
private final List<TrackTier> _tierRequirements = new ArrayList<>();
|
||||
|
||||
private List<PointWrapper> _lore = new ArrayList<>();
|
||||
private List<PointWrapper> _bonuses = new ArrayList<>();
|
||||
|
||||
private final GadgetManager _gadgetManager = Managers.require(GadgetManager.class);
|
||||
|
||||
public TrackRequirements(Track track)
|
||||
{
|
||||
this._track = track;
|
||||
@ -29,8 +43,10 @@ public class TrackRequirements
|
||||
|
||||
public TrackTier getTier(Player player)
|
||||
{
|
||||
for (int i = _tierRequirements.size() - 1; i >= 0; i--) {
|
||||
if (_tierRequirements.get(i).test(_track, player)) {
|
||||
for (int i = _tierRequirements.size() - 1; i >= 0; i--)
|
||||
{
|
||||
if (_tierRequirements.get(i).test(player))
|
||||
{
|
||||
return _tierRequirements.get(i);
|
||||
}
|
||||
}
|
||||
@ -39,11 +55,16 @@ public class TrackRequirements
|
||||
|
||||
public TrackTier getNextTier(Player player)
|
||||
{
|
||||
for (int i = _tierRequirements.size() - 1; i >= 0; i--) {
|
||||
if (_tierRequirements.get(i).test(_track, player)) {
|
||||
if (i == _tierRequirements.size() - 1) {
|
||||
for (int i = _tierRequirements.size() - 1; i >= 0; i--)
|
||||
{
|
||||
if (_tierRequirements.get(i).test(player))
|
||||
{
|
||||
if (i == _tierRequirements.size() - 1)
|
||||
{
|
||||
return null;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return _tierRequirements.get(i + 1);
|
||||
}
|
||||
}
|
||||
@ -60,4 +81,79 @@ public class TrackRequirements
|
||||
{
|
||||
return _tierRequirements.indexOf(tier) + 1;
|
||||
}
|
||||
|
||||
public TrackRequirements withRequirement(int points, String perName)
|
||||
{
|
||||
return withRequirement(points, "per", perName);
|
||||
}
|
||||
|
||||
public TrackRequirements withRequirement(int points, String verb, String name)
|
||||
{
|
||||
_lore.add(new PointWrapper(points, name, builder ->
|
||||
{
|
||||
builder.append("+ ", ComponentBuilder.FormatRetention.NONE)
|
||||
.append(points + " " + UtilText.plural("point", points) + " ", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.GREEN)
|
||||
.append(verb, ComponentBuilder.FormatRetention.NONE)
|
||||
.append(" ", ComponentBuilder.FormatRetention.NONE)
|
||||
.append(name)
|
||||
.color(ChatColor.GREEN)
|
||||
.append("\n", ComponentBuilder.FormatRetention.NONE);
|
||||
}));
|
||||
_lore.sort((a, b) ->
|
||||
{
|
||||
int result = Integer.compare(b._pts, a._pts);
|
||||
return result == 0 ? ChatColor.stripColor(b._name).compareTo(ChatColor.stripColor(a._name)) : result;
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
public TrackRequirements withSetBonus(Class<? extends GadgetSet> clazz, int bonusMultiplier)
|
||||
{
|
||||
return withBonus(_gadgetManager.getGadgetSet(clazz).getName() + " Set", "with", bonusMultiplier);
|
||||
}
|
||||
|
||||
public TrackRequirements withBonus(String name, String verb, int multiplier)
|
||||
{
|
||||
_bonuses.add(new PointWrapper(multiplier, name, builder ->
|
||||
{
|
||||
builder.append(multiplier + "x", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.GREEN)
|
||||
.append(" points ", ComponentBuilder.FormatRetention.NONE)
|
||||
.append(verb, ComponentBuilder.FormatRetention.NONE)
|
||||
.append(" ", ComponentBuilder.FormatRetention.NONE)
|
||||
.append(name)
|
||||
.color(ChatColor.GREEN)
|
||||
.append("\n", ComponentBuilder.FormatRetention.NONE);
|
||||
}));
|
||||
_bonuses.sort((a, b) ->
|
||||
{
|
||||
int result = Integer.compare(b._pts, a._pts);
|
||||
return result == 0 ? ChatColor.stripColor(b._name).compareTo(ChatColor.stripColor(a._name)) : result;
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
public void appendLore(ComponentBuilder builder)
|
||||
{
|
||||
_lore.forEach(wrapper -> wrapper._consumer.accept(builder));
|
||||
_bonuses.forEach(wrapper -> wrapper._consumer.accept(builder));
|
||||
|
||||
if (!_bonuses.isEmpty() || !_lore.isEmpty())
|
||||
builder.append("\n");
|
||||
}
|
||||
|
||||
private class PointWrapper
|
||||
{
|
||||
private int _pts;
|
||||
private String _name;
|
||||
private Consumer<ComponentBuilder> _consumer;
|
||||
|
||||
public PointWrapper(int pts, String name, Consumer<ComponentBuilder> consumer)
|
||||
{
|
||||
_pts = pts;
|
||||
_name = name;
|
||||
_consumer = consumer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,10 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -15,32 +12,41 @@ public class TrackTier
|
||||
{
|
||||
private final String _title;
|
||||
private final String _description;
|
||||
private final ChatColor _color;
|
||||
private final BiFunction<Track, Player, Integer> _current;
|
||||
private final Function<Player, Long> _current;
|
||||
private final int _goal;
|
||||
private final TrackFormat _format;
|
||||
|
||||
public TrackTier(String title, String description, ChatColor color, BiFunction<Track, Player, Integer> current, int goal)
|
||||
public TrackTier(String title, String description, Predicate<Player> condition, TrackFormat format)
|
||||
{
|
||||
this._title = title;
|
||||
this._current = player -> condition.test(player) ? 1L : 0L;
|
||||
this._goal = 1;
|
||||
this._description = description;
|
||||
this._format = format;
|
||||
}
|
||||
|
||||
public TrackTier(String title, String description, Function<Player, Long> current, int goal, TrackFormat format)
|
||||
{
|
||||
this._title = title;
|
||||
this._current = current;
|
||||
this._goal = goal;
|
||||
this._description = description;
|
||||
this._color = color;
|
||||
this._format = format;
|
||||
}
|
||||
|
||||
public boolean test(Track track, Player player)
|
||||
public boolean test(Player player)
|
||||
{
|
||||
return getProgress(track, player) >= 1.0;
|
||||
return getProgress(player) >= 1.0;
|
||||
}
|
||||
|
||||
public double getProgress(Track track, Player player)
|
||||
public double getProgress(Player player)
|
||||
{
|
||||
return ((double) get(track, player)) / _goal;
|
||||
return ((double) get(player)) / _goal;
|
||||
}
|
||||
|
||||
public int get(Track track, Player player)
|
||||
public long get(Player player)
|
||||
{
|
||||
return _current.apply(track, player);
|
||||
return _current.apply(player);
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
@ -53,13 +59,24 @@ public class TrackTier
|
||||
return this._description;
|
||||
}
|
||||
|
||||
public ChatColor getColor()
|
||||
{
|
||||
return this._color;
|
||||
}
|
||||
|
||||
public int getGoal()
|
||||
{
|
||||
return _goal;
|
||||
}
|
||||
|
||||
public TrackFormat getFormat()
|
||||
{
|
||||
return this._format;
|
||||
}
|
||||
|
||||
public String getDisplayName()
|
||||
{
|
||||
ComponentBuilder builder = new ComponentBuilder("");
|
||||
getFormat().preFormat(builder);
|
||||
builder.append(getTitle(), ComponentBuilder.FormatRetention.NONE);
|
||||
getFormat().format(builder);
|
||||
getFormat().postFormat(builder);
|
||||
|
||||
return BaseComponent.toLegacyText(builder.create());
|
||||
}
|
||||
}
|
||||
|
@ -24,46 +24,53 @@ public class TreasureHunterTrack extends Track
|
||||
POINTS.put(TreasureType.HAUNTED, 25);
|
||||
POINTS.put(TreasureType.CHRISTMAS, 25);
|
||||
POINTS.put(TreasureType.TRICK_OR_TREAT, 25);
|
||||
POINTS.put(TreasureType.THANKFUL, 25);
|
||||
POINTS.put(TreasureType.OMEGA, 50);
|
||||
}
|
||||
|
||||
public TreasureHunterTrack()
|
||||
{
|
||||
super("treasure-hunter", "Treasure Hunter", "This tree is unlocked by opening chests in the lobby");
|
||||
super("treasure-hunter", "Treasure Hunter", "This track is unlocked by opening chests in the lobby");
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"Rookie Treasure Hunter",
|
||||
"Gain 100 Treasure Points",
|
||||
ChatColor.GRAY,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
100
|
||||
this::getStat,
|
||||
100,
|
||||
new TrackFormat(ChatColor.GRAY)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Advanced Treasure Hunter",
|
||||
"Gain 250 Treasure Points",
|
||||
ChatColor.WHITE,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
250
|
||||
this::getStat,
|
||||
250,
|
||||
new TrackFormat(ChatColor.LIGHT_PURPLE)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Veteran Treasure Hunter",
|
||||
"Gain 500 Treasure Points",
|
||||
ChatColor.BLUE,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
500
|
||||
)).addTier(new TrackTier(
|
||||
this::getStat,
|
||||
500,
|
||||
new TrackFormat(ChatColor.BLUE, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Legendary Treasure Hunter",
|
||||
"Gain 1,000 Treasure Points",
|
||||
ChatColor.GREEN,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
1000
|
||||
)).addTier(new TrackTier(
|
||||
this::getStat,
|
||||
1000,
|
||||
new TrackFormat(ChatColor.GREEN, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Master Treasure Hunter",
|
||||
"Gain 2,000 Treasure Points",
|
||||
ChatColor.RED,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
2000
|
||||
this::getStat,
|
||||
2000,
|
||||
new TrackFormat(ChatColor.RED, ChatColor.RED)
|
||||
));
|
||||
|
||||
POINTS.forEach((type, value) -> getRequirements().withRequirement(value, type.getName()));
|
||||
getRequirements()
|
||||
.withSetBonus(SetWisdom.class, 2);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -1,66 +1,101 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.treasure.TreasureType;
|
||||
import mineplex.core.treasure.event.TreasureStartEvent;
|
||||
|
||||
public class UnluckyTrack extends Track
|
||||
{
|
||||
private static final EnumMap<RewardRarity, Integer> POINTS = new EnumMap<>(RewardRarity.class);
|
||||
private static final Set<Material> IRON = new HashSet<>();
|
||||
private static final Set<Material> DIAMOND = new HashSet<>();
|
||||
|
||||
static
|
||||
{
|
||||
POINTS.put(RewardRarity.COMMON, 1);
|
||||
POINTS.put(RewardRarity.UNCOMMON, 5);
|
||||
|
||||
IRON.add(Material.IRON_SPADE);
|
||||
IRON.add(Material.IRON_PICKAXE);
|
||||
IRON.add(Material.IRON_AXE);
|
||||
IRON.add(Material.IRON_SWORD);
|
||||
IRON.add(Material.IRON_HOE);
|
||||
IRON.add(Material.IRON_INGOT);
|
||||
IRON.add(Material.IRON_HELMET);
|
||||
IRON.add(Material.IRON_CHESTPLATE);
|
||||
IRON.add(Material.IRON_LEGGINGS);
|
||||
IRON.add(Material.IRON_BOOTS);
|
||||
|
||||
DIAMOND.add(Material.DIAMOND_SPADE);
|
||||
DIAMOND.add(Material.DIAMOND_PICKAXE);
|
||||
DIAMOND.add(Material.DIAMOND_AXE);
|
||||
DIAMOND.add(Material.DIAMOND_SWORD);
|
||||
DIAMOND.add(Material.DIAMOND_HOE);
|
||||
DIAMOND.add(Material.DIAMOND);
|
||||
DIAMOND.add(Material.DIAMOND_HELMET);
|
||||
DIAMOND.add(Material.DIAMOND_CHESTPLATE);
|
||||
DIAMOND.add(Material.DIAMOND_LEGGINGS);
|
||||
DIAMOND.add(Material.DIAMOND_BOOTS);
|
||||
}
|
||||
|
||||
public UnluckyTrack()
|
||||
{
|
||||
super("unlucky", "Unlucky", "This tree is unlocked by getting bad chest drops");
|
||||
super("unlucky", "Unlucky", "This track is unlocked by getting bad chest drops");
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"Unlucky",
|
||||
"Gain 1,000 Unlucky Points",
|
||||
ChatColor.GRAY,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
1000
|
||||
this::getStat,
|
||||
1000,
|
||||
new TrackFormat(ChatColor.GRAY)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Cursed",
|
||||
"Gain 2,000 Unlucky Points",
|
||||
ChatColor.WHITE,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
2000
|
||||
this::getStat,
|
||||
2000,
|
||||
new TrackFormat(ChatColor.LIGHT_PURPLE)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Accident Prone",
|
||||
"Gain 3,000 Unlucky Points",
|
||||
ChatColor.BLUE,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
3000
|
||||
)).addTier(new TrackTier(
|
||||
this::getStat,
|
||||
3000,
|
||||
new TrackFormat(ChatColor.BLUE, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Corroded",
|
||||
"Gain 5,000 Unlucky Points",
|
||||
ChatColor.GREEN,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
5000
|
||||
)).addTier(new TrackTier(
|
||||
this::getStat,
|
||||
5000,
|
||||
new TrackFormat(ChatColor.GREEN, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Things Don't Go My Way",
|
||||
"Gain 10,000 Unlucky Points",
|
||||
ChatColor.RED,
|
||||
(track, player) -> (int) track.getStat(player),
|
||||
10000
|
||||
this::getStat,
|
||||
10000,
|
||||
new TrackFormat(ChatColor.RED, ChatColor.RED)
|
||||
));
|
||||
|
||||
getRequirements()
|
||||
.withRequirement(1, "Common Item")
|
||||
.withRequirement(5, "Uncommon Item")
|
||||
.withRequirement(1, "per game chest without", "Diamond/Iron/Food");
|
||||
}
|
||||
|
||||
// todo: handle chest loot in games
|
||||
@EventHandler
|
||||
public void onUseCosmetic(TreasureStartEvent event)
|
||||
{
|
||||
@ -74,4 +109,19 @@ public class UnluckyTrack extends Track
|
||||
incrementFor(event.getPlayer(), basePoints);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleLoot(Player player, Inventory inventory)
|
||||
{
|
||||
for (ItemStack item : inventory)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
if (IRON.contains(item.getType())) return;
|
||||
if (DIAMOND.contains(item.getType())) return;
|
||||
if (item.getType().isEdible()) return;
|
||||
}
|
||||
}
|
||||
|
||||
incrementFor(player, 1);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,68 @@
|
||||
package mineplex.core.titles.tracks;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.gadget.set.SetVampire;
|
||||
|
||||
public class WarriorTrack extends Track
|
||||
{
|
||||
public WarriorTrack()
|
||||
{
|
||||
super("warrior", "Warrior", "This track is unlocked by earning kills in PvP games");
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"Warrior in Training",
|
||||
"Gain 500 Warrior Points",
|
||||
this::getStat,
|
||||
500,
|
||||
new TrackFormat(ChatColor.GRAY)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Savage",
|
||||
"Gain 1,000 Warrior Points",
|
||||
this::getStat,
|
||||
1000,
|
||||
new TrackFormat(ChatColor.LIGHT_PURPLE)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Berserker",
|
||||
"Gain 2,000 Warrior Points",
|
||||
this::getStat,
|
||||
2000,
|
||||
new TrackFormat(ChatColor.BLUE, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Duelist",
|
||||
"Gain 5,000 Warrior Points",
|
||||
this::getStat,
|
||||
5000,
|
||||
new TrackFormat(ChatColor.GREEN, null)
|
||||
))
|
||||
.addTier(new TrackTier(
|
||||
"Champion",
|
||||
"Gain 10,000 Warrior Points",
|
||||
this::getStat,
|
||||
10000,
|
||||
new TrackFormat(ChatColor.RED, ChatColor.RED)
|
||||
));
|
||||
|
||||
getRequirements()
|
||||
.withRequirement(1, "Kill")
|
||||
.withSetBonus(SetVampire.class, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this method when the specified Player has earned kills
|
||||
*/
|
||||
public void earnedKill(Player player, int kills)
|
||||
{
|
||||
if (kills <= 0) return;
|
||||
|
||||
if (isSetActive(player, SetVampire.class))
|
||||
kills *= 2;
|
||||
|
||||
incrementFor(player, kills);
|
||||
}
|
||||
}
|
@ -47,6 +47,8 @@ import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
import mineplex.core.thank.ThankManager;
|
||||
import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager;
|
||||
import mineplex.core.titles.Titles;
|
||||
import mineplex.core.titles.tracks.TrackManager;
|
||||
import mineplex.core.updater.FileUpdater;
|
||||
import mineplex.core.updater.Updater;
|
||||
import mineplex.core.velocity.VelocityFix;
|
||||
@ -168,6 +170,9 @@ public class ClansHub extends JavaPlugin
|
||||
|
||||
//Updates
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
||||
|
||||
require(TrackManager.class);
|
||||
require(Titles.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -276,24 +276,6 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter
|
||||
event.setMotd("Restarting soon");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an entity can be bumped
|
||||
* @param ent The entity to check
|
||||
* @return Whether the entity can be bumped
|
||||
*/
|
||||
public boolean BumpDisabled(Entity ent)
|
||||
{
|
||||
if (ent == null)
|
||||
return false;
|
||||
|
||||
if (ent instanceof Player)
|
||||
{
|
||||
return !_preferences.get((Player)ent).isActive(Preference.HUB_GAMES);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void redirectStopCommand(PlayerCommandPreprocessEvent event)
|
||||
|
@ -29,7 +29,7 @@ public class SalesAnnouncementRepository extends MinecraftRepository
|
||||
|
||||
public SalesAnnouncementRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.getAccount());
|
||||
super(DBPool.getAccount());
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,6 @@ import mineplex.core.updater.Updater;
|
||||
import mineplex.core.velocity.VelocityFix;
|
||||
import mineplex.core.visibility.VisibilityManager;
|
||||
import mineplex.hub.modules.BillboardManager;
|
||||
import mineplex.hub.modules.StackerManager;
|
||||
import mineplex.hub.queue.QueueManager;
|
||||
import mineplex.hub.server.ServerManager;
|
||||
import mineplex.core.titles.Titles;
|
||||
@ -177,7 +176,7 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
HologramManager hologramManager = new HologramManager(this, packetHandler);
|
||||
|
||||
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, eloManager, partyManager);
|
||||
ServerManager serverManager = new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager, boosterManager);
|
||||
ServerManager serverManager = new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, queueManager, boosterManager);
|
||||
new FountainManager(this, clientManager, donationManager, hologramManager, statsManager, serverManager);
|
||||
|
||||
Chat chat = new Chat(this, incognito, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
|
||||
|
@ -408,19 +408,6 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
}
|
||||
}
|
||||
|
||||
public boolean BumpDisabled(Entity ent)
|
||||
{
|
||||
if (ent == null)
|
||||
return false;
|
||||
|
||||
if (ent instanceof Player)
|
||||
{
|
||||
return !_preferences.get((Player) ent).isActive(Preference.HUB_GAMES);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void redirectStopCommand(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
@ -885,20 +872,6 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
return UtilTime.elapsed(_portalTime.get(player.getName()), 5000);
|
||||
}
|
||||
|
||||
public boolean hasPlayerStackingEnabled(LivingEntity ent)
|
||||
{
|
||||
if (!(ent instanceof Player))
|
||||
return true;
|
||||
|
||||
if (BumpDisabled(ent))
|
||||
return false;
|
||||
|
||||
if (!getPreferences().get((Player) ent).isActive(Preference.SHOW_PLAYERS))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void SkillTrigger(SkillTriggerEvent event)
|
||||
{
|
||||
|
@ -1,372 +0,0 @@
|
||||
package mineplex.hub.modules;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryCrafting;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Bat;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.event.StackerEvent;
|
||||
import mineplex.core.gadget.gadgets.item.ItemBatGun;
|
||||
import mineplex.core.gadget.gadgets.morph.MorphBlock;
|
||||
import mineplex.core.gadget.gadgets.morph.MorphGrimReaper;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.projectile.IThrown;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.projectile.ProjectileUser;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.hub.HubManager;
|
||||
|
||||
public class StackerManager extends MiniPlugin implements IThrown
|
||||
{
|
||||
public HubManager Manager;
|
||||
|
||||
private ProjectileManager _projectileManager;
|
||||
|
||||
private HashSet<Entity> _tempStackShift = new HashSet<Entity>();
|
||||
|
||||
public StackerManager(HubManager manager)
|
||||
{
|
||||
super("Stacker", manager.getPlugin());
|
||||
|
||||
Manager = manager;
|
||||
|
||||
_projectileManager = Managers.get(ProjectileManager.class);
|
||||
}
|
||||
|
||||
// @EventHandler
|
||||
public void GrabEntity(PlayerInteractAtEntityEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
Entity stackee = event.getRightClicked();
|
||||
if (stackee == null)
|
||||
return;
|
||||
|
||||
if(Manager.GetMount().isMount(stackee))
|
||||
return;
|
||||
|
||||
if (!(stackee instanceof LivingEntity))
|
||||
return;
|
||||
|
||||
if (stackee instanceof Horse)
|
||||
return;
|
||||
|
||||
if (stackee instanceof EnderDragon)
|
||||
return;
|
||||
|
||||
if (Manager.getMavericksManager().isStatueEntity(stackee))
|
||||
return;
|
||||
|
||||
if (stackee instanceof Player && ((Player)stackee).getGameMode() != GameMode.SURVIVAL)
|
||||
return;
|
||||
|
||||
if(stackee instanceof ArmorStand)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(stackee instanceof Minecart)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player stacker = event.getPlayer();
|
||||
|
||||
if (stacker.getGameMode() != GameMode.SURVIVAL)
|
||||
return;
|
||||
|
||||
if (UtilGear.isMat(stacker.getItemInHand(), Material.SNOW_BALL))
|
||||
return;
|
||||
|
||||
StackerEvent stackerEvent = new StackerEvent(stacker);
|
||||
Bukkit.getServer().getPluginManager().callEvent(stackerEvent);
|
||||
if (stackerEvent.isCancelled())
|
||||
return;
|
||||
|
||||
//Parkour Disable
|
||||
if (Manager.GetParkour().InsideParkour(stacker.getLocation()))
|
||||
{
|
||||
if (!stackee.isCustomNameVisible())
|
||||
UtilPlayer.message(stacker, F.main("Parkour", "You cannot Stack/Throw near Parkour Challenges."));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (stacker.getVehicle() != null || _tempStackShift.contains(stacker))
|
||||
{
|
||||
UtilPlayer.message(stacker, F.main("Stacker", "You cannot stack while stacked..."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Manager.GetGadget().getActive(stacker, GadgetType.MORPH) instanceof MorphBlock)
|
||||
{
|
||||
UtilPlayer.message(stacker, F.main("Stacker", "You cannot stack while using the Block Morph."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Manager.GetGadget().getActive(stacker, GadgetType.MORPH) instanceof MorphGrimReaper)
|
||||
{
|
||||
if (stacker.getItemInHand().getType() == Material.WOOD_HOE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Manager.GetTreasure().isOpening(stacker))
|
||||
return;
|
||||
|
||||
stackerEvent = new StackerEvent(stackee);
|
||||
Bukkit.getServer().getPluginManager().callEvent(stackerEvent);
|
||||
if (stackerEvent.isCancelled())
|
||||
return;
|
||||
|
||||
if (stackee instanceof Player)
|
||||
{
|
||||
Player stackeePlayer = (Player) stackee;
|
||||
|
||||
if (!Manager.hasPlayerStackingEnabled(stacker))
|
||||
{
|
||||
UtilPlayer.message(stacker, F.main("Stacker", "You have player stacking disabled."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Manager.hasPlayerStackingEnabled((stackeePlayer)))
|
||||
{
|
||||
UtilPlayer.message(stacker, F.main("Stacker", F.name(UtilEnt.getName(stackee)) + " has player stacking disabled."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Manager.GetTreasure().isOpening(stackeePlayer))
|
||||
{
|
||||
UtilPlayer.message(stacker, F.main("Stacker", F.main("Stacker", F.name(UtilEnt.getName(stackee)) + " is opening a chest!")));
|
||||
return;
|
||||
}
|
||||
|
||||
Inventory top = stackeePlayer.getOpenInventory().getTopInventory();
|
||||
|
||||
if (!(top instanceof CraftInventoryCrafting) && hasItems(top))
|
||||
{
|
||||
String message = F.main("Stacker", F.name(UtilEnt.getName(stackee)) + " cannot be stacked right now.");
|
||||
|
||||
if (top.getHolder() != null)
|
||||
{
|
||||
if (top.getHolder().equals(stackeePlayer))
|
||||
{
|
||||
UtilPlayer.message(stacker, message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
UtilPlayer.message(stacker, message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (stackee instanceof LivingEntity)
|
||||
{
|
||||
ItemBatGun batGun = (ItemBatGun) Manager.GetGadget().getGadget(ItemBatGun.class);
|
||||
|
||||
if (stackee instanceof Bat)
|
||||
{
|
||||
Bat bat = (Bat) stackee;
|
||||
|
||||
if (batGun.isThrownBat(bat))
|
||||
return;
|
||||
}
|
||||
|
||||
PetManager petManager = Manager.getPetManager();
|
||||
LivingEntity livingStackee = (LivingEntity) stackee;
|
||||
boolean cannotStack = petManager.getPets().contains(stackee) || stackee instanceof Wither || stackee instanceof EnderDragon;
|
||||
|
||||
if (cannotStack || livingStackee.isCustomNameVisible())
|
||||
{
|
||||
// Prevent from showing this message when players right-click on game npc's.
|
||||
if (cannotStack)
|
||||
UtilPlayer.message(stacker, F.main("Stacker", "You cannot stack this entity."));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
while (stackee.getVehicle() != null)
|
||||
stackee = stackee.getVehicle();
|
||||
|
||||
if (stackee.equals(stacker))
|
||||
return;
|
||||
|
||||
Entity top = stacker;
|
||||
while (top.getPassenger() != null)
|
||||
top = top.getPassenger();
|
||||
|
||||
if (!Recharge.Instance.use(stacker, "Stacker", 500, true, false))
|
||||
return;
|
||||
|
||||
top.setPassenger(stackee);
|
||||
|
||||
UtilPlayer.message(stacker, F.main("Stacker", "You stacked " + F.name(UtilEnt.getName(stackee)) + "."));
|
||||
UtilPlayer.message(stackee, F.main("Stacker", "You were stacked by " + F.name(stacker.getName()) + "."));
|
||||
UtilPlayer.message(stackee, F.main("Stacker", "Push " + F.skill("Crouch") + " to escape!"));
|
||||
|
||||
//Portal Delay
|
||||
Manager.SetPortalDelay(stacker);
|
||||
Manager.SetPortalDelay(stackee);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// @EventHandler
|
||||
public void ThrowEntity(PlayerInteractEvent event)
|
||||
{
|
||||
if (!UtilEvent.isAction(event, ActionType.L))
|
||||
return;
|
||||
|
||||
Player thrower = event.getPlayer();
|
||||
|
||||
if (thrower.getVehicle() != null)
|
||||
return;
|
||||
|
||||
Entity throwee = thrower.getPassenger();
|
||||
if (throwee == null)
|
||||
return;
|
||||
|
||||
StackerEvent stackerEvent = new StackerEvent(thrower);
|
||||
Bukkit.getServer().getPluginManager().callEvent(stackerEvent);
|
||||
if (stackerEvent.isCancelled())
|
||||
return;
|
||||
|
||||
thrower.eject();
|
||||
|
||||
Entity throweeStack = throwee.getPassenger();
|
||||
if (throweeStack != null)
|
||||
{
|
||||
throwee.eject();
|
||||
throweeStack.leaveVehicle();
|
||||
|
||||
final Entity fThrower = thrower;
|
||||
final Entity fThroweeStack = throweeStack;
|
||||
|
||||
_tempStackShift.add(throweeStack);
|
||||
|
||||
getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if ((fThrower instanceof Player && !((Player)fThrower).isOnline())
|
||||
|| (fThroweeStack instanceof Player && !((Player)fThroweeStack).isOnline()))
|
||||
{
|
||||
fThrower.setPassenger(fThroweeStack);
|
||||
}
|
||||
|
||||
_tempStackShift.remove(fThroweeStack);
|
||||
}
|
||||
}, 2);
|
||||
}
|
||||
|
||||
//Parkour Disable
|
||||
if (Manager.GetParkour().InsideParkour(thrower.getLocation()))
|
||||
{
|
||||
UtilPlayer.message(thrower, F.main("Parkour", "You cannot Stack/Throw near Parkour Challenges."));
|
||||
return;
|
||||
}
|
||||
|
||||
UtilPlayer.message(thrower, F.main("Stacker", "You threw " + F.name(UtilEnt.getName(throwee)) + "."));
|
||||
UtilPlayer.message(throwee, F.main("Stacker", "You were thrown by " + F.name(thrower.getName()) + "."));
|
||||
|
||||
UtilAction.velocity(throwee, thrower.getLocation().getDirection(), 1.8, false, 0, 0.3, 2, false);
|
||||
|
||||
_projectileManager.AddThrow(throwee, thrower, this, 4000, true, false, true, false, 0.5f);
|
||||
|
||||
//Portal Delay
|
||||
Manager.SetPortalDelay(thrower);
|
||||
Manager.SetPortalDelay(throwee);
|
||||
}
|
||||
|
||||
// @Override
|
||||
public void Collide(LivingEntity target, Block block, ProjectileUser data)
|
||||
{
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
if (target.getCustomName() != null || (target.getPassenger() != null && target.getPassenger() instanceof LivingEntity && ((LivingEntity)target.getPassenger()).getCustomName() != null))
|
||||
return;
|
||||
|
||||
if (!Manager.hasPlayerStackingEnabled(target))
|
||||
return;
|
||||
|
||||
//Velocity
|
||||
UtilAction.velocity(target, UtilAlg.getTrajectory2d(data.getThrown(), target), 1, true, 0.8, 0, 10, true);
|
||||
|
||||
Entity rider = target.getPassenger();
|
||||
while (rider != null)
|
||||
{
|
||||
//Portal Delay
|
||||
Manager.SetPortalDelay(rider);
|
||||
|
||||
rider.leaveVehicle();
|
||||
UtilAction.velocity(rider, new Vector(0.25 - Math.random()/2, Math.random()/2, 0.25 - Math.random()/2));
|
||||
rider = rider.getPassenger();
|
||||
}
|
||||
|
||||
UtilPlayer.message(target, F.main("Stacker", F.name(UtilEnt.getName(data.getThrower())) + " hit you with " + F.name(UtilEnt.getName(data.getThrown()))));
|
||||
|
||||
//Effect
|
||||
data.getThrown().getWorld().playSound(data.getThrown().getLocation(), Sound.HURT_FLESH, 1f, 1f);
|
||||
|
||||
//Portal Delay
|
||||
Manager.SetPortalDelay(target);
|
||||
}
|
||||
|
||||
private boolean hasItems(Inventory inventory)
|
||||
{
|
||||
for (ItemStack item : inventory.getContents())
|
||||
{
|
||||
if (item != null)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Idle(ProjectileUser data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Expire(ProjectileUser data)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ public class SalesAnnouncementRepository extends MinecraftRepository
|
||||
|
||||
public SalesAnnouncementRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.getAccount());
|
||||
super(DBPool.getAccount());
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,6 @@ import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.modules.StackerManager;
|
||||
import mineplex.hub.queue.QueueManager;
|
||||
import mineplex.hub.server.ui.LobbyShop;
|
||||
import mineplex.hub.server.ui.QuickShop;
|
||||
@ -99,7 +98,7 @@ public class ServerManager extends MiniPlugin implements BrawlShopProvider
|
||||
private boolean _retrieving = false;
|
||||
private long _lastRetrieve = 0;
|
||||
|
||||
public ServerManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Portal portal, PartyManager partyManager, ServerStatusManager statusManager, HubManager hubManager, StackerManager stackerManager, QueueManager queueManager, BoosterManager boosterManager)
|
||||
public ServerManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Portal portal, PartyManager partyManager, ServerStatusManager statusManager, HubManager hubManager, QueueManager queueManager, BoosterManager boosterManager)
|
||||
{
|
||||
super("Server Manager", plugin);
|
||||
|
||||
|
@ -57,6 +57,8 @@ import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
import mineplex.core.thank.ThankManager;
|
||||
import mineplex.core.titles.Titles;
|
||||
import mineplex.core.titles.tracks.TrackManager;
|
||||
import mineplex.core.updater.FileUpdater;
|
||||
import mineplex.core.updater.Updater;
|
||||
import mineplex.core.velocity.VelocityFix;
|
||||
@ -179,7 +181,7 @@ public class Arcade extends JavaPlugin
|
||||
cosmeticManager.disableTeamArmor();
|
||||
|
||||
CustomDataManager customDataManager = new CustomDataManager(this, _clientManager);
|
||||
|
||||
|
||||
//Arcade Manager
|
||||
PollManager pollManager = new PollManager(this, _clientManager, _donationManager);
|
||||
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, incognito, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, customDataManager, punish, eloManager, thankManager, boosterManager);
|
||||
|
@ -46,6 +46,7 @@ import mineplex.core.boosters.BoosterManager;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.timing.TimingManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
@ -91,6 +92,7 @@ import mineplex.core.progression.KitProgressionManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.rankGiveaway.eternal.EternalGiveawayManager;
|
||||
import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager;
|
||||
import mineplex.core.resourcepack.ResourcePackManager;
|
||||
import mineplex.core.scoreboard.MineplexScoreboard;
|
||||
import mineplex.core.scoreboard.ScoreboardManager;
|
||||
@ -100,8 +102,8 @@ import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
import mineplex.core.thank.ThankManager;
|
||||
import mineplex.core.common.timing.TimingManager;
|
||||
import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager;
|
||||
import mineplex.core.titles.Titles;
|
||||
import mineplex.core.titles.tracks.TrackManager;
|
||||
import mineplex.core.valentines.ValentinesGiftManager;
|
||||
import mineplex.core.youtube.YoutubeManager;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||
@ -163,6 +165,7 @@ import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager;
|
||||
import nautilus.game.arcade.managers.lobby.legacy.LegacyGameLobbyManager;
|
||||
import nautilus.game.arcade.player.ArcadePlayer;
|
||||
import nautilus.game.arcade.shop.ArcadeShop;
|
||||
import static mineplex.core.Managers.require;
|
||||
|
||||
public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
{
|
||||
@ -227,6 +230,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
private ServerUptimeManager _serverUptimeManager;
|
||||
private ScoreboardManager _scoreboardManager;
|
||||
private NextBestGameManager _nextBestGameManager;
|
||||
private TrackManager _trackManager;
|
||||
|
||||
private IncognitoManager _incognitoManager;
|
||||
|
||||
@ -255,12 +259,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
public final boolean IsHolidayEnabled;
|
||||
|
||||
private final Titles _titles;
|
||||
|
||||
public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig,
|
||||
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
|
||||
StatsManager statsManager, IncognitoManager incognitoManager, AchievementManager achievementManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat,
|
||||
Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler,
|
||||
CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager,
|
||||
NpcManager npcManager, CustomDataManager customDataManager, Punish punish, EloManager eloManager, ThankManager thankManager, BoosterManager boosterManager)
|
||||
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
|
||||
StatsManager statsManager, IncognitoManager incognitoManager, AchievementManager achievementManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat,
|
||||
Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler,
|
||||
CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager,
|
||||
NpcManager npcManager, CustomDataManager customDataManager, Punish punish, EloManager eloManager, ThankManager thankManager, BoosterManager boosterManager)
|
||||
{
|
||||
super("Game Manager", plugin);
|
||||
|
||||
@ -334,7 +340,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager);
|
||||
YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager);
|
||||
PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager);
|
||||
_bonusManager = new BonusManager(plugin, _gameLobbyManager.getCarl(), playWireManager, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _cosmeticManager.getGadgetManager(), thankManager);
|
||||
_bonusManager = new BonusManager(plugin, _gameLobbyManager.getCarl(), playWireManager, clientManager, donationManager, pollManager, npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _cosmeticManager.getGadgetManager(), thankManager);
|
||||
|
||||
new GameLootManager(this, petManager, _bonusManager.getRewardManager());
|
||||
_spectatorManager = new GameSpectatorManager(this);
|
||||
@ -344,10 +350,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
_idleManager = new IdleManager(this);
|
||||
TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager);
|
||||
EternalGiveawayManager eternalGiveawayManager = new EternalGiveawayManager(getPlugin(), clientManager, serverStatusManager);
|
||||
|
||||
|
||||
new HolidayManager(this, titanGiveaway, eternalGiveawayManager);
|
||||
IsHolidayEnabled = true;
|
||||
|
||||
|
||||
new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _cosmeticManager.getGadgetManager(), statsManager);
|
||||
new GameTestingManager(this);
|
||||
require(PlayerDisguiseManager.class);
|
||||
@ -393,7 +399,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
Region region = new File("eu.dat").exists() ? Region.EU : Region.US;
|
||||
|
||||
_nextBestGameManager = new NextBestGameManager(serverConfig.ServerGroup, region, _partyManager);
|
||||
_nextBestGameManager = new NextBestGameManager(serverConfig.ServerGroup, region, _partyManager);
|
||||
|
||||
addCommand(new GoToNextGameCommand(this));
|
||||
addCommand(new OpenGameMechPrefsCommand(this));
|
||||
@ -507,7 +513,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
scoreboard.setSidebarName(ChatColor.GREEN + "§l" + "Waiting for game");
|
||||
}
|
||||
|
||||
scoreboard.get(ArcadeScoreboardLine.PLAYERS_VALUE).write( _gameManager.getValidPlayersForGameStart().size() + "/" + GetPlayerFull());
|
||||
scoreboard.get(ArcadeScoreboardLine.PLAYERS_VALUE).write(_gameManager.getValidPlayersForGameStart().size() + "/" + GetPlayerFull());
|
||||
scoreboard.get(ArcadeScoreboardLine.GEM_VALUE).write(donationManager.Get(scoreboard.getOwner()).getBalance(GlobalCurrency.GEM));
|
||||
|
||||
if (GetGame() != null)
|
||||
@ -563,6 +569,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
};
|
||||
new MenuManager(_plugin);
|
||||
Managers.put(_scoreboardManager, ScoreboardManager.class);
|
||||
_trackManager = require(TrackManager.class);
|
||||
_titles = require(Titles.class);
|
||||
Titles.BOOK_SLOT = 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -920,13 +929,13 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
if (_gameHostManager.isPrivateServer() && _gameHostManager.hasRank(Rank.TWITCH))
|
||||
extrainformation += "|HostRank." + _gameHostManager.getHostRank().toString();
|
||||
|
||||
//Always Joinable
|
||||
// if (_game != null && _game.JoinInProgress)
|
||||
// {
|
||||
// event.setMotd(ChatColor.GREEN + "Recruiting" + extrainformation);
|
||||
// }
|
||||
//Always Joinable
|
||||
// if (_game != null && _game.JoinInProgress)
|
||||
// {
|
||||
// event.setMotd(ChatColor.GREEN + "Recruiting" + extrainformation);
|
||||
// }
|
||||
|
||||
//Recruiting
|
||||
//Recruiting
|
||||
else if (_game == null || _game.GetState() == GameState.Recruit)
|
||||
{
|
||||
if (_game != null && _game.GetCountdown() != -1)
|
||||
@ -1575,6 +1584,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
//Disable
|
||||
if (event.GetState() == GameState.Recruit)
|
||||
{
|
||||
getTitles().forceEnable();
|
||||
getCosmeticManager().setActive(true);
|
||||
getCosmeticManager().setHideParticles(false);
|
||||
}
|
||||
@ -1874,10 +1884,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
{
|
||||
return new File(GAME_CMD_MODE_FILE).exists();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the minimum rank requirement to use game commands.
|
||||
*
|
||||
*
|
||||
* @return The minimum rank requirement.
|
||||
*/
|
||||
public Rank getGameCommandRank()
|
||||
@ -1904,7 +1914,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
* @return Whether or not the player can successfully use the command.
|
||||
*/
|
||||
public boolean canPlayerUseGameCmd(Player player)
|
||||
{
|
||||
{
|
||||
// Check whether they are of high enough rank status.
|
||||
if (_gameCommandRank == null || !GetClients().hasRank(player, _gameCommandRank))
|
||||
{
|
||||
@ -1966,6 +1976,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
/**
|
||||
* Allows mob spawning from core
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler
|
||||
@ -1979,6 +1990,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
/**
|
||||
* Allows adding a condition from another modules
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler
|
||||
@ -1989,6 +2001,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
/**
|
||||
* Allows toggling mob spawning from another module
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler
|
||||
@ -2025,4 +2038,13 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
return _nextBestGameManager;
|
||||
}
|
||||
|
||||
public TrackManager getTrackManager()
|
||||
{
|
||||
return this._trackManager;
|
||||
}
|
||||
|
||||
public Titles getTitles()
|
||||
{
|
||||
return this._titles;
|
||||
}
|
||||
}
|
||||
|
@ -374,6 +374,11 @@ public enum GameType
|
||||
return _ownMaps;
|
||||
}
|
||||
|
||||
public GameDisplay getDisplay()
|
||||
{
|
||||
return this._display;
|
||||
}
|
||||
|
||||
public String GetName()
|
||||
{
|
||||
return _display.getName();
|
||||
|
@ -34,6 +34,7 @@ import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.packethandler.PacketInfo;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.titles.tracks.HolidayCheerTrack;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
@ -277,6 +278,7 @@ public class Christmas extends SoloGame
|
||||
{
|
||||
if ((_part == null || _part.IsDone()) && _parts != null && !_parts.isEmpty())
|
||||
{
|
||||
|
||||
if (_part != null)
|
||||
HandlerList.unregisterAll(_part);
|
||||
|
||||
@ -477,7 +479,14 @@ public class Christmas extends SoloGame
|
||||
if (!player.isOnline())
|
||||
continue;
|
||||
|
||||
if (Manager.GetDonation().Get(player).OwnsUnknownPackage("Christmas Kings Head"))
|
||||
if (IsAlive(player))
|
||||
{
|
||||
Manager.getTrackManager().getTrack(HolidayCheerTrack.class).wonGame(player);
|
||||
}
|
||||
|
||||
Manager.getTrackManager().getTrack(HolidayCheerTrack.class).wonRound(player);
|
||||
|
||||
if (Manager.GetDonation().Get(player).ownsUnknownSalesPackage("Christmas Kings Head"))
|
||||
{
|
||||
SetCustomWinMessage(player, "You already earned your reward");
|
||||
}
|
||||
@ -485,7 +494,7 @@ public class Christmas extends SoloGame
|
||||
{
|
||||
SetCustomWinMessage(player, "You earned " + C.cYellow + "Christmas King Morph");
|
||||
|
||||
Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), Manager.GetClients().Get(player).getAccountId(), "Christmas Kings Head", GlobalCurrency.TREASURE_SHARD, 0, true);
|
||||
Manager.GetDonation().purchaseUnknownSalesPackage(player, "Christmas Kings Head", GlobalCurrency.TREASURE_SHARD, 0, true, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -500,6 +509,7 @@ public class Christmas extends SoloGame
|
||||
{
|
||||
for (Player player : GetPlayers(false))
|
||||
{
|
||||
Manager.getTrackManager().getTrack(HolidayCheerTrack.class).wonRound(player);
|
||||
Manager.GetGame().AddGems(player, 10, "Participation", false, false);
|
||||
}
|
||||
|
||||
@ -511,6 +521,7 @@ public class Christmas extends SoloGame
|
||||
{
|
||||
for (Player player : GetPlayers(false))
|
||||
{
|
||||
Manager.getTrackManager().getTrack(HolidayCheerTrack.class).wonRound(player);
|
||||
Manager.GetGame().AddGems(player, 10, "Participation", false, false);
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,14 @@ import org.bukkit.block.Chest;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.loot.ChestLoot;
|
||||
import mineplex.core.titles.tracks.LuckyTrack;
|
||||
import mineplex.core.titles.tracks.UnluckyTrack;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
|
||||
/**
|
||||
* The Island Object represents a flying Island <br/>
|
||||
@ -23,45 +28,45 @@ public class Island extends Crumbleable
|
||||
{
|
||||
|
||||
private Location _location;
|
||||
|
||||
|
||||
private ArrayList<Location> _chests;
|
||||
private ArrayList<Location> _blocks;
|
||||
|
||||
|
||||
private ArrayList<Location> _lootedBlocks;
|
||||
|
||||
|
||||
private int _bounds;
|
||||
private int _height;
|
||||
|
||||
private ChestLoot _loot;
|
||||
|
||||
|
||||
private BoosterRing _boosterRing;
|
||||
|
||||
|
||||
/**
|
||||
* @param location top middle location of the island
|
||||
* @param bounds how many blocks to go in each direction
|
||||
* @param height of the island
|
||||
* @param bounds how many blocks to go in each direction
|
||||
* @param height of the island
|
||||
*/
|
||||
public Island(Location location, int bounds, int height)
|
||||
{
|
||||
this(location, new ChestLoot(), bounds, height);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param location top middle location of the island
|
||||
* @param loot prefered {@link LootTable}
|
||||
* @param bounds how many blocks to go in each direction
|
||||
* @param height of the island
|
||||
* @param loot prefered {@link LootTable}
|
||||
* @param bounds how many blocks to go in each direction
|
||||
* @param height of the island
|
||||
*/
|
||||
public Island(Location location, LootTable loot, int bounds, int height)
|
||||
{
|
||||
this(location, loot.getloot(), bounds, height);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param location top middle location of the island
|
||||
* @param loot prefered {@link ChestLoot}
|
||||
* @param bounds how many blocks to go in each direction
|
||||
* @param height of the island
|
||||
* @param loot prefered {@link ChestLoot}
|
||||
* @param bounds how many blocks to go in each direction
|
||||
* @param height of the island
|
||||
*/
|
||||
public Island(Location location, ChestLoot loot, int bounds, int height)
|
||||
{
|
||||
@ -72,25 +77,25 @@ public class Island extends Crumbleable
|
||||
_blocks = new ArrayList<>();
|
||||
_lootedBlocks = new ArrayList<>();
|
||||
_loot = loot;
|
||||
|
||||
|
||||
registerBlocks();
|
||||
}
|
||||
|
||||
public void fillLoot(Block block)
|
||||
|
||||
public void fillLoot(Block block, Player player, ArcadeManager arcadeManager)
|
||||
{
|
||||
if (block.getType() != Material.CHEST
|
||||
&& block.getType() != Material.TRAPPED_CHEST)
|
||||
return;
|
||||
|
||||
|
||||
if (_lootedBlocks.contains(block.getLocation()))
|
||||
return;
|
||||
|
||||
|
||||
_lootedBlocks.add(block.getLocation());
|
||||
|
||||
|
||||
Chest chest = (Chest) block.getState();
|
||||
Inventory inventory = chest.getBlockInventory();
|
||||
inventory.clear();
|
||||
|
||||
|
||||
int items = 3;
|
||||
if (Math.random() > 0.50)
|
||||
items++;
|
||||
@ -100,7 +105,7 @@ public class Island extends Crumbleable
|
||||
items++;
|
||||
if (Math.random() > 0.95)
|
||||
items++;
|
||||
|
||||
|
||||
for (int i = 0; i < items; i++)
|
||||
{
|
||||
int trys = 0;
|
||||
@ -110,41 +115,47 @@ public class Island extends Crumbleable
|
||||
trys++;
|
||||
slot = UtilMath.r(27);
|
||||
}
|
||||
|
||||
|
||||
inventory.setItem(slot, _loot.getLoot());
|
||||
}
|
||||
|
||||
if (player != null && arcadeManager != null && arcadeManager.GetServerConfig().RewardStats)
|
||||
{
|
||||
arcadeManager.getTrackManager().getTrack(LuckyTrack.class).handleLoot(player, chest.getBlockInventory());
|
||||
arcadeManager.getTrackManager().getTrack(UnluckyTrack.class).handleLoot(player, chest.getBlockInventory());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<Location> getChests()
|
||||
{
|
||||
return _chests;
|
||||
}
|
||||
|
||||
|
||||
public int getBounds()
|
||||
{
|
||||
return _bounds;
|
||||
}
|
||||
|
||||
|
||||
public int getHeight()
|
||||
{
|
||||
return _height;
|
||||
}
|
||||
|
||||
|
||||
public boolean isOnIsland(Player player)
|
||||
{
|
||||
return isOnIsland(player.getLocation());
|
||||
}
|
||||
|
||||
|
||||
public boolean isOnIsland(Location location)
|
||||
{
|
||||
{
|
||||
if (UtilMath.offset(location, _location) > _bounds)
|
||||
return false;
|
||||
|
||||
|
||||
for (int y = ((int) (Math.round(_location.getY()) - _height)); y <= _location.getBlockY(); y++)
|
||||
{
|
||||
if (location.getBlockY() == y)
|
||||
@ -152,7 +163,7 @@ public class Island extends Crumbleable
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void crumbledAway()
|
||||
{
|
||||
@ -162,32 +173,32 @@ public class Island extends Crumbleable
|
||||
_boosterRing.disable();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void registerBlocks()
|
||||
{
|
||||
for (Block block : UtilBlock.getInBoundingBox(_location.clone().add(_bounds, 0, _bounds), _location.clone().subtract(_bounds, _height, _bounds)))
|
||||
{
|
||||
if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST)
|
||||
getChests().add(block.getLocation());
|
||||
|
||||
|
||||
_blocks.add(block.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void refillChests()
|
||||
{
|
||||
_lootedBlocks.clear();
|
||||
for (Location loc : _chests)
|
||||
{
|
||||
fillLoot(loc.getBlock());
|
||||
fillLoot(loc.getBlock(), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setBoosterRing(BoosterRing ring)
|
||||
{
|
||||
_boosterRing = ring;
|
||||
}
|
||||
|
||||
|
||||
public BoosterRing getBoosterRing()
|
||||
{
|
||||
return _boosterRing;
|
||||
|
@ -10,6 +10,7 @@ import java.util.UUID;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
@ -59,6 +60,8 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.titles.tracks.LuckyTrack;
|
||||
import mineplex.core.titles.tracks.UnluckyTrack;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
@ -89,84 +92,83 @@ import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker;
|
||||
*/
|
||||
public abstract class Skyfall extends Game
|
||||
{
|
||||
private static final long MAP_CRUMBLE_DELAY = 1000*30; // 30 Seconds
|
||||
private static final long CHEST_REFILL_TIME = 1000*60*3; // 3 minutes
|
||||
private static final long CHEST_REFILL_ANNOUNCE_TIME = 1000*60*3; // 3 minutes
|
||||
private static final long MAP_CRUMBLE_DELAY = 1000 * 30; // 30 Seconds
|
||||
private static final long CHEST_REFILL_TIME = 1000 * 60 * 3; // 3 minutes
|
||||
private static final long CHEST_REFILL_ANNOUNCE_TIME = 1000 * 60 * 3; // 3 minutes
|
||||
private static final int BIG_ISLAND_BOUNDS = 30;
|
||||
private static final int BIG_ISLAND_HEIGHT = 40;
|
||||
private static final long ELYTRA_TAKEAWAY = 1000;
|
||||
|
||||
|
||||
private static final int ISLAND_CRUMBLE_RATE = 7;
|
||||
private static final int BIG_ISLAND_CRUMBLE_RATE = 5;
|
||||
private static final int BOOSTER_RING_CRUMBLE_RATE = 3;
|
||||
private static final float RING_BOOST_STRENGTH = 2.5F;
|
||||
private static final float BIG_RING_BOOST_STRENGTH = 3.5F;
|
||||
|
||||
private static final long BOOSTER_COOLDOWN_TIME = 1000*20; // 20 Seconds
|
||||
|
||||
private static final long SUPPLY_DROP_TIME = 1000*60*5; // 5 Minutes
|
||||
private static final long DEATHMATCH_START_TIME = 1000*30; // 30 Seconds
|
||||
private static final long DEATHMATCH_WAIT_TIME = 1000*10; // 10 Seconds
|
||||
|
||||
|
||||
private static final long BOOSTER_COOLDOWN_TIME = 1000 * 20; // 20 Seconds
|
||||
|
||||
private static final long SUPPLY_DROP_TIME = 1000 * 60 * 5; // 5 Minutes
|
||||
private static final long DEATHMATCH_START_TIME = 1000 * 30; // 30 Seconds
|
||||
private static final long DEATHMATCH_WAIT_TIME = 1000 * 10; // 10 Seconds
|
||||
|
||||
private static final int TNT_EXPLOSION_RADIUS = 14;
|
||||
|
||||
private static final long EAT_RECHARGE = 500; // 0.5 Second
|
||||
|
||||
|
||||
private int _islandBounds;
|
||||
private int _islandHeight;
|
||||
|
||||
|
||||
private Island _upperIsland;
|
||||
private Island _lowerIsland;
|
||||
|
||||
|
||||
private HashMap<Island, TreeMap<Island, Integer>> _islands;
|
||||
private HashMap<Entity, Player> _tntMap;
|
||||
private ArrayList<BoosterRing> _boosterRings;
|
||||
private HashMap<UUID, Long> _disabledElytras;
|
||||
|
||||
|
||||
private HashSet<UUID> _currentlyEating;
|
||||
|
||||
private boolean _crumbleAnnounced;
|
||||
|
||||
|
||||
private long _chestsRefilled;
|
||||
|
||||
|
||||
private Location _supplyDrop;
|
||||
private Location _supplyEffect;
|
||||
private boolean _supplyDropActive;
|
||||
private boolean _supplyDropOver;
|
||||
|
||||
|
||||
private ArrayList<Location> _deathMatchSpawns;
|
||||
private boolean _deathmatch;
|
||||
private boolean _deathMatchStarted;
|
||||
private boolean _teleportedDeathmatch;
|
||||
private long _deathMatchStartTime;
|
||||
|
||||
|
||||
private boolean _refillAnnounced;
|
||||
|
||||
|
||||
private int _currentCrumble = 300;
|
||||
private boolean _supplyOpened;
|
||||
|
||||
public Skyfall(ArcadeManager manager, GameType type)
|
||||
|
||||
public Skyfall(ArcadeManager manager, GameType type)
|
||||
{
|
||||
super(manager, type,
|
||||
|
||||
new Kit[]
|
||||
{
|
||||
new KitSpeeder(manager),
|
||||
//new KitBooster(manager), // Broken? :(
|
||||
new KitJouster(manager),
|
||||
new KitStunner(manager),
|
||||
//new KitSurefoot(manager),
|
||||
new KitAeronaught(manager),
|
||||
new KitDeadeye(manager)
|
||||
new KitSpeeder(manager),
|
||||
//new KitBooster(manager), // Broken? :(
|
||||
new KitJouster(manager),
|
||||
new KitStunner(manager),
|
||||
//new KitSurefoot(manager),
|
||||
new KitAeronaught(manager),
|
||||
new KitDeadeye(manager)
|
||||
},
|
||||
|
||||
new String[]
|
||||
{
|
||||
"Fly with your Elytra",
|
||||
"Try to land on Islands",
|
||||
"Get your gear from chests"
|
||||
});
|
||||
|
||||
new String[]
|
||||
{
|
||||
"Fly with your Elytra",
|
||||
"Try to land on Islands",
|
||||
"Get your gear from chests"
|
||||
});
|
||||
|
||||
|
||||
registerStatTrackers(new WinWithoutWearingArmorStatTracker(this),
|
||||
@ -174,7 +176,7 @@ public abstract class Skyfall extends Game
|
||||
new FirstSupplyDropOpenStatTracker(this),
|
||||
new RingStatTracker(this),
|
||||
new AeronaughtStatTracker(this));
|
||||
|
||||
|
||||
registerChatStats(
|
||||
Kills,
|
||||
Assists,
|
||||
@ -183,7 +185,7 @@ public abstract class Skyfall extends Game
|
||||
DamageDealt,
|
||||
BlankLine
|
||||
);
|
||||
|
||||
|
||||
new VersionModule(MinecraftVersion.Version1_9).register(this);
|
||||
|
||||
// Disable specific GWEN checks for this game
|
||||
@ -197,8 +199,8 @@ public abstract class Skyfall extends Game
|
||||
_tntMap = new HashMap<>();
|
||||
_disabledElytras = new HashMap<>();
|
||||
_currentlyEating = new HashSet<>();
|
||||
|
||||
PrepareFreeze = true;
|
||||
|
||||
PrepareFreeze = true;
|
||||
AnnounceStay = false;
|
||||
DeathDropItems = true;
|
||||
QuitDropItems = true;
|
||||
@ -217,143 +219,143 @@ public abstract class Skyfall extends Game
|
||||
StrictAntiHack = false;
|
||||
|
||||
new CompassModule().register(this);
|
||||
|
||||
|
||||
SpeedMeasurement = true;
|
||||
|
||||
|
||||
_islandBounds = 25;
|
||||
_islandHeight = 15;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void gameStart(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() == GameState.Live)
|
||||
{
|
||||
_chestsRefilled = System.currentTimeMillis();
|
||||
|
||||
|
||||
for (Location spawn : GetTeamList().get(0).GetSpawns())
|
||||
{
|
||||
spawn.clone().subtract(0, 1, 0).getBlock().setType(Material.AIR);
|
||||
}
|
||||
|
||||
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
ItemStack stack = new ItemStack(Material.COMPASS);
|
||||
|
||||
|
||||
ItemMeta itemMeta = stack.getItemMeta();
|
||||
itemMeta.setDisplayName(C.cGreen + C.Bold + "Tracking Compass");
|
||||
stack.setItemMeta(itemMeta);
|
||||
|
||||
|
||||
player.getInventory().addItem(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void chestRefill(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
|
||||
if (!UtilTime.elapsed(_chestsRefilled, CHEST_REFILL_TIME))
|
||||
return;
|
||||
|
||||
|
||||
if (_deathmatch)
|
||||
return;
|
||||
|
||||
|
||||
_chestsRefilled = System.currentTimeMillis();
|
||||
_refillAnnounced = false;
|
||||
|
||||
|
||||
_upperIsland.refillChests();
|
||||
_lowerIsland.refillChests();
|
||||
|
||||
|
||||
Announce(ChatColor.AQUA + "" + ChatColor.BOLD + "Chests on the middle Islands have been refilled!", true);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void chestRefillAnnounce(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (!UtilTime.elapsed(_chestsRefilled, CHEST_REFILL_ANNOUNCE_TIME))
|
||||
return;
|
||||
|
||||
|
||||
if (_refillAnnounced)
|
||||
return;
|
||||
|
||||
|
||||
Announce(C.cGold + C.Bold + "The chests will be refilled in "
|
||||
+ UtilTime.MakeStr(CHEST_REFILL_TIME - CHEST_REFILL_ANNOUNCE_TIME), false);
|
||||
|
||||
|
||||
_refillAnnounced = true;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void dontRemoveElytra(InventoryClickEvent event)
|
||||
{
|
||||
if (event.getCurrentItem() == null)
|
||||
return;
|
||||
|
||||
|
||||
if (event.getCurrentItem().getType() == Material.ELYTRA)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void mapCrumble(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTEST)
|
||||
return;
|
||||
|
||||
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
|
||||
if (!UtilTime.elapsed(GetStateTime(), MAP_CRUMBLE_DELAY))
|
||||
return;
|
||||
|
||||
|
||||
if (!_crumbleAnnounced)
|
||||
{
|
||||
Announce(C.cGreenB + "As time passes, the world begins to rot...", true);
|
||||
_crumbleAnnounced = true;
|
||||
}
|
||||
|
||||
|
||||
for (Island island : islandCrumble())
|
||||
{
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
if (!island.isOnIsland(player))
|
||||
continue;
|
||||
|
||||
|
||||
if (UtilPlayer.isGliding(player))
|
||||
continue;
|
||||
|
||||
|
||||
Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 1, false, false, true, "Island Rot", "Island Rot");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (BoosterRing ring : _boosterRings)
|
||||
{
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
if (!ring.isCrumbledAway())
|
||||
continue;
|
||||
|
||||
|
||||
if (UtilPlayer.isGliding(player))
|
||||
continue;
|
||||
|
||||
if (UtilMath.offset(player.getLocation(), ring.getMiddle()) > (ring.getSize()/2))
|
||||
|
||||
if (UtilMath.offset(player.getLocation(), ring.getMiddle()) > (ring.getSize() / 2))
|
||||
continue;
|
||||
|
||||
|
||||
Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 1, false, false, true, "Island Rot", "Island Rot");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<Island> islandCrumble()
|
||||
{
|
||||
ArrayList<Island> islands = new ArrayList<>();
|
||||
@ -361,11 +363,11 @@ public abstract class Skyfall extends Game
|
||||
{
|
||||
if (island.crumblePercentage() <= 0.5)
|
||||
islands.add(island);
|
||||
|
||||
|
||||
Material[] mats = new Material[]{Material.COAL_BLOCK, Material.ENDER_STONE};
|
||||
if (island.getLocation().getBlockY() >= GetTeamList().get(0).GetSpawns().get(0).getBlockY())
|
||||
mats = new Material[] {Material.AIR};
|
||||
|
||||
mats = new Material[]{Material.AIR};
|
||||
|
||||
if (!island.crumble(ISLAND_CRUMBLE_RATE, mats))
|
||||
{
|
||||
return islands;
|
||||
@ -373,7 +375,7 @@ public abstract class Skyfall extends Game
|
||||
}
|
||||
if (_upperIsland.crumblePercentage() <= 0.5)
|
||||
islands.add(_upperIsland);
|
||||
|
||||
|
||||
if (!_upperIsland.crumble(BIG_ISLAND_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE))
|
||||
{
|
||||
_currentCrumble = _upperIsland.getLocation().getBlockY();
|
||||
@ -390,7 +392,7 @@ public abstract class Skyfall extends Game
|
||||
{
|
||||
if (island.crumblePercentage() <= 0.5)
|
||||
islands.add(island);
|
||||
|
||||
|
||||
if (!island.crumble(ISLAND_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE))
|
||||
{
|
||||
return islands;
|
||||
@ -410,41 +412,41 @@ public abstract class Skyfall extends Game
|
||||
}
|
||||
return islands;
|
||||
}
|
||||
|
||||
|
||||
//@EventHandler
|
||||
public void deathMatch(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
|
||||
if (_deathmatch)
|
||||
{
|
||||
if (!UtilTime.elapsed(_deathMatchStartTime, DEATHMATCH_START_TIME))
|
||||
return;
|
||||
|
||||
|
||||
if (_teleportedDeathmatch)
|
||||
{
|
||||
|
||||
|
||||
if (UtilTime.elapsed(_deathMatchStartTime, DEATHMATCH_START_TIME + DEATHMATCH_WAIT_TIME))
|
||||
{
|
||||
|
||||
if (_deathMatchStarted)
|
||||
return;
|
||||
|
||||
|
||||
_deathMatchStarted = true;
|
||||
|
||||
Announce(C.cRed + C.Bold + "Deathmatch has begun!", false);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!_deathMatchStarted)
|
||||
{
|
||||
long time = (_deathMatchStartTime + DEATHMATCH_START_TIME + DEATHMATCH_WAIT_TIME) - System.currentTimeMillis();
|
||||
int real = Math.round(time/1000) + 1;
|
||||
|
||||
int real = Math.round(time / 1000) + 1;
|
||||
|
||||
Announce(C.cRed + C.Bold + "Deathmatch is starting in " + real + "...", false);
|
||||
}
|
||||
}
|
||||
@ -466,7 +468,7 @@ public abstract class Skyfall extends Game
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void deathMatch()
|
||||
{
|
||||
for (Player player : GetPlayers(true))
|
||||
@ -475,55 +477,55 @@ public abstract class Skyfall extends Game
|
||||
player.teleport(loc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void ringCrumble(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTER)
|
||||
return;
|
||||
|
||||
|
||||
for (BoosterRing ring : _boosterRings)
|
||||
{
|
||||
if (ring.getMiddle().getBlockY() < _currentCrumble)
|
||||
continue;
|
||||
|
||||
|
||||
if (!ring.crumble(BOOSTER_RING_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void playerHunger(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOW)
|
||||
return;
|
||||
|
||||
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
if (!UtilPlayer.isGliding(player))
|
||||
continue;
|
||||
|
||||
|
||||
if (player.getFoodLevel() > 0)
|
||||
player.setFoodLevel(player.getFoodLevel() - 1);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void supplyDrop(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTEST)
|
||||
return;
|
||||
|
||||
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
|
||||
if (!UtilTime.elapsed(GetStateTime(), SUPPLY_DROP_TIME))
|
||||
return;
|
||||
|
||||
if (_supplyDropOver)
|
||||
return;
|
||||
|
||||
|
||||
if (!_supplyDropActive)
|
||||
{
|
||||
Announce(C.cYellow + C.Bold + "Supply Drop Incoming");
|
||||
@ -535,7 +537,7 @@ public abstract class Skyfall extends Game
|
||||
for (int z = -1; z <= 1; z++)
|
||||
_supplyDrop.getBlock().getRelative(x, -3, z)
|
||||
.setType(Material.IRON_BLOCK);
|
||||
|
||||
|
||||
_supplyDropActive = true;
|
||||
}
|
||||
|
||||
@ -550,10 +552,10 @@ public abstract class Skyfall extends Game
|
||||
UtilFirework.playFirework(_supplyEffect, effect);
|
||||
|
||||
_supplyDrop.getBlock().getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN).setType(Material.GLASS);
|
||||
|
||||
|
||||
Block block = _supplyDrop.getBlock();
|
||||
block.setType(Material.CHEST);
|
||||
|
||||
|
||||
Chest chest = (Chest) block.getState();
|
||||
for (int i = 0; i < UtilMath.rRange(5, 8); i++)
|
||||
{
|
||||
@ -562,20 +564,20 @@ public abstract class Skyfall extends Game
|
||||
_supplyDropOver = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void lootChest(PlayerInteractEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
|
||||
if (event.getClickedBlock().getType() != Material.CHEST
|
||||
&& event.getClickedBlock().getType() != Material.TRAPPED_CHEST)
|
||||
return;
|
||||
|
||||
|
||||
if (event.getClickedBlock().getLocation().getBlockX() == _supplyDrop.getBlockX()
|
||||
&& event.getClickedBlock().getLocation().getBlockY() == _supplyDrop.getBlockY()
|
||||
&& event.getClickedBlock().getLocation().getBlockZ() == _supplyDrop.getBlockZ())
|
||||
@ -588,95 +590,95 @@ public abstract class Skyfall extends Game
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Island island = getCurrentIsland(event.getPlayer());
|
||||
if (island == null)
|
||||
{
|
||||
_upperIsland.fillLoot(event.getClickedBlock());
|
||||
_upperIsland.fillLoot(event.getClickedBlock(), event.getPlayer(), getArcadeManager());
|
||||
return;
|
||||
}
|
||||
|
||||
island.fillLoot(event.getClickedBlock());
|
||||
|
||||
island.fillLoot(event.getClickedBlock(), event.getPlayer(), getArcadeManager());
|
||||
}
|
||||
|
||||
|
||||
// I have no clue why, but this is fixing all food issues
|
||||
@EventHandler
|
||||
public void foodFix(PlayerInteractEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
|
||||
if (!UtilEvent.isAction(event, ActionType.R))
|
||||
return;
|
||||
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
|
||||
if (player.getItemInHand() == null)
|
||||
return;
|
||||
|
||||
|
||||
ItemStack stack = player.getItemInHand();
|
||||
|
||||
|
||||
if (!UtilItem.isFood(stack))
|
||||
return;
|
||||
|
||||
|
||||
if (stack.getType() == Material.MUSHROOM_SOUP)
|
||||
return;
|
||||
|
||||
|
||||
if (player.getFoodLevel() >= 20)
|
||||
return;
|
||||
|
||||
|
||||
if (!Recharge.Instance.usable(player, "eating"))
|
||||
return;
|
||||
|
||||
|
||||
if (_currentlyEating.contains(player.getUniqueId()))
|
||||
return;
|
||||
|
||||
_currentlyEating.add(player.getUniqueId());
|
||||
|
||||
_currentlyEating.add(player.getUniqueId());
|
||||
//player.setWalkSpeed(0.1F);
|
||||
|
||||
|
||||
Manager.runSyncLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
//player.setWalkSpeed(0.2F);
|
||||
|
||||
|
||||
if (stack.getAmount() <= 0)
|
||||
return;
|
||||
|
||||
|
||||
Recharge.Instance.use(player, "eating", EAT_RECHARGE, false, false);
|
||||
|
||||
|
||||
_currentlyEating.remove(player.getUniqueId());
|
||||
//stack.setAmount(stack.getAmount() - 1);
|
||||
|
||||
|
||||
int heal = 4;
|
||||
if (stack.getType() == Material.BAKED_POTATO
|
||||
if (stack.getType() == Material.BAKED_POTATO
|
||||
|| stack.getType() == Material.BREAD
|
||||
|| stack.getType() == Material.COOKED_FISH)
|
||||
heal = 5;
|
||||
|
||||
|
||||
if (stack.getType() == Material.COOKED_BEEF
|
||||
|| stack.getType() == Material.GRILLED_PORK
|
||||
|| stack.getType() == Material.PUMPKIN_PIE)
|
||||
heal = 8;
|
||||
|
||||
|
||||
//player.setFoodLevel(player.getFoodLevel() + heal);
|
||||
//player.getWorld().playSound(player.getEyeLocation(), Sound.BURP, 100, 1);
|
||||
}
|
||||
}
|
||||
}, 40);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void ParseData()
|
||||
{
|
||||
WorldData.MaxY = 1000;
|
||||
|
||||
|
||||
_supplyDrop = WorldData.GetDataLocs("PINK").get(0);
|
||||
_deathMatchSpawns = (ArrayList<Location>) WorldData.GetDataLocs("BROWN").clone();
|
||||
|
||||
|
||||
_upperIsland = new Island(WorldData.GetDataLocs("GREEN").get(0), LootTable.BASIC, BIG_ISLAND_BOUNDS, BIG_ISLAND_HEIGHT);
|
||||
_lowerIsland = new Island(WorldData.GetDataLocs("YELLOW").get(0), LootTable.BASIC, BIG_ISLAND_BOUNDS, BIG_ISLAND_HEIGHT);
|
||||
|
||||
|
||||
for (String name : WorldData.GetAllCustomLocs().keySet())
|
||||
{
|
||||
if (name.split(" ")[0].equalsIgnoreCase("HEIGHT"))
|
||||
@ -688,50 +690,50 @@ public abstract class Skyfall extends Game
|
||||
_islandBounds = Integer.parseInt(name.split(" ")[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
registerIslands();
|
||||
registerBoosters();
|
||||
|
||||
|
||||
((CraftWorld) WorldData.World).getHandle().spigotConfig.playerTrackingRange = 250;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void ringBoost(PlayerBoostRingEvent event)
|
||||
{
|
||||
event.getRing().disable(BOOSTER_COOLDOWN_TIME, Material.STAINED_CLAY, (byte) 14, true);
|
||||
}
|
||||
|
||||
|
||||
public void registerBoosters()
|
||||
{
|
||||
ArrayList<Location> boosters = WorldData.GetDataLocs("ORANGE");
|
||||
for (Location boosterMid : boosters)
|
||||
{
|
||||
BoosterRing ring = new BoosterRing(this, boosterMid, RING_BOOST_STRENGTH);
|
||||
|
||||
|
||||
if (_upperIsland.isOnIsland(boosterMid))
|
||||
{
|
||||
_upperIsland.setBoosterRing(ring);
|
||||
ring.setBoostStrength(BIG_RING_BOOST_STRENGTH);
|
||||
}
|
||||
|
||||
|
||||
if (_lowerIsland.isOnIsland(boosterMid))
|
||||
{
|
||||
_lowerIsland.setBoosterRing(ring);
|
||||
ring.setBoostStrength(BIG_RING_BOOST_STRENGTH);
|
||||
}
|
||||
|
||||
|
||||
_boosterRings.add(ring);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void registerIslands()
|
||||
{
|
||||
|
||||
|
||||
HashMap<Island, Integer> upperIslandMap = new HashMap<>();
|
||||
HashMap<Island, Integer> lowerIslandMap = new HashMap<>();
|
||||
|
||||
HashMap<Island, Integer> lowerIslandMap = new HashMap<>();
|
||||
|
||||
ArrayList<Location> islands = WorldData.GetDataLocs("RED");
|
||||
|
||||
|
||||
for (Location islandMid : islands)
|
||||
{
|
||||
if (islandMid.getBlockY() >= _lowerIsland.getLocation().getBlockY())
|
||||
@ -743,24 +745,24 @@ public abstract class Skyfall extends Game
|
||||
lowerIslandMap.put(new Island(islandMid, LootTable.BASIC, _islandBounds, _islandHeight), islandMid.getBlockY());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IslandSorter upperSorter = new IslandSorter(upperIslandMap);
|
||||
IslandSorter lowerSorter = new IslandSorter(lowerIslandMap);
|
||||
|
||||
|
||||
_islands.put(_upperIsland, new TreeMap<>(upperSorter));
|
||||
_islands.get(_upperIsland).putAll(upperIslandMap);
|
||||
|
||||
_islands.put(_lowerIsland, new TreeMap<>(lowerSorter));
|
||||
_islands.get(_lowerIsland).putAll(lowerIslandMap);
|
||||
}
|
||||
|
||||
|
||||
public Island getCurrentIsland(Player player)
|
||||
{
|
||||
for (Island island : _islands.keySet())
|
||||
{
|
||||
if (island.isOnIsland(player))
|
||||
return island;
|
||||
|
||||
|
||||
for (Island subIsland : _islands.get(island).keySet())
|
||||
{
|
||||
if (subIsland.isOnIsland(player))
|
||||
@ -769,8 +771,8 @@ public abstract class Skyfall extends Game
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.HIGHEST)
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void elytraDrop(PlayerDeathEvent event)
|
||||
{
|
||||
Iterator<ItemStack> itemIterator = event.getDrops().iterator();
|
||||
@ -783,7 +785,7 @@ public abstract class Skyfall extends Game
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void deathmatchBowShoot(EntityShootBowEvent event)
|
||||
{
|
||||
@ -825,7 +827,7 @@ public abstract class Skyfall extends Game
|
||||
|
||||
event.setTo(event.getFrom());
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void supplyGlow(UpdateEvent event)
|
||||
{
|
||||
@ -834,7 +836,7 @@ public abstract class Skyfall extends Game
|
||||
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
|
||||
Block block = _supplyDrop.getBlock();
|
||||
|
||||
if (block.getType() != Material.CHEST)
|
||||
@ -844,40 +846,40 @@ public abstract class Skyfall extends Game
|
||||
|
||||
if (_supplyOpened)
|
||||
return;
|
||||
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.SPELL, block.getLocation()
|
||||
.add(0.5, 0.5, 0.5), 0.3f, 0.3f, 0.3f, 0, 1, ViewDist.LONG,
|
||||
UtilServer.getPlayers());
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void sendWarning(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (!IsLive())
|
||||
UtilPlayer.removeWorldBorder(player);
|
||||
|
||||
|
||||
if (!IsAlive(player))
|
||||
UtilPlayer.removeWorldBorder(player);
|
||||
|
||||
|
||||
if (player.getInventory().getChestplate() == null)
|
||||
continue;
|
||||
|
||||
|
||||
UtilPlayer.removeWorldBorder(player);
|
||||
}
|
||||
|
||||
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
if (player.getInventory().getChestplate() != null)
|
||||
continue;
|
||||
|
||||
|
||||
if (!UtilPlayer.hasWorldBorder(player))
|
||||
UtilPlayer.sendRedScreen(player, 100000);
|
||||
}
|
||||
@ -895,7 +897,7 @@ public abstract class Skyfall extends Game
|
||||
|
||||
@EventHandler
|
||||
public void TNTExplosion(ExplosionPrimeEvent event)
|
||||
{
|
||||
{
|
||||
if (!_tntMap.containsKey(event.getEntity()))
|
||||
return;
|
||||
|
||||
@ -903,7 +905,7 @@ public abstract class Skyfall extends Game
|
||||
|
||||
for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), TNT_EXPLOSION_RADIUS))
|
||||
Manager.GetCondition().Factory().Explosion("Throwing TNT", other, player, 50, 0.1, false, false);
|
||||
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@ -960,49 +962,49 @@ public abstract class Skyfall extends Game
|
||||
|
||||
_tntMap.put(tnt, player);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void removeElytraLava(CustomDamageEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
|
||||
if (event.GetCause() != DamageCause.LAVA)
|
||||
return;
|
||||
|
||||
Recharge.Instance.useForce(event.GetDamageePlayer(), "Elytra Removal", ELYTRA_TAKEAWAY, true);
|
||||
_disabledElytras.put(event.GetDamageePlayer().getUniqueId(), System.currentTimeMillis() + ELYTRA_TAKEAWAY);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void removeElytraWater(UpdateEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
if (player.getLocation().getBlock().getTypeId() == 8 || player.getLocation().getBlock().getRelative(BlockFace.UP).getTypeId() == 8 ||
|
||||
player.getLocation().getBlock().getTypeId() == 9 || player.getLocation().getBlock().getRelative(BlockFace.UP).getTypeId() == 9)
|
||||
if (player.getLocation().getBlock().getTypeId() == 8 || player.getLocation().getBlock().getRelative(BlockFace.UP).getTypeId() == 8 ||
|
||||
player.getLocation().getBlock().getTypeId() == 9 || player.getLocation().getBlock().getRelative(BlockFace.UP).getTypeId() == 9)
|
||||
{
|
||||
Recharge.Instance.useForce(player, "Elytra Removal", ELYTRA_TAKEAWAY, true);
|
||||
_disabledElytras.put(player.getUniqueId(), System.currentTimeMillis() + ELYTRA_TAKEAWAY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void updateElytras(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
|
||||
if (Manager.GetGame() == null)
|
||||
return;
|
||||
|
||||
|
||||
for (Player player : Manager.GetGame().GetPlayers(true))
|
||||
{
|
||||
if (_disabledElytras.containsKey(player.getUniqueId()))
|
||||
@ -1022,47 +1024,47 @@ public abstract class Skyfall extends Game
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isDeathMatch()
|
||||
{
|
||||
return _deathmatch;
|
||||
}
|
||||
|
||||
|
||||
public boolean isDeathMatchStarted()
|
||||
{
|
||||
return _deathMatchStarted;
|
||||
}
|
||||
|
||||
|
||||
public boolean isTeleportedDeathmatch()
|
||||
{
|
||||
return _teleportedDeathmatch;
|
||||
}
|
||||
|
||||
|
||||
public long getDeathmatchStartTime()
|
||||
{
|
||||
return _deathMatchStartTime;
|
||||
}
|
||||
|
||||
|
||||
public long getChestsRefilled()
|
||||
{
|
||||
return _chestsRefilled;
|
||||
}
|
||||
|
||||
|
||||
public long getChestRefillTime()
|
||||
{
|
||||
return CHEST_REFILL_TIME;
|
||||
}
|
||||
|
||||
|
||||
public long getDeathmatchStartingTime()
|
||||
{
|
||||
return DEATHMATCH_START_TIME;
|
||||
}
|
||||
|
||||
|
||||
public long getDeathmatchWaitTime()
|
||||
{
|
||||
return DEATHMATCH_WAIT_TIME;
|
||||
}
|
||||
|
||||
|
||||
private class IslandSorter implements Comparator<Island>
|
||||
{
|
||||
private HashMap<Island, Integer> _map;
|
||||
@ -1071,13 +1073,13 @@ public abstract class Skyfall extends Game
|
||||
{
|
||||
_map = map;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compare(Island a, Island b)
|
||||
{
|
||||
return _map.get(a) >= _map.get(b) ? -1 : 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -68,6 +68,8 @@ import mineplex.core.explosion.ExplosionEvent;
|
||||
import mineplex.core.loot.ChestLoot;
|
||||
import mineplex.core.loot.RandomItem;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.titles.tracks.LuckyTrack;
|
||||
import mineplex.core.titles.tracks.UnluckyTrack;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.combat.CombatComponent;
|
||||
@ -1190,6 +1192,12 @@ public abstract class Skywars extends Game
|
||||
// Misc
|
||||
chest.getBlockInventory().setItem(getIndex(used), _middleMisc.getLoot());
|
||||
}
|
||||
|
||||
if (getArcadeManager().GetServerConfig().RewardStats)
|
||||
{
|
||||
getArcadeManager().getTrackManager().getTrack(LuckyTrack.class).handleLoot(looter, chest.getBlockInventory());
|
||||
getArcadeManager().getTrackManager().getTrack(UnluckyTrack.class).handleLoot(looter, chest.getBlockInventory());
|
||||
}
|
||||
}
|
||||
|
||||
private int getIndex(HashSet<Integer> used)
|
||||
|
@ -81,6 +81,8 @@ import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.loot.*;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.titles.tracks.LuckyTrack;
|
||||
import mineplex.core.titles.tracks.UnluckyTrack;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.visibility.VisibilityManager;
|
||||
@ -760,6 +762,12 @@ public abstract class SurvivalGames extends Game
|
||||
}
|
||||
|
||||
_supplyCrates.remove(block);
|
||||
|
||||
if (getArcadeManager().GetServerConfig().RewardStats)
|
||||
{
|
||||
getArcadeManager().getTrackManager().getTrack(LuckyTrack.class).handleLoot(looter, chest.getBlockInventory());
|
||||
getArcadeManager().getTrackManager().getTrack(UnluckyTrack.class).handleLoot(looter, chest.getBlockInventory());
|
||||
}
|
||||
}
|
||||
|
||||
protected ItemStack GetChestItem(boolean superChest)
|
||||
|
@ -1,37 +0,0 @@
|
||||
package nautilus.game.arcade.gui.spectatorMenu;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.addons.compass.CompassAddon;
|
||||
import nautilus.game.arcade.gui.spectatorMenu.page.SpectatorPage;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by shaun on 14-09-24.
|
||||
*/
|
||||
public class SpectatorShop extends ShopBase<CompassAddon>
|
||||
{
|
||||
|
||||
private ArcadeManager _arcadeManager;
|
||||
|
||||
public SpectatorShop(CompassAddon plugin, ArcadeManager arcadeManager, CoreClientManager clientManager, DonationManager donationManager)
|
||||
{
|
||||
super(plugin, clientManager, donationManager, "Spectate Menu");
|
||||
_arcadeManager = arcadeManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ShopPageBase<CompassAddon, ? extends ShopBase<CompassAddon>> buildPagesFor(Player player)
|
||||
{
|
||||
return new SpectatorPage(getPlugin(), _arcadeManager, this, getClientManager(), getDonationManager(), player);
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
getPlayerPageMap().values().forEach(ShopPageBase::refresh);
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package nautilus.game.arcade.managers;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.PlayerSelector;
|
||||
import mineplex.core.common.util.UtilLambda;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -31,6 +32,7 @@ import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.mount.Mount;
|
||||
import mineplex.core.mount.types.MountDragon;
|
||||
import mineplex.core.titles.Titles;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.RestartServerEvent;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
@ -374,6 +376,11 @@ public class GameManager implements Listener
|
||||
if (Manager.GetGameHostManager().isPrivateServer() && Manager.GetGameHostManager().isVoteInProgress())
|
||||
return;
|
||||
|
||||
if ((game.GetCountdown() <= 5 && game.GetCountdown() >= 0) || timer <= 5)
|
||||
{
|
||||
Manager.getTitles().forceDisable();
|
||||
}
|
||||
|
||||
//Disabling Cosmetics
|
||||
if (game.GetCountdown() <= 5 && game.GetCountdown() >= 0 && game.GadgetsDisabled)
|
||||
{
|
||||
|
@ -7,6 +7,7 @@ import mineplex.core.boosters.Booster;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.titles.tracks.GemCollectorTrack;
|
||||
import mineplex.minecraft.game.core.combat.CombatComponent;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import mineplex.serverdata.Utility;
|
||||
@ -178,14 +179,6 @@ public class GameRewardManager implements Listener
|
||||
gemsToReward = baseGemsEarned;
|
||||
}
|
||||
|
||||
String oldName = player.getName();
|
||||
|
||||
if (Manager.GetClients().Get(player).getDisguisedAs() != null)
|
||||
{
|
||||
changeName(player, Manager.GetClients().Get(player).getName());
|
||||
System.out.println("Gems for " + Manager.GetClients().Get(player).getName());
|
||||
}
|
||||
|
||||
// Award players shards equal to base gems, plus booster bonuses.
|
||||
final int baseShardsEarned = baseGemsEarned;
|
||||
int shardsToReward = baseShardsEarned;
|
||||
@ -245,16 +238,11 @@ public class GameRewardManager implements Listener
|
||||
{
|
||||
Manager.GetDonation().rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, player, "Earned", shardsToReward);
|
||||
}
|
||||
Manager.getTrackManager().getTrack(GemCollectorTrack.class).earnedGems(player, gemsToReward);
|
||||
|
||||
//Stats
|
||||
Manager.GetStatsManager().incrementStat(player, "Global.GemsEarned", gemsToReward);
|
||||
Manager.GetStatsManager().incrementStat(player, game.GetName() + ".GemsEarned", gemsToReward);
|
||||
|
||||
if (Manager.GetClients().Get(player).getDisguisedAs() != null)
|
||||
{
|
||||
changeName(player, oldName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void changeName(Player player, String newName)
|
||||
|
@ -1,6 +1,8 @@
|
||||
package nautilus.game.arcade.managers.lobby;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.PlayerSelector;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.Rank;
|
||||
@ -15,6 +17,7 @@ import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.donation.Donor;
|
||||
import mineplex.core.event.CustomTagEvent;
|
||||
import mineplex.core.scoreboard.MineplexScoreboard;
|
||||
import mineplex.core.titles.Titles;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
@ -732,6 +735,7 @@ public abstract class LobbyManager implements Listener
|
||||
//Cosmetic Menu
|
||||
_manager.getCosmeticManager().giveInterfaceItem(player);
|
||||
_manager.getBoosterManager().giveInterfaceItem(player);
|
||||
_manager.getTitles().giveBookIfNotExists(player, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.titles.tracks.WarriorTrack;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
|
||||
@ -33,6 +34,11 @@ public class KillsStatTracker extends StatTracker<Game>
|
||||
|
||||
addStat(player, "Kills", 1, false, false);
|
||||
|
||||
if (getGame().getArcadeManager().GetServerConfig().RewardStats)
|
||||
{
|
||||
getGame().getArcadeManager().getTrackManager().getTrack(WarriorTrack.class).earnedKill(player, 1);
|
||||
}
|
||||
|
||||
// if (getGame().GetKit(player) != null)
|
||||
// addStat(player, getGame().GetKit(player).getName() + " Kills", 1, false, false);
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import mineplex.core.titles.tracks.PeacefulTrack;
|
||||
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
|
||||
@ -31,6 +33,13 @@ public class WinStatTracker extends StatTracker<Game>
|
||||
continue;
|
||||
|
||||
addStat(winner, "Wins", 1, false, false);
|
||||
addStat(winner, "TrackWins", 1, false, false);
|
||||
|
||||
|
||||
if (getGame().getArcadeManager().GetServerConfig().RewardStats)
|
||||
{
|
||||
getGame().getArcadeManager().getTrackManager().getTrack(PeacefulTrack.class).wonGame(winner, getGame().GetType().getDisplay());
|
||||
}
|
||||
|
||||
// if (getGame().GetKit(winner) != null)
|
||||
// addStat(winner, getGame().GetKit(winner).getName() + " Wins", 1, false, false);
|
||||
|
Loading…
Reference in New Issue
Block a user