Merge remote-tracking branch 'refs/remotes/origin/develop' into update/castle-siege
This commit is contained in:
commit
d9e1d211ac
@ -1225,7 +1225,62 @@ public enum Achievement
|
||||
new String[]{"Gem Hunters.ChestsOpened"},
|
||||
new String[]{"+1 for each chest opened"},
|
||||
new int[]{50,100,200,400,1000},
|
||||
AchievementCategory.GEM_HUNTERS);
|
||||
AchievementCategory.GEM_HUNTERS),
|
||||
|
||||
MOBA_GOLD_EARNED("Gold Farmer", 0,
|
||||
new String[]{"Heroes of GWEN.GoldEarned"},
|
||||
new String[]{"Earn Gold"},
|
||||
new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}},
|
||||
new int[]{100000,500000,1000000,2500000,5000000},
|
||||
"I",
|
||||
new String[] {"II","III","IV","V","X"},
|
||||
AchievementCategory.MOBA),
|
||||
|
||||
MOBA_KILLS("Champion Slayer", 0,
|
||||
new String[]{"Heroes of GWEN.Kills"},
|
||||
new String[]{"Kill players"},
|
||||
new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}},
|
||||
new int[]{100,250,500,1000,5000},
|
||||
"I",
|
||||
new String[] {"II","III","IV","V","X"},
|
||||
AchievementCategory.MOBA),
|
||||
|
||||
MOBA_WINS_ASSASSIN("Assassin Victor", 0,
|
||||
new String[]{"Heroes of GWEN.Assassin.Wins"},
|
||||
new String[]{"Win Games as an Assassin"},
|
||||
new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}},
|
||||
new int[]{10,50,100,250,500},
|
||||
"I",
|
||||
new String[] {"II","III","IV","V","X"},
|
||||
AchievementCategory.MOBA),
|
||||
|
||||
MOBA_WINS_HUNTER("Hunter Victor", 0,
|
||||
new String[]{"Heroes of GWEN.Hunter.Wins"},
|
||||
new String[]{"Win Games as a Hunter"},
|
||||
new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}},
|
||||
new int[]{10,50,100,250,500},
|
||||
"I",
|
||||
new String[] {"II","III","IV","V","X"},
|
||||
AchievementCategory.MOBA),
|
||||
|
||||
MOBA_WINS_MAGE("Mage Victor", 0,
|
||||
new String[]{"Heroes of GWEN.Mage.Wins"},
|
||||
new String[]{"Win Games as a Mage"},
|
||||
new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}},
|
||||
new int[]{10,50,100,250,500},
|
||||
"I",
|
||||
new String[] {"II","III","IV","V","X"},
|
||||
AchievementCategory.MOBA),
|
||||
|
||||
MOBA_WINS_WARRIOR("Warrior Victor", 0,
|
||||
new String[]{"Heroes of GWEN.Warrior.Wins"},
|
||||
new String[]{"Win Games as a Warrior"},
|
||||
new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}},
|
||||
new int[]{10,50,100,250,500},
|
||||
"I",
|
||||
new String[] {"II","III","IV","V","X"},
|
||||
AchievementCategory.MOBA),
|
||||
;
|
||||
|
||||
private String _name;
|
||||
private String[] _desc;
|
||||
|
@ -43,7 +43,7 @@ public enum AchievementCategory
|
||||
StatDisplay.fromGame("Wins", GameDisplay.SkywarsTeams, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.SkywarsTeams, "Wins", "Losses"),
|
||||
StatDisplay.fromGame("Kills", GameDisplay.SkywarsTeams, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.SkywarsTeams, "Deaths"),
|
||||
StatDisplay.fromGame("Gems Earned", GameDisplay.SkywarsTeams, "GemsEarned") },
|
||||
Material.FEATHER, 0, GameCategory.SURVIVAL, "Destructor Kit", false, GameDisplay.Skywars.getGameId(), GameDisplay.SkywarsTeams.getGameId()),
|
||||
Material.FEATHER, 0, GameCategory.SURVIVAL, "Earth Kit", false, GameDisplay.Skywars.getGameId(), GameDisplay.SkywarsTeams.getGameId()),
|
||||
|
||||
UHC("Ultra Hardcore", null,
|
||||
new StatDisplay[] {
|
||||
@ -220,7 +220,7 @@ public enum AchievementCategory
|
||||
Material.EMERALD, 0, GameCategory.SURVIVAL, null, false, GameDisplay.GemHunters.getGameId()),
|
||||
|
||||
MOBA("Heroes of GWEN", null,
|
||||
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, StatDisplay.fromGame("Gold Earned", GameDisplay.MOBA, "GoldEarned")},
|
||||
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED, null, StatDisplay.fromGame("Gold Earned", GameDisplay.MOBA, "GoldEarned")},
|
||||
Material.PRISMARINE_SHARD, 0, GameCategory.CLASSICS, null, false, GameDisplay.MOBA.getGameId());
|
||||
|
||||
private String _name;
|
||||
|
@ -31,7 +31,7 @@ import mineplex.core.stats.StatsManager;
|
||||
|
||||
public class AchievementPage extends ShopPageBase<AchievementManager, AchievementShop>
|
||||
{
|
||||
private static int ACHIEVEMENT_MIDDLE_INDEX = 31;
|
||||
private static final int ACHIEVEMENT_MIDDLE_INDEX = 31;
|
||||
|
||||
private AchievementCategory _category;
|
||||
private StatsManager _statsManager;
|
||||
|
@ -3,7 +3,6 @@ package mineplex.core.antihack.logging.builtin;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
@ -19,7 +18,6 @@ public class PlayerInfoMetadata extends AnticheatMetadata
|
||||
private static final String KEY_UUID = "uuid";
|
||||
private static final String KEY_ACCOUNT_ID = "accountid";
|
||||
private static final String KEY_NAME = "name";
|
||||
private static final String KEY_PING = "ping";
|
||||
|
||||
private final CoreClientManager _clientManager = require(CoreClientManager.class);
|
||||
|
||||
@ -40,7 +38,6 @@ public class PlayerInfoMetadata extends AnticheatMetadata
|
||||
{
|
||||
object.addProperty(KEY_NAME, bPlayer.getName());
|
||||
object.addProperty(KEY_ACCOUNT_ID, _clientManager.getAccountId(bPlayer));
|
||||
object.addProperty(KEY_PING, Math.min(((CraftPlayer) bPlayer).getHandle().ping, 1000));
|
||||
}
|
||||
|
||||
return object;
|
||||
|
@ -7,14 +7,12 @@ import com.google.gson.JsonObject;
|
||||
|
||||
import mineplex.core.antihack.logging.AnticheatMetadata;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
|
||||
public class ServerInfoMetadata extends AnticheatMetadata
|
||||
{
|
||||
private static final String KEY_SERVER_NAME = "server-name";
|
||||
private static final String KEY_SERVER_REGION = "server-region";
|
||||
private static final String KEY_SERVER_GROUP = "server-group";
|
||||
private static final String KEY_SERVER_TPS = "";
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
@ -29,7 +27,6 @@ public class ServerInfoMetadata extends AnticheatMetadata
|
||||
info.addProperty(KEY_SERVER_NAME, UtilServer.getServerName());
|
||||
info.addProperty(KEY_SERVER_REGION, UtilServer.getRegion().name());
|
||||
info.addProperty(KEY_SERVER_GROUP, UtilServer.getGroup());
|
||||
info.addProperty(KEY_SERVER_TPS, MinecraftServer.getServer().recentTps[0]);
|
||||
return info;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import java.util.UUID;
|
||||
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
@ -49,6 +50,8 @@ public class ViolationInfoMetadata extends AnticheatMetadata
|
||||
private static final String KEY_Z = "z";
|
||||
private static final String KEY_YAW = "yaw";
|
||||
private static final String KEY_PITCH = "pitch";
|
||||
private static final String KEY_PING = "ping";
|
||||
private static final String KEY_SERVER_TPS = "server-tps";
|
||||
|
||||
private static final JsonObject VAL_CHECK_DISABLED;
|
||||
|
||||
@ -143,11 +146,13 @@ public class ViolationInfoMetadata extends AnticheatMetadata
|
||||
location.addProperty(KEY_PITCH, MUTABLE_LOCATION.getPitch());
|
||||
|
||||
playerInfo.add(KEY_LOCATION, location);
|
||||
playerInfo.addProperty(KEY_PING, Math.min(((CraftPlayer) event.getPlayer()).getHandle().ping, 1000));
|
||||
|
||||
JsonObject data = new JsonObject();
|
||||
data.add(KEY_CURRENT_TIME, currentTime);
|
||||
data.add(KEY_VIOLATION_INFO, violationInfo);
|
||||
data.add(KEY_PLAYER_INFO, playerInfo);
|
||||
data.addProperty(KEY_SERVER_TPS, MinecraftServer.getServer().recentTps[0]);
|
||||
|
||||
violations.add(data);
|
||||
}
|
||||
|
@ -250,6 +250,19 @@ public class MobCommand extends MultiCommandBase<Creature>
|
||||
}
|
||||
argHandle.add(arg);
|
||||
}
|
||||
|
||||
else if (arg.equalsIgnoreCase("wither"))
|
||||
{
|
||||
for (Entity ent : entSet)
|
||||
{
|
||||
if (ent instanceof Skeleton)
|
||||
{
|
||||
((Skeleton) ent).setSkeletonType(SkeletonType.WITHER);
|
||||
}
|
||||
}
|
||||
|
||||
argHandle.add(arg);
|
||||
}
|
||||
}
|
||||
for (String arg : argHandle)
|
||||
argSet.remove(arg);
|
||||
|
@ -423,10 +423,26 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
|
||||
DisguisePlayer disguise = _disguises.remove(caller.getUniqueId());
|
||||
|
||||
undisguise(caller, disguise);
|
||||
|
||||
_mapping.remove(disguise.getName().toLowerCase());
|
||||
|
||||
UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!"));
|
||||
getPluginManager().callEvent(new PlayerUndisguisedEvent(caller));
|
||||
removeDisguiseData(caller);
|
||||
}
|
||||
|
||||
public void undisguise(Player caller, DisguisePlayer disguise)
|
||||
{
|
||||
GameProfile originalProfile = disguise.getOriginalProfile();
|
||||
GameProfile currentProfile = ((CraftPlayer) caller).getProfile();
|
||||
boolean sameName = caller.getName().equals(currentProfile.getName());
|
||||
|
||||
if (!sameName)
|
||||
{
|
||||
require(ScoreboardManager.class).handlePlayerQuit(disguise.getName());
|
||||
}
|
||||
|
||||
require(ScoreboardManager.class).handlePlayerQuit(disguise.getName());
|
||||
try
|
||||
{
|
||||
UtilGameProfile.changeName(currentProfile, originalProfile.getName());
|
||||
@ -447,7 +463,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
return;
|
||||
}
|
||||
|
||||
getDisguiseManager().undisguise(caller);
|
||||
getDisguiseManager().undisguise(disguise);
|
||||
|
||||
GameProfile disguisedProfile = disguise.getProfile();
|
||||
|
||||
@ -458,14 +474,10 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
require(FriendManager.class).updatePlayerStatus(originalProfile.getId(), new PlayerStatus(originalProfile.getId(), originalProfile.getName(), _serverName));
|
||||
getPreferencesManager().handlePlayerJoin(caller, true);
|
||||
|
||||
require(ScoreboardManager.class).handlePlayerJoin(disguise.getOriginalProfile().getName());
|
||||
|
||||
|
||||
_mapping.remove(disguise.getName().toLowerCase());
|
||||
|
||||
UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!"));
|
||||
getPluginManager().callEvent(new PlayerUndisguisedEvent(caller));
|
||||
removeDisguiseData(caller);
|
||||
if (!sameName)
|
||||
{
|
||||
require(ScoreboardManager.class).handlePlayerJoin(disguise.getOriginalProfile().getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void disguise(Player caller, GameProfile requestedProfile)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package mineplex.core.gadget.gadgets.particle;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import java.awt.*;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -11,6 +11,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.ParticleGadget;
|
||||
@ -19,8 +21,6 @@ import mineplex.core.inventory.data.Item;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public class ParticleLegend extends ParticleGadget
|
||||
{
|
||||
private static final double PI = Math.PI;
|
||||
@ -70,14 +70,14 @@ public class ParticleLegend extends ParticleGadget
|
||||
|
||||
for (int i = 0; i < MOVING_PARTICLES; i++)
|
||||
{
|
||||
if (_colors[i].getGreen() == 0)
|
||||
if (_colors[i % _colors.length].getGreen() == 0)
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.SMOKE,
|
||||
UtilMath.gauss(player.getLocation(), 8, 4, 8), null, 0, 1, UtilParticle.ViewDist.NORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST,
|
||||
UtilParticle.playColoredParticleToAll(_colors[i % _colors.length], UtilParticle.ParticleType.RED_DUST,
|
||||
UtilMath.gauss(player.getLocation(), 8, 4, 8), 0, UtilParticle.ViewDist.NORMAL);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,132 @@
|
||||
package mineplex.core.imagemap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.DataWatcher;
|
||||
import net.minecraft.server.v1_8_R3.EntityItemFrame;
|
||||
import net.minecraft.server.v1_8_R3.ItemStack;
|
||||
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftItemFrame;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.packethandler.PacketInfo;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class CustomItemFrames extends MiniPlugin implements IPacketHandler
|
||||
{
|
||||
|
||||
private final List<Packet> _ourPackets;
|
||||
private final Map<Integer, Map<UUID, ItemStack>> _frameData;
|
||||
|
||||
private CustomItemFrames()
|
||||
{
|
||||
super("CustomItemFrames");
|
||||
|
||||
_ourPackets = new ArrayList<>();
|
||||
_frameData = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable()
|
||||
{
|
||||
require(PacketHandler.class).addPacketHandler(this, PacketPlayOutEntityMetadata.class, PacketPlayInUseEntity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
require(PacketHandler.class).removePacketHandler(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketInfo packetInfo)
|
||||
{
|
||||
if (packetInfo.getPacket() instanceof PacketPlayOutEntityMetadata)
|
||||
{
|
||||
if (_ourPackets.remove(packetInfo.getPacket()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PacketPlayOutEntityMetadata packet = (PacketPlayOutEntityMetadata) packetInfo.getPacket();
|
||||
Map<UUID, ItemStack> map = _frameData.get(packet.a);
|
||||
|
||||
if (map != null)
|
||||
{
|
||||
UUID uuid = packetInfo.getPlayer().getUniqueId();
|
||||
ItemStack item = map.get(uuid);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
for (DataWatcher.WatchableObject meta : packet.b)
|
||||
{
|
||||
if (meta.getIndex().a() == 8)
|
||||
{
|
||||
meta.a(item, Optional.fromNullable(item));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (packetInfo.getPacket() instanceof PacketPlayInUseEntity)
|
||||
{
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) packetInfo.getPacket();
|
||||
|
||||
if (_frameData.containsKey(packet.a))
|
||||
{
|
||||
packetInfo.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setItem(Player player, ItemFrame frame, org.bukkit.inventory.ItemStack item)
|
||||
{
|
||||
ItemStack nmsItem = CraftItemStack.asNMSCopy(item.clone());
|
||||
|
||||
DataWatcher.WatchableObject<Optional<ItemStack>> frameMetaItem = new DataWatcher.WatchableObject<>(5, 8, nmsItem, EntityItemFrame.META_ITEM, Optional.fromNullable(nmsItem));
|
||||
|
||||
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata();
|
||||
packet.a = frame.getEntityId();
|
||||
packet.b = Collections.singletonList(frameMetaItem);
|
||||
|
||||
_ourPackets.add(packet);
|
||||
|
||||
UtilPlayer.sendPacket(player, packet);
|
||||
|
||||
_frameData.computeIfAbsent(frame.getEntityId(), HashMap::new).put(player.getUniqueId(), nmsItem);
|
||||
}
|
||||
|
||||
public void removeItems(ItemFrame frame)
|
||||
{
|
||||
_frameData.remove(frame.getEntityId());
|
||||
|
||||
ItemStack nmsItem = null;
|
||||
EntityItemFrame nmsEntity = ((CraftItemFrame) frame).getHandle();
|
||||
|
||||
DataWatcher watcher = new DataWatcher(nmsEntity);
|
||||
watcher.add(8, 5, EntityItemFrame.META_ITEM, Optional.fromNullable(nmsItem));
|
||||
|
||||
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(frame.getEntityId(), watcher, true);
|
||||
|
||||
MinecraftServer.getServer().getPlayerList().players.forEach(player -> player.playerConnection.sendPacket(packet));
|
||||
}
|
||||
}
|
@ -0,0 +1,266 @@
|
||||
package mineplex.core.imagemap;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.FileUtil;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.imagemap.objects.PlayerMapBoard;
|
||||
import mineplex.core.imagemap.objects.PlayerMapImage;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.utils.UtilScheduler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class ImageMapManager extends MiniPlugin
|
||||
{
|
||||
|
||||
private static final String IMAGE_DIR = ".." + File.separator + ".." + File.separator + "update" + File.separator + "files";
|
||||
private static final int PIXELS_PER_MAP = 128;
|
||||
|
||||
public static int getMapDimension()
|
||||
{
|
||||
return PIXELS_PER_MAP;
|
||||
}
|
||||
|
||||
private final CustomItemFrames _itemFrames;
|
||||
|
||||
private final Map<String, BufferedImage> _imageCache;
|
||||
private List<PlayerMapBoard> _boards;
|
||||
|
||||
private ImageMapManager()
|
||||
{
|
||||
super("Image Map");
|
||||
|
||||
_itemFrames = require(CustomItemFrames.class);
|
||||
|
||||
_imageCache = new HashMap<>();
|
||||
_boards = new ArrayList<>();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
runSyncLater(() -> _boards.forEach(board -> board.onPlayerJoin(player)), 50);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
_boards.forEach(board -> board.getImages().forEach(image -> image.removeViewer(player)));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void refreshBoards(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOWER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_boards.forEach(PlayerMapBoard::onRefresh);
|
||||
}
|
||||
|
||||
public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, String... images)
|
||||
{
|
||||
BufferedImage[] bufferedImages = new BufferedImage[images.length];
|
||||
|
||||
for (int i = 0; i < images.length; i++)
|
||||
{
|
||||
bufferedImages[i] = getImage(new File(IMAGE_DIR + File.separator + images[i]));
|
||||
}
|
||||
|
||||
return createPlayerBoard(topLeft, direction, width, height, bufferedImages);
|
||||
}
|
||||
|
||||
public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, File... images)
|
||||
{
|
||||
BufferedImage[] bufferedImages = new BufferedImage[images.length];
|
||||
|
||||
for (int i = 0; i < images.length; i++)
|
||||
{
|
||||
bufferedImages[i] = getImage(images[i]);
|
||||
}
|
||||
|
||||
return createPlayerBoard(topLeft, direction, width, height, bufferedImages);
|
||||
}
|
||||
|
||||
public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, URL... images)
|
||||
{
|
||||
BufferedImage[] bufferedImages = new BufferedImage[images.length];
|
||||
|
||||
for (int i = 0; i < images.length; i++)
|
||||
{
|
||||
bufferedImages[i] = getImage(images[i]);
|
||||
}
|
||||
|
||||
return createPlayerBoard(topLeft, direction, width, height, bufferedImages);
|
||||
}
|
||||
|
||||
public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, BufferedImage... images)
|
||||
{
|
||||
List<ItemFrame> itemFrames = createItemFrames(topLeft, direction, width, height);
|
||||
List<PlayerMapImage> mapImageList = new ArrayList<>();
|
||||
|
||||
for (BufferedImage image : images)
|
||||
{
|
||||
PlayerMapImage mapImage = new PlayerMapImage(_itemFrames, image, itemFrames, width, height);
|
||||
mapImage.create();
|
||||
|
||||
mapImageList.add(mapImage);
|
||||
}
|
||||
|
||||
PlayerMapBoard board = new PlayerMapBoard(topLeft, mapImageList);
|
||||
|
||||
runSyncLater(() -> Bukkit.getOnlinePlayers().forEach(board::onPlayerJoin), 50);
|
||||
|
||||
_boards.add(board);
|
||||
return board;
|
||||
}
|
||||
|
||||
private List<ItemFrame> createItemFrames(Location topLeft, BlockFace direction, int width, int height)
|
||||
{
|
||||
List<ItemFrame> itemFrames = new ArrayList<>();
|
||||
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
Location location = modLocation(topLeft, direction, x, y);
|
||||
|
||||
Block opposite = location.getBlock().getRelative(direction.getOppositeFace());
|
||||
|
||||
if (!UtilBlock.solid(opposite))
|
||||
{
|
||||
opposite.setType(Material.SMOOTH_BRICK);
|
||||
}
|
||||
|
||||
ItemFrame itemFrame = location.getWorld().spawn(location, ItemFrame.class);
|
||||
itemFrame.setFacingDirection(direction, true);
|
||||
itemFrames.add(itemFrame);
|
||||
}
|
||||
}
|
||||
|
||||
return itemFrames;
|
||||
}
|
||||
|
||||
private Location modLocation(Location location, BlockFace direction, int x, int y)
|
||||
{
|
||||
int modX = 0;
|
||||
int modZ = 0;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case NORTH:
|
||||
modX = -x;
|
||||
break;
|
||||
case SOUTH:
|
||||
modX = x;
|
||||
break;
|
||||
case WEST:
|
||||
modZ = x;
|
||||
break;
|
||||
case EAST:
|
||||
modZ = -x;
|
||||
break;
|
||||
}
|
||||
|
||||
return new Location(location.getWorld(), location.getBlockX() + modX, location.getBlockY() - y, location.getBlockZ() + modZ);
|
||||
}
|
||||
|
||||
private BufferedImage getImage(File file)
|
||||
{
|
||||
if (_imageCache.containsKey(file.getName()))
|
||||
{
|
||||
return _imageCache.get(file.getName());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage image = ImageIO.read(file);
|
||||
_imageCache.put(file.getName(), image);
|
||||
return image;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private BufferedImage getImage(URL url)
|
||||
{
|
||||
if (_imageCache.containsKey(url.toString()))
|
||||
{
|
||||
return _imageCache.get(url.toString());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage image = ImageIO.read(url);
|
||||
_imageCache.put(url.toString(), image);
|
||||
return image;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanupBoard(PlayerMapBoard board)
|
||||
{
|
||||
_boards.remove(board);
|
||||
|
||||
//TODO Fix when multiple boards are needed at one time
|
||||
File dataDir = new File(board.getLocation().getWorld().getName() + File.separator + "data");
|
||||
if (dataDir.isDirectory())
|
||||
{
|
||||
File[] files = dataDir.listFiles();
|
||||
|
||||
if (files != null)
|
||||
{
|
||||
for (File file : files)
|
||||
{
|
||||
if (file.getName().startsWith("map"))
|
||||
{
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
board.getImages().forEach(image ->
|
||||
{
|
||||
image.getViewers().clear();
|
||||
image.getItemFrames().forEach(Entity::remove);
|
||||
image.getItemFrames().clear();
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package mineplex.core.imagemap;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.map.MapCanvas;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class ImageMapRenderer extends MapRenderer
|
||||
{
|
||||
|
||||
private Image _image;
|
||||
private boolean _rendered;
|
||||
|
||||
public ImageMapRenderer(BufferedImage image, int x1, int y1)
|
||||
{
|
||||
int startX = Math.min(x1 * ImageMapManager.getMapDimension(), image.getWidth());
|
||||
startX = Math.max(image.getMinX(), startX);
|
||||
int startY = Math.min(y1 * ImageMapManager.getMapDimension(), image.getHeight());
|
||||
startY = Math.max(image.getMinY(), startY);
|
||||
|
||||
if (startX + ImageMapManager.getMapDimension() > image.getWidth() || startY + ImageMapManager.getMapDimension() > image.getHeight())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_image = image.getSubimage(startX, startY, ImageMapManager.getMapDimension(), ImageMapManager.getMapDimension());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MapView view, MapCanvas canvas, Player player)
|
||||
{
|
||||
if (_image != null && !_rendered)
|
||||
{
|
||||
canvas.drawImage(0, 0, _image);
|
||||
_rendered = true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
package mineplex.core.imagemap.objects;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class MapBoardSelector implements Listener
|
||||
{
|
||||
|
||||
private final PlayerMapBoard _board;
|
||||
private ArmorStand _goNext;
|
||||
private Slime _goNextBox;
|
||||
private ArmorStand _goBack;
|
||||
private Slime _goBackBox;
|
||||
|
||||
public MapBoardSelector(PlayerMapBoard board)
|
||||
{
|
||||
_board = board;
|
||||
|
||||
UtilServer.RegisterEvents(this);
|
||||
}
|
||||
|
||||
public void createHolograms(Location goNext, Location goBack)
|
||||
{
|
||||
_goNext = createArmourStand(goNext);
|
||||
_goNext.setCustomName(C.cGreen + "Next Page");
|
||||
|
||||
_goNextBox = createSlimeBox(goNext);
|
||||
|
||||
_goBack = createArmourStand(goBack);
|
||||
_goBack.setCustomName(C.cGreen + "Previous Page");
|
||||
|
||||
_goBackBox = createSlimeBox(goBack);
|
||||
}
|
||||
|
||||
private ArmorStand createArmourStand(Location location)
|
||||
{
|
||||
ArmorStand stand = location.getWorld().spawn(location.clone().subtract(0, 0.5, 0), ArmorStand.class);
|
||||
|
||||
UtilEnt.vegetate(stand);
|
||||
UtilEnt.ghost(stand, true, false);
|
||||
|
||||
stand.setCustomNameVisible(true);
|
||||
stand.setVisible(false);
|
||||
stand.setGravity(false);
|
||||
stand.setRemoveWhenFarAway(false);
|
||||
|
||||
return stand;
|
||||
}
|
||||
|
||||
private Slime createSlimeBox(Location location)
|
||||
{
|
||||
Slime slime = location.getWorld().spawn(location.clone().add(0, 1, 0), Slime.class);
|
||||
|
||||
UtilEnt.vegetate(slime);
|
||||
UtilEnt.ghost(slime, true, false);
|
||||
UtilEnt.setFakeHead(slime, true);
|
||||
UtilEnt.silence(slime, true);
|
||||
|
||||
slime.setSize(5);
|
||||
slime.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false));
|
||||
slime.setRemoveWhenFarAway(false);
|
||||
|
||||
return slime;
|
||||
}
|
||||
|
||||
public void cleanup()
|
||||
{
|
||||
_goNext.remove();
|
||||
_goNextBox.remove();
|
||||
_goBack.remove();
|
||||
_goBackBox.remove();
|
||||
UtilServer.Unregister(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClick(PlayerInteractAtEntityEvent event)
|
||||
{
|
||||
if (onClick(event.getPlayer(), event.getRightClicked()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onClick(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (onClick(event.getDamager(), event.getEntity()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean onClick(Entity clicker, Entity clicked)
|
||||
{
|
||||
if (!(clicker instanceof Player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = (Player) clicker;
|
||||
boolean action = false;
|
||||
|
||||
if (!Recharge.Instance.use(player, "Change Page", 500, false, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_goNextBox != null && _goNextBox.equals(clicked))
|
||||
{
|
||||
_board.goTo(player, true);
|
||||
action = true;
|
||||
}
|
||||
else if (_goBackBox != null && _goBackBox.equals(clicked))
|
||||
{
|
||||
_board.goTo(player, false);
|
||||
action = true;
|
||||
}
|
||||
|
||||
if (action)
|
||||
{
|
||||
UtilParticle.PlayParticle(ParticleType.CRIT, clicked.getLocation().add(0, 1.5, 0), 0.25F, 0.25F, 0.25F, 0.2F, 15, ViewDist.SHORT, player);
|
||||
player.playSound(clicked.getLocation(), Sound.WOOD_CLICK, 1, 1);
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package mineplex.core.imagemap.objects;
|
||||
|
||||
import mineplex.core.imagemap.ImageMapRenderer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.List;
|
||||
|
||||
public class MapImage
|
||||
{
|
||||
|
||||
protected final BufferedImage _image;
|
||||
protected final List<ItemFrame> _itemFrames;
|
||||
protected final int _width, _height;
|
||||
|
||||
public MapImage(BufferedImage image, List<ItemFrame> itemFrames, int width, int height)
|
||||
{
|
||||
_image = image;
|
||||
_itemFrames = itemFrames;
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
|
||||
public void create()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (int x = 0; x < _width; x++)
|
||||
{
|
||||
for (int y = 0; y < _height; y++)
|
||||
{
|
||||
ItemFrame frame = _itemFrames.get(i++);
|
||||
|
||||
frame.setItem(getMapItem(frame.getWorld(), x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected ItemStack getMapItem(World world, int x, int y)
|
||||
{
|
||||
ItemStack item = new ItemStack(Material.MAP);
|
||||
|
||||
MapView map = Bukkit.getServer().createMap(world);
|
||||
map.getRenderers().forEach(map::removeRenderer);
|
||||
|
||||
map.addRenderer(new ImageMapRenderer(_image, x, y));
|
||||
item.setDurability(map.getId());
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package mineplex.core.imagemap.objects;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class PlayerMapBoard
|
||||
{
|
||||
|
||||
private static final int VIEW_DIST_SQUARED = 28 * 28;
|
||||
|
||||
private final Location _location;
|
||||
private final List<PlayerMapImage> _images;
|
||||
private final Set<Player> _viewers;
|
||||
|
||||
public PlayerMapBoard(Location location, List<PlayerMapImage> images)
|
||||
{
|
||||
_location = location;
|
||||
_images = images;
|
||||
_viewers = new HashSet<>();
|
||||
}
|
||||
|
||||
public void goTo(Player player, boolean next)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (PlayerMapImage image : _images)
|
||||
{
|
||||
if (image.getViewers().contains(player))
|
||||
{
|
||||
if (next && _images.size() - 1 == i)
|
||||
{
|
||||
i = -1;
|
||||
}
|
||||
else if (!next && i == 0)
|
||||
{
|
||||
i = _images.size();
|
||||
}
|
||||
|
||||
image.removeViewer(player);
|
||||
_images.get(next ? i + 1 : i - 1).addViewer(player);
|
||||
return;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerJoin(Player player)
|
||||
{
|
||||
_images.get(0).addViewer(player);
|
||||
}
|
||||
|
||||
public void onRefresh()
|
||||
{
|
||||
Bukkit.getOnlinePlayers().forEach(player ->
|
||||
{
|
||||
|
||||
if (UtilMath.offset2dSquared(player.getLocation(), _location) < VIEW_DIST_SQUARED)
|
||||
{
|
||||
_viewers.add(player);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
public List<PlayerMapImage> getImages()
|
||||
{
|
||||
return _images;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package mineplex.core.imagemap.objects;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.imagemap.CustomItemFrames;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerMapImage extends MapImage
|
||||
{
|
||||
|
||||
private final CustomItemFrames _itemFramesManager;
|
||||
private final List<ItemStack> _itemMaps;
|
||||
private final List<Player> _viewers;
|
||||
|
||||
public PlayerMapImage(CustomItemFrames itemFramesManager, BufferedImage image, List<ItemFrame> itemFrames, int width, int height)
|
||||
{
|
||||
super(image, itemFrames, width, height);
|
||||
|
||||
_itemFramesManager = itemFramesManager;
|
||||
_itemMaps = new ArrayList<>();
|
||||
_viewers = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create()
|
||||
{
|
||||
World world = _itemFrames.get(0).getWorld();
|
||||
|
||||
for (int x = 0; x < _width; x++)
|
||||
{
|
||||
for (int y = 0; y < _height; y++)
|
||||
{
|
||||
_itemMaps.add(getMapItem(world, x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<ItemFrame> getItemFrames()
|
||||
{
|
||||
return _itemFrames;
|
||||
}
|
||||
|
||||
public void addViewer(Player player)
|
||||
{
|
||||
if (!_viewers.add(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//FIXME
|
||||
int slot = 8;
|
||||
for (ItemStack itemStack : _itemMaps)
|
||||
{
|
||||
player.getInventory().setItem(slot++, itemStack);
|
||||
}
|
||||
|
||||
UtilServer.runSyncLater(() -> player.getInventory().removeItem(_itemMaps.toArray(new ItemStack[0])), 5);
|
||||
|
||||
for (int i = 0; i < _itemMaps.size(); i++)
|
||||
{
|
||||
ItemFrame itemFrame = _itemFrames.get(i);
|
||||
ItemStack itemStack = _itemMaps.get(i);
|
||||
|
||||
_itemFramesManager.setItem(player, itemFrame, itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeViewer(Player player)
|
||||
{
|
||||
_viewers.remove(player);
|
||||
}
|
||||
|
||||
public List<Player> getViewers()
|
||||
{
|
||||
return _viewers;
|
||||
}
|
||||
}
|
@ -15,13 +15,13 @@ import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType;
|
||||
|
||||
public class Leaderboard
|
||||
{
|
||||
private String _display;
|
||||
private Pair<String, String> _statDisplay;
|
||||
private String[] _statNames;
|
||||
private int[] _statIds;
|
||||
private int _size, _start;
|
||||
private LeaderboardSQLType _type;
|
||||
private Location _loc;
|
||||
private final String _display;
|
||||
private final Pair<String, String> _statDisplay;
|
||||
private final String[] _statNames;
|
||||
private final int[] _statIds;
|
||||
private final int _size, _start;
|
||||
private final LeaderboardSQLType _type;
|
||||
private final Location _loc;
|
||||
private Hologram _holo;
|
||||
|
||||
public Leaderboard(String display, Pair<String, String> statDisplayNames, String[] statNames, LeaderboardSQLType type, Location displayLoc, int size)
|
||||
@ -37,6 +37,7 @@ public class Leaderboard
|
||||
_statIds = new int[_statNames.length];
|
||||
_type = type;
|
||||
_size = size;
|
||||
_start = start;
|
||||
_loc = displayLoc;
|
||||
|
||||
update(new LinkedHashMap<>());
|
||||
@ -52,12 +53,15 @@ public class Leaderboard
|
||||
return _start;
|
||||
}
|
||||
|
||||
/**
|
||||
* The returned array is not safe for mutation
|
||||
*/
|
||||
public String[] getStatNames()
|
||||
{
|
||||
return _statNames;
|
||||
}
|
||||
|
||||
public int[] getStatIds()
|
||||
public synchronized int[] getStatIds()
|
||||
{
|
||||
return _statIds;
|
||||
}
|
||||
@ -89,6 +93,14 @@ public class Leaderboard
|
||||
_holo = new Hologram(Managers.get(LeaderboardManager.class).getHologramManager(), _loc, display.toArray(new String[display.size()])).start();
|
||||
}
|
||||
|
||||
public synchronized void setStatId(int index, int id)
|
||||
{
|
||||
if (_statIds.length > index && index >= 0)
|
||||
{
|
||||
_statIds[index] = id;
|
||||
}
|
||||
}
|
||||
|
||||
public void deconstruct()
|
||||
{
|
||||
if (_holo != null)
|
||||
|
@ -120,7 +120,7 @@ public class LeaderboardManager extends MiniPlugin
|
||||
final int index = i;
|
||||
Managers.get(StatsManager.class).loadStatId(board.getStatNames()[index], id ->
|
||||
{
|
||||
board.getStatIds()[index] = id.intValue();
|
||||
board.setStatId(index, id.intValue());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -90,73 +90,79 @@ public class LeaderboardRepository extends RepositoryBase
|
||||
|
||||
public void insertStats(int accountId, Map<Integer, Long> stats)
|
||||
{
|
||||
try (
|
||||
Connection c = getConnection();
|
||||
PreparedStatement updateStat = c.prepareStatement(UPDATE_STAT);
|
||||
PreparedStatement insertStat = c.prepareStatement(INSERT_STAT);
|
||||
)
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
for (Integer statId : stats.keySet())
|
||||
try (
|
||||
Connection c = getConnection();
|
||||
PreparedStatement updateStat = c.prepareStatement(UPDATE_STAT);
|
||||
PreparedStatement insertStat = c.prepareStatement(INSERT_STAT);
|
||||
)
|
||||
{
|
||||
updateStat.setLong(1, stats.get(statId));
|
||||
updateStat.setInt(2, accountId);
|
||||
updateStat.setInt(3, statId);
|
||||
updateStat.addBatch();
|
||||
}
|
||||
int[] rowsAffected = updateStat.executeBatch();
|
||||
int i = 0;
|
||||
for (Integer statId : stats.keySet())
|
||||
{
|
||||
if (rowsAffected[i] < 1)
|
||||
for (Integer statId : stats.keySet())
|
||||
{
|
||||
insertStat.setInt(1, accountId);
|
||||
insertStat.setInt(2, statId);
|
||||
insertStat.setLong(3, stats.get(statId));
|
||||
insertStat.addBatch();
|
||||
updateStat.setLong(1, stats.get(statId));
|
||||
updateStat.setInt(2, accountId);
|
||||
updateStat.setInt(3, statId);
|
||||
updateStat.addBatch();
|
||||
}
|
||||
i++;
|
||||
int[] rowsAffected = updateStat.executeBatch();
|
||||
int i = 0;
|
||||
for (Integer statId : stats.keySet())
|
||||
{
|
||||
if (rowsAffected[i] < 1)
|
||||
{
|
||||
insertStat.setInt(1, accountId);
|
||||
insertStat.setInt(2, statId);
|
||||
insertStat.setLong(3, stats.get(statId));
|
||||
insertStat.addBatch();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
insertStat.executeBatch();
|
||||
}
|
||||
insertStat.executeBatch();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadLeaderboard(Leaderboard board, Consumer<Map<String, Integer>> leaderboard)
|
||||
{
|
||||
Map<String, Integer> names = new LinkedHashMap<>();
|
||||
try (
|
||||
Connection c = getConnection();
|
||||
Statement s = c.createStatement();
|
||||
)
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
s.execute(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize()));
|
||||
for (int i = 0; i < board.getStatIds().length; i++)
|
||||
Map<String, Integer> names = new LinkedHashMap<>();
|
||||
try (
|
||||
Connection c = getConnection();
|
||||
Statement s = c.createStatement();
|
||||
)
|
||||
{
|
||||
try (ResultSet rs = s.getResultSet())
|
||||
s.execute(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize()));
|
||||
for (int i = 0; i < board.getStatIds().length; i++)
|
||||
{
|
||||
while (rs.next())
|
||||
try (ResultSet rs = s.getResultSet())
|
||||
{
|
||||
names.merge(rs.getString("name"), rs.getInt("value"), Integer::sum);
|
||||
}
|
||||
|
||||
if (!s.getMoreResults())
|
||||
{
|
||||
break;
|
||||
while (rs.next())
|
||||
{
|
||||
names.merge(rs.getString("name"), rs.getInt("value"), Integer::sum);
|
||||
}
|
||||
|
||||
if (!s.getMoreResults())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
UtilServer.runSync(() -> leaderboard.accept(names));
|
||||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
UtilServer.runSync(() -> leaderboard.accept(names));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -7,12 +7,12 @@ import org.bukkit.map.MapCanvas;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
public class ImageMapRenderer extends MapRenderer
|
||||
class ImageMapRenderer extends MapRenderer
|
||||
{
|
||||
private BufferedImage _image;
|
||||
private boolean _first = true;
|
||||
|
||||
public ImageMapRenderer(BufferedImage image)
|
||||
ImageMapRenderer(BufferedImage image)
|
||||
{
|
||||
_image = image;
|
||||
}
|
||||
|
@ -42,6 +42,12 @@ public class LagMeter extends MiniPlugin
|
||||
_start = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new VersionsCommand(this));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
|
@ -0,0 +1,74 @@
|
||||
package mineplex.core.monitor;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.print.attribute.IntegerSyntax;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
|
||||
/**
|
||||
* Statistics on versions
|
||||
* @author Dan
|
||||
*/
|
||||
public class VersionsCommand extends CommandBase<LagMeter>
|
||||
{
|
||||
public VersionsCommand(LagMeter plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "versions", "getver");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
Map<Integer, Integer> versions = new HashMap<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
int version = ((CraftPlayer) player).getHandle().getProtocol();
|
||||
int players = versions.getOrDefault(version, 0);
|
||||
versions.put(version, players + 1);
|
||||
}
|
||||
|
||||
UtilPlayer.message(caller, F.main("Version", "Distribution on " + C.cGold
|
||||
+ UtilServer.getServerName()));
|
||||
|
||||
List<Map.Entry<Integer, Integer>> sorted = versions
|
||||
.entrySet().stream()
|
||||
.sorted(Comparator.comparing(Map.Entry::getValue, (i1, i2) -> -i1.compareTo(i2)))
|
||||
.collect(Collectors.toList());
|
||||
for (Map.Entry<Integer, Integer> entry : sorted)
|
||||
{
|
||||
UtilPlayer.message(caller,
|
||||
F.main("Version", C.cYellow + entry.getKey() + C.cGray + ": " + C.cGreen
|
||||
+ entry.getValue() + C.cGray + " players"));
|
||||
}
|
||||
} else if (args.length == 1)
|
||||
{
|
||||
List<Player> players = UtilPlayer.matchOnline(caller, args[0], true);
|
||||
if (!players.isEmpty())
|
||||
{
|
||||
Player player = players.get(0);
|
||||
UtilPlayer.message(caller,
|
||||
F.main("Version", C.cYellow + player.getName() + C.cGray + " is on protocol "
|
||||
+ C.cGreen + ((CraftPlayer) player).getHandle().getProtocol()));
|
||||
}
|
||||
} else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Version", "Invalid argument list."));
|
||||
}
|
||||
}
|
||||
}
|
@ -132,7 +132,7 @@ public class Portal extends MiniPlugin
|
||||
{
|
||||
if (server.getGroup().equalsIgnoreCase("Clans") && server.getMotd().equalsIgnoreCase("Restarting soon"))
|
||||
{
|
||||
UtilPlayer.message(player, F.main(getName(), C.cGold + "serverName" + C.cRed + " is restarting!"));
|
||||
UtilPlayer.message(player, F.main(getName(), C.cGold + serverName + C.cRed + " is restarting!"));
|
||||
return;
|
||||
}
|
||||
if (server.getPlayerCount() < server.getMaxPlayerCount() || playerRank.has(Rank.ULTRA))
|
||||
|
@ -8,7 +8,7 @@ package mineplex.core.quests;
|
||||
public enum TriggerType
|
||||
{
|
||||
|
||||
KILL("Kill"), DIE("Die"), WIN("Win"), LOSE("Lose"), COLLECT("Collect"), PLAY("Play"), COMPLETE("Complete");
|
||||
KILL("Kill"), DIE("Die"), WIN("Win"), LOSE("Lose"), COLLECT("Collect"), PLAY("Play"), COMPLETE("Complete"), HIT("Hit"), FIRST_BLOOD("First Blood");
|
||||
|
||||
private String _name;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.core.quests.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -7,6 +9,7 @@ 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.common.util.UtilServer;
|
||||
import mineplex.core.quests.Quest;
|
||||
import mineplex.core.quests.QuestManager;
|
||||
|
||||
@ -37,19 +40,44 @@ public class GetQuestCommand extends CommandBase<QuestManager>
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = caller;
|
||||
ArrayList<Player> players = new ArrayList<>();
|
||||
if (args.length == 2)
|
||||
{
|
||||
if (UtilPlayer.searchExact(args[1]) != null)
|
||||
player = UtilPlayer.searchExact(args[1]);
|
||||
{
|
||||
players.add(UtilPlayer.searchExact(args[1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (args[1].equalsIgnoreCase("all"))
|
||||
{
|
||||
players.addAll(UtilServer.getPlayersCollection());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
players.add(caller);
|
||||
}
|
||||
|
||||
Quest quest = Plugin.getQuestByID(Integer.parseInt(args[0]));
|
||||
|
||||
Plugin.addNewQuest(player, quest);
|
||||
UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "Added " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName()));
|
||||
for (Player player : players)
|
||||
{
|
||||
Plugin.addNewQuest(player, quest);
|
||||
UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "Added " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName()));
|
||||
|
||||
|
||||
if (!args[1].equalsIgnoreCase("all"))
|
||||
{
|
||||
if (caller != players.get(0))
|
||||
UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
if (caller != player)
|
||||
UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + player.getName()));
|
||||
if (args[1].equalsIgnoreCase("all"))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + "everyone"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,133 +0,0 @@
|
||||
package mineplex.core.sponsorbranding;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* Manager for creating billboards with branding logos
|
||||
*/
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class BrandingManager extends MiniPlugin
|
||||
{
|
||||
private ConcurrentHashMap<Integer, BrandingPost> _posts = new ConcurrentHashMap<Integer, BrandingPost>();
|
||||
private ConcurrentHashMap<String, BufferedImage> _imgCache = new ConcurrentHashMap<String, BufferedImage>();
|
||||
|
||||
private BrandingManager()
|
||||
{
|
||||
super("Branding Manager");
|
||||
}
|
||||
|
||||
private BufferedImage getImage(String fileName)
|
||||
{
|
||||
if (_imgCache.containsKey(fileName))
|
||||
{
|
||||
return _imgCache.get(fileName);
|
||||
}
|
||||
|
||||
File folder = new File("../../update");
|
||||
File f = new File(folder, "logos" + File.separatorChar + fileName);
|
||||
BufferedImage image = null;
|
||||
|
||||
if (!f.exists())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
image = ImageIO.read(f);
|
||||
_imgCache.put(fileName, image);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
private BufferedImage getImage(URL url)
|
||||
{
|
||||
if (_imgCache.containsKey(url.toString()))
|
||||
{
|
||||
return _imgCache.get(url.toString());
|
||||
}
|
||||
|
||||
BufferedImage image = null;
|
||||
|
||||
try
|
||||
{
|
||||
image = ImageIO.read(url);
|
||||
_imgCache.put(url.toString(), image);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a billboard with a stored logo
|
||||
* @param location The center of the billboard
|
||||
* @param facing The BlockFace the logo will appear on
|
||||
* @param imageFileName The file name of the logo's base image
|
||||
*/
|
||||
public void createPost(Location location, BlockFace facing, String imageFileName)
|
||||
{
|
||||
BufferedImage img = getImage(imageFileName);
|
||||
if (img == null)
|
||||
{
|
||||
System.out.println("ERROR! Invalid image file name!");
|
||||
return;
|
||||
}
|
||||
BrandingPost bp = new BrandingPost(location, facing, img);
|
||||
bp.spawn();
|
||||
_posts.put(_posts.size(), bp);
|
||||
}
|
||||
|
||||
public void createPost(Location location, BlockFace facing, URL url)
|
||||
{
|
||||
BufferedImage image = getImage(url);
|
||||
|
||||
if (image == null)
|
||||
{
|
||||
System.out.println("ERROR! Invalid image url!");
|
||||
return;
|
||||
}
|
||||
|
||||
BrandingPost brandingPost = new BrandingPost(location, facing, image);
|
||||
brandingPost.spawn();
|
||||
// Umm why not use a List?
|
||||
_posts.put(_posts.size(), brandingPost);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears away all existing billboards
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
disable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
for (Integer key : _posts.keySet())
|
||||
{
|
||||
_posts.remove(key).despawn();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,242 +0,0 @@
|
||||
package mineplex.core.sponsorbranding;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* An instance of a billboard with all its required data
|
||||
*/
|
||||
public class BrandingPost
|
||||
{
|
||||
private Location _center;
|
||||
private BlockFace _facing;
|
||||
private BufferedImage _img;
|
||||
|
||||
private Location[] _corners;
|
||||
private List<ItemFrame> _ents = Lists.newArrayList();
|
||||
|
||||
public BrandingPost(Location center, BlockFace facing, BufferedImage image)
|
||||
{
|
||||
_center = center;
|
||||
_facing = facing;
|
||||
_img = image;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private ItemStack getMapItem(int x, int y, BufferedImage image)
|
||||
{
|
||||
ItemStack item = new ItemStack(Material.MAP);
|
||||
|
||||
MapView map = Bukkit.getServer().createMap(Bukkit.getServer().getWorlds().get(0));
|
||||
for (MapRenderer r : map.getRenderers())
|
||||
{
|
||||
map.removeRenderer(r);
|
||||
}
|
||||
|
||||
map.addRenderer(new LogoMapRenderer(image, x, y));
|
||||
item.setDurability(map.getId());
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a billboard using parameters from instance constructor
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void spawn()
|
||||
{
|
||||
Location corner1 = _center.clone();
|
||||
Location corner2 = _center.clone();
|
||||
Location corner3 = _center.clone();
|
||||
Location corner4 = _center.clone();
|
||||
|
||||
int width = (int) Math.ceil(_img.getWidth() / 128);
|
||||
int height = (int) Math.ceil(_img.getHeight() / 128);
|
||||
|
||||
Bukkit.broadcastMessage("width=" + width + " height=" + height);
|
||||
|
||||
switch (_facing)
|
||||
{
|
||||
case EAST:
|
||||
corner1.add(0, 1, -2);
|
||||
corner2.add(0, -1, 2);
|
||||
corner3.add(0, 2, -3);
|
||||
corner4.add(0, -2, 3);
|
||||
break;
|
||||
case WEST:
|
||||
corner1.add(0, 1, -2);
|
||||
corner2.add(0, -1, 2);
|
||||
corner3.add(0, 2, -3);
|
||||
corner4.add(0, -2, 3);
|
||||
break;
|
||||
case SOUTH:
|
||||
corner1.add(-2, 1, 0);
|
||||
corner2.add(2, -1, 0);
|
||||
corner3.add(-3, 2, 0);
|
||||
corner4.add(3, -2, 0);
|
||||
break;
|
||||
case NORTH:
|
||||
corner1.add(-2, 1, 0);
|
||||
corner2.add(2, -1, 0);
|
||||
corner3.add(-3, 2, 0);
|
||||
corner4.add(3, -2, 0);
|
||||
break;
|
||||
default:
|
||||
System.out.println("ERROR! Invalid BlockFace given while loading BrandingPost!");
|
||||
return;
|
||||
}
|
||||
|
||||
_corners = new Location[] {corner1, corner2, corner3, corner4};
|
||||
|
||||
for (int x = Math.max(corner1.getBlockX(), corner2.getBlockX()); x >= Math.min(corner1.getBlockX(), corner2.getBlockX()); x--)
|
||||
{
|
||||
for (int y = Math.max(corner1.getBlockY(), corner2.getBlockY()); y >= Math.min(corner1.getBlockY(), corner2.getBlockY()); y--)
|
||||
{
|
||||
for (int z = Math.max(corner1.getBlockZ(), corner2.getBlockZ()); z >= Math.min(corner1.getBlockZ(), corner2.getBlockZ()); z--)
|
||||
{
|
||||
Location set = new Location(_center.getWorld(), x, y, z);
|
||||
set.getBlock().setType(Material.STAINED_CLAY);
|
||||
set.getBlock().setData(DyeColor.LIGHT_BLUE.getWoolData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int xMod = 0;
|
||||
int zMod = 0;
|
||||
|
||||
switch (_facing)
|
||||
{
|
||||
case EAST:
|
||||
zMod = -1;
|
||||
break;
|
||||
case WEST:
|
||||
zMod = 1;
|
||||
break;
|
||||
case SOUTH:
|
||||
xMod = 1;
|
||||
break;
|
||||
case NORTH:
|
||||
xMod = -1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
BufferedImage image = _img;
|
||||
|
||||
if (image == null)
|
||||
{
|
||||
System.out.println("ERROR! Invalid image given while loading BrandingPost!");
|
||||
return;
|
||||
}
|
||||
|
||||
Block base = corner1.getBlock().getRelative(_facing);
|
||||
|
||||
try
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
ItemFrame i = null;
|
||||
Block block = base.getRelative(x * xMod, -y, x * zMod);
|
||||
i = block.getWorld().spawn(block.getLocation(), ItemFrame.class);
|
||||
|
||||
i.setFacingDirection(_facing, false);
|
||||
|
||||
ItemStack item = getMapItem(x, y, _img);
|
||||
i.setItem(item);
|
||||
|
||||
Bukkit.broadcastMessage(x + " <- X Y -> " + y);
|
||||
_ents.add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("ERROR! ItemFrame space already occupied!");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int x = Math.max(corner3.getBlockX(), corner4.getBlockX()); x >= Math.min(corner3.getBlockX(), corner4.getBlockX()); x--)
|
||||
{
|
||||
for (int y = Math.max(corner3.getBlockY(), corner4.getBlockY()); y >= Math.min(corner3.getBlockY(), corner4.getBlockY()); y--)
|
||||
{
|
||||
for (int z = Math.max(corner3.getBlockZ(), corner4.getBlockZ()); z >= Math.min(corner3.getBlockZ(), corner4.getBlockZ()); z--)
|
||||
{
|
||||
Location set = new Location(_center.getWorld(), x, y, z);
|
||||
if (set.getBlock().getType() == Material.STAINED_CLAY)
|
||||
continue;
|
||||
|
||||
if (UtilMath.offset2d(corner3.getBlock().getLocation(), set.getBlock().getLocation()) == 0 || UtilMath.offset2d(corner4.getBlock().getLocation(), set.getBlock().getLocation()) == 0)
|
||||
{
|
||||
if (corner3.getBlockY() != set.getBlockY() && corner4.getBlockY() != set.getBlockY())
|
||||
{
|
||||
Material type = Material.COBBLE_WALL;
|
||||
if (_center.getBlockY() == set.getBlockY())
|
||||
{
|
||||
type = Material.FENCE;
|
||||
}
|
||||
|
||||
set.getBlock().setType(type);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Material type = Material.STEP;
|
||||
byte data = (byte)5;
|
||||
if (set.getBlockY() == corner4.getBlockY())
|
||||
{
|
||||
type = Material.SMOOTH_BRICK;
|
||||
data = (byte)0;
|
||||
}
|
||||
|
||||
set.getBlock().setType(type);
|
||||
set.getBlock().setData(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears away all blocks and ItemFrames generated by this billboard
|
||||
*/
|
||||
public void despawn()
|
||||
{
|
||||
if (_corners != null)
|
||||
{
|
||||
for (int x = Math.max(_corners[2].getBlockX(), _corners[3].getBlockX()); x >= Math.min(_corners[2].getBlockX(), _corners[3].getBlockX()); x--)
|
||||
{
|
||||
for (int y = Math.max(_corners[2].getBlockY(), _corners[3].getBlockY()); y >= Math.min(_corners[2].getBlockY(), _corners[3].getBlockY()); y--)
|
||||
{
|
||||
for (int z = Math.max(_corners[2].getBlockZ(), _corners[3].getBlockZ()); z >= Math.min(_corners[2].getBlockZ(), _corners[3].getBlockZ()); z--)
|
||||
{
|
||||
Location set = new Location(_center.getWorld(), x, y, z);
|
||||
set.getBlock().setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ItemFrame it : _ents)
|
||||
{
|
||||
it.setItem(new ItemStack(Material.AIR));
|
||||
it.remove();
|
||||
}
|
||||
_ents.clear();
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package mineplex.core.sponsorbranding;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.map.MapCanvas;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
/**
|
||||
* Renderer for each map panel of the full billboard logo
|
||||
*/
|
||||
public class LogoMapRenderer extends MapRenderer
|
||||
{
|
||||
private Image _img;
|
||||
private boolean _first = true;
|
||||
|
||||
public LogoMapRenderer(BufferedImage image, int x1, int y1)
|
||||
{
|
||||
recalculateInput(image, x1, y1);
|
||||
}
|
||||
|
||||
private void recalculateInput(BufferedImage input, int x1, int y1)
|
||||
{
|
||||
if (x1 > input.getWidth() || y1 > input.getHeight())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int startX = Math.min(x1 * 128, input.getWidth());
|
||||
startX = Math.max(input.getMinX(), startX);
|
||||
int startY = Math.min(y1 * 128, input.getHeight());
|
||||
startY = Math.max(input.getMinY(), startY);
|
||||
|
||||
_img = input.getSubimage(startX, startY, 128, 128);
|
||||
|
||||
_first = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MapView view, MapCanvas canvas, Player player)
|
||||
{
|
||||
if (_img != null && _first)
|
||||
{
|
||||
canvas.drawImage(0, 0, _img);
|
||||
_first = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package mineplex.core.stats.game;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.timing.TimingManager;
|
||||
import mineplex.core.game.GameDisplay;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class GameStatisticsManager extends MiniPlugin
|
||||
{
|
||||
|
||||
private final StatsManager _statsManager;
|
||||
|
||||
private final GameStatisticsRepository _repository;
|
||||
|
||||
private final Map<String, Integer> _gameMaps;
|
||||
|
||||
private GameStatisticsManager()
|
||||
{
|
||||
super("Game Statistics");
|
||||
|
||||
_statsManager = require(StatsManager.class);
|
||||
_repository = new GameStatisticsRepository(_statsManager);
|
||||
_gameMaps = Collections.synchronizedMap(new HashMap<>());
|
||||
}
|
||||
|
||||
public void getMapId(Consumer<Integer> callback, GameDisplay gameType, String mapName)
|
||||
{
|
||||
if (_gameMaps.containsKey(mapName))
|
||||
{
|
||||
if (callback != null)
|
||||
{
|
||||
callback.accept(_gameMaps.get(mapName));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
runAsync(() ->
|
||||
_repository.getMapId(mapId ->
|
||||
{
|
||||
_gameMaps.put(mapName, mapId);
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
runSync(() -> callback.accept(mapId));
|
||||
}
|
||||
}, gameType.getGameId(), mapName));
|
||||
}
|
||||
}
|
||||
|
||||
public void saveGameStats(GameStats gameStats)
|
||||
{
|
||||
runAsync(() ->
|
||||
{
|
||||
TimingManager.start("Save Game Stats");
|
||||
_repository.saveGame(gameStats);
|
||||
TimingManager.stop("Save Game Stats");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,166 @@
|
||||
package mineplex.core.stats.game;
|
||||
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.game.GameDisplay;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnTimestamp;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class GameStatisticsRepository extends RepositoryBase
|
||||
{
|
||||
|
||||
private static final String INSERT_MAP = "INSERT INTO gameMaps (gameType,mapName) VALUES (?,?)";
|
||||
private static final String GET_MAP_BY_ID = "SELECT mapId FROM gameMaps WHERE mapName=?";
|
||||
private static final String SAVE_GAME = "INSERT INTO gameStatistics (region,gameType,map,startTime,endTime) VALUES (?,?,?,?,?)";
|
||||
private static final String SAVE_STAT = "INSERT INTO gamePlayerStatistics VALUES (?,?,?,?);";
|
||||
private static final String GET_BY_ID = "SELECT * FROM gameStatistics WHERE gameId=?";
|
||||
private static final String SQL_REGEX = "\\?";
|
||||
private static final long MAX_RESPONSE_TIME = TimeUnit.SECONDS.toMillis(5);
|
||||
|
||||
private final StatsManager _statsManager;
|
||||
|
||||
public GameStatisticsRepository(StatsManager statsManager)
|
||||
{
|
||||
super(DBPool.getAccount());
|
||||
|
||||
_statsManager = statsManager;
|
||||
}
|
||||
|
||||
public void getMapId(Consumer<Integer> callback, int gameId, String mapName)
|
||||
{
|
||||
executeQuery(GET_MAP_BY_ID, resultSet ->
|
||||
{
|
||||
if (resultSet.next())
|
||||
{
|
||||
callback.accept(resultSet.getInt(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
executeInsert(INSERT_MAP, resultSetInsert ->
|
||||
{
|
||||
if (resultSetInsert.next())
|
||||
{
|
||||
callback.accept(resultSetInsert.getInt(1));
|
||||
}
|
||||
},
|
||||
new ColumnInt("gameType", gameId),
|
||||
new ColumnVarChar("mapName", 32, mapName)
|
||||
);
|
||||
}
|
||||
}, new ColumnVarChar("mapName", 32, mapName));
|
||||
}
|
||||
|
||||
public void saveGame(GameStats gameStats)
|
||||
{
|
||||
executeInsert(SAVE_GAME, resultSet ->
|
||||
{
|
||||
if (resultSet.next())
|
||||
{
|
||||
int gameId = resultSet.getInt(1);
|
||||
|
||||
saveGameStats(gameId, gameStats);
|
||||
}
|
||||
},
|
||||
|
||||
new ColumnVarChar("region", 2, gameStats.getRegion().name()),
|
||||
new ColumnInt("gameType", gameStats.getGameType().getGameId()),
|
||||
new ColumnInt("map", gameStats.getMapId()),
|
||||
new ColumnTimestamp("startTime", new Timestamp(gameStats.getStartTime())),
|
||||
new ColumnTimestamp("endTime", new Timestamp(gameStats.getEndTime()))
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
private void saveGameStats(int gameId, GameStats gameStats)
|
||||
{
|
||||
String gameIdString = String.valueOf(gameId);
|
||||
Map<Integer, Map<String, Long>> stats = gameStats.getStats();
|
||||
|
||||
StringBuilder builder = new StringBuilder(1000);
|
||||
long start = System.currentTimeMillis();
|
||||
AtomicInteger sqlAppends = new AtomicInteger();
|
||||
AtomicInteger expectedSqlAppends = new AtomicInteger();
|
||||
|
||||
stats.forEach((playerId, statsMap) -> expectedSqlAppends.getAndAdd(statsMap.size()));
|
||||
|
||||
stats.forEach((playerId, statsMap) ->
|
||||
{
|
||||
String playerIdString = String.valueOf(playerId);
|
||||
|
||||
statsMap.forEach((name, value) ->
|
||||
{
|
||||
_statsManager.loadStatId(name, statId ->
|
||||
{
|
||||
String statIdString = String.valueOf(statId);
|
||||
String statValueString = String.valueOf(value);
|
||||
|
||||
String sql = SAVE_STAT
|
||||
.replaceFirst(SQL_REGEX, gameIdString)
|
||||
.replaceFirst(SQL_REGEX, playerIdString)
|
||||
.replaceFirst(SQL_REGEX, statIdString)
|
||||
.replaceFirst(SQL_REGEX, statValueString);
|
||||
|
||||
builder.append(sql);
|
||||
sqlAppends.getAndIncrement();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
while (sqlAppends.get() < expectedSqlAppends.get())
|
||||
{
|
||||
if (UtilTime.elapsed(start, MAX_RESPONSE_TIME))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Thread.sleep(500);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try (
|
||||
Connection connection = getConnection()
|
||||
)
|
||||
{
|
||||
PreparedStatement preparedStatement = connection.prepareStatement(builder.toString());
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void getGameStats(Consumer<GameStats> callback, int gameId)
|
||||
{
|
||||
executeQuery(GET_BY_ID, resultSet ->
|
||||
{
|
||||
|
||||
if (resultSet.next())
|
||||
{
|
||||
GameStats stats = new GameStats(gameId, Region.valueOf(resultSet.getString("region")), GameDisplay.getById(gameId));
|
||||
callback.accept(stats);
|
||||
}
|
||||
|
||||
}, new ColumnInt("gameId", gameId));
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package mineplex.core.stats.game;
|
||||
|
||||
import mineplex.core.game.GameDisplay;
|
||||
import mineplex.serverdata.Region;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class GameStats
|
||||
{
|
||||
|
||||
private final int _gameId;
|
||||
private final Region _region;
|
||||
private final GameDisplay _gameType;
|
||||
|
||||
private int _mapId;
|
||||
private long _startTime;
|
||||
private long _endTime;
|
||||
|
||||
private final Map<Integer, Map<String, Long>> _stats;
|
||||
|
||||
public GameStats(int gameId, Region region, GameDisplay display)
|
||||
{
|
||||
_gameId = gameId;
|
||||
_region = region;
|
||||
_gameType = display;
|
||||
_stats = new HashMap<>();
|
||||
}
|
||||
|
||||
public int getGameId()
|
||||
{
|
||||
return _gameId;
|
||||
}
|
||||
|
||||
public Region getRegion()
|
||||
{
|
||||
return _region;
|
||||
}
|
||||
|
||||
public GameDisplay getGameType()
|
||||
{
|
||||
return _gameType;
|
||||
}
|
||||
|
||||
public void setMapId(int mapId)
|
||||
{
|
||||
_mapId = mapId;
|
||||
}
|
||||
|
||||
public int getMapId()
|
||||
{
|
||||
return _mapId;
|
||||
}
|
||||
|
||||
public void setStartTime(long startTime)
|
||||
{
|
||||
_startTime = startTime;
|
||||
}
|
||||
|
||||
public long getStartTime()
|
||||
{
|
||||
return _startTime;
|
||||
}
|
||||
|
||||
public void setEndTime(long endTime)
|
||||
{
|
||||
_endTime = endTime;
|
||||
}
|
||||
|
||||
public long getEndTime()
|
||||
{
|
||||
return _endTime;
|
||||
}
|
||||
|
||||
public Map<Integer, Map<String, Long>> getStats()
|
||||
{
|
||||
return _stats;
|
||||
}
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
return _region != null && _gameType != null && _mapId != 0 && _startTime != 0 && _endTime != 0;
|
||||
}
|
||||
}
|
@ -18,10 +18,10 @@ public class SeniorModeratorTrack extends ItemizedTrack
|
||||
|
||||
public SeniorModeratorTrack()
|
||||
{
|
||||
super("staff-srmod", ChatColor.GOLD, "Sr.Mod", "I my team is the best team", "Team loyalty at its finest", true);
|
||||
super("staff-srmod", ChatColor.GOLD, "Sr.Mod", "My Team's the Best Team", "Team loyalty at its finest", true);
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"I think my team is the best team",
|
||||
"My Team's the Best Team",
|
||||
null,
|
||||
this::owns,
|
||||
new TrackFormat(ChatColor.GOLD, ChatColor.GOLD)
|
||||
|
@ -1,10 +1,5 @@
|
||||
package mineplex.hub;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.CustomTagFix;
|
||||
import mineplex.core.PacketsInteractionFix;
|
||||
import mineplex.core.TwitchIntegrationFix;
|
||||
@ -16,7 +11,6 @@ import mineplex.core.antihack.guardians.GuardianManager;
|
||||
import mineplex.core.aprilfools.AprilFoolsManager;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
import mineplex.hub.brawl.fountain.FountainManager;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.chatsnap.SnapshotManager;
|
||||
import mineplex.core.chatsnap.SnapshotPlugin;
|
||||
@ -62,7 +56,6 @@ import mineplex.core.report.ReportManager;
|
||||
import mineplex.core.report.ReportPlugin;
|
||||
import mineplex.core.resourcepack.ResourcePackManager;
|
||||
import mineplex.core.serverConfig.ServerConfiguration;
|
||||
import mineplex.core.sponsorbranding.BrandingManager;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
@ -77,8 +70,8 @@ import mineplex.core.updater.Updater;
|
||||
import mineplex.core.velocity.VelocityFix;
|
||||
import mineplex.core.visibility.VisibilityManager;
|
||||
import mineplex.core.website.WebsiteLinkManager;
|
||||
import mineplex.hub.brawl.fountain.FountainManager;
|
||||
import mineplex.hub.modules.AprilFoolsTreasureHunt;
|
||||
import mineplex.hub.modules.BillboardManager;
|
||||
import mineplex.hub.queue.QueueManager;
|
||||
import mineplex.hub.server.ServerManager;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||
@ -91,6 +84,10 @@ import mineplex.minecraft.game.core.IRelation;
|
||||
import mineplex.minecraft.game.core.combat.CombatManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import mineplex.minecraft.game.core.fire.Fire;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import static mineplex.core.Managers.require;
|
||||
|
||||
@ -209,7 +206,6 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
|
||||
CombatManager combatManager = new CombatManager(this);
|
||||
|
||||
|
||||
DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, conditionManager);
|
||||
conditionManager.setDamageManager(damage);
|
||||
|
||||
@ -233,9 +229,6 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
//Updates
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
||||
|
||||
BrandingManager brandingManager = require(BrandingManager.class);
|
||||
new BillboardManager(this, brandingManager);
|
||||
|
||||
require(TrackManager.class);
|
||||
require(Titles.class);
|
||||
require(TwoFactorAuth.class);
|
||||
|
@ -1,66 +0,0 @@
|
||||
package mineplex.hub.modules;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.events.ServerShutdownEvent;
|
||||
import mineplex.core.sponsorbranding.BrandingManager;
|
||||
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* Manager to handle generation and protection of billboards in the hub
|
||||
*/
|
||||
public class BillboardManager extends MiniPlugin
|
||||
{
|
||||
private BrandingManager _branding;
|
||||
|
||||
public BillboardManager(JavaPlugin plugin, BrandingManager branding)
|
||||
{
|
||||
super("Billboard", plugin);
|
||||
_branding = branding;
|
||||
|
||||
generateBoards();
|
||||
}
|
||||
|
||||
private void generateBoards()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void stopBreaking(HangingBreakEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof ItemFrame)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void stopBreaking(EntityDamageEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof ItemFrame)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void stopInteract(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (event.getRightClicked() != null && event.getRightClicked() instanceof ItemFrame)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleShutdown(ServerShutdownEvent event)
|
||||
{
|
||||
_branding.reset();
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package mineplex.hub.server.ui;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.hub.server.ServerManager;
|
||||
import mineplex.serverdata.data.ServerGroup;
|
||||
|
||||
public class MOBAServerTypePage extends ShopPageBase<ServerManager, ServerNpcShop>
|
||||
{
|
||||
private final ServerGroup _serverGroup;
|
||||
|
||||
public MOBAServerTypePage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, ServerGroup serverGroup)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, "Heroes of GWEN ", player, 27);
|
||||
_serverGroup = serverGroup;
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
setItem(12, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setTitle(C.Reset + C.cGold + "Play " + C.cYellow + "Heroes of GWEN")
|
||||
.addLore(new String[]
|
||||
{
|
||||
C.Reset + "",
|
||||
C.Reset + C.cGreen + "Click to Play",
|
||||
}).build());
|
||||
|
||||
setItem(14, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setTitle(C.Reset + C.cYellow + "Heroes of GWEN " + C.cGold + "Training")
|
||||
.addLore(new String[]
|
||||
{
|
||||
C.Reset + "",
|
||||
C.Reset + C.cGreen + "Click to Play",
|
||||
}).build());
|
||||
|
||||
getButtonMap().put(12, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Heroes of GWEN", player, "MOBA")));
|
||||
getButtonMap().put(14, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Heroes of GWEN Training", player, "MOBAT")));
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
getButtonMap().clear();
|
||||
buildPage();
|
||||
}
|
||||
}
|
@ -126,7 +126,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
||||
add(13, Material.FEATHER, (byte) 0, C.cYellowB + "Skywars " + C.cGray + "Solo/Team Survival", new String[]
|
||||
{
|
||||
C.Reset + "",
|
||||
C.Reset + "16 contenders fight to rule the skies!",
|
||||
C.Reset + "12 contenders fight to rule the skies!",
|
||||
C.Reset + "Spawn on a sky island and build your path!",
|
||||
C.Reset + "Find weapons to take your enemies down!",
|
||||
C.Reset + "Up in the skies, death looming if you fall..",
|
||||
|
@ -41,6 +41,9 @@ public class ServerNpcShop extends ShopBase<ServerManager>
|
||||
case "SSM":
|
||||
return new SuperSmashMobsServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player, _serverGroup);
|
||||
|
||||
case "MOBA":
|
||||
return new MOBAServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player, _serverGroup);
|
||||
|
||||
default:
|
||||
return new ServerNpcPage(getPlugin(), this, getClientManager(), getDonationManager(), _serverGroup.getServerNpcName(), player, _serverGroup.getPrefix());
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package nautilus.game.arcade;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
||||
import mineplex.core.imagemap.CustomItemFrames;
|
||||
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -229,6 +230,8 @@ public class Arcade extends JavaPlugin
|
||||
|
||||
AprilFoolsManager.getInstance();
|
||||
|
||||
require(CustomItemFrames.class);
|
||||
|
||||
//Updates
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
||||
|
||||
|
@ -1,44 +1,10 @@
|
||||
package nautilus.game.arcade;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
import mineplex.core.google.GoogleSheetsManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.antihack.compedaccount.PriorityCause;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.blood.Blood;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
@ -74,6 +40,7 @@ import mineplex.core.facebook.FacebookManager;
|
||||
import mineplex.core.gadget.event.ToggleMobsEvent;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.google.GoogleSheetsManager;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.incognito.IncognitoManager;
|
||||
import mineplex.core.incognito.events.IncognitoStatusChangeEvent;
|
||||
@ -100,7 +67,6 @@ import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager;
|
||||
import mineplex.core.resourcepack.ResourcePackManager;
|
||||
import mineplex.core.scoreboard.MineplexScoreboard;
|
||||
import mineplex.core.scoreboard.ScoreboardManager;
|
||||
import mineplex.core.sponsorbranding.BrandingManager;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
@ -169,6 +135,37 @@ import nautilus.game.arcade.managers.lobby.legacy.LegacyGameLobbyManager;
|
||||
import nautilus.game.arcade.player.ArcadePlayer;
|
||||
import nautilus.game.arcade.shop.ArcadeShop;
|
||||
import net.minecraft.server.v1_8_R3.EntityLiving;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
{
|
||||
@ -224,7 +221,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
private ResourcePackManager _resourcePackManager;
|
||||
private CustomDataManager _customDataManager;
|
||||
private Punish _punishmentManager;
|
||||
private BrandingManager _brandingManager;
|
||||
private BonusManager _bonusManager;
|
||||
private KitProgressionManager _kitProgressionManager;
|
||||
private ProgressingKitManager _progressionKitManager;
|
||||
@ -289,8 +285,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
_conditionManager = new SkillConditionManager(plugin);
|
||||
|
||||
_brandingManager = require(BrandingManager.class);
|
||||
|
||||
_boosterManager = boosterManager;
|
||||
|
||||
_clientManager = clientManager;
|
||||
@ -723,11 +717,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
return _punishmentManager;
|
||||
}
|
||||
|
||||
public BrandingManager getBrandingManager()
|
||||
{
|
||||
return _brandingManager;
|
||||
}
|
||||
|
||||
public Portal GetPortal()
|
||||
{
|
||||
return _portal;
|
||||
|
@ -3,6 +3,7 @@ package nautilus.game.arcade.game;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.arcadeevents.CoreGameStartEvent;
|
||||
import mineplex.core.arcadeevents.CoreGameStopEvent;
|
||||
@ -43,6 +44,8 @@ import nautilus.game.arcade.managers.chat.ChatStatData;
|
||||
import nautilus.game.arcade.managers.lobby.LobbyManager;
|
||||
import nautilus.game.arcade.quest.ChestOpenQuestTracker;
|
||||
import nautilus.game.arcade.quest.CollectQuestTracker;
|
||||
import nautilus.game.arcade.quest.FirstBloodQuestTracker;
|
||||
import nautilus.game.arcade.quest.HitQuestTracker;
|
||||
import nautilus.game.arcade.quest.KillEntityQuestTracker;
|
||||
import nautilus.game.arcade.quest.KillQuestTracker;
|
||||
import nautilus.game.arcade.quest.ParticipateQuestTracker;
|
||||
@ -436,7 +439,9 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
new ChestOpenQuestTracker(this),
|
||||
new KillEntityQuestTracker(this),
|
||||
new PlayGameQuestTracker(this),
|
||||
new ParticipateQuestTracker(this));
|
||||
new ParticipateQuestTracker(this),
|
||||
new HitQuestTracker(this),
|
||||
new FirstBloodQuestTracker(this));
|
||||
|
||||
Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrls(this), gameType.isEnforceResourcePack(this));
|
||||
|
||||
@ -1774,6 +1779,16 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
{
|
||||
return _questTrackers;
|
||||
}
|
||||
|
||||
public <T extends QuestTracker<? extends Game>> T getQuestTracker(Class<T> clazz)
|
||||
{
|
||||
for (QuestTracker<? extends Game> tracker : _questTrackers)
|
||||
{
|
||||
if (tracker.getClass().equals(clazz))
|
||||
return clazz.cast(tracker);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHangingBreak(HangingBreakEvent event)
|
||||
@ -2053,7 +2068,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
public void onQuestBuy(QuestInteractEvent event)
|
||||
{
|
||||
if (GetState() == GameState.Live || GetState() == GameState.Prepare || GetState() == GameState.End)
|
||||
event.setCancelled("You cant interact with " + QuestManager.QUEST_NAME + "s while you are ingame!");
|
||||
event.setCancelled("You can't interact with " + QuestManager.QUEST_NAME + "s while you are ingame!");
|
||||
}
|
||||
|
||||
public NautHashMap<String, Entity> getDeadBodies()
|
||||
|
@ -8,7 +8,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import mineplex.core.common.Pair;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
@ -34,6 +33,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.block.BlockData;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -52,6 +52,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
@ -61,6 +62,7 @@ import nautilus.game.arcade.game.games.dragonescape.kits.KitDigger;
|
||||
import nautilus.game.arcade.game.games.dragonescape.kits.KitDisruptor;
|
||||
import nautilus.game.arcade.game.games.dragonescape.kits.KitLeaper;
|
||||
import nautilus.game.arcade.game.games.dragonescape.kits.KitWarper;
|
||||
import nautilus.game.arcade.game.games.dragonescape.quests.DragonEscapeWinQuestTracker;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.managers.chat.ChatStatData;
|
||||
@ -143,6 +145,8 @@ public class DragonEscape extends SoloGame
|
||||
BlankLine,
|
||||
new ChatStatData("kit", "Kit", true)
|
||||
);
|
||||
|
||||
registerQuestTrackers(new DragonEscapeWinQuestTracker(this));
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompass(true)
|
||||
@ -486,7 +490,10 @@ public class DragonEscape extends SoloGame
|
||||
AddGems(_winner, 10, "Course Complete", false, false);
|
||||
|
||||
if (places.size() >= 1)
|
||||
{
|
||||
AddGems(places.get(0), 20, "1st Place", false, false);
|
||||
getQuestTracker(DragonEscapeWinQuestTracker.class).increment(places.get(0));
|
||||
}
|
||||
|
||||
if (places.size() >= 2)
|
||||
AddGems(places.get(1), 15, "2nd Place", false, false);
|
||||
|
@ -0,0 +1,30 @@
|
||||
package nautilus.game.arcade.game.games.dragonescape.quests;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.Arcade;
|
||||
import nautilus.game.arcade.game.games.dragonescape.DragonEscape;
|
||||
import nautilus.game.arcade.quest.QuestTracker;
|
||||
|
||||
/**
|
||||
* DragonEscapeWinQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class DragonEscapeWinQuestTracker extends QuestTracker<DragonEscape>
|
||||
{
|
||||
|
||||
public DragonEscapeWinQuestTracker(DragonEscape game)
|
||||
{
|
||||
super(game, TriggerType.COMPLETE);
|
||||
}
|
||||
|
||||
public void increment(Player player)
|
||||
{
|
||||
incrementQuests(player, 1, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), getGame().GetKit(player).GetName() + "Kit", "Parkour");
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package nautilus.game.arcade.game.games.moba;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.beta.BetaWhitelist;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -9,9 +8,14 @@ import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.disguise.disguises.DisguiseBase;
|
||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||
import mineplex.core.disguise.playerdisguise.PlayerDisguiseManager;
|
||||
import mineplex.core.imagemap.ImageMapManager;
|
||||
import mineplex.core.imagemap.objects.MapBoardSelector;
|
||||
import mineplex.core.imagemap.objects.PlayerMapBoard;
|
||||
import mineplex.core.leaderboard.Leaderboard;
|
||||
import mineplex.core.leaderboard.LeaderboardManager;
|
||||
import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType;
|
||||
import mineplex.core.stats.event.StatChangeEvent;
|
||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
@ -42,6 +46,7 @@ import nautilus.game.arcade.game.games.moba.kit.larissa.HeroLarissa;
|
||||
import nautilus.game.arcade.game.games.moba.kit.rowena.HeroRowena;
|
||||
import nautilus.game.arcade.game.games.moba.minion.MinionManager;
|
||||
import nautilus.game.arcade.game.games.moba.overtime.OvertimeManager;
|
||||
import nautilus.game.arcade.game.games.moba.progression.MobaProgression;
|
||||
import nautilus.game.arcade.game.games.moba.shop.MobaShop;
|
||||
import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager;
|
||||
import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager;
|
||||
@ -53,6 +58,7 @@ import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -72,6 +78,17 @@ import java.util.Set;
|
||||
public class Moba extends TeamGame
|
||||
{
|
||||
|
||||
private static final String[] ITEM_IMAGES = {
|
||||
"Anath_the_Burnt.png",
|
||||
"Bardolf.png",
|
||||
"Biff.png",
|
||||
"Dana.png",
|
||||
"Devon.png",
|
||||
"Hattori.png",
|
||||
"Larissa.png",
|
||||
"Rowena.png"
|
||||
};
|
||||
|
||||
private final HeroKit[] _kits;
|
||||
|
||||
protected final Set<MobaPlayer> _playerData = new HashSet<>();
|
||||
@ -86,7 +103,10 @@ public class Moba extends TeamGame
|
||||
protected final TowerManager _tower;
|
||||
protected final CapturePointManager _capturePoint;
|
||||
protected final MinionManager _minion;
|
||||
private BetaWhitelist _betaWhitelist;
|
||||
private final MobaProgression _progression;
|
||||
private final ImageMapManager _mapManager = Managers.require(ImageMapManager.class);
|
||||
private PlayerMapBoard _board;
|
||||
private MapBoardSelector _selector;
|
||||
|
||||
private int _inPlayers;
|
||||
|
||||
@ -120,6 +140,7 @@ public class Moba extends TeamGame
|
||||
_buffs = registerManager(new BuffManager());
|
||||
_arrowKb = registerManager(new ArrowKBManager(this));
|
||||
_minion = registerManager(new MinionManager(this));
|
||||
_progression = registerManager(new MobaProgression(this));
|
||||
registerManager(new HPManager(this));
|
||||
registerManager(new MobaDamageManager(this));
|
||||
registerManager(new MobaFountain(this));
|
||||
@ -132,17 +153,6 @@ public class Moba extends TeamGame
|
||||
// Beta Message
|
||||
registerManager(new BetaManager(this));
|
||||
|
||||
// Beta Whitelist
|
||||
_betaWhitelist = Managers.get(BetaWhitelist.class);
|
||||
if (_betaWhitelist == null)
|
||||
{
|
||||
_betaWhitelist = new BetaWhitelist(manager.GetClients(), manager.getBonusManager().getPowerPlayClubRepository());
|
||||
}
|
||||
else
|
||||
{
|
||||
_betaWhitelist.registerSelf();
|
||||
}
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompass(true)
|
||||
.setGiveCompassToSpecs(true)
|
||||
@ -232,6 +242,12 @@ public class Moba extends TeamGame
|
||||
Location location = lobbyCustomLocs.get("TOP_GOLD").get(0);
|
||||
leaderboard.registerLeaderboard("TOP_HOG_GOLD", new Leaderboard("Top Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.ALL, location, 10));
|
||||
}
|
||||
|
||||
_progression.spawnRoleViewers(lobbyCustomLocs);
|
||||
|
||||
_board = _mapManager.createPlayerBoard(lobbyCustomLocs.get("HERO_VIEWER").get(0), BlockFace.EAST, 7, 4, ITEM_IMAGES);
|
||||
_selector = new MapBoardSelector(_board);
|
||||
_selector.createHolograms(lobbyCustomLocs.get("HERO_VIEWER NEXT").get(0), lobbyCustomLocs.get("HERO_VIEWER BACK").get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -253,6 +269,11 @@ public class Moba extends TeamGame
|
||||
_playerData.add(new MobaPlayer(player));
|
||||
MobaUtil.setTeamEntity(player, GetTeam(player));
|
||||
}
|
||||
|
||||
// Cleanup tutorial boards
|
||||
_mapManager.cleanupBoard(_board);
|
||||
_selector.cleanup();
|
||||
_progression.removeRoleViewers();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -281,18 +302,22 @@ public class Moba extends TeamGame
|
||||
super.disable();
|
||||
_listeners.forEach(UtilServer::Unregister);
|
||||
_listeners.clear();
|
||||
_betaWhitelist.deregisterSelf();
|
||||
|
||||
// Undisguise all players
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
Manager.runSyncLater(() ->
|
||||
{
|
||||
DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player);
|
||||
PlayerDisguiseManager playerDisguiseManager = Managers.require(PlayerDisguiseManager.class);
|
||||
|
||||
if (disguise != null && disguise instanceof DisguisePlayer)
|
||||
// Undisguise all players
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
Manager.GetDisguise().undisguise(disguise);
|
||||
DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player);
|
||||
|
||||
if (disguise != null && disguise instanceof DisguisePlayer)
|
||||
{
|
||||
playerDisguiseManager.undisguise(player, (DisguisePlayer) disguise);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -312,6 +337,12 @@ public class Moba extends TeamGame
|
||||
return DeathMessageType.Detailed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double GetKillsGems(Player killer, Player killed, boolean assist)
|
||||
{
|
||||
return assist ? 1 : 2;
|
||||
}
|
||||
|
||||
// Clear up memory
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
@ -531,4 +562,9 @@ public class Moba extends TeamGame
|
||||
{
|
||||
return _minion;
|
||||
}
|
||||
|
||||
public MobaProgression getProgression()
|
||||
{
|
||||
return _progression;
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss;
|
||||
import nautilus.game.arcade.game.games.moba.prepare.PrepareManager;
|
||||
import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection;
|
||||
import nautilus.game.arcade.game.modules.CustomScoreboardModule;
|
||||
import nautilus.game.arcade.game.modules.GameStatisticsModule;
|
||||
import nautilus.game.arcade.scoreboard.GameScoreboard;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -46,6 +47,9 @@ public class MobaClassic extends Moba
|
||||
registerManager(new PrepareManager(this));
|
||||
registerManager(new PrepareSelection(this));
|
||||
|
||||
// new GameStatisticsModule()
|
||||
// .register(this);
|
||||
|
||||
new CustomScoreboardModule()
|
||||
.setSidebar((player, scoreboard) ->
|
||||
{
|
||||
@ -250,11 +254,15 @@ public class MobaClassic extends Moba
|
||||
|
||||
for (Player player : otherTeam.GetPlayers(true))
|
||||
{
|
||||
MobaPlayer mobaPlayer = getMobaData(player);
|
||||
|
||||
AddStat(player, mobaPlayer.getRole().getName() + ".Wins", 1, true, false);
|
||||
AddGems(player, 20, "Winning", false, false);
|
||||
}
|
||||
|
||||
AnnounceEnd(otherTeam);
|
||||
SetState(GameState.End);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +1,29 @@
|
||||
package nautilus.game.arcade.game.games.moba;
|
||||
|
||||
import mineplex.core.common.skin.SkinData;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
|
||||
public enum MobaRole
|
||||
{
|
||||
|
||||
ASSASSIN("Assassin", Color.GRAY, ChatColor.GRAY),
|
||||
HUNTER("Hunter", Color.LIME, ChatColor.GREEN),
|
||||
MAGE("Mage", Color.PURPLE, ChatColor.DARK_PURPLE),
|
||||
WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD),
|
||||
ASSASSIN("Assassin", Color.GRAY, ChatColor.GRAY, SkinData.HATTORI),
|
||||
HUNTER("Hunter", Color.LIME, ChatColor.GREEN, SkinData.DEVON),
|
||||
MAGE("Mage", Color.PURPLE, ChatColor.DARK_PURPLE, SkinData.ANATH),
|
||||
WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD, SkinData.DANA),
|
||||
;
|
||||
|
||||
private final String _name;
|
||||
private final Color _color;
|
||||
private final ChatColor _chatColor;
|
||||
private final SkinData _skinData;
|
||||
|
||||
MobaRole(String name, Color color, ChatColor chatColor)
|
||||
MobaRole(String name, Color color, ChatColor chatColor, SkinData skinData)
|
||||
{
|
||||
_name = name;
|
||||
_color = color;
|
||||
_chatColor = chatColor;
|
||||
_skinData = skinData;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
@ -37,4 +40,9 @@ public enum MobaRole
|
||||
{
|
||||
return _chatColor;
|
||||
}
|
||||
|
||||
public SkinData getSkin()
|
||||
{
|
||||
return _skinData;
|
||||
}
|
||||
}
|
||||
|
@ -102,8 +102,14 @@ public class BossManager implements Listener
|
||||
{
|
||||
List<MobaBoss> bosses = new ArrayList<>();
|
||||
|
||||
bosses.addAll(_teamBosses.values());
|
||||
bosses.add(_pumpkinBoss);
|
||||
if (_teamBosses != null)
|
||||
{
|
||||
bosses.addAll(_teamBosses.values());
|
||||
}
|
||||
if (_pumpkinBoss != null)
|
||||
{
|
||||
bosses.add(_pumpkinBoss);
|
||||
}
|
||||
|
||||
return bosses;
|
||||
}
|
||||
|
@ -1,11 +1,15 @@
|
||||
package nautilus.game.arcade.game.games.moba.general;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ClickEvent.Action;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -13,7 +17,16 @@ import org.bukkit.event.Listener;
|
||||
public class BetaManager implements Listener
|
||||
{
|
||||
|
||||
private static final String MESSAGE = F.main("Game", "You can suggest improvements for the game on our Trello here ") + C.cYellow + "https://trello.com/b/MrxWVhlI/mineplex-heroes-of-gwen-feedback-update";
|
||||
private static final TextComponent MESSAGE;
|
||||
|
||||
static
|
||||
{
|
||||
MESSAGE = new TextComponent("You can suggest improvements for the game on our Trello by clicking here!");
|
||||
MESSAGE.setColor(ChatColor.AQUA);
|
||||
MESSAGE.setClickEvent(new ClickEvent(Action.OPEN_URL, "https://trello.com/b/MrxWVhlI/mineplex-heroes-of-gwen-feedback-update"));
|
||||
MESSAGE.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click here to open the Trello board").color(ChatColor.YELLOW).create()));
|
||||
}
|
||||
|
||||
private final Moba _host;
|
||||
|
||||
public BetaManager(Moba host)
|
||||
@ -29,6 +42,6 @@ public class BetaManager implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.broadcastMessage(MESSAGE);
|
||||
Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(MESSAGE));
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,12 @@ import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import nautilus.game.arcade.game.games.moba.util.MobaConstants;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class MobaDamageManager implements Listener
|
||||
{
|
||||
@ -97,4 +99,30 @@ public class MobaDamageManager implements Listener
|
||||
event.setKilledWord(word);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void mageStrength(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetReason() == null || !event.GetReason().contains(MobaConstants.BASIC_ATTACK))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player damager = event.GetDamagerPlayer(true);
|
||||
|
||||
if (damager == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
damager.getActivePotionEffects().forEach(effect ->
|
||||
{
|
||||
|
||||
if (effect.getType().toString().equals(PotionEffectType.INCREASE_DAMAGE.toString()))
|
||||
{
|
||||
event.AddMod("Strength", (effect.getAmplifier() + 1) * 2 + 1);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import mineplex.core.utils.UtilGameProfile;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import nautilus.game.arcade.game.games.moba.MobaRole;
|
||||
import nautilus.game.arcade.game.games.moba.progression.MobaProgression;
|
||||
import nautilus.game.arcade.game.games.moba.shop.MobaItem;
|
||||
import nautilus.game.arcade.game.games.moba.util.MobaConstants;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
@ -32,13 +33,15 @@ import java.util.List;
|
||||
public class HeroKit extends Kit
|
||||
{
|
||||
|
||||
private final MobaRole _role;
|
||||
|
||||
private static final int AMMO_SLOT = 7;
|
||||
|
||||
private final MobaRole _role;
|
||||
private final SkinData _skin;
|
||||
private final int _unlockLevel;
|
||||
|
||||
private ItemStack _ammo;
|
||||
private long _giveTime;
|
||||
private int _maxAmmo;
|
||||
private SkinData _skin;
|
||||
|
||||
private static final int SHOP_SLOT = 8;
|
||||
private static final ItemStack SHOP_ITEM = new ItemBuilder(Material.GOLD_INGOT)
|
||||
@ -49,12 +52,18 @@ public class HeroKit extends Kit
|
||||
private boolean _visible = true;
|
||||
|
||||
public HeroKit(ArcadeManager manager, String name, Perk[] kitPerks, MobaRole role, SkinData skin)
|
||||
{
|
||||
this(manager, name, kitPerks, role, skin, 0);
|
||||
}
|
||||
|
||||
public HeroKit(ArcadeManager manager, String name, Perk[] kitPerks, MobaRole role, SkinData skin, int unlockLevel)
|
||||
{
|
||||
super(manager, name, KitAvailability.Free, new String[0], kitPerks, null, null);
|
||||
|
||||
_role = role;
|
||||
_maxAmmo = 64;
|
||||
_skin = skin;
|
||||
_unlockLevel = unlockLevel;
|
||||
}
|
||||
|
||||
public MobaRole getRole()
|
||||
@ -62,11 +71,22 @@ public class HeroKit extends Kit
|
||||
return _role;
|
||||
}
|
||||
|
||||
public int getUnlockLevel()
|
||||
{
|
||||
return _unlockLevel;
|
||||
}
|
||||
|
||||
public ItemStack getAmmo()
|
||||
{
|
||||
return _ammo;
|
||||
}
|
||||
|
||||
public boolean ownsKit(Player player)
|
||||
{
|
||||
MobaProgression progression = ((Moba) Manager.GetGame()).getProgression();
|
||||
return _unlockLevel == 0 || Manager.GetDonation().Get(player).ownsUnknownSalesPackage(progression.getPackageName(this));
|
||||
}
|
||||
|
||||
public void setAmmo(ItemStack ammo, long giveTime)
|
||||
{
|
||||
_ammo = ammo;
|
||||
|
@ -49,7 +49,7 @@ public class HeroBardolf extends HeroKit
|
||||
|
||||
public HeroBardolf(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Bardolf", PERKS, MobaRole.ASSASSIN, SkinData.BARDOLF);
|
||||
super(manager, "Bardolf", PERKS, MobaRole.ASSASSIN, SkinData.BARDOLF, 10);
|
||||
|
||||
_data = new ArrayList<>(2);
|
||||
}
|
||||
@ -151,7 +151,7 @@ public class HeroBardolf extends HeroKit
|
||||
}
|
||||
GameTeam team = Manager.GetGame().GetTeam((Player) damager);
|
||||
|
||||
if (team != null && MobaUtil.isTeamEntity(damagee, team))
|
||||
if (team != null && !Manager.GetGame().DamageTeamSelf && MobaUtil.isTeamEntity(damagee, team))
|
||||
{
|
||||
event.SetCancelled("Team Wolf");
|
||||
}
|
||||
|
@ -19,6 +19,6 @@ public class HeroBiff extends HeroKit
|
||||
|
||||
public HeroBiff(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Biff", PERKS, MobaRole.WARRIOR, SkinData.BIFF);
|
||||
super(manager, "Biff", PERKS, MobaRole.WARRIOR, SkinData.BIFF, 10);
|
||||
}
|
||||
}
|
||||
|
@ -151,6 +151,11 @@ public class SkillRally extends HeroSkill
|
||||
|
||||
for (LivingEntity nearby : UtilEnt.getInRadius(player.getLocation(), 3).keySet())
|
||||
{
|
||||
if (isTeamDamage(nearby, player))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Manager.GetDamage().NewDamageEvent(nearby, player, null, DamageCause.CUSTOM, 7, true, true, false, UtilEnt.getName(player), GetName());
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class HeroLarissa extends HeroKit
|
||||
|
||||
public HeroLarissa(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Larissa", PERKS, MobaRole.MAGE, SkinData.LARISSA);
|
||||
super(manager, "Larissa", PERKS, MobaRole.MAGE, SkinData.LARISSA, 10);
|
||||
|
||||
setAmmo(AMMO, 3000);
|
||||
setMaxAmmo(5);
|
||||
|
@ -29,7 +29,7 @@ public class SkillAquaCannon extends HeroSkill
|
||||
"Fires a beam of water that deals damage",
|
||||
"to the first enemy it comes in contact with."
|
||||
};
|
||||
private static final int DAMAGE = 6;
|
||||
private static final int DAMAGE = 4;
|
||||
private static final ItemStack SKILL_ITEM = new ItemStack(Material.DIAMOND_HOE);
|
||||
|
||||
public SkillAquaCannon(int slot)
|
||||
@ -66,7 +66,7 @@ public class SkillAquaCannon extends HeroSkill
|
||||
continue;
|
||||
}
|
||||
|
||||
Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, DAMAGE, true, false, false, player.getName(), MobaConstants.BASIC_ATTACK);
|
||||
Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, DAMAGE, false, false, false, player.getName(), MobaConstants.BASIC_ATTACK);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class HeroRowena extends HeroKit
|
||||
|
||||
public HeroRowena(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Rowena", PERKS, MobaRole.HUNTER, SkinData.ROWENA);
|
||||
super(manager, "Rowena", PERKS, MobaRole.HUNTER, SkinData.ROWENA, 10);
|
||||
|
||||
setAmmo(AMMO, 2000);
|
||||
setMaxAmmo(2);
|
||||
|
@ -66,7 +66,7 @@ public class MinionManager implements Listener
|
||||
@EventHandler
|
||||
public void spawnMinions(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC || !_enabled || !_host.IsLive() || !UtilTime.elapsed(_lastWave, MINION_SPAWN_TIME))
|
||||
if (event.getType() != UpdateType.SEC || !_enabled || !_host.IsLive() || !UtilTime.elapsed(_lastWave, MINION_SPAWN_TIME) || _waves.size() > 6)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilAlg;
|
||||
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.UtilTextMiddle;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
@ -42,6 +43,11 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
public class PrepareSelection implements Listener, IPacketHandler
|
||||
{
|
||||
|
||||
public static ItemStack buildColouredStack(Material material, MobaRole role)
|
||||
{
|
||||
return new ItemBuilder(material).setColor(role.getColor()).build();
|
||||
}
|
||||
|
||||
private final Moba _host;
|
||||
private final Map<ClientArmorStand, MobaRole> _roleStands = new HashMap<>();
|
||||
private final Map<ClientArmorStand, HeroKit> _kitStands = new HashMap<>();
|
||||
@ -75,8 +81,6 @@ public class PrepareSelection implements Listener, IPacketHandler
|
||||
Location average = UtilAlg.getAverageLocation(team.GetSpawns());
|
||||
Player[] players = team.GetPlayers(true).toArray(new Player[0]);
|
||||
|
||||
ItemStack head = new ItemBuilder(Material.SKULL_ITEM, (byte) 3).build();
|
||||
|
||||
UtilServer.runSyncLater(() ->
|
||||
{
|
||||
for (Player player : team.GetPlayers(true))
|
||||
@ -98,7 +102,7 @@ public class PrepareSelection implements Listener, IPacketHandler
|
||||
stand.setCustomNameVisible(true);
|
||||
stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + C.cGreenB + "AVAILABLE");
|
||||
stand.setArms(true);
|
||||
stand.setHelmet(head);
|
||||
stand.setHelmet(role.getSkin().getSkull());
|
||||
stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role));
|
||||
stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role));
|
||||
stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role));
|
||||
@ -146,7 +150,7 @@ public class PrepareSelection implements Listener, IPacketHandler
|
||||
ClientArmorStand stand = ClientArmorStand.spawn(location.clone().add(0, 1, 0), player);
|
||||
|
||||
stand.setCustomNameVisible(true);
|
||||
stand.setCustomName(C.cGreenB + kit.GetName());
|
||||
stand.setCustomName((kit.ownsKit(player) ? C.cGreenB : C.cRedB) + kit.GetName());
|
||||
stand.setArms(true);
|
||||
stand.setHelmet(kit.getSkinData().getSkull());
|
||||
stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, kit.getRole()));
|
||||
@ -175,11 +179,6 @@ public class PrepareSelection implements Listener, IPacketHandler
|
||||
return location.clone().add(0, 1, 0);
|
||||
}
|
||||
|
||||
private ItemStack buildColouredStack(Material material, MobaRole role)
|
||||
{
|
||||
return new ItemBuilder(material).setColor(role.getColor()).build();
|
||||
}
|
||||
|
||||
private void removePodiums()
|
||||
{
|
||||
_host.getLocationStartsWith("KIT").forEach((key, location) -> location.getBlock().setType(Material.AIR));
|
||||
@ -193,6 +192,11 @@ public class PrepareSelection implements Listener, IPacketHandler
|
||||
Player player = packetInfo.getPlayer();
|
||||
int entityId = packet.a;
|
||||
|
||||
if (UtilPlayer.isSpectator(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClientArmorStand goBackStand = _goBackStands.get(player);
|
||||
|
||||
if (goBackStand != null && goBackStand.getEntityId() == entityId)
|
||||
@ -258,6 +262,13 @@ public class PrepareSelection implements Listener, IPacketHandler
|
||||
|
||||
HeroKit kit = _kitStands.get(stand);
|
||||
|
||||
if (!kit.ownsKit(player))
|
||||
{
|
||||
player.sendMessage(F.main("Game", "You have not unlocked this kit. Try picking one with a " + C.cGreen + "Green" + C.cGray + " name."));
|
||||
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 0.2F);
|
||||
return;
|
||||
}
|
||||
|
||||
if (goBackStand != null)
|
||||
{
|
||||
_goBackStands.remove(player).remove();
|
||||
|
@ -0,0 +1,303 @@
|
||||
package nautilus.game.arcade.game.games.moba.progression;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.ArcadeFormat;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.DebugCommand;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.GemData;
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import nautilus.game.arcade.game.games.moba.MobaPlayer;
|
||||
import nautilus.game.arcade.game.games.moba.MobaRole;
|
||||
import nautilus.game.arcade.game.games.moba.kit.HeroKit;
|
||||
import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection;
|
||||
import nautilus.game.arcade.game.games.moba.progression.ui.MobaRoleShop;
|
||||
import nautilus.game.arcade.game.games.moba.util.MobaUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class MobaProgression implements Listener
|
||||
{
|
||||
|
||||
private static final int[] EXP_LEVELS;
|
||||
public static final DecimalFormat FORMAT = new DecimalFormat("0.0");
|
||||
|
||||
static
|
||||
{
|
||||
EXP_LEVELS = new int[100];
|
||||
int expRequired = 2000;
|
||||
|
||||
for (int level = 0; level < 100; level++)
|
||||
{
|
||||
EXP_LEVELS[level] = expRequired += 2000;
|
||||
}
|
||||
}
|
||||
|
||||
private final Moba _host;
|
||||
private final Map<ArmorStand, MobaRole> _roleViewers;
|
||||
private final MobaRoleShop _roleShop;
|
||||
|
||||
private MobaUnlockAnimation _currentAnimation;
|
||||
|
||||
public MobaProgression(Moba host)
|
||||
{
|
||||
_host = host;
|
||||
_roleViewers = new HashMap<>();
|
||||
_roleShop = new MobaRoleShop(host.getArcadeManager());
|
||||
|
||||
host.registerDebugCommand(new DebugCommand("fakeexp", Rank.DEVELOPER)
|
||||
{
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
int exp = Integer.parseInt(args[0]);
|
||||
_host.GetGems(caller).put("Fake Exp", new GemData(exp, false));
|
||||
caller.sendMessage(F.main("Debug", "Gave you " + F.elem(exp) + " fake exp."));
|
||||
}
|
||||
});
|
||||
host.registerDebugCommand(new DebugCommand("setmobalevel", Rank.DEVELOPER)
|
||||
{
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
MobaRole role = MobaRole.valueOf(args[0].toUpperCase());
|
||||
int exp = getExperience(Integer.parseInt(args[1])) - 1;
|
||||
_host.getArcadeManager().GetStatsManager().setStat(caller, _host.GetName() + "." + role.getName() + ".ExpEarned", exp);
|
||||
caller.sendMessage(F.main("Debug", "Set your " + role.getChatColor() + role.getName() + C.cGray + " level to " + F.elem(getLevel(exp)) + "."));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void spawnRoleViewers(Map<String, List<Location>> lobbyLocations)
|
||||
{
|
||||
Location center = lobbyLocations.get("SPAWN").get(0);
|
||||
|
||||
for (MobaRole role : MobaRole.values())
|
||||
{
|
||||
List<Location> locations = lobbyLocations.get(role.name());
|
||||
|
||||
if (locations == null || locations.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Location location = locations.get(0).clone();
|
||||
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, center)));
|
||||
|
||||
ArmorStand stand = location.getWorld().spawn(location, ArmorStand.class);
|
||||
|
||||
UtilEnt.vegetate(stand);
|
||||
UtilEnt.ghost(stand, true, false);
|
||||
|
||||
stand.setCustomName(C.cGreenB + role.getName());
|
||||
stand.setCustomNameVisible(true);
|
||||
stand.setArms(true);
|
||||
stand.setBasePlate(false);
|
||||
stand.setHelmet(role.getSkin().getSkull());
|
||||
stand.setChestplate(PrepareSelection.buildColouredStack(Material.LEATHER_CHESTPLATE, role));
|
||||
stand.setLeggings(PrepareSelection.buildColouredStack(Material.LEATHER_LEGGINGS, role));
|
||||
stand.setBoots(PrepareSelection.buildColouredStack(Material.LEATHER_BOOTS, role));
|
||||
|
||||
_roleViewers.put(stand, role);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeRoleViewers()
|
||||
{
|
||||
for (ArmorStand stand : _roleViewers.keySet())
|
||||
{
|
||||
stand.remove();
|
||||
}
|
||||
|
||||
_roleViewers.clear();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClick(CustomDamageEvent event)
|
||||
{
|
||||
onClick(event.GetDamagerEntity(true), event.GetDamageeEntity());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClick(PlayerInteractAtEntityEvent event)
|
||||
{
|
||||
onClick(event.getPlayer(), event.getRightClicked());
|
||||
}
|
||||
|
||||
private void onClick(Entity clicker, Entity clicked)
|
||||
{
|
||||
if (clicker == null || !(clicker instanceof Player) || !_roleViewers.containsKey(clicked))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) clicker;
|
||||
MobaRole role = _roleViewers.get(clicked);
|
||||
|
||||
if (role == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_roleShop.openShop(player, role);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void end(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.End || !_host.getArcadeManager().IsRewardStats())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_host.GetPlayers(true).forEach(this::rewardPlayer);
|
||||
}
|
||||
|
||||
public int getExperience(int level)
|
||||
{
|
||||
if (level > EXP_LEVELS.length)
|
||||
{
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
else if (level < 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return EXP_LEVELS[level - 1];
|
||||
}
|
||||
|
||||
public long getExperience(Player player, MobaRole role)
|
||||
{
|
||||
String stat = _host.GetName() + "." + role.getName() + ".ExpEarned";
|
||||
return _host.getArcadeManager().GetStatsManager().Get(player).getStat(stat);
|
||||
}
|
||||
|
||||
public long getExperienceCurrentLevel(Player player, MobaRole role)
|
||||
{
|
||||
int level = getLevel(player, role);
|
||||
return getExperience(level) - getExperience(level - 1);
|
||||
}
|
||||
public int getLevel(Player player, HeroKit kit)
|
||||
{
|
||||
return getLevel(player, kit.getRole());
|
||||
}
|
||||
|
||||
public int getLevel(Player player, MobaRole role)
|
||||
{
|
||||
return getLevel(getExperience(player, role));
|
||||
}
|
||||
|
||||
private int getLevel(long exp)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (int expRequired : EXP_LEVELS)
|
||||
{
|
||||
i++;
|
||||
if (expRequired > exp)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private void rewardPlayer(Player player)
|
||||
{
|
||||
MobaPlayer mobaPlayer = _host.getMobaData(player);
|
||||
MobaRole role = mobaPlayer.getRole();
|
||||
String stat = _host.GetName() + "." + role.getName() + ".ExpEarned";
|
||||
long currentExp = _host.getArcadeManager().GetStatsManager().Get(player).getStat(stat);
|
||||
AtomicInteger earnedExp = new AtomicInteger();
|
||||
|
||||
for (GemData data : _host.GetGems(player).values())
|
||||
{
|
||||
earnedExp.getAndAdd((int) data.Gems);
|
||||
}
|
||||
|
||||
int level = getLevel(currentExp);
|
||||
int newLevel = getLevel(currentExp + earnedExp.get());
|
||||
long expForThisLevel = getExperienceCurrentLevel(player, role);
|
||||
AtomicBoolean levelUp = new AtomicBoolean();
|
||||
|
||||
if (newLevel > level)
|
||||
{
|
||||
levelUp.set(true);
|
||||
}
|
||||
|
||||
_host.getArcadeManager().GetStatsManager().incrementStat(player, stat, earnedExp.get());
|
||||
|
||||
UtilServer.runSyncLater(() ->
|
||||
{
|
||||
player.sendMessage(ArcadeFormat.Line);
|
||||
player.sendMessage("");
|
||||
|
||||
player.sendMessage(" " + role.getChatColor() + C.Bold + role.getName() + " Progression" + (levelUp.get() ? C.cGreenB + " LEVEL UP" : ""));
|
||||
player.sendMessage("");
|
||||
player.sendMessage(MobaUtil.getProgressBar(currentExp, currentExp + earnedExp.get(), expForThisLevel, 100) + " " + C.cGray + "+" + C.cGreen + earnedExp + C.cGray + "/" + C.cAqua + expForThisLevel);
|
||||
player.sendMessage(C.cGreen + FORMAT.format((currentExp + earnedExp.get()) / (double) expForThisLevel * 100D) + C.cWhite + "% complete for Level " + level);
|
||||
|
||||
player.sendMessage("");
|
||||
player.sendMessage(ArcadeFormat.Line);
|
||||
|
||||
if (levelUp.get())
|
||||
{
|
||||
for (HeroKit kit : _host.getKits())
|
||||
{
|
||||
if (!kit.getRole().equals(role) || kit.getUnlockLevel() != newLevel)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
player.playSound(player.getLocation(), Sound.ENDERDRAGON_DEATH, 1, 1);
|
||||
UtilTextMiddle.display(role.getColor() + kit.GetName(), "You unlocked a new Hero!", 10, 40, 10, player);
|
||||
return;
|
||||
}
|
||||
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.CLICK, 1, 1);
|
||||
}
|
||||
}, 60);
|
||||
}
|
||||
|
||||
public String getPackageName(HeroKit kit)
|
||||
{
|
||||
return "MOBA_KIT_" + kit.GetName().toUpperCase();
|
||||
}
|
||||
|
||||
public void setCurrentAnimation(MobaUnlockAnimation animation)
|
||||
{
|
||||
_currentAnimation = animation;
|
||||
}
|
||||
|
||||
public MobaUnlockAnimation getCurrentAnimation()
|
||||
{
|
||||
return _currentAnimation;
|
||||
}
|
||||
}
|
@ -0,0 +1,188 @@
|
||||
package nautilus.game.arcade.game.games.moba.progression;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import nautilus.game.arcade.game.games.moba.kit.HeroKit;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MobaUnlockAnimation implements Listener
|
||||
{
|
||||
|
||||
private static final FireworkEffect FIREWORK_EFFECT = FireworkEffect.builder()
|
||||
.withColor(Color.ORANGE)
|
||||
.withFlicker()
|
||||
.with(Type.BURST)
|
||||
.build();
|
||||
|
||||
private final Moba _host;
|
||||
private final Player _player;
|
||||
private final HeroKit _kit;
|
||||
private final Location _spawn;
|
||||
private final Location _toTeleport;
|
||||
private final Location _npc;
|
||||
private final Location _info;
|
||||
private final long _start;
|
||||
|
||||
private ArmorStand _npcEntity;
|
||||
private int _animationStage;
|
||||
private Hologram _skillInfo;
|
||||
|
||||
public MobaUnlockAnimation(Moba host, Player player, HeroKit kit)
|
||||
{
|
||||
_host = host;
|
||||
_player = player;
|
||||
_kit = kit;
|
||||
|
||||
Map<String, List<Location>> lobbyLocations = ((NewGameLobbyManager) host.getArcadeManager().GetLobby()).getCustomLocs();
|
||||
_spawn = lobbyLocations.get("SPAWN").get(0);
|
||||
_toTeleport = lobbyLocations.get("HERO_UNLOCK PLAYER").get(0);
|
||||
_npc = lobbyLocations.get("HERO_UNLOCK NPC").get(0);
|
||||
_info = lobbyLocations.get("HERO_UNLOCK INFO_1").get(0);
|
||||
|
||||
Vector dir = UtilAlg.getTrajectory(_toTeleport, _npc);
|
||||
_toTeleport.setYaw(UtilAlg.GetYaw(dir));
|
||||
_npc.setYaw(UtilAlg.GetYaw(dir.clone().multiply(-1)));
|
||||
|
||||
_start = System.currentTimeMillis();
|
||||
|
||||
UtilServer.RegisterEvents(this);
|
||||
_host.getProgression().setCurrentAnimation(this);
|
||||
start();
|
||||
}
|
||||
|
||||
public void start()
|
||||
{
|
||||
_player.sendMessage(F.main("Game", "Unlocking " + _kit.getRole().getChatColor() + _kit.GetName() + "."));
|
||||
_player.teleport(_toTeleport);
|
||||
|
||||
_npcEntity = _npc.getWorld().spawn(_npc, ArmorStand.class);
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), _kit.GetName());
|
||||
profile.getProperties().clear();
|
||||
profile.getProperties().put("textures", _kit.getSkinData().getProperty());
|
||||
DisguisePlayer disguise = new DisguisePlayer(_npcEntity, profile);
|
||||
disguise.setSendSkinDataToSelf(false);
|
||||
_host.getArcadeManager().GetDisguise().disguise(disguise);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTEST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (_animationStage)
|
||||
{
|
||||
case 0:
|
||||
if (!UtilTime.elapsed(_start, 2000))
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, _npcEntity.getLocation().add(0, 1.5, 0), 1, 1, 1, 0.0001F, 50, ViewDist.NORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
_animationStage++;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
_npcEntity.getWorld().strikeLightningEffect(_npcEntity.getLocation());
|
||||
|
||||
String[] text = new String[_kit.GetPerks().length + 1];
|
||||
int i = 0;
|
||||
text[i++] = C.cAqua + "Skills";
|
||||
|
||||
for (Perk perk : _kit.GetPerks())
|
||||
{
|
||||
text[i++] = C.cYellow + perk.GetName();
|
||||
}
|
||||
|
||||
_skillInfo = new Hologram(_host.getArcadeManager().getHologramManager(), _info, text);
|
||||
_skillInfo.start();
|
||||
|
||||
for (int j = 0; j < 10; j++)
|
||||
{
|
||||
UtilFirework.playFirework(UtilAlg.getRandomLocation(_npcEntity.getLocation(), 4, 0, 4), FIREWORK_EFFECT);
|
||||
}
|
||||
|
||||
_animationStage++;
|
||||
break;
|
||||
case 2:
|
||||
if (UtilTime.elapsed(_start, 12000))
|
||||
{
|
||||
_player.sendMessage(F.main("Game", "Unlocked" + _kit.getRole().getChatColor() + _kit.GetName() + ". You can now select them at the start of the game!"));
|
||||
_player.teleport(_spawn);
|
||||
_player.playSound(_player.getLocation(), Sound.LEVEL_UP, 1, 1.2F);
|
||||
cleanup();
|
||||
_animationStage++;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (!event.getPlayer().equals(_player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Location from = event.getFrom();
|
||||
Location to = event.getTo();
|
||||
|
||||
if (from.getBlockX() == to.getBlockX() && from.getBlockZ() == to.getBlockZ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setTo(event.getFrom());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if (event.getPlayer().equals(_player))
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanup()
|
||||
{
|
||||
UtilServer.Unregister(this);
|
||||
_npcEntity.remove();
|
||||
_skillInfo.stop();
|
||||
_host.getProgression().setCurrentAnimation(null);
|
||||
}
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
package nautilus.game.arcade.game.games.moba.progression.ui;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilUI;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.server.util.TransactionResponse;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import nautilus.game.arcade.game.games.moba.MobaRole;
|
||||
import nautilus.game.arcade.game.games.moba.kit.HeroKit;
|
||||
import nautilus.game.arcade.game.games.moba.progression.MobaProgression;
|
||||
import nautilus.game.arcade.game.games.moba.progression.MobaUnlockAnimation;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MobaRolePage extends ShopPageBase<ArcadeManager, MobaRoleShop>
|
||||
{
|
||||
|
||||
private static final int SIZE = 45;
|
||||
private static final int[] MAPPINGS = UtilUI.getIndicesFor(4, 3);
|
||||
private static final ItemStack COMING_SOON = new ItemBuilder(Material.STAINED_CLAY, (byte) 15)
|
||||
.setTitle(C.cRed + "Coming Soon")
|
||||
.build();
|
||||
private static final int ANIMATION_TIME = 20;
|
||||
|
||||
private final Moba _host;
|
||||
private final MobaRole _role;
|
||||
|
||||
public MobaRolePage(ArcadeManager plugin, MobaRoleShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, Moba host, MobaRole role)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, role.getName(), player, SIZE);
|
||||
|
||||
_host = host;
|
||||
_role = role;
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
int level = _host.getProgression().getLevel(_player, _role);
|
||||
long currentExp = _host.getProgression().getExperience(_player, _role);
|
||||
long thisLevel = _host.getProgression().getExperienceCurrentLevel(_player, _role);
|
||||
long toNextLevel = _host.getProgression().getExperience(level) - currentExp;
|
||||
long levelExp = _host.getProgression().getExperience(level);
|
||||
|
||||
addButtonNoAction(13, new ItemBuilder(_role.getSkin().getSkull())
|
||||
.setTitle(_role.getChatColor() + _role.getName())
|
||||
.addLore(
|
||||
"",
|
||||
"Every " + F.elem(10) + " levels you unlock a new",
|
||||
"hero within the " + F.name(_role.getName()) + " category.",
|
||||
"",
|
||||
"Your Level: " + C.cGreen + level,
|
||||
"Next Level: " + C.cGreen + toNextLevel + C.cGray + "/" + C.cGreen + thisLevel + C.cGray + " (" + C.cAqua + MobaProgression.FORMAT.format(100 - ((double) currentExp / (double) levelExp) * 100D) + C.cGray + "%)"
|
||||
)
|
||||
.build());
|
||||
|
||||
List<HeroKit> kits = new ArrayList<>();
|
||||
|
||||
for (HeroKit kit : _host.getKits())
|
||||
{
|
||||
if (!kit.getRole().equals(_role) || !kit.isVisible() || kit.getUnlockLevel() == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
kits.add(kit);
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (int slot : MAPPINGS)
|
||||
{
|
||||
if (i >= kits.size())
|
||||
{
|
||||
addButtonNoAction(slot, COMING_SOON);
|
||||
continue;
|
||||
}
|
||||
|
||||
HeroKit kit = kits.get(i++);
|
||||
String packageName = _host.getProgression().getPackageName(kit);
|
||||
boolean hasUnlocked = _plugin.GetDonation().Get(_player).ownsUnknownSalesPackage(packageName);
|
||||
boolean canUnlock = _host.getProgression().getLevel(_player, kit) >= kit.getUnlockLevel();
|
||||
ItemBuilder builder = new ItemBuilder(Material.STAINED_CLAY);
|
||||
|
||||
builder.setTitle(C.cGreen + kit.GetName());
|
||||
builder.addLore("", "Unlocks at " + _role.getName() + " Level " + C.cGreen + (i * 10));
|
||||
|
||||
if (hasUnlocked)
|
||||
{
|
||||
builder.setData((byte) 5);
|
||||
builder.addLore(C.cRed + "You have already unlocked this hero!");
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.setData((byte) 14);
|
||||
builder.setGlow(canUnlock);
|
||||
|
||||
if (canUnlock)
|
||||
{
|
||||
builder.addLore(C.cGreen + "Click to unlock!");
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.addLore(C.cRed + "You cannot unlock this hero!");
|
||||
}
|
||||
}
|
||||
|
||||
addButton(slot, builder.build(), (player, clickType) ->
|
||||
{
|
||||
if (!Recharge.Instance.use(player, "Hero Unlock", 1000, false, false))
|
||||
{
|
||||
playDenySound(player);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean allowAnimation = (_host.GetCountdown() > ANIMATION_TIME || _host.GetCountdown() < 0) && _host.getProgression().getCurrentAnimation() == null;
|
||||
|
||||
if (!hasUnlocked && canUnlock)
|
||||
{
|
||||
if (allowAnimation)
|
||||
{
|
||||
_host.getArcadeManager().GetDonation().purchaseUnknownSalesPackage(player, packageName, GlobalCurrency.GEM, 0, true, data ->
|
||||
{
|
||||
if (data != TransactionResponse.Success)
|
||||
{
|
||||
player.sendMessage(F.main("Game", "Failed to unlock " + kit.GetName() + " please try again in a few seconds."));
|
||||
return;
|
||||
}
|
||||
|
||||
new MobaUnlockAnimation(_host, player, kit);
|
||||
playAcceptSound(player);
|
||||
player.closeInventory();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage(F.main("Game", "You cannot unlock a Hero right now."));
|
||||
playDenySound(player);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
playDenySound(player);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package nautilus.game.arcade.game.games.moba.progression.ui;
|
||||
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import nautilus.game.arcade.game.games.moba.MobaRole;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MobaRoleShop extends ShopBase<ArcadeManager>
|
||||
{
|
||||
|
||||
public MobaRoleShop(ArcadeManager plugin)
|
||||
{
|
||||
super(plugin, plugin.GetClients(), plugin.GetDonation(), "Moba Heroes");
|
||||
}
|
||||
|
||||
public void openShop(Player player, MobaRole role)
|
||||
{
|
||||
openPageForPlayer(player, new MobaRolePage(getPlugin(), this, getClientManager(), getDonationManager(), player, (Moba) getPlugin().GetGame(), role));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ShopPageBase<ArcadeManager, ? extends ShopBase<ArcadeManager>> buildPagesFor(Player player)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
@ -42,8 +41,6 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -95,6 +92,7 @@ public class MobaShop implements Listener
|
||||
villager.setCustomNameVisible(true);
|
||||
UtilEnt.vegetate(villager);
|
||||
UtilEnt.silence(villager, true);
|
||||
UtilEnt.ghost(villager, true, false);
|
||||
UtilEnt.CreatureForceLook(villager, 0, UtilAlg.GetYaw(UtilAlg.getTrajectory(villager.getLocation(), _host.GetSpectatorLocation())));
|
||||
((CraftLivingEntity) villager).getHandle().k = false;
|
||||
|
||||
@ -226,6 +224,12 @@ public class MobaShop implements Listener
|
||||
}
|
||||
|
||||
_host.GetKit(player).GiveItems(player);
|
||||
|
||||
// If we aren't tracking purchases then after we give the item remove it.
|
||||
if (!category.isTrackingPurchases())
|
||||
{
|
||||
owned.remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean ownsItem(Player player, MobaItem item)
|
||||
|
@ -44,21 +44,21 @@ public class MobaWarriorShop extends MobaShopMenu
|
||||
new MobaItem(new ItemBuilder(Material.IRON_HELMET)
|
||||
.setTitle(C.cGreenB + "Archer's Bane")
|
||||
.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1)
|
||||
.build(), 400)
|
||||
.build(), 100)
|
||||
.addEffects(
|
||||
new MobaHPRegenEffect(0.03)
|
||||
),
|
||||
// new MobaItem(new ItemBuilder(Material.IRON_HELMET)
|
||||
// .setTitle(C.cYellowB + "Superior Archer's Bane")
|
||||
// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2)
|
||||
// .build(), 750)
|
||||
// .addEffects(
|
||||
// new MobaHPRegenEffect(0.05)
|
||||
// ),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_HELMET)
|
||||
.setTitle(C.cYellowB + "Superior Archer's Bane")
|
||||
.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2)
|
||||
.build(), 300)
|
||||
.addEffects(
|
||||
new MobaHPRegenEffect(0.05)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_HELMET)
|
||||
.setTitle(C.cGreenB + "Brawler's Plate")
|
||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
||||
.build(), 400)
|
||||
.build(), 300)
|
||||
.addEffects(
|
||||
new MobaHPRegenEffect(0.03)
|
||||
),
|
||||
@ -71,7 +71,7 @@ public class MobaWarriorShop extends MobaShopMenu
|
||||
// ),
|
||||
new MobaItem(new ItemBuilder(Material.DIAMOND_HELMET)
|
||||
.setTitle(C.cDRedB + "Prince's Plate")
|
||||
.build(), 2000)
|
||||
.build(), 1200)
|
||||
.addEffects(
|
||||
new MobaHPRegenEffect(0.15)
|
||||
)
|
||||
@ -81,21 +81,21 @@ public class MobaWarriorShop extends MobaShopMenu
|
||||
new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE)
|
||||
.setTitle(C.cGreenB + "Archer's Bane")
|
||||
.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1)
|
||||
.build(), 600)
|
||||
.build(), 150)
|
||||
.addEffects(
|
||||
new MobaTotalHealthEffect(2)
|
||||
),
|
||||
// new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE)
|
||||
// .setTitle(C.cYellowB + "Superior Archer's Bane")
|
||||
// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2)
|
||||
// .build(), 1000)
|
||||
// .addEffects(
|
||||
// new MobaTotalHealthEffect(4)
|
||||
// ),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE)
|
||||
.setTitle(C.cYellowB + "Superior Archer's Bane")
|
||||
.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2)
|
||||
.build(), 400)
|
||||
.addEffects(
|
||||
new MobaTotalHealthEffect(4)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE)
|
||||
.setTitle(C.cGreenB + "Brawler's Plate")
|
||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
||||
.build(), 600)
|
||||
.build(), 400)
|
||||
.addEffects(
|
||||
new MobaTotalHealthEffect(2)
|
||||
),
|
||||
@ -108,7 +108,7 @@ public class MobaWarriorShop extends MobaShopMenu
|
||||
// ),
|
||||
new MobaItem(new ItemBuilder(Material.DIAMOND_CHESTPLATE)
|
||||
.setTitle(C.cDRedB + "Prince's Plate")
|
||||
.build(), 2500)
|
||||
.build(), 1500)
|
||||
.addEffects(
|
||||
new MobaTotalHealthEffect(4)
|
||||
)
|
||||
@ -118,21 +118,21 @@ public class MobaWarriorShop extends MobaShopMenu
|
||||
new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS)
|
||||
.setTitle(C.cGreenB + "Archer's Bane")
|
||||
.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1)
|
||||
.build(), 600)
|
||||
.build(), 150)
|
||||
.addEffects(
|
||||
new MobaCDREffect(0.05)
|
||||
),
|
||||
// new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS)
|
||||
// .setTitle(C.cYellowB + "Superior Archer's Bane")
|
||||
// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2)
|
||||
// .build(), 1000)
|
||||
// .addEffects(
|
||||
// new MobaCDREffect(0.07)
|
||||
// ),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS)
|
||||
.setTitle(C.cYellowB + "Superior Archer's Bane")
|
||||
.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2)
|
||||
.build(), 400)
|
||||
.addEffects(
|
||||
new MobaCDREffect(0.07)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS)
|
||||
.setTitle(C.cGreenB + "Brawler's Plate")
|
||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
||||
.build(), 600)
|
||||
.build(), 400)
|
||||
.addEffects(
|
||||
new MobaCDREffect(0.05)
|
||||
),
|
||||
@ -145,7 +145,7 @@ public class MobaWarriorShop extends MobaShopMenu
|
||||
// ),
|
||||
new MobaItem(new ItemBuilder(Material.DIAMOND_LEGGINGS)
|
||||
.setTitle(C.cDRedB + "Prince's Plate")
|
||||
.build(), 2500)
|
||||
.build(), 1500)
|
||||
.addEffects(
|
||||
new MobaCDREffect(0.1)
|
||||
)
|
||||
@ -155,21 +155,21 @@ public class MobaWarriorShop extends MobaShopMenu
|
||||
new MobaItem(new ItemBuilder(Material.IRON_BOOTS)
|
||||
.setTitle(C.cGreenB + "Archer's Bane")
|
||||
.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1)
|
||||
.build(), 400)
|
||||
.build(), 100)
|
||||
.addEffects(
|
||||
new MobaSpeedEffect(0.04)
|
||||
),
|
||||
// new MobaItem(new ItemBuilder(Material.IRON_BOOTS)
|
||||
// .setTitle(C.cYellowB + "Superior Archer's Bane")
|
||||
// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2)
|
||||
// .build(), 750)
|
||||
// .addEffects(
|
||||
// new MobaSpeedEffect(0.06)
|
||||
// ),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_BOOTS)
|
||||
.setTitle(C.cYellowB + "Superior Archer's Bane")
|
||||
.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2)
|
||||
.build(), 300)
|
||||
.addEffects(
|
||||
new MobaSpeedEffect(0.06)
|
||||
),
|
||||
new MobaItem(new ItemBuilder(Material.IRON_BOOTS)
|
||||
.setTitle(C.cGreenB + "Brawler's Plate")
|
||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
||||
.build(), 400)
|
||||
.build(), 300)
|
||||
.addEffects(
|
||||
new MobaSpeedEffect(0.04)
|
||||
),
|
||||
@ -182,7 +182,7 @@ public class MobaWarriorShop extends MobaShopMenu
|
||||
// ),
|
||||
new MobaItem(new ItemBuilder(Material.DIAMOND_BOOTS)
|
||||
.setTitle(C.cDRedB + "Prince's Plate")
|
||||
.build(), 2000)
|
||||
.build(), 1200)
|
||||
.addEffects(
|
||||
new MobaSpeedEffect(0.1)
|
||||
)
|
||||
|
@ -33,6 +33,7 @@ public class Tower
|
||||
{
|
||||
|
||||
private static final int DAMAGE = 3;
|
||||
private static final double HEALING = 2.6;
|
||||
private static final int TARGET_RANGE = 10;
|
||||
public static final int TARGET_RANGE_SQUARED = TARGET_RANGE * TARGET_RANGE;
|
||||
private static final int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30);
|
||||
@ -135,6 +136,24 @@ public class Tower
|
||||
_host.getArcadeManager().GetDamage().NewDamageEvent(_target, null, null, DamageCause.CUSTOM, _damage++, false, true, false, "Tower", "Tower");
|
||||
}
|
||||
|
||||
public void updateHealing()
|
||||
{
|
||||
if (_dead)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : _team.GetPlayers(true))
|
||||
{
|
||||
if (UtilPlayer.isSpectator(player) || UtilMath.offsetSquared(player, _crystal) > TARGET_RANGE_SQUARED)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
MobaUtil.heal(player, null, HEALING);
|
||||
}
|
||||
}
|
||||
|
||||
private void setLaserTarget(LivingEntity target)
|
||||
{
|
||||
if (target == null)
|
||||
@ -199,7 +218,6 @@ public class Tower
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_LAND, 1, 0.5F);
|
||||
player.sendMessage(F.main("Game", "Your Tower is under attack!"));
|
||||
//UtilTextMiddle.display("", _team.GetColor() + "Your Tower is under attack!", 0, 30, 10, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,6 +144,13 @@ public class TowerManager implements Listener
|
||||
tower.updateDamage();
|
||||
}
|
||||
}
|
||||
else if (event.getType() == UpdateType.SLOW)
|
||||
{
|
||||
for (Tower tower : _towers)
|
||||
{
|
||||
tower.updateHealing();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -25,16 +25,20 @@ import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.scoreboard.GameScoreboard;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.Villager.Profession;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -108,8 +112,7 @@ public class MobaTraining extends Moba
|
||||
|
||||
private Location _borderA;
|
||||
private Location _borderB;
|
||||
private Location _selectKit;
|
||||
private LivingEntity _selectKitEntity;
|
||||
private List<Location> _selectKit;
|
||||
|
||||
private final Map<LivingEntity, Location> _entities = new HashMap<>();
|
||||
|
||||
@ -129,8 +132,6 @@ public class MobaTraining extends Moba
|
||||
// Prevent the wither from being damaged as well as to not spawn the pumpkin king
|
||||
_boss.setDummyBosses(true);
|
||||
_overtimeManager.disableOvertime();
|
||||
|
||||
// Disable minions
|
||||
_minion.disableMinions();
|
||||
|
||||
Function<Player, Boolean> safeFunction = player -> UtilAlg.inBoundingBox(player.getLocation(), _borderA, _borderB);
|
||||
@ -243,13 +244,13 @@ public class MobaTraining extends Moba
|
||||
{
|
||||
super.ParseData();
|
||||
|
||||
List<Location> locations = WorldData.GetDataLocs("BROWN");
|
||||
List<Location> locations = WorldData.GetCustomLocs("PVP_AREA");
|
||||
|
||||
_borderA = locations.get(0);
|
||||
_borderB = locations.get(1);
|
||||
|
||||
_selectKit = WorldData.GetCustomLocs("SELECT_KIT").get(0);
|
||||
SpectatorSpawn = _selectKit;
|
||||
_selectKit = WorldData.GetCustomLocs("SELECT_KIT");
|
||||
SpectatorSpawn = _selectKit.get(0);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -262,12 +263,12 @@ public class MobaTraining extends Moba
|
||||
|
||||
for (Location location : GetTeam(ChatColor.YELLOW).GetSpawns())
|
||||
{
|
||||
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _selectKit)));
|
||||
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, SpectatorSpawn)));
|
||||
}
|
||||
|
||||
for (Location location : GetTeam(ChatColor.GRAY).GetSpawns())
|
||||
{
|
||||
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _selectKit)));
|
||||
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, SpectatorSpawn)));
|
||||
}
|
||||
|
||||
Location center = WorldData.GetCustomLocs("CENTER").get(0);
|
||||
@ -318,6 +319,15 @@ public class MobaTraining extends Moba
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetKit(Player player, Kit kit, boolean announce)
|
||||
{
|
||||
super.SetKit(player, kit, announce);
|
||||
|
||||
player.setFlying(false);
|
||||
player.setAllowFlight(false);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void giveGold(UpdateEvent event)
|
||||
{
|
||||
@ -336,7 +346,7 @@ public class MobaTraining extends Moba
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void plaeyrJoin(PlayerJoinEvent event)
|
||||
public void playerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (InProgress())
|
||||
{
|
||||
@ -361,9 +371,11 @@ public class MobaTraining extends Moba
|
||||
for (LivingEntity entity : _entities.keySet())
|
||||
{
|
||||
entity.setCustomNameVisible(true);
|
||||
entity.setRemoveWhenFarAway(false);
|
||||
UtilEnt.vegetate(entity);
|
||||
UtilEnt.setFakeHead(entity, true);
|
||||
UtilEnt.silence(entity, true);
|
||||
UtilEnt.ghost(entity, true, false);
|
||||
}
|
||||
|
||||
CreatureAllowOverride = false;
|
||||
@ -379,16 +391,29 @@ public class MobaTraining extends Moba
|
||||
|
||||
event.SetCancelled("NPC");
|
||||
|
||||
if (_selectKitEntity != null && _selectKitEntity.equals(event.GetDamageeEntity()))
|
||||
String name = event.GetDamageeEntity().getCustomName();
|
||||
|
||||
if (name != null && name.contains("Select A Hero"))
|
||||
{
|
||||
openMenu(event.GetDamagerPlayer(false));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void entityCombust(EntityCombustEvent event)
|
||||
{
|
||||
if (!_entities.containsKey(event.getEntity()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void entityInteract(PlayerInteractAtEntityEvent event)
|
||||
{
|
||||
if (_selectKitEntity != null && event.getRightClicked().equals(_selectKitEntity))
|
||||
if (isKitSelectionEntity(event.getRightClicked()))
|
||||
{
|
||||
openMenu(event.getPlayer());
|
||||
}
|
||||
@ -421,6 +446,11 @@ public class MobaTraining extends Moba
|
||||
new SelectKitMenu(Manager).open(player);
|
||||
}
|
||||
|
||||
private boolean isKitSelectionEntity(Entity entity)
|
||||
{
|
||||
return entity.getCustomName() != null && entity.getCustomName().contains("Select A Hero");
|
||||
}
|
||||
|
||||
private void spawnHelpText()
|
||||
{
|
||||
Map<String, Location> locationMap = getLocationStartsWith("HELP");
|
||||
@ -441,7 +471,7 @@ public class MobaTraining extends Moba
|
||||
{
|
||||
Skeleton skeleton = UtilVariant.spawnWitherSkeleton(WorldData.GetCustomLocs("PUMPKIN_KING").get(0));
|
||||
skeleton.setCustomName(C.cDRedB + "Pumpkin King");
|
||||
UtilEnt.CreatureLook(skeleton, 90);
|
||||
skeleton.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
|
||||
|
||||
_entities.put(skeleton, skeleton.getLocation());
|
||||
}
|
||||
@ -449,11 +479,8 @@ public class MobaTraining extends Moba
|
||||
Location location = WorldData.GetCustomLocs("DUMMY_WITHER").get(0);
|
||||
ArmorStand stand = location.getWorld().spawn(location, ArmorStand.class);
|
||||
|
||||
// Reducing the wither's health to 10% gives a shield like effect.
|
||||
stand.setGravity(false);
|
||||
|
||||
UtilEnt.setBoundingBox(stand, 3, 5);
|
||||
|
||||
DisguiseWither disguise = new DisguiseWither(stand);
|
||||
disguise.setName(C.cAqua + "Blue's Wither");
|
||||
disguise.setCustomNameVisible(true);
|
||||
@ -473,12 +500,14 @@ public class MobaTraining extends Moba
|
||||
|
||||
private void spawnNPCs()
|
||||
{
|
||||
Villager villager = WorldData.World.spawn(_selectKit, Villager.class);
|
||||
villager.setCustomName(C.cYellowB + "Select A Hero");
|
||||
UtilEnt.CreatureLook(villager, GetTeam(ChatColor.YELLOW).GetSpawns().get(0));
|
||||
for (Location location : _selectKit)
|
||||
{
|
||||
Villager villager = WorldData.World.spawn(location, Villager.class);
|
||||
villager.setCustomName(C.cYellowB + "Select A Hero");
|
||||
UtilEnt.CreatureLook(villager, GetTeam(ChatColor.YELLOW).GetSpawns().get(0));
|
||||
|
||||
_entities.put(villager, villager.getLocation());
|
||||
_selectKitEntity = villager;
|
||||
_entities.put(villager, villager.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
public void teleportIntoArena(Player player, HeroKit kit)
|
||||
|
@ -137,16 +137,21 @@ public class MobaUtil
|
||||
}
|
||||
|
||||
public static String getHealthBar(LivingEntity entity, double newHealth, int bars)
|
||||
{
|
||||
return getProgressBar(newHealth, entity.getMaxHealth(), bars);
|
||||
}
|
||||
|
||||
public static String getProgressBar(double value, double max, int bars)
|
||||
{
|
||||
StringBuilder out = new StringBuilder();
|
||||
double health = newHealth / entity.getMaxHealth();
|
||||
String colour = getColour(health);
|
||||
double progress = value / max;
|
||||
String colour = getColour(progress);
|
||||
|
||||
for (int i = 0; i < bars; i++)
|
||||
{
|
||||
double cur = i * (1D / (double) bars);
|
||||
|
||||
if (cur < health)
|
||||
if (cur < progress)
|
||||
{
|
||||
out.append(colour).append("|");
|
||||
}
|
||||
@ -159,6 +164,33 @@ public class MobaUtil
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public static String getProgressBar(double valueA, double valueB, double max, int bars)
|
||||
{
|
||||
StringBuilder out = new StringBuilder();
|
||||
double progressA = valueA / max;
|
||||
double progressB = valueB / max;
|
||||
|
||||
for (int i = 0; i < bars; i++)
|
||||
{
|
||||
double cur = i * (1D / (double) bars);
|
||||
|
||||
if (cur < progressA)
|
||||
{
|
||||
out.append(C.cAqua).append("|");
|
||||
}
|
||||
else if (cur < progressB)
|
||||
{
|
||||
out.append(C.cGreen).append("|");
|
||||
}
|
||||
else
|
||||
{
|
||||
out.append(C.cGrayB).append("|");
|
||||
}
|
||||
}
|
||||
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public static String getColour(double percentage)
|
||||
{
|
||||
if (percentage < 0.25)
|
||||
|
@ -71,6 +71,7 @@ import nautilus.game.arcade.game.games.paintball.kits.KitMachineGun;
|
||||
import nautilus.game.arcade.game.games.paintball.kits.KitRifle;
|
||||
import nautilus.game.arcade.game.games.paintball.kits.KitShotgun;
|
||||
import nautilus.game.arcade.game.games.paintball.kits.KitSniper;
|
||||
import nautilus.game.arcade.game.games.paintball.quests.ReviveQuestTracker;
|
||||
import nautilus.game.arcade.game.games.paintball.trackers.KillingSpreeTracker;
|
||||
import nautilus.game.arcade.game.games.paintball.trackers.LastStandStatTracker;
|
||||
import nautilus.game.arcade.game.games.paintball.trackers.MedicStatTracker;
|
||||
@ -125,6 +126,8 @@ public class Paintball extends TeamGame
|
||||
DamageTaken,
|
||||
DamageDealt
|
||||
);
|
||||
|
||||
registerQuestTrackers(new ReviveQuestTracker(this));
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompass(true)
|
||||
|
@ -0,0 +1,32 @@
|
||||
package nautilus.game.arcade.game.games.paintball.quests;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.games.paintball.events.ReviveEvent;
|
||||
import nautilus.game.arcade.quest.QuestTracker;
|
||||
|
||||
/**
|
||||
* ReviveQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class ReviveQuestTracker extends QuestTracker<Game>
|
||||
{
|
||||
|
||||
public ReviveQuestTracker(Game game)
|
||||
{
|
||||
super(game, TriggerType.COLLECT);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHit(ReviveEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
incrementQuests(event.getPlayer(), 1, "Revive", getGame().GetKit(event.getPlayer()).GetName() + "Kit");
|
||||
}
|
||||
}
|
@ -1,10 +1,5 @@
|
||||
package nautilus.game.arcade.game.games.speedbuilders;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -32,7 +27,6 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||
import nautilus.game.arcade.game.SoloGame;
|
||||
import nautilus.game.arcade.game.games.skyfall.quests.RingQuestTracker;
|
||||
import nautilus.game.arcade.game.games.speedbuilders.data.BuildData;
|
||||
import nautilus.game.arcade.game.games.speedbuilders.data.DemolitionData;
|
||||
import nautilus.game.arcade.game.games.speedbuilders.data.MobData;
|
||||
@ -49,7 +43,6 @@ import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.managers.chat.ChatStatData;
|
||||
import nautilus.game.arcade.stats.BlockPlaceStatTracker;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutGameStateChange;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Effect;
|
||||
@ -97,6 +90,11 @@ import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class SpeedBuilders extends SoloGame
|
||||
{
|
||||
private static final String GUARDIAN_NAME = "Gwen the Guardian";
|
||||
@ -206,15 +204,6 @@ public class SpeedBuilders extends SoloGame
|
||||
.setGiveCompassToAlive(false)
|
||||
.register(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEnd(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() == GameState.End || event.GetState() == GameState.Dead)
|
||||
{
|
||||
Manager.getBrandingManager().reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ParseData()
|
||||
|
@ -58,6 +58,7 @@ import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.games.turfforts.kits.KitInfiltrator;
|
||||
import nautilus.game.arcade.game.games.turfforts.kits.KitMarksman;
|
||||
import nautilus.game.arcade.game.games.turfforts.kits.KitShredder;
|
||||
import nautilus.game.arcade.game.games.turfforts.quests.BlockBreakQuestTracker;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.managers.chat.ChatStatData;
|
||||
@ -171,6 +172,7 @@ public class TurfForts extends TeamGame
|
||||
new ChatStatData("BlocksBroken", "Blocks Broken", true)
|
||||
);
|
||||
|
||||
registerQuestTrackers(new BlockBreakQuestTracker(this));
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompass(true)
|
||||
|
@ -0,0 +1,33 @@
|
||||
package nautilus.game.arcade.game.games.turfforts.quests;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.games.turfforts.TurfForts;
|
||||
import nautilus.game.arcade.quest.QuestTracker;
|
||||
|
||||
/**
|
||||
* BlockBreakQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class BlockBreakQuestTracker extends QuestTracker<Game>
|
||||
{
|
||||
|
||||
public BlockBreakQuestTracker(Game game)
|
||||
{
|
||||
super(game, TriggerType.COLLECT);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHit(TurfForts.ShredBlockEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
incrementQuests((Player) event.getArrow().getShooter(), 1, "Block Break", getGame().GetKit((Player) event.getArrow().getShooter()).GetName() + "Kit");
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package nautilus.game.arcade.game.modules;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.stats.event.StatChangeEvent;
|
||||
import mineplex.core.stats.game.GameStatisticsManager;
|
||||
import mineplex.core.stats.game.GameStats;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class GameStatisticsModule extends Module
|
||||
{
|
||||
|
||||
private static final GameStatisticsManager STATS_MANAGER;
|
||||
|
||||
static
|
||||
{
|
||||
STATS_MANAGER = Managers.require(GameStatisticsManager.class);
|
||||
}
|
||||
|
||||
private GameStats _currentGame;
|
||||
private final List<String> _statsToListen;
|
||||
private final Map<UUID, Integer> _playerId;
|
||||
|
||||
public GameStatisticsModule()
|
||||
{
|
||||
_statsToListen = new ArrayList<>();
|
||||
_playerId = new HashMap<>();
|
||||
}
|
||||
|
||||
public void addStatListener(String stat)
|
||||
{
|
||||
_statsToListen.add(stat);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup()
|
||||
{
|
||||
_currentGame = new GameStats(-1, UtilServer.getRegion(), getGame().GetType().getDisplay());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup()
|
||||
{
|
||||
if (getGame().getArcadeManager().IsRewardStats() && _currentGame.isValid())
|
||||
{
|
||||
STATS_MANAGER.saveGameStats(_currentGame);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void live(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Live)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int id = 0;
|
||||
for (Player player : getGame().GetPlayers(true))
|
||||
{
|
||||
_playerId.put(player.getUniqueId(), ++id);
|
||||
}
|
||||
|
||||
STATS_MANAGER.getMapId(mapId -> _currentGame.setMapId(mapId), getGame().GetType().getDisplay(), getGame().WorldData.MapName);
|
||||
_currentGame.setStartTime(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void end(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.End)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_currentGame.setEndTime(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void statChange(StatChangeEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
String stat = event.getStatName();
|
||||
long change = event.getValueAfter() - event.getValueBefore();
|
||||
|
||||
if (_statsToListen.contains(getGame().GetName() + "." + stat) && _playerId.containsKey(player.getUniqueId()))
|
||||
{
|
||||
int playerId = _playerId.get(player.getUniqueId());
|
||||
_currentGame.getStats().putIfAbsent(playerId, new HashMap<>());
|
||||
_currentGame.getStats().get(playerId).put(stat, change);
|
||||
}
|
||||
}
|
||||
}
|
@ -166,6 +166,11 @@ public class TrainingGameModule extends Module
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void playerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (!getGame().InProgress())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (UtilPlayer.isSpectator(player))
|
||||
|
@ -123,6 +123,7 @@ public class GameHostManager implements Listener
|
||||
legendGames.add(GameType.Skywars);
|
||||
legendGames.add(GameType.SpeedBuilders);
|
||||
legendGames.add(GameType.TypeWars);
|
||||
legendGames.add(GameType.MOBA);
|
||||
// Team variants - Currently being remade.
|
||||
/*
|
||||
legendGames.add(GameType.DragonEscapeTeams);
|
||||
|
@ -38,6 +38,9 @@ public class ChestOpenQuestTracker extends QuestTracker<Game>
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
if (!getGame().IsAlive(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (event.getClickedBlock().getType() != Material.CHEST)
|
||||
return;
|
||||
|
||||
|
@ -1,18 +1,24 @@
|
||||
package nautilus.game.arcade.quest;
|
||||
|
||||
import java.awt.dnd.DragSourceDropEvent;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.DoubleChest;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
@ -29,7 +35,9 @@ import nautilus.game.arcade.game.Game;
|
||||
public class CollectQuestTracker extends QuestTracker<Game>
|
||||
{
|
||||
private ArrayList<ItemStack> _itemsAvailable = new ArrayList<>();
|
||||
private ArrayList<ItemStack> _badItems = new ArrayList<>();
|
||||
private ArrayList<Location> _usedChests = new ArrayList<>();
|
||||
private ArrayList<Location> _usedBlocks = new ArrayList<>();
|
||||
|
||||
public CollectQuestTracker(Game game)
|
||||
{
|
||||
@ -45,6 +53,71 @@ public class CollectQuestTracker extends QuestTracker<Game>
|
||||
_usedChests.clear();
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.HIGHEST)
|
||||
public void blockRegister(BlockPlaceEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (event.getBlockPlaced().getType() == Material.IRON_ORE
|
||||
|| event.getBlockPlaced().getType() == Material.GOLD_ORE)
|
||||
{
|
||||
_usedBlocks.add(event.getBlock().getLocation());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.HIGHEST)
|
||||
public void itemRegister(PlayerDropItemEvent event)
|
||||
{
|
||||
_badItems.add(event.getItemDrop().getItemStack());
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.HIGHEST)
|
||||
public void itemRegister(BlockBreakEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (!_usedBlocks.contains(event.getBlock().getLocation()))
|
||||
return;
|
||||
|
||||
for (ItemStack item : event.getBlock().getDrops())
|
||||
{
|
||||
_badItems.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.HIGHEST)
|
||||
public void itemPickup(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
ItemStack item = event.getItem().getItemStack();
|
||||
|
||||
if (_badItems.contains(item))
|
||||
{
|
||||
_badItems.remove(item);
|
||||
return;
|
||||
}
|
||||
String itemName = item.getType().toString();
|
||||
|
||||
if (item.hasItemMeta())
|
||||
itemName = item.getItemMeta().getDisplayName();
|
||||
|
||||
incrementQuests(event.getPlayer(), item.getAmount(), ChatColor.stripColor(itemName));
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.HIGHEST)
|
||||
public void chestRegister(PlayerInteractEvent event)
|
||||
{
|
||||
|
@ -0,0 +1,31 @@
|
||||
package nautilus.game.arcade.quest;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.events.FirstBloodEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
|
||||
/**
|
||||
* FirstBloodQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class FirstBloodQuestTracker extends QuestTracker<Game>
|
||||
{
|
||||
|
||||
public FirstBloodQuestTracker(Game game)
|
||||
{
|
||||
super(game, TriggerType.FIRST_BLOOD);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHit(FirstBloodEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
incrementQuests(event.getPlayer(), 1, getGame().GetKit(event.getPlayer()).GetName() + "Kit");
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package nautilus.game.arcade.quest;
|
||||
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import nautilus.game.arcade.game.Game;
|
||||
|
||||
/**
|
||||
* HitQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class HitQuestTracker extends QuestTracker<Game>
|
||||
{
|
||||
|
||||
public HitQuestTracker(Game game)
|
||||
{
|
||||
super(game, TriggerType.HIT);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHit(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
if (!(event.getDamager() instanceof Player) || !(event.getEntity() instanceof Item))
|
||||
return;
|
||||
|
||||
|
||||
Item itemEntity = (Item) event.getEntity();
|
||||
String item = itemEntity.getItemStack().getType().toString();
|
||||
|
||||
incrementQuests((Player) event.getDamager(), 1, "Player", item, getGame().GetKit((Player) event.getDamager()).GetName() + "Kit");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileHit(CustomDamageEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
if (event.GetReason() == null)
|
||||
return;
|
||||
|
||||
if (!event.GetReason().contains("Axe Thrower"))
|
||||
return;
|
||||
|
||||
System.out.println("Test2");
|
||||
|
||||
incrementQuests(event.GetDamagerPlayer(true), 1, "Player", "Axe", getGame().GetKit(event.GetDamagerPlayer(true)).GetName() + "Kit");
|
||||
}
|
||||
}
|
@ -42,6 +42,9 @@ public class QuestTracker<T extends Game> implements Listener
|
||||
|
||||
public void incrementQuests(Player player, int value, String... items)
|
||||
{
|
||||
if (getGame().getArcadeManager().GetGameHostManager().isPrivateServer())
|
||||
return;
|
||||
|
||||
if (canProgressQuests())
|
||||
{
|
||||
for (Quest quest : getGame().getArcadeManager().getQuestManager().getAvailableQuests())
|
||||
|
@ -1,13 +1,5 @@
|
||||
package mineplex.gemhunters;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.spigotmc.SpigotConfig;
|
||||
|
||||
import mineplex.core.CustomTagFix;
|
||||
import mineplex.core.FoodDupeFix;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
@ -70,7 +62,6 @@ import mineplex.core.updater.FileUpdater;
|
||||
import mineplex.core.updater.Updater;
|
||||
import mineplex.core.visibility.VisibilityManager;
|
||||
import mineplex.gemhunters.beta.BetaModule;
|
||||
import mineplex.gemhunters.bounties.BountyModule;
|
||||
import mineplex.gemhunters.chat.ChatModule;
|
||||
import mineplex.gemhunters.death.DeathModule;
|
||||
import mineplex.gemhunters.death.quitnpc.QuitNPCModule;
|
||||
@ -100,6 +91,12 @@ import mineplex.gemhunters.worldevent.WorldEventModule;
|
||||
import mineplex.minecraft.game.core.combat.CombatManager;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.spigotmc.SpigotConfig;
|
||||
|
||||
import static mineplex.core.Managers.require;
|
||||
|
||||
@ -275,7 +272,6 @@ public class GemHunters extends JavaPlugin
|
||||
// Though if any other module needs one of these it will be generated in
|
||||
// order, however they are all here just for good measure.
|
||||
require(BetaModule.class);
|
||||
require(BountyModule.class);
|
||||
require(CashOutModule.class);
|
||||
require(ChatModule.class);
|
||||
require(DeathModule.class);
|
||||
|
@ -1,36 +0,0 @@
|
||||
package mineplex.gemhunters.bounties;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Bounty
|
||||
{
|
||||
|
||||
private UUID _target;
|
||||
private UUID _setter;
|
||||
private int _amount;
|
||||
|
||||
public Bounty(Player target, Player setter, int amount)
|
||||
{
|
||||
_target = target.getUniqueId();
|
||||
_setter = setter.getUniqueId();
|
||||
_amount = amount;
|
||||
}
|
||||
|
||||
public UUID getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public UUID getSetter()
|
||||
{
|
||||
return _setter;
|
||||
}
|
||||
|
||||
public int getAmount()
|
||||
{
|
||||
return _amount;
|
||||
}
|
||||
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package mineplex.gemhunters.bounties;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.sponsorbranding.BrandingManager;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class BountyModule extends MiniPlugin
|
||||
{
|
||||
|
||||
private final BrandingManager _brandingManager;
|
||||
|
||||
private BountyModule()
|
||||
{
|
||||
super("Bounty");
|
||||
|
||||
_brandingManager = require(BrandingManager.class);
|
||||
}
|
||||
|
||||
//@EventHandler
|
||||
public void test(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (!event.getMessage().startsWith("/want"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
event.setCancelled(true);
|
||||
_brandingManager.createPost(event.getPlayer().getLocation(), BlockFace.SOUTH, new URL("http://minotar.net/helm/Moppletop.png"));
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -6,6 +6,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.redis.RedisRepository;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
public class QuitNPCRepository extends RedisRepository
|
||||
{
|
||||
@ -18,16 +19,34 @@ public class QuitNPCRepository extends RedisRepository
|
||||
|
||||
public CompletableFuture<String> loadNpcServer(UUID uuid)
|
||||
{
|
||||
return CompletableFuture.supplyAsync(() -> getResource(false).get(getKey(REDIS_KEY_PREFIX + uuid.toString())));
|
||||
return CompletableFuture.supplyAsync(() ->
|
||||
{
|
||||
try (Jedis jedis = getResource(false))
|
||||
{
|
||||
return jedis.get(getKey(REDIS_KEY_PREFIX + uuid.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteNpc(UUID uuid)
|
||||
{
|
||||
UtilServer.runAsync(() -> getResource(true).del(getKey(REDIS_KEY_PREFIX + uuid.toString())));
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
try (Jedis jedis = getResource(true))
|
||||
{
|
||||
jedis.del(getKey(REDIS_KEY_PREFIX + uuid.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void insertNpc(UUID uuid, String serverName)
|
||||
{
|
||||
UtilServer.runAsync(() -> getResource(true).setex(REDIS_KEY_PREFIX + uuid.toString(), 60, serverName));
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
try (Jedis jedis = getResource(true))
|
||||
{
|
||||
jedis.setex(getKey(REDIS_KEY_PREFIX + uuid.toString()), 60, serverName);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -672,6 +672,10 @@ public class LootModule extends MiniPlugin
|
||||
{
|
||||
for (LootItemReward reward : _itemRewards)
|
||||
{
|
||||
if (reward.getPlayer() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (reward.getPlayer().equals(event.getEntity()))
|
||||
{
|
||||
reward.death(event);
|
||||
|
Loading…
Reference in New Issue
Block a user