Fix indent

This commit is contained in:
Olof Larsson 2013-08-22 13:53:19 +02:00
parent 8b7b19fada
commit 443c800a90
3 changed files with 396 additions and 396 deletions

View File

@ -20,18 +20,18 @@ public class MCorePlayerToRecipientChatEvent extends MCoreEvent
private final Player sender;
public Player getSender() { return this.sender; }
private final CommandSender recipient;
public CommandSender getRecipient() { return this.recipient; }
private final CommandSender recipient;
public CommandSender getRecipient() { return this.recipient; }
private String message;
public String getMessage() { return this.message; }
public void setMessage(String message) { this.message = message; }
private String format;
public String getFormat() { return this.format; }
private String format;
public String getFormat() { return this.format; }
public void setFormat(String format) { this.format = format; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //

View File

@ -96,13 +96,13 @@ public abstract class PlayerConnectionWrapAbstract extends PlayerConnection
// private final MinecraftServer minecraftServer;
// Same argumentation as above.
// public boolean disconnected;
// public boolean disconnected;
// This one is set in two locations only from within this class
// 1. public void a(String s, Object[] aobject)
// 2. public void disconnect(String s)
// For that reason we update the reference upwards at those locations.
// public EntityPlayer player;
// public EntityPlayer player;
// This one is set in two locations only from within this class
// 1. The constructor
// 2. public void a(Packet205ClientCommand packet205clientcommand)
@ -162,251 +162,251 @@ public abstract class PlayerConnectionWrapAbstract extends PlayerConnection
// -------------------------------------------- //
@Override
public CraftPlayer getPlayer()
{
return this.inner.getPlayer();
}
@Override
public void e()
{
this.inner.e();
}
@Override
public void disconnect(String s)
{
this.inner.disconnect(s);
this.disconnected = this.inner.disconnected;
}
@Override
public void a(Packet27PlayerInput packet27playerinput)
{
this.inner.a(packet27playerinput);
}
@Override
public void a(Packet10Flying packet10flying)
{
this.inner.a(packet10flying);
}
public CraftPlayer getPlayer()
{
return this.inner.getPlayer();
}
@Override
public void a(double d0, double d1, double d2, float f, float f1)
{
this.inner.a(d0, d1, d2, f, f1);
}
@Override
public void teleport(Location dest)
{
this.inner.teleport(dest);
}
@Override
public void a(Packet14BlockDig packet14blockdig)
{
this.inner.a(packet14blockdig);
}
@Override
public void a(Packet15Place packet15place)
{
this.inner.a(packet15place);
}
@Override
public void a(String s, Object[] aobject)
{
this.inner.a(s, aobject);
this.disconnected = this.inner.disconnected;
}
@Override
public void onUnhandledPacket(Packet packet)
public void e()
{
this.inner.onUnhandledPacket(packet);
}
@Override
public void sendPacket(Packet packet)
{
this.inner.sendPacket(packet);
}
@Override
public void a(Packet16BlockItemSwitch packet16blockitemswitch)
{
this.inner.a(packet16blockitemswitch);
}
@Override
public void a(Packet3Chat packet3chat)
{
this.inner.a(packet3chat);
}
@Override
public void chat(String s, boolean async)
{
this.inner.chat(s, async);
}
this.inner.e();
}
public void handleCommandPublic(String s)
@Override
public void disconnect(String s)
{
// CraftBukkit start
CraftPlayer player = this.getPlayer();
PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, s, new LazyPlayerSet());
this.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
try {
this.getMinecraftServer().getLogger().info(event.getPlayer().getName() + " issued server command: " + event.getMessage()); // CraftBukkit
if (this.getServer().dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) {
return;
}
} catch (org.bukkit.command.CommandException ex) {
player.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
return;
}
// CraftBukkit end
/* CraftBukkit start - No longer needed as we have already handled it in server.dispatchServerCommand above.
this.minecraftServer.getCommandHandler().a(this.player, s);
// CraftBukkit end */
}
this.inner.disconnect(s);
this.disconnected = this.inner.disconnected;
}
@Override
public void a(Packet18ArmAnimation packet18armanimation)
{
this.inner.a(packet18armanimation);
}
@Override
public void a(Packet19EntityAction packet19entityaction)
{
this.inner.a(packet19entityaction);
}
@Override
public void a(Packet255KickDisconnect packet255kickdisconnect)
public void a(Packet27PlayerInput packet27playerinput)
{
this.inner.a(packet255kickdisconnect);
}
this.inner.a(packet27playerinput);
}
@Override
public int lowPriorityCount()
{
return this.inner.lowPriorityCount();
}
@Override
public void a(Packet7UseEntity packet7useentity)
public void a(Packet10Flying packet10flying)
{
this.inner.a(packet7useentity);
}
this.inner.a(packet10flying);
}
@Override
public void a(Packet205ClientCommand packet205clientcommand)
{
this.inner.a(packet205clientcommand);
this.player = this.inner.player;
}
public void a(double d0, double d1, double d2, float f, float f1)
{
this.inner.a(d0, d1, d2, f, f1);
}
@Override
public boolean b()
{
return this.inner.b();
}
public void teleport(Location dest)
{
this.inner.teleport(dest);
}
@Override
public void a(Packet9Respawn packet9respawn)
{
this.inner.a(packet9respawn);
}
public void a(Packet14BlockDig packet14blockdig)
{
this.inner.a(packet14blockdig);
}
@Override
public void handleContainerClose(Packet101CloseWindow packet101closewindow)
{
this.inner.handleContainerClose(packet101closewindow);
}
public void a(Packet15Place packet15place)
{
this.inner.a(packet15place);
}
@Override
public void a(Packet102WindowClick packet102windowclick)
{
this.inner.a(packet102windowclick);
}
public void a(String s, Object[] aobject)
{
this.inner.a(s, aobject);
this.disconnected = this.inner.disconnected;
}
@Override
public void a(Packet108ButtonClick packet108buttonclick)
{
this.inner.a(packet108buttonclick);
}
public void onUnhandledPacket(Packet packet)
{
this.inner.onUnhandledPacket(packet);
}
@Override
public void a(Packet107SetCreativeSlot packet107setcreativeslot)
{
this.inner.a(packet107setcreativeslot);
}
public void sendPacket(Packet packet)
{
this.inner.sendPacket(packet);
}
@Override
public void a(Packet106Transaction packet106transaction)
{
this.inner.a(packet106transaction);
}
public void a(Packet16BlockItemSwitch packet16blockitemswitch)
{
this.inner.a(packet16blockitemswitch);
}
@Override
public void a(Packet130UpdateSign packet130updatesign)
{
this.inner.a(packet130updatesign);
}
public void a(Packet3Chat packet3chat)
{
this.inner.a(packet3chat);
}
@Override
public void a(Packet0KeepAlive packet0keepalive)
{
this.inner.a(packet0keepalive);
}
public void chat(String s, boolean async)
{
this.inner.chat(s, async);
}
public void handleCommandPublic(String s)
{
// CraftBukkit start
CraftPlayer player = this.getPlayer();
PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, s, new LazyPlayerSet());
this.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
try {
this.getMinecraftServer().getLogger().info(event.getPlayer().getName() + " issued server command: " + event.getMessage()); // CraftBukkit
if (this.getServer().dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) {
return;
}
} catch (org.bukkit.command.CommandException ex) {
player.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
return;
}
// CraftBukkit end
/* CraftBukkit start - No longer needed as we have already handled it in server.dispatchServerCommand above.
this.minecraftServer.getCommandHandler().a(this.player, s);
// CraftBukkit end */
}
@Override
public boolean a()
{
return this.inner.a();
}
public void a(Packet18ArmAnimation packet18armanimation)
{
this.inner.a(packet18armanimation);
}
@Override
public void a(Packet202Abilities packet202abilities)
{
this.inner.a(packet202abilities);
}
public void a(Packet19EntityAction packet19entityaction)
{
this.inner.a(packet19entityaction);
}
@Override
public void a(Packet203TabComplete packet203tabcomplete)
{
this.inner.a(packet203tabcomplete);
}
public void a(Packet255KickDisconnect packet255kickdisconnect)
{
this.inner.a(packet255kickdisconnect);
}
@Override
public void a(Packet204LocaleAndViewDistance packet204localeandviewdistance)
{
this.inner.a(packet204localeandviewdistance);
}
public int lowPriorityCount()
{
return this.inner.lowPriorityCount();
}
@Override
public void a(Packet250CustomPayload packet250custompayload)
{
this.inner.a(packet250custompayload);
}
public void a(Packet7UseEntity packet7useentity)
{
this.inner.a(packet7useentity);
}
@Override
public boolean c()
{
return this.inner.c();
}
public void a(Packet205ClientCommand packet205clientcommand)
{
this.inner.a(packet205clientcommand);
this.player = this.inner.player;
}
@Override
public boolean b()
{
return this.inner.b();
}
@Override
public void a(Packet9Respawn packet9respawn)
{
this.inner.a(packet9respawn);
}
@Override
public void handleContainerClose(Packet101CloseWindow packet101closewindow)
{
this.inner.handleContainerClose(packet101closewindow);
}
@Override
public void a(Packet102WindowClick packet102windowclick)
{
this.inner.a(packet102windowclick);
}
@Override
public void a(Packet108ButtonClick packet108buttonclick)
{
this.inner.a(packet108buttonclick);
}
@Override
public void a(Packet107SetCreativeSlot packet107setcreativeslot)
{
this.inner.a(packet107setcreativeslot);
}
@Override
public void a(Packet106Transaction packet106transaction)
{
this.inner.a(packet106transaction);
}
@Override
public void a(Packet130UpdateSign packet130updatesign)
{
this.inner.a(packet130updatesign);
}
@Override
public void a(Packet0KeepAlive packet0keepalive)
{
this.inner.a(packet0keepalive);
}
@Override
public boolean a()
{
return this.inner.a();
}
@Override
public void a(Packet202Abilities packet202abilities)
{
this.inner.a(packet202abilities);
}
@Override
public void a(Packet203TabComplete packet203tabcomplete)
{
this.inner.a(packet203tabcomplete);
}
@Override
public void a(Packet204LocaleAndViewDistance packet204localeandviewdistance)
{
this.inner.a(packet204localeandviewdistance);
}
@Override
public void a(Packet250CustomPayload packet250custompayload)
{
this.inner.a(packet250custompayload);
}
@Override
public boolean c()
{
return this.inner.c();
}
}

View File

@ -81,193 +81,193 @@ public class PlayerConnectionWrapMCore extends PlayerConnectionWrapAbstract
@SuppressWarnings("rawtypes")
@Override
public void a(Packet3Chat packet3chat)
{
if (this.player.getChatFlags() == 2) {
this.sendPacket(new Packet3Chat(ChatMessage.e("chat.cannotSend").a(EnumChatFormat.RED)));
} else {
String s = packet3chat.message;
public void a(Packet3Chat packet3chat)
{
if (this.player.getChatFlags() == 2) {
this.sendPacket(new Packet3Chat(ChatMessage.e("chat.cannotSend").a(EnumChatFormat.RED)));
} else {
String s = packet3chat.message;
if (s.length() > 100) {
// CraftBukkit start
if (packet3chat.a_()) {
Waitable waitable = new Waitable() {
@Override
protected Object evaluate() {
PlayerConnectionWrapMCore.this.disconnect("Chat message too long");
return null;
}
};
if (s.length() > 100) {
// CraftBukkit start
if (packet3chat.a_()) {
Waitable waitable = new Waitable() {
@Override
protected Object evaluate() {
PlayerConnectionWrapMCore.this.disconnect("Chat message too long");
return null;
}
};
this.getMinecraftServer().processQueue.add(waitable);
this.getMinecraftServer().processQueue.add(waitable);
try {
waitable.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
} else {
this.disconnect("Chat message too long");
}
// CraftBukkit end
} else {
s = StringUtils.normalizeSpace(s);
try {
waitable.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
} else {
this.disconnect("Chat message too long");
}
// CraftBukkit end
} else {
s = StringUtils.normalizeSpace(s);
for (int i = 0; i < s.length(); ++i) {
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
// CraftBukkit start
if (packet3chat.a_()) {
Waitable waitable = new Waitable() {
@Override
protected Object evaluate() {
PlayerConnectionWrapMCore.this.disconnect("Illegal characters in chat");
return null;
}
};
for (int i = 0; i < s.length(); ++i) {
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
// CraftBukkit start
if (packet3chat.a_()) {
Waitable waitable = new Waitable() {
@Override
protected Object evaluate() {
PlayerConnectionWrapMCore.this.disconnect("Illegal characters in chat");
return null;
}
};
this.getMinecraftServer().processQueue.add(waitable);
this.getMinecraftServer().processQueue.add(waitable);
try {
waitable.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
} else {
this.disconnect("Illegal characters in chat");
}
// CraftBukkit end
return;
}
}
try {
waitable.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
} else {
this.disconnect("Illegal characters in chat");
}
// CraftBukkit end
return;
}
}
// CraftBukkit start
if (this.player.getChatFlags() == 1 && !s.startsWith("/")) {
this.sendPacket(new Packet3Chat(ChatMessage.e("chat.cannotSend").a(EnumChatFormat.RED)));
return;
}
// CraftBukkit start
if (this.player.getChatFlags() == 1 && !s.startsWith("/")) {
this.sendPacket(new Packet3Chat(ChatMessage.e("chat.cannotSend").a(EnumChatFormat.RED)));
return;
}
this.chat(s, packet3chat.a_());
this.chat(s, packet3chat.a_());
// This section stays because it is only applicable to packets
if (this.getChatSpamField().addAndGet(this, 20) > 200 && !this.getMinecraftServer().getPlayerList().isOp(this.player.getName())) { // CraftBukkit use thread-safe spam
if (packet3chat.a_()) {
Waitable waitable = new Waitable() {
@Override
protected Object evaluate() {
PlayerConnectionWrapMCore.this.disconnect("disconnect.spam");
return null;
}
};
// This section stays because it is only applicable to packets
if (this.getChatSpamField().addAndGet(this, 20) > 200 && !this.getMinecraftServer().getPlayerList().isOp(this.player.getName())) { // CraftBukkit use thread-safe spam
if (packet3chat.a_()) {
Waitable waitable = new Waitable() {
@Override
protected Object evaluate() {
PlayerConnectionWrapMCore.this.disconnect("disconnect.spam");
return null;
}
};
this.getMinecraftServer().processQueue.add(waitable);
this.getMinecraftServer().processQueue.add(waitable);
try {
waitable.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
} else {
this.disconnect("disconnect.spam");
}
}
}
}
}
try {
waitable.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
} else {
this.disconnect("disconnect.spam");
}
}
}
}
}
@SuppressWarnings("rawtypes")
@Override
public void chat(String s, boolean async)
{
if (!this.player.dead) {
if (s.length() == 0) {
this.getMinecraftServer().getLogger().warning(this.player.getName() + " tried to send an empty message");
return;
}
if (s.length() == 0) {
this.getMinecraftServer().getLogger().warning(this.player.getName() + " tried to send an empty message");
return;
}
if (getPlayer().isConversing()) {
getPlayer().acceptConversationInput(s);
return;
}
if (getPlayer().isConversing()) {
getPlayer().acceptConversationInput(s);
return;
}
if (s.startsWith("/")) {
this.handleCommandPublic(s);
return;
} else {
Player player = this.getPlayer();
AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet());
this.getServer().getPluginManager().callEvent(event);
if (s.startsWith("/")) {
this.handleCommandPublic(s);
return;
} else {
Player player = this.getPlayer();
AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet());
this.getServer().getPluginManager().callEvent(event);
if (PlayerChatEvent.getHandlerList().getRegisteredListeners().length != 0) {
// Evil plugins still listening to deprecated event
final PlayerChatEvent queueEvent = new PlayerChatEvent(player, event.getMessage(), event.getFormat(), event.getRecipients());
queueEvent.setCancelled(event.isCancelled());
Waitable waitable = new Waitable() {
@Override
protected Object evaluate() {
org.bukkit.Bukkit.getPluginManager().callEvent(queueEvent);
if (PlayerChatEvent.getHandlerList().getRegisteredListeners().length != 0) {
// Evil plugins still listening to deprecated event
final PlayerChatEvent queueEvent = new PlayerChatEvent(player, event.getMessage(), event.getFormat(), event.getRecipients());
queueEvent.setCancelled(event.isCancelled());
Waitable waitable = new Waitable() {
@Override
protected Object evaluate() {
org.bukkit.Bukkit.getPluginManager().callEvent(queueEvent);
if (queueEvent.isCancelled()) {
return null;
}
// MCore - start
distributeMessage(false, queueEvent.getPlayer(), queueEvent.getRecipients(), queueEvent.getMessage(), queueEvent.getFormat());
/*String message = String.format(queueEvent.getFormat(), queueEvent.getPlayer().getDisplayName(), queueEvent.getMessage());
minecraftServerPublic.console.sendMessage(message);
if (((LazyPlayerSet) queueEvent.getRecipients()).isLazy()) {
for (Object player : minecraftServerPublic.getPlayerList().players) {
((EntityPlayer) player).sendMessage(ChatMessage.d(message));
}
} else {
for (Player player : queueEvent.getRecipients()) {
player.sendMessage(message);
}
}*/
// MCore - end
return null;
}};
if (async) {
this.getMinecraftServer().processQueue.add(waitable);
} else {
waitable.run();
}
try {
waitable.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // This is proper habit for java. If we aren't handling it, pass it on!
} catch (ExecutionException e) {
throw new RuntimeException("Exception processing chat event", e.getCause());
}
} else {
if (event.isCancelled()) {
return;
}
// MCore - start
distributeMessage(async, event.getPlayer(), event.getRecipients(), event.getMessage(), event.getFormat());
/*s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
minecraftServerPublic.console.sendMessage(s);
if (((LazyPlayerSet) event.getRecipients()).isLazy()) {
for (Object recipient : minecraftServerPublic.getPlayerList().players) {
((EntityPlayer) recipient).sendMessage(ChatMessage.d(s));
}
} else {
for (Player recipient : event.getRecipients()) {
recipient.sendMessage(s);
}
}*/
// MCore - end
}
}
}
if (queueEvent.isCancelled()) {
return null;
}
// MCore - start
distributeMessage(false, queueEvent.getPlayer(), queueEvent.getRecipients(), queueEvent.getMessage(), queueEvent.getFormat());
/*String message = String.format(queueEvent.getFormat(), queueEvent.getPlayer().getDisplayName(), queueEvent.getMessage());
minecraftServerPublic.console.sendMessage(message);
if (((LazyPlayerSet) queueEvent.getRecipients()).isLazy()) {
for (Object player : minecraftServerPublic.getPlayerList().players) {
((EntityPlayer) player).sendMessage(ChatMessage.d(message));
}
} else {
for (Player player : queueEvent.getRecipients()) {
player.sendMessage(message);
}
}*/
// MCore - end
return null;
}};
if (async) {
this.getMinecraftServer().processQueue.add(waitable);
} else {
waitable.run();
}
try {
waitable.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // This is proper habit for java. If we aren't handling it, pass it on!
} catch (ExecutionException e) {
throw new RuntimeException("Exception processing chat event", e.getCause());
}
} else {
if (event.isCancelled()) {
return;
}
// MCore - start
distributeMessage(async, event.getPlayer(), event.getRecipients(), event.getMessage(), event.getFormat());
/*s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
minecraftServerPublic.console.sendMessage(s);
if (((LazyPlayerSet) event.getRecipients()).isLazy()) {
for (Object recipient : minecraftServerPublic.getPlayerList().players) {
((EntityPlayer) recipient).sendMessage(ChatMessage.d(s));
}
} else {
for (Player recipient : event.getRecipients()) {
recipient.sendMessage(s);
}
}*/
// MCore - end
}
}
}
return;
return;
}
}