diff --git a/.gitignore b/.gitignore index e416ca3..480af51 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ /eclipse /gradlew /gradlew.bat -/output \ No newline at end of file +/output +/run \ No newline at end of file diff --git a/build.gradle b/build.gradle index 6f8f5ef..bbc6912 100644 --- a/build.gradle +++ b/build.gradle @@ -3,37 +3,34 @@ buildscript { mavenCentral() maven { name = "forge" - url = "https://repo.spongepowered.org/repository/forge-proxy/" - } - maven { - name = "sunproject" - url = "http://mvn.sunproject.xyz/releases" - } - maven { - name = "sonatype" - url = "https://oss.sonatype.org/content/repositories/snapshots/" + url = "https://maven.minecraftforge.net/" } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' + classpath ('com.anatawa12.forge:ForgeGradle:1.2-1.1.+') { + changing = true + } } } +plugins { + id 'java-library' + id 'maven-publish' +} + apply plugin: 'forge' -compileJava.options.encoding = 'UTF-8' +// These settings allow you to choose what version of Java you want to be compatible with. Forge 1.7.10 runs on Java 6 to 8. +sourceCompatibility = 1.8 +targetCompatibility = 1.8 -version = "0.0.0" -group = "xamora.gp_dbc" // http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = "gp_dbc" -sourceCompatibility = targetCompatibility = "1.8" -compileJava { - sourceCompatibility = targetCompatibility = "1.8" -} +version = "4.2.1.4" +group = "hedaox.ninjinmod" // http://maven.apache.org/guides/mini/guide-naming-conventions.html +archivesBaseName = "ninjinmod" minecraft { version = "1.7.10-10.13.4.1614-1.7.10" - runDir = "eclipse" + runDir = "run" } dependencies { @@ -72,18 +69,41 @@ processResources } } -sourceSets - { - main - { - output.resourcesDir = output.classesDir - } - } +// Ensures that the encoding of source files is set to UTF-8, see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" +} -idea - { - module - { - inheritOutputDirs = true - } - } \ No newline at end of file +// This task creates a .jar file containing the source code of this mod. +task sourcesJar(type: Jar, dependsOn: classes) { + classifier = "sources" + from sourceSets.main.allSource +} + +// This task creates a .jar file containing a deobfuscated version of this mod, for other developers to use in a development environment. +task devJar(type: Jar) { + classifier = "dev" + from sourceSets.main.output +} + +// Creates the listed artifacts on building the mod. +artifacts { + archives sourcesJar + archives devJar +} + +// This block configures any maven publications you want to make. +publishing.publications { + mavenJava(MavenPublication) { + // Add any other artifacts here that you would like to publish! + artifact(jar) { + builtBy build + } + artifact(sourcesJar) { + builtBy sourcesJar + } + artifact(devJar) { + builtBy devJar + } + } +} \ No newline at end of file diff --git a/src/main/java/gp_dbc/Main.java b/src/main/java/gp_dbc/Main.java index 86b6c5f..2f2eeb9 100644 --- a/src/main/java/gp_dbc/Main.java +++ b/src/main/java/gp_dbc/Main.java @@ -60,7 +60,7 @@ public class Main public static CreativeTabs tabGP = new CreativeTabs("tabGP"){ @Override public Item getTabIconItem() { - return Items.poisonous_potato; + return ItemsGP.jail_manager; } }; } diff --git a/src/main/java/gp_dbc/config/ConfigManager.java b/src/main/java/gp_dbc/config/ConfigManager.java index b0d5582..076d7a4 100644 --- a/src/main/java/gp_dbc/config/ConfigManager.java +++ b/src/main/java/gp_dbc/config/ConfigManager.java @@ -53,6 +53,8 @@ public class ConfigManager { public static String MSG_INMATE_GOING_TO_JAIL = "You are in jail for "; public static int FORMAT_TIME_JAIL = 4; + public static String ERROR_ALREADY_HANDCUFFED = "Already handcuffed"; + static public int SEC_TO_BE_IN_JAIL = 120; // second static public String POS_EXIT_JAIL = ""; //"-247 66 275 20"; static public Pos pos_exit_jail; @@ -149,6 +151,9 @@ public class ConfigManager { 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); } diff --git a/src/main/java/gp_dbc/items/ItemGPHandcuff.java b/src/main/java/gp_dbc/items/ItemGPHandcuff.java index 53ddbfe..65ca20c 100644 --- a/src/main/java/gp_dbc/items/ItemGPHandcuff.java +++ b/src/main/java/gp_dbc/items/ItemGPHandcuff.java @@ -6,6 +6,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gp_dbc.Main; import gp_dbc.config.ConfigManager; +import gp_dbc.system.Handcuff; import gp_dbc.utils.EntityUtils; import gp_dbc.utils.RayTrace; import net.minecraft.entity.Entity; @@ -17,6 +18,7 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; +import org.lwjgl.Sys; import java.util.List; @@ -24,35 +26,46 @@ public class ItemGPHandcuff extends Item { public ItemGPHandcuff() { - super(); setUnlocalizedName(Main.MODID +".gp_handcuff"); GameRegistry.registerItem(this, getUnlocalizedName()); setCreativeTab(Main.tabGP); setTextureName(Main.MODID + ":gp_handcuff"); - setMaxStackSize(2); + setMaxStackSize(1); } - //@SideOnly(Side.SERVER) @Override - public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { + @SideOnly(Side.SERVER) + public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int par4) { + int timeUse = getMaxItemUseDuration(stack) - par4; + System.out.println(timeUse); + } + @Override + @SideOnly(Side.SERVER) + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { Entity entity = EntityUtils.getEntityLookedAt(player, 5); if (entity instanceof EntityPlayer) { - EntityPlayer jailer = (EntityPlayer) entity; + EntityPlayer jailer = (EntityPlayer) entity; - NBTTagCompound nbtPlayer = JRMCoreH.nbt(jailer, "pres"); - boolean ko = nbtPlayer.getInteger("jrmcHar4va") > 0; - if (ko) { - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - if (!world.isRemote) - Main.gp.jail.putPlayerInJail(player, jailer, 20, true); - } + NBTTagCompound nbtPlayer = JRMCoreH.nbt(jailer, "pres"); + boolean ko = nbtPlayer.getInteger("jrmcHar4va") > 0; + if (ko) { + if (Handcuff.putHandcuff(player)) + player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(this, itemStack.stackSize - 1)); + } + else { + //if (Handcuff.putHandcuff(player)) + //player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(this, itemStack.stackSize - 1)); + } } + player.setItemInUse(itemStack, getMaxItemUseDuration(itemStack)); + //System.out.println(itemStack.stackSize); return itemStack; } - @SideOnly(Side.CLIENT) + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { par3List.add("Right Click to put in jail"); } diff --git a/src/main/java/gp_dbc/system/Handcuff.java b/src/main/java/gp_dbc/system/Handcuff.java new file mode 100644 index 0000000..538354b --- /dev/null +++ b/src/main/java/gp_dbc/system/Handcuff.java @@ -0,0 +1,37 @@ +package gp_dbc.system; + +import JinRyuu.JRMCore.JRMCoreH; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gp_dbc.Main; +import gp_dbc.config.ConfigManager; +import gp_dbc.utils.EntityUtils; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import org.lwjgl.Sys; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +public class Handcuff { + + // UUID~StartTimeHandcuffed + @SideOnly(Side.SERVER) + public static HashMaphandcuffed = new HashMap(); + + @SideOnly(Side.SERVER) + public static boolean putHandcuff(EntityPlayer player) { + if (handcuffed.get(player.getUniqueID()) != null) { + player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + ConfigManager.ERROR_ALREADY_HANDCUFFED)); + return false; + } + handcuffed.put(player.getUniqueID(), System.currentTimeMillis()); + return true; + } +}