Merge remote-tracking branch 'origin/master'

This commit is contained in:
Shaun Bennett 2015-05-12 00:37:40 -05:00
commit 06a0f3d0d5
25 changed files with 908 additions and 483 deletions

View File

@ -8,14 +8,16 @@ import org.bukkit.entity.Player;
public enum Rank
{
LT("LT", ChatColor.DARK_RED),
OWNER("Owner", ChatColor.DARK_RED),
DEVELOPER("Dev", ChatColor.RED),
ADMIN("Admin", ChatColor.RED),
SNR_MODERATOR("Sr.Mod", ChatColor.GOLD),
MODERATOR("Mod", ChatColor.GOLD),
HELPER("Helper", ChatColor.DARK_AQUA),
MAPDEV("Builder", ChatColor.BLUE),
HELPER("Trainee", ChatColor.DARK_AQUA),
MAPLEAD("MapLead", ChatColor.DARK_PURPLE),
MAPDEV("Builder", ChatColor.BLUE),
EVENT("Event", ChatColor.WHITE),

View File

@ -12,7 +12,11 @@ public class FileUtil
public static void DeleteFolder(File folder)
{
if (!folder.exists())
{
System.out.println("Delete target does not exist: " + folder);
return;
}
File[] files = folder.listFiles();

View File

@ -98,8 +98,8 @@ public class UtilTime
if (type == TimeUnit.DAYS) text = (num = UtilMath.trim(trim, time / 86400000d)) + " Day";
else if (type == TimeUnit.HOURS) text = (num = UtilMath.trim(trim, time / 3600000d)) + " Hour";
else if (type == TimeUnit.MINUTES) text = (num = UtilMath.trim(trim, time / 60000d)) + " Minute";
else if (type == TimeUnit.SECONDS) text = (num = UtilMath.trim(trim, time / 1000d)) + " Second";
else text = (num = UtilMath.trim(trim, time)) + " Millisecond";
else if (type == TimeUnit.SECONDS) text = (int) (num = (int) UtilMath.trim(0, time / 1000d)) + " Second";
else text = (int) (num = (int) UtilMath.trim(0, time)) + " Millisecond";
}
if (num != 1)

View File

@ -16,6 +16,9 @@ import mineplex.core.account.event.ClientWebResponseEvent;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.donation.command.CoinCommand;
import mineplex.core.donation.command.GemCommand;
import mineplex.core.donation.command.GoldCommand;
import mineplex.core.donation.repository.DonationRepository;
import mineplex.core.donation.repository.token.DonorTokenWrapper;
import mineplex.core.server.util.TransactionResponse;

View File

@ -1,4 +1,4 @@
package mineplex.core.donation;
package mineplex.core.donation.command;
import java.util.UUID;
@ -11,6 +11,7 @@ import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
public class CoinCommand extends CommandBase<DonationManager>
{

View File

@ -1,4 +1,4 @@
package mineplex.core.donation;
package mineplex.core.donation.command;
import java.util.UUID;
@ -10,6 +10,7 @@ import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
public class GemCommand extends CommandBase<DonationManager>
{

View File

@ -1,4 +1,4 @@
package mineplex.core.donation;
package mineplex.core.donation.command;
import java.util.UUID;
@ -11,6 +11,7 @@ import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
public class GoldCommand extends CommandBase<DonationManager>
{

View File

@ -1,9 +1,11 @@
package mineplex.core.give;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
@ -43,13 +45,16 @@ public class Give extends MiniPlugin
help(player);
else if (args.length == 1)
give(player, player.getName(), args[0], "1");
give(player, player.getName(), args[0], "1", "");
else if (args.length == 2)
give(player, args[0], args[1], "1");
give(player, args[0], args[1], "1", "");
else if (args.length == 3)
give(player, args[0], args[1], args[2], "");
else
give(player, args[0], args[1], args[2]);
give(player, args[0], args[1], args[2], args[3]);
}
public void help(Player player)
@ -57,7 +62,7 @@ public class Give extends MiniPlugin
UtilPlayer.message(player, F.main("Give", "Commands List;"));
}
public void give(Player player, String target, String itemNames, String amount)
public void give(Player player, String target, String itemNames, String amount, String enchants)
{
//Item
LinkedList<Entry<Material, Byte>> itemList = new LinkedList<Entry<Material, Byte>>();
@ -98,6 +103,24 @@ public class Give extends MiniPlugin
UtilPlayer.message(player, F.main("Give", "Invalid Amount [" + amount + "]. Defaulting to [1]."));
}
//Enchants
HashMap<Enchantment, Integer> enchs = new HashMap<Enchantment, Integer>();
if (enchants.length() > 0)
{
for (String cur : enchants.split(","))
{
try
{
String[] tokens = cur.split(":");
enchs.put(Enchantment.getByName(tokens[0]), Integer.parseInt(tokens[1]));
}
catch (Exception e)
{
UtilPlayer.message(player, F.main("Give", "Invalid Enchantment [" + cur + "]."));
}
}
}
//Create
String givenList = "";
for (Player cur : giveList)
@ -111,6 +134,9 @@ public class Give extends MiniPlugin
{
ItemStack stack = ItemStackFactory.Instance.CreateStack(curItem.getKey(), curItem.getValue(), count);
//Enchants
stack.addUnsafeEnchantments(enchs);
//Give
if (UtilInv.insert(cur, stack))
{

View File

@ -21,7 +21,7 @@ public class GiveItemCommand extends CommandBase<InventoryManager>
{
public GiveItemCommand(InventoryManager plugin)
{
super(plugin, Rank.DEVELOPER, "giveitem");
super(plugin, Rank.ADMIN, "giveitem");
}
@Override

View File

@ -75,10 +75,7 @@ public class TimingManager implements Listener
{
if (_totalList.containsKey(title))
{
TimeData data = _totalList.get(title);
data.addTime();
_totalList.put(title, data);
_totalList.get(title).addTime();
}
}
}

View File

@ -120,7 +120,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
new Field(plugin, creature, _condition, energy, serverName);
DamageManager damageManager = new DamageManager(plugin, _combatManager, new NpcManager(plugin, creature), disguiseManager);
DamageManager damageManager = new DamageManager(plugin, _combatManager, new NpcManager(plugin, creature), disguiseManager, _condition);
new Weapon(plugin, energy);
new Gameplay(plugin, this, blockRestore, damageManager);

View File

@ -146,7 +146,7 @@ public class Hub extends JavaPlugin implements IRelation
ProjectileManager throwManager = new ProjectileManager(this);
SkillConditionManager conditionManager = new SkillConditionManager(this);
DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager);
DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, conditionManager);
Fire fire = new Fire(this, conditionManager, damage);
Teleport teleport = new Teleport(this);
Energy energy = new Energy(this);

View File

@ -67,7 +67,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
ChatColor.RESET + "",
ChatColor.RESET + "Search for chests to find loot and ",
ChatColor.RESET + "fight others to be the last man standing. ",
ChatColor.RESET + "Beware of the deep freeze!",
ChatColor.RESET + "Stay away from the borders!",
ChatColor.RESET + "",
ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("HG") + ChatColor.RESET + " other players!",
}));

View File

@ -3,6 +3,7 @@ package mineplex.minecraft.game.core.damage;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
@ -16,6 +17,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.npc.NpcManager;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.damage.compatibility.NpcProtectListener;
import net.minecraft.server.v1_7_R4.DamageSource;
import net.minecraft.server.v1_7_R4.EntityHuman;
@ -28,6 +30,7 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Fish;
import org.bukkit.entity.LivingEntity;
@ -42,10 +45,13 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import com.sun.jndi.ldap.ManageReferralControl;
public class DamageManager extends MiniPlugin
{
private CombatManager _combatManager;
private DisguiseManager _disguiseManager;
private ConditionManager _conditionManager;
protected Field _lastDamageByPlayerTime;
protected Method _k;
@ -54,12 +60,13 @@ public class DamageManager extends MiniPlugin
private boolean _enabled = true;
public DamageManager(JavaPlugin plugin, CombatManager combatManager, NpcManager npcManager, DisguiseManager disguiseManager)
public DamageManager(JavaPlugin plugin, CombatManager combatManager, NpcManager npcManager, DisguiseManager disguiseManager, ConditionManager conditionManager)
{
super("Damage Manager", plugin);
_combatManager = combatManager;
_disguiseManager = disguiseManager;
_conditionManager = conditionManager;
try
{
@ -230,6 +237,73 @@ public class DamageManager extends MiniPlugin
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void handleEnchants(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
//Defensive
Player damagee = event.GetDamageePlayer();
if (damagee != null)
{
for (ItemStack stack : damagee.getInventory().getArmorContents())
{
if (stack == null)
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);
}
}
}
//Offensive
Player damager = event.GetDamagerPlayer(true);
if (damager != null)
{
ItemStack stack = damager.getItemInHand();
if (stack == null)
return;
Map<Enchantment, Integer> enchants = stack.getEnchantments();
for (Enchantment e : enchants.keySet())
{
if (e.equals(Enchantment.ARROW_KNOCKBACK) || e.equals(Enchantment.KNOCKBACK))
event.AddKnockback("Ench Knockback", 1 + (0.5 * (double)enchants.get(e)));
else if (e.equals(Enchantment.ARROW_DAMAGE))
event.AddMod("Enchant", "Ench Damage", 0.5 * (double)enchants.get(e), true);
else if (e.equals(Enchantment.ARROW_FIRE) || e.equals(Enchantment.FIRE_ASPECT))
if (_conditionManager != null)
_conditionManager.Factory().Ignite("Ench Fire", event.GetDamageeEntity(), damager,
1 * (double)enchants.get(e), false, false);
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void EndDamageEvent(CustomDamageEvent event)
{
@ -295,27 +369,32 @@ public class DamageManager extends MiniPlugin
((CraftLivingEntity)event.GetDamageeEntity()).getHandle().p(((CraftLivingEntity)event.GetDamageeEntity()).getHandle().aZ() + 1);
//Knockback
if (event.IsKnockback() && event.GetDamagerEntity(true) != null)
{
//Base
double knockback = event.GetDamage();
if (knockback < 2) knockback = 2;
knockback = Math.log10(knockback);
//Mults
for (double cur : event.GetKnockback().values())
knockback = knockback * cur;
if (event.IsKnockback())
if (event.GetDamagerEntity(true) != null)
{
//Origin
Location origin = event.GetDamagerEntity(true).getLocation();
if (event.getKnockbackOrigin() != null)
origin = event.getKnockbackOrigin();
//Vec
Vector trajectory = UtilAlg.getTrajectory2d(origin, event.GetDamageeEntity().getLocation());
trajectory.multiply(0.6 * knockback);
trajectory.setY(Math.abs(trajectory.getY()));
//Apply
UtilAction.velocity(event.GetDamageeEntity(),
trajectory, 0.2 + trajectory.length() * 0.8, false, 0, Math.abs(0.2 * knockback), 0.4 + (0.04 * knockback), true);
}
}
catch (IllegalAccessException e)
{
@ -586,4 +665,9 @@ public class DamageManager extends MiniPlugin
{
return _combatManager;
}
public void setConditionManager(ConditionManager cm)
{
_conditionManager = cm;
}
}

View File

@ -105,7 +105,7 @@ public class Arcade extends JavaPlugin
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
_damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager);
_damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager, null);
Punish punish = new Punish(this, webServerAddress, _clientManager);
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);

View File

@ -214,7 +214,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
// Modules
_blockRestore = new BlockRestore(plugin);
_blood = blood;
_preferencesManager = preferences;
@ -239,6 +238,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_damageManager = damageManager;
_damageManager.UseSimpleWeaponDamage = true;
_damageManager.setConditionManager(_conditionManager);
_disguiseManager = disguiseManager;

View File

@ -10,7 +10,7 @@ public class YoutubeCommand extends CommandBase<ArcadeManager>
{
public YoutubeCommand(ArcadeManager plugin)
{
super(plugin, Rank.OWNER, new Rank[] {Rank.YOUTUBE}, "youtube");
super(plugin, Rank.OWNER, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, new String[] {"youtube", "twitch"});
}
@Override

View File

@ -190,12 +190,14 @@ public class EventGame extends SoloGame
UtilPlayer.message(player, F.value("/e silence [Time]", "Silence Chat"));
UtilPlayer.message(player, F.value("/e admin [Player]", "Toggle Event Admin"));
UtilPlayer.message(player, F.value("/e gm [Player]", "Toggle Creative Mode"));
UtilPlayer.message(player, F.value("/e radius [Radius]", "Set Forcefield Radius"));
UtilPlayer.message(player, F.value("/e give <item> <amount>", "Give Item to Self"));
UtilPlayer.message(player, F.value("/e give <player> <item> <amount>", "Give Item to Player"));
UtilPlayer.message(player, F.value("/e give <item> <amount>", "Give Item"));
UtilPlayer.message(player, F.value("/e give <player> <item> <amount> [e:#,e:#...]", "Give Item"));
UtilPlayer.message(player, F.value("/e doublejump", "Toggles Double Jump"));
@ -276,6 +278,10 @@ public class EventGame extends SoloGame
{
commandSilence(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("admin"))
{
commandAdmin(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("gm"))
{
commandGamemode(event.getPlayer(), args);
@ -804,6 +810,28 @@ public class EventGame extends SoloGame
}
}
//Gamemode (Self and Others)
private void commandAdmin(Player player, String[] args)
{
Player target = player;
if (args.length >= 2)
{
Player newTarget = UtilPlayer.searchOnline(player, args[1], true);
if (newTarget != null)
target = newTarget;
else
return;
}
if (Manager.GetGameHostManager().isAdmin(target, false))
Manager.GetGameHostManager().giveAdmin(target);
else
Manager.GetGameHostManager().removeAdmin(target.getName());
UtilPlayer.message(player, F.main("Event Admin", target.getName() + " Admin: " + F.tf(Manager.GetGameHostManager().isAdmin(target, false))));
}
//Gamemode (Self and Others)
private void commandGamemode(Player player, String[] args)
{

View File

@ -15,11 +15,13 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.itemstack.ItemStackFactory;
@ -46,6 +48,8 @@ public class SnowFight extends TeamGame
{
"Just like... kill your enemies. with snow."
});
this.HungerSet = 20;
}
@ -80,11 +84,12 @@ public class SnowFight extends TeamGame
if (!IsSnow(event.getBlock()))
return;
if (player.getInventory().getHeldItemSlot() != 0)
if (UtilInv.contains(player, Material.SNOW_BALL, (byte)0, 16))
return;
//Item
SnowballCount(player, 1);
UtilInv.insert(player, new ItemStack(Material.SNOW_BALL));
//Snow Height
SnowDecrease(event.getBlock(), 1);
@ -93,83 +98,83 @@ public class SnowFight extends TeamGame
event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.STEP_SOUND, 80);
}
@EventHandler
public void InteractSnowball(PlayerInteractEvent event)
{
Player player = event.getPlayer();
// @EventHandler
// public void InteractSnowball(PlayerInteractEvent event)
// {
// Player player = event.getPlayer();
//
// if (!IsLive())
// return;
//
// if (!IsPlaying(player))
// return;
//
// if (!UtilGear.isMat(player.getItemInHand(), Material.SNOW_BALL))
// return;
//
// event.setCancelled(true);
//
// if (UtilEvent.isAction(event, ActionType.L))
// SnowballThrow(player);
//
// else if (UtilEvent.isAction(event, ActionType.R_BLOCK))
// SnowballPlace(player, event.getClickedBlock(), 1);
// }
//
// private void SnowballPlace(Player player, Block block, int above)
// {
// if (block.getTypeId() == 78 || UtilBlock.airFoliage(block))
// {
// //Build
// if (block.getTypeId() == 78)
// {
// block.setTypeIdAndData(78, (byte)(block.getData() + 1), true);
//
// if (block.getData() >= 7)
// block.setTypeIdAndData(80, (byte)0, true);
// }
// else
// {
// block.setTypeIdAndData(78, (byte)0, true);
// }
//
// //Sound
// block.getWorld().playSound(block.getLocation(), Sound.STEP_SNOW, 1f, 0.6f);
//
// //Use Snow
// SnowballCount(player, -1);
// }
// else if ((IsSnow(block) || UtilBlock.solid(block)) && above > 0)
// {
// SnowballPlace(player, block.getRelative(BlockFace.UP), above - 1);
// }
// }
//
// private void SnowballThrow(Player player)
// {
// //Throw
// player.launchProjectile(Snowball.class);
//
// //Use Snow
// SnowballCount(player, -1);
//
// //Sound
// player.getWorld().playSound(player.getLocation(), Sound.STEP_SNOW, 3f, 1.5f);
// }
if (!IsLive())
return;
if (!IsPlaying(player))
return;
if (!UtilGear.isMat(player.getItemInHand(), Material.SNOW_BALL))
return;
event.setCancelled(true);
if (UtilEvent.isAction(event, ActionType.L))
SnowballThrow(player);
else if (UtilEvent.isAction(event, ActionType.R_BLOCK))
SnowballPlace(player, event.getClickedBlock(), 1);
}
private void SnowballPlace(Player player, Block block, int above)
{
if (block.getTypeId() == 78 || UtilBlock.airFoliage(block))
{
//Build
if (block.getTypeId() == 78)
{
block.setTypeIdAndData(78, (byte)(block.getData() + 1), true);
if (block.getData() >= 7)
block.setTypeIdAndData(80, (byte)0, true);
}
else
{
block.setTypeIdAndData(78, (byte)0, true);
}
//Sound
block.getWorld().playSound(block.getLocation(), Sound.STEP_SNOW, 1f, 0.6f);
//Use Snow
SnowballCount(player, -1);
}
else if ((IsSnow(block) || UtilBlock.solid(block)) && above > 0)
{
SnowballPlace(player, block.getRelative(BlockFace.UP), above - 1);
}
}
private void SnowballThrow(Player player)
{
//Throw
player.launchProjectile(Snowball.class);
//Use Snow
SnowballCount(player, -1);
//Sound
player.getWorld().playSound(player.getLocation(), Sound.STEP_SNOW, 3f, 1.5f);
}
private void SnowballCount(Player player, int count)
{
if (player.getInventory().getItem(1) != null)
count += player.getInventory().getItem(1).getAmount();
if (count > 16)
count = 16;
if (count > 0)
player.getInventory().setItem(1, ItemStackFactory.Instance.CreateStack(Material.SNOW_BALL, count));
else
player.getInventory().setItem(1, null);
}
// private void SnowballCount(Player player, int count)
// {
// if (player.getInventory().getItem(1) != null)
// count += player.getInventory().getItem(1).getAmount();
//
// if (count > 16)
// count = 16;
//
// if (count > 0)
// player.getInventory().setItem(1, ItemStackFactory.Instance.CreateStack(Material.SNOW_BALL, count));
// else
// player.getInventory().setItem(1, null);
// }
private void SnowDecrease(Block block, int height)
{

View File

@ -2,11 +2,11 @@ package nautilus.game.arcade.game.games.uhc;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.Difficulty;
import org.bukkit.Location;
import org.bukkit.Material;
@ -14,9 +14,11 @@ import org.bukkit.Sound;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLargeFireball;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Ghast;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
@ -30,10 +32,13 @@ import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerPortalEvent;
@ -49,23 +54,28 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.packethandler.PacketPlayOutWorldBorder;
import mineplex.core.recharge.Recharge;
import mineplex.core.timing.TimingManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -78,28 +88,39 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.kit.Kit;
import net.minecraft.server.v1_7_R4.EntityLargeFireball;
public class UHC extends TeamGame
{
private NautHashMap<String, Long> _deathTime = new NautHashMap<String, Long>();
// private NautHashMap<String, Long> _combatTime = new NautHashMap<String, Long>();
private int _borderSize = 1000;
private int _yMax = 0;
private Chunk _chunk = null;
private int _chunkX = 0;
private int _chunkZ = 0;
private int _chunksLoaded = 0;
private int _gameMinutes = 0;
private int _safeTime = 11;
private long _lastMinute = System.currentTimeMillis();
private Objective _scoreObj;
private long _hour = 3600000;
private long _createTime;
private long _serverTime;
private boolean _mapLoaded = false;
private boolean xrayDebug = false;
// Border
private int _secondsSinceStart;
private HashMap<Integer, Double> _borderPositions = new HashMap<Integer, Double>();
private double _currentBorder = 1000;
private double _previousBorder = 1000;
private long _borderStartedMoving;
public UHC(ArcadeManager manager)
{
super(manager, GameType.UHC,
@ -109,12 +130,10 @@ public class UHC extends TeamGame
new KitUHC(manager)
},
new String[] {
"10 minutes of no PvP",
"Only Golden Apples restore health",
"Ores can only be found in caves",
"Borders shrink over time",
"Last player/team alive wins!"
new String[]
{
"10 minutes of no PvP", "Only Golden Apples restore health", "Ores can only be found in caves",
"Borders shrink over time", "Last player/team alive wins!"
});
this.StrictAntiHack = true;
@ -189,6 +208,339 @@ public class UHC extends TeamGame
public void ParseData()
{
WorldData.World.setDifficulty(Difficulty.HARD);
_chunkX = (int) -(_currentBorder / 16);
_chunkZ = (int) -(_currentBorder / 16);
WorldData.MinX = -1000;
WorldData.MinZ = -1000;
WorldData.MaxX = 1000;
WorldData.MaxZ = 1000;
int i = 0;
for (double border : buildBorders(1000, 1000, 32))
{
_borderPositions.put(i++ * 4, border);
}
}
@EventHandler
public void onSecond(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
if (!IsLive())
{
return;
}
_previousBorder = _currentBorder;
// We half the number so this only activates every 2nd second.
if (_borderPositions.containsKey(_secondsSinceStart))
{
_currentBorder = _borderPositions.get(_secondsSinceStart);
setBorder();
}
_secondsSinceStart++;
}
private void setBorder()
{
_borderStartedMoving = System.currentTimeMillis();
PacketPlayOutWorldBorder packet = new PacketPlayOutWorldBorder();
packet.worldBorderType = 1;
packet.newRadius = _currentBorder;
packet.oldRadius = _previousBorder;
packet.speed = _currentBorder != _previousBorder ? 1000 : 0;
for (Player player : Bukkit.getOnlinePlayers())
{
if (UtilPlayer.is1_8(player))
{
UtilPlayer.sendPacket(player, packet);
}
}
}
@EventHandler
public void outsideBorder(UpdateEvent event)
{
if (!IsLive())
{
return;
}
if (event.getType() != UpdateType.FAST)
{
return;
}
// The distance between the old border and the new
double distanceMovedSince = _currentBorder - _previousBorder;
// Multiply that distance depending on how long its been since it moved.
long timeSinceMoved = System.currentTimeMillis() - _borderStartedMoving;
double percentageBorderMoved = Math.min(timeSinceMoved, 1000D) / 1000D;
distanceMovedSince *= percentageBorderMoved;
double border = (_previousBorder - 0.3D) + distanceMovedSince;
// 24 @ 100+ reduced to 0 at 32-
double borderAttackDist = Math.max(8, (Math.min(100, border) - 28d) / 3d);
for (Player player : UtilServer.getPlayers())
{
Location loc = player.getLocation();
// Bump Players Back In
if (loc.getX() > border || loc.getX() < -border || loc.getZ() > border || loc.getZ() < -border)
{
if (Recharge.Instance.use(player, "Hit by Border", 1000, false, false))
{
Entity bottom = player;
while (bottom.getVehicle() != null)
bottom = bottom.getVehicle();
UtilAction
.velocity(bottom, UtilAlg.getTrajectory2d(loc, GetSpectatorLocation()), 1.2, true, 0.4, 0, 10, true);
if (Manager.IsAlive(player))
{
Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 10, false, false, false,
"Nether Field", "Vaporize");
player.getWorld().playSound(loc, Sound.NOTE_BASS, 2f, 1f);
player.getWorld().playSound(loc, Sound.NOTE_BASS, 2f, 1f);
}
}
}
}
}
@EventHandler
public void onGameState(PlayerChangedWorldEvent event)
{
if (GetState() == GameState.Prepare || IsLive())
{
setupBorder(event.getPlayer());
}
}
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
if (GetState() == GameState.Prepare || IsLive())
{
setupBorder(event.getPlayer());
}
}
private void setupBorder(Player player)
{
PacketPlayOutWorldBorder packet = new PacketPlayOutWorldBorder();
packet.worldBorderType = 3;
packet.newRadius = _currentBorder;
packet.oldRadius = _previousBorder;
packet.warningBlocks = -10;
packet.warningTime = -10;
if (_currentBorder != _previousBorder)
{
packet.speed = 1000 - Math.min(1000, (System.currentTimeMillis() - _borderStartedMoving));
}
// We don't set warnings speed or blocks as its not particularly useful for this game.
// Also if we don't use it here, its more effective in other places to reinforce the idea what its for.
if (UtilPlayer.is1_8(player))
{
UtilPlayer.sendPacket(player, packet);
}
}
private ArrayList<Double> buildBorders(int seconds, double border, double leaveRemaining)
{
double totalNumber = Math.pow(seconds, 1.9D) + (seconds * 50);
ArrayList<Double> borders = new ArrayList<Double>();
for (int i = 0; i <= seconds; i++)
{
borders.add(border - ((border - leaveRemaining) * (((Math.pow(i, 1.9D) + (i * 50))) / totalNumber)));
}
return borders;
}
@EventHandler
public void loadMap(UpdateEvent event)
{
if (_mapLoaded)
return;
if (WorldData.World == null)
return;
int chunksPerTick = 20;
// Print Debug
if (event.getType() == UpdateType.SLOW)
{
int chunkTotal = (int) ((_currentBorder * 2 / 16) * (_currentBorder * 2 / 16));
int chunksToGo = chunkTotal - _chunksLoaded;
Announce(C.cGreen + C.Bold + "Generating Map: " + ChatColor.RESET
+ UtilTime.MakeStr((long) ((double) chunksToGo / (double) (20 * chunksPerTick) * 1000d), 1) + " Remaining...");
TimingManager.endTotal("UHC Generation", true);
return;
}
if (event.getType() != UpdateType.TICK)
return;
// Timings
TimingManager.startTotal("UHC Generation");
for (int i = 0; i < chunksPerTick; i++)
{
// Unload Previous
// if (_chunk != null)
// _chunk.unload(true);
// Load Chunks
_chunk = WorldData.World.getChunkAt(_chunkX, _chunkZ);
_chunk.load(true);
// Scan Map
if (_chunkX < _currentBorder / 16)
{
_chunkX++;
}
else if (_chunkZ < _currentBorder / 16)
{
_chunkX = (int) -(_currentBorder / 16);
_chunkZ++;
}
else
{
Announce(C.cGreen + C.Bold + "Generating Map: " + ChatColor.RESET + "Complete!");
_mapLoaded = true;
System.out.println("Map Loading Finished!");
generateSpawns();
break;
}
_chunksLoaded++;
}
// Timings
TimingManager.stopTotal("UHC Generation");
}
public void generateSpawns()
{
// Wipe Spawns
for (GameTeam team : this.GetTeamList())
{
team.GetSpawns().clear();
}
TimingManager.start("UHC Spawn Generation");
// Solo Game
if (this.GetTeamList().size() == 1)
{
while (GetTeamList().get(0).GetSpawns().size() < this.GetPlayers(true).size())
{
Location loc = GetRandomSpawn(null);
// Dynamically scale distance requirement based on how many teams need to fit
double dist = (2 * _currentBorder) / (Math.sqrt(this.GetPlayers(true).size()) + 3);
// Ensure distance between Teams
while (true)
{
boolean clash = false;
for (Location otherSpawn : GetTeamList().get(0).GetSpawns())
{
if (UtilMath.offset(loc, otherSpawn) < dist)
{
clash = true;
break;
}
}
if (!clash)
break;
loc = GetRandomSpawn(null);
}
GetTeamList().get(0).GetSpawns().add(loc);
}
}
// Team Game
else
{
for (GameTeam team : GetTeamList())
{
Location loc = GetRandomSpawn(null);
// Dynamically scale distance requirement based on how many teams need to fit
double dist = (2 * _currentBorder) / (Math.sqrt(GetTeamList().size()) + 3);
// Ensure distance between Teams
while (true)
{
boolean clash = false;
for (GameTeam otherTeam : GetTeamList())
{
if (otherTeam.GetSpawns().isEmpty())
continue;
if (UtilMath.offset(loc, otherTeam.GetSpawn()) < dist)
{
clash = true;
break;
}
}
if (!clash)
break;
loc = GetRandomSpawn(null);
}
team.GetSpawns().add(loc);
while (team.GetSpawns().size() < 20)
{
Location other = GetRandomSpawn(loc);
team.GetSpawns().add(other);
}
}
}
TimingManager.stop("UHC Spawn Generation");
}
@EventHandler
@ -230,7 +582,6 @@ public class UHC extends TeamGame
}
}
@EventHandler
public void EarlyGameUpdate(UpdateEvent event)
{
@ -278,7 +629,7 @@ public class UHC extends TeamGame
}
}
@EventHandler
/*@EventHandler
public void WorldBoundaryCheck(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
@ -305,7 +656,7 @@ public class UHC extends TeamGame
_borderSize--;
}
@EventHandler
//@EventHandler
public void WorldBoundarySet(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Recruit)
@ -334,121 +685,21 @@ public class UHC extends TeamGame
System.out.println("Y Max: " + _yMax);
System.out.println("Time: " + UtilTime.MakeStr(System.currentTimeMillis() - time));
}
}*/
@EventHandler
public void WorldBoundaryYLimit(BlockPlaceEvent event)
{
if (event.getBlock().getX() >= -16 &&
event.getBlock().getX() <= 16 &&
event.getBlock().getZ() >= -16 &&
event.getBlock().getZ() <= 16 &&
event.getBlock().getY() >= _yMax)
if (event.getBlock().getX() >= -16 && event.getBlock().getX() <= 16 && event.getBlock().getZ() >= -16
&& event.getBlock().getZ() <= 16 && event.getBlock().getY() >= _yMax)
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot build this high near center of map."));
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void GenerateSpawns(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Recruit)
return;
//Wipe Spawns
for (GameTeam team : this.GetTeamList())
{
team.GetSpawns().clear();
}
TimingManager.start("UHC Spawn Generation");
//Solo Game
if (this.GetTeamList().size() == 1)
{
while (GetTeamList().get(0).GetSpawns().size() < this.GetPlayers(true).size())
{
Location loc = GetRandomSpawn(null);
//Dynamically scale distance requirement based on how many teams need to fit
double dist = (2*_borderSize) / (Math.sqrt(this.GetPlayers(true).size()) + 3);
//Ensure distance between Teams
while (true)
{
boolean clash = false;
for (Location otherSpawn : GetTeamList().get(0).GetSpawns())
{
if (UtilMath.offset(loc, otherSpawn) < dist)
{
clash = true;
break;
}
}
if (!clash)
break;
loc = GetRandomSpawn(null);
}
GetTeamList().get(0).GetSpawns().add(loc);
}
}
//Team Game
else
{
for (GameTeam team : GetTeamList())
{
Location loc = GetRandomSpawn(null);
//Dynamically scale distance requirement based on how many teams need to fit
double dist = (2*_borderSize) / (Math.sqrt(GetTeamList().size()) + 3);
//Ensure distance between Teams
while (true)
{
boolean clash = false;
for (GameTeam otherTeam : GetTeamList())
{
if (otherTeam.GetSpawns().isEmpty())
continue;
if (UtilMath.offset(loc, otherTeam.GetSpawn()) < dist)
{
clash = true;
break;
}
}
if (!clash)
break;
loc = GetRandomSpawn(null);
}
team.GetSpawns().add(loc);
while (team.GetSpawns().size() < 20)
{
Location other = GetRandomSpawn(loc);
team.GetSpawns().add(other);
}
}
}
TimingManager.stop("UHC Spawn Generation");
}
public Location GetRandomSpawn(Location around)
{
HashSet<Material> ignore = new HashSet<Material>();
ignore.add(Material.LEAVES);
Location loc = null;
while (loc == null)
@ -458,15 +709,17 @@ public class UHC extends TeamGame
// Get Team Location
if (around == null)
{
int x = (int)(UtilMath.r((int)(1.8*_borderSize)) - (0.9*_borderSize));
int z = (int)(UtilMath.r((int)(1.8*_borderSize)) - (0.9*_borderSize));
// Return a int from 0 - 1800, then remove 900 so its a int from -900 to 900
int x = (int) (UtilMath.r((int) (1.8 * _currentBorder)) - (0.9 * _currentBorder));
int z = (int) (UtilMath.r((int) (1.8 * _currentBorder)) - (0.9 * _currentBorder));
block = UtilBlock.getHighest(WorldData.World, x, z, ignore);
block = UtilBlock.getHighest(WorldData.World, x, z, null);
}
// Get Radius Location
else
{
block = UtilBlock.getHighest(WorldData.World, around.getBlockX() - 4 + UtilMath.r(8), around.getBlockZ() - 4 + UtilMath.r(8), ignore);
block = UtilBlock.getHighest(WorldData.World, around.getBlockX() - 4 + UtilMath.r(8), around.getBlockZ() - 4
+ UtilMath.r(8), null);
}
// Check Validity
@ -476,7 +729,7 @@ public class UHC extends TeamGame
continue;
// Suffocated
if (block.getTypeId() != 0 || block.getRelative(BlockFace.UP).getTypeId() != 0)
if (block.getType() != Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR)
continue;
loc = block.getLocation().add(0.5, 0.5, 0.5);
@ -501,7 +754,8 @@ public class UHC extends TeamGame
Player player = event.getPlayer();
GameTeam team = GetTeam(player);
if (team == null) return;
if (team == null)
return;
if (!IsAlive(player))
return;
@ -513,7 +767,8 @@ public class UHC extends TeamGame
UtilInv.drop(player, true);
// Skull Drop
ItemStack stack = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte)3, 1, team.GetColor() + player.getName() + "'s Head");
ItemStack stack = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1,
team.GetColor() + player.getName() + "'s Head");
SkullMeta meta = (SkullMeta) stack.getItemMeta();
meta.setOwner(player.getName());
@ -528,10 +783,12 @@ public class UHC extends TeamGame
Player player = event.getEntity();
GameTeam team = GetTeam(player);
if (team == null) return;
if (team == null)
return;
// Skull Drop
ItemStack stack = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte)3, 1, team.GetColor() + player.getName() + "'s Head");
ItemStack stack = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1,
team.GetColor() + player.getName() + "'s Head");
SkullMeta meta = (SkullMeta) stack.getItemMeta();
meta.setOwner(player.getName());
@ -572,23 +829,20 @@ public class UHC extends TeamGame
// Simple
if (killer != null)
{
Announce(Manager.GetColor(dead) + C.Bold + dead.getName() +
C.cGray + C.Bold + " was killed by " +
Manager.GetColor(killer) + C.Bold + killer.getName() +
C.cGray + C.Bold + ".");
Announce(Manager.GetColor(dead) + C.Bold + dead.getName() + C.cGray + C.Bold + " was killed by "
+ Manager.GetColor(killer) + C.Bold + killer.getName() + C.cGray + C.Bold + ".");
}
else
{
if (log.GetAttackers().isEmpty())
{
Announce(Manager.GetColor(dead) + C.Bold + dead.getName() +
C.cGray + C.Bold + " has died by unknown causes.");
Announce(Manager.GetColor(dead) + C.Bold + dead.getName() + C.cGray + C.Bold + " has died by unknown causes.");
}
else
{
Announce(Manager.GetColor(dead) + C.Bold + dead.getName() +
C.cGray + C.Bold + " was killed by " + log.GetAttackers().getFirst().GetName() + ".");
Announce(Manager.GetColor(dead) + C.Bold + dead.getName() + C.cGray + C.Bold + " was killed by "
+ log.GetAttackers().getFirst().GetName() + ".");
}
}
}
@ -657,7 +911,6 @@ public class UHC extends TeamGame
}
*/
@EventHandler
public void CreatureCull(UpdateEvent event)
{
@ -761,7 +1014,8 @@ public class UHC extends TeamGame
if (item.getItemMeta().getDisplayName() == null)
continue;
ItemStack apple = ItemStackFactory.Instance.CreateStack(Material.GOLDEN_APPLE, (byte)0, 1, item.getItemMeta().getDisplayName() + ChatColor.AQUA + " Golden Apple");
ItemStack apple = ItemStackFactory.Instance.CreateStack(Material.GOLDEN_APPLE, (byte) 0, 1, item
.getItemMeta().getDisplayName() + ChatColor.AQUA + " Golden Apple");
apple.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
inv.setResult(apple);
@ -880,13 +1134,13 @@ public class UHC extends TeamGame
{
if (event.getBlock().getType() == Material.OBSIDIAN)
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.elem("Obsidian") + " in the " + F.elem("Nether") + "."));
UtilPlayer.message(event.getPlayer(),
F.main("Game", "You cannot place " + F.elem("Obsidian") + " in the " + F.elem("Nether") + "."));
event.setCancelled(true);
}
}
}
@EventHandler
public void Commands(PlayerCommandPreprocessEvent event)
{
@ -1051,7 +1305,7 @@ public class UHC extends TeamGame
Scoreboard.WriteBlank();
Scoreboard.Write(C.cYellow + C.Bold + "Borders");
Scoreboard.Write("-" + _borderSize + " to " + "+" + _borderSize);
Scoreboard.Write("-" + (int) _currentBorder + " to " + "+" + (int) _currentBorder);
Scoreboard.Draw();
}
@ -1269,9 +1523,7 @@ public class UHC extends TeamGame
public boolean isOre(Block block)
{
return (block.getType() == Material.IRON_ORE ||
block.getType() == Material.GOLD_ORE ||
block.getType() == Material.DIAMOND_ORE);
return (block.getType() == Material.IRON_ORE || block.getType() == Material.GOLD_ORE || block.getType() == Material.DIAMOND_ORE);
}
private ArrayList<ArrayList<Block>> generateVeins(ArrayList<Block> ores)

View File

@ -323,7 +323,7 @@ public enum SpellType // ❤
"Rumble", // Spell name
new ItemStack(Material.PUMPKIN_SEEDS), // Spell icon
SpellRumble.class, // Spell class
5, // Spell max level
3, // Spell max level
30, // Mana cost
15, // Spell cooldown
0, // Mana cost change per level

View File

@ -509,7 +509,7 @@ public class GameHostManager implements Listener
public int getMaxPlayerCap()
{
if (hasRank(Rank.SNR_MODERATOR) || _hostRank == Rank.YOUTUBE)
if (hasRank(Rank.SNR_MODERATOR) || _hostRank == Rank.YOUTUBE || _hostRank == Rank.TWITCH)
return 100;
else if (hasRank(Rank.LEGEND))
return 40;

View File

@ -224,11 +224,8 @@ public class GameManager implements Listener
public void StateCountdown(Game game, int timer, boolean force)
{
if (game instanceof UHC)
{
if (((UHC)game).isMapLoaded())
if (game instanceof UHC && !((UHC)game).isMapLoaded())
return;
}
//Disabling Cosmetics
if (game.GetCountdown() <= 5 && game.GetCountdown() >= 0 && game.GadgetsDisabled)

View File

@ -44,7 +44,7 @@ public class ExperienceStatTracker extends StatTracker<Game>
for (Player player : event.GetGame().GetPlayers(false))
{
//Tally Gems
double gems = 0;
double gemExp = 0;
for (String reason : event.GetGame().GetGems(player).keySet())
{
if (reason.toLowerCase().contains("participation"))
@ -52,21 +52,20 @@ public class ExperienceStatTracker extends StatTracker<Game>
GemData gem = event.GetGame().GetGems(player).get(reason);
gems += (int)gem.Gems;
gemExp += (int)gem.Gems;
}
gemExp = Math.min(gemExp, 250) * 3;
gems = Math.min(gems, 250);
//Game Time
double time = (System.currentTimeMillis() - _startTime)/60000d;
//Game Time = 1 Exp per 3 Seconds
double timeExp = (System.currentTimeMillis() - _startTime)/2000d;
//Mult
double mult = 1;
if (!winners.contains(player))
mult = 0.25;
if (winners.contains(player))
mult = 1.5;
//Exp
int expGained = (int)(time*gems*mult);
int expGained = (int)((timeExp + gemExp)*mult);
//Record Global and per Game
addStat(player, "ExpEarned", expGained, false, true);

View File

@ -17,11 +17,13 @@ import mineplex.core.common.util.WorldUtil;
import mineplex.core.common.util.ZipUtil;
import mineplex.core.timing.TimingManager;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.uhc.UHC;
import net.minecraft.server.v1_7_R4.ChunkPreLoadEvent;
import org.bukkit.Difficulty;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldCreator;
import org.bukkit.event.world.ChunkUnloadEvent;
@ -80,7 +82,30 @@ public class WorldData
{
TimingManager.start("WorldData loading world.");
//Start World
if (Host instanceof UHC)
{
//Delete Old World
File dir = new File(GetFolder() + "/data");
FileUtil.DeleteFolder(dir);
dir = new File(GetFolder() + "/region");
FileUtil.DeleteFolder(dir);
dir = new File(GetFolder() + "/level.dat");
dir.delete();
//Create Fresh World with Random Seed
WorldCreator creator = new WorldCreator(GetFolder());
creator.seed(UtilMath.r(999999999));
creator.environment(Environment.NORMAL);
creator.generateStructures(true);
World = creator.createWorld();
}
else
{
World = WorldUtil.LoadWorld(new WorldCreator(GetFolder()));
}
TimingManager.stop("WorldData loading world.");
World.setDifficulty(Difficulty.HARD);