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

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

View File

@ -96,13 +96,13 @@ public abstract class PlayerConnectionWrapAbstract extends PlayerConnection
// private final MinecraftServer minecraftServer; // private final MinecraftServer minecraftServer;
// Same argumentation as above. // Same argumentation as above.
// public boolean disconnected; // public boolean disconnected;
// This one is set in two locations only from within this class // This one is set in two locations only from within this class
// 1. public void a(String s, Object[] aobject) // 1. public void a(String s, Object[] aobject)
// 2. public void disconnect(String s) // 2. public void disconnect(String s)
// For that reason we update the reference upwards at those locations. // 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 // This one is set in two locations only from within this class
// 1. The constructor // 1. The constructor
// 2. public void a(Packet205ClientCommand packet205clientcommand) // 2. public void a(Packet205ClientCommand packet205clientcommand)
@ -162,251 +162,251 @@ public abstract class PlayerConnectionWrapAbstract extends PlayerConnection
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public CraftPlayer getPlayer() 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);
}
@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)
{ {
this.inner.onUnhandledPacket(packet); return this.inner.getPlayer();
} }
@Override @Override
public void sendPacket(Packet packet) public void e()
{ {
this.inner.sendPacket(packet); this.inner.e();
} }
@Override @Override
public void a(Packet16BlockItemSwitch packet16blockitemswitch) public void disconnect(String s)
{ {
this.inner.a(packet16blockitemswitch); this.inner.disconnect(s);
} this.disconnected = this.inner.disconnected;
}
@Override @Override
public void a(Packet3Chat packet3chat) public void a(Packet27PlayerInput packet27playerinput)
{
this.inner.a(packet3chat);
}
@Override
public void chat(String s, boolean async)
{
this.inner.chat(s, async);
}
public void handleCommandPublic(String s)
{ {
// CraftBukkit start this.inner.a(packet27playerinput);
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 @Override
public void a(Packet18ArmAnimation packet18armanimation) public void a(Packet10Flying packet10flying)
{
this.inner.a(packet18armanimation);
}
@Override
public void a(Packet19EntityAction packet19entityaction)
{
this.inner.a(packet19entityaction);
}
@Override
public void a(Packet255KickDisconnect packet255kickdisconnect)
{ {
this.inner.a(packet255kickdisconnect); this.inner.a(packet10flying);
} }
@Override @Override
public int lowPriorityCount() public void a(double d0, double d1, double d2, float f, float f1)
{
return this.inner.lowPriorityCount();
}
@Override
public void a(Packet7UseEntity packet7useentity)
{ {
this.inner.a(packet7useentity); this.inner.a(d0, d1, d2, f, f1);
} }
@Override @Override
public void a(Packet205ClientCommand packet205clientcommand) public void teleport(Location dest)
{ {
this.inner.a(packet205clientcommand); this.inner.teleport(dest);
this.player = this.inner.player; }
}
@Override @Override
public boolean b() public void a(Packet14BlockDig packet14blockdig)
{ {
return this.inner.b(); this.inner.a(packet14blockdig);
} }
@Override @Override
public void a(Packet9Respawn packet9respawn) public void a(Packet15Place packet15place)
{ {
this.inner.a(packet9respawn); this.inner.a(packet15place);
} }
@Override @Override
public void handleContainerClose(Packet101CloseWindow packet101closewindow) public void a(String s, Object[] aobject)
{ {
this.inner.handleContainerClose(packet101closewindow); this.inner.a(s, aobject);
} this.disconnected = this.inner.disconnected;
}
@Override @Override
public void a(Packet102WindowClick packet102windowclick) public void onUnhandledPacket(Packet packet)
{ {
this.inner.a(packet102windowclick); this.inner.onUnhandledPacket(packet);
} }
@Override @Override
public void a(Packet108ButtonClick packet108buttonclick) public void sendPacket(Packet packet)
{ {
this.inner.a(packet108buttonclick); this.inner.sendPacket(packet);
} }
@Override @Override
public void a(Packet107SetCreativeSlot packet107setcreativeslot) public void a(Packet16BlockItemSwitch packet16blockitemswitch)
{ {
this.inner.a(packet107setcreativeslot); this.inner.a(packet16blockitemswitch);
} }
@Override @Override
public void a(Packet106Transaction packet106transaction) public void a(Packet3Chat packet3chat)
{ {
this.inner.a(packet106transaction); this.inner.a(packet3chat);
} }
@Override @Override
public void a(Packet130UpdateSign packet130updatesign) public void chat(String s, boolean async)
{ {
this.inner.a(packet130updatesign); 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 @Override
public void a(Packet0KeepAlive packet0keepalive) public void a(Packet18ArmAnimation packet18armanimation)
{ {
this.inner.a(packet0keepalive); this.inner.a(packet18armanimation);
} }
@Override @Override
public boolean a() public void a(Packet19EntityAction packet19entityaction)
{ {
return this.inner.a(); this.inner.a(packet19entityaction);
} }
@Override @Override
public void a(Packet202Abilities packet202abilities) public void a(Packet255KickDisconnect packet255kickdisconnect)
{ {
this.inner.a(packet202abilities); this.inner.a(packet255kickdisconnect);
} }
@Override @Override
public void a(Packet203TabComplete packet203tabcomplete) public int lowPriorityCount()
{ {
this.inner.a(packet203tabcomplete); return this.inner.lowPriorityCount();
} }
@Override @Override
public void a(Packet204LocaleAndViewDistance packet204localeandviewdistance) public void a(Packet7UseEntity packet7useentity)
{ {
this.inner.a(packet204localeandviewdistance); this.inner.a(packet7useentity);
} }
@Override @Override
public void a(Packet250CustomPayload packet250custompayload) public void a(Packet205ClientCommand packet205clientcommand)
{ {
this.inner.a(packet250custompayload); this.inner.a(packet205clientcommand);
} this.player = this.inner.player;
}
@Override @Override
public boolean c() public boolean b()
{ {
return this.inner.c(); 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") @SuppressWarnings("rawtypes")
@Override @Override
public void a(Packet3Chat packet3chat) public void a(Packet3Chat packet3chat)
{ {
if (this.player.getChatFlags() == 2) { if (this.player.getChatFlags() == 2) {
this.sendPacket(new Packet3Chat(ChatMessage.e("chat.cannotSend").a(EnumChatFormat.RED))); this.sendPacket(new Packet3Chat(ChatMessage.e("chat.cannotSend").a(EnumChatFormat.RED)));
} else { } else {
String s = packet3chat.message; String s = packet3chat.message;
if (s.length() > 100) { if (s.length() > 100) {
// CraftBukkit start // CraftBukkit start
if (packet3chat.a_()) { if (packet3chat.a_()) {
Waitable waitable = new Waitable() { Waitable waitable = new Waitable() {
@Override @Override
protected Object evaluate() { protected Object evaluate() {
PlayerConnectionWrapMCore.this.disconnect("Chat message too long"); PlayerConnectionWrapMCore.this.disconnect("Chat message too long");
return null; return null;
} }
}; };
this.getMinecraftServer().processQueue.add(waitable); this.getMinecraftServer().processQueue.add(waitable);
try { try {
waitable.get(); waitable.get();
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} catch (ExecutionException e) { } catch (ExecutionException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} else { } else {
this.disconnect("Chat message too long"); this.disconnect("Chat message too long");
} }
// CraftBukkit end // CraftBukkit end
} else { } else {
s = StringUtils.normalizeSpace(s); s = StringUtils.normalizeSpace(s);
for (int i = 0; i < s.length(); ++i) { for (int i = 0; i < s.length(); ++i) {
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
// CraftBukkit start // CraftBukkit start
if (packet3chat.a_()) { if (packet3chat.a_()) {
Waitable waitable = new Waitable() { Waitable waitable = new Waitable() {
@Override @Override
protected Object evaluate() { protected Object evaluate() {
PlayerConnectionWrapMCore.this.disconnect("Illegal characters in chat"); PlayerConnectionWrapMCore.this.disconnect("Illegal characters in chat");
return null; return null;
} }
}; };
this.getMinecraftServer().processQueue.add(waitable); this.getMinecraftServer().processQueue.add(waitable);
try { try {
waitable.get(); waitable.get();
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} catch (ExecutionException e) { } catch (ExecutionException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} else { } else {
this.disconnect("Illegal characters in chat"); this.disconnect("Illegal characters in chat");
} }
// CraftBukkit end // CraftBukkit end
return; return;
} }
} }
// CraftBukkit start // CraftBukkit start
if (this.player.getChatFlags() == 1 && !s.startsWith("/")) { if (this.player.getChatFlags() == 1 && !s.startsWith("/")) {
this.sendPacket(new Packet3Chat(ChatMessage.e("chat.cannotSend").a(EnumChatFormat.RED))); this.sendPacket(new Packet3Chat(ChatMessage.e("chat.cannotSend").a(EnumChatFormat.RED)));
return; return;
} }
this.chat(s, packet3chat.a_()); this.chat(s, packet3chat.a_());
// This section stays because it is only applicable to packets // 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 (this.getChatSpamField().addAndGet(this, 20) > 200 && !this.getMinecraftServer().getPlayerList().isOp(this.player.getName())) { // CraftBukkit use thread-safe spam
if (packet3chat.a_()) { if (packet3chat.a_()) {
Waitable waitable = new Waitable() { Waitable waitable = new Waitable() {
@Override @Override
protected Object evaluate() { protected Object evaluate() {
PlayerConnectionWrapMCore.this.disconnect("disconnect.spam"); PlayerConnectionWrapMCore.this.disconnect("disconnect.spam");
return null; return null;
} }
}; };
this.getMinecraftServer().processQueue.add(waitable); this.getMinecraftServer().processQueue.add(waitable);
try { try {
waitable.get(); waitable.get();
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} catch (ExecutionException e) { } catch (ExecutionException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} else { } else {
this.disconnect("disconnect.spam"); this.disconnect("disconnect.spam");
} }
} }
} }
} }
} }
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Override @Override
public void chat(String s, boolean async) public void chat(String s, boolean async)
{ {
if (!this.player.dead) { if (!this.player.dead) {
if (s.length() == 0) { if (s.length() == 0) {
this.getMinecraftServer().getLogger().warning(this.player.getName() + " tried to send an empty message"); this.getMinecraftServer().getLogger().warning(this.player.getName() + " tried to send an empty message");
return; return;
} }
if (getPlayer().isConversing()) { if (getPlayer().isConversing()) {
getPlayer().acceptConversationInput(s); getPlayer().acceptConversationInput(s);
return; return;
} }
if (s.startsWith("/")) { if (s.startsWith("/")) {
this.handleCommandPublic(s); this.handleCommandPublic(s);
return; return;
} else { } else {
Player player = this.getPlayer(); Player player = this.getPlayer();
AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet()); AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet());
this.getServer().getPluginManager().callEvent(event); this.getServer().getPluginManager().callEvent(event);
if (PlayerChatEvent.getHandlerList().getRegisteredListeners().length != 0) { if (PlayerChatEvent.getHandlerList().getRegisteredListeners().length != 0) {
// Evil plugins still listening to deprecated event // Evil plugins still listening to deprecated event
final PlayerChatEvent queueEvent = new PlayerChatEvent(player, event.getMessage(), event.getFormat(), event.getRecipients()); final PlayerChatEvent queueEvent = new PlayerChatEvent(player, event.getMessage(), event.getFormat(), event.getRecipients());
queueEvent.setCancelled(event.isCancelled()); queueEvent.setCancelled(event.isCancelled());
Waitable waitable = new Waitable() { Waitable waitable = new Waitable() {
@Override @Override
protected Object evaluate() { protected Object evaluate() {
org.bukkit.Bukkit.getPluginManager().callEvent(queueEvent); org.bukkit.Bukkit.getPluginManager().callEvent(queueEvent);
if (queueEvent.isCancelled()) { if (queueEvent.isCancelled()) {
return null; return null;
} }
// MCore - start // MCore - start
distributeMessage(false, queueEvent.getPlayer(), queueEvent.getRecipients(), queueEvent.getMessage(), queueEvent.getFormat()); distributeMessage(false, queueEvent.getPlayer(), queueEvent.getRecipients(), queueEvent.getMessage(), queueEvent.getFormat());
/*String message = String.format(queueEvent.getFormat(), queueEvent.getPlayer().getDisplayName(), queueEvent.getMessage()); /*String message = String.format(queueEvent.getFormat(), queueEvent.getPlayer().getDisplayName(), queueEvent.getMessage());
minecraftServerPublic.console.sendMessage(message); minecraftServerPublic.console.sendMessage(message);
if (((LazyPlayerSet) queueEvent.getRecipients()).isLazy()) { if (((LazyPlayerSet) queueEvent.getRecipients()).isLazy()) {
for (Object player : minecraftServerPublic.getPlayerList().players) { for (Object player : minecraftServerPublic.getPlayerList().players) {
((EntityPlayer) player).sendMessage(ChatMessage.d(message)); ((EntityPlayer) player).sendMessage(ChatMessage.d(message));
} }
} else { } else {
for (Player player : queueEvent.getRecipients()) { for (Player player : queueEvent.getRecipients()) {
player.sendMessage(message); player.sendMessage(message);
} }
}*/ }*/
// MCore - end // MCore - end
return null; return null;
}}; }};
if (async) { if (async) {
this.getMinecraftServer().processQueue.add(waitable); this.getMinecraftServer().processQueue.add(waitable);
} else { } else {
waitable.run(); waitable.run();
} }
try { try {
waitable.get(); waitable.get();
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); // This is proper habit for java. If we aren't handling it, pass it on! Thread.currentThread().interrupt(); // This is proper habit for java. If we aren't handling it, pass it on!
} catch (ExecutionException e) { } catch (ExecutionException e) {
throw new RuntimeException("Exception processing chat event", e.getCause()); throw new RuntimeException("Exception processing chat event", e.getCause());
} }
} else { } else {
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
} }
// MCore - start // MCore - start
distributeMessage(async, event.getPlayer(), event.getRecipients(), event.getMessage(), event.getFormat()); distributeMessage(async, event.getPlayer(), event.getRecipients(), event.getMessage(), event.getFormat());
/*s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()); /*s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
minecraftServerPublic.console.sendMessage(s); minecraftServerPublic.console.sendMessage(s);
if (((LazyPlayerSet) event.getRecipients()).isLazy()) { if (((LazyPlayerSet) event.getRecipients()).isLazy()) {
for (Object recipient : minecraftServerPublic.getPlayerList().players) { for (Object recipient : minecraftServerPublic.getPlayerList().players) {
((EntityPlayer) recipient).sendMessage(ChatMessage.d(s)); ((EntityPlayer) recipient).sendMessage(ChatMessage.d(s));
} }
} else { } else {
for (Player recipient : event.getRecipients()) { for (Player recipient : event.getRecipients()) {
recipient.sendMessage(s); recipient.sendMessage(s);
} }
}*/ }*/
// MCore - end // MCore - end
} }
} }
} }
return; return;
} }
} }