Compare commits

...
88 Commits
Author SHA1 Message Date
Kam 1a7ac52297 REMVOEOMOWAMo Arggg LOUIS! 2023-06-22 17:13:14 -04:00
Kam 37e9d5f899 Update to Main API 2023-06-01 16:31:22 -04:00
Kam 09423427a0 Merge branch 'patch' 2023-06-01 16:30:38 -04:00
Kam f213cab261 Add Search to Manage Banks 2023-06-01 16:10:38 -04:00
Kam bf78c1be0f Display Selected Wand Tags in Cloner 2023-06-01 12:29:28 -04:00
Kam ff5e7de1be Save NPC Quick Tags properly on Close 2023-06-01 12:29:16 -04:00
Luis C.M 01339e7baf ScriptLivingBase:
-Reverted previous change, not worth the inaccuracies it would cause on servers
2023-06-01 00:49:33 -05:00
Luis C.M 62ee42a23d ScriptLivingBase:
-Slightly improved getLookingAtPos() results
2023-06-01 00:36:40 -05:00
Luis C.M a8a0528275 ScriptWorld:
-Increased the accuracy of rayCastPos().
2023-05-31 23:59:11 -05:00
Luis C.M 0e9ddd75b6 Fixed index out of bounds error on custom GUI slot clicks. 2023-05-31 20:21:00 -05:00
Luis C.M 0c25d7ec1c Reverted changes to saving/loading player data from previous commit to 2023-05-31 19:59:20 -05:00
Luis C.M b3a5854ff1 Merge remote-tracking branch 'origin/patch' into patch 2023-05-31 18:55:12 -05:00
Luis C.M 7000b525f3 Fixed entity custom item rendering, and rendering of textures for custom GUI buttons and rectangles. 2023-05-31 18:55:06 -05:00
Kam 9bcb8133bb Update api 2023-05-31 19:46:21 -04:00
Kam 9d727499df Fix Gradle Order 2023-05-31 19:45:36 -04:00
Kam 075e3fdb41 1.8.4 Version Change 2023-05-31 19:34:24 -04:00
Kam 5befe141bd Fix Searching in Clone Tab to now account for the displayed tags 2023-05-31 18:45:10 -04:00
Luis C.M 895d20335f DataScript:
-Now doesn't create a new instance of NpcAPI
2023-05-30 01:27:34 -05:00
Luis C.M 1ce5b7b302 ScriptCustomItem:
-Fixed issue where NBT data was not being sent to the client side, caused by latest commit.
2023-05-30 00:56:39 -05:00
Luis C.M 7c4965d368 ScriptCustomItem:
-Made engine for containers also set on saving
2023-05-29 23:59:57 -05:00
Luis C.M a0adf0d7bd Fixed item toss event not being cancellable. Setting a script container's engine doesn't happen on every script call now, reducing lag. 2023-05-29 23:57:45 -05:00
Luis C.M 2ec6e5b753 PacketHandlerServer:
-Fixed global scripts still running old versions of their scripts when changed.
2023-05-26 00:22:14 -05:00
Luis C.M 130ac26879 ScriptContainer:
-Fixed issue where the full code the script engine evaluates wouldn't get remade after being changed
2023-05-25 22:18:54 -05:00
Luis C.M cbf99be297 PlayerData:
-Renamed loadPlayerDataFromFile() to load(), and moved it next to the save() function for later addition to the API.
-Moved saving/loading to EP functions where they used to be.
-Removed now unused PlayerData.get() and loadPlayerDataOld() functions

ServerEventsHandler:
-Added new EntityConstructing event to add the PlayerData EP earlier.

NoppesUtilPlayer:
-questCompletion() now saves player data right before its return statement.
2023-05-21 02:48:30 -05:00
Luis C.M dc42beee15 Merge branch 'dev' into patch
# Conflicts:
#	src/api
2023-05-20 21:15:14 -05:00
Luis C.M b49402f8bd Implemented ImageData object caching for custom GUI button & rect elements 2023-05-20 19:23:54 -05:00
Luis C.M 8df94aaf67 IDBCPlayer:
-Created separate mastery functions for racial and non-racial forms.
2023-05-20 16:13:15 -05:00
Luis C.M ed5cfad00d IDBCPlayer:
-Changed mastery functions to use a boolean for racial or non-racial forms.
2023-05-20 15:00:58 -05:00
Kam a9961ed740 Update to 1.8.4-beta 2023-05-19 14:29:08 -04:00
Kam 6700030890 Fix Animation on Players not finding body parts 2023-05-19 14:28:55 -04:00
Kam 02b44953cb Remove duplicate Quest Completed Message 2023-05-17 16:18:09 -04:00
Kam b8c3e9bef2 QuestData Null check for QuestKill 2023-05-17 12:21:38 -04:00
Kam 5b361d779f Fix Crate Crash 2023-05-17 11:43:43 -04:00
Kam 6df7d3643f Remove runTack() 2023-05-16 19:16:34 -04:00
Luis C.M e7ed34a591 Merge remote-tracking branch 'origin/dev' into dev 2023-05-16 18:02:19 -05:00
Kam a6cd55fcea Merge branch 'master' into patch 2023-05-16 17:46:42 -04:00
Kam 13b153d922 1.8.3 2023-05-16 17:46:34 -04:00
Kam f77a2ff101 Remove more threading 2023-05-16 17:45:23 -04:00
Kam 49fab85291 Revert lots of multithreading for better threaded saving and data synchronization 2023-05-16 17:43:54 -04:00
Kam 6f1914c002 Remove ClientSide 2023-05-16 17:33:28 -04:00
Kam d1901dcf0c Spoof 1.8.3 2023-05-16 17:17:47 -04:00
Kam 204e7a9c15 Revert Some Multithreading for Synchronization 2023-05-16 17:17:11 -04:00
Kam 892d11b89b Synchronized savePlayerDataMap 2023-05-16 14:40:16 -04:00
Kam b965d2e097 1.8.3 - version change 2023-05-16 14:33:06 -04:00
Kam 3c1d7e6689 oops 2023-05-16 12:59:08 -04:00
Kam 99298226f7 Faster Quest/Faction Menu loading 2023-05-16 12:58:28 -04:00
Kam 0306cff24e Fast Quest Log Loading 2023-05-16 12:51:14 -04:00
Kam b77d98eba5 revert 2023-05-16 12:41:06 -04:00
Kam 44f4301239 Fix Permission crash 2023-05-16 12:39:55 -04:00
Kam b82177d8d9 Merge branch 'patch' 2023-05-16 11:36:33 -04:00
Kam eb77ae3b99 1.8.2 2023-05-16 11:36:25 -04:00
Kam 2b1449b5f3 Fix and Remove Universal Permissions 2023-05-16 11:34:48 -04:00
Kam 221f00ccf4 Make Save PlayerData within PlayerData. More multithreaded saving 2023-05-15 23:06:21 -04:00
Kam cf82314181 Final & Synchronized Data sending with slight delays to heavily improve server performance 2023-05-15 20:03:52 -04:00
Kam ee33a57323 send Associated Data to all 2023-05-15 19:40:53 -04:00
Kam ae1f33d327 Utilize a One Thread and Synchronized attribute to better control data integrity and prevent data loss 2023-05-15 19:31:40 -04:00
Kam 60dbcc7146 Ensure Tracked Quest does not equal null when updating 2023-05-15 16:02:44 -04:00
Kam 0b7bd2f009 Add Update Tracked Quest Frequency for ITEM QUESTs 2023-05-15 15:55:41 -04:00
Kam 8e247f8232 Deobf Jar options 2023-05-15 15:25:49 -04:00
Luis C.M 92097769d9 ScriptPlayerEventHandler:
-Temporary fix to updating tracked item quests.

Fixed more tracked quest issues.
2023-05-14 19:14:43 -05:00
Kam 13953edaaf Update LICENSE 2023-05-13 17:24:50 -04:00
Kam 9db86d0870 Update LICENSE
More appropriate license
2023-05-13 16:53:42 -04:00
Kam 8d21291e7b Add Universal Developer support to Commands 2023-05-12 20:34:02 -04:00
Kam 88eb96e784 Change Mod name to CustomNPC+ 2023-05-12 20:32:55 -04:00
Kam 78978bda92 Reorganize File System Commands 2023-05-12 20:32:44 -04:00
Kam 314bc462f0 Better Permission handling for /KAMKEEL Commands 2023-05-12 18:06:55 -04:00
Kam b04ac96690 Beta2 2023-05-12 17:39:13 -04:00
Kam 97c97cf939 Fix ModelRenderer cast for Child Models causing render corruption 2023-05-12 17:38:40 -04:00
Kam d4a62b1334 Fix Mixin Model Cast Issue 2023-05-12 17:01:15 -04:00
Kam ceac11d251 Fix Tracked Quest null crash 2023-05-12 14:26:45 -04:00
Kam f2faf3513d ___playermap.dat_old not being found 2023-05-12 12:52:39 -04:00
Kam 515a6e8550 Crate Null Checks 2023-05-12 12:52:29 -04:00
Luis C.M 142fbe51e2 Fixed quest not tracking from previous commit. 2023-05-11 20:27:00 -05:00
Luis C.M e0360f9a6e Made tracked quest a private field, clearer intent in code for bug fixing. 2023-05-11 20:17:16 -05:00
Luis C.M f5bae9099d Merge remote-tracking branch 'origin/patch' into patch 2023-05-11 18:29:49 -05:00
Luis C.M 241120c32a Fixes to quest tracking and setting alerts. 2023-05-11 18:29:44 -05:00
Kam 9ff341bd17 Fix Quest Completion Message 2023-05-11 16:58:03 -04:00
Kam dd5ca106bc Fix Quest Cooldown string results 2023-05-11 16:45:25 -04:00
Kam 3cba19cea2 Fix UUIDS not saving when spawning an NPC 2023-05-11 13:19:53 -04:00
Kam 6859b2da47 1.8.2-beta 2023-05-11 12:14:09 -04:00
Kam fa7fb7f734 ??? Fix Quest Cooldown Times ??? 2023-05-11 11:57:39 -04:00
Kam 6f7ea7340c Remove Blank Named recipes and items 2023-05-11 11:24:25 -04:00
Kam 1183f7d91b Fix NullPointer Crash with Carpentry Search bench and BLANK recipes 2023-05-11 11:19:36 -04:00
Kam 9e7e3c8e5d Merge pull request #76 from Dreamfinity/better-json-to-nbt-parsing
More NBT serialising and deserialising
2023-05-11 01:28:31 -04:00
Luis C.M 0c07260999 Merge branch 'dev' into patch 2023-05-10 23:03:44 -05:00
Luis C.M 8a4c9f6f6b DataScript:
-Fixed loading error on NPC scripts causing index oob exceptions when reading event scripts.
2023-05-10 22:57:58 -05:00
georgii.imeshkenov 112305f059 wow looks like this string was not committed 2023-02-03 00:23:22 +03:00
georgii.imeshkenov 45f006b7bf de- and serialization of NBTTagByteArray from json based on post-array "b" suffix 2023-02-02 21:24:34 +03:00
81 changed files with 1496 additions and 991 deletions

No files matched your search

+50 -17
View File
@@ -1,21 +1,54 @@
MIT License
CustomNPC+ is distributed under a reasonably open license. You probably want to have a read through this if you want to do something with it other than just play.
Copyright (c) 2021 KAMKEEL
You are completely free and have the right to Use, Share and Adapt the mod. These rights can not be removed from you as long as follow the license terms.
If you simply wish to play with the mod and do nothing else, go for it, this license is of no use to you.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
TL;DR
> You CAN
-- Fork and modify the code.
-- Submit Pull Requests to this repository.
-- Copy portions of this code for use in other projects.
-- Write your own code that uses this code as a dependency. (addon mods!)
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
> You CANNOT
-- Redistribute this in its entirety as source or compiled code.
-- Create or distribute code which contains 50% or more Functionally Equivalent Statements* from this repository.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
> You MUST
-- Maintain a visible repository of your code which is inspired by, derived from, or copied from this code. Basically, if you use it, pay it forward. You keep rights to your OWN code, but you still must make your source visible.
General Clauses
Clauses that apply in general to any of the uses that follow.
- Personal Permission Clause
I will only give personal permission if I, KAMKEEL, am directly asked. If personal permission is given this does not imply endorsement.
- Waive Clause
All restrictive clauses in this license can be ignored with personal permission. Read the above clause.
- Extensive Clause
This license applies to CustomNPC+, the CustomNPC+ website, the legacy CustomNPC+ website and all other code, assets or binaries found on this website or the github repository unless otherwise indicated.
- Informal Clause
This license will not hold up in court. I have no intention of suing anyone for breaking it, the worst that can happen to you if you do is that I'll get annoyed and ask you to rectify your mistake. If you use a public distribution platform (such as CurseForge) it's also possible your project will get taken down. Breaking the license also makes you a jerk, and you don't want to be a jerk, do you?
If you want to Distribute CustomNPC+
"Distribution" refers to making available binaries, assets, or source of the mod available from the original sources as part of your modpack or otherwise.
- Attribution Clause
You must give appropriate credit to KAMKEEL as the creator of CustomNPC+ or the parts of it you're using. Noppes can also be credit as the original Mod Author. If you do any alterations the fact that you do so should also be indicated. A link back is optional but it would be cool if you would do so.
- Redistribution Clause
You may not redistribute the enitirity of the source code provided, unless heavy modifications are made to it as a whole. More than 50% of the code cannot be redistributed unless direct permission is provided from either KAMKEEL or Noppes.
- Non-Monetary Clause
You may not charge for access to the distribution itself or gain money through it, this includes any type of inline advertisement, such as url shorteners (adf.ly or otherwise) or ads in your service slowing the download down. This includes restricting any amount of access behind a paywall. Charging for ingame goods such as mod items or cosmetic features on a server does not count as distribution and falls purely under the Mojang Terms of Service.
If you want to Feature CustomNPC+
"Featuring" refers to using CustomNPC+ in an environment where you do not distribute binaries, assets, or source. An example would be a YouTube Let's Play.
- Thief Clause
You must not claim that you made CustomNPC+. Giving appropriate credit to KAMKEEL as the creator of CustomNPC+ makes you cooler, but you don't have to do it if you don't want to.
If you want to Use CustomNPC+ Code or Assets
Usage of code or assets falls under the Extensive Clause.
- External Clause
Certain parts of the codebase are indicated to be licensed under alternative licenses. You must obey those licenses.
- Attribution Clause
You must give appropriate credit to KAMKEEL as the creator of CustomNPC+ or the parts of it you're using. Noppes can also be credit as the original Mod Author. If you do any alterations the fact that you do so should also be indicated. A link back is optional but it would be cool if you would do so.
- Copyleft Clause
Your project must be open source (have its source visible and allow for redistribution and modification) and include a clause similar to this one in its license.
- API Clause
Any of the other clauses under this section do not apply to any CustomNPC+ API code (the subdirectory src/api or https://github.com/KAMKEEL/CustomNPC-Plus-API). However, if CustomNPC+ API code is used, it must be included verbatim as it was obtained.
+6 -3
View File
@@ -34,7 +34,7 @@ configurations {
apply plugin: 'forge'
version = "1.8.1"
version = "1.8.4"
group= "com.kamkeel.customnpc-plus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "CustomNPC-Plus"
@@ -89,8 +89,6 @@ processResources
}
}
sourceSets {main { output.resourcesDir = output.classesDir }}
jar {
from sourceSets.api.output
@@ -197,6 +195,11 @@ afterEvaluate {
}
}
task deobfJar(type: Jar) {
classifier = 'dev'
from sourceSets.main.output
}
sourceSets {
main {
ext.refMap = refMapForYourConfig
+1 -1
Submodule src/api updated: 5685f9a0f8...8c61d07b10.
+2 -2
View File
@@ -50,7 +50,7 @@ public class CmdDialog extends ChMcLogger {
}
for(PlayerData playerdata : data){
playerdata.dialogData.dialogsRead.add(diagid);
playerdata.savePlayerDataOnFile();
playerdata.save();
}
return true;
}
@@ -76,7 +76,7 @@ public class CmdDialog extends ChMcLogger {
}
for(PlayerData playerdata : data){
playerdata.dialogData.dialogsRead.remove(diagid);
playerdata.savePlayerDataOnFile();
playerdata.save();
}
return true;
}
+124 -163
View File
@@ -41,173 +41,170 @@ import foxz.commandhelper.permissions.PlayerOnly;
)
public class CmdNoppes extends ChMcLogger {
public CmdFaction cmdfaction = new CmdFaction(ctorParm);
public CmdNpc cmdnpc= new CmdNpc(ctorParm);
public static Map<String,Class<?>> SlayMap = new LinkedHashMap<String,Class<?>>();
public CmdNoppes(Object sender) {
super(sender);
SlayMap.clear();
SlayMap.put("all",EntityLivingBase.class);
SlayMap.put("mobs",EntityMob.class);
public CmdFaction cmdfaction = new CmdFaction(ctorParm);
public CmdNpc cmdnpc = new CmdNpc(ctorParm);
public static Map<String, Class<?>> SlayMap = new LinkedHashMap<String, Class<?>>();
public CmdNoppes(Object sender) {
super(sender);
SlayMap.clear();
SlayMap.put("all", EntityLivingBase.class);
SlayMap.put("mobs", EntityMob.class);
SlayMap.put("animals", EntityAnimal.class);
SlayMap.put("items", EntityItem.class);
SlayMap.put("xporbs", EntityXPOrb.class);
SlayMap.put("npcs", EntityNPCInterface.class);
HashMap<String,Class<?>> list = new HashMap<String,Class<?>>(EntityList.stringToClassMapping);
for(String name : list.keySet()){
HashMap<String, Class<?>> list = new HashMap<String, Class<?>>(EntityList.stringToClassMapping);
for (String name : list.keySet()) {
Class<?> cls = list.get(name);
if(EntityNPCInterface.class.isAssignableFrom(cls))
if (EntityNPCInterface.class.isAssignableFrom(cls))
continue;
if(!EntityLivingBase.class.isAssignableFrom(cls))
if (!EntityLivingBase.class.isAssignableFrom(cls))
continue;
SlayMap.put(name.toLowerCase(), list.get(name));
}
SlayMap.remove("monster");
SlayMap.remove("mob");
}
}
@SubCommand(
name = "faction",
desc = "Faction operations",
usage = "<player> <faction> <command>",
permissions = {OpOnly.class, ParamCheck.class}
)
public Boolean faction(String[] args) {
String playername = args[0];
String factionname = args[1];
cmdfaction.data = getPlayersData(playername);
if (cmdfaction.data.isEmpty()) {
sendmessage(String.format("Unknow player '%s'", playername));
return false;
}
try{
cmdfaction.selectedFaction = FactionController.getInstance().get(Integer.parseInt(factionname));
}
catch(NumberFormatException e){
cmdfaction.selectedFaction = FactionController.getInstance().getFactionFromName(factionname); // get faction data
}
if (cmdfaction.selectedFaction == null) {
sendmessage(String.format("Unknow facion '%s", factionname));
return false;
}
args = Arrays.copyOfRange(args, 2, args.length);
cmdfaction.processCommand(this.pcParam, args);
for(PlayerData playerdata : cmdfaction.data){
playerdata.savePlayerDataOnFile();
}
return true;
}
@SubCommand(
desc="NPC manipulations",
usage="<npc> <command>",
permissions={OpOnly.class,ParamCheck.class}
)
public boolean npc(String[] args){
String npcname=args[0].replace("%", " ");
args = Arrays.copyOfRange(args, 1, args.length);
if(args[0].equalsIgnoreCase("create")){
cmdnpc.processCommand(this.pcParam, new String[]{args[0], npcname});
return true;
}
int x = pcParam.getPlayerCoordinates().posX;
int y = pcParam.getPlayerCoordinates().posY;
int z = pcParam.getPlayerCoordinates().posZ;
List<EntityNPCInterface> list = getNearbeEntityFromPlayer(EntityNPCInterface.class, pcParam.getEntityWorld(), x, y, z, 80);
EntityNPCInterface closest = null;
for (EntityNPCInterface npc : list) {
String name = npc.display.name.replace(" ", "_");
if (name.equalsIgnoreCase(npcname)){
if(closest == null || closest.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
closest = npc;
}
}
if(closest != null){
cmdnpc.selectedNpc=closest;
cmdnpc.processCommand(this.pcParam, args);
cmdnpc.selectedNpc = null;
}
else
sendmessage(String.format("NPC '%s' was not found",npcname));
return true;
}
@SubCommand(
name = "slay",
desc = "Kills given entity within range. Also has all, mobs, animal options. Can have multiple types",
usage = "<type>.. [range]",
permissions = {PlayerOnly.class, OpOnly.class, ParamCheck.class}
)
public Boolean slay(String[] args) {
EntityPlayerMP player = (EntityPlayerMP) pcParam;
@SubCommand(
name = "faction",
desc = "Faction operations",
usage = "<player> <faction> <command>",
permissions = {OpOnly.class, ParamCheck.class}
)
public Boolean faction(String[] args) {
String playername = args[0];
String factionname = args[1];
cmdfaction.data = getPlayersData(playername);
if (cmdfaction.data.isEmpty()) {
sendmessage(String.format("Unknow player '%s'", playername));
return false;
}
try {
cmdfaction.selectedFaction = FactionController.getInstance().get(Integer.parseInt(factionname));
} catch (NumberFormatException e) {
cmdfaction.selectedFaction = FactionController.getInstance().getFactionFromName(factionname); // get faction data
}
if (cmdfaction.selectedFaction == null) {
sendmessage(String.format("Unknow facion '%s", factionname));
return false;
}
args = Arrays.copyOfRange(args, 2, args.length);
cmdfaction.processCommand(this.pcParam, args);
for (PlayerData playerdata : cmdfaction.data) {
playerdata.save();
}
return true;
}
@SubCommand(
desc = "NPC manipulations",
usage = "<npc> <command>",
permissions = {OpOnly.class, ParamCheck.class}
)
public boolean npc(String[] args) {
String npcname = args[0].replace("%", " ");
args = Arrays.copyOfRange(args, 1, args.length);
if (args[0].equalsIgnoreCase("create")) {
cmdnpc.processCommand(this.pcParam, new String[]{args[0], npcname});
return true;
}
int x = pcParam.getPlayerCoordinates().posX;
int y = pcParam.getPlayerCoordinates().posY;
int z = pcParam.getPlayerCoordinates().posZ;
List<EntityNPCInterface> list = getNearbeEntityFromPlayer(EntityNPCInterface.class, pcParam.getEntityWorld(), x, y, z, 80);
EntityNPCInterface closest = null;
for (EntityNPCInterface npc : list) {
String name = npc.display.name.replace(" ", "_");
if (name.equalsIgnoreCase(npcname)) {
if (closest == null || closest.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
closest = npc;
}
}
if (closest != null) {
cmdnpc.selectedNpc = closest;
cmdnpc.processCommand(this.pcParam, args);
cmdnpc.selectedNpc = null;
} else
sendmessage(String.format("NPC '%s' was not found", npcname));
return true;
}
@SubCommand(
name = "slay",
desc = "Kills given entity within range. Also has all, mobs, animal options. Can have multiple types",
usage = "<type>.. [range]",
permissions = {PlayerOnly.class, OpOnly.class, ParamCheck.class}
)
public Boolean slay(String[] args) {
EntityPlayerMP player = (EntityPlayerMP) pcParam;
ArrayList<Class<?>> toDelete = new ArrayList<Class<?>>();
boolean deleteNPCs = false;
for(String delete : args){
for (String delete : args) {
delete = delete.toLowerCase();
Class<?> cls = SlayMap.get(delete);
if(cls != null)
if (cls != null)
toDelete.add(cls);
if(delete.equals("mobs")){
if (delete.equals("mobs")) {
toDelete.add(EntityGhast.class);
toDelete.add(EntityDragon.class);
}
if(delete.equals("npcs"))
if (delete.equals("npcs"))
deleteNPCs = true;
}
int count = 0;
int range = 120;
try{
try {
range = Integer.parseInt(args[args.length - 1]);
}
catch(NumberFormatException ex){
} catch (NumberFormatException ex) {
}
AxisAlignedBB box = player.boundingBox.expand(range, range, range);
List<Entity> list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, box);
for(Entity entity : list){
if(entity instanceof EntityPlayer)
for (Entity entity : list) {
if (entity instanceof EntityPlayer)
continue;
if(entity instanceof EntityTameable && ((EntityTameable)entity).isTamed())
if (entity instanceof EntityTameable && ((EntityTameable) entity).isTamed())
continue;
if(entity instanceof EntityNPCInterface && !deleteNPCs)
if (entity instanceof EntityNPCInterface && !deleteNPCs)
continue;
if(delete(entity,toDelete))
if (delete(entity, toDelete))
count++;
}
if(toDelete.contains(EntityXPOrb.class)){
if (toDelete.contains(EntityXPOrb.class)) {
list = player.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, box);
for(Entity entity : list){
for (Entity entity : list) {
entity.isDead = true;
count++;
}
}
if(toDelete.contains(EntityItem.class)){
if (toDelete.contains(EntityItem.class)) {
list = player.worldObj.getEntitiesWithinAABB(EntityItem.class, box);
for(Entity entity : list){
for (Entity entity : list) {
entity.isDead = true;
count++;
}
}
player.addChatMessage(new ChatComponentTranslation(count + " entities deleted"));
return true;
}
private boolean delete(Entity entity, ArrayList<Class<?>> toDelete) {
for(Class<?> delete : toDelete){
if(delete == EntityAnimal.class && (entity instanceof EntityHorse)){
return true;
}
private boolean delete(Entity entity, ArrayList<Class<?>> toDelete) {
for (Class<?> delete : toDelete) {
if (delete == EntityAnimal.class && (entity instanceof EntityHorse)) {
continue;
}
if(delete.isAssignableFrom(entity.getClass())){
if (delete.isAssignableFrom(entity.getClass())) {
entity.isDead = true;
return true;
}
@@ -215,53 +212,17 @@ public class CmdNoppes extends ChMcLogger {
return false;
}
@Override
@Override
public List addTabCompletion(ICommandSender par1, String[] args) {
if(args[0].equalsIgnoreCase("slay")){
if (args[0].equalsIgnoreCase("slay")) {
return CommandBase.getListOfStringsMatchingLastWord(args, SlayMap.keySet().toArray(new String[SlayMap.size()]));
}
if(args[0].equalsIgnoreCase("npc") && args.length == 3){
}
if (args[0].equalsIgnoreCase("npc") && args.length == 3) {
return cmdnpc.addTabCompletion(par1, Arrays.copyOfRange(args, 1, args.length));
}
if(args[0].equalsIgnoreCase("faction") && args.length == 4){
if (args[0].equalsIgnoreCase("faction") && args.length == 4) {
return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"add", "subtract", "set", "reset", "drop", "create"});
}
return super.addTabCompletion(par1, args);
}
//<editor-fold desc="--- FoxZ fork (keep it pls)">
// @SubCommand(
// desc = "Save AltPlayerInv",
// usage = "{player} {inv}",
// permissions={OpOnly.class}
// )
// public boolean sapi(String[] args) {
// EntityPlayer p = getOnlinePlayer(args[0]);
// sendmessage(String.format("noppes.sapi:%s %s", args[0], args[1]));
// if (p == null) {
// sendmessage("noppes.sapi:unkow " + args[0]);
// return false;
// }
// savePlayerAltInv(p, args[1]);
// sendmessage("noppes.sapi:saved");
// return true;
// }
//
// @SubCommand(
// desc = "Load AltPlayerInv",
// usage = "{player} {inv}",
// permissions={OpOnly.class}
// )
// public boolean lapi(String[] args) {
// EntityPlayer p = getOnlinePlayer(args[0]);
// sendmessage(String.format("noppes.lapi:%s %s", args[0], args[1]));
// if (p == null) {
// sendmessage("noppes.sapi:unknow " + args[0]);
// return false;
// }
//
// loadPlayerAltInv(p, args[1]);
// sendmessage("noppes.lapi:loaded");
// return true;
// }
//</editor-fold>
}
return super.addTabCompletion(par1, args);
}
}
+4 -4
View File
@@ -56,7 +56,7 @@ public class CmdQuest extends ChMcLogger{
continue;
QuestData questdata = new QuestData(quest);
playerdata.questData.activeQuests.put(questid, questdata);
playerdata.savePlayerDataOnFile();
playerdata.save();
if(playerdata.player != null){
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
@@ -93,7 +93,7 @@ public class CmdQuest extends ChMcLogger{
}
for(PlayerData playerdata : data){
playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis());
playerdata.savePlayerDataOnFile();
playerdata.save();
}
return true;
}
@@ -124,7 +124,7 @@ public class CmdQuest extends ChMcLogger{
}
for(PlayerData playerdata : data){
playerdata.questData.activeQuests.remove(questid);
playerdata.savePlayerDataOnFile();
playerdata.save();
}
return true;
}
@@ -156,7 +156,7 @@ public class CmdQuest extends ChMcLogger{
for(PlayerData playerdata : data){
playerdata.questData.activeQuests.remove(questid);
playerdata.questData.finishedQuests.remove(questid);
playerdata.savePlayerDataOnFile();
playerdata.save();
}
return true;
}
@@ -1,14 +1,11 @@
package kamkeel;
package kamkeel.command;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.monster.EntityEnderman;
import noppes.npcs.controllers.AnimationController;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.PlayerFactionData;
import java.util.Arrays;
import java.util.List;
@@ -49,7 +46,7 @@ public class AnimationCommand extends CommandKamkeelBase {
processSubCommand(sender, args[1], Arrays.copyOfRange(args, 2, args.length));
data.get(0).animationData.updateClient();
data.get(0).savePlayerDataOnFile();
data.get(0).save();
}
@SubCommand(desc = "enable animation")
@@ -1,4 +1,4 @@
package kamkeel;
package kamkeel.command;
import java.util.List;
@@ -1,17 +1,18 @@
package kamkeel;
package kamkeel.command;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.client.Minecraft;
import kamkeel.developer.Developer;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;
import noppes.npcs.CustomNpcsPermissions;
import noppes.npcs.scripted.CustomNPCsException;
public class CommandKamkeel extends CommandBase{
@@ -61,7 +62,7 @@ public class CommandKamkeel extends CommandBase{
args = Arrays.copyOfRange(args, 1, args.length);
if(command.subcommands.isEmpty() || !command.runSubCommands()){
if(!sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getCommandPermission(command.getCommandName())))
if(!canSendCommand(sender, command))
throw new CommandException("You are not allowed to use this command: " + command);
command.canRun(sender, command.getUsage(), args);
command.processCommand(sender, args);
@@ -117,5 +118,25 @@ public class CommandKamkeel extends CommandBase{
public static String getCommandPermission(String command){
return "cnpc.kamkeel." + command.toLowerCase();
}
public static String getUniversalPermission(){
return "cnpc.kamkeel.*";
}
public static boolean canSendCommand(ICommandSender sender, CommandKamkeelBase command){
if(sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getUniversalPermission())){
return true;
}
if(sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getCommandPermission(command.getCommandName()))){
return true;
}
if(sender instanceof EntityPlayer){
return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getCommandPermission(command.getCommandName()));
}
return false;
}
}
@@ -1,4 +1,4 @@
package kamkeel;
package kamkeel.command;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -10,10 +10,13 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import kamkeel.developer.Developer;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentTranslation;
import noppes.npcs.CustomNpcsPermissions;
public abstract class CommandKamkeelBase extends CommandBase{
public Map<String, Method> subcommands = new HashMap<String, Method>();
@@ -87,7 +90,7 @@ public abstract class CommandKamkeelBase extends CommandBase{
throw new CommandException("Unknown subcommand " + command);
SubCommand sc = m.getAnnotation(SubCommand.class);
if(!sender.canCommandSenderUseCommand(sc.permission(), getSubCommandPermission(command)))
if(!canSendCommand(sender, sc, command))
throw new CommandException("You are not allowed to use this command: " + command);
canRun(sender, sc.usage(), args);
@@ -123,4 +126,24 @@ public abstract class CommandKamkeelBase extends CommandBase{
public String getSubCommandPermission(String subCommand){
return "cnpc.kamkeel." + getCommandName().toLowerCase() + "." + subCommand.toLowerCase();
}
public String getSubUniversalPermission(){
return "cnpc.kamkeel." + getCommandName().toLowerCase() + "*";
}
public boolean canSendCommand(ICommandSender sender, SubCommand command, String subCommand){
if(sender.canCommandSenderUseCommand(command.permission(), getSubUniversalPermission())){
return true;
}
if(sender.canCommandSenderUseCommand(command.permission(), getSubCommandPermission(subCommand))){
return true;
}
if(sender instanceof EntityPlayer){
return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getSubCommandPermission(subCommand));
}
return false;
}
}
@@ -1,4 +1,4 @@
package kamkeel;
package kamkeel.command;
import net.minecraft.block.Block;
import net.minecraft.block.BlockIce;
@@ -1,4 +1,4 @@
package kamkeel;
package kamkeel.command;
import java.util.List;
@@ -48,7 +48,7 @@ public class DialogCommand extends CommandKamkeelBase {
}
for(PlayerData playerdata : data){
playerdata.dialogData.dialogsRead.add(diagid);
playerdata.savePlayerDataOnFile();
playerdata.save();
sendResult(sender, String.format("Forced Read for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername));
}
}
@@ -73,7 +73,7 @@ public class DialogCommand extends CommandKamkeelBase {
}
for(PlayerData playerdata : data){
playerdata.dialogData.dialogsRead.remove(diagid);
playerdata.savePlayerDataOnFile();
playerdata.save();
sendResult(sender, String.format("Forced Unread for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername));
}
}
@@ -1,4 +1,4 @@
package kamkeel;
package kamkeel.command;
import java.util.Arrays;
import java.util.List;
@@ -64,7 +64,7 @@ public class FactionCommand extends CommandKamkeelBase {
processSubCommand(sender, args[2], Arrays.copyOfRange(args, 3, args.length));
for(PlayerData playerdata : data){
playerdata.savePlayerDataOnFile();
playerdata.save();
}
}
@@ -1,4 +1,4 @@
package kamkeel;
package kamkeel.command;
import java.lang.reflect.Method;
import java.util.Map.Entry;
@@ -1,4 +1,4 @@
package kamkeel;
package kamkeel.command;
import java.util.Arrays;
import java.util.List;
@@ -1,4 +1,4 @@
package kamkeel;
package kamkeel.command;
import java.util.List;
@@ -7,7 +7,7 @@ import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.Server;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.controllers.DialogController;
import noppes.npcs.constants.EnumQuestRepeat;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.QuestController;
import noppes.npcs.controllers.data.PlayerData;
@@ -56,8 +56,8 @@ public class QuestCommand extends CommandKamkeelBase {
for(PlayerData playerdata : data){
QuestData questdata = new QuestData(quest);
playerdata.questData.activeQuests.put(questid, questdata);
playerdata.savePlayerDataOnFile();
if(playerdata.player != null){
playerdata.save();
if(playerdata.player != null && questdata.sendAlerts){
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
}
@@ -95,9 +95,13 @@ public class QuestCommand extends CommandKamkeelBase {
if(playerdata.questData.activeQuests.containsKey(questid)){
playerdata.questData.activeQuests.remove(questid);
}
playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis());
playerdata.savePlayerDataOnFile();
if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY)
playerdata.questData.finishedQuests.put(quest.id, System.currentTimeMillis());
else
playerdata.questData.finishedQuests.put(quest.id, sender.getEntityWorld().getTotalWorldTime());
playerdata.save();
if(playerdata.player != null){
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.completed", quest.title);
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.completed", ": ", quest.title);
@@ -131,7 +135,7 @@ public class QuestCommand extends CommandKamkeelBase {
}
for(PlayerData playerdata : data){
playerdata.questData.activeQuests.remove(questid);
playerdata.savePlayerDataOnFile();
playerdata.save();
sendResult(sender, String.format("Stopped Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
}
}
@@ -165,7 +169,7 @@ public class QuestCommand extends CommandKamkeelBase {
for(PlayerData playerdata : data){
playerdata.questData.activeQuests.remove(questid);
playerdata.questData.finishedQuests.remove(questid);
playerdata.savePlayerDataOnFile();
playerdata.save();
sendResult(sender, String.format("Removed Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
}
}
@@ -1,4 +1,4 @@
package kamkeel;
package kamkeel.command;
import net.minecraft.command.ICommandSender;
import noppes.npcs.controllers.ScriptController;
@@ -1,4 +1,4 @@
package kamkeel;
package kamkeel.command;
import java.util.ArrayList;
import java.util.HashMap;
@@ -23,7 +23,6 @@ import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentTranslation;
import noppes.npcs.entity.EntityNPCInterface;
public class SlayCommand extends CommandKamkeelBase {
@@ -0,0 +1,44 @@
package kamkeel.developer;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
public class Developer {
public static HashSet<UUID> Universal = new HashSet<>();
public static HashSet<UUID> ScriptUser = new HashSet<>();
public static HashSet<UUID> WandUser = new HashSet<>();
public static HashSet<UUID> QuestMaker = new HashSet<>();
public static Developer instance;
public Developer(){
instance = this;
// Temp for testing
Universal.add(UUID.fromString("29cc52dd-2c50-4e8f-a388-be6c497cf0b4"));
}
public boolean hasUniversal(UUID uuid){
if(Universal == null){
Universal = new HashSet<>();
}
return Universal.contains(uuid);
}
public boolean hasScriptUser(UUID uuid){
if(ScriptUser == null){
ScriptUser = new HashSet<>();
}
return ScriptUser.contains(uuid);
}
public boolean hasWandUser(UUID uuid){
return WandUser.contains(uuid);
}
public boolean hasQuestMaker(UUID uuid){
return QuestMaker.contains(uuid);
}
}
+4 -4
View File
@@ -9,7 +9,8 @@ import cpw.mods.fml.common.network.FMLEventChannel;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import foxz.command.CommandNoppes;
import kamkeel.CommandKamkeel;
import kamkeel.command.CommandKamkeel;
import kamkeel.developer.Developer;
import net.minecraft.block.Block;
import net.minecraft.block.BlockIce;
import net.minecraft.block.BlockLeavesBase;
@@ -35,7 +36,7 @@ import java.util.ArrayList;
import java.util.Set;
import java.util.UUID;
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.8.1")
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.8.4")
public class CustomNpcs {
@SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy")
@@ -52,8 +53,6 @@ public class CustomNpcs {
public static FMLEventChannel Channel;
public static FMLEventChannel ChannelPlayer;
public static ArrayList<UUID> ScriptDevs = new ArrayList<>();
public static final MarkovGenerator[] MARKOV_GENERATOR = new MarkovGenerator[10];
public static boolean InitIgnore = false;
@@ -168,6 +167,7 @@ public class CustomNpcs {
ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkController());
new CustomNpcsPermissions();
new Developer();
PixelmonHelper.load();
}
@@ -1,5 +1,6 @@
package noppes.npcs;
import kamkeel.developer.Developer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import org.apache.logging.log4j.LogManager;
@@ -74,12 +75,29 @@ public class CustomNpcsPermissions{
}
public static boolean hasPermission(EntityPlayer player, Permission permission){
if(Instance.bukkit != null){
return Instance.bukkitPermission(player.getCommandSenderName(), permission.name);
if(player != null){
if(Developer.instance.hasUniversal(player.getUniqueID())){
return true;
}
if(permission != null){
if(Instance.bukkit != null){
return Instance.bukkitPermission(player.getCommandSenderName(), permission.name);
}
}
}
return true;
}
public static boolean hasCustomPermission(EntityPlayer player, String permission){
if(Developer.instance.hasUniversal(player.getUniqueID())){
return true;
}
if(Instance.bukkit != null){
return Instance.bukkitPermission(player.getCommandSenderName(), permission);
}
return false;
}
private boolean bukkitPermission(String username, String permission) {
try {
Object player = getPlayer.invoke(null, username);
+60 -18
View File
@@ -32,10 +32,7 @@ import noppes.npcs.scripted.event.DialogEvent;
import noppes.npcs.scripted.event.QuestEvent;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.*;
public class NoppesUtilPlayer {
@@ -300,22 +297,65 @@ public class NoppesUtilPlayer {
else
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
}
public static void sendTrackedQuestData(EntityPlayerMP player, Quest trackedQuest) {
Quest quest = (Quest) PlayerDataController.instance.getPlayerData(player).questData.trackedQuest;
if (quest == null || trackedQuest == null || quest.id != trackedQuest.id) {
return;
public static void updateQuestLogData(ByteBuf buffer, EntityPlayerMP player) throws IOException {
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
NBTTagCompound compound = Server.readNBT(buffer);
HashMap<String,String> questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10));
for (Map.Entry<String,String> entry : questAlerts.entrySet()) {
Quest quest = getQuestFromStringKey(entry.getKey());
if (quest != null) {
playerData.questData.activeQuests.get(quest.id).sendAlerts = Boolean.parseBoolean(entry.getValue());
}
}
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("Quest",trackedQuest.writeToNBT(new NBTTagCompound()));
compound.setString("CategoryName", trackedQuest.getCategory().getName());
compound.setString("TurnInNPC", trackedQuest.getNpcName());
NBTTagList nbtTagList = new NBTTagList();
for (IQuestObjective objective : trackedQuest.questInterface.getObjectives(player)) {
nbtTagList.appendTag(new NBTTagString(objective.getText()));
String trackedQuestString = Server.readString(buffer);
Quest trackedQuest = getQuestFromStringKey(trackedQuestString);
if (trackedQuest != null) {
playerData.questData.trackQuest(trackedQuest);
} else {
playerData.questData.untrackQuest();
}
}
private static Quest getQuestFromStringKey(String string) {
if (string != null && string.contains(":")) {
String[] splitString = string.split(":");
if(splitString.length < 2){
return null;
}
String categoryName = splitString[0];
String questName = splitString[1];
for (QuestCategory category : QuestController.instance.categories.values()) {
if (category.title.equals(categoryName)) {
for (Quest quest : category.quests.values()) {
if (quest.title.equals(questName)) {
return quest;
}
}
}
}
}
return null;
}
public static void sendTrackedQuestData(EntityPlayerMP player) {
Quest trackedQuest = (Quest) PlayerDataController.instance.getPlayerData(player).questData.getTrackedQuest();
if(trackedQuest != null){
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("Quest",trackedQuest.writeToNBT(new NBTTagCompound()));
compound.setString("CategoryName", trackedQuest.getCategory().getName());
compound.setString("TurnInNPC", trackedQuest.getNpcName());
NBTTagList nbtTagList = new NBTTagList();
for (IQuestObjective objective : trackedQuest.questInterface.getObjectives(player)) {
nbtTagList.appendTag(new NBTTagString(objective.getText()));
}
compound.setTag("ObjectiveList",nbtTagList);
Server.sendData(player, EnumPacketClient.OVERLAY_QUEST_TRACKING, compound);
}
compound.setTag("ObjectiveList",nbtTagList);
Server.sendData(player, EnumPacketClient.OVERLAY_QUEST_TRACKING, compound);
}
public static void sendQuestLogData(EntityPlayerMP player) {
@@ -398,9 +438,11 @@ public class NoppesUtilPlayer {
QuestData nextQuest = new QuestData(data.quest.getNextQuest());
nextQuest.sendAlerts = data.quest.id != data.quest.getNextQuest().id || data.sendAlerts;
PlayerQuestController.addActiveQuest(nextQuest, player);
NoppesUtilPlayer.sendTrackedQuestData(player,nextQuest.quest);
questData.trackQuest(nextQuest.quest);
}
playerData.save();
return true;
}
+47 -32
View File
@@ -55,7 +55,7 @@ public class NoppesUtilServer {
PlayerData data = PlayerDataController.instance.getPlayerData(player);
data.editingNpc = npc;
if(npc != null)
Server.sendData((EntityPlayerMP)player, EnumPacketClient.EDIT_NPC, npc.getEntityId());
Server.sendDataChecked((EntityPlayerMP)player, EnumPacketClient.EDIT_NPC, npc.getEntityId());
}
public static EntityNPCInterface getEditingNpc(EntityPlayer player){
PlayerData data = PlayerDataController.instance.getPlayerData(player);
@@ -172,7 +172,7 @@ public class NoppesUtilServer {
}
}
if(npc instanceof EntityDialogNpc){
if(npc instanceof EntityDialogNpc || dia.id < 0){
dialog.hideNPC = true;
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG_DUMMY, npc.getCommandSenderName(), dialog.writeToNBT(new NBTTagCompound()));
}
@@ -241,19 +241,48 @@ public class NoppesUtilServer {
EnumGuiType gui, EntityNPCInterface npc) {
sendOpenGui(player, gui, npc, 0, 0, 0);
}
public static void sendOpenGui(EntityPlayer player,
EnumGuiType gui, EntityNPCInterface npc, int i, int j, int k) {
public static void sendOpenGuiNoDelay(EntityPlayer player,
EnumGuiType gui, EntityNPCInterface npc) {
sendOpenGuiNoDelay(player, gui, npc, 0, 0, 0);
}
public static void sendOpenGui(final EntityPlayer player,
final EnumGuiType gui, final EntityNPCInterface npc, final int i, final int j, final int k) {
if(!(player instanceof EntityPlayerMP))
return;
setEditingNpc(player, npc);
sendExtraData(player, npc,gui, i, j, k);
if(CustomNpcs.proxy.getServerGuiElement(gui.ordinal(), player, player.worldObj, i, j, k) != null){
player.openGui(CustomNpcs.instance, gui.ordinal(), player.worldObj, i, j, k);
return;
}
else{
Server.sendData((EntityPlayerMP)player, EnumPacketClient.GUI, gui.ordinal(), i, j, k);
Server.sendDataChecked((EntityPlayerMP)player, EnumPacketClient.GUI, gui.ordinal(), i, j, k);
}
ArrayList<String> list = getScrollData(player, gui, npc);
if(list == null || list.isEmpty())
return;
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SCROLL_LIST, list);
}
public static void sendOpenGuiNoDelay(final EntityPlayer player,
final EnumGuiType gui, final EntityNPCInterface npc, final int i, final int j, final int k) {
if(!(player instanceof EntityPlayerMP))
return;
setEditingNpc(player, npc);
sendExtraData(player, npc,gui, i, j, k);
if(CustomNpcs.proxy.getServerGuiElement(gui.ordinal(), player, player.worldObj, i, j, k) != null){
player.openGui(CustomNpcs.instance, gui.ordinal(), player.worldObj, i, j, k);
return;
}
else{
Server.sendDataChecked((EntityPlayerMP)player, EnumPacketClient.GUI, gui.ordinal(), i, j, k);
}
ArrayList<String> list = getScrollData(player, gui, npc);
if(list == null || list.isEmpty())
@@ -470,7 +499,7 @@ public class NoppesUtilServer {
if(pl != null){
playerdata.setNBT(new NBTTagCompound());
sendPlayerData(type, player, name);
playerdata.savePlayerDataOnFile();
playerdata.save();
return;
}
else {
@@ -483,27 +512,27 @@ public class NoppesUtilServer {
int questId = buffer.readInt();
data.activeQuests.remove(questId);
data.finishedQuests.remove(questId);
playerdata.savePlayerDataOnFile();
playerdata.save();
}
if(type == EnumPlayerData.Dialog){
PlayerDialogData data = playerdata.dialogData;
data.dialogsRead.remove(buffer.readInt());
playerdata.savePlayerDataOnFile();
playerdata.save();
}
if(type == EnumPlayerData.Transport){
PlayerTransportData data = playerdata.transportData;
data.transports.remove(buffer.readInt());
playerdata.savePlayerDataOnFile();
playerdata.save();
}
if(type == EnumPlayerData.Bank){
PlayerBankData data = playerdata.bankData;
data.banks.remove(buffer.readInt());
playerdata.savePlayerDataOnFile();
playerdata.save();
}
if(type == EnumPlayerData.Factions){
PlayerFactionData data = playerdata.factionData;
data.factionData.remove(buffer.readInt());
playerdata.savePlayerDataOnFile();
playerdata.save();
}
sendPlayerData(type, player, name);
}
@@ -799,35 +828,21 @@ public class NoppesUtilServer {
long minutes = seconds / 60;
long hours = minutes / 60;
long days = hours / 24;
long months = days / 30;
long years = months / 12;
months = months % 12;
days = days % 30;
hours = hours % 24;
minutes = minutes % 60;
seconds = seconds % 60;
seconds %= 60;
minutes %= 60;
hours %= 24;
StringBuilder sb = new StringBuilder();
if (years > 0) {
sb.append(years + " year(s) ");
}
if (months > 0) {
sb.append(months + " month(s) ");
}
if (days > 0) {
sb.append(days + " day(s) ");
sb.append(days).append(" day").append(days == 1 ? "" : "s").append(", ");
}
if (hours > 0) {
sb.append(hours + " hour(s) ");
sb.append(hours).append(" hour").append(hours == 1 ? "" : "s").append(", ");
}
if (minutes > 0) {
sb.append(minutes + " minute(s) ");
sb.append(minutes).append(" minute").append(minutes == 1 ? "" : "s").append(", ");
}
if (seconds > 0) {
sb.append(seconds + " second(s)");
}
sb.append(seconds).append(" second").append(seconds == 1 ? "" : "s");
return sb.toString();
}
}
@@ -88,7 +88,7 @@ public class PacketHandlerServer{
EventHooks.onCustomGuiClose((IPlayer) NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer)));
return;
} else if (type == EnumPacketServer.QuestLogToServer) {
updateQuestLogData(buffer, player);
NoppesUtilPlayer.updateQuestLogData(buffer, player);
return;
} else if(type == EnumPacketServer.DimensionsGet){
HashMap<String,Integer> map = new HashMap<String,Integer>();
@@ -157,51 +157,6 @@ public class PacketHandlerServer{
}
}
private Quest getQuestFromString(String string) {
if (string != null && string.contains(":")) {
String[] splitString = string.split(":");
if(splitString.length < 2){
return null;
}
String categoryName = splitString[0];
String questName = splitString[1];
for (QuestCategory category : QuestController.instance.categories.values()) {
if (category.title.equals(categoryName)) {
for (Quest quest : category.quests.values()) {
if (quest.title.equals(questName)) {
return quest;
}
}
}
}
}
return null;
}
private void updateQuestLogData(ByteBuf buffer, EntityPlayerMP player) throws IOException {
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
NBTTagCompound compound = Server.readNBT(buffer);
HashMap<String,String> questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10));
for (Map.Entry<String,String> entry : questAlerts.entrySet()) {
Quest quest = this.getQuestFromString(entry.getKey());
if (quest != null) {
playerData.questData.activeQuests.get(quest.id).sendAlerts = Boolean.parseBoolean(entry.getValue());
}
}
String trackedQuestString = Server.readString(buffer);
Quest trackedQuest = this.getQuestFromString(trackedQuestString);
if (trackedQuest != null) {
playerData.questData.trackedQuest = trackedQuest;
NoppesUtilPlayer.sendTrackedQuestData(player, trackedQuest);
}
playerData.questData.trackedQuest = null;
Server.sendData(player, EnumPacketClient.OVERLAY_QUEST_TRACKING);
}
private void isGuiOpenPacket(ByteBuf buffer, EntityPlayerMP player) throws IOException {
NoppesUtilServer.isGUIOpen(buffer, player);
}
@@ -272,7 +227,9 @@ public class PacketHandlerServer{
data.getScripts().add(new ScriptContainer(data));
}
NBTTagCompound tabCompound = Server.readNBT(buffer);
data.getScripts().get(tab).readFromNBT(tabCompound);
ScriptContainer script = new ScriptContainer(data);
script.readFromNBT(tabCompound);
data.getScripts().set(tab,script);
} else {
NBTTagCompound compound = Server.readNBT(buffer);
data.setLanguage(compound.getString("ScriptLanguage"));
@@ -284,6 +241,9 @@ public class PacketHandlerServer{
}
}
data.setEnabled(compound.getBoolean("ScriptEnabled"));
for (ScriptContainer container : data.getScripts()) {
container.setEngine(data.getLanguage());
}
}
}
@@ -334,6 +294,7 @@ public class PacketHandlerServer{
private void itemScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
if (type == EnumPacketServer.ScriptItemDataGet) {
ScriptCustomItem iw = (ScriptCustomItem) NpcAPI.Instance().getIItemStack(player.getHeldItem());
iw.loadScriptData();
NBTTagCompound compound = iw.getMCNbt();
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound});
@@ -345,7 +306,8 @@ public class PacketHandlerServer{
NBTTagCompound compound = Server.readNBT(buffer);
ScriptCustomItem wrapper = (ScriptCustomItem) NpcAPI.Instance().getIItemStack(player.getHeldItem());
wrapper.setMCNbt(compound);
wrapper.lastInited = -1L;
wrapper.loadScriptData();
wrapper.loaded = false;
wrapper.saveScriptData();
player.sendContainerToPlayer(player.inventoryContainer);
}
+2 -2
View File
@@ -57,8 +57,8 @@ public class QuestLogData {
if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(playerData))
finish.put(category + ":" + quest.title, quest.completerNpc);
if (playerData.questData.trackedQuest != null) {
if (quest.id == playerData.questData.trackedQuest.getId()) {
if (playerData.questData.getTrackedQuest() != null) {
if (quest.id == playerData.questData.getTrackedQuest().getId()) {
trackedQuestKey = category + ":" + quest.title;
}
}
@@ -58,7 +58,7 @@ public class ScriptItemEventHandler {
try {
if (event.entityItem.getEntityItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
IItemCustom isw = ItemScripted.GetWrapper(event.entityItem.getEntityItem());
EventHooks.onScriptItemTossed(isw, event.player, event.entityItem);
event.setCanceled(EventHooks.onScriptItemTossed(isw, event.player, event.entityItem));
}
} catch (Exception e) {}
}
@@ -26,15 +26,19 @@ import net.minecraftforge.event.entity.player.*;
import net.minecraftforge.event.world.BlockEvent;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.controllers.data.PlayerQuestData;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.item.ScriptCustomItem;
import static noppes.npcs.config.ConfigMain.TrackedQuestUpdateFrequency;
public class ScriptPlayerEventHandler {
public ScriptPlayerEventHandler() {
}
@@ -67,14 +71,22 @@ public class ScriptPlayerEventHandler {
playerData.timers.update();
}
if (playerData.questData.trackedQuest != null && !playerData.questData.activeQuests.containsKey(playerData.questData.trackedQuest.getId())) {
PlayerDataController.instance.getPlayerData(player).questData.trackedQuest = null;
Server.sendData((EntityPlayerMP) player, EnumPacketClient.OVERLAY_QUEST_TRACKING);
if (playerData.questData.getTrackedQuest() != null && !playerData.questData.activeQuests.containsKey(playerData.questData.getTrackedQuest().getId())) {
PlayerDataController.instance.getPlayerData(player).questData.untrackQuest();
}
if (player.ticksExisted%20 == 0 && !PlayerDataController.instance.getPlayerData(player).skinOverlays.overlayList.isEmpty()) {
if (player.ticksExisted % 20 == 0 && !PlayerDataController.instance.getPlayerData(player).skinOverlays.overlayList.isEmpty()) {
PlayerDataController.instance.getPlayerData(player).skinOverlays.updateClient();
}
if (player.ticksExisted % (TrackedQuestUpdateFrequency * 20) == 0) {
PlayerQuestData questData = playerData.questData;
if(questData != null){
if (questData.getTrackedQuest() != null && ((Quest) questData.getTrackedQuest()).type == EnumQuestType.Item) {
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player);
}
}
}
}
}
}
@@ -317,7 +329,7 @@ public class ScriptPlayerEventHandler {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem);
event.setCanceled(EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem));
}
}
@@ -464,9 +476,9 @@ public class ScriptPlayerEventHandler {
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerLogin(handler, scriptPlayer);
Quest quest = (Quest) PlayerDataController.instance.getPlayerData(event.player).questData.trackedQuest;
Quest quest = (Quest) PlayerDataController.instance.getPlayerData(event.player).questData.getTrackedQuest();
if (quest != null) {
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player, quest);
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player);
}
PlayerDataController.instance.getPlayerData(event.player).skinOverlays.updateClient();
+11 -6
View File
@@ -13,6 +13,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraft.village.MerchantRecipeList;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.util.CustomNPCsThreader;
import java.io.IOException;
import java.util.List;
@@ -20,19 +21,23 @@ import java.util.Map;
public class Server {
public static boolean sendData(EntityPlayerMP player, EnumPacketClient enu, Object... obs) {
ByteBuf buffer = Unpooled.buffer();
public static void sendData(final EntityPlayerMP player, final EnumPacketClient enu, final Object... obs) {
sendDataChecked(player, enu, obs);
}
public static boolean sendDataChecked(EntityPlayerMP player, EnumPacketClient type, Object... obs) {
PacketBuffer buffer = new PacketBuffer(Unpooled.buffer());
try {
if(!fillBuffer(buffer, enu, obs))
if(!fillBuffer(buffer, type, obs))
return false;
CustomNpcs.Channel.sendTo(new FMLProxyPacket(buffer, "CustomNPCs"), player);
} catch (IOException e) {
e.printStackTrace();
LogWriter.error(type + " Errored", e);
}
return true;
}
public static void sendAssociatedData(Entity entity, EnumPacketClient enu, Object... obs) {
public static void sendAssociatedData(final Entity entity, final EnumPacketClient enu, final Object... obs) {
ByteBuf buffer = Unpooled.buffer();
try {
if(!fillBuffer(buffer, enu, obs))
@@ -1,6 +1,7 @@
package noppes.npcs;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.block.Block;
@@ -20,6 +21,7 @@ import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector;
import net.minecraft.village.MerchantRecipeList;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
@@ -92,7 +94,7 @@ public class ServerEventsHandler {
return;
PlayerData data = PlayerDataController.instance.getPlayerData(event.entityPlayer);
ServerCloneController.Instance.cleanTags(compound);
if(!Server.sendData((EntityPlayerMP)event.entityPlayer, EnumPacketClient.CLONE, compound))
if(!Server.sendDataChecked((EntityPlayerMP)event.entityPlayer, EnumPacketClient.CLONE, compound))
event.entityPlayer.addChatMessage(new ChatComponentText("Entity too big to clone"));
data.cloned = compound;
if (event.target instanceof EntityNPCInterface) {
@@ -253,7 +255,7 @@ public class ServerEventsHandler {
doExcalibur((EntityPlayer) event.source.getEntity(),event.entityLiving);
}
if(event.source.getEntity() instanceof EntityNPCInterface && event.entityLiving != null){
if(event.source.getEntity() instanceof EntityNPCInterface){
EntityNPCInterface npc = (EntityNPCInterface) event.source.getEntity();
Line line = npc.advanced.getKillLine();
if(line != null)
@@ -276,7 +278,7 @@ public class ServerEventsHandler {
}
if(event.entityLiving instanceof EntityPlayer){
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer)event.entityLiving);
data.savePlayerDataOnFile();
data.save();
}
}
@@ -358,6 +360,12 @@ public class ServerEventsHandler {
questData.checkQuestCompletion(playerData, EnumQuestType.Item);
}
@SubscribeEvent
public void world(PlayerEvent.SaveToFile event){
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer) event.entity);
data.save();
}
@SubscribeEvent
public void world(EntityJoinWorldEvent event){
if(event.world.isRemote || !(event.entity instanceof EntityPlayer))
@@ -366,12 +374,6 @@ public class ServerEventsHandler {
data.updateCompanion(event.world);
}
@SubscribeEvent
public void world(PlayerEvent.SaveToFile event){
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer) event.entity);
data.savePlayerDataOnFile();
}
@SubscribeEvent
public void populateChunk(PopulateChunkEvent.Post event){
NPCSpawning.performWorldGenSpawning(event.world, event.chunkX, event.chunkZ, event.rand);
+1 -1
View File
@@ -23,7 +23,7 @@ public class Client {
public static HashMap<UUID, AnimationData> playerAnimations = new HashMap<>();
private static HashMap<String, ImageData> imageDataCache = new HashMap<>();
public static void sendData(EnumPacketServer enu, Object... obs) {
public static void sendData(final EnumPacketServer enu, final Object... obs) {
ByteBuf buffer = Unpooled.buffer();
try {
if(!Server.fillBuffer(buffer, enu, obs))
@@ -219,13 +219,12 @@ public class ClientProxy extends CommonProxy {
private GuiScreen getGui(EntityNPCInterface npc, EnumGuiType gui, Container container, int x, int y, int z) {
if (gui == EnumGuiType.MainMenuDisplay){
if(npc != null)
if (gui == EnumGuiType.MainMenuDisplay) {
if (npc != null)
return new GuiNpcDisplay(npc);
else
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Unable to find npc"));
}
else if (gui == EnumGuiType.MainMenuStats)
} else if (gui == EnumGuiType.MainMenuStats)
return new GuiNpcStats(npc);
else if (gui == EnumGuiType.MainMenuInv)
@@ -234,10 +233,10 @@ public class ClientProxy extends CommonProxy {
else if (gui == EnumGuiType.MainMenuAdvanced)
return new GuiNpcAdvanced(npc);
else if(gui == EnumGuiType.QuestReward)
else if (gui == EnumGuiType.QuestReward)
return new GuiNpcQuestReward(npc, (ContainerNpcQuestReward) container);
else if(gui == EnumGuiType.QuestItem)
else if (gui == EnumGuiType.QuestItem)
return new GuiNpcQuestTypeItem(npc, (ContainerNpcQuestTypeItem) container);
else if (gui == EnumGuiType.MovingPath)
@@ -261,16 +260,14 @@ public class ClientProxy extends CommonProxy {
animNpc.display.texture = "customnpcs:textures/entity/humanmale/AnimationBody.png";
}
return new GuiNPCManageAnimations(animNpc);
}
else if (gui == EnumGuiType.ManageLinked)
} else if (gui == EnumGuiType.ManageLinked)
return new GuiNPCManageLinkedNpc(npc);
else if (gui == EnumGuiType.ManageTransport)
return new GuiNPCManageTransporters(npc);
else if (gui == EnumGuiType.ManageRecipes)
return new GuiNpcManageRecipes(npc,(ContainerManageRecipes) container);
return new GuiNpcManageRecipes(npc, (ContainerManageRecipes) container);
else if (gui == EnumGuiType.ManageDialogs)
return new GuiNPCManageDialogs(npc);
@@ -278,8 +275,8 @@ public class ClientProxy extends CommonProxy {
else if (gui == EnumGuiType.ManageQuests)
return new GuiNPCManageQuest(npc);
else if(gui == EnumGuiType.ManageBanks)
return new GuiNPCManageBanks(npc,(ContainerManageBanks) container);
else if (gui == EnumGuiType.ManageBanks)
return new GuiNPCManageBanks(npc, (ContainerManageBanks) container);
else if (gui == EnumGuiType.MainMenuGlobal)
return new GuiNPCGlobalMainMenu(npc);
@@ -293,56 +290,56 @@ public class ClientProxy extends CommonProxy {
else if (gui == EnumGuiType.PlayerFollower)
return new GuiNpcFollower(npc, (ContainerNPCFollower) container);
else if(gui == EnumGuiType.PlayerTrader)
else if (gui == EnumGuiType.PlayerTrader)
return new GuiNPCTrader(npc, (ContainerNPCTrader) container);
else if(gui == EnumGuiType.PlayerBankSmall || gui == EnumGuiType.PlayerBankUnlock || gui == EnumGuiType.PlayerBankUprade || gui == EnumGuiType.PlayerBankLarge)
else if (gui == EnumGuiType.PlayerBankSmall || gui == EnumGuiType.PlayerBankUnlock || gui == EnumGuiType.PlayerBankUprade || gui == EnumGuiType.PlayerBankLarge)
return new GuiNPCBankChest(npc, (ContainerNPCBankInterface) container);
else if(gui == EnumGuiType.PlayerTransporter)
else if (gui == EnumGuiType.PlayerTransporter)
return new GuiTransportSelection(npc);
else if(gui == EnumGuiType.Script && ConfigScript.ScriptingEnabled)
else if (gui == EnumGuiType.Script && ConfigScript.ScriptingEnabled)
return new GuiScript(npc);
else if (gui == EnumGuiType.ScriptItem)
return new GuiScriptItem();
else if(gui == EnumGuiType.PlayerAnvil)
else if (gui == EnumGuiType.PlayerAnvil)
return new GuiNpcCarpentryBench((ContainerCarpentryBench) container);
else if (gui == EnumGuiType.SetupFollower)
return new GuiNpcFollowerSetup(npc, (ContainerNPCFollowerSetup) container);
return new GuiNpcFollowerSetup(npc, (ContainerNPCFollowerSetup) container);
else if (gui == EnumGuiType.SetupItemGiver)
return new GuiNpcItemGiver(npc, (ContainerNpcItemGiver) container);
else if(gui == EnumGuiType.SetupTrader)
else if (gui == EnumGuiType.SetupTrader)
return new GuiNpcTraderSetup(npc, (ContainerNPCTraderSetup) container);
else if(gui == EnumGuiType.SetupTransporter)
else if (gui == EnumGuiType.SetupTransporter)
return new GuiNpcTransporter(npc);
else if(gui == EnumGuiType.SetupBank)
else if (gui == EnumGuiType.SetupBank)
return new GuiNpcBankSetup(npc);
else if(gui == EnumGuiType.NpcRemote && Minecraft.getMinecraft().currentScreen == null)
else if (gui == EnumGuiType.NpcRemote && Minecraft.getMinecraft().currentScreen == null)
return new GuiNpcRemoteEditor();
else if(gui == EnumGuiType.ScriptEvent && Minecraft.getMinecraft().currentScreen == null)
else if (gui == EnumGuiType.ScriptEvent && Minecraft.getMinecraft().currentScreen == null)
return new GuiScriptGlobal();
else if(gui == EnumGuiType.PlayerMailman)
else if (gui == EnumGuiType.PlayerMailman)
return new GuiMailmanWrite((ContainerMail) container, x == 1, y == 1);
else if(gui == EnumGuiType.PlayerMailbox)
else if (gui == EnumGuiType.PlayerMailbox)
return new GuiMailbox();
else if(gui == EnumGuiType.MerchantAdd)
else if (gui == EnumGuiType.MerchantAdd)
return new GuiMerchantAdd();
else if(gui == EnumGuiType.Crate)
return new GuiCrate((ContainerCrate)container);
else if (gui == EnumGuiType.Crate)
return new GuiCrate((ContainerCrate) container);
else if(gui == EnumGuiType.NpcDimensions)
return new GuiNpcDimension();
@@ -42,6 +42,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
private int posX,posY,posZ;
private List<String> list;
private List<String> rawList;
private List<String> tagList;
private static int showingClones = 0;
@@ -181,6 +182,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
}
}
this.list = list;
this.rawList = new ArrayList<String>(this.list);
scroll.setList(getSearchList(), ascending == 0, sortType == 0);
}
private void showClones() {
@@ -198,6 +200,26 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
}
this.tagMap = ClientTagMapController.Instance.getTagMap(activeTab);
this.rawList = new ArrayList<String>(this.list);
if(this.tagMap != null){
if(GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1){
for(int i = 0; i < this.list.size(); i++){
StringBuilder npcName = new StringBuilder(list.get(i));
if (this.tagMap.hasClone(list.get(i))) {
for (UUID tagUUID : this.tagMap.getUUIDsList(list.get(i))){
Tag tag = tags.get(tagUUID);
if(tag != null){
if(GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()){
npcName.append(" [" + tag.name + "]");
}
}
}
}
this.rawList.set(i, npcName.toString());
}
}
}
scroll.setList(getSearchList(), ascending == 0, sortType == 0);
}
public void keyTyped(char c, int i)
@@ -222,6 +244,9 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
if(this.list == null){
this.list = new ArrayList<String>();
}
if(this.rawList == null){
this.rawList = new ArrayList<String>();
}
// No Filters - or - Entities
if(tagFilters.size() == 0 || showingClones == 1){
@@ -231,9 +256,10 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
// Yes Search
else {
List<String> list = new ArrayList<String>();
for(String name : this.list){
if(name.toLowerCase().contains(search))
list.add(name);
for(int i = 0; i < this.list.size(); i++){
if(this.rawList.get(i).toLowerCase().contains(search)){
list.add(this.list.get(i));
}
}
return list;
}
@@ -257,14 +283,16 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
// Yes Search
List<String> list = new ArrayList<String>();
for(String name : this.list){
if(name.toLowerCase().contains(search)) {
if(tagMap.hasClone(name)){
if(meetsCondition(name)){
list.add(name);
for(int i = 0; i < this.list.size(); i++){
if(this.rawList.get(i).toLowerCase().contains(search)){
String npcName = this.list.get(i);
if(tagMap.hasClone(npcName)){
if(meetsCondition(npcName)){
list.add(npcName);
}
}
}
}
return list;
}
@@ -481,6 +509,27 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
}
this.list = list;
this.rawList = new ArrayList<String>(this.list);
if(this.tagMap != null){
if(GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1){
for(int i = 0; i < this.list.size(); i++){
StringBuilder npcName = new StringBuilder(list.get(i));
if (this.tagMap.hasClone(list.get(i))) {
for (UUID tagUUID : this.tagMap.getUUIDsList(list.get(i))){
Tag tag = tags.get(tagUUID);
if(tag != null){
if(GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()){
npcName.append(" [" + tag.name + "]");
}
}
}
}
this.rawList.set(i, npcName.toString());
}
}
}
scroll.setList(getSearchList(), ascending == 0, sortType == 0);
}
}
@@ -172,6 +172,10 @@ public class GuiNpcMobSpawnerAdd extends GuiNPCInterface implements GuiYesNoCall
@Override
public void subGuiClosed(SubGuiInterface subgui) {
if(subgui instanceof SubGuiClonerNPCTags){
close();
return;
}
initGui();
}
@@ -78,7 +78,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
hooks.selected = activeTab;
addScroll(hooks);
ScriptContainer container = script.scripts.get(activeTab);
ScriptContainer container = script.getNPCScript(activeTab);
addTextField(new GuiNpcTextArea(2, this, guiLeft + 74, guiTop + 4, 239, 208, container == null?"":container.script));
@@ -185,11 +185,11 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
getTextField(2).setText("");
if(!showScript){
if(activeConsole == 0){
for(ScriptContainer container : script.scripts)
for(ScriptContainer container : script.getNPCScripts())
container.console.clear();
}
else{
ScriptContainer container = script.scripts.get(activeConsole - 1);
ScriptContainer container = script.getNPCScript(activeConsole - 1);
if(container != null)
container.console.clear();
}
@@ -209,13 +209,13 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
NoppesUtil.openFolder(ScriptController.Instance.dir);
}
if (guibutton.id == 107) {
ScriptContainer container = script.scripts.get(activeTab);
ScriptContainer container = script.getNPCScript(activeTab);
if(container == null)
script.scripts.set(activeTab, container = new ScriptContainer(this.script));
script.setNPCScript(activeTab, container = new ScriptContainer(this.script));
setSubGui(new GuiScriptList(languages.get(script.scriptLanguage), container));
}
if (guibutton.id == 108) {
ScriptContainer container = script.scripts.get(activeTab);
ScriptContainer container = script.getNPCScript(activeTab);
if(container != null){
setScript();
this.AWTWindow = new GuiJTextArea(container.script).setListener(this);
@@ -225,9 +225,9 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
private void setScript(){
if(showScript){
ScriptContainer container = script.scripts.get(activeTab);
ScriptContainer container = script.getNPCScript(activeTab);
if(container == null)
script.scripts.set(activeTab, container = new ScriptContainer(this.script));
script.setNPCScript(activeTab, container = new ScriptContainer(this.script));
String text = getTextField(2).getText();
text = text.replace("\r\n", "\n");
text = text.replace("\r", "\n");
@@ -270,7 +270,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
@Override
public void saveText(String text) {
ScriptContainer container = script.scripts.get(activeTab);
ScriptContainer container = script.getNPCScript(activeTab);
if(container != null)
container.script = text;
initGui();
@@ -30,8 +30,8 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc
setBackground("menubg.png");
xSize = 305;
ySize = 220;
closeOnEsc = false;
this.npc = npc;
closeOnEsc = false;
}
public void initGui()
@@ -86,6 +86,7 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc
tagNames.clear();
}
if (guibutton.id == 66) {
save();
close();
}
initGui();
@@ -154,11 +155,4 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc
}
return list;
}
@Override
public void close() {
save();
super.close();
}
}
@@ -1,14 +1,9 @@
package noppes.npcs.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.Client;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.data.Tag;
import noppes.npcs.controllers.data.TagMap;
import org.lwjgl.Sys;
import java.util.*;
@@ -16,6 +11,7 @@ public class SubGuiClonerQuickTags extends SubGuiInterface implements IScrollDat
{
public GuiNpcMobSpawnerAdd parent;
public GuiCustomScroll quickScroll = new GuiCustomScroll(this,0);
public GuiCustomScroll selectedScroll = new GuiCustomScroll(this,5);
private static String quickSearch = "";
public SubGuiClonerQuickTags(GuiNpcMobSpawnerAdd par){
@@ -36,35 +32,60 @@ public class SubGuiClonerQuickTags extends SubGuiInterface implements IScrollDat
quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags);
this.addScroll(quickScroll);
addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("cloner.wandtags"), guiLeft + 7, guiTop + 7));
addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("cloner.wandTags"), guiLeft + 7, guiTop + 7));
addScroll(quickScroll);
addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 4, guiTop + 190, 140, 20, quickSearch));
addButton(new GuiNpcButton(10, guiLeft + 150, guiTop + 20, 120, 20, "gui.selectAll"));
addButton(new GuiNpcButton(11, guiLeft + 150, guiTop + 43, 120, 20, "gui.deselectAll"));
addButton(new GuiNpcButton(66, guiLeft + 240, guiTop + 175, 60, 20, "gui.done"));
selectedScroll.clear();
selectedScroll.setSize(145, 103);
selectedScroll.guiLeft = guiLeft + 150;
selectedScroll.guiTop = guiTop + 82;
selectedScroll.setUnselectable();
this.addScroll(selectedScroll);
getSelected();
addLabel(new GuiNpcLabel(3, StatCollector.translateToLocal("tags.selectedTags"), guiLeft + 153, guiTop + 68));
addScroll(selectedScroll);
addButton(new GuiNpcButton(66, guiLeft + 240, guiTop + 190, 60, 20, "gui.done"));
setSelected();
refreshSelected();
}
protected void actionPerformed(GuiButton guibutton){
if (guibutton.id == 10) {
GuiNpcMobSpawnerAdd.addTags = new HashSet<>(parent.allTags);
quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags);
refreshSelected();
}
if (guibutton.id == 11) {
GuiNpcMobSpawnerAdd.addTags = new HashSet<>();
quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags);
refreshSelected();
}
if (guibutton.id == 66) {
close();
}
}
public void getSelected(){
@Override
public void mouseClicked(int i, int j, int k)
{
super.mouseClicked(i, j, k);
refreshSelected();
}
public void setSelected(){
quickScroll.setList(getQuickTags());
}
public void refreshSelected(){
List<String> sortedList = new ArrayList<>(new TreeSet<>(GuiNpcMobSpawnerAdd.addTags));
selectedScroll.setList(sortedList);
}
@Override
public void keyTyped(char c, int i)
{
@@ -9,26 +9,19 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.IResource;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.api.gui.ICustomGuiComponent;
import noppes.npcs.client.ImageDownloadAlt;
import noppes.npcs.client.Client;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IClickListener;
import noppes.npcs.client.renderer.ImageBufferDownloadAlt;
import noppes.npcs.client.renderer.customitem.ImageData;
import noppes.npcs.scripted.gui.ScriptGuiButton;
import org.lwjgl.opengl.GL11;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
public class CustomGuiButton extends GuiButton implements IClickListener {
GuiCustom parent;
ResourceLocation location = null;
ImageData imageData = null;
String texture;
public int textureX;
public int textureY;
boolean field_146123_n;
@@ -39,11 +32,6 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
float alpha;
float scale = 1.0F;
private int totalWidth, totalHeight;
private ImageDownloadAlt imageDownloadAlt = null;
private boolean isUrl = false;
private boolean gotWidthHeight = false;
public CustomGuiButton(int id, String buttonText, int x, int y) {
super(id, x, y, buttonText);
}
@@ -58,24 +46,12 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
public CustomGuiButton(int buttonId, String buttonText, int x, int y, int width, int height, String texture, int textureX, int textureY) {
this(buttonId, buttonText, x, y, width, height);
this.texture = texture;
this.textureX = textureX;
this.textureY = textureY;
this.label = buttonText;
if (texture != null && !texture.isEmpty()) {
this.location = new ResourceLocation(texture);
if(texture.startsWith("https://")){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(null, texture, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false));
texturemanager.loadTexture(this.location, object);
} else {
try {
this.getWidthHeight();
} catch (IOException e) {
e.printStackTrace();
}
}
} else {
this.location = null;
this.imageData = Client.getImageData(texture);
}
}
@@ -115,42 +91,36 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
this.field_146123_n = mouseX >= this.xPosition + GuiCustom.guiLeft && mouseY >= this.yPosition + GuiCustom.guiTop && mouseX < this.xPosition + GuiCustom.guiLeft + this.width * this.scale && mouseY < this.yPosition + GuiCustom.guiTop + this.height * this.scale;
if (this.location == null) {
totalWidth = totalHeight = 256;
textureX = textureY = 0;
}
float u1 = (float)textureX/(float)totalWidth;
float u2 = u1 + (float)width/(float)totalWidth;
float v1 = (float)textureY/(float)totalHeight;
float v2 = v1 + (float)height/(float)totalHeight;
if (this.location != null && this.enabled) {
if (this.field_146123_n) {
v1 = (float)(textureY + 2 * this.height)/(float)totalHeight;
} else {
v1 = (float)(textureY + this.height)/(float)totalHeight;
}
v2 = v1 + (float)height/(float)totalHeight;
}
if(imageDownloadAlt != null && isUrl && !gotWidthHeight){
getURLWidthHeight();
}
FontRenderer fontRenderer = mc.fontRenderer;
GL11.glPushMatrix();
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha);
GL11.glTranslatef(GuiCustom.guiLeft + this.xPosition - u1 * totalWidth * this.scale, GuiCustom.guiTop + this.yPosition - v1 * totalHeight * this.scale,(float)this.id);
GL11.glScalef(this.scale,this.scale,1.0F);
if (this.imageData != null && this.imageData.imageLoaded()) {
int totalWidth = this.imageData.getTotalWidth();
int totalHeight = this.imageData.getTotalHeight();
if (this.location != null) {
mc.getTextureManager().bindTexture(this.location);
float u1 = (float)textureX/(float)totalWidth;
float u2 = u1 + (float)width/(float)totalWidth;
float v1 = (float)textureY/(float)totalHeight;
float v2 = v1 + (float)height/(float)totalHeight;
if (this.enabled) {
if (this.field_146123_n) {
v1 = (float)(textureY + 2 * this.height)/(float)totalHeight;
} else {
v1 = (float)(textureY + this.height)/(float)totalHeight;
}
v2 = v1 + (float)height/(float)totalHeight;
}
GL11.glPushMatrix();
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha);
GL11.glTranslatef(GuiCustom.guiLeft + this.xPosition - u1 * totalWidth * this.scale, GuiCustom.guiTop + this.yPosition - v1 * totalHeight * this.scale,(float)this.id);
GL11.glScalef(this.scale,this.scale,1.0F);
this.imageData.bindTexture();
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
@@ -163,7 +133,9 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
tessellator.draw();
GL11.glTranslated(0.0D, 0.0D, 0.1D);
this.drawCenteredString(fontRenderer, this.label, this.width / 2, (this.height - 8) / 2, this.color);
} else {
GL11.glPopMatrix();
} else {
GL11.glPushMatrix();
mc.getTextureManager().bindTexture(buttonTextures);
int i = this.getHoverState(this.field_146123_n);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
@@ -179,9 +151,9 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
j = 16777120;
}
GL11.glTranslated(0.0D, 0.0D, 0.1D);
this.drawCenteredString(fontRenderer, this.displayString, this.width / 2, (this.height-8)/2, j);
}
GL11.glPopMatrix();
this.drawCenteredString(fontRenderer, this.displayString, this.width / 2, (this.height - 8) / 2, j);
GL11.glPopMatrix();
}
if (this.field_146123_n && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
@@ -189,7 +161,7 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
}
public ICustomGuiComponent toComponent() {
ScriptGuiButton component = new ScriptGuiButton(this.id, this.label, this.xPosition, this.yPosition, this.width, this.height, this.location.toString(), this.textureX, this.textureY);
ScriptGuiButton component = new ScriptGuiButton(this.id, this.label, this.xPosition, this.yPosition, this.width, this.height, this.texture, this.textureX, this.textureY);
component.setHoverText(this.hoverText);
component.setColor(this.color);
component.setAlpha(this.alpha);
@@ -204,40 +176,4 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
return false;
}
}
public void getWidthHeight() throws IOException {
InputStream inputstream = null;
try {
IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(this.location);
inputstream = iresource.getInputStream();
BufferedImage bufferedimage = ImageIO.read(inputstream);
gotWidthHeight = true;
this.totalWidth = bufferedimage.getWidth();
this.totalHeight = bufferedimage.getHeight();
correctWidthHeight();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (inputstream != null) {
inputstream.close();
}
}
}
public void getURLWidthHeight(){
if(imageDownloadAlt.getBufferedImage() != null) {
gotWidthHeight = true;
this.totalWidth = imageDownloadAlt.getBufferedImage().getWidth();
this.totalHeight = imageDownloadAlt.getBufferedImage().getHeight();
correctWidthHeight();
}
}
public void correctWidthHeight(){
totalWidth = Math.max(totalWidth, 1);
totalHeight = Math.max(totalHeight, 1);
this.width = width < 0 ? totalWidth : width;
this.height = height < 0 ? totalHeight : height;
}
}
@@ -8,25 +8,19 @@ package noppes.npcs.client.gui.custom.components;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.IResource;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.api.gui.ICustomGuiComponent;
import noppes.npcs.client.ImageDownloadAlt;
import noppes.npcs.client.Client;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
import noppes.npcs.client.renderer.ImageBufferDownloadAlt;
import noppes.npcs.client.renderer.customitem.ImageData;
import noppes.npcs.scripted.gui.ScriptGuiTexturedRect;
import org.lwjgl.opengl.GL11;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
GuiCustom parent;
ResourceLocation location;
ImageData imageData = null;
String texture;
int id;
int x;
int y;
@@ -41,11 +35,6 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
float alpha;
float rotation;
private int totalWidth, totalHeight;
private ImageDownloadAlt imageDownloadAlt = null;
private boolean isUrl = false;
private boolean gotWidthHeight = false;
public CustomGuiTexturedRect(int id, String texture, int x, int y, int width, int height) {
this(id, texture, x, y, width, height, 0, 0);
}
@@ -53,25 +42,15 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
public CustomGuiTexturedRect(int id, String directory, int x, int y, int width, int height, int textureX, int textureY) {
this.scale = 1.0F;
this.id = id;
this.location = new ResourceLocation(directory);
this.texture = directory;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.textureX = textureX;
this.textureY = textureY;
if(directory.startsWith("https://")){
this.isUrl = true;
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
this.imageDownloadAlt = new ImageDownloadAlt(null, directory, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false));
texturemanager.loadTexture(this.location, this.imageDownloadAlt);
} else {
try {
this.getWidthHeight();
} catch (IOException e) {
e.printStackTrace();
}
if (texture != null && !texture.isEmpty()) {
this.imageData = Client.getImageData(texture);
}
}
@@ -85,37 +64,38 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
boolean hovered = mouseX >= this.x + GuiCustom.guiLeft && mouseY >= this.y + GuiCustom.guiTop && mouseX < this.x + GuiCustom.guiLeft + this.width && mouseY < this.y + GuiCustom.guiTop + this.height;
mc.getTextureManager().bindTexture(this.location);
float u1 = (float)textureX/(float)totalWidth;
float u2 = u1 + (float)width/(float)totalWidth;
float v1 = (float)textureY/(float)totalHeight;
float v2 = v1 + (float)height/(float)totalHeight;
if (this.imageData != null && this.imageData.imageLoaded()) {
int totalWidth = this.imageData.getTotalWidth();
int totalHeight = this.imageData.getTotalHeight();
if(imageDownloadAlt != null && isUrl && !gotWidthHeight){
getURLWidthHeight();
}
float u1 = (float) textureX / (float) totalWidth;
float u2 = u1 + (float) width / (float) totalWidth;
float v1 = (float) textureY / (float) totalHeight;
float v2 = v1 + (float) height / (float) totalHeight;
GL11.glPushMatrix();
GL11.glPushMatrix();
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha);
GL11.glColor4f(red, green, blue, this.alpha);
GL11.glTranslatef(GuiCustom.guiLeft + this.x - u1 * totalWidth, GuiCustom.guiTop + this.y - v1 * totalHeight,(float)this.id);
GL11.glRotatef(this.rotation,0.0F,0.0F,1.0F);
GL11.glTranslatef(GuiCustom.guiLeft + this.x - u1 * totalWidth, GuiCustom.guiTop + this.y - v1 * totalHeight, (float) this.id);
GL11.glRotatef(this.rotation, 0.0F, 0.0F, 1.0F);
GL11.glScalef(this.scale, this.scale, this.scale);
this.imageData.bindTexture();
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorOpaque_F(1, 1, 1);
tessellator.setColorRGBA_F(red, green, blue, alpha);
tessellator.addVertexWithUV( u2 * totalWidth, v2 * totalHeight, 0, u2, v2);
tessellator.addVertexWithUV( u2 * totalWidth, v1 * totalHeight, 0, u2, v1);
tessellator.addVertexWithUV( u1 * totalWidth, v1 * totalHeight, 0, u1, v1);
tessellator.addVertexWithUV( u1 * totalWidth, v2 * totalHeight, 0, u1, v2);
tessellator.addVertexWithUV(u2 * totalWidth, v2 * totalHeight, 0, u2, v2);
tessellator.addVertexWithUV(u2 * totalWidth, v1 * totalHeight, 0, u2, v1);
tessellator.addVertexWithUV(u1 * totalWidth, v1 * totalHeight, 0, u1, v1);
tessellator.addVertexWithUV(u1 * totalWidth, v2 * totalHeight, 0, u1, v2);
tessellator.draw();
GL11.glPopMatrix();
GL11.glPopMatrix();
}
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
@@ -123,7 +103,7 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
}
public ICustomGuiComponent toComponent() {
ScriptGuiTexturedRect component = new ScriptGuiTexturedRect(this.id, this.location.toString(), this.x, this.y, this.width, this.height, this.textureX, this.textureY);
ScriptGuiTexturedRect component = new ScriptGuiTexturedRect(this.id, this.texture, this.x, this.y, this.width, this.height, this.textureX, this.textureY);
component.setHoverText(this.hoverText);
component.setScale(this.scale);
component.setColor(color);
@@ -151,40 +131,4 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
return rect;
}
public void getWidthHeight() throws IOException {
InputStream inputstream = null;
try {
IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(this.location);
inputstream = iresource.getInputStream();
BufferedImage bufferedimage = ImageIO.read(inputstream);
gotWidthHeight = true;
this.totalWidth = bufferedimage.getWidth();
this.totalHeight = bufferedimage.getHeight();
correctWidthHeight();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (inputstream != null) {
inputstream.close();
}
}
}
public void getURLWidthHeight(){
if(imageDownloadAlt.getBufferedImage() != null) {
gotWidthHeight = true;
this.totalWidth = imageDownloadAlt.getBufferedImage().getWidth();
this.totalHeight = imageDownloadAlt.getBufferedImage().getHeight();
correctWidthHeight();
}
}
public void correctWidthHeight(){
totalWidth = Math.max(totalWidth, 1);
totalHeight = Math.max(totalHeight, 1);
this.width = width < 0 ? totalWidth : width;
this.height = height < 0 ? totalHeight : height;
}
}
@@ -10,7 +10,9 @@ import noppes.npcs.containers.ContainerManageBanks;
import noppes.npcs.controllers.data.Bank;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;
public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData
@@ -20,6 +22,7 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
private ContainerManageBanks container;
private Bank bank = new Bank();
private String selected = null;
private String search = "";
public GuiNPCManageBanks(EntityNPCInterface npc,ContainerManageBanks container)
{
@@ -61,6 +64,8 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+10, guiTop + 110, 16, 16, ""));
getTextField(2).integersOnly = true;
getTextField(2).setMaxStringLength(1);
addTextField(new GuiNpcTextField(33, this, fontRendererObj, guiLeft + 174, guiTop + 8 + 3 + 180, 160, 20, search));
}
public void drawScreen(int x, int y, float f)
@@ -137,12 +142,37 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
}
setSelected(bank.name);
}
public void keyTyped(char c, int i)
{
super.keyTyped(c, i);
if(getTextField(33) != null){
if(getTextField(33).isFocused()){
if(search.equals(getTextField(33).getText()))
return;
search = getTextField(33).getText().toLowerCase();
scroll.setList(getSearchList());
}
}
}
private List<String> getSearchList(){
if(search.isEmpty()){
return new ArrayList<String>(this.data.keySet());
}
List<String> list = new ArrayList<String>();
for(String name : this.data.keySet()){
if(name.toLowerCase().contains(search))
list.add(name);
}
return list;
}
@Override
public void setData(Vector<String> list, HashMap<String, Integer> data) {
String name = scroll.getSelected();
this.data = data;
scroll.setList(list);
scroll.setList(getSearchList());
if(name != null)
scroll.setSelected(name);
@@ -20,10 +20,7 @@ import org.lwjgl.opengl.GL11;
import tconstruct.client.tabs.InventoryTabQuests;
import tconstruct.client.tabs.TabRegistry;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.*;
public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,ICustomScrollListener, IGuiData{
@@ -36,6 +33,9 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
private boolean noQuests = false;
private boolean questDetails = true;
private HashMap<String,String> questAlertsOnOpen;
private String trackedQuestKeyOnOpen;
private Minecraft mc = Minecraft.getMinecraft();
public GuiQuestLog(EntityPlayer player) {
@@ -245,6 +245,8 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
QuestLogData data = new QuestLogData();
data.readNBT(compound);
this.data = data;
this.questAlertsOnOpen = new HashMap<>(data.questAlerts);
this.trackedQuestKeyOnOpen = data.trackedQuestKey;
initGui();
}
@@ -256,7 +258,9 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
@Override
public void save() {
if (this.data != null) {
if (this.data != null &&
(!Objects.equals(this.questAlertsOnOpen, data.questAlerts) ||
!Objects.equals(this.trackedQuestKeyOnOpen, data.trackedQuestKey))) {
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("Alerts", NBTTags.nbtStringStringMap(data.questAlerts));
Client.sendData(EnumPacketServer.QuestLogToServer, compound, this.data.trackedQuestKey);
@@ -72,7 +72,15 @@ public class GuiRecipes extends GuiNPCInterface
}
List<IRecipe> list = new ArrayList<IRecipe>();
for(IRecipe recipe : RecipeController.instance.anvilRecipes.values()){
// System.out.println(recipe.getRecipeOutput().getDisplayName());
if(recipe.getRecipeOutput() == null)
continue;
if(recipe.getRecipeOutput().getDisplayName() == null)
continue;
if(recipe.getRecipeOutput().getDisplayName().trim().equals(""))
continue;
if(recipe.getRecipeOutput().getDisplayName().toLowerCase().contains(search.toLowerCase()))
list.add(recipe);
}
@@ -29,6 +29,7 @@ public class GuiScriptItem extends GuiScriptInterface {
public void setGuiData(NBTTagCompound compound) {
this.item.setMCNbt(compound);
this.item.loadScriptData();
super.setGuiData(compound);
}
@@ -56,7 +56,7 @@ public class GuiCustomScrollCloner extends GuiCustomScroll {
}
if((this.parent.getShowingClones() == 0 || this.parent.getShowingClones() == 2) && this.parent.tagMap != null){
int tagStartX = j + fontRendererObj.getStringWidth(displayString) + 5;
int tagStartX = j + fontRendererObj.getStringWidth(displayString) + 3;
if(GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1){
if (this.parent.tagMap.hasClone(list.get(i))) {
for (UUID tagUUID : this.parent.tagMap.getUUIDsList(list.get(i))){
@@ -64,7 +64,7 @@ public class GuiCustomScrollCloner extends GuiCustomScroll {
if(tag != null){
if(GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()){
fontRendererObj.drawString("[" + tag.name + "]", tagStartX, k, tag.color);
tagStartX += fontRendererObj.getStringWidth("[" + tag.name + "]") + 2;
tagStartX += fontRendererObj.getStringWidth("[" + tag.name + "]") + 3;
}
}
}
@@ -49,15 +49,10 @@ public class CustomItemRenderer implements IItemRenderer {
public void renderItem(ItemRenderType type, ItemStack itemStack, Object... data) {
ScriptCustomItem scriptCustomItem = ItemScripted.GetWrapper(itemStack);
BufferedImage bufferedImage = Client.getImageData(scriptCustomItem.texture).getBufferedImage();
if (bufferedImage != null && (scriptCustomItem.width != bufferedImage.getWidth() || scriptCustomItem.height != bufferedImage.getHeight())) {
scriptCustomItem.width = bufferedImage.getWidth();
scriptCustomItem.height = bufferedImage.getHeight();
scriptCustomItem.saveItemData();
}
if(scriptCustomItem.width < 1 || scriptCustomItem.height < 1)
ImageData imageData = Client.getImageData(scriptCustomItem.texture);
if (!imageData.imageLoaded()) {
return;
}
if (type == ItemRenderType.INVENTORY) {
GL11.glPushMatrix();
@@ -80,7 +75,6 @@ public class CustomItemRenderer implements IItemRenderer {
GL11.glRotatef(scriptCustomItem.rotationYRate * entityRenderTicks%360, 0, 1, 0);
GL11.glRotatef(scriptCustomItem.rotationZRate * entityRenderTicks%360, 0, 0, 1);
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
GL11.glTranslatef(0.0F, bobbingY, 0.0F);
int color = scriptCustomItem.getColor();
@@ -184,6 +178,7 @@ public class CustomItemRenderer implements IItemRenderer {
b0 = 4;
}
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
GL11.glTranslatef(-f7, -f8, -((f9 + f10) * (float)b0 / 2.0F));
for (int k = 0; k < b0; ++k)
@@ -253,6 +248,7 @@ public class CustomItemRenderer implements IItemRenderer {
for (int l = 0; l < b0; ++l)
{
GL11.glPushMatrix();
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
if (l > 0)
{
@@ -13,12 +13,13 @@ import java.io.IOException;
import java.io.InputStream;
public class ImageData {
private ResourceLocation location;
private final ResourceLocation location;
private final boolean isUrl;
private ImageDownloadAlt imageDownloadAlt = null;
private BufferedImage bufferedImage = null;
private int totalWidth, totalHeight;
private int totalWidth, totalHeight;
private boolean gotWidthHeight;
private boolean invalid;
@@ -28,14 +29,23 @@ public class ImageData {
this.isUrl = true;
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
this.imageDownloadAlt = new ImageDownloadAlt(null, directory, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true, false));
texturemanager.loadTexture(location, this.imageDownloadAlt);
texturemanager.loadTexture(this.location, this.imageDownloadAlt);
} else {
this.isUrl = false;
}
}
public boolean invalidTexture() {
return this.invalid;
public boolean imageLoaded() {
if (!this.gotWidthHeight) {
try {
if (!this.isUrl) {
this.getWidthHeight();
} else {
this.getURLWidthHeight();
}
} catch (Exception ignored) {}
}
return !this.invalid && this.location != null && this.gotWidthHeight;
}
public void bindTexture() {
@@ -49,7 +59,7 @@ public class ImageData {
}
}
public ResourceLocation getLocation() {
private ResourceLocation getLocation() {
return this.isUrl && this.imageDownloadAlt.getBufferedImage() == null ? null : this.location;
}
@@ -69,6 +79,10 @@ public class ImageData {
}
private void getWidthHeight() throws IOException {
if (this.invalid) {
return;
}
InputStream inputstream = null;
try {
@@ -80,7 +94,7 @@ public class ImageData {
this.totalHeight = bufferedimage.getHeight();
correctWidthHeight();
} catch (Exception e) {
e.printStackTrace();
this.invalid = true;
} finally {
if (inputstream != null) {
inputstream.close();
@@ -89,7 +103,7 @@ public class ImageData {
}
private void getURLWidthHeight(){
if(this.imageDownloadAlt.getBufferedImage() != null) {
if(this.imageDownloadAlt.getBufferedImage() != null && !this.invalid) {
this.gotWidthHeight = true;
this.totalWidth = this.imageDownloadAlt.getBufferedImage().getWidth();
this.totalHeight = this.imageDownloadAlt.getBufferedImage().getHeight();
@@ -103,34 +117,10 @@ public class ImageData {
}
public int getTotalWidth() {
if (!this.gotWidthHeight) {
try {
if (!this.isUrl) {
this.getWidthHeight();
} else {
this.getURLWidthHeight();
}
} catch (Exception ignored) {}
if (!this.gotWidthHeight) {
return -1;
}
}
return this.totalWidth;
return this.gotWidthHeight ? this.totalWidth : -1;
}
public int getTotalHeight() {
if (!this.gotWidthHeight) {
try {
if (!this.isUrl) {
this.getWidthHeight();
} else {
this.getURLWidthHeight();
}
} catch (Exception ignored) {}
if (!this.gotWidthHeight) {
return -1;
}
}
return this.totalHeight;
return this.gotWidthHeight ? this.totalHeight : -1;
}
}
@@ -15,6 +15,7 @@ public class ConfigMain
public final static String GENERAL = "General";
public final static String NPC = "NPC";
public final static String UPDATE = "Update";
/**
* General Main Properties
@@ -87,6 +88,13 @@ public class ConfigMain
public static Property NpcUseOpCommandsProperty;
public static boolean NpcUseOpCommands = false;
/**
* Update Properties
**/
public static Property TrackedQuestUpdateFrequencyProperty;
public static int TrackedQuestUpdateFrequency = 5;
public static void init(File configFile)
{
config = new Configuration(configFile);
@@ -161,6 +169,10 @@ public class ConfigMain
SkinOverlayLimitProperty = config.get(NPC, "Skin Overlay Limit", 10, "The maximum number of overlays any npc/player can hold.");
SkinOverlayLimit = SkinOverlayLimitProperty.getInt(10);
// Update
TrackedQuestUpdateFrequencyProperty = config.get(UPDATE, "Tracked Quest Update Frequency", 5, "How often in seconds to update a players tracked quest. [Only applies to Item Quest currently]");
TrackedQuestUpdateFrequency = TrackedQuestUpdateFrequencyProperty.getInt(5);
// Convert to Legacy
if(CustomNpcs.legacyExist){
EnableUpdateChecker = LegacyConfig.EnableUpdateChecker;
@@ -1,6 +1,7 @@
package noppes.npcs.config;
import cpw.mods.fml.common.FMLLog;
import kamkeel.developer.Developer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.common.config.Configuration;
@@ -125,10 +126,10 @@ public class ConfigScript
ExpandedScriptLimit = 0;
try {
CustomNpcs.ScriptDevs.clear();
Developer.ScriptUser.clear();
String[] uuidStrings = ScriptDevIDs.split(",");
for (String s : uuidStrings) {
CustomNpcs.ScriptDevs.add(UUID.fromString(s));
Developer.ScriptUser.add(UUID.fromString(s));
}
} catch (Exception ignored) {}
@@ -147,7 +148,7 @@ public class ConfigScript
public static boolean isScriptDev(EntityPlayer player) {
if(ScriptOpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile()) ||
CustomNpcs.ScriptDevs.contains(player.getUniqueID())){
Developer.ScriptUser.contains(player.getUniqueID()) || Developer.Universal.contains(player.getUniqueID())){
return true;
} else return ScriptDevIDs.isEmpty();
}
@@ -7,11 +7,9 @@ package noppes.npcs.containers;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import noppes.npcs.EventHooks;
import noppes.npcs.api.entity.IPlayer;
@@ -110,6 +108,11 @@ public class ContainerCustomGui extends Container {
public ItemStack slotClick(int slotId, int dragType, int clickTypeIn, EntityPlayer player) {
if(slotId < 0)
return super.slotClick(slotId, dragType, clickTypeIn, player);
if (slotId >= this.inventorySlots.size()) {
return null;
}
Slot mcSlot = (Slot)this.inventorySlots.get(slotId);
if(!player.worldObj.isRemote && mcSlot != null) {
IItemSlot slot = null;
@@ -135,7 +138,6 @@ public class ContainerCustomGui extends Container {
EntityPlayerMP p = (EntityPlayerMP) player;
p.sendContainerToPlayer(this);
return item;
}
}
@@ -80,6 +80,10 @@ public class ContainerNPCBankInterface extends ContainerNpcInterface
return false;
}
public synchronized void setCurrency(ItemStack item){
currency.item = item;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i)
{
@@ -27,12 +27,12 @@ public class CustomGuiController {
EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player.getMCEntity();
entityPlayerMP.openGui(CustomNpcs.instance, EnumGuiType.CustomGui.ordinal(), player.getWorld().getMCWorld(), gui.getSlots().size(), 0, 0);
((ContainerCustomGui)((EntityPlayerMP)player.getMCEntity()).openContainer).setGui(gui, (EntityPlayer)player.getMCEntity());
Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()});
Server.sendDataChecked((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()});
}
public static boolean updateGui(IPlayer player, ScriptGui gui) {
if (((EntityPlayerMP)player.getMCEntity()).openContainer instanceof ContainerCustomGui) {
Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()});
Server.sendDataChecked((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()});
return true;
} else {
return false;
@@ -40,11 +40,11 @@ public class CustomGuiController {
}
public static void openOverlay(IPlayer player, ScriptOverlay gui) {
Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.SCRIPT_OVERLAY_DATA, new Object[]{gui.toNBT()});
Server.sendDataChecked((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.SCRIPT_OVERLAY_DATA, new Object[]{gui.toNBT()});
}
public static boolean updateOverlay(IPlayer player, ScriptOverlay gui) {
Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.SCRIPT_OVERLAY_DATA, new Object[]{gui.toNBT()});
Server.sendDataChecked((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.SCRIPT_OVERLAY_DATA, new Object[]{gui.toNBT()});
return true;
}
@@ -9,7 +9,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter;
import noppes.npcs.controllers.data.*;
@@ -17,15 +16,15 @@ import noppes.npcs.util.NBTJsonUtil;
import java.io.*;
import java.util.*;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.zip.GZIPInputStream;
import static noppes.npcs.util.CustomNPCsThreader.playerDataThread;
public class PlayerDataController {
public static PlayerDataController instance;
public HashMap<String, String> nameUUIDs;
private static final Executor playerDataThread = Executors.newSingleThreadExecutor();
public PlayerDataController(){
instance = this;
@@ -140,14 +139,18 @@ public class PlayerDataController {
return true;
}
} catch (Exception e) {
try {
File file = new File(getSaveDir(), "___playermap.dat_old");
if(file.exists()){
loadPlayerDataMap(file);
return true;
}
} catch (Exception ignored) {}
LogWriter.except(e);
}
try {
File file = new File(getSaveDir(), "___playermap.dat_old");
if(file.exists()){
loadPlayerDataMap(file);
return true;
}
} catch (Exception e2) {
LogWriter.except(e2);
}
return false;
}
@@ -163,30 +166,32 @@ public class PlayerDataController {
readNBT(nbttagcompound);
}
public void savePlayerDataMap(){
try {
File saveDir = getSaveDir();
File file = new File(saveDir, "___playermap.dat_new");
File file1 = new File(saveDir, "___playermap.dat_old");
File file2 = new File(saveDir, "___playermap.dat");
CompressedStreamTools.writeCompressed(writeNBT(), new FileOutputStream(file));
if(file1.exists())
{
file1.delete();
public synchronized void savePlayerDataMap(){
playerDataThread.execute(() -> {
try {
File saveDir = getSaveDir();
File file = new File(saveDir, "___playermap.dat_new");
File file1 = new File(saveDir, "___playermap.dat_old");
File file2 = new File(saveDir, "___playermap.dat");
CompressedStreamTools.writeCompressed(writeNBT(), new FileOutputStream(file));
if(file1.exists())
{
file1.delete();
}
file2.renameTo(file1);
if(file2.exists())
{
file2.delete();
}
file.renameTo(file2);
if(file.exists())
{
file.delete();
}
} catch (Exception e) {
LogWriter.except(e);
}
file2.renameTo(file1);
if(file2.exists())
{
file2.delete();
}
file.renameTo(file2);
if(file.exists())
{
file.delete();
}
} catch (Exception e) {
LogWriter.except(e);
}
});
}
public File getSaveDir(){
@@ -252,28 +257,6 @@ public class PlayerDataController {
return new NBTTagCompound();
}
public void savePlayerData(PlayerData data){
NBTTagCompound compound = data.getNBT();
playerDataThread.execute(() -> {
String filename = data.uuid + ".json";
try {
File saveDir = getSaveDir();
File file = new File(saveDir, filename+"_new");
File file1 = new File(saveDir, filename);
NBTJsonUtil.SaveFile(file, compound);
if(file1.exists()){
file1.delete();
}
file.renameTo(file1);
} catch (Exception e) {
LogWriter.except(e);
}
nameUUIDs.put(data.playername, data.uuid);
savePlayerDataMap();
});
}
public PlayerBankData getBankData(EntityPlayer player, int bankId) {
Bank bank = BankController.getInstance().getBank(bankId);
PlayerBankData data = getPlayerData(player).bankData;
@@ -288,7 +271,7 @@ public class PlayerDataController {
if(data == null){
player.registerExtendedProperties("CustomNpcsData", data = new PlayerData());
data.player = player;
data.loadPlayerDataFromFile();
data.load();
}
data.player = player;
return data;
@@ -326,7 +309,7 @@ public class PlayerDataController {
EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username);
PlayerData data = getDataFromUsername(username);
data.mailData.playermail.add(mail.copy());
savePlayerData(data);
data.save();
}
public List<PlayerData> getPlayersData(ICommandSender sender, String username){
@@ -346,6 +329,11 @@ public class PlayerDataController {
return list;
}
public void putPlayerMap(String playerName, String uuid) {
nameUUIDs.put(playerName, uuid);
savePlayerDataMap();
}
public boolean hasMail(EntityPlayer player) {
return getPlayerData(player).mailData.hasMail();
}
@@ -60,17 +60,24 @@ public class PlayerQuestController {
public static void setQuestFinished(Quest quest, EntityPlayer player){
PlayerData playerdata = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData data = playerdata.questData;
QuestData questData = data.activeQuests.get(quest.id);
data.activeQuests.remove(quest.id);
if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY)
data.finishedQuests.put(quest.id, System.currentTimeMillis());
else
data.finishedQuests.put(quest.id,player.worldObj.getTotalWorldTime());
if(quest.repeat != EnumQuestRepeat.NONE && quest.type == EnumQuestType.Dialog){
QuestDialog questdialog = (QuestDialog) quest.questInterface;
for(int dialog : questdialog.dialogs.values()){
playerdata.dialogData.dialogsRead.remove(dialog);
}
}
if (questData.sendAlerts) {
Server.sendData((EntityPlayerMP) player, EnumPacketClient.MESSAGE, "quest.completed", questData.quest.title);
Server.sendData((EntityPlayerMP) player, EnumPacketClient.CHAT, "quest.completed", ": ", questData.quest.title);
}
}
public static boolean canQuestBeAccepted(Quest quest, EntityPlayer player){
if(quest == null)
@@ -33,7 +33,7 @@ public class ScriptContainer {
private String currentScriptLanguage = null;
public ScriptEngine engine = null;
private IScriptHandler handler = null;
private boolean init = false;
private boolean evaluated = false;
private static Method luaCoerce;
private static Method luaCall;
private CompiledScript compScript = null;
@@ -43,6 +43,7 @@ public class ScriptContainer {
}
public void readFromNBT(NBTTagCompound compound) {
String prevScript = this.script;
this.script = compound.getString("Script");
for (int i = 0; i < ConfigScript.ExpandedScriptLimit; i++) {
if (compound.hasKey("ExpandedScript"+i)) {
@@ -51,7 +52,11 @@ public class ScriptContainer {
break;
}
}
//this.type = compound.getString("Type");
if (!this.script.equals(prevScript)) {
this.evaluated = false;
}
this.console = NBTTags.GetLongStringMap(compound.getTagList("Console", 10));
this.scripts = NBTTags.getStringList(compound.getTagList("ScriptList", 10));
this.lastCreated = 0L;
@@ -88,7 +93,7 @@ public class ScriptContainer {
}
private String getFullCode() {
if(!this.init) {
if(!this.evaluated) {
this.fullscript = this.script;
if(!this.fullscript.isEmpty()) {
this.fullscript = this.fullscript + "\n";
@@ -145,12 +150,11 @@ public class ScriptContainer {
if(errored || !hasCode() || unknownFunctions.contains(type) || !ConfigScript.ScriptingEnabled)
return;
this.setEngine(handler.getLanguage());
if(engine == null)
return;
if(ScriptController.Instance.lastLoaded > this.lastCreated){
this.lastCreated = ScriptController.Instance.lastLoaded;
init = false;
evaluated = false;
}
synchronized (lock) {
@@ -170,9 +174,9 @@ public class ScriptContainer {
}
try {
if(!init){
if(!evaluated){
engine.eval(getFullCode());
init = true;
evaluated = true;
}
if(engine.getFactory().getLanguageName().equals("lua")){
Object ob = engine.get(type);
@@ -220,7 +224,7 @@ public class ScriptContainer {
}
public boolean isValid() {
return init && !errored;
return evaluated && !errored;
}
public boolean hasCode() {
@@ -233,9 +237,9 @@ public class ScriptContainer {
if (ConfigScript.ScriptingECMA6 && scriptLanguage.equals("ECMAScript")) {
System.setProperty("nashorn.args", "--language=es6");
}
this.engine = new ScriptEngineManager().getEngineByName(scriptLanguage.toLowerCase());
this.engine = ScriptController.Instance.getEngineByName(scriptLanguage.toLowerCase());
currentScriptLanguage = scriptLanguage;
init = false;
evaluated = false;
}
}
@@ -33,7 +33,7 @@ public class ScriptController {
public static ScriptController Instance;
public static boolean HasStart = false;
private ScriptEngineManager manager;
private final ScriptEngineManager manager;
public Map<String, String> languages = new HashMap<String, String>();
public Map<String, String> scripts = new HashMap<String, String>();
public long lastLoaded = 0;
@@ -254,8 +254,6 @@ public class ServerCloneController implements ICloneHandler {
nbttagcompound.removeTag("MovingPathNew");
nbttagcompound.removeTag("Pos");
nbttagcompound.removeTag("Riding");
nbttagcompound.removeTag("UUIDMost");
nbttagcompound.removeTag("UUIDLeast");
if(!nbttagcompound.hasKey("ModRev"))
nbttagcompound.setInteger("ModRev", 1);
@@ -15,6 +15,7 @@ import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.containers.ContainerNPCBankInterface;
import noppes.npcs.controllers.BankController;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.util.CustomNPCsThreader;
import java.util.HashMap;
@@ -74,10 +75,8 @@ public class BankData {
return bank.canBeUpgraded(slot) && upgradedSlots.get(slot);
}
public void openBankGui(EntityPlayer player, EntityNPCInterface npc, int bankId, int slot) {
Bank bank = BankController.getInstance().banks.get(bankId);
if(bank == null)
bank = BankController.getInstance().banks.values().iterator().next();
public void openBankGui(final EntityPlayer player, EntityNPCInterface npc, int bankId, int slot) {
final Bank bank = BankController.getInstance().getBank(bankId);
if(bank.getMaxSlots() <= slot)
return;
@@ -100,17 +99,17 @@ public class BankData {
else{
NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankSmall, npc, slot, bank.id, 0);
}
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("MaxSlots", bank.getMaxSlots());
compound.setInteger("UnlockedSlots", unlockedSlots);
if(currency != null){
compound.setTag("Currency", NoppesUtilServer.writeItem(currency, new NBTTagCompound()));
ContainerNPCBankInterface container = getContainer(player);
container.currency.item = currency;
}
Server.sendData((EntityPlayerMP)player, EnumPacketClient.GUI_DATA,compound);
final ItemStack item = currency;
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("MaxSlots", bank.getMaxSlots());
compound.setInteger("UnlockedSlots", unlockedSlots);
if (item != null) {
compound.setTag("Currency", NoppesUtilServer.writeItem(item, new NBTTagCompound()));
ContainerNPCBankInterface container = getContainer(player);
if (container != null)
container.setCurrency(item);
}
Server.sendDataChecked((EntityPlayerMP) player, EnumPacketClient.GUI_DATA, compound);
}
private ContainerNPCBankInterface getContainer(EntityPlayer player){
Container con = player.openContainer;
@@ -30,9 +30,9 @@ import javax.script.ScriptEngine;
import java.util.*;
public class DataScript implements IScriptHandler {
public List<ScriptContainer> eventScripts = new ArrayList();
public List<ScriptContainer> eventScripts = new ArrayList<>();
public List<ScriptContainer> scripts = new ArrayList();
private HashMap<EnumScriptType,ScriptContainer> scripts = new HashMap<>();
private final static EntityType entities = new EntityType();
private final static JobType jobs = new JobType();
private final static RoleType roles = new RoleType();
@@ -49,7 +49,7 @@ public class DataScript implements IScriptHandler {
public DataScript(EntityNPCInterface npc) {
for (int i = 0; i < 15; i++) {
scripts.add(new ScriptContainer(this));
this.setNPCScript(i, new ScriptContainer(this));
}
this.npc = npc;
@@ -72,11 +72,19 @@ public class DataScript implements IScriptHandler {
this.scriptLanguage = "ECMAScript";
}
}
for (ScriptContainer container : this.scripts.values()) {
container.setEngine(this.getLanguage());
}
enabled = compound.getBoolean("ScriptEnabled");
}
public void readEventsFromNBT(NBTTagCompound compound) {
eventScripts = NBTTags.GetScript(compound,this);
for (ScriptContainer container : this.eventScripts) {
container.setEngine(this.getLanguage());
}
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
@@ -94,30 +102,30 @@ public class DataScript implements IScriptHandler {
return compound;
}
private List<ScriptContainer> readScript(NBTTagList list){
List<ScriptContainer> scripts = new ArrayList<>();
private HashMap<EnumScriptType,ScriptContainer> readScript(NBTTagList list){
HashMap<EnumScriptType,ScriptContainer> scripts = new HashMap<>();
for (int i = 0; i < 15; i++) {
scripts.add(new ScriptContainer(this));
scripts.put(EnumScriptType.values()[i], new ScriptContainer(this));
}
for(int i = 0; i < list.tagCount(); i++){
NBTTagCompound compoundd = list.getCompoundTagAt(i);
ScriptContainer script = new ScriptContainer(this);
script.readFromNBT(compoundd);
if(script.hasCode() || npc.isRemote())
scripts.set(compoundd.getInteger("Type"), script);
if (script.hasCode() || npc.isRemote()) {
scripts.put(EnumScriptType.values()[compoundd.getInteger("Type")], script);
}
}
return scripts;
}
private NBTTagList writeScript(List<ScriptContainer> scripts){
private NBTTagList writeScript(HashMap<EnumScriptType,ScriptContainer> scripts){
NBTTagList list = new NBTTagList();
for(int type = 0; type < scripts.size(); type++){
NBTTagCompound compoundd = new NBTTagCompound();
compoundd.setInteger("Type", type);
ScriptContainer script = scripts.get(type);
script.writeToNBT(compoundd);
list.appendTag(compoundd);
for (Map.Entry<EnumScriptType,ScriptContainer> entry : scripts.entrySet()) {
NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setInteger("Type", entry.getKey().ordinal());
entry.getValue().writeToNBT(tagCompound);
list.appendTag(tagCompound);
}
return list;
}
@@ -146,10 +154,9 @@ public class DataScript implements IScriptHandler {
script.run(type, event);
}
ScriptContainer script = scripts.get(type.ordinal());
ScriptContainer script = scripts.get(type);
if(script == null || script.errored || !script.hasCode())
return false;
script.setEngine(scriptLanguage);
if(script.engine == null)
return false;
for(int i = 0; i + 1 < obs.length; i += 2){
@@ -173,7 +180,7 @@ public class DataScript implements IScriptHandler {
engine.put("npc", dummyNpc);
engine.put("world", dummyWorld);
engine.put("event", event);
engine.put("API", new NpcAPI());
engine.put("API", NpcAPI.Instance());
engine.put("EntityType", entities);
engine.put("RoleType", roles);
engine.put("JobType", jobs);
@@ -198,18 +205,11 @@ public class DataScript implements IScriptHandler {
}
public Map<Long, String> getOldConsoleText() {
Map<Long, String> map = new TreeMap();
int tab = 0;
Iterator var3 = this.scripts.iterator();
Map<Long, String> map = new TreeMap<>();
while(var3.hasNext()) {
ScriptContainer script = (ScriptContainer)var3.next();
++tab;
Iterator var5 = script.console.entrySet().iterator();
while(var5.hasNext()) {
Map.Entry<Long, String> entry = (Map.Entry)var5.next();
map.put(entry.getKey(), " tab " + tab + ":\n" + (String)entry.getValue());
for (Map.Entry<EnumScriptType,ScriptContainer> entry : scripts.entrySet()) {
for (Map.Entry<Long,String> consoleEntry : entry.getValue().console.entrySet()) {
map.put(consoleEntry.getKey(), " tab " + entry.getKey().ordinal() + ":\n" + consoleEntry.getValue());
}
}
@@ -261,7 +261,7 @@ public class DataScript implements IScriptHandler {
}
public void setScripts(List<ScriptContainer> list) {
this.scripts = list;
this.eventScripts = list;
}
public List<ScriptContainer> getScripts() {
@@ -279,4 +279,23 @@ public class DataScript implements IScriptHandler {
dummyWorld = new ScriptWorld((WorldServer) world);
}
public ScriptContainer getNPCScript(EnumScriptType scriptType) {
return this.scripts.get(scriptType);
}
public ScriptContainer getNPCScript(int ordinal) {
return this.getNPCScript(EnumScriptType.values()[ordinal]);
}
public void setNPCScript(EnumScriptType scriptType, ScriptContainer container) {
this.scripts.put(scriptType, container);
}
public void setNPCScript(int ordinal, ScriptContainer container) {
this.setNPCScript(EnumScriptType.values()[ordinal], container);
}
public Collection<ScriptContainer> getNPCScripts() {
return this.scripts.values();
}
}
@@ -5,6 +5,7 @@ import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NBTTags;
import noppes.npcs.api.entity.ICustomNpc;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.handler.IPlayerFactionData;
import noppes.npcs.api.handler.data.IFaction;
import noppes.npcs.controllers.FactionController;
import noppes.npcs.controllers.PlayerDataController;
@@ -133,8 +134,8 @@ public class Faction implements IFaction {
}
public int playerStatus(IPlayer player) {
PlayerFactionData data = PlayerData.get((EntityPlayer) player.getMCEntity()).factionData;
int points = data.getFactionPoints(this.id);
IPlayerFactionData data = player.getData().getFactionData();
int points = data.getPoints(this.id);
if (points >= this.friendlyPoints) {
return 1;
} else {
@@ -46,6 +46,10 @@ public class ForgeDataScript implements IScriptHandler {
}
}
this.enabled = compound.getBoolean("ScriptEnabled");
for (ScriptContainer container : this.scripts) {
container.setEngine(this.getLanguage());
}
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
@@ -49,6 +49,10 @@ public class GlobalNPCDataScript implements IScriptHandler {
}
}
this.enabled = compound.getBoolean("ScriptEnabled");
for (ScriptContainer container : this.scripts) {
container.setEngine(this.getLanguage());
}
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setInteger("TotalScripts",this.scripts.size());
@@ -2,7 +2,6 @@ package noppes.npcs.controllers.data;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties;
@@ -19,10 +18,10 @@ import noppes.npcs.entity.data.DataSkinOverlays;
import noppes.npcs.entity.data.DataTimers;
import noppes.npcs.roles.RoleCompanion;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.util.CustomNPCsThreader;
import noppes.npcs.util.NBTJsonUtil;
import java.io.File;
import java.io.FileInputStream;
public class PlayerData implements IExtendedEntityProperties, IPlayerData {
public PlayerDialogData dialogData = new PlayerDialogData(this);
@@ -52,24 +51,10 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
@Override
public void saveNBTData(NBTTagCompound nbtTagCompound) {
//Do Nothing
}
public void savePlayerDataOnFile() {
PlayerDataController.instance.savePlayerData(this);
}
@Override
public void loadNBTData(NBTTagCompound compound) {
//Do Nothing
}
public void loadPlayerDataFromFile() {
NBTTagCompound data = PlayerDataController.instance.loadPlayerData(player.getPersistentID().toString());
if(data.hasNoTags()){
data = PlayerDataController.instance.loadPlayerDataOld(player.getCommandSenderName());
}
setNBT(data);
}
public void setNBT(NBTTagCompound data){
@@ -141,13 +126,11 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
}
public void setGUIOpen(boolean bool) {
isGUIOpen = bool;
savePlayerDataOnFile();
this.isGUIOpen = bool;
}
public boolean getGUIOpen() {
loadPlayerDataFromFile();
return isGUIOpen;
return this.isGUIOpen;
}
public boolean hasCompanion(){
@@ -161,7 +144,7 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
activeCompanion = npc;
if(npc != null)
((RoleCompanion)npc.roleInterface).companionID = companionID;
savePlayerDataOnFile();
save();
}
public void updateCompanion(World world) {
@@ -183,44 +166,6 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
world.spawnEntityInWorld(npc);
}
public static NBTTagCompound loadPlayerDataOld(String player) {
File saveDir = CustomNpcs.getWorldSaveDirectory("playerdata");
String filename = player;
if (player.isEmpty()) {
filename = "noplayername";
}
filename = filename + ".dat";
File file;
try {
file = new File(saveDir, filename);
if (file.exists()) {
NBTTagCompound comp = CompressedStreamTools.readCompressed(new FileInputStream(file));
file.delete();
file = new File(saveDir, filename + "_old");
if (file.exists()) {
file.delete();
}
return comp;
}
} catch (Exception var6) {
LogWriter.except(var6);
}
try {
file = new File(saveDir, filename + "_old");
if (file.exists()) {
return CompressedStreamTools.readCompressed(new FileInputStream(file));
}
} catch (Exception var5) {
LogWriter.except(var5);
}
return new NBTTagCompound();
}
public static NBTTagCompound loadPlayerData(String player) {
File saveDir = CustomNpcs.getWorldSaveDirectory("playerdata");
String filename = player;
@@ -243,25 +188,6 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
return new NBTTagCompound();
}
public static PlayerData get(EntityPlayer player) {
if(player.worldObj.isRemote) {
return CustomNpcs.proxy.getPlayerData(player);
} else {
PlayerData data = new PlayerData();
if (data.player == null) {
data.player = player;
NBTTagCompound compound = loadPlayerData(player.getPersistentID().toString());
if (compound.hasNoTags()) {
compound = loadPlayerDataOld(player.getCommandSenderName());
}
data.setNBT(compound);
}
return data;
}
}
public void setCompanion(ICustomNpc npc) {
this.setCompanion((EntityNPCInterface) npc.getMCEntity());
}
@@ -302,7 +228,31 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
return mailData;
}
public void save() {
PlayerDataController.instance.savePlayerData(this);
public synchronized void save() {
final NBTTagCompound compound = getNBT();
final String filename = uuid + ".json";
CustomNPCsThreader.playerDataThread.execute(() -> {
try {
File saveDir = PlayerDataController.instance.getSaveDir();
File file = new File(saveDir, filename + "_new");
File file1 = new File(saveDir, filename);
NBTJsonUtil.SaveFile(file, compound);
if(file1.exists()){
file1.delete();
}
file.renameTo(file1);
} catch (Exception e) {
LogWriter.except(e);
}
});
PlayerDataController.instance.putPlayerMap(playername, uuid);
}
public void load() {
NBTTagCompound data = PlayerDataController.instance.loadPlayerData(player.getPersistentID().toString());
if(data.hasNoTags()){
data = PlayerDataController.instance.loadPlayerDataOld(player.getCommandSenderName());
}
setNBT(data);
}
}
@@ -55,6 +55,10 @@ public class PlayerDataScript implements IScriptHandler {
}
}
this.enabled = compound.getBoolean("ScriptEnabled");
for (ScriptContainer container : this.scripts) {
container.setEngine(this.getLanguage());
}
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setInteger("TotalScripts",this.scripts.size());
@@ -11,6 +11,7 @@ import noppes.npcs.api.handler.IPlayerQuestData;
import noppes.npcs.api.handler.data.IQuest;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestCompletion;
import noppes.npcs.constants.EnumQuestRepeat;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.QuestController;
@@ -24,7 +25,7 @@ import java.util.List;
public class PlayerQuestData implements IPlayerQuestData {
private final PlayerData parent;
public IQuest trackedQuest = null;
private IQuest trackedQuest = null;
public HashMap<Integer,QuestData> activeQuests = new HashMap<Integer,QuestData>();
public HashMap<Integer,Long> finishedQuests = new HashMap<Integer,Long>();
@@ -120,15 +121,9 @@ public class PlayerQuestData implements IPlayerQuestData {
if(data.quest.type != type && type != null)
continue;
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) player,data.quest);
QuestInterface inter = data.quest.questInterface;
if(inter.isCompleted(playerData)){
if((!data.isCompleted && data.quest.completion == EnumQuestCompletion.Npc) || data.quest.instantComplete(player,data)){
if (data.quest.completeText.isEmpty() && data.sendAlerts) {
Server.sendData((EntityPlayerMP)player, EnumPacketClient.MESSAGE, "quest.completed", data.quest.title);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.CHAT, "quest.completed",": ",data.quest.title);
}
data.isCompleted = true;
if (data.quest.completion == EnumQuestCompletion.Npc) {
EventHooks.onQuestFinished(player, data.quest);
@@ -138,14 +133,32 @@ public class PlayerQuestData implements IPlayerQuestData {
} else {
data.isCompleted = false;
}
if (this.trackedQuest != null && data.quest.getId() == this.trackedQuest.getId()) {
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) player);
}
}
QuestItem.pickedUp = null;
return bo;
}
public void trackQuest(IQuest quest) {
if (this.trackedQuest == null || quest.getId() != this.trackedQuest.getId()) {
this.trackedQuest = quest;
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) this.parent.player);
}
}
public void untrackQuest() {
if (this.trackedQuest != null) {
this.trackedQuest = null;
Server.sendData((EntityPlayerMP) this.parent.player, EnumPacketClient.OVERLAY_QUEST_TRACKING);
}
}
public IQuest getTrackedQuest() {
return trackedQuest;
return this.trackedQuest;
}
public void startQuest(int id) {
@@ -164,7 +177,11 @@ public class PlayerQuestData implements IPlayerQuestData {
Quest quest = QuestController.instance.quests.get(id);
if (quest == null)
return;
finishedQuests.put(id, System.currentTimeMillis());
if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY)
finishedQuests.put(quest.id, System.currentTimeMillis());
else
finishedQuests.put(quest.id, parent.player.worldObj.getTotalWorldTime());
}
public void stopQuest(int id) {
@@ -148,11 +148,11 @@ public class Quest implements ICompatibilty, IQuest {
switch (repeat) {
case MCDAILY:
return Math.max(0, questTime + 24000 - player.worldObj.getTotalWorldTime());
return Math.max(0, (questTime + 24000 - player.worldObj.getTotalWorldTime()) * 50);
case MCWEEKLY:
return Math.max(0, questTime + 168000 - player.worldObj.getTotalWorldTime());
return Math.max(0, (questTime + 168000 - player.worldObj.getTotalWorldTime()) * 50);
case RLDAILY:
return Math.max(0, questTime + 86400000 - System.currentTimeMillis());
return Math.max(0, questTime + 86400000 - System.currentTimeMillis());
case RLWEEKLY:
return Math.max(0, questTime + 604800000 - System.currentTimeMillis());
}
@@ -35,14 +35,14 @@ public class ItemNpcWand extends Item{
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
public boolean onItemUse(ItemStack par1ItemStack, final EntityPlayer player, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
if(par3World.isRemote)
return true;
if(ConfigMain.OpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile())){
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
}
else if(CustomNpcsPermissions.Instance.hasPermission(player, CustomNpcsPermissions.NPC_CREATE)){
else if(CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.NPC_CREATE)){
EntityCustomNpc npc = new EntityCustomNpc(par3World);
npc.ai.startPos = new int[]{par4,par5,par6};
@@ -50,8 +50,8 @@ public class ItemNpcWand extends Item{
par3World.spawnEntityInWorld(npc);
npc.setHealth(npc.getMaxHealth());
NoppesUtilServer.sendOpenGui(player,EnumGuiType.MainMenuDisplay,npc);
NoppesUtilServer.sendOpenGuiNoDelay(player, EnumGuiType.MainMenuDisplay,npc);
}
else
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
@@ -1,7 +1,9 @@
package noppes.npcs.mixin;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelRenderer;
import noppes.npcs.AnimationData;
@@ -38,6 +40,8 @@ public abstract class MixinModelRenderer {
@Shadow public List childModels;
@Shadow abstract void compileDisplayList(float p_78788_1_);
@Shadow public ModelBase baseModel;
/**
* @author Someone
* @reason Because we need it
@@ -157,7 +161,9 @@ public abstract class MixinModelRenderer {
{
for (i = 0; i < this.childModels.size(); ++i)
{
((ModelRenderer)this.childModels.get(i)).render(p_78785_1_);
if(this.childModels.get(i) instanceof ModelRenderer){
((ModelRenderer)this.childModels.get(i)).render(p_78785_1_);
}
}
}
}
@@ -170,7 +176,9 @@ public abstract class MixinModelRenderer {
{
for (i = 0; i < this.childModels.size(); ++i)
{
((ModelRenderer)this.childModels.get(i)).render(p_78785_1_);
if(this.childModels.get(i) instanceof ModelRenderer){
((ModelRenderer)this.childModels.get(i)).render(p_78785_1_);
}
}
}
@@ -203,10 +211,11 @@ public abstract class MixinModelRenderer {
{
for (i = 0; i < this.childModels.size(); ++i)
{
((ModelRenderer)this.childModels.get(i)).render(p_78785_1_);
if(this.childModels.get(i) instanceof ModelRenderer){
((ModelRenderer)this.childModels.get(i)).render(p_78785_1_);
}
}
}
GL11.glPopMatrix();
}
@@ -274,30 +283,32 @@ public abstract class MixinModelRenderer {
}
public EnumAnimationPart pivotEqualPart(ModelRenderer renderer) {
ModelRenderer head = ((ModelBiped) renderer.baseModel).bipedHead;
ModelRenderer body = ((ModelBiped) renderer.baseModel).bipedBody;
ModelRenderer larm = ((ModelBiped) renderer.baseModel).bipedLeftArm;
ModelRenderer rarm = ((ModelBiped) renderer.baseModel).bipedRightArm;
ModelRenderer lleg = ((ModelBiped) renderer.baseModel).bipedLeftLeg;
ModelRenderer rleg = ((ModelBiped) renderer.baseModel).bipedRightLeg;
if(renderer.baseModel instanceof ModelBiped){
ModelRenderer head = ((ModelBiped) renderer.baseModel).bipedHead;
ModelRenderer body = ((ModelBiped) renderer.baseModel).bipedBody;
ModelRenderer larm = ((ModelBiped) renderer.baseModel).bipedLeftArm;
ModelRenderer rarm = ((ModelBiped) renderer.baseModel).bipedRightArm;
ModelRenderer lleg = ((ModelBiped) renderer.baseModel).bipedLeftLeg;
ModelRenderer rleg = ((ModelBiped) renderer.baseModel).bipedRightLeg;
if (pivotsEqual(renderer,head)) {
return EnumAnimationPart.HEAD;
}
if (pivotsEqual(renderer,body)) {
return EnumAnimationPart.BODY;
}
if (pivotsEqual(renderer,rarm)) {
return EnumAnimationPart.RIGHT_ARM;
}
if (pivotsEqual(renderer,larm)) {
return EnumAnimationPart.LEFT_ARM;
}
if (pivotsEqual(renderer,rleg)) {
return EnumAnimationPart.RIGHT_LEG;
}
if (pivotsEqual(renderer,lleg)) {
return EnumAnimationPart.LEFT_LEG;
if (pivotsEqual(renderer,head)) {
return EnumAnimationPart.HEAD;
}
if (pivotsEqual(renderer,body)) {
return EnumAnimationPart.BODY;
}
if (pivotsEqual(renderer,rarm)) {
return EnumAnimationPart.RIGHT_ARM;
}
if (pivotsEqual(renderer,larm)) {
return EnumAnimationPart.LEFT_ARM;
}
if (pivotsEqual(renderer,rleg)) {
return EnumAnimationPart.RIGHT_LEG;
}
if (pivotsEqual(renderer,lleg)) {
return EnumAnimationPart.LEFT_LEG;
}
}
return null;
@@ -99,13 +99,13 @@ public class QuestDialog extends QuestInterface implements IQuestDialog {
if (progress == 0 && completed) {
data.dialogData.dialogsRead.remove(this.dialog.id);
data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]);
data.savePlayerDataOnFile();
data.save();
}
if (progress == 1 && !completed) {
data.dialogData.dialogsRead.add(this.dialog.id);
data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]);
data.savePlayerDataOnFile();
data.save();
}
} else {
@@ -10,6 +10,7 @@ import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.QuestController;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.PlayerQuestData;
import java.util.Vector;
@@ -19,9 +20,11 @@ public abstract class QuestInterface implements IQuestInterface {
public abstract void readEntityFromNBT(NBTTagCompound compound);
public abstract boolean isCompleted(PlayerData player);
public void handleComplete(EntityPlayer player) {
if (QuestController.instance.get(questId).equals(PlayerDataController.instance.getPlayerData(player).questData.trackedQuest)) {
PlayerDataController.instance.getPlayerData(player).questData.trackedQuest = null;
Server.sendData((EntityPlayerMP) player, EnumPacketClient.OVERLAY_QUEST_TRACKING);
PlayerQuestData questData = PlayerDataController.instance.getPlayerData(player).questData;
if(questData != null && questData.getTrackedQuest() != null){
if (this.questId == PlayerDataController.instance.getPlayerData(player).questData.getTrackedQuest().getId()) {
PlayerDataController.instance.getPlayerData(player).questData.untrackQuest();
}
}
}
public abstract Vector<String> getQuestLogStatus(EntityPlayer player);
@@ -131,18 +131,16 @@ public class QuestItem extends QuestInterface implements IQuestItem {
}
public IQuestObjective[] getObjectives(EntityPlayer player) {
List<IQuestObjective> list = new ArrayList();
List<IQuestObjective> list = new ArrayList<>();
List<ItemStack> questItems = NoppesUtilPlayer.countStacks(this.items, this.ignoreDamage, this.ignoreNBT);
Iterator var4 = questItems.iterator();
while(var4.hasNext()) {
ItemStack stack = (ItemStack)var4.next();
for (ItemStack stack : questItems) {
if (stack.stackSize > 0) {
list.add(new noppes.npcs.quests.QuestItem.QuestItemObjective(this, player, stack));
list.add(new QuestItemObjective(this, player, stack));
}
}
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
return list.toArray(new IQuestObjective[0]);
}
public void setLeaveItems(boolean leaveItems){
@@ -180,8 +178,13 @@ public class QuestItem extends QuestInterface implements IQuestItem {
public int getProgress() {
int count = 0;
ItemStack item = QuestItem.pickedUp;
if (!NoppesUtilServer.IsItemStackNull(item) && NoppesUtilPlayer.compareItems(this.questItem, item, this.parent.ignoreDamage, this.parent.ignoreNBT)) {
count += item.stackSize;
}
for(int i = 0; i < this.player.inventory.getSizeInventory(); ++i) {
ItemStack item = this.player.inventory.getStackInSlot(i);
item = this.player.inventory.getStackInSlot(i);
if (!NoppesUtilServer.IsItemStackNull(item) && NoppesUtilPlayer.compareItems(this.questItem, item, this.parent.ignoreDamage, this.parent.ignoreNBT)) {
count += item.stackSize;
}
@@ -146,8 +146,11 @@ public class QuestKill extends QuestInterface implements IQuestKill {
PlayerData data = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData playerdata = data.questData;
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
return !killed.containsKey(this.entity) ? 0 : (Integer)killed.get(this.entity);
if(questdata != null){
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
return !killed.containsKey(this.entity) ? 0 : (Integer)killed.get(this.entity);
}
return 0;
}
public void setProgress(int progress) {
@@ -155,13 +158,15 @@ public class QuestKill extends QuestInterface implements IQuestKill {
PlayerData data = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData playerdata = data.questData;
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) {
killed.put(this.entity, progress);
this.parent.setKilled(questdata, killed);
data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]);
data.questData.checkQuestCompletion(data, EnumQuestType.values()[4]);
data.savePlayerDataOnFile();
if(questdata != null){
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) {
killed.put(this.entity, progress);
this.parent.setKilled(questdata, killed);
data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]);
data.questData.checkQuestCompletion(data, EnumQuestType.values()[4]);
data.save();
}
}
} else {
throw new CustomNPCsException("Progress has to be between 0 and " + this.amount, new Object[0]);
@@ -166,7 +166,7 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
if ((!completed || progress != 1) && (completed || progress != 0)) {
questData.extraData.setBoolean(this.nbtName, progress == 1);
data.questData.checkQuestCompletion(data, EnumQuestType.values()[3]);
data.savePlayerDataOnFile();
data.save();
}
} else {
throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]);
+15 -6
View File
@@ -74,7 +74,7 @@ public class NpcAPI extends AbstractNpcAPI {
public static final EventBus EVENT_BUS = new EventBus();
private static AbstractNpcAPI instance = null;
public NpcAPI() {
private NpcAPI() {
}
public static void clearCache() {
@@ -248,10 +248,14 @@ public class NpcAPI extends AbstractNpcAPI {
}
public IBlock getIBlock(IWorld world, IPos pos) {
return this.getIBlock(world, pos.getX(),pos.getY(),pos.getZ());
return pos == null ? null : this.getIBlock(world, pos.getX(),pos.getY(),pos.getZ());
}
public ITileEntity getITileEntity(IWorld world, IPos pos) {
if (pos == null) {
return null;
}
TileEntity tileEntity = world.getMCWorld().getTileEntity(pos.getX(), pos.getY(),pos.getZ());
return this.getITileEntity(tileEntity);
}
@@ -282,11 +286,13 @@ public class NpcAPI extends AbstractNpcAPI {
}
public IPos[] getAllInBox(IPos from, IPos to, boolean sortByDistance) {
Iterator<BlockPos> posIterable = BlockPos.getAllInBox(from.getMCPos(),to.getMCPos()).iterator();
ArrayList<IPos> list = new ArrayList<>();
posIterable.forEachRemaining(BlockPos -> list.add(this.getIPos(BlockPos)));
if (sortByDistance) {
list.sort(Comparator.comparingDouble(pos -> pos.distanceTo(from)));
if (from != null && to != null) {
Iterator<BlockPos> posIterable = BlockPos.getAllInBox(from.getMCPos(),to.getMCPos()).iterator();
posIterable.forEachRemaining(BlockPos -> list.add(this.getIPos(BlockPos)));
if (sortByDistance) {
list.sort(Comparator.comparingDouble(pos -> pos.distanceTo(from)));
}
}
return list.toArray(new IPos[0]);
}
@@ -333,6 +339,9 @@ public class NpcAPI extends AbstractNpcAPI {
}
public ICustomNpc<?> spawnNPC(IWorld world, IPos pos) {
if (pos == null) {
return null;
}
return this.spawnNPC(world, pos.getX(), pos.getY(), pos.getZ());
}
@@ -1,7 +1,9 @@
package noppes.npcs.scripted;
import net.minecraft.block.Block;
import net.minecraft.block.BlockAir;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
@@ -15,6 +17,8 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntitySign;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
@@ -520,36 +524,229 @@ public class ScriptWorld implements IWorld {
return this.isBreakCancelled(pos.getX(),pos.getY(),pos.getZ());
}
public MovingObjectPosition func_147447_a(Vec3 startVec, Vec3 endVec, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision)
{
if (!Double.isNaN(startVec.xCoord) && !Double.isNaN(startVec.yCoord) && !Double.isNaN(startVec.zCoord))
{
if (!Double.isNaN(endVec.xCoord) && !Double.isNaN(endVec.yCoord) && !Double.isNaN(endVec.zCoord))
{
int endX = MathHelper.floor_double(endVec.xCoord);
int endY = MathHelper.floor_double(endVec.yCoord);
int endZ = MathHelper.floor_double(endVec.zCoord);
int l = MathHelper.floor_double(startVec.xCoord);
int i1 = MathHelper.floor_double(startVec.yCoord);
int j1 = MathHelper.floor_double(startVec.zCoord);
Block block = this.world.getBlock(l, i1, j1);
int k1 = this.world.getBlockMetadata(l, i1, j1);
if (block.canCollideCheck(k1, false))
{
MovingObjectPosition movingobjectposition = block.collisionRayTrace(this.world, l, i1, j1, startVec, endVec);
if (movingobjectposition != null)
{
return movingobjectposition;
}
}
k1 = 200;
while (k1-- >= 0)
{
if (Double.isNaN(startVec.xCoord) || Double.isNaN(startVec.yCoord) || Double.isNaN(startVec.zCoord))
{
return null;
}
if (l == endX && i1 == endY && j1 == endZ)
{
return null;
}
boolean flag6 = true;
boolean flag3 = true;
boolean flag4 = true;
double d0 = 999.0D;
double d1 = 999.0D;
double d2 = 999.0D;
if (endX > l)
{
d0 = (double)l + 1.0D;
}
else if (endX < l)
{
d0 = (double)l + 0.0D;
}
else
{
flag6 = false;
}
if (endY > i1)
{
d1 = (double)i1 + 1.0D;
}
else if (endY < i1)
{
d1 = (double)i1 + 0.0D;
}
else
{
flag3 = false;
}
if (endZ > j1)
{
d2 = (double)j1 + 1.0D;
}
else if (endZ < j1)
{
d2 = (double)j1 + 0.0D;
}
else
{
flag4 = false;
}
double d3 = 999.0D;
double d4 = 999.0D;
double d5 = 999.0D;
double d6 = endVec.xCoord - startVec.xCoord;
double d7 = endVec.yCoord - startVec.yCoord;
double d8 = endVec.zCoord - startVec.zCoord;
if (flag6)
{
d3 = (d0 - startVec.xCoord) / d6;
}
if (flag3)
{
d4 = (d1 - startVec.yCoord) / d7;
}
if (flag4)
{
d5 = (d2 - startVec.zCoord) / d8;
}
byte b0;
if (d3 < d4 && d3 < d5)
{
if (endX > l)
{
b0 = 4;
}
else
{
b0 = 5;
}
startVec.xCoord = d0;
startVec.yCoord += d7 * d3;
startVec.zCoord += d8 * d3;
}
else if (d4 < d5)
{
if (endY > i1)
{
b0 = 0;
}
else
{
b0 = 1;
}
startVec.xCoord += d6 * d4;
startVec.yCoord = d1;
startVec.zCoord += d8 * d4;
}
else
{
if (endZ > j1)
{
b0 = 2;
}
else
{
b0 = 3;
}
startVec.xCoord += d6 * d5;
startVec.yCoord += d7 * d5;
startVec.zCoord = d2;
}
Vec3 vec32 = Vec3.createVectorHelper(startVec.xCoord, startVec.yCoord, startVec.zCoord);
l = (int)(vec32.xCoord = (double)MathHelper.floor_double(startVec.xCoord));
if (b0 == 5)
{
--l;
++vec32.xCoord;
}
i1 = (int)(vec32.yCoord = (double)MathHelper.floor_double(startVec.yCoord));
if (b0 == 1)
{
--i1;
++vec32.yCoord;
}
j1 = (int)(vec32.zCoord = (double)MathHelper.floor_double(startVec.zCoord));
if (b0 == 3)
{
--j1;
++vec32.zCoord;
}
Block block1 = this.world.getBlock(l, i1, j1);
int l1 = this.world.getBlockMetadata(l, i1, j1);
MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(this.world, l, i1, j1, startVec, endVec);
if (movingobjectposition1 != null)
{
if (block1.canCollideCheck(l1, false) && stopOnBlock ||
block1.getMaterial().isLiquid() && stopOnLiquid ||
!(block1 instanceof BlockAir) && block1.getCollisionBoundingBoxFromPool(this.world,l,i1,j1) == null && !stopOnCollision)
{
return movingobjectposition1;
}
}
}
return null;
}
else
{
return null;
}
}
else
{
return null;
}
}
public IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
if (startPos.length != 3 || lookVector.length != 3) {
return null;
}
IPos pos;
Vec3 currentPos = Vec3.createVectorHelper(startPos[0], startPos[1], startPos[2]); int rep = 0;
Vec3 startVec = Vec3.createVectorHelper(startPos[0], startPos[1], startPos[2]);
Vec3 endVec = startVec.addVector(lookVector[0]*maxDistance,lookVector[1]*maxDistance,lookVector[2]*maxDistance);
while (rep++ < maxDistance + 10) {
currentPos = currentPos.addVector(lookVector[0], lookVector[1], lookVector[2]);
pos = NpcAPI.Instance().getIPos(currentPos.xCoord, currentPos.yCoord, currentPos.zCoord);
IBlock block = getBlock((int)currentPos.xCoord, (int)currentPos.yCoord, (int)currentPos.zCoord);
if (block != null && stopOnBlock) {
if ((!stopOnLiquid || block.getMCBlock() instanceof BlockLiquid)
&& (!stopOnCollision || block.canCollide()))
return pos;
}
double distance = Math.pow(
Math.pow(currentPos.xCoord-startPos[0],2)
+Math.pow(currentPos.yCoord-startPos[1],2)
+Math.pow(currentPos.zCoord-startPos[2],2)
, 0.5);
if (distance > maxDistance) {
return pos;
}
IPos endPos = NpcAPI.Instance().getIPos(endVec.xCoord,endVec.yCoord,endVec.zCoord);
if (!stopOnBlock && !stopOnLiquid && !stopOnCollision) {
return endPos;
}
return null;
MovingObjectPosition mob = this.func_147447_a(startVec,endVec,stopOnBlock,stopOnLiquid,stopOnCollision);
return mob != null ? NpcAPI.Instance().getIPos(mob.blockX,mob.blockY,mob.blockZ) : endPos;
}
public IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance) {
@@ -1,8 +1,5 @@
package noppes.npcs.scripted.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -12,9 +9,6 @@ import noppes.npcs.api.item.IItemStack;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.NpcAPI;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> implements IDBCPlayer {
public T player;
@@ -522,8 +516,9 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcState2");
}
public double getFormMastery(String formTree, byte form) {
public double getRacialFormMastery(byte form) {
try {
String formTree = this.getRacialTreeName();
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) {
String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMastery" + formTree).split(";");
@@ -534,8 +529,9 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
return 0.0D;
}
public void setFormMastery(String formTree, byte form, double value) {
public void setRacialFormMastery(byte form, double value) {
try {
String formTree = this.getRacialTreeName();
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) {
String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMastery" + formTree).split(";");
@@ -558,8 +554,9 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
} catch (Exception ignored) {}
}
public void addFormMastery(String formTree, byte form, double value) {
public void addRacialFormMastery(byte form, double value) {
try {
String formTree = this.getRacialTreeName();
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) {
String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMastery" + formTree).split(";");
@@ -583,6 +580,107 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
} catch (Exception ignored) {}
}
private String getRacialTreeName() {
switch (this.getRace()) {
case 0:
return "Racial_Human";
case 1:
return "Racial_Saiyan";
case 2:
return "Racial_Half-Saiyan";
case 3:
return "Racial_Namekian";
case 4:
return "Racial_Arcosian";
case 5:
return "Racial_Majin";
}
return "Racial_Human";
}
public double getOtherFormMastery(String formName) {
try {
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMasteryNonRacial")) {
String masteryData = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMasteryNonRacial");
if (!masteryData.contains(formName)) {
return 0.0D;
}
String[] formMasteries = masteryData.split(";");
for (String masteryString : formMasteries) {
if (masteryString.split(",")[0].equals(formName)) {
return Double.parseDouble(masteryString.split(",")[1]);
}
}
}
} catch (Exception ignored) {}
return 0.0D;
}
public void setOtherFormMastery(String formName, double value) {
try {
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMasteryNonRacial")) {
String masteryData = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMasteryNonRacial");
if (!masteryData.contains(formName)) {
return;
}
String[] formMasteries = masteryData.split(";");
for (int i = 0; i < formMasteries.length; i++) {
String name = formMasteries[i].split(",")[0];
if (name.equals(formName)) {
formMasteries[i] = name + "," + value;
}
}
StringBuilder masteryString = new StringBuilder();
for (int i = 0; i < formMasteries.length; i++) {
masteryString.append(formMasteries[i]);
if (i < formMasteries.length - 1) {
masteryString.append(';');
}
}
player.getEntityData().getCompoundTag("PlayerPersisted").
setString("jrmcFormMasteryNonRacial", String.valueOf(masteryString));
}
} catch (Exception ignored) {}
}
public void addOtherFormMastery(String formName, double value) {
try {
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMasteryNonRacial")) {
String masteryData = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMasteryNonRacial");
if (!masteryData.contains(formName)) {
return;
}
String[] formMasteries = masteryData.split(";");
for (int i = 0; i < formMasteries.length; i++) {
String name = formMasteries[i].split(",")[0];
if (name.equals(formName)) {
double newMastery = Double.parseDouble(formMasteries[i].split(",")[1]) + value;
formMasteries[i] = name + "," + newMastery;
}
}
StringBuilder masteryString = new StringBuilder();
for (int i = 0; i < formMasteries.length; i++) {
masteryString.append(formMasteries[i]);
if (i < formMasteries.length - 1) {
masteryString.append(';');
}
}
player.getEntityData().getCompoundTag("PlayerPersisted").
setString("jrmcFormMasteryNonRacial", String.valueOf(masteryString));
}
} catch (Exception ignored) {}
}
public void setPowerPoints(int points){
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcArcRsrv",points);
}
@@ -162,11 +162,7 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
}
public IBlock getLookingAtBlock(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
Vec3 lookVec = entity.getLookVec();
return getWorld().rayCastBlock(
new double[] {entity.posX, entity.posY+entity.getEyeHeight(), entity.posZ},
new double[] {lookVec.xCoord, lookVec.yCoord, lookVec.zCoord},
maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision);
return NpcAPI.Instance().getIBlock(getWorld(),getLookingAtPos(maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision));
}
public IBlock getLookingAtBlock(int maxDistance) {
@@ -176,7 +172,7 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
public IPos getLookingAtPos(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
Vec3 lookVec = entity.getLookVec();
return getWorld().rayCastPos(
new double[] {entity.posX, entity.posY+entity.getEyeHeight(), entity.posZ},
new double[] {entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ},
new double[] {lookVec.xCoord, lookVec.yCoord, lookVec.zCoord},
maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision);
}
@@ -27,6 +27,7 @@ import noppes.npcs.api.item.IItemStack;
import noppes.npcs.api.overlay.ICustomOverlay;
import noppes.npcs.config.ConfigScript;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestRepeat;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.containers.ContainerCustomGui;
import noppes.npcs.controllers.*;
@@ -270,7 +271,11 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
if (quest == null)
return;
PlayerData data = PlayerDataController.instance.getPlayerData(player);
data.questData.finishedQuests.put(id, System.currentTimeMillis());
if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY)
data.questData.finishedQuests.put(quest.id, System.currentTimeMillis());
else
data.questData.finishedQuests.put(quest.id, player.worldObj.getTotalWorldTime());
}
/**
@@ -19,7 +19,6 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
public List<Integer> errored = new ArrayList();
public String scriptLanguage = "ECMAScript";
public boolean enabled = false;
public long lastInited = -1L;
public boolean loaded = false;
public boolean durabilityShow = false;
@@ -43,11 +42,8 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
public float rotationX, rotationY, rotationZ;
public float rotationXRate, rotationYRate, rotationZRate;
public int width = -1, height = -1;
public ScriptCustomItem(ItemStack item) {
super(item);
loadScriptData();
loadItemData();
}
@@ -74,16 +70,12 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
if (!this.loaded) {
this.loadScriptData();
this.loaded = true;
if (type != EnumScriptType.INIT) {
EventHooks.onScriptItemInit(this);
}
}
if (this.isEnabled()) {
if (ScriptController.Instance.lastLoaded > this.lastInited) {
this.lastInited = ScriptController.Instance.lastLoaded;
if (type != EnumScriptType.INIT) {
EventHooks.onScriptItemInit(this);
}
}
for (int i = 0; i < this.scripts.size(); i++) {
ScriptContainer script = this.scripts.get(i);
if (!this.errored.contains(i)) {
@@ -421,12 +413,18 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
}
c.setTag("ScriptedData", this.getScriptNBT(new NBTTagCompound()));
for (ScriptContainer container : this.scripts) {
container.setEngine(this.getLanguage());
}
}
public void loadScriptData() {
NBTTagCompound c = this.item.getTagCompound();
if (c != null) {
this.setScriptNBT(c.getCompoundTag("ScriptedData"));
for (ScriptContainer container : this.scripts) {
container.setEngine(this.getLanguage());
}
}
}
@@ -0,0 +1,11 @@
package noppes.npcs.util;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
public class CustomNPCsThreader {
private final static ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
public static final Executor playerDataThread = Executors.newSingleThreadExecutor();
}
@@ -24,8 +24,8 @@ public class NBTJsonUtil {
json = json.trim();
JsonFile file = new JsonFile(json);
if(!json.startsWith("{") || !json.endsWith("}"))
throw new JsonException("Not properly incapsulated between { }", file);
throw new JsonException("Not properly encapsulated between { }", file);
NBTTagCompound compound = new NBTTagCompound();
FillCompound(compound, file);
return compound;
@@ -36,7 +36,7 @@ public class NBTJsonUtil {
json.cut(1);
if(json.startsWith("}"))
return;
int index = json.indexOf(":");
int index = json.findObjectColonIndex();
if(index < 1)
throw new JsonException("Expected key after ," ,json);
@@ -85,6 +85,16 @@ public class NBTJsonUtil {
if(!json.startsWith("]")){
throw new JsonException("Expected ]", json);
}
if (json.startsWith("]b")) {
json.cut(2);
byte[] arr = new byte[list.tagCount()];
for(int i = 0; list.tagCount() > 0 ; i++){
arr[i] = ((NBTTagInt)list.removeTag(0)).func_150290_f();
}
return new NBTTagByteArray(arr);
}
json.cut(1);
if(list.func_150303_d() == 3){
@@ -156,7 +166,19 @@ public class NBTJsonUtil {
private static JsonLine ReadTag(String name, NBTBase base, List<JsonLine> list){
if(!name.isEmpty())
name = "\"" + name + "\": ";
if(base.getId() == 8){//NBTTagString
if (base.getId() == 7) {//NBTTagByteArray
list.add(new JsonLine(name + "["));
byte[] bytes = ((NBTTagByteArray) base).func_150292_c();
for(int i = 0; i < (bytes.length-1); i++) {
list.add(new JsonLine(String.format("%s,", bytes[i])));
}
if (bytes.length > 0) {
list.add(new JsonLine(String.format("%s", bytes[bytes.length-1])));
}
list.add(new JsonLine("]b"));
}
else if(base.getId() == 8){//NBTTagString
String data = ((NBTTagString)base).func_150285_a_();
data = data.replace("\"", "\\\""); //replace " with \"
list.add(new JsonLine(name + "\"" + data + "\""));
@@ -225,7 +247,8 @@ public class NBTJsonUtil {
public boolean reduceTab(){
int length = line.length();
return length == 1 && (line.endsWith("}") || line.endsWith("]"))
|| length == 2 && (line.endsWith("},") ||line.endsWith("],"));
|| length == 2 && (line.endsWith("},") ||line.endsWith("],") || line.endsWith("]b"))
|| length == 3 && (line.endsWith("]b,"));
}
public boolean increaseTab(){
@@ -283,6 +306,24 @@ public class NBTJsonUtil {
return "Line: " + lines.length + ", Pos: " + pos + ", Text: " + line;
}
public int findObjectColonIndex() {
int trueQuotesAmount = 0;
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) == '"') {
if (i > 1 && text.charAt(i-1) != '\\' || i == 0) {
trueQuotesAmount++;
}
}
if (trueQuotesAmount == 2) {
return text.indexOf(":", i);
}
}
return -1;
}
public boolean startsWith(String... ss) {
for(String s : ss)
if(text.startsWith(s))
@@ -3,7 +3,6 @@ package tconstruct.client.tabs;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.C0DPacketCloseWindow;
import noppes.npcs.CustomItems;
import noppes.npcs.client.gui.player.GuiQuestLog;
@@ -410,13 +410,13 @@ cloner.tagFilters=Tag Filters
cloner.tagVisibility=Tag Visibility
cloner.wandTags=Wand Tags
cloner.npcTags=NPC Tags
cloner.selectedTags=Selected Tags
cloner.order=Sort Order
cloner.ascending=Ascending
cloner.descending=Descending
cloner.type=Sort Type
cloner.name=Name
cloner.date=Date
cloner.wandtags=Wand Tags
cloner.wandtagsapplied=Wand Tags will be applied
tags.allTags=All Tags