Merging changes from master to Better-Holograms

* master:
  Antistack replacement

Conflicts:
	Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java
This commit is contained in:
libraryaddict 2014-11-27 01:01:19 +13:00
commit ef59cb7a9d
11 changed files with 45 additions and 165 deletions

View File

@ -1,138 +0,0 @@
package mineplex.core.antistack;
import java.util.HashSet;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
import org.bukkit.entity.Item;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class AntiStack extends MiniPlugin
{
private boolean _enabled = true;
private HashSet<Location> _ignoreAround = new HashSet<Location>();
public AntiStack(JavaPlugin plugin)
{
super("AntiStack", plugin);
}
@EventHandler(priority = EventPriority.MONITOR)
public void BlockBreak(BlockBreakEvent event)
{
if (!_enabled)
return;
if (event.isCancelled())
return;
_ignoreAround.add(event.getBlock().getLocation().add(0.5, 0.5, 0.5));
}
@EventHandler
public void ClearIgnoreAround(UpdateEvent event)
{
if (!_enabled)
return;
if (event.getType() != UpdateType.TICK)
return;
_ignoreAround.clear();
}
@EventHandler (priority=EventPriority.HIGHEST)
public void ItemSpawn(ItemSpawnEvent event)
{
if (!_enabled)
return;
if (event.isCancelled())
return;
Item item = event.getEntity();
for (Location loc : _ignoreAround)
if (UtilMath.offset(loc, event.getLocation()) < 2)
return;
//ItemName()
if (item.getLocation().getY() < -10)
return;
//Get Name
String name = ((CraftItemStack)item.getItemStack()).getHandle().getName();
//Append UID
name += ":" + item.getUniqueId();
//Set Name
((CraftItemStack)item.getItemStack()).getHandle().c(name);
}
@EventHandler (priority=EventPriority.HIGHEST)
public void PlayerPickup(PlayerPickupItemEvent event)
{
if (!_enabled)
return;
if (event.isCancelled())
return;
Item item = event.getItem();
removeUID(item);
}
@EventHandler
public void HopperPickup(InventoryPickupItemEvent event)
{
if (!_enabled)
return;
if (event.isCancelled())
return;
Item item = event.getItem();
//Get Name
String name = ((CraftItemStack)item.getItemStack()).getHandle().getName();
//Remove UID
if (name.contains(":"))
name = name.substring(0, name.indexOf(":" + item.getUniqueId()));
//Set Name
((CraftItemStack)item.getItemStack()).getHandle().c(name);
}
public void SetEnabled(boolean var)
{
_enabled = var;
}
public static void removeUID(Item item)
{
//Get Name
String name = ((CraftItemStack)item.getItemStack()).getHandle().getName();
//Remove UID
if (name.contains(":"))
name = name.substring(0, name.indexOf(":" + item.getUniqueId()));
//Set Name
((CraftItemStack)item.getItemStack()).getHandle().c(name);
}
}

View File

@ -7,7 +7,6 @@ import mineplex.core.CustomTagFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.antistack.AntiStack;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandCenter;
@ -92,7 +91,6 @@ public class Hub extends JavaPlugin implements IRelation
Creature creature = new Creature(this);
NpcManager npcManager = new NpcManager(this, creature);
PetManager petManager = new PetManager(this, clientManager, donationManager, creature, webServerAddress);
new AntiStack(this);
PollManager pollManager = new PollManager(this, donationManager);
//Main Modules

View File

@ -158,6 +158,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
_portal = portal;
_spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5);
// Disable item merging
((CraftWorld) _spawn.getWorld()).getHandle().spigotConfig.itemMerge = 0;
_textCreator = new TextManager(this);
_parkour = new ParkourManager(this, donationManager, taskManager);

View File

@ -9,7 +9,6 @@ import net.minecraft.server.v1_7_R4.MinecraftServer;
import mineplex.core.CustomTagFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.antistack.AntiStack;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.blood.Blood;
import mineplex.core.command.CommandCenter;
@ -90,7 +89,6 @@ public class Arcade extends JavaPlugin
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
new MessageManager(this, _clientManager, preferenceManager);
AntiStack antistack = new AntiStack(this);
Creature creature = new Creature(this);
Spawn spawn = new Spawn(this);
Teleport teleport = new Teleport(this, _clientManager, spawn);
@ -121,7 +119,7 @@ public class Arcade extends JavaPlugin
cosmeticManager.setInterfaceSlot(7);
//Arcade Manager
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress);
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress);
new MemoryFix(this);
new CustomTagFix(this, packetHandler);

View File

@ -36,7 +36,6 @@ import org.bukkit.event.server.ServerListPingEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antistack.AntiStack;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.blood.Blood;
import mineplex.core.chat.Chat;
@ -117,7 +116,6 @@ import nautilus.game.arcade.shop.ArcadeShop;
public class ArcadeManager extends MiniPlugin implements IRelation
{
// Modules
private AntiStack _antistack;
private BlockRestore _blockRestore;
private Blood _blood;
private Chat _chat;
@ -174,7 +172,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,
DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood,
Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler,
CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress)
{
@ -183,8 +181,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_serverConfig = serverConfig;
// Modules
_antistack = antistack;
_blockRestore = new BlockRestore(plugin);
_blood = blood;
@ -302,11 +298,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
return _achievementManager;
}
public AntiStack GetAntiStack()
{
return _antistack;
}
public Blood GetBlood()
{
return _blood;

View File

@ -14,6 +14,7 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Hanging;
@ -33,6 +34,7 @@ import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.scoreboard.Objective;
import org.bukkit.util.Vector;
@ -203,6 +205,7 @@ public abstract class Game implements Listener
public boolean RepairWeapons = true;
private double _itemMergeRadius = 0;
public boolean AnnounceStay = true;
public boolean AnnounceJoinQuit = true;
@ -1286,8 +1289,34 @@ public abstract class Game implements Listener
loc.getY() >= WorldData.MaxY ||
loc.getY() <= WorldData.MinY);
}
public void setItemMerge(boolean itemMerge)
{
setItemMergeRadius(itemMerge ? 3.5 : 0);
}
public void setItemMergeRadius(double mergeRadius)
{
_itemMergeRadius = mergeRadius;
if (WorldData.World != null)
{
((CraftWorld) WorldData.World).getHandle().spigotConfig.itemMerge = _itemMergeRadius;
}
}
public double getItemMergeRadius()
{
return _itemMergeRadius;
}
@EventHandler
public void applyItemMerge(WorldLoadEvent event)
{
if (event.getWorld().getName().equals(WorldData.GetFolder()))
{
System.out.println("Setting item merge radius for game to " + _itemMergeRadius);
((CraftWorld) event.getWorld()).getHandle().spigotConfig.itemMerge = _itemMergeRadius;
}
}
}

View File

@ -57,7 +57,6 @@ import org.bukkit.scoreboard.Team;
import org.bukkit.scoreboard.TeamNameTagVisibility;
import org.bukkit.util.Vector;
import mineplex.core.antistack.AntiStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
@ -898,8 +897,6 @@ public class MineStrike extends TeamGame
if (UtilInv.contains(event.getPlayer(), Material.SHEARS, (byte)0, 1))
return;
AntiStack.removeUID(event.getItem());
event.getPlayer().getInventory().setItem(8, event.getItem().getItemStack());
UtilPlayer.message(event.getPlayer(), F.main("Game", "You equipped Defusal Kit."));

View File

@ -149,7 +149,8 @@ public class SurvivalGamesTeams extends TeamGame
C.cAqua + "Compass finds Players during day time.",
};
Manager.GetAntiStack().SetEnabled(false);
setItemMerge(true);
// Manager.GetAntiStack().SetEnabled(false);
this.GameTimeout = 9600000;

View File

@ -174,7 +174,8 @@ public class UHC extends TeamGame
Manager.GetCreature().SetDisableCustomDrops(true);
//Disable Anti-Stack
Manager.GetAntiStack().SetEnabled(false);
setItemMerge(true);
// Manager.GetAntiStack().SetEnabled(false);
//Damage Settings
Manager.GetDamage().SetEnabled(false);

View File

@ -159,7 +159,7 @@ public class GameCreationManager implements Listener
Manager.GetDamage().SetEnabled(true);
Manager.GetExplosion().SetRegenerate(false);
Manager.GetExplosion().SetTNTSpread(true);
Manager.GetAntiStack().SetEnabled(true);
// Manager.GetAntiStack().SetEnabled(true);
Manager.getCosmeticManager().setHideParticles(false);
HashMap<String, ChatColor> pastTeams = null;

View File

@ -23,6 +23,7 @@ import org.bukkit.Difficulty;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.event.world.ChunkUnloadEvent;
public class WorldData
@ -84,7 +85,7 @@ public class WorldData
TimingManager.stop("WorldData loading world.");
World.setDifficulty(Difficulty.HARD);
TimingManager.start("WorldData loading WorldConfig.");
//Load World Data
worldData.LoadWorldConfig();
@ -116,7 +117,7 @@ public class WorldData
return File;
}
protected String GetFolder()
public String GetFolder()
{
if (Folder == null)
Folder = "Game" + Id + "_" + Host.GetName() + "_" + GetFile();