Merge branch 'master' of ssh://198.245.50.91:7999/min/master

Conflicts:
	Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java
resolved
This commit is contained in:
Chiss 2013-09-05 07:50:13 +10:00
commit f29b844798
19 changed files with 219 additions and 93 deletions

View File

@ -1,7 +1,6 @@
package me.chiss.Core.Server;
import me.chiss.Core.Events.ServerSaveEvent;
import me.chiss.Core.Server.command.BroadcastCommand;
import me.chiss.Core.Server.command.ListCommand;
import me.chiss.Core.Server.command.SpawnSetCommand;
import me.chiss.Core.Server.command.WaterSpreadCommand;
@ -9,6 +8,7 @@ import mineplex.core.MiniPlugin;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.account.CoreClientManager;
import mineplex.core.chat.command.BroadcastCommand;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;

Binary file not shown.

View File

@ -1,12 +1,12 @@
package me.chiss.Core.Chat;
package mineplex.core.chat;
import me.chiss.Core.Chat.command.SilenceCommand;
import me.chiss.Core.Plugin.IChat;
import mineplex.core.MiniPlugin;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.account.CoreClientManager;
import mineplex.core.chat.command.BroadcastCommand;
import mineplex.core.chat.command.SilenceCommand;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
@ -17,27 +17,27 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class Chat extends MiniPlugin
{
private CoreClientManager _clientManager;
private IChat _chat;
private long _silenced = 0;
public Chat(JavaPlugin plugin, CoreClientManager clientManager,IChat chat)
public Chat(JavaPlugin plugin, CoreClientManager clientManager)
{
super("Chat", plugin);
_clientManager = clientManager;
_chat = chat;
}
@Override
public void AddCommands()
{
AddCommand(new SilenceCommand(this));
AddCommand(new BroadcastCommand(this));
}
public void Silence(long duration, boolean inform)
@ -60,6 +60,16 @@ public class Chat extends MiniPlugin
UtilServer.broadcast(F.main("Chat", "Chat has been silenced for " + F.time(UtilTime.MakeStr(duration, 1)) + "."));
}
@EventHandler
public void preventMe(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().startsWith("/me"))
{
event.getPlayer().sendMessage(F.main(GetName(), "Quite full of yourself aren't you? Nobody cares."));
event.setCancelled(true);
}
}
@EventHandler
public void SilenceUpdate(UpdateEvent event)
{
@ -96,7 +106,7 @@ public class Chat extends MiniPlugin
return true;
}
@EventHandler(priority = EventPriority.HIGHEST)
@EventHandler(priority = EventPriority.LOWEST)
public void HandleChat(AsyncPlayerChatEvent event)
{
if (event.isCancelled())
@ -114,10 +124,6 @@ public class Chat extends MiniPlugin
UtilPlayer.message(sender, F.main("Chat", "You are sending messages too fast."));
event.setCancelled(true);
}
else
{
_chat.HandleChat(event, event.getMessage());
}
}
public long Silenced()

View File

@ -1,15 +1,15 @@
package me.chiss.Core.Server.command;
package mineplex.core.chat.command;
import org.bukkit.entity.Player;
import me.chiss.Core.Server.Server;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilServer;
public class BroadcastCommand extends CommandBase<Server>
public class BroadcastCommand extends CommandBase<Chat>
{
public BroadcastCommand(Server plugin)
public BroadcastCommand(Chat plugin)
{
super(plugin, Rank.MODERATOR, "s");
}

View File

@ -1,8 +1,8 @@
package me.chiss.Core.Chat.command;
package mineplex.core.chat.command;
import org.bukkit.entity.Player;
import me.chiss.Core.Chat.Chat;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;

View File

@ -0,0 +1,117 @@
package mineplex.core.monitor;
import java.util.HashSet;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class LagMeter extends MiniPlugin
{
private CoreClientManager _clientManager;
private long _lastRun = -1;
private int _count;
private double _ticksPerSecond;
private double _ticksPerSecondAverage;
private long _lastAverage;
private HashSet<Player> _monitoring = new HashSet<Player>();
public LagMeter(JavaPlugin plugin, CoreClientManager clientManager)
{
super("LagMeter", plugin);
_clientManager = clientManager;
_lastRun = System.currentTimeMillis();
_lastAverage = System.currentTimeMillis();
}
@EventHandler
public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event)
{
if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR))
{
if (event.getMessage().trim().equalsIgnoreCase("/lag"))
{
sendUpdate(event.getPlayer());
event.setCancelled(true);
}
else if (event.getMessage().trim().equalsIgnoreCase("/monitor"))
{
if (_monitoring.contains(event.getPlayer()))
_monitoring.remove(event.getPlayer());
else
_monitoring.add(event.getPlayer());
event.setCancelled(true);
}
}
}
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{
_monitoring.remove(event.getPlayer());
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (_count % 20 == 0)
{
_ticksPerSecond = (1000D / (System.currentTimeMillis() - _lastRun)) * 20D;
sendUpdates();
_lastRun = System.currentTimeMillis();
}
if (_count % 600 == 0)
{
_ticksPerSecondAverage = 30000D / (System.currentTimeMillis() - _lastAverage);
_ticksPerSecond = 0;
_lastAverage = System.currentTimeMillis();
}
_count++;
}
public double GetTicksPerSecond()
{
return _ticksPerSecond;
}
private void sendUpdates()
{
for (Player player : _monitoring)
{
sendUpdate(player);
}
}
private void sendUpdate(Player player)
{
player.sendMessage(" ");
player.sendMessage(" ");
player.sendMessage(" ");
player.sendMessage(" ");
player.sendMessage(" ");
player.sendMessage(F.main(GetName(), ChatColor.GRAY + "Live-------" + ChatColor.YELLOW + String.format("%.00f", _ticksPerSecond)));
player.sendMessage(F.main(GetName(), ChatColor.GRAY + "Avg--------" + ChatColor.YELLOW + String.format("%.00f", _ticksPerSecondAverage * 20)));
player.sendMessage(F.main(GetName(), ChatColor.YELLOW + "MEM"));
player.sendMessage(F.main(GetName(), ChatColor.GRAY + "Free-------" + ChatColor.YELLOW + (Runtime.getRuntime().freeMemory() / 1048576) + "MB"));
player.sendMessage(F.main(GetName(), ChatColor.GRAY + "Max--------" + ChatColor.YELLOW + (Runtime.getRuntime().maxMemory() / 1048576)) + "MB");
}
}

View File

@ -51,6 +51,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
@ -223,11 +224,31 @@ public class PetManager extends MiniClientPlugin<PetClient>
}
}
@EventHandler
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamage(EntityDamageEvent event)
{
if (event.getEntity() instanceof Creature && _activePetOwners.containsValue((Creature)event.getEntity()))
{
if (event.getCause() == DamageCause.VOID)
{
String playerName = null;
for (Entry<String,Creature> entry : _activePetOwners.entrySet())
{
if (entry.getValue() == event.getEntity())
playerName = entry.getKey();
}
if (playerName != null)
{
Player player = Bukkit.getPlayerExact(playerName);
if (player != null && player.isOnline())
{
RemovePet(player, true, true);
}
}
}
event.setCancelled(true);
}
}

View File

@ -3,6 +3,7 @@ package mineplex.hub;
import me.chiss.Core.MemoryFix.MemoryFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandCenter;
import mineplex.core.creature.Creature;
import mineplex.core.disguise.DisguiseManager;
@ -10,6 +11,7 @@ import mineplex.core.donation.DonationManager;
import mineplex.core.energy.Energy;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.message.MessageManager;
import mineplex.core.monitor.LagMeter;
import mineplex.core.movement.Movement;
import mineplex.core.npc.NpcManager;
import mineplex.core.packethandler.PacketHandler;
@ -75,8 +77,10 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
new HubManager(this, clientManager, donationManager, new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()));
new Stacker(this);
new ServerManager(this, clientManager, donationManager, portal);
new Chat(this, clientManager);
new MemoryFix(this);
new FileUpdater(this, portal);
new LagMeter(this, clientManager);
CombatManager combatManager = new CombatManager(this);
BlockRestore blockRestore = new BlockRestore(this);

View File

@ -20,6 +20,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftPlayer;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Cow;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Pig;
@ -33,6 +34,7 @@ import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
@ -147,6 +149,14 @@ public class HubManager extends MiniClientPlugin<HubClient>
return line;
}
@EventHandler
public void preventEggSpawn(ItemSpawnEvent event)
{
if (event.getEntity() instanceof Egg)
{
event.setCancelled(true);
}
}
@EventHandler
public void PlayerRespawn(PlayerRespawnEvent event)

View File

@ -1,54 +0,0 @@
package nautilus.minecraft.core.utils;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class LagMeter implements Runnable, Listener
{
private long _lastRun = -1;
private int _count;
private double _ticksPerSecond;
private double _ticksPerSecondAverage;
public LagMeter(JavaPlugin plugin)
{
plugin.getServer().getPluginManager().registerEvents(this, plugin);
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, this, 0, 20);
}
@EventHandler
public void OnPlayerCommandPreProcess(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().trim().equalsIgnoreCase("/lag"))
{
event.getPlayer().sendMessage(ChatColor.GRAY + "Server is running at " + String.format("%.00f", _ticksPerSecondAverage * 20) + " TPS (" + String.format("%.00f", _ticksPerSecondAverage) + "% Max speed)");
event.setCancelled(true);
}
}
public void run()
{
if (_lastRun != -1)
{
_ticksPerSecond += (double)1000 / (System.currentTimeMillis() - _lastRun);
if (_count % 5 == 0)
{
_ticksPerSecondAverage = _ticksPerSecond / 5;
_ticksPerSecond = 0;
}
_count++;
}
_lastRun = System.currentTimeMillis();
}
public double GetTicksPerSecond()
{
return _ticksPerSecond;
}
}

View File

@ -26,6 +26,7 @@ import me.chiss.Core.Modules.*;
import me.chiss.Core.Plugin.IPlugin;
import me.chiss.Core.Scheduler.Scheduler;
import mineplex.core.message.MessageManager;
import mineplex.core.monitor.LagMeter;
import mineplex.core.npc.NpcManager;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.pet.PetManager;
@ -109,6 +110,7 @@ public class Arcade extends JavaPlugin implements INautilusPlugin, IPlugin
GetSpawn();
GetTeleport();
new FileUpdater(this, new Portal(this));
new LagMeter(this, _clientManager);
PacketHandler packetHandler = new PacketHandler(this);
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);

View File

@ -20,7 +20,6 @@ import org.bukkit.craftbukkit.v1_6_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -32,13 +31,12 @@ import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.DamageManager;
import mineplex.minecraft.game.core.fire.Fire;
import me.chiss.Core.Chat.Chat;
import mineplex.core.MiniPlugin;
import mineplex.core.itemstack.ItemStackFactory;
import me.chiss.Core.Modules.Blood;
import me.chiss.Core.Plugin.IChat;
import mineplex.core.account.CoreClientManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat;
import mineplex.core.common.util.*;
import mineplex.core.creature.Creature;
import mineplex.core.disguise.DisguiseManager;
@ -48,7 +46,7 @@ import mineplex.core.explosion.Explosion;
import mineplex.core.portal.Portal;
import mineplex.core.projectile.ProjectileManager;
public class ArcadeManager extends MiniPlugin implements IRelation, IChat
public class ArcadeManager extends MiniPlugin implements IRelation
{
//Modules
private BlockRestore _blockRestore;
@ -70,7 +68,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation, IChat
//Managers
private GameFactory _gameFactory;
private GameChatManager _gameChatManager;
private GameCreationManager _gameCreationManager;
private GameGemManager _gameGemManager;
private GameManager _gameManager;
@ -101,7 +98,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation, IChat
_clientManager = clientManager;
_chat = new Chat(plugin, _clientManager, this);
_chat = new Chat(plugin, _clientManager);
_creature = creature;
@ -127,7 +124,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation, IChat
_gameFactory = new GameFactory(this);
//Managers
_gameChatManager = new GameChatManager(this);
new GameChatManager(this);
_gameCreationManager = new GameCreationManager(this);
_gameGemManager = new GameGemManager(this);
_gameManager = new GameManager(this);
@ -274,12 +271,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation, IChat
return team.GetColor();
}
@Override
public void HandleChat(AsyncPlayerChatEvent event, String filteredMessage)
{
_gameChatManager.HandleChat(event, filteredMessage);
}
@Override
public boolean CanHurt(String a, String b)
{

View File

@ -1,6 +1,8 @@
package nautilus.game.arcade.game.standalone.smash.kits;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -13,6 +15,8 @@ import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.disguise.disguises.DisguiseEnderman;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
@ -117,4 +121,25 @@ public class KitEnderman extends SmashKit
Manager.GetDisguise().updateDisguise(disguise);
}
@EventHandler
public void cleanDisguises(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (Iterator<Entry<Player, DisguiseEnderman>> iterator = _disguises.entrySet().iterator(); iterator.hasNext();)
{
Entry<Player, DisguiseEnderman> current = iterator.next();
if (!Manager.GetDisguise().isDisguised(current.getKey()))
{
iterator.remove();
}
else if (Manager.GetDisguise().getDisguise(current.getKey()) != current.getValue())
{
iterator.remove();
}
}
}
}

View File

@ -198,6 +198,7 @@ public class KitKnight extends SmashKit
_calledEvents.add(newEvent);
Manager.GetPlugin().getServer().getPluginManager().callEvent(newEvent);
_calledEvents.remove(newEvent);
}
@EventHandler(priority = EventPriority.LOWEST)
@ -223,13 +224,13 @@ public class KitKnight extends SmashKit
Player player = (Player)horse.getPassenger();
//Damage Event
CustomDamageEvent newEvent = new CustomDamageEvent(player, event.GetDamagerEntity(true), event.GetProjectile(),
final CustomDamageEvent newEvent = new CustomDamageEvent(player, event.GetDamagerEntity(true), event.GetProjectile(),
event.GetCause(), event.GetDamageInitial(), true, false, false,
UtilEnt.getName(event.GetDamagerPlayer(true)), event.GetReason(), false);
_calledEvents.add(newEvent);
Manager.GetPlugin().getServer().getPluginManager().callEvent(newEvent);
_calledEvents.remove(newEvent);
//Add Knockback
event.AddKnockback("Knockback Multiplier", 1.2);
}

View File

@ -5,7 +5,6 @@ import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.ArcadeFormat;
import nautilus.game.arcade.ArcadeManager;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

View File

@ -37,8 +37,12 @@ public class GameChatManager implements Listener
}
}
public void HandleChat(AsyncPlayerChatEvent event, String filteredMessage)
@EventHandler
public void HandleChat(AsyncPlayerChatEvent event)
{
if (event.isCancelled())
return;
Player sender = event.getPlayer();
//Dead Prefix

View File

@ -2,9 +2,9 @@ package nautilus.game.capturethepig;
import org.bukkit.entity.Player;
import me.chiss.Core.Chat.Chat;
import me.chiss.Core.PlayerTagNamer.INameColorer;
import me.chiss.Core.Plugin.IRelation;
import mineplex.core.chat.Chat;
import nautilus.game.capturethepig.arena.CaptureThePigArenaParser;
import nautilus.game.capturethepig.arena.ICaptureThePigArena;
import nautilus.game.capturethepig.engine.CaptureThePigGameEngine;

View File

@ -2,7 +2,7 @@ package nautilus.game.dominate;
import org.bukkit.entity.Player;
import me.chiss.Core.Chat.Chat;
import mineplex.core.chat.Chat;
import nautilus.game.core.GamePlugin;
import nautilus.game.core.arena.ArenaManager;
import nautilus.game.dominate.arena.DominateArenaParser;

View File

@ -2,7 +2,6 @@ package nautilus.game.pvp;
import java.util.HashSet;
import me.chiss.Core.Chat.Chat;
import me.chiss.Core.Class.ClassFactory;
import me.chiss.Core.Config.Config;
import me.chiss.Core.Field.Field;
@ -31,6 +30,7 @@ import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.antistack.AntiStack;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;