Added ProtectedPlayer.java for storing data on protected players. Created an event for players joining and adding the joined player to a list of protected players.
This commit is contained in:
@ -1,12 +1,17 @@
|
|||||||
package com.micle.loginprotection;
|
package com.micle.loginprotection;
|
||||||
|
|
||||||
|
import com.micle.loginprotection.data.ProtectedPlayer;
|
||||||
import com.micle.loginprotection.setup.Registration;
|
import com.micle.loginprotection.setup.Registration;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Mod(LoginProtection.MOD_ID)
|
@Mod(LoginProtection.MOD_ID)
|
||||||
public class LoginProtection {
|
public class LoginProtection {
|
||||||
public static final String MOD_ID = "loginprotection";
|
public static final String MOD_ID = "loginprotection";
|
||||||
|
public static List<ProtectedPlayer> protected_players = new ArrayList<>();
|
||||||
|
|
||||||
public LoginProtection() {
|
public LoginProtection() {
|
||||||
Registration.register();
|
Registration.register();
|
||||||
|
|||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.micle.loginprotection.data;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class ProtectedPlayer {
|
||||||
|
private final UUID player_uuid;
|
||||||
|
private int grace_period;
|
||||||
|
private boolean is_loading;
|
||||||
|
|
||||||
|
public ProtectedPlayer(UUID player_uuid) {
|
||||||
|
this.player_uuid = player_uuid;
|
||||||
|
this.grace_period = 200;
|
||||||
|
this.is_loading = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getPlayerUUID() {
|
||||||
|
return this.player_uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGracePeriod() {
|
||||||
|
return this.grace_period;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGracePeriod(int new_grace_period) {
|
||||||
|
this.grace_period = new_grace_period;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLoading() {
|
||||||
|
return this.is_loading;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoading(boolean new_loading) {
|
||||||
|
this.is_loading = new_loading;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package com.micle.loginprotection.events;
|
||||||
|
|
||||||
|
import com.micle.loginprotection.LoginProtection;
|
||||||
|
import com.micle.loginprotection.data.ProtectedPlayer;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
||||||
|
public class OnEntityJoinEventHandler {
|
||||||
|
@SubscribeEvent
|
||||||
|
public void EntityJoinWorldEvent(EntityJoinWorldEvent event) {
|
||||||
|
if (!(event.getEntity() instanceof PlayerEntity)) { return; }
|
||||||
|
PlayerEntity player = (PlayerEntity) event.getEntity();
|
||||||
|
|
||||||
|
LoginProtection.protected_players.add(new ProtectedPlayer(player.getUUID()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,10 +1,14 @@
|
|||||||
package com.micle.loginprotection.setup;
|
package com.micle.loginprotection.setup;
|
||||||
|
|
||||||
|
import com.micle.loginprotection.events.OnEntityJoinEventHandler;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
|
|
||||||
public class Registration {
|
public class Registration {
|
||||||
public static void register() {
|
public static void register() {
|
||||||
IEventBus mod_event_bus = FMLJavaModLoadingContext.get().getModEventBus();
|
IEventBus mod_event_bus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
|
|
||||||
|
MinecraftForge.EVENT_BUS.register(new OnEntityJoinEventHandler());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user