Merge remote-tracking branch 'refs/remotes/origin/develop' into update/castle-siege

This commit is contained in:
Sam 2017-07-31 19:11:34 +01:00
commit 5aefca3c6c
66 changed files with 1468 additions and 777 deletions

View File

@ -1025,14 +1025,15 @@ public class UtilEnt
}
// Nicer than doing entity.getMetadata(key).get(0);
public static Object GetMetadata(Entity entity, String key)
@SuppressWarnings("unchecked")
public static <T> T GetMetadata(Entity entity, String key)
{
if (!entity.hasMetadata(key))
{
return null;
}
return entity.getMetadata(key).get(0).value();
return (T) entity.getMetadata(key).get(0).value();
}
public static void removeMetadata(Entity entity, String key)

View File

@ -9,6 +9,7 @@ import mineplex.serverdata.Region;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.Sound;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@ -43,14 +44,7 @@ public class UtilServer
public static List<Player> getSortedPlayers()
{
return getSortedPlayers(new Comparator<Player>()
{
@Override
public int compare(Player o1, Player o2)
{
return o1.getName().compareTo(o2.getName());
}
});
return getSortedPlayers(Comparator.comparing(HumanEntity::getName));
}
public static List<Player> getSortedPlayers(Comparator<Player> comparator)

View File

@ -536,6 +536,15 @@ public enum Achievement
new String[]{"Novice I", "Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"},
AchievementCategory.CASTLE_ASSAULT),
CASTLE_ASSAULT_ALCHEMIST_KIT("Alchemist", 0,
new String[]{"Castle Assault.AlchemistKitKills", "Castle Assault TDM.AlchemistKitKills"},
new String[]{"Kill opponents while wearing the Alchemist Kit"},
new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}},
new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000},
"Initiate",
new String[]{"Novice I", "Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"},
AchievementCategory.CASTLE_ASSAULT),
CASTLE_ASSAULT_WINNER("Assault", 0,
new String[]{"Castle Assault.Wins", "Castle Assault TDM.Wins"},
new String[]{"Win games of Castle Assault"},

View File

@ -1,6 +1,5 @@
package mineplex.core.antihack;
import javax.xml.bind.DatatypeConverter;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
@ -10,11 +9,7 @@ import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import javax.xml.bind.DatatypeConverter;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -77,6 +72,7 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.preferences.Preference;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.punish.Category;
@ -85,6 +81,11 @@ import mineplex.core.punish.PunishClient;
import mineplex.core.punish.Punishment;
import mineplex.core.punish.PunishmentResponse;
import mineplex.serverdata.commands.ServerCommandManager;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
@ReflectivelyCreateMiniPlugin
public class AntiHack extends MiniPlugin
@ -114,6 +115,7 @@ public class AntiHack extends MiniPlugin
.put(Speed.class, new ImmediateBanAction(10000))
.put(HeadRoll.class, new ImmediateBanAction(2000))
.put(Toggle.class, new ImmediateBanAction(500))
.put(Timer.class, new ImmediateBanAction(15000))
.put(BadPackets.class, new GEPBanAction(300))
.put(KillauraTypeB.class, new GEPBanAction(100))
.build();
@ -238,7 +240,7 @@ public class AntiHack extends MiniPlugin
{
_punish.getClansPunish().loadClient(coreClient.getUniqueId(), client ->
{
_punish.getClansPunish().ban(client, null, AntiHack.NAME, 90 * 24 * 60 * 60 * 1000, finalMessage, null, ban -> {});
_punish.getClansPunish().ban(client, null, AntiHack.NAME, UtilTime.convert(90L, UtilTime.TimeUnit.DAYS, UtilTime.TimeUnit.MILLISECONDS), ChatColor.stripColor(finalMessage).replace("\n", ""), null, ban -> {});
});
}
};
@ -254,17 +256,18 @@ public class AntiHack extends MiniPlugin
else
{
runBanAnimation(player, () ->
doPunish.accept(result ->
{
doPunish.accept(result ->
{
if (result == PunishmentResponse.Punished)
{
if (result == PunishmentResponse.Punished)
{
announceBan(player);
_banned.add(player.getUniqueId());
_banWaveManager.flagDone(coreClient);
}
_pendingBan.remove(player);
})
);
announceBan(player);
_banned.add(player.getUniqueId());
_banWaveManager.flagDone(coreClient);
}
_pendingBan.remove(player);
});
});
}
}, custom);
}
@ -286,7 +289,7 @@ public class AntiHack extends MiniPlugin
{
_punish.getClansPunish().loadClient(coreClient.getUniqueId(), client ->
{
_punish.getClansPunish().ban(client, null, AntiHack.NAME, 90 * 24 * 60 * 60 * 1000, info.getMessage(), null, ban -> {});
_punish.getClansPunish().ban(client, null, AntiHack.NAME, UtilTime.convert(90L, UtilTime.TimeUnit.DAYS, UtilTime.TimeUnit.MILLISECONDS), ChatColor.stripColor(info.getMessage()).replace("\n", ""), null, ban -> {});
});
}
};

View File

@ -5,7 +5,6 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import mineplex.core.common.util.UtilTasks;
import mineplex.core.database.MinecraftRepository;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.RepositoryBase;
@ -45,4 +44,4 @@ public class AnticheatDatabase extends RepositoryBase
}
}
}
}
}

View File

@ -20,4 +20,4 @@ public abstract class AnticheatMetadata implements Listener
public abstract JsonElement build(UUID player);
public abstract void remove(UUID player);
}
}

View File

@ -28,7 +28,12 @@ public class PartyInfoMetadata extends AnticheatMetadata
@Override
public JsonElement build(UUID player)
{
Party party = require(PartyManager.class).getPartyByPlayer(player);
PartyManager pm = require(PartyManager.class);
if (pm == null)
{
return JsonNull.INSTANCE;
}
Party party = pm.getPartyByPlayer(player);
if (party != null)
{
JsonObject partyData = new JsonObject();
@ -52,4 +57,4 @@ public class PartyInfoMetadata extends AnticheatMetadata
{
}
}
}

View File

@ -48,4 +48,4 @@ public class PlayerInfoMetadata extends AnticheatMetadata
{
}
}
}

View File

@ -156,4 +156,4 @@ public class ViolationInfoMetadata extends AnticheatMetadata
violations.add(data);
}
}
}

View File

@ -149,7 +149,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
private int _visualTick;
private ArrayList<String> _voteList;
private List<Pair<String, String>> _youtubers;
private String _creeperName;
@ -182,18 +181,8 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
{
_voteList.add("http://vote1.mineplex.com");
_voteList.add("http://vote2.mineplex.com");
_voteList.add("http://vote3.mineplex.com");
}
_youtubers = new ArrayList<>();
if (!ClansBonus)
{
_youtubers.add(Pair.create("Sigils", "https://www.youtube.com/user/SigilsPlaysGames?sub_confirmation=1"));
_youtubers.add(Pair.create("SallyGreenGamer", "https://www.youtube.com/channel/UCt8eypdLUND5CBvgXzEZrxw?sub_confirmation=1"));
_youtubers.add(Pair.create("RustyDawgT", "https://www.youtube.com/user/RustyDawgT?sub_confirmation=1"));
}
_youtubers.add(Pair.create("SamitoD", "https://www.youtube.com/user/SamitoD?sub_confirmation=1"));
_creeperName = "Carl";
updateOffSet();
@ -240,18 +229,8 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
{
_voteList.add("http://vote1.mineplex.com");
_voteList.add("http://vote2.mineplex.com");
_voteList.add("http://vote3.mineplex.com");
}
_canVote = true;
_youtubers = new ArrayList<>();
if (!ClansBonus)
{
_youtubers.add(Pair.create("Sigils", "https://www.youtube.com/user/SigilsPlaysGames?sub_confirmation=1"));
_youtubers.add(Pair.create("SallyGreenGamer", "https://www.youtube.com/channel/UCt8eypdLUND5CBvgXzEZrxw?sub_confirmation=1"));
_youtubers.add(Pair.create("RustyDawgT", "https://www.youtube.com/user/RustyDawgT?sub_confirmation=1"));
}
_youtubers.add(Pair.create("SamitoD", "https://www.youtube.com/user/SamitoD?sub_confirmation=1"));
if (npcManager != null)
{
@ -1005,7 +984,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (canVote(player)) availableRewards++;
if (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) availableRewards++;
if (_youtubeManager.canYoutube(player)) availableRewards++;
if (_youtubeManager.canSpecificYoutube(player)) availableRewards++;
if (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) availableRewards++;
if (canDaily(player)) availableRewards++;
if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++;
@ -1165,7 +1143,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
{
if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false))
{
if (_pollManager.hasPoll(player) || canVote(player) || _youtubeManager.canSpecificYoutube(player) || _youtubeManager.canYoutube(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository))
if (_pollManager.hasPoll(player) || canVote(player) || _youtubeManager.canYoutube(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository))
{
if (_showCarl.containsKey(player.getName()))
{
@ -1186,23 +1164,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
int index = date % _voteList.size();
return _voteList.get(index);
}
public Pair<String, String> getSpecificCreator()
{
long sqlTime = getSqlTime();
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(sqlTime);
int date = calendar.get(Calendar.DAY_OF_YEAR);
if (_youtubers.size() >= 1)
{
int index = date % _youtubers.size();
return _youtubers.get(index);
}
else
{
return Pair.create("MineplexGames", "http://youtube.com/mineplexgamesofficial?sub_confirmation=1");
}
}
/**
* Used for disabling rank rewards during first month of release

View File

@ -12,7 +12,6 @@ import mineplex.core.bonuses.gui.buttons.PlayWireButton;
import mineplex.core.bonuses.gui.buttons.PollButton;
import mineplex.core.bonuses.gui.buttons.PowerPlayClubButton;
import mineplex.core.bonuses.gui.buttons.RankBonusButton;
import mineplex.core.bonuses.gui.buttons.SpecificChannelButton;
import mineplex.core.bonuses.gui.buttons.TwitterButton;
import mineplex.core.bonuses.gui.buttons.VoteButton;
import mineplex.core.bonuses.gui.buttons.YoutubeButton;
@ -33,10 +32,9 @@ public class BonusGui extends SimpleGui
private final int CLAIM_TIPS_SLOT = 30;
private final int POWER_PLAY_SLOT = 16;
private final int CARL_SPINNER_SLOT = 14;
private final int YOUTUBE_SLOT = 22;
private final int YOUTUBE_SLOT = 24;
private final int TWITTER_SLOT = 34;
private final int PLAY_WIRE_SLOT = 32;
private final int SPECIFIC_YOUTUBE_SLOT = 24;
private static final int INV_SIZE = 54;
@ -65,8 +63,6 @@ public class BonusGui extends SimpleGui
setItem(CARL_SPINNER_SLOT, new CarlSpinButton(getPlugin(), player, manager, rewardManager));
setItem(PLAY_WIRE_SLOT, new PlayWireButton(playWireManager, player));
setItem(SPECIFIC_YOUTUBE_SLOT, new SpecificChannelButton(player, youtubeManager));
}
@Override
@ -74,4 +70,4 @@ public class BonusGui extends SimpleGui
{
super.finalize();
}
}
}

View File

@ -34,7 +34,7 @@ public class SpecificChannelButton implements GuiItem
@Override
public void setup()
{
_channel = Managers.get(BonusManager.class).getSpecificCreator();
_channel = Pair.create("", "");
if (_youtubeManager.canSpecificYoutube(_player))
{
_item = new ItemBuilder(Material.APPLE)
@ -111,4 +111,4 @@ public class SpecificChannelButton implements GuiItem
{
return _item;
}
}
}

View File

@ -228,6 +228,9 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
if (!spawnedIn)
{
refreshTrackers(disguise.getEntity().getBukkitEntity());
} else
{
disguise.markSpawnedIn();
}
disguise.onDisguise(true);

View File

@ -1,7 +1,11 @@
package mineplex.core.disguise.disguises;
import mineplex.core.common.DummyEntity;
import mineplex.core.common.util.UtilPlayer;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
import java.util.function.Supplier;
import net.minecraft.server.v1_8_R3.*;
@ -10,12 +14,8 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;
import mineplex.core.common.DummyEntity;
import mineplex.core.common.util.UtilPlayer;
public abstract class DisguiseBase
{
@ -32,6 +32,8 @@ public abstract class DisguiseBase
*/
private boolean _hideIfNotDisguised = false;
protected boolean _spawnedIn = false;
public DisguiseBase(EntityType entityType, org.bukkit.entity.Entity entity)
{
if (entity == null)
@ -67,7 +69,7 @@ public abstract class DisguiseBase
DataWatcher.watch(1, getEntity().getDataWatcher().getShort(1), net.minecraft.server.v1_8_R3.Entity.META_AIR, (int) getEntity().getDataWatcher().getShort(1));
}
public void sendToWatchers(Supplier<Packet> supplier)
protected void sendToWatchers(Predicate<Integer> protocolPredicate, Supplier<Packet> supplier)
{
if (getEntity() == null || !getEntity().getBukkitEntity().isValid() || !(getEntity().world instanceof WorldServer))
return;
@ -83,12 +85,16 @@ public abstract class DisguiseBase
for (EntityPlayer player : tracker.get(getEntity().getId()).trackedPlayers)
{
int protocol = player.getProtocol();
if (!protocolPredicate.test(protocol))
continue;
if (packet instanceof PacketPlayOutEntityMetadata)
{
player.playerConnection.sendPacket(modifyMetaPacket(player.getProtocol(), packet));
player.playerConnection.sendPacket(modifyMetaPacket(protocol, packet));
} else if (packet instanceof PacketPlayOutSpawnEntityLiving)
{
player.playerConnection.sendPacket(modifySpawnPacket(player.getProtocol(), packet));
player.playerConnection.sendPacket(modifySpawnPacket(protocol, packet));
} else
{
player.playerConnection.sendPacket(packet);
@ -96,6 +102,11 @@ public abstract class DisguiseBase
}
}
protected void sendToWatchers(Supplier<Packet> supplier)
{
sendToWatchers(x -> true, supplier);
}
public abstract Packet getSpawnPacket();
public Packet modifySpawnPacket(int protocol, Packet packet)
@ -203,6 +214,11 @@ public abstract class DisguiseBase
}
public void markSpawnedIn()
{
_spawnedIn = true;
}
public void setHideIfNotDisguised(boolean hideIfNotDisguised)
{
this._hideIfNotDisguised = hideIfNotDisguised;

View File

@ -1,10 +1,10 @@
package mineplex.core.disguise.disguises;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import com.mineplex.MetaWrapper;
import com.mineplex.MetadataRewriter;
import com.mineplex.ProtocolVersion;
import net.minecraft.server.v1_8_R3.*;
@ -25,9 +25,9 @@ public abstract class DisguiseCreature extends DisguiseInsentient
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = getEntity().getId();
packet.b = (byte) getDisguiseType().getTypeId();
packet.c = (int) MathHelper.floor(getEntity().locX*32D);
packet.d = (int) MathHelper.floor(getEntity().locY * 32.0D);
packet.e = (int) MathHelper.floor(getEntity().locZ*32D);
packet.c = MathHelper.floor(getEntity().locX * 32.0D);
packet.d = MathHelper.floor(getEntity().locY * 32.0D);
packet.e = MathHelper.floor(getEntity().locZ * 32.0D);
packet.i = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (getEntity().pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F));
@ -78,45 +78,96 @@ public abstract class DisguiseCreature extends DisguiseInsentient
return packet;
}
// ---- Metadata processing
// This WON'T be post-processed by the Spigot metadata processor
@Override
public Packet modifySpawnPacket(int protocol, Packet packet)
{
if (protocol >= ProtocolVersion.v1_10_PRE)
{
PacketPlayOutSpawnEntityLiving newSpawn = (PacketPlayOutSpawnEntityLiving) getSpawnPacket();
newSpawn.m = processSpawnMeta(protocol, DataWatcher.c());
// Allow the entity type to be changed (needed on 1.11+)
newSpawn.b = getTypeId(protocol >= ProtocolVersion.v1_11);
boolean hasArms = false;
List<WatchableObject> meta = DataWatcher.b();
if (meta != null)
{
// Run the meta through our Spigot rewriter
meta = MetadataRewriter.rewrite(getTypeId(false), protocol, meta).objects;
// Remove indexes >= 12 on 1.11+
if (protocol >= ProtocolVersion.v1_11)
{
Iterator<WatchableObject> iter = meta.iterator();
while (iter.hasNext())
{
WatchableObject next = iter.next();
if (next.getIndex().a() == 6)
{
hasArms = true;
} else if (next.getIndex().a() >= 12)
{
iter.remove();
}
}
}
} else
{
meta = new ArrayList<>();
}
if (!hasArms)
{
WatchableObject<Byte> arms = new WatchableObject<>(0, 0, null,
new DataIndex<>(6, DataType.BYTE), (byte) 0);
meta.add(arms);
}
newSpawn.m = meta;
return newSpawn;
}
return packet;
}
private List<WatchableObject> processSpawnMeta(int protocol, List<WatchableObject> list)
protected int getTypeId(boolean separate)
{
List<MetaWrapper> newMeta = new ArrayList<>();
for (WatchableObject meta : list)
return getDisguiseType().getTypeId();
}
// This WILL be post-processed by Spigot's metadata processor
@Override
public Packet modifyMetaPacket(int protocol, Packet packet)
{
if (protocol >= ProtocolVersion.v1_10_PRE)
{
MetaWrapper wrapper = new MetaWrapper(meta);
if (wrapper.getIndex() >= 5) // 1.10
PacketPlayOutEntityMetadata newMeta = new PacketPlayOutEntityMetadata();
newMeta.a = getEntityId();
List<WatchableObject> meta = MetadataRewriter.rewrite(getTypeId(false), protocol, DataWatcher.c()).objects;
for (int i = 0; i < meta.size(); i++)
{
wrapper.setIndex(wrapper.getIndex() + 1);
WatchableObject object = meta.get(i);
int index = object.getIndex().a();
if (index >= 6)
{
index--;
meta.set(i, new WatchableObject(0, 0, null,
new DataIndex(index, object.getIndex().b()), object.getValue()));
}
}
if (protocol < ProtocolVersion.v1_11)
{
newMeta.add(wrapper);
continue;
}
if (getEntity() instanceof EntityArmorStand && wrapper.getIndex() >= 12)
{
// Armor stand meta conflicts with a lot of entities on 1.11+
continue;
}
newMeta.add(wrapper);
newMeta.b = meta;
return newMeta;
}
return newMeta.stream().map(MetaWrapper::toWatchableObject).collect(Collectors.toList());
return packet;
}
}

View File

@ -1,20 +1,14 @@
package mineplex.core.disguise.disguises;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import net.minecraft.server.v1_8_R3.EntityGuardian;
import com.mineplex.MetaWrapper;
import com.mineplex.ProtocolVersion;
import net.minecraft.server.v1_8_R3.*;
import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
public class DisguiseGuardian extends DisguiseCreature
public class DisguiseGuardian extends DisguiseMutable
{
private static final int GUARDIAN_ID = 68;
private static final int ELDER_GUARDIAN_ID = 4;
private int target = 0;
private boolean elder = false;
@ -41,9 +35,7 @@ public class DisguiseGuardian extends DisguiseCreature
DataWatcher.watch(16, Integer.valueOf(newValue), EntityGuardian.META_ELDER, (byte) newValue);
sendToWatchers(() -> new PacketPlayOutEntityDestroy(new int[]{getEntityId()}));
sendToWatchers(this::getSpawnPacket);
sendToWatchers(this::getMetadataPacket);
mutate();
}
public boolean isElder()
@ -66,49 +58,9 @@ public class DisguiseGuardian extends DisguiseCreature
return "mob.guardian.hit";
}
// ---- Packet modification for 1.11 and up
@Override
public Packet modifySpawnPacket(int protocol, Packet packet)
protected int getTypeId(boolean separate)
{
PacketPlayOutSpawnEntityLiving newSpawn = (PacketPlayOutSpawnEntityLiving) super.modifySpawnPacket(protocol, packet);
if (protocol >= ProtocolVersion.v1_11 && isElder())
{
newSpawn.b = 4;
}
return newSpawn;
}
@Override
public Packet modifyMetaPacket(int protocol, Packet packet)
{
if (protocol >= ProtocolVersion.v1_11)
{
PacketPlayOutEntityMetadata newPacket = (PacketPlayOutEntityMetadata) getMetadataPacket();
newPacket.b = processMeta(newPacket.b);
return newPacket;
}
return packet;
}
private List<WatchableObject> processMeta(List<WatchableObject> list)
{
List<MetaWrapper> newMeta = new ArrayList<>();
for (WatchableObject meta : list)
{
MetaWrapper wrapper = new MetaWrapper(meta);
if (wrapper.getIndex() == 11)
{
byte value = (byte) wrapper.getValue();
newMeta.add(new MetaWrapper(11, DataType.BOOLEAN, (value & 0x02) != 0));
} else
{
newMeta.add(wrapper);
}
}
return newMeta.stream().map(MetaWrapper::toWatchableObject).collect(Collectors.toList());
return separate && isElder() ? ELDER_GUARDIAN_ID : GUARDIAN_ID;
}
}

View File

@ -2,14 +2,24 @@ package mineplex.core.disguise.disguises;
import java.util.UUID;
import net.minecraft.server.v1_8_R3.EntityHorse;
import org.bukkit.entity.*;
import com.google.common.base.Optional;
public class DisguiseHorse extends DisguiseAnimal
import net.minecraft.server.v1_8_R3.EntityAgeable;
import net.minecraft.server.v1_8_R3.EntityHorse;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Horse;
public class DisguiseHorse extends DisguiseMutable
{
private static final int HORSE_ID = 100;
private static final int DONKEY_ID = 31;
private static final int MULE_ID = 32;
private static final int ZOMBIE_HORSE_ID = 29;
private static final int SKELETON_HORSE_ID = 28;
private Horse.Variant variant = Horse.Variant.HORSE;
public DisguiseHorse(org.bukkit.entity.Entity entity)
{
super(EntityType.HORSE, entity);
@ -19,11 +29,25 @@ public class DisguiseHorse extends DisguiseAnimal
DataWatcher.a(20, Integer.valueOf(0), EntityHorse.META_VARIANT, 0);
DataWatcher.a(21, String.valueOf(""), EntityHorse.META_OWNER, Optional.<UUID> absent());
DataWatcher.a(22, Integer.valueOf(0), EntityHorse.META_ARMOR, 0);
DataWatcher.a(12, new Byte((byte)0), EntityAgeable.META_BABY, false);
}
public boolean isBaby()
{
return DataWatcher.getByte(12) < 0;
}
public void setBaby()
{
DataWatcher.watch(12, new Byte((byte) ( -1 )), EntityAgeable.META_BABY, true);
}
public void setType(Horse.Variant horseType)
{
DataWatcher.watch(19, Byte.valueOf((byte) horseType.ordinal()), EntityHorse.META_TYPE, horseType.ordinal());
this.variant = horseType;
mutate();
}
public Horse.Variant getType()
@ -72,4 +96,23 @@ public class DisguiseHorse extends DisguiseAnimal
{
DataWatcher.watch(22, Integer.valueOf(i), EntityHorse.META_ARMOR, i);
}
// 1.11 and up require separate entity ids
@Override
protected int getTypeId(boolean separate)
{
if (separate && variant != Horse.Variant.HORSE)
{
switch (variant)
{
case DONKEY: return DONKEY_ID;
case MULE: return MULE_ID;
case UNDEAD_HORSE: return ZOMBIE_HORSE_ID;
case SKELETON_HORSE: return SKELETON_HORSE_ID;
default: return HORSE_ID;
}
}
return HORSE_ID;
}
}

View File

@ -1,95 +1,15 @@
package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_8_R3.EntitySlime;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
public class DisguiseMagmaCube extends DisguiseInsentient
/**
* Magma cubes are essentially identical to slimes for disguise purposes
*/
public class DisguiseMagmaCube extends DisguiseSlime
{
public DisguiseMagmaCube(org.bukkit.entity.Entity entity)
public DisguiseMagmaCube(Entity entity)
{
super(EntityType.MAGMA_CUBE, entity);
DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1);
}
public void SetSize(int i)
{
DataWatcher.watch(16, new Byte((byte) i), EntitySlime.META_SIZE, i);
}
public int GetSize()
{
return DataWatcher.getByte(16);
}
public Packet getSpawnPacket()
{
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = getEntity().getId();
packet.b = (byte) 62;
packet.c = (int) MathHelper.floor(getEntity().locX * 32D);
packet.d = (int) MathHelper.floor(getEntity().locY * 32.0D);
packet.e = (int) MathHelper.floor(getEntity().locZ * 32D);
packet.i = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (getEntity().pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F));
packet.uuid = getEntity().getUniqueID();
double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
if (var4 < -var2)
{
var4 = -var2;
}
if (var6 < -var2)
{
var6 = -var2;
}
if (var8 < -var2)
{
var8 = -var2;
}
if (var4 > var2)
{
var4 = var2;
}
if (var6 > var2)
{
var6 = var2;
}
if (var8 > var2)
{
var8 = var2;
}
packet.f = (int) (var4 * 8000.0D);
packet.g = (int) (var6 * 8000.0D);
packet.h = (int) (var8 * 8000.0D);
packet.l = DataWatcher;
packet.m = DataWatcher.b();
return packet;
}
protected String getHurtSound()
{
return "mob.slime." + (GetSize() > 1 ? "big" : "small");
}
protected float getVolume()
{
return 0.4F * (float) GetSize();
}
}
}

View File

@ -0,0 +1,40 @@
package mineplex.core.disguise.disguises;
import java.util.function.Predicate;
import com.mineplex.ProtocolVersion;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
/**
* Represents a disguise that can "mutate" from one entity type to another.
*/
public abstract class DisguiseMutable extends DisguiseCreature
{
public DisguiseMutable(EntityType disguiseType, Entity entity)
{
super(disguiseType, entity);
}
protected void mutate()
{
// if (!_spawnedIn)
// return;
Predicate<Integer> pred = v -> v >= ProtocolVersion.v1_11;
sendToWatchers(pred, this::getDestroyPacket);
sendToWatchers(pred, this::getSpawnPacket);
sendToWatchers(pred, this::getMetadataPacket);
}
private Packet getDestroyPacket()
{
return new PacketPlayOutEntityDestroy(new int[] { getEntityId() });
}
protected abstract int getTypeId(boolean separate);
}

View File

@ -2,11 +2,16 @@ package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_8_R3.EntitySkeleton;
import org.bukkit.entity.*;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Skeleton.SkeletonType;
public class DisguiseSkeleton extends DisguiseMonster
public class DisguiseSkeleton extends DisguiseMutable
{
private static final int SKELETON_ID = 51;
private static final int WITHER_SKELETON_ID = 5;
private SkeletonType type = SkeletonType.NORMAL;
public DisguiseSkeleton(org.bukkit.entity.Entity entity)
{
super(EntityType.SKELETON, entity);
@ -17,15 +22,24 @@ public class DisguiseSkeleton extends DisguiseMonster
public void SetSkeletonType(SkeletonType skeletonType)
{
DataWatcher.watch(13, Byte.valueOf((byte) skeletonType.getId()), EntitySkeleton.META_TYPE, skeletonType.getId());
this.type = skeletonType;
mutate();
}
public int GetSkeletonType()
public SkeletonType getSkeletonType()
{
return DataWatcher.getByte(13);
return type;
}
protected String getHurtSound()
{
return "mob.skeleton.hurt";
}
// 1.11 and up require separate entity ids
@Override
protected int getTypeId(boolean separate)
{
return separate && type == SkeletonType.WITHER ? WITHER_SKELETON_ID : SKELETON_ID;
}
}

View File

@ -4,14 +4,26 @@ import net.minecraft.server.v1_8_R3.EntitySlime;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
public class DisguiseSlime extends DisguiseInsentient
/**
* Slimes have an odd type hierarchy, but they're essentially creatures as far as disguises are concerned.
*/
public class DisguiseSlime extends DisguiseCreature
{
public DisguiseSlime(org.bukkit.entity.Entity entity)
public DisguiseSlime(Entity entity)
{
super(EntityType.SLIME, entity);
this(EntityType.SLIME, entity);
}
/**
* For magma cubes
*/
protected DisguiseSlime(EntityType type, Entity entity)
{
super(type, entity);
DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1);
}
@ -25,63 +37,6 @@ public class DisguiseSlime extends DisguiseInsentient
return DataWatcher.getByte(16);
}
public Packet getSpawnPacket()
{
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = getEntity().getId();
packet.b = (byte) 55;
packet.c = (int) MathHelper.floor(getEntity().locX * 32D);
packet.d = (int) MathHelper.floor(getEntity().locY * 32.0D);
packet.e = (int) MathHelper.floor(getEntity().locZ * 32D);
packet.i = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (getEntity().pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F));
packet.uuid = getEntity().getUniqueID();
double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
if (var4 < -var2)
{
var4 = -var2;
}
if (var6 < -var2)
{
var6 = -var2;
}
if (var8 < -var2)
{
var8 = -var2;
}
if (var4 > var2)
{
var4 = var2;
}
if (var6 > var2)
{
var6 = var2;
}
if (var8 > var2)
{
var8 = var2;
}
packet.f = (int) (var4 * 8000.0D);
packet.g = (int) (var6 * 8000.0D);
packet.h = (int) (var8 * 8000.0D);
packet.l = DataWatcher;
packet.m = DataWatcher.b();
return packet;
}
protected String getHurtSound()
{
return "mob.slime." + (GetSize() > 1 ? "big" : "small");

View File

@ -1,5 +1,6 @@
package mineplex.core.monitor;
import java.lang.reflect.Field;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
@ -8,6 +9,8 @@ import java.util.stream.Collectors;
import javax.print.attribute.IntegerSyntax;
import com.mineplex.ProtocolVersion;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
@ -25,14 +28,37 @@ import mineplex.core.common.util.UtilServer;
*/
public class VersionsCommand extends CommandBase<LagMeter>
{
private static Map<Integer, String> PRETTY_VERSIONS;
public VersionsCommand(LagMeter plugin)
{
super(plugin, Rank.DEVELOPER, "versions", "getver");
}
private void ensureVersions()
{
if (PRETTY_VERSIONS == null)
{
PRETTY_VERSIONS = new HashMap<>();
for (Field field : ProtocolVersion.class.getFields())
{
try
{
int protocol = field.getInt(null);
String version = field.getName().replace("v", "").replace("_", ".");
version += " (" + protocol + ")";
PRETTY_VERSIONS.put(protocol, version);
} catch (ReflectiveOperationException ex) { }
}
}
}
@Override
public void Execute(Player caller, String[] args)
{
ensureVersions();
if (args.length == 0)
{
Map<Integer, Integer> versions = new HashMap<>();
@ -52,8 +78,11 @@ public class VersionsCommand extends CommandBase<LagMeter>
.collect(Collectors.toList());
for (Map.Entry<Integer, Integer> entry : sorted)
{
int protocol = entry.getKey();
String pretty = PRETTY_VERSIONS.computeIfAbsent(protocol, x -> Integer.toString(protocol));
UtilPlayer.message(caller,
F.main("Version", C.cYellow + entry.getKey() + C.cGray + ": " + C.cGreen
F.main("Version", C.cYellow + pretty + C.cGray + ": " + C.cGreen
+ entry.getValue() + C.cGray + " players"));
}
} else if (args.length == 1)
@ -62,9 +91,12 @@ public class VersionsCommand extends CommandBase<LagMeter>
if (!players.isEmpty())
{
Player player = players.get(0);
int protocol = ((CraftPlayer) player).getHandle().getProtocol();
String pretty = PRETTY_VERSIONS.computeIfAbsent(protocol, x -> Integer.toString(protocol));
UtilPlayer.message(caller,
F.main("Version", C.cYellow + player.getName() + C.cGray + " is on protocol "
+ C.cGreen + ((CraftPlayer) player).getHandle().getProtocol()));
F.main("Version", C.cYellow + player.getName() + C.cGray + " is on version "
+ C.cGreen + pretty));
}
} else
{

View File

@ -108,20 +108,19 @@ public class ClansBanRepository extends RepositoryBase
{
// Yes, this is garbage.
// Yes, it would be better implemented in a functional language.
return CompletableFuture.supplyAsync(() -> Managers.get(CoreClientManager.class).loadUUIDFromDB(name))
.thenCompose(uuid ->
{
if (uuid == null)
{
CompletableFuture<Optional<ClansBanClient>> future = new CompletableFuture<>();
future.complete(Optional.empty());
return future;
}
else
{
return loadClient(uuid).thenApply(Optional::of);
}
});
return CompletableFuture.supplyAsync(() -> Managers.get(CoreClientManager.class).loadUUIDFromDB(name)).thenCompose(uuid ->
{
if (uuid == null)
{
CompletableFuture<Optional<ClansBanClient>> future = new CompletableFuture<>();
future.complete(Optional.empty());
return future;
}
else
{
return loadClient(uuid).thenApply(Optional::of);
}
});
}
public void removeBan(ClansBan ban)

View File

@ -268,7 +268,7 @@ public class MountManager extends MiniDbClientPlugin<MountOwnerData>
{
if (UtilEnt.GetMetadata(entry.getKey(), "DISMOUNT_TIME") != null)
{
Long dismount = (Long) UtilEnt.GetMetadata(entry.getKey(), "DISMOUNT_TIME");
Long dismount = UtilEnt.GetMetadata(entry.getKey(), "DISMOUNT_TIME");
if (UtilTime.elapsed(dismount.longValue(), MAX_TIME_DISMOUNTED))
{
mountIterator.remove();

View File

@ -1,9 +1,13 @@
package mineplex.game.clans.items.legendaries;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansUtility;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class DemonicScythe extends LegendaryItem
@ -21,14 +25,48 @@ public class DemonicScythe extends LegendaryItem
C.cYellow + "Attack" + C.cWhite + " to use" + C.cGreen + " Leach Health",
}, Material.RECORD_8);
}
private boolean isTeammate(Entity attacker, Entity defender)
{
if (attacker == null || defender == null) return false;
// Don't count attacks towards teammates
if (attacker instanceof Player && defender instanceof Player)
{
ClansUtility.ClanRelation relation = ClansManager.getInstance().getRelation((Player) attacker, (Player) defender);
if (relation == ClansUtility.ClanRelation.ALLY
|| relation == ClansUtility.ClanRelation.SAFE
|| relation == ClansUtility.ClanRelation.SELF)
{
return true;
}
}
return false;
}
@Override
public void onAttack(CustomDamageEvent event, Player wielder)
{
if (!event.isCancelled())
if (event.isCancelled())
{
event.AddMod("Scythe of the Fallen Lord", 8);
wielder.setHealth(Math.min(wielder.getMaxHealth(), wielder.getHealth() + 2));
return;
}
if (ClansManager.getInstance().isSafe(wielder))
{
return;
}
if (event.GetDamageeEntity() instanceof Player && ClansManager.getInstance().isSafe(event.GetDamageePlayer()))
{
return;
}
if (wielder.getGameMode().equals(GameMode.CREATIVE))
{
return;
}
if (isTeammate(wielder, event.GetDamageeEntity()))
{
return;
}
event.AddMod("Scythe of the Fallen Lord", 8);
wielder.setHealth(Math.min(wielder.getMaxHealth(), wielder.getHealth() + 2));
}
}

View File

@ -12,6 +12,7 @@ public class SalesAnnouncementDeleteCommand extends ServerCommand
{
_id = id;
_from = from;
_clans = clans;
}
public Integer getId()

View File

@ -66,7 +66,7 @@ public class SalesAnnouncementManager extends MiniPlugin
{
if (forceRemoveFromList)
{
_data.remove(data);
_data.remove(data.getId());
}
_repo.deleteAnnouncement(data, () ->
{

View File

@ -915,7 +915,9 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
@EventHandler
public void ignoreVelocity(PlayerVelocityEvent event)
{
if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH) && _preferences.get(event.getPlayer()).isActive(Preference.IGNORE_VELOCITY))
Player player = event.getPlayer();
if (_clientManager.Get(player).GetRank().has(Rank.TWITCH) && _preferences.get(player).isActive(Preference.IGNORE_VELOCITY) && !getJumpManager().isDoubleJumping(player))
{
event.setCancelled(true);
}

View File

@ -2,34 +2,37 @@ package mineplex.hub.modules;
import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.preferences.Preference;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.visibility.VisibilityManager;
import mineplex.hub.HubManager;
import org.bukkit.Material;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class HubVisibilityManager extends MiniPlugin
{
private static final String JUST_SPAWNED_FLAG = "JustSpawned";
private static final int HIDE_SPAWN_RADIUS_SQUARED = 4;
public HubManager Manager;
private HashMap<Player, Integer> _particle = new HashMap<Player, Integer>();
private HashSet<Player> _hiddenPlayers = new HashSet<Player>();
private final Set<Player> _hiddenPlayers = new HashSet<>();
private final Map<Player, Integer> _nextShownPlayer = new HashMap<>();
public HubVisibilityManager(HubManager manager)
{
@ -48,87 +51,110 @@ public class HubVisibilityManager extends MiniPlugin
}
@EventHandler
public void removeHiddenPlayerOnQuit(PlayerQuitEvent event)
public void playerQuit(PlayerQuitEvent event)
{
_hiddenPlayers.remove(event.getPlayer());
Player player = event.getPlayer();
_hiddenPlayers.remove(player);
_nextShownPlayer.remove(player);
}
@EventHandler
public void updateVisibility(UpdateEvent event)
public void playerJoin(PlayerJoinEvent event)
{
UtilEnt.addFlag(event.getPlayer(), JUST_SPAWNED_FLAG);
}
@EventHandler
public void updateVisibility0(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
for (Player player : UtilServer.getPlayers())
{
Rank rank = Manager.GetClients().Get(player).GetRank();
boolean hideMe = UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0
|| (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) &&
(rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH))
|| _hiddenPlayers.contains(player);
return;
}
for (Player other : UtilServer.getPlayers())
Collection<? extends Player> online = UtilServer.getPlayersCollection();
for (Player subject : online)
{
boolean hideMe = shouldHide(subject);
for (Player perspective : online)
{
boolean localHideMe = hideMe;
if (player.equals(other))
boolean closeToSpawn = closeToSpawn(perspective);
boolean justSpawned = UtilEnt.hasFlag(perspective, JUST_SPAWNED_FLAG);
// Don't hide themselves OR they are currently being sent player data one by one
if (perspective.equals(subject) || _nextShownPlayer.containsKey(perspective))
{
continue;
if (Manager.GetClients().Get(other).GetRank().has(Rank.MODERATOR))
localHideMe = UtilMath.offset2d(other.getLocation(), Manager.GetSpawn()) == 0;
if (localHideMe || !Manager.getPreferences().get(other).isActive(Preference.SHOW_PLAYERS))
{
VisibilityManager.Instance.setVisibility(player, false, other);
} else
{
VisibilityManager.Instance.setVisibility(player, true, other);
}
// Player has just spawned flag however they are no longer near the spawn
if (justSpawned && !closeToSpawn)
{
UtilEnt.removeFlag(perspective, JUST_SPAWNED_FLAG);
_nextShownPlayer.put(perspective, 0);
}
// Has preference AND is not close to the spawn AND has not just spawned
boolean showOthers = Manager.getPreferences().get(perspective).isActive(Preference.SHOW_PLAYERS) && (!closeToSpawn || !justSpawned);
VisibilityManager.Instance.setVisibility(subject, !hideMe && showOthers, perspective);
}
}
}
@EventHandler
public void ParticleSwap(PlayerInteractEvent event)
public void updateVisibility1(UpdateEvent event)
{
Player player = event.getPlayer();
if (!player.isOp())
return;
if (!UtilGear.isMat(player.getItemInHand(), Material.GOLD_NUGGET))
return;
int past = 0;
if (_particle.containsKey(player))
past = _particle.get(player);
if (UtilEvent.isAction(event, ActionType.R))
if (event.getType() != UpdateType.FASTEST)
{
past = (past+1)%ParticleType.values().length;
}
else if (UtilEvent.isAction(event, ActionType.L))
{
past = past - 1;
if (past < 0)
past = ParticleType.values().length - 1;
return;
}
_particle.put(player, past);
Player[] online = UtilServer.getPlayers();
Iterator<Player> iterator = _nextShownPlayer.keySet().iterator();
player.sendMessage("Particle: " + ParticleType.values()[past]);
while (iterator.hasNext())
{
Player perspective = iterator.next();
int index = _nextShownPlayer.get(perspective);
if (perspective == null || !perspective.isOnline() || online.length <= index)
{
iterator.remove();
continue;
}
Player subject = online[index];
if (!perspective.equals(subject) && !shouldHide(subject))
{
VisibilityManager.Instance.setVisibility(subject, true, perspective);
}
_nextShownPlayer.put(perspective, ++index);
}
}
@EventHandler
public void Particles(UpdateEvent event)
private boolean shouldHide(Player subject)
{
if (event.getType() != UpdateType.FAST)
return;
Rank subjectRank = Manager.GetClients().Get(subject).GetRank();
for (Player player : _particle.keySet())
{
UtilParticle.PlayParticle(ParticleType.values()[_particle.get(player)],
player.getLocation().add(1, 1, 0), 0f, 0f, 0f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
return
// Close to spawn
closeToSpawn(subject) ||
// Enabled Invisibility
Manager.getPreferences().get(subject).isActive(Preference.INVISIBILITY) &&
// AND Is Moderator+ OR Youtube OR Twitch
(subjectRank.has(Rank.MODERATOR) || subjectRank == Rank.YOUTUBE || subjectRank == Rank.TWITCH) ||
// OR Player has been explicitly hidden
_hiddenPlayers.contains(subject);
}
private boolean closeToSpawn(Player player)
{
return UtilMath.offset2dSquared(player.getLocation(), Manager.GetSpawn()) < HIDE_SPAWN_RADIUS_SQUARED;
}
}

View File

@ -1,16 +1,5 @@
package mineplex.hub.modules;
import java.util.HashSet;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.util.Vector;
import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilAction;
@ -27,9 +16,20 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.util.Vector;
import java.util.HashSet;
public class JumpManager extends MiniPlugin
{
public HubManager Manager;
private HashSet<String> _preparedDoubleJump = new HashSet<>();
@ -45,11 +45,10 @@ public class JumpManager extends MiniPlugin
{
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE)
return;
if (player.isFlying())
if (player.getGameMode() == GameMode.CREATIVE || player.isFlying())
{
return;
}
Rank rank = Manager.GetClients().Get(player).GetRank();
if (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH))
@ -75,11 +74,11 @@ public class JumpManager extends MiniPlugin
//Velocity
_preparedDoubleJump.add(player.getName());
UtilAction.velocity(player, vec, 1.4, false, 0, 0.2, 1, true);
//Sound
player.playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0);
Recharge.Instance.useForce(player, "Double Jump", 500);
Recharge.Instance.useForce(player, "Double Jump", 250);
}
@EventHandler
@ -129,4 +128,9 @@ public class JumpManager extends MiniPlugin
{
return _preparedDoubleJump.contains(player.getName());
}
public boolean isDoubleJumping(Player player)
{
return !Recharge.Instance.usable(player, "Double Jump");
}
}

View File

@ -12,6 +12,7 @@ public class SalesAnnouncementDeleteCommand extends ServerCommand
{
_id = id;
_from = from;
_clans = clans;
}
public Integer getId()

View File

@ -66,7 +66,7 @@ public class SalesAnnouncementManager extends MiniPlugin
{
if (forceRemoveFromList)
{
_data.remove(data);
_data.remove(data.getId());
}
_repo.deleteAnnouncement(data, () ->
{

View File

@ -16,6 +16,8 @@ public enum GameType
Build("Master Builders"),
BuildMavericks("Mavericks Master Builders"),
CastleSiege("Castle Siege"),
CastleAssault("Castle Assault"),
CastleAssaultTDM("Castle Assault TDM"),
ChampionsTDM("Champions TDM", "Champions"),
ChampionsDominate("Champions Domination", "Champions"),
ChampionsCTF("Champions CTF", "Champions"),

View File

@ -1215,13 +1215,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
UtilServer.getServer().getPluginManager().callEvent(event);
// Re-Give Kit
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
{
public void run()
{
GetKit(player).ApplyKit(player);
}
}, 0);
Manager.runSyncLater(() -> GetKit(player).ApplyKit(player), 0);
}
public void RespawnPlayerTeleport(Player player)

View File

@ -14,6 +14,7 @@ import org.bukkit.ChatColor;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest;
@ -56,7 +57,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Dispenser;
import org.bukkit.material.MaterialData;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.util.Vector;
import mineplex.core.Managers;
@ -97,6 +97,7 @@ import nautilus.game.arcade.game.games.castleassault.data.KillStreakData;
import nautilus.game.arcade.game.games.castleassault.data.ObjectiveTNTSpawner;
import nautilus.game.arcade.game.games.castleassault.data.TeamCrystal;
import nautilus.game.arcade.game.games.castleassault.data.TeamKing;
import nautilus.game.arcade.game.games.castleassault.kits.KitAlchemist;
import nautilus.game.arcade.game.games.castleassault.kits.KitArcher;
import nautilus.game.arcade.game.games.castleassault.kits.KitDemolitionist;
import nautilus.game.arcade.game.games.castleassault.kits.KitFighter;
@ -143,7 +144,7 @@ public class CastleAssault extends TeamGame
super(manager, GameType.CastleAssault,
new Kit[]
{
//new KitAlchemist(manager),
new KitAlchemist(manager),
new KitArcher(manager),
new KitDemolitionist(manager),
//new KitEnchanter(manager),
@ -233,7 +234,7 @@ public class CastleAssault extends TeamGame
private void generateLoot()
{
{
_rangedGear.addLoot(new ItemStack(Material.BOW), 3);
_rangedGear.addLoot(new ItemStack(Material.EGG), 3, 5, 9);
_rangedGear.addLoot(Material.ARROW, 3, 8, 16);
}
{
@ -246,7 +247,6 @@ public class CastleAssault extends TeamGame
}
{
_potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8193).build(), 2);
_potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8195).build(), 2);
}
{
_miscGear.addLoot(new ItemStack(Material.ENDER_PEARL), 2);
@ -956,7 +956,8 @@ public class CastleAssault extends TeamGame
float radius = event.getRadius();
event.setRadius(0f);
Player player = UtilPlayer.searchExact(((MetadataValue)UtilEnt.GetMetadata(event.getEntity(), "THROWER")).asString());
String thrower = UtilEnt.GetMetadata(event.getEntity(), "THROWER");
Player player = UtilPlayer.searchExact(thrower);
if (player == null)
{
return;
@ -1003,7 +1004,7 @@ public class CastleAssault extends TeamGame
}
blastProtEPF = Math.min(blastProtEPF, 20);
double damage = 8 * mult;
double damage = 10 * mult;
damage = damage * (1 - (blastProtEPF / 25));
double knockbackReduction = 1 - (highestBlastProt * 0.15);
@ -1194,6 +1195,7 @@ public class CastleAssault extends TeamGame
{
if (Recharge.Instance.use(alert, "KingDamageAlert", 5000, false, false))
{
alert.playSound(alert.getLocation(), Sound.ANVIL_LAND, 10, 3);
alert.sendMessage(king.getName(true) + " is under attack!");
}
}

View File

@ -46,7 +46,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Dispenser;
import org.bukkit.material.MaterialData;
import org.bukkit.metadata.MetadataValue;
import mineplex.core.Managers;
import mineplex.core.common.Pair;
@ -807,7 +806,8 @@ public class CastleAssaultTDM extends TeamGame
float radius = event.getRadius();
event.setRadius(0f);
Player player = UtilPlayer.searchExact(((MetadataValue)UtilEnt.GetMetadata(event.getEntity(), "THROWER")).asString());
String thrower = UtilEnt.GetMetadata(event.getEntity(), "THROWER");
Player player = UtilPlayer.searchExact(thrower);
if (player == null)
{
return;

View File

@ -2,7 +2,12 @@ package nautilus.game.arcade.game.games.castleassault.kits;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
@ -12,21 +17,130 @@ public class KitAlchemist extends KitPlayer
{
public KitAlchemist(ArcadeManager manager)
{
super(manager, "Alchemist", KitAvailability.Free, new String[] {}, new Perk[] {}, Material.POTION);
super(manager, "Alchemist", KitAvailability.Free,
new String[]
{
C.cWhiteB + "Starting Kit:",
C.cGray + "Diamond Sword",
C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots",
C.cGray + "Speed I Potion",
C.cGreenB + "Passive Ability:",
C.cGreen + "Netherborne: Permanent Fire Resistance"
},
new Perk[][]
{
new Perk[] {},
new Perk[] {},
new Perk[] {},
new Perk[] {},
new Perk[] {},
new Perk[] {}
},
new String[][]
{
{
C.cGray + "Receive a Regeneration II Potion"
},
{
C.cGray + "Obtain a time extension on your Speed I Potion"
},
{
C.cGray + "Obtain a time extension on your Regeneration II Potion"
},
{
C.cGray + "Receive a Resistance I Potion"
},
{
C.cGray + "Obtain a time extension on your Resistance I Potion"
}
},
Material.POTION);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().setItem(0, new ItemBuilder(Material.IRON_SWORD).setUnbreakable(true).build());
player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setData((short)8194).build());
player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setData((short)8193).build());
player.getInventory().setHelmet(new ItemBuilder(Material.IRON_HELMET).setUnbreakable(true).build());
player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setUnbreakable(true).build());
player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setUnbreakable(true).build());
player.getInventory().setBoots(new ItemBuilder(Material.IRON_BOOTS).setUnbreakable(true).build());
giveRegeneration(player);
player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 100000, 0));
player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
int level = getUpgradeLevel(player.getUniqueId());
if (level == 0)
{
player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8194).build());
}
else if (level == 1)
{
player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8194).build());
player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8225).build());
}
else if (level == 2)
{
player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8258).build());
player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8225).build());
}
else if (level == 3)
{
player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8258).build());
player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8289).build());
}
else if (level == 4)
{
player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8258).build());
player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8289).build());
ItemStack item = new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8205).build();
PotionMeta pm = (PotionMeta) item.getItemMeta();
pm.clearCustomEffects();
pm.addCustomEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20 * 60, 0), true);
item.setItemMeta(pm);
player.getInventory().addItem(item);
}
else if (level == 5)
{
player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8258).build());
player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8289).build());
ItemStack item = new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8205).build();
PotionMeta pm = (PotionMeta) item.getItemMeta();
pm.clearCustomEffects();
pm.addCustomEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20 * 130, 0), true);
item.setItemMeta(pm);
player.getInventory().addItem(item);
}
player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
}
@Override
public void awardKillStreak(Player player, int streak) {}
public void awardKillStreak(Player player, int streak)
{
if (streak == 2)
{
player.sendMessage(C.cRed + "You have received a Slowness I Splash Potion as a Kill Streak Reward!");
player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)16394).build());
}
else if (streak == 4)
{
player.sendMessage(C.cRed + "You have received a Weakness I Splash Potion as a Kill Streak Reward!");
player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)16392).build());
}
else if (streak == 6)
{
player.sendMessage(C.cRed + "You have received 4 Instant Damage II Splash Potions as a Kill Streak Reward!");
player.getInventory().addItem(new ItemBuilder(Material.POTION, 4).setData((short)16428).build());
}
else if (streak == 8)
{
player.sendMessage(C.cRed + "You have received a Regeneration III Potion as a Kill Streak Reward!");
ItemStack item = new ItemBuilder(Material.POTION).setData((short)8193).build();
PotionMeta pm = (PotionMeta) item.getItemMeta();
pm.clearCustomEffects();
pm.addCustomEffect(new PotionEffect(PotionEffectType.REGENERATION, 20 * 10, 2), true);
item.setItemMeta(pm);
player.getInventory().addItem(item);
}
}
}

View File

@ -20,21 +20,22 @@ public class KitArcher extends KitPlayer
super(manager, "Archer", KitAvailability.Free,
new String[]
{
C.cGrayB + "Starting Kit:",
C.cWhiteB + "Starting Kit:",
C.cGray + "Diamond Sword",
C.cGray + "Bow",
C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots",
C.cGray + "10 Fletched Arrows",
C.cGreenB + "Starting Ability:",
C.cGreen + "Fletcher: Obtain 1 Fletched Arrow every 7 seconds (Max of 10)"
C.cGreen + "Fletcher: Obtain 1 Fletched Arrow every 6 seconds (Max of 10)"
},
new Perk[][]
{
new Perk[] {new PerkFletcher(7, 10, true, false)},
new Perk[] {new PerkFletcher(7, 16, true, false)},
new Perk[] {new PerkFletcher(7, 24, true, false)},
new Perk[] {new PerkFletcher(7, 32, true, false)},
new Perk[] {new PerkFletcher(7, 32, true, false)},
new Perk[] {new PerkFletcher(7, 32, true, false)}
new Perk[] {new PerkFletcher(6, 10, true, false)},
new Perk[] {new PerkFletcher(6, 16, true, false)},
new Perk[] {new PerkFletcher(6, 24, true, false)},
new Perk[] {new PerkFletcher(6, 32, true, false)},
new Perk[] {new PerkFletcher(6, 32, true, false)},
new Perk[] {new PerkFletcher(6, 32, true, false)}
},
new String[][]
{
@ -43,7 +44,8 @@ public class KitArcher extends KitPlayer
},
{
C.cGray + "Increase maximum and starting amount of Fletched Arrows to 24",
C.cGray + "Obtain a Power I Enchantment on your Bow"
C.cGray + "Obtain a Power I Enchantment on your Bow",
C.cGray + "Receive a Feather Falling II Enchantment on your Diamond Boots"
},
{
C.cGray + "Increase maximum and starting amount of Fletched Arrows to 32",
@ -100,10 +102,14 @@ public class KitArcher extends KitPlayer
player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
if (level < 5)
if (level < 2)
{
player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
}
else if (level < 5)
{
player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_FALL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
}
else
{
player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_FALL, 4).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
@ -115,23 +121,24 @@ public class KitArcher extends KitPlayer
{
if (streak == 2)
{
player.sendMessage(C.cRedB + "You have received 8 Arrows as a Kill Streak Reward!");
player.sendMessage(C.cRed + "You have received 8 Arrows as a Kill Streak Reward!");
player.getInventory().addItem(new ItemBuilder(Material.ARROW).setAmount(8).setTitle(F.item("Fletched Arrow")).build());
}
else if (streak == 4)
{
player.sendMessage(C.cRedB + "You have received 12 Arrows as a Kill Streak Reward!");
player.sendMessage(C.cRed + "You have received 12 Arrows as a Kill Streak Reward!");
player.getInventory().addItem(new ItemBuilder(Material.ARROW).setAmount(12).setTitle(F.item("Fletched Arrow")).build());
}
else if (streak == 6)
{
player.sendMessage(C.cRedB + "You have received a Punch I book as a Kill Streak Reward!");
player.sendMessage(C.cRed + "You have received a Punch I book as a Kill Streak Reward!");
player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_KNOCKBACK, 1).build());
}
else if (streak == 8)
{
player.sendMessage(C.cRedB + "You have received 32 Arrows as a Kill Streak Reward!");
player.sendMessage(C.cRed + "You have received 32 Arrows and a Flame I book as a Kill Streak Reward!");
player.getInventory().addItem(new ItemBuilder(Material.ARROW).setAmount(32).setTitle(F.item("Fletched Arrow")).build());
player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_FIRE, 1).build());
}
}
}

View File

@ -19,7 +19,7 @@ public class KitDemolitionist extends KitPlayer
super(manager, "Demolitionist", KitAvailability.Free,
new String[]
{
C.cGrayB + "Starting Kit:",
C.cWhiteB + "Starting Kit:",
C.cGray + "Diamond Sword, Flint and Steel",
C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots",
C.cGray + "Blast Protection IV on all Armor",
@ -130,23 +130,24 @@ public class KitDemolitionist extends KitPlayer
{
if (streak == 2)
{
player.sendMessage(C.cRedB + "You have received 2 Throwing TNT as a Kill Streak Reward!");
player.sendMessage(C.cRed + "You have received 2 Throwing TNT as a Kill Streak Reward!");
player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(2).build());
}
else if (streak == 4)
{
player.sendMessage(C.cRedB + "You have received 3 Throwing TNT as a Kill Streak Reward!");
player.sendMessage(C.cRed + "You have received 3 Throwing TNT as a Kill Streak Reward!");
player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(3).build());
}
else if (streak == 6)
{
player.sendMessage(C.cRedB + "You have received 4 Throwing TNT as a Kill Streak Reward!");
player.sendMessage(C.cRed + "You have received 4 Throwing TNT as a Kill Streak Reward!");
player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(4).build());
}
else if (streak == 8)
{
player.sendMessage(C.cRedB + "You have received 5 Throwing TNT as a Kill Streak Reward!");
player.sendMessage(C.cRed + "You have received 5 Throwing TNT and a 30-Use Flint and Steel as a Kill Streak Reward!");
player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(5).build());
player.getInventory().addItem(new ItemBuilder(Material.FLINT_AND_STEEL).setData((short) (Material.FLINT_AND_STEEL.getMaxDurability() - 30)).build());
}
}
}

View File

@ -18,11 +18,11 @@ public class KitFighter extends KitPlayer
super(manager, "Fighter", KitAvailability.Free,
new String[]
{
C.cGrayB + "Starting Kit:",
C.cWhiteB + "Starting Kit:",
C.cGray + "Diamond Sword",
C.cGray + "1 Golden Applegate",
C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots",
C.cGreenB + "Passive Ability:",
C.cGreenB + "Starting Ability:",
C.cGreen + "Bloodlust: Deal half a heart more damage for 3 seconds after killing an enemy"
},
new Perk[][]
@ -32,7 +32,7 @@ public class KitFighter extends KitPlayer
new Perk[] {new PerkBloodlust(1, 3)},
new Perk[] {new PerkBloodlust(1, 3)},
new Perk[] {new PerkBloodlust(1, 3)},
new Perk[] {new PerkBloodlust(1, 3)}
new Perk[] {new PerkBloodlust(1, 5)}
},
new String[][]
{
@ -50,7 +50,7 @@ public class KitFighter extends KitPlayer
C.cGray + "Increase starting amount of Golden Applegates to 3"
},
{
C.cGray + "Obtain a Sharpness II Enchantment on your Diamond Sword"
C.cGray + "Increase duration of Bloodlust to 5 seconds"
}
},
Material.DIAMOND_SWORD);
@ -92,7 +92,7 @@ public class KitFighter extends KitPlayer
}
else if (level == 5)
{
player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setItem(1, new ItemBuilder(Material.FISHING_ROD).addEnchantment(Enchantment.KNOCKBACK, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setItem(2, new ItemBuilder(Material.GOLDEN_APPLE).setAmount(3).setTitle(C.cPurple + "Golden Applegate").build());
}
@ -108,22 +108,22 @@ public class KitFighter extends KitPlayer
{
if (streak == 2)
{
player.sendMessage(C.cRedB + "You have received a Golden Applegate as a Kill Streak Reward!");
player.sendMessage(C.cRed + "You have received a Golden Applegate as a Kill Streak Reward!");
player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setAmount(1).setTitle(C.cPurple + "Golden Applegate").build());
}
else if (streak == 4)
{
player.sendMessage(C.cRedB + "You have received a Splash Healing II Potion as a Kill Streak Reward!");
player.sendMessage(C.cRed + "You have received a Healing II Splash Potion as a Kill Streak Reward!");
player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)16421).build());
}
else if (streak == 6)
{
player.sendMessage(C.cRedB + "You have received a Speed II Potion as a Kill Streak Reward!");
player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)8290).build());
player.sendMessage(C.cRed + "You have received a Speed II Potion as a Kill Streak Reward!");
player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)8226).build());
}
else if (streak == 8)
{
player.sendMessage(C.cRedB + "You have received a Fire Aspect I book as a Kill Streak Reward!");
player.sendMessage(C.cRed + "You have received a Fire Aspect I book as a Kill Streak Reward!");
player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.FIRE_ASPECT, 1).build());
}
}

View File

@ -39,7 +39,9 @@ public abstract class KitPlayer extends ProgressingKit
protected void giveRegeneration(Player player)
{
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20 * 5, 3));
player.getActivePotionEffects().forEach(p -> player.removePotionEffect(p.getType()));
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20 * 8, 4));
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20 * 8, 3));
}
@Override

View File

@ -22,10 +22,10 @@ public class KitTank extends KitPlayer
super(manager, "Tank", KitAvailability.Free,
new String[]
{
C.cGrayB + "Starting Kit:",
C.cWhiteB + "Starting Kit:",
C.cGray + "Diamond Sword",
C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots",
C.cGray + "Protection I on Iron Armor"
C.cGray + "Protection I on Iron Chestplace"
},
new Perk[][]
{
@ -39,21 +39,19 @@ public class KitTank extends KitPlayer
new String[][]
{
{
C.cGray + "Obtain a Protection II Enchantment on your Iron Armor"
C.cGray + "Obtain a Protection I Enchantment on your Iron Leggings"
},
{
C.cGray + "Obtain a Protection II Enchantment on your Iron Chestplate"
},
{
C.cGray + "Obtain a Protection II Enchantment on your Iron Leggings"
},
{
C.cGray + "Obtain a Protection I Enchantment on your Diamond Helmet"
},
{
C.cGray + "Obtain a Protection I Enchantment on your Diamond Boots"
},
{
C.cGray + "Obtain a Protection II Enchantment on your Diamond Helmet",
C.cGray + "Obtain a Protection II Enchantment on your Diamond Boots"
},
{
C.cGray + "Obtain a Protection III Enchantment on your Iron Chestplate",
C.cGray + "Obtain a Protection III Enchantment on your Iron Leggings"
}
},
Material.DIAMOND_CHESTPLATE);
@ -71,44 +69,44 @@ public class KitTank extends KitPlayer
{
player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
}
else if (level == 1)
{
player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
}
else if (level == 2)
{
player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
}
else if (level == 3)
{
player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
}
else if (level == 2)
else if (level == 4)
{
player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
}
else if (level == 3)
else if (level == 5)
{
player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
}
else if (level == 4)
{
player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
}
else if (level == 5)
{
player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build());
}
}
@Override
@ -116,17 +114,17 @@ public class KitTank extends KitPlayer
{
if (streak == 2)
{
player.sendMessage(C.cRedB + "You have received a Golden Applegate as a Kill Streak Reward!");
player.sendMessage(C.cRed + "You have received a Golden Applegate as a Kill Streak Reward!");
player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setAmount(1).setTitle(C.cPurple + "Golden Applegate").build());
}
else if (streak == 4)
{
player.sendMessage(C.cRedB + "You have received a Regeneration II Potion as a Kill Streak Reward!");
player.sendMessage(C.cRed + "You have received a Regeneration II Potion as a Kill Streak Reward!");
player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)8289).build());
}
else if (streak == 6)
{
player.sendMessage(C.cRedB + "You have received a Resistance I Potion as a Kill Streak Reward!");
player.sendMessage(C.cRed + "You have received a Resistance I Potion as a Kill Streak Reward!");
ItemStack item = new ItemBuilder(Material.POTION).setData((short)8205).build();
PotionMeta pm = (PotionMeta) item.getItemMeta();
pm.clearCustomEffects();
@ -136,7 +134,7 @@ public class KitTank extends KitPlayer
}
else if (streak == 8)
{
player.sendMessage(C.cRedB + "You have received a Thorns II book as a Kill Streak Reward!");
player.sendMessage(C.cRed + "You have received a Thorns II book as a Kill Streak Reward!");
player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.THORNS, 2).build());
}
}

View File

@ -27,7 +27,7 @@ public class PerkBloodlust extends Perk
public PerkBloodlust(double damageBoost, int duration)
{
super("Bloodlust",
new String[]
new String[]
{
C.cGray + "Deal an extra " + (damageBoost / 2) + " hearts of damage for " + duration + " seconds after a kill.",
}
@ -92,7 +92,7 @@ public class PerkBloodlust extends Perk
Bukkit.getScheduler().cancelTask(id.intValue());
}
player.sendMessage(C.cRed + "You are now channeling bloodlust for 3 seconds!");
player.sendMessage(C.cRed + "You are now channeling bloodlust for " + _duration + " seconds!");
_lusting.put(player, Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), () -> _lusting.remove(player), _duration * 20).getTaskId());
}

View File

@ -44,11 +44,13 @@ import nautilus.game.arcade.game.games.moba.kit.hp.HPManager;
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.modes.MobaMapType;
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;
import nautilus.game.arcade.game.games.moba.training.MobaTraining;
import nautilus.game.arcade.game.games.moba.util.MobaUtil;
import nautilus.game.arcade.game.modules.CustomScoreboardModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
@ -195,9 +197,6 @@ public class Moba extends TeamGame
@Override
public void ParseData()
{
// Register all "Managers"
_listeners.forEach(UtilServer::RegisterEvents);
// Make all spawns face the center of the map
for (List<Location> locations : WorldData.SpawnLocs.values())
{
@ -206,49 +205,72 @@ public class Moba extends TeamGame
SpectatorSpawn = WorldData.GetCustomLocs("CENTER").get(0);
// Leaderboards
if (Manager.IsRewardStats())
if (!(this instanceof MobaTraining))
{
if (Manager.GetLobby() instanceof NewGameLobbyManager)
MobaMapType mapType = null;
for (String key : WorldData.GetAllCustomLocs().keySet())
{
Map<String, List<Location>> lobbyCustomLocs = ((NewGameLobbyManager) Manager.GetLobby()).getCustomLocs();
LeaderboardManager leaderboard = Managers.get(LeaderboardManager.class);
Pair<String, String> winPair = Pair.create("Win", "Wins");
Pair<String, String> killPair = Pair.create("Kill", "Kills");
Pair<String, String> goldPair = Pair.create("Gold", "Gold");
try
{
Location location = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0);
leaderboard.registerLeaderboard("TOP_HOG_DAILY_WINS", new Leaderboard("Top Daily Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.DAILY, location, 10));
mapType = MobaMapType.valueOf(key);
break;
}
catch (IllegalArgumentException e)
{
Location location = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0);
leaderboard.registerLeaderboard("TOP_HOG_DAILY_KILLS", new Leaderboard("Top Daily Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.DAILY, location, 10));
}
{
Location location = lobbyCustomLocs.get("TOP_DAILY_GOLD").get(0);
leaderboard.registerLeaderboard("TOP_HOG_DAILY_GOLD", new Leaderboard("Top Daily Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.DAILY, location, 10));
}
{
Location location = lobbyCustomLocs.get("TOP_WINS").get(0);
leaderboard.registerLeaderboard("TOP_HOG_WINS", new Leaderboard("Top Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.ALL, location, 10));
}
{
Location location = lobbyCustomLocs.get("TOP_KILLS").get(0);
leaderboard.registerLeaderboard("TOP_HOG_KILLS", new Leaderboard("Top Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.ALL, location, 10));
}
{
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));
}
if (mapType == null)
{
mapType = MobaMapType.HEROES_VALLEY;
}
registerManager(mapType.createInstance(this));
}
if (Manager.IsRewardStats() && Manager.GetLobby() instanceof NewGameLobbyManager)
{
Map<String, List<Location>> lobbyCustomLocs = ((NewGameLobbyManager) Manager.GetLobby()).getCustomLocs();
LeaderboardManager leaderboard = Managers.get(LeaderboardManager.class);
Pair<String, String> winPair = Pair.create("Win", "Wins");
Pair<String, String> killPair = Pair.create("Kill", "Kills");
Pair<String, String> goldPair = Pair.create("Gold", "Gold");
{
Location location = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0);
leaderboard.registerLeaderboard("TOP_HOG_DAILY_WINS", new Leaderboard("Top Daily Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.DAILY, location, 10));
}
{
Location location = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0);
leaderboard.registerLeaderboard("TOP_HOG_DAILY_KILLS", new Leaderboard("Top Daily Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.DAILY, location, 10));
}
{
Location location = lobbyCustomLocs.get("TOP_DAILY_GOLD").get(0);
leaderboard.registerLeaderboard("TOP_HOG_DAILY_GOLD", new Leaderboard("Top Daily Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.DAILY, location, 10));
}
{
Location location = lobbyCustomLocs.get("TOP_WINS").get(0);
leaderboard.registerLeaderboard("TOP_HOG_WINS", new Leaderboard("Top Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.ALL, location, 10));
}
{
Location location = lobbyCustomLocs.get("TOP_KILLS").get(0);
leaderboard.registerLeaderboard("TOP_HOG_KILLS", new Leaderboard("Top Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.ALL, location, 10));
}
{
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));
}
// Register all "Managers"
_listeners.forEach(UtilServer::RegisterEvents);
}
@EventHandler(priority = EventPriority.LOWEST)
@ -263,16 +285,16 @@ public class Moba extends TeamGame
setKits(_kits);
// Store player data
for (Player player : GetPlayers(true))
{
_playerData.add(new MobaPlayer(player));
MobaUtil.setTeamEntity(player, GetTeam(player));
}
GetPlayers(true).forEach(this::setupPlayerData);
// Cleanup tutorial boards
_mapManager.cleanupBoard(_board);
_selector.cleanup();
_progression.removeRoleViewers();
// Make sure to cleanup
cleanupLobby();
}
public void setupPlayerData(Player player)
{
_playerData.add(new MobaPlayer(player));
MobaUtil.setTeamEntity(player, GetTeam(player));
}
@EventHandler
@ -295,6 +317,17 @@ public class Moba extends TeamGame
player.setGameMode(GameMode.ADVENTURE);
}
private void cleanupLobby()
{
if (_board != null)
{
_mapManager.cleanupBoard(_board);
_selector.cleanup();
}
_progression.removeRoleViewers();
}
@Override
public void disable()
{
@ -302,6 +335,8 @@ public class Moba extends TeamGame
_listeners.forEach(UtilServer::Unregister);
_listeners.clear();
cleanupLobby();
Manager.runSyncLater(() ->
{
PlayerDisguiseManager playerDisguiseManager = Managers.require(PlayerDisguiseManager.class);

View File

@ -6,10 +6,10 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss;
import nautilus.game.arcade.game.games.moba.general.HotJoiningManager;
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;
@ -47,6 +47,9 @@ public class MobaClassic extends Moba
registerManager(new PrepareManager(this));
registerManager(new PrepareSelection(this));
// Hot joining
registerManager(new HotJoiningManager(this));
// new GameStatisticsModule()
// .register(this);
@ -94,7 +97,7 @@ public class MobaClassic extends Moba
{
suffix = C.cYellow + " Unknown";
}
else if (mobaPlayer.getKit() == null)
else if (mobaPlayer == null || mobaPlayer.getKit() == null)
{
suffix = C.cYellow + " Selecting";
}

View File

@ -4,35 +4,36 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.boss.pumpkin.PumpkinBoss;
import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss;
import nautilus.game.arcade.game.games.moba.util.MobaUtil;
import nautilus.game.arcade.world.WorldData;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class BossManager implements Listener
{
private final Moba _host;
private Map<GameTeam, WitherBoss> _teamBosses;
private PumpkinBoss _pumpkinBoss;
private final Set<MobaBoss> _bosses;
private final Map<GameTeam, WitherBoss> _teamBosses;
private boolean _dummyBosses;
public BossManager(Moba host)
{
_host = host;
_bosses = new HashSet<>();
_teamBosses = new HashMap<>(2);
}
private void spawnBosses()
private void spawnTeamWithers()
{
if (_dummyBosses)
{
@ -52,10 +53,6 @@ public class BossManager implements Listener
_teamBosses.put(team, boss);
}
// Pumpkin King
_pumpkinBoss = new PumpkinBoss(_host, worldData.GetDataLocs("BLACK").get(0));
_pumpkinBoss.setup();
_host.CreatureAllowOverride = false;
}
@ -67,7 +64,7 @@ public class BossManager implements Listener
return;
}
spawnBosses();
spawnTeamWithers();
}
@EventHandler
@ -79,17 +76,19 @@ public class BossManager implements Listener
}
_teamBosses.forEach((team, witherBoss) -> witherBoss.cleanup());
_bosses.forEach(MobaBoss::cleanup);
_bosses.clear();
}
if (_pumpkinBoss != null)
{
_pumpkinBoss.cleanup();
}
public void registerBoss(MobaBoss boss)
{
_bosses.add(boss);
boss.setup();
}
public String getWitherDisplayString(GameTeam team)
{
WitherBoss boss = getWitherBoss(team);
return MobaUtil.getColour(boss.getHealthPercentage()) + "";
}
@ -98,20 +97,9 @@ public class BossManager implements Listener
return _teamBosses.get(team);
}
public List<MobaBoss> getBosses()
public Collection<WitherBoss> getWitherBosses()
{
List<MobaBoss> bosses = new ArrayList<>();
if (_teamBosses != null)
{
bosses.addAll(_teamBosses.values());
}
if (_pumpkinBoss != null)
{
bosses.add(_pumpkinBoss);
}
return bosses;
return _teamBosses.values();
}
public void setDummyBosses(boolean dummyBosses)

View File

@ -113,6 +113,11 @@ public abstract class MobaBoss implements Listener
getAi().setEntity(_entity);
}
public void registerBoss()
{
_host.getBossManager().registerBoss(this);
}
public abstract LivingEntity spawnEntity();
public abstract MobaAI getAi();

View File

@ -113,7 +113,7 @@ public class PumpkinBoss extends MobaBoss
getAi().setEntity(skeleton);
UtilTextMiddle.display(C.cDRedB + "The Pumpkin King", "Has Awoken!", 10, 40, 10);
_host.Announce(F.main("Game", C.cRedB + "The Pumpkin King Has Awoken!"), false);
_host.Announce(F.main("Game", "The " + F.elem("Pumpkin King") + " has spawned! Killing him will give your team a buff!"), false);
for (Player player : Bukkit.getOnlinePlayers())
{
@ -125,7 +125,8 @@ public class PumpkinBoss extends MobaBoss
Block block = entry.getKey();
double setChance = entry.getValue();
if (!UtilBlock.solid(block)|| block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() > setChance)
if (!UtilBlock.solid(block) || block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() >
setChance)
{
continue;
}
@ -230,12 +231,7 @@ public class PumpkinBoss extends MobaBoss
BuffManager buffManager = _host.getBuffManager();
for (Player teamMember : team.GetPlayers(true))
{
if (UtilPlayer.isSpectator(teamMember))
{
continue;
}
buffManager.apply(new BuffPumpkinKing(_host, teamMember));
buffManager.apply(new BuffPumpkinKing(_host, teamMember, HELMET));
}
}
@ -283,7 +279,7 @@ public class PumpkinBoss extends MobaBoss
}
else
{
_entity.setHealth(Math.min(_entity.getHealth() + HEALTH_OUT_OF_COMBAT, _entity.getMaxHealth()));
MobaUtil.heal(_entity, null, HEALTH_OUT_OF_COMBAT);
updateDisplay();
}

View File

@ -4,6 +4,8 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -36,25 +38,7 @@ public class BuffManager implements Listener
_buffs.get(buff.getEntity()).add(buff);
buff.apply();
}
public boolean hasBuff(LivingEntity entity, Class<? extends Buff<? extends LivingEntity>> clazz)
{
if (!_buffs.containsKey(entity))
{
return false;
}
for (Buff<? extends LivingEntity> buff : _buffs.get(entity))
{
if (buff.getClass().equals(clazz))
{
return true;
}
}
return false;
}
@EventHandler
public void update(UpdateEvent event)
{
@ -91,4 +75,15 @@ public class BuffManager implements Listener
}
}
}
@EventHandler
public void end(GameStateChangeEvent event)
{
if (event.GetState() != GameState.End)
{
return;
}
_buffs.forEach((livingEntity, buffs) -> buffs.forEach(Buff::expire));
}
}

View File

@ -12,6 +12,7 @@ import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.buff.Buff;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
@ -29,13 +30,16 @@ public class BuffPumpkinKing extends Buff<Player>
{
private static final long DURATION = TimeUnit.MINUTES.toMillis(1);
private static final String DAMAGE_REASON = "Pumpkin King Buff";
private static final String DAMAGE_REASON = "Boss Buff";
private static final double DAMAGE_FACTOR = 1.5;
private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN);
public BuffPumpkinKing(Moba host, Player entity)
private final ItemStack _helmet;
public BuffPumpkinKing(Moba host, Player entity, ItemStack helmet)
{
super(host, entity, DURATION);
_helmet = helmet;
}
@Override
@ -44,7 +48,7 @@ public class BuffPumpkinKing extends Buff<Player>
_entity.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60 * 20, 1));
UtilParticle.PlayParticleToAll(ParticleType.LAVA, _entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 10, ViewDist.LONG);
_entity.playSound(_entity.getLocation(), Sound.PORTAL_TRAVEL, 1, 0.5F);
_entity.sendMessage(F.main("Game", "You feel the power of the Pumpkin King flow through you. Your damage and regeneration are increased!"));
_entity.sendMessage(F.main("Game", "You feel a " + F.elem("Great Power") + " flow through you. Your " + F.elem("Damage") + " and " + F.elem("Regeneration") + " are increased!"));
}
@Override
@ -61,7 +65,7 @@ public class BuffPumpkinKing extends Buff<Player>
return;
}
sendFakeHelmet(_entity, HELMET);
sendFakeHelmet(_entity, _helmet);
}
@EventHandler(priority = EventPriority.HIGHEST)
@ -80,7 +84,7 @@ public class BuffPumpkinKing extends Buff<Player>
return;
}
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, damagee.getLocation().add(0, 0.5, 0), 0.25F, 0.25F, 0.25F, 0.1F, 10, ViewDist.NORMAL);
damagee.getWorld().playEffect(damagee.getLocation().add(0, 0.5, 0), Effect.STEP_SOUND, Material.REDSTONE_BLOCK);
event.AddMod(DAMAGE_REASON, DAMAGE_FACTOR);
}

View File

@ -0,0 +1,152 @@
package nautilus.game.arcade.game.games.moba.general;
import mineplex.core.common.util.F;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.kit.HeroSkill;
import nautilus.game.arcade.game.games.moba.progression.MobaExperienceCalculateEvent;
import nautilus.game.arcade.game.games.moba.structure.tower.Tower;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class HotJoiningManager implements Listener
{
private static final int HOT_JOIN_EXP_REWARD = 100;
private final Moba _host;
private final List<Player> _pending;
private final List<Player> _hotJoined;
private final List<UUID> _played;
public HotJoiningManager(Moba host)
{
_host = host;
_pending = new ArrayList<>();
_hotJoined = new ArrayList<>();
_played = new ArrayList<>(8);
}
@EventHandler(priority = EventPriority.LOWEST)
public void playerLogin(PlayerLoginEvent event)
{
if (!_host.IsLive() || !_host.getArcadeManager().IsRewardStats())
{
return;
}
Player player = event.getPlayer();
GameTeam team = _host.ChooseTeam(player);
if (team == null || team.GetSize() >= 4)
{
return;
}
_pending.add(player);
team.AddPlayer(player, true);
}
@EventHandler(priority = EventPriority.MONITOR)
public void playerJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
if (!_pending.remove(player))
{
return;
}
GameTeam team = _host.GetTeam(player);
if (_host.getArcadeManager().isVanished(player))
{
if (team != null)
{
team.RemovePlayer(player);
}
return;
}
for (Tower tower : _host.getTowerManager().getTowers())
{
// If the team's second tower is dead
if (tower.getOwner().equals(team) && !tower.isFirstTower() && tower.isDead())
{
player.sendMessage(F.main("Game", "Sorry but you can only join a game in progress if they have at least " + F.elem(1) + " tower alive."));
return;
}
}
boolean played = _played.contains(player.getUniqueId());
team.SpawnTeleport(player);
if (!played)
{
_hotJoined.add(player);
}
_host.setupPlayerData(player);
_host.getArcadeManager().runSyncLater(() ->
{
Kit kit = _host.getFirstKit(player);
if (!played)
{
player.sendMessage(F.main("Game", "Thanks for choosing to join a game in progress! If you stay until the end of the game you will were an additional " + F.elem(HOT_JOIN_EXP_REWARD) + " " + F.greenElem("Heroes of GWEN Role") + " experience."));
}
_host.SetKit(player, kit, true);
Perk perk = kit.GetPerks()[kit.GetPerks().length - 1];
// Put Ultimates on cooldown
if (perk instanceof HeroSkill)
{
((HeroSkill) perk).useSkill(player);
}
}, 1);
}
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{
Player player = event.getPlayer();
_pending.remove(player);
_hotJoined.remove(player);
}
@EventHandler
public void live(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
{
return;
}
_host.GetPlayers(true).forEach(player -> _played.add(player.getUniqueId()));
}
@EventHandler
public void expCalculate(MobaExperienceCalculateEvent event)
{
if (_hotJoined.contains(event.getPlayer()))
{
event.getExpEarned().getAndAdd(HOT_JOIN_EXP_REWARD);
}
}
}

View File

@ -50,7 +50,7 @@ public class SkillInfinity extends HeroSkill
@EventHandler
public void interact(PlayerInteractEvent event)
{
if (!isSkillItem(event) || _active.contains(event.getPlayer()))
if (!isSkillItem(event))
{
return;
}
@ -66,13 +66,11 @@ public class SkillInfinity extends HeroSkill
// Give 1 arrow just incase the player didn't have one
_kit.giveAmmo(player, 1);
bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
_active.add(player);
broadcast(player);
useActiveSkill(() ->
{
bow.removeEnchantment(Enchantment.ARROW_INFINITE);
_active.remove(player);
}, player, 7000);
}

View File

@ -28,6 +28,7 @@ import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@ -243,16 +244,9 @@ public class MinionWave implements Listener
private Location targetWither(Minion minion)
{
for (MobaBoss boss : _host.getBossManager().getBosses())
for (WitherBoss boss : _host.getBossManager().getWitherBosses())
{
if (boss.isDead() || !(boss instanceof WitherBoss))
{
continue;
}
WitherBoss witherBoss = (WitherBoss) boss;
if (witherBoss.getTeam().equals(_owner))
if (boss.isDead() || boss.getTeam().equals(_owner))
{
continue;
}
@ -352,11 +346,11 @@ public class MinionWave implements Listener
return;
}
List<MobaBoss> bosses = _host.getBossManager().getBosses();
Collection<WitherBoss> bosses = _host.getBossManager().getWitherBosses();
for (Minion minion : _minions)
{
for (MobaBoss boss : bosses)
for (WitherBoss boss : bosses)
{
// Dead, not close enough
if (boss.isDead() || MobaUtil.isTeamEntity(boss.getEntity(), _owner) || UtilMath.offsetSquared(minion.getEntity(), boss.getEntity()) > DAMAGE_RANGE_SQUARED)

View File

@ -0,0 +1,18 @@
package nautilus.game.arcade.game.games.moba.modes;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.boss.pumpkin.PumpkinBoss;
import org.bukkit.Bukkit;
public class MobaHeroesValleyMap extends MobaMap
{
public MobaHeroesValleyMap(Moba host)
{
super(host);
new PumpkinBoss(host, host.WorldData.GetDataLocs("BLACK").get(0))
.registerBoss();
}
}

View File

@ -0,0 +1,15 @@
package nautilus.game.arcade.game.games.moba.modes;
import nautilus.game.arcade.game.games.moba.Moba;
import org.bukkit.event.Listener;
public class MobaMap implements Listener
{
protected final Moba _host;
public MobaMap(Moba host)
{
_host = host;
}
}

View File

@ -0,0 +1,42 @@
package nautilus.game.arcade.game.games.moba.modes;
import nautilus.game.arcade.game.games.moba.Moba;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import java.lang.reflect.InvocationTargetException;
public enum MobaMapType
{
HEROES_VALLEY("Heroes Valley", MobaHeroesValleyMap.class),
MONOCHROME("Monochrome", MobaMonochromeMap.class)
;
private final String _name;
private final Class<? extends MobaMap> _clazz;
MobaMapType(String name, Class<? extends MobaMap> clazz)
{
_name = name;
_clazz = clazz;
}
public String getName()
{
return _name;
}
public MobaMap createInstance(Moba host)
{
try
{
return _clazz.getConstructor(Moba.class).newInstance(host);
}
catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e)
{
e.printStackTrace();
return null;
}
}
}

View File

@ -0,0 +1,225 @@
package nautilus.game.arcade.game.games.moba.modes;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
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.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.utils.UtilVariant;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.buff.BuffManager;
import nautilus.game.arcade.game.games.moba.buff.buffs.BuffPumpkinKing;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
public class MobaMonochromeMap extends MobaMap
{
private static final long START_TIME = TimeUnit.MINUTES.toMillis(5);
private static final long ACTIVE_TIME = TimeUnit.SECONDS.toMillis(30);
private static final ItemStack IN_HAND = new ItemStack(Material.STONE_SWORD);
private static final ItemStack BUFF_HELMET = new ItemBuilder(Material.SKULL_ITEM, (byte) 1).build();
private final Set<LivingEntity> _skeletons;
private final Map<GameTeam, Integer> _killedSkeletons;
private boolean _active;
private long _lastStart;
public MobaMonochromeMap(Moba host)
{
super(host);
_skeletons = new HashSet<>();
_killedSkeletons = new HashMap<>();
}
@EventHandler
public void live(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
{
return;
}
_lastStart = System.currentTimeMillis();
}
@EventHandler
public void updateStart(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST || !_host.IsLive() || _active || !UtilTime.elapsed(_lastStart, START_TIME))
{
return;
}
_lastStart = System.currentTimeMillis();
_active = true;
UtilTextMiddle.display(C.cRedB + "Wither Skeletons", "Have Spawned!", 10, 40, 10);
_host.Announce(F.main("Game", F.elem("Wither Skeletons") + " have spawned! The team that kills the most within " + F.time("30 seconds") + " receives a buff!"), false);
for (Player player : Bukkit.getOnlinePlayers())
{
player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1, 0.4F);
}
_host.CreatureAllowOverride = true;
for (Location location : _host.WorldData.GetDataLocs("BLACK"))
{
Skeleton skeleton = UtilVariant.spawnWitherSkeleton(location);
skeleton.getEquipment().setItemInHand(IN_HAND);
skeleton.setCustomName(C.Bold + "Wither Skeleton");
skeleton.setCustomNameVisible(true);
_skeletons.add(skeleton);
}
_host.CreatureAllowOverride = false;
for (GameTeam team : _host.GetTeamList())
{
_killedSkeletons.put(team, 0);
}
}
@EventHandler
public void updateEnd(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST || !_host.IsLive() || !_active || !UtilTime.elapsed(_lastStart, ACTIVE_TIME))
{
return;
}
GameTeam red = _host.GetTeam(ChatColor.RED);
int redKills = _killedSkeletons.get(red);
GameTeam blue = _host.GetTeam(ChatColor.AQUA);
int blueKills = _killedSkeletons.get(blue);
List<GameTeam> winners;
// Draw
if (redKills == blueKills)
{
winners = Arrays.asList(red, blue);
}
// Red win
else if (redKills > blueKills)
{
winners = Collections.singletonList(red);
}
// Blue win
else
{
winners = Collections.singletonList(blue);
}
if (winners.size() == 1)
{
GameTeam winner = winners.get(0);
_host.Announce(F.main("Game", F.name(winner.GetFormattedName()) + " killed the most " + F.elem("Wither Skeletons") + ". They have been given the buff!"), false);
UtilTextMiddle.display("", winner.GetFormattedName() + C.cWhite + " killed the most " + F.elem("Wither Skeletons"), 10, 40, 10);
}
else
{
_host.Announce(F.main("Game", F.elem(C.Bold + "Draw") + "! No one was given the buff!"), false);
UtilTextMiddle.display("", C.cYellowB + "Draw" + C.cWhite + "! No one was given the buff!", 10, 40, 10);
cleanup();
return;
}
// Give the team members the buff
BuffManager buffManager = _host.getBuffManager();
winners.forEach(team ->
{
for (Player teamMember : team.GetPlayers(true))
{
buffManager.apply(new BuffPumpkinKing(_host, teamMember, BUFF_HELMET));
}
});
cleanup();
}
private void cleanup()
{
_skeletons.forEach(entity ->
{
if (!entity.isDead())
{
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, entity.getLocation().add(0, 1.5, 0), 0.5F, 1, 0.5F, 0.001F, 15, ViewDist.LONG);
}
entity.remove();
});
_skeletons.clear();
_killedSkeletons.clear();
_active = false;
}
@EventHandler
public void entityDeath(EntityDeathEvent event)
{
LivingEntity entity = event.getEntity();
if (_skeletons.remove(entity))
{
Player player = entity.getKiller();
if (player == null)
{
return;
}
GameTeam team = _host.GetTeam(player);
if (team == null)
{
return;
}
event.getDrops().clear();
event.setDroppedExp(0);
_killedSkeletons.put(team, _killedSkeletons.get(team) + 1);
player.sendMessage(F.main("Game", "You killed a " + F.name("Wither Skeleton") + "!"));
}
}
@EventHandler
public void entityCombust(EntityCombustEvent event)
{
if (_skeletons.contains(event.getEntity()))
{
event.setCancelled(true);
}
}
}

View File

@ -49,12 +49,9 @@ public class OvertimeManager implements Listener
UtilTextMiddle.display(C.cRedB + "OVERTIME", "Victory or Death, Withers are moving to the center!");
_host.Announce(F.main("Game", "Victory or Death, Withers are moving to the center!"), false);
for (MobaBoss boss : _host.getBossManager().getBosses())
for (WitherBoss boss : _host.getBossManager().getWitherBosses())
{
if (boss instanceof WitherBoss)
{
((WitherBoss) boss).setDamageable(true);
}
boss.setDamageable(true);
}
for (Player player : Bukkit.getOnlinePlayers())

View File

@ -1,7 +1,11 @@
package nautilus.game.arcade.game.games.moba.prepare;
import mineplex.core.common.entity.ClientArmorStand;
import mineplex.core.common.util.*;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.events.GamePrepareCountdownCommence;
@ -80,9 +84,6 @@ public class PrepareManager implements Listener
}
HeroKit heroKit = _host.getFirstKit(player);
MobaPlayer mobaPlayer = _host.getMobaData(player);
mobaPlayer.setRole(heroKit.getRole());
_host.SetKit(player, heroKit, true);
}

View File

@ -0,0 +1,39 @@
package nautilus.game.arcade.game.games.moba.progression;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import java.util.concurrent.atomic.AtomicInteger;
public class MobaExperienceCalculateEvent extends PlayerEvent
{
private static final HandlerList _handlers = new HandlerList();
private AtomicInteger _expEarned;
public MobaExperienceCalculateEvent(Player player, AtomicInteger expEarned)
{
super(player);
_expEarned = expEarned;
}
public AtomicInteger getExpEarned()
{
return _expEarned;
}
public static HandlerList getHandlerList()
{
return _handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
}

View File

@ -0,0 +1,58 @@
package nautilus.game.arcade.game.games.moba.progression;
public class MobaLevelData
{
private final int _exp;
private final int _level;
private final int _thisLevel;
private final int _nextLevel;
public MobaLevelData(long exp)
{
_exp = (int) exp;
_level = MobaProgression.getLevel(exp);
_thisLevel = MobaProgression.getExpFor(_level);
_nextLevel = MobaProgression.getExpFor(_level + 1);
}
public int getExp()
{
return _exp;
}
public int getLevel()
{
return _level;
}
public int getDisplayLevel()
{
return _level + 1;
}
public int getExpThisLevel()
{
return _thisLevel;
}
public int getExpJustThisLevel()
{
return _nextLevel - _thisLevel;
}
public int getExpLevelProgress()
{
return _exp - _thisLevel;
}
public int getExpReminder()
{
return _nextLevel - _exp;
}
public double getPercentageComplete()
{
return (double) (getExpLevelProgress()) / (double) (getExpJustThisLevel());
}
}

View File

@ -40,20 +40,18 @@ import java.util.concurrent.atomic.AtomicInteger;
public class MobaProgression implements Listener
{
private static final int[] EXP_LEVELS;
private static final int EXP_PER_LEVEL = 500;
private static final int EXP_PER_LEVEL = 1000;
private static final int EXP_FACTOR = 3;
public static final DecimalFormat FORMAT = new DecimalFormat("0.0");
static
public static int getExpFor(int level)
{
EXP_LEVELS = new int[100];
int expRequired = EXP_PER_LEVEL;
return EXP_PER_LEVEL * level;
}
for (int level = 0; level < 100; level++)
{
EXP_LEVELS[level] = expRequired += EXP_PER_LEVEL;
}
public static int getLevel(long exp)
{
return (int) Math.floor(exp / EXP_PER_LEVEL);
}
private final Moba _host;
@ -84,9 +82,9 @@ public class MobaProgression implements Listener
public void Execute(Player caller, String[] args)
{
MobaRole role = MobaRole.valueOf(args[0].toUpperCase());
int exp = getExperience(Integer.parseInt(args[1])) - 1;
int exp = getExpFor(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)) + "."));
caller.sendMessage(F.main("Debug", "Set your " + role.getChatColor() + role.getName() + C.cGray + " level to " + F.elem(getLevel(exp) + 1) + "."));
}
});
}
@ -176,32 +174,12 @@ public class MobaProgression implements Listener
_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());
@ -212,28 +190,22 @@ public class MobaProgression implements Listener
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);
if (mobaPlayer == null)
{
return;
}
MobaRole role = mobaPlayer.getRole();
String stat = _host.GetName() + "." + role.getName() + ".ExpEarned";
long currentExp = _host.getArcadeManager().GetStatsManager().Get(player).getStat(stat);
// EXP before earning
long currentExp = getExperience(player, role);
// Level before earning
int currentLevel = getLevel(currentExp);
AtomicInteger earnedExp = new AtomicInteger();
for (GemData data : _host.GetGems(player).values())
@ -243,15 +215,12 @@ public class MobaProgression implements Listener
earnedExp.getAndAdd(earnedExp.get() * EXP_FACTOR);
int level = getLevel(currentExp);
int newLevel = getLevel(currentExp + earnedExp.get());
long expForThisLevel = getExperienceCurrentLevel(player, role);
AtomicBoolean levelUp = new AtomicBoolean();
MobaExperienceCalculateEvent event = new MobaExperienceCalculateEvent(player, earnedExp);
UtilServer.CallEvent(event);
if (newLevel > level)
{
levelUp.set(true);
}
MobaLevelData levelData = new MobaLevelData(currentExp + earnedExp.get());
AtomicBoolean levelUp = new AtomicBoolean(levelData.getLevel() > currentLevel);
_host.getArcadeManager().GetStatsManager().incrementStat(player, stat, earnedExp.get());
@ -262,8 +231,8 @@ public class MobaProgression implements Listener
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(MobaUtil.getProgressBar(levelData.getExpLevelProgress() - earnedExp.get(), levelData.getExpLevelProgress(), levelData.getExpJustThisLevel(), 100) + " " + C.cGray + "+" + C.cGreen + earnedExp + C.cGray + "/" + C.cAqua + levelData.getExpJustThisLevel());
player.sendMessage(C.cGreen + FORMAT.format((levelData.getPercentageComplete() * 100D)) + C.cWhite + "% complete for Level " + levelData.getDisplayLevel());
player.sendMessage("");
player.sendMessage(ArcadeFormat.Line);
@ -272,7 +241,7 @@ public class MobaProgression implements Listener
{
for (HeroKit kit : _host.getKits())
{
if (!kit.getRole().equals(role) || kit.getUnlockLevel() != newLevel)
if (!kit.getRole().equals(role) || kit.getUnlockLevel() != levelData.getDisplayLevel())
{
continue;
}

View File

@ -14,6 +14,7 @@ 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.MobaLevelData;
import nautilus.game.arcade.game.games.moba.progression.MobaProgression;
import nautilus.game.arcade.game.games.moba.progression.MobaUnlockAnimation;
import org.bukkit.Material;
@ -49,11 +50,7 @@ public class MobaRolePage extends ShopPageBase<ArcadeManager, MobaRoleShop>
@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);
MobaLevelData levelData = new MobaLevelData(_host.getProgression().getExperience(_player, _role));
addButtonNoAction(13, new ItemBuilder(_role.getSkin().getSkull())
.setTitle(_role.getChatColor() + _role.getName())
@ -62,8 +59,8 @@ public class MobaRolePage extends ShopPageBase<ArcadeManager, MobaRoleShop>
"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 + "%)"
"Your Level: " + C.cGreen + levelData.getDisplayLevel(),
"Next Level: " + C.cGreen + levelData.getExpLevelProgress() + C.cGray + "/" + C.cGreen + levelData.getExpJustThisLevel() + C.cGray + " (" + C.cAqua + MobaProgression.FORMAT.format(levelData.getPercentageComplete() * 100D) + C.cGray + "%)"
)
.build());

View File

@ -26,7 +26,6 @@ import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop;
import nautilus.game.arcade.game.games.moba.shop.mage.MobaMageShop;
import nautilus.game.arcade.game.games.moba.shop.warrior.MobaWarriorShop;
import nautilus.game.arcade.game.games.moba.util.MobaConstants;
import nautilus.game.arcade.kit.Kit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
@ -249,6 +248,7 @@ public class MobaShop implements Listener
public List<MobaItem> getOwnedItems(Player player)
{
_upgrades.putIfAbsent(player, new ArrayList<>());
return _upgrades.get(player);
}
@ -329,20 +329,6 @@ public class MobaShop implements Listener
Handle MobaItem events
*/
@EventHandler
public void prepare(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
{
return;
}
for (Player player : _host.GetPlayers(true))
{
_upgrades.put(player, new ArrayList<>());
}
}
@EventHandler
public void ammoGive(AmmoGiveEvent event)
{

View File

@ -184,7 +184,7 @@ public class MobaUtil
}
else
{
out.append(C.cGrayB).append("|");
out.append(C.cGray).append("|");
}
}

View File

@ -1,26 +1,12 @@
package nautilus.game.arcade.game.games.smash.perks.chicken;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Sound;
import org.bukkit.entity.Egg;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
@ -29,6 +15,16 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.smash.perks.SmashPerk;
import org.bukkit.Sound;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class PerkEggGun extends SmashPerk
{
@ -148,28 +144,21 @@ public class PerkEggGun extends SmashPerk
@EventHandler
public void EggHit(CustomDamageEvent event)
{
if (event.GetProjectile() == null)
if (event.GetProjectile() == null || !(event.GetProjectile() instanceof Egg))
{
return;
}
if (!(event.GetProjectile() instanceof Egg))
{
return;
}
if (event.GetDamage() >= _damage)
{
return;
}
event.SetCancelled("Egg Blaster");
Egg egg = (Egg) event.GetProjectile();
Player damager = event.GetDamagerPlayer(true);
// Damage Event
Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), (LivingEntity) egg.getShooter(), egg, DamageCause.PROJECTILE, _damage, true, true, false, UtilEnt.getName((LivingEntity) egg
.getShooter()), GetName());
if (damager == null || !hasPerk(damager))
{
return;
}
event.AddMod("Negate", -event.GetDamage());
event.AddMod(damager.getName(), "Egg Blaster", _damage, true);
event.SetIgnoreRate(true);
UtilAction.zeroVelocity(event.GetDamageeEntity());
}