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

This commit is contained in:
CoderTim 2014-09-07 18:10:31 -04:00
commit 3e5b827a7f
52 changed files with 1089 additions and 1206 deletions

View File

@ -1,4 +1,4 @@
From dab2987baf7b1908affbdda61b2019d4338d2d72 Mon Sep 17 00:00:00 2001
From 52ffc1e292f4a6ead573bdfcd884c800b8c4b1a5 Mon Sep 17 00:00:00 2001
From: Jonathan Williams <jonathan@mineplex.com>
Date: Tue, 2 Sep 2014 21:54:15 -0700
Subject: [PATCH] Mineplex Patches
@ -1834,6 +1834,36 @@ index ea786ae..20ab405 100644
world.addEntity(entity, reason);
return (T) entity.getBukkitEntity();
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 0c4976d..28ab76a 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -49,25 +49,6 @@ public class Main {
+ "*** Any bug reports not running the very latest versions of these softwares will be ignored ***\n\n" );
Enumeration<URL> resources = Main.class.getClassLoader().getResources( "META-INF/MANIFEST.MF" );
- while ( resources.hasMoreElements() )
- {
- Manifest manifest = new Manifest( resources.nextElement().openStream() );
- String ts = manifest.getMainAttributes().getValue( "Timestamp" );
- if ( ts != null )
- {
- Date buildDate = new SimpleDateFormat( "yyyyMMdd-hhmm" ).parse( ts );
-
- Calendar cal = Calendar.getInstance();
- cal.add( Calendar.DAY_OF_YEAR, -2 );
- if ( buildDate.before(cal.getTime() ) )
- {
- System.err.println( "WARNING: This build is more than 2 days old and there are likely updates available!" );
- System.err.println( "You will get no support with this build unless you update from http://ci.md-5.net/job/Spigot/" );
- System.err.println( "The server will start in 10 seconds!" );
- Thread.sleep( TimeUnit.SECONDS.toMillis( 10 ) );
- }
- }
- }
// Spigot End
// Todo: Installation script
OptionParser parser = new OptionParser() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 35f2bfa..8a6ca55 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java

View File

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

Binary file not shown.

View File

@ -1,4 +1,4 @@
package mineplex.core.disguise.disguises;
package mineplex.core.common;
import net.minecraft.server.v1_7_R4.Entity;
import net.minecraft.server.v1_7_R4.NBTTagCompound;

View File

@ -3,6 +3,7 @@ package mineplex.core.common.util;
import java.lang.reflect.Field;
import java.util.HashMap;
import mineplex.core.common.DummyEntity;
import net.minecraft.server.v1_7_R4.DataWatcher;
import net.minecraft.server.v1_7_R4.EntityPlayer;
import net.minecraft.server.v1_7_R4.MathHelper;
@ -12,6 +13,8 @@ import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -20,7 +23,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class UtilDisplay
{
public static final int ENTITY_ID = 1234;
public static final int ENTITY_ID = 777777;
private static HashMap<String, Boolean> hasHealthBar = new HashMap<String, Boolean>();
@ -35,9 +38,9 @@ public class UtilDisplay
PacketPlayOutSpawnEntityLiving mobPacket = new PacketPlayOutSpawnEntityLiving();
mobPacket.a = (int) ENTITY_ID; //Entity ID
mobPacket.b = (byte) EntityType.ENDER_DRAGON.getTypeId(); //Mob type (ID: 64)
mobPacket.b = (byte) EntityType.WITHER.getTypeId(); //Mob type (ID: 64)
mobPacket.c = (int) Math.floor(loc.getBlockX() * 32.0D); //X position
mobPacket.d = (int) MathHelper.floor(-200 * 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.f = (byte) 0; //Pitch
mobPacket.g = (byte) 0; //Head Pitch
@ -46,7 +49,7 @@ public class UtilDisplay
mobPacket.j = (short) 0; //Y velocity
mobPacket.k = (short) 0; //Z velocity
DataWatcher watcher = getWatcher(text, healthPercent * 200);
DataWatcher watcher = getWatcher(text, 101 + healthPercent * 99, loc.getWorld());
mobPacket.l = watcher;
@ -76,14 +79,24 @@ public class UtilDisplay
return metaPacket;
}
public static DataWatcher getWatcher(String text, double health){
DataWatcher watcher = new DataWatcher(null);
public static DataWatcher getWatcher(String text, double health, World world)
{
DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld)world).getHandle()));
watcher.a(0, (Byte) (byte) 32); //Flags, 0x20 = invisible
health = Math.max(151, health);
watcher.a(0, (Byte) (byte) 0); //Flags, 0x20 = invisible
watcher.a(6, (Float) (float) health);
watcher.a(2, (String) text); //Entity name
watcher.a(10, (String) text); //Entity name
watcher.a(11, (Byte) (byte) 1); //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(16, (Integer) (int) health); //Wither health, 200 = full health
watcher.a(20, (Integer) (int) 0); //Wither invuln, 200 = full health
int i1 = watcher.getInt(0);
watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5)));
watcher.watch(20, 0);
return watcher;
}
@ -91,7 +104,11 @@ public class UtilDisplay
//Other methods
public static void displayTextBar(JavaPlugin plugin, final Player player, double healthPercent, String text)
{
PacketPlayOutSpawnEntityLiving mobPacket = getMobPacket(text, healthPercent, player.getLocation());
PacketPlayOutEntityDestroy destroyEntityPacket = getDestroyEntityPacket();
sendPacket(player, destroyEntityPacket);
PacketPlayOutSpawnEntityLiving mobPacket = getMobPacket(text, healthPercent, player.getEyeLocation().getDirection().multiply(24).toLocation(player.getWorld()).add(player.getLocation()));
sendPacket(player, mobPacket);
hasHealthBar.put(player.getName(), true);
@ -108,18 +125,21 @@ public class UtilDisplay
}
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){
PacketPlayOutSpawnEntityLiving mobPacket = getMobPacket(text, 0, player.getLocation());
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 ? 0 : 200);
int health = (loadUp ? 150 : 300);
@Override
@Override
public void run(){
if((loadUp ? health < 200 : health > 0)){
DataWatcher watcher = getWatcher(text, health);
if((loadUp ? health < 300 : health > 150)){
DataWatcher watcher = getWatcher(text, health, player.getWorld());
PacketPlayOutEntityMetadata metaPacket = getMetadataPacket(watcher);
sendPacket(player, metaPacket);
@ -130,7 +150,7 @@ public class UtilDisplay
health -= healthAdd;
}
} else {
DataWatcher watcher = getWatcher(text, (loadUp ? 200 : 0));
DataWatcher watcher = getWatcher(text, (loadUp ? 300 : 150), player.getWorld());
PacketPlayOutEntityMetadata metaPacket = getMetadataPacket(watcher);
PacketPlayOutEntityDestroy destroyEntityPacket = getDestroyEntityPacket();
@ -139,12 +159,12 @@ public class UtilDisplay
hasHealthBar.put(player.getName(), false);
//Complete text
PacketPlayOutSpawnEntityLiving mobPacket = getMobPacket(completeText, 100, player.getLocation());
PacketPlayOutSpawnEntityLiving mobPacket = getMobPacket(completeText, 150, player.getLocation());
sendPacket(player, mobPacket);
hasHealthBar.put(player.getName(), true);
DataWatcher watcher2 = getWatcher(completeText, 200);
DataWatcher watcher2 = getWatcher(completeText, 300, player.getWorld());
PacketPlayOutEntityMetadata metaPacket2 = getMetadataPacket(watcher2);
sendPacket(player, metaPacket2);
@ -166,7 +186,7 @@ public class UtilDisplay
}
public static void displayLoadingBar(final String text, final String completeText, final Player player, final int secondsDelay, final boolean loadUp, JavaPlugin plugin){
final int healthChangePerSecond = 200 / secondsDelay;
final int healthChangePerSecond = 150 / secondsDelay;
displayLoadingBar(text, completeText, player, healthChangePerSecond, 20L, loadUp, plugin);
}

View File

@ -10,6 +10,7 @@ import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
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.Player;
@ -396,6 +397,11 @@ public class UtilPlayer
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)

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 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 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"/>
</classpath>

View File

@ -0,0 +1,312 @@
package mineplex.core;
import java.lang.reflect.Field;
import java.util.List;
import mineplex.core.common.DummyEntity;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.packethandler.PlayerPacketEvent;
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.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.WatchableObject;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.plugin.java.JavaPlugin;
public class CustomTagFix extends MiniPlugin
{
private static int _fakeIdCounter = 455000;
private NautHashMap<Integer, Integer> _entityMap = new NautHashMap<Integer, Integer>();
private Field _destroyId;
public CustomTagFix(JavaPlugin plugin)
{
super("Custom Tag Fix", plugin);
try
{
_destroyId = PacketPlayOutEntityDestroy.class.getDeclaredField("a");
_destroyId.setAccessible(true);
}
catch (Exception exception)
{
System.out.println("Field exception in CustomTagFix : ");
exception.printStackTrace();
}
}
@SuppressWarnings("unchecked")
@EventHandler(priority = EventPriority.HIGHEST)
public void handlePackets(PlayerPacketEvent event)
{
Packet packet = event.getPacket();
Player owner = event.getPlayer();
PacketVerifier verifier = event.getVerifier();
if (UtilPlayer.is1_8(event.getPlayer()))
{
if (packet instanceof PacketPlayOutSpawnEntityLiving)
{
PacketPlayOutSpawnEntityLiving spawnPacket = (PacketPlayOutSpawnEntityLiving)packet;
final String entityName = spawnPacket.l.getString(10);
if (spawnPacket.l.getByte(11) == 1 || spawnPacket.l.getByte(3) == 1)
{
int newId = _fakeIdCounter++;
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier);
_entityMap.put(spawnPacket.a, newId);
}
}
else if (packet instanceof PacketPlayOutEntityMetadata)
{
PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata)packet;
if (!_entityMap.containsKey(metaPacket.a) && metaPacket.a != 777777)
{
String entityName = "";
for (WatchableObject watchable : (List<WatchableObject>)metaPacket.b)
{
if ((watchable.a() == 10 || watchable.a() == 2) && watchable.b() instanceof String)
{
entityName = (String)watchable.b();
}
}
if (!entityName.isEmpty())
{
int newId = _fakeIdCounter++;
sendProtocolPackets(owner, metaPacket.a, newId, entityName, verifier);
_entityMap.put(metaPacket.a, newId);
}
}
}
else if (packet instanceof PacketPlayOutEntityDestroy)
{
try
{
for (int id : (int[])_destroyId.get(packet))
{
if (_entityMap.containsKey(id))
{
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(id)));
_entityMap.remove(id);
}
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
else if (packet instanceof PacketPlayOutAttachEntity)
{
PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity)packet;
if (attachPacket.c == owner.getEntityId())
{
event.setCancelled(true);
//verifier.bypassProcess(new PacketPlayOutEntityDestroy(attachPacket.b));
/*
System.out.println("Adding patch item.");
PacketPlayOutSpawnEntityLiving armorPacket = new PacketPlayOutSpawnEntityLiving();
armorPacket.a = _fakeIdCounter++;
armorPacket.b = (byte) EntityType.SLIME.getTypeId();
armorPacket.c = (int)EnumEntitySize.SIZE_2.a(100);
armorPacket.d = (int)MathHelper.floor(64 * 32.0D);
armorPacket.e = (int)EnumEntitySize.SIZE_2.a(100);
armorPacket.i = (byte) ((int) (0 * 256.0F / 360.0F));
armorPacket.j = (byte) ((int) (0 * 256.0F / 360.0F));
armorPacket.k = (byte) ((int) (0 * 256.0F / 360.0F));
double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
if (var4 < -var2)
{
var4 = -var2;
}
if (var6 < -var2)
{
var6 = -var2;
}
if (var8 < -var2)
{
var8 = -var2;
}
if (var4 > var2)
{
var4 = var2;
}
if (var6 > var2)
{
var6 = var2;
}
if (var8 > var2)
{
var8 = var2;
}
armorPacket.f = (int)(var4 * 8000.0D);
armorPacket.g = (int)(var6 * 8000.0D);
armorPacket.h = (int)(var8 * 8000.0D);
final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld)owner.getWorld()).getHandle()));
watcher.a(0, Byte.valueOf((byte)0));
watcher.a(1, Short.valueOf((short)300));
watcher.a(2, "");
watcher.a(3, Byte.valueOf((byte) 0));
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
byte b1 = watcher.getByte(10);
b1 = (byte)(b1 | 0x1);
watcher.watch(10, Byte.valueOf(b1));
armorPacket.l = watcher;
verifier.bypassProcess(packet);
attachPacket.c = armorPacket.a;
PacketPlayOutAttachEntity attachPacket2 = new PacketPlayOutAttachEntity();
attachPacket2.c = owner.getEntityId();
attachPacket2.b = attachPacket.a;
attachPacket2.a = 0;
verifier.bypassProcess(packet);
*/
}
}
}
}
private void sendProtocolPackets(final Player owner, final int entityId, final int newEntityId, final String entityName, final PacketVerifier packetList)
{
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
{
public void run()
{
final PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = newEntityId;
packet.b = (byte) 30;
packet.c = (int)EnumEntitySize.SIZE_2.a(100);
packet.d = (int)MathHelper.floor(64 * 32.0D);
packet.e = (int)EnumEntitySize.SIZE_2.a(100);
packet.i = (byte) ((int) (0 * 256.0F / 360.0F));
packet.j = (byte) ((int) (0 * 256.0F / 360.0F));
packet.k = (byte) ((int) (0 * 256.0F / 360.0F));
double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
if (var4 < -var2)
{
var4 = -var2;
}
if (var6 < -var2)
{
var6 = -var2;
}
if (var8 < -var2)
{
var8 = -var2;
}
if (var4 > var2)
{
var4 = var2;
}
if (var6 > var2)
{
var6 = var2;
}
if (var8 > var2)
{
var8 = var2;
}
packet.f = (int)(var4 * 8000.0D);
packet.g = (int)(var6 * 8000.0D);
packet.h = (int)(var8 * 8000.0D);
final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld)owner.getWorld()).getHandle()));
watcher.a(0, Byte.valueOf((byte)0));
watcher.a(1, Short.valueOf((short)300));
watcher.a(2, "");
watcher.a(3, Byte.valueOf((byte) 0));
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
byte b1 = watcher.getByte(10);
b1 = (byte)(b1 | 0x1);
watcher.watch(10, Byte.valueOf(b1));
watcher.watch(2, entityName);
watcher.watch(3, Byte.valueOf((byte)1));
packet.l = watcher;
packetList.bypassProcess(packet);
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = packet.a;
vehiclePacket.c = entityId;
packetList.bypassProcess(vehiclePacket);
}
});
}
}

View File

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

View File

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

View File

@ -16,6 +16,7 @@ import mineplex.core.cosmetic.ui.button.ActivateGadgetButton;
import mineplex.core.cosmetic.ui.button.DeactivateGadgetButton;
import mineplex.core.cosmetic.ui.button.GadgetButton;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.gadgets.MorphNotch;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.ItemGadget;
@ -62,6 +63,11 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
protected void addGadget(Gadget gadget, int slot)
{
if (gadget instanceof MorphNotch)
{
setItem(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), "Disabled " + gadget.GetName(), new String[] { "Sorry! Currently disabled until fix is made for 1.8 players!" }, 1, false, false));
return;
}
List<String> itemLore = new ArrayList<String>();
if (gadget.GetCost(CurrencyType.Coins) >= 0)

View File

@ -2,7 +2,7 @@ package mineplex.core.disguise;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
@ -34,23 +34,19 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilMath;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseBlock;
import mineplex.core.disguise.disguises.DisguiseInsentient;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.packethandler.IPacketRunnable;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.packethandler.PlayerPacketEvent;
import mineplex.core.timing.TimingManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class DisguiseManager extends MiniPlugin implements IPacketRunnable
public class DisguiseManager extends MiniPlugin
{
private NautHashMap<Integer, DisguiseBase> _spawnPacketMap = new NautHashMap<Integer, DisguiseBase>();
private NautHashMap<Integer, PacketPlayOutEntityVelocity> _movePacketMap = new NautHashMap<Integer, PacketPlayOutEntityVelocity>();
@ -61,17 +57,17 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
private HashSet<String> _delTempList = new HashSet<String>();
private NautHashMap<DisguiseBase, HashSet<Player>> _disguisePlayerMap = new NautHashMap<DisguiseBase, HashSet<Player>>();
private boolean _handlingPacket = false;
private Field _attributesA;
private Field _soundB;
private Field _soundC;
private Field _soundD;
public DisguiseManager(JavaPlugin plugin, PacketHandler packetHandler)
public DisguiseManager(JavaPlugin plugin)
{
super("Disguise Manager", plugin);
packetHandler.AddPacketRunnable(this);
try
{
_attributesA = PacketPlayOutUpdateAttributes.class.getDeclaredField("a");
@ -136,15 +132,14 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
{
if (!disguise.GetEntity().isAlive())
return;
if (players == null || players.length == 0)
if (players != null && players.length != 0)
{
players = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]);
disguise.Global = false;
}
_spawnPacketMap.put(disguise.GetEntityId(), disguise);
_disguisePlayerMap.put(disguise, new HashSet<Player>());
_disguisePlayerMap.get(disguise).addAll(Arrays.asList(players));
reApplyDisguise(disguise);
}
@ -158,7 +153,9 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
_movePacketMap.remove(entity.getEntityId());
_moveTempMap.remove(entity.getEntityId());
for (Player player : _disguisePlayerMap.get(disguise))
Collection<? extends Player> players = (disguise.Global ? Bukkit.getOnlinePlayers() : _disguisePlayerMap.get(disguise));
for (Player player : players)
{
if (entity == player)
continue;
@ -180,9 +177,17 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
public void reApplyDisguise(final DisguiseBase disguise)
{
reApplyDisguise(disguise, 1);
}
public void reApplyDisguise(final DisguiseBase disguise, long reapplyTime)
{
_handlingPacket = true;
PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(disguise.GetEntityId());
for (Player player : _disguisePlayerMap.get(disguise))
Collection<? extends Player> players = (disguise.Global ? Bukkit.getOnlinePlayers() : _disguisePlayerMap.get(disguise));
for (Player player : players)
{
if (disguise.GetEntity() == ((CraftPlayer)player).getHandle())
continue;
@ -191,7 +196,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
entityPlayer.playerConnection.sendPacket(destroyPacket);
}
List<Packet> tempArmor = new ArrayList<Packet>();
if (disguise instanceof DisguiseInsentient && disguise.GetEntity() instanceof LivingEntity)
@ -205,15 +210,18 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
final List<Packet> armorPackets = tempArmor;
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
Bukkit.getServer().getScheduler().runTaskLater(GetPlugin(), new Runnable()
{
public void run()
{
for (Player player : _disguisePlayerMap.get(disguise))
Collection<? extends Player> players = (disguise.Global ? Bukkit.getOnlinePlayers() : _disguisePlayerMap.get(disguise));
_handlingPacket = true;
for (Player player : players)
{
if (disguise.GetEntity() == ((CraftPlayer)player).getHandle())
continue;
EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle();
entityPlayer.playerConnection.sendPacket(disguise.GetSpawnPacket());
@ -222,8 +230,11 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
entityPlayer.playerConnection.sendPacket(packet);
}
}
_handlingPacket = false;
}
});
}, reapplyTime);
_handlingPacket = false;
}
public void reApplyDisguise(final DisguiseBase disguise, final Player player)
@ -267,7 +278,9 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
public void updateDisguise(DisguiseBase disguise)
{
for (Player player : _disguisePlayerMap.get(disguise))
Collection<? extends Player> players = (disguise.Global ? Bukkit.getOnlinePlayers() : _disguisePlayerMap.get(disguise));
for (Player player : players)
{
if (disguise.GetEntity() == ((CraftPlayer)player).getHandle())
continue;
@ -347,27 +360,34 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
}
}
@Override
public boolean run(final Packet packet, Player owner, final PacketVerifier packetList)
@EventHandler
public void handlePackets(PlayerPacketEvent event)
{
if (_handlingPacket)
return;
final Packet packet = event.getPacket();
Player owner = event.getPlayer();
final PacketVerifier packetVerifier = event.getVerifier();
if (packet instanceof PacketPlayOutNamedEntitySpawn)
{
int entityId = ((PacketPlayOutNamedEntitySpawn)packet).a;
if (_spawnPacketMap.containsKey(entityId) && _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner))
if (_spawnPacketMap.containsKey(entityId) && (_spawnPacketMap.get(entityId).Global || _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner)))
{
packetList.forceProcess(_spawnPacketMap.get(entityId).GetSpawnPacket());
return false;
handlePacket(_spawnPacketMap.get(entityId).GetSpawnPacket(), packetVerifier);
event.setCancelled(true);
}
}
else if (packet instanceof PacketPlayOutSpawnEntity)
{
int entityId = ((PacketPlayOutSpawnEntity)packet).a;
if (_spawnPacketMap.containsKey(entityId) && _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner))
if (_spawnPacketMap.containsKey(entityId) && (_spawnPacketMap.get(entityId).Global || _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner)))
{
packetList.forceProcess(_spawnPacketMap.get(entityId).GetSpawnPacket());
return false;
handlePacket(_spawnPacketMap.get(entityId).GetSpawnPacket(), packetVerifier);
event.setCancelled(true);
}
}
else if (packet instanceof PacketPlayOutUpdateAttributes)
@ -387,11 +407,11 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
e.printStackTrace();
}
if (_spawnPacketMap.containsKey(entityId) && owner.getEntityId() != entityId && _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner))
if (_spawnPacketMap.containsKey(entityId) && owner.getEntityId() != entityId && (_spawnPacketMap.get(entityId).Global || _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner)))
{
// Crash clients with meta to a block id.
if (_spawnPacketMap.get(entityId) instanceof DisguiseBlock)
return false;
event.setCancelled(true);
}
}
else if (packet instanceof PacketPlayOutAnimation)
@ -400,7 +420,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
if (containsSpawnDisguise(owner, entityId) && owner.getEntityId() != entityId)
{
return false;
event.setCancelled(true);
}
}
else if (packet instanceof PacketPlayOutEntityMetadata)
@ -409,8 +429,8 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
if (containsSpawnDisguise(owner, entityId) && owner.getEntityId() != entityId)
{
packetList.forceProcess(_spawnPacketMap.get(entityId).GetMetaDataPacket());
return false;
handlePacket(_spawnPacketMap.get(entityId).GetMetaDataPacket(), packetVerifier);
event.setCancelled(true);
}
}
else if (packet instanceof PacketPlayOutEntityEquipment)
@ -421,7 +441,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
{
if (!((DisguiseInsentient)_spawnPacketMap.get(entityId)).armorVisible() && ((PacketPlayOutEntityEquipment)packet).b != 0)
{
return false;
event.setCancelled(true);
}
}
}
@ -437,11 +457,11 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
}
else if (velocityPacket.b == 0 && velocityPacket.c == 0 && velocityPacket.d == 0)
{
return true;
return;
}
else if (_spawnPacketMap.containsKey(velocityPacket.a))
{
return false;
event.setCancelled(true);
}
}
else if (packet instanceof PacketPlayOutRelEntityMove)
@ -450,7 +470,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
// Only for viewers
if (movePacket.a == owner.getEntityId())
return true;
return;
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c < 20)
{
@ -459,7 +479,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
}
if (!containsSpawnDisguise(owner, movePacket.a))
return true;
return;
final PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity();
velocityPacket.a = movePacket.a;
@ -478,7 +498,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
_movePacketMap.put(movePacket.a, velocityPacket);
packetList.forceProcess(velocityPacket);
packetVerifier.bypassProcess(velocityPacket);
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c > 20)
{
@ -486,7 +506,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
{
public void run()
{
packetList.forceProcess(velocityPacket);
packetVerifier.bypassProcess(velocityPacket);
}
});
}
@ -502,7 +522,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
// Only for viewers
if (movePacket.a == owner.getEntityId())
return true;
return;
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c <= 20)
{
@ -511,7 +531,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
}
if (!containsSpawnDisguise(owner, movePacket.a))
return true;
return;
final PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity();
velocityPacket.a = movePacket.a;
@ -530,7 +550,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
_movePacketMap.put(movePacket.a, velocityPacket);
packetList.forceProcess(velocityPacket);
packetVerifier.bypassProcess(velocityPacket);
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c > 20)
{
@ -538,7 +558,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
{
public void run()
{
packetList.forceProcess(velocityPacket);
packetVerifier.bypassProcess(velocityPacket);
}
});
}
@ -569,13 +589,18 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
}
}
*/
return true;
}
private void handlePacket(Packet packet, PacketVerifier verifier)
{
_handlingPacket = true;
verifier.process(packet);
_handlingPacket = false;
}
private boolean containsSpawnDisguise(Player owner, int entityId)
{
return _spawnPacketMap.containsKey(entityId) && (_disguisePlayerMap.containsKey(_spawnPacketMap.get(entityId)) && _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner));
return _spawnPacketMap.containsKey(entityId) && (_spawnPacketMap.get(entityId).Global || (_disguisePlayerMap.containsKey(_spawnPacketMap.get(entityId)) && _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner)));
}
public void PrepAddDisguise(Player caller, EntityType entityType)

View File

@ -1,6 +1,7 @@
package mineplex.core.disguise.disguises;
import mineplex.core.common.*;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
@ -9,6 +10,7 @@ import net.minecraft.server.v1_7_R4.DataWatcher;
import net.minecraft.server.v1_7_R4.Entity;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import org.bukkit.entity.*;
public abstract class DisguiseBase
@ -18,6 +20,8 @@ public abstract class DisguiseBase
private DisguiseBase _soundDisguise;
public boolean Global = true;
public DisguiseBase(org.bukkit.entity.Entity entity)
{
Entity = ((CraftEntity)entity).getHandle();

View File

@ -42,7 +42,7 @@ public class DisguiseBlock extends DisguiseBase
packet.h = MathHelper.d(Entity.pitch * 256.0F / 360.0F);
packet.i = MathHelper.d(Entity.yaw * 256.0F / 360.0F);
packet.j = 70;
packet.k = _blockId | _blockData << 16;
packet.k = _blockId | _blockData << 12;
double d1 = Entity.motX;
double d2 = Entity.motY;

View File

@ -1,12 +1,15 @@
package mineplex.core.disguise.disguises;
import org.spigotmc.ProtocolData;
public abstract class DisguiseHuman extends DisguiseLiving
{
public DisguiseHuman(org.bukkit.entity.Entity entity)
{
super(entity);
DataWatcher.a(16, Byte.valueOf((byte)0));
DataWatcher.a(10, new ProtocolData.HiddenByte( (byte) 0 ) ); // Spigot - protocol patch, handle new metadata value
DataWatcher.a(16, new ProtocolData.DualByte( (byte) 0, (byte) 0 ) );
DataWatcher.a(17, Float.valueOf(0.0F));
DataWatcher.a(18, Integer.valueOf(0));
}

View File

@ -1,5 +1,7 @@
package mineplex.core.disguise.disguises;
import org.spigotmc.ProtocolData;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn;

View File

@ -1,315 +0,0 @@
package mineplex.core.fakeEntity;
import java.lang.reflect.Field;
import net.minecraft.server.v1_7_R4.BlockCloth;
import net.minecraft.server.v1_7_R4.DataWatcher;
import net.minecraft.server.v1_7_R4.Entity;
import net.minecraft.server.v1_7_R4.EntityLiving;
import net.minecraft.server.v1_7_R4.EntitySlime;
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.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.entity.EntityType;
public class FakeEntity
{
private static int _entityIdCounter = 50000;
private int _entityId;
private Location _location;
private EntityType _entityType;
private static Field _spawnDataWatcherField;
private static Field _spawnListField;
public FakeEntity(EntityType entityType, Location location)
{
_entityId = _entityIdCounter++;
_entityType = entityType;
_location = location;
SetSpawnDataWatcherField();
SetSpawnListField();
}
public int GetEntityId()
{
return _entityId;
}
public EntityType GetEntityType()
{
return _entityType;
}
public void SetLocation(Location location)
{
_location = location;
}
public Location GetLocation()
{
return _location;
}
public Packet Spawn()
{
return Spawn(_entityId);
}
public Packet Destroy()
{
return new PacketPlayOutEntityDestroy(new int[] { GetEntityId() });
}
public Packet Spawn(int id)
{
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = id;
packet.b = (byte) _entityType.getTypeId();
packet.c = (int)EnumEntitySize.SIZE_2.a(_location.getX());
packet.d = (int)MathHelper.floor(_location.getY() * 32.0D);
packet.e = (int)EnumEntitySize.SIZE_2.a(_location.getZ());
packet.i = (byte) ((int) (_location.getYaw() * 256.0F / 360.0F));
packet.j = (byte) ((int) (_location.getPitch() * 256.0F / 360.0F));
packet.k = (byte) ((int) (_location.getYaw() * 256.0F / 360.0F));
double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
if (var4 < -var2)
{
var4 = -var2;
}
if (var6 < -var2)
{
var6 = -var2;
}
if (var8 < -var2)
{
var8 = -var2;
}
if (var4 > var2)
{
var4 = var2;
}
if (var6 > var2)
{
var6 = var2;
}
if (var8 > var2)
{
var8 = var2;
}
packet.f = (int)(var4 * 8000.0D);
packet.g = (int)(var6 * 8000.0D);
packet.h = (int)(var8 * 8000.0D);
DataWatcher dataWatcher = new DataWatcher(new EntitySlime(((CraftWorld)Bukkit.getWorlds().get(0)).getHandle()));
UpdateDataWatcher(dataWatcher);
try
{
_spawnDataWatcherField.set(packet, dataWatcher);
}
catch (IllegalArgumentException e)
{
e.printStackTrace();
}
catch (IllegalAccessException e)
{
e.printStackTrace();
}
try
{
_spawnListField.set(packet, dataWatcher.b());
}
catch (IllegalArgumentException e)
{
e.printStackTrace();
}
catch (IllegalAccessException e)
{
e.printStackTrace();
}
return packet;
}
public Packet Hide()
{
return Hide(_entityId);
}
public Packet Hide(int entityId)
{
DataWatcher dataWatcher = new DataWatcher(new EntitySlime(((CraftWorld)Bukkit.getWorlds().get(0)).getHandle()));
UpdateDataWatcher(dataWatcher);
dataWatcher.watch(0, Byte.valueOf((byte) 32));
return new PacketPlayOutEntityMetadata(entityId, dataWatcher, false);
}
public Packet Show()
{
DataWatcher dataWatcher = new DataWatcher(new EntitySlime(((CraftWorld)Bukkit.getWorlds().get(0)).getHandle()));
UpdateDataWatcher(dataWatcher);
return new PacketPlayOutEntityMetadata(_entityId, dataWatcher, true);
}
public Packet SetVehicle(int vehicleId)
{
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = _entityId;
vehiclePacket.c = vehicleId;
return vehiclePacket;
}
public Packet SetPassenger(int passengerId)
{
return SetPassenger(passengerId, _entityId);
}
public Packet SetPassenger(int passengerId, int entityId)
{
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = passengerId;
vehiclePacket.c = entityId;
return vehiclePacket;
}
protected void UpdateDataWatcher(DataWatcher dataWatcher)
{
dataWatcher.a(0, Byte.valueOf((byte) 0));
dataWatcher.a(1, Short.valueOf((short)300));
dataWatcher.a(6, Float.valueOf(4.0F));
dataWatcher.a(7, Integer.valueOf(0));
dataWatcher.a(8, Byte.valueOf((byte)0));
dataWatcher.a(9, Byte.valueOf((byte) 0));
dataWatcher.a(10, " ");
dataWatcher.a(11, Byte.valueOf((byte)0));
switch (_entityType)
{
case BAT:
case BLAZE:
case PIG:
case SHEEP:
case IRON_GOLEM:
case GHAST:
dataWatcher.a(16, new Byte((byte) 0));
break;
case CREEPER:
dataWatcher.a(16, Byte.valueOf((byte) -1));
dataWatcher.a(17, Byte.valueOf((byte) 0));
break;
case ENDERMAN:
dataWatcher.a(16, new Byte((byte) 0));
dataWatcher.a(17, new Byte((byte) 0));
dataWatcher.a(18, new Byte((byte) 0));
break;
case PLAYER:
dataWatcher.a(16, Byte.valueOf((byte) 0));
dataWatcher.a(17, Byte.valueOf((byte) 0));
break;
case OCELOT:
case SPIDER:
dataWatcher.a(16, new Byte((byte) 0));
break;
case WOLF:
dataWatcher.a(18, new Integer(20));
dataWatcher.a(19, new Byte((byte) 0));
dataWatcher.a(20, new Byte((byte) BlockCloth.b(1)));
case SKELETON:
dataWatcher.a(13, new Byte((byte) 0));
break;
case SLIME:
dataWatcher.a(16, new Byte((byte) 1));
break;
case WITCH:
dataWatcher.a(21, Byte.valueOf((byte) 0));
break;
case WITHER:
dataWatcher.a(16, new Integer(100));
dataWatcher.a(17, new Integer(0));
dataWatcher.a(18, new Integer(0));
dataWatcher.a(19, new Integer(0));
dataWatcher.a(20, new Integer(0));
break;
case ZOMBIE:
dataWatcher.a(13, Byte.valueOf((byte) 0));
dataWatcher.a(14, Byte.valueOf((byte) 0));
break;
default:
break;
}
}
private void SetSpawnListField()
{
if (_spawnListField == null)
{
try
{
_spawnListField = PacketPlayOutSpawnEntityLiving.class.getDeclaredField("m");
_spawnListField.setAccessible(true);
}
catch (NoSuchFieldException e)
{
e.printStackTrace();
}
catch (SecurityException e)
{
e.printStackTrace();
}
}
}
private void SetSpawnDataWatcherField()
{
if (_spawnDataWatcherField == null)
{
try
{
_spawnDataWatcherField = PacketPlayOutSpawnEntityLiving.class.getDeclaredField("l");
_spawnDataWatcherField.setAccessible(true);
}
catch (NoSuchFieldException e)
{
e.printStackTrace();
}
catch (SecurityException e)
{
e.printStackTrace();
}
}
}
}

View File

@ -1,115 +0,0 @@
package mineplex.core.fakeEntity;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.server.v1_7_R4.Packet;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.packethandler.PacketHandler;
public class FakeEntityManager extends MiniPlugin
{
public static FakeEntityManager Instance;
private PacketHandler _packetHandler;
private NautHashMap<String, List<FakeEntity>> _playerFakeEntityMap;
public FakeEntityManager(JavaPlugin plugin)
{
super("Fake Entity Manager", plugin);
_playerFakeEntityMap = new NautHashMap<String, List<FakeEntity>>();
}
public static void Initialize(JavaPlugin plugin)
{
Instance = new FakeEntityManager(plugin);
}
public void AddFakeEntity(FakeEntity entity, String name)
{
if (!_playerFakeEntityMap.containsKey(name))
{
_playerFakeEntityMap.put(name, new ArrayList<FakeEntity>());
}
_playerFakeEntityMap.get(name).add(entity);
}
public void ClearFakes(String name)
{
_playerFakeEntityMap.remove(name);
}
public void ClearFakeFor(FakeEntity entity, String name)
{
if (!_playerFakeEntityMap.containsKey(name))
{
_playerFakeEntityMap.put(name, new ArrayList<FakeEntity>());
}
_playerFakeEntityMap.get(name).remove(entity);
}
public List<FakeEntity> GetFakesFor(String name)
{
if (!_playerFakeEntityMap.containsKey(name))
{
_playerFakeEntityMap.put(name, new ArrayList<FakeEntity>());
}
return _playerFakeEntityMap.get(name);
}
public void SetPacketHandler(PacketHandler packetHandler)
{
_packetHandler = packetHandler;
}
public void RemoveForward(Player viewer)
{
_packetHandler.RemoveForward(viewer);
}
public void ForwardMovement(Player viewer, Player traveller, int entityId)
{
_packetHandler.ForwardMovement(viewer, traveller.getEntityId(), entityId);
}
public void BlockMovement(Player otherPlayer, int entityId)
{
_packetHandler.BlockMovement(otherPlayer, entityId);
}
public void FakePassenger(Player viewer, int entityId, Packet attachPacket)
{
_packetHandler.FakePassenger(viewer, entityId, attachPacket);
}
public void RemoveFakePassenger(Player viewer, int entityId)
{
_packetHandler.RemoveFakePassenger(viewer, entityId);
}
public void FakeVehicle(Player viewer, int entityId, Packet attachPacket)
{
_packetHandler.FakeVehicle(viewer, entityId, attachPacket);
}
public void RemoveFakeVehicle(Player viewer, int entityId)
{
_packetHandler.RemoveFakeVehicle(viewer, entityId);
}
public void SendPacketTo(Packet packet, Player player)
{
((CraftPlayer)player).getHandle().playerConnection.sendPacket(packet);
}
}

View File

@ -1,79 +0,0 @@
package mineplex.core.fakeEntity;
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.PacketPlayOutSpawnEntity;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
public class FakeFallingBlock extends FakeEntity
{
private int _materialId;
private byte _data;
public FakeFallingBlock(int materialId, byte data, Location location)
{
super(EntityType.FALLING_BLOCK, location);
_materialId = materialId;
_data = data;
}
public Packet Spawn(int id)
{
PacketPlayOutSpawnEntity packet = new PacketPlayOutSpawnEntity();
packet.a = id;
packet.b = (int)EnumEntitySize.SIZE_2.a(GetLocation().getX());
packet.c = (int)MathHelper.floor(GetLocation().getY() * 32.0D);
packet.d = (int)EnumEntitySize.SIZE_2.a(GetLocation().getZ());
double var4 = 0;
double var6 = .045;
double var8 = 0;
double var10 = 3.9D;
if (var4 < -var10)
{
var4 = -var10;
}
if (var6 < -var10)
{
var6 = -var10;
}
if (var8 < -var10)
{
var8 = -var10;
}
if (var4 > var10)
{
var4 = var10;
}
if (var6 > var10)
{
var6 = var10;
}
if (var8 > var10)
{
var8 = var10;
}
packet.e = (int)(var4 * 8000.0D);
packet.f = (int)(var6 * 8000.0D);
packet.g = (int)(var8 * 8000.0D);
packet.h = 0;
packet.i = 0;
packet.j = 70;
packet.k = _materialId | _data << 16;
System.out.println("Creating fake falling block with entityId " + GetEntityId());
return packet;
}
}

View File

@ -1,85 +0,0 @@
package mineplex.core.fakeEntity;
import net.minecraft.server.v1_7_R4.DataWatcher;
import net.minecraft.server.v1_7_R4.ItemStack;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
import org.bukkit.entity.EntityType;
public class FakeItemDrop extends FakeEntity
{
private ItemStack _itemStack;
public FakeItemDrop(org.bukkit.inventory.ItemStack itemStack, Location location)
{
super(EntityType.DROPPED_ITEM, location);
_itemStack = CraftItemStack.asNMSCopy(itemStack);
}
public Packet Spawn()
{
PacketPlayOutSpawnEntity packet = new PacketPlayOutSpawnEntity();
packet.a = GetEntityId();
packet.b = MathHelper.floor(GetLocation().getX() * 32.0D);
packet.c = MathHelper.floor(GetLocation().getY() * 32.0D);
packet.d = MathHelper.floor(GetLocation().getZ() * 32.0D);
packet.h = MathHelper.d(GetLocation().getYaw() * 256.0F / 360.0F);
packet.i = MathHelper.d(GetLocation().getPitch() * 256.0F / 360.0F);
packet.j = 2;
packet.k = 1;
double d0 = 0;
double d1 = 0;
double d2 = 0;
double d3 = 3.9D;
if (d0 < -d3) {
d0 = -d3;
}
if (d1 < -d3) {
d1 = -d3;
}
if (d2 < -d3) {
d2 = -d3;
}
if (d0 > d3) {
d0 = d3;
}
if (d1 > d3) {
d1 = d3;
}
if (d2 > d3) {
d2 = d3;
}
packet.e = (int) (d0 * 8000.0D);
packet.f = (int) (d1 * 8000.0D);
packet.g = (int) (d2 * 8000.0D);
return packet;
}
protected void UpdateDataWatcher(DataWatcher dataWatcher)
{
dataWatcher.a(0, Byte.valueOf((byte) 0));
dataWatcher.a(1, Short.valueOf((short)300));
dataWatcher.a(8, Integer.valueOf(0));
dataWatcher.a(9, Byte.valueOf((byte) 0));
dataWatcher.a(10, new net.minecraft.server.v1_7_R4.ItemStack(_itemStack.getItem(), _itemStack.count));
}
public void SetItemStack(org.bukkit.inventory.ItemStack itemStack)
{
_itemStack = CraftItemStack.asNMSCopy(itemStack);
}
}

View File

@ -1,50 +0,0 @@
package mineplex.core.fakeEntity;
import java.lang.reflect.Field;
import java.util.UUID;
import net.minecraft.server.v1_7_R4.DataWatcher;
import net.minecraft.server.v1_7_R4.EntitySlime;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.entity.EntityType;
public class FakePlayer extends FakeEntity
{
private String _name;
private static Field _spawnDataWatcherField;
public FakePlayer(String name, Location location)
{
super(EntityType.PLAYER, location);
_name = name;
}
public Packet Spawn(int id)
{
PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
packet.a = id;
packet.b = new GameProfile(UUID.randomUUID(), _name);
packet.c = MathHelper.floor(GetLocation().getX() * 32.0D);
packet.d = MathHelper.floor(GetLocation().getY() * 32.0D);
packet.e = MathHelper.floor(GetLocation().getZ() * 32.0D);
packet.f = (byte) ((int) (GetLocation().getYaw() * 256.0F / 360.0F));
packet.g = (byte) ((int) (GetLocation().getPitch() * 256.0F / 360.0F));
DataWatcher dataWatcher = new DataWatcher(new EntitySlime(((CraftWorld)Bukkit.getWorlds().get(0)).getHandle()));
UpdateDataWatcher(dataWatcher);
packet.i = dataWatcher;
return packet;
}
}

View File

@ -1,10 +0,0 @@
package mineplex.core.fakeEntity;
public class LeashData
{
public int LeashedID;
public int LeasherID;
public boolean LeashedOn;
public boolean LeasherOn;
}

View File

@ -1,6 +1,5 @@
package mineplex.core.friend;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo;
import org.bukkit.Bukkit;
@ -21,28 +20,24 @@ import mineplex.core.friend.command.DeleteFriend;
import mineplex.core.friend.data.FriendData;
import mineplex.core.friend.data.FriendRepository;
import mineplex.core.friend.ui.FriendTabList;
import mineplex.core.packethandler.IPacketRunnable;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.packethandler.PlayerPacketEvent;
import mineplex.core.timing.TimingManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class FriendManager extends MiniClientPlugin<FriendData> implements IPacketRunnable
public class FriendManager extends MiniClientPlugin<FriendData>
{
private FriendRepository _repository;
private NautHashMap<Player, FriendTabList> _playerTabMap;
private boolean _sendingPackets = false;
public FriendManager(JavaPlugin plugin, PacketHandler packetHandler)
public FriendManager(JavaPlugin plugin)
{
super("Friends", plugin);
_repository = new FriendRepository(plugin);
_playerTabMap = new NautHashMap<Player, FriendTabList>();
packetHandler.AddPacketRunnable(this);
}
@Override
@ -139,15 +134,16 @@ public class FriendManager extends MiniClientPlugin<FriendData> implements IPack
_playerTabMap.remove(event.getPlayer());
}
@Override
public boolean run(Packet packet, Player owner, PacketVerifier packetList)
@EventHandler
public void handleFriendPackets(PlayerPacketEvent event)
{
if (packet instanceof PacketPlayOutPlayerInfo)
{
return _sendingPackets;
}
if (event.isCancelled())
return;
return true;
if (event.getPacket() instanceof PacketPlayOutPlayerInfo)
{
event.setCancelled(_sendingPackets);
}
}
public void addFriend(final Player caller, final String name)

View File

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

View File

@ -1,10 +0,0 @@
package mineplex.core.packethandler;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_7_R4.Packet;
public interface IPacketRunnable
{
boolean run(Packet packet, Player owner, PacketVerifier packetList);
}

View File

@ -1,215 +1,30 @@
package mineplex.core.packethandler;
import java.util.ArrayList;
import java.util.HashSet;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.NautHashMap;
import net.minecraft.server.v1_7_R4.Packet;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
public class PacketHandler extends MiniPlugin
{
private NautHashMap<String, NautHashMap<Integer, Integer>> _forwardMap;
private NautHashMap<String, HashSet<Integer>> _blockMap;
private NautHashMap<String, NautHashMap<Integer, Packet>> _fakeVehicleMap;
private NautHashMap<String, NautHashMap<Integer, Packet>> _fakePassengerMap;
private ArrayList<IPacketRunnable> _packetRunnables;
public PacketHandler(JavaPlugin plugin)
{
super("PacketHandler", plugin);
_forwardMap = new NautHashMap<String, NautHashMap<Integer, Integer>>();
_blockMap = new NautHashMap<String, HashSet<Integer>>();
_fakeVehicleMap = new NautHashMap<String, NautHashMap<Integer, Packet>>();
_fakePassengerMap = new NautHashMap<String, NautHashMap<Integer, Packet>>();
_packetRunnables = new ArrayList<IPacketRunnable>();
}
public String GetDataType(int c)
public PacketHandler(JavaPlugin plugin)
{
switch (c)
{
case 0:
return "Byte";
case 1:
return "Short";
case 2:
return "Integer";
case 3:
return "Float";
case 4:
return "String";
case 5:
return "ItemStack";
case 6:
return "ChunkCoordinates";
}
return "Say what?";
}
public void AddPacketRunnable(IPacketRunnable runnable)
{
_packetRunnables.add(runnable);
}
public void RemovePacketRunnable(IPacketRunnable runnable)
{
_packetRunnables.remove(runnable);
}
public Packet GetFakeAttached(Player owner, int a)
{
return _fakeVehicleMap.get(owner.getName()).get(a);
}
public boolean IsFakeAttached(Player owner, int a)
{
return _fakeVehicleMap.containsKey(owner.getName()) && _fakeVehicleMap.get(owner.getName()).containsKey(a);
}
public Packet GetFakePassenger(Player owner, int a)
{
return _fakePassengerMap.get(owner.getName()).get(a);
}
public boolean IsFakePassenger(Player owner, int a)
{
return _fakePassengerMap.containsKey(owner.getName()) && _fakePassengerMap.get(owner.getName()).containsKey(a);
}
public boolean IsBlocked(Player owner, int a)
{
return _blockMap.containsKey(owner.getName()) && _blockMap.get(owner.getName()).contains(a);
}
public int GetForwardId(Player owner, int a)
{
return _forwardMap.get(owner.getName()).get(a);
}
public boolean IsForwarded(Player owner, int a)
{
return _forwardMap.get(owner.getName()).containsKey(a);
}
public boolean IsForwarding(Player owner)
{
return _forwardMap.containsKey(owner.getName());
super("PacketHandler", plugin);
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event)
{
in(event.getPlayer());
((CraftPlayer) event.getPlayer()).getHandle().playerConnection.PacketVerifier.addPacketVerifier(new PacketVerifier(event.getPlayer()));
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event)
{
out(event.getPlayer());
((CraftPlayer) event.getPlayer()).getHandle().playerConnection.PacketVerifier.clearVerifiers();
}
public void in(Player player)
{
((CraftPlayer) player).getHandle().playerConnection.PacketVerifier.addPacketVerifier(new PacketVerifier(player, this));
}
public void out(Player player)
{
((CraftPlayer) player).getHandle().playerConnection.PacketVerifier.clearVerifiers();
}
public void shutdown()
{
for (final Player player : this._plugin.getServer().getOnlinePlayers())
{
if (player != null)
{
this.out(player);
}
}
}
public void ForwardMovement(Player viewer, int travellerId, int entityId)
{
if (!_forwardMap.containsKey(viewer.getName()))
{
_forwardMap.put(viewer.getName(), new NautHashMap<Integer, Integer>());
}
_forwardMap.get(viewer.getName()).put(travellerId, entityId);
}
public void BlockMovement(Player otherPlayer, int entityId)
{
if (!_blockMap.containsKey(otherPlayer.getName()))
{
_blockMap.put(otherPlayer.getName(), new HashSet<Integer>());
}
_blockMap.get(otherPlayer.getName()).add(entityId);
}
public void FakeVehicle(Player viewer, int entityId, Packet packet)
{
if (!_fakeVehicleMap.containsKey(viewer.getName()))
{
_fakeVehicleMap.put(viewer.getName(), new NautHashMap<Integer, Packet>());
}
_fakeVehicleMap.get(viewer.getName()).put(entityId, packet);
}
public void RemoveFakeVehicle(Player viewer, int entityId)
{
if (_fakeVehicleMap.containsKey(viewer.getName()))
{
_fakeVehicleMap.get(viewer.getName()).remove(entityId);
}
}
public void FakePassenger(Player viewer, int entityId, Packet packet)
{
if (!_fakePassengerMap.containsKey(viewer.getName()))
{
_fakePassengerMap.put(viewer.getName(), new NautHashMap<Integer, Packet>());
}
_fakePassengerMap.get(viewer.getName()).put(entityId, packet);
}
public void RemoveFakePassenger(Player viewer, int entityId)
{
if (_fakePassengerMap.containsKey(viewer.getName()))
{
_fakePassengerMap.get(viewer.getName()).remove(entityId);
}
}
public void RemoveForward(Player viewer)
{
_forwardMap.remove(viewer.getName());
}
public boolean FireRunnables(Packet o, Player owner, PacketVerifier packetList)
{
boolean addOriginal = true;
for (IPacketRunnable packetRunnable : _packetRunnables)
{
if (!packetRunnable.run(o, owner, packetList))
addOriginal = false;
}
return addOriginal;
}
}
}

View File

@ -2,33 +2,62 @@ package mineplex.core.packethandler;
import net.minecraft.server.v1_7_R4.IPacketVerifier;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutAnimation;
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityEquipment;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityVelocity;
import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMove;
import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMoveLook;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.PacketPlayOutUpdateAttributes;
import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class PacketVerifier implements IPacketVerifier
{
private Player _owner;
private PacketHandler _handler;
public PacketVerifier(Player owner, PacketHandler handler)
public PacketVerifier(Player owner)
{
_owner = owner;
_handler = handler;
}
@Override
public boolean verify(Packet o)
{
return _handler.FireRunnables(o, _owner, this);
if (o instanceof PacketPlayOutNamedEntitySpawn
|| o instanceof PacketPlayOutSpawnEntity
|| o instanceof PacketPlayOutSpawnEntityLiving
|| o instanceof PacketPlayOutUpdateAttributes
|| o instanceof PacketPlayOutAnimation
|| o instanceof PacketPlayOutEntityMetadata
|| o instanceof PacketPlayOutEntityEquipment
|| o instanceof PacketPlayOutEntityVelocity
|| o instanceof PacketPlayOutRelEntityMove
|| o instanceof PacketPlayOutRelEntityMoveLook
|| o instanceof PacketPlayOutPlayerInfo
|| o instanceof PacketPlayOutEntityDestroy
|| o instanceof PacketPlayOutAttachEntity)
{
PlayerPacketEvent event = new PlayerPacketEvent(_owner, o, this);
Bukkit.getServer().getPluginManager().callEvent(event);
return !event.isCancelled();
}
return true;
}
public void forceProcess(Packet packet)
public void bypassProcess(Packet packet)
{
((CraftPlayer)_owner).getHandle().playerConnection.networkManager.handle(packet, new GenericFutureListener[0]);
}
@ -37,4 +66,9 @@ public class PacketVerifier implements IPacketVerifier
{
_owner = null;
}
public void process(Packet packet)
{
((CraftPlayer)_owner).getHandle().playerConnection.sendPacket(packet);
}
}

View File

@ -0,0 +1,60 @@
package mineplex.core.packethandler;
import net.minecraft.server.v1_7_R4.Packet;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerPacketEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private Packet _packet;
private PacketVerifier _verifier;
private boolean _cancelled = false;
public PlayerPacketEvent(Player player, Packet packet, PacketVerifier verifier)
{
_player = player;
_packet = packet;
_verifier = verifier;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public Packet getPacket()
{
return _packet;
}
public Player getPlayer()
{
return _player;
}
public PacketVerifier getVerifier()
{
return _verifier;
}
public void setCancelled(boolean cancel)
{
_cancelled = cancel;
}
public boolean isCancelled()
{
return _cancelled;
}
}

View File

@ -1,27 +0,0 @@
package mineplex.core.sound;
import net.minecraft.server.v1_7_R4.Packet;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.packethandler.IPacketRunnable;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketVerifier;
public class SoundManager extends MiniPlugin implements IPacketRunnable
{
public SoundManager(JavaPlugin plugin, PacketHandler packetHandler)
{
super("Sound Manager", plugin);
packetHandler.AddPacketRunnable(this);
}
@Override
public boolean run(Packet packet, Player owner, PacketVerifier packetList)
{
return false;
}
}

View File

@ -5,7 +5,6 @@ import java.util.LinkedList;
import java.util.Map;
import java.util.Random;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -16,9 +15,7 @@ import mineplex.core.common.util.NautHashMap;
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.reward.ExampleReward;
import mineplex.core.treasure.reward.ITreasureReward;
/**
@ -32,18 +29,17 @@ public class Treasure
private Block _centerBlock;
private int _tickCount;
private ChestData[] _chestData;
private ITreasureReward[] _rewards;
private LinkedList<Animation> _animations;
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;
_random = seed;
@ -56,10 +52,10 @@ public class Treasure
// _animations.add(new ParticleAnimation(this));
_chestData = new ChestData[4];
_chestData[0] = new ChestData(_centerBlock.getRelative(2, 1, 0), new ExampleReward());
_chestData[1] = new ChestData(_centerBlock.getRelative(-2, 1, 0), new ExampleReward());
_chestData[2] = new ChestData(_centerBlock.getRelative(0, 1, 2), new ExampleReward());
_chestData[3] = new ChestData(_centerBlock.getRelative(0, 1, -2), new ExampleReward());
_chestData[0] = new ChestData(_centerBlock.getRelative(2, 1, 0), rewards[0]);
_chestData[1] = new ChestData(_centerBlock.getRelative(-2, 1, 0), rewards[1]);
_chestData[2] = new ChestData(_centerBlock.getRelative(0, 1, 2), rewards[2]);
_chestData[3] = new ChestData(_centerBlock.getRelative(0, 1, -2), rewards[3]);
}
private void createCenterClay()
@ -219,6 +215,7 @@ public class Treasure
if (data != null && !data.isOpened())
{
data.setOpened(true);
data.getReward().giveReward(_player);
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data);
_animations.add(chestOpenTask);

View File

@ -30,6 +30,10 @@ import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.donation.DonationManager;
import mineplex.core.treasure.reward.ITreasureReward;
import mineplex.core.treasure.reward.RewardManager;
import mineplex.core.treasure.reward.rewards.GemReward;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -39,12 +43,23 @@ import mineplex.core.updater.event.UpdateEvent;
public class TreasureManager extends MiniPlugin
{
private NautHashMap<Player, Treasure> _playerTreasureMap;
private RewardManager _rewardManager;
private DonationManager _donationManager;
public TreasureManager(JavaPlugin plugin)
public TreasureManager(JavaPlugin plugin, DonationManager donationManager)
{
super("Treasure", plugin);
_donationManager = donationManager;
_playerTreasureMap = new NautHashMap<Player, Treasure>();
_rewardManager = new RewardManager();
_rewardManager.addReward(new GemReward(_donationManager, 5));
_rewardManager.addReward(new GemReward(_donationManager, 50));
_rewardManager.addReward(new GemReward(_donationManager, 200));
_rewardManager.addReward(new GemReward(_donationManager, 500));
_rewardManager.addReward(new GemReward(_donationManager, 5000));
}
@Override
@ -61,7 +76,14 @@ public class TreasureManager extends MiniPlugin
if (!checkNearbyBlocks(player))
return;
Treasure treasure = new Treasure(player);
ITreasureReward[] rewards = new ITreasureReward[4];
for (int i = 0; i < 4; i++)
{
rewards[i] = _rewardManager.nextReward(player);
}
Treasure treasure = new Treasure(player, rewards);
_playerTreasureMap.put(player, treasure);
Location teleportLocation = treasure.getPlayerBlock().getLocation().add(0.5, 0, 0.5);
@ -74,6 +96,7 @@ public class TreasureManager extends MiniPlugin
private boolean checkNearbyBlocks(Player player)
{
//todo improve this
Block centerBlock = player.getLocation().getBlock();
for (int y = 0; y <= 3; y++)
@ -85,7 +108,7 @@ public class TreasureManager extends MiniPlugin
Block block = centerBlock.getRelative(x, y, z);
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 not open a treasure at this spot. Please find an open location"));
return false;
}
}

View File

@ -1,5 +1,6 @@
package mineplex.core.treasure.reward;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
/**
@ -13,4 +14,7 @@ public interface ITreasureReward
public RewardRarity getRarity();
public void giveReward(Player player);
public boolean canGiveReward(Player player);
}

View File

@ -0,0 +1,83 @@
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 nextReward(Player player)
{
/*
This is potentially blocking, need to make sure each RewardRarity has at least one reward that
players can recieve no matter what. May need to touch on this later.
*/
//todo
double rand = _random.nextDouble();
RewardRarity rarity;
if (rand >= 98)
{
// 2%
rarity = RewardRarity.VERY_RARE;
}
else if (rand >= 90)
{
// 8%
rarity = RewardRarity.RARE;
}
else if (rand >= 60)
{
// 30%
rarity = RewardRarity.UNCOMMON;
}
else
{
// 60%
rarity = RewardRarity.COMMON;
}
List<ITreasureReward> treasureList = _treasureMap.get(rarity);
ITreasureReward reward;
do
{
reward = treasureList.get(_random.nextInt(treasureList.size()));
}
while (!reward.canGiveReward(player));
return reward;
}
}

View File

@ -1,9 +1,12 @@
package mineplex.core.treasure.reward;
package mineplex.core.treasure.reward.rewards;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.treasure.reward.ITreasureReward;
import mineplex.core.treasure.reward.RewardRarity;
/**
* Created by Shaun on 9/2/2014.
@ -27,4 +30,16 @@ public class ExampleReward implements ITreasureReward
{
return RewardRarity.COMMON;
}
@Override
public void giveReward(Player player)
{
player.sendMessage("give example reward...");
}
@Override
public boolean canGiveReward(Player player)
{
return true;
}
}

View File

@ -0,0 +1,56 @@
package mineplex.core.treasure.reward.rewards;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.account.CoreClientManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.treasure.reward.ITreasureReward;
import mineplex.core.treasure.reward.RewardRarity;
/**
* Created by shaun on 2014-09-04.
*/
public class GadgetReward implements ITreasureReward
{
private Gadget _gadget;
private DonationManager _donationManager;
public GadgetReward(Gadget gadget, DonationManager donationManager)
{
_gadget = gadget;
_donationManager = donationManager;
}
@Override
public String getText()
{
return _gadget.GetDisplayName();
}
@Override
public ItemStack getItem()
{
return new ItemStack(_gadget.GetDisplayMaterial());
}
@Override
public RewardRarity getRarity()
{
return RewardRarity.VERY_RARE;
}
@Override
public void giveReward(Player player)
{
_donationManager.Get(player.getName()).AddUnknownSalesPackagesOwned(_gadget.GetName());
}
@Override
public boolean canGiveReward(Player player)
{
return !(_donationManager.Get(player.getName()).OwnsUnknownPackage(_gadget.GetName()));
}
}

View File

@ -0,0 +1,66 @@
package mineplex.core.treasure.reward.rewards;
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.ITreasureReward;
import mineplex.core.treasure.reward.RewardRarity;
/**
* Created by shaun on 2014-09-04.
*/
public class GemReward implements ITreasureReward
{
private DonationManager _donationManager;
private ItemStack _itemStack;
private int _gemAmount;
public GemReward(DonationManager donationManager, int gemAmount)
{
_donationManager = donationManager;
_gemAmount = gemAmount;
_itemStack = new ItemStack(Material.EMERALD);
}
@Override
public String getText()
{
return C.cGreen + _gemAmount + " Gems";
}
@Override
public ItemStack getItem()
{
return _itemStack;
}
@Override
public RewardRarity getRarity()
{
return RewardRarity.COMMON;
}
@Override
public void giveReward(Player player)
{
_donationManager.RewardGems(new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
}
}, "Treasure Chest", player.getName(), _gemAmount);
}
@Override
public boolean canGiveReward(Player player)
{
return true;
}
}

View File

@ -1,10 +1,9 @@
package mineplex.hub;
import net.minecraft.server.v1_7_R4.MinecraftServer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.CustomTagFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.antistack.AntiStack;
@ -92,12 +91,12 @@ public class Hub extends JavaPlugin implements IRelation
//Main Modules
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, clientManager));
PacketHandler packetHandler = new PacketHandler(this);
//new FriendManager(this, packetHandler);
PartyManager partyManager = new PartyManager(this, clientManager, preferenceManager);
Portal portal = new Portal(this, serverStatusManager.getCurrentServerName());
AntiHack.Initialize(this, punish, portal);
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager);
DisguiseManager disguiseManager = new DisguiseManager(this);
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager);
new PlayerTracker(this, serverStatusManager.getCurrentServerName(), serverStatusManager.getUs());
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this), partyManager);
@ -106,13 +105,15 @@ public class Hub extends JavaPlugin implements IRelation
new Chat(this, clientManager, preferenceManager, serverStatusManager.getCurrentServerName());
new MemoryFix(this);
new FileUpdater(this, portal);
new CustomTagFix(this);
new PacketHandler(this);
CombatManager combatManager = new CombatManager(this);
BlockRestore blockRestore = new BlockRestore(this);
ProjectileManager throwManager = new ProjectileManager(this);
SkillConditionManager conditionManager = new SkillConditionManager(this);
DamageManager damage = new DamageManager(this, combatManager, npcManager, new DisguiseManager(this, packetHandler));
DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager);
Fire fire = new Fire(this, conditionManager, damage);
Teleport teleport = new Teleport(this, clientManager, new Spawn(this));
Energy energy = new Energy(this);

View File

@ -54,7 +54,6 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.treasure.TreasureManager;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.disguise.DisguiseManager;
@ -115,7 +114,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
private InventoryManager _inventoryManager;
private NewsManager _news;
private AchievementManager _achievementManager;
private PollManager _pollManager;
private Location _spawn;
private int _scoreboardTick = 0;
@ -164,7 +162,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
_partyManager = partyManager;
_preferences = preferences;
_pollManager = pollManager;
_tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator);
_visibilityManager = new VisibilityManager(this);

View File

@ -42,6 +42,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
BuildPage();
}
@SuppressWarnings("deprecation")
@Override
protected void BuildPage()
{
@ -118,6 +119,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
ButtonMap.put(26, new SelectMINButton(this));
}
@SuppressWarnings("deprecation")
private void createMinigameCycle()
{
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(98, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []

View File

@ -25,7 +25,6 @@ import mineplex.hub.server.ui.button.JoinServerButton;
public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> implements IServerPage
{
// Shop Item Messages
private static final String MESSAGE_SHOP_URL = ChatColor.RESET + "www.mineplex.com/shop";
private static final String MESSAGE_BETA_GET_ULTRA = ChatColor.RESET + C.Line + "Get Ultra to join Beta servers!";
private static final String MESSAGE_JOIN = ChatColor.RESET + C.Line + "Click to Join";
private static final String MESSAGE_IN_PROGRESS = ChatColor.RESET + C.Line + "Game in Progress.";

View File

@ -18,6 +18,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
@ -48,6 +49,12 @@ public class CustomerSupport extends MiniPlugin
@EventHandler
public void Join(PlayerJoinEvent event)
{
if (!_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR))
{
event.getPlayer().kickPlayer("Only for staff.");
return;
}
event.setJoinMessage(F.sys("Join", event.getPlayer().getName()));
}

View File

@ -8,6 +8,7 @@ import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;
import mineplex.core.CustomTagFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.antistack.AntiStack;
@ -44,7 +45,6 @@ import mineplex.core.updater.Updater;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import nautilus.game.arcade.game.GameServerConfig;
import net.minecraft.server.*;
import net.minecraft.server.v1_7_R4.MinecraftServer;
import org.bukkit.entity.Player;
@ -97,8 +97,7 @@ public class Arcade extends JavaPlugin
Portal portal = new Portal(this, serverStatusManager.getCurrentServerName());
new FileUpdater(this, portal);
PacketHandler packetHandler = new PacketHandler(this);
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
DisguiseManager disguiseManager = new DisguiseManager(this);
_damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager);
@ -116,9 +115,11 @@ public class Arcade extends JavaPlugin
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager);
CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, true);
cosmeticManager.setInterfaceSlot(7);
new CustomTagFix(this);
new PacketHandler(this);
//Arcade Manager
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, packetHandler, preferenceManager, inventoryManager, cosmeticManager, projectileManager, webServerAddress);
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, preferenceManager, inventoryManager, cosmeticManager, projectileManager, webServerAddress);
new PlayerTracker(this, serverStatusManager.getCurrentServerName(), serverStatusManager.getUs());
new MemoryFix(this);

View File

@ -64,13 +64,11 @@ import mineplex.core.chat.Chat;
import mineplex.core.common.Rank;
import mineplex.core.common.util.*;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.creature.Creature;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.movement.Movement;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.elo.EloManager;
import mineplex.core.energy.Energy;
import mineplex.core.explosion.Explosion;
@ -141,7 +139,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig,
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, AntiStack antistack,
Portal portal, PacketHandler packetHandler, PreferencesManager preferences, InventoryManager inventoryManager,
Portal portal, PreferencesManager preferences, InventoryManager inventoryManager,
CosmeticManager cosmeticManager, ProjectileManager projectileManager, String webAddress)
{
super("Game Manager", plugin);
@ -221,7 +219,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
// Shop
_arcadeShop = new ArcadeShop(this, clientManager, donationManager);
// Game Factory
// Game Factory
_gameFactory = new GameFactory(this);
// Managers
@ -229,7 +227,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_gameCreationManager = new GameCreationManager(this);
_gameGemManager = new GameGemManager(this);
_gameManager = new GameManager(this);
_gameLobbyManager = new GameLobbyManager(this, packetHandler);
_gameLobbyManager = new GameLobbyManager(this);
new GameFlagManager(this);
_gamePlayerManager = new GamePlayerManager(this);
new GameAchievementManager(this);

View File

@ -41,8 +41,10 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilWorld;
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.UtilPlayer;
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 };
//Bridge Timer
private int _bridgeTime = 600000;
private int _bridgeTime = 5000; //600000
private boolean _bridgesDown = false;
//Wood Bridge
@ -732,7 +734,7 @@ public class Bridge extends TeamGame implements OreObsfucation
// Create Part
FallingBlock block = bestLoc.getWorld().spawnFallingBlock(
source, 10, (byte) 0);
source, 87, (byte) 0);
BridgePart part = new BridgePart(block, bestLoc, true);
_bridgeParts.add(part);

View File

@ -310,7 +310,7 @@ public class Draw extends SoloGame
if (!IsLive())
return;
if (event.getType() != UpdateType.TICK)
if (event.getType() != UpdateType.FAST)
return;
if (_round == null)

View File

@ -1,6 +1,11 @@
package nautilus.game.arcade.game.games.hideseek.kits;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -53,40 +58,6 @@ public class KitHiderQuick extends KitHider
slime.SetName(GetAvailability().GetColor() + GetName());
slime.SetCustomNameVisible(true);
DisguiseBlock block = new DisguiseBlock(ent, 46, 0);
ToBlock(block, slime);
}
public void ToBlock(final DisguiseBlock block, final DisguiseSlime slime)
{
if (Manager.GetGame() == null || Manager.GetGame().InProgress())
return;
Manager.GetDisguise().disguise(block);
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
ToSlime(block, slime);
}
}, 60);
}
public void ToSlime(final DisguiseBlock block, final DisguiseSlime slime)
{
if (Manager.GetGame() == null || Manager.GetGame().InProgress())
return;
Manager.GetDisguise().disguise(slime);
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
ToBlock(block, slime);
}
}, 60);
Manager.GetDisguise().disguise(new DisguiseBlock(ent, 46, 0));
}
}

View File

@ -1,6 +1,11 @@
package nautilus.game.arcade.game.games.hideseek.kits;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -52,41 +57,7 @@ public class KitHiderShocker extends KitHider
slime.SetSize(2);
slime.SetName(GetAvailability().GetColor() + GetName());
slime.SetCustomNameVisible(true);
DisguiseBlock block = new DisguiseBlock(ent, 61, 0);
ToBlock(block, slime);
}
public void ToBlock(final DisguiseBlock block, final DisguiseSlime slime)
{
if (Manager.GetGame() == null || Manager.GetGame().InProgress())
return;
Manager.GetDisguise().disguise(block);
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
ToSlime(block, slime);
}
}, 60);
}
public void ToSlime(final DisguiseBlock block, final DisguiseSlime slime)
{
if (Manager.GetGame() == null || Manager.GetGame().InProgress())
return;
Manager.GetDisguise().disguise(slime);
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
ToBlock(block, slime);
}
}, 60);
Manager.GetDisguise().disguise(new DisguiseBlock(ent, 61, 0));
}
}

View File

@ -1,6 +1,11 @@
package nautilus.game.arcade.game.games.hideseek.kits;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -52,43 +57,11 @@ public class KitHiderSwapper extends KitHider
slime.SetName(GetAvailability().GetColor() + GetName());
slime.SetCustomNameVisible(true);
ToBlock(ent, slime);
}
public void ToBlock(final LivingEntity ent, final DisguiseSlime slime)
{
if (Manager.GetGame() == null || Manager.GetGame().InProgress())
return;
double r = Math.random();
if (r > 0.75) Manager.GetDisguise().disguise(new DisguiseBlock(ent, 54, 0));
else if (r > 0.5) Manager.GetDisguise().disguise(new DisguiseBlock(ent, 145, 0));
else if (r > 0.25) Manager.GetDisguise().disguise(new DisguiseBlock(ent, 140, 11));
else Manager.GetDisguise().disguise(new DisguiseBlock(ent, 47, 0));
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
ToSlime(ent, slime);
}
}, 60);
}
public void ToSlime(final LivingEntity ent, final DisguiseSlime slime)
{
if (Manager.GetGame() == null || Manager.GetGame().InProgress())
return;
Manager.GetDisguise().disguise(slime);
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
ToBlock(ent, slime);
}
}, 60);
}
}

View File

@ -112,7 +112,7 @@ public class MineStrike extends TeamGame
private int _bulletInstant = 2; //0 = Slow, 1 = Instant, 2 = Mix
private boolean _customHitbox = true;
private boolean _bulletAlternate = false;
//Map Data
private ArrayList<Location> _bombSites;
@ -772,13 +772,13 @@ public class MineStrike extends TeamGame
gun.reduceCone();
}
}
@EventHandler
public void slowBulletHit(final ProjectileHitEvent event)
{
if (!(event.getEntity() instanceof Snowball))
return;
Bullet bullet = _bullets.get(event.getEntity());
//Particle
@ -787,21 +787,21 @@ public class MineStrike extends TeamGame
//Hit Block Sound
event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.ENDERMAN_HIT, 1f, 1f);
//Block Particle
Location loc = event.getEntity().getLocation().add(event.getEntity().getVelocity().multiply(0.8));
Block block = loc.getBlock();
if (block.getType() == Material.AIR)
{
Block closest = null;
double closestDist = 0;
for (Block other : UtilBlock.getSurrounding(block, true))
{
if (other.getType() == Material.AIR)
continue;
double dist = UtilMath.offset(loc, other.getLocation().add(0.5, 0.5, 0.5));
if (closest == null || dist < closestDist)
@ -810,30 +810,30 @@ public class MineStrike extends TeamGame
closestDist = dist;
}
}
if (closest != null)
block = closest;
}
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
}
@EventHandler
public void slowBulletWhizz(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Entity ent : _bullets.keySet())
{
if (ent instanceof Snowball)
continue;
if (ent.getTicksLived() < 10)
continue;
Bullet bullet = _bullets.get(ent);
for (Player player : UtilServer.getPlayers())
{
if (UtilMath.offset(ent, player) < 4)
@ -946,16 +946,16 @@ public class MineStrike extends TeamGame
}
}
@EventHandler(priority=EventPriority.MONITOR)
public void removeArrowsFromPlayer(CustomDamageEvent event)
{
if (event.GetDamageePlayer() != null)
((CraftPlayer) event.GetDamageePlayer()).getHandle().p(0);
}
@EventHandler(priority=EventPriority.HIGH)
public void damage(CustomDamageEvent event)
{
@ -1032,7 +1032,7 @@ public class MineStrike extends TeamGame
//Get Hit Area
int hitArea = 0;
if (_customHitbox)
{
if (event.GetProjectile() instanceof Arrow)
@ -1040,14 +1040,14 @@ public class MineStrike extends TeamGame
else
hitArea = getSnowballHitArea(event.GetDamageePlayer(), event.GetProjectile());
}
if (hitArea == -1)
{
event.SetCancelled("Miss");
return;
}
//Bullet Whiz Sound
if (event.GetProjectile() instanceof Arrow)
instantBulletWhizz(event.GetDamageePlayer().getEyeLocation(), bullet);
@ -1064,7 +1064,7 @@ public class MineStrike extends TeamGame
//Damage + Dropoff
double damage = bullet.getDamage();
double damageDropoff = bullet.getDamageDropoff(event.GetDamageeEntity().getLocation());
//Add Damages
event.AddMod(bullet.Shooter.getName(), bullet.Gun.getName(), damage, true);
event.AddMod(bullet.Shooter.getName(), "Distance Dropoff", damageDropoff, false);
@ -1073,19 +1073,21 @@ public class MineStrike extends TeamGame
if (hitArea == 1)
{
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.GetDamageePlayer().getWorld().playSound(event.GetDamageePlayer().getEyeLocation(), Sound.SPIDER_DEATH, 1f, 1f);
}
else
{
event.GetDamageePlayer().getWorld().playSound(event.GetDamageePlayer().getEyeLocation(), Sound.SLIME_ATTACK, 1f, 1f);
}
}
//Kevlar - Body Hit
if (hitArea == 0 && Armor.isArmor(event.GetDamageePlayer().getInventory().getChestplate()))
{
@ -1103,56 +1105,68 @@ public class MineStrike extends TeamGame
event.SetIgnoreRate(true);
event.SetIgnoreArmor(true);
}
public int getArrowHitArea(Player damagee, Location origin, Vector trajectory)
{
System.out.println("Getting Area");
//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();
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));
}
if (hitHead(damagee, loc))
{
System.out.println("Head");
return 1;
}
if (hitBody(damagee, loc))
{
System.out.println("Body");
return 0;
}
System.out.println("Miss");
return -1;
}
public int getSnowballHitArea(Player damagee, Projectile snowball)
{
//Move to near-player
Location start = snowball.getLocation();
Location loc = start.clone();
while (!hitHead(damagee, loc) && !hitBody(damagee, loc) && UtilMath.offset(damagee.getLocation(), loc) < 6)
{
loc.add(snowball.getVelocity().clone().multiply(0.1));
}
if (hitHead(damagee, loc))
return 1;
if (hitBody(damagee, loc))
return 0;
return -1;
}
public boolean hitBody(Player player, Location loc)
{
return UtilMath.offset2d(loc, player.getLocation()) < 0.6 && //0.6 is ideal
loc.getY() > player.getLocation().getY() &&
loc.getY() < player.getEyeLocation().getY() - 0.2;
}
public boolean hitHead(Player player, Location loc)
{
return UtilMath.offset2d(loc, player.getLocation()) < 0.3 && //0.3 is ideal
@ -1416,7 +1430,7 @@ public class MineStrike extends TeamGame
_bombDefuser.setExp(0f);
UtilPlayer.message(player, F.main("Game", "You are defusing the Bomb."));
_bombDefuser.getWorld().playSound(_bombDefuser.getLocation(), Sound.PISTON_RETRACT, 2f, 1f);
}
@ -1709,7 +1723,7 @@ public class MineStrike extends TeamGame
{
player.playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 2f);
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
@ -1720,21 +1734,21 @@ public class MineStrike extends TeamGame
for (GameTeam team : GetTeamList())
for (Player teamMember : team.GetPlayers(true))
GetScoreboard().SetPlayerTeam(teamMember, team.GetName().toUpperCase());
//Alternate Bullets
if (_bulletAlternate)
_bulletInstant = (_bulletInstant + 1)%3;
//Debug Details
if (_debug)
{
Announce(C.cDPurple + C.Bold + "ROUND SETTINGS:");
if (_customHitbox)
Announce(C.cPurple + C.Bold + "Hitbox: " + ChatColor.RESET + "Accurate with Headshots");
else
Announce(C.cPurple + C.Bold + "Hitbox: " + ChatColor.RESET + "Default with No Headshot");
if (_bulletInstant == 0)
Announce(C.cPurple + C.Bold + "Bullets: " + ChatColor.RESET + "Slow and Visible");
else if (_bulletInstant == 1)
@ -1833,11 +1847,11 @@ public class MineStrike extends TeamGame
//Restock Ammo
for (Gun gun : _gunsEquipped.keySet())
gun.restockAmmo(_gunsEquipped.get(gun));
//Health
for (Player player : UtilServer.getPlayers())
player.setHealth(20);
//Reset Shop
for (Player player : UtilServer.getPlayers())
_shopManager.leaveShop(player, false, false);
@ -1997,7 +2011,7 @@ public class MineStrike extends TeamGame
continue;
Gun gun = getGunInHand(player, null);
if (!gun.hasScope() || !player.isSneaking())
if (gun == null || !gun.hasScope() || !player.isSneaking())
{
removeScope(player);
}
@ -2060,16 +2074,16 @@ public class MineStrike extends TeamGame
{
if (event.getType() != UpdateType.TICK)
return;
if (_bombItem == null)
return;
if (!_bombItem.isValid())
{
Location loc = _bombItem.getLocation();
_bombItem.remove();
_bombItem = loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.GOLD_SWORD));
}
}
@ -2265,7 +2279,7 @@ public class MineStrike extends TeamGame
{
if (!IsLive())
return;
if (event.getType() != UpdateType.TICK)
return;
@ -2369,7 +2383,7 @@ public class MineStrike extends TeamGame
_shopManager.addMoney(event.getPlayer(), 16000, "Debug");
event.setCancelled(true);
}
if (event.getMessage().contains("instant"))
{
_bulletInstant = (_bulletInstant + 1)%3;
@ -2380,11 +2394,11 @@ public class MineStrike extends TeamGame
Announce(C.cPurple + C.Bold + "Bullets: " + ChatColor.RESET + "Instant and Invisible");
else
Announce(C.cPurple + C.Bold + "Bullets: " + ChatColor.RESET + "Slow and Visible with Instant Sniper");
event.setCancelled(true);
}
if (event.getMessage().contains("hitbox"))
{
_customHitbox = !_customHitbox;
@ -2396,7 +2410,7 @@ public class MineStrike extends TeamGame
event.setCancelled(true);
}
if (event.getMessage().contains("alternate"))
{
_bulletAlternate = !_bulletAlternate;
@ -2405,16 +2419,16 @@ public class MineStrike extends TeamGame
event.setCancelled(true);
}
if (event.getMessage().contains("god"))
{
if (HealthSet == 20)
HealthSet = -1;
else
HealthSet = 20;
Announce(C.cPurple + C.Bold + "God Mode: " + ChatColor.RESET + (HealthSet == 20));
event.setCancelled(true);
}

View File

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

View File

@ -31,7 +31,6 @@ import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.scoreboard.DisplaySlot;
@ -44,23 +43,17 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilText.TextAlign;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
import mineplex.core.donation.Donor;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.packethandler.IPacketRunnable;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.packethandler.PlayerPacketEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -79,7 +72,7 @@ import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.WatchableObject;
public class GameLobbyManager implements IPacketRunnable, Listener
public class GameLobbyManager implements Listener
{
public ArcadeManager Manager;
@ -111,11 +104,12 @@ public class GameLobbyManager implements IPacketRunnable, Listener
private NautHashMap<Player, String> _kitMap = new NautHashMap<Player, String>();
private int _oldPlayerCount = 0;
private boolean _handlingPacket = false;
public GameLobbyManager(ArcadeManager manager, PacketHandler packetHandler)
public GameLobbyManager(ArcadeManager manager)
{
Manager = manager;
packetHandler.AddPacketRunnable(this);
World world = UtilWorld.getWorld("world");
@ -1037,19 +1031,22 @@ public class GameLobbyManager implements IPacketRunnable, Listener
}
@SuppressWarnings("unchecked")
@Override
public boolean run(Packet packet, Player owner, PacketVerifier packetList)
@EventHandler
public void handlePacket(PlayerPacketEvent event)
{
if (_handlingPacket)
return;
Packet packet = event.getPacket();
Player owner = event.getPlayer();
PacketVerifier packetVerifier = event.getVerifier();
int entityId = -1;
if (packet instanceof PacketPlayOutEntityMetadata)
{
entityId = ((PacketPlayOutEntityMetadata)packet).a;
}
else if (packet instanceof PacketPlayOutSpawnEntityLiving)
{
//entityId = ((Packet24MobSpawn)packet).a;
}
if (entityId != -1)
{
@ -1089,15 +1086,11 @@ public class GameLobbyManager implements IPacketRunnable, Listener
newPacket.a = entityId;
newPacket.b = watchables;
packetList.forceProcess(newPacket);
_handlingPacket = true;
packetVerifier.process(newPacket);
_handlingPacket = false;
return false;
}
else if (packet instanceof PacketPlayOutSpawnEntityLiving)
{
DataWatcher watcher = ((PacketPlayOutSpawnEntityLiving)packet).l;
watcher.watch(10, customName);
watcher.watch(11, Byte.valueOf((byte)1));
event.setCancelled(true);
}
}
catch (IllegalArgumentException e)
@ -1106,8 +1099,6 @@ public class GameLobbyManager implements IPacketRunnable, Listener
}
}
}
return true;
}
public void AddPlayerToScoreboards(Player player, String teamName)