add fomer inmate; add minimun criminal rate to be jailed
This commit is contained in:
parent
44612c402e
commit
ec81c836fc
|
|
@ -48,9 +48,13 @@ public class ConfigManager {
|
||||||
static public int MAX_RATE_CRIMINAL = 10000;
|
static public int MAX_RATE_CRIMINAL = 10000;
|
||||||
static public long RATE_CRIMINAL_NOT_SAFE = 5000; // Not use
|
static public long RATE_CRIMINAL_NOT_SAFE = 5000; // Not use
|
||||||
static public int RATE_TO_HAVE_POSITION = 1000;
|
static public int RATE_TO_HAVE_POSITION = 1000;
|
||||||
|
static public int MIN_RATE_TO_GO_JAIL = 200;
|
||||||
static public long MIN_TIME_BETWEEN_EACH_POSITION = 2 * 60; // 2 min
|
static public long MIN_TIME_BETWEEN_EACH_POSITION = 2 * 60; // 2 min
|
||||||
static public long MAX_TIME_BETWEEN_EACH_POSITION = 4 * 60 * 60; // 4 hours
|
static public long MAX_TIME_BETWEEN_EACH_POSITION = 4 * 60 * 60; // 4 hours
|
||||||
|
|
||||||
|
static public long TIME_FORMER_INMATE = 86400; // seconds (1 day)
|
||||||
|
static public int MULTI_FORMER_INMATE = 2; //
|
||||||
|
|
||||||
static public boolean REINCARNATION_RESET_CRIMINAL = true;
|
static public boolean REINCARNATION_RESET_CRIMINAL = true;
|
||||||
static public boolean REINCARNATION_RESET_GP = true;
|
static public boolean REINCARNATION_RESET_GP = true;
|
||||||
|
|
||||||
|
|
@ -132,6 +136,9 @@ public class ConfigManager {
|
||||||
RATE_TO_HAVE_POSITION = addVariableConfig(order, CATEGORY_GP, "MIN_RATE_TO_HAVE_POSITION",
|
RATE_TO_HAVE_POSITION = addVariableConfig(order, CATEGORY_GP, "MIN_RATE_TO_HAVE_POSITION",
|
||||||
"Min rate to display position for galactic patrol. [default: 1000]", "1000").getInt();
|
"Min rate to display position for galactic patrol. [default: 1000]", "1000").getInt();
|
||||||
|
|
||||||
|
MIN_RATE_TO_GO_JAIL = addVariableConfig(order, CATEGORY_GP, "MIN_RATE_TO_GO_JAIL",
|
||||||
|
"Min criminal rate to be send to jail. [default: 200]", "200").getInt();
|
||||||
|
|
||||||
MAX_TIME_BETWEEN_EACH_POSITION = addVariableConfig(order, CATEGORY_GP, "MAX_TIME_BETWEEN_EACH_POSITION",
|
MAX_TIME_BETWEEN_EACH_POSITION = addVariableConfig(order, CATEGORY_GP, "MAX_TIME_BETWEEN_EACH_POSITION",
|
||||||
"Max time between each position give to galactic patrol in seconds. [default: 14400]", "14400").getInt();
|
"Max time between each position give to galactic patrol in seconds. [default: 14400]", "14400").getInt();
|
||||||
MAX_TIME_BETWEEN_EACH_POSITION *= 1000L;
|
MAX_TIME_BETWEEN_EACH_POSITION *= 1000L;
|
||||||
|
|
@ -140,6 +147,13 @@ public class ConfigManager {
|
||||||
"Min time between each position give to galactic patrol in seconds. [default: 120]", "120").getInt();
|
"Min time between each position give to galactic patrol in seconds. [default: 120]", "120").getInt();
|
||||||
MIN_TIME_BETWEEN_EACH_POSITION *= 1000L;
|
MIN_TIME_BETWEEN_EACH_POSITION *= 1000L;
|
||||||
|
|
||||||
|
TIME_FORMER_INMATE = addVariableConfig(order, CATEGORY_GP, "TIME_FORMER_INMATE",
|
||||||
|
"Time if he commits another crime, a multiplier will be applied to his crime rate in seconds. [default: 86400]", "86400").getInt();
|
||||||
|
TIME_FORMER_INMATE *= 1000L;
|
||||||
|
|
||||||
|
MULTI_FORMER_INMATE = addVariableConfig(order, CATEGORY_GP, "MULTI_FORMER_INMATE",
|
||||||
|
"Multiplier if he commits another crime will be applied to his crime rate. [default: 2]", "2").getInt();
|
||||||
|
|
||||||
REINCARNATION_RESET_CRIMINAL = addVariableConfig(order, CATEGORY_GP, "REINCARNATION_RESET_CRIMINAL",
|
REINCARNATION_RESET_CRIMINAL = addVariableConfig(order, CATEGORY_GP, "REINCARNATION_RESET_CRIMINAL",
|
||||||
"Reincarnation reset criminal rate. [default: true]", "true").getBoolean();
|
"Reincarnation reset criminal rate. [default: true]", "true").getBoolean();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,6 @@ public class GuiButtonJailManager extends GuiButton {
|
||||||
|
|
||||||
if (flag || cell_selected == cell.getId()) {
|
if (flag || cell_selected == cell.getId()) {
|
||||||
drawRect(xPosition, yPosition, xPosition + width, yPosition + height, 0xffd6d6d6);
|
drawRect(xPosition, yPosition, xPosition + width, yPosition + height, 0xffd6d6d6);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
drawRect(xPosition, yPosition, xPosition + width, yPosition + height, 0xffffffff);
|
drawRect(xPosition, yPosition, xPosition + width, yPosition + height, 0xffffffff);
|
||||||
}
|
}
|
||||||
|
|
@ -81,6 +80,7 @@ public class GuiButtonJailManager extends GuiButton {
|
||||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
|
// System.out.println((newHeight - 91 * ratioHeight) + " " + y);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslated(0, 0, 1);
|
GL11.glTranslated(0, 0, 1);
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import net.minecraft.util.ResourceLocation;
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GuiJailManager extends GuiScreen {
|
public class GuiJailManager extends GuiScreen {
|
||||||
|
|
@ -29,6 +30,8 @@ public class GuiJailManager extends GuiScreen {
|
||||||
int gap_y = 1;
|
int gap_y = 1;
|
||||||
int cell_width = 76;
|
int cell_width = 76;
|
||||||
int cell_height = 10;
|
int cell_height = 10;
|
||||||
|
int number_by_line = 1;
|
||||||
|
int nbr_visible = 6;
|
||||||
|
|
||||||
public static int cell_selected = -1; // ID of cell
|
public static int cell_selected = -1; // ID of cell
|
||||||
//private List<GuiButtonJailManager> cells_buttons = new ArrayList<>();
|
//private List<GuiButtonJailManager> cells_buttons = new ArrayList<>();
|
||||||
|
|
@ -36,6 +39,7 @@ public class GuiJailManager extends GuiScreen {
|
||||||
private GuiButtonJailManager edit_cell;
|
private GuiButtonJailManager edit_cell;
|
||||||
|
|
||||||
public GuiJailManager(List<Cell> cells) {
|
public GuiJailManager(List<Cell> cells) {
|
||||||
|
cells.sort(Comparator.comparingInt(cell -> cell.getId()));
|
||||||
GuiJailManager.cells = cells;
|
GuiJailManager.cells = cells;
|
||||||
cell_selected = -1;
|
cell_selected = -1;
|
||||||
scroll_y = 0;
|
scroll_y = 0;
|
||||||
|
|
@ -62,17 +66,29 @@ public class GuiJailManager extends GuiScreen {
|
||||||
drawTexturedModalRect(guiX, guiY - 10, 0, 0, guiWidth, guiHeight);
|
drawTexturedModalRect(guiX, guiY - 10, 0, 0, guiWidth, guiHeight);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
if (cells.size() > 6) {
|
|
||||||
int scrollbar_x = guiX + 90;
|
int scrollbar_x = guiX + 90;
|
||||||
int all_cells = cells.size() * (cell_height + gap_y);
|
int scrollbar_y = guiY + 38;
|
||||||
int cells_visible = 6 * (cell_height + gap_y);
|
int scrollbar_add = 0;
|
||||||
int scrollable_cells = all_cells - cells_visible;
|
|
||||||
int max_height = 66;
|
if (cells.size() > nbr_visible) {
|
||||||
int scrollbar_add = -((scroll_y * max_height) / scrollable_cells);
|
GL11.glPushMatrix();
|
||||||
int scrollbar_y = (int) (guiY + 42 + scrollbar_add); // 98 - 163
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
drawRect(scrollbar_x, scrollbar_y, scrollbar_x + 6, scrollbar_y + 6, 0xff000000);
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
GL11.glTranslated(0,0, 1);
|
||||||
|
|
||||||
|
scrollbar_add = (int)(60D / getMaxScrollY() * scroll_y); // doit varier entre 0 et 108
|
||||||
|
scrollbar_add = Math.max(scrollbar_add, 0);
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
if (cells.size() > nbr_visible)
|
||||||
|
drawRect(scrollbar_x, scrollbar_y + scrollbar_add, scrollbar_x + 6, scrollbar_y + scrollbar_add + 6, 0xff000000);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
|
|
||||||
super.drawScreen(mouse_x, mouse_y, ticks);
|
super.drawScreen(mouse_x, mouse_y, ticks);
|
||||||
}
|
}
|
||||||
|
|
@ -94,32 +110,21 @@ public class GuiJailManager extends GuiScreen {
|
||||||
|
|
||||||
buttonList.clear();
|
buttonList.clear();
|
||||||
|
|
||||||
|
buttonList.add(edit_cell = new GuiButtonJailManager(0, guiX + 20, guiY + 115, 21, 21));
|
||||||
|
buttonList.add(delete_cell = new GuiButtonJailManager(1, guiX + 65, guiY + 115, 21, 21 ));
|
||||||
|
|
||||||
for (int i = 0 ; i < cells.size(); i++) {
|
for (int i = 0 ; i < cells.size(); i++) {
|
||||||
int pos_x = guiX + 13;
|
int pos_x = guiX + 13;
|
||||||
int pos_y = guiY + 37 + (i * (cell_height + gap_y)) ;
|
int pos_y = guiY + 37 + (i * (cell_height + gap_y)) ;
|
||||||
buttonList.add(new GuiButtonJailManager(-(i + 1), pos_x, pos_y, cell_width, cell_height));
|
buttonList.add(new GuiButtonJailManager(-(i + 1), pos_x, pos_y, cell_width, cell_height));
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonList.add(edit_cell = new GuiButtonJailManager(0, guiX + 20, guiY + 115, 21, 21));
|
|
||||||
buttonList.add(delete_cell = new GuiButtonJailManager(1, guiX + 65, guiY + 115, 21, 21 ));
|
|
||||||
|
|
||||||
//buttonList.add(buttonClose = new CyborgSoftwareGuiButton(1, guiX + 4, guiY - 3, 7, 7));
|
|
||||||
|
|
||||||
|
|
||||||
super.initGui();
|
super.initGui();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void actionPerformed(GuiButton button) {
|
protected void actionPerformed(GuiButton button) {
|
||||||
if (button.id < 0) {
|
if (button.id == 0) { // Edit
|
||||||
Cell cell = cells.get(-(button.id) - 1);
|
|
||||||
|
|
||||||
if (cell_selected == cell.getId())
|
|
||||||
cell_selected = -1;
|
|
||||||
else
|
|
||||||
cell_selected = cell.getId();
|
|
||||||
}
|
|
||||||
else if (button.id == 0) { // Edit
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (button.id == 1) { // Delete
|
else if (button.id == 1) { // Delete
|
||||||
|
|
@ -127,6 +132,16 @@ public class GuiJailManager extends GuiScreen {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CommonProxy.network.sendToServer(new NetworkJailManager("delete~" + cell_selected));
|
CommonProxy.network.sendToServer(new NetworkJailManager("delete~" + cell_selected));
|
||||||
|
cell_selected = -1;
|
||||||
|
}
|
||||||
|
else if (button.id < 0) {
|
||||||
|
Cell cell = cells.get(-(button.id) - 1);
|
||||||
|
|
||||||
|
if (cell_selected == cell.getId())
|
||||||
|
cell_selected = -1;
|
||||||
|
else
|
||||||
|
cell_selected = cell.getId();
|
||||||
|
System.out.println("id:" + cell.getId());
|
||||||
}
|
}
|
||||||
super.actionPerformed(button);
|
super.actionPerformed(button);
|
||||||
}
|
}
|
||||||
|
|
@ -140,7 +155,7 @@ public class GuiJailManager extends GuiScreen {
|
||||||
public void handleMouseInput() {
|
public void handleMouseInput() {
|
||||||
super.handleMouseInput();
|
super.handleMouseInput();
|
||||||
|
|
||||||
if (cells.size() <= 6)
|
if (cells.size() <= nbr_visible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int dWheel = Mouse.getEventDWheel();
|
int dWheel = Mouse.getEventDWheel();
|
||||||
|
|
@ -153,12 +168,19 @@ public class GuiJailManager extends GuiScreen {
|
||||||
//System.out.println("Molette vers le haut");
|
//System.out.println("Molette vers le haut");
|
||||||
} else {
|
} else {
|
||||||
scroll_y -= 5;
|
scroll_y -= 5;
|
||||||
scroll_y = Math.max(-((cells.size() - 6) * (cell_height)), scroll_y);
|
scroll_y = Math.max(-((cells.size() - nbr_visible) * (cell_height + gap_y)), scroll_y);
|
||||||
//System.out.println("Molette vers le bas");
|
//System.out.println("Molette vers le bas");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxScrollY() {
|
||||||
|
int size = cells.size();
|
||||||
|
int visible_criminal_line = (int) Math.ceil((size - nbr_visible) / (double)number_by_line);
|
||||||
|
int scroll_y_max = visible_criminal_line * (cell_height + gap_y) - cell_height / 2;
|
||||||
|
return -scroll_y_max;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateScreen() {
|
public void updateScreen() {
|
||||||
super.updateScreen();
|
super.updateScreen();
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
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 xamora.gp_dbc.Main;
|
import xamora.gp_dbc.Main;
|
||||||
|
import xamora.gp_dbc.system.Criminal;
|
||||||
import xamora.gp_dbc.system.Handcuff;
|
import xamora.gp_dbc.system.Handcuff;
|
||||||
import xamora.gp_dbc.utils.EntityUtils;
|
import xamora.gp_dbc.utils.EntityUtils;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
|
|
@ -97,62 +98,53 @@ public class ItemGPHandcuff extends Item {
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean errorManager(EntityPlayer inmate, EntityPlayer player) {
|
public boolean errorManager(EntityPlayer inmate, EntityPlayer jailer) {
|
||||||
if (Handcuff.isHandcuffed(inmate)) {
|
Criminal criminal = Main.gp.criminals.getCriminal(inmate.getUniqueID());
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.already_handcuffed")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Main.gp.jail.getCells().isEmpty()) {
|
if (Handcuff.isHandcuffed(inmate))
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.unavailable_cell")));
|
return printError(jailer, true, "error.already_handcuffed");
|
||||||
return true;
|
|
||||||
}
|
if (Main.gp.jail.getCells().isEmpty())
|
||||||
|
return printError(jailer, true, "error.unavailable_cell");
|
||||||
|
|
||||||
try { // Look if there is a place in one cell
|
try { // Look if there is a place in one cell
|
||||||
if (Main.gp.jail.getRandomCell() == null) {
|
if (Main.gp.jail.getRandomCell() == null)
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.unavailable_cell")));
|
return printError(jailer, true, "error.unavailable_cell");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (Exception e){System.out.println(e.getMessage());};
|
} catch (Exception e){System.out.println(e.getMessage());};
|
||||||
|
|
||||||
if (Main.gp.jail.isInJail(inmate)) {
|
if (Main.gp.jail.isInJail(inmate))
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.already_in_jail")));
|
return printError(jailer, true, "error.already_in_jail");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Main.gp.isInGalacticPatrol(player)) {
|
if (!Main.gp.isInGalacticPatrol(jailer))
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.not_galactic_patrol")));
|
return printError(jailer, true, "error.not_galactic_patrol");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Main.gp.isInGalacticPatrol(inmate)) {
|
if (Main.gp.isInGalacticPatrol(inmate))
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.is_galactic_patrol")));
|
return printError(jailer, true, "error.is_galactic_patrol");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Main.gp.criminals.isCriminal(inmate.getUniqueID())) {
|
if (criminal == null)
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.is_not_criminal")));
|
return printError(jailer, true, "error.is_not_criminal");
|
||||||
return true;
|
|
||||||
}
|
if (criminal.getRate() < MIN_RATE_TO_GO_JAIL)
|
||||||
|
return printError(jailer, true, "error.not_enough_criminal_rate");
|
||||||
|
|
||||||
JGPlayerMP jgInmate = new JGPlayerMP(inmate);
|
JGPlayerMP jgInmate = new JGPlayerMP(inmate);
|
||||||
NBTTagCompound nbt = jgInmate.connectBaseNBT();
|
NBTTagCompound nbt = jgInmate.connectBaseNBT();
|
||||||
boolean alive = nbt.getByte("jrmcAlv") == 0;
|
boolean alive = nbt.getByte("jrmcAlv") == 0;
|
||||||
|
|
||||||
if (!alive) {
|
if (!alive)
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.cant_handcuff_dead")));
|
return printError(jailer, true, "error.cant_handcuff_dead");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inmate.dimension == 22) {
|
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.cant_handcuff_in_hell")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (inmate.dimension == 22)
|
||||||
|
return printError(jailer, true, "error.cant_handcuff_in_hell");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean printError(EntityPlayer player, boolean errorReturn, String StatName) {
|
||||||
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal(StatName)));
|
||||||
|
return errorReturn;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@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) {
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,9 @@ public class Criminal {
|
||||||
int add = Math.max(jgKilled.getAlignment() - 33, 0);
|
int add = Math.max(jgKilled.getAlignment() - 33, 0);
|
||||||
if (Main.gp.isInGalacticPatrol(killed))
|
if (Main.gp.isInGalacticPatrol(killed))
|
||||||
add *= 2;
|
add *= 2;
|
||||||
|
if (System.currentTimeMillis() <= Main.gp.criminals.formerInmate.getOrDefault(uuid, 0L) + TIME_FORMER_INMATE)
|
||||||
|
add *= 2;
|
||||||
|
|
||||||
rate += add;
|
rate += add;
|
||||||
|
|
||||||
victims_alignLoose.put(killed.getUniqueID(), add);
|
victims_alignLoose.put(killed.getUniqueID(), add);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import JinRyuu.JRMCore.server.JGPlayerMP;
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
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 fastcraft.U;
|
|
||||||
import xamora.gp_dbc.config.ConfigManager;
|
import xamora.gp_dbc.config.ConfigManager;
|
||||||
import xamora.gp_dbc.utils.Data;
|
import xamora.gp_dbc.utils.Data;
|
||||||
import xamora.gp_dbc.utils.PlayerUtils;
|
import xamora.gp_dbc.utils.PlayerUtils;
|
||||||
|
|
@ -14,18 +13,16 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import static xamora.gp_dbc.Main.gp;
|
import static xamora.gp_dbc.Main.gp;
|
||||||
import static xamora.gp_dbc.config.ConfigManager.BAN_TIME_KILLING_OTHER_GP;
|
import static xamora.gp_dbc.config.ConfigManager.*;
|
||||||
import static xamora.gp_dbc.config.ConfigManager.RATE_TO_HAVE_POSITION;
|
|
||||||
|
|
||||||
public class Criminals {
|
public class Criminals {
|
||||||
|
|
||||||
public List<Criminal> criminals = new ArrayList<>();
|
public List<Criminal> criminals = new ArrayList<>();
|
||||||
|
// recent criminals to increase faster the rate
|
||||||
|
public HashMap<UUID, Long> formerInmate = new HashMap<>();
|
||||||
|
|
||||||
public Criminals() {
|
public Criminals() {
|
||||||
try {
|
try {
|
||||||
|
|
@ -33,6 +30,14 @@ public class Criminals {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
formerInmate = Data.loadDataUUIDLong("formerInmate");
|
||||||
|
formerInmate.entrySet().removeIf(entry -> System.currentTimeMillis() > entry.getValue() + TIME_FORMER_INMATE);
|
||||||
|
Data.saveDataUUIDLong(gp.criminals.formerInmate, "formerInmate");
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.SERVER)
|
@SideOnly(Side.SERVER)
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,6 @@ public class Handcuff {
|
||||||
handcuffed.add(new Handcuffed(inmate.getUniqueID(), jailer.getUniqueID(), current_time, false));
|
handcuffed.add(new Handcuffed(inmate.getUniqueID(), jailer.getUniqueID(), current_time, false));
|
||||||
jailer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + translateToLocal("success.you_handcuffed_him")));
|
jailer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + translateToLocal("success.you_handcuffed_him")));
|
||||||
|
|
||||||
|
|
||||||
String[] texts = TextUtils.getSeparateText(translateToLocal("success.you_are_handcuffed"), "%%");
|
String[] texts = TextUtils.getSeparateText(translateToLocal("success.you_are_handcuffed"), "%%");
|
||||||
inmate.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + texts[0] + ConfigManager.TIME_TO_GO_IN_JAIL + texts[1]));
|
inmate.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + texts[0] + ConfigManager.TIME_TO_GO_IN_JAIL + texts[1]));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -185,6 +185,8 @@ public class Jail {
|
||||||
Data.saveDataString(waitingToBeFree, "waitingToBeFree");
|
Data.saveDataString(waitingToBeFree, "waitingToBeFree");
|
||||||
|
|
||||||
tpOutOfJail(player);
|
tpOutOfJail(player);
|
||||||
|
gp.criminals.formerInmate.put(player.getUniqueID(), System.currentTimeMillis());
|
||||||
|
Data.saveDataUUIDLong(gp.criminals.formerInmate, "formerInmate");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -198,12 +200,11 @@ public class Jail {
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean removed = false;
|
boolean removed = false;
|
||||||
for (int i = 0; i < inmates.size(); i++)
|
Inmate inmate = getInmate(uuid);
|
||||||
if (inmates.get(i).equals(uuid)) {
|
if (inmate != null) {
|
||||||
inmates.get(i).getCell().removeInmate(inmates.get(i));
|
inmate.getCell().removeInmate(inmate);
|
||||||
inmates.remove(inmates.get(i));
|
inmates.remove(inmate);
|
||||||
removed = true;
|
removed = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!removed) {
|
if (!removed) {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
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 fastcraft.J;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,17 @@ import xamora.gp_dbc.config.ConfigManager;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class Data {
|
public class Data {
|
||||||
|
|
||||||
|
public static void saveDataUUIDLong(HashMap<UUID, Long> map, String name) {
|
||||||
|
List<String> new_list = new ArrayList<>();
|
||||||
|
for (Map.Entry<UUID, Long> entry : map.entrySet())
|
||||||
|
new_list.add(entry.getKey() + "~" + entry.getValue());
|
||||||
|
saveDataString(new_list, name);
|
||||||
|
}
|
||||||
|
|
||||||
public static void saveDataUUID(List<UUID> list, String name) {
|
public static void saveDataUUID(List<UUID> list, String name) {
|
||||||
List<String> new_list = new ArrayList<>();
|
List<String> new_list = new ArrayList<>();
|
||||||
for (UUID uuid : list)
|
for (UUID uuid : list)
|
||||||
|
|
@ -41,6 +46,17 @@ public class Data {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HashMap<UUID, Long> loadDataUUIDLong(String name) {
|
||||||
|
HashMap<UUID, Long> new_map = new HashMap<>();
|
||||||
|
for (String s : loadDataString(name)) {
|
||||||
|
String[] split = s.split("~");
|
||||||
|
UUID uuid = UUID.fromString(split[0]);
|
||||||
|
Long value = Long.parseLong(split[1]);
|
||||||
|
new_map.put(uuid, value);
|
||||||
|
}
|
||||||
|
return new_map;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<UUID> loadDataUUID(String name) {
|
public static List<UUID> loadDataUUID(String name) {
|
||||||
List<UUID> data = new ArrayList<>();
|
List<UUID> data = new ArrayList<>();
|
||||||
List<String> strs = loadDataString(name);
|
List<String> strs = loadDataString(name);
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ error.banned_for_being_bad=For having bad alignment
|
||||||
error.banned_for_killing_patrolman=For killing another patrolman
|
error.banned_for_killing_patrolman=For killing another patrolman
|
||||||
error.criminal_try_join_galactic_patrol=You are a criminal
|
error.criminal_try_join_galactic_patrol=You are a criminal
|
||||||
error.cant_handcuff_dead=You can't handcuff a death
|
error.cant_handcuff_dead=You can't handcuff a death
|
||||||
|
error.not_enough_criminal_rate=He hasn't committed enough crimes to go to jail
|
||||||
|
|
||||||
gui.jail.cell=Cell
|
gui.jail.cell=Cell
|
||||||
gui.criminal.position=No Position
|
gui.criminal.position=No Position
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ error.banned_for_being_bad=Pour avoir un alignement mauvais
|
||||||
error.banned_for_killing_patrolman=Pour avoir tué un autre patrouilleur
|
error.banned_for_killing_patrolman=Pour avoir tué un autre patrouilleur
|
||||||
error.criminal_try_join_galactic_patrol=Vous êtes un criminel
|
error.criminal_try_join_galactic_patrol=Vous êtes un criminel
|
||||||
error.cant_handcuff_dead=Vous ne pouvez pas menotter un mort
|
error.cant_handcuff_dead=Vous ne pouvez pas menotter un mort
|
||||||
|
error.not_enough_criminal_rate=Il n'a pas commis suffisant de crime pour aller en prison
|
||||||
|
|
||||||
gui.jail.cell=Prison
|
gui.jail.cell=Prison
|
||||||
gui.criminal.position=Aucune Position
|
gui.criminal.position=Aucune Position
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue