1
0
forked from xjboss/KCauldronX
KCauldronX/patches/net/minecraftforge/common/util/FakePlayer.java.patch

76 lines
3.4 KiB
Diff
Raw Normal View History

--- ../src-base/minecraft/net/minecraftforge/common/util/FakePlayer.java
+++ ../src-work/minecraft/net/minecraftforge/common/util/FakePlayer.java
2017-07-02 11:55:18 +00:00
@@ -3,9 +3,12 @@
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.common.FMLCommonHandler;
2017-07-02 11:55:18 +00:00
+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;
import net.minecraft.network.play.client.C15PacketClientSettings;
+import net.minecraft.server.MinecraftServer;
import net.minecraft.server.management.ItemInWorldManager;
import net.minecraft.stats.StatBase;
import net.minecraft.util.ChunkCoordinates;
2017-07-02 11:55:18 +00:00
@@ -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;
2017-07-02 11:55:18 +00:00
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.ForgeEventFactory;
2017-07-02 11:55:18 +00:00
+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;
2017-07-02 11:55:18 +00:00
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.concurrent.ConcurrentSkipListSet;
+
//Preliminary, simple Fake Player class
public class FakePlayer extends EntityPlayerMP
{
2017-07-02 11:55:18 +00:00
+ 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
2017-07-02 11:55:18 +00:00
+ if(MinecraftServer.cauldronConfig.fakePlayerLogin.getValue()) {
+ if (!BukkitInited) {
+ fakePlayers.add(this);
+ } else {
+ callBukkitLoginEvent();
+ }
+ }
+ //KCauldronX End
}
2017-07-02 11:55:18 +00:00
-
+ 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; }
2017-07-02 11:55:18 +00:00
@Override public ChunkCoordinates getPlayerCoordinates()
{