Handcuffed, config advanced

This commit is contained in:
Xamora 2024-06-17 13:46:16 +02:00
parent fd78039b62
commit aa04ef34db
11 changed files with 205 additions and 60 deletions

2
.gitignore vendored
View file

@ -2,6 +2,8 @@
/build /build
/Minecraft Client/* /Minecraft Client/*
/Minecraft Server/* /Minecraft Server/*
/MinecraftClient/*
/MinecraftServer/*
/Minecraft Server Save/* /Minecraft Server Save/*
/.idea /.idea
/.gradle /.gradle

View file

@ -27,6 +27,7 @@ public class ConfigManager {
public static final String CATEGORY_GP = "Galactic Patrol"; public static final String CATEGORY_GP = "Galactic Patrol";
public static final String CATEGORY_GPE = "Galactic Patrol Error"; public static final String CATEGORY_GPE = "Galactic Patrol Error";
public static final String CATEGORY_GPS = "Galactic Patrol Success"; public static final String CATEGORY_GPS = "Galactic Patrol Success";
public static final String CATEGORY_GPW = "Galactic Patrol Warning";
public static String DIR_SAVE = "./" + Main.MODID + "/"; public static String DIR_SAVE = "./" + Main.MODID + "/";
@ -52,8 +53,16 @@ public class ConfigManager {
public static String SUCCESS_IN_JAIL = "Player put in jail for "; public static String SUCCESS_IN_JAIL = "Player put in jail for ";
public static String MSG_INMATE_GOING_TO_JAIL = "You are in jail for "; public static String MSG_INMATE_GOING_TO_JAIL = "You are in jail for ";
public static int FORMAT_TIME_JAIL = 4; public static int FORMAT_TIME_JAIL = 4;
public static String SUCCESS_OUT_OF_JAIL = "You are out of the jail";
public static String ERROR_ALREADY_HANDCUFFED = "Already handcuffed"; public static String ERROR_ALREADY_HANDCUFFED = "Already handcuffed";
public static int TIME_HANDCUFFING = 10; // seconds
public static String WARNING_HANDCUFFING_YOU = "A galactic patrol handcuffing you!";
public static String WARNING_HANDCUFFING_HIM = "You handcuffing someone";
public static String SUCCESS_YOU_HANDCUFFED_HIM = "You handcuffed him";
public static String SUCCESS_YOU_ARE_HANDCUFFED = "You are handcuffed, going in %% seconds";
public static String SUCCESS_GOING_IN_JAIL = "%% seconds left";
public static int TIME_TO_GO_IN_JAIL = 20; // seconds
static public int SEC_TO_BE_IN_JAIL = 120; // second static public int SEC_TO_BE_IN_JAIL = 120; // second
static public String POS_EXIT_JAIL = ""; //"-247 66 275 20"; static public String POS_EXIT_JAIL = ""; //"-247 66 275 20";
@ -93,10 +102,17 @@ public class ConfigManager {
pos_exit_jail = null; pos_exit_jail = null;
} }
TIME_HANDCUFFING = (byte)addVariableConfig(order, CATEGORY_GP, "TIME_HANDCUFFING",
"Time to handcuffing someone who is not K.O, in seconds. [default: 10]", "10").getInt();
TIME_TO_GO_IN_JAIL = (byte)addVariableConfig(order, CATEGORY_GP, "TIME_TO_GO_IN_JAIL",
"Time to go in jail when someone is handcuffed. [default: 20]", "20").getInt();
config.setCategoryPropertyOrder(CATEGORY_GP, order); config.setCategoryPropertyOrder(CATEGORY_GP, order);
loadConfigurationError(); loadConfigurationError();
loadConfigurationSuccess(); loadConfigurationSuccess();
loadConfigurationWarning();
if (config.hasChanged()) if (config.hasChanged())
config.save(); config.save();
@ -178,6 +194,30 @@ public class ConfigManager {
FORMAT_TIME_JAIL = addVariableConfig(orderSuccess, CATEGORY_GPS, "FORMAT_TIME_JAIL", FORMAT_TIME_JAIL = addVariableConfig(orderSuccess, CATEGORY_GPS, "FORMAT_TIME_JAIL",
"Format of the time print when a player going to jail; 1=dd/MM/yyyy - HH:mm:ss; 2=dd/MM - HH:mm:ss; 3=dd - HH:mm:ss; 4=HH:mm:ss. [default: 4]", "4").getInt(); "Format of the time print when a player going to jail; 1=dd/MM/yyyy - HH:mm:ss; 2=dd/MM - HH:mm:ss; 3=dd - HH:mm:ss; 4=HH:mm:ss. [default: 4]", "4").getInt();
SUCCESS_OUT_OF_JAIL = addVariableConfig(orderSuccess, CATEGORY_GPS, "SUCCESS_OUT_OF_JAIL",
"Text when you are out of the jail. [default: \"You are out of the jail\"]", "You are out of the jail").getString();
SUCCESS_YOU_HANDCUFFED_HIM = addVariableConfig(orderSuccess, CATEGORY_GPS, "SUCCESS_YOU_HANDCUFFED_HIM",
"Success when you handcuffed someone. [default: \"You handcuffed him\"]", "You handcuffed him").getString();
SUCCESS_YOU_ARE_HANDCUFFED = addVariableConfig(orderSuccess, CATEGORY_GPS, "SUCCESS_YOU_ARE_HANDCUFFED",
"When you are handcuffed, \"\" for seconds before you are going in jail. [default: \"You are handcuffed, going in %% seconds\"]", "You are handcuffed, going in %% seconds").getString();
SUCCESS_GOING_IN_JAIL = addVariableConfig(orderSuccess, CATEGORY_GPS, "SUCCESS_GOING_IN_JAIL",
"Message to say how many time remains before you are going in jail, \"%%\" for seconds. [default: \"%% seconds left\"]", "%% seconds left").getString();
config.setCategoryPropertyOrder(CATEGORY_GPS, orderSuccess); config.setCategoryPropertyOrder(CATEGORY_GPS, orderSuccess);
} }
private static void loadConfigurationWarning() {
List<String> orderWarning = new ArrayList<String>();
WARNING_HANDCUFFING_YOU = addVariableConfig(orderWarning, CATEGORY_GPW, "WARNING_HANDCUFFING_YOU",
"Warning when a galactic patrol try to handcuffing you [default: \"A galactic patrol handcuffing you\"]", "A galactic patrol handcuffing you").getString();
WARNING_HANDCUFFING_HIM = addVariableConfig(orderWarning, CATEGORY_GPW, "WARNING_HANDCUFFING_HIM",
"Warning when you handcuffing someone [default: \"You handcuffing someone\"]", "You handcuffing someone").getString();
config.setCategoryPropertyOrder(CATEGORY_GPW, orderWarning);
}
} }

View file

@ -8,65 +8,123 @@ import gp_dbc.Main;
import gp_dbc.config.ConfigManager; import gp_dbc.config.ConfigManager;
import gp_dbc.system.Handcuff; import gp_dbc.system.Handcuff;
import gp_dbc.utils.EntityUtils; import gp_dbc.utils.EntityUtils;
import gp_dbc.utils.RayTrace; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.lwjgl.Sys;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.UUID;
import static gp_dbc.config.ConfigManager.*;
public class ItemGPHandcuff extends Item { public class ItemGPHandcuff extends Item {
public ItemGPHandcuff() // Scum|TimeStart
{ public static HashMap<UUID, Long> handcuffing = new HashMap<>();
private long timeStart;
private IIcon open;
private IIcon close;
public ItemGPHandcuff() {
setUnlocalizedName(Main.MODID +".gp_handcuff"); setUnlocalizedName(Main.MODID +".gp_handcuff");
GameRegistry.registerItem(this, getUnlocalizedName()); GameRegistry.registerItem(this, getUnlocalizedName());
setCreativeTab(Main.tabGP); setCreativeTab(Main.tabGP);
setTextureName(Main.MODID + ":gp_handcuff"); setTextureName(Main.MODID + ":gp_handcuff");
setMaxStackSize(1); setMaxStackSize(2);
} }
@Override @Override
@SideOnly(Side.SERVER) @SideOnly(Side.SERVER)
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int par4) { public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int par4) {
int timeUse = getMaxItemUseDuration(stack) - par4; Entity entity = EntityUtils.getEntityLookedAt(player, 5);
System.out.println(timeUse); if (entity instanceof EntityPlayer) {
EntityPlayer inmate = (EntityPlayer) entity;
if (!handcuffing.containsKey(inmate.getUniqueID()))
return;
long startTime = handcuffing.get(inmate.getUniqueID());
long time = (System.currentTimeMillis() - startTime) / 1000;
if (time >= TIME_HANDCUFFING && time <= TIME_HANDCUFFING * 2L && Handcuff.putHandcuff(player, inmate))
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(this, stack.stackSize - 1));
}
} }
@Override @Override
@SideOnly(Side.SERVER) public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
if (!world.isRemote) {
Entity entity = EntityUtils.getEntityLookedAt(player, 5); Entity entity = EntityUtils.getEntityLookedAt(player, 5);
if (entity instanceof EntityPlayer) { if (entity instanceof EntityPlayer) {
EntityPlayer jailer = (EntityPlayer) entity; EntityPlayer inmate = (EntityPlayer) entity;
NBTTagCompound nbtPlayer = JRMCoreH.nbt(jailer, "pres"); if (Handcuff.isHandcuffed(inmate)) {
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_ALREADY_HANDCUFFED));
return stack;
}
NBTTagCompound nbtPlayer = JRMCoreH.nbt(inmate, "pres");
boolean ko = nbtPlayer.getInteger("jrmcHar4va") > 0; boolean ko = nbtPlayer.getInteger("jrmcHar4va") > 0;
if (ko) { if (ko) {
if (Handcuff.putHandcuff(player)) if (Handcuff.putHandcuff(player, inmate))
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(this, itemStack.stackSize - 1)); player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(this, stack.stackSize - 1));
} } else {
else { handcuffing.put(inmate.getUniqueID(), System.currentTimeMillis());
//if (Handcuff.putHandcuff(player)) inmate.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + WARNING_HANDCUFFING_YOU));
//player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(this, itemStack.stackSize - 1)); player.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + WARNING_HANDCUFFING_HIM));
System.out.println("handcuffing not ko");
} }
} }
player.setItemInUse(itemStack, getMaxItemUseDuration(itemStack)); }
player.setItemInUse(stack, getMaxItemUseDuration(stack));
timeStart = System.currentTimeMillis();
//System.out.println(itemStack.stackSize); //System.out.println(itemStack.stackSize);
return itemStack; return stack;
} }
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked" })
@Override @Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
par3List.add("Right Click to put in jail"); par3List.add("Right Click to put in jail");
} }
public int getMaxItemUseDuration(ItemStack par1ItemStack) {
return 72000;
}
public EnumAction getItemUseAction(ItemStack stack) {
return EnumAction.block;
}
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
{
long timeUsing = (System.currentTimeMillis() - timeStart) / 1000;
if (useRemaining <= 0)
return getIcon(stack, renderPass);
else if (timeUsing >= 0 && timeUsing < TIME_HANDCUFFING )
return open;
else
return close;
}
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) {
this.itemIcon = iconRegister.registerIcon(Main.MODID + ":gp_handcuff");
this.open = iconRegister.registerIcon(Main.MODID + ":gp_handcuff_open");
this.close = iconRegister.registerIcon(Main.MODID + ":gp_handcuff_close");
}
} }

View file

@ -14,6 +14,7 @@ import net.minecraft.util.*;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.List; import java.util.List;
import static gp_dbc.config.ConfigManager.*;
public class ItemJailManager extends Item { public class ItemJailManager extends Item {
@ -35,9 +36,9 @@ public class ItemJailManager extends Item {
if (trace != null && trace.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { if (trace != null && trace.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
player.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "x: " + trace.blockX + " y: " + trace.blockY + " z: " + trace.blockZ)); player.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "x: " + trace.blockX + " y: " + trace.blockY + " z: " + trace.blockZ));
if (Main.gp.jail.addCell(trace.blockX, trace.blockY, trace.blockZ, player.dimension)) if (Main.gp.jail.addCell(trace.blockX, trace.blockY, trace.blockZ, player.dimension))
player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + ConfigManager.SUCCESS_ADD_CELL)); player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + SUCCESS_ADD_CELL));
else else
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ConfigManager.ERROR_ADD_CELL)); player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_ADD_CELL));
} }
} }
else { } else { }

View file

@ -5,6 +5,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import gp_dbc.TemporaryEvent; import gp_dbc.TemporaryEvent;
import gp_dbc.system.Handcuff;
import gp_dbc.system.TimeJail; import gp_dbc.system.TimeJail;
public class ServerProxy extends CommonProxy{ public class ServerProxy extends CommonProxy{
@ -14,6 +15,7 @@ public class ServerProxy extends CommonProxy{
FMLCommonHandler.instance().bus().register(new TemporaryEvent()); FMLCommonHandler.instance().bus().register(new TemporaryEvent());
FMLCommonHandler.instance().bus().register(new TimeJail()); FMLCommonHandler.instance().bus().register(new TimeJail());
FMLCommonHandler.instance().bus().register(new Handcuff());
} }
public void init(FMLInitializationEvent $e) { public void init(FMLInitializationEvent $e) {

View file

@ -1,10 +1,7 @@
package gp_dbc.system; package gp_dbc.system;
import JinRyuu.JRMCore.server.JGPlayerMP; import JinRyuu.JRMCore.server.JGPlayerMP;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import gp_dbc.utils.Data; import gp_dbc.utils.Data;
import gp_dbc.config.ConfigManager;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
@ -13,6 +10,8 @@ import net.minecraft.util.EnumChatFormatting;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import static gp_dbc.config.ConfigManager.*;
public class GalacticPatrol { public class GalacticPatrol {
private List<UUID> patrolmans; private List<UUID> patrolmans;
@ -42,23 +41,23 @@ public class GalacticPatrol {
int align = jgPlayer.getAlignment(); int align = jgPlayer.getAlignment();
if (align < ConfigManager.MIN_ALIGN_TO_JOIN) { if (align < MIN_ALIGN_TO_JOIN) {
if (chatError) if (chatError)
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ConfigManager.ERROR_MIN_ALIGN_TO_JOIN)); player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_MIN_ALIGN_TO_JOIN));
return 2; return 2;
} }
else if (align > ConfigManager.MAX_ALIGN_TO_JOIN) { else if (align > MAX_ALIGN_TO_JOIN) {
if (chatError) if (chatError)
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ConfigManager.ERROR_MAX_ALIGN_TO_JOIN)); player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_MAX_ALIGN_TO_JOIN));
return 3; return 3;
} }
if (!patrolmans.contains(player.getUniqueID())) { if (!patrolmans.contains(player.getUniqueID())) {
patrolmans.add(player.getUniqueID()); patrolmans.add(player.getUniqueID());
player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + ConfigManager.SUCCESS_JOIN_GALACTIC_PATROL)); player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + SUCCESS_JOIN_GALACTIC_PATROL));
} }
else else
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ConfigManager.ERROR_JOIN_GALACTIC_PATROL)); player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_JOIN_GALACTIC_PATROL));
Data.saveDataUUID(patrolmans, "galactic_patrols"); Data.saveDataUUID(patrolmans, "galactic_patrols");
@ -88,9 +87,9 @@ public class GalacticPatrol {
Data.saveDataUUID(patrolmans, "galactic_patrols"); Data.saveDataUUID(patrolmans, "galactic_patrols");
if (removed) if (removed)
player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + ConfigManager.SUCCESS_LEAVE_GALACTIC_PATROL)); player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + SUCCESS_LEAVE_GALACTIC_PATROL));
else else
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ConfigManager.ERROR_LEAVE_GALACTIC_PATROL)); player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_LEAVE_GALACTIC_PATROL));
return removed; return removed;
} }

View file

@ -1,14 +1,18 @@
package gp_dbc.system; package gp_dbc.system;
import JinRyuu.JRMCore.JRMCoreH; import JinRyuu.JRMCore.JRMCoreH;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import gp_dbc.Main; import gp_dbc.Main;
import gp_dbc.config.ConfigManager; import gp_dbc.config.ConfigManager;
import gp_dbc.utils.EntityUtils; import gp_dbc.utils.EntityUtils;
import gp_dbc.utils.PlayerUtils;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -19,19 +23,54 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import static gp_dbc.config.ConfigManager.*;
public class Handcuff { public class Handcuff {
// UUID~StartTimeHandcuffed // UUID~StartTimeHandcuffed
@SideOnly(Side.SERVER) @SideOnly(Side.SERVER)
public static HashMap<UUID, Long>handcuffed = new HashMap<UUID, Long>(); public static HashMap<UUID, Long>handcuffed = new HashMap<UUID, Long>();
int tick = 0;
final int SLOWTICK_MAX = 20;//2000;
@SideOnly(Side.SERVER) @SideOnly(Side.SERVER)
public static boolean putHandcuff(EntityPlayer player) { @SubscribeEvent
if (handcuffed.get(player.getUniqueID()) != null) { public void checkTimeJailer(TickEvent.ServerTickEvent event) {
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ConfigManager.ERROR_ALREADY_HANDCUFFED)); if (handcuffed.isEmpty())
return;
if (tick >= SLOWTICK_MAX) {
tick = 0;
for (UUID uuid : handcuffed.keySet()) {
long timeStart = handcuffed.get(uuid);
}
}
else
tick++;
}
@SideOnly(Side.SERVER)
public static boolean putHandcuff(EntityPlayer jailer, EntityPlayer inmate) {
if (handcuffed.get(inmate.getUniqueID()) != null) {
jailer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_ALREADY_HANDCUFFED));
return false; return false;
} }
handcuffed.put(player.getUniqueID(), System.currentTimeMillis()); handcuffed.put(inmate.getUniqueID(), System.currentTimeMillis());
jailer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + SUCCESS_YOU_HANDCUFFED_HIM));
int time_pos = SUCCESS_YOU_ARE_HANDCUFFED.indexOf("%%");
String first = SUCCESS_YOU_ARE_HANDCUFFED.substring(0, time_pos);
String second = SUCCESS_YOU_ARE_HANDCUFFED.substring(time_pos);
inmate.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + first + TIME_TO_GO_IN_JAIL + second));
return true; return true;
} }
@SideOnly(Side.SERVER)
public static boolean isHandcuffed(EntityPlayer player) {
return handcuffed.containsKey(player.getUniqueID());
}
} }

View file

@ -14,6 +14,8 @@ import org.lwjgl.Sys;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import static gp_dbc.config.ConfigManager.*;
public class Jail { public class Jail {
private List<Cell> cells; private List<Cell> cells;
@ -64,10 +66,10 @@ public class Jail {
} }
public boolean thereIsExitPos(ICommandSender chat, boolean chatMsg) { public boolean thereIsExitPos(ICommandSender chat, boolean chatMsg) {
String[] split = ConfigManager.POS_EXIT_JAIL.split(" "); String[] split = POS_EXIT_JAIL.split(" ");
if (split.length != 4) { if (split.length != 4) {
if (chatMsg) if (chatMsg)
chat.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ConfigManager.ERROR_DEFINITION_EXIT_POS)); chat.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_DEFINITION_EXIT_POS));
return false; return false;
} }
else { else {
@ -75,7 +77,7 @@ public class Jail {
Integer.parseInt(split[0]); Integer.parseInt(split[1]); Integer.parseInt(split[2]); Integer.parseInt(split[3]); Integer.parseInt(split[0]); Integer.parseInt(split[1]); Integer.parseInt(split[2]); Integer.parseInt(split[3]);
} catch (Exception e) { } catch (Exception e) {
if (chatMsg) if (chatMsg)
chat.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ConfigManager.ERROR_INVALID_VALUE_EXIT_POS)); chat.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_INVALID_VALUE_EXIT_POS));
return false; return false;
} }
} }
@ -96,29 +98,29 @@ public class Jail {
if (cell == null) { if (cell == null) {
if (chatMsg) if (chatMsg)
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ConfigManager.ERROR_UNAVAILABLE_CELL)); sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_UNAVAILABLE_CELL));
return null; return null;
} }
if (inmates.contains(new Inmate(jailer.getUniqueID()))) { if (inmates.contains(new Inmate(jailer.getUniqueID()))) {
if (chatMsg) if (chatMsg)
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ConfigManager.ERROR_ALREADY_IN_JAIL)); sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_ALREADY_IN_JAIL));
return null; return null;
} }
String timeString = ""; String timeString = "";
if (ConfigManager.FORMAT_TIME_JAIL == 1) if (FORMAT_TIME_JAIL == 1)
timeString = TimeUtils.getTimeYears(sec); timeString = TimeUtils.getTimeYears(sec);
else if (ConfigManager.FORMAT_TIME_JAIL == 2) else if (FORMAT_TIME_JAIL == 2)
timeString = TimeUtils.getTimeMonths(sec); timeString = TimeUtils.getTimeMonths(sec);
else if (ConfigManager.FORMAT_TIME_JAIL == 3) else if (FORMAT_TIME_JAIL == 3)
timeString = TimeUtils.getTimeDays(sec); timeString = TimeUtils.getTimeDays(sec);
else if (ConfigManager.FORMAT_TIME_JAIL == 4) else if (FORMAT_TIME_JAIL == 4)
timeString = TimeUtils.getTimeHours(sec); timeString = TimeUtils.getTimeHours(sec);
if (ConfigManager.SUCCESS_IN_JAIL.length() > 0) if (!SUCCESS_IN_JAIL.isEmpty())
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + ConfigManager.SUCCESS_IN_JAIL + timeString)); sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + SUCCESS_IN_JAIL + timeString));
if (ConfigManager.MSG_INMATE_GOING_TO_JAIL.length() > 0) if (!MSG_INMATE_GOING_TO_JAIL.isEmpty())
jailer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + ConfigManager.MSG_INMATE_GOING_TO_JAIL + timeString)); jailer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + MSG_INMATE_GOING_TO_JAIL + timeString));
inmates.add(new Inmate(cell, jailer.getUniqueID(), sec)); inmates.add(new Inmate(cell, jailer.getUniqueID(), sec));
Data.saveDataString(listJailerToListString(), "jailers"); Data.saveDataString(listJailerToListString(), "jailers");
@ -159,7 +161,7 @@ public class Jail {
if (!removed) { if (!removed) {
if (chatMsg) if (chatMsg)
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ConfigManager.ERROR_NOT_IN_JAIL)); sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_NOT_IN_JAIL));
return 2; return 2;
} }
@ -191,7 +193,7 @@ public class Jail {
} }
public void tpOutOfJail(EntityPlayer player) { public void tpOutOfJail(EntityPlayer player) {
Pos pos = ConfigManager.pos_exit_jail; Pos pos = pos_exit_jail;
if (player.dimension != pos.dimension) if (player.dimension != pos.dimension)
player.travelToDimension(pos.dimension); player.travelToDimension(pos.dimension);
player.setPositionAndUpdate(pos.x + 0.5, pos.y, pos.z + 0.5); player.setPositionAndUpdate(pos.x + 0.5, pos.y, pos.z + 0.5);
@ -225,7 +227,7 @@ public class Jail {
String[] split = s.split("~"); String[] split = s.split("~");
if (split.length != 4) if (split.length != 4)
throw new Exception("Error loading " + ConfigManager.DIR_SAVE + "cells.txt"); throw new Exception("Error loading " + DIR_SAVE + "cells.txt");
try { try {
cells.add(new Cell(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3]))); cells.add(new Cell(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3])));
@ -264,7 +266,7 @@ public class Jail {
String[] split = s.split("~"); String[] split = s.split("~");
if (split.length != 7) if (split.length != 7)
throw new Exception("Error loading " + ConfigManager.DIR_SAVE + "jailers.txt"); throw new Exception("Error loading " + DIR_SAVE + "jailers.txt");
try { try {
inmates.add(new Inmate(new Cell(Integer.parseInt(split[3]), Integer.parseInt(split[4]), Integer.parseInt(split[5]), Integer.parseInt(split[6])), inmates.add(new Inmate(new Cell(Integer.parseInt(split[3]), Integer.parseInt(split[4]), Integer.parseInt(split[5]), Integer.parseInt(split[6])),

View file

@ -14,6 +14,8 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import static gp_dbc.config.ConfigManager.*;
public class TimeJail { public class TimeJail {
int tick = 0; int tick = 0;
@ -50,7 +52,7 @@ public class TimeJail {
@SubscribeEvent @SubscribeEvent
public void checkPlayerIsFree(PlayerEvent.PlayerLoggedInEvent event) { public void checkPlayerIsFree(PlayerEvent.PlayerLoggedInEvent event) {
if (Main.gp.jail.freePlayer(event.player)) if (Main.gp.jail.freePlayer(event.player))
event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "You are out of the jail")); event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + SUCCESS_OUT_OF_JAIL));
} }
@SideOnly(Side.SERVER) @SideOnly(Side.SERVER)

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB