Jail manager almost finish
This commit is contained in:
parent
aa04ef34db
commit
d9b140274f
|
@ -32,13 +32,12 @@ public class Main
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent e) {
|
public void preInit(FMLPreInitializationEvent e) {
|
||||||
proxy.preInit(e);
|
proxy.preInit(e);
|
||||||
ConfigManager.init(e.getModConfigurationDirectory().toString());
|
|
||||||
FMLCommonHandler.instance().bus().register(new ConfigManager());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void init(FMLInitializationEvent e) {
|
public void init(FMLInitializationEvent e) {
|
||||||
proxy.init(e);
|
proxy.init(e);
|
||||||
|
proxy.registerRender();
|
||||||
ItemsGP.init();
|
ItemsGP.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,15 @@ package gp_dbc;
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
|
||||||
|
import static net.minecraft.util.StatCollector.translateToLocal;
|
||||||
|
|
||||||
public class TemporaryEvent {
|
public class TemporaryEvent {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void PlayerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event) {
|
public void PlayerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event) {
|
||||||
MinecraftServer.getServer().getCommandManager().executeCommand(MinecraftServer.getServer(), "/op " + event.player.getDisplayName());
|
MinecraftServer.getServer().getCommandManager().executeCommand(MinecraftServer.getServer(), "/op " + event.player.getDisplayName());
|
||||||
|
event.player.addChatMessage(new ChatComponentText(translateToLocal("error.min_align_to_join")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.forgeessentials.core.commands.ForgeEssentialsCommandBase.getListOfStringsMatchingLastWord;
|
import static com.forgeessentials.core.commands.ForgeEssentialsCommandBase.getListOfStringsMatchingLastWord;
|
||||||
|
import static gp_dbc.Main.gp;
|
||||||
|
|
||||||
public class CommandGP implements ICommand {
|
public class CommandGP implements ICommand {
|
||||||
|
|
||||||
|
@ -89,29 +90,29 @@ public class CommandGP implements ICommand {
|
||||||
jgPlayer.connectBaseNBT();
|
jgPlayer.connectBaseNBT();
|
||||||
|
|
||||||
if (arg.equals(COMMANDS[0])) // Add
|
if (arg.equals(COMMANDS[0])) // Add
|
||||||
Main.gp.addToGalaticPatrol(player, true);
|
gp.addToGalaticPatrol(player, true);
|
||||||
else if (arg.equals(COMMANDS[1])) // Remove
|
else if (arg.equals(COMMANDS[1])) // Remove
|
||||||
Main.gp.removeFromGalaticPatrol(player, true);
|
gp.removeFromGalaticPatrol(player, true);
|
||||||
else if (arg.equals(COMMANDS[2])) { // Inmate
|
else if (arg.equals(COMMANDS[2])) { // Inmate
|
||||||
if (args.size() != 1)
|
if (args.size() != 1)
|
||||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "/gp jail sec [<player>]"));
|
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "/gp jail sec [<player>]"));
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
Main.gp.jail.putPlayerInJail(sender, player, Long.parseLong(args.get(0)), true);
|
gp.jail.putPlayerInJail(sender, player, Long.parseLong(args.get(0)), true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "/gp jail sec [<player>]"));
|
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "/gp jail sec [<player>]"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (arg.equals(COMMANDS[3])) { // freeInmate
|
else if (arg.equals(COMMANDS[3])) { // freeInmate
|
||||||
Main.gp.jail.removePlayerFromJail(sender, player, true);
|
gp.jail.removePlayerFromJail(sender, player, true);
|
||||||
}
|
}
|
||||||
else if (arg.equals(COMMANDS[4])) {// RemoveJail
|
else if (arg.equals(COMMANDS[4])) {// RemoveJail
|
||||||
if (args.size() != 4)
|
if (args.size() != 4)
|
||||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "/gp removeJail <x> <y> <z> <dimension>"));
|
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "/gp removeJail <x> <y> <z> <dimension>"));
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
if (Main.gp.jail.removeCell(Integer.parseInt(args.get(0)), Integer.parseInt(args.get(1)), Integer.parseInt(args.get(2)), Integer.parseInt(args.get(3))))
|
if (gp.jail.removeCell(Integer.parseInt(args.get(0)), Integer.parseInt(args.get(1)), Integer.parseInt(args.get(2)), Integer.parseInt(args.get(3))))
|
||||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Cell removed"));
|
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Cell removed"));
|
||||||
else
|
else
|
||||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Cell doesn't exist"));
|
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Cell doesn't exist"));
|
||||||
|
|
|
@ -8,6 +8,9 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import gp_dbc.Main;
|
import gp_dbc.Main;
|
||||||
import gp_dbc.utils.Pos;
|
import gp_dbc.utils.Pos;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.util.ChunkCoordinates;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.common.config.Property;
|
import net.minecraftforge.common.config.Property;
|
||||||
|
|
||||||
|
@ -19,49 +22,23 @@ import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static net.minecraft.util.StatCollector.translateToFallback;
|
||||||
|
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
|
|
||||||
private static Configuration config;
|
private static Configuration config;
|
||||||
public static boolean updateCheck = true;
|
public static boolean updateCheck = true;
|
||||||
|
|
||||||
public static final String CATEGORY_GP = "Galactic Patrol";
|
public static final String CATEGORY_GP = "Galactic Patrol";
|
||||||
public static final String CATEGORY_GPE = "Galactic Patrol Error";
|
|
||||||
public static final String CATEGORY_GPS = "Galactic Patrol Success";
|
|
||||||
public static final String CATEGORY_GPW = "Galactic Patrol Warning";
|
|
||||||
|
|
||||||
public static String DIR_SAVE = "./" + Main.MODID + "/";
|
public static String DIR_SAVE = "./" + Main.MODID + "/";
|
||||||
|
|
||||||
public static byte MIN_ALIGN_TO_JOIN = 33;
|
public static byte MIN_ALIGN_TO_JOIN = 33;
|
||||||
public static String ERROR_MIN_ALIGN_TO_JOIN = "Alignment too low";
|
|
||||||
public static byte MAX_ALIGN_TO_JOIN = 100;
|
public static byte MAX_ALIGN_TO_JOIN = 100;
|
||||||
public static String ERROR_MAX_ALIGN_TO_JOIN = "Alignment too high";
|
|
||||||
|
|
||||||
public static String SUCCESS_JOIN_GALACTIC_PATROL = "You have joined Galactic Patrol";
|
|
||||||
public static String ERROR_JOIN_GALACTIC_PATROL = "You are already in Galactic Patrol";
|
|
||||||
|
|
||||||
public static String SUCCESS_LEAVE_GALACTIC_PATROL = "You have left Galactic Patrol";
|
|
||||||
public static String ERROR_LEAVE_GALACTIC_PATROL = "You aren't in Galactic Patrol";
|
|
||||||
|
|
||||||
public static String SUCCESS_ADD_CELL = "You have added a new cell";
|
|
||||||
public static String ERROR_ADD_CELL = "There is already a cell here";
|
|
||||||
|
|
||||||
public static String ERROR_DEFINITION_EXIT_POS = "There isn't exit position";
|
|
||||||
public static String ERROR_INVALID_VALUE_EXIT_POS = "Invalid value in exit position";
|
|
||||||
public static String ERROR_UNAVAILABLE_CELL = "There aren't cell available";
|
|
||||||
public static String ERROR_ALREADY_IN_JAIL = "Player already in jail";
|
|
||||||
public static String ERROR_NOT_IN_JAIL = "Player not in jail";
|
|
||||||
public static String SUCCESS_IN_JAIL = "Player put in jail for ";
|
|
||||||
public static String MSG_INMATE_GOING_TO_JAIL = "You are in jail for ";
|
|
||||||
public static int FORMAT_TIME_JAIL = 4;
|
public static int FORMAT_TIME_JAIL = 4;
|
||||||
public static String SUCCESS_OUT_OF_JAIL = "You are out of the jail";
|
|
||||||
|
|
||||||
public static String ERROR_ALREADY_HANDCUFFED = "Already handcuffed";
|
|
||||||
public static int TIME_HANDCUFFING = 10; // seconds
|
public static int TIME_HANDCUFFING = 10; // seconds
|
||||||
public static String WARNING_HANDCUFFING_YOU = "A galactic patrol handcuffing you!";
|
|
||||||
public static String WARNING_HANDCUFFING_HIM = "You handcuffing someone";
|
|
||||||
public static String SUCCESS_YOU_HANDCUFFED_HIM = "You handcuffed him";
|
|
||||||
public static String SUCCESS_YOU_ARE_HANDCUFFED = "You are handcuffed, going in %% seconds";
|
|
||||||
public static String SUCCESS_GOING_IN_JAIL = "%% seconds left";
|
|
||||||
public static int TIME_TO_GO_IN_JAIL = 20; // seconds
|
public static int TIME_TO_GO_IN_JAIL = 20; // seconds
|
||||||
|
|
||||||
static public int SEC_TO_BE_IN_JAIL = 120; // second
|
static public int SEC_TO_BE_IN_JAIL = 120; // second
|
||||||
|
@ -99,7 +76,8 @@ public class ConfigManager {
|
||||||
pos_exit_jail = new Pos(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3]));
|
pos_exit_jail = new Pos(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3]));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
pos_exit_jail = null;
|
ChunkCoordinates spawnPoint = MinecraftServer.getServer().worldServerForDimension(0).getSpawnPoint();;
|
||||||
|
pos_exit_jail = new Pos(spawnPoint.posX, spawnPoint.posY, spawnPoint.posZ, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TIME_HANDCUFFING = (byte)addVariableConfig(order, CATEGORY_GP, "TIME_HANDCUFFING",
|
TIME_HANDCUFFING = (byte)addVariableConfig(order, CATEGORY_GP, "TIME_HANDCUFFING",
|
||||||
|
@ -110,9 +88,6 @@ public class ConfigManager {
|
||||||
|
|
||||||
config.setCategoryPropertyOrder(CATEGORY_GP, order);
|
config.setCategoryPropertyOrder(CATEGORY_GP, order);
|
||||||
|
|
||||||
loadConfigurationError();
|
|
||||||
loadConfigurationSuccess();
|
|
||||||
loadConfigurationWarning();
|
|
||||||
|
|
||||||
if (config.hasChanged())
|
if (config.hasChanged())
|
||||||
config.save();
|
config.save();
|
||||||
|
@ -134,90 +109,4 @@ public class ConfigManager {
|
||||||
|
|
||||||
public static Configuration getConfiguration() {return config;}
|
public static Configuration getConfiguration() {return config;}
|
||||||
|
|
||||||
private static void loadConfigurationError() {
|
|
||||||
List<String> orderError = new ArrayList<String>();
|
|
||||||
|
|
||||||
ERROR_MIN_ALIGN_TO_JOIN = addVariableConfig(orderError, CATEGORY_GPE, "ERROR_MIN_ALIGN_TO_JOIN",
|
|
||||||
"Error text in chat when a player tries to join without enough alignment. [default: \"Alignment too low\"]", "Alignment too low").getString();
|
|
||||||
|
|
||||||
ERROR_MAX_ALIGN_TO_JOIN = addVariableConfig(orderError, CATEGORY_GPE, "ERROR_MAX_ALIGN_TO_JOIN",
|
|
||||||
"Error text in chat when a player try to join with too much alignment. [default: \"Alignment too high\"]", "Alignment too high").getString();
|
|
||||||
|
|
||||||
ERROR_JOIN_GALACTIC_PATROL = addVariableConfig(orderError, CATEGORY_GPE, "ERROR_JOIN_GALACTIC_PATROL",
|
|
||||||
"Error text when a player tries to join Galactic Patrol and already in. [default: \"You are already in Galactic Patrol\"]", "You are already in Galactic Patrol").getString();
|
|
||||||
|
|
||||||
ERROR_LEAVE_GALACTIC_PATROL = addVariableConfig(orderError, CATEGORY_GPE, "ERROR_LEAVE_GALACTIC_PATROL",
|
|
||||||
"Error text when a player tries to leave Galactic Patrol and aren't in. [default: \"You aren't in Galactic Patrol\"]", "You aren't in Galactic Patrol").getString();
|
|
||||||
|
|
||||||
ERROR_ADD_CELL = addVariableConfig(orderError, CATEGORY_GPE, "ERROR_ADD_CELL",
|
|
||||||
"Error text when a player tries to add a new cell. [default: \"There isn't exit position\"]", "There isn't exit position").getString();
|
|
||||||
|
|
||||||
ERROR_DEFINITION_EXIT_POS = addVariableConfig(orderError, CATEGORY_GPE, "ERROR_DEFINITION_EXIT_POS",
|
|
||||||
"Error text when a player goes to jail but there isn't exit position. [default: \"There isn't exit position\"]", "There isn't exit position").getString();
|
|
||||||
|
|
||||||
ERROR_INVALID_VALUE_EXIT_POS = addVariableConfig(orderError, CATEGORY_GPE, "ERROR_INVALID_VALUE_EXIT_POS",
|
|
||||||
"Error text when a player goes to jail but the exit position is invalid. [default: \"Invalid value in exit position\"]", "Invalid value in exit position").getString();
|
|
||||||
|
|
||||||
ERROR_UNAVAILABLE_CELL = addVariableConfig(orderError, CATEGORY_GPE, "ERROR_UNAVAILABLE_CELL",
|
|
||||||
"Error text when a player cannot go to jail because all the cells are full or no cell is defined. [default: \"There aren't cell available\"]", "There aren't cell available").getString();
|
|
||||||
|
|
||||||
ERROR_ALREADY_IN_JAIL = addVariableConfig(orderError, CATEGORY_GPE, "ERROR_ALREADY_IN_JAIL",
|
|
||||||
"Error text when a player goes to jail but he is already in. [default: \"Player already in jail\"]", "Player already in jail").getString();
|
|
||||||
|
|
||||||
ERROR_NOT_IN_JAIL = addVariableConfig(orderError, CATEGORY_GPE, "ERROR_NOT_IN_JAIL",
|
|
||||||
"Error text when a inmate is release but he's already free. [default: \"There is already a cell here\"]", "There is already a cell here").getString();
|
|
||||||
|
|
||||||
ERROR_ALREADY_HANDCUFFED = addVariableConfig(orderError, CATEGORY_GPE, "ERROR_ALREADY_HANDCUFFED",
|
|
||||||
"Error text when a player try to handcuffed a players already handcuffed. [default: \"Already handcuffed\"]", "Already handcuffed").getString();
|
|
||||||
|
|
||||||
config.setCategoryPropertyOrder(CATEGORY_GPE, orderError);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void loadConfigurationSuccess() {
|
|
||||||
List<String> orderSuccess = new ArrayList<String>();
|
|
||||||
|
|
||||||
SUCCESS_JOIN_GALACTIC_PATROL = addVariableConfig(orderSuccess, CATEGORY_GPS, "SUCCESS_JOIN_GALACTIC_PATROL",
|
|
||||||
"Success text when a player join Galactic Patrol. [default: \"You joined Galactic Patrol\"]", "You joined Galactic Patrol").getString();
|
|
||||||
|
|
||||||
SUCCESS_LEAVE_GALACTIC_PATROL = addVariableConfig(orderSuccess, CATEGORY_GPS, "SUCCESS_LEAVE_GALACTIC_PATROL",
|
|
||||||
"Success text when a player left Galactic Patrol. [default: \"You have left Galactic Patrol\"]", "You have left Galactic Patrol").getString();
|
|
||||||
|
|
||||||
SUCCESS_ADD_CELL = addVariableConfig(orderSuccess, CATEGORY_GPS, "SUCCESS_ADD_CELL",
|
|
||||||
"Success text when a player adds new cell. [default: \"You have added a new cell\"]", "You have added a new cell").getString();
|
|
||||||
|
|
||||||
SUCCESS_IN_JAIL = addVariableConfig(orderSuccess, CATEGORY_GPS, "SUCCESS_IN_JAIL",
|
|
||||||
"Success text when a player put a other in jail. [default: \"Player put in jail for <Time>\"]", "Player put in jail for ").getString();
|
|
||||||
|
|
||||||
MSG_INMATE_GOING_TO_JAIL = addVariableConfig(orderSuccess, CATEGORY_GPS, "MSG_INMATE_GOING_TO_JAIL",
|
|
||||||
"Text when you are going to jail. [default: \"You are in jail for <Time>\"]", "You are in jail for ").getString();
|
|
||||||
|
|
||||||
FORMAT_TIME_JAIL = addVariableConfig(orderSuccess, CATEGORY_GPS, "FORMAT_TIME_JAIL",
|
|
||||||
"Format of the time print when a player going to jail; 1=dd/MM/yyyy - HH:mm:ss; 2=dd/MM - HH:mm:ss; 3=dd - HH:mm:ss; 4=HH:mm:ss. [default: 4]", "4").getInt();
|
|
||||||
|
|
||||||
SUCCESS_OUT_OF_JAIL = addVariableConfig(orderSuccess, CATEGORY_GPS, "SUCCESS_OUT_OF_JAIL",
|
|
||||||
"Text when you are out of the jail. [default: \"You are out of the jail\"]", "You are out of the jail").getString();
|
|
||||||
|
|
||||||
SUCCESS_YOU_HANDCUFFED_HIM = addVariableConfig(orderSuccess, CATEGORY_GPS, "SUCCESS_YOU_HANDCUFFED_HIM",
|
|
||||||
"Success when you handcuffed someone. [default: \"You handcuffed him\"]", "You handcuffed him").getString();
|
|
||||||
|
|
||||||
SUCCESS_YOU_ARE_HANDCUFFED = addVariableConfig(orderSuccess, CATEGORY_GPS, "SUCCESS_YOU_ARE_HANDCUFFED",
|
|
||||||
"When you are handcuffed, \"\" for seconds before you are going in jail. [default: \"You are handcuffed, going in %% seconds\"]", "You are handcuffed, going in %% seconds").getString();
|
|
||||||
|
|
||||||
SUCCESS_GOING_IN_JAIL = addVariableConfig(orderSuccess, CATEGORY_GPS, "SUCCESS_GOING_IN_JAIL",
|
|
||||||
"Message to say how many time remains before you are going in jail, \"%%\" for seconds. [default: \"%% seconds left\"]", "%% seconds left").getString();
|
|
||||||
|
|
||||||
config.setCategoryPropertyOrder(CATEGORY_GPS, orderSuccess);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void loadConfigurationWarning() {
|
|
||||||
List<String> orderWarning = new ArrayList<String>();
|
|
||||||
|
|
||||||
WARNING_HANDCUFFING_YOU = addVariableConfig(orderWarning, CATEGORY_GPW, "WARNING_HANDCUFFING_YOU",
|
|
||||||
"Warning when a galactic patrol try to handcuffing you [default: \"A galactic patrol handcuffing you\"]", "A galactic patrol handcuffing you").getString();
|
|
||||||
|
|
||||||
WARNING_HANDCUFFING_HIM = addVariableConfig(orderWarning, CATEGORY_GPW, "WARNING_HANDCUFFING_HIM",
|
|
||||||
"Warning when you handcuffing someone [default: \"You handcuffing someone\"]", "You handcuffing someone").getString();
|
|
||||||
|
|
||||||
config.setCategoryPropertyOrder(CATEGORY_GPW, orderWarning);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
75
src/main/java/gp_dbc/gui/GuiHandcuffed.java
Normal file
75
src/main/java/gp_dbc/gui/GuiHandcuffed.java
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
package gp_dbc.gui;
|
||||||
|
|
||||||
|
import JinRyuu.JRMCore.JRMCoreH;
|
||||||
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import gp_dbc.Main;
|
||||||
|
import gp_dbc.system.Handcuff;
|
||||||
|
import gp_dbc.utils.TextUtils;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.Gui;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import static gp_dbc.config.ConfigManager.TIME_TO_GO_IN_JAIL;
|
||||||
|
import static gp_dbc.utils.DrawGui.*;
|
||||||
|
import static net.minecraft.util.StatCollector.translateToLocal;
|
||||||
|
|
||||||
|
public class GuiHandcuffed extends Gui {
|
||||||
|
|
||||||
|
private Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
|
private final ResourceLocation gui_handcuffed = new ResourceLocation(Main.MODID + ":textures/gui/handcuffed.png");
|
||||||
|
|
||||||
|
int guiWidth = 70 / 2 + 1;
|
||||||
|
int guiHeight = 35 / 2 + 1;
|
||||||
|
|
||||||
|
public static long startTime = System.currentTimeMillis();
|
||||||
|
public static long timeToWait = 20;
|
||||||
|
|
||||||
|
// Client Side
|
||||||
|
public static boolean handcuffed = false;
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void RenderHandcuffTime(RenderGameOverlayEvent event)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Pour éviter d'impacter d'autre gui
|
||||||
|
if(event.type == RenderGameOverlayEvent.ElementType.EXPERIENCE || event.type == RenderGameOverlayEvent.ElementType.FOOD
|
||||||
|
|| event.type == RenderGameOverlayEvent.ElementType.HEALTHMOUNT || event.type == RenderGameOverlayEvent.ElementType.HEALTH
|
||||||
|
|| event.type == RenderGameOverlayEvent.ElementType.CHAT || event.type == RenderGameOverlayEvent.ElementType.BOSSHEALTH
|
||||||
|
|| event.type == RenderGameOverlayEvent.ElementType.PLAYER_LIST || event.type == RenderGameOverlayEvent.ElementType.HELMET
|
||||||
|
|| event.type == RenderGameOverlayEvent.ElementType.JUMPBAR || event.type == RenderGameOverlayEvent.ElementType.AIR
|
||||||
|
|| event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS || event.type == RenderGameOverlayEvent.ElementType.DEBUG || event.type == RenderGameOverlayEvent.ElementType.ARMOR
|
||||||
|
|| event.type == RenderGameOverlayEvent.ElementType.PORTAL || event.type == RenderGameOverlayEvent.ElementType.TEXT
|
||||||
|
|| event.type == RenderGameOverlayEvent.ElementType.HOTBAR)
|
||||||
|
return;
|
||||||
|
|
||||||
|
long time_left = (startTime + (timeToWait * 1000) - System.currentTimeMillis()) / 1000;
|
||||||
|
|
||||||
|
if (event.isCancelable())
|
||||||
|
return;
|
||||||
|
//if (time_left < -timeToWait)
|
||||||
|
//return;
|
||||||
|
|
||||||
|
if (JRMCoreH.ko <= 0)
|
||||||
|
return;
|
||||||
|
if (!handcuffed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int width = (int) (event.resolution.getScaledWidth());
|
||||||
|
int height = (int) (event.resolution.getScaledHeight());
|
||||||
|
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glDepthMask(false);
|
||||||
|
mc.renderEngine.bindTexture(gui_handcuffed);
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
drawTexturedModalRect(width / 2 - guiWidth / 2 - 20, 20 - guiHeight / 2, 0, 0, guiWidth, guiHeight + 1);
|
||||||
|
GL11.glDepthMask(true);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
|
String[] texts = TextUtils.getSeparateText(translateToLocal("warning.going_in_jail"), "%%");
|
||||||
|
if (texts != null)
|
||||||
|
drawLimitedShadow(mc.fontRenderer, texts[0] + time_left + texts[1], width / 2, 17, 70 , 9, 0xffffff);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package gp_dbc.gui.JailManager;
|
||||||
|
|
||||||
|
import gp_dbc.Main;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class GuiButtonJailManager extends GuiButton {
|
||||||
|
|
||||||
|
private static final ResourceLocation buttonTexturesNinjin = new ResourceLocation(Main.MODID, "textures/gui/jailManager.png");
|
||||||
|
ItemStack stack;
|
||||||
|
|
||||||
|
public GuiButtonJailManager(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws this button to the screen.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void drawButton(Minecraft minecraft, int x, int y) {
|
||||||
|
if (!this.visible)
|
||||||
|
return;
|
||||||
|
|
||||||
|
minecraft.getTextureManager().bindTexture(buttonTexturesNinjin);
|
||||||
|
|
||||||
|
boolean flag = x >= this.xPosition && y >= this.yPosition && x < this.xPosition + this.width && y < this.yPosition + this.height;
|
||||||
|
if (id < 0) { // cells
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
|
if (flag) {
|
||||||
|
GL11.glColor4f(0.8f, 0.8f, 0.8f, 1.0f);
|
||||||
|
this.drawTexturedModalRect(this.xPosition, this.yPosition, 130, 7, this.width, this.height);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.drawTexturedModalRect(this.xPosition, this.yPosition, 130, 7, this.width, this.height);
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
182
src/main/java/gp_dbc/gui/JailManager/GuiJailManager.java
Normal file
182
src/main/java/gp_dbc/gui/JailManager/GuiJailManager.java
Normal file
|
@ -0,0 +1,182 @@
|
||||||
|
package gp_dbc.gui.JailManager;
|
||||||
|
|
||||||
|
import gp_dbc.Main;
|
||||||
|
import gp_dbc.system.Cell;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.client.gui.ScaledResolution;
|
||||||
|
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;
|
||||||
|
|
||||||
|
import static gp_dbc.utils.DrawGui.drawLimited;
|
||||||
|
|
||||||
|
public class GuiJailManager extends GuiScreen {
|
||||||
|
|
||||||
|
final int guiWidth = 212 / 2 + 1;
|
||||||
|
final int guiHeight = 320 / 2 + 1;
|
||||||
|
|
||||||
|
private int scroll_y = 0;
|
||||||
|
|
||||||
|
private List<Cell> cells;
|
||||||
|
int gap_y = 1;
|
||||||
|
int cell_width = 76;
|
||||||
|
int cell_height = 10;
|
||||||
|
|
||||||
|
public static int cell_selected = -1; // ID of cell
|
||||||
|
private GuiButtonJailManager[] cells_buttons;
|
||||||
|
private GuiButtonJailManager delete_cell;
|
||||||
|
private GuiButtonJailManager edit_cell;
|
||||||
|
|
||||||
|
public GuiJailManager(List<Cell> cells) {
|
||||||
|
this.cells = cells;
|
||||||
|
cell_selected = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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/jailManager.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 - 10, 0, 0, guiWidth, guiHeight);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
|
int displayWidth = mc.displayWidth;
|
||||||
|
int displayHeight = mc.displayHeight;
|
||||||
|
|
||||||
|
int ratioWidth = (int) Math.round((double)displayWidth / width);
|
||||||
|
int ratioHeight = (int) Math.round((double)displayHeight / height);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glScissor(displayGuiX, displayGuiY + 54 * ratioHeight , newWidth, (int) (newHeight - 91 * ratioHeight));
|
||||||
|
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||||
|
for (int i = 0; i < cells.size(); i++) {
|
||||||
|
//GL11.glColor4d(0.1, 0.6, 0.96, 0.95);
|
||||||
|
//GL11.glTranslated(0,0, 1);
|
||||||
|
int pos_x = guiX + 13;
|
||||||
|
int pos_y = guiY + 37 + (i * (cell_height + gap_y)) + scroll_y ;
|
||||||
|
drawRect(pos_x, pos_y, pos_x + cell_width, pos_y + cell_height, 0xffffffff);
|
||||||
|
|
||||||
|
drawLimited(fontRendererObj, "Cell #" + cells.get(i).getId(), pos_x, pos_y, cell_width / 2, cell_height, 0xff000000);
|
||||||
|
}
|
||||||
|
//drawRect(0, 0, this.width, this.height, 0x60ffffff);
|
||||||
|
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
|
if (cells.size() > 6) {
|
||||||
|
int scrollbar_x = guiX + 90;
|
||||||
|
int all_cells = cells.size() * (cell_height + gap_y);
|
||||||
|
int cells_visible = 6 * (cell_height + gap_y);
|
||||||
|
int scrollable_cells = all_cells - cells_visible;
|
||||||
|
int max_height = 71;
|
||||||
|
int scrollbar_add = -((scroll_y * max_height) / scrollable_cells);
|
||||||
|
int scrollbar_y = (int) (guiY + 38 + scrollbar_add); // 98 - 163
|
||||||
|
drawRect(scrollbar_x, scrollbar_y, scrollbar_x + 6, scrollbar_y + 6, 0xff000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
super.drawScreen(mouse_x, mouse_y, ticks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui() {
|
||||||
|
|
||||||
|
if (cells == null) {
|
||||||
|
Minecraft.getMinecraft().displayGuiScreen(null);
|
||||||
|
Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "Error null cells"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int guiX = (width - guiWidth) / 2;
|
||||||
|
int guiY = (height - guiHeight) / 2;
|
||||||
|
|
||||||
|
buttonList.clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < cells.size(); i++) {
|
||||||
|
//GL11.glColor4d(0.1, 0.6, 0.96, 0.95);
|
||||||
|
//GL11.glTranslated(0,0, 1);
|
||||||
|
int pos_x = guiX + 13;
|
||||||
|
int pos_y = guiY + 37 + (i * (cell_height + gap_y)) + scroll_y ;
|
||||||
|
drawRect(pos_x, pos_y, pos_x + cell_width, pos_y + cell_height, 0xffffffff);
|
||||||
|
|
||||||
|
drawLimited(fontRendererObj, "Cell #" + cells.get(i).getId(), pos_x, pos_y, cell_width / 2, cell_height, 0xff000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0 ; i < cells.size(); i++) {
|
||||||
|
int pos_x = guiX + 13;
|
||||||
|
int pos_y = guiY + 37 + (i * (cell_height + gap_y)) + scroll_y ;
|
||||||
|
buttonList.add(cells_buttons[i] = new GuiButtonJailManager(-(i + 1), pos_x, pos_y, pos_x + cell_width, pos_y + cell_height));
|
||||||
|
}
|
||||||
|
|
||||||
|
//buttonList.add(buttonClose = new CyborgSoftwareGuiButton(1, guiX + 4, guiY - 3, 7, 7));
|
||||||
|
|
||||||
|
|
||||||
|
super.initGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton button) {
|
||||||
|
switch (button.id) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
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 (cells.size() <= 6)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int dWheel = Mouse.getEventDWheel();
|
||||||
|
|
||||||
|
//System.out.println(dWheel);
|
||||||
|
if (dWheel != 0) {
|
||||||
|
if (dWheel > 0) {
|
||||||
|
scroll_y += 5;
|
||||||
|
scroll_y = Math.min(1, scroll_y);
|
||||||
|
//System.out.println("Molette vers le haut");
|
||||||
|
} else {
|
||||||
|
scroll_y -= 5;
|
||||||
|
scroll_y = Math.max(-((cells.size() - 6) * (cell_height)), scroll_y);
|
||||||
|
//System.out.println("Molette vers le bas");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateScreen() {
|
||||||
|
super.updateScreen();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,16 +1,20 @@
|
||||||
package gp_dbc.items;
|
package gp_dbc.items;
|
||||||
|
|
||||||
import JinRyuu.JRMCore.JRMCoreH;
|
import JinRyuu.JRMCore.JRMCoreH;
|
||||||
|
import JinRyuu.JRMCore.server.JGPlayerMP;
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import gp_dbc.Main;
|
import gp_dbc.Main;
|
||||||
import gp_dbc.config.ConfigManager;
|
import gp_dbc.config.ConfigManager;
|
||||||
|
import gp_dbc.network.client.NetworkDeleteItemC;
|
||||||
|
import gp_dbc.proxy.CommonProxy;
|
||||||
import gp_dbc.system.Handcuff;
|
import gp_dbc.system.Handcuff;
|
||||||
import gp_dbc.utils.EntityUtils;
|
import gp_dbc.utils.EntityUtils;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.EnumAction;
|
import net.minecraft.item.EnumAction;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -24,7 +28,10 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static gp_dbc.Main.gp;
|
||||||
import static gp_dbc.config.ConfigManager.*;
|
import static gp_dbc.config.ConfigManager.*;
|
||||||
|
import static gp_dbc.utils.PlayerUtils.*;
|
||||||
|
import static net.minecraft.util.StatCollector.translateToLocal;
|
||||||
|
|
||||||
public class ItemGPHandcuff extends Item {
|
public class ItemGPHandcuff extends Item {
|
||||||
|
|
||||||
|
@ -57,8 +64,9 @@ public class ItemGPHandcuff extends Item {
|
||||||
|
|
||||||
long time = (System.currentTimeMillis() - startTime) / 1000;
|
long time = (System.currentTimeMillis() - startTime) / 1000;
|
||||||
|
|
||||||
if (time >= TIME_HANDCUFFING && time <= TIME_HANDCUFFING * 2L && Handcuff.putHandcuff(player, inmate))
|
if (time >= TIME_HANDCUFFING && time <= TIME_HANDCUFFING * 2L)
|
||||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(this, stack.stackSize - 1));
|
if (Handcuff.putHandcuff(player, inmate))
|
||||||
|
removeCurrentItem(player, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,8 +78,18 @@ public class ItemGPHandcuff extends Item {
|
||||||
if (entity instanceof EntityPlayer) {
|
if (entity instanceof EntityPlayer) {
|
||||||
EntityPlayer inmate = (EntityPlayer) entity;
|
EntityPlayer inmate = (EntityPlayer) entity;
|
||||||
|
|
||||||
if (Handcuff.isHandcuffed(inmate)) {
|
/*if (Handcuff.isHandcuffed(inmate)) {
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_ALREADY_HANDCUFFED));
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.already_handcuffed")));
|
||||||
|
return stack;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if (gp.jail.isInJail(inmate)) {
|
||||||
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.already_in_jail")));
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gp.isInGalacticPatrol(player)) {
|
||||||
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.not_galactic_patrol")));
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,12 +97,12 @@ public class ItemGPHandcuff extends Item {
|
||||||
boolean ko = nbtPlayer.getInteger("jrmcHar4va") > 0;
|
boolean ko = nbtPlayer.getInteger("jrmcHar4va") > 0;
|
||||||
if (ko) {
|
if (ko) {
|
||||||
if (Handcuff.putHandcuff(player, inmate))
|
if (Handcuff.putHandcuff(player, inmate))
|
||||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(this, stack.stackSize - 1));
|
removeCurrentItem(player, 1);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
handcuffing.put(inmate.getUniqueID(), System.currentTimeMillis());
|
handcuffing.put(inmate.getUniqueID(), System.currentTimeMillis());
|
||||||
inmate.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + WARNING_HANDCUFFING_YOU));
|
inmate.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + translateToLocal("warning.handcuffing_you")));
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + WARNING_HANDCUFFING_HIM));
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + translateToLocal("warning.handcuffing_him")));
|
||||||
System.out.println("handcuffing not ko");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,16 +5,23 @@ import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import gp_dbc.Main;
|
import gp_dbc.Main;
|
||||||
import gp_dbc.config.ConfigManager;
|
import gp_dbc.config.ConfigManager;
|
||||||
|
import gp_dbc.network.client.NetworkJailManagerC;
|
||||||
|
import gp_dbc.proxy.CommonProxy;
|
||||||
|
import gp_dbc.system.Cell;
|
||||||
import gp_dbc.utils.Data;
|
import gp_dbc.utils.Data;
|
||||||
import gp_dbc.utils.RayTrace;
|
import gp_dbc.utils.RayTrace;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.*;
|
import net.minecraft.util.*;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static gp_dbc.Main.gp;
|
||||||
import static gp_dbc.config.ConfigManager.*;
|
import static gp_dbc.config.ConfigManager.*;
|
||||||
|
import static net.minecraft.util.StatCollector.translateToLocal;
|
||||||
|
|
||||||
public class ItemJailManager extends Item {
|
public class ItemJailManager extends Item {
|
||||||
|
|
||||||
|
@ -35,13 +42,19 @@ public class ItemJailManager extends Item {
|
||||||
MovingObjectPosition trace = RayTrace.rayTraceServer(player, 5);
|
MovingObjectPosition trace = RayTrace.rayTraceServer(player, 5);
|
||||||
if (trace != null && trace.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
if (trace != null && trace.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "x: " + trace.blockX + " y: " + trace.blockY + " z: " + trace.blockZ));
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "x: " + trace.blockX + " y: " + trace.blockY + " z: " + trace.blockZ));
|
||||||
if (Main.gp.jail.addCell(trace.blockX, trace.blockY, trace.blockZ, player.dimension))
|
if (gp.jail.addCell(trace.blockX, trace.blockY, trace.blockZ, player.dimension))
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + SUCCESS_ADD_CELL));
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + translateToLocal("success.add_cell")));
|
||||||
else
|
else
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_ADD_CELL));
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.add_cell")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { }
|
else {
|
||||||
|
String cells = "";
|
||||||
|
for (Cell cell : gp.jail.getCells())
|
||||||
|
cells += cell.toString() + "#";
|
||||||
|
|
||||||
|
CommonProxy.network.sendTo(new NetworkJailManagerC("open~" + cells), (EntityPlayerMP) player);
|
||||||
|
}
|
||||||
// gui manage jail cells
|
// gui manage jail cells
|
||||||
|
|
||||||
return itemStack;
|
return itemStack;
|
||||||
|
|
67
src/main/java/gp_dbc/network/client/NetworkDeleteItemC.java
Normal file
67
src/main/java/gp_dbc/network/client/NetworkDeleteItemC.java
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
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.GuiHandcuffed;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import static gp_dbc.utils.PlayerUtils.*;
|
||||||
|
|
||||||
|
public class NetworkDeleteItemC implements IMessage {
|
||||||
|
|
||||||
|
private String toSend;
|
||||||
|
|
||||||
|
public NetworkDeleteItemC() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public NetworkDeleteItemC(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<NetworkDeleteItemC, IMessage> {
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public IMessage onMessage(NetworkDeleteItemC message,
|
||||||
|
MessageContext ctx) {
|
||||||
|
|
||||||
|
String[] split = message.toSend.split("~");
|
||||||
|
//String key = split[0];
|
||||||
|
String item_name = split[0];
|
||||||
|
|
||||||
|
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||||
|
ItemStack current_stack = player.getHeldItem();
|
||||||
|
if (!current_stack.getDisplayName().equals(item_name))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
int number = 1;
|
||||||
|
|
||||||
|
try {
|
||||||
|
number = Integer.parseInt(split[1]);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
removeCurrentItem(number);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
59
src/main/java/gp_dbc/network/client/NetworkHandcuffedC.java
Normal file
59
src/main/java/gp_dbc/network/client/NetworkHandcuffedC.java
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
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.GuiHandcuffed;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
|
public class NetworkHandcuffedC implements IMessage {
|
||||||
|
|
||||||
|
private String toSend;
|
||||||
|
|
||||||
|
public NetworkHandcuffedC() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public NetworkHandcuffedC(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<NetworkHandcuffedC, IMessage> {
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public IMessage onMessage(NetworkHandcuffedC message,
|
||||||
|
MessageContext ctx) {
|
||||||
|
|
||||||
|
String[] split = message.toSend.split("~");
|
||||||
|
String key = split[0];
|
||||||
|
|
||||||
|
if (key.equals("start")) {
|
||||||
|
try {
|
||||||
|
GuiHandcuffed.startTime = Long.parseLong(split[1]);
|
||||||
|
GuiHandcuffed.timeToWait = Long.parseLong(split[2]);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiHandcuffed.handcuffed = true;
|
||||||
|
}
|
||||||
|
else if (key.equals("end"))
|
||||||
|
GuiHandcuffed.handcuffed = false;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
96
src/main/java/gp_dbc/network/client/NetworkJailManagerC.java
Normal file
96
src/main/java/gp_dbc/network/client/NetworkJailManagerC.java
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
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.JailManager.GuiJailManager;
|
||||||
|
import gp_dbc.system.Cell;
|
||||||
|
import gp_dbc.system.Inmate;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class NetworkJailManagerC implements IMessage {
|
||||||
|
|
||||||
|
private String toSend;
|
||||||
|
|
||||||
|
public NetworkJailManagerC() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public NetworkJailManagerC(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<NetworkJailManagerC, IMessage> {
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public IMessage onMessage(NetworkJailManagerC message,
|
||||||
|
MessageContext ctx) {
|
||||||
|
|
||||||
|
String[] split = message.toSend.split("~");
|
||||||
|
String key = split[0];
|
||||||
|
|
||||||
|
if (key.equals("open")) {
|
||||||
|
|
||||||
|
List<Cell> cells = new ArrayList<>();
|
||||||
|
|
||||||
|
if (split.length > 1) {
|
||||||
|
String content = split[1];
|
||||||
|
|
||||||
|
String[] cells_string = content.split("#");
|
||||||
|
for (String cell_string : cells_string) {
|
||||||
|
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]);
|
||||||
|
|
||||||
|
int x = Integer.parseInt(pos[0]);
|
||||||
|
int y = Integer.parseInt(pos[1]);
|
||||||
|
int z = Integer.parseInt(pos[2]);
|
||||||
|
int dimension = Integer.parseInt(pos[3]);
|
||||||
|
|
||||||
|
Cell cell = new Cell(x, y, z, dimension, place, id);
|
||||||
|
|
||||||
|
if (info_cell.length > 3) {
|
||||||
|
String[] inmates_string = info_cell[3].split("&");
|
||||||
|
for (String inmate_string : inmates_string) {
|
||||||
|
String[] info_inmate = inmate_string.split("_");
|
||||||
|
|
||||||
|
long sec_in_jail = Long.parseLong(info_inmate[0]);
|
||||||
|
long time_start_jail = Long.parseLong(info_inmate[1]);
|
||||||
|
|
||||||
|
UUID uuid = UUID.fromString(info_inmate[2]);
|
||||||
|
|
||||||
|
Inmate inmate = new Inmate(cell, uuid, sec_in_jail, time_start_jail);
|
||||||
|
cell.addInmate(inmate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cells.add(cell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Minecraft.getMinecraft().displayGuiScreen(new GuiJailManager(cells));
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,8 @@ package gp_dbc.proxy;
|
||||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
import gp_dbc.gui.GuiHandcuffed;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
|
||||||
public class ClientProxy extends CommonProxy {
|
public class ClientProxy extends CommonProxy {
|
||||||
|
|
||||||
|
@ -17,4 +19,8 @@ public class ClientProxy extends CommonProxy {
|
||||||
public void postInit(FMLPostInitializationEvent $e) {
|
public void postInit(FMLPostInitializationEvent $e) {
|
||||||
super.postInit($e);
|
super.postInit($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void registerRender() {
|
||||||
|
MinecraftForge.EVENT_BUS.register(new GuiHandcuffed());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,13 @@ package gp_dbc.proxy;
|
||||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import gp_dbc.Main;
|
||||||
|
import gp_dbc.network.client.NetworkDeleteItemC;
|
||||||
|
import gp_dbc.network.client.NetworkHandcuffedC;
|
||||||
|
import gp_dbc.network.client.NetworkJailManagerC;
|
||||||
|
|
||||||
public class CommonProxy {
|
public class CommonProxy {
|
||||||
|
|
||||||
|
@ -11,6 +17,17 @@ public class CommonProxy {
|
||||||
|
|
||||||
public void preInit(FMLPreInitializationEvent $e) {
|
public void preInit(FMLPreInitializationEvent $e) {
|
||||||
|
|
||||||
|
network = NetworkRegistry.INSTANCE.newSimpleChannel(Main.MODID + "_1");
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
// Server to Client
|
||||||
|
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);
|
||||||
|
|
||||||
|
// Client to Server
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(FMLInitializationEvent $e) {
|
public void init(FMLInitializationEvent $e) {
|
||||||
|
@ -21,6 +38,8 @@ public class CommonProxy {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void registerRender() {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||||
import gp_dbc.TemporaryEvent;
|
import gp_dbc.TemporaryEvent;
|
||||||
|
import gp_dbc.config.ConfigManager;
|
||||||
import gp_dbc.system.Handcuff;
|
import gp_dbc.system.Handcuff;
|
||||||
import gp_dbc.system.TimeJail;
|
import gp_dbc.system.TimeJail;
|
||||||
|
|
||||||
|
@ -13,6 +14,9 @@ public class ServerProxy extends CommonProxy{
|
||||||
public void preInit(FMLPreInitializationEvent $e) {
|
public void preInit(FMLPreInitializationEvent $e) {
|
||||||
super.preInit($e);
|
super.preInit($e);
|
||||||
|
|
||||||
|
ConfigManager.init($e.getModConfigurationDirectory().toString());
|
||||||
|
FMLCommonHandler.instance().bus().register(new ConfigManager());
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().register(new TemporaryEvent());
|
FMLCommonHandler.instance().bus().register(new TemporaryEvent());
|
||||||
FMLCommonHandler.instance().bus().register(new TimeJail());
|
FMLCommonHandler.instance().bus().register(new TimeJail());
|
||||||
FMLCommonHandler.instance().bus().register(new Handcuff());
|
FMLCommonHandler.instance().bus().register(new Handcuff());
|
||||||
|
|
|
@ -8,6 +8,8 @@ import java.util.List;
|
||||||
|
|
||||||
public class Cell {
|
public class Cell {
|
||||||
|
|
||||||
|
private static int last_id = 0;
|
||||||
|
private int id;
|
||||||
private Pos pos;
|
private Pos pos;
|
||||||
private int place;
|
private int place;
|
||||||
private List<Inmate> inmates;
|
private List<Inmate> inmates;
|
||||||
|
@ -24,26 +26,39 @@ public class Cell {
|
||||||
this(new Pos(x, y, z, dimension), place);
|
this(new Pos(x, y, z, dimension), place);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Cell(int x, int y, int z, int dimension, int place, int id) {
|
||||||
|
this(new Pos(x, y, z, dimension), place, id);
|
||||||
|
}
|
||||||
|
|
||||||
public Cell(Pos pos, int place) {
|
public Cell(Pos pos, int place) {
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
this.place = place;
|
this.place = place;
|
||||||
this.inmates = new ArrayList<>();
|
this.inmates = new ArrayList<>();
|
||||||
|
this.id = last_id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inmate addJailer(EntityPlayer player, long sec) {
|
public Cell(Pos pos, int place, int id) {
|
||||||
return addJailer(new Inmate(this, player.getUniqueID(), sec));
|
this.pos = pos;
|
||||||
|
this.place = place;
|
||||||
|
this.inmates = new ArrayList<>();
|
||||||
|
this.id = id;
|
||||||
|
last_id = Math.max(last_id, id) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inmate addJailer(Inmate inmate) {
|
public Inmate addInmate(EntityPlayer player, long sec) {
|
||||||
|
return addInmate(new Inmate(this, player.getUniqueID(), sec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Inmate addInmate(Inmate inmate) {
|
||||||
inmates.add(inmate);
|
inmates.add(inmate);
|
||||||
return inmate;
|
return inmate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeJailer(EntityPlayer player, long sec) {
|
public boolean removeInmate(EntityPlayer player, long sec) {
|
||||||
return removeJailer(new Inmate(this, player.getUniqueID(), sec));
|
return removeInmate(new Inmate(this, player.getUniqueID(), sec));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeJailer(Inmate inmate) {
|
public boolean removeInmate(Inmate inmate) {
|
||||||
return inmates.remove(inmate);
|
return inmates.remove(inmate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +69,8 @@ public class Cell {
|
||||||
public Pos getPos() { return pos; }
|
public Pos getPos() { return pos; }
|
||||||
public int getPlace() { return place; }
|
public int getPlace() { return place; }
|
||||||
public void setPlace(int place) { this.place = place; }
|
public void setPlace(int place) { this.place = place; }
|
||||||
public List<Inmate> getJailers() { return inmates; }
|
public List<Inmate> getInmates() { return inmates; }
|
||||||
|
public int getId() { return id; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
|
@ -72,4 +88,13 @@ public class Cell {
|
||||||
return pos.x == x && pos.y == y && pos.z == z && pos.dimension == dimension;
|
return pos.x == x && pos.y == y && pos.z == z && pos.dimension == dimension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
String inmates = "";
|
||||||
|
for (Inmate inmate : this.inmates)
|
||||||
|
inmates += inmate.toString() + "&";
|
||||||
|
|
||||||
|
return pos.x + "_" + pos.y + "_" + pos.z + "_" + pos.dimension + "@" + place + "@" + id + "@" + inmates;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static gp_dbc.config.ConfigManager.*;
|
import static gp_dbc.config.ConfigManager.*;
|
||||||
|
import static net.minecraft.util.StatCollector.translateToLocal;
|
||||||
|
|
||||||
public class GalacticPatrol {
|
public class GalacticPatrol {
|
||||||
|
|
||||||
|
@ -43,21 +44,21 @@ public class GalacticPatrol {
|
||||||
|
|
||||||
if (align < MIN_ALIGN_TO_JOIN) {
|
if (align < MIN_ALIGN_TO_JOIN) {
|
||||||
if (chatError)
|
if (chatError)
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_MIN_ALIGN_TO_JOIN));
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.min_align_to_join")));
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
else if (align > MAX_ALIGN_TO_JOIN) {
|
else if (align > MAX_ALIGN_TO_JOIN) {
|
||||||
if (chatError)
|
if (chatError)
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_MAX_ALIGN_TO_JOIN));
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.max_align_to_join")));
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!patrolmans.contains(player.getUniqueID())) {
|
if (!patrolmans.contains(player.getUniqueID())) {
|
||||||
patrolmans.add(player.getUniqueID());
|
patrolmans.add(player.getUniqueID());
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + SUCCESS_JOIN_GALACTIC_PATROL));
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + translateToLocal("success.join_galactic_patrol")));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_JOIN_GALACTIC_PATROL));
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.join_galactic_patrol")));
|
||||||
|
|
||||||
Data.saveDataUUID(patrolmans, "galactic_patrols");
|
Data.saveDataUUID(patrolmans, "galactic_patrols");
|
||||||
|
|
||||||
|
@ -87,9 +88,9 @@ public class GalacticPatrol {
|
||||||
Data.saveDataUUID(patrolmans, "galactic_patrols");
|
Data.saveDataUUID(patrolmans, "galactic_patrols");
|
||||||
|
|
||||||
if (removed)
|
if (removed)
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + SUCCESS_LEAVE_GALACTIC_PATROL));
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + translateToLocal("success.leave_galactic_patrol")));
|
||||||
else
|
else
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_LEAVE_GALACTIC_PATROL));
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.leave_galactic_patrol")));
|
||||||
|
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,35 +1,37 @@
|
||||||
package gp_dbc.system;
|
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.eventhandler.SubscribeEvent;
|
||||||
|
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import gp_dbc.Main;
|
import gp_dbc.Main;
|
||||||
import gp_dbc.config.ConfigManager;
|
import gp_dbc.network.client.NetworkHandcuffedC;
|
||||||
import gp_dbc.utils.EntityUtils;
|
import gp_dbc.proxy.CommonProxy;
|
||||||
import gp_dbc.utils.PlayerUtils;
|
import gp_dbc.utils.TextUtils;
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.util.ChatComponentText;
|
import net.minecraft.util.ChatComponentText;
|
||||||
import net.minecraft.util.EnumChatFormatting;
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
import net.minecraft.world.World;
|
|
||||||
import org.lwjgl.Sys;
|
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static gp_dbc.Main.gp;
|
||||||
import static gp_dbc.config.ConfigManager.*;
|
import static gp_dbc.config.ConfigManager.*;
|
||||||
|
import static gp_dbc.utils.PlayerUtils.getPlayerFromUUID;
|
||||||
|
import static net.minecraft.util.StatCollector.translateToLocal;
|
||||||
|
|
||||||
public class Handcuff {
|
public class Handcuff {
|
||||||
|
|
||||||
// UUID~StartTimeHandcuffed
|
// patrol~handcuffed|StartTimeHandcuffed
|
||||||
@SideOnly(Side.SERVER)
|
@SideOnly(Side.SERVER)
|
||||||
public static HashMap<UUID, Long>handcuffed = new HashMap<UUID, Long>();
|
public static HashMap<String, Long> handcuffed = new HashMap<>();
|
||||||
|
|
||||||
int tick = 0;
|
int tick = 0;
|
||||||
final int SLOWTICK_MAX = 20;//2000;
|
final int SLOWTICK_MAX = 20;//2000;
|
||||||
|
@ -43,9 +45,31 @@ public class Handcuff {
|
||||||
if (tick >= SLOWTICK_MAX) {
|
if (tick >= SLOWTICK_MAX) {
|
||||||
tick = 0;
|
tick = 0;
|
||||||
|
|
||||||
for (UUID uuid : handcuffed.keySet()) {
|
Iterator<Map.Entry<String, Long>> iterator = handcuffed.entrySet().iterator();
|
||||||
long timeStart = handcuffed.get(uuid);
|
while (iterator.hasNext()) {
|
||||||
|
Map.Entry<String, Long> entry = iterator.next();
|
||||||
|
UUID uuid_patrol = UUID.fromString(entry.getKey().split("~")[0]);
|
||||||
|
UUID uuid_inmate = UUID.fromString(entry.getKey().split("~")[1]);
|
||||||
|
long time_start = entry.getValue();
|
||||||
|
long time_left = (time_start + (TIME_TO_GO_IN_JAIL * 1000) - System.currentTimeMillis()) / 1000;
|
||||||
|
|
||||||
|
if (time_left <= 0) {
|
||||||
|
EntityPlayer inmate = getPlayerFromUUID(uuid_inmate);
|
||||||
|
if (inmate != null) {
|
||||||
|
CommonProxy.network.sendTo(new NetworkHandcuffedC("end~"), (EntityPlayerMP) inmate);
|
||||||
|
|
||||||
|
JGPlayerMP jgInmate = new JGPlayerMP(inmate);
|
||||||
|
NBTTagCompound nbt = jgInmate.connectBaseNBT();
|
||||||
|
nbt.setInteger("jrmcHar4va", 0);
|
||||||
|
|
||||||
|
iterator.remove();
|
||||||
|
|
||||||
|
EntityPlayer patrol = getPlayerFromUUID(uuid_patrol);
|
||||||
|
gp.jail.putPlayerInJail(patrol, inmate, 20, patrol != null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
entry.setValue(-1L);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,24 +77,61 @@ public class Handcuff {
|
||||||
tick++;
|
tick++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void LogInCheckKOHandcuff(PlayerEvent.PlayerLoggedInEvent event) {
|
||||||
|
EntityPlayer inmate = event.player;
|
||||||
|
JGPlayerMP jgInmate = new JGPlayerMP(inmate);
|
||||||
|
NBTTagCompound nbt = jgInmate.connectBaseNBT();
|
||||||
|
if (getTimeHandcuffed(inmate) == -1) {
|
||||||
|
nbt.setInteger("jrmcHar4va", 0);
|
||||||
|
handcuffed.remove(getHandcuffed(inmate));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SideOnly(Side.SERVER)
|
@SideOnly(Side.SERVER)
|
||||||
public static boolean putHandcuff(EntityPlayer jailer, EntityPlayer inmate) {
|
public static boolean putHandcuff(EntityPlayer jailer, EntityPlayer inmate) {
|
||||||
if (handcuffed.get(inmate.getUniqueID()) != null) {
|
/*if (handcuffeds.get(inmate.getUniqueID()) != null) {
|
||||||
jailer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_ALREADY_HANDCUFFED));
|
jailer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_ALREADY_HANDCUFFED));
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
handcuffed.put(inmate.getUniqueID(), System.currentTimeMillis());
|
long current_time = System.currentTimeMillis();
|
||||||
jailer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + SUCCESS_YOU_HANDCUFFED_HIM));
|
|
||||||
|
handcuffed.put(jailer.getUniqueID() + "~" + inmate.getUniqueID(), current_time);
|
||||||
|
jailer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + translateToLocal("success.you_handcuffed_him")));
|
||||||
|
|
||||||
|
|
||||||
|
String[] texts = TextUtils.getSeparateText(translateToLocal("success.you_are_handcuffed"), "%%");
|
||||||
|
inmate.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + texts[0] + TIME_TO_GO_IN_JAIL + texts[1]));
|
||||||
|
|
||||||
|
JGPlayerMP jgInmate = new JGPlayerMP(inmate);
|
||||||
|
NBTTagCompound nbt = jgInmate.connectBaseNBT();
|
||||||
|
nbt.setInteger("jrmcHar4va", Integer.MAX_VALUE);
|
||||||
|
|
||||||
|
CommonProxy.network.sendTo(new NetworkHandcuffedC("start~" + current_time + "~" + TIME_TO_GO_IN_JAIL), (EntityPlayerMP) inmate);
|
||||||
|
|
||||||
int time_pos = SUCCESS_YOU_ARE_HANDCUFFED.indexOf("%%");
|
|
||||||
String first = SUCCESS_YOU_ARE_HANDCUFFED.substring(0, time_pos);
|
|
||||||
String second = SUCCESS_YOU_ARE_HANDCUFFED.substring(time_pos);
|
|
||||||
inmate.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + first + TIME_TO_GO_IN_JAIL + second));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.SERVER)
|
@SideOnly(Side.SERVER)
|
||||||
public static boolean isHandcuffed(EntityPlayer player) {
|
public static String getHandcuffed(EntityPlayer inmate) {
|
||||||
return handcuffed.containsKey(player.getUniqueID());
|
for (String uuids : handcuffed.keySet()) {
|
||||||
|
String[] split = uuids.split("~");
|
||||||
|
if (split[1].equals(inmate.getUniqueID().toString()))
|
||||||
|
return uuids;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.SERVER)
|
||||||
|
public static long getTimeHandcuffed(EntityPlayer inmate) {
|
||||||
|
String uuids = getHandcuffed(inmate);
|
||||||
|
if (uuids == null)
|
||||||
|
return 0;
|
||||||
|
return handcuffed.get(uuids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.SERVER)
|
||||||
|
public static boolean isHandcuffed(EntityPlayer inmate) {
|
||||||
|
return getHandcuffed(inmate) != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package gp_dbc.system;
|
package gp_dbc.system;
|
||||||
|
|
||||||
|
import org.lwjgl.Sys;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Inmate {
|
public class Inmate {
|
||||||
|
@ -14,17 +16,17 @@ public class Inmate {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inmate(Cell cell, UUID uuid, long secInJail) {
|
public Inmate(Cell cell, UUID uuid, long secInJail) {
|
||||||
this(cell, uuid, secInJail, secInJail);
|
this(cell, uuid, secInJail, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inmate(Cell cell, UUID uuid, long secInJail, long secInJailLeft) {
|
public Inmate(Cell cell, UUID uuid, long secInJail, long timeStartJail) {
|
||||||
this.cell = cell;
|
this.cell = cell;
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.secInJail = secInJail;
|
this.secInJail = secInJail;
|
||||||
this.timeStartJail = System.currentTimeMillis();
|
this.timeStartJail = timeStartJail;
|
||||||
|
|
||||||
if (cell != null)
|
if (cell != null)
|
||||||
cell.addJailer(this);
|
cell.addInmate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -48,5 +50,10 @@ public class Inmate {
|
||||||
public UUID getUuid() { return uuid; }
|
public UUID getUuid() { return uuid; }
|
||||||
public Cell getCell() { return cell; }
|
public Cell getCell() { return cell; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return secInJail + "_" + timeStartJail + "_" + uuid;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,13 @@ import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static gp_dbc.config.ConfigManager.*;
|
import static gp_dbc.config.ConfigManager.*;
|
||||||
|
import static net.minecraft.util.StatCollector.translateToLocal;
|
||||||
|
|
||||||
public class Jail {
|
public class Jail {
|
||||||
|
|
||||||
private List<Cell> cells;
|
private List<Cell> cells;
|
||||||
private List<Inmate> inmates;
|
private List<Inmate> inmates;
|
||||||
private List<String> waitingToBeFree; // UUID
|
private List<String> waitingToBeFree; // UUID
|
||||||
private List<String> inmatesToBe; // UUID
|
|
||||||
|
|
||||||
public Jail() {
|
public Jail() {
|
||||||
try {
|
try {
|
||||||
|
@ -31,7 +31,7 @@ public class Jail {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
inmates = listStringToListJailer(Data.loadDataString("jailers"));
|
inmates = listStringToListInmate(Data.loadDataString("Inmates"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,16 @@ public class Jail {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean contains_cells(int x, int y, int z, int dimension) {
|
||||||
|
for (Cell cell : cells)
|
||||||
|
if (cell.equals(x, y, z, dimension))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean addCell(int x, int y, int z, int dimension) {
|
public boolean addCell(int x, int y, int z, int dimension) {
|
||||||
if (cells.contains(new Cell(x, y , z , dimension)))
|
if (contains_cells(x, y , z , dimension))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
cells.add(new Cell(x, y, z, dimension));
|
cells.add(new Cell(x, y, z, dimension));
|
||||||
|
@ -51,7 +59,7 @@ public class Jail {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeCell(int x, int y, int z, int dimension) {
|
public boolean removeCell(int x, int y, int z, int dimension) {
|
||||||
if (!cells.contains(new Cell(x, y , z , dimension)))
|
if (!contains_cells(x, y , z , dimension))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
boolean removed = true;
|
boolean removed = true;
|
||||||
|
@ -65,11 +73,15 @@ public class Jail {
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Cell>getCells() {
|
||||||
|
return cells;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean thereIsExitPos(ICommandSender chat, boolean chatMsg) {
|
public boolean thereIsExitPos(ICommandSender chat, boolean chatMsg) {
|
||||||
String[] split = POS_EXIT_JAIL.split(" ");
|
String[] split = POS_EXIT_JAIL.split(" ");
|
||||||
if (split.length != 4) {
|
if (split.length != 4) {
|
||||||
if (chatMsg)
|
if (chatMsg)
|
||||||
chat.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_DEFINITION_EXIT_POS));
|
chat.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.definition_exit_pos")));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -77,14 +89,14 @@ public class Jail {
|
||||||
Integer.parseInt(split[0]); Integer.parseInt(split[1]); Integer.parseInt(split[2]); Integer.parseInt(split[3]);
|
Integer.parseInt(split[0]); Integer.parseInt(split[1]); Integer.parseInt(split[2]); Integer.parseInt(split[3]);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (chatMsg)
|
if (chatMsg)
|
||||||
chat.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_INVALID_VALUE_EXIT_POS));
|
chat.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.invalid_value_exit_pos")));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cell putPlayerInJail(ICommandSender sender, EntityPlayer jailer, long sec, boolean chatMsg) {
|
public Cell putPlayerInJail(ICommandSender sender, EntityPlayer inmate, long sec, boolean chatMsg) {
|
||||||
|
|
||||||
if (!thereIsExitPos(sender, chatMsg))
|
if (!thereIsExitPos(sender, chatMsg))
|
||||||
return null;
|
return null;
|
||||||
|
@ -98,12 +110,12 @@ public class Jail {
|
||||||
|
|
||||||
if (cell == null) {
|
if (cell == null) {
|
||||||
if (chatMsg)
|
if (chatMsg)
|
||||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_UNAVAILABLE_CELL));
|
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.unavailable_cell")));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (inmates.contains(new Inmate(jailer.getUniqueID()))) {
|
if (inmates.contains(new Inmate(inmate.getUniqueID()))) {
|
||||||
if (chatMsg)
|
if (chatMsg)
|
||||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_ALREADY_IN_JAIL));
|
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.already_in_jail")));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,20 +129,24 @@ public class Jail {
|
||||||
else if (FORMAT_TIME_JAIL == 4)
|
else if (FORMAT_TIME_JAIL == 4)
|
||||||
timeString = TimeUtils.getTimeHours(sec);
|
timeString = TimeUtils.getTimeHours(sec);
|
||||||
|
|
||||||
if (!SUCCESS_IN_JAIL.isEmpty())
|
if (!translateToLocal("success.in_jail").isEmpty())
|
||||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + SUCCESS_IN_JAIL + timeString));
|
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + translateToLocal("success.in_jail") + timeString));
|
||||||
if (!MSG_INMATE_GOING_TO_JAIL.isEmpty())
|
if (!translateToLocal("msg.inmate_going_to_jail").isEmpty())
|
||||||
jailer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + MSG_INMATE_GOING_TO_JAIL + timeString));
|
inmate.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + translateToLocal("msg.inmate_going_to_jail") + timeString));
|
||||||
|
|
||||||
inmates.add(new Inmate(cell, jailer.getUniqueID(), sec));
|
inmates.add(new Inmate(cell, inmate.getUniqueID(), sec));
|
||||||
Data.saveDataString(listJailerToListString(), "jailers");
|
Data.saveDataString(listInmateToListString(), "Inmates");
|
||||||
|
|
||||||
Pos pos = cell.getPos();
|
Pos pos = cell.getPos();
|
||||||
if (jailer.dimension != pos.dimension)
|
if (inmate.dimension != pos.dimension)
|
||||||
jailer.travelToDimension(pos.dimension);
|
inmate.travelToDimension(pos.dimension);
|
||||||
jailer.setPositionAndUpdate(pos.x + 0.5, pos.y + 1, pos.z + 0.5);
|
inmate.setPositionAndUpdate(pos.x + 0.5, pos.y + 1, pos.z + 0.5);
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInJail(EntityPlayer inmate) {
|
||||||
|
return inmates.contains(new Inmate(inmate.getUniqueID()));
|
||||||
|
}
|
||||||
|
|
||||||
public int removePlayerFromJail(ICommandSender sender, EntityPlayer player, boolean chatMsg) {
|
public int removePlayerFromJail(ICommandSender sender, EntityPlayer player, boolean chatMsg) {
|
||||||
|
|
||||||
|
@ -153,7 +169,7 @@ public class Jail {
|
||||||
boolean removed = false;
|
boolean removed = false;
|
||||||
for (int i = 0; i < inmates.size(); i++)
|
for (int i = 0; i < inmates.size(); i++)
|
||||||
if (inmates.get(i).equals(uuid)) {
|
if (inmates.get(i).equals(uuid)) {
|
||||||
inmates.get(i).getCell().removeJailer(inmates.get(i));
|
inmates.get(i).getCell().removeInmate(inmates.get(i));
|
||||||
inmates.remove(inmates.get(i));
|
inmates.remove(inmates.get(i));
|
||||||
removed = true;
|
removed = true;
|
||||||
break;
|
break;
|
||||||
|
@ -161,11 +177,11 @@ public class Jail {
|
||||||
|
|
||||||
if (!removed) {
|
if (!removed) {
|
||||||
if (chatMsg)
|
if (chatMsg)
|
||||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ERROR_NOT_IN_JAIL));
|
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + translateToLocal("error.not_int_jail")));
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
Data.saveDataString(listJailerToListString(), "jailers");
|
Data.saveDataString(listInmateToListString(), "Inmates");
|
||||||
waitingToBeFree.add(uuid.toString());
|
waitingToBeFree.add(uuid.toString());
|
||||||
Data.saveDataString(waitingToBeFree, "waitingToBeFree");
|
Data.saveDataString(waitingToBeFree, "waitingToBeFree");
|
||||||
|
|
||||||
|
@ -173,25 +189,6 @@ public class Jail {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int handcuffedPlayer(ICommandSender sender, EntityPlayer player, boolean chatMsg) {
|
|
||||||
|
|
||||||
if (inmatesToBe.contains(player.getUniqueID().toString())) {
|
|
||||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "He's already handcuffed"));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inmates.contains(new Inmate(player.getUniqueID()))) {
|
|
||||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "He's already in jail"));
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "You handcuffed him, He'll go to jail in " ));
|
|
||||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You are handcuffed, you'll go to jail in " ));
|
|
||||||
inmatesToBe.add(player.getUniqueID().toString());
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void tpOutOfJail(EntityPlayer player) {
|
public void tpOutOfJail(EntityPlayer player) {
|
||||||
Pos pos = pos_exit_jail;
|
Pos pos = pos_exit_jail;
|
||||||
if (player.dimension != pos.dimension)
|
if (player.dimension != pos.dimension)
|
||||||
|
@ -206,7 +203,7 @@ public class Jail {
|
||||||
List<Cell> availableCells = new ArrayList<>();
|
List<Cell> availableCells = new ArrayList<>();
|
||||||
|
|
||||||
for (Cell cell : cells)
|
for (Cell cell : cells)
|
||||||
if (cell.getJailers().size() < cell.getPlace())
|
if (cell.getInmates().size() < cell.getPlace())
|
||||||
availableCells.add(cell);
|
availableCells.add(cell);
|
||||||
|
|
||||||
if (availableCells.size() == 0)
|
if (availableCells.size() == 0)
|
||||||
|
@ -226,11 +223,11 @@ public class Jail {
|
||||||
for (String s : cellsStr) {
|
for (String s : cellsStr) {
|
||||||
|
|
||||||
String[] split = s.split("~");
|
String[] split = s.split("~");
|
||||||
if (split.length != 4)
|
if (split.length != 6)
|
||||||
throw new Exception("Error loading " + DIR_SAVE + "cells.txt");
|
throw new Exception("Error loading " + DIR_SAVE + "cells.txt");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cells.add(new Cell(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3])));
|
cells.add(new Cell(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3]), Integer.parseInt(split[4]), Integer.parseInt(split[5])));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println(e);
|
System.out.println(e);
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -244,7 +241,7 @@ public class Jail {
|
||||||
|
|
||||||
List<String> cellsStr = new ArrayList<>();
|
List<String> cellsStr = new ArrayList<>();
|
||||||
for (Cell cell : cells)
|
for (Cell cell : cells)
|
||||||
cellsStr.add(cell.getPos().x + "~" + cell.getPos().y + "~" + cell.getPos().z + "~" + cell.getPos().dimension);
|
cellsStr.add(cell.getPos().x + "~" + cell.getPos().y + "~" + cell.getPos().z + "~" + cell.getPos().dimension + "~" + cell.getPlace() + "~" + cell.getId());
|
||||||
|
|
||||||
return cellsStr;
|
return cellsStr;
|
||||||
}
|
}
|
||||||
|
@ -257,16 +254,16 @@ public class Jail {
|
||||||
return cells.contains(new Cell(x, y , z , dimension));
|
return cells.contains(new Cell(x, y , z , dimension));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Inmate> getJailers() { return inmates; }
|
public List<Inmate> getInmates() { return inmates; }
|
||||||
|
|
||||||
private List<Inmate> listStringToListJailer(List<String> cellsStr) throws Exception {
|
private List<Inmate> listStringToListInmate(List<String> cellsStr) throws Exception {
|
||||||
|
|
||||||
inmates = new ArrayList<>();
|
inmates = new ArrayList<>();
|
||||||
for (String s : cellsStr) {
|
for (String s : cellsStr) {
|
||||||
|
|
||||||
String[] split = s.split("~");
|
String[] split = s.split("~");
|
||||||
if (split.length != 7)
|
if (split.length != 7)
|
||||||
throw new Exception("Error loading " + DIR_SAVE + "jailers.txt");
|
throw new Exception("Error loading " + DIR_SAVE + "Inmates.txt");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
inmates.add(new Inmate(new Cell(Integer.parseInt(split[3]), Integer.parseInt(split[4]), Integer.parseInt(split[5]), Integer.parseInt(split[6])),
|
inmates.add(new Inmate(new Cell(Integer.parseInt(split[3]), Integer.parseInt(split[4]), Integer.parseInt(split[5]), Integer.parseInt(split[6])),
|
||||||
|
@ -280,7 +277,7 @@ public class Jail {
|
||||||
return inmates;
|
return inmates;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> listJailerToListString() {
|
private List<String> listInmateToListString() {
|
||||||
|
|
||||||
List<String> cellsStr = new ArrayList<>();
|
List<String> cellsStr = new ArrayList<>();
|
||||||
for (Inmate inmate : inmates)
|
for (Inmate inmate : inmates)
|
||||||
|
|
|
@ -14,7 +14,9 @@ import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.util.ChatComponentText;
|
import net.minecraft.util.ChatComponentText;
|
||||||
import net.minecraft.util.EnumChatFormatting;
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
|
|
||||||
|
import static gp_dbc.Main.gp;
|
||||||
import static gp_dbc.config.ConfigManager.*;
|
import static gp_dbc.config.ConfigManager.*;
|
||||||
|
import static net.minecraft.util.StatCollector.translateToLocal;
|
||||||
|
|
||||||
public class TimeJail {
|
public class TimeJail {
|
||||||
|
|
||||||
|
@ -23,24 +25,24 @@ public class TimeJail {
|
||||||
|
|
||||||
@SideOnly(Side.SERVER)
|
@SideOnly(Side.SERVER)
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void checkTimeJailer(TickEvent.ServerTickEvent event) {
|
public void checkTimeInmate(TickEvent.ServerTickEvent event) {
|
||||||
if (tick >= SLOWTICK_MAX) {
|
if (tick >= SLOWTICK_MAX) {
|
||||||
tick = 0;
|
tick = 0;
|
||||||
|
|
||||||
if (Main.gp.jail.getJailers() == null)
|
if (gp.jail.getInmates() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < Main.gp.jail.getJailers().size(); i++) {
|
for (int i = 0; i < gp.jail.getInmates().size(); i++) {
|
||||||
Inmate inmate = Main.gp.jail.getJailers().get(i);
|
Inmate inmate = gp.jail.getInmates().get(i);
|
||||||
|
|
||||||
if (System.currentTimeMillis() - inmate.getTimeStartJail() > inmate.getSecInJail() * 1000) {
|
if (System.currentTimeMillis() - inmate.getTimeStartJail() > inmate.getSecInJail() * 1000) {
|
||||||
|
|
||||||
// Connected
|
// Connected
|
||||||
EntityPlayer player = PlayerUtils.getPlayerFromUUID(inmate.getUuid());
|
EntityPlayer player = PlayerUtils.getPlayerFromUUID(inmate.getUuid());
|
||||||
if (player == null)
|
if (player == null)
|
||||||
Main.gp.jail.removePlayerFromJail(MinecraftServer.getServer(), inmate.getUuid(), true);
|
gp.jail.removePlayerFromJail(MinecraftServer.getServer(), inmate.getUuid(), true);
|
||||||
else
|
else
|
||||||
Main.gp.jail.removePlayerFromJail(MinecraftServer.getServer(), player, true);
|
gp.jail.removePlayerFromJail(MinecraftServer.getServer(), player, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,8 +53,8 @@ public class TimeJail {
|
||||||
@SideOnly(Side.SERVER)
|
@SideOnly(Side.SERVER)
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void checkPlayerIsFree(PlayerEvent.PlayerLoggedInEvent event) {
|
public void checkPlayerIsFree(PlayerEvent.PlayerLoggedInEvent event) {
|
||||||
if (Main.gp.jail.freePlayer(event.player))
|
if (gp.jail.freePlayer(event.player))
|
||||||
event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + SUCCESS_OUT_OF_JAIL));
|
event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + translateToLocal("success.out_of_jail")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.SERVER)
|
@SideOnly(Side.SERVER)
|
||||||
|
|
30
src/main/java/gp_dbc/utils/DrawGui.java
Normal file
30
src/main/java/gp_dbc/utils/DrawGui.java
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
package gp_dbc.utils;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
public class DrawGui {
|
||||||
|
public static void drawLimited(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;
|
||||||
|
double scale_x = (double)width / (double)size_x;
|
||||||
|
double scale_y = (double)height / (double)size_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;
|
||||||
|
double scale_x = (double)width / (double)size_x;
|
||||||
|
double scale_y = (double)height / (double)size_y;
|
||||||
|
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glScaled(scale_x, scale_y, 1.0);
|
||||||
|
fontRenderer.drawStringWithShadow(text, (int) (Math.round(x / scale_x)), (int) (Math.round(y / scale_y)), color);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,12 @@ package gp_dbc.utils;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import gp_dbc.network.client.NetworkDeleteItemC;
|
||||||
|
import gp_dbc.proxy.CommonProxy;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -23,4 +28,26 @@ public class PlayerUtils {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.SERVER)
|
||||||
|
public static void removeCurrentItem(EntityPlayer player, int number) {
|
||||||
|
ItemStack stack = player.getHeldItem();
|
||||||
|
if (stack.stackSize > number)
|
||||||
|
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(stack.getItem(), stack.stackSize - number));
|
||||||
|
else
|
||||||
|
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||||
|
|
||||||
|
CommonProxy.network.sendTo(new NetworkDeleteItemC(stack.getDisplayName() + "~" + number), (EntityPlayerMP) player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public static void removeCurrentItem(int number) {
|
||||||
|
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||||
|
ItemStack stack = player.getHeldItem();
|
||||||
|
|
||||||
|
if (stack.stackSize > number)
|
||||||
|
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(stack.getItem(), stack.stackSize - number));
|
||||||
|
else
|
||||||
|
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
15
src/main/java/gp_dbc/utils/TextUtils.java
Normal file
15
src/main/java/gp_dbc/utils/TextUtils.java
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
package gp_dbc.utils;
|
||||||
|
|
||||||
|
public class TextUtils {
|
||||||
|
public static String[] getSeparateText(String text, String separation) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
int time_pos = text.indexOf(separation);
|
||||||
|
String first = text.substring(0, time_pos);
|
||||||
|
String second = text.substring(time_pos + separation.length());
|
||||||
|
|
||||||
|
return new String[]{first, second};
|
||||||
|
} catch (Exception ignore) {}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
package gp_dbc.utils;
|
package gp_dbc.utils;
|
||||||
|
|
||||||
|
import static net.minecraft.util.StatCollector.translateToLocal;
|
||||||
|
|
||||||
public class TimeUtils {
|
public class TimeUtils {
|
||||||
|
|
||||||
public static String getTimeYears(long sec) {
|
public static String getTimeYears(long sec) {
|
||||||
|
@ -42,4 +44,5 @@ public class TimeUtils {
|
||||||
|
|
||||||
return String.format("%02d:%02d:%02d", hours, minutes, seconds);
|
return String.format("%02d:%02d:%02d", hours, minutes, seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
24
src/main/resources/assets/gp_dbc/lang/en_US.lang
Normal file
24
src/main/resources/assets/gp_dbc/lang/en_US.lang
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
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.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.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
|
||||||
|
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
|
||||||
|
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
|
||||||
|
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
|
BIN
src/main/resources/assets/gp_dbc/textures/gui/handcuffed.png
Normal file
BIN
src/main/resources/assets/gp_dbc/textures/gui/handcuffed.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
BIN
src/main/resources/assets/gp_dbc/textures/gui/jailManager.png
Normal file
BIN
src/main/resources/assets/gp_dbc/textures/gui/jailManager.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
Loading…
Reference in a new issue