3
0

Initial commit (Forge 1291).

This commit is contained in:
gamerforEA
2015-03-22 20:38:04 +03:00
commit 16773ead6a
611 changed files with 64826 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,249 @@
--- ../src-base/minecraft/net/minecraft/server/dedicated/DedicatedServer.java
+++ ../src-work/minecraft/net/minecraft/server/dedicated/DedicatedServer.java
@@ -34,9 +34,19 @@
import net.minecraft.world.World;
import net.minecraft.world.WorldSettings;
import net.minecraft.world.WorldType;
+import net.minecraft.world.chunk.storage.AnvilSaveConverter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import java.io.PrintStream;
+import org.apache.logging.log4j.Level;
+
+import org.bukkit.craftbukkit.LoggerOutputStream;
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
+import org.bukkit.event.server.ServerCommandEvent;
+// CraftBukkit end
+
@SideOnly(Side.SERVER)
public class DedicatedServer extends MinecraftServer implements IServer
{
@@ -44,7 +54,7 @@
public final List pendingCommandList = Collections.synchronizedList(new ArrayList());
private RConThreadQuery theRConThreadQuery;
private RConThreadMain theRConThreadMain;
- private PropertyManager settings;
+ public PropertyManager settings; // CraftBukkit - private -> public
private ServerEula field_154332_n;
private boolean canSpawnStructures;
private WorldSettings.GameType gameType;
@@ -52,9 +62,12 @@
public static boolean allowPlayerLogins = false;
private static final String __OBFID = "CL_00001784";
- public DedicatedServer(File p_i1508_1_)
+ // CraftBukkit start - Signature changed
+ public DedicatedServer(joptsimple.OptionSet options)
{
- super(p_i1508_1_, Proxy.NO_PROXY);
+ super(options, Proxy.NO_PROXY);
+ // super(p_i1508_1_, Proxy.NO_PROXY);
+ // CraftBukkit end
Thread thread = new Thread("Server Infinisleeper")
{
private static final String __OBFID = "CL_00001787";
@@ -82,31 +95,77 @@
};
}
- protected boolean startServer() throws IOException
+ protected boolean startServer() throws java.net.UnknownHostException // CraftBukkit - throws UnknownHostException
{
Thread thread = new Thread("Server console handler")
{
private static final String __OBFID = "CL_00001786";
+ final DedicatedServer server = DedicatedServer.this;
public void run()
{
- BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in));
- String s4;
+ // CraftBukkit start
+ if (!useConsole)
+ {
+ return;
+ }
+ // CraftBukkit end
+ jline.console.ConsoleReader bufferedreader = this.server.reader; // CraftBukkit
+ String s;
+
try
{
- while (!DedicatedServer.this.isServerStopped() && DedicatedServer.this.isServerRunning() && (s4 = bufferedreader.readLine()) != null)
+ // CraftBukkit start - JLine disabling compatibility
+ while (!this.server.isServerStopped() && this.server.isServerRunning())
{
- DedicatedServer.this.addPendingCommand(s4, DedicatedServer.this);
+ if (useJline)
+ {
+ s = bufferedreader.readLine(">", null);
+ }
+ else
+ {
+ s = bufferedreader.readLine();
+ }
+ if (s != null)
+ {
+ this.server.addPendingCommand(s, this.server);
+ }
+ // CraftBukkit end
}
+
}
- catch (IOException ioexception1)
+ catch (IOException ioexception)
{
- DedicatedServer.field_155771_h.error("Exception handling console input", ioexception1);
+ DedicatedServer.field_155771_h.error("Exception handling console input", ioexception);
}
}
};
thread.setDaemon(true);
thread.start();
+ // CraftBukkit start - TODO: handle command-line logging arguments
+ java.util.logging.Logger global = java.util.logging.Logger.getLogger("");
+ global.setUseParentHandlers(false);
+
+ for (java.util.logging.Handler handler : global.getHandlers())
+ {
+ global.removeHandler(handler);
+ }
+
+ global.addHandler(new org.bukkit.craftbukkit.util.ForwardLogHandler());
+ final org.apache.logging.log4j.core.Logger logger = ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger());
+
+ for (org.apache.logging.log4j.core.Appender appender : logger.getAppenders().values())
+ {
+ if (appender instanceof org.apache.logging.log4j.core.appender.ConsoleAppender)
+ {
+ logger.removeAppender(appender);
+ }
+ }
+
+ new Thread(new org.bukkit.craftbukkit.util.TerminalConsoleWriterThread(System.out, this.reader)).start();
+ System.setOut(new PrintStream(new LoggerOutputStream(logger, Level.INFO), true));
+ System.setErr(new PrintStream(new LoggerOutputStream(logger, Level.WARN), true));
+ // CraftBukkit end
field_155771_h.info("Starting minecraft server version 1.7.10");
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L)
@@ -117,7 +176,7 @@
FMLCommonHandler.instance().onServerStart(this);
field_155771_h.info("Loading properties");
- this.settings = new PropertyManager(new File("server.properties"));
+ this.settings = new PropertyManager(this.options); // CraftBukkit - CLI argument support
this.field_154332_n = new ServerEula(new File("eula.txt"));
if (!this.field_154332_n.func_154346_a())
@@ -172,6 +231,16 @@
this.setServerPort(this.settings.getIntProperty("server-port", 25565));
}
+ // Spigot start
+ this.func_152361_a((ServerConfigurationManager) (new DedicatedPlayerList(this)));
+ org.spigotmc.SpigotConfig.init();
+ org.spigotmc.SpigotConfig.registerCommands();
+ // Spigot end
+ // Cauldron start
+ this.cauldronConfig.registerCommands();
+ this.tileEntityConfig.registerCommands();
+ // Cauldron end
+
field_155771_h.info("Generating keypair");
this.setKeyPair(CryptManager.createNewKeyPair());
field_155771_h.info("Starting Minecraft server on " + (this.getServerHostname().length() == 0 ? "*" : this.getServerHostname()) + ":" + this.getServerPort());
@@ -180,7 +249,7 @@
{
this.func_147137_ag().addLanEndpoint(inetaddress, this.getServerPort());
}
- catch (IOException ioexception)
+ catch (Throwable ioexception) // CraftBukkit - IOException -> Throwable
{
field_155771_h.warn("**** FAILED TO BIND TO PORT!");
field_155771_h.warn("The exception was: {}", new Object[] {ioexception.toString()});
@@ -196,10 +265,17 @@
field_155771_h.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
}
- if (this.func_152368_aE())
+ try
{
- this.func_152358_ax().func_152658_c();
+ if (this.func_152368_aE())
+ {
+ this.func_152358_ax().func_152658_c();
+ }
}
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
if (!PreYggdrasilConverter.func_152714_a(this.settings))
{
@@ -208,7 +284,8 @@
else
{
FMLCommonHandler.instance().onServerStarted();
- this.func_152361_a(new DedicatedPlayerList(this));
+ // this.func_152361_a(new DedicatedPlayerList(this)); // CraftBukkit - moved up
+ this.anvilConverterForAnvilFile = new AnvilSaveConverter(server.getWorldContainer()); // CraftBukkit - moved from MinecraftServer constructor
long j = System.nanoTime();
if (this.getFolderName() == null)
@@ -274,11 +351,30 @@
this.theRConThreadMain.startThread();
}
+ // CraftBukkit start
+ if (this.server.getBukkitSpawnRadius() > -1)
+ {
+ field_155771_h
+ .info("'settings.spawn-radius' in bukkit.yml has been moved to 'spawn-protection' in server.properties. I will move your config for you.");
+ this.settings.serverProperties.remove("spawn-protection");
+ this.settings.getIntProperty("spawn-protection", this.server.getBukkitSpawnRadius());
+ this.server.removeBukkitSpawnRadius();
+ this.settings.saveProperties();
+ }
+ // CraftBukkit end
+
return FMLCommonHandler.instance().handleServerStarting(this);
}
}
}
+ // CraftBukkit start
+ public PropertyManager getPropertyManager()
+ {
+ return this.settings;
+ }
+ // CraftBukkit end
+
public boolean canStructuresSpawn()
{
return this.canSpawnStructures;
@@ -364,11 +460,19 @@
public void executePendingCommands()
{
+ SpigotTimings.serverCommandTimer.startTiming(); // Spigot
while (!this.pendingCommandList.isEmpty())
{
- ServerCommand servercommand = (ServerCommand)this.pendingCommandList.remove(0);
- this.getCommandManager().executeCommand(servercommand.sender, servercommand.command);
+ ServerCommand servercommand = (ServerCommand) this.pendingCommandList.remove(0);
+ // CraftBukkit start - ServerCommand for preprocessing
+ ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.command);
+ this.server.getPluginManager().callEvent(event);
+ servercommand = new ServerCommand(event.getCommand(), servercommand.sender);
+ // this.getCommandManager().executeCommand(servercommand.sender, servercommand.command); // Called in dispatchServerCommand
+ this.server.dispatchServerCommand(this.console, servercommand);
+ // CraftBukkit end
}
+ SpigotTimings.serverCommandTimer.stopTiming(); // Spigot
}
public boolean isDedicatedServer()

View File

@ -0,0 +1,98 @@
--- ../src-base/minecraft/net/minecraft/server/dedicated/PropertyManager.java
+++ ../src-work/minecraft/net/minecraft/server/dedicated/PropertyManager.java
@@ -10,11 +10,13 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import joptsimple.OptionSet; // CraftBukkit
+
@SideOnly(Side.SERVER)
public class PropertyManager
{
private static final Logger field_164440_a = LogManager.getLogger();
- private final Properties serverProperties = new Properties();
+ public final Properties serverProperties = new Properties(); // CraftBukkit - private -> public
private final File serverPropertiesFile;
private static final String __OBFID = "CL_00001782";
@@ -58,6 +60,26 @@
}
}
+ // CraftBukkit start
+ private OptionSet options = null;
+
+ public PropertyManager(final OptionSet options)
+ {
+ this((File) options.valueOf("config"));
+ this.options = options;
+ }
+
+ private <T> T getOverride(String name, T value)
+ {
+ if ((this.options != null) && (this.options.has(name)))
+ {
+ return (T) this.options.valueOf(name);
+ }
+
+ return value;
+ }
+ // CraftBukkit end
+
public void generateNewProperties()
{
field_164440_a.info("Generating new properties file");
@@ -70,6 +92,13 @@
try
{
+ // CraftBukkit start - Don't attempt writing to file if it's read only
+ if (this.serverPropertiesFile.exists() && !this.serverPropertiesFile.canWrite())
+ {
+ return;
+ }
+
+ // CraftBukkit end
fileoutputstream = new FileOutputStream(this.serverPropertiesFile);
this.serverProperties.store(fileoutputstream, "Minecraft server properties");
}
@@ -108,20 +137,20 @@
this.saveProperties();
}
- return this.serverProperties.getProperty(p_73671_1_, p_73671_2_);
+ return this.getOverride(p_73671_1_, this.serverProperties.getProperty(p_73671_1_, p_73671_2_)); // CraftBukkit
}
public int getIntProperty(String p_73669_1_, int p_73669_2_)
{
try
{
- return Integer.parseInt(this.getStringProperty(p_73669_1_, "" + p_73669_2_));
+ return this.getOverride(p_73669_1_, Integer.parseInt(this.getStringProperty(p_73669_1_, "" + p_73669_2_))); // CraftBukkit
}
catch (Exception exception)
{
this.serverProperties.setProperty(p_73669_1_, "" + p_73669_2_);
this.saveProperties();
- return p_73669_2_;
+ return this.getOverride(p_73669_1_, p_73669_2_); // CraftBukkit
}
}
@@ -129,13 +158,13 @@
{
try
{
- return Boolean.parseBoolean(this.getStringProperty(p_73670_1_, "" + p_73670_2_));
+ return this.getOverride(p_73670_1_, Boolean.parseBoolean(this.getStringProperty(p_73670_1_, "" + p_73670_2_))); // CraftBukkit
}
catch (Exception exception)
{
this.serverProperties.setProperty(p_73670_1_, "" + p_73670_2_);
this.saveProperties();
- return p_73670_2_;
+ return this.getOverride(p_73670_1_, p_73670_2_); // CraftBukkit
}
}

View File

@ -0,0 +1,60 @@
--- ../src-base/minecraft/net/minecraft/server/integrated/IntegratedServer.java
+++ ../src-work/minecraft/net/minecraft/server/integrated/IntegratedServer.java
@@ -13,9 +13,11 @@
import net.minecraft.crash.CrashReport;
import net.minecraft.profiler.PlayerUsageSnooper;
import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.dedicated.PropertyManager;
import net.minecraft.util.CryptManager;
import net.minecraft.util.HttpUtil;
import net.minecraft.world.EnumDifficulty;
+import net.minecraft.world.MinecraftException;
import net.minecraft.world.WorldManager;
import net.minecraft.world.WorldServer;
import net.minecraft.world.WorldServerMulti;
@@ -78,7 +80,7 @@
this.initialWorldChunkLoad();
}
- protected boolean startServer() throws IOException
+ protected boolean startServer() throws java.net.UnknownHostException // Cauldron
{
logger.info("Starting integrated minecraft server version 1.7.10");
this.setOnlineMode(true);
@@ -103,7 +105,15 @@
{
logger.info("Saving and pausing game...");
this.getConfigurationManager().saveAllPlayerData();
- this.saveAllWorlds(false);
+ try
+ {
+ this.saveAllWorlds(false);
+ }
+ catch (MinecraftException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
if (!this.isGamePaused)
@@ -236,7 +246,7 @@
}
}
- public void stopServer()
+ public void stopServer() throws MinecraftException // Cauldron
{
super.stopServer();
@@ -277,4 +287,10 @@
{
return 4;
}
+
+ @Override
+ public PropertyManager getPropertyManager()
+ {
+ return null;
+ }
}

View File

@ -0,0 +1,33 @@
--- ../src-base/minecraft/net/minecraft/server/management/BanEntry.java
+++ ../src-work/minecraft/net/minecraft/server/management/BanEntry.java
@@ -76,4 +76,30 @@
p_152641_1_.addProperty("expires", this.banEndDate == null ? "forever" : dateFormat.format(this.banEndDate));
p_152641_1_.addProperty("reason", this.reason);
}
+
+ // CraftBukkit start
+ public String getSource() {
+ return this.bannedBy;
+ }
+
+ public Date getCreated() {
+ return this.banStartDate;
+ }
+
+ private static Object checkExpiry(Object object, JsonObject jsonobject) {
+ Date expires = null;
+
+ try {
+ expires = jsonobject.has("expires") ? dateFormat.parse(jsonobject.get("expires").getAsString()) : null;
+ } catch (ParseException ex) {
+ // Guess we don't have a date
+ }
+
+ if (expires == null || expires.after(new Date())) {
+ return object;
+ } else {
+ return null;
+ }
+ }
+ // CraftBukkit end
}

View File

@ -0,0 +1,298 @@
--- ../src-base/minecraft/net/minecraft/server/management/ItemInWorldManager.java
+++ ../src-work/minecraft/net/minecraft/server/management/ItemInWorldManager.java
@@ -4,6 +4,7 @@
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.network.play.server.S23PacketBlockChange;
@@ -13,13 +14,28 @@
import net.minecraft.world.WorldSettings;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
-import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
-import net.minecraftforge.event.entity.player.PlayerInteractEvent;
-import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import net.minecraftforge.event.world.BlockEvent;
+// CraftBukkit start
+import net.minecraft.init.Blocks;
+
+import org.bukkit.event.block.BlockBreakEvent;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.event.Event;
+import org.bukkit.event.block.Action;
+import org.bukkit.event.player.PlayerInteractEvent;
+// CraftBukkit end
+// Cauldron start
+import net.minecraft.inventory.ContainerPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+import org.bukkit.event.inventory.InventoryType;
+// Cauldron end
+
public class ItemInWorldManager
{
/** Forge reach distance */
@@ -135,15 +151,29 @@
public void onBlockClicked(int p_73074_1_, int p_73074_2_, int p_73074_3_, int p_73074_4_)
{
+ // CraftBukkit start
+ org.bukkit.event.player.PlayerInteractEvent cbEvent = CraftEventFactory.callPlayerInteractEvent(this.thisPlayerMP, Action.LEFT_CLICK_BLOCK, p_73074_1_, p_73074_2_, p_73074_3_, p_73074_4_, this.thisPlayerMP.inventory.getCurrentItem());
+
if (!this.gameType.isAdventure() || this.thisPlayerMP.isCurrentToolAdventureModeExempt(p_73074_1_, p_73074_2_, p_73074_3_))
{
- PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(thisPlayerMP, Action.LEFT_CLICK_BLOCK, p_73074_1_, p_73074_2_, p_73074_3_, p_73074_4_, theWorld);
- if (event.isCanceled())
+ net.minecraftforge.event.entity.player.PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(this.thisPlayerMP, net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.LEFT_CLICK_BLOCK, p_73074_1_, p_73074_2_, p_73074_3_, p_73074_4_, theWorld); // Forge
+
+ if (cbEvent.isCancelled() || event.isCanceled())
{
- thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(p_73074_1_, p_73074_2_, p_73074_3_, theWorld));
+ // Let the client know the block still exists
+ ((EntityPlayerMP) this.thisPlayerMP).playerNetServerHandler.sendPacket(new S23PacketBlockChange(p_73074_1_, p_73074_2_, p_73074_3_, this.theWorld));
+ // Update any tile entity data for this block
+ TileEntity tileentity = this.theWorld.getTileEntity(p_73074_1_, p_73074_2_, p_73074_3_);
+
+ if (tileentity != null)
+ {
+ this.thisPlayerMP.playerNetServerHandler.sendPacket(tileentity.getDescriptionPacket());
+ }
+
return;
}
+ // CraftBukkit end
if (this.isCreative())
{
if (!this.theWorld.extinguishFire((EntityPlayer)null, p_73074_1_, p_73074_2_, p_73074_3_, p_73074_4_))
@@ -157,30 +187,56 @@
float f = 1.0F;
Block block = this.theWorld.getBlock(p_73074_1_, p_73074_2_, p_73074_3_);
-
- if (!block.isAir(theWorld, p_73074_1_, p_73074_2_, p_73074_3_))
+ // CraftBukkit start - Swings at air do *NOT* exist.
+ if (cbEvent.useInteractedBlock() == org.bukkit.event.Event.Result.DENY || event.useBlock == cpw.mods.fml.common.eventhandler.Event.Result.DENY) // Cauldron
{
- if (event.useBlock != Event.Result.DENY)
+ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
+ if (block == Blocks.wooden_door)
{
- block.onBlockClicked(theWorld, p_73074_1_, p_73074_2_, p_73074_3_, thisPlayerMP);
- theWorld.extinguishFire(null, p_73074_1_, p_73074_2_, p_73074_3_, p_73074_4_);
+ // For some reason *BOTH* the bottom/top part have to be marked updated.
+ boolean bottom = (this.theWorld.getBlockMetadata(p_73074_1_, p_73074_2_, p_73074_3_) & 8) == 0;
+ ((EntityPlayerMP) this.thisPlayerMP).playerNetServerHandler.sendPacket(new S23PacketBlockChange(p_73074_1_, p_73074_2_, p_73074_3_, this.theWorld));
+ ((EntityPlayerMP) this.thisPlayerMP).playerNetServerHandler.sendPacket(new S23PacketBlockChange(p_73074_1_, p_73074_2_ + (bottom ? 1 : -1), p_73074_3_, this.theWorld));
}
- else
+ else if (block == Blocks.trapdoor)
{
- thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(p_73074_1_, p_73074_2_, p_73074_3_, theWorld));
+ ((EntityPlayerMP) this.thisPlayerMP).playerNetServerHandler.sendPacket(new S23PacketBlockChange(p_73074_1_, p_73074_2_, p_73074_3_, this.theWorld));
}
- f = block.getPlayerRelativeBlockHardness(thisPlayerMP, thisPlayerMP.worldObj, p_73074_1_, p_73074_2_, p_73074_3_);
}
-
- if (event.useItem == Event.Result.DENY)
+ else if (!block.isAir(theWorld, p_73074_1_, p_73074_2_, p_73074_3_))
{
- if (f >= 1.0f)
+ block.onBlockClicked(this.theWorld, p_73074_1_, p_73074_2_, p_73074_3_, this.thisPlayerMP);
+ f = block.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.worldObj, p_73074_1_, p_73074_2_, p_73074_3_);
+ // Allow fire punching to be blocked
+ this.theWorld.extinguishFire((EntityPlayer) null, p_73074_1_, p_73074_2_, p_73074_3_, p_73074_4_);
+ }
+ if (cbEvent.useItemInHand() == org.bukkit.event.Event.Result.DENY || event.useItem == cpw.mods.fml.common.eventhandler.Event.Result.DENY) // Forge
+ {
+ // If we 'insta destroyed' then the client needs to be informed.
+ if (f > 1.0f)
{
- thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(p_73074_1_, p_73074_2_, p_73074_3_, theWorld));
+ ((EntityPlayerMP) this.thisPlayerMP).playerNetServerHandler.sendPacket(new S23PacketBlockChange(p_73074_1_, p_73074_2_, p_73074_3_, this.theWorld));
}
+
return;
}
+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.thisPlayerMP, p_73074_1_, p_73074_2_, p_73074_3_, this.thisPlayerMP.inventory.getCurrentItem(), f >= 1.0f);
+
+ if (blockEvent.isCancelled())
+ {
+ // Let the client know the block still exists
+ ((EntityPlayerMP) this.thisPlayerMP).playerNetServerHandler.sendPacket(new S23PacketBlockChange(p_73074_1_, p_73074_2_, p_73074_3_, this.theWorld));
+ return;
+ }
+
+ if (blockEvent.getInstaBreak())
+ {
+ f = 2.0f;
+ }
+
+ // CraftBukkit end
+
if (!block.isAir(theWorld, p_73074_1_, p_73074_2_, p_73074_3_) && f >= 1.0F)
{
this.tryHarvestBlock(p_73074_1_, p_73074_2_, p_73074_3_);
@@ -269,6 +325,12 @@
return false;
}
Block block = this.theWorld.getBlock(p_73084_1_, p_73084_2_, p_73084_3_);
+
+ if (block == Blocks.air)
+ {
+ return false; // CraftBukkit - A plugin set block to air without cancelling
+ }
+
int l = this.theWorld.getBlockMetadata(p_73084_1_, p_73084_2_, p_73084_3_);
this.theWorld.playAuxSFXAtEntity(this.thisPlayerMP, 2001, p_73084_1_, p_73084_2_, p_73084_3_, Block.getIdFromBlock(block) + (this.theWorld.getBlockMetadata(p_73084_1_, p_73084_2_, p_73084_3_) << 12));
boolean flag = false;
@@ -350,57 +412,104 @@
public boolean activateBlockOrUseItem(EntityPlayer p_73078_1_, World p_73078_2_, ItemStack p_73078_3_, int p_73078_4_, int p_73078_5_, int p_73078_6_, int p_73078_7_, float p_73078_8_, float p_73078_9_, float p_73078_10_)
{
- PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(p_73078_1_, Action.RIGHT_CLICK_BLOCK, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_, p_73078_2_);
- if (event.isCanceled())
- {
- thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(p_73078_4_, p_73078_5_, p_73078_6_, theWorld));
- return false;
- }
-
- if (p_73078_3_ != null && p_73078_3_.getItem().onItemUseFirst(p_73078_3_, p_73078_1_, p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_, p_73078_8_, p_73078_9_, p_73078_10_))
- {
- if (p_73078_3_.stackSize <= 0) ForgeEventFactory.onPlayerDestroyItem(thisPlayerMP, p_73078_3_);
- return true;
- }
-
+ // CraftBukkit start - Interact
Block block = p_73078_2_.getBlock(p_73078_4_, p_73078_5_, p_73078_6_);
- boolean isAir = block.isAir(p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_);
- boolean useBlock = !p_73078_1_.isSneaking() || p_73078_1_.getHeldItem() == null;
- if (!useBlock) useBlock = p_73078_1_.getHeldItem().getItem().doesSneakBypassUse(p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_1_);
+ boolean isAir = block.isAir(p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_); // Cauldron
boolean result = false;
- if (useBlock)
+ if (!isAir)
{
- if (event.useBlock != Event.Result.DENY)
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(p_73078_1_, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_, p_73078_3_);
+ net.minecraftforge.event.entity.player.PlayerInteractEvent forgeEvent = ForgeEventFactory.onPlayerInteract(p_73078_1_, net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_, p_73078_2_);
+ // Cauldron start
+ // if forge event is explicitly cancelled, return
+ if (forgeEvent.isCanceled())
{
+ thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(p_73078_4_, p_73078_5_, p_73078_6_, theWorld));
+ return false;
+ }
+ // if we have no explicit deny, check if item can be used
+ if (event.useItemInHand() != org.bukkit.event.Event.Result.DENY && forgeEvent.useItem != cpw.mods.fml.common.eventhandler.Event.Result.DENY)
+ {
+ Item item = (p_73078_3_ != null ? p_73078_3_.getItem() : null);
+ // try to use an item in hand before activating a block. Used for items such as IC2's wrench.
+ if (item != null && item.onItemUseFirst(p_73078_3_, p_73078_1_, p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_, p_73078_8_, p_73078_9_, p_73078_10_))
+ {
+ if (p_73078_3_.stackSize <= 0) ForgeEventFactory.onPlayerDestroyItem(thisPlayerMP, p_73078_3_);
+ return true;
+ }
+ }
+ // Cauldron end
+ if (event.useInteractedBlock() == org.bukkit.event.Event.Result.DENY || forgeEvent.useBlock == cpw.mods.fml.common.eventhandler.Event.Result.DENY)
+ {
+ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
+ if (block == Blocks.wooden_door)
+ {
+ boolean bottom = (p_73078_2_.getBlockMetadata(p_73078_4_, p_73078_5_, p_73078_6_) & 8) == 0;
+ ((EntityPlayerMP) p_73078_1_).playerNetServerHandler.sendPacket(new S23PacketBlockChange(p_73078_4_, p_73078_5_ + (bottom ? 1 : -1), p_73078_6_, p_73078_2_));
+ }
+
+ result = (event.useItemInHand() != org.bukkit.event.Event.Result.ALLOW);
+ }
+ else if (!p_73078_1_.isSneaking() || p_73078_3_ == null || p_73078_1_.getHeldItem().getItem().doesSneakBypassUse(p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_1_))
+ {
result = block.onBlockActivated(p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_1_, p_73078_7_, p_73078_8_, p_73078_9_, p_73078_10_);
+ // Cauldron start - if bukkitView is null, create one. Required for Ender Chests since they do not use NetworkRegistry.openRemoteGUI
+ if (thisPlayerMP != null && !(thisPlayerMP.openContainer instanceof ContainerPlayer))
+ {
+ if (thisPlayerMP.openContainer.getBukkitView() == null)
+ {
+ TileEntity te = thisPlayerMP.worldObj.getTileEntity(p_73078_4_, p_73078_5_, p_73078_6_);
+ if (te != null && te instanceof IInventory)
+ {
+ IInventory teInv = (IInventory)te;
+ CraftInventory inventory = new CraftInventory(teInv);
+ thisPlayerMP.openContainer.bukkitView = new CraftInventoryView(thisPlayerMP.getBukkitEntity(), inventory, thisPlayerMP.openContainer);
+ }
+ else
+ {
+ thisPlayerMP.openContainer.bukkitView = new CraftInventoryView(thisPlayerMP.getBukkitEntity(), MinecraftServer.getServer().server.createInventory(thisPlayerMP.getBukkitEntity(), InventoryType.CHEST), thisPlayerMP.openContainer);
+ }
+
+ thisPlayerMP.openContainer = CraftEventFactory.callInventoryOpenEvent(thisPlayerMP, thisPlayerMP.openContainer, false);
+ if (thisPlayerMP.openContainer == null)
+ {
+ thisPlayerMP.openContainer = thisPlayerMP.inventoryContainer;
+ return false;
+ }
+ }
+ }
+ // Cauldron end
}
- else
+
+ if (p_73078_3_ != null && !result)
{
- thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(p_73078_4_, p_73078_5_, p_73078_6_, theWorld));
- result = event.useItem != Event.Result.ALLOW;
+ int meta = p_73078_3_.getItemDamage();
+ int size = p_73078_3_.stackSize;
+ result = p_73078_3_.tryPlaceItemIntoWorld(p_73078_1_, p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_, p_73078_8_, p_73078_9_, p_73078_10_);
+
+ // The item count should not decrement in Creative mode.
+ if (this.isCreative())
+ {
+ p_73078_3_.setItemDamage(meta);
+ p_73078_3_.stackSize = size;
+ }
+
+ if (p_73078_3_.stackSize <= 0)
+ {
+ ForgeEventFactory.onPlayerDestroyItem(this.thisPlayerMP, p_73078_3_);
+ }
}
- }
- if (p_73078_3_ != null && !result && event.useItem != Event.Result.DENY)
- {
- int meta = p_73078_3_.getItemDamage();
- int size = p_73078_3_.stackSize;
- result = p_73078_3_.tryPlaceItemIntoWorld(p_73078_1_, p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_, p_73078_8_, p_73078_9_, p_73078_10_);
- if (isCreative())
+ // If we have 'true' and no explicit deny *or* an explicit allow -- run the item part of the hook
+ if (p_73078_3_ != null && ((!result && event.useItemInHand() != org.bukkit.event.Event.Result.DENY) || event.useItemInHand() == org.bukkit.event.Event.Result.ALLOW))
{
- p_73078_3_.setItemDamage(meta);
- p_73078_3_.stackSize = size;
+ this.tryUseItem(p_73078_1_, p_73078_2_, p_73078_3_);
}
- if (p_73078_3_.stackSize <= 0) ForgeEventFactory.onPlayerDestroyItem(thisPlayerMP, p_73078_3_);
}
- /* Re-enable if this causes bukkit incompatibility, or re-write client side to only send a single packet per right click.
- if (par3ItemStack != null && ((!result && event.useItem != Event.Result.DENY) || event.useItem == Event.Result.ALLOW))
- {
- this.tryUseItem(thisPlayerMP, par2World, par3ItemStack);
- }*/
return result;
+ // CraftBukkit end
}
public void setWorld(WorldServer p_73080_1_)

View File

@ -0,0 +1,132 @@
--- ../src-base/minecraft/net/minecraft/server/management/PlayerManager.java
+++ ../src-work/minecraft/net/minecraft/server/management/PlayerManager.java
@@ -18,17 +18,23 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+//CraftBukkit start
+import java.util.Collections;
+import java.util.Queue;
+// CraftBukkit end
+
public class PlayerManager
{
private static final Logger field_152627_a = LogManager.getLogger();
private final WorldServer theWorldServer;
private final List players = new ArrayList();
private final LongHashMap playerInstances = new LongHashMap();
- private final List chunkWatcherWithPlayers = new ArrayList();
- private final List playerInstanceList = new ArrayList();
+ private final Queue chunkWatcherWithPlayers = new java.util.concurrent.ConcurrentLinkedQueue(); // CraftBukkit ArrayList -> ConcurrentLinkedQueue
+ private final Queue playerInstanceList = new java.util.concurrent.ConcurrentLinkedQueue(); // CraftBukkit ArrayList -> ConcurrentLinkedQueue
private int playerViewRadius;
private long previousTotalWorldTime;
private final int[][] xzDirectionsConst = new int[][] {{1, 0}, {0, 1}, { -1, 0}, {0, -1}};
+ private boolean wasNotEmpty; // CraftBukkit
private static final String __OBFID = "CL_00001434";
public PlayerManager(WorldServer p_i1176_1_)
@@ -37,6 +43,14 @@
this.func_152622_a(p_i1176_1_.func_73046_m().getConfigurationManager().getViewDistance());
}
+ // Cauldron start - vanilla compatibility
+ public PlayerManager(WorldServer p_i1176_1_, int viewDistance /* Spigot */)
+ {
+ this.theWorldServer = p_i1176_1_;
+ this.func_152622_a(viewDistance); // Spigot
+ }
+ // Cauldron end
+
public WorldServer getWorldServer()
{
return this.theWorldServer;
@@ -51,34 +65,53 @@
if (i - this.previousTotalWorldTime > 8000L)
{
this.previousTotalWorldTime = i;
+ // CraftBukkit start - Use iterator
+ java.util.Iterator iterator = this.playerInstanceList.iterator();
- for (j = 0; j < this.playerInstanceList.size(); ++j)
+ while (iterator.hasNext())
{
- playerinstance = (PlayerManager.PlayerInstance)this.playerInstanceList.get(j);
+ playerinstance = (PlayerManager.PlayerInstance)iterator.next();
playerinstance.sendChunkUpdate();
playerinstance.processChunk();
}
}
else
{
- for (j = 0; j < this.chunkWatcherWithPlayers.size(); ++j)
+ java.util.Iterator iterator = this.chunkWatcherWithPlayers.iterator();
+
+ while (iterator.hasNext())
{
- playerinstance = (PlayerManager.PlayerInstance)this.chunkWatcherWithPlayers.get(j);
+ playerinstance = (PlayerManager.PlayerInstance)iterator.next();
playerinstance.sendChunkUpdate();
+ iterator.remove();
+ // CraftBukkit end
}
}
- this.chunkWatcherWithPlayers.clear();
+ // this.chunkWatcherWithPlayers.clear(); // CraftBukkit - Removals are already covered
if (this.players.isEmpty())
{
+ if (!wasNotEmpty)
+ {
+ return; // CraftBukkit - Only do unload when we go from non-empty to empty
+ }
+
WorldProvider worldprovider = this.theWorldServer.provider;
if (!worldprovider.canRespawnHere())
{
this.theWorldServer.theChunkProviderServer.unloadAllChunks();
}
+
+ // CraftBukkit start
+ wasNotEmpty = false;
}
+ else
+ {
+ wasNotEmpty = true;
+ }
+ // CraftBukkit end
}
public boolean func_152621_a(int p_152621_1_, int p_152621_2_)
@@ -102,6 +135,20 @@
return playerinstance;
}
+ // CraftBukkit start
+ public final boolean isChunkInUse(int x, int z)
+ {
+ PlayerManager.PlayerInstance pi = getOrCreateChunkWatcher(x, z, false);
+
+ if (pi != null)
+ {
+ return (pi.playersWatchingChunk.size() > 0);
+ }
+
+ return false;
+ }
+ // CraftBukkit end
+
public void markBlockForUpdate(int p_151250_1_, int p_151250_2_, int p_151250_3_)
{
int l = p_151250_1_ >> 4;
@@ -541,7 +588,7 @@
{
i = this.chunkLocation.chunkXPos * 16;
j = this.chunkLocation.chunkZPos * 16;
- this.sendToAllPlayersWatchingChunk(new S21PacketChunkData(PlayerManager.this.theWorldServer.getChunkFromChunkCoords(this.chunkLocation.chunkXPos, this.chunkLocation.chunkZPos), false, this.flagsYAreasToUpdate));
+ this.sendToAllPlayersWatchingChunk(new S21PacketChunkData(PlayerManager.this.theWorldServer.getChunkFromChunkCoords(this.chunkLocation.chunkXPos, this.chunkLocation.chunkZPos), (this.flagsYAreasToUpdate == 0xFFFF), this.flagsYAreasToUpdate)); // CraftBukkit - send everything (including biome) if all sections flagged
// Forge: Grabs ALL tile entities is costly on a modded server, only send needed ones
for (k = 0; false && k < 16; ++k)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,15 @@
--- ../src-base/minecraft/net/minecraft/server/management/UserList.java
+++ ../src-work/minecraft/net/minecraft/server/management/UserList.java
@@ -184,6 +184,12 @@
return this.field_152696_d.size() < 1;
}
+ // CraftBukkit start
+ public Collection<UserListEntry> getValues() {
+ return this.field_152696_d.values();
+ }
+ // CraftBukkit end
+
@SideOnly(Side.SERVER)
public void func_152679_g() throws IOException
{

View File

@ -0,0 +1,11 @@
--- ../src-base/minecraft/net/minecraft/server/management/UserListEntry.java
+++ ../src-work/minecraft/net/minecraft/server/management/UserListEntry.java
@@ -17,7 +17,7 @@
this.field_152642_a = p_i1147_1_;
}
- Object func_152640_f()
+ public Object func_152640_f() // CraftBukkit - private -> public
{
return this.field_152642_a;
}

View File

@ -0,0 +1,10 @@
--- ../src-base/minecraft/net/minecraft/server/management/UserListOps.java
+++ ../src-work/minecraft/net/minecraft/server/management/UserListOps.java
@@ -35,6 +35,7 @@
protected String func_152699_b(GameProfile p_152699_1_)
{
+ if (p_152699_1_ == null || p_152699_1_.getId() == null) return "invalid"; // Cauldron - handle GameProfiles with no ID
return p_152699_1_.getId().toString();
}

View File

@ -0,0 +1,122 @@
--- ../src-base/minecraft/net/minecraft/server/network/NetHandlerHandshakeTCP.java
+++ ../src-work/minecraft/net/minecraft/server/network/NetHandlerHandshakeTCP.java
@@ -3,6 +3,7 @@
import cpw.mods.fml.common.FMLCommonHandler;
import io.netty.util.concurrent.GenericFutureListener;
import net.minecraft.network.EnumConnectionState;
+import net.minecraft.network.INetHandler;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.handshake.INetHandlerHandshakeServer;
import net.minecraft.network.handshake.client.C00Handshake;
@@ -11,8 +12,24 @@
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
+
+// CraftBukkit start
+import java.net.InetAddress;
+import java.util.HashMap;
+// CraftBukkit end
+// Spigot start
+import com.mojang.authlib.properties.Property;
+import com.mojang.util.UUIDTypeAdapter;
+// Spigot end
+
public class NetHandlerHandshakeTCP implements INetHandlerHandshakeServer
{
+ private static final com.google.gson.Gson gson = new com.google.gson.Gson(); // Spigot
+ // CraftBukkit start
+ private static final HashMap<InetAddress, Long> throttleTracker = new HashMap<InetAddress, Long>();
+ private static int throttleCounter = 0;
+ // CraftBukkit end
+
private final MinecraftServer field_147387_a;
private final NetworkManager field_147386_b;
private static final String __OBFID = "CL_00001456";
@@ -39,6 +56,52 @@
this.field_147386_b.setConnectionState(EnumConnectionState.LOGIN);
ChatComponentText chatcomponenttext;
+ // CraftBukkit start
+ try
+ {
+ long currentTime = System.currentTimeMillis();
+ long connectionThrottle = MinecraftServer.getServer().server.getConnectionThrottle();
+ InetAddress address = ((java.net.InetSocketAddress) this.field_147386_b.getSocketAddress()).getAddress();
+
+ synchronized (throttleTracker)
+ {
+ if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle)
+ {
+ throttleTracker.put(address, currentTime);
+ chatcomponenttext = new ChatComponentText("Connection throttled! Please wait before reconnecting.");
+ this.field_147386_b.scheduleOutboundPacket(new S00PacketDisconnect(chatcomponenttext), new GenericFutureListener[0]);
+ this.field_147386_b.closeChannel(chatcomponenttext); // Should be close
+ return;
+ }
+
+ throttleTracker.put(address, currentTime);
+ throttleCounter++;
+
+ if (throttleCounter > 200)
+ {
+ throttleCounter = 0;
+ // Cleanup stale entries
+ java.util.Iterator iter = throttleTracker.entrySet().iterator();
+
+ while (iter.hasNext())
+ {
+ java.util.Map.Entry<InetAddress, Long> entry = (java.util.Map.Entry) iter.next();
+
+ if (entry.getValue() > connectionThrottle)
+ {
+ iter.remove();
+ }
+ }
+ }
+ }
+ }
+ catch (Throwable t)
+ {
+ org.apache.logging.log4j.LogManager.getLogger().debug("Failed to check connection throttle", t);
+ }
+
+ // CraftBukkit end
+
if (p_147383_1_.func_149595_d() > 5)
{
chatcomponenttext = new ChatComponentText("Outdated server! I\'m still on 1.7.10");
@@ -54,6 +117,33 @@
else
{
this.field_147386_b.setNetHandler(new NetHandlerLoginServer(this.field_147387_a, this.field_147386_b));
+
+ // Spigot Start
+ if (org.spigotmc.SpigotConfig.bungee)
+ {
+ String[] split = p_147383_1_.field_149598_b.split("\00");
+
+ if (split.length == 3 || split.length == 4)
+ {
+ p_147383_1_.field_149598_b = split[0];
+ field_147386_b.socketAddress = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) field_147386_b.getSocketAddress()).getPort());
+ field_147386_b.spoofedUUID = UUIDTypeAdapter.fromString( split[2] );
+ }
+ else
+ {
+ chatcomponenttext = new ChatComponentText("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!");
+ this.field_147386_b.scheduleOutboundPacket(new S00PacketDisconnect(chatcomponenttext), new GenericFutureListener[0]);
+ this.field_147386_b.closeChannel(chatcomponenttext);
+ return;
+ }
+
+ if (split.length == 4)
+ {
+ field_147386_b.spoofedProfile = gson.fromJson(split[3], Property[].class);
+ }
+ }
+ // Spigot End
+ ((NetHandlerLoginServer) this.field_147386_b.getNetHandler()).hostname = p_147383_1_.field_149598_b + ":" + p_147383_1_.field_149599_c; // CraftBukkit - set hostname
}
break;

View File

@ -0,0 +1,239 @@
--- ../src-base/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java
+++ ../src-work/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java
@@ -13,6 +13,7 @@
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import javax.crypto.SecretKey;
+
import net.minecraft.network.EnumConnectionState;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.login.INetHandlerLoginServer;
@@ -29,6 +30,14 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import net.minecraft.entity.player.EntityPlayerMP;
+import org.bukkit.craftbukkit.util.Waitable;
+import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
+import org.bukkit.event.player.PlayerPreLoginEvent;
+// CraftBukkit end
+import com.mojang.authlib.properties.Property;
+
public class NetHandlerLoginServer implements INetHandlerLoginServer
{
private static final AtomicInteger field_147331_b = new AtomicInteger(0);
@@ -37,16 +46,17 @@
private final byte[] field_147330_e = new byte[4];
private final MinecraftServer field_147327_f;
public final NetworkManager field_147333_a;
- private NetHandlerLoginServer.LoginState field_147328_g;
+ private LoginState field_147328_g;
private int field_147336_h;
private GameProfile field_147337_i;
private String field_147334_j;
private SecretKey field_147335_k;
+ public String hostname = ""; // CraftBukkit - add field
private static final String __OBFID = "CL_00001458";
public NetHandlerLoginServer(MinecraftServer p_i45298_1_, NetworkManager p_i45298_2_)
{
- this.field_147328_g = NetHandlerLoginServer.LoginState.HELLO;
+ this.field_147328_g = LoginState.HELLO;
this.field_147334_j = "";
this.field_147327_f = p_i45298_1_;
this.field_147333_a = p_i45298_2_;
@@ -55,7 +65,7 @@
public void onNetworkTick()
{
- if (this.field_147328_g == NetHandlerLoginServer.LoginState.READY_TO_ACCEPT)
+ if (this.field_147328_g == LoginState.READY_TO_ACCEPT)
{
this.func_147326_c();
}
@@ -81,24 +91,54 @@
}
}
+ // Spigot start
+ public void initUUID()
+ {
+ UUID uuid;
+ if ( field_147333_a.spoofedUUID != null )
+ {
+ uuid = field_147333_a.spoofedUUID;
+ } else
+ {
+ uuid = UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + this.field_147337_i.getName() ).getBytes( Charsets.UTF_8 ) );
+ }
+
+ this.field_147337_i = new GameProfile( uuid, this.field_147337_i.getName() );
+
+ if (field_147333_a.spoofedProfile != null)
+ {
+ for ( Property property : field_147333_a.spoofedProfile )
+ {
+ this.field_147337_i.getProperties().put( property.getName(), property );
+ }
+ }
+ }
+ // Spigot end
+
public void func_147326_c()
{
+ // Spigot start - Moved to initUUID
+ /*
if (!this.field_147337_i.isComplete())
{
this.field_147337_i = this.func_152506_a(this.field_147337_i);
}
+ */
+ // Spigot end
- String s = this.field_147327_f.getConfigurationManager().allowUserToConnect(this.field_147333_a.getSocketAddress(), this.field_147337_i);
+ // CraftBukkit start - fire PlayerLoginEvent
+ EntityPlayerMP s = this.field_147327_f.getConfigurationManager().attemptLogin(this, this.field_147337_i, this.hostname);
- if (s != null)
+ if (s == null)
{
- this.func_147322_a(s);
+ // this.func_147322_a(s);
+ // CraftBukkit end
}
else
{
this.field_147328_g = NetHandlerLoginServer.LoginState.ACCEPTED;
this.field_147333_a.scheduleOutboundPacket(new S02PacketLoginSuccess(this.field_147337_i), new GenericFutureListener[0]);
- FMLNetworkHandler.fmlServerHandshake(this.field_147327_f.getConfigurationManager(), this.field_147333_a, this.field_147327_f.getConfigurationManager().createPlayerForUser(this.field_147337_i));
+ FMLNetworkHandler.fmlServerHandshake(this.field_147327_f.getConfigurationManager(), this.field_147333_a, this.field_147327_f.getConfigurationManager().processLogin(this.field_147337_i, s)); // CraftBukkit - add player reference
}
}
@@ -114,29 +154,29 @@
public void onConnectionStateTransition(EnumConnectionState p_147232_1_, EnumConnectionState p_147232_2_)
{
- Validate.validState(this.field_147328_g == NetHandlerLoginServer.LoginState.ACCEPTED || this.field_147328_g == NetHandlerLoginServer.LoginState.HELLO, "Unexpected change in protocol", new Object[0]);
+ Validate.validState(this.field_147328_g == LoginState.ACCEPTED || this.field_147328_g == LoginState.HELLO, "Unexpected change in protocol", new Object[0]);
Validate.validState(p_147232_2_ == EnumConnectionState.PLAY || p_147232_2_ == EnumConnectionState.LOGIN, "Unexpected protocol " + p_147232_2_, new Object[0]);
}
public void processLoginStart(C00PacketLoginStart p_147316_1_)
{
- Validate.validState(this.field_147328_g == NetHandlerLoginServer.LoginState.HELLO, "Unexpected hello packet", new Object[0]);
+ Validate.validState(this.field_147328_g == LoginState.HELLO, "Unexpected hello packet", new Object[0]);
this.field_147337_i = p_147316_1_.func_149304_c();
if (this.field_147327_f.isServerInOnlineMode() && !this.field_147333_a.isLocalChannel())
{
- this.field_147328_g = NetHandlerLoginServer.LoginState.KEY;
+ this.field_147328_g = LoginState.KEY;
this.field_147333_a.scheduleOutboundPacket(new S01PacketEncryptionRequest(this.field_147334_j, this.field_147327_f.getKeyPair().getPublic(), this.field_147330_e), new GenericFutureListener[0]);
}
else
{
- this.field_147328_g = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT;
+ (new ThreadPlayerLookupUUID(this, "User Authenticator #" + field_147331_b.incrementAndGet())).start(); // Spigot
}
}
public void processEncryptionResponse(C01PacketEncryptionResponse p_147315_1_)
{
- Validate.validState(this.field_147328_g == NetHandlerLoginServer.LoginState.KEY, "Unexpected key packet", new Object[0]);
+ Validate.validState(this.field_147328_g == LoginState.KEY, "Unexpected key packet", new Object[0]);
PrivateKey privatekey = this.field_147327_f.getKeyPair().getPrivate();
if (!Arrays.equals(this.field_147330_e, p_147315_1_.func_149299_b(privatekey)))
@@ -148,51 +188,7 @@
this.field_147335_k = p_147315_1_.func_149300_a(privatekey);
this.field_147328_g = NetHandlerLoginServer.LoginState.AUTHENTICATING;
this.field_147333_a.enableEncryption(this.field_147335_k);
- (new Thread("User Authenticator #" + field_147331_b.incrementAndGet())
- {
- private static final String __OBFID = "CL_00001459";
- public void run()
- {
- GameProfile gameprofile = NetHandlerLoginServer.this.field_147337_i;
-
- try
- {
- String s = (new BigInteger(CryptManager.getServerIdHash(NetHandlerLoginServer.this.field_147334_j, NetHandlerLoginServer.this.field_147327_f.getKeyPair().getPublic(), NetHandlerLoginServer.this.field_147335_k))).toString(16);
- NetHandlerLoginServer.this.field_147337_i = NetHandlerLoginServer.this.field_147327_f.func_147130_as().hasJoinedServer(new GameProfile((UUID)null, gameprofile.getName()), s);
-
- if (NetHandlerLoginServer.this.field_147337_i != null)
- {
- NetHandlerLoginServer.logger.info("UUID of player " + NetHandlerLoginServer.this.field_147337_i.getName() + " is " + NetHandlerLoginServer.this.field_147337_i.getId());
- NetHandlerLoginServer.this.field_147328_g = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT;
- }
- else if (NetHandlerLoginServer.this.field_147327_f.isSinglePlayer())
- {
- NetHandlerLoginServer.logger.warn("Failed to verify username but will let them in anyway!");
- NetHandlerLoginServer.this.field_147337_i = NetHandlerLoginServer.this.func_152506_a(gameprofile);
- NetHandlerLoginServer.this.field_147328_g = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT;
- }
- else
- {
- NetHandlerLoginServer.this.func_147322_a("Failed to verify username!");
- NetHandlerLoginServer.logger.error("Username \'" + NetHandlerLoginServer.this.field_147337_i.getName() + "\' tried to join with an invalid session");
- }
- }
- catch (AuthenticationUnavailableException authenticationunavailableexception)
- {
- if (NetHandlerLoginServer.this.field_147327_f.isSinglePlayer())
- {
- NetHandlerLoginServer.logger.warn("Authentication servers are down but will let them in anyway!");
- NetHandlerLoginServer.this.field_147337_i = NetHandlerLoginServer.this.func_152506_a(gameprofile);
- NetHandlerLoginServer.this.field_147328_g = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT;
- }
- else
- {
- NetHandlerLoginServer.this.func_147322_a("Authentication servers are down. Please try again later, sorry!");
- NetHandlerLoginServer.logger.error("Couldn\'t verify username because servers are unavailable");
- }
- }
- }
- }).start();
+ (new ThreadPlayerLookupUUID(this, "User Authenticator #" + field_147331_b.incrementAndGet())).start();
}
}
@@ -202,6 +198,37 @@
return new GameProfile(uuid, p_152506_1_.getName());
}
+ // Cauldron start - access methods for ThreadPlayerLookupUUID
+ static String getLoginServerId(NetHandlerLoginServer loginServer) {
+ return loginServer.field_147334_j;
+ }
+
+ static MinecraftServer getMinecraftServer(NetHandlerLoginServer loginServer) {
+ return loginServer.field_147327_f;
+ }
+
+ static SecretKey getSecretKey(NetHandlerLoginServer loginServer) {
+ return loginServer.field_147335_k;
+ }
+
+ static GameProfile processPlayerLoginGameProfile(NetHandlerLoginServer loginServer, GameProfile gameprofile) {
+ return loginServer.field_147337_i = gameprofile;
+ }
+
+ static GameProfile getGameProfile(NetHandlerLoginServer loginServer) {
+ return loginServer.field_147337_i;
+ }
+
+ static Logger getLogger() {
+ return logger;
+ }
+
+ static void setLoginState(NetHandlerLoginServer loginServer, LoginState state)
+ {
+ loginServer.field_147328_g = state;
+ }
+ // Cauldron end
+
static enum LoginState
{
HELLO,

View File

@ -0,0 +1,61 @@
--- ../src-base/minecraft/net/minecraft/server/network/NetHandlerStatusServer.java
+++ ../src-work/minecraft/net/minecraft/server/network/NetHandlerStatusServer.java
@@ -1,5 +1,6 @@
package net.minecraft.server.network;
+
import io.netty.util.concurrent.GenericFutureListener;
import net.minecraft.network.EnumConnectionState;
import net.minecraft.network.NetworkManager;
@@ -11,6 +12,13 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.IChatComponent;
+// CraftBukkit start
+import java.net.InetSocketAddress;
+import net.minecraft.network.ServerStatusResponse;
+import net.minecraft.util.ChatComponentText;
+import org.bukkit.craftbukkit.util.CraftIconCache;
+// CraftBukkit end
+
public class NetHandlerStatusServer implements INetHandlerStatusServer
{
private final MinecraftServer field_147314_a;
@@ -37,7 +45,36 @@
public void processServerQuery(C00PacketServerQuery p_147312_1_)
{
- this.field_147313_b.scheduleOutboundPacket(new S00PacketServerInfo(this.field_147314_a.func_147134_at()), new GenericFutureListener[0]);
+ // CraftBukkit start - fire ping event
+ class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent
+ {
+ CraftIconCache icon = field_147314_a.server.getServerIcon();
+
+ ServerListPingEvent()
+ {
+ super(((InetSocketAddress) field_147313_b.getSocketAddress()).getAddress(), field_147314_a.getMOTD(), field_147314_a.getConfigurationManager().getCurrentPlayerCount(), field_147314_a.getConfigurationManager().getMaxPlayers());
+ }
+
+ @Override
+ public void setServerIcon(org.bukkit.util.CachedServerIcon icon)
+ {
+ if (!(icon instanceof CraftIconCache))
+ {
+ throw new IllegalArgumentException(icon + " was not created by " + org.bukkit.craftbukkit.CraftServer.class);
+ }
+
+ this.icon = (CraftIconCache) icon;
+ }
+ }
+ ServerListPingEvent event = new ServerListPingEvent();
+ this.field_147314_a.server.getPluginManager().callEvent(event);
+ ServerStatusResponse ping = new ServerStatusResponse();
+ ping.func_151320_a(event.icon.value);
+ ping.func_151315_a(new ChatComponentText(event.getMotd()));
+ ping.func_151319_a(new ServerStatusResponse.PlayerCountData(event.getMaxPlayers(), field_147314_a.getConfigurationManager().getCurrentPlayerCount()));
+ ping.func_151321_a(new ServerStatusResponse.MinecraftProtocolVersionIdentifier(field_147314_a.getServerModName() + " " + field_147314_a.getMinecraftVersion(), 5)); // TODO: Update when protocol changes
+ this.field_147313_b.scheduleOutboundPacket(new S00PacketServerInfo(ping), new GenericFutureListener[0]);
+ // CraftBukkit end
}
public void processPing(C01PacketPing p_147311_1_)