Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex

Conflicts:
	Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java
This commit is contained in:
Jonathan Williams 2014-09-12 19:46:19 -10:00
commit a196e43fde
101 changed files with 2338 additions and 502 deletions

View File

@ -10,7 +10,7 @@
<option name="ENABLE_SWING_INSPECTOR" value="false" /> <option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" /> <option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" /> <option name="PASS_PARENT_ENVS" value="true" />
<module name="" /> <module name="Classpath.Dummy" />
<envs /> <envs />
<RunnerSettings RunnerId="Debug"> <RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value="" /> <option name="DEBUG_PORT" value="" />

View File

@ -10,7 +10,7 @@
<option name="ENABLE_SWING_INSPECTOR" value="false" /> <option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" /> <option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" /> <option name="PASS_PARENT_ENVS" value="true" />
<module name="" /> <module name="Classpath.Dummy" />
<envs /> <envs />
<RunnerSettings RunnerId="Debug"> <RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value="" /> <option name="DEBUG_PORT" value="" />

View File

@ -24,6 +24,7 @@
<include name="**/*.class"/> <include name="**/*.class"/>
</fileset> </fileset>
<zipfileset src="../Libraries/jooq-3.4.2.jar" />
<zipfileset src="../Libraries/httpclient-4.2.jar" /> <zipfileset src="../Libraries/httpclient-4.2.jar" />
<zipfileset src="../Libraries/httpcore-4.2.jar" /> <zipfileset src="../Libraries/httpcore-4.2.jar" />
<zipfileset src="../Libraries/httpclient-cache-4.2.jar" /> <zipfileset src="../Libraries/httpclient-cache-4.2.jar" />

Binary file not shown.

View File

@ -84,4 +84,9 @@ public enum Rank
if (bold) return Color + C.Bold + name; if (bold) return Color + C.Bold + name;
else return Color + name; else return Color + name;
} }
public ChatColor GetColor()
{
return Color;
}
} }

View File

@ -58,13 +58,7 @@ public class C
public static String listValue = "" + ChatColor.YELLOW; public static String listValue = "" + ChatColor.YELLOW;
public static String listValueOn = "" + ChatColor.GREEN; public static String listValueOn = "" + ChatColor.GREEN;
public static String listValueOff = "" + ChatColor.RED; public static String listValueOff = "" + ChatColor.RED;
public static String rAll = "" + ChatColor.WHITE;
public static String rHelp = "" + ChatColor.GREEN;
public static String rMod = "" + ChatColor.GOLD;
public static String rAdmin = "" + ChatColor.RED;
public static String rOwner = "" + ChatColor.DARK_RED;
public static String consoleHead = "" + ChatColor.RED; public static String consoleHead = "" + ChatColor.RED;
public static String consoleFill = "" + ChatColor.WHITE; public static String consoleFill = "" + ChatColor.WHITE;
public static String consoleBody = "" + ChatColor.YELLOW; public static String consoleBody = "" + ChatColor.YELLOW;

View File

@ -95,22 +95,15 @@ public class F
public static String help(String cmd, String body, Rank rank) public static String help(String cmd, String body, Rank rank)
{ {
if (rank == Rank.OWNER) return C.rOwner + cmd + " " + C.mBody + body + " " + rank(Rank.OWNER); return rank.GetColor() + cmd + " " + C.mBody + body + " " + rank(rank);
else if (rank == Rank.ADMIN) return C.rAdmin + cmd + " " + C.mBody + body + " " + rank(Rank.ADMIN);
else if (rank == Rank.MODERATOR) return C.rMod + cmd + " " + C.mBody + body + " " + rank(Rank.MODERATOR);
else if (rank == Rank.HELPER) return C.rHelp + cmd + " " + C.mBody + body + " " + rank(Rank.HELPER);
else return C.rAll + cmd + " " + C.mBody + body + " " + rank(Rank.ALL);
} }
public static String rank(Rank rank) public static String rank(Rank rank)
{ {
if (rank == Rank.OWNER) return C.rOwner + "Owner"; if (rank == Rank.ALL)
else if (rank == Rank.ADMIN) return C.rAdmin + "Admin"; return rank.GetColor() + "Player";
else if (rank == Rank.DEVELOPER) return C.rAdmin + "Developer";
else if (rank == Rank.SNR_MODERATOR) return C.rMod + "Senior Mod"; return rank.GetTag(false, false);
else if (rank == Rank.MODERATOR) return C.rMod + "Mod";
else if (rank == Rank.HELPER) return C.rHelp + "Helper";
else return C.rAll + "Player";
} }
public static String value(String variable, String value) public static String value(String variable, String value)

View File

@ -10,7 +10,7 @@ import org.bukkit.inventory.meta.FireworkMeta;
public class FireworkUtil public class FireworkUtil
{ {
public static void LaunchRandomFirework(Location location) public static Firework LaunchRandomFirework(Location location)
{ {
Builder builder = FireworkEffect.builder(); Builder builder = FireworkEffect.builder();
@ -40,5 +40,7 @@ public class FireworkUtil
data.addEffects(builder.build()); data.addEffects(builder.build());
data.setPower(RandomUtils.nextInt(3)); data.setPower(RandomUtils.nextInt(3));
firework.setFireworkMeta(data); firework.setFireworkMeta(data);
return firework;
} }
} }

View File

@ -12,6 +12,7 @@ import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving; import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
@ -20,11 +21,14 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class UtilDisplay public class UtilDisplay
{ {
public static final int ENTITY_ID = 777777; public static final int ENTITY_ID = 777777;
public static final EntityType ENTITY_TYPE = EntityType.WITHER;
public static final boolean HALF_HEALTH = true;
private static HashMap<String, Boolean> hasHealthBar = new HashMap<String, Boolean>(); private static HashMap<String, Boolean> hasHealthBar = new HashMap<String, Boolean>();
public static void sendPacket(Player player, Packet packet){ public static void sendPacket(Player player, Packet packet){
@ -34,11 +38,12 @@ public class UtilDisplay
} }
//Accessing packets //Accessing packets
public static PacketPlayOutSpawnEntityLiving getMobPacket(String text, double healthPercent, Location loc){ public static PacketPlayOutSpawnEntityLiving getMobPacket(String text, double healthPercent, Location loc)
{
PacketPlayOutSpawnEntityLiving mobPacket = new PacketPlayOutSpawnEntityLiving(); PacketPlayOutSpawnEntityLiving mobPacket = new PacketPlayOutSpawnEntityLiving();
mobPacket.a = (int) ENTITY_ID; //Entity ID mobPacket.a = (int) ENTITY_ID; //Entity ID
mobPacket.b = (byte) EntityType.WITHER.getTypeId(); //Mob type (ID: 64) mobPacket.b = (byte) ENTITY_TYPE.getTypeId(); //Mob type (ID: 64)
mobPacket.c = (int) Math.floor(loc.getBlockX() * 32.0D); //X position mobPacket.c = (int) Math.floor(loc.getBlockX() * 32.0D); //X position
mobPacket.d = (int) MathHelper.floor(loc.getBlockY() * 32.0D); //Y position mobPacket.d = (int) MathHelper.floor(loc.getBlockY() * 32.0D); //Y position
mobPacket.e = (int) Math.floor(loc.getBlockZ() * 32.0D); //Z position mobPacket.e = (int) Math.floor(loc.getBlockZ() * 32.0D); //Z position
@ -48,31 +53,53 @@ public class UtilDisplay
mobPacket.i = (short) 0; //X velocity mobPacket.i = (short) 0; //X velocity
mobPacket.j = (short) 0; //Y velocity mobPacket.j = (short) 0; //Y velocity
mobPacket.k = (short) 0; //Z velocity mobPacket.k = (short) 0; //Z velocity
DataWatcher watcher = getWatcher(text, 101 + healthPercent * 99, loc.getWorld()); //Dragon or Wither
double health;
if (ENTITY_TYPE == EntityType.WITHER)
{
if (HALF_HEALTH)
health = healthPercent * 149 + 151;
else
health = healthPercent * 299.9 + 0.1;
}
else
{
if (HALF_HEALTH)
health = healthPercent * 99 + 101;
else
health = healthPercent * 199.9 + 0.1;
}
DataWatcher watcher = getWatcher(text, health, loc.getWorld());
mobPacket.l = watcher; mobPacket.l = watcher;
return mobPacket; return mobPacket;
} }
public static PacketPlayOutEntityDestroy getDestroyEntityPacket(){ public static PacketPlayOutEntityDestroy getDestroyEntityPacket()
{
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(ENTITY_ID); PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(ENTITY_ID);
return packet; return packet;
} }
public static PacketPlayOutEntityMetadata getMetadataPacket(DataWatcher watcher){ public static PacketPlayOutEntityMetadata getMetadataPacket(DataWatcher watcher)
{
PacketPlayOutEntityMetadata metaPacket = new PacketPlayOutEntityMetadata(); PacketPlayOutEntityMetadata metaPacket = new PacketPlayOutEntityMetadata();
metaPacket.a = (int) ENTITY_ID; metaPacket.a = (int) ENTITY_ID;
try{ try
{
Field b = PacketPlayOutEntityMetadata.class.getDeclaredField("b"); Field b = PacketPlayOutEntityMetadata.class.getDeclaredField("b");
b.setAccessible(true); b.setAccessible(true);
b.set(metaPacket, watcher.c()); b.set(metaPacket, watcher.c());
} catch(Exception e){ }
catch(Exception e)
{
e.printStackTrace(); e.printStackTrace();
} }
@ -83,16 +110,14 @@ public class UtilDisplay
{ {
DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld)world).getHandle())); DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld)world).getHandle()));
health = Math.max(151, health);
watcher.a(0, (Byte) (byte) 0); //Flags, 0x20 = invisible watcher.a(0, (Byte) (byte) 0); //Flags, 0x20 = invisible
watcher.a(6, (Float) (float) health); watcher.a(6, (Float) (float) health);
watcher.a(2, (String) text); //Entity name watcher.a(2, (String) text); //Entity name
watcher.a(10, (String) text); //Entity name watcher.a(10, (String) text); //Entity name
watcher.a(3, (Byte) (byte) 0); //Show name, 1 = show, 0 = don't show watcher.a(3, (Byte) (byte) 0); //Show name, 1 = show, 0 = don't show
watcher.a(11, (Byte) (byte) 0); //Show name, 1 = show, 0 = don't show watcher.a(11, (Byte) (byte) 0); //Show name, 1 = show, 0 = don't show
watcher.a(16, (Integer) (int) health); //Wither health, 200 = full health watcher.a(16, (Integer) (int) health); //Wither health, 300 = full health
watcher.a(20, (Integer) (int) 0); //Wither invuln, 200 = full health watcher.a(20, (Integer) (int) 0); //Wither invuln,
int i1 = watcher.getInt(0); int i1 = watcher.getInt(0);
watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5))); watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5)));
@ -101,93 +126,44 @@ public class UtilDisplay
return watcher; return watcher;
} }
//Other methods //Display
public static void displayTextBar(JavaPlugin plugin, final Player player, double healthPercent, String text) public static void displayTextBar(JavaPlugin plugin, final Player player, double healthPercent, String text)
{ {
PacketPlayOutEntityDestroy destroyEntityPacket = getDestroyEntityPacket(); PacketPlayOutEntityDestroy destroyEntityPacket = getDestroyEntityPacket();
sendPacket(player, destroyEntityPacket); sendPacket(player, destroyEntityPacket);
PacketPlayOutSpawnEntityLiving mobPacket = getMobPacket(text, healthPercent, player.getEyeLocation().getDirection().multiply(24).toLocation(player.getWorld()).add(player.getLocation())); Location loc = player.getEyeLocation().add(player.getLocation().getDirection().multiply(24));
/*
//Downward
if (player.getLocation().getPitch() > 0)
{
loc = player.getLocation().subtract(0, 10, 0);
}
//Upward
else
{
loc.add(player.getLocation().getDirection().multiply(12));
loc.add(UtilAlg.getDown(player.getLocation().getDirection()).multiply(12));
}
*/
PacketPlayOutSpawnEntityLiving mobPacket = getMobPacket(text, healthPercent, loc);
sendPacket(player, mobPacket); sendPacket(player, mobPacket);
hasHealthBar.put(player.getName(), true); hasHealthBar.put(player.getName(), true);
new BukkitRunnable(){ Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable()
@Override {
public void run(){ public void run()
{
PacketPlayOutEntityDestroy destroyEntityPacket = getDestroyEntityPacket(); PacketPlayOutEntityDestroy destroyEntityPacket = getDestroyEntityPacket();
sendPacket(player, destroyEntityPacket); sendPacket(player, destroyEntityPacket);
hasHealthBar.put(player.getName(), false); hasHealthBar.put(player.getName(), false);
} }
}.runTaskLater(plugin, 120L); }, 20);
}
public static void displayLoadingBar(final String text, final String completeText, final Player player, final int healthAdd, final long delay, final boolean loadUp, final JavaPlugin plugin){
PacketPlayOutEntityDestroy destroyEntityPacket = getDestroyEntityPacket();
sendPacket(player, destroyEntityPacket);
PacketPlayOutSpawnEntityLiving mobPacket = getMobPacket(text, 0, player.getEyeLocation().getDirection().multiply(24).toLocation(player.getWorld()).add(player.getLocation()));
sendPacket(player, mobPacket);
hasHealthBar.put(player.getName(), true);
new BukkitRunnable(){
int health = (loadUp ? 150 : 300);
@Override
public void run(){
if((loadUp ? health < 300 : health > 150)){
DataWatcher watcher = getWatcher(text, health, player.getWorld());
PacketPlayOutEntityMetadata metaPacket = getMetadataPacket(watcher);
sendPacket(player, metaPacket);
if(loadUp){
health += healthAdd;
} else {
health -= healthAdd;
}
} else {
DataWatcher watcher = getWatcher(text, (loadUp ? 300 : 150), player.getWorld());
PacketPlayOutEntityMetadata metaPacket = getMetadataPacket(watcher);
PacketPlayOutEntityDestroy destroyEntityPacket = getDestroyEntityPacket();
sendPacket(player, metaPacket);
sendPacket(player, destroyEntityPacket);
hasHealthBar.put(player.getName(), false);
//Complete text
PacketPlayOutSpawnEntityLiving mobPacket = getMobPacket(completeText, 150, player.getLocation());
sendPacket(player, mobPacket);
hasHealthBar.put(player.getName(), true);
DataWatcher watcher2 = getWatcher(completeText, 300, player.getWorld());
PacketPlayOutEntityMetadata metaPacket2 = getMetadataPacket(watcher2);
sendPacket(player, metaPacket2);
new BukkitRunnable(){
@Override
public void run(){
PacketPlayOutEntityDestroy destroyEntityPacket = getDestroyEntityPacket();
sendPacket(player, destroyEntityPacket);
hasHealthBar.put(player.getName(), false);
}
}.runTaskLater(plugin, 40L);
this.cancel();
}
}
}.runTaskTimer(plugin, delay, delay);
}
public static void displayLoadingBar(final String text, final String completeText, final Player player, final int secondsDelay, final boolean loadUp, JavaPlugin plugin){
final int healthChangePerSecond = 150 / secondsDelay;
displayLoadingBar(text, completeText, player, healthChangePerSecond, 20L, loadUp, plugin);
} }
} }

View File

@ -33,6 +33,8 @@ import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
public class UtilEnt public class UtilEnt
{ {
private static int entityIdCount = 455000;
//Custom Entity Names //Custom Entity Names
private static HashMap<Entity, String> _nameMap = new HashMap<Entity, String>(); private static HashMap<Entity, String> _nameMap = new HashMap<Entity, String>();
private static HashMap<String, EntityType> creatureMap = new HashMap<String, EntityType>(); private static HashMap<String, EntityType> creatureMap = new HashMap<String, EntityType>();
@ -568,4 +570,9 @@ public class UtilEnt
return true; return true;
} }
public static int getNewEntityId()
{
return entityIdCount++;
}
} }

View File

@ -4,6 +4,7 @@ import org.bukkit.FireworkEffect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFirework;
import org.bukkit.entity.Firework; import org.bukkit.entity.Firework;
import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -19,10 +20,10 @@ public class UtilFirework
data.setPower(1); data.setPower(1);
data.addEffect(fe); data.addEffect(fe);
firework.setFireworkMeta(data); firework.setFireworkMeta(data);
((CraftWorld)loc.getWorld()).getHandle().broadcastEntityEffect(((CraftEntity)firework).getHandle(), (byte)17);
firework.remove(); ((CraftFirework) firework).getHandle().expectedLifespan = 1;
// ((CraftWorld)loc.getWorld()).getHandle().broadcastEntityEffect(((CraftEntity)firework).getHandle(), (byte)17);
// firework.remove();
} }
public static Firework launchFirework(Location loc, FireworkEffect fe, Vector dir, int power) public static Firework launchFirework(Location loc, FireworkEffect fe, Vector dir, int power)

View File

@ -10,6 +10,7 @@ import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -396,6 +397,11 @@ public class UtilPlayer
return (((CraftEntity)player).getHandle().getDataWatcher().getByte(0) & 1 << 4) != 0; return (((CraftEntity)player).getHandle().getDataWatcher().getByte(0) & 1 << 4) != 0;
} }
public static boolean is1_8(Player player)
{
return ((CraftPlayer)player).getHandle().playerConnection.networkManager.getVersion() >= 47;
}
/* /*
public void setListName(Player player, CoreClient client) public void setListName(Player player, CoreClient client)

View File

@ -0,0 +1,82 @@
package mineplex.core.common.util;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_7_R4.ChatMessage;
import org.spigotmc.ProtocolInjector.PacketTitle;
import org.spigotmc.ProtocolInjector.PacketTitle.Action;
/**
* Created by Shaun on 9/5/2014.
*/
public class UtilTitle
{
/**
* Show Title text for a player with their current set timings.
*
* Default timings are 20, 60, 20 (in ticks)
*/
public static void showTitle(String text, Player... players)
{
ChatMessage message = new ChatMessage(text);
PacketTitle packet = new PacketTitle(Action.TITLE, message);
sendPacket(packet, players);
}
/**
* Set the current subtitle for a player.
*
* This stays unless reset or cleared, and doesn't appear unless a title is showing
*/
public static void setSubtitle(String text, Player... players)
{
ChatMessage message = new ChatMessage(text);
PacketTitle packet = new PacketTitle(Action.SUBTITLE, message);
sendPacket(packet, players);
}
/**
* Set timings for a player.
*
* Remember these are in ticks
*/
public static void setTimings(int fadeInTicks, int stayTicks, int fadeOutTicks, Player... players)
{
PacketTitle packet = new PacketTitle(Action.TIMES, fadeInTicks, stayTicks, fadeOutTicks);
sendPacket(packet, players);
}
/**
* Clear the title that is currently being displayed, has no affect on timings or subtitle.
*/
public static void clear(Player... players)
{
PacketTitle packet = new PacketTitle(Action.CLEAR);
sendPacket(packet, players);
}
/**
* Reset subtitle and timings for a player.
*
* This will set the subtitle to nothing and timings back to default (20, 60, 20)
*/
public static void reset(Player... players)
{
PacketTitle packet = new PacketTitle(Action.RESET);
sendPacket(packet, players);
}
private static void sendPacket(PacketTitle packet, Player... players)
{
for (Player player : players)
{
if (UtilPlayer.is1_8(player))
{
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
}
}

View File

@ -10,5 +10,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.ServerData"/> <classpathentry combineaccessrules="false" kind="src" path="/Mineplex.ServerData"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jedis-2.4.2.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jedis-2.4.2.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/commons-pool2-2.2.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/commons-pool2-2.2.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Database"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.4.2.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -15,8 +15,8 @@
<orderEntry type="module" module-name="Mineplex.Core.Common" /> <orderEntry type="module" module-name="Mineplex.Core.Common" />
<orderEntry type="module" module-name="Mineplex.ServerData" /> <orderEntry type="module" module-name="Mineplex.ServerData" />
<orderEntry type="library" name="craftbukkit" level="project" /> <orderEntry type="library" name="craftbukkit" level="project" />
<orderEntry type="library" name="jooq" level="project" />
<orderEntry type="module" module-name="Mineplex.Database" /> <orderEntry type="module" module-name="Mineplex.Database" />
<orderEntry type="library" name="jooq" level="project" />
</component> </component>
</module> </module>

View File

@ -6,7 +6,9 @@ import java.util.List;
import mineplex.core.common.DummyEntity; import mineplex.core.common.DummyEntity;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketHandler;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.packethandler.PacketVerifier; import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.packethandler.PacketInfo; import mineplex.core.packethandler.PacketInfo;
import net.minecraft.server.v1_7_R4.DataWatcher; import net.minecraft.server.v1_7_R4.DataWatcher;
@ -29,7 +31,6 @@ import org.bukkit.plugin.java.JavaPlugin;
public class CustomTagFix extends MiniPlugin implements IPacketHandler public class CustomTagFix extends MiniPlugin implements IPacketHandler
{ {
private static int _fakeIdCounter = 455000;
private NautHashMap<Player, NautHashMap<Integer, Integer>> _entityMap = new NautHashMap<Player, NautHashMap<Integer, Integer>>(); private NautHashMap<Player, NautHashMap<Integer, Integer>> _entityMap = new NautHashMap<Player, NautHashMap<Integer, Integer>>();
private Field _destroyId; private Field _destroyId;
@ -68,7 +69,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
Player owner = packetInfo.getPlayer(); Player owner = packetInfo.getPlayer();
PacketVerifier verifier = packetInfo.getVerifier(); PacketVerifier verifier = packetInfo.getVerifier();
if (((CraftPlayer)owner).getHandle().playerConnection.networkManager.getVersion() >= 47) if (UtilPlayer.is1_8(owner))
{ {
if (owner.isOnline() && !_entityMap.containsKey(owner)) if (owner.isOnline() && !_entityMap.containsKey(owner))
_entityMap.put(owner, new NautHashMap<Integer, Integer>()); _entityMap.put(owner, new NautHashMap<Integer, Integer>());
@ -76,6 +77,12 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
if (packet instanceof PacketPlayOutSpawnEntityLiving) if (packet instanceof PacketPlayOutSpawnEntityLiving)
{ {
PacketPlayOutSpawnEntityLiving spawnPacket = (PacketPlayOutSpawnEntityLiving)packet; PacketPlayOutSpawnEntityLiving spawnPacket = (PacketPlayOutSpawnEntityLiving)packet;
// Ignore Armor stand packets
if (spawnPacket.b == 30)
{
return;
}
final String entityName = spawnPacket.l.getString(10); final String entityName = spawnPacket.l.getString(10);
@ -86,7 +93,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner).get(spawnPacket.a))); verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner).get(spawnPacket.a)));
} }
int newId = _fakeIdCounter++; int newId = UtilEnt.getNewEntityId();
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier); sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier);
_entityMap.get(owner).put(spawnPacket.a, newId); _entityMap.get(owner).put(spawnPacket.a, newId);
} }
@ -109,7 +116,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
if (!entityName.isEmpty()) if (!entityName.isEmpty())
{ {
int newId = _fakeIdCounter++; int newId = UtilEnt.getNewEntityId();
sendProtocolPackets(owner, metaPacket.a, newId, entityName, verifier); sendProtocolPackets(owner, metaPacket.a, newId, entityName, verifier);
_entityMap.get(owner).put(metaPacket.a, newId); _entityMap.get(owner).put(metaPacket.a, newId);
} }

View File

@ -88,8 +88,8 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
PlayerStats stats = _statsManager.Get(_target); PlayerStats stats = _statsManager.Get(_target);
for (int i = 0; i < statsToDisplay.length && i < max; i++) for (int i = 0; i < statsToDisplay.length && i < max; i++)
{ {
// Skip showing Wins and Losses for other players // Skip showing Losses, Kills, Deaths for other players
if ((!Player.equals(_target)) && (statsToDisplay[i].equalsIgnoreCase("Wins") || statsToDisplay[i].equalsIgnoreCase("Losses"))) if ((!Player.equals(_target)) && (statsToDisplay[i].equalsIgnoreCase("Losses") || statsToDisplay[i].contains("Kills") || statsToDisplay[i].contains("Deaths")))
continue; continue;
String statName = statsToDisplay[i]; String statName = statsToDisplay[i];

View File

@ -162,8 +162,8 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
String[] friendlyStatNames = _category.getFriendlyStatNames(); String[] friendlyStatNames = _category.getFriendlyStatNames();
for (int i = 0; i < statsToDisplay.length; i++) for (int i = 0; i < statsToDisplay.length; i++)
{ {
// Skip showing Wins and Losses for other players // Skip showing Losses, Kills, Deaths for other players
if ((!Player.equals(_target)) && (statsToDisplay[i].equalsIgnoreCase("Wins") || statsToDisplay[i].equalsIgnoreCase("Losses"))) if ((!Player.equals(_target)) && (statsToDisplay[i].equalsIgnoreCase("Losses") || statsToDisplay[i].contains("Kills") || statsToDisplay[i].contains("Deaths")))
continue; continue;
int statNumber = 0; int statNumber = 0;

View File

@ -2,13 +2,17 @@ package mineplex.core.blockrestore;
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 mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -89,6 +93,32 @@ public class BlockRestore extends MiniPlugin
_blocks.remove(block).restore(); _blocks.remove(block).restore();
} }
public HashSet<Location> RestoreBlockAround(Material type, Location location, int radius)
{
HashSet<Location> restored = new HashSet<Location>();
Iterator<Block> blockIterator = _blocks.keySet().iterator();
while (blockIterator.hasNext())
{
Block block = blockIterator.next();
if (block.getType() != type)
continue;
if (UtilMath.offset(block.getLocation().add(0.5, 0.5, 0.5), location) > radius)
continue;
restored.add(block.getLocation().add(0.5, 0.5, 0.5));
_blocks.get(block).restore();
blockIterator.remove();
}
return restored;
}
public void Add(Block block, int toID, byte toData, long expireTime) public void Add(Block block, int toID, byte toData, long expireTime)
{ {
@ -168,4 +198,6 @@ public class BlockRestore extends MiniPlugin
{ {
return _blocks; return _blocks;
} }
} }

View File

@ -31,7 +31,7 @@ public class MorphBlaze extends MorphGadget
C.cPurple + "Unlocked with Hero Rank", C.cPurple + "Unlocked with Hero Rank",
}, },
-1, -1,
Material.FIRE, (byte)0); Material.BLAZE_POWDER, (byte)0);
} }
@Override @Override

View File

@ -36,6 +36,8 @@ public abstract class OutfitGadget extends Gadget
{ {
Manager.RemoveMorph(player); Manager.RemoveMorph(player);
Manager.RemoveOutfit(player, _slot);
_active.add(player); _active.add(player);
UtilPlayer.message(player, F.main("Gadget", "You put on " + F.elem(GetName()) + ".")); UtilPlayer.message(player, F.main("Gadget", "You put on " + F.elem(GetName()) + "."));
@ -60,7 +62,7 @@ public abstract class OutfitGadget extends Gadget
UtilPlayer.message(player, F.main("Gadget", "You took off " + F.elem(GetName()) + ".")); UtilPlayer.message(player, F.main("Gadget", "You took off " + F.elem(GetName()) + "."));
if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(null); if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(null);
else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(null); else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(null);
else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(null); else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(null);
else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(null); else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(null);

View File

@ -0,0 +1,89 @@
package mineplex.core.hologram;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_7_R4.DataWatcher;
import net.minecraft.server.v1_7_R4.EnumEntitySize;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.PlayerConnection;
import mineplex.core.common.DummyEntity;
import mineplex.core.common.util.UtilEnt;
/**
* Created by Shaun on 9/5/2014.
*/
public class ArmorStandHologram
{
private String _text;
private Packet _packet;
private int _entityId;
public ArmorStandHologram(Location location, String text)
{
_text = text;
_entityId = UtilEnt.getNewEntityId();
_packet = createArmorStandPacket(location);
}
public void sendToPlayer(Player player)
{
((CraftPlayer) player).getHandle().playerConnection.sendPacket(_packet);
}
public void removeForPlayer(Player player)
{
PacketPlayOutEntityDestroy entityDestroyPacket = new PacketPlayOutEntityDestroy(_entityId);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(entityDestroyPacket);
}
private PacketPlayOutSpawnEntityLiving createArmorStandPacket(Location location)
{
final PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = _entityId;
packet.b = (byte) 30;
packet.c = MathHelper.floor(location.getX() * 32D);//(int) EnumEntitySize.SIZE_2.a(100);
packet.d = MathHelper.floor((location.getY() - 0.8) * 32D);//(int) MathHelper.floor(64 * 32.0D);
packet.e = MathHelper.floor(location.getZ() * 32D);//(int)EnumEntitySize.SIZE_2.a(100);
packet.f = 0; // Velocity X
packet.g = 0; // Velocity Y
packet.h = 0; // Velocity Z
packet.i = (byte) 0; // Yaw
packet.j = (byte) 0; // Pitch
packet.k = (byte) 0; // Head Pitch
final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld)location.getWorld()).getHandle()));
watcher.a(0, Byte.valueOf((byte)0));
watcher.a(1, Short.valueOf((short)300));
watcher.a(2, _text);
watcher.a(3, Byte.valueOf((byte) 1));
watcher.a(4, Byte.valueOf((byte)0));
watcher.a(7, Integer.valueOf(0));
watcher.a(8, Byte.valueOf((byte)0));
watcher.a(9, Byte.valueOf((byte)0));
watcher.a(6, Float.valueOf(1.0F));
watcher.a(10, Byte.valueOf((byte)0));
// Set invisible
int i1 = watcher.getInt(0);
watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5)));
// Set small and No Gravity
byte b1 = watcher.getByte(10);
b1 = (byte)(b1 | 0x1);
b1 = (byte)(b1 | 0x2);
watcher.watch(10, Byte.valueOf(b1));
packet.l = watcher;
return packet;
}
}

View File

@ -0,0 +1,68 @@
package mineplex.core.hologram;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import mineplex.core.common.util.UtilPlayer;
/**
* Created by shaun on 2014-09-09.
*/
public class Hologram
{
private HorseHologram _horseHologram;
private ArmorStandHologram _armorStandHologram;
private Location _location;
private String _text;
public Hologram(Location location, String text)
{
_location = location;
_text = text;
_horseHologram = new HorseHologram(location, text);
_armorStandHologram = new ArmorStandHologram(location, text);
}
public void sendToPlayer(Player player)
{
if (UtilPlayer.is1_8(player))
{
_armorStandHologram.sendToPlayer(player);
}
else
{
_horseHologram.sendToPlayer(player);
}
}
public void sendToPlayers(Player... players)
{
for (Player player : players)
{
sendToPlayer(player);
}
}
public void removeForPlayer(Player player)
{
if (UtilPlayer.is1_8(player))
{
_armorStandHologram.removeForPlayer(player);
}
else
{
_horseHologram.removeForPlayer(player);
}
}
public void removeForPlayers(Player... players)
{
for (Player player : players)
{
removeForPlayer(player);
}
}
}

View File

@ -19,10 +19,10 @@ import mineplex.core.common.util.UtilServer;
/** /**
* Created by Shaun on 8/29/2014. * Created by Shaun on 8/29/2014.
*/ */
public class SimpleHologram public class HorseHologram
{ {
/** /**
* SimpleHologram creates the required entities to spawn in a hologram. It is possible to send the packets for the entities to a player, * HorseHologram creates the required entities to spawn in a hologram. It is possible to send the packets for the entities to a player,
* but it is also possible to add the entities to the nmsWorld to keep them loaded into the server. * but it is also possible to add the entities to the nmsWorld to keep them loaded into the server.
*/ */
@ -33,7 +33,7 @@ public class SimpleHologram
private EntityFireball _fireball; private EntityFireball _fireball;
private EntityHorse _horse; private EntityHorse _horse;
public SimpleHologram(Location location, String text) public HorseHologram(Location location, String text)
{ {
_location = location; _location = location;
_text = text; _text = text;
@ -52,31 +52,40 @@ public class SimpleHologram
_horse.setCustomNameVisible(true); _horse.setCustomNameVisible(true);
} }
public void spawnWithPackets() public void sendToPlayer(Player player)
{ {
Packet fireballSpawn = getFireballSpawnPacket(); Packet fireballSpawn = getFireballSpawnPacket();
Packet horseSpawn = getHorseSpawnPacket(); Packet horseSpawn = getHorseSpawnPacket();
Packet attachPacket = getAttachEntityPacket(); Packet attachPacket = getAttachEntityPacket();
sendPacket(player, fireballSpawn);
sendPacket(player, horseSpawn);
sendPacket(player, attachPacket);
}
public void removeForPlayer(Player player)
{
Packet horseDestroy = getHorseDestroyPacket();
Packet fireballDestroy = getFireballDestroyPacket();
sendPacket(player, horseDestroy);
sendPacket(player, fireballDestroy);
}
public void spawnWithPackets()
{
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
sendPacket(player, fireballSpawn); sendToPlayer(player);
sendPacket(player, horseSpawn);
sendPacket(player, attachPacket);
} }
} }
public void removeWithPackets() public void removeWithPackets()
{ {
Packet horseDestroy = getHorseDestroyPacket(); for (Player player : UtilServer.getPlayers())
Packet fireballDestroy = getFireballDestroyPacket(); {
removeForPlayer(player);
for (Player player : UtilServer.getPlayers()) }
{
sendPacket(player, horseDestroy);
sendPacket(player, fireballDestroy);
}
} }
public void setText(String text) public void setText(String text)

View File

@ -11,7 +11,7 @@ import mineplex.core.database.RepositoryBase;
import mineplex.database.Tables; import mineplex.database.Tables;
import org.jooq.DSLContext; import org.jooq.DSLContext;
import org.jooq.Query; import org.jooq.Query;
import org.jooq.impl.DSL; import org.jooq.impl.DSL;
public class LeaderboardRepository extends RepositoryBase public class LeaderboardRepository extends RepositoryBase
{ {

View File

@ -18,13 +18,11 @@ public class ChestData
private Block _block; private Block _block;
private ITreasureReward _reward; private ITreasureReward _reward;
private boolean _opened; private boolean _opened;
private boolean _finishedOpen;
public ChestData(Block block, ITreasureReward reward) public ChestData(Block block, ITreasureReward reward)
{ {
_block = block; _block = block;
_opened = false; _opened = false;
_finishedOpen = false;
_reward = reward; _reward = reward;
} }
@ -33,21 +31,11 @@ public class ChestData
return _opened; return _opened;
} }
public boolean isFinishedOpen()
{
return _finishedOpen;
}
public void setOpened(boolean opened) public void setOpened(boolean opened)
{ {
_opened = opened; _opened = opened;
} }
public void setFinishedOpen(boolean finishedOpen)
{
_finishedOpen = finishedOpen;
}
public Block getBlock() public Block getBlock()
{ {
return _block; return _block;

View File

@ -5,21 +5,26 @@ import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import org.bukkit.ChatColor; import org.bukkit.Bukkit;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
import mineplex.core.treasure.animation.ChestSpawnAnimation;
import mineplex.core.treasure.animation.ChestOpenAnimation;
import mineplex.core.treasure.animation.ParticleAnimation;
import mineplex.core.treasure.animation.Animation; import mineplex.core.treasure.animation.Animation;
import mineplex.core.treasure.reward.ExampleReward; import mineplex.core.treasure.animation.ChestExplodeAnimation;
import mineplex.core.treasure.animation.ChestOpenAnimation;
import mineplex.core.treasure.animation.ChestSpawnAnimation;
import mineplex.core.treasure.animation.CircleAnimation;
import mineplex.core.treasure.animation.FireworksAnimation;
import mineplex.core.treasure.event.TreasureFinishEvent;
import mineplex.core.treasure.reward.ITreasureReward; import mineplex.core.treasure.reward.ITreasureReward;
import mineplex.core.treasure.reward.RewardRarity;
/** /**
* Created by Shaun on 8/27/2014. * Created by Shaun on 8/27/2014.
@ -32,18 +37,20 @@ public class Treasure
private Block _centerBlock; private Block _centerBlock;
private int _tickCount; private int _tickCount;
private ChestData[] _chestData; private ChestData[] _chestData;
private ITreasureReward[] _rewards;
private boolean _finished;
private int _finishedTickCount;
private LinkedList<Animation> _animations; private LinkedList<Animation> _animations;
private TreasureStyle _style; private TreasureStyle _style;
public Treasure(Player player) public Treasure(Player player, ITreasureReward[] rewards)
{ {
this(player, new Random()); this(player, new Random(), rewards);
} }
public Treasure(Player player, Random seed) public Treasure(Player player, Random seed, ITreasureReward[] rewards)
{ {
_player = player; _player = player;
_random = seed; _random = seed;
@ -56,10 +63,12 @@ public class Treasure
// _animations.add(new ParticleAnimation(this)); // _animations.add(new ParticleAnimation(this));
_chestData = new ChestData[4]; _chestData = new ChestData[4];
_chestData[0] = new ChestData(_centerBlock.getRelative(2, 1, 0), new ExampleReward()); _chestData[0] = new ChestData(_centerBlock.getRelative(2, 1, 0), rewards[0]);
_chestData[1] = new ChestData(_centerBlock.getRelative(-2, 1, 0), new ExampleReward()); _chestData[1] = new ChestData(_centerBlock.getRelative(-2, 1, 0), rewards[1]);
_chestData[2] = new ChestData(_centerBlock.getRelative(0, 1, 2), new ExampleReward()); _chestData[2] = new ChestData(_centerBlock.getRelative(0, 1, 2), rewards[2]);
_chestData[3] = new ChestData(_centerBlock.getRelative(0, 1, -2), new ExampleReward()); _chestData[3] = new ChestData(_centerBlock.getRelative(0, 1, -2), rewards[3]);
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " is opening a " + C.cGreen + "Treasure Chest"));
} }
private void createCenterClay() private void createCenterClay()
@ -122,8 +131,17 @@ public class Treasure
} }
} }
public int getFinishedTickCount()
{
return _finishedTickCount;
}
public void update() public void update()
{ {
if (_finished)
{
_finishedTickCount++;
}
if (_tickCount == 5) if (_tickCount == 5)
{ {
@ -218,14 +236,30 @@ public class Treasure
ChestData data = getChestData(block); ChestData data = getChestData(block);
if (data != null && !data.isOpened()) if (data != null && !data.isOpened())
{ {
data.setOpened(true); String text = data.getReward().giveReward(_player);
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data); data.setOpened(true);
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data, text);
_animations.add(chestOpenTask); _animations.add(chestOpenTask);
// Extra effects based off the rarity of the treasure
if (data.getReward().getRarity() == RewardRarity.UNCOMMON)
{
_animations.add(new FireworksAnimation(this, data.getBlock()));
}
else if (data.getReward().getRarity() == RewardRarity.RARE)
{
_animations.add(new CircleAnimation(this, data.getBlock().getLocation().add(0.5, 1.5, 0.5)));
}
else if (data.getReward().getRarity() == RewardRarity.VERY_RARE)
{
_animations.add(new ChestExplodeAnimation(this, data.getBlock()));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " opened an extremely rare treasure!"));
}
if (isFinished()) if (isFinished())
{ {
System.out.println("finished"); _finished = true;
} }
} }
} }
@ -242,6 +276,11 @@ public class Treasure
return null; return null;
} }
public Player getPlayer()
{
return _player;
}
public boolean isFinished() public boolean isFinished()
{ {
boolean allOpened = true; boolean allOpened = true;
@ -254,8 +293,20 @@ public class Treasure
return allOpened; return allOpened;
} }
public void finish() public void cleanup()
{ {
for (ChestData chestData : _chestData)
{
// Give any unopened rewards to the player
// This only applies if they leave the server
// while opening a treasure
if (!chestData.isOpened())
{
chestData.setOpened(true);
chestData.getReward().giveReward(_player);
}
}
for (Map.Entry<Block, BlockInfo> entry : _blockRestoreMap.entrySet()) for (Map.Entry<Block, BlockInfo> entry : _blockRestoreMap.entrySet())
{ {
Block block = entry.getKey(); Block block = entry.getKey();
@ -263,6 +314,7 @@ public class Treasure
block.setTypeId(data.getId()); block.setTypeId(data.getId());
block.setData(data.getData()); block.setData(data.getData());
block.getLocation().getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
} }
for (Animation animation : _animations) for (Animation animation : _animations)

View File

@ -1,16 +1,11 @@
package mineplex.core.treasure; package mineplex.core.treasure;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.block.CraftBlock;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
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;
@ -18,18 +13,28 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.treasure.event.TreasureFinishEvent;
import mineplex.core.treasure.event.TreasureStartEvent;
import mineplex.core.treasure.reward.ITreasureReward;
import mineplex.core.treasure.reward.RewardManager;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.treasure.reward.rewards.CoinReward;
import mineplex.core.treasure.reward.rewards.InventoryReward;
import mineplex.core.treasure.reward.rewards.UnknownPackageReward;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -39,12 +44,77 @@ import mineplex.core.updater.event.UpdateEvent;
public class TreasureManager extends MiniPlugin public class TreasureManager extends MiniPlugin
{ {
private NautHashMap<Player, Treasure> _playerTreasureMap; private NautHashMap<Player, Treasure> _playerTreasureMap;
private RewardManager _rewardManager;
private DonationManager _donationManager;
private InventoryManager _inventoryManager;
public TreasureManager(JavaPlugin plugin) public TreasureManager(JavaPlugin plugin, DonationManager donationManager, InventoryManager inventoryManager)
{ {
super("Treasure", plugin); super("Treasure", plugin);
_donationManager = donationManager;
_playerTreasureMap = new NautHashMap<Player, Treasure>(); _playerTreasureMap = new NautHashMap<Player, Treasure>();
_rewardManager = new RewardManager();
_inventoryManager = inventoryManager;
// Very Rare
_rewardManager.addReward(new CoinReward(donationManager, 1000, 2000, 1000, RewardRarity.VERY_RARE));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Helix Particles", "Blood Helix",
new ItemStack(Material.REDSTONE), RewardRarity.VERY_RARE, 100));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Enchant Particles", "Enchanted",
new ItemStack(Material.BOOK), RewardRarity.VERY_RARE, 1000));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Fire Rings Particles", "Flame Rings",
new ItemStack(Material.BLAZE_POWDER), RewardRarity.VERY_RARE, 600));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Foot Particles", "Shadow Walk",
new ItemStack(Material.LEATHER_BOOTS), RewardRarity.VERY_RARE, 1200));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Green Particles", "Green Ring",
new ItemStack(Material.EMERALD), RewardRarity.VERY_RARE, 200));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Rain Particles", "Rain Cloud",
new ItemStack(Material.INK_SACK), RewardRarity.VERY_RARE, 300));
// _rewardManager.addReward(new UnknownPackageReward(donationManager, "Notch Morph", "Notch",
// new ItemStack(Material.INK_SACK), RewardRarity.VERY_RARE, 10));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Gem Boosters", "Gem Booster", 50, 100,
new ItemStack(Material.EMERALD_BLOCK), RewardRarity.VERY_RARE, 500));
// Rare
_rewardManager.addReward(new CoinReward(donationManager, 500, 1000, 1000, RewardRarity.RARE));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Bat Morph", "Bat Morph",
new ItemStack(Material.SKULL_ITEM, 1, (short) 0, (byte) 1), RewardRarity.RARE, 100));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Block Morph", "Block Morph",
new ItemStack(Material.EMERALD_BLOCK), RewardRarity.RARE, 200));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Chicken Morph", "Chicken Morph",
new ItemStack(Material.FEATHER), RewardRarity.RARE, 300));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Cow Morph", "Cow Morph",
new ItemStack(Material.LEATHER), RewardRarity.RARE, 500));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Enderman Morph", "Enderman Morph",
new ItemStack(Material.ENDER_PEARL), RewardRarity.RARE, 200));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Gem Boosters", "Gem Booster", 10, 20,
new ItemStack(Material.EMERALD_BLOCK), RewardRarity.RARE, 500));
// Uncommon
_rewardManager.addReward(new CoinReward(donationManager, 100, 500, 2000, RewardRarity.UNCOMMON));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Ender Pearls", "Ethereal Pearl", 75, 150,
new ItemStack(Material.ENDER_PEARL), RewardRarity.UNCOMMON, 1000));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks", 75, 150,
new ItemStack(Material.FIREWORK), RewardRarity.UNCOMMON, 1000));
_rewardManager.addReward(new InventoryReward(inventoryManager, "TNT", "TNT", 30, 60,
new ItemStack(Material.TNT), RewardRarity.UNCOMMON, 1000));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Melons", "Melon Launcher", 150, 300,
new ItemStack(Material.MELON_BLOCK), RewardRarity.UNCOMMON, 1000));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Gem Boosters", "Gem Booster", 1, 10,
new ItemStack(Material.EMERALD_BLOCK), RewardRarity.UNCOMMON, 500));
// Common
_rewardManager.addReward(new CoinReward(donationManager, 0, 100, 2000, RewardRarity.COMMON));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Ender Pearls", "Ethereal Pearl", 25, 75,
new ItemStack(Material.ENDER_PEARL), RewardRarity.COMMON, 1000));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks", 25, 75,
new ItemStack(Material.FIREWORK), RewardRarity.COMMON, 1000));
_rewardManager.addReward(new InventoryReward(inventoryManager, "TNT", "TNT", 10, 30,
new ItemStack(Material.TNT), RewardRarity.COMMON, 1000));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Melons", "Melon Launcher", 50, 150,
new ItemStack(Material.MELON_BLOCK), RewardRarity.COMMON, 1000));
} }
@Override @Override
@ -52,16 +122,25 @@ public class TreasureManager extends MiniPlugin
{ {
for (Treasure treasure : _playerTreasureMap.values()) for (Treasure treasure : _playerTreasureMap.values())
{ {
treasure.finish(); treasure.cleanup();
} }
} }
public void attemptOpenTreasure(Player player) public void attemptOpenTreasure(Player player)
{ {
if (!checkNearbyBlocks(player)) if (!checkNearbyBlocks(player) || checkNearSpawn(player) || checkInAir(player))
return; return;
Treasure treasure = new Treasure(player); TreasureStartEvent event = new TreasureStartEvent(player);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
ITreasureReward[] rewards = _rewardManager.getRewards(player);
Treasure treasure = new Treasure(player, rewards);
_playerTreasureMap.put(player, treasure); _playerTreasureMap.put(player, treasure);
Location teleportLocation = treasure.getPlayerBlock().getLocation().add(0.5, 0, 0.5); Location teleportLocation = treasure.getPlayerBlock().getLocation().add(0.5, 0, 0.5);
@ -74,6 +153,7 @@ public class TreasureManager extends MiniPlugin
private boolean checkNearbyBlocks(Player player) private boolean checkNearbyBlocks(Player player)
{ {
//todo improve this
Block centerBlock = player.getLocation().getBlock(); Block centerBlock = player.getLocation().getBlock();
for (int y = 0; y <= 3; y++) for (int y = 0; y <= 3; y++)
@ -85,7 +165,7 @@ public class TreasureManager extends MiniPlugin
Block block = centerBlock.getRelative(x, y, z); Block block = centerBlock.getRelative(x, y, z);
if (UtilBlock.solid(block)) if (UtilBlock.solid(block))
{ {
UtilPlayer.message(player, F.main("Treasure", "You can not open a treasure at this spot. Please find a more open location")); UtilPlayer.message(player, F.main("Treasure", "You can't open chests here."));
return false; return false;
} }
} }
@ -94,6 +174,25 @@ public class TreasureManager extends MiniPlugin
return true; return true;
} }
private boolean checkInAir(Player player)
{
boolean grounded = UtilEnt.isGrounded(player);
if (!grounded)
UtilPlayer.message(player, F.main("Treasure", "You can't open chests while in the air."));
return !grounded;
}
private boolean checkNearSpawn(Player player)
{
boolean nearSpawn = UtilMath.offset2d(new Location(player.getWorld(), 0, 0, 0), player.getLocation()) < 10;
if (nearSpawn)
UtilPlayer.message(player, F.main("Treasure", "You can't open chests near spawn."));
return nearSpawn;
}
@EventHandler @EventHandler
public void update(UpdateEvent event) public void update(UpdateEvent event)
@ -101,9 +200,21 @@ public class TreasureManager extends MiniPlugin
if (event.getType() != UpdateType.TICK) if (event.getType() != UpdateType.TICK)
return; return;
for (Treasure treasure : _playerTreasureMap.values()) Iterator<Treasure> iterator = _playerTreasureMap.values().iterator();
while(iterator.hasNext())
{ {
Treasure treasure = iterator.next();
treasure.update(); treasure.update();
if (treasure.isFinished() && treasure.getFinishedTickCount() >= 100)
{
treasure.cleanup();
iterator.remove();
TreasureFinishEvent finishEvent = new TreasureFinishEvent(treasure.getPlayer(), treasure);
Bukkit.getPluginManager().callEvent(finishEvent);
}
} }
} }
@ -113,7 +224,7 @@ public class TreasureManager extends MiniPlugin
if (_playerTreasureMap.containsKey(event.getPlayer())) if (_playerTreasureMap.containsKey(event.getPlayer()))
{ {
Treasure treasure = _playerTreasureMap.remove(event.getPlayer()); Treasure treasure = _playerTreasureMap.remove(event.getPlayer());
treasure.finish(); treasure.cleanup();
} }
} }
@ -175,16 +286,22 @@ public class TreasureManager extends MiniPlugin
} }
} }
// @EventHandler @EventHandler
// public void command(PlayerCommandPreprocessEvent event) public void treasureFinish(TreasureFinishEvent event)
// { {
// //TODO Remove _playerTreasureMap.remove(event.getPlayer());
// if (event.getMessage().startsWith("/treasure")) }
// {
// event.getPlayer().sendMessage("Attempting to open treasure..."); @EventHandler
// attemptOpenTreasure(event.getPlayer()); public void command(PlayerCommandPreprocessEvent event)
// event.setCancelled(true); {
// } //TODO Remove
// } if (event.getMessage().startsWith("/treasure"))
{
event.getPlayer().sendMessage("Attempting to open treasure...");
attemptOpenTreasure(event.getPlayer());
event.setCancelled(true);
}
}
} }

View File

@ -12,20 +12,40 @@ public enum TreasureStyle
/** /**
* These are examples, not final! * These are examples, not final!
*/ */
RED(Material.STAINED_CLAY, (byte) 14, NETHER(Material.NETHERRACK, (byte) 0,
Material.STAINED_CLAY, (byte) 6, Material.NETHER_BRICK, (byte) 0,
Material.STAINED_GLASS_PANE, (byte) 14, Material.NETHER_FENCE, (byte) 0,
ParticleType.HEART, null,
ParticleType.HAPPY_VILLAGER,
ParticleType.FLAME),
GREEN(Material.STAINED_CLAY,(byte) 5,
Material.STAINED_CLAY, (byte) 13,
Material.STAINED_GLASS_PANE, (byte) 5,
ParticleType.FLAME, ParticleType.FLAME,
ParticleType.RED_DUST, ParticleType.LAVA),
ParticleType.LAVA);
NATURE(Material.GRASS, (byte) 0,
Material.LOG, (byte) 0,
Material.LEAVES, (byte) 0,
null,
ParticleType.HAPPY_VILLAGER,
ParticleType.SLIME),
WATER(Material.ICE,(byte) 9,
Material.PACKED_ICE, (byte) 5,
Material.STAINED_GLASS_PANE, (byte) 8,
null,
ParticleType.SPLASH,
ParticleType.SNOWBALL_POOF);
// FANCY(Material.DIAMOND_BLOCK,(byte) 0,
// Material.GOLD_BLOCK, (byte) 0,
// Material.AIR, (byte) 0,
// ParticleType.FLAME,
// ParticleType.CLOUD,
// ParticleType.LAVA),
//
// FANCY_2(Material.IRON_BLOCK,(byte) 0,
// Material.EMERALD_BLOCK, (byte) 0,
// Material.AIR, (byte) 0,
// ParticleType.FLAME,
// ParticleType.HAPPY_VILLAGER,
// null);
private Material _primaryMaterial; private Material _primaryMaterial;
private byte _primaryData; private byte _primaryData;

View File

@ -0,0 +1,68 @@
package mineplex.core.treasure.animation;
import java.util.Random;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.treasure.Treasure;
/**
* Created by shaun on 14-09-12.
*/
public class ChestExplodeAnimation extends Animation
{
/**
* Played when a "Very Rare" chest is opened
*/
private Random _random = new Random();
private Block _chestBlock;
public ChestExplodeAnimation(Treasure treasure, Block chestBlock)
{
super(treasure);
_chestBlock = chestBlock;
}
@Override
protected void tick()
{
if (getTicks() == 1)
{
// _chestBlock.getLocation().getWorld().playSound(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Sound.WITHER_SPAWN, 10F, 1.2F);
_chestBlock.getLocation().getWorld().playSound(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F);
}
if (getTicks() == 10)
{
FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.RED).withFade(Color.BLACK).build();
UtilFirework.playFirework(_chestBlock.getLocation().add(0.5, 0.5, 0.5), effect);
// ((CraftWorld) _chestBlock.getWorld()).getHandle().triggerEffect(1005, _chestBlock.getX(), _chestBlock.getY(), _chestBlock.getZ(), 2257);
}
else if (getTicks() < 10)
{
double xDif = _random.nextGaussian() * 0.5;
double zDif = _random.nextGaussian() * 0.5;
double yDif = _random.nextGaussian() * 0.5;
Location loc = _chestBlock.getLocation().add(0.5, 0.5, 0.5).add(xDif, zDif, yDif);
loc.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 0F);
}
else
{
finish();
}
}
@Override
protected void onFinish()
{
}
}

View File

@ -8,11 +8,11 @@ import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction; import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.hologram.SimpleHologram; import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HorseHologram;
import mineplex.core.treasure.ChestData; import mineplex.core.treasure.ChestData;
import mineplex.core.treasure.Treasure; import mineplex.core.treasure.Treasure;
@ -22,14 +22,16 @@ import mineplex.core.treasure.Treasure;
public class ChestOpenAnimation extends Animation public class ChestOpenAnimation extends Animation
{ {
private ChestData _chestData; private ChestData _chestData;
private String _text;
private Item _itemEntity; private Item _itemEntity;
private SimpleHologram _hologram; private Hologram _hologram;
public ChestOpenAnimation(Treasure treasure, ChestData chestData) public ChestOpenAnimation(Treasure treasure, ChestData chestData, String text)
{ {
super(treasure); super(treasure);
_chestData = chestData; _chestData = chestData;
_text = text;
// Send chest open packet // Send chest open packet
Block block = chestData.getBlock(); Block block = chestData.getBlock();
@ -53,10 +55,8 @@ public class ChestOpenAnimation extends Animation
} }
else if (getTicks() == 15) else if (getTicks() == 15)
{ {
_hologram = new SimpleHologram(_chestData.getBlock().getLocation().add(0.5, 1.1, 0.5), _chestData.getReward().getText()); _hologram = new Hologram(_chestData.getBlock().getLocation().add(0.5, 1.1, 0.5), _text);
_hologram.spawnWithPackets(); _hologram.sendToPlayers(_chestData.getBlock().getLocation().getWorld().getPlayers().toArray(new Player[0]));
_chestData.setFinishedOpen(true);
} }
} }
@ -64,7 +64,7 @@ public class ChestOpenAnimation extends Animation
{ {
if (_hologram != null) if (_hologram != null)
{ {
_hologram.removeWithPackets(); _hologram.removeForPlayers(_chestData.getBlock().getLocation().getWorld().getPlayers().toArray(new Player[0]));
_itemEntity.remove(); _itemEntity.remove();
} }
} }

View File

@ -4,6 +4,10 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.PacketPlayOutWorldEvent;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
import mineplex.core.treasure.Treasure; import mineplex.core.treasure.Treasure;
@ -49,7 +53,20 @@ public class ChestSpawnAnimation extends Animation
getTreasure().setBlock(_block, Material.CHEST, _direction); getTreasure().setBlock(_block, Material.CHEST, _direction);
_block.getLocation().getWorld().playSound(_centerLocation, Sound.ANVIL_LAND, 0.5f, 1f); _block.getLocation().getWorld().playSound(_centerLocation, Sound.ANVIL_LAND, 0.5f, 1f);
UtilParticle.PlayParticle(getTreasure().getStyle().getChestSpawnParticle(), _centerLocation, 0.2f, 0.2f, 0.2f, 0, 50); UtilParticle.ParticleType particleType = getTreasure().getStyle().getChestSpawnParticle();
if (particleType != null)
{
UtilParticle.PlayParticle(particleType, _centerLocation, 0.2f, 0.2f, 0.2f, 0, 50);
}
else
{
// TODO This doesnt work for 1.8 clients
int i = MathHelper.floor(_centerLocation.getX());
int j = MathHelper.floor(_centerLocation.getY() - 0.20000000298023224D - 0.5);
int k = MathHelper.floor(_centerLocation.getZ());
((CraftWorld) _centerLocation.getWorld()).getHandle().triggerEffect(2006, i, j, k, MathHelper.f(60 - 3.0F));
}
finish(); finish();
} }
} }

View File

@ -0,0 +1,60 @@
package mineplex.core.treasure.animation;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.treasure.Treasure;
/**
* Created by shaun on 2014-09-09.
*/
public class CircleAnimation extends Animation
{
/**
* Played when a "Rare" chest is opened
*/
private Location _centerLocation;
public CircleAnimation(Treasure treasure, Location centerLocation)
{
super(treasure);
_centerLocation = centerLocation;
}
@Override
protected void tick()
{
if (getTicks() == 2)
{
UtilFirework.playFirework(_centerLocation, FireworkEffect.builder().withColor(Color.ORANGE).with(FireworkEffect.Type.BURST).build());
_centerLocation.getWorld().playSound(_centerLocation, Sound.WITHER_SPAWN, 10F, 1.2F);
}
else if (getTicks() >= 60)
{
finish();
}
double currentRotation = getTicks() / 20D;
double radius = currentRotation;
double yDiff = currentRotation;
double xDiff = Math.sin(currentRotation * 2 * Math.PI) * radius;
double zDiff = Math.cos(currentRotation * 2 * Math.PI) * radius;
Location location = _centerLocation.clone().add(xDiff, yDiff, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, location, 0, 0, 0, 0, 1);
}
@Override
protected void onFinish()
{
}
}

View File

@ -0,0 +1,68 @@
package mineplex.core.treasure.animation;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFirework;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityStatus;
import mineplex.core.common.util.FireworkUtil;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.treasure.Treasure;
/**
* Created by shaun on 2014-09-09.
*/
public class FireworksAnimation extends Animation
{
/**
* Played when an "Uncommon" chest is opened
*/
private Random _random = new Random();
private Block _block;
public FireworksAnimation(Treasure treasure, Block block)
{
super(treasure);
_block = block;
}
@Override
protected void tick()
{
if (getTicks() >= 1)
finish();
if (getTicks() % 10 == 0)
{
double xDif = 0;//_random.nextGaussian() * 1;
double zDif = 0;//_random.nextGaussian() * 1;
double yDif = 2;//(_random.nextInt(3) * _random.nextDouble()) + 2;
FireworkEffect effect = FireworkEffect.builder().withColor(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255)))
.withFade(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255)))
.with(FireworkEffect.Type.STAR)
.build();
UtilFirework.playFirework(_block.getLocation().add(xDif, yDif, zDif), effect);
}
}
@Override
protected void onFinish()
{
}
}

View File

@ -0,0 +1,44 @@
package mineplex.core.treasure.event;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.core.treasure.Treasure;
/**
* Created by shaun on 14-09-12.
*/
public class TreasureFinishEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private final Player _player;
private final Treasure _treasure;
public TreasureFinishEvent(Player player, Treasure treasure)
{
_player = player;
_treasure = treasure;
}
public Player getPlayer()
{
return _player;
}
public Treasure getTreasure()
{
return _treasure;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -0,0 +1,49 @@
package mineplex.core.treasure.event;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Created by shaun on 14-09-12.
*/
public class TreasureStartEvent extends Event implements Cancellable
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private boolean _cancelled = false;
public TreasureStartEvent(Player player)
{
_player = player;
}
public Player getPlayer()
{
return _player;
}
@Override
public boolean isCancelled()
{
return _cancelled;
}
@Override
public void setCancelled(boolean cancelled)
{
_cancelled = cancelled;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -1,30 +0,0 @@
package mineplex.core.treasure.reward;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
/**
* Created by Shaun on 9/2/2014.
*/
public class ExampleReward implements ITreasureReward
{
@Override
public String getText()
{
return C.cGreen + "100 Gems";
}
@Override
public ItemStack getItem()
{
return new ItemStack(Material.EMERALD);
}
@Override
public RewardRarity getRarity()
{
return RewardRarity.COMMON;
}
}

View File

@ -1,5 +1,6 @@
package mineplex.core.treasure.reward; package mineplex.core.treasure.reward;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
/** /**
@ -7,10 +8,22 @@ import org.bukkit.inventory.ItemStack;
*/ */
public interface ITreasureReward public interface ITreasureReward
{ {
public String getText();
public ItemStack getItem(); public ItemStack getItem();
public RewardRarity getRarity(); public RewardRarity getRarity();
/**
* Give the reward to the player.
*
* @return String detailing the reward. This will be shown to the player
*/
public String giveReward(Player player);
public boolean canGiveReward(Player player);
/**
* This is used to weight rewards across different rarities. Rewards with a larger weight
* will have a higher chance of being selected
*/
public int getWeight();
} }

View File

@ -0,0 +1,149 @@
package mineplex.core.treasure.reward;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import org.bukkit.entity.Player;
/**
* Created by shaun on 2014-09-04.
*/
public class RewardManager
{
private HashMap<RewardRarity, List<ITreasureReward>> _treasureMap;
private Random _random;
public RewardManager()
{
_treasureMap = new HashMap<RewardRarity, List<ITreasureReward>>();
_random = new Random();
for (RewardRarity rarity : RewardRarity.values())
{
_treasureMap.put(rarity, new ArrayList<ITreasureReward>());
}
}
public void addReward(ITreasureReward reward)
{
RewardRarity rarity = reward.getRarity();
List<ITreasureReward> treasureList = _treasureMap.get(rarity);
treasureList.add(reward);
}
public ITreasureReward[] getRewards(Player player)
{
int currentReward = 0;
ITreasureReward[] rewards = new ITreasureReward[4];
boolean hasUncommon = false;
while (currentReward < 4)
{
ITreasureReward reward = nextReward(player, rewards, currentReward == 3 && !hasUncommon);
if (reward == null)
{
continue;
}
if (reward.getRarity().ordinal() >= RewardRarity.UNCOMMON.ordinal())
{
hasUncommon = true;
}
rewards[currentReward] = reward;
currentReward++;
}
// Swap the last reward with another one, this makes the uncommon added at the end of some chests seem more random
int slotToSwitch = _random.nextInt(4);
if (slotToSwitch != 3)
{
ITreasureReward thirdReward = rewards[3];
ITreasureReward otherReward = rewards[slotToSwitch];
rewards[3] = otherReward;
rewards[slotToSwitch] = thirdReward;
}
return rewards;
}
private ITreasureReward nextReward(Player player, ITreasureReward[] excludedRewards)
{
return nextReward(player, excludedRewards, false);
}
private ITreasureReward nextReward(Player player, ITreasureReward[] excludedRewards, boolean requiresUncommon)
{
double rand = _random.nextDouble();
RewardRarity rarity;
if (rand <= 0.01)
{
// 1%
rarity = RewardRarity.VERY_RARE;
}
else if (rand <= 0.05)
{
// 4%
rarity = RewardRarity.RARE;
}
else if (rand <= 0.30 || requiresUncommon)
{
// 25%
rarity = RewardRarity.UNCOMMON;
}
else
{
// 70%
rarity = RewardRarity.COMMON;
}
List<ITreasureReward> treasureList = _treasureMap.get(rarity);
int totalWeight = 0;
ArrayList<ITreasureReward> possibleRewards = new ArrayList<ITreasureReward>();
for (ITreasureReward treasure : treasureList)
{
boolean isExcluded = false;
if (excludedRewards != null)
{
for (int i = 0; i < excludedRewards.length && !isExcluded; i++)
{
if (excludedRewards[i] != null && excludedRewards[i].equals(treasure))
{
isExcluded = true;
}
}
}
if (treasure.canGiveReward(player) && !isExcluded)
{
possibleRewards.add(treasure);
totalWeight += treasure.getWeight();
}
}
if (totalWeight > 0)
{
int weight = _random.nextInt(totalWeight);
int currentWeight = 0;
for (ITreasureReward reward : possibleRewards)
{
currentWeight += reward.getWeight();
if (weight <= currentWeight)
return reward;
}
}
return null;
}
}

View File

@ -1,17 +1,31 @@
package mineplex.core.treasure.reward; package mineplex.core.treasure.reward;
import mineplex.core.common.util.C;
import static mineplex.core.common.util.C.*;
/** /**
* Created by Shaun on 9/2/2014. * Created by Shaun on 9/2/2014.
*/ */
public enum RewardRarity public enum RewardRarity
{ {
/** /**
* This will probably be used to figure out what effects are shown when the chest is opened * This will probably be used to figure out what effects are shown when the chest is opened
* *
* (Fireworks, sounds, etc) * (Fireworks, sounds, etc)
*/ */
COMMON, UNCOMMON, RARE, VERY_RARE; COMMON(cAqua), UNCOMMON(cGreen), RARE(cGold), VERY_RARE(cRed);
private String _color;
RewardRarity(String color)
{
_color = color;
}
public String getColor()
{
return _color;
}
} }

View File

@ -0,0 +1,45 @@
package mineplex.core.treasure.reward.rewards;
import java.util.Random;
import org.bukkit.inventory.ItemStack;
import mineplex.core.treasure.reward.ITreasureReward;
import mineplex.core.treasure.reward.RewardRarity;
/**
* Created by shaun on 2014-09-08.
*/
public abstract class AbstractReward implements ITreasureReward
{
protected static final Random RANDOM = new Random();
private ItemStack _itemStack;
private RewardRarity _rarity;
private int _weight;
public AbstractReward(ItemStack itemStack, RewardRarity rarity, int weight)
{
_itemStack = itemStack;
_rarity = rarity;
_weight = weight;
}
@Override
public ItemStack getItem()
{
return _itemStack;
}
@Override
public int getWeight()
{
return _weight;
}
@Override
public RewardRarity getRarity()
{
return _rarity;
}
}

View File

@ -0,0 +1,75 @@
package mineplex.core.treasure.reward.rewards;
/**
* Created by shaun on 2014-09-08.
*/
import java.util.Random;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.donation.DonationManager;
import mineplex.core.treasure.reward.RewardRarity;
/**
* Created by shaun on 2014-09-08.
*/
public class CoinReward extends AbstractReward
{
private DonationManager _donationManager;
private Random _random;
private int _minCoinCount;
private int _maxCoinCount;
public CoinReward(DonationManager donationManager, int minGemCount, int maxGemCount, int weight, RewardRarity rarity)
{
this(donationManager, minGemCount, maxGemCount, weight, rarity, RANDOM);
}
public CoinReward(DonationManager donationManager, int minCoinCount, int maxCoinCount, int weight, RewardRarity rarity, Random random)
{
super(new ItemStack(Material.GOLD_INGOT), rarity, weight);
_donationManager = donationManager;
_minCoinCount = minCoinCount;
_maxCoinCount = maxCoinCount;
_random = random;
}
@Override
public String giveReward(Player player)
{
int gemsToReward = _random.nextInt(_maxCoinCount - _minCoinCount) + _minCoinCount;
_donationManager.RewardCoins(new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
}
}, "Treasure Chest", player.getName(), gemsToReward);
return getRarity().getColor() + gemsToReward + " Coins";
}
@Override
public boolean canGiveReward(Player player)
{
return true;
}
@Override
public boolean equals(Object obj)
{
if (obj instanceof CoinReward)
return true;
return false;
}
}

View File

@ -0,0 +1,54 @@
package mineplex.core.treasure.reward.rewards;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.treasure.reward.RewardRarity;
/**
* Created by shaun on 2014-09-04.
*/
public class GadgetReward extends AbstractReward
{
private DonationManager _donationManager;
private Gadget _gadget;
public GadgetReward(Gadget gadget, DonationManager donationManager, RewardRarity rarity, int weight)
{
super(new ItemStack(gadget.GetDisplayMaterial()), rarity, weight);
_gadget = gadget;
_donationManager = donationManager;
}
@Override
public String giveReward(Player player)
{
_donationManager.Get(player.getName()).AddUnknownSalesPackagesOwned(_gadget.GetName());
return getRarity().getColor() + _gadget.GetDisplayName();
}
@Override
public boolean canGiveReward(Player player)
{
return !(_donationManager.Get(player.getName()).OwnsUnknownPackage(_gadget.GetName()));
}
@Override
public boolean equals(Object obj)
{
if (obj instanceof GadgetReward)
{
return ((GadgetReward) obj).getGadget().equals(_gadget);
}
return false;
}
protected Gadget getGadget()
{
return _gadget;
}
}

View File

@ -0,0 +1,70 @@
package mineplex.core.treasure.reward.rewards;
import java.util.Random;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.donation.DonationManager;
import mineplex.core.treasure.reward.RewardRarity;
/**
* Created by shaun on 2014-09-04.
*/
public class GemReward extends AbstractReward
{
private DonationManager _donationManager;
private Random _random;
private int _minGemCount;
private int _maxGemCount;
public GemReward(DonationManager donationManager, int minGemCount, int maxGemCount, int weight, RewardRarity rarity)
{
this(donationManager, minGemCount, maxGemCount, weight, rarity, RANDOM);
}
public GemReward(DonationManager donationManager, int minGemCount, int maxGemCount, int weight, RewardRarity rarity, Random random)
{
super(new ItemStack(Material.EMERALD), rarity, weight);
_donationManager = donationManager;
_minGemCount = minGemCount;
_maxGemCount = maxGemCount;
_random = random;
}
@Override
public String giveReward(Player player)
{
int gemsToReward = _random.nextInt(_maxGemCount - _minGemCount) + _minGemCount;
_donationManager.RewardGems(new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
}
}, "Treasure Chest", player.getName(), gemsToReward);
return C.cGreen + gemsToReward + " Gems";
}
@Override
public boolean canGiveReward(Player player)
{
return true;
}
@Override
public boolean equals(Object obj)
{
if (obj instanceof GemReward)
return true;
return false;
}
}

View File

@ -0,0 +1,73 @@
package mineplex.core.treasure.reward.rewards;
import java.util.Random;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.treasure.reward.RewardRarity;
/**
* Created by shaun on 14-09-12.
*/
public class InventoryReward extends AbstractReward
{
private Random _random;
private InventoryManager _inventoryManager;
private String _name;
private String _packageName;
private int _minAmount;
private int _maxAmount;
public InventoryReward(InventoryManager inventoryManager, String name, String packageName, int minAmount, int maxAmount, ItemStack itemStack, RewardRarity rarity, int weight)
{
this(RANDOM, inventoryManager, name, packageName, minAmount, maxAmount, itemStack, rarity, weight);
}
public InventoryReward(Random random, InventoryManager inventoryManager, String name, String packageName, int minAmount, int maxAmount, ItemStack itemStack, RewardRarity rarity, int weight)
{
super(itemStack, rarity, weight);
_random = random;
_name = name;
_packageName = packageName;
_minAmount = minAmount;
_maxAmount = maxAmount;
_inventoryManager = inventoryManager;
}
@Override
public String giveReward(Player player)
{
int amountToGive = _random.nextInt(_maxAmount - _minAmount) + _minAmount;
_inventoryManager.addItemToInventory(player, "Item", _packageName, amountToGive);
return getRarity().getColor() + amountToGive + " " + _name;
}
@Override
public boolean canGiveReward(Player player)
{
return true;
}
protected String getPackageName()
{
return _packageName;
}
@Override
public boolean equals(Object obj)
{
if (obj instanceof InventoryReward)
{
return ((InventoryReward) obj).getPackageName().equals(_packageName);
}
return false;
}
}

View File

@ -0,0 +1,55 @@
package mineplex.core.treasure.reward.rewards;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.donation.DonationManager;
import mineplex.core.treasure.reward.RewardRarity;
/**
* Created by shaun on 14-09-12.
*/
public class UnknownPackageReward extends AbstractReward
{
private DonationManager _donationManager;
private String _name;
private String _packageName;
public UnknownPackageReward(DonationManager donationManager, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight)
{
super(itemStack, rarity, weight);
_donationManager = donationManager;
_name = name;
_packageName = packageName;
}
@Override
public String giveReward(Player player)
{
_donationManager.Get(player.getName()).AddUnknownSalesPackagesOwned(_packageName);
return getRarity().getColor() + _name;
}
@Override
public boolean canGiveReward(Player player)
{
return _donationManager.Get(player.getName()).OwnsUnknownPackage(_packageName);
}
protected String getPackageName()
{
return _packageName;
}
@Override
public boolean equals(Object obj)
{
if (obj instanceof UnknownPackageReward)
{
return ((UnknownPackageReward) obj).getPackageName().equals(_packageName);
}
return false;
}
}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.4.2.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-meta-3.4.2.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-codegen-3.4.2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Mineplex.Database</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -11,7 +11,7 @@ package mineplex.database.tables;
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) @java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class TournamentLeaderboard extends org.jooq.impl.TableImpl<mineplex.database.tables.records.TournamentLeaderboard> implements java.io.Serializable, java.lang.Cloneable { public class TournamentLeaderboard extends org.jooq.impl.TableImpl<mineplex.database.tables.records.TournamentLeaderboard> implements java.io.Serializable, java.lang.Cloneable {
private static final long serialVersionUID = -2050960225; private static final long serialVersionUID = 1795216465;
/** /**
* The singleton instance of <code>Account.tournamentLeaderboard</code> * The singleton instance of <code>Account.tournamentLeaderboard</code>
@ -57,9 +57,9 @@ public class TournamentLeaderboard extends org.jooq.impl.TableImpl<mineplex.data
public final org.jooq.TableField<mineplex.database.tables.records.TournamentLeaderboard, java.lang.Integer> total = createField("total", org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaulted(true), this, ""); public final org.jooq.TableField<mineplex.database.tables.records.TournamentLeaderboard, java.lang.Integer> total = createField("total", org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaulted(true), this, "");
/** /**
* The column <code>Account.tournamentLeaderboard.ratio</code>. * The column <code>Account.tournamentLeaderboard.score</code>.
*/ */
public final org.jooq.TableField<mineplex.database.tables.records.TournamentLeaderboard, java.lang.Double> ratio = createField("ratio", org.jooq.impl.SQLDataType.FLOAT, this, ""); public final org.jooq.TableField<mineplex.database.tables.records.TournamentLeaderboard, java.lang.Double> score = createField("score", org.jooq.impl.SQLDataType.DOUBLE, this, "");
/** /**
* Create a <code>Account.tournamentLeaderboard</code> table reference * Create a <code>Account.tournamentLeaderboard</code> table reference

View File

@ -11,7 +11,7 @@ package mineplex.database.tables.records;
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) @java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class TournamentLeaderboard extends org.jooq.impl.UpdatableRecordImpl<mineplex.database.tables.records.TournamentLeaderboard> implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record7<java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Double> { public class TournamentLeaderboard extends org.jooq.impl.UpdatableRecordImpl<mineplex.database.tables.records.TournamentLeaderboard> implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record7<java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Double> {
private static final long serialVersionUID = -1193236965; private static final long serialVersionUID = 1130073862;
/** /**
* Setter for <code>Account.tournamentLeaderboard.id</code>. * Setter for <code>Account.tournamentLeaderboard.id</code>.
@ -98,16 +98,16 @@ public class TournamentLeaderboard extends org.jooq.impl.UpdatableRecordImpl<min
} }
/** /**
* Setter for <code>Account.tournamentLeaderboard.ratio</code>. * Setter for <code>Account.tournamentLeaderboard.score</code>.
*/ */
public void setRatio(java.lang.Double value) { public void setScore(java.lang.Double value) {
setValue(6, value); setValue(6, value);
} }
/** /**
* Getter for <code>Account.tournamentLeaderboard.ratio</code>. * Getter for <code>Account.tournamentLeaderboard.score</code>.
*/ */
public java.lang.Double getRatio() { public java.lang.Double getScore() {
return (java.lang.Double) getValue(6); return (java.lang.Double) getValue(6);
} }
@ -196,7 +196,7 @@ public class TournamentLeaderboard extends org.jooq.impl.UpdatableRecordImpl<min
*/ */
@Override @Override
public org.jooq.Field<java.lang.Double> field7() { public org.jooq.Field<java.lang.Double> field7() {
return mineplex.database.tables.TournamentLeaderboard.tournamentLeaderboard.ratio; return mineplex.database.tables.TournamentLeaderboard.tournamentLeaderboard.score;
} }
/** /**
@ -252,7 +252,7 @@ public class TournamentLeaderboard extends org.jooq.impl.UpdatableRecordImpl<min
*/ */
@Override @Override
public java.lang.Double value7() { public java.lang.Double value7() {
return getRatio(); return getScore();
} }
/** /**
@ -314,7 +314,7 @@ public class TournamentLeaderboard extends org.jooq.impl.UpdatableRecordImpl<min
*/ */
@Override @Override
public TournamentLeaderboard value7(java.lang.Double value) { public TournamentLeaderboard value7(java.lang.Double value) {
setRatio(value); setScore(value);
return this; return this;
} }
@ -340,7 +340,7 @@ public class TournamentLeaderboard extends org.jooq.impl.UpdatableRecordImpl<min
/** /**
* Create a detached, initialised TournamentLeaderboard * Create a detached, initialised TournamentLeaderboard
*/ */
public TournamentLeaderboard(java.lang.Integer id, java.lang.Integer tournamentId, java.lang.Integer accountId, java.lang.Integer gameId, java.lang.Integer wins, java.lang.Integer total, java.lang.Double ratio) { public TournamentLeaderboard(java.lang.Integer id, java.lang.Integer tournamentId, java.lang.Integer accountId, java.lang.Integer gameId, java.lang.Integer wins, java.lang.Integer total, java.lang.Double score) {
super(mineplex.database.tables.TournamentLeaderboard.tournamentLeaderboard); super(mineplex.database.tables.TournamentLeaderboard.tournamentLeaderboard);
setValue(0, id); setValue(0, id);
@ -349,6 +349,6 @@ public class TournamentLeaderboard extends org.jooq.impl.UpdatableRecordImpl<min
setValue(3, gameId); setValue(3, gameId);
setValue(4, wins); setValue(4, wins);
setValue(5, total); setValue(5, total);
setValue(6, ratio); setValue(6, score);
} }
} }

View File

@ -54,6 +54,7 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilWorld;
import mineplex.core.treasure.TreasureManager;
import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.DisguiseManager;
@ -81,6 +82,7 @@ import mineplex.hub.modules.MapManager;
import mineplex.hub.modules.NewsManager; import mineplex.hub.modules.NewsManager;
import mineplex.hub.modules.ParkourManager; import mineplex.hub.modules.ParkourManager;
import mineplex.hub.modules.TextManager; import mineplex.hub.modules.TextManager;
import mineplex.hub.modules.UHCManager;
import mineplex.hub.modules.VisibilityManager; import mineplex.hub.modules.VisibilityManager;
import mineplex.hub.modules.WorldManager; import mineplex.hub.modules.WorldManager;
import mineplex.hub.party.Party; import mineplex.hub.party.Party;
@ -151,6 +153,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
new MapManager(this); new MapManager(this);
new WorldManager(this); new WorldManager(this);
new JumpManager(this); new JumpManager(this);
//new UHCManager(this);
_news = new NewsManager(this); _news = new NewsManager(this);
@ -158,7 +161,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
_inventoryManager = new InventoryManager(plugin); _inventoryManager = new InventoryManager(plugin);
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin)); _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin));
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, false); new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, false);
// new TreasureManager(_plugin); new TreasureManager(_plugin, donationManager, _inventoryManager);
_partyManager = partyManager; _partyManager = partyManager;
_preferences = preferences; _preferences = preferences;

View File

@ -39,6 +39,7 @@ import mineplex.core.gadget.event.GadgetBlockEvent;
import mineplex.core.mount.event.MountActivateEvent; import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.task.TaskManager; import mineplex.core.task.TaskManager;
import mineplex.core.treasure.event.TreasureStartEvent;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager; import mineplex.hub.HubManager;
@ -356,7 +357,7 @@ public class ParkourManager extends MiniPlugin
if (!isParkourMode(player)) if (!isParkourMode(player))
{ {
//Inform //Inform
UtilPlayer.message(player, F.main("Parkour", "You must be in " + F.elem("Parkour Mode") + " to finish.")); UtilPlayer.message(player, F.main("Parkour", "You must be in " + F.elem("Parkour Mode") + " to cleanup."));
UtilPlayer.message(player, F.main("Parkour", "Talk to the " + F.elem("Start NPC") + " to enter Parkour Mode.")); UtilPlayer.message(player, F.main("Parkour", "Talk to the " + F.elem("Start NPC") + " to enter Parkour Mode."));
return; return;
} }
@ -418,7 +419,16 @@ public class ParkourManager extends MiniPlugin
return false; return false;
} }
@EventHandler
public void preventTreasureNearParkour(TreasureStartEvent event)
{
if (InsideParkour(event.getPlayer().getLocation()))
{
event.setCancelled(true);
UtilPlayer.message(event.getPlayer(), F.main("Parkour", "You can't open chests near Parkour."));
}
}
@EventHandler @EventHandler
public void snakeUpdate(UpdateEvent event) public void snakeUpdate(UpdateEvent event)

View File

@ -89,6 +89,8 @@ public class TextManager extends MiniPlugin
UtilText.MakeText("SURVIVAL GAMES", locSurvival.clone().add(-15, 21, 0), faceSurvival, 159, (byte)1, TextAlign.CENTER); UtilText.MakeText("SURVIVAL GAMES", locSurvival.clone().add(-15, 21, 0), faceSurvival, 159, (byte)1, TextAlign.CENTER);
UtilText.MakeText("SURVIVAL GAMES", locSurvival.clone().add(-16, 21, 0), faceSurvival, 159, (byte)15, TextAlign.CENTER); UtilText.MakeText("SURVIVAL GAMES", locSurvival.clone().add(-16, 21, 0), faceSurvival, 159, (byte)15, TextAlign.CENTER);
//UtilText.MakeText("ULTRA HARDCORE", locSurvival.clone().add(-15, 28, 0), faceSurvival, 159, (byte)14, TextAlign.CENTER);
//UtilText.MakeText("ULTRA HARDCORE", locSurvival.clone().add(-16, 28, 0), faceSurvival, 159, (byte)15, TextAlign.CENTER);
//Other //Other
UtilText.MakeText("CLASSICS", locClassics, faceOther, 159, (byte)5, TextAlign.CENTER); UtilText.MakeText("CLASSICS", locClassics, faceOther, 159, (byte)5, TextAlign.CENTER);

View File

@ -0,0 +1,82 @@
package mineplex.hub.modules;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager;
public class UHCManager extends MiniPlugin
{
public HubManager Manager;
private long _delay = 3600000;
private boolean _canAnnounce3 = true;
private boolean _canAnnounce2 = true;
private boolean _canAnnounce1 = true;
private boolean _canAnnounce0 = true;
public UHCManager(HubManager manager)
{
super("UHC Manager", manager.GetPlugin());
Manager = manager;
}
@EventHandler
public void AnnounceUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
System.out.println("UHC in " + UtilTime.MakeStr(_delay - (System.currentTimeMillis() % _delay)));
//Reset
if (System.currentTimeMillis() % _delay > 30000 && System.currentTimeMillis() % _delay < _delay - 180000)
{
_canAnnounce3 = true;
_canAnnounce2 = true;
_canAnnounce1 = true;
_canAnnounce0 = true;
}
//Announce
else
{
if (_canAnnounce3 && System.currentTimeMillis() % _delay > _delay - 180000)
{
_canAnnounce3 = false;
announce("Starting in 3 minutes...");
}
else if (_canAnnounce2 && System.currentTimeMillis() % _delay > _delay - 120000)
{
_canAnnounce2 = false;
announce("Starting in 2 minutes...");
}
else if (_canAnnounce1 && System.currentTimeMillis() % _delay > _delay - 60000)
{
_canAnnounce1 = false;
announce("Starting in 1 minute...");
}
else if (_canAnnounce0 && System.currentTimeMillis() % _delay < 30000)
{
_canAnnounce0 = false;
announce("Join at the Ultra Hardcore NPC!");
}
}
}
private void announce(String message)
{
for (Player player : UtilServer.getPlayers())
UtilPlayer.message(player, C.cDPurple + "[Ultra Hardcore] " + C.cPurple + C.Bold + message);
}
}

View File

@ -162,14 +162,14 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
} }
else else
{ {
if (serverInfo.CurrentPlayers >= serverInfo.MaxPlayers && !ownsUltraPackage) if (serverInfo.CurrentPlayers >= serverInfo.MaxPlayers && !ownsUltraPackage)
{ {
lore.add(MESSAGE_FULL_GET_ULTRA); lore.add(MESSAGE_FULL_GET_ULTRA);
} }
else else
{ {
lore.add(MESSAGE_JOIN); lore.add(MESSAGE_JOIN);
} }
} }
} }

View File

@ -7,6 +7,7 @@ import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
@ -29,6 +30,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
@ -109,6 +112,9 @@ public class MapParser extends JavaPlugin implements Listener
ResetInventory(event.getPlayer()); ResetInventory(event.getPlayer());
DisplayHelp(player); DisplayHelp(player);
for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
player.addAttachment(plugin, "worldedit.*", true);
} }
public void DisplayHelp(Player player) public void DisplayHelp(Player player)

View File

@ -203,7 +203,7 @@ public class Immolate extends Skill
int level = getLevel(cur); int level = getLevel(cur);
//Fire //Fire
Item fire = cur.getWorld().dropItem(cur.getLocation().add(0, 0.5, 0), ItemStackFactory.Instance.CreateStack(Material.FIRE)); Item fire = cur.getWorld().dropItem(cur.getLocation().add(0, 0.5, 0), ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER));
fire.setVelocity(new Vector((Math.random() - 0.5)/3,Math.random()/3,(Math.random() - 0.5)/3)); fire.setVelocity(new Vector((Math.random() - 0.5)/3,Math.random()/3,(Math.random() - 0.5)/3));
Factory.Fire().Add(fire, cur, 2, 0, 0.25 + (level * 0.25), 0, GetName()); Factory.Fire().Add(fire, cur, 2, 0, 0.25 + (level * 0.25), 0, GetName());

View File

@ -103,7 +103,7 @@ public class Inferno extends SkillActive
} }
//Fire //Fire
Item fire = cur.getWorld().dropItem(cur.getEyeLocation().add(cur.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(Material.FIRE)); Item fire = cur.getWorld().dropItem(cur.getEyeLocation().add(cur.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER));
Factory.Fire().Add(fire, cur, 0.7, 0, 0.3 + (0.1 * level), 1, GetName()); Factory.Fire().Add(fire, cur, 0.7, 0, 0.3 + (0.1 * level), 1, GetName());
fire.teleport(cur.getEyeLocation()); fire.teleport(cur.getEyeLocation());

View File

@ -121,7 +121,7 @@ public class NapalmShot extends SkillActive
for (int i = 0 ; i < 8 + (8 * level) ; i++) for (int i = 0 ; i < 8 + (8 * level) ; i++)
{ {
Item fire = proj.getWorld().dropItemNaturally(proj.getLocation(), ItemStackFactory.Instance.CreateStack(Material.FIRE, 1)); Item fire = proj.getWorld().dropItemNaturally(proj.getLocation(), ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER, 1));
Factory.Fire().Add(fire, damager, 16, 0.25, 2, 0, GetName()); Factory.Fire().Add(fire, damager, 16, 0.25, 2, 0, GetName());
fire.setVelocity(fire.getVelocity().multiply(1 + (0.15 * level))); fire.setVelocity(fire.getVelocity().multiply(1 + (0.15 * level)));
} }

View File

@ -105,13 +105,13 @@ public class CustomBuildPage extends ShopPageBase<ClassShopManager, ClassCombatS
if (i != 0) if (i != 0)
{ {
AddButton(slot + 18, new ShopItem(Material.ANVIL, "Edit Build", new String[] { }, 1, locked, true), new EditAndSaveCustomBuildButton(this, customBuild)); AddButton(slot + 18, new ShopItem(Material.ANVIL, "Edit Build", new String[] { }, 1, locked, true), new EditAndSaveCustomBuildButton(this, customBuild));
AddButton(slot + 36, new ShopItem(Material.FIRE, "Delete Build", new String[] { "§rIt will never come back..."}, 1, locked, true), new DeleteCustomBuildButton(this, customBuild)); AddButton(slot + 36, new ShopItem(Material.TNT, "Delete Build", new String[] { "§rIt will never come back..."}, 1, locked, true), new DeleteCustomBuildButton(this, customBuild));
} }
} }
else else
{ {
getInventory().setItem(slot + 18, new ShopItem(Material.ANVIL, "Edit Build", new String[] { }, 1, locked, true).getHandle()); getInventory().setItem(slot + 18, new ShopItem(Material.ANVIL, "Edit Build", new String[] { }, 1, locked, true).getHandle());
getInventory().setItem(slot + 36, new ShopItem(Material.FIRE, "Delete Build", new String[] { "§rIt will never come back..."}, 1, locked, true).getHandle()); getInventory().setItem(slot + 36, new ShopItem(Material.TNT, "Delete Build", new String[] { "§rIt will never come back..."}, 1, locked, true).getHandle());
} }
slot += 2; slot += 2;

View File

@ -13,6 +13,7 @@ import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameServerConfig; import nautilus.game.arcade.game.GameServerConfig;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.uhc.UHC;
import nautilus.game.arcade.managers.*; import nautilus.game.arcade.managers.*;
import nautilus.game.arcade.shop.ArcadeShop; import nautilus.game.arcade.shop.ArcadeShop;
import nautilus.game.arcade.world.FireworkHandler; import nautilus.game.arcade.world.FireworkHandler;
@ -220,7 +221,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
// Shop // Shop
_arcadeShop = new ArcadeShop(this, clientManager, donationManager); _arcadeShop = new ArcadeShop(this, clientManager, donationManager);
// Game Factory // Game Factory
_gameFactory = new GameFactory(this); _gameFactory = new GameFactory(this);
// Managers // Managers
@ -467,8 +468,19 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{ {
String extrainformation = "|" + _serverConfig.ServerType + "|" + (_game == null ? "Unknown" : _game.GetName()) String extrainformation = "|" + _serverConfig.ServerType + "|" + (_game == null ? "Unknown" : _game.GetName())
+ "|" + ((_game == null || _game.WorldData == null) ? "Unknown" : _game.WorldData.MapName); + "|" + ((_game == null || _game.WorldData == null) ? "Unknown" : _game.WorldData.MapName);
if (_game == null || _game.GetState() == GameState.Recruit) //Always Joinable
if (_game.JoinInProgress)
{
event.setMotd(ChatColor.GREEN + "Recruiting" + extrainformation);
}
//UHC Timed
else if (_game != null && _game.GetType() == GameType.UHC)
{
event.setMotd(((UHC)_game).getMotdStatus() + extrainformation);
}
//Recruiting
else if (_game == null || _game.GetState() == GameState.Recruit)
{ {
if (_game != null && _game.GetCountdown() != -1) if (_game != null && _game.GetCountdown() != -1)
{ {
@ -478,8 +490,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{ {
event.setMotd(ChatColor.GREEN + "Recruiting" + extrainformation); event.setMotd(ChatColor.GREEN + "Recruiting" + extrainformation);
} }
} }
//In Progress
else else
{ {
event.setMotd(ChatColor.YELLOW + "In Progress" + extrainformation); event.setMotd(ChatColor.YELLOW + "In Progress" + extrainformation);

View File

@ -139,7 +139,8 @@ public abstract class Game implements Listener
public HashSet<Integer> ItemDropAllow = new HashSet<Integer>(); public HashSet<Integer> ItemDropAllow = new HashSet<Integer>();
public HashSet<Integer> ItemDropDeny = new HashSet<Integer>(); public HashSet<Integer> ItemDropDeny = new HashSet<Integer>();
public boolean InventoryOpen = false; public boolean InventoryOpenBlock = false;
public boolean InventoryOpenChest = false;
public boolean InventoryClick = false; public boolean InventoryClick = false;
public boolean PrivateBlocks = false; public boolean PrivateBlocks = false;
@ -151,7 +152,7 @@ public abstract class Game implements Listener
public boolean QuitOut = true; public boolean QuitOut = true;
public boolean IdleKick = true; public boolean IdleKickz = true;
public boolean CreatureAllow = false; public boolean CreatureAllow = false;
public boolean CreatureAllowOverride = false; public boolean CreatureAllowOverride = false;
@ -181,11 +182,9 @@ public abstract class Game implements Listener
public boolean DisplayLobbySide = true; public boolean DisplayLobbySide = true;
//Tourney
public boolean AutoBalance = true;
public boolean AutoStart = true;
public GameState KitRegisterState = GameState.Live; public GameState KitRegisterState = GameState.Live;
public boolean JoinInProgress = false;
//Addons //Addons
public boolean CompassEnabled = false; public boolean CompassEnabled = false;
@ -821,7 +820,7 @@ public abstract class Game implements Listener
public boolean CanJoinTeam(GameTeam team) public boolean CanJoinTeam(GameTeam team)
{ {
return (AutoBalance && Manager.IsTeamBalance()) ? team.GetSize() < Math.max(1, UtilServer.getPlayers().length/GetTeamList().size()) : true; return Manager.IsTeamBalance() ? team.GetSize() < Math.max(1, UtilServer.getPlayers().length/GetTeamList().size()) : true;
} }
public GameTeam GetTeamPreference(Player player) public GameTeam GetTeamPreference(Player player)

View File

@ -286,6 +286,7 @@ public class GameTeam
//if (GetColor() == ChatColor.BROWN) return (byte)12; //if (GetColor() == ChatColor.BROWN) return (byte)12;
if (GetColor() == ChatColor.DARK_GREEN) return (byte)13; if (GetColor() == ChatColor.DARK_GREEN) return (byte)13;
if (GetColor() == ChatColor.RED) return (byte)14; if (GetColor() == ChatColor.RED) return (byte)14;
if (GetColor() == ChatColor.DARK_RED) return (byte)14;
else return (byte)15; else return (byte)15;
} }

View File

@ -127,7 +127,7 @@ public abstract class SoloGame extends Game
@Override @Override
public List<Player> getWinners() public List<Player> getWinners()
{ {
if (GetPlayers(true).size() <= 1) if (GetState().ordinal() >= GameState.End.ordinal())
{ {
List<Player> places = _players.GetPlacements(true); List<Player> places = _players.GetPlacements(true);

View File

@ -41,8 +41,10 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
@ -77,7 +79,7 @@ public class Bridge extends TeamGame implements OreObsfucation
private static final Material[] PLAYER_DROP_DELAY_MATERIALS = new Material[] { Material.LOG, Material.LOG_2, Material.IRON_ORE, Material.DIAMOND_ORE, Material.COAL_ORE, Material.GOLD_ORE, Material.WORKBENCH, Material.FURNACE }; private static final Material[] PLAYER_DROP_DELAY_MATERIALS = new Material[] { Material.LOG, Material.LOG_2, Material.IRON_ORE, Material.DIAMOND_ORE, Material.COAL_ORE, Material.GOLD_ORE, Material.WORKBENCH, Material.FURNACE };
//Bridge Timer //Bridge Timer
private int _bridgeTime = 600000; private int _bridgeTime = 5000; //600000
private boolean _bridgesDown = false; private boolean _bridgesDown = false;
//Wood Bridge //Wood Bridge
@ -157,7 +159,8 @@ public class Bridge extends TeamGame implements OreObsfucation
BlockBreak = true; BlockBreak = true;
BlockPlace = true; BlockPlace = true;
InventoryOpen = true; InventoryOpenBlock = true;
InventoryOpenChest = true;
WorldTimeSet = 2000; WorldTimeSet = 2000;
@ -732,7 +735,7 @@ public class Bridge extends TeamGame implements OreObsfucation
// Create Part // Create Part
FallingBlock block = bestLoc.getWorld().spawnFallingBlock( FallingBlock block = bestLoc.getWorld().spawnFallingBlock(
source, 10, (byte) 0); source, 87, (byte) 0);
BridgePart part = new BridgePart(block, bestLoc, true); BridgePart part = new BridgePart(block, bestLoc, true);
_bridgeParts.add(part); _bridgeParts.add(part);

View File

@ -53,6 +53,8 @@ public class ChampionsDominate extends Domination
Manager.GetDamage().UseSimpleWeaponDamage = false; Manager.GetDamage().UseSimpleWeaponDamage = false;
InventoryOpenChest = true;
EloRanking = false; EloRanking = false;
EloStart = 1000; EloStart = 1000;

View File

@ -54,6 +54,8 @@ public class ChampionsTDM extends TeamDeathmatch
this.Manager.GetDamage().UseSimpleWeaponDamage = false; this.Manager.GetDamage().UseSimpleWeaponDamage = false;
InventoryOpenChest = true;
registerStatTrackers( registerStatTrackers(
new WinWithoutLosingTeammateStatTracker(this, "FlawlessVictory"), new WinWithoutLosingTeammateStatTracker(this, "FlawlessVictory"),
new KillAllOpposingStatTracker(this), new KillAllOpposingStatTracker(this),

View File

@ -413,7 +413,7 @@ public class Halloween extends SoloGame
{ {
Material type = event.getEntity().getItemStack().getType(); Material type = event.getEntity().getItemStack().getType();
if (type == Material.DIAMOND_AXE || type == Material.FIRE || type == Material.SNOW_BALL) if (type == Material.DIAMOND_AXE || type == Material.BLAZE_POWDER || type == Material.SNOW_BALL)
return; return;
event.setCancelled(true); event.setCancelled(true);

View File

@ -146,7 +146,7 @@ public class PumpkinKing extends CreatureBase<Skeleton>
return; return;
//Effect //Effect
Host.Manager.GetBlood().Effects(event.GetDamageeEntity().getLocation(), 10, 0.2, null, 0f, 0f, Material.FIRE, (byte)0, 10, false); Host.Manager.GetBlood().Effects(event.GetDamageeEntity().getLocation(), 10, 0.2, null, 0f, 0f, Material.BLAZE_POWDER, (byte)0, 10, false);
event.GetDamageeEntity().getWorld().playEffect(event.GetDamageeEntity().getLocation(), Effect.STEP_SOUND, 51); event.GetDamageeEntity().getWorld().playEffect(event.GetDamageeEntity().getLocation(), Effect.STEP_SOUND, 51);
//Remove //Remove

View File

@ -206,7 +206,6 @@ public class HideSeek extends TeamGame
this.DamageSelf = false; this.DamageSelf = false;
this.DeathOut = false; this.DeathOut = false;
this.InventoryOpen = false;
this.HungerSet = 20; this.HungerSet = 20;
this.PrepareFreeze = false; this.PrepareFreeze = false;

View File

@ -87,6 +87,7 @@ import nautilus.game.arcade.game.games.minestrike.data.Bomb;
import nautilus.game.arcade.game.games.minestrike.data.Bullet; import nautilus.game.arcade.game.games.minestrike.data.Bullet;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItem; import nautilus.game.arcade.game.games.minestrike.items.StrikeItem;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType;
import nautilus.game.arcade.game.games.minestrike.items.equipment.DefusalKit;
import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.Armor; import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.Armor;
import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade; import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade;
import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; import nautilus.game.arcade.game.games.minestrike.items.guns.Gun;
@ -112,7 +113,7 @@ public class MineStrike extends TeamGame
private int _bulletInstant = 2; //0 = Slow, 1 = Instant, 2 = Mix private int _bulletInstant = 2; //0 = Slow, 1 = Instant, 2 = Mix
private boolean _customHitbox = true; private boolean _customHitbox = true;
private boolean _bulletAlternate = false; private boolean _bulletAlternate = false;
//Map Data //Map Data
private ArrayList<Location> _bombSites; private ArrayList<Location> _bombSites;
@ -131,6 +132,8 @@ public class MineStrike extends TeamGame
private HashMap<Entity, Bullet> _bullets = new HashMap<Entity, Bullet>(); private HashMap<Entity, Bullet> _bullets = new HashMap<Entity, Bullet>();
private HashMap<Entity, Grenade> _grenadesThrown = new HashMap<Entity, Grenade>(); private HashMap<Entity, Grenade> _grenadesThrown = new HashMap<Entity, Grenade>();
private HashSet<Entity> _defusalDropped = new HashSet<Entity>();
private HashMap<Location, Long> _incendiary = new HashMap<Location, Long>(); private HashMap<Location, Long> _incendiary = new HashMap<Location, Long>();
private Bomb _bomb = null; private Bomb _bomb = null;
@ -181,6 +184,8 @@ public class MineStrike extends TeamGame
this.ItemDrop = true; this.ItemDrop = true;
this.InventoryClick = true; this.InventoryClick = true;
this.JoinInProgress = true;
this._help = new String[] this._help = new String[]
{ {
@ -380,8 +385,14 @@ public class MineStrike extends TeamGame
} }
else else
{ {
for (Player other : team.GetPlayers(false))
if (!other.equals(player))
UtilPlayer.message(other, C.cGold + C.Bold + player.getName() + " picked up the Bomb!");
UtilPlayer.message(player, C.cGold + C.Bold + "You picked up the Bomb!"); UtilPlayer.message(player, C.cGold + C.Bold + "You picked up the Bomb!");
} }
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 2f); player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 2f);
_bombHolder = player; _bombHolder = player;
@ -618,6 +629,7 @@ public class MineStrike extends TeamGame
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void deathDrop(PlayerDeathEvent event) public void deathDrop(PlayerDeathEvent event)
{ {
_scoped.remove(event.getEntity());
dropInventory(event.getEntity()); dropInventory(event.getEntity());
} }
@ -691,6 +703,12 @@ public class MineStrike extends TeamGame
item.drop(this, player, true, false); item.drop(this, player, true, false);
} }
//Defuse Kit
if (stack.getType() == Material.SHEARS)
{
_defusalDropped.add(player.getWorld().dropItemNaturally(player.getEyeLocation(), stack));
}
//Bomb //Bomb
if (stack.getType() == Material.GOLD_SWORD) if (stack.getType() == Material.GOLD_SWORD)
{ {
@ -722,14 +740,34 @@ public class MineStrike extends TeamGame
Gun gun = _gunsDropped.get(event.getItem()); Gun gun = _gunsDropped.get(event.getItem());
if (gun != null) if (gun != null)
{ {
gun.pickup(this, event.getPlayer()); if (gun.pickup(this, event.getPlayer()))
event.getItem().remove();
} }
//Grenades //Grenades
Grenade grenade = _grenadesDropped.get(event.getItem()); Grenade grenade = _grenadesDropped.get(event.getItem());
if (grenade != null) if (grenade != null)
{ {
grenade.pickup(this, event.getPlayer()); if (grenade.pickup(this, event.getPlayer()))
event.getItem().remove();
}
//Defusal
if (UtilGear.isMat(event.getItem().getItemStack(), Material.SHEARS))
{
if (GetTeam(event.getPlayer()).GetColor() == ChatColor.RED)
return;
if (UtilInv.contains(event.getPlayer(), Material.SHEARS, (byte)0, 1))
return;
event.getPlayer().getInventory().setItem(8, event.getItem().getItemStack());
UtilPlayer.message(event.getPlayer(), F.main("Game", "You equipped Defusal Kit."));
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.HORSE_ARMOR, 1.5f, 1f);
event.getItem().remove();
} }
//Bomb //Bomb
@ -739,6 +777,18 @@ public class MineStrike extends TeamGame
} }
} }
@EventHandler
public void reloadCancel(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Gun gun : _gunsEquipped.keySet())
{
gun.cancelReloadCheck(_gunsEquipped.get(gun), this);
}
}
@EventHandler @EventHandler
public void rechargeWeapons(RechargedEvent event) public void rechargeWeapons(RechargedEvent event)
{ {
@ -772,13 +822,13 @@ public class MineStrike extends TeamGame
gun.reduceCone(); gun.reduceCone();
} }
} }
@EventHandler @EventHandler
public void slowBulletHit(final ProjectileHitEvent event) public void slowBulletHit(final ProjectileHitEvent event)
{ {
if (!(event.getEntity() instanceof Snowball)) if (!(event.getEntity() instanceof Snowball))
return; return;
Bullet bullet = _bullets.get(event.getEntity()); Bullet bullet = _bullets.get(event.getEntity());
//Particle //Particle
@ -787,21 +837,21 @@ public class MineStrike extends TeamGame
//Hit Block Sound //Hit Block Sound
event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.ENDERMAN_HIT, 1f, 1f); event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.ENDERMAN_HIT, 1f, 1f);
//Block Particle //Block Particle
Location loc = event.getEntity().getLocation().add(event.getEntity().getVelocity().multiply(0.8)); Location loc = event.getEntity().getLocation().add(event.getEntity().getVelocity().multiply(0.8));
Block block = loc.getBlock(); Block block = loc.getBlock();
if (block.getType() == Material.AIR) if (block.getType() == Material.AIR)
{ {
Block closest = null; Block closest = null;
double closestDist = 0; double closestDist = 0;
for (Block other : UtilBlock.getSurrounding(block, true)) for (Block other : UtilBlock.getSurrounding(block, true))
{ {
if (other.getType() == Material.AIR) if (other.getType() == Material.AIR)
continue; continue;
double dist = UtilMath.offset(loc, other.getLocation().add(0.5, 0.5, 0.5)); double dist = UtilMath.offset(loc, other.getLocation().add(0.5, 0.5, 0.5));
if (closest == null || dist < closestDist) if (closest == null || dist < closestDist)
@ -810,30 +860,30 @@ public class MineStrike extends TeamGame
closestDist = dist; closestDist = dist;
} }
} }
if (closest != null) if (closest != null)
block = closest; block = closest;
} }
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
} }
@EventHandler @EventHandler
public void slowBulletWhizz(UpdateEvent event) public void slowBulletWhizz(UpdateEvent event)
{ {
if (event.getType() != UpdateType.TICK) if (event.getType() != UpdateType.TICK)
return; return;
for (Entity ent : _bullets.keySet()) for (Entity ent : _bullets.keySet())
{ {
if (ent instanceof Snowball) if (ent instanceof Snowball)
continue; continue;
if (ent.getTicksLived() < 10) if (ent.getTicksLived() < 10)
continue; continue;
Bullet bullet = _bullets.get(ent); Bullet bullet = _bullets.get(ent);
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
if (UtilMath.offset(ent, player) < 4) if (UtilMath.offset(ent, player) < 4)
@ -946,16 +996,16 @@ public class MineStrike extends TeamGame
} }
} }
@EventHandler(priority=EventPriority.MONITOR) @EventHandler(priority=EventPriority.MONITOR)
public void removeArrowsFromPlayer(CustomDamageEvent event) public void removeArrowsFromPlayer(CustomDamageEvent event)
{ {
if (event.GetDamageePlayer() != null) if (event.GetDamageePlayer() != null)
((CraftPlayer) event.GetDamageePlayer()).getHandle().p(0); ((CraftPlayer) event.GetDamageePlayer()).getHandle().p(0);
} }
@EventHandler(priority=EventPriority.HIGH) @EventHandler(priority=EventPriority.HIGH)
public void damage(CustomDamageEvent event) public void damage(CustomDamageEvent event)
{ {
@ -1032,7 +1082,7 @@ public class MineStrike extends TeamGame
//Get Hit Area //Get Hit Area
int hitArea = 0; int hitArea = 0;
if (_customHitbox) if (_customHitbox)
{ {
if (event.GetProjectile() instanceof Arrow) if (event.GetProjectile() instanceof Arrow)
@ -1040,14 +1090,14 @@ public class MineStrike extends TeamGame
else else
hitArea = getSnowballHitArea(event.GetDamageePlayer(), event.GetProjectile()); hitArea = getSnowballHitArea(event.GetDamageePlayer(), event.GetProjectile());
} }
if (hitArea == -1) if (hitArea == -1)
{ {
event.SetCancelled("Miss"); event.SetCancelled("Miss");
return; return;
} }
//Bullet Whiz Sound //Bullet Whiz Sound
if (event.GetProjectile() instanceof Arrow) if (event.GetProjectile() instanceof Arrow)
instantBulletWhizz(event.GetDamageePlayer().getEyeLocation(), bullet); instantBulletWhizz(event.GetDamageePlayer().getEyeLocation(), bullet);
@ -1064,7 +1114,7 @@ public class MineStrike extends TeamGame
//Damage + Dropoff //Damage + Dropoff
double damage = bullet.getDamage(); double damage = bullet.getDamage();
double damageDropoff = bullet.getDamageDropoff(event.GetDamageeEntity().getLocation()); double damageDropoff = bullet.getDamageDropoff(event.GetDamageeEntity().getLocation());
//Add Damages //Add Damages
event.AddMod(bullet.Shooter.getName(), bullet.Gun.getName(), damage, true); event.AddMod(bullet.Shooter.getName(), bullet.Gun.getName(), damage, true);
event.AddMod(bullet.Shooter.getName(), "Distance Dropoff", damageDropoff, false); event.AddMod(bullet.Shooter.getName(), "Distance Dropoff", damageDropoff, false);
@ -1073,19 +1123,21 @@ public class MineStrike extends TeamGame
if (hitArea == 1) if (hitArea == 1)
{ {
event.AddMod(bullet.Shooter.getName(), "Headshot", damage*2, true); event.AddMod(bullet.Shooter.getName(), "Headshot", damage*2, true);
if (Armor.isArmor(event.GetDamageePlayer().getInventory().getHelmet())) //Wearing Helmet
if (Armor.isArmor(event.GetDamageePlayer().getInventory().getHelmet()) ||
(_scoped.containsKey(event.GetDamageePlayer()) && UtilGear.isMat(_scoped.get(event.GetDamageePlayer()), Material.LEATHER_HELMET)))
{ {
event.AddMod(event.GetDamageePlayer().getName(), "Helmet", -damage*1, false); event.AddMod(event.GetDamageePlayer().getName(), "Helmet", -damage*1, false);
event.GetDamageePlayer().getWorld().playSound(event.GetDamageePlayer().getEyeLocation(), Sound.SPIDER_DEATH, 1f, 1f); event.GetDamageePlayer().getWorld().playSound(event.GetDamageePlayer().getEyeLocation(), Sound.SPIDER_DEATH, 1f, 1f);
} }
else else
{ {
event.GetDamageePlayer().getWorld().playSound(event.GetDamageePlayer().getEyeLocation(), Sound.SLIME_ATTACK, 1f, 1f); event.GetDamageePlayer().getWorld().playSound(event.GetDamageePlayer().getEyeLocation(), Sound.SLIME_ATTACK, 1f, 1f);
} }
} }
//Kevlar - Body Hit //Kevlar - Body Hit
if (hitArea == 0 && Armor.isArmor(event.GetDamageePlayer().getInventory().getChestplate())) if (hitArea == 0 && Armor.isArmor(event.GetDamageePlayer().getInventory().getChestplate()))
{ {
@ -1103,56 +1155,68 @@ public class MineStrike extends TeamGame
event.SetIgnoreRate(true); event.SetIgnoreRate(true);
event.SetIgnoreArmor(true); event.SetIgnoreArmor(true);
} }
public int getArrowHitArea(Player damagee, Location origin, Vector trajectory) public int getArrowHitArea(Player damagee, Location origin, Vector trajectory)
{ {
System.out.println("Getting Area");
//Move to near-player //Move to near-player
Location start = origin.clone().add(trajectory.multiply(UtilMath.offset(origin, damagee.getEyeLocation()) - 2)); Location start = origin.clone().add(trajectory.clone().multiply(UtilMath.offset(origin, damagee.getEyeLocation()) - 2));
Location loc = start.clone(); Location loc = start.clone();
while (!hitHead(damagee, loc) && !hitBody(damagee, loc) && UtilMath.offset(damagee.getLocation(), loc) < 6) while (!hitHead(damagee, loc) && !hitBody(damagee, loc) && UtilMath.offset(damagee.getLocation(), loc) < 6)
{ {
UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, loc, 0, 0, 0, 0, 1);
loc.add(trajectory.clone().multiply(0.1)); loc.add(trajectory.clone().multiply(0.1));
} }
if (hitHead(damagee, loc)) if (hitHead(damagee, loc))
{
System.out.println("Head");
return 1; return 1;
}
if (hitBody(damagee, loc)) if (hitBody(damagee, loc))
{
System.out.println("Body");
return 0; return 0;
}
System.out.println("Miss");
return -1; return -1;
} }
public int getSnowballHitArea(Player damagee, Projectile snowball) public int getSnowballHitArea(Player damagee, Projectile snowball)
{ {
//Move to near-player //Move to near-player
Location start = snowball.getLocation(); Location start = snowball.getLocation();
Location loc = start.clone(); Location loc = start.clone();
while (!hitHead(damagee, loc) && !hitBody(damagee, loc) && UtilMath.offset(damagee.getLocation(), loc) < 6) while (!hitHead(damagee, loc) && !hitBody(damagee, loc) && UtilMath.offset(damagee.getLocation(), loc) < 6)
{ {
loc.add(snowball.getVelocity().clone().multiply(0.1)); loc.add(snowball.getVelocity().clone().multiply(0.1));
} }
if (hitHead(damagee, loc)) if (hitHead(damagee, loc))
return 1; return 1;
if (hitBody(damagee, loc)) if (hitBody(damagee, loc))
return 0; return 0;
return -1; return -1;
} }
public boolean hitBody(Player player, Location loc) public boolean hitBody(Player player, Location loc)
{ {
return UtilMath.offset2d(loc, player.getLocation()) < 0.6 && //0.6 is ideal return UtilMath.offset2d(loc, player.getLocation()) < 0.6 && //0.6 is ideal
loc.getY() > player.getLocation().getY() && loc.getY() > player.getLocation().getY() &&
loc.getY() < player.getEyeLocation().getY() - 0.2; loc.getY() < player.getEyeLocation().getY() - 0.2;
} }
public boolean hitHead(Player player, Location loc) public boolean hitHead(Player player, Location loc)
{ {
return UtilMath.offset2d(loc, player.getLocation()) < 0.3 && //0.3 is ideal return UtilMath.offset2d(loc, player.getLocation()) < 0.3 && //0.3 is ideal
@ -1416,7 +1480,7 @@ public class MineStrike extends TeamGame
_bombDefuser.setExp(0f); _bombDefuser.setExp(0f);
UtilPlayer.message(player, F.main("Game", "You are defusing the Bomb.")); UtilPlayer.message(player, F.main("Game", "You are defusing the Bomb."));
_bombDefuser.getWorld().playSound(_bombDefuser.getLocation(), Sound.PISTON_RETRACT, 2f, 1f); _bombDefuser.getWorld().playSound(_bombDefuser.getLocation(), Sound.PISTON_RETRACT, 2f, 1f);
} }
@ -1703,13 +1767,17 @@ public class MineStrike extends TeamGame
if (GetKit(player) != null) if (GetKit(player) != null)
GetKit(player).ApplyKit(player); GetKit(player).ApplyKit(player);
} }
//Remove Scope
for (Player player : GetPlayers(false))
removeScope(player);
//Prepare Sound //Prepare Sound
for (Player player : GetPlayers(false)) for (Player player : GetPlayers(false))
{ {
player.playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 2f); player.playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 2f);
Manager.GetCondition().Factory().Blind("Respawn", player, null, 2, 0, false, false, false); Manager.GetCondition().Factory().Blind("Respawn", player, null, 2, 0, false, false, false);
UtilPlayer.message(player, F.main("Game", "You have " + F.elem(C.cGreen + "$" + _shopManager.getMoney(player)) + ".")); UtilPlayer.message(player, F.main("Game", "You have " + F.elem(C.cGreen + "$" + _shopManager.getMoney(player)) + ". Open your Inventory to spend it."));
} }
//Give Bomb //Give Bomb
@ -1720,21 +1788,21 @@ public class MineStrike extends TeamGame
for (GameTeam team : GetTeamList()) for (GameTeam team : GetTeamList())
for (Player teamMember : team.GetPlayers(true)) for (Player teamMember : team.GetPlayers(true))
GetScoreboard().SetPlayerTeam(teamMember, team.GetName().toUpperCase()); GetScoreboard().SetPlayerTeam(teamMember, team.GetName().toUpperCase());
//Alternate Bullets //Alternate Bullets
if (_bulletAlternate) if (_bulletAlternate)
_bulletInstant = (_bulletInstant + 1)%3; _bulletInstant = (_bulletInstant + 1)%3;
//Debug Details //Debug Details
if (_debug) if (_debug)
{ {
Announce(C.cDPurple + C.Bold + "ROUND SETTINGS:"); Announce(C.cDPurple + C.Bold + "ROUND SETTINGS:");
if (_customHitbox) if (_customHitbox)
Announce(C.cPurple + C.Bold + "Hitbox: " + ChatColor.RESET + "Accurate with Headshots"); Announce(C.cPurple + C.Bold + "Hitbox: " + ChatColor.RESET + "Accurate with Headshots");
else else
Announce(C.cPurple + C.Bold + "Hitbox: " + ChatColor.RESET + "Default with No Headshot"); Announce(C.cPurple + C.Bold + "Hitbox: " + ChatColor.RESET + "Default with No Headshot");
if (_bulletInstant == 0) if (_bulletInstant == 0)
Announce(C.cPurple + C.Bold + "Bullets: " + ChatColor.RESET + "Slow and Visible"); Announce(C.cPurple + C.Bold + "Bullets: " + ChatColor.RESET + "Slow and Visible");
else if (_bulletInstant == 1) else if (_bulletInstant == 1)
@ -1826,6 +1894,11 @@ public class MineStrike extends TeamGame
for (Entity ent : _bullets.keySet()) for (Entity ent : _bullets.keySet())
ent.remove(); ent.remove();
_bullets.clear(); _bullets.clear();
//Bullets
for (Entity ent : _defusalDropped)
ent.remove();
_defusalDropped.clear();
//Incendiary //Incendiary
_incendiary.clear(); _incendiary.clear();
@ -1833,11 +1906,11 @@ public class MineStrike extends TeamGame
//Restock Ammo //Restock Ammo
for (Gun gun : _gunsEquipped.keySet()) for (Gun gun : _gunsEquipped.keySet())
gun.restockAmmo(_gunsEquipped.get(gun)); gun.restockAmmo(_gunsEquipped.get(gun));
//Health //Health
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
player.setHealth(20); player.setHealth(20);
//Reset Shop //Reset Shop
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
_shopManager.leaveShop(player, false, false); _shopManager.leaveShop(player, false, false);
@ -1973,7 +2046,9 @@ public class MineStrike extends TeamGame
if (gun.getGunType() == GunType.SNIPER) if (gun.getGunType() == GunType.SNIPER)
{ {
event.getPlayer().getWorld().playSound(event.getPlayer().getEyeLocation(), Sound.GHAST_DEATH, 0.8f, 1f); event.getPlayer().getWorld().playSound(event.getPlayer().getEyeLocation(), Sound.GHAST_DEATH, 0.8f, 1f);
Manager.GetCondition().Factory().Blind("Scope Blind", event.getPlayer(), null, 1, 1, false, false, false);
//if (Manager.GetCondition().GetActiveCondition(event.getPlayer(), ConditionType.BLINDNESS) == null)
Manager.GetCondition().Factory().Blind("Scope Blind", event.getPlayer(), null, 1, 0, false, false, false);
} }
} }
else else
@ -1997,7 +2072,7 @@ public class MineStrike extends TeamGame
continue; continue;
Gun gun = getGunInHand(player, null); Gun gun = getGunInHand(player, null);
if (!gun.hasScope() || !player.isSneaking()) if (gun == null || !gun.hasScope() || !player.isSneaking())
{ {
removeScope(player); removeScope(player);
} }
@ -2006,7 +2081,11 @@ public class MineStrike extends TeamGame
public void removeScope(Player player) public void removeScope(Player player)
{ {
if (!_scoped.containsKey(player))
return;
ItemStack stack = _scoped.remove(player); ItemStack stack = _scoped.remove(player);
player.getInventory().setHelmet(stack); player.getInventory().setHelmet(stack);
Manager.GetCondition().EndCondition(player, null, "Scope"); Manager.GetCondition().EndCondition(player, null, "Scope");
@ -2060,16 +2139,16 @@ public class MineStrike extends TeamGame
{ {
if (event.getType() != UpdateType.TICK) if (event.getType() != UpdateType.TICK)
return; return;
if (_bombItem == null) if (_bombItem == null)
return; return;
if (!_bombItem.isValid()) if (!_bombItem.isValid())
{ {
Location loc = _bombItem.getLocation(); Location loc = _bombItem.getLocation();
_bombItem.remove(); _bombItem.remove();
_bombItem = loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.GOLD_SWORD)); _bombItem = loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.GOLD_SWORD));
} }
} }
@ -2229,6 +2308,9 @@ public class MineStrike extends TeamGame
if (_bullets.containsKey(ent)) if (_bullets.containsKey(ent))
continue; continue;
if (_defusalDropped.contains(ent))
continue;
if (_bombItem != null && _bombItem.equals(ent)) if (_bombItem != null && _bombItem.equals(ent))
continue; continue;
@ -2255,6 +2337,9 @@ public class MineStrike extends TeamGame
else if (_grenadesThrown.containsKey(event.getEntity())) else if (_grenadesThrown.containsKey(event.getEntity()))
event.setCancelled(true); event.setCancelled(true);
else if (_defusalDropped.contains(event.getEntity()))
event.setCancelled(true);
else if (_bombItem != null && _bombItem.equals(event.getEntity())) else if (_bombItem != null && _bombItem.equals(event.getEntity()))
event.setCancelled(true); event.setCancelled(true);
@ -2265,7 +2350,7 @@ public class MineStrike extends TeamGame
{ {
if (!IsLive()) if (!IsLive())
return; return;
if (event.getType() != UpdateType.TICK) if (event.getType() != UpdateType.TICK)
return; return;
@ -2369,7 +2454,7 @@ public class MineStrike extends TeamGame
_shopManager.addMoney(event.getPlayer(), 16000, "Debug"); _shopManager.addMoney(event.getPlayer(), 16000, "Debug");
event.setCancelled(true); event.setCancelled(true);
} }
if (event.getMessage().contains("instant")) if (event.getMessage().contains("instant"))
{ {
_bulletInstant = (_bulletInstant + 1)%3; _bulletInstant = (_bulletInstant + 1)%3;
@ -2380,11 +2465,11 @@ public class MineStrike extends TeamGame
Announce(C.cPurple + C.Bold + "Bullets: " + ChatColor.RESET + "Instant and Invisible"); Announce(C.cPurple + C.Bold + "Bullets: " + ChatColor.RESET + "Instant and Invisible");
else else
Announce(C.cPurple + C.Bold + "Bullets: " + ChatColor.RESET + "Slow and Visible with Instant Sniper"); Announce(C.cPurple + C.Bold + "Bullets: " + ChatColor.RESET + "Slow and Visible with Instant Sniper");
event.setCancelled(true); event.setCancelled(true);
} }
if (event.getMessage().contains("hitbox")) if (event.getMessage().contains("hitbox"))
{ {
_customHitbox = !_customHitbox; _customHitbox = !_customHitbox;
@ -2396,7 +2481,7 @@ public class MineStrike extends TeamGame
event.setCancelled(true); event.setCancelled(true);
} }
if (event.getMessage().contains("alternate")) if (event.getMessage().contains("alternate"))
{ {
_bulletAlternate = !_bulletAlternate; _bulletAlternate = !_bulletAlternate;
@ -2405,16 +2490,16 @@ public class MineStrike extends TeamGame
event.setCancelled(true); event.setCancelled(true);
} }
if (event.getMessage().contains("god")) if (event.getMessage().contains("god"))
{ {
if (HealthSet == 20) if (HealthSet == 20)
HealthSet = -1; HealthSet = -1;
else else
HealthSet = 20; HealthSet = 20;
Announce(C.cPurple + C.Bold + "God Mode: " + ChatColor.RESET + (HealthSet == 20)); Announce(C.cPurple + C.Bold + "God Mode: " + ChatColor.RESET + (HealthSet == 20));
event.setCancelled(true); event.setCancelled(true);
} }

View File

@ -14,6 +14,10 @@ public class Bomb
public long BombTime = 45000; public long BombTime = 45000;
public Block Block; public Block Block;
public Material Type;
public byte Data;
public long StartTime; public long StartTime;
public long LastBeep; public long LastBeep;
@ -27,6 +31,10 @@ public class Bomb
Planter = planter; Planter = planter;
Block = planter.getLocation().getBlock(); Block = planter.getLocation().getBlock();
Type = Block.getType();
Data = Block.getData();
Block.setType(Material.DAYLIGHT_DETECTOR); Block.setType(Material.DAYLIGHT_DETECTOR);
StartTime = System.currentTimeMillis(); StartTime = System.currentTimeMillis();
@ -49,7 +57,7 @@ public class Bomb
if (UtilTime.elapsed(StartTime, BombTime)) if (UtilTime.elapsed(StartTime, BombTime))
{ {
Block.setType(Material.AIR); clean();
//Effect //Effect
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, Block.getLocation(), 10f, 10f, 10f, 0, 30); UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, Block.getLocation(), 10f, 10f, 10f, 0, 30);
@ -73,7 +81,7 @@ public class Bomb
public void defuse() public void defuse()
{ {
Block.setType(Material.AIR); clean();
//Effect //Effect
UtilParticle.PlayParticle(ParticleType.CLOUD, Block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1); UtilParticle.PlayParticle(ParticleType.CLOUD, Block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1);
@ -81,6 +89,7 @@ public class Bomb
public void clean() public void clean()
{ {
Block.setType(Material.AIR); Block.setType(Type);
Block.setData(Data);
} }
} }

View File

@ -28,7 +28,7 @@ public abstract class StrikeItem
private String _name; private String _name;
private String[] _desc; private String[] _desc;
private int _cost; private int _cost;
private int _gemCost; private int _gemCost;
private Material _skin; private Material _skin;
private String _ownerName; private String _ownerName;

View File

@ -58,7 +58,6 @@ public class Armor extends StrikeItem
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace();
return false; return false;
} }
} }

View File

@ -26,7 +26,7 @@ public abstract class FireGrenadeBase extends Grenade
{ {
}, },
price, gemCost, Material.PORK, 1); price, gemCost, skin, 1);
_baseTime = burnTime; _baseTime = burnTime;
} }
@ -56,7 +56,7 @@ public abstract class FireGrenadeBase extends Grenade
final HashMap<Block, Double> blocks = UtilBlock.getInRadius(loc, 3.5d); final HashMap<Block, Double> blocks = UtilBlock.getInRadius(loc, 3.5d);
for (final Block block : blocks.keySet()) for (final Block block : blocks.keySet())
{ {
if (block.getType() != Material.AIR) if (block.getType() != Material.AIR && !block.getType().name().toLowerCase().contains("step"))
continue; continue;
if (!UtilBlock.solid(block.getRelative(BlockFace.DOWN))) if (!UtilBlock.solid(block.getRelative(BlockFace.DOWN)))

View File

@ -185,6 +185,8 @@ public abstract class Grenade extends StrikeItem
{ {
game.registerGrenade(this, player); game.registerGrenade(this, player);
game.deregisterDroppedGrenade(this); game.deregisterDroppedGrenade(this);
return true;
} }
return false; return false;

View File

@ -4,6 +4,7 @@ import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ParticleType;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.MineStrike;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -24,10 +25,15 @@ public class Smoke extends Grenade
{ {
if (ent.getTicksLived() > 60) if (ent.getTicksLived() > 60)
{ {
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, ent.getLocation(), 0, 0, 0, 0, 1); UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, ent.getLocation(), 0.3f, 0.3f, 0.3f, 0, 1);
ent.getWorld().playSound(ent.getLocation(), Sound.FIZZ, 0.1f, 0.1f); ent.getWorld().playSound(ent.getLocation(), Sound.FIZZ, 0.1f, 0.1f);
for (Location loc : game.Manager.GetBlockRestore().RestoreBlockAround(Material.FIRE, ent.getLocation(), 5))
{
loc.getWorld().playSound(loc, Sound.FIZZ, 1f, 1f);
}
return false; return false;
} }

View File

@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.minestrike.items.guns;
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.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilDisplay;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
@ -51,6 +52,8 @@ public abstract class Gun extends StrikeItem
protected double _coneIncreaseRate; protected double _coneIncreaseRate;
protected boolean _scope = false; protected boolean _scope = false;
protected boolean _reloading = false;
//Active Data //Active Data
@ -102,6 +105,9 @@ public abstract class Gun extends StrikeItem
public void shoot(final Player player, final MineStrike game) public void shoot(final Player player, final MineStrike game)
{ {
if (_reloading)
return;
//Standard (300) RPM //Standard (300) RPM
shootOnce(player, game); shootOnce(player, game);
@ -157,6 +163,10 @@ public abstract class Gun extends StrikeItem
loc.add(UtilAlg.getDown(player.getLocation().getDirection()).multiply(0.3)); loc.add(UtilAlg.getDown(player.getLocation().getDirection()).multiply(0.3));
UtilParticle.PlayParticle(ParticleType.EXPLODE, loc, 0, 0, 0, 0, 1); UtilParticle.PlayParticle(ParticleType.EXPLODE, loc, 0, 0, 0, 0, 1);
//Unscope
if (_gunType == GunType.SNIPER)
game.removeScope(player);
game.registerBullet(fireBullet(player, game)); game.registerBullet(fireBullet(player, game));
} }
@ -260,27 +270,22 @@ public abstract class Gun extends StrikeItem
{ {
if (_loadedAmmo == _clipSize) if (_loadedAmmo == _clipSize)
return; return;
int ammo = _reserveAmmo + _loadedAmmo; int ammo = _reserveAmmo + _loadedAmmo;
if (ammo == 0) if (ammo == 0 || _reserveAmmo == 0)
{ {
UtilPlayer.message(player, F.main("Gun", "You have no ammo for " + F.name(getName()) + ".")); UtilPlayer.message(player, F.main("Gun", "You have no more ammo for " + F.name(getName()) + "."));
return; return;
} }
_loadedAmmo = Math.min(ammo, _clipSize);
_reserveAmmo = Math.max(0, ammo - _clipSize);
//Recharge //Recharge
Recharge.Instance.useForce(player, getName() + " Shoot", getReloadTime());
Recharge.Instance.use(player, getName() + " Reload", getReloadTime(), false, true); Recharge.Instance.use(player, getName() + " Reload", getReloadTime(), false, true);
//Sound //Sound
soundReload(player.getLocation()); soundReload(player.getLocation());
//Update _reloading = true;
updateWeaponName(player);
} }
@Override @Override
@ -321,9 +326,39 @@ public abstract class Gun extends StrikeItem
loc.getWorld().playSound(loc, Sound.PISTON_RETRACT, 1f, 0.8f); loc.getWorld().playSound(loc, Sound.PISTON_RETRACT, 1f, 0.8f);
} }
public void soundReloaded(Location loc) public void cancelReloadCheck(Player player, MineStrike game)
{ {
loc.getWorld().playSound(loc, Sound.PISTON_EXTEND, 1f, 1.6f); if (!_reloading)
return;
if (!isHolding(player))
{
_reloading = false;
Recharge.Instance.recharge(player, getName() + " Reload");
UtilDisplay.displayTextBar(game.Manager.GetPlugin(), player, 1, C.cRed + C.Bold + getName() + " Reload");
return;
}
}
public void handleReloaded(Player player)
{
if (!_reloading)
return;
_reloading = false;
//Update Ammo
int ammo = _reserveAmmo + _loadedAmmo;
_loadedAmmo = Math.min(ammo, _clipSize);
_reserveAmmo = Math.max(0, ammo - _clipSize);
//Update
updateWeaponName(player);
//Sound
player.getWorld().playSound(player.getEyeLocation(), Sound.PISTON_EXTEND, 1f, 1.6f);
} }
public void soundRefire(Location loc) public void soundRefire(Location loc)
@ -353,7 +388,7 @@ public abstract class Gun extends StrikeItem
{ {
_cone = Math.max(_coneMin, _cone - (_coneReduceRate / 20d)); _cone = Math.max(_coneMin, _cone - (_coneReduceRate / 20d));
} }
public void reloadEvent(RechargedEvent event) public void reloadEvent(RechargedEvent event)
{ {
if (!isHolding(event.GetPlayer())) if (!isHolding(event.GetPlayer()))
@ -365,7 +400,7 @@ public abstract class Gun extends StrikeItem
} }
else if (event.GetAbility().equals(getName() + " Reload")) else if (event.GetAbility().equals(getName() + " Reload"))
{ {
soundReloaded(event.GetPlayer().getEyeLocation()); handleReloaded(event.GetPlayer());
} }
} }

View File

@ -34,6 +34,9 @@ public abstract class Shotgun extends Gun
@Override @Override
public void shoot(Player player, MineStrike game) public void shoot(Player player, MineStrike game)
{ {
if (_reloading)
return;
//Check Ammo //Check Ammo
if (!ammoCheck(player)) if (!ammoCheck(player))
return; return;
@ -78,6 +81,8 @@ public abstract class Shotgun extends Gun
@Override @Override
public long getReloadTime() public long getReloadTime()
{ {
return _reloadTime * Math.min(_reserveAmmo, _clipSize - _loadedAmmo); long time = _reloadTime + _reloadTime * Math.min(_reserveAmmo, _clipSize - _loadedAmmo);
return time;
} }
} }

View File

@ -20,7 +20,7 @@ public class AWP extends Gun
10, 3, //Clip Size, Spare Ammo 10, 3, //Clip Size, Spare Ammo
1500, 3600, //ROF, Reload Time 1500, 3600, //ROF, Reload Time
115, 0, 0.97, //Damage, Dropoff, Armor Penetration 115, 0, 0.97, //Damage, Dropoff, Armor Penetration
0.1, 0.1, //COF Min, COF Max 0.14, 0.14, //COF Min, COF Max
0, 0, //COF Inc per Bullet, COF Dec per Second 0, 0, //COF Inc per Bullet, COF Dec per Second
Material.GOLD_SPADE, Sound.DRINK); Material.GOLD_SPADE, Sound.DRINK);

View File

@ -17,9 +17,9 @@ public class Nova extends Shotgun
}, },
1200, 5000, //Cost, Gem Cost 1200, 5000, //Cost, Gem Cost
8, 4, //Clip Size, Spare Ammo 8, 4, //Clip Size, Spare Ammo
1000, 800, //ROF, Reload Time 1000, 600, //ROF, Reload Time
26, 0.01, 0.5, //Damage, Dropoff, Armor Penetration 26, 0.01, 0.5, //Damage, Dropoff, Armor Penetration
0.15, 0.15, //COF Min, COF Max 0.1, 0.1, //COF Min, COF Max
0, 0, //COF Inc per Bullet, COF Dec per Second 0, 0, //COF Inc per Bullet, COF Dec per Second
Material.GOLD_AXE, Sound.BLAZE_DEATH, 9); Material.GOLD_AXE, Sound.BLAZE_DEATH, 9);
} }

View File

@ -17,9 +17,9 @@ public class XM1014 extends Shotgun
}, },
2000, 5000, //Cost, Gem Cost 2000, 5000, //Cost, Gem Cost
7, 4, //Clip Size, Spare Ammo 7, 4, //Clip Size, Spare Ammo
260, 800, //ROF, Reload Time 260, 600, //ROF, Reload Time
20, 0.01, 0.8, //Damage, Dropoff, Armor Penetration 20, 0.01, 0.8, //Damage, Dropoff, Armor Penetration
0.15, 0.15, //COF Min, COF Max 0.12, 0.12, //COF Min, COF Max
0, 0, //COF Inc per Bullet, COF Dec per Second 0, 0, //COF Inc per Bullet, COF Dec per Second
Material.DIAMOND_AXE, Sound.SKELETON_DEATH, 6); Material.DIAMOND_AXE, Sound.SKELETON_DEATH, 6);
} }

View File

@ -19,7 +19,7 @@ public class P90 extends Gun
2350, 5000, //Cost, Gem Cost 2350, 5000, //Cost, Gem Cost
50, 2, //Clip Size, Spare Ammo 50, 2, //Clip Size, Spare Ammo
35, 3300, //ROF, Reload Time 35, 3300, //ROF, Reload Time
22, 0.006, 0.65, //Damage, Dropoff, Armor Penetration 17, 0.006, 0.65, //Damage, Dropoff, Armor Penetration
0, 0.25, //COF Min, COF Max 0, 0.25, //COF Min, COF Max
0.022, 0.3, //COF Inc per Bullet, COF Dec per Second 0.022, 0.3, //COF Inc per Bullet, COF Dec per Second
Material.STONE_AXE, Sound.CREEPER_DEATH); Material.STONE_AXE, Sound.CREEPER_DEATH);

View File

@ -84,8 +84,9 @@ public class MineWare extends SoloGame
this.ItemDrop = true; this.ItemDrop = true;
this.ItemPickup = true; this.ItemPickup = true;
this.InventoryOpen = true; InventoryOpenBlock = true;
this.InventoryClick = true; InventoryOpenChest = true;
InventoryClick = true;
PopulateOrders(); PopulateOrders();
} }

View File

@ -86,9 +86,7 @@ public class SuperSmash extends SoloGame
this.CompassEnabled = true; this.CompassEnabled = true;
this.SpawnDistanceRequirement = 16; this.SpawnDistanceRequirement = 16;
this.InventoryOpen = false;
// Add stat table here // Add stat table here
// Example // Example
//Manager.GetStatsManager().addTable("SuperSmashMobStats", "Kills", "Deaths", "Wins", "Losses"); //Manager.GetStatsManager().addTable("SuperSmashMobStats", "Kills", "Deaths", "Wins", "Losses");

View File

@ -87,8 +87,6 @@ public class SuperSmashTeam extends TeamGame
this.SpawnDistanceRequirement = 16; this.SpawnDistanceRequirement = 16;
this.InventoryOpen = false;
this.TeamArmorHotbar = true; this.TeamArmorHotbar = true;
} }

View File

@ -71,7 +71,7 @@ public class KitSkeletalHorse extends SmashKit
})); }));
if (Manager.GetGame().GetState() == GameState.Recruit) if (Manager.GetGame().GetState() == GameState.Recruit)
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.FIRE, (byte)0, 1, player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER, (byte)0, 1,
C.cYellow + C.Bold + "Passive" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Infernal Horror", C.cYellow + C.Bold + "Passive" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Infernal Horror",
new String[] new String[]
{ {

View File

@ -174,6 +174,8 @@ public class SurvivalGames extends SoloGame
this.ItemPickup = true; this.ItemPickup = true;
this.InventoryClick = true; this.InventoryClick = true;
this.InventoryOpenBlock = true;
this.InventoryOpenChest = true;
this.CompassEnabled = false; //XXX this.CompassEnabled = false; //XXX

View File

@ -73,7 +73,7 @@ public class UHC extends TeamGame
{ {
private NautHashMap<String, Long> _deathTime = new NautHashMap<String, Long>(); private NautHashMap<String, Long> _deathTime = new NautHashMap<String, Long>();
private NautHashMap<String, Long> _combatTime = new NautHashMap<String, Long>(); private NautHashMap<String, Long> _combatTime = new NautHashMap<String, Long>();
private int _borderSize = 1000; private int _borderSize = 1000;
private int _gameMinutes = 0; private int _gameMinutes = 0;
@ -81,7 +81,7 @@ public class UHC extends TeamGame
private long _lastMinute = System.currentTimeMillis(); private long _lastMinute = System.currentTimeMillis();
private Objective _scoreObj; private Objective _scoreObj;
public UHC(ArcadeManager manager) public UHC(ArcadeManager manager)
{ {
super(manager, GameType.UHC, super(manager, GameType.UHC,
@ -99,7 +99,7 @@ public class UHC extends TeamGame
}); });
this.GameTimeout = 10800000; this.GameTimeout = 10800000;
this.DamagePvP = false; this.DamagePvP = false;
this.DeathDropItems = true; this.DeathDropItems = true;
@ -110,8 +110,9 @@ public class UHC extends TeamGame
this.BlockBreak = true; this.BlockBreak = true;
this.BlockPlace = true; this.BlockPlace = true;
this.InventoryOpen = true; this.InventoryOpenBlock = true;
this.InventoryOpenChest = true;
this.DeathOut = true; this.DeathOut = true;
this.QuitOut = false; this.QuitOut = false;
@ -125,8 +126,6 @@ public class UHC extends TeamGame
this.SoupEnabled = false; this.SoupEnabled = false;
this.IdleKick = true;
this.AutoStart = true;
this.CompassEnabled = true; this.CompassEnabled = true;
this.WorldBoundaryKill = false; this.WorldBoundaryKill = false;
@ -140,13 +139,9 @@ public class UHC extends TeamGame
//Disable Anti-Stack //Disable Anti-Stack
Manager.GetAntiStack().SetEnabled(false); Manager.GetAntiStack().SetEnabled(false);
_scoreObj = Scoreboard.GetScoreboard().registerNewObjective("Health", "health"); _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("Health", "health");
_scoreObj.setDisplaySlot(DisplaySlot.PLAYER_LIST); _scoreObj.setDisplaySlot(DisplaySlot.PLAYER_LIST);
//Tournament
this.AutoBalance = false;
this.AutoStart = false;
} }
@Override @Override
@ -191,7 +186,7 @@ public class UHC extends TeamGame
this.DamagePvP = true; this.DamagePvP = true;
} }
} }
@EventHandler @EventHandler
public void EarlyGameUpdate(UpdateEvent event) public void EarlyGameUpdate(UpdateEvent event)
@ -201,12 +196,12 @@ public class UHC extends TeamGame
if (event.getType() != UpdateType.FAST) if (event.getType() != UpdateType.FAST)
return; return;
if (DamagePvP) if (DamagePvP)
return; return;
WorldData.World.setTime(2000); WorldData.World.setTime(2000);
for (Player player : GetPlayers(true)) for (Player player : GetPlayers(true))
{ {
player.setSaturation(3f); player.setSaturation(3f);
@ -260,14 +255,14 @@ public class UHC extends TeamGame
Manager.GetCondition().Factory().Poison("Border", event.getPlayer(), event.getPlayer(), 1.9, 0, false, false, false); Manager.GetCondition().Factory().Poison("Border", event.getPlayer(), event.getPlayer(), 1.9, 0, false, false, false);
} }
} }
*/ */
@EventHandler @EventHandler
public void WorldBoundaryCheck(UpdateEvent event) public void WorldBoundaryCheck(UpdateEvent event)
{ {
if (event.getType() != UpdateType.FASTER) if (event.getType() != UpdateType.FASTER)
return; return;
for (Player player : GetPlayers(true)) for (Player player : GetPlayers(true))
{ {
//Damage //Damage
@ -275,42 +270,101 @@ public class UHC extends TeamGame
{ {
player.damage(0.75); player.damage(0.75);
} }
//Effect VisualBoundary(player);
if (Math.abs(player.getLocation().getX()) + 7 < _borderSize && Math.abs(player.getLocation().getZ()) + 7 < _borderSize) VisualBoundaryClose(player);
continue; }
}
for (Block block : UtilBlock.getInRadius(player.getLocation(), 7d).keySet())
public void VisualBoundary(Player player)
{
//Effect 1
if (Math.abs(player.getLocation().getX()) + 16 < _borderSize && Math.abs(player.getLocation().getZ()) + 16 < _borderSize)
return;
//X Wall
if (Math.abs(player.getLocation().getX()) + 16 >= _borderSize)
{
Location loc = player.getLocation().getBlock().getLocation().add(0.5, 0.5, 0.5);
loc.setX(_borderSize);
for (int y=-16 ; y<=16 ; y++)
{ {
if (Math.random() > 0.80) for (int z=-16 ; z<=16 ; z++)
continue; {
if (Math.abs(loc.getZ() + z) > _borderSize)
if (Math.abs(block.getX()) < _borderSize && Math.abs(block .getZ()) < _borderSize) continue;
continue;
Location newLoc = loc.clone().add(0, y, z);
if (!UtilBlock.airFoliage(block))
continue; if (UtilMath.offset(player.getLocation(), newLoc) > 16)
continue;
if (!UtilBlock.solid(block.getRelative(BlockFace.DOWN)))
continue; UtilParticle.PlayParticle(player, ParticleType.FLAME, newLoc, 0.5f, 0.5f, 0.5f, 0, 1);
if (_borderSize > 16)
UtilParticle.PlayParticle(player, ParticleType.LARGE_EXPLODE, block.getLocation(), (float)Math.random(), (float)Math.random(), (float)Math.random(), 0, 1); player.playSound(newLoc, Sound.FIZZ, 0.1f, 0.1f);
}
player.playSound(block.getLocation(), Sound.FIZZ, 0.1f, 0.1f); }
}
//Z Wall
if (Math.abs(player.getLocation().getZ()) + 16 >= _borderSize)
{
Location loc = player.getLocation().getBlock().getLocation().add(0.5, 0.5, 0.5);
loc.setZ(_borderSize);
for (int x=-16 ; x<=16 ; x++)
{
for (int y=-16 ; y<=16 ; y++)
{
if (Math.abs(loc.getX() + x) > _borderSize)
continue;
Location newLoc = loc.clone().add(x, y, 0);
if (UtilMath.offset(player.getLocation(), newLoc) > 16)
continue;
UtilParticle.PlayParticle(player, ParticleType.FLAME, newLoc, 0.5f, 0.5f, 0.5f, 0, 1);
if (_borderSize > 16)
player.playSound(newLoc, Sound.FIZZ, 0.1f, 0.1f);
}
} }
} }
} }
public void VisualBoundaryClose(Player player)
{
//Effect
if (Math.abs(player.getLocation().getX()) + 5 < _borderSize && Math.abs(player.getLocation().getZ()) + 5 < _borderSize)
return;
for (Block block : UtilBlock.getInRadius(player.getLocation(), 5d).keySet())
{
if (Math.random() > 0.80)
continue;
if (Math.abs(block.getX()) < _borderSize && Math.abs(block .getZ()) < _borderSize)
continue;
if (!UtilBlock.airFoliage(block))
continue;
UtilParticle.PlayParticle(player, ParticleType.LAVA, block.getLocation().add(0.5, 0.5, 0.5), 0.5f, 0.5f, 0.5f, 0, 1);
}
}
@EventHandler @EventHandler
public void WorldBoundaryShrink(UpdateEvent event) public void WorldBoundaryShrink(UpdateEvent event)
{ {
if (!IsLive()) if (!IsLive())
return; return;
if (event.getType() != UpdateType.SLOW) if (event.getType() != UpdateType.SLOW)
return; return;
if (_borderSize > 16) if (_borderSize > 16)
_borderSize--; _borderSize--;
} }
@ -331,6 +385,7 @@ public class UHC extends TeamGame
this.WorldData.MinY = -1000; this.WorldData.MinY = -1000;
this.WorldData.MaxY = 1000; this.WorldData.MaxY = 1000;
/*
for (int y=0 ; y<128 ; y++) for (int y=0 ; y<128 ; y++)
for (int x=-_borderSize ; x<_borderSize ; x++) for (int x=-_borderSize ; x<_borderSize ; x++)
for (int z=-_borderSize ; z<_borderSize ; z++) for (int z=-_borderSize ; z<_borderSize ; z++)
@ -340,6 +395,7 @@ public class UHC extends TeamGame
MapUtil.QuickChangeBlockAt(WorldData.World, x, y, z , 159, (byte)14); MapUtil.QuickChangeBlockAt(WorldData.World, x, y, z , 159, (byte)14);
} }
} }
*/
System.out.println("Time: " + UtilTime.MakeStr(System.currentTimeMillis() - time)); System.out.println("Time: " + UtilTime.MakeStr(System.currentTimeMillis() - time));
} }
@ -355,7 +411,7 @@ public class UHC extends TeamGame
{ {
team.GetSpawns().clear(); team.GetSpawns().clear();
} }
TimingManager.start("UHC Spawn Generation"); TimingManager.start("UHC Spawn Generation");
//Solo Game //Solo Game
@ -434,7 +490,7 @@ public class UHC extends TeamGame
} }
} }
} }
TimingManager.stop("UHC Spawn Generation"); TimingManager.stop("UHC Spawn Generation");
} }
@ -454,7 +510,7 @@ public class UHC extends TeamGame
{ {
int x = (int)(UtilMath.r((int)(1.8*_borderSize)) - (0.9*_borderSize)); int x = (int)(UtilMath.r((int)(1.8*_borderSize)) - (0.9*_borderSize));
int z = (int)(UtilMath.r((int)(1.8*_borderSize)) - (0.9*_borderSize)); int z = (int)(UtilMath.r((int)(1.8*_borderSize)) - (0.9*_borderSize));
block = UtilBlock.getHighest(WorldData.World, x, z, ignore); block = UtilBlock.getHighest(WorldData.World, x, z, ignore);
} }
//Get Radius Location //Get Radius Location
@ -589,7 +645,7 @@ public class UHC extends TeamGame
if (player.isDead()) if (player.isDead())
return; return;
if (true) if (true)
{ {
//Announcement //Announcement
@ -598,7 +654,7 @@ public class UHC extends TeamGame
player.damage(5000); player.damage(5000);
return; return;
} }
if (_combatTime.containsKey(player.getName()) && !UtilTime.elapsed(_combatTime.get(player.getName()), 15000)) if (_combatTime.containsKey(player.getName()) && !UtilTime.elapsed(_combatTime.get(player.getName()), 15000))
{ {
@ -609,21 +665,21 @@ public class UHC extends TeamGame
return; return;
} }
} }
*/ */
@EventHandler(priority=EventPriority.MONITOR) @EventHandler(priority=EventPriority.MONITOR)
public void DamageRecord(CustomDamageEvent event) public void DamageRecord(CustomDamageEvent event)
{ {
if (event.IsCancelled()) if (event.IsCancelled())
return; return;
if (event.GetDamagerPlayer(true) != null && event.GetDamageePlayer() != null) if (event.GetDamagerPlayer(true) != null && event.GetDamageePlayer() != null)
{ {
_combatTime.put(event.GetDamageePlayer().getName(), System.currentTimeMillis()); _combatTime.put(event.GetDamageePlayer().getName(), System.currentTimeMillis());
_combatTime.put(event.GetDamagerPlayer(true).getName(), System.currentTimeMillis()); _combatTime.put(event.GetDamagerPlayer(true).getName(), System.currentTimeMillis());
} }
} }
@EventHandler @EventHandler
public void CreatureCull(UpdateEvent event) public void CreatureCull(UpdateEvent event)
{ {
@ -647,7 +703,7 @@ public class UHC extends TeamGame
{ {
ArrayList<Entity> entList = ents.get(type); ArrayList<Entity> entList = ents.get(type);
int count = 0; int count = 0;
if (type == EntityType.DROPPED_ITEM) if (type == EntityType.DROPPED_ITEM)
continue; continue;
@ -907,7 +963,7 @@ public class UHC extends TeamGame
if (GetPlayers(true).size() <= 1) if (GetPlayers(true).size() <= 1)
{ {
ArrayList<Player> places = GetTeamList().get(0).GetPlacements(true); ArrayList<Player> places = GetTeamList().get(0).GetPlacements(true);
//Announce //Announce
AnnounceEnd(places); AnnounceEnd(places);
@ -949,23 +1005,23 @@ public class UHC extends TeamGame
} }
} }
} }
@Override @Override
@EventHandler @EventHandler
public void ScoreboardUpdate(UpdateEvent event) public void ScoreboardUpdate(UpdateEvent event)
{ {
if (event != null && event.getType() != UpdateType.FAST) if (event != null && event.getType() != UpdateType.FAST)
return; return;
ScoreboardWrite(); ScoreboardWrite();
} }
public void ScoreboardWrite() public void ScoreboardWrite()
{ {
Scoreboard.Reset(); Scoreboard.Reset();
Scoreboard.WriteBlank(); Scoreboard.WriteBlank();
//Solo //Solo
if (GetTeamList().size() == 1) if (GetTeamList().size() == 1)
{ {
@ -986,11 +1042,11 @@ public class UHC extends TeamGame
else else
{ {
ArrayList<GameTeam> aliveList = new ArrayList<GameTeam>(); ArrayList<GameTeam> aliveList = new ArrayList<GameTeam>();
for (GameTeam team : GetTeamList()) for (GameTeam team : GetTeamList())
if (team.IsTeamAlive()) if (team.IsTeamAlive())
aliveList.add(team); aliveList.add(team);
if (GetPlayers(true).size() < 8) if (GetPlayers(true).size() < 8)
{ {
for (Player player : GetPlayers(true)) for (Player player : GetPlayers(true))
@ -1011,27 +1067,44 @@ public class UHC extends TeamGame
Scoreboard.Write(GetTeamList().size() + " Alive"); Scoreboard.Write(GetTeamList().size() + " Alive");
} }
} }
Scoreboard.WriteBlank(); Scoreboard.WriteBlank();
Scoreboard.Write(C.cYellow + C.Bold + "Time"); Scoreboard.Write(C.cYellow + C.Bold + "Time");
Scoreboard.Write(UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime())); 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");
Scoreboard.Write("-" + _borderSize + " to " + "+" + _borderSize); Scoreboard.Write("-" + _borderSize + " to " + "+" + _borderSize);
Scoreboard.Draw(); Scoreboard.Draw();
} }
public int GetHealth(Player player) public int GetHealth(Player player)
{ {
int health = (int)player.getHealth(); int health = (int)player.getHealth();
if (player.getHealth() % 1d != 0) if (player.getHealth() % 1d != 0)
{ {
health += 1; health += 1;
} }
return health; return health;
} }
public String getMotdStatus()
{
long hour = 3600000;
if (InProgress())
{
return ChatColor.YELLOW + "In Progress";
}
if (System.currentTimeMillis() % hour < 60000)
{
return ChatColor.GREEN + "Recruiting";
}
return ChatColor.GOLD + "Starting in " + UtilTime.MakeStr(hour - (System.currentTimeMillis() % hour));
}
} }

View File

@ -149,7 +149,7 @@ public class PerkBoneRush extends Perk implements IThrown
} }
else else
{ {
Item fire = player.getWorld().dropItem(player.getLocation().add(Math.random()*5 - 2.5, Math.random()*3, Math.random()*5 - 2.5), new ItemStack(Material.FIRE)); Item fire = player.getWorld().dropItem(player.getLocation().add(Math.random()*5 - 2.5, Math.random()*3, Math.random()*5 - 2.5), new ItemStack(Material.BLAZE_POWDER));
UtilAction.velocity(fire, dir, 0.6 + 0.3 * Math.random(), false, 0, 0.1 + Math.random() * 0.05, 0.3, false); UtilAction.velocity(fire, dir, 0.6 + 0.3 * Math.random(), false, 0, 0.1 + Math.random() * 0.05, 0.3, false);
Manager.GetProjectile().AddThrow(fire, player, this, -1, true, true, true, false, 1d); Manager.GetProjectile().AddThrow(fire, player, this, -1, true, true, true, false, 1d);
} }
@ -169,7 +169,7 @@ public class PerkBoneRush extends Perk implements IThrown
@Override @Override
public void Collide(LivingEntity target, Block block, ProjectileUser data) public void Collide(LivingEntity target, Block block, ProjectileUser data)
{ {
boolean burning = ((Item)data.GetThrown()).getItemStack().getType() == Material.FIRE; boolean burning = ((Item)data.GetThrown()).getItemStack().getType() == Material.BLAZE_POWDER;
data.GetThrown().remove(); data.GetThrown().remove();

View File

@ -110,7 +110,7 @@ public class PerkFlamingSword extends Perk
} }
//Fire //Fire
Item fire = cur.getWorld().dropItem(cur.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.FIRE)); Item fire = cur.getWorld().dropItem(cur.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER));
Manager.GetFire().Add(fire, cur, 0.7, 0, 0.5, 1, "Inferno"); Manager.GetFire().Add(fire, cur, 0.7, 0, 0.5, 1, "Inferno");
fire.teleport(cur.getEyeLocation()); fire.teleport(cur.getEyeLocation());

View File

@ -100,7 +100,7 @@ public class PerkInferno extends Perk
} }
//Fire //Fire
Item fire = cur.getWorld().dropItem(cur.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.FIRE)); Item fire = cur.getWorld().dropItem(cur.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER));
Manager.GetFire().Add(fire, cur, 0.7, 0, 0.5, 1, "Inferno"); Manager.GetFire().Add(fire, cur, 0.7, 0, 0.5, 1, "Inferno");
fire.teleport(cur.getEyeLocation()); fire.teleport(cur.getEyeLocation());

View File

@ -85,7 +85,7 @@ public class PerkInfernoFinn extends Perk
} }
//Fire //Fire
Item fire = cur.getWorld().dropItem(cur.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.FIRE)); Item fire = cur.getWorld().dropItem(cur.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER));
Manager.GetFire().Add(fire, cur, 0.7, 0, 2, 2, "Inferno"); Manager.GetFire().Add(fire, cur, 0.7, 0, 2, 2, "Inferno");
fire.teleport(cur.getEyeLocation()); fire.teleport(cur.getEyeLocation());

View File

@ -14,6 +14,7 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.stats.StatTracker;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -92,8 +93,12 @@ public class GameCreationManager implements Listener
{ {
Game game = gameIterator.next(); Game game = gameIterator.next();
HandlerList.unregisterAll(game); HandlerList.unregisterAll(game);
for (StatTracker tracker : game.getStatTrackers())
HandlerList.unregisterAll(tracker);
TimingManager.start("GameCreationManager - Attempting Removal - " + game.GetName()); TimingManager.start("GameCreationManager - Attempting Removal - " + game.GetName());
//Cleaned //Cleaned

View File

@ -44,6 +44,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
@ -229,9 +230,9 @@ public class GameFlagManager implements Listener
} }
} }
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void InventoryOpen(PlayerInteractEvent event) public void InventoryOpen(InventoryOpenEvent event)
{ {
Game game = Manager.GetGame(); Game game = Manager.GetGame();
if (game == null) if (game == null)
@ -240,16 +241,34 @@ public class GameFlagManager implements Listener
if (!game.InProgress()) if (!game.InProgress())
return; return;
if (game.InventoryOpen) if (!game.InventoryOpenBlock)
return; {
if (event.getInventory().getType() == InventoryType.ANVIL ||
event.getInventory().getType() == InventoryType.BEACON ||
event.getInventory().getType() == InventoryType.BREWING ||
event.getInventory().getType() == InventoryType.DISPENSER ||
event.getInventory().getType() == InventoryType.DROPPER ||
event.getInventory().getType() == InventoryType.ENCHANTING ||
event.getInventory().getType() == InventoryType.FURNACE ||
event.getInventory().getType() == InventoryType.HOPPER ||
event.getInventory().getType() == InventoryType.MERCHANT ||
event.getInventory().getType() == InventoryType.ENDER_CHEST ||
event.getInventory().getType() == InventoryType.WORKBENCH)
{
event.setCancelled(true);
event.getPlayer().closeInventory();
}
}
if (event.getClickedBlock() == null)
return;
if (!UtilBlock.usable(event.getClickedBlock())) if (!game.InventoryOpenChest)
return; {
if (event.getInventory().getType() == InventoryType.CHEST)
event.setCancelled(true); {
event.setCancelled(true);
event.getPlayer().closeInventory();
}
}
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)

View File

@ -316,6 +316,55 @@ public class GameLobbyManager implements Listener, IPacketHandler
CreateScoreboards(); CreateScoreboards();
return; return;
} }
//UHC
if (game.GetType() == GameType.UHC)
{
if (game.GetTeamList().size() > 1)
{
//Text
WriteTeamLine("", 0, 159, (byte)15);
WriteTeamLine("", 1, 159, (byte)4);
for (int i=0 ; i<game.GetTeamList().size() ; i++)
{
GameTeam team = game.GetTeamList().get(i);
//Circle Math
double lead = i * ((2d * Math.PI)/game.GetTeamList().size());
double sizeMod = 32;
double oX = -Math.sin(lead) * sizeMod;
double oZ = Math.cos(lead) * sizeMod;
//Location
Location entLoc = spawn.clone().add(oX, 0, oZ);
entLoc.setY(_teamDisplay.getY());
//Blocks
SetKitTeamBlocks(entLoc.clone(), 35, team.GetColorData(), _teamBlocks);
entLoc.add(0, 1.5, 0);
entLoc.getChunk().load();
//NPC
Sheep ent = (Sheep)Manager.GetCreature().SpawnEntity(entLoc, EntityType.SHEEP);
ent.setRemoveWhenFarAway(false);
ent.setCustomNameVisible(false);
ent.setColor(DyeColor.getByWoolData(team.GetColorData()));
UtilEnt.Vegetate(ent);
team.SetTeamEntity(ent);
_teams.put(ent, new LobbyEnt(ent, entLoc, team));
}
return;
}
}
//Standard //Standard
if (game.GetKits().length > 1 || game.GetTeamList().size() < 6) if (game.GetKits().length > 1 || game.GetTeamList().size() < 6)

View File

@ -123,7 +123,7 @@ public class GameManager implements Listener
if (game.GetCountdown() != -1) if (game.GetCountdown() != -1)
StateCountdown(game, -1, false); StateCountdown(game, -1, false);
else if (game.AutoStart && Manager.IsGameAutoStart()) else if (Manager.IsGameAutoStart())
{ {
if (UtilServer.getPlayers().length >= Manager.GetPlayerFull()) if (UtilServer.getPlayers().length >= Manager.GetPlayerFull())
StateCountdown(game, 20, false); StateCountdown(game, 20, false);
@ -339,19 +339,20 @@ public class GameManager implements Listener
{ {
color = ChatColor.DARK_GREEN; color = ChatColor.DARK_GREEN;
if (game.GetTeamList().size() == 0) if (game.WorldData.SpawnLocs.size() > 1) color = ChatColor.RED; if (game.GetTeamList().size()%14 == 0) if (game.WorldData.SpawnLocs.size() > 1) color = ChatColor.RED;
if (game.GetTeamList().size() == 1) color = ChatColor.YELLOW; if (game.GetTeamList().size()%14 == 1) color = ChatColor.YELLOW;
if (game.GetTeamList().size() == 2) color = ChatColor.GREEN; if (game.GetTeamList().size()%14 == 2) color = ChatColor.GREEN;
if (game.GetTeamList().size() == 3) color = ChatColor.AQUA; if (game.GetTeamList().size()%14 == 3) color = ChatColor.AQUA;
if (game.GetTeamList().size() == 4) color = ChatColor.GOLD; if (game.GetTeamList().size()%14 == 4) color = ChatColor.GOLD;
if (game.GetTeamList().size() == 5) color = ChatColor.LIGHT_PURPLE; if (game.GetTeamList().size()%14 == 5) color = ChatColor.LIGHT_PURPLE;
if (game.GetTeamList().size() == 6) color = ChatColor.DARK_BLUE; if (game.GetTeamList().size()%14 == 6) color = ChatColor.DARK_BLUE;
if (game.GetTeamList().size() == 7) color = ChatColor.WHITE; if (game.GetTeamList().size()%14 == 7) color = ChatColor.WHITE;
if (game.GetTeamList().size() == 8) color = ChatColor.BLUE; if (game.GetTeamList().size()%14 == 8) color = ChatColor.BLUE;
if (game.GetTeamList().size() == 9) color = ChatColor.DARK_GREEN; if (game.GetTeamList().size()%14 == 9) color = ChatColor.DARK_GREEN;
if (game.GetTeamList().size() == 10) color = ChatColor.DARK_PURPLE; if (game.GetTeamList().size()%14 == 10) color = ChatColor.DARK_PURPLE;
if (game.GetTeamList().size() == 11) color = ChatColor.DARK_GRAY; if (game.GetTeamList().size()%14 == 11) color = ChatColor.GRAY;
if (game.GetTeamList().size() == 12) color = ChatColor.DARK_RED; if (game.GetTeamList().size()%14 == 12) color = ChatColor.DARK_RED;
if (game.GetTeamList().size()%14 == 13) color = ChatColor.DARK_AQUA;
} }
GameTeam newTeam = new GameTeam(game, team, color, game.WorldData.SpawnLocs.get(team)); GameTeam newTeam = new GameTeam(game, team, color, game.WorldData.SpawnLocs.get(team));

View File

@ -46,9 +46,6 @@ public class IdleManager implements Listener
if (Manager.GetGame() == null) if (Manager.GetGame() == null)
return; return;
if (Manager.GetGame() != null && !Manager.GetGame().IdleKick)
return;
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
if (!_yaw.containsKey(player) || !_idle.containsKey(player)) if (!_yaw.containsKey(player) || !_idle.containsKey(player))

View File

@ -53,7 +53,7 @@ public class TheLongestShotStatTracker extends StatTracker<Game>
{ {
Arrow arrow = (Arrow) edbee.getDamager(); Arrow arrow = (Arrow) edbee.getDamager();
if (arrow.getShooter() == killer && killer.getLocation().distanceSquared(player.getLocation()) <= 64 * 64) if (arrow.getShooter() == killer && killer.getLocation().distanceSquared(player.getLocation()) >= 64 * 64)
addStat(killer, "TheLongestShot", 1, false, false); addStat(killer, "TheLongestShot", 1, false, false);
} }
} }

View File

@ -22,6 +22,9 @@ public class WinWithoutLosingTeammateStatTracker extends StatTracker<TeamGame>
{ {
GameTeam winner = getGame().WinnerTeam; GameTeam winner = getGame().WinnerTeam;
if (winner == null)
return;
if (winner.GetPlayers(false).size() < 4) if (winner.GetPlayers(false).size() < 4)
return; return;

Some files were not shown because too many files have changed in this diff Show More