Merge pull request #128 from Mineplex-LLC/develop

Merge develop into project-cosmetics
This commit is contained in:
LCastr0 2016-07-02 13:07:03 -03:00 committed by GitHub
commit 9990e15244
42 changed files with 1074 additions and 180 deletions

View File

@ -45,21 +45,25 @@ public class Pair<L, R> implements Serializable {
return getLeft().toString() + ":" + getRight().toString(); return getLeft().toString() + ":" + getRight().toString();
} }
@SuppressWarnings("rawtypes")
@Override @Override
public boolean equals(Object obj) public boolean equals(Object o)
{ {
if (this == obj) if (this == o) return true;
return true; if (o == null || getClass() != o.getClass()) return false;
if (!(obj instanceof Pair))
return false;
Pair localPair = (Pair) obj; Pair<?, ?> pair = (Pair<?, ?>) o;
if (getLeft() != null ? !getLeft().equals(localPair.getLeft()) : localPair.getLeft() != null) if (left != null ? !left.equals(pair.left) : pair.left != null) return false;
return false; return right != null ? right.equals(pair.right) : pair.right == null;
if (getRight() != null ? !getRight().equals(localPair.getRight()) : localPair.getRight() != null)
return false; }
return true;
@Override
public int hashCode()
{
int result = left != null ? left.hashCode() : 0;
result = 31 * result + (right != null ? right.hashCode() : 0);
return result;
} }
} }

View File

@ -173,7 +173,17 @@ public class UtilInv
return getItems(player, true, true, true); return getItems(player, true, true, true);
} }
public static ArrayList<ItemStack> getItemsUncloned(Player player)
{
return getItems(player, true, true, true, false);
}
public static ArrayList<ItemStack> getItems(Player player, boolean getArmor, boolean getCursor, boolean getCrafting) public static ArrayList<ItemStack> getItems(Player player, boolean getArmor, boolean getCursor, boolean getCrafting)
{
return getItems(player, getArmor, getCursor, getCrafting, true);
}
public static ArrayList<ItemStack> getItems(Player player, boolean getArmor, boolean getCursor, boolean getCrafting, boolean clone)
{ {
ArrayList<ItemStack> items = new ArrayList<ItemStack>(); ArrayList<ItemStack> items = new ArrayList<ItemStack>();
PlayerInventory inv = player.getInventory(); PlayerInventory inv = player.getInventory();
@ -182,7 +192,7 @@ public class UtilInv
{ {
if (item != null && item.getType() != Material.AIR) if (item != null && item.getType() != Material.AIR)
{ {
items.add(item.clone()); items.add(clone ? item.clone() : item);
} }
} }
@ -192,7 +202,7 @@ public class UtilInv
{ {
if (item != null && item.getType() != Material.AIR) if (item != null && item.getType() != Material.AIR)
{ {
items.add(item.clone()); items.add(clone ? item.clone() : item);
} }
} }
} }
@ -202,7 +212,7 @@ public class UtilInv
ItemStack cursorItem = player.getItemOnCursor(); ItemStack cursorItem = player.getItemOnCursor();
if (cursorItem != null && cursorItem.getType() != Material.AIR) if (cursorItem != null && cursorItem.getType() != Material.AIR)
items.add(cursorItem.clone()); items.add(clone ? cursorItem.clone() : cursorItem);
} }
if (getCrafting) if (getCrafting)
@ -215,7 +225,7 @@ public class UtilInv
{ {
if (item != null && item.getType() != Material.AIR) if (item != null && item.getType() != Material.AIR)
{ {
items.add(item.clone()); items.add(clone ? item.clone() : item);
} }
} }
} }

View File

@ -57,7 +57,14 @@ public class CoreClientManager extends MiniPlugin
private static AtomicInteger _clientsConnecting = new AtomicInteger(0); private static AtomicInteger _clientsConnecting = new AtomicInteger(0);
private static AtomicInteger _clientsProcessing = new AtomicInteger(0); private static AtomicInteger _clientsProcessing = new AtomicInteger(0);
private final Rank WHITELIST_BYPASS;
public CoreClientManager(JavaPlugin plugin, String webServer) public CoreClientManager(JavaPlugin plugin, String webServer)
{
this(plugin, webServer, Rank.MODERATOR);
}
public CoreClientManager(JavaPlugin plugin, String webServer, Rank whitelistBypass)
{ {
super("Client Manager", plugin); super("Client Manager", plugin);
@ -65,6 +72,7 @@ public class CoreClientManager extends MiniPlugin
_repository = new AccountRepository(plugin, webServer); _repository = new AccountRepository(plugin, webServer);
_clientList = new NautHashMap<String, CoreClient>(); _clientList = new NautHashMap<String, CoreClient>();
_duplicateLoginGlitchPreventionList = new HashSet<String>(); _duplicateLoginGlitchPreventionList = new HashSet<String>();
WHITELIST_BYPASS = whitelistBypass;
} }
public AccountRepository getRepository() public AccountRepository getRepository()
@ -195,7 +203,7 @@ public class CoreClientManager extends MiniPlugin
_clientsProcessing.decrementAndGet(); _clientsProcessing.decrementAndGet();
} }
if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().has(Rank.MODERATOR)) if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().has(WHITELIST_BYPASS))
{ {
for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) for (OfflinePlayer player : Bukkit.getWhitelistedPlayers())
{ {

View File

@ -89,11 +89,14 @@ import mineplex.minecraft.game.classcombat.shop.ClassCombatShop;
import mineplex.minecraft.game.classcombat.shop.ClassShopManager; import mineplex.minecraft.game.classcombat.shop.ClassShopManager;
import mineplex.minecraft.game.core.IRelation; import mineplex.minecraft.game.core.IRelation;
import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.condition.Condition;
import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.damage.DamageManager;
import mineplex.minecraft.game.core.fire.Fire; import mineplex.minecraft.game.core.fire.Fire;
import mineplex.minecraft.game.core.mechanics.Weapon; import mineplex.minecraft.game.core.mechanics.Weapon;
import mineplex.serverdata.commands.ServerCommandManager; import mineplex.serverdata.commands.ServerCommandManager;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -321,6 +324,19 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
Material targetType = event.getTargetBlock().getType(); Material targetType = event.getTargetBlock().getType();
event.setCancelled(targetType == Material.POTATO || targetType == Material.CARROT); event.setCancelled(targetType == Material.POTATO || targetType == Material.CARROT);
} }
@EventHandler
public void on(CustomDamageEvent event)
{
if (event.GetCause() == EntityDamageEvent.DamageCause.CUSTOM
&& event.GetDamageInitial() == 0.1
&& event.GetDamageePlayer() != null)
{
Condition poisonShock = _condition.GetActiveCondition(event.GetDamageePlayer(), Condition.ConditionType.POISON_SHOCK);
if (poisonShock != null)
event.SetIgnoreArmor(true);
}
}
}); });
_worldEvent.setFactory(skillManager); _worldEvent.setFactory(skillManager);

View File

@ -1,6 +1,7 @@
package mineplex.game.clans.clans.commands; package mineplex.game.clans.clans.commands;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.minecraft.game.classcombat.Skill.Global.Recharge;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
@ -29,6 +30,11 @@ public class KillCommand extends CommandBase<DamageManager>
UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in the tutorial.")); UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in the tutorial."));
return; return;
} }
if (mineplex.core.recharge.Recharge.Instance.use(caller, "Suicide", 5000, false, false))
{
UtilPlayer.message(caller, F.main("Clans", "Please wait a bit before suiciding"));
return;
}
UtilPlayer.message(caller, F.main("Clans", "You have imploded.")); UtilPlayer.message(caller, F.main("Clans", "You have imploded."));

View File

@ -62,7 +62,7 @@ public class ClanWhoPage extends ClanPageBase
// Basic Clan Info // Basic Clan Info
lore.add(C.Reset + C.cYellow + "Founder " + C.cWhite + _lookupClan.getDesc()); lore.add(C.Reset + C.cYellow + "Founder " + C.cWhite + _lookupClan.getDesc());
lore.add(C.Reset + C.cYellow + "Formed " + C.cWhite + UtilTime.convertString(System.currentTimeMillis() - _lookupClan.getDateCreated().getTime(), 1, UtilTime.TimeUnit.FIT)); lore.add(C.Reset + C.cYellow + "Formed " + C.cWhite + UtilTime.convertString(System.currentTimeMillis() - _lookupClan.getDateCreated().getTime(), 1, UtilTime.TimeUnit.FIT) + " ago on " + UtilTime.when(_lookupClan.getDateCreated().getTime()));
lore.add(C.Reset + C.cYellow + "Members " + C.cWhite + _lookupClan.getOnlinePlayerCount() + "/" + _lookupClan.getMembers().size()); lore.add(C.Reset + C.cYellow + "Members " + C.cWhite + _lookupClan.getOnlinePlayerCount() + "/" + _lookupClan.getMembers().size());
lore.add(C.Reset + C.cYellow + "Territory " + C.cWhite + _lookupClan.getClaims() + "/" + _lookupClan.getClaimsMax()); lore.add(C.Reset + C.cYellow + "Territory " + C.cWhite + _lookupClan.getClaims() + "/" + _lookupClan.getClaimsMax());
lore.add(C.Reset + C.cYellow + "TNT Protection " + C.cWhite + _lookupClan.getProtected()); lore.add(C.Reset + C.cYellow + "TNT Protection " + C.cWhite + _lookupClan.getProtected());

View File

@ -58,7 +58,10 @@ public class SafeLog extends MiniPlugin
if (!isSafeLog) if (!isSafeLog)
{ {
NPCManager.getInstance().spawnLogoutNpc(player); if (!_clansManager.getIncognitoManager().Get(player).Status)
{
NPCManager.getInstance().spawnLogoutNpc(player);
}
} }
} }

View File

@ -6,6 +6,9 @@ import java.util.UUID;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftItem;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemFactory;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
@ -105,7 +108,7 @@ public class CustomItem implements Listener
public ItemStack toItemStack(int amount) public ItemStack toItemStack(int amount)
{ {
ItemStack item = new ItemStack(_material, amount); ItemStack item = CraftItemStack.asCraftMirror(CraftItemStack.asNMSCopy(new ItemStack(_material, amount)));
update(item); update(item);
if (_dullEnchantment) if (_dullEnchantment)

View File

@ -2,6 +2,8 @@ package mineplex.game.clans.items;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@ -86,21 +88,6 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems;
*/ */
public class GearManager extends MiniPlugin implements IPacketHandler, Runnable public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
{ {
private static final Field UNHANDLED_TAGS_FIELD;
static
{
try
{
UNHANDLED_TAGS_FIELD = Class.forName("org.bukkit.craftbukkit.v1_8_R3.inventory.CraftMetaItem").getDeclaredField("unhandledTags");
UNHANDLED_TAGS_FIELD.setAccessible(true);
}
catch (Throwable t)
{
throw new RuntimeException("Error getting unhandledTags field", t);
}
}
private static final String ITEM_SERIALIZATION_TAG = "-JSON-"; private static final String ITEM_SERIALIZATION_TAG = "-JSON-";
private static final Gson GSON; private static final Gson GSON;
@ -626,7 +613,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
return null; return null;
} }
CraftItemStack originalItem = CraftItemStack.asCraftMirror(item); CraftItemStack originalItem = CraftItemStack.asCraftMirror(item.cloneItemStack());
ItemMeta originalMeta = originalItem.getItemMeta(); ItemMeta originalMeta = originalItem.getItemMeta();
// No need to modify item packets with no lore // No need to modify item packets with no lore
@ -680,7 +667,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
List<String> cleansed = new ArrayList<>(); List<String> cleansed = new ArrayList<>();
for (String s : input) for (String s : input)
{ {
if (!s.startsWith(ITEM_SERIALIZATION_TAG)) if (s.startsWith(ITEM_SERIALIZATION_TAG))
{ {
cleansed.add(s); cleansed.add(s);
} }
@ -697,40 +684,35 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
// This will not be persistent if the ItemStack is a block and placed then picked up // This will not be persistent if the ItemStack is a block and placed then picked up
private static Map<String, NBTBase> getUnhandledTags(ItemStack itemStack) private static Map<String, NBTBase> getUnhandledTags(ItemStack itemStack)
{ {
ItemMeta itemMeta = itemStack.getItemMeta(); net.minecraft.server.v1_8_R3.ItemStack handle = ((CraftItemStack) itemStack).getHandle();
if (itemMeta == null) if (handle == null)
return Collections.emptyMap();
NBTTagCompound tag = handle.getTag();
if (tag == null)
return Collections.emptyMap();
Map<String, NBTBase> unhandled = new HashMap<>();
for (String name : tag.c())
{ {
return null; unhandled.put(name, tag.get(name));
} }
try return unhandled;
{
return (Map<String, NBTBase>) UNHANDLED_TAGS_FIELD.get(itemMeta);
}
catch (IllegalAccessException e)
{
System.out.println("Could not get unhandledTags");
e.printStackTrace();
}
return null;
} }
private static void saveUnhandledTags(ItemStack itemStack, Map<String, NBTBase> map) private static void saveUnhandledTags(ItemStack itemStack, Map<String, NBTBase> map)
{ {
ItemMeta itemMeta = itemStack.getItemMeta(); net.minecraft.server.v1_8_R3.ItemStack handle = ((CraftItemStack) itemStack).getHandle();
if (itemMeta == null) NBTTagCompound tag = handle.getTag();
if (tag != null)
{ {
return; for (String name : map.keySet())
{
tag.set(name, map.get(name));
}
} }
try
{
UNHANDLED_TAGS_FIELD.set(itemMeta, map);
}
catch (IllegalAccessException e)
{
System.out.println("Could not get unhandledTags");
e.printStackTrace();
}
itemStack.setItemMeta(itemMeta);
} }
public static void save(ItemStack itemStack, boolean remove) public static void save(ItemStack itemStack, boolean remove)
@ -743,7 +725,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
saveUnhandledTags(itemStack, data); saveUnhandledTags(itemStack, data);
if (remove) if (remove)
{ {
_customItemCache.remove(item); _customItemCache.remove(UUID.fromString(item._uuid));
} }
} }
} }

View File

@ -16,6 +16,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent; import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.event.player.PlayerItemHeldEvent;
@ -44,7 +45,7 @@ public class ItemListener implements Listener, Runnable
public ItemListener(JavaPlugin plugin) public ItemListener(JavaPlugin plugin)
{ {
_plugin = plugin; _plugin = plugin;
_plugin.getServer().getScheduler().runTaskTimer(_plugin, this, 20 * 60 * 5, 0); _plugin.getServer().getScheduler().runTaskTimer(_plugin, this, 0, 20 * 60 * 5);
} }
@Override @Override
@ -65,7 +66,7 @@ public class ItemListener implements Listener, Runnable
private void save(Player player, boolean remove) private void save(Player player, boolean remove)
{ {
for (ItemStack item : UtilInv.getItems(player)) for (ItemStack item : UtilInv.getItemsUncloned(player))
{ {
GearManager.save(item, remove); GearManager.save(item, remove);
} }

View File

@ -13,7 +13,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class LegendaryItem extends CustomItem public class LegendaryItem extends CustomItem
{ {
private final long BLOCK_COOLDOWN = 200L; // Right clicking activates right click for 200ms private static final long BLOCK_COOLDOWN = 200L; // Right clicking activates right click for 200ms
protected long _lastBlock; // Timestamp of last block from wielder protected long _lastBlock; // Timestamp of last block from wielder

View File

@ -403,6 +403,18 @@ public class ConditionManager extends MiniPlugin
return false; return false;
} }
public boolean HasCondition(LivingEntity target, ConditionType type)
{
if (!_conditions.containsKey(target))
return false;
for (Condition cond : _conditions.get(target))
if (type == null || cond.GetType() == type)
return true;
return false;
}
public WeakHashMap<LivingEntity, LinkedList<ConditionActive>> GetActiveConditions() public WeakHashMap<LivingEntity, LinkedList<ConditionActive>> GetActiveConditions()
{ {
return _activeConditions; return _activeConditions;

View File

@ -3,6 +3,9 @@ package mineplex.minecraft.game.core.damage;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
@ -58,6 +61,9 @@ public class DamageManager extends MiniPlugin
private boolean _enabled = true; private boolean _enabled = true;
private final HashMap<String, Integer> _protectionTypeModifiers = new HashMap<String, Integer>();
private final HashMap<String, DamageCause[]> _protectionCauses = new HashMap<String, DamageCause[]>();
public DamageManager(JavaPlugin plugin, CombatManager combatManager, NpcManager npcManager, DisguiseManager disguiseManager, ConditionManager conditionManager) public DamageManager(JavaPlugin plugin, CombatManager combatManager, NpcManager npcManager, DisguiseManager disguiseManager, ConditionManager conditionManager)
{ {
super("Damage Manager", plugin); super("Damage Manager", plugin);
@ -79,6 +85,102 @@ public class DamageManager extends MiniPlugin
} }
registerEvents(new NpcProtectListener(npcManager)); registerEvents(new NpcProtectListener(npcManager));
_protectionTypeModifiers.put(Enchantment.PROTECTION_ENVIRONMENTAL.getName(), 1);
_protectionTypeModifiers.put(Enchantment.PROTECTION_FIRE.getName(), 2);
_protectionTypeModifiers.put(Enchantment.PROTECTION_EXPLOSIONS.getName(), 2);
_protectionTypeModifiers.put(Enchantment.PROTECTION_PROJECTILE.getName(), 2);
_protectionTypeModifiers.put(Enchantment.PROTECTION_FALL.getName(), 3);
_protectionCauses.put(Enchantment.PROTECTION_ENVIRONMENTAL.getName(), new DamageCause[] {DamageCause.BLOCK_EXPLOSION, DamageCause.CONTACT, DamageCause.CUSTOM, DamageCause.DROWNING, DamageCause.ENTITY_ATTACK, DamageCause.ENTITY_EXPLOSION, DamageCause.FALL, DamageCause.FALLING_BLOCK, DamageCause.FIRE, DamageCause.FIRE_TICK, DamageCause.LAVA, DamageCause.LIGHTNING, DamageCause.PROJECTILE, DamageCause.SUFFOCATION, DamageCause.THORNS});
_protectionCauses.put(Enchantment.PROTECTION_FIRE.getName(), new DamageCause[] {DamageCause.FIRE, DamageCause.FIRE_TICK, DamageCause.LAVA});
_protectionCauses.put(Enchantment.PROTECTION_EXPLOSIONS.getName(), new DamageCause[] {DamageCause.BLOCK_EXPLOSION, DamageCause.ENTITY_EXPLOSION});
_protectionCauses.put(Enchantment.PROTECTION_PROJECTILE.getName(), new DamageCause[] {DamageCause.PROJECTILE});
_protectionCauses.put(Enchantment.PROTECTION_FALL.getName(), new DamageCause[] {DamageCause.FALL});
}
private int getHighestLevel(Enchantment ench, ItemStack[] items)
{
int level = 0;
for (ItemStack item : items)
{
if (item == null && item.getType() == Material.AIR)
{
continue;
}
if (!item.containsEnchantment(ench))
{
continue;
}
if (item.getEnchantmentLevel(ench) <= level)
{
continue;
}
level = item.getEnchantmentLevel(ench);
}
return level;
}
private int getTotalEPF(Enchantment ench, ItemStack[] items)
{
if (!_protectionTypeModifiers.containsKey(ench.getName()))
{
return 0;
}
if (!_protectionCauses.containsKey(ench.getName()))
{
return 0;
}
int epf = 0;
for (ItemStack item : items)
{
if (item == null || item.getType() == Material.AIR)
{
continue;
}
if (!item.containsEnchantment(ench))
{
continue;
}
if (item.getEnchantmentLevel(ench) <= 0)
{
continue;
}
epf += (item.getEnchantmentLevel(ench) * _protectionTypeModifiers.get(ench.getName()));
}
return Math.min(20, epf);
}
private double getTotalEnchantReduction(ItemStack[] armor, DamageCause cause)
{
int epf = 0;
for (Enchantment ench : Enchantment.values())
{
if (!_protectionTypeModifiers.containsKey(ench.getName()))
{
continue;
}
if (!_protectionCauses.containsKey(ench.getName()))
{
continue;
}
if (!Arrays.asList(_protectionCauses.get(ench.getName())).contains(cause))
{
continue;
}
epf += getTotalEPF(ench, armor);
}
epf = Math.max(0, Math.min(20, epf));
return new BigDecimal(1).subtract(new BigDecimal(epf).divide(new BigDecimal(25))).doubleValue();
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
@ -273,35 +375,9 @@ public class DamageManager extends MiniPlugin
Player damagee = event.GetDamageePlayer(); Player damagee = event.GetDamageePlayer();
if (damagee != null) if (damagee != null)
{ {
for (ItemStack stack : damagee.getInventory().getArmorContents()) if (getTotalEnchantReduction(damagee.getInventory().getArmorContents(), event.GetCause()) > 0)
{ {
if (stack == null) event.AddMult("Ench Prot", damagee.getName(), getTotalEnchantReduction(damagee.getInventory().getArmorContents(), event.GetCause()), false);
continue;
Map<Enchantment, Integer> enchants = stack.getEnchantments();
for (Enchantment e : enchants.keySet())
{
if (e.equals(Enchantment.PROTECTION_ENVIRONMENTAL))
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
else if (e.equals(Enchantment.PROTECTION_FIRE) &&
event.GetCause() == DamageCause.FIRE &&
event.GetCause() == DamageCause.FIRE_TICK &&
event.GetCause() == DamageCause.LAVA)
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
else if (e.equals(Enchantment.PROTECTION_FALL) &&
event.GetCause() == DamageCause.FALL)
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
else if (e.equals(Enchantment.PROTECTION_EXPLOSIONS) &&
event.GetCause() == DamageCause.ENTITY_EXPLOSION)
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
else if (e.equals(Enchantment.PROTECTION_PROJECTILE) &&
event.GetCause() == DamageCause.PROJECTILE)
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
}
} }
} }
@ -324,8 +400,15 @@ public class DamageManager extends MiniPlugin
else if (e.equals(Enchantment.FIRE_ASPECT)) else if (e.equals(Enchantment.FIRE_ASPECT))
if (_conditionManager != null) if (_conditionManager != null)
{
double reduce = 0;
if (damagee != null)
{
reduce = (15 * getHighestLevel(Enchantment.PROTECTION_FIRE, damagee.getInventory().getArmorContents())) * (4 * (double)enchants.get(e));
}
_conditionManager.Factory().Ignite("Ench Fire", event.GetDamageeEntity(), damager, _conditionManager.Factory().Ignite("Ench Fire", event.GetDamageeEntity(), damager,
4 * (double)enchants.get(e), false, false); (4 * (double)enchants.get(e)) - reduce, false, false);
}
} }
} }

View File

@ -7,6 +7,7 @@ import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack; import mineplex.core.antihack.AntiHack;
import mineplex.core.chat.Chat; import mineplex.core.chat.Chat;
import mineplex.core.command.CommandCenter; import mineplex.core.command.CommandCenter;
import mineplex.core.common.Rank;
import mineplex.core.creature.Creature; import mineplex.core.creature.Creature;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.elo.EloManager; import mineplex.core.elo.EloManager;
@ -48,7 +49,7 @@ public class StaffServer extends JavaPlugin
//Static Modules //Static Modules
CommandCenter.Initialize(this); CommandCenter.Initialize(this);
CoreClientManager clientManager = new CoreClientManager(this, webServerAddress); CoreClientManager clientManager = new CoreClientManager(this, webServerAddress, Rank.DEVELOPER);
CommandCenter.Instance.setClientManager(clientManager); CommandCenter.Instance.setClientManager(clientManager);
Recharge.Initialize(this); Recharge.Initialize(this);
@ -83,15 +84,15 @@ public class StaffServer extends JavaPlugin
((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("cf1b629c-cc55-4eb4-be9e-3ca86dfc7b9d"), "mannalou")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("cf1b629c-cc55-4eb4-be9e-3ca86dfc7b9d"), "mannalou"));
((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("04a484d0-93e0-4777-a70c-808046917e3a"), "EvilEsther")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("04a484d0-93e0-4777-a70c-808046917e3a"), "EvilEsther"));
((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("adaa7613-6683-400f-baf8-7272c04b2cb4"), "Timmy48081_")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("adaa7613-6683-400f-baf8-7272c04b2cb4"), "Timmy48081_"));
((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("57791647-93b1-4980-8835-7fddadd20eb8"), "xTheOnlyOreOx")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("231fb752-9556-489b-8428-f47c7598e061"), "Nuclear_Poptart"));
((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("efaf9a17-2304-4f42-8433-421523c308dc"), "B2_mp")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("efaf9a17-2304-4f42-8433-421523c308dc"), "B2_mp"));
((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("492ff708-fe76-4c5a-b9ed-a747b5fa20a0"), "Cherdy8s")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("492ff708-fe76-4c5a-b9ed-a747b5fa20a0"), "Cherdy8s"));
((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("cf85f470-5248-4978-8208-435736fa136e"), "RustyRoo")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("6edf17d5-6bb2-4ed9-92e9-bed8e96fff68"), "BlueBeetleHD"));
((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("377bdea3-badc-448d-81c1-65db43b17ea4"), "Strutt20")); ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("377bdea3-badc-448d-81c1-65db43b17ea4"), "Strutt20"));
((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("efaf9a17-2304-4f42-8433-421523c308dc"), "B2_mp")); ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("efaf9a17-2304-4f42-8433-421523c308dc"), "B2_mp"));
((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("cf85f470-5248-4978-8208-435736fa136e"), "RustyRoo")); ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("6edf17d5-6bb2-4ed9-92e9-bed8e96fff68"), "BlueBeetleHD"));
new ProfileCacheManager(this); new ProfileCacheManager(this);
} }

View File

@ -57,9 +57,9 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable
@EventHandler @EventHandler
public void Join(PlayerJoinEvent event) public void Join(PlayerJoinEvent event)
{ {
if (!_clientManager.Get(event.getPlayer()).GetRank().has(Rank.MODERATOR)) if (!_clientManager.Get(event.getPlayer()).GetRank().has(Rank.SUPPORT))
{ {
event.getPlayer().kickPlayer("Only for staff."); event.getPlayer().kickPlayer("Only for support staff.");
return; return;
} }
@ -119,7 +119,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable
caller.sendMessage(C.cDGreen + C.Strike + "============================================="); caller.sendMessage(C.cDGreen + C.Strike + "=============================================");
caller.sendMessage(C.cBlue + "Name: " + C.cYellow + playerName); caller.sendMessage(C.cBlue + "Name: " + C.cYellow + playerName);
caller.sendMessage(C.cBlue + "Rank: " + C.cYellow + (client.GetRank() == null ? C.cRed + "Error rank null!" : (client.GetRank().Name.isEmpty() ? "Regular" : client.GetRank().Name))); caller.sendMessage(C.cBlue + "Rank: " + C.cYellow + (client.GetRank() == null ? C.cRed + "Error rank null!" : (client.GetRank().Name.isEmpty() ? "Regular" : client.GetRank().Name)));
caller.sendMessage(C.cBlue + "Coins: " + C.cYellow + donor.getCoins()); caller.sendMessage(C.cBlue + "Shards: " + C.cYellow + donor.getCoins());
caller.sendMessage(C.cBlue + "Gems: " + C.cYellow + donor.GetGems()); caller.sendMessage(C.cBlue + "Gems: " + C.cYellow + donor.GetGems());
int enjinCoinsReceived = 0; int enjinCoinsReceived = 0;
@ -234,7 +234,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable
} }
// Strutt20 asked me to remove some stuff from the menu // Strutt20 asked me to remove some stuff from the menu
caller.sendMessage(C.cBlue + "Enjin Coin Total Received: " + C.cYellow + enjinCoinsReceived); caller.sendMessage(C.cBlue + "Enjin Shard Total Received: " + C.cYellow + enjinCoinsReceived);
caller.sendMessage(C.cBlue + "Old Chests Received: " + C.cYellow + oldChestsReceived); caller.sendMessage(C.cBlue + "Old Chests Received: " + C.cYellow + oldChestsReceived);
caller.sendMessage(C.cBlue + "Ancient Chests Received: " + C.cYellow + ancientChestsReceived); caller.sendMessage(C.cBlue + "Ancient Chests Received: " + C.cYellow + ancientChestsReceived);
caller.sendMessage(C.cBlue + "Mythical Chests Received: " + C.cYellow + mythicalChestsReceived); caller.sendMessage(C.cBlue + "Mythical Chests Received: " + C.cYellow + mythicalChestsReceived);

View File

@ -94,7 +94,7 @@ public class SalesPackageManager extends MiniPlugin
public void displaySalesPackages(Player caller, String playerName) public void displaySalesPackages(Player caller, String playerName)
{ {
JsonMessage coinBuilder = new JsonMessage("Coins : ").color("blue"); JsonMessage coinBuilder = new JsonMessage("Shards : ").color("blue");
JsonMessage packageBuilder = new JsonMessage("Rank Packages : ").color("blue"); JsonMessage packageBuilder = new JsonMessage("Rank Packages : ").color("blue");
JsonMessage chestBuilder = new JsonMessage("Chest Packages : ").color("blue"); JsonMessage chestBuilder = new JsonMessage("Chest Packages : ").color("blue");
@ -104,7 +104,7 @@ public class SalesPackageManager extends MiniPlugin
{ {
coinBuilder = coinBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); coinBuilder = coinBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray");
} }
else if (salesPackage instanceof MythicalChest || salesPackage instanceof AncientChest || salesPackage instanceof OldChest || salesPackage instanceof IlluminatedChest) else if (salesPackage instanceof MythicalChest || salesPackage instanceof AncientChest || salesPackage instanceof OldChest || salesPackage instanceof IlluminatedChest || salesPackage instanceof FreedomChest)
{ {
chestBuilder = chestBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); chestBuilder = chestBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray");
} }

View File

@ -17,7 +17,7 @@ public class CoinCommand extends CommandBase<SalesPackageManager>
{ {
public CoinCommand(SalesPackageManager plugin) public CoinCommand(SalesPackageManager plugin)
{ {
super(plugin, Rank.MODERATOR, "coin"); super(plugin, Rank.MODERATOR, "coin", "shard", "shards");
} }
@Override @Override
@ -43,11 +43,11 @@ public class CoinCommand extends CommandBase<SalesPackageManager>
{ {
if (completed) if (completed)
{ {
caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " coins to " + playerName + "'s account!")); caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " shards to " + playerName + "'s account!"));
} }
else else
{ {
UtilPlayer.message(caller, F.main(Plugin.getName(), "There was an error giving " + F.elem(amount + "Coins") + " to " + F.name(playerName) + ".")); UtilPlayer.message(caller, F.main(Plugin.getName(), "There was an error giving " + F.elem(amount + "Shards") + " to " + F.name(playerName) + "."));
} }
} }
}, caller.getName(), playerName, client.getAccountId(), amount); }, caller.getName(), playerName, client.getAccountId(), amount);

View File

@ -10,13 +10,13 @@ public class Coins extends SalesPackageBase
public Coins(SalesPackageManager manager, int amount) public Coins(SalesPackageManager manager, int amount)
{ {
super(manager, amount + " Coins"); super(manager, amount + " Shards");
_amount = amount; _amount = amount;
} }
public void displayToAgent(Player agent, String playerName) public void displayToAgent(Player agent, String playerName)
{ {
addButton(agent, "/sales coin " + playerName + " " + _amount, _amount + " Coins."); addButton(agent, "/sales coin " + playerName + " " + _amount, _amount + " Shards.");
agent.sendMessage(" "); agent.sendMessage(" ");
addBackButton(agent, playerName); addBackButton(agent, playerName);
} }

View File

@ -19,5 +19,9 @@
<artifactId>mineplex-minecraft-game-classcombat</artifactId> <artifactId>mineplex-minecraft-game-classcombat</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -917,7 +917,7 @@ public abstract class Game implements Listener
if (GetKit(player) == null) if (GetKit(player) == null)
return false; return false;
return GetKit(player).equals(kit); return GetKit(player).GetName().equals(kit.GetName());
} }
public boolean SetPlayerState(Player player, PlayerState state) public boolean SetPlayerState(Player player, PlayerState state)

View File

@ -268,11 +268,18 @@ public class GameTeam
return GetColor() + "§l" + GetName(); return GetColor() + "§l" + GetName();
} }
public void SpawnTeleport(Player player) public Location SpawnTeleport(Player player)
{
Location l = GetSpawn();
player.teleport(l);
return l;
}
public void SpawnTeleport(Player player, Location location)
{ {
player.leaveVehicle(); player.leaveVehicle();
player.eject(); player.eject();
player.teleport(GetSpawn()); player.teleport(location);
} }
public void SpawnTeleport() public void SpawnTeleport()

View File

@ -1505,6 +1505,11 @@ public class Build extends Game
{ {
Player player = ((Player) event.getWhoClicked()); Player player = ((Player) event.getWhoClicked());
if (_buildGameState == 2 || _buildGameState == 3)
{
event.setCancelled(true);
}
if (IsLive() && IsAlive(player)) if (IsLive() && IsAlive(player))
{ {
BuildData buildData = _data.get(player); BuildData buildData = _data.get(player);

View File

@ -632,8 +632,15 @@ public class DragonEscape extends SoloGame
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) public void onPlayerInteract(PlayerInteractEvent event)
{ {
if (!IsLive())
return;
if (event.getClickedBlock() == null)
return;
if(event.getClickedBlock().getType() != Material.TRAP_DOOR) if(event.getClickedBlock().getType() != Material.TRAP_DOOR)
return; return;
// Stops players using trap doors in game. // Stops players using trap doors in game.
event.setCancelled(true); event.setCancelled(true);
} }

View File

@ -21,7 +21,7 @@ public class HotbarInventory
{ {
Inventory inv = UtilServer.getServer().createInventory(null, 36, "Hotbar Editor"); Inventory inv = UtilServer.getServer().createInventory(null, 36, "Hotbar Editor");
for (int slot : Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 18, 19, 20, 21, 22, 23, 24, 25, 26)) for (int slot : Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 31, 33, 34, 35))
{ {
inv.setItem(slot, getGlass(slot)); inv.setItem(slot, getGlass(slot));
} }

View File

@ -8,12 +8,21 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
/** /**
* Created by William (WilliamTiger). * Created by William (WilliamTiger).
@ -140,4 +149,51 @@ public class HotbarPageListener implements Listener
i.remove(); i.remove();
} }
@EventHandler
public void updateInv(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
return;
for (Player player : UtilServer.GetPlayers())
{
if (player.getOpenInventory() == null)
continue;
if (player.getOpenInventory().getTopInventory() == null)
continue;
if (!player.getOpenInventory().getTopInventory().getName().equals("Hotbar Editor"))
continue;
for (Material mat : new Material[]{Material.DIAMOND_SWORD, Material.BOW, Material.FISHING_ROD, Material.ARROW})
{
boolean founditem = false;
for (ItemStack item : player.getOpenInventory().getTopInventory().getContents())
{
if (item != null && item.getType() == mat)
{
founditem = true;
}
}
if (player.getItemOnCursor() != null)
{
if (player.getItemOnCursor().getType() == mat)
founditem = true;
}
if (!founditem)
{
player.getOpenInventory().getTopInventory().addItem(new ItemStack(mat));
}
if (UtilInv.contains(player, null, mat, (byte) 0, 1, false, true, false))
{
UtilInv.removeAll(player, mat, (byte) 0);
}
}
}
}
} }

View File

@ -7,6 +7,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import nautilus.game.arcade.game.games.lobbers.events.TNTThrowEvent; import nautilus.game.arcade.game.games.lobbers.events.TNTThrowEvent;
@ -76,6 +77,11 @@ public class PerkWaller extends Perk
return; return;
} }
if (!Recharge.Instance.usable(event.getPlayer(), "Waller"))
return;
Recharge.Instance.use(event.getPlayer(), "Waller", 100, false, false);
UtilInv.remove(event.getPlayer(), Material.STONE_SPADE, (byte) 0, 1); UtilInv.remove(event.getPlayer(), Material.STONE_SPADE, (byte) 0, 1);
_wallBlocks.addAll(buildWall(event.getClickedBlock().getLocation(), event.getPlayer().getLocation().getYaw())); _wallBlocks.addAll(buildWall(event.getClickedBlock().getLocation(), event.getPlayer().getLocation().getYaw()));

View File

@ -331,7 +331,7 @@ public class Gun extends StrikeItem
{ {
new BukkitRunnable() { new BukkitRunnable() {
public void run() { public void run() {
PlayerStats remoteStats = game.getArcadeManager().GetStatsManager().Get(player);; PlayerStats remoteStats = game.getArcadeManager().GetStatsManager().Get(player);
_kills = (int) remoteStats.getStat(game.GetName() + "." + getStatNameKills(true)); _kills = (int) remoteStats.getStat(game.GetName() + "." + getStatNameKills(true));
Player owner = UtilPlayer.searchExact(getOwnerName()); Player owner = UtilPlayer.searchExact(getOwnerName());

View File

@ -48,6 +48,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
public class MonsterMaze extends SoloGame public class MonsterMaze extends SoloGame
@ -61,6 +63,9 @@ public class MonsterMaze extends SoloGame
private HashMap<Player, Long> _launched = new HashMap<Player, Long>(); private HashMap<Player, Long> _launched = new HashMap<Player, Long>();
private static final int JUMP_POTION_AMPLIFIER = -10;
private int _potionMult = JUMP_POTION_AMPLIFIER;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public MonsterMaze(ArcadeManager manager) public MonsterMaze(ArcadeManager manager)
{ {
@ -260,6 +265,36 @@ public class MonsterMaze extends SoloGame
} }
} }
@EventHandler
public void onDebug(PlayerCommandPreprocessEvent event)
{
if (!event.getPlayer().isOp())
return;
if (event.getMessage().toLowerCase().contains("/setmult "))
{
event.setCancelled(true);
Integer mult = Integer.parseInt(event.getMessage().toLowerCase().replace("/setmult ", ""));
_potionMult = mult;
for (Player pl : GetPlayers(true))
{
Manager.GetCondition().Clean(pl);
}
}
}
@EventHandler
public void onBreakJumper(InventoryClickEvent event)
{
if (!InProgress())
return;
if (!IsAlive(event.getWhoClicked()))
return;
event.setCancelled(true);
}
@EventHandler @EventHandler
public void PotionEffects(UpdateEvent event) public void PotionEffects(UpdateEvent event)
{ {
@ -276,7 +311,7 @@ public class MonsterMaze extends SoloGame
else else
{ {
if (!Manager.GetCondition().HasCondition(pl, ConditionType.JUMP, null)) if (!Manager.GetCondition().HasCondition(pl, ConditionType.JUMP, null))
Manager.GetCondition().Factory().Jump("No jumping", pl, null, 9999999, 250, true, false, false); Manager.GetCondition().Factory().Jump("No jumping", pl, null, 9999999, _potionMult, true, false, false);
} }
// if (!Manager.GetCondition().HasCondition(pl, ConditionType.INVISIBILITY, null)) // if (!Manager.GetCondition().HasCondition(pl, ConditionType.INVISIBILITY, null))

View File

@ -42,7 +42,7 @@ public class KitJumper extends ProgressingKit
@Override @Override
public void GiveItems(Player player) public void GiveItems(Player player)
{ {
player.getInventory().setItem(4, PLAYER_ITEMS[4]); player.getInventory().setItem(4, PLAYER_ITEMS[0]);
player.getInventory().setItem(8, PLAYER_ITEMS[8]); player.getInventory().setItem(8, PLAYER_ITEMS[1]);
} }
} }

View File

@ -4,6 +4,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
@ -11,6 +12,7 @@ import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkArrowRebound; import nautilus.game.arcade.kit.perks.PerkArrowRebound;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -31,7 +33,7 @@ public class KitEnchanter extends ProgressingKit
private static final ItemStack IN_HAND = new ItemStack(Material.BOW); private static final ItemStack IN_HAND = new ItemStack(Material.BOW);
private static final ItemStack[] PLAYER_ITEMS = { private static final ItemStack[] PLAYER_ITEMS = {
ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD), new ItemBuilder(Material.STONE_SWORD).setGlow(true).build(),
ItemStackFactory.Instance.CreateStack(Material.BOW) ItemStackFactory.Instance.CreateStack(Material.BOW)
}; };

View File

@ -31,7 +31,7 @@ public class KitLeaper extends ProgressingKit
private static final ItemStack IN_HAND = new ItemStack(Material.STONE_SWORD); private static final ItemStack IN_HAND = new ItemStack(Material.STONE_SWORD);
private static final ItemStack[] PLAYER_ITEMS = { private static final ItemStack[] PLAYER_ITEMS = {
ItemStackFactory.Instance.CreateStack(Material.IRON_AXE), ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD),
ItemStackFactory.Instance.CreateStack(Material.BOW) ItemStackFactory.Instance.CreateStack(Material.BOW)
}; };

View File

@ -674,8 +674,7 @@ public abstract class Skywars extends Game
Player player = e.getPlayer(); Player player = e.getPlayer();
if (is.getType() == Material.TNT) if (is.getType() == Material.TNT)
{ {
e.setCancelled(true); e.setCancelled(_tntGen.pickup(player, e.getItem()));
_tntGen.pickup(player, e.getItem());
} }
} }

View File

@ -76,23 +76,23 @@ public class TNTGenerator
.trail(true).build()); .trail(true).build());
} }
public void pickup(Player player, Item item) public boolean pickup(Player player, Item item)
{ {
if (_ent == null) if (_ent == null)
return; return false;
if (!_ent.equals(item)) if (!_ent.equals(item))
return; return false;
if (!Host.IsAlive(player)) if (!Host.IsAlive(player))
return; return true;
if (Host.Manager.isSpectator(player)) if (Host.Manager.isSpectator(player))
return; return true;
GameTeam team = Host.GetTeam(player); GameTeam team = Host.GetTeam(player);
if (team == null) if (team == null)
return; return true;
// Remove // Remove
_ent.remove(); _ent.remove();
@ -124,6 +124,7 @@ public class TNTGenerator
player.playSound(player.getLocation(), Sound.ENDERDRAGON_HIT, 3F, 1F); player.playSound(player.getLocation(), Sound.ENDERDRAGON_HIT, 3F, 1F);
Bukkit.getPluginManager().callEvent(new TNTPickupEvent(player)); Bukkit.getPluginManager().callEvent(new TNTPickupEvent(player));
return true;
} }
public String getScoreboardInfo() public String getScoreboardInfo()

View File

@ -37,6 +37,7 @@ import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
@ -1937,6 +1938,15 @@ public abstract class SurvivalGames extends Game
} }
} }
@EventHandler
public void craftedItems(CraftItemEvent event)
{
if (UtilItem.isWeapon(event.getCurrentItem()) || UtilItem.isArmor(event.getCurrentItem()))
{
UtilItem.makeUnbreakable(event.getCurrentItem());
}
}
@EventHandler @EventHandler
public void UpdateNametagVisibility(UpdateEvent event) public void UpdateNametagVisibility(UpdateEvent event)
{ {

View File

@ -1,14 +1,27 @@
package nautilus.game.arcade.game.games.uhc; package nautilus.game.arcade.game.games.uhc;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import com.mineplex.spigot.ChunkPreLoadEvent;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.access.IViolationInfo;
import fr.neatmonster.nocheatplus.hooks.NCPHook;
import fr.neatmonster.nocheatplus.hooks.NCPHookManager;
import mineplex.core.common.Pair;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
@ -34,38 +47,35 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.serverdata.Utility; import mineplex.serverdata.Utility;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GamePrepareCountdownCommence;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import net.minecraft.server.v1_8_R3.BiomeCache; import net.minecraft.server.v1_8_R3.BiomeCache;
import net.minecraft.server.v1_8_R3.ChunkCoordIntPair;
import net.minecraft.server.v1_8_R3.ChunkProviderServer; import net.minecraft.server.v1_8_R3.ChunkProviderServer;
import net.minecraft.server.v1_8_R3.EmptyChunk; import net.minecraft.server.v1_8_R3.ChunkRegionLoader;
import net.minecraft.server.v1_8_R3.ExceptionWorldConflict;
import net.minecraft.server.v1_8_R3.FileIOThread; import net.minecraft.server.v1_8_R3.FileIOThread;
import net.minecraft.server.v1_8_R3.IChunkLoader;
import net.minecraft.server.v1_8_R3.IChunkProvider; import net.minecraft.server.v1_8_R3.IChunkProvider;
import net.minecraft.server.v1_8_R3.LongHashMap;
import net.minecraft.server.v1_8_R3.MinecraftServer; import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.NBTTagCompound; import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.World;
import net.minecraft.server.v1_8_R3.WorldChunkManager; import net.minecraft.server.v1_8_R3.WorldChunkManager;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.Difficulty; import org.bukkit.Difficulty;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.WorldBorder; import org.bukkit.WorldBorder;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.generator.NormalChunkGenerator;
import org.bukkit.craftbukkit.v1_8_R3.util.LongHash; import org.bukkit.craftbukkit.v1_8_R3.util.LongHash;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -74,24 +84,27 @@ import org.bukkit.entity.Ghast;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster; import org.bukkit.entity.Monster;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
@ -107,10 +120,16 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Objective;
import org.spigotmc.WatchdogThread; import org.spigotmc.AsyncCatcher;
public class UHC extends TeamGame public class UHC extends TeamGame implements NCPHook
{ {
// The view distance of UHC. The amount of time and ram needed grows polynomially
private static final int VIEW_DISTANCE = 5;
// The number of threads to use for reading chunks from disk
private static final int THREADS_FOR_CHUNK_LOADING = 4;
private NautHashMap<Player, Player> _teamReqs = new NautHashMap<Player, Player>(); private NautHashMap<Player, Player> _teamReqs = new NautHashMap<Player, Player>();
private NautHashMap<String, Long> _deathTime = new NautHashMap<String, Long>(); private NautHashMap<String, Long> _deathTime = new NautHashMap<String, Long>();
@ -145,6 +164,14 @@ public class UHC extends TeamGame
private double _previousBorder = 1000; private double _previousBorder = 1000;
private long _borderStartedMoving; private long _borderStartedMoving;
private volatile boolean _isDecorating = false;
private volatile boolean _allowSpawning = true;
private int _teleportedPlayers = -1;
private int _totalPlayers = 0;
private AtomicInteger actual = new AtomicInteger();
private AtomicInteger expected = new AtomicInteger(23000); // Most likely it'll be around 23000
public UHC(ArcadeManager manager) public UHC(ArcadeManager manager)
{ {
this(manager, GameType.UHC); this(manager, GameType.UHC);
@ -213,8 +240,6 @@ public class UHC extends TeamGame
this.WorldBoundaryKill = false; this.WorldBoundaryKill = false;
this.TickPerTeleport = 3;
this.GemBoosterEnabled = false; this.GemBoosterEnabled = false;
this.GemDoubleEnabled = false; this.GemDoubleEnabled = false;
this.GemHunterEnabled = false; this.GemHunterEnabled = false;
@ -243,6 +268,8 @@ public class UHC extends TeamGame
_createTime = System.currentTimeMillis(); _createTime = System.currentTimeMillis();
_serverTime = Utility.currentTimeMillis(); _serverTime = Utility.currentTimeMillis();
NCPHookManager.addHook(CheckType.ALL, this);
} }
@Override @Override
@ -274,23 +301,6 @@ public class UHC extends TeamGame
border.setWarningTime(-99); border.setWarningTime(-99);
} }
@EventHandler
public void onDamage(CustomDamageEvent event)
{
if (!IsLive())
return;
if (UtilTime.elapsed(getGameLiveTime(), 20000))
return;
if (!(event.GetDamageeEntity() instanceof Player))
return;
event.SetCancelled("Spawn Invincibility");
event.GetDamageeEntity().setFireTicks(0);
}
@EventHandler @EventHandler
public void onSecond(UpdateEvent event) public void onSecond(UpdateEvent event)
{ {
@ -479,6 +489,333 @@ public class UHC extends TeamGame
} }
TimingManager.stop("UHC Spawn Generation"); TimingManager.stop("UHC Spawn Generation");
Location spawn = GetRandomSpawn(WorldData.World.getSpawnLocation());
WorldData.World.setSpawnLocation(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ());
WorldServer worldServer = ((CraftWorld) WorldData.World).getHandle();
// Update view distance
worldServer.spigotConfig.viewDistance = VIEW_DISTANCE;
worldServer.getPlayerChunkMap().a(VIEW_DISTANCE);
if (Runtime.getRuntime().maxMemory() / 1024 / 1024 < 2048)
{
Announce(C.cGreen + C.Bold + "Skipping spawn pregeneration", false);
return;
}
// Ensures the server does not tick us
worldServer.getMinecraftServer().worlds.remove(worldServer);
_allowSpawning = false;
new Thread(() ->
{
try
{
TimingManager.start("UHC Chunk Loading");
ChunkProviderServer chunkProviderServer = worldServer.chunkProviderServer;
Field chunkLoaderField = chunkProviderServer.getClass().getDeclaredField("chunkLoader");
chunkLoaderField.setAccessible(true);
ChunkRegionLoader loader = (ChunkRegionLoader) chunkLoaderField.get(chunkProviderServer);
Map<Long, net.minecraft.server.v1_8_R3.Chunk> loaded = new ConcurrentHashMap<>();
Map<Long, NBTTagCompound> compounds = new ConcurrentHashMap<>();
// Step 1: Read all the required chunks from the disk
// We're going to read all the required chunks from disk async
{
Set<Pair<Integer, Integer>> coordPairs = new HashSet<>();
// Special case for 0, 0
{
int x = spawn.getBlockX() >> 4;
int z = spawn.getBlockZ() >> 4;
for (int dx = -VIEW_DISTANCE; dx <= VIEW_DISTANCE; dx++)
{
for (int dz = -VIEW_DISTANCE; dz <= VIEW_DISTANCE; dz++)
{
coordPairs.add(Pair.create(x + dx, z + dz));
}
}
}
// All the team spawns
{
for (int i = 0; i < GetTeamList().size(); i++)
{
GameTeam team = GetTeamList().get(i);
for (Location l : team.GetSpawns())
{
int x = l.getChunk().getX();
int z = l.getChunk().getZ();
for (int dx = -VIEW_DISTANCE; dx <= VIEW_DISTANCE; dx++)
{
for (int dz = -VIEW_DISTANCE; dz <= VIEW_DISTANCE; dz++)
{
coordPairs.add(Pair.create(x + dx, z + dz));
}
}
}
}
}
// Sigh... I don't want this to be here but it needs to be set somewhere...
// Multiply by 3 because there are 3 stages
expected.set(coordPairs.size() * 3);
// Load them now
ExecutorService chunkLoaders = Executors.newFixedThreadPool(THREADS_FOR_CHUNK_LOADING);
for (Pair<Integer, Integer> coords : coordPairs)
{
chunkLoaders.submit(() ->
{
try
{
Object[] data = loader.loadChunk(worldServer, coords.getLeft(), coords.getRight());
if (data != null)
{
NBTTagCompound compound = (NBTTagCompound) data[1];
net.minecraft.server.v1_8_R3.Chunk chunk = (net.minecraft.server.v1_8_R3.Chunk) data[0];
loaded.put(LongHash.toLong(coords.getLeft(), coords.getRight()), chunk);
compounds.put(LongHash.toLong(coords.getLeft(), coords.getRight()), compound);
}
else
{
System.out.println("Failed to load chunk " + coords.getLeft() + "," + coords.getRight());
}
}
catch (Throwable t)
{
t.printStackTrace();
}
finally
{
actual.getAndIncrement();
}
});
}
chunkLoaders.shutdown();
// We've got plenty of time to wait
System.out.println("Finished submitting tasks to executor, waiting...");
chunkLoaders.awaitTermination(1, TimeUnit.DAYS);
System.out.println("Loaded: " + loaded.size() + " and coords: " + coordPairs.size());
}
// Step 2: Recreate structures, update neighbors, load entities
// This step should be super quick so there's no point in scheduling it elsewhere
// Code is plain copypasted from ChunkIOProvider
{
for (net.minecraft.server.v1_8_R3.Chunk chunk : loaded.values())
{
NBTTagCompound compound = compounds.get(LongHash.toLong(chunk.locX, chunk.locZ));
loader.loadEntities(chunk, compound.getCompound("Level"), worldServer);
chunk.setLastSaved(chunkProviderServer.world.getTime());
if (chunkProviderServer.chunkProvider != null)
{
chunkProviderServer.chunkProvider.recreateStructures(chunk, chunk.locX, chunk.locZ);
}
for (int x = -2; x < 3; ++x)
{
for (int z = -2; z < 3; ++z)
{
if (x != 0 || z != 0)
{
net.minecraft.server.v1_8_R3.Chunk neighbor = loaded.get(LongHash.toLong(chunk.locX + x, chunk.locZ + z));
if (neighbor != null)
{
neighbor.setNeighborLoaded(-x, -z);
chunk.setNeighborLoaded(x, z);
}
}
}
}
actual.getAndIncrement();
}
}
AtomicBoolean lockCompleted = new AtomicBoolean(false);
Object lock = new Object();
// Hop back onto the main thread
Manager.runSync(() ->
{
// We want to add all the chunks to the chunkmap so that the server is not out of sync
for (Map.Entry<Long, net.minecraft.server.v1_8_R3.Chunk> ent : loaded.entrySet())
{
ent.getValue().addEntities();
chunkProviderServer.chunks.put(ent.getKey(), ent.getValue());
}
lockCompleted.set(true);
synchronized (lock)
{
lock.notifyAll();
}
});
if (!lockCompleted.get())
{
synchronized (lock)
{
lock.wait();
}
}
if (!lockCompleted.get())
{
throw new IllegalStateException("Lock was not completed");
}
// Step 3: Decorate the chunks. This step must be performed async as otherwise the server lags way too hard
// Notes: Do not allow the server to tick the world. If this is allowed EntityTracker will raise CME
// NextTickList will also raise errors
// And worst case the server will crash
{
// Live life on the edge
AsyncCatcher.enabled = false;
_isDecorating = true;
int x = 0;
for (net.minecraft.server.v1_8_R3.Chunk chunk : loaded.values())
{
loadNearby(chunkProviderServer, chunkProviderServer, chunk.locX, chunk.locZ, worldServer, chunk);
x++;
if (x % 100 == 0)
{
System.out.println(x);
}
actual.getAndIncrement();
}
TimingManager.stop("UHC Chunk Loading");
_isDecorating = false;
AsyncCatcher.enabled = true;
System.out.println("Expected: " + expected.get() + ", actual: " + actual.get());
Manager.runSync(() ->
{
World world = worldServer.getWorld();
for (Entity entity : world.getLivingEntities())
{
if (!(entity instanceof Player) && !(entity instanceof Villager))
{
entity.remove();
}
}
// You may tick again
worldServer.getMinecraftServer().worlds.add(worldServer);
// Well, if they're not equal, not much we can do. We've hit the end
actual.set(expected.get());
});
}
}
catch (Throwable t)
{
t.printStackTrace();
}
}, "Chunk Loader").start();
}
// Plain copypasted from Chunk, but modified so that it doesn't load surrounding chunks if they're nonexistant
// This decorates the chunks. Do not remove!
public void loadNearby(ChunkProviderServer ichunkprovider, ChunkProviderServer ichunkprovider1, int i, int j, net.minecraft.server.v1_8_R3.World world, net.minecraft.server.v1_8_R3.Chunk chunk1)
{
boolean flag = ichunkprovider.isChunkLoaded(i, j - 1);
boolean flag1 = ichunkprovider.isChunkLoaded(i + 1, j);
boolean flag2 = ichunkprovider.isChunkLoaded(i, j + 1);
boolean flag3 = ichunkprovider.isChunkLoaded(i - 1, j);
boolean flag4 = ichunkprovider.isChunkLoaded(i - 1, j - 1);
boolean flag5 = ichunkprovider.isChunkLoaded(i + 1, j + 1);
boolean flag6 = ichunkprovider.isChunkLoaded(i - 1, j + 1);
boolean flag7 = ichunkprovider.isChunkLoaded(i + 1, j - 1);
if (flag1 && flag2 && flag5)
{
if (!chunk1.isDone())
{
ichunkprovider.getChunkAt(ichunkprovider1, i, j);
}
else
{
ichunkprovider.a(ichunkprovider1, chunk1, i, j);
}
}
net.minecraft.server.v1_8_R3.Chunk chunk;
if (flag3 && flag2 && flag6)
{
chunk = ichunkprovider.getChunkIfLoaded(i - 1, j);
if (chunk != null)
{
if (!chunk.isDone())
{
ichunkprovider.getChunkAt(ichunkprovider1, i - 1, j);
}
else
{
ichunkprovider.a(ichunkprovider1, chunk, i - 1, j);
}
}
}
if (flag && flag1 && flag7)
{
chunk = ichunkprovider.getChunkIfLoaded(i, j - 1);
if (chunk != null)
{
if (!chunk.isDone())
{
ichunkprovider.getChunkAt(ichunkprovider1, i, j - 1);
}
else
{
ichunkprovider.a(ichunkprovider1, chunk, i, j - 1);
}
}
}
if (flag4 && flag && flag3)
{
chunk = ichunkprovider.getChunkIfLoaded(i - 1, j - 1);
if (chunk != null)
{
if (!chunk.isDone())
{
ichunkprovider.getChunkAt(ichunkprovider1, i - 1, j - 1);
}
else
{
ichunkprovider.a(ichunkprovider1, chunk, i - 1, j - 1);
}
}
}
}
@EventHandler
public void on(EntitySpawnEvent event)
{
// Don't allow entity spawns while decorating, period
if (_isDecorating || !_allowSpawning)
{
if (event.getLocation().getWorld().getUID() == WorldData.World.getUID())
{
event.setCancelled(true);
}
}
}
private boolean areSpawnsGenerated()
{
return actual.get() == expected.get();
} }
@EventHandler @EventHandler
@ -675,7 +1012,7 @@ public class UHC extends TeamGame
while (!stopGen) while (!stopGen)
{ {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if ((now - last) >= 4000) if ((now - last) >= 10 * 1000)
{ {
Announce(C.cGreen + C.Bold + "Generating Map: " + C.cWhite + getMapLoadETA() + " Remaining...", false); Announce(C.cGreen + C.Bold + "Generating Map: " + C.cWhite + getMapLoadETA() + " Remaining...", false);
last = now; last = now;
@ -745,6 +1082,170 @@ public class UHC extends TeamGame
}, "WorldGen Thread").start(); }, "WorldGen Thread").start();
} }
@EventHandler
public void on(ChunkUnloadEvent event)
{
if (IsLive())
return;
event.setCancelled(true);
}
private volatile boolean _isTeleporting = false;
@EventHandler
public void on(ChunkPreLoadEvent event)
{
if (_isTeleporting)
{
System.out.println("WARNING: TRIED TO LOAD CHUNK WHILE TELEPORTING: " + event.getX() + " " + event.getZ());
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void on(PlayerKickEvent event)
{
// Don't kick players while teleporting. Probably NCP trying to kick for fly or something
if (_isTeleporting)
{
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOW)
public void PlayerPrepare(GameStateChangeEvent event)
{
final Game game = event.GetGame();
if (event.GetState() != GameState.Prepare)
return;
_isTeleporting = true;
List<Player> players = game.GetPlayers(true);
Location zero = WorldData.World.getSpawnLocation();
for (Player player : players)
{
player.teleport(zero);
// Heal
player.setHealth(player.getMaxHealth());
// Resistance and regen
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 30 * 20, 128), true);
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 30 * 20, 128), true);
}
Announce(C.cGreen + C.Bold + "Please wait while you are teleported to your spawn", false);
_totalPlayers = players.size();
Map<UUID, Location> teleportedLocations = new HashMap<>();
AtomicInteger id = new AtomicInteger();
id.set(UtilServer.getServer().getScheduler().runTaskTimer(Manager.getPlugin(), () ->
{
_teleportedPlayers++;
if (_teleportedPlayers >= players.size())
{
Manager.runSyncLater(() ->
{
try
{
for (Player player : players)
{
GameTeam team = game.GetTeam(player);
if (team != null)
{
if (teleportedLocations.get(player.getUniqueId()) != null)
{
team.SpawnTeleport(player, teleportedLocations.get(player.getUniqueId()));
}
}
// Heal
player.setHealth(player.getMaxHealth());
// Resistance and regen
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 30 * 20, 128), true);
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 30 * 20, 128), true);
}
}
finally
{
game.AnnounceGame();
game.StartPrepareCountdown();
//Event
GamePrepareCountdownCommence gamePrepareCountdownCommence = new GamePrepareCountdownCommence(game);
UtilServer.getServer().getPluginManager().callEvent(gamePrepareCountdownCommence);
_isTeleporting = false;
Manager.runSyncLater(() ->
{
for (Player player : players)
{
player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
player.removePotionEffect(PotionEffectType.REGENERATION);
}
}, 10 * 20L);
// Yes, right now they're both set to 10 seconds, but this may change in the future
Manager.runSyncLater(() ->
{
_allowSpawning = true;
}, 10 * 20L);
}
}, 3 * 20L);
Bukkit.getServer().getScheduler().cancelTask(id.get());
return;
}
Player player = players.get(_teleportedPlayers);
GameTeam team = game.GetTeam(player);
// This could happen if the player left (and rejoined) while teleporting
// Team maps based on player as a key
if (team != null)
{
// Save where they teleported
teleportedLocations.put(player.getUniqueId(), team.SpawnTeleport(player));
// Update scoreboard
_scoreObj.getScore(player).setScore((int) player.getMaxHealth());
game.addPlayerInTime(player);
Manager.Clear(player);
UtilInv.Clear(player);
// Heal
player.setHealth(player.getMaxHealth());
// Resistance and regen
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 30 * 20, 128), true);
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 30 * 20, 128), true);
game.ValidateKit(player, game.GetTeam(player));
if (game.GetKit(player) != null)
game.GetKit(player).ApplyKit(player);
//Event
PlayerPrepareTeleportEvent playerStateEvent = new PlayerPrepareTeleportEvent(game, player);
UtilServer.getServer().getPluginManager().callEvent(playerStateEvent);
}
}, 4 * 20L, 4L).getTaskId());
//Spectators Move
for (Player player : UtilServer.getPlayers())
{
if (Manager.GetGame().IsAlive(player))
continue;
Manager.addSpectator(player, true);
}
}
@EventHandler @EventHandler
public void WorldBoundaryYLimit(BlockPlaceEvent event) public void WorldBoundaryYLimit(BlockPlaceEvent event)
{ {
@ -758,10 +1259,14 @@ public class UHC extends TeamGame
public Location GetRandomSpawn(Location around) public Location GetRandomSpawn(Location around)
{ {
// Sometimes getting a random spawn at 0,0 hangs forever
int tries = 0;
Location loc = null; Location loc = null;
while (loc == null) while (loc == null)
{ {
tries++;
Block block = null; Block block = null;
// Get Team Location // Get Team Location
@ -776,8 +1281,8 @@ public class UHC extends TeamGame
// Get Radius Location // Get Radius Location
else else
{ {
block = UtilBlock.getHighest(WorldData.World, around.getBlockX() - 4 + UtilMath.r(8), around.getBlockZ() - 4 block = UtilBlock.getHighest(WorldData.World, around.getBlockX() - 4 + UtilMath.r(tries < 10 ? 8 : 30), around.getBlockZ() - 4
+ UtilMath.r(8), null); + UtilMath.r(tries < 10 ? 8 : 30), null);
} }
// Check Validity // Check Validity
@ -786,6 +1291,9 @@ public class UHC extends TeamGame
if (block.getRelative(BlockFace.DOWN).isLiquid()) if (block.getRelative(BlockFace.DOWN).isLiquid())
continue; continue;
if (block.getRelative(BlockFace.DOWN).getType() == Material.AIR)
continue;
// Suffocated // Suffocated
if (block.getType() != Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR) if (block.getType() != Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR)
continue; continue;
@ -1273,8 +1781,18 @@ public class UHC extends TeamGame
} }
Scoreboard.WriteBlank(); Scoreboard.WriteBlank();
Scoreboard.Write(C.cYellow + C.Bold + "Time"); if (GetState() == GameState.Prepare)
Scoreboard.Write(UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime())); {
Scoreboard.Write(C.cYellow + C.Bold + "Status");
int players = _teleportedPlayers + 1;
if (players > _totalPlayers) players = _totalPlayers;
Scoreboard.Write("Teleporting Players (" + players + "/" + _totalPlayers + ")");
}
else
{
Scoreboard.Write(C.cYellow + C.Bold + "Time");
Scoreboard.Write(UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime()));
}
Scoreboard.WriteBlank(); Scoreboard.WriteBlank();
Scoreboard.Write(C.cYellow + C.Bold + "Borders"); Scoreboard.Write(C.cYellow + C.Bold + "Borders");
@ -1585,7 +2103,7 @@ public class UHC extends TeamGame
break; break;
} }
if(visible) if (visible)
setOreType(vein); setOreType(vein);
// Remove Vein // Remove Vein
@ -1617,7 +2135,7 @@ public class UHC extends TeamGame
public boolean isMapLoaded() public boolean isMapLoaded()
{ {
return _mapLoaded; return _mapLoaded && areSpawnsGenerated();
} }
public String getMapLoadPercent() public String getMapLoadPercent()
@ -1625,6 +2143,23 @@ public class UHC extends TeamGame
return (int) (_mapLoadPercent * 100) + "%"; return (int) (_mapLoadPercent * 100) + "%";
} }
public String getSpawnGenPercent()
{
return UtilMath.clamp((int) ((actual.get() * 1.0 / expected.get()) * 100), 0, 100) + "%";
}
public String getObjectiveName(boolean _colorTick)
{
if (!getMapLoadPercent().equals("100%"))
{
return getMapLoadPercent() + " " + (_colorTick ? ChatColor.GREEN : ChatColor.YELLOW) + "§l" + "Generating Map";
}
else
{
return getSpawnGenPercent() + " " + (_colorTick ? ChatColor.GREEN : ChatColor.YELLOW) + "§l" + "Generating Spawns";
}
}
public String getMapLoadETA() public String getMapLoadETA()
{ {
int chunksToGo = _chunkTotal - _chunksLoaded; int chunksToGo = _chunkTotal - _chunksLoaded;
@ -1768,4 +2303,26 @@ public class UHC extends TeamGame
return null; return null;
} }
@Override
public String getHookName()
{
return "UHC Hook";
}
@Override
public String getHookVersion()
{
return "0.0.1";
}
@Override
public boolean onCheckFailure(CheckType checkType, Player player, IViolationInfo iViolationInfo)
{
if (GetState() == GameState.Prepare)
{
return false;
}
return true;
}
} }

View File

@ -18,6 +18,7 @@ import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ParticleType;
@ -956,6 +957,9 @@ public class Wizards extends SoloGame
UtilInv.addDullEnchantment(item); UtilInv.addDullEnchantment(item);
} }
if (UtilItem.isArmor(item))
UtilItem.makeUnbreakable(item);
inv.setItem(UtilMath.r(inv.getSize()), item); inv.setItem(UtilMath.r(inv.getSize()), item);
} }

View File

@ -127,6 +127,15 @@ public class PerkBomber extends Perk
UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot drop " + F.item("Throwing TNT") + ".")); UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot drop " + F.item("Throwing TNT") + "."));
} }
@EventHandler (ignoreCancelled = true)
public void on(BlockPlaceEvent event)
{
if (!isThrowingTnt(event.getItemInHand()))
return;
event.setCancelled(true);
UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot place " + F.item("Throwing TNT") + "."));
}
@EventHandler @EventHandler
public void TNTDeathRemove(PlayerDeathEvent event) public void TNTDeathRemove(PlayerDeathEvent event)
{ {
@ -139,6 +148,7 @@ public class PerkBomber extends Perk
int oldAmount = _tntCount.get(event.getEntity()).get(); int oldAmount = _tntCount.get(event.getEntity()).get();
if (oldAmount < remove.size()) if (oldAmount < remove.size())
{ {
// fixme If you die with someone else's tnt, then this will occur
System.out.println("Strange.... expected " + oldAmount + " of tnt for " + event.getEntity().getName() + " but removed " + remove.size() + " instead"); System.out.println("Strange.... expected " + oldAmount + " of tnt for " + event.getEntity().getName() + " but removed " + remove.size() + " instead");
_tntCount.get(event.getEntity()).set(0); _tntCount.get(event.getEntity()).set(0);
} }

View File

@ -6,6 +6,7 @@ import org.bukkit.entity.Horse;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
@ -18,6 +19,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.event.PerkLeapEvent; import nautilus.game.arcade.kit.perks.event.PerkLeapEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PerkLeap extends Perk public class PerkLeap extends Perk
{ {
@ -125,4 +127,22 @@ public class PerkLeap extends Perk
PerkLeapEvent leapEvent = new PerkLeapEvent(player); PerkLeapEvent leapEvent = new PerkLeapEvent(player);
UtilServer.getServer().getPluginManager().callEvent(leapEvent); UtilServer.getServer().getPluginManager().callEvent(leapEvent);
} }
@EventHandler
public void removeDataOnQuit(PlayerQuitEvent event)
{
_uses.remove(event.getPlayer().getName());
}
@EventHandler
public void removeDataOnDeath(PlayerDeathEvent event)
{
_uses.remove(event.getEntity().getName());
}
@Override
public void unregisteredEvents()
{
_uses.clear();
}
} }

View File

@ -1048,7 +1048,7 @@ public class GameLobbyManager implements Listener
{ {
if (Manager.GetGame() instanceof UHC && !((UHC)Manager.GetGame()).isMapLoaded()) if (Manager.GetGame() instanceof UHC && !((UHC)Manager.GetGame()).isMapLoaded())
{ {
objective.setDisplayName(((UHC)Manager.GetGame()).getMapLoadPercent() + " " + (_colorTick ? ChatColor.GREEN : ChatColor.YELLOW) + "§l" + "Generating Map"); objective.setDisplayName(((UHC) Manager.GetGame()).getObjectiveName(_colorTick));
} }
else else
{ {

View File

@ -741,6 +741,10 @@ public class GameManager implements Listener
if (event.GetState() != GameState.Prepare) if (event.GetState() != GameState.Prepare)
return; return;
// Sir, I'll handle this.
if (game instanceof UHC)
return;
final ArrayList<Player> players = game.GetPlayers(true); final ArrayList<Player> players = game.GetPlayers(true);
//Prepare Players //Prepare Players

View File

@ -1,12 +1,19 @@
package nautilus.game.arcade.managers; package nautilus.game.arcade.managers;
import java.util.ArrayList;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTabTitle; import mineplex.core.common.util.UtilTabTitle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
@ -16,6 +23,8 @@ import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.kit.ProgressingKit;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -32,11 +41,12 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
public class GamePlayerManager implements Listener public class GamePlayerManager implements Listener
{ {
ArcadeManager Manager; ArcadeManager Manager;
private static final long PLAYER_VISIBILITY_REFRESH_RATE = 30000;
private static final int VIEW_DISTANCE_BLOCK_VALUE = 8;
private long _lastVisibilityRefresh = 0;
public GamePlayerManager(ArcadeManager manager) public GamePlayerManager(ArcadeManager manager)
{ {
@ -45,6 +55,34 @@ public class GamePlayerManager implements Listener
Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
} }
@EventHandler
public void onRefreshVisibility(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
if (UtilTime.elapsed(_lastVisibilityRefresh, PLAYER_VISIBILITY_REFRESH_RATE))
{
_lastVisibilityRefresh = System.currentTimeMillis();
if (Manager.GetGame() == null)
{
return;
}
for (Player player : Manager.GetGame().GetPlayers(true))
{
if (!Manager.GetCondition().HasCondition(player, ConditionType.INVISIBILITY) && Manager.GetGame().IsAlive(player) && !UtilPlayer.isSpectator(player))
{
for (Player viewer : Bukkit.getOnlinePlayers())
{
if (UtilMath.offset2d(viewer, player) <= (Bukkit.getViewDistance() * VIEW_DISTANCE_BLOCK_VALUE))
{
viewer.showPlayer(player);
}
}
}
}
}
}
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void PlayerDeath(CombatDeathEvent event) public void PlayerDeath(CombatDeathEvent event)
{ {

View File

@ -250,7 +250,7 @@ public class GameScoreboard
if (i >= _chars.length) if (i >= _chars.length)
break; break;
String str = ChatColor.COLOR_CHAR + "" + _chars[i]; String str = ChatColor.COLOR_CHAR + "" + _chars[i] + C.Reset;
Score score = GetObjectiveSide().getScore(str); Score score = GetObjectiveSide().getScore(str);