Add fake player do login
This commit is contained in:
parent
0e0f8a1dc2
commit
ad3dd74bd8
@ -54,11 +54,10 @@ minecraft {
|
||||
mainClass = 'cpw.mods.fml.relauncher.ServerLaunchWrapper'
|
||||
tweakClass = 'cpw.mods.fml.common.launcher.FMLTweaker'
|
||||
installerVersion = "1.4"
|
||||
|
||||
srgExtra "PK: org/bukkit/craftbukkit org/bukkit/craftbukkit/v1_7_R4"
|
||||
}
|
||||
|
||||
group = 'pw.prok'
|
||||
|
||||
ext.buildInfoCached = null;
|
||||
|
||||
def buildInfo(String key) {
|
||||
@ -105,7 +104,7 @@ version = "${mcVersion}-${forgeVersion}.${revision}"
|
||||
if (project.hasProperty('officialBuild')) println "Updated KCauldron version: ${version}"
|
||||
|
||||
launch4j {
|
||||
jreMinVersion = '1.6.0'
|
||||
jreMinVersion = '1.7.0'
|
||||
}
|
||||
|
||||
configurations {
|
||||
|
@ -8,11 +8,12 @@
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.io.BufferedReader;
|
||||
@@ -34,9 +35,21 @@
|
||||
@@ -34,9 +35,23 @@
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.minecraft.world.WorldType;
|
||||
+import net.minecraft.world.chunk.storage.AnvilSaveConverter;
|
||||
+import net.minecraftforge.common.MinecraftForge;
|
||||
+import net.minecraftforge.common.util.FakePlayer;
|
||||
+import net.minecraftforge.event.ForgeEventFactory;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@ -24,13 +25,14 @@
|
||||
+
|
||||
+import org.bukkit.craftbukkit.LoggerOutputStream;
|
||||
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
||||
+import org.bukkit.event.player.PlayerLoginEvent;
|
||||
+import org.bukkit.event.server.ServerCommandEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
@SideOnly(Side.SERVER)
|
||||
public class DedicatedServer extends MinecraftServer implements IServer
|
||||
{
|
||||
@@ -44,7 +57,7 @@
|
||||
@@ -44,7 +59,7 @@
|
||||
public final List pendingCommandList = Collections.synchronizedList(new ArrayList());
|
||||
private RConThreadQuery theRConThreadQuery;
|
||||
private RConThreadMain theRConThreadMain;
|
||||
@ -39,7 +41,7 @@
|
||||
private ServerEula field_154332_n;
|
||||
private boolean canSpawnStructures;
|
||||
private WorldSettings.GameType gameType;
|
||||
@@ -52,10 +65,13 @@
|
||||
@@ -52,10 +67,13 @@
|
||||
public static boolean allowPlayerLogins = false;
|
||||
private static final String __OBFID = "CL_00001784";
|
||||
|
||||
@ -56,7 +58,7 @@
|
||||
{
|
||||
private static final String __OBFID = "CL_00001787";
|
||||
{
|
||||
@@ -82,31 +98,77 @@
|
||||
@@ -82,31 +100,77 @@
|
||||
};
|
||||
}
|
||||
|
||||
@ -141,7 +143,7 @@
|
||||
field_155771_h.info("Starting minecraft server version 1.7.10");
|
||||
|
||||
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L)
|
||||
@@ -117,7 +179,7 @@
|
||||
@@ -117,7 +181,7 @@
|
||||
FMLCommonHandler.instance().onServerStart(this);
|
||||
|
||||
field_155771_h.info("Loading properties");
|
||||
@ -150,7 +152,7 @@
|
||||
this.field_154332_n = new ServerEula(new File("eula.txt"));
|
||||
|
||||
if (!this.field_154332_n.func_154346_a())
|
||||
@@ -172,6 +234,18 @@
|
||||
@@ -172,6 +236,18 @@
|
||||
this.setServerPort(this.settings.getIntProperty("server-port", 25565));
|
||||
}
|
||||
|
||||
@ -169,7 +171,7 @@
|
||||
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 +254,7 @@
|
||||
@@ -180,7 +256,7 @@
|
||||
{
|
||||
this.func_147137_ag().addLanEndpoint(inetaddress, this.getServerPort());
|
||||
}
|
||||
@ -178,7 +180,7 @@
|
||||
{
|
||||
field_155771_h.warn("**** FAILED TO BIND TO PORT!");
|
||||
field_155771_h.warn("The exception was: {}", new Object[] {ioexception.toString()});
|
||||
@@ -196,10 +270,17 @@
|
||||
@@ -196,10 +272,17 @@
|
||||
field_155771_h.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
|
||||
}
|
||||
|
||||
@ -198,7 +200,7 @@
|
||||
|
||||
if (!PreYggdrasilConverter.func_152714_a(this.settings))
|
||||
{
|
||||
@@ -208,7 +289,8 @@
|
||||
@@ -208,7 +291,8 @@
|
||||
else
|
||||
{
|
||||
FMLCommonHandler.instance().onServerStarted();
|
||||
@ -208,7 +210,7 @@
|
||||
long j = System.nanoTime();
|
||||
|
||||
if (this.getFolderName() == null)
|
||||
@@ -274,11 +356,36 @@
|
||||
@@ -274,11 +358,36 @@
|
||||
this.theRConThreadMain.startThread();
|
||||
}
|
||||
|
||||
@ -225,7 +227,7 @@
|
||||
+ // CraftBukkit end
|
||||
+ // KCauldronX start
|
||||
+ for(FakePlayer fp:FakePlayer.fakePlayers){
|
||||
+ PlayerEvent.PlayerLoggedInEvent join=new PlayerEvent.PlayerLoggedInEvent(fp);
|
||||
+ fp.callBukkitLoginEvent();
|
||||
+ }
|
||||
+ FakePlayer.fakePlayers=null;
|
||||
+ FakePlayer.BukkitInited=true;
|
||||
@ -245,7 +247,7 @@
|
||||
public boolean canStructuresSpawn()
|
||||
{
|
||||
return this.canSpawnStructures;
|
||||
@@ -364,11 +471,19 @@
|
||||
@@ -364,11 +473,19 @@
|
||||
|
||||
public void executePendingCommands()
|
||||
{
|
||||
|
@ -1,9 +1,10 @@
|
||||
--- ../src-base/minecraft/net/minecraftforge/common/util/FakePlayer.java
|
||||
+++ ../src-work/minecraft/net/minecraftforge/common/util/FakePlayer.java
|
||||
@@ -3,9 +3,11 @@
|
||||
@@ -3,9 +3,12 @@
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
+import cpw.mods.fml.common.FMLLog;
|
||||
+import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@ -12,13 +13,21 @@
|
||||
import net.minecraft.server.management.ItemInWorldManager;
|
||||
import net.minecraft.stats.StatBase;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
@@ -13,13 +15,29 @@
|
||||
@@ -13,15 +16,58 @@
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
+import net.minecraftforge.cauldron.configuration.CauldronConfig;
|
||||
+import net.minecraftforge.common.MinecraftForge;
|
||||
+import net.minecraftforge.event.ForgeEventFactory;
|
||||
+import org.apache.logging.log4j.LogManager;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.scheduler.CraftTask;
|
||||
+import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
+import org.bukkit.event.player.PlayerLoginEvent;
|
||||
+import org.bukkit.event.player.PlayerPreLoginEvent;
|
||||
|
||||
+import java.net.InetAddress;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.HashSet;
|
||||
+import java.util.concurrent.ConcurrentSkipListSet;
|
||||
@ -26,19 +35,41 @@
|
||||
//Preliminary, simple Fake Player class
|
||||
public class FakePlayer extends EntityPlayerMP
|
||||
{
|
||||
+ static public ArrayList<FakePlayer> fakePlayers=new ArrayList<>();
|
||||
+ static public ArrayList<FakePlayer> fakePlayers=new ArrayList();
|
||||
+ static public boolean BukkitInited=false;
|
||||
public FakePlayer(WorldServer world, GameProfile name)
|
||||
{
|
||||
super(FMLCommonHandler.instance().getMinecraftServerInstance(), world, name, new ItemInWorldManager(world));
|
||||
+ //KCauldronX Start
|
||||
+ if(MinecraftServer.cauldronConfig.fakePlayerLogin.getValue())
|
||||
+ if(!BukkitInited) {
|
||||
+ fakePlayers.add(this);
|
||||
+ }else{
|
||||
+ PlayerEvent.PlayerLoggedInEvent join=new PlayerEvent.PlayerLoggedInEvent(this);
|
||||
+ if(MinecraftServer.cauldronConfig.fakePlayerLogin.getValue()) {
|
||||
+ if (!BukkitInited) {
|
||||
+ fakePlayers.add(this);
|
||||
+ } else {
|
||||
+ callBukkitLoginEvent();
|
||||
+ }
|
||||
+ }
|
||||
+ //KCauldronX End
|
||||
}
|
||||
|
||||
-
|
||||
+ public void callBukkitLoginEvent(){
|
||||
+ new Thread(new Runnable() {
|
||||
+ @Override
|
||||
+ public void run() {
|
||||
+ AsyncPlayerPreLoginEvent prelogin2 = new AsyncPlayerPreLoginEvent(getCommandSenderName(), InetAddress.getLoopbackAddress(), getUniqueID());
|
||||
+ Bukkit.getPluginManager().callEvent(prelogin2);
|
||||
+ MinecraftServer.getServer().processQueue.add(new Runnable() {
|
||||
+ @Override
|
||||
+ public void run() {
|
||||
+ PlayerPreLoginEvent prelogin1 = new PlayerPreLoginEvent(getCommandSenderName(), InetAddress.getLoopbackAddress(), getUniqueID());
|
||||
+ Bukkit.getPluginManager().callEvent(prelogin1);
|
||||
+ PlayerLoginEvent login = new PlayerLoginEvent(getBukkitEntity(), "localhost", InetAddress.getLoopbackAddress());
|
||||
+ Bukkit.getPluginManager().callEvent(login);
|
||||
+ FMLLog.info("%s","[KCauldronX] Fakeplayer "+getCommandSenderName()+" ("+getUniqueID()+") joined server");
|
||||
+ }
|
||||
+ });
|
||||
+ }
|
||||
+ }).start();
|
||||
+ }
|
||||
@Override public boolean canCommandSenderUseCommand(int i, String s){ return false; }
|
||||
@Override public ChunkCoordinates getPlayerCoordinates()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user