Removed servermods
This commit is contained in:
parent
2f80083948
commit
fe976cac50
4 changed files with 0 additions and 233 deletions
|
@ -1,42 +0,0 @@
|
|||
package cr0s.serverMods;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
|
||||
/**
|
||||
* Гашение урона при падении с джетпаком или квантовыми бутсами
|
||||
* @author Cr0s
|
||||
*/
|
||||
public class AntiFallDamage
|
||||
{
|
||||
private final int JETPACK_ID = 29954;
|
||||
private final int ELECTRIC_JETPACK_ID = 29953;
|
||||
private final int QUANTUM_BOOTS_ID = 29915;
|
||||
|
||||
@ForgeSubscribe
|
||||
public void livingFall(LivingFallEvent event)
|
||||
{
|
||||
EntityLivingBase entity = event.entityLiving;
|
||||
float distance = event.distance;
|
||||
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
int check = MathHelper.ceiling_float_int(distance - 3.0F);
|
||||
|
||||
if (check > 0) // Падение может нанести урон
|
||||
{
|
||||
// Проверяем наличие защиты
|
||||
if ((player.getCurrentArmor(0) != null && player.getCurrentArmor(0).itemID == QUANTUM_BOOTS_ID) ||
|
||||
(player.getCurrentArmor(2) != null && player.getCurrentArmor(2).itemID == JETPACK_ID) ||
|
||||
(player.getCurrentArmor(2) != null && player.getCurrentArmor(2).itemID == ELECTRIC_JETPACK_ID))
|
||||
{
|
||||
event.setCanceled(true); // Блокируем падение, если защита есть
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package cr0s.serverMods;
|
||||
|
||||
public class CommonProxy
|
||||
{
|
||||
// some code goes here
|
||||
public void setupLoginHook()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
package cr0s.serverMods;
|
||||
|
||||
import cpw.mods.fml.common.network.IConnectionHandler;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import java.io.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.NetLoginHandler;
|
||||
import net.minecraft.network.packet.NetHandler;
|
||||
import net.minecraft.network.packet.Packet1Login;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
public class LoginHookClass implements IConnectionHandler
|
||||
{
|
||||
private String checkLogin(String s) throws FileNotFoundException, IOException
|
||||
{
|
||||
if (s.indexOf(".") == -1 || s.split("\\.").length != 2)
|
||||
return "Никнейм и пароль должны быть разделены точками.";
|
||||
|
||||
if (!s.matches("^[a-zA-Z0-9_.]+$"))
|
||||
return "Имя пользователя или пароль содержат недопустимые символы.";
|
||||
|
||||
String s4 = s.split("\\.")[0].trim();
|
||||
String s5 = s.split("\\.")[1].trim();
|
||||
|
||||
if (s4.length() < 2 && !s4.equals("Q"))
|
||||
return "Имя пользователя слишком короткое.";
|
||||
|
||||
if (s5.length() < 3)
|
||||
return "Пароль слишком короткий.";
|
||||
|
||||
if (s4.length() > 15)
|
||||
return "Слишком длинный логин! (>15)";
|
||||
|
||||
BufferedReader bufferedreader = new BufferedReader(new FileReader(MinecraftServer.getServer().getFile("users.txt")));
|
||||
|
||||
String s1;
|
||||
|
||||
while ((s1 = bufferedreader.readLine()) != null)
|
||||
{
|
||||
String s2;
|
||||
String s3;
|
||||
|
||||
try
|
||||
{
|
||||
s2 = s1.split("\\.")[0];
|
||||
s3 = s1.split("\\.")[1];
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
bufferedreader.close();
|
||||
return "login.password error, database is corrupted.";
|
||||
}
|
||||
|
||||
if (s2.toLowerCase().equals(s4.toLowerCase()))
|
||||
{
|
||||
if (!s3.equals(s5))
|
||||
{
|
||||
System.out.println((new StringBuilder()).append(s).append(" failed to login (pwd: ").append(s3).append(")").toString());
|
||||
bufferedreader.close();
|
||||
return "Неправильный пароль!";
|
||||
}
|
||||
else
|
||||
{
|
||||
bufferedreader.close();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bufferedreader.close();
|
||||
PrintWriter printwriter = new PrintWriter(new FileWriter(MinecraftServer.getServer().getFile("users.txt"), true));
|
||||
printwriter.println(s);
|
||||
printwriter.close();
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager)
|
||||
{
|
||||
//throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager)
|
||||
{
|
||||
String kickReason = "";
|
||||
String s = netHandler.clientUsername;
|
||||
|
||||
try
|
||||
{
|
||||
kickReason = checkLogin(s);
|
||||
System.out.println("[SERVER MODS] Logging in user: " + s + " Result: " + kickReason);
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
Logger.getLogger(LoginHookClass.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.getLogger(LoginHookClass.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
if (Strings.isNullOrEmpty(kickReason))
|
||||
netHandler.clientUsername = s.split("\\.")[0];
|
||||
|
||||
return kickReason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager)
|
||||
{
|
||||
//throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager)
|
||||
{
|
||||
//throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosed(INetworkManager manager)
|
||||
{
|
||||
//throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login)
|
||||
{
|
||||
//throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package cr0s.serverMods;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.Init;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.Mod.PostInit;
|
||||
import cpw.mods.fml.common.Mod.PreInit;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cr0s.WarpDrive.SpaceEventHandler;
|
||||
|
||||
@Mod(modid = "ServerMods", name = "ServerMods", version = "0.0.1")
|
||||
@NetworkMod(clientSideRequired = false, serverSideRequired = true, connectionHandler = LoginHookClass.class)
|
||||
|
||||
/**
|
||||
* @author Cr0s
|
||||
*/
|
||||
public class ServerMods
|
||||
{
|
||||
// The instance of your mod that Forge uses.
|
||||
@Instance("ServerMods")
|
||||
public static ServerMods instance;
|
||||
|
||||
@PreInit
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
// Stub Method
|
||||
}
|
||||
|
||||
@Init
|
||||
public void load(FMLInitializationEvent event)
|
||||
{
|
||||
// Включить авторизацию (включается автоматически)
|
||||
//proxy.setupLoginHook();
|
||||
// Снять урон от падения с джетпаком и крузис-тапками
|
||||
MinecraftForge.EVENT_BUS.register(new AntiFallDamage());
|
||||
}
|
||||
|
||||
@PostInit
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
// Stub Method
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue