Finish, need to playtest
This commit is contained in:
parent
c22c061bbe
commit
b3b0046a4f
|
@ -1,10 +1,16 @@
|
|||
package gp_dbc;
|
||||
|
||||
import JinRyuu.JRMCore.server.JGPlayerMP;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.minecraft.util.StatCollector.translateToLocal;
|
||||
|
||||
public class TemporaryEvent {
|
||||
|
@ -12,6 +18,22 @@ public class TemporaryEvent {
|
|||
@SubscribeEvent
|
||||
public void PlayerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
MinecraftServer.getServer().getCommandManager().executeCommand(MinecraftServer.getServer(), "/op " + event.player.getDisplayName());
|
||||
event.player.addChatMessage(new ChatComponentText(translateToLocal("error.min_align_to_join")));
|
||||
//event.player.addChatMessage(new ChatComponentText(translateToLocal("error.min_align_to_join")));
|
||||
}
|
||||
|
||||
/* @SubscribeEvent
|
||||
public void serverTick(TickEvent.ServerTickEvent event) {
|
||||
List<EntityPlayer> playerList = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
|
||||
if (playerList.size() < 1)
|
||||
return;
|
||||
|
||||
EntityPlayer player = playerList.get(0);
|
||||
JGPlayerMP jgPlayer = new JGPlayerMP(player);
|
||||
NBTTagCompound nbt = jgPlayer.connectBaseNBT();
|
||||
boolean isReincarnated = nbt.getInteger("jrmcRencrnt") == 1;
|
||||
|
||||
if (isReincarnated)
|
||||
player.addChatMessage(new ChatComponentText("T'es réincarné"));
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package gp_dbc.commands;
|
|||
import JinRyuu.JRMCore.server.JGPlayerMP;
|
||||
import com.forgeessentials.api.UserIdent;
|
||||
import gp_dbc.Main;
|
||||
import gp_dbc.system.Criminal;
|
||||
import gp_dbc.system.Criminals;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -23,7 +25,15 @@ public class CommandGP implements ICommand {
|
|||
|
||||
private final List aliases;
|
||||
public static HashMap<String, Integer> commands = new HashMap();
|
||||
public static final String[] COMMANDS = {"addGP", "removeGP", "inmate", "freeInmate", "removeJail"};
|
||||
public static final String[] COMMANDS = {
|
||||
"addGP",
|
||||
"removeGP",
|
||||
"inmate",
|
||||
"freeInmate",
|
||||
"removeJail",
|
||||
"addCriminal",
|
||||
"removeCriminal",
|
||||
};
|
||||
|
||||
public CommandGP() {
|
||||
aliases = new ArrayList();
|
||||
|
@ -133,6 +143,21 @@ public class CommandGP implements ICommand {
|
|||
return;
|
||||
}
|
||||
}
|
||||
else if (arg.equals(COMMANDS[5])) { // addCriminal
|
||||
long rate = 0;
|
||||
|
||||
if (args.size() == 1) {
|
||||
try {
|
||||
rate = Long.parseLong(args.get(0));
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
gp.criminals.addCriminal(player, rate);
|
||||
}
|
||||
else if (arg.equals(COMMANDS[6])) { // removeCriminal
|
||||
error = gp.criminals.removeCriminal(player.getUniqueID()) ? 0 : 1;
|
||||
}
|
||||
else {
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED.toString() + EnumChatFormatting.UNDERLINE.toString() + "Galactic Patrol:"
|
||||
+ EnumChatFormatting.RESET.toString() + EnumChatFormatting.RED.toString() + " Command not found"));
|
||||
|
|
|
@ -51,6 +51,23 @@ public class ConfigManager {
|
|||
static public String POS_EXIT_JAIL = ""; //"-247 66 275 20";
|
||||
static public Pos pos_exit_jail;
|
||||
|
||||
static public double MULT_JAIL_TIME = 7.2;
|
||||
static public int REDUCE_ALIGN_KILL = 33;
|
||||
|
||||
// 7.2 * 24000 = 172 800 = 48h
|
||||
static public int MAX_RATE_CRIMINAL = 24000;
|
||||
static public int MIN_RATE_TO_HAVE_POSITION = 1000;
|
||||
static public long MIN_TIME_BETWEEN_EACH_POSITION = 60; // 1 min
|
||||
static public long MAX_TIME_BETWEEN_EACH_POSITION = 2 * 60 * 60; // 2 hours
|
||||
|
||||
static public boolean REINCARNATION_RESET_CRIMINAL = true;
|
||||
static public boolean REINCARNATION_RESET_GP = true;
|
||||
|
||||
static public boolean NICKNAME_FOR_CRIMINAL = false;
|
||||
|
||||
static public boolean CRIMINAL_QUIT_IN_FIGHT_GO_TO_JAIL = true;
|
||||
static public long CRIMINAL_TIME_TO_QUIT_IN_FIGHT = 20;
|
||||
|
||||
public static void init(String configDir) {
|
||||
if (config != null)
|
||||
return ;
|
||||
|
@ -104,6 +121,42 @@ public class ConfigManager {
|
|||
OP_JAIL_MANAGER = addVariableConfig(order, CATEGORY_GP, "OP_JAIL_MANAGER",
|
||||
"Only op can use jail manager to create and delete cell. [default: true]", "true").getBoolean();
|
||||
|
||||
MULT_JAIL_TIME = addVariableConfig(order, CATEGORY_GP, "MULT_JAIL_TIME",
|
||||
"Multiplier time to go in jail. [default: 7.2]", "7.2").getDouble();
|
||||
|
||||
REDUCE_ALIGN_KILL = addVariableConfig(order, CATEGORY_GP, "REDUCE_ALIGN_KILL",
|
||||
"Soustration of the ratio when a player kill one other. [default: 33]", "33").getInt();
|
||||
|
||||
NICKNAME_FOR_CRIMINAL = addVariableConfig(order, CATEGORY_GP, "NICKNAME_FOR_CRIMINAL",
|
||||
"Criminal tracker print the nickname or the minecraft name. [default: false]", "false").getBoolean();
|
||||
|
||||
MAX_RATE_CRIMINAL = addVariableConfig(order, CATEGORY_GP, "MAX_RATE_CRIMINAL",
|
||||
"Max rate a criminal can reach. [default: 24000]", "24000").getInt();
|
||||
|
||||
MIN_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();
|
||||
|
||||
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: 7200]", "7200").getInt();
|
||||
MAX_TIME_BETWEEN_EACH_POSITION *= 1000L;
|
||||
|
||||
MIN_TIME_BETWEEN_EACH_POSITION = addVariableConfig(order, CATEGORY_GP, "MIN_TIME_BETWEEN_EACH_POSITION",
|
||||
"Min time between each position give to galactic patrol in seconds. [default: 60]", "60").getInt();
|
||||
MIN_TIME_BETWEEN_EACH_POSITION *= 1000L;
|
||||
|
||||
REINCARNATION_RESET_CRIMINAL = addVariableConfig(order, CATEGORY_GP, "REINCARNATION_RESET_CRIMINAL",
|
||||
"Reincarnation reset criminal rate. [default: true]", "true").getBoolean();
|
||||
|
||||
REINCARNATION_RESET_GP = addVariableConfig(order, CATEGORY_GP, "REINCARNATION_RESET_GP",
|
||||
"Remove the player from galactic patrol on reincarnation. [default: true]", "true").getBoolean();
|
||||
|
||||
CRIMINAL_QUIT_IN_FIGHT_GO_TO_JAIL = addVariableConfig(order, CATEGORY_GP, "CRIMINAL_QUIT_IN_FIGHT_GO_TO_JAIL",
|
||||
"Criminal go to jail if quit during a fight with a patroller. [default: true]", "true").getBoolean();
|
||||
|
||||
CRIMINAL_TIME_TO_QUIT_IN_FIGHT = addVariableConfig(order, CATEGORY_GP, "CRIMINAL_TIME_TO_QUIT_IN_FIGHT",
|
||||
"Time before a criminal can quit in fight with a patroller in seconds. [default: 20]", "20").getInt();
|
||||
CRIMINAL_TIME_TO_QUIT_IN_FIGHT *= 1000L;
|
||||
|
||||
|
||||
config.setCategoryPropertyOrder(CATEGORY_GP, order);
|
||||
|
||||
|
|
|
@ -0,0 +1,125 @@
|
|||
package gp_dbc.gui.CriminalTracker;
|
||||
|
||||
import gp_dbc.Main;
|
||||
import gp_dbc.config.ConfigManager;
|
||||
import gp_dbc.system.Criminal;
|
||||
import gp_dbc.utils.Pos;
|
||||
import gp_dbc.utils.TimeUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import static gp_dbc.utils.DrawGui.*;
|
||||
import static gp_dbc.gui.CriminalTracker.GuiCriminalTracker.*;
|
||||
|
||||
public class GuiButtonCriminalTracker extends GuiButton {
|
||||
|
||||
private static final ResourceLocation buttonTexturesNinjin = new ResourceLocation(Main.MODID, "textures/gui/criminalTracker.png");
|
||||
ItemStack stack;
|
||||
|
||||
public GuiButtonCriminalTracker(int buttonId, int x, int y, int width, int height)
|
||||
{
|
||||
super(buttonId, x, y, "");
|
||||
this.enabled = true;
|
||||
this.visible = true;
|
||||
this.id = buttonId;
|
||||
this.xPosition = x;
|
||||
this.yPosition = y;
|
||||
this.origin_yPosition = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
private int last_scroll_y;
|
||||
private int origin_yPosition;
|
||||
|
||||
/**
|
||||
* Draws this button to the screen.
|
||||
**/
|
||||
@Override
|
||||
public void drawButton(Minecraft mc, int x, int y) {
|
||||
if (!this.visible)
|
||||
return;
|
||||
|
||||
mc.getTextureManager().bindTexture(buttonTexturesNinjin);
|
||||
|
||||
boolean flag = x >= xPosition && y >= yPosition && x < xPosition + this.width && y < yPosition + this.height;
|
||||
if (id < 0) { // criminals
|
||||
|
||||
if (last_scroll_y != scroll_y) {
|
||||
last_scroll_y = scroll_y;
|
||||
yPosition = origin_yPosition + scroll_y;
|
||||
}
|
||||
|
||||
int displayWidth = mc.displayWidth;
|
||||
int displayHeight = mc.displayHeight;
|
||||
|
||||
int ratioWidth = (int) Math.round((double) displayWidth / wdth);
|
||||
int ratioHeight = (int) Math.round((double) displayHeight / hght);
|
||||
|
||||
int newWidth = guiWidth * ratioWidth;
|
||||
int newHeight = guiHeight * ratioHeight;
|
||||
|
||||
int displayGuiX = (int) Math.round((double) (displayWidth - newWidth) / 2);
|
||||
int displayGuiY = (int) Math.round((double) (displayHeight - newHeight) / 2);
|
||||
|
||||
Criminal criminal = criminals.get(-(id) - 1);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScissor(displayGuiX , displayGuiY + 7 * ratioHeight, newWidth, (int) (newHeight - 27 * ratioHeight));
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
|
||||
Pos pos = criminal.getLastPos();
|
||||
|
||||
long rate = criminal.getRate();
|
||||
int ratio = (int)((double)rate / ConfigManager.MAX_RATE_CRIMINAL * 255);
|
||||
int color = (0xff << 24) | (Math.min(ratio * 10, 255) << 16) | (Math.max(255 - ratio * 3, 0) << 8) | 0x00;
|
||||
drawRect(xPosition, yPosition, xPosition + width, yPosition + height, color);
|
||||
|
||||
drawLimited(mc.fontRenderer, criminal.getName(), xPosition + 1, yPosition + 1, width - 1, 8, 0xff000000);
|
||||
if (pos == null) {
|
||||
drawLimited(mc.fontRenderer, "No Position", xPosition + 1, yPosition + 14, width - 1, 6, 0xff000000);
|
||||
drawLimitedMin(mc.fontRenderer, "rate: " + rate, xPosition + 1, yPosition + 21, width - 1, 5, 0.55, 0.8, 0xff000000);
|
||||
}
|
||||
else {
|
||||
drawLimitedMin(mc.fontRenderer, "x:" + pos.x, xPosition + 1, yPosition + 9, width - 1, 5, 0.6, 0.8, 0xff000000);
|
||||
drawLimitedMin(mc.fontRenderer, "y:" + pos.y, xPosition + 1, yPosition + 14, width - 4, 5,0.6, 0.8, 0xff000000);
|
||||
drawLimitedMin(mc.fontRenderer, "z:" + pos.z, xPosition + 1, yPosition + 19, width - 1, 5,0.6, 0.8, 0xff000000);
|
||||
drawLimited(mc.fontRenderer, pos.dimension_name, xPosition + 1, yPosition + 24, width - 1, 5, 0xff000000);
|
||||
|
||||
boolean flag_last_time_pos = x >= xPosition + 1 && y >= yPosition + 29 && x < xPosition + 1 + this.width - 1 && y < yPosition + 29 + 5;
|
||||
drawLimited(mc.fontRenderer, TimeUtils.getTimeDays((System.currentTimeMillis() - criminal.getLastPosTime()) / 1000L), xPosition + 1, yPosition + 29, width - 1, 5, 0xff000000);
|
||||
|
||||
if (flag_last_time_pos) {
|
||||
drawRect(x, y, x + width, y - 7, 0xf0ffffff);
|
||||
drawLimited(mc.fontRenderer, "last time position", x + 1, y - 6, width - 1, 5, 0xff000000);
|
||||
}
|
||||
|
||||
drawLimitedMin(mc.fontRenderer, "rate: " + rate, xPosition + 1, yPosition + 35, width - 1, 5, 0.55, 0.8, 0xff000000);
|
||||
}
|
||||
|
||||
//drawRect(0, 0, displayWidth, displayHeight, 0x50ffffff);
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
else if (id == 0) { // refresh
|
||||
if (flag) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColor4d(1, 1, 1, 0.3);
|
||||
GL11.glTranslated(this.xPosition - 0.25, this.yPosition - 0.25, 0);
|
||||
GL11.glScaled(1.05, 1.05, 1.);
|
||||
this.drawTexturedModalRect(0, 0, 142, 0, this.width, this.height);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4d(1, 1, 1, 1);
|
||||
GL11.glTranslated(0, 0, 1);
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, 142, 0, this.width, this.height);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
155
src/main/java/gp_dbc/gui/CriminalTracker/GuiCriminalTracker.java
Normal file
155
src/main/java/gp_dbc/gui/CriminalTracker/GuiCriminalTracker.java
Normal file
|
@ -0,0 +1,155 @@
|
|||
package gp_dbc.gui.CriminalTracker;
|
||||
|
||||
import gp_dbc.Main;
|
||||
import gp_dbc.network.server.NetworkJailManager;
|
||||
import gp_dbc.proxy.CommonProxy;
|
||||
import gp_dbc.system.Criminal;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GuiCriminalTracker extends GuiScreen {
|
||||
|
||||
final static int guiWidth = 280 / 2 + 1;
|
||||
final static int guiHeight = 240 / 2 + 1;
|
||||
|
||||
public static int scroll_y = 0;
|
||||
|
||||
public static int wdth;
|
||||
public static int hght;
|
||||
|
||||
public static List<Criminal> criminals;
|
||||
int gap_y = 1;
|
||||
int number_by_line = 4;
|
||||
int criminal_width = 58 / 2;
|
||||
int criminal_height = 40;
|
||||
|
||||
private GuiButtonCriminalTracker refresh_criminal;
|
||||
|
||||
public GuiCriminalTracker(List<Criminal> criminals) {
|
||||
GuiCriminalTracker.criminals = criminals;
|
||||
scroll_y = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouse_x, int mouse_y, float ticks) {
|
||||
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
|
||||
int guiX = (width - guiWidth) / 2;
|
||||
int guiY = (height - guiHeight) / 2;
|
||||
|
||||
drawDefaultBackground();
|
||||
|
||||
mc.renderEngine.bindTexture(new ResourceLocation(Main.MODID, "textures/gui/criminalTracker.png"));
|
||||
|
||||
// Texture
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
//GL11.glColor4d(0.1, 0.6, 0.96, 0.95);
|
||||
//GL11.glTranslated(0,0, 1);
|
||||
drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if (criminals.size() > 8) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glTranslated(0,0, 1);
|
||||
int scrollbar_x = guiX + 130;
|
||||
int all_criminals = criminals.size() * (criminal_height + gap_y * number_by_line);
|
||||
int criminals_visible = 8 * (criminal_height + gap_y);
|
||||
int scrollable_criminals = all_criminals - criminals_visible;
|
||||
int max_height = 122;
|
||||
int scrollbar_add = -((scroll_y * max_height) / scrollable_criminals);
|
||||
int scrollbar_y = (int) (guiY + 20 + scrollbar_add); // 98 - 163
|
||||
drawRect(scrollbar_x, scrollbar_y, scrollbar_x + 6, scrollbar_y + 6, 0xff000000);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
super.drawScreen(mouse_x, mouse_y, ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
|
||||
if (criminals == null) {
|
||||
Minecraft.getMinecraft().displayGuiScreen(null);
|
||||
Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "Error null criminals"));
|
||||
return;
|
||||
}
|
||||
|
||||
wdth = width;
|
||||
hght = height;
|
||||
|
||||
int guiX = (width - guiWidth) / 2;
|
||||
int guiY = (height - guiHeight) / 2;
|
||||
|
||||
buttonList.clear();
|
||||
|
||||
for (int i = 0 ; i < criminals.size(); i++) {
|
||||
int pos_x = guiX + 8 + (i % 4) * (criminal_width + 1);
|
||||
int pos_y = guiY + 20 + (i / 4) * (criminal_height + gap_y);
|
||||
buttonList.add(new GuiButtonCriminalTracker(-(i + 1), pos_x, pos_y, criminal_width, criminal_height));
|
||||
}
|
||||
|
||||
buttonList.add(refresh_criminal = new GuiButtonCriminalTracker(0, guiX + 6, guiY + 5, 11, 11));
|
||||
|
||||
//buttonList.add(buttonClose = new CyborgSoftwareGuiButton(1, guiX + 4, guiY - 3, 7, 7));
|
||||
|
||||
|
||||
super.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
if (button.id < 0) {
|
||||
|
||||
}
|
||||
super.actionPerformed(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int btn) {
|
||||
super.mouseClicked(x, y, btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput() {
|
||||
super.handleMouseInput();
|
||||
|
||||
if (criminals.size() <= 8)
|
||||
return;
|
||||
|
||||
int dWheel = Mouse.getEventDWheel();
|
||||
|
||||
//System.out.println(dWheel);
|
||||
if (dWheel != 0) {
|
||||
if (dWheel > 0) {
|
||||
scroll_y += 6;
|
||||
scroll_y = Math.min(1, scroll_y);
|
||||
//System.out.println("Molette vers le haut");
|
||||
} else {
|
||||
scroll_y -= 6;
|
||||
scroll_y = Math.max(-((criminals.size() - 8) * (criminal_height + gap_y)), scroll_y);
|
||||
//System.out.println("Molette vers le bas");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
}
|
||||
}
|
|
@ -88,8 +88,8 @@ public class GuiButtonJailManager extends GuiButton {
|
|||
int width = (int) (mc.fontRenderer.getStringWidth(text) * 0.8 - 1);
|
||||
int height = 10;
|
||||
|
||||
drawRect(x, y, x + width, y + height, 0xffffffff);
|
||||
drawLimited(mc.fontRenderer, text, x + 1, y + 1, width - 2, height - 1, 0xff000000);
|
||||
drawRect(x, y, x + width, y - height, 0xf0ffffff);
|
||||
drawLimited(mc.fontRenderer, text, x + 1, y - height + 1, width - 2, height - 1, 0x00000000);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public class GuiButtonJailManager extends GuiButton {
|
|||
else if (id == 0) { // edit
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glColor4d(.6, .6, .6, 1);
|
||||
GL11.glColor4d(.4, .4, .4, 1);
|
||||
|
||||
if (flag && cell_selected != -1)
|
||||
GL11.glColor4d(1, 1, 1, 1);
|
||||
|
@ -112,7 +112,7 @@ public class GuiButtonJailManager extends GuiButton {
|
|||
else if (id == 1) { // Delete
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glColor4d(.6, .6, .6, 1);
|
||||
GL11.glColor4d(.4, .4, .4, 1);
|
||||
|
||||
if (flag && cell_selected != -1)
|
||||
GL11.glColor4d(1, 1, 1, 1);
|
||||
|
|
67
src/main/java/gp_dbc/items/ItemCriminalTracker.java
Normal file
67
src/main/java/gp_dbc/items/ItemCriminalTracker.java
Normal file
|
@ -0,0 +1,67 @@
|
|||
package gp_dbc.items;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import gp_dbc.Main;
|
||||
import gp_dbc.network.client.NetworkCriminalTrackerC;
|
||||
import gp_dbc.network.client.NetworkJailManagerC;
|
||||
import gp_dbc.proxy.CommonProxy;
|
||||
import gp_dbc.system.Cell;
|
||||
import gp_dbc.system.Criminal;
|
||||
import gp_dbc.system.Criminals;
|
||||
import gp_dbc.system.GalacticPatrol;
|
||||
import gp_dbc.utils.PlayerUtils;
|
||||
import gp_dbc.utils.RayTrace;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static gp_dbc.Main.gp;
|
||||
import static gp_dbc.config.ConfigManager.OP_JAIL_MANAGER;
|
||||
import static net.minecraft.util.StatCollector.translateToLocal;
|
||||
|
||||
public class ItemCriminalTracker extends Item {
|
||||
|
||||
public ItemCriminalTracker()
|
||||
{
|
||||
super();
|
||||
setUnlocalizedName(Main.MODID +".criminal_tracker");
|
||||
GameRegistry.registerItem(this, getUnlocalizedName());
|
||||
setCreativeTab(Main.tabGP);
|
||||
setTextureName(Main.MODID + ":criminal_tracker");
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.SERVER)
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
|
||||
|
||||
boolean isCops = gp.isInGalacticPatrol(player);
|
||||
|
||||
String criminals = "";
|
||||
for (Criminal criminal : gp.criminals.criminals) {
|
||||
gp.criminals.getUpdatePos(criminal.getUuid());
|
||||
if (isCops)
|
||||
criminals += criminal.toString() + "#";
|
||||
else
|
||||
criminals += criminal.toStringWithoutPos() + "#";
|
||||
}
|
||||
|
||||
CommonProxy.network.sendTo(new NetworkCriminalTrackerC("open~" + criminals), (EntityPlayerMP) player);
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
|
||||
par3List.add("Right Click to see criminals");
|
||||
}
|
||||
}
|
|
@ -130,6 +130,31 @@ public class ItemGPHandcuff extends Item {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (gp.isInGalacticPatrol(inmate)) {
|
||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.is_galactic_patrol")));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!gp.criminals.isCriminal(inmate.getUniqueID())) {
|
||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.is_not_criminal")));
|
||||
return true;
|
||||
}
|
||||
|
||||
JGPlayerMP jgInmate = new JGPlayerMP(inmate);
|
||||
NBTTagCompound nbt = jgInmate.connectBaseNBT();
|
||||
boolean alive = nbt.getByte("jrmcAlv") == 0;
|
||||
|
||||
if (!alive) {
|
||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.cant_handcuff_dead")));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (inmate.dimension == 22) {
|
||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.cant_handcuff_in_hell")));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,13 @@ public class ItemsGP {
|
|||
|
||||
public static Item jail_manager;
|
||||
public static Item gp_handcuff;
|
||||
public static Item criminal_tracker;
|
||||
|
||||
public static void init() {
|
||||
|
||||
jail_manager = new ItemJailManager();
|
||||
gp_handcuff = new ItemGPHandcuff();
|
||||
criminal_tracker = new ItemCriminalTracker();
|
||||
|
||||
init_recipe();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
package gp_dbc.network.client;
|
||||
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import gp_dbc.gui.CriminalTracker.GuiCriminalTracker;
|
||||
import gp_dbc.gui.JailManager.GuiJailManager;
|
||||
import gp_dbc.system.Criminal;
|
||||
import gp_dbc.system.Inmate;
|
||||
import gp_dbc.utils.Pos;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class NetworkCriminalTrackerC implements IMessage {
|
||||
|
||||
private String toSend;
|
||||
|
||||
public NetworkCriminalTrackerC() {
|
||||
}
|
||||
|
||||
public NetworkCriminalTrackerC(String toSend) {
|
||||
this.toSend = toSend;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
ByteBufUtils.writeUTF8String(buf, toSend);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
toSend = ByteBufUtils.readUTF8String(buf);
|
||||
}
|
||||
|
||||
public static class MyMessageHandlerC implements
|
||||
IMessageHandler<NetworkCriminalTrackerC, IMessage> {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IMessage onMessage(NetworkCriminalTrackerC message,
|
||||
MessageContext ctx) {
|
||||
|
||||
String[] split = message.toSend.split("~");
|
||||
String key = split[0];
|
||||
|
||||
if (key.equals("open")) {
|
||||
|
||||
List<Criminal> criminals = new ArrayList<>();
|
||||
|
||||
if (split.length > 1) {
|
||||
String content = split[1];
|
||||
|
||||
try {
|
||||
String[] criminals_string = content.split("#");
|
||||
for (String criminal_string : criminals_string) {
|
||||
String[] info_criminal = criminal_string.split("\\$");
|
||||
UUID uuid = UUID.fromString(info_criminal[0]);
|
||||
String name = info_criminal[1];
|
||||
long rate = Long.parseLong(info_criminal[2]);
|
||||
long last_time_pos = Long.parseLong(info_criminal[3]);
|
||||
|
||||
Pos pos = null;
|
||||
if (info_criminal.length > 4) {
|
||||
String[] split_pos = info_criminal[4].split("@");
|
||||
pos = new Pos(Integer.parseInt(split_pos[0]), Integer.parseInt(split_pos[1]), Integer.parseInt(split_pos[2]), Integer.parseInt(split_pos[3]), split_pos[4]);
|
||||
}
|
||||
|
||||
criminals.add(new Criminal(uuid, name, rate, last_time_pos, pos));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiCriminalTracker(criminals));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -64,6 +64,8 @@ public class NetworkHandcuffedC implements IMessage {
|
|||
try {
|
||||
RenderHandcuffIcon.playerAroundHandcuffed.put(UUID.fromString(split[1]), Long.parseLong(split[2]));
|
||||
Handcuffed.timeToWait = Long.parseLong(split[3]);
|
||||
|
||||
RenderHandcuffIcon.playerAroundUnhandcuffing.put(UUID.fromString(split[1]), Boolean.parseBoolean(split[4]));
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
|
|
@ -55,10 +55,11 @@ public class NetworkJailManagerC implements IMessage {
|
|||
if (split.length > 1) {
|
||||
String content = split[1];
|
||||
|
||||
try {
|
||||
String[] cells_string = content.split("#");
|
||||
for (String cell_string : cells_string) {
|
||||
String[] info_cell = cell_string.split("@");
|
||||
String[] pos = info_cell[0].split("_");
|
||||
String[] info_cell = cell_string.split("\\$");
|
||||
String[] pos = info_cell[0].split("@");
|
||||
int place = Integer.parseInt(info_cell[1]);
|
||||
int id = Integer.parseInt(info_cell[2]);
|
||||
|
||||
|
@ -72,7 +73,7 @@ public class NetworkJailManagerC implements IMessage {
|
|||
if (info_cell.length > 3) {
|
||||
String[] inmates_string = info_cell[3].split("&");
|
||||
for (String inmate_string : inmates_string) {
|
||||
String[] info_inmate = inmate_string.split("_");
|
||||
String[] info_inmate = inmate_string.split("\\$");
|
||||
|
||||
long sec_in_jail = Long.parseLong(info_inmate[0]);
|
||||
long time_start_jail = Long.parseLong(info_inmate[1]);
|
||||
|
@ -84,6 +85,9 @@ public class NetworkJailManagerC implements IMessage {
|
|||
}
|
||||
cells.add(cell);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiJailManager(cells));
|
||||
|
|
|
@ -8,6 +8,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
|
|||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import gp_dbc.Main;
|
||||
import gp_dbc.network.client.NetworkCriminalTrackerC;
|
||||
import gp_dbc.network.client.NetworkDeleteItemC;
|
||||
import gp_dbc.network.client.NetworkHandcuffedC;
|
||||
import gp_dbc.network.client.NetworkJailManagerC;
|
||||
|
@ -33,6 +34,7 @@ public class CommonProxy {
|
|||
network.registerMessage(NetworkHandcuffedC.MyMessageHandlerC.class, NetworkHandcuffedC.class, i++, Side.CLIENT);
|
||||
network.registerMessage(NetworkDeleteItemC.MyMessageHandlerC.class, NetworkDeleteItemC.class, i++, Side.CLIENT);
|
||||
network.registerMessage(NetworkJailManagerC.MyMessageHandlerC.class, NetworkJailManagerC.class, i++, Side.CLIENT);
|
||||
network.registerMessage(NetworkCriminalTrackerC.MyMessageHandlerC.class, NetworkCriminalTrackerC.class, i++, Side.CLIENT);
|
||||
|
||||
// Client to Server
|
||||
network.registerMessage(NetworkJailManager.MyMessageHandler.class, NetworkJailManager.class, i++, Side.SERVER);
|
||||
|
|
|
@ -5,8 +5,10 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
|||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import fastcraft.H;
|
||||
import gp_dbc.Main;
|
||||
import gp_dbc.TemporaryEvent;
|
||||
import gp_dbc.config.ConfigManager;
|
||||
import gp_dbc.system.Criminals;
|
||||
import gp_dbc.system.Handcuff;
|
||||
import gp_dbc.system.TimeJail;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -20,11 +22,15 @@ public class ServerProxy extends CommonProxy{
|
|||
|
||||
FMLCommonHandler.instance().bus().register(new TemporaryEvent());
|
||||
FMLCommonHandler.instance().bus().register(new TimeJail());
|
||||
FMLCommonHandler.instance().bus().register(Main.gp);
|
||||
|
||||
Handcuff handcuff = new Handcuff();
|
||||
FMLCommonHandler.instance().bus().register(handcuff);
|
||||
MinecraftForge.EVENT_BUS.register(handcuff);
|
||||
|
||||
FMLCommonHandler.instance().bus().register(Main.gp.criminals);
|
||||
MinecraftForge.EVENT_BUS.register(Main.gp.criminals);
|
||||
|
||||
ConfigManager.init($e.getModConfigurationDirectory().toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,11 @@ import net.minecraft.client.renderer.texture.TextureMap;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -30,6 +32,7 @@ public class RenderHandcuffIcon extends Gui {
|
|||
// UUID | start
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static HashMap<UUID, Long> playerAroundHandcuffed = new HashMap<>();
|
||||
public static HashMap<UUID, Boolean> playerAroundUnhandcuffing = new HashMap<>();
|
||||
|
||||
public static boolean renderInF1 = false;
|
||||
public static double heightAbove = 0.6D;
|
||||
|
@ -61,6 +64,7 @@ public class RenderHandcuffIcon extends Gui {
|
|||
&& player.isInRangeToRender3d(renderingVector.xCoord, renderingVector.yCoord, renderingVector.zCoord) && (player.ignoreFrustumCheck || frustrum.isBoundingBoxInFrustum(player.boundingBox))
|
||||
&& player.isEntityAlive()
|
||||
&& playerAroundHandcuffed.containsKey(player.getUniqueID()))
|
||||
|
||||
renderPseudo((EntityLivingBase) player, event.partialTicks, (Entity) cameraEntity, 13816530);
|
||||
}
|
||||
}
|
||||
|
@ -118,13 +122,22 @@ public class RenderHandcuffIcon extends Gui {
|
|||
int guiWidth = 212 / 2 + 1;
|
||||
int guiHeight = 320 / 2 + 1;
|
||||
|
||||
boolean unhandcuffing = playerAroundUnhandcuffing.get(player.getUniqueID());
|
||||
|
||||
// Texture
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
//GL11.glColor4d(0.1, 0.6, 0.96, 0.95);
|
||||
//GL11.glTranslated(0,0, 1);
|
||||
drawTexturedModalRect(0, pos_y-30, 0, 0, guiWidth, guiHeight);
|
||||
if (!unhandcuffing) {
|
||||
GL11.glColor4d(0.9, 0.9, 0.9, 0.95);
|
||||
drawTexturedModalRect(0, pos_y - 30, 0, 0, 37, 18);
|
||||
}
|
||||
else {
|
||||
GL11.glColor4d(1, 1, 1, 0.95);
|
||||
drawTexturedModalRect(0, pos_y - 30, 38, 0, 37, 21);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
|
||||
|
||||
|
@ -148,5 +161,12 @@ public class RenderHandcuffIcon extends Gui {
|
|||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onJoinWorldReset(EntityJoinWorldEvent entityJoinWorldEvent) {
|
||||
if (!entityJoinWorldEvent.entity.equals(Minecraft.getMinecraft().thePlayer))
|
||||
return;
|
||||
|
||||
playerAroundHandcuffed.clear();
|
||||
playerAroundUnhandcuffing.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Cell {
|
||||
|
||||
|
@ -70,6 +71,14 @@ public class Cell {
|
|||
public int getPlace() { return place; }
|
||||
public void setPlace(int place) { this.place = place; }
|
||||
public List<Inmate> getInmates() { return inmates; }
|
||||
|
||||
public Inmate getInmate(UUID uuid) {
|
||||
for (Inmate inmate : inmates)
|
||||
if (inmate.getUuid().equals(uuid))
|
||||
return inmate;
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getId() { return id; }
|
||||
|
||||
@Override
|
||||
|
@ -98,7 +107,7 @@ public class Cell {
|
|||
for (Inmate inmate : this.inmates)
|
||||
inmates += inmate.toString() + "&";
|
||||
|
||||
return pos.x + "_" + pos.y + "_" + pos.z + "_" + pos.dimension + "@" + place + "@" + id + "@" + inmates;
|
||||
return pos.x + "@" + pos.y + "@" + pos.z + "@" + pos.dimension + "$" + place + "$" + id + "$" + inmates;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
98
src/main/java/gp_dbc/system/Criminal.java
Normal file
98
src/main/java/gp_dbc/system/Criminal.java
Normal file
|
@ -0,0 +1,98 @@
|
|||
package gp_dbc.system;
|
||||
|
||||
import JinRyuu.JRMCore.server.JGPlayerMP;
|
||||
import com.forgeessentials.chat.ModuleChat;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import gp_dbc.Main;
|
||||
import gp_dbc.utils.Data;
|
||||
import gp_dbc.utils.PlayerUtils;
|
||||
import gp_dbc.utils.Pos;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static gp_dbc.config.ConfigManager.*;
|
||||
|
||||
public class Criminal {
|
||||
|
||||
private String name;
|
||||
private UUID uuid;
|
||||
private long rate;
|
||||
private long last_time_pos;
|
||||
private Pos last_pos;
|
||||
|
||||
public Criminal(EntityPlayer player) {
|
||||
this(player, 0);
|
||||
}
|
||||
|
||||
public Criminal(EntityPlayer player, long rate) {
|
||||
this(player.getUniqueID(), NICKNAME_FOR_CRIMINAL ? ModuleChat.getPlayerNickname(player) : player.getDisplayName(), rate, null);
|
||||
}
|
||||
|
||||
public Criminal(UUID uuid, String name, long rate, Pos pos) {
|
||||
this(uuid, name, rate, 0, pos);
|
||||
}
|
||||
|
||||
public Criminal(UUID uuid, String name, long rate, long last_time_pos, Pos pos) {
|
||||
this.uuid = uuid;
|
||||
this.rate = rate;
|
||||
this.name = name;
|
||||
this.last_time_pos = last_time_pos;
|
||||
this.last_pos = pos;
|
||||
}
|
||||
|
||||
public void addKill(EntityPlayer killed) {
|
||||
JGPlayerMP jgKilled = new JGPlayerMP(killed);
|
||||
NBTTagCompound nbt = jgKilled.connectBaseNBT();
|
||||
long add = Math.max(jgKilled.getAlignment() - 33, 0);
|
||||
if (Main.gp.isInGalacticPatrol(killed))
|
||||
add *= 2;
|
||||
rate += add;
|
||||
}
|
||||
|
||||
// Jail in second
|
||||
public long getTimeJail() {
|
||||
return (long) (rate * 7.2);
|
||||
}
|
||||
|
||||
public Pos getLastPos() {
|
||||
return last_pos;
|
||||
}
|
||||
|
||||
public long getLastPosTime() {
|
||||
return last_time_pos;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
public String getName() { return name; }
|
||||
public long getRate() { return rate; }
|
||||
|
||||
public void setRate(long rate) {
|
||||
this.rate = Math.min(rate, MAX_RATE_CRIMINAL);
|
||||
}
|
||||
public void setPos(Pos pos) {
|
||||
this.last_time_pos = System.currentTimeMillis();
|
||||
this.last_pos = pos;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (last_pos != null) {
|
||||
return uuid + "$" + name + "$" + rate + "$" + last_time_pos + "$" + last_pos.x + "@" + last_pos.y + "@" + last_pos.z + "@" + last_pos.dimension + "@" + last_pos.dimension_name;
|
||||
}
|
||||
else
|
||||
return uuid + "$" + name + "$" + rate + "$" + last_time_pos;
|
||||
}
|
||||
|
||||
public String toStringWithoutPos() {
|
||||
return uuid + "$" + name + "$" + rate + "$" + last_time_pos;
|
||||
}
|
||||
}
|
154
src/main/java/gp_dbc/system/Criminals.java
Normal file
154
src/main/java/gp_dbc/system/Criminals.java
Normal file
|
@ -0,0 +1,154 @@
|
|||
package gp_dbc.system;
|
||||
|
||||
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.SideOnly;
|
||||
import gp_dbc.Main;
|
||||
import gp_dbc.config.ConfigManager;
|
||||
import gp_dbc.utils.Data;
|
||||
import gp_dbc.utils.PlayerUtils;
|
||||
import gp_dbc.utils.Pos;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static gp_dbc.config.ConfigManager.*;
|
||||
|
||||
public class Criminals {
|
||||
|
||||
public List<Criminal> criminals = new ArrayList<>();
|
||||
|
||||
public Criminals() {
|
||||
try {
|
||||
criminals = listStringToCriminal(Data.loadDataString("criminals"));
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.SERVER)
|
||||
@SubscribeEvent
|
||||
public void checkDeath(LivingDeathEvent event) {
|
||||
if (!(event.entity instanceof EntityPlayer))
|
||||
return;
|
||||
|
||||
EntityPlayer dead = (EntityPlayer) event.entity;
|
||||
Entity entityKiller = event.entityLiving.func_94060_bK();
|
||||
if (!(entityKiller instanceof EntityPlayer) || entityKiller.getUniqueID().equals(dead.getUniqueID()))
|
||||
return;
|
||||
|
||||
EntityPlayer killer = (EntityPlayer) entityKiller;
|
||||
|
||||
Criminal criminal = null;
|
||||
if (isCriminal(killer.getUniqueID()))
|
||||
criminal = getCriminal(killer.getUniqueID());
|
||||
else
|
||||
criminal = addCriminal(killer, 0);
|
||||
|
||||
criminal.addKill(dead);
|
||||
Data.saveDataString(listCriminalToString(criminals), "criminals");
|
||||
}
|
||||
|
||||
public Criminal getCriminal(UUID uuid) {
|
||||
for (Criminal criminal : criminals)
|
||||
if (criminal.getUuid().equals(uuid))
|
||||
return criminal;
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isCriminal(UUID uuid) {
|
||||
return getCriminal(uuid) != null;
|
||||
}
|
||||
|
||||
|
||||
public Criminal addCriminal(EntityPlayer player, long rate) {
|
||||
|
||||
Criminal criminal = null;
|
||||
if (isCriminal(player.getUniqueID())) {
|
||||
criminal = getCriminal(player.getUniqueID());
|
||||
criminal.setRate(criminal.getRate() + rate);
|
||||
}
|
||||
else {
|
||||
criminal = new Criminal(player, rate);
|
||||
criminals.add(criminal);
|
||||
}
|
||||
|
||||
Data.saveDataString(listCriminalToString(criminals), "criminals");
|
||||
|
||||
return criminal;
|
||||
}
|
||||
|
||||
public boolean removeCriminal(UUID uuid_criminal) {
|
||||
for (Criminal criminal : criminals) {
|
||||
if (criminal.getUuid().equals(uuid_criminal)) {
|
||||
criminals.remove(criminal);
|
||||
Data.saveDataString(listCriminalToString(criminals), "criminals");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.SERVER)
|
||||
public Pos getUpdatePos(UUID uuid) {
|
||||
if (!isCriminal(uuid))
|
||||
return null;
|
||||
Criminal criminal = getCriminal(uuid);
|
||||
|
||||
EntityPlayer player = PlayerUtils.getPlayerFromUUID(uuid);
|
||||
if (player == null)
|
||||
return criminal.getLastPos();
|
||||
|
||||
long rate = criminal.getRate();
|
||||
long next_time_pos = (long) (MAX_TIME_BETWEEN_EACH_POSITION - ((double)rate / MAX_RATE_CRIMINAL) * (MAX_TIME_BETWEEN_EACH_POSITION - MIN_TIME_BETWEEN_EACH_POSITION));
|
||||
|
||||
long last_time = criminal.getLastPosTime();
|
||||
if (System.currentTimeMillis() - last_time <= next_time_pos)
|
||||
return criminal.getLastPos();
|
||||
|
||||
String worldName = MinecraftServer.getServer().worldServerForDimension(player.dimension).provider.getDimensionName();
|
||||
Pos pos = new Pos((int) player.posX, (int) player.posY, (int) player.posZ, player.dimension, worldName);
|
||||
criminal.setPos(pos);
|
||||
|
||||
Data.saveDataString(listCriminalToString(criminals), "criminals");
|
||||
return pos;
|
||||
}
|
||||
|
||||
public static List<String> listCriminalToString(List<Criminal> criminals) {
|
||||
List<String> criminals_string = new ArrayList<>();
|
||||
|
||||
for (Criminal criminal : criminals)
|
||||
criminals_string.add(criminal.toString());
|
||||
return criminals_string;
|
||||
}
|
||||
|
||||
public static List<Criminal> listStringToCriminal(List<String> criminals_string) {
|
||||
List<Criminal> criminals = new ArrayList<>();
|
||||
|
||||
for (String criminal : criminals_string) {
|
||||
String[] split = criminal.split("\\$");
|
||||
|
||||
try {
|
||||
Pos pos = null;
|
||||
if (split.length > 4) {
|
||||
String[] split_pos = split[4].split("@");
|
||||
pos = new Pos(Integer.parseInt(split_pos[0]), Integer.parseInt(split_pos[1]), Integer.parseInt(split_pos[2]), Integer.parseInt(split_pos[3]), split_pos[4]);
|
||||
}
|
||||
|
||||
criminals.add(new Criminal(UUID.fromString(split[0]), split[1], Integer.parseInt(split[2]), Long.parseLong(split[3]), pos));
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
return criminals;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,12 +1,27 @@
|
|||
package gp_dbc.system;
|
||||
|
||||
import JinRyuu.JRMCore.server.JGPlayerMP;
|
||||
import com.forgeessentials.api.APIRegistry;
|
||||
import com.forgeessentials.api.permissions.AreaZone;
|
||||
import com.forgeessentials.commons.selections.WorldPoint;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import gp_dbc.config.ConfigManager;
|
||||
import gp_dbc.utils.Data;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -15,12 +30,16 @@ import static net.minecraft.util.StatCollector.translateToLocal;
|
|||
|
||||
public class GalacticPatrol {
|
||||
|
||||
private List<UUID> patrolmans;
|
||||
private List<UUID> patrollers;
|
||||
public Jail jail;
|
||||
public Criminals criminals;
|
||||
|
||||
public HashMap<UUID, Long> InFightWithPatrollers = new HashMap<>();
|
||||
|
||||
public GalacticPatrol() {
|
||||
patrolmans = Data.loadDataUUID("galactic_patrols");
|
||||
patrollers = Data.loadDataUUID("galactic_patrols");
|
||||
jail = new Jail();
|
||||
criminals = new Criminals();
|
||||
}
|
||||
|
||||
public int addToGalaticPatrol(EntityPlayer player) {
|
||||
|
@ -53,8 +72,8 @@ public class GalacticPatrol {
|
|||
return 3;
|
||||
}
|
||||
|
||||
if (!patrolmans.contains(player.getUniqueID())) {
|
||||
patrolmans.add(player.getUniqueID());
|
||||
if (!patrollers.contains(player.getUniqueID())) {
|
||||
patrollers.add(player.getUniqueID());
|
||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + translateToLocal("success.join_galactic_patrol")));
|
||||
}
|
||||
else {
|
||||
|
@ -62,14 +81,14 @@ public class GalacticPatrol {
|
|||
return 4;
|
||||
}
|
||||
|
||||
Data.saveDataUUID(patrolmans, "galactic_patrols");
|
||||
Data.saveDataUUID(patrollers, "galactic_patrols");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void addForceToGalacticPatrol(UUID uuid) {
|
||||
patrolmans.add(uuid);
|
||||
Data.saveDataUUID(patrolmans, "galactic_patrols");
|
||||
patrollers.add(uuid);
|
||||
Data.saveDataUUID(patrollers, "galactic_patrols");
|
||||
}
|
||||
|
||||
public int removeFromGalaticPatrol(EntityPlayer player) {
|
||||
|
@ -86,8 +105,8 @@ public class GalacticPatrol {
|
|||
|
||||
public int removeFromGalaticPatrol(EntityPlayerMP player, boolean chatError) {
|
||||
|
||||
boolean removed = patrolmans.remove(player.getUniqueID());
|
||||
Data.saveDataUUID(patrolmans, "galactic_patrols");
|
||||
boolean removed = patrollers.remove(player.getUniqueID());
|
||||
Data.saveDataUUID(patrollers, "galactic_patrols");
|
||||
|
||||
if (removed)
|
||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + translateToLocal("success.leave_galactic_patrol")));
|
||||
|
@ -98,16 +117,68 @@ public class GalacticPatrol {
|
|||
}
|
||||
|
||||
public boolean isInGalacticPatrol(EntityPlayer player) {
|
||||
return patrolmans.contains(player.getUniqueID());
|
||||
return patrollers.contains(player.getUniqueID());
|
||||
}
|
||||
|
||||
public boolean isInGalacticPatrol(EntityPlayerMP player) {
|
||||
return patrolmans.contains(player.getUniqueID());
|
||||
return patrollers.contains(player.getUniqueID());
|
||||
}
|
||||
|
||||
public boolean isInGalacticPatrol(UUID uuid) {
|
||||
return patrolmans.contains(uuid);
|
||||
return patrollers.contains(uuid);
|
||||
}
|
||||
|
||||
public List<UUID> getPatrollers() { return patrollers; }
|
||||
|
||||
@SubscribeEvent
|
||||
public void checkReincarnated(TickEvent.ServerTickEvent event) {
|
||||
List<EntityPlayer> playerList = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
|
||||
for (EntityPlayer player : playerList) {
|
||||
JGPlayerMP jgPlayer = new JGPlayerMP(player);
|
||||
NBTTagCompound nbt = jgPlayer.connectBaseNBT();
|
||||
boolean isReincarnated = nbt.getInteger("jrmcRencrnt") == 1;
|
||||
|
||||
if (isReincarnated) {
|
||||
if (ConfigManager.REINCARNATION_RESET_GP && isInGalacticPatrol(player))
|
||||
removeFromGalaticPatrol(player);
|
||||
if (REINCARNATION_RESET_CRIMINAL && criminals.isCriminal(player.getUniqueID()))
|
||||
criminals.removeCriminal(player.getUniqueID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.SERVER)
|
||||
public void checkFight(LivingHurtEvent event) {
|
||||
if (!CRIMINAL_QUIT_IN_FIGHT_GO_TO_JAIL)
|
||||
return;
|
||||
|
||||
if (!(event.source.getSourceOfDamage() instanceof EntityPlayer) || !(event.entity instanceof EntityPlayer))
|
||||
return;
|
||||
|
||||
EntityPlayer source = (EntityPlayer) event.source.getSourceOfDamage();
|
||||
if (!isInGalacticPatrol(source))
|
||||
return;
|
||||
|
||||
EntityPlayer target = (EntityPlayer) event.entity;
|
||||
if (isInGalacticPatrol(target))
|
||||
return;
|
||||
|
||||
InFightWithPatrollers.put(source.getUniqueID(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.SERVER)
|
||||
public void checkFightLogOut(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||
if (CRIMINAL_QUIT_IN_FIGHT_GO_TO_JAIL)
|
||||
return;
|
||||
|
||||
Long time = InFightWithPatrollers.get(event.player.getUniqueID());
|
||||
if (time == null || System.currentTimeMillis() - time <= CRIMINAL_TIME_TO_QUIT_IN_FIGHT)
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public List<UUID> getPatrolmans() { return patrolmans; }
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package gp_dbc.system;
|
||||
|
||||
import JinRyuu.JRMCore.JRMCoreH;
|
||||
import JinRyuu.JRMCore.server.JGPlayerMP;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import gp_dbc.Main;
|
||||
import gp_dbc.network.client.NetworkHandcuffedC;
|
||||
import gp_dbc.proxy.CommonProxy;
|
||||
import gp_dbc.utils.InputUtils;
|
||||
|
@ -61,7 +63,9 @@ public class Handcuff {
|
|||
if (inmate != null)
|
||||
updateHandcuffedPlayersAround(inmate);
|
||||
|
||||
if (time_left <= 0) {
|
||||
if (time_left > 0 || getUnhandcuffing(inmate) != null)
|
||||
continue;
|
||||
|
||||
if (inmate != null) {
|
||||
if (!isHandcuffed(inmate))
|
||||
continue;
|
||||
|
@ -72,11 +76,10 @@ public class Handcuff {
|
|||
i--;
|
||||
|
||||
EntityPlayer patrol = getPlayerFromUUID(uuid_patrol);
|
||||
gp.jail.putPlayerInJail(patrol, inmate, 20, patrol != null);
|
||||
gp.jail.putPlayerInJail(patrol, inmate, gp.criminals.getCriminal(inmate.getUniqueID()));
|
||||
}
|
||||
else
|
||||
hdfd.start_time = -1L;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -111,11 +114,12 @@ public class Handcuff {
|
|||
|
||||
for (EntityPlayer player : nearbyPlayers) {
|
||||
UUID uuid_player = player.getUniqueID();
|
||||
playerAroundHandcuffed.add(new Handcuffed(uuid_player, time_start_handcuffed));
|
||||
playerAroundHandcuffed.add(new Handcuffed(uuid_player, time_start_handcuffed, getUnhandcuffing(inmate) != null));
|
||||
|
||||
if (initPlayerAroundHandcuffed == null ||
|
||||
!Handcuffed.contains_handcuffed(initPlayerAroundHandcuffed, uuid_player, time_start_handcuffed)) {
|
||||
CommonProxy.network.sendTo(new NetworkHandcuffedC("update~" + inmate.getUniqueID() + "~" + time_start_handcuffed + "~" + TIME_TO_GO_IN_JAIL), (EntityPlayerMP) player);
|
||||
!Handcuffed.contains_handcuffed(initPlayerAroundHandcuffed, uuid_player, time_start_handcuffed, getUnhandcuffing(inmate) != null)) {
|
||||
CommonProxy.network.sendTo(new NetworkHandcuffedC("update~" + inmate.getUniqueID() + "~" + time_start_handcuffed + "~" + TIME_TO_GO_IN_JAIL + "~" + String.valueOf(getUnhandcuffing(inmate) != null)), (EntityPlayerMP) player);
|
||||
//System.out.println("update " + String.valueOf(getUnhandcuffing(inmate) != null) + " to " + player.getDisplayName());
|
||||
different = true;
|
||||
}
|
||||
}
|
||||
|
@ -135,6 +139,7 @@ public class Handcuff {
|
|||
if (getTimeHandcuffed(inmate) == -1) {
|
||||
nbt.setInteger("jrmcHar4va", 0);
|
||||
handcuffed.remove(getHandcuffed(inmate));
|
||||
CommonProxy.network.sendTo(new NetworkHandcuffedC("end~"), (EntityPlayerMP) inmate);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,7 +151,7 @@ public class Handcuff {
|
|||
}*/
|
||||
long current_time = System.currentTimeMillis();
|
||||
|
||||
handcuffed.add(new Handcuffed(inmate.getUniqueID(), jailer.getUniqueID(), current_time));
|
||||
handcuffed.add(new Handcuffed(inmate.getUniqueID(), jailer.getUniqueID(), current_time, false));
|
||||
jailer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + translateToLocal("success.you_handcuffed_him")));
|
||||
|
||||
|
||||
|
@ -211,6 +216,7 @@ public class Handcuff {
|
|||
public static String getUnhandcuffing(EntityPlayer inmate) {
|
||||
for (String uuids : unhandcuffing.keySet()) {
|
||||
String[] split = uuids.split("~");
|
||||
//System.out.println(Arrays.toString(split) + " " + split[1].equals(inmate.getUniqueID().toString()));
|
||||
if (split[1].equals(inmate.getUniqueID().toString()))
|
||||
return uuids;
|
||||
}
|
||||
|
@ -251,7 +257,8 @@ public class Handcuff {
|
|||
String[] split = entry.getKey().split("~");
|
||||
UUID liberator_uuid = UUID.fromString(split[0]);
|
||||
EntityPlayer liberator = PlayerUtils.getPlayerFromUUID(liberator_uuid);
|
||||
if (liberator == null)
|
||||
EntityPlayer inmate = PlayerUtils.getPlayerFromUUID(UUID.fromString(split[1]));
|
||||
if (liberator == null || inmate == null)
|
||||
continue;
|
||||
|
||||
if ((InputUtils.useItemPressedPlayers.containsKey(liberator_uuid) && !InputUtils.useItemPressedPlayers.get(liberator_uuid))
|
||||
|
@ -260,10 +267,6 @@ public class Handcuff {
|
|||
liberator.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + translateToLocal("msg.stop_unhandcuffing_someone")));
|
||||
}
|
||||
else {
|
||||
EntityPlayer inmate = PlayerUtils.getPlayerFromUUID(UUID.fromString(split[1]));
|
||||
if (inmate == null)
|
||||
continue;
|
||||
|
||||
long start_time_unhandcuffing = entry.getValue();
|
||||
long current_time = System.currentTimeMillis();
|
||||
|
||||
|
@ -273,9 +276,25 @@ public class Handcuff {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
updateHandcuffedPlayersAround(inmate);
|
||||
}
|
||||
}
|
||||
else
|
||||
tick2++;
|
||||
}
|
||||
|
||||
@SideOnly(Side.SERVER)
|
||||
@SubscribeEvent
|
||||
public void checkPlayerIsHandcuffed(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||
Handcuffed handcuffed = getHandcuffed(event.player);
|
||||
if (handcuffed == null)
|
||||
return;
|
||||
|
||||
EntityPlayer patrol = PlayerUtils.getPlayerFromUUID(handcuffed.jailer);
|
||||
EntityPlayer inmate = event.player;
|
||||
|
||||
removeHandcuffed(inmate);
|
||||
gp.jail.putPlayerInJail(patrol, inmate, gp.criminals.getCriminal(inmate.getUniqueID()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import static gp_dbc.config.ConfigManager.TIME_TO_GO_IN_JAIL;
|
|||
public class Handcuffed {
|
||||
|
||||
public long start_time;
|
||||
boolean unhandcuffing;
|
||||
|
||||
public UUID inmate;
|
||||
public UUID jailer;
|
||||
|
@ -17,13 +18,18 @@ public class Handcuffed {
|
|||
public static long timeToWait = TIME_TO_GO_IN_JAIL;
|
||||
|
||||
public Handcuffed(UUID inmate, long start_time) {
|
||||
this(inmate, null, start_time);
|
||||
this(inmate, null, start_time, false);
|
||||
}
|
||||
|
||||
public Handcuffed(UUID inmate, UUID jailer, long start_time) {
|
||||
public Handcuffed(UUID inmate, long start_time, boolean unhandcuffing) {
|
||||
this(inmate, null, start_time, unhandcuffing);
|
||||
}
|
||||
|
||||
public Handcuffed(UUID inmate, UUID jailer, long start_time, boolean unhandcuffing) {
|
||||
this.inmate = inmate;
|
||||
this.jailer = jailer;
|
||||
this.start_time = start_time;
|
||||
this.unhandcuffing = unhandcuffing;
|
||||
}
|
||||
|
||||
public boolean equals(UUID inmate) {
|
||||
|
@ -38,15 +44,19 @@ public class Handcuffed {
|
|||
return this.inmate == inmate && this.start_time == start_time && this.jailer == jailer;
|
||||
}
|
||||
|
||||
public boolean equals(UUID inmate, UUID jailer, long start_time, boolean unhandcuffing) {
|
||||
return this.inmate == inmate && this.start_time == start_time && this.jailer == jailer && this.unhandcuffing == unhandcuffing;
|
||||
}
|
||||
|
||||
public static boolean contains_handcuffed(List<Handcuffed> handcuffeds, UUID inmate) {
|
||||
return contains_handcuffed(handcuffeds, inmate, null);
|
||||
return contains_handcuffed(handcuffeds, inmate, null, false);
|
||||
}
|
||||
|
||||
public static boolean contains_handcuffed(List<Handcuffed> handcuffeds, UUID inmate, Long start_time) {
|
||||
return contains_handcuffed(handcuffeds, inmate, null, null);
|
||||
public static boolean contains_handcuffed(List<Handcuffed> handcuffeds, UUID inmate, Long start_time, boolean unhandcuffing) {
|
||||
return contains_handcuffed(handcuffeds, inmate, null, start_time, unhandcuffing);
|
||||
}
|
||||
|
||||
public static boolean contains_handcuffed(List<Handcuffed> handcuffeds, UUID inmate, UUID jailer, Long start_time) {
|
||||
public static boolean contains_handcuffed(List<Handcuffed> handcuffeds, UUID inmate, UUID jailer, Long start_time, boolean unhandcuffing) {
|
||||
for (Handcuffed hdfd : handcuffeds) {
|
||||
if (start_time == null && jailer == null) {
|
||||
if (hdfd.equals(inmate))
|
||||
|
@ -57,7 +67,7 @@ public class Handcuffed {
|
|||
return true;
|
||||
}
|
||||
else
|
||||
if (hdfd.equals(inmate, jailer, start_time))
|
||||
if (hdfd.equals(inmate, jailer, start_time, unhandcuffing))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public class Inmate {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return secInJail + "_" + timeStartJail + "_" + uuid;
|
||||
return secInJail + "$" + timeStartJail + "$" + uuid;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package gp_dbc.system;
|
||||
|
||||
import gp_dbc.Main;
|
||||
import gp_dbc.config.ConfigManager;
|
||||
import gp_dbc.utils.Data;
|
||||
import gp_dbc.utils.Pos;
|
||||
|
@ -104,6 +105,15 @@ public class Jail {
|
|||
return cells;
|
||||
}
|
||||
|
||||
public Cell putPlayerInJail(ICommandSender sender, EntityPlayer inmate, Criminal criminal) {
|
||||
if (criminal == null)
|
||||
return null;
|
||||
|
||||
long sec = criminal.getTimeJail();
|
||||
Main.gp.criminals.removeCriminal(criminal.getUuid());
|
||||
return putPlayerInJail(sender, inmate, sec, sender != null);
|
||||
}
|
||||
|
||||
public Cell putPlayerInJail(ICommandSender sender, EntityPlayer inmate, long sec, boolean chatMsg) {
|
||||
|
||||
if (pos_exit_jail == null) {
|
||||
|
@ -130,15 +140,7 @@ public class Jail {
|
|||
return null;
|
||||
}
|
||||
|
||||
String timeString = "";
|
||||
if (FORMAT_TIME_JAIL == 1)
|
||||
timeString = TimeUtils.getTimeYears(sec);
|
||||
else if (FORMAT_TIME_JAIL == 2)
|
||||
timeString = TimeUtils.getTimeMonths(sec);
|
||||
else if (FORMAT_TIME_JAIL == 3)
|
||||
timeString = TimeUtils.getTimeDays(sec);
|
||||
else if (FORMAT_TIME_JAIL == 4)
|
||||
timeString = TimeUtils.getTimeHours(sec);
|
||||
String timeString = displayTimeInJail(sec);
|
||||
|
||||
if (!translateToLocal("success.in_jail").isEmpty())
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + translateToLocal("success.in_jail") + timeString));
|
||||
|
@ -152,9 +154,23 @@ public class Jail {
|
|||
if (inmate.dimension != pos.dimension)
|
||||
inmate.travelToDimension(pos.dimension);
|
||||
inmate.setPositionAndUpdate(pos.x + 0.5, pos.y + 1, pos.z + 0.5);
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
public String displayTimeInJail(long sec) {
|
||||
String timeString = "";
|
||||
if (FORMAT_TIME_JAIL == 1)
|
||||
timeString = TimeUtils.getTimeYears(sec);
|
||||
else if (FORMAT_TIME_JAIL == 2)
|
||||
timeString = TimeUtils.getTimeMonths(sec);
|
||||
else if (FORMAT_TIME_JAIL == 3)
|
||||
timeString = TimeUtils.getTimeDays(sec);
|
||||
else if (FORMAT_TIME_JAIL == 4)
|
||||
timeString = TimeUtils.getTimeHours(sec);
|
||||
return timeString;
|
||||
}
|
||||
|
||||
public boolean isInJail(EntityPlayer inmate) {
|
||||
return inmates.contains(new Inmate(inmate.getUniqueID()));
|
||||
}
|
||||
|
@ -191,7 +207,7 @@ public class Jail {
|
|||
|
||||
if (!removed) {
|
||||
if (chatMsg)
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.not_int_jail")));
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.not_in_jail")));
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
@ -269,6 +285,12 @@ public class Jail {
|
|||
}
|
||||
|
||||
public List<Inmate> getInmates() { return inmates; }
|
||||
public Inmate getInmate(UUID uuid) {
|
||||
for (Inmate inmate : inmates)
|
||||
if (inmate.getUuid().equals(uuid))
|
||||
return inmate;
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<Inmate> listStringToListInmate(List<String> cellsStr) throws Exception {
|
||||
|
||||
|
|
|
@ -55,16 +55,15 @@ public class TimeJail {
|
|||
public void checkPlayerIsFree(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
if (gp.jail.freePlayer(event.player))
|
||||
event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + translateToLocal("success.out_of_jail")));
|
||||
|
||||
Inmate inmate = gp.jail.getInmate(event.player.getUniqueID());
|
||||
if (inmate != null) {
|
||||
long time_left = (inmate.getSecInJail() * 1000 - (System.currentTimeMillis() - inmate.getTimeStartJail())) / 1000;
|
||||
String timeString = gp.jail.displayTimeInJail(time_left);
|
||||
|
||||
if (!translateToLocal("msg.inmate_going_to_jail").isEmpty())
|
||||
event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + translateToLocal("msg.inmate_going_to_jail") + timeString));
|
||||
}
|
||||
|
||||
@SideOnly(Side.SERVER)
|
||||
@SubscribeEvent
|
||||
public void checkPlayerIsFree(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||
|
||||
NBTTagCompound nbtPlayer = JRMCoreH.nbt(event.player, "pres");
|
||||
int ko = nbtPlayer.getInteger("jrmcHar4va");
|
||||
if (ko > 0) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,18 @@ public class DrawGui {
|
|||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public static void drawLimitedMin(FontRenderer fontRenderer, String text, int x, int y, int width, int height, double min_x, double min_y, int color) {
|
||||
int size_x = fontRenderer.getStringWidth(text);
|
||||
int size_y = fontRenderer.FONT_HEIGHT;
|
||||
double scale_x = Math.min((double)width / (double)size_x, min_x);
|
||||
double scale_y = Math.min((double)height / (double)size_y, min_y);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled(scale_x, scale_y, 1.0);
|
||||
fontRenderer.drawString(text, (int) (Math.round(x / scale_x)), (int) (Math.round(y / scale_y)), color);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public static void drawLimitedShadow(FontRenderer fontRenderer, String text, int x, int y, int width, int height, int color) {
|
||||
int size_x = fontRenderer.getStringWidth(text);
|
||||
int size_y = fontRenderer.FONT_HEIGHT;
|
||||
|
|
|
@ -28,7 +28,7 @@ public class InputUtils {
|
|||
useItemPressed = pressed;
|
||||
CommonProxy.network.sendToServer(new NetworkKeyManage("useItem~" + useItemPressed));
|
||||
|
||||
System.out.println(useItemPressed);
|
||||
//System.out.println(useItemPressed);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class PlayerUtils {
|
|||
@SideOnly(Side.SERVER)
|
||||
public static EntityPlayer getPlayerFromUUID(UUID uuid) {
|
||||
|
||||
playerList = MinecraftServer.getServer().getEntityWorld().playerEntities;
|
||||
playerList = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
for (EntityPlayer player : playerList) {
|
||||
if (player.getUniqueID().equals(uuid))
|
||||
return player;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package gp_dbc.utils;
|
||||
|
||||
import gp_dbc.system.Cell;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public class Pos {
|
||||
|
||||
|
@ -8,16 +10,22 @@ public class Pos {
|
|||
public int y;
|
||||
public int z;
|
||||
public int dimension;
|
||||
public String dimension_name;
|
||||
|
||||
public Pos (int x, int y, int z) {
|
||||
this(x, y , z, 0);
|
||||
}
|
||||
|
||||
public Pos (int x, int y, int z, int dimension) {
|
||||
this(x, y , z, dimension, null);
|
||||
}
|
||||
|
||||
public Pos (int x, int y, int z, int dimension, String dimension_name) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.dimension = dimension;
|
||||
this.dimension_name = dimension_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,4 +40,12 @@ public class Pos {
|
|||
return objPos.x == x && objPos.y == y && objPos.z == z && objPos.dimension == dimension;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (dimension_name == null)
|
||||
return x + "@" + y + "@" + z + "@" + dimension;
|
||||
else
|
||||
return x + "@" + y + "@" + z + "@" + dimension + "@" + dimension_name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class TimeUtils {
|
|||
}
|
||||
|
||||
public static String getTimeHours(long sec) {
|
||||
long hours = (sec % (24 * 3600)) / 3600;
|
||||
long hours = sec / 3600;
|
||||
long minutes = ((sec % (24 * 3600)) % 3600) / 60;
|
||||
long seconds = ((sec % (24 * 3600)) % 3600) % 60;
|
||||
|
||||
|
|
|
@ -26,3 +26,5 @@ msg.unhandcuffing_someone=You are unhandcuffing...
|
|||
msg.unhandcuffing_you=Someone try to unhandcuffing you...
|
||||
msg.stop_unhandcuffing_someone=You stop unhandcuffing someone
|
||||
success.you_are_free=You are free!
|
||||
error.is_galactic_patrol=He is a galactic patrol
|
||||
error.is_not_criminal=He isn't a criminal
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Loading…
Reference in a new issue