Add new visual criminal tracker, add banned, ...
This commit is contained in:
parent
fecf07d9d3
commit
feb12855dc
|
@ -2,7 +2,6 @@ package xamora.gp_dbc.commands;
|
|||
|
||||
import JinRyuu.JRMCore.server.JGPlayerMP;
|
||||
import com.forgeessentials.api.UserIdent;
|
||||
import xamora.gp_dbc.Main;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -11,15 +10,14 @@ import net.minecraft.util.ChatComponentText;
|
|||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static com.forgeessentials.core.commands.ForgeEssentialsCommandBase.getListOfStringsMatchingLastWord;
|
||||
import static xamora.gp_dbc.Main.gp;
|
||||
|
||||
public class CommandGP implements ICommand {
|
||||
|
||||
private final List aliases;
|
||||
public static HashMap<String, Integer> commands = new HashMap();
|
||||
public static final String[] COMMANDS = {
|
||||
"addGP",
|
||||
"removeGP",
|
||||
|
@ -28,6 +26,8 @@ public class CommandGP implements ICommand {
|
|||
"removeJail",
|
||||
"addCriminal",
|
||||
"removeCriminal",
|
||||
"banGP",
|
||||
"removeBanGP",
|
||||
};
|
||||
|
||||
public CommandGP() {
|
||||
|
@ -97,9 +97,9 @@ public class CommandGP implements ICommand {
|
|||
int error = 0;
|
||||
|
||||
if (arg.equals(COMMANDS[0])) // Add
|
||||
error = Main.gp.addToGalaticPatrol(player, true);
|
||||
error = gp.addToGalaticPatrol(player, true);
|
||||
else if (arg.equals(COMMANDS[1])) // Remove
|
||||
error = Main.gp.removeFromGalaticPatrol(player, true);
|
||||
error = gp.removeFromGalacticPatrol(player);
|
||||
else if (arg.equals(COMMANDS[2])) { // Inmate
|
||||
if (args.size() != 1) {
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "/gp inmate sec [<player>]"));
|
||||
|
@ -107,7 +107,7 @@ public class CommandGP implements ICommand {
|
|||
}
|
||||
else {
|
||||
try {
|
||||
error = Main.gp.jail.putPlayerInJail(sender, player, Long.parseLong(args.get(0)), true) != null ? 0 : 1;
|
||||
error = gp.jail.putPlayerInJail(sender, player, Long.parseLong(args.get(0)), true) != null ? 0 : 1;
|
||||
} catch (Exception e) {
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "/gp inmate sec [<player>]"));
|
||||
return;
|
||||
|
@ -115,19 +115,19 @@ public class CommandGP implements ICommand {
|
|||
}
|
||||
}
|
||||
else if (arg.equals(COMMANDS[3])) { // freeInmate
|
||||
error = Main.gp.jail.removePlayerFromJail(sender, player, true);
|
||||
error = gp.jail.removePlayerFromJail(sender, player, true);
|
||||
}
|
||||
else if (arg.equals(COMMANDS[4])) {// RemoveJail
|
||||
if (args.size() == 1) {
|
||||
try {
|
||||
error = Main.gp.jail.removeCell(Integer.parseInt(args.get(0)));
|
||||
error = gp.jail.removeCell(Integer.parseInt(args.get(0)));
|
||||
} catch (Exception e) {
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "/gp removeJail <id>"));
|
||||
}
|
||||
}
|
||||
else if (args.size() == 4) {
|
||||
try {
|
||||
error = Main.gp.jail.removeCell(Integer.parseInt(args.get(0)), Integer.parseInt(args.get(1)), Integer.parseInt(args.get(2)), Integer.parseInt(args.get(3)));
|
||||
error = gp.jail.removeCell(Integer.parseInt(args.get(0)), Integer.parseInt(args.get(1)), Integer.parseInt(args.get(2)), Integer.parseInt(args.get(3)));
|
||||
} catch (Exception e) {
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "/gp removeJail <x> <y> <z> <dimension>"));
|
||||
}
|
||||
|
@ -148,10 +148,22 @@ public class CommandGP implements ICommand {
|
|||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
Main.gp.criminals.addCriminal(player, rate);
|
||||
gp.criminals.addCriminal(player, rate);
|
||||
}
|
||||
else if (arg.equals(COMMANDS[6])) { // removeCriminal
|
||||
error = Main.gp.criminals.removeCriminal(player.getUniqueID()) ? 0 : 1;
|
||||
error = gp.criminals.removeCriminal(player.getUniqueID()) ? 0 : 1;
|
||||
}
|
||||
else if (arg.equals(COMMANDS[7])) { // banGP
|
||||
try {
|
||||
error = gp.banFromGalacticPatrol(player, "", Long.parseLong(args.get(0)));
|
||||
} catch (Exception e) {
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "/gp banGP <sec> [<player>]"));
|
||||
error = 1;
|
||||
}
|
||||
|
||||
}
|
||||
else if (arg.equals(COMMANDS[8])) { // removeBanGP
|
||||
error = gp.bannedFromGP.remove(player.getUniqueID()) == null ? 1 : 0;
|
||||
}
|
||||
else {
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED.toString() + EnumChatFormatting.UNDERLINE.toString() + "Galactic Patrol:"
|
||||
|
@ -183,7 +195,7 @@ public class CommandGP implements ICommand {
|
|||
for (EntityPlayer player : listPlayer)
|
||||
strListComp.add(player.getDisplayName());
|
||||
else if (strArray.length == 1)
|
||||
return getListOfStringsMatchingLastWord(strArray, commands.keySet());
|
||||
return getListOfStringsMatchingLastWord(strArray, COMMANDS);
|
||||
|
||||
return strListComp;
|
||||
}
|
||||
|
@ -198,8 +210,4 @@ public class CommandGP implements ICommand {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static {
|
||||
for (int i = 0; i < COMMANDS.length; i++)
|
||||
commands.put(COMMANDS[i], i + 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class ConfigManager {
|
|||
|
||||
public static int TIME_HANDCUFFING = 5; // seconds
|
||||
public static int TIME_UNHANDCUFFING = 10; // seconds
|
||||
public static int TIME_TO_GO_IN_JAIL = 20; // seconds
|
||||
public static int TIME_TO_GO_IN_JAIL = 60; // seconds
|
||||
|
||||
public static boolean OP_JAIL_MANAGER = true;
|
||||
|
||||
|
@ -41,14 +41,15 @@ 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 double MULT_JAIL_TIME = 17.28; // 17.28 * 10 000 = 48 hours
|
||||
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 int MAX_RATE_CRIMINAL = 10000;
|
||||
static public long RATE_CRIMINAL_NOT_SAFE = 5000; // Not use
|
||||
static public int RATE_TO_HAVE_POSITION = 1000;
|
||||
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 boolean REINCARNATION_RESET_CRIMINAL = true;
|
||||
static public boolean REINCARNATION_RESET_GP = true;
|
||||
|
@ -58,6 +59,11 @@ public class ConfigManager {
|
|||
static public boolean CRIMINAL_QUIT_IN_FIGHT_GO_TO_JAIL = true;
|
||||
static public long CRIMINAL_TIME_TO_QUIT_IN_FIGHT = 20;
|
||||
|
||||
static public boolean GP_CAN_BE_BAN_KILL_OTHER_GP = true;
|
||||
static public boolean GP_CAN_BE_BAN_BEING_BAD = true;
|
||||
static public long BAN_TIME_KILLING_OTHER_GP = 345600; // 345600s = 4 days
|
||||
static public long BAN_TIME_BEING_BAD = 172800; // 172800s = 2 days
|
||||
|
||||
public static void init(String configDir) {
|
||||
if (config != null)
|
||||
return ;
|
||||
|
@ -100,7 +106,7 @@ public class ConfigManager {
|
|||
"Time to unhandcuffing someone, in seconds. [default: 10]", "10").getInt();
|
||||
|
||||
TIME_TO_GO_IN_JAIL = (byte)addVariableConfig(order, CATEGORY_GP, "TIME_TO_GO_IN_JAIL",
|
||||
"Time to go in jail when someone is handcuffed. [default: 20]", "20").getInt();
|
||||
"Time to go in jail when someone is handcuffed. [default: 60]", "60").getInt();
|
||||
|
||||
FORMAT_TIME_JAIL = addVariableConfig(order, CATEGORY_GP, "FORMAT_TIME_JAIL",
|
||||
"Format of the time print when a player going to jail; 1=dd/MM/yyyy - HH:mm:ss; 2=dd/MM - HH:mm:ss; 3=dd - HH:mm:ss; 4=HH:mm:ss. [default: 4]", "4").getInt();
|
||||
|
@ -112,7 +118,7 @@ public class ConfigManager {
|
|||
"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();
|
||||
"Multiplier time to go in jail in sec. [default: 17.28]", "17.28").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();
|
||||
|
@ -121,17 +127,17 @@ public class ConfigManager {
|
|||
"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();
|
||||
"Max rate a criminal can reach. [default: 10000]", "10000").getInt();
|
||||
|
||||
MIN_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();
|
||||
|
||||
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 give to galactic patrol in seconds. [default: 14400]", "14400").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 give to galactic patrol in seconds. [default: 120]", "120").getInt();
|
||||
MIN_TIME_BETWEEN_EACH_POSITION *= 1000L;
|
||||
|
||||
REINCARNATION_RESET_CRIMINAL = addVariableConfig(order, CATEGORY_GP, "REINCARNATION_RESET_CRIMINAL",
|
||||
|
@ -147,6 +153,20 @@ public class ConfigManager {
|
|||
"Time before a criminal can quit in fight with a patroller in seconds. [default: 20]", "20").getInt();
|
||||
CRIMINAL_TIME_TO_QUIT_IN_FIGHT *= 1000L;
|
||||
|
||||
GP_CAN_BE_BAN_KILL_OTHER_GP = addVariableConfig(order, CATEGORY_GP, "GP_CAN_BE_BAN_KILL_OTHER_GP",
|
||||
"If one patrolman kill other patrolman he is ban for galactic patrol. [default: true]", "true").getBoolean();
|
||||
|
||||
BAN_TIME_KILLING_OTHER_GP = addVariableConfig(order, CATEGORY_GP, "BAN_TIME_KILLING_OTHER_GP",
|
||||
"Time ban. [default: 345600]", "345600").getInt();
|
||||
|
||||
GP_CAN_BE_BAN_BEING_BAD = addVariableConfig(order, CATEGORY_GP, "GP_CAN_BE_BAN_BEING_BAD",
|
||||
"If one patrolman being bad. [default: true]", "true").getBoolean();
|
||||
|
||||
BAN_TIME_BEING_BAD = addVariableConfig(order, CATEGORY_GP, "BAN_TIME_BEING_BAD",
|
||||
"Time ban being bad. [default: 172800]", "172800").getInt();
|
||||
|
||||
RATE_CRIMINAL_NOT_SAFE = addVariableConfig(order, CATEGORY_GP, "RATE_CRIMINAL_NOT_SAFE",
|
||||
"Rate when a criminal it's not safe (Not use). [default: 5000]", "5000").getInt();
|
||||
|
||||
config.setCategoryPropertyOrder(CATEGORY_GP, order);
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.util.ResourceLocation;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
import xamora.gp_dbc.utils.DrawGui;
|
||||
|
||||
import static xamora.gp_dbc.config.ConfigManager.*;
|
||||
import static xamora.gp_dbc.gui.CriminalTracker.GuiCriminalTracker.*;
|
||||
|
||||
public class GuiButtonCriminalTracker extends GuiButton {
|
||||
|
@ -44,6 +45,7 @@ public class GuiButtonCriminalTracker extends GuiButton {
|
|||
return;
|
||||
|
||||
mc.getTextureManager().bindTexture(buttonTexturesNinjin);
|
||||
GL11.glColor4d(1, 1, 1, 1);
|
||||
|
||||
boolean flag = x >= xPosition && y >= yPosition && x < xPosition + this.width && y < yPosition + this.height;
|
||||
if (id < 0) { // criminals
|
||||
|
@ -68,57 +70,57 @@ public class GuiButtonCriminalTracker extends GuiButton {
|
|||
Criminal criminal = criminals.get(-(id) - 1);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScissor(displayGuiX , displayGuiY + 7 * ratioHeight, newWidth, (int) (newHeight - 27 * ratioHeight));
|
||||
GL11.glScissor(displayGuiX , displayGuiY + 12 * ratioHeight, newWidth, (int) (newHeight - 47 * 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);
|
||||
//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);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColor4d(rate >= RATE_TO_HAVE_POSITION ? 1 : 0, rate >= RATE_TO_HAVE_POSITION ? (rate >= RATE_CRIMINAL_NOT_SAFE ? 0 : 0.6) : 1, 0, 1);
|
||||
drawTexturedModalRect(xPosition, yPosition, 312 / 2, 0, width, height);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
DrawGui.drawLimited(mc.fontRenderer, criminal.getName(), xPosition + 1, yPosition + 1, width - 1, 8, 0xff000000);
|
||||
DrawGui.drawLimited(mc.fontRenderer, criminal.getName(), xPosition + 3, yPosition + 6, width - 5, 8, 0xff000000);
|
||||
if (pos == null) {
|
||||
DrawGui.drawLimited(mc.fontRenderer, "No Position", xPosition + 1, yPosition + 14, width - 1, 6, 0xff000000);
|
||||
DrawGui.drawLimitedMin(mc.fontRenderer, "rate: " + rate, xPosition + 1, yPosition + 21, width - 1, 5, 0.55, 0.8, 0xff000000);
|
||||
DrawGui.drawLimited(mc.fontRenderer, "No Position", xPosition + 3, yPosition + 16, width - 5, 6, 0xff000000);
|
||||
DrawGui.drawLimitedMin(mc.fontRenderer, "rate: " + rate, xPosition + 3, yPosition + 22, width - 5, 5, 0.55, 0.8, 0xff000000);
|
||||
}
|
||||
else {
|
||||
DrawGui.drawLimitedMin(mc.fontRenderer, "x:" + pos.x, xPosition + 1, yPosition + 9, width - 1, 5, 0.6, 0.8, 0xff000000);
|
||||
DrawGui.drawLimitedMin(mc.fontRenderer, "y:" + pos.y, xPosition + 1, yPosition + 14, width - 4, 5,0.6, 0.8, 0xff000000);
|
||||
DrawGui.drawLimitedMin(mc.fontRenderer, "z:" + pos.z, xPosition + 1, yPosition + 19, width - 1, 5,0.6, 0.8, 0xff000000);
|
||||
DrawGui.drawLimited(mc.fontRenderer, pos.dimension_name, xPosition + 1, yPosition + 24, width - 1, 5, 0xff000000);
|
||||
DrawGui.drawLimitedMin(mc.fontRenderer, "x:" + pos.x, xPosition + 3, yPosition + 16, width - 5, 5, 0.6, 0.8, 0xff000000);
|
||||
DrawGui.drawLimitedMin(mc.fontRenderer, "y:" + pos.y, xPosition + 3, yPosition + 21, width - 5, 5,0.6, 0.8, 0xff000000);
|
||||
DrawGui.drawLimitedMin(mc.fontRenderer, "z:" + pos.z, xPosition + 3, yPosition + 26, width - 5, 5,0.6, 0.8, 0xff000000);
|
||||
DrawGui.drawLimited(mc.fontRenderer, pos.dimension_name, xPosition + 3, yPosition + 31, width - 5, 5, 0xff000000);
|
||||
|
||||
boolean flag_last_time_pos = x >= xPosition + 1 && y >= yPosition + 29 && x < xPosition + 1 + this.width - 1 && y < yPosition + 29 + 5;
|
||||
DrawGui.drawLimited(mc.fontRenderer, TimeUtils.getTimeDays((System.currentTimeMillis() - criminal.getLastPosTime()) / 1000L), xPosition + 1, yPosition + 29, width - 1, 5, 0xff000000);
|
||||
boolean flag_last_time_pos = x >= xPosition + 3 && y >= yPosition + 36 && x < xPosition + 3 + this.width - 5 && y < yPosition + 36 + 5;
|
||||
DrawGui.drawLimited(mc.fontRenderer, TimeUtils.getTimeDays((System.currentTimeMillis() - criminal.getLastPosTime()) / 1000L), xPosition + 3, yPosition + 36, width - 5, 5, 0xff000000);
|
||||
|
||||
if (flag_last_time_pos) {
|
||||
GL11.glTranslated(0, 0, 1);
|
||||
drawRect(x, y, x + width, y - 7, 0xf0ffffff);
|
||||
DrawGui.drawLimited(mc.fontRenderer, "last time position", x + 1, y - 6, width - 1, 5, 0xff000000);
|
||||
GL11.glTranslated(0, 0, -1);
|
||||
}
|
||||
|
||||
DrawGui.drawLimitedMin(mc.fontRenderer, "rate: " + rate, xPosition + 1, yPosition + 35, width - 1, 5, 0.55, 0.8, 0xff000000);
|
||||
DrawGui.drawLimitedMin(mc.fontRenderer, "rate: " + rate, xPosition + 3, yPosition + 41, width - 5, 5, 0.55, 0.8, 0xff000000);
|
||||
}
|
||||
|
||||
// Test draw Scissor
|
||||
//drawRect(0, 0, displayWidth, displayHeight, 0x50ffffff);
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
else if (id == 0) { // refresh
|
||||
if (flag) {
|
||||
if (flag)
|
||||
GL11.glColor4d(0.8, 0.8, 0.8, 1);
|
||||
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);
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, 398 / 2, 0, this.width, this.height);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package xamora.gp_dbc.gui.CriminalTracker;
|
||||
|
||||
import xamora.gp_dbc.Main;
|
||||
import xamora.gp_dbc.network.server.NetworkRefreshCriminalTracker;
|
||||
import xamora.gp_dbc.proxy.CommonProxy;
|
||||
import xamora.gp_dbc.system.Criminal;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
@ -15,8 +17,8 @@ import java.util.List;
|
|||
|
||||
public class GuiCriminalTracker extends GuiScreen {
|
||||
|
||||
final static int guiWidth = 280 / 2 + 1;
|
||||
final static int guiHeight = 240 / 2 + 1;
|
||||
final static int guiWidth = 308 / 2 + 1;
|
||||
final static int guiHeight = 360 / 2 + 1;
|
||||
|
||||
public static int scroll_y = 0;
|
||||
|
||||
|
@ -24,10 +26,11 @@ public class GuiCriminalTracker extends GuiScreen {
|
|||
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;
|
||||
int gap_y = 2;
|
||||
int number_by_line = 3;
|
||||
int nbr_visible = 6;
|
||||
int criminal_width = 84 / 2;
|
||||
int criminal_height = 104 / 2;
|
||||
|
||||
private GuiButtonCriminalTracker refresh_criminal;
|
||||
|
||||
|
@ -52,33 +55,50 @@ public class GuiCriminalTracker extends GuiScreen {
|
|||
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) {
|
||||
|
||||
int scrollbar_x = guiX + 141;
|
||||
int scrollbar_y = guiY + 70 / 2;
|
||||
int scrollbar_add = 0;
|
||||
|
||||
if (criminals.size() > nbr_visible) {
|
||||
|
||||
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);
|
||||
|
||||
scrollbar_add = (int)(108D / getMaxScrollY() * scroll_y); // doit varier entre 0 et 108
|
||||
scrollbar_add = Math.max(scrollbar_add, 0);
|
||||
|
||||
//-((criminals.size() - 6) * (criminal_height + gap_y))
|
||||
//drawRect(scrollbar_x, scrollbar_y, scrollbar_x + 6, scrollbar_y + 6, 0xff000000);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
drawTexturedModalRect(scrollbar_x, scrollbar_y, 312 / 2, 108 / 2, 24 / 2, 268 / 2); // Background
|
||||
if (criminals.size() > nbr_visible)
|
||||
drawTexturedModalRect(scrollbar_x - 2, scrollbar_y + scrollbar_add, 338 / 2, 108 / 2, 32 / 2, 52 / 2); // Point
|
||||
GL11.glPopMatrix();
|
||||
|
||||
|
||||
|
||||
super.drawScreen(mouse_x, mouse_y, ticks);
|
||||
}
|
||||
|
||||
public int getMaxScrollY() {
|
||||
int size = criminals.size();
|
||||
int visible_criminal_line = (int) Math.ceil((size - nbr_visible) / (double)number_by_line);
|
||||
int scroll_y_max = -(visible_criminal_line * ((criminal_height + gap_y) / 2));
|
||||
return scroll_y_max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
|
||||
|
@ -97,12 +117,12 @@ public class GuiCriminalTracker extends GuiScreen {
|
|||
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));
|
||||
int pos_x = guiX + 8 + (i % number_by_line) * (criminal_width + 2);
|
||||
int pos_y = guiY + 70 / 2 + (i / number_by_line) * (criminal_height + gap_y);
|
||||
buttonList.add(new GuiButtonCriminalTracker(-(i + 1), pos_x, pos_y, criminal_width + 1, criminal_height + 1));
|
||||
}
|
||||
|
||||
buttonList.add(refresh_criminal = new GuiButtonCriminalTracker(0, guiX + 6, guiY + 5, 11, 11));
|
||||
buttonList.add(refresh_criminal = new GuiButtonCriminalTracker(0, guiX + 15, guiY + 10, 32 / 2 + 1, 32 / 2 + 1));
|
||||
|
||||
//buttonList.add(buttonClose = new CyborgSoftwareGuiButton(1, guiX + 4, guiY - 3, 7, 7));
|
||||
|
||||
|
@ -112,9 +132,8 @@ public class GuiCriminalTracker extends GuiScreen {
|
|||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
if (button.id < 0) {
|
||||
|
||||
}
|
||||
if (button.id == 0)
|
||||
CommonProxy.network.sendToServer(new NetworkRefreshCriminalTracker(""));
|
||||
super.actionPerformed(button);
|
||||
}
|
||||
|
||||
|
@ -127,7 +146,7 @@ public class GuiCriminalTracker extends GuiScreen {
|
|||
public void handleMouseInput() {
|
||||
super.handleMouseInput();
|
||||
|
||||
if (criminals.size() <= 8)
|
||||
if (criminals.size() <= nbr_visible)
|
||||
return;
|
||||
|
||||
int dWheel = Mouse.getEventDWheel();
|
||||
|
@ -140,7 +159,7 @@ public class GuiCriminalTracker extends GuiScreen {
|
|||
//System.out.println("Molette vers le haut");
|
||||
} else {
|
||||
scroll_y -= 6;
|
||||
scroll_y = Math.max(-((criminals.size() - 8) * (criminal_height + gap_y)), scroll_y);
|
||||
scroll_y = Math.max(getMaxScrollY(), scroll_y);
|
||||
//System.out.println("Molette vers le bas");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package xamora.gp_dbc.network.server;
|
||||
|
||||
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 io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import xamora.gp_dbc.Main;
|
||||
import xamora.gp_dbc.network.client.NetworkCriminalTrackerC;
|
||||
import xamora.gp_dbc.proxy.CommonProxy;
|
||||
import xamora.gp_dbc.system.Criminal;
|
||||
import xamora.gp_dbc.utils.InputUtils;
|
||||
|
||||
public class NetworkRefreshCriminalTracker implements IMessage {
|
||||
|
||||
private String toSend;
|
||||
|
||||
public NetworkRefreshCriminalTracker() {}
|
||||
|
||||
public NetworkRefreshCriminalTracker(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 MyMessageHandler implements
|
||||
IMessageHandler<NetworkRefreshCriminalTracker, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(NetworkRefreshCriminalTracker message,
|
||||
MessageContext ctx) {
|
||||
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
boolean isCops = Main.gp.isInGalacticPatrol(player);
|
||||
|
||||
String criminals = "";
|
||||
for (Criminal criminal : Main.gp.criminals.criminals) {
|
||||
Main.gp.criminals.getUpdatePos(criminal.getUuid());
|
||||
if (isCops)
|
||||
criminals += criminal.toString() + "#";
|
||||
else
|
||||
criminals += criminal.toStringWithoutPos() + "#";
|
||||
}
|
||||
|
||||
CommonProxy.network.sendTo(new NetworkCriminalTrackerC("open~" + criminals), player);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ import xamora.gp_dbc.network.client.NetworkHandcuffedC;
|
|||
import xamora.gp_dbc.network.client.NetworkJailManagerC;
|
||||
import xamora.gp_dbc.network.server.NetworkJailManager;
|
||||
import xamora.gp_dbc.network.server.NetworkKeyManage;
|
||||
import xamora.gp_dbc.network.server.NetworkRefreshCriminalTracker;
|
||||
import xamora.gp_dbc.utils.InputUtils;
|
||||
|
||||
public class CommonProxy {
|
||||
|
@ -37,6 +38,7 @@ public class CommonProxy {
|
|||
// Client to Server
|
||||
network.registerMessage(NetworkJailManager.MyMessageHandler.class, NetworkJailManager.class, i++, Side.SERVER);
|
||||
network.registerMessage(NetworkKeyManage.MyMessageHandler.class, NetworkKeyManage.class, i++, Side.SERVER);
|
||||
network.registerMessage(NetworkRefreshCriminalTracker.MyMessageHandler.class, NetworkRefreshCriminalTracker.class, i++, Side.SERVER);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
|||
import xamora.gp_dbc.Main;
|
||||
import xamora.gp_dbc.config.ConfigManager;
|
||||
import xamora.gp_dbc.system.Handcuff;
|
||||
import xamora.gp_dbc.system.TimeJail;
|
||||
import xamora.gp_dbc.system.JailEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class ServerProxy extends CommonProxy{
|
||||
|
@ -17,7 +17,10 @@ public class ServerProxy extends CommonProxy{
|
|||
|
||||
FMLCommonHandler.instance().bus().register(new ConfigManager());
|
||||
|
||||
FMLCommonHandler.instance().bus().register(new TimeJail());
|
||||
JailEvent jailEvent = new JailEvent();
|
||||
FMLCommonHandler.instance().bus().register(jailEvent);
|
||||
MinecraftForge.EVENT_BUS.register(jailEvent);
|
||||
|
||||
FMLCommonHandler.instance().bus().register(Main.gp);
|
||||
MinecraftForge.EVENT_BUS.register(Main.gp);
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import xamora.gp_dbc.Main;
|
||||
import xamora.gp_dbc.system.Handcuff;
|
||||
import xamora.gp_dbc.system.Handcuffed;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
|
@ -60,11 +61,16 @@ public class RenderHandcuffIcon extends Gui {
|
|||
if (player != null
|
||||
&& player.isInRangeToRender3d(renderingVector.xCoord, renderingVector.yCoord, renderingVector.zCoord) && (player.ignoreFrustumCheck || frustrum.isBoundingBoxInFrustum(player.boundingBox))
|
||||
&& player.isEntityAlive()
|
||||
&& playerAroundHandcuffed.containsKey(player.getUniqueID()))
|
||||
&& playerAroundHandcuffed.containsKey(player.getUniqueID())) {
|
||||
|
||||
long time_left = (playerAroundHandcuffed.get(player.getUniqueID()) + (Handcuffed.timeToWait * 1000) - System.currentTimeMillis()) / 1000;
|
||||
if (time_left < -Handcuffed.timeToWait)
|
||||
playerAroundHandcuffed.remove(player.getUniqueID());
|
||||
else
|
||||
renderPseudo((EntityLivingBase) player, event.partialTicks, (Entity) cameraEntity, 13816530);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void renderPseudo(EntityLivingBase passedEntity, float partialTicks, Entity viewPoint, int opacity) {
|
||||
if (passedEntity.riddenByEntity != null)
|
||||
|
|
|
@ -81,6 +81,13 @@ public class Cell {
|
|||
|
||||
public int getId() { return id; }
|
||||
|
||||
public void tpTo(EntityPlayer player) {
|
||||
Pos pos = getPos();
|
||||
if (player.dimension != pos.dimension)
|
||||
player.travelToDimension(pos.dimension);
|
||||
player.setPositionAndUpdate(pos.x + 0.5, pos.y + 1, pos.z + 0.5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
|
|
|
@ -10,6 +10,8 @@ import xamora.gp_dbc.config.ConfigManager;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
import static xamora.gp_dbc.config.ConfigManager.*;
|
||||
|
||||
public class Criminal {
|
||||
|
||||
private String name;
|
||||
|
@ -49,7 +51,7 @@ public class Criminal {
|
|||
|
||||
// Jail in second
|
||||
public long getTimeJail() {
|
||||
return (long) (rate * 7.2);
|
||||
return (long) (rate * MULT_JAIL_TIME);
|
||||
}
|
||||
|
||||
public Pos getLastPos() {
|
||||
|
@ -69,6 +71,7 @@ public class Criminal {
|
|||
public void setRate(long rate) {
|
||||
this.rate = Math.min(rate, ConfigManager.MAX_RATE_CRIMINAL);
|
||||
}
|
||||
|
||||
public void setPos(Pos pos) {
|
||||
this.last_time_pos = System.currentTimeMillis();
|
||||
this.last_pos = pos;
|
||||
|
|
|
@ -16,6 +16,10 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
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.RATE_TO_HAVE_POSITION;
|
||||
|
||||
public class Criminals {
|
||||
|
||||
public List<Criminal> criminals = new ArrayList<>();
|
||||
|
@ -41,6 +45,13 @@ public class Criminals {
|
|||
|
||||
EntityPlayer killer = (EntityPlayer) entityKiller;
|
||||
|
||||
if (gp.isInGalacticPatrol(killer)) {
|
||||
if (gp.isInGalacticPatrol(dead))
|
||||
gp.banFromGalacticPatrol(killer, "error.banned_for_killing_patrolman", BAN_TIME_KILLING_OTHER_GP);
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
Criminal criminal = null;
|
||||
if (isCriminal(killer.getUniqueID()))
|
||||
criminal = getCriminal(killer.getUniqueID());
|
||||
|
@ -97,6 +108,9 @@ public class Criminals {
|
|||
return null;
|
||||
Criminal criminal = getCriminal(uuid);
|
||||
|
||||
if (criminal.getRate() < RATE_TO_HAVE_POSITION)
|
||||
return null;
|
||||
|
||||
EntityPlayer player = PlayerUtils.getPlayerFromUUID(uuid);
|
||||
if (player == null)
|
||||
return criminal.getLastPos();
|
||||
|
|
|
@ -6,6 +6,8 @@ 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 net.minecraft.entity.Entity;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import xamora.gp_dbc.config.ConfigManager;
|
||||
import xamora.gp_dbc.utils.Data;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -15,12 +17,16 @@ import net.minecraft.server.MinecraftServer;
|
|||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import xamora.gp_dbc.utils.TimeUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static net.minecraft.util.StatCollector.translateToLocal;
|
||||
import static xamora.gp_dbc.Main.gp;
|
||||
import static xamora.gp_dbc.config.ConfigManager.*;
|
||||
|
||||
public class GalacticPatrol {
|
||||
|
||||
|
@ -29,11 +35,17 @@ public class GalacticPatrol {
|
|||
public Criminals criminals;
|
||||
|
||||
public HashMap<UUID, Long> InFightWithPatrollers = new HashMap<>();
|
||||
public HashMap<UUID, Long> bannedFromGP = new HashMap<>();
|
||||
|
||||
public GalacticPatrol() {
|
||||
patrollers = Data.loadDataUUID("galactic_patrols");
|
||||
jail = new Jail();
|
||||
criminals = new Criminals();
|
||||
try {
|
||||
listStringToBanned(Data.loadDataString("banned"));
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
};
|
||||
}
|
||||
|
||||
public int addToGalaticPatrol(EntityPlayer player) {
|
||||
|
@ -66,13 +78,39 @@ public class GalacticPatrol {
|
|||
return 3;
|
||||
}
|
||||
|
||||
Criminal criminal = criminals.getCriminal(player.getUniqueID());
|
||||
if (criminal != null) {
|
||||
if (criminal.getRate() > 0) {
|
||||
if (chatError)
|
||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.criminal_try_join_galactic_patrol")));
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (bannedFromGP.containsKey(player.getUniqueID())) {
|
||||
long time_player = bannedFromGP.get(player.getUniqueID());
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
if (bannedFromGP.get(player.getUniqueID()) > System.currentTimeMillis()) {
|
||||
|
||||
if (chatError) {
|
||||
long second_left = (bannedFromGP.get(player.getUniqueID()) - System.currentTimeMillis()) / 1000L;
|
||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.banned_from_galactic_patrol")));
|
||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + TimeUtils.getTimeHours(second_left)));
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
else
|
||||
bannedFromGP.remove(player.getUniqueID());
|
||||
}
|
||||
|
||||
if (!patrollers.contains(player.getUniqueID())) {
|
||||
patrollers.add(player.getUniqueID());
|
||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + translateToLocal("success.join_galactic_patrol")));
|
||||
}
|
||||
else {
|
||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.join_galactic_patrol")));
|
||||
return 4;
|
||||
return 6;
|
||||
}
|
||||
|
||||
Data.saveDataUUID(patrollers, "galactic_patrols");
|
||||
|
@ -85,19 +123,11 @@ public class GalacticPatrol {
|
|||
Data.saveDataUUID(patrollers, "galactic_patrols");
|
||||
}
|
||||
|
||||
public int removeFromGalaticPatrol(EntityPlayer player) {
|
||||
return removeFromGalaticPatrol(player, false);
|
||||
public int removeFromGalacticPatrol(EntityPlayer player) {
|
||||
return removeFromGalacticPatrol((EntityPlayerMP)player);
|
||||
}
|
||||
|
||||
public int removeFromGalaticPatrol(EntityPlayer player, boolean chatError) {
|
||||
return removeFromGalaticPatrol((EntityPlayerMP)player, chatError);
|
||||
}
|
||||
|
||||
public int removeFromGalaticPatrol(EntityPlayerMP player) {
|
||||
return removeFromGalaticPatrol(player, false);
|
||||
}
|
||||
|
||||
public int removeFromGalaticPatrol(EntityPlayerMP player, boolean chatError) {
|
||||
public int removeFromGalacticPatrol(EntityPlayerMP player) {
|
||||
|
||||
boolean removed = patrollers.remove(player.getUniqueID());
|
||||
Data.saveDataUUID(patrollers, "galactic_patrols");
|
||||
|
@ -110,6 +140,49 @@ public class GalacticPatrol {
|
|||
return removed ? 0 : 1;
|
||||
}
|
||||
|
||||
// time in second
|
||||
public int banFromGalacticPatrol(EntityPlayer banned, String reason, long time) {
|
||||
if (removeFromGalacticPatrol(banned) == 1)
|
||||
return 1;
|
||||
bannedFromGP.put(banned.getUniqueID(), System.currentTimeMillis() + time * 1000L);
|
||||
|
||||
banned.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.banned_from_galactic_patrol") + " " + TimeUtils.getTimeHours(time)));
|
||||
if (reason.length() > 0)
|
||||
banned.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal(reason)));
|
||||
|
||||
Data.saveDataString(listBannedToListString(), "banned");
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void listStringToBanned(List<String> banned_str) throws Exception {
|
||||
for (String s : banned_str) {
|
||||
|
||||
String[] split = s.split("~");
|
||||
if (split.length != 7)
|
||||
throw new Exception("Error loading " + ConfigManager.DIR_SAVE + "Inmates.txt");
|
||||
|
||||
try {
|
||||
bannedFromGP.put(UUID.fromString(split[0]), Long.parseLong(split[1]));
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> listBannedToListString() {
|
||||
|
||||
List<String> banned_str = new ArrayList<>();
|
||||
for (UUID uuid : bannedFromGP.keySet()) {
|
||||
long time = bannedFromGP.get(uuid);
|
||||
|
||||
banned_str.add(uuid + "~" + time);
|
||||
}
|
||||
|
||||
return banned_str;
|
||||
}
|
||||
|
||||
|
||||
public boolean isInGalacticPatrol(EntityPlayer player) {
|
||||
return patrollers.contains(player.getUniqueID());
|
||||
}
|
||||
|
@ -125,6 +198,7 @@ public class GalacticPatrol {
|
|||
public List<UUID> getPatrollers() { return patrollers; }
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.SERVER)
|
||||
public void checkReincarnated(TickEvent.ServerTickEvent event) {
|
||||
List<EntityPlayer> playerList = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
|
||||
|
@ -135,7 +209,7 @@ public class GalacticPatrol {
|
|||
|
||||
if (isReincarnated) {
|
||||
if (ConfigManager.REINCARNATION_RESET_GP && isInGalacticPatrol(player))
|
||||
removeFromGalaticPatrol(player);
|
||||
removeFromGalacticPatrol(player);
|
||||
if (ConfigManager.REINCARNATION_RESET_CRIMINAL && criminals.isCriminal(player.getUniqueID()))
|
||||
criminals.removeCriminal(player.getUniqueID());
|
||||
}
|
||||
|
@ -186,4 +260,23 @@ public class GalacticPatrol {
|
|||
jail.putPlayerInJail(jailer, event.player);
|
||||
}
|
||||
|
||||
// Ban
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.SERVER)
|
||||
public void checkAlignment(TickEvent.ServerTickEvent event) {
|
||||
List<EntityPlayer> playerList = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
|
||||
for (EntityPlayer player : playerList) {
|
||||
if (!isInGalacticPatrol(player))
|
||||
return;
|
||||
|
||||
JGPlayerMP jgPlayer = new JGPlayerMP(player);
|
||||
NBTTagCompound nbt = jgPlayer.connectBaseNBT();
|
||||
int align = jgPlayer.getAlignment();
|
||||
|
||||
if (align < MIN_ALIGN_TO_JOIN)
|
||||
banFromGalacticPatrol(player, "error.banned_for_being_bad", BAN_TIME_BEING_BAD);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -152,10 +152,8 @@ public class Jail {
|
|||
inmates.add(new Inmate(cell, inmate.getUniqueID(), sec));
|
||||
Data.saveDataString(listInmateToListString(), "Inmates");
|
||||
|
||||
Pos pos = cell.getPos();
|
||||
if (inmate.dimension != pos.dimension)
|
||||
inmate.travelToDimension(pos.dimension);
|
||||
inmate.setPositionAndUpdate(pos.x + 0.5, pos.y + 1, pos.z + 0.5);
|
||||
cell.tpTo(inmate);
|
||||
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
|
119
src/main/java/xamora/gp_dbc/system/JailEvent.java
Normal file
119
src/main/java/xamora/gp_dbc/system/JailEvent.java
Normal file
|
@ -0,0 +1,119 @@
|
|||
package xamora.gp_dbc.system;
|
||||
|
||||
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 fastcraft.J;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import xamora.gp_dbc.Main;
|
||||
import xamora.gp_dbc.utils.PlayerUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import xamora.gp_dbc.utils.Pos;
|
||||
|
||||
import static net.minecraft.util.StatCollector.translateToLocal;
|
||||
import static xamora.gp_dbc.Main.gp;
|
||||
|
||||
public class JailEvent {
|
||||
|
||||
int tick_time = 0;
|
||||
final int SLOWTICK_MAX = 20;//2000;
|
||||
|
||||
@SideOnly(Side.SERVER)
|
||||
@SubscribeEvent
|
||||
public void checkTimeInmate(TickEvent.ServerTickEvent event) {
|
||||
if (tick_time >= SLOWTICK_MAX) {
|
||||
tick_time = 0;
|
||||
|
||||
if (gp.jail.getInmates() == null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < gp.jail.getInmates().size(); i++) {
|
||||
Inmate inmate = gp.jail.getInmates().get(i);
|
||||
|
||||
if (System.currentTimeMillis() - inmate.getTimeStartJail() > inmate.getSecInJail() * 1000) {
|
||||
|
||||
// Connected
|
||||
EntityPlayer player = PlayerUtils.getPlayerFromUUID(inmate.getUuid());
|
||||
if (player == null)
|
||||
gp.jail.removePlayerFromJail(MinecraftServer.getServer(), inmate.getUuid(), true);
|
||||
else
|
||||
gp.jail.removePlayerFromJail(MinecraftServer.getServer(), player, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
tick_time++;
|
||||
}
|
||||
|
||||
@SideOnly(Side.SERVER)
|
||||
@SubscribeEvent
|
||||
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));
|
||||
|
||||
JGPlayerMP jgPlayer = new JGPlayerMP(event.player);
|
||||
NBTTagCompound nbt = jgPlayer.connectBaseNBT();
|
||||
|
||||
if (nbt.getByte("jrmcAlv") == 1)
|
||||
nbt.setByte("jrmcAlv", (byte) 0);
|
||||
|
||||
inmate.getCell().tpTo(event.player);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int tick_release = 0;
|
||||
|
||||
@SideOnly(Side.SERVER)
|
||||
@SubscribeEvent
|
||||
public void checkRelease(TickEvent.ServerTickEvent event) {
|
||||
if (tick_release >= SLOWTICK_MAX) {
|
||||
tick_release = 0;
|
||||
|
||||
if (gp.jail.getInmates() == null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < gp.jail.getInmates().size(); i++) {
|
||||
Inmate inmate = gp.jail.getInmates().get(i);
|
||||
|
||||
EntityPlayer player = PlayerUtils.getPlayerFromUUID(inmate.getUuid());
|
||||
if (player != null) {
|
||||
JGPlayerMP jgPlayer = new JGPlayerMP(player);
|
||||
NBTTagCompound nbt = jgPlayer.connectBaseNBT();
|
||||
|
||||
if (jgPlayer.getRelease() > 0)
|
||||
jgPlayer.setRelease(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
tick_release++;
|
||||
}
|
||||
|
||||
@SideOnly(Side.SERVER)
|
||||
@SubscribeEvent
|
||||
public void checkDeathCancel(LivingHurtEvent event) {
|
||||
if (!(event.entity instanceof EntityPlayer))
|
||||
return;
|
||||
|
||||
EntityPlayer player = (EntityPlayer)event.entity;
|
||||
if (gp.jail.isInJail(player))
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package xamora.gp_dbc.system;
|
||||
|
||||
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 xamora.gp_dbc.Main;
|
||||
import xamora.gp_dbc.utils.PlayerUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import static net.minecraft.util.StatCollector.translateToLocal;
|
||||
|
||||
public class TimeJail {
|
||||
|
||||
int tick = 0;
|
||||
final int SLOWTICK_MAX = 20;//2000;
|
||||
|
||||
@SideOnly(Side.SERVER)
|
||||
@SubscribeEvent
|
||||
public void checkTimeInmate(TickEvent.ServerTickEvent event) {
|
||||
if (tick >= SLOWTICK_MAX) {
|
||||
tick = 0;
|
||||
|
||||
if (Main.gp.jail.getInmates() == null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < Main.gp.jail.getInmates().size(); i++) {
|
||||
Inmate inmate = Main.gp.jail.getInmates().get(i);
|
||||
|
||||
if (System.currentTimeMillis() - inmate.getTimeStartJail() > inmate.getSecInJail() * 1000) {
|
||||
|
||||
// Connected
|
||||
EntityPlayer player = PlayerUtils.getPlayerFromUUID(inmate.getUuid());
|
||||
if (player == null)
|
||||
Main.gp.jail.removePlayerFromJail(MinecraftServer.getServer(), inmate.getUuid(), true);
|
||||
else
|
||||
Main.gp.jail.removePlayerFromJail(MinecraftServer.getServer(), player, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
tick++;
|
||||
}
|
||||
|
||||
@SideOnly(Side.SERVER)
|
||||
@SubscribeEvent
|
||||
public void checkPlayerIsFree(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
if (Main.gp.jail.freePlayer(event.player))
|
||||
event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + translateToLocal("success.out_of_jail")));
|
||||
|
||||
Inmate inmate = Main.gp.jail.getInmate(event.player.getUniqueID());
|
||||
if (inmate != null) {
|
||||
long time_left = (inmate.getSecInJail() * 1000 - (System.currentTimeMillis() - inmate.getTimeStartJail())) / 1000;
|
||||
String timeString = Main.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));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ public class InputUtils {
|
|||
useItemPressed = pressed;
|
||||
CommonProxy.network.sendToServer(new NetworkKeyManage("useItem~" + useItemPressed));
|
||||
|
||||
System.out.println(useItemPressed);
|
||||
//System.out.println(useItemPressed);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,30 +1,34 @@
|
|||
error.min_align_to_join=Alignment too low
|
||||
error.max_align_to_join=Alignment too high
|
||||
success.join_galactic_patrol=You have joined Galactic Patrol
|
||||
error.join_galactic_patrol=You are already in Galactic Patrol
|
||||
success.leave_galactic_patrol=You have left Galactic Patrol
|
||||
error.leave_galactic_patrol=You aren't in Galactic Patrol
|
||||
success.join_galactic_patrol=You have joined the Galactic Patrol
|
||||
error.join_galactic_patrol=You are already in the Galactic Patrol
|
||||
success.leave_galactic_patrol=You have left the Galactic Patrol
|
||||
error.leave_galactic_patrol=You aren't in the Galactic Patrol
|
||||
success.add_cell=You have added a new cell
|
||||
error.add_cell=There is already a cell here
|
||||
error.definition_exit_pos=There isn't exit position
|
||||
error.definition_exit_pos=There is no exit position
|
||||
error.invalid_value_exit_pos=Invalid value in exit position
|
||||
error.unavailable_cell=There aren't cell available
|
||||
error.already_in_jail=Player already in jail
|
||||
error.not_in_jail=Player not in jail
|
||||
error.unavailable_cell=There are no cells available
|
||||
error.already_in_jail=Player is already in jail
|
||||
error.not_in_jail=Player is not in jail
|
||||
success.in_jail=Player put in jail for
|
||||
msg.inmate_going_to_jail=You are in jail for
|
||||
success.out_of_jail=You are out of the jail
|
||||
success.out_of_jail=You are out of jail
|
||||
error.already_handcuffed=Already handcuffed
|
||||
warning.handcuffing_you=A galactic patrol handcuffing you!
|
||||
warning.handcuffing_him=You handcuffing someone
|
||||
success.you_handcuffed_him=You handcuffed him
|
||||
warning.handcuffing_you=A Galactic Patrol officer is handcuffing you!
|
||||
warning.handcuffing_him=You are handcuffing someone
|
||||
success.you_handcuffed_him=You have handcuffed him
|
||||
success.you_are_handcuffed=You are handcuffed, going in %% seconds
|
||||
warning.going_in_jail=%% second(s) left(s)
|
||||
error.cancel_handcuffing=Handcuffing cancel
|
||||
error.not_galactic_patrol=You are not a galactic patrol
|
||||
warning.going_in_jail=%% second(s) left
|
||||
error.cancel_handcuffing=Handcuffing cancelled
|
||||
error.not_galactic_patrol=You are not a Galactic Patrol officer
|
||||
msg.unhandcuffing_someone=You are unhandcuffing...
|
||||
msg.unhandcuffing_you=Someone try to unhandcuffing you...
|
||||
msg.unhandcuffing_you=Someone is trying to unhandcuff 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_galactic_patrol=He is a Galactic Patrol officer
|
||||
error.is_not_criminal=He isn't a criminal
|
||||
error.banned_from_galactic_patrol=You are banned from the Galactic Patrol for
|
||||
error.banned_for_being_bad=For having bad alignment
|
||||
error.banned_for_killing_patrolman=For killing another patrolman
|
||||
error.criminal_try_join_galactic_patrol=You are a criminal
|
Binary file not shown.
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 5.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.8 KiB |
Loading…
Reference in a new issue