mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-24 21:04:27 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b82177d8d9 | ||
|
|
eb77ae3b99 | ||
|
|
2b1449b5f3 | ||
|
|
221f00ccf4 | ||
|
|
cf82314181 | ||
|
|
ee33a57323 | ||
|
|
ae1f33d327 | ||
|
|
60dbcc7146 | ||
|
|
0b7bd2f009 | ||
|
|
8e247f8232 | ||
|
|
92097769d9 | ||
|
|
13953edaaf | ||
|
|
9db86d0870 | ||
|
|
8d21291e7b | ||
|
|
88eb96e784 | ||
|
|
78978bda92 | ||
|
|
314bc462f0 | ||
|
|
b04ac96690 | ||
|
|
97c97cf939 | ||
|
|
d4a62b1334 | ||
|
|
ceac11d251 | ||
|
|
f2faf3513d | ||
|
|
515a6e8550 | ||
|
|
142fbe51e2 | ||
|
|
e0360f9a6e | ||
|
|
f5bae9099d | ||
|
|
241120c32a | ||
|
|
9ff341bd17 | ||
|
|
dd5ca106bc | ||
|
|
3cba19cea2 | ||
|
|
6859b2da47 | ||
|
|
fa7fb7f734 | ||
|
|
6f7ea7340c | ||
|
|
1183f7d91b | ||
|
|
0c07260999 | ||
|
|
8a4c9f6f6b | ||
|
|
6ea7244a25 | ||
|
|
809b1f269c | ||
|
|
6ee79f181f | ||
|
|
110a7c71fb | ||
|
|
f7c0f2bdf9 | ||
|
|
8cd4cfd82c | ||
|
|
745bebaf73 | ||
|
|
e1c4c2b786 | ||
|
|
d08e4fc925 | ||
|
|
a6c0acdbcf | ||
|
|
bad130b937 | ||
|
|
b25a598580 | ||
|
|
e2e7b660d9 | ||
|
|
7e88ebb696 | ||
|
|
05926667c6 | ||
|
|
5ed264f3bd | ||
|
|
9c8ae316ff | ||
|
|
8ed683800f | ||
|
|
ed97534e67 | ||
|
|
dd14f3ded0 | ||
|
|
d95f2476f9 | ||
|
|
6f7e2e8b18 | ||
|
|
e38e592acb | ||
|
|
de6fb94562 | ||
|
|
96c621fb14 | ||
|
|
8e389a66b9 | ||
|
|
f56358f4f9 |
No files matched your search
@@ -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
|
TL;DR
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
> You CAN
|
||||||
in the Software without restriction, including without limitation the rights
|
-- Fork and modify the code.
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
-- Submit Pull Requests to this repository.
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
-- Copy portions of this code for use in other projects.
|
||||||
furnished to do so, subject to the following conditions:
|
-- 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
|
> You CANNOT
|
||||||
copies or substantial portions of the Software.
|
-- 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
|
> You MUST
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
-- 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.
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
General Clauses
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
Clauses that apply in general to any of the uses that follow.
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
- Personal Permission Clause
|
||||||
SOFTWARE.
|
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.
|
||||||
+7
-4
@@ -34,7 +34,7 @@ configurations {
|
|||||||
|
|
||||||
apply plugin: 'forge'
|
apply plugin: 'forge'
|
||||||
|
|
||||||
version = "1.8"
|
version = "1.8.2"
|
||||||
group= "com.kamkeel.customnpc-plus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
group= "com.kamkeel.customnpc-plus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = "CustomNPC-Plus"
|
archivesBaseName = "CustomNPC-Plus"
|
||||||
|
|
||||||
@@ -89,8 +89,6 @@ processResources
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {main { output.resourcesDir = output.classesDir }}
|
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
from sourceSets.api.output
|
from sourceSets.api.output
|
||||||
|
|
||||||
@@ -113,7 +111,7 @@ def refMapForYourConfig = 'customnpcs.refmap.json'
|
|||||||
def relativePathToMixinAP = 'tools/mixin-0.8-SNAPSHOT.jar'
|
def relativePathToMixinAP = 'tools/mixin-0.8-SNAPSHOT.jar'
|
||||||
|
|
||||||
if(!embedMixin){
|
if(!embedMixin){
|
||||||
version += "+nomixin"
|
version += "-nomixin"
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -202,3 +200,8 @@ sourceSets {
|
|||||||
ext.refMap = refMapForYourConfig
|
ext.refMap = refMapForYourConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task deobfJar(type: Jar) {
|
||||||
|
from sourceSets.main.output
|
||||||
|
classifier = 'dev'
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
+1
-1
Submodule src/api updated: 3f8d6e5581...5685f9a0f8.
@@ -50,7 +50,7 @@ public class CmdDialog extends ChMcLogger {
|
|||||||
}
|
}
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.dialogData.dialogsRead.add(diagid);
|
playerdata.dialogData.dialogsRead.add(diagid);
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.save();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ public class CmdDialog extends ChMcLogger {
|
|||||||
}
|
}
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.dialogData.dialogsRead.remove(diagid);
|
playerdata.dialogData.dialogsRead.remove(diagid);
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.save();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,173 +41,170 @@ import foxz.commandhelper.permissions.PlayerOnly;
|
|||||||
)
|
)
|
||||||
public class CmdNoppes extends ChMcLogger {
|
public class CmdNoppes extends ChMcLogger {
|
||||||
|
|
||||||
public CmdFaction cmdfaction = new CmdFaction(ctorParm);
|
public CmdFaction cmdfaction = new CmdFaction(ctorParm);
|
||||||
public CmdNpc cmdnpc= new CmdNpc(ctorParm);
|
public CmdNpc cmdnpc = new CmdNpc(ctorParm);
|
||||||
public static Map<String,Class<?>> SlayMap = new LinkedHashMap<String,Class<?>>();
|
public static Map<String, Class<?>> SlayMap = new LinkedHashMap<String, Class<?>>();
|
||||||
|
|
||||||
public CmdNoppes(Object sender) {
|
public CmdNoppes(Object sender) {
|
||||||
super(sender);
|
super(sender);
|
||||||
|
|
||||||
SlayMap.clear();
|
SlayMap.clear();
|
||||||
|
|
||||||
SlayMap.put("all",EntityLivingBase.class);
|
SlayMap.put("all", EntityLivingBase.class);
|
||||||
SlayMap.put("mobs",EntityMob.class);
|
SlayMap.put("mobs", EntityMob.class);
|
||||||
SlayMap.put("animals", EntityAnimal.class);
|
SlayMap.put("animals", EntityAnimal.class);
|
||||||
SlayMap.put("items", EntityItem.class);
|
SlayMap.put("items", EntityItem.class);
|
||||||
SlayMap.put("xporbs", EntityXPOrb.class);
|
SlayMap.put("xporbs", EntityXPOrb.class);
|
||||||
SlayMap.put("npcs", EntityNPCInterface.class);
|
SlayMap.put("npcs", EntityNPCInterface.class);
|
||||||
|
|
||||||
HashMap<String,Class<?>> list = new HashMap<String,Class<?>>(EntityList.stringToClassMapping);
|
HashMap<String, Class<?>> list = new HashMap<String, Class<?>>(EntityList.stringToClassMapping);
|
||||||
for(String name : list.keySet()){
|
for (String name : list.keySet()) {
|
||||||
Class<?> cls = list.get(name);
|
Class<?> cls = list.get(name);
|
||||||
if(EntityNPCInterface.class.isAssignableFrom(cls))
|
if (EntityNPCInterface.class.isAssignableFrom(cls))
|
||||||
continue;
|
continue;
|
||||||
if(!EntityLivingBase.class.isAssignableFrom(cls))
|
if (!EntityLivingBase.class.isAssignableFrom(cls))
|
||||||
continue;
|
continue;
|
||||||
SlayMap.put(name.toLowerCase(), list.get(name));
|
SlayMap.put(name.toLowerCase(), list.get(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
SlayMap.remove("monster");
|
SlayMap.remove("monster");
|
||||||
SlayMap.remove("mob");
|
SlayMap.remove("mob");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SubCommand(
|
@SubCommand(
|
||||||
name = "faction",
|
name = "faction",
|
||||||
desc = "Faction operations",
|
desc = "Faction operations",
|
||||||
usage = "<player> <faction> <command>",
|
usage = "<player> <faction> <command>",
|
||||||
permissions = {OpOnly.class, ParamCheck.class}
|
permissions = {OpOnly.class, ParamCheck.class}
|
||||||
)
|
)
|
||||||
public Boolean faction(String[] args) {
|
public Boolean faction(String[] args) {
|
||||||
String playername = args[0];
|
String playername = args[0];
|
||||||
String factionname = args[1];
|
String factionname = args[1];
|
||||||
|
|
||||||
cmdfaction.data = getPlayersData(playername);
|
cmdfaction.data = getPlayersData(playername);
|
||||||
if (cmdfaction.data.isEmpty()) {
|
if (cmdfaction.data.isEmpty()) {
|
||||||
sendmessage(String.format("Unknow player '%s'", playername));
|
sendmessage(String.format("Unknow player '%s'", playername));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try{
|
try {
|
||||||
cmdfaction.selectedFaction = FactionController.getInstance().get(Integer.parseInt(factionname));
|
cmdfaction.selectedFaction = FactionController.getInstance().get(Integer.parseInt(factionname));
|
||||||
}
|
} catch (NumberFormatException e) {
|
||||||
catch(NumberFormatException e){
|
cmdfaction.selectedFaction = FactionController.getInstance().getFactionFromName(factionname); // get faction data
|
||||||
cmdfaction.selectedFaction = FactionController.getInstance().getFactionFromName(factionname); // get faction data
|
}
|
||||||
}
|
if (cmdfaction.selectedFaction == null) {
|
||||||
if (cmdfaction.selectedFaction == null) {
|
sendmessage(String.format("Unknow facion '%s", factionname));
|
||||||
sendmessage(String.format("Unknow facion '%s", factionname));
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
args = Arrays.copyOfRange(args, 2, args.length);
|
||||||
args = Arrays.copyOfRange(args, 2, args.length);
|
cmdfaction.processCommand(this.pcParam, args);
|
||||||
cmdfaction.processCommand(this.pcParam, args);
|
|
||||||
|
|
||||||
for(PlayerData playerdata : cmdfaction.data){
|
for (PlayerData playerdata : cmdfaction.data) {
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.save();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubCommand(
|
@SubCommand(
|
||||||
desc="NPC manipulations",
|
desc = "NPC manipulations",
|
||||||
usage="<npc> <command>",
|
usage = "<npc> <command>",
|
||||||
permissions={OpOnly.class,ParamCheck.class}
|
permissions = {OpOnly.class, ParamCheck.class}
|
||||||
)
|
)
|
||||||
public boolean npc(String[] args){
|
public boolean npc(String[] args) {
|
||||||
String npcname=args[0].replace("%", " ");
|
String npcname = args[0].replace("%", " ");
|
||||||
args = Arrays.copyOfRange(args, 1, args.length);
|
args = Arrays.copyOfRange(args, 1, args.length);
|
||||||
if(args[0].equalsIgnoreCase("create")){
|
if (args[0].equalsIgnoreCase("create")) {
|
||||||
cmdnpc.processCommand(this.pcParam, new String[]{args[0], npcname});
|
cmdnpc.processCommand(this.pcParam, new String[]{args[0], npcname});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int x = pcParam.getPlayerCoordinates().posX;
|
int x = pcParam.getPlayerCoordinates().posX;
|
||||||
int y = pcParam.getPlayerCoordinates().posY;
|
int y = pcParam.getPlayerCoordinates().posY;
|
||||||
int z = pcParam.getPlayerCoordinates().posZ;
|
int z = pcParam.getPlayerCoordinates().posZ;
|
||||||
List<EntityNPCInterface> list = getNearbeEntityFromPlayer(EntityNPCInterface.class, pcParam.getEntityWorld(), x, y, z, 80);
|
List<EntityNPCInterface> list = getNearbeEntityFromPlayer(EntityNPCInterface.class, pcParam.getEntityWorld(), x, y, z, 80);
|
||||||
EntityNPCInterface closest = null;
|
EntityNPCInterface closest = null;
|
||||||
for (EntityNPCInterface npc : list) {
|
for (EntityNPCInterface npc : list) {
|
||||||
String name = npc.display.name.replace(" ", "_");
|
String name = npc.display.name.replace(" ", "_");
|
||||||
if (name.equalsIgnoreCase(npcname)){
|
if (name.equalsIgnoreCase(npcname)) {
|
||||||
if(closest == null || closest.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
|
if (closest == null || closest.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
|
||||||
closest = npc;
|
closest = npc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(closest != null){
|
if (closest != null) {
|
||||||
cmdnpc.selectedNpc=closest;
|
cmdnpc.selectedNpc = closest;
|
||||||
cmdnpc.processCommand(this.pcParam, args);
|
cmdnpc.processCommand(this.pcParam, args);
|
||||||
cmdnpc.selectedNpc = null;
|
cmdnpc.selectedNpc = null;
|
||||||
}
|
} else
|
||||||
else
|
sendmessage(String.format("NPC '%s' was not found", npcname));
|
||||||
sendmessage(String.format("NPC '%s' was not found",npcname));
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@SubCommand(
|
@SubCommand(
|
||||||
name = "slay",
|
name = "slay",
|
||||||
desc = "Kills given entity within range. Also has all, mobs, animal options. Can have multiple types",
|
desc = "Kills given entity within range. Also has all, mobs, animal options. Can have multiple types",
|
||||||
usage = "<type>.. [range]",
|
usage = "<type>.. [range]",
|
||||||
permissions = {PlayerOnly.class, OpOnly.class, ParamCheck.class}
|
permissions = {PlayerOnly.class, OpOnly.class, ParamCheck.class}
|
||||||
)
|
)
|
||||||
public Boolean slay(String[] args) {
|
public Boolean slay(String[] args) {
|
||||||
EntityPlayerMP player = (EntityPlayerMP) pcParam;
|
EntityPlayerMP player = (EntityPlayerMP) pcParam;
|
||||||
ArrayList<Class<?>> toDelete = new ArrayList<Class<?>>();
|
ArrayList<Class<?>> toDelete = new ArrayList<Class<?>>();
|
||||||
boolean deleteNPCs = false;
|
boolean deleteNPCs = false;
|
||||||
for(String delete : args){
|
for (String delete : args) {
|
||||||
delete = delete.toLowerCase();
|
delete = delete.toLowerCase();
|
||||||
Class<?> cls = SlayMap.get(delete);
|
Class<?> cls = SlayMap.get(delete);
|
||||||
if(cls != null)
|
if (cls != null)
|
||||||
toDelete.add(cls);
|
toDelete.add(cls);
|
||||||
if(delete.equals("mobs")){
|
if (delete.equals("mobs")) {
|
||||||
toDelete.add(EntityGhast.class);
|
toDelete.add(EntityGhast.class);
|
||||||
toDelete.add(EntityDragon.class);
|
toDelete.add(EntityDragon.class);
|
||||||
}
|
}
|
||||||
if(delete.equals("npcs"))
|
if (delete.equals("npcs"))
|
||||||
deleteNPCs = true;
|
deleteNPCs = true;
|
||||||
}
|
}
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int range = 120;
|
int range = 120;
|
||||||
try{
|
try {
|
||||||
range = Integer.parseInt(args[args.length - 1]);
|
range = Integer.parseInt(args[args.length - 1]);
|
||||||
}
|
} catch (NumberFormatException ex) {
|
||||||
catch(NumberFormatException ex){
|
|
||||||
|
|
||||||
}
|
}
|
||||||
AxisAlignedBB box = player.boundingBox.expand(range, range, range);
|
AxisAlignedBB box = player.boundingBox.expand(range, range, range);
|
||||||
List<Entity> list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, box);
|
List<Entity> list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, box);
|
||||||
|
|
||||||
for(Entity entity : list){
|
for (Entity entity : list) {
|
||||||
if(entity instanceof EntityPlayer)
|
if (entity instanceof EntityPlayer)
|
||||||
continue;
|
continue;
|
||||||
if(entity instanceof EntityTameable && ((EntityTameable)entity).isTamed())
|
if (entity instanceof EntityTameable && ((EntityTameable) entity).isTamed())
|
||||||
continue;
|
continue;
|
||||||
if(entity instanceof EntityNPCInterface && !deleteNPCs)
|
if (entity instanceof EntityNPCInterface && !deleteNPCs)
|
||||||
continue;
|
continue;
|
||||||
if(delete(entity,toDelete))
|
if (delete(entity, toDelete))
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
if(toDelete.contains(EntityXPOrb.class)){
|
if (toDelete.contains(EntityXPOrb.class)) {
|
||||||
list = player.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, box);
|
list = player.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, box);
|
||||||
for(Entity entity : list){
|
for (Entity entity : list) {
|
||||||
entity.isDead = true;
|
entity.isDead = true;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(toDelete.contains(EntityItem.class)){
|
if (toDelete.contains(EntityItem.class)) {
|
||||||
list = player.worldObj.getEntitiesWithinAABB(EntityItem.class, box);
|
list = player.worldObj.getEntitiesWithinAABB(EntityItem.class, box);
|
||||||
for(Entity entity : list){
|
for (Entity entity : list) {
|
||||||
entity.isDead = true;
|
entity.isDead = true;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.addChatMessage(new ChatComponentTranslation(count + " entities deleted"));
|
player.addChatMessage(new ChatComponentTranslation(count + " entities deleted"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean delete(Entity entity, ArrayList<Class<?>> toDelete) {
|
private boolean delete(Entity entity, ArrayList<Class<?>> toDelete) {
|
||||||
for(Class<?> delete : toDelete){
|
for (Class<?> delete : toDelete) {
|
||||||
if(delete == EntityAnimal.class && (entity instanceof EntityHorse)){
|
if (delete == EntityAnimal.class && (entity instanceof EntityHorse)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(delete.isAssignableFrom(entity.getClass())){
|
if (delete.isAssignableFrom(entity.getClass())) {
|
||||||
entity.isDead = true;
|
entity.isDead = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -215,53 +212,17 @@ public class CmdNoppes extends ChMcLogger {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List addTabCompletion(ICommandSender par1, String[] args) {
|
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()]));
|
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));
|
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 CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"add", "subtract", "set", "reset", "drop", "create"});
|
||||||
}
|
}
|
||||||
return super.addTabCompletion(par1, args);
|
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>
|
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ public class CmdQuest extends ChMcLogger{
|
|||||||
continue;
|
continue;
|
||||||
QuestData questdata = new QuestData(quest);
|
QuestData questdata = new QuestData(quest);
|
||||||
playerdata.questData.activeQuests.put(questid, questdata);
|
playerdata.questData.activeQuests.put(questid, questdata);
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.save();
|
||||||
if(playerdata.player != null){
|
if(playerdata.player != null){
|
||||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
|
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
|
||||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "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){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis());
|
playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis());
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.save();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ public class CmdQuest extends ChMcLogger{
|
|||||||
}
|
}
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.questData.activeQuests.remove(questid);
|
playerdata.questData.activeQuests.remove(questid);
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.save();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -156,7 +156,7 @@ public class CmdQuest extends ChMcLogger{
|
|||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.questData.activeQuests.remove(questid);
|
playerdata.questData.activeQuests.remove(questid);
|
||||||
playerdata.questData.finishedQuests.remove(questid);
|
playerdata.questData.finishedQuests.remove(questid);
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.save();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-5
@@ -1,14 +1,11 @@
|
|||||||
package kamkeel;
|
package kamkeel.command;
|
||||||
|
|
||||||
import net.minecraft.command.CommandBase;
|
|
||||||
import net.minecraft.command.CommandException;
|
import net.minecraft.command.CommandException;
|
||||||
import net.minecraft.command.ICommandSender;
|
import net.minecraft.command.ICommandSender;
|
||||||
import net.minecraft.entity.monster.EntityEnderman;
|
|
||||||
import noppes.npcs.controllers.AnimationController;
|
import noppes.npcs.controllers.AnimationController;
|
||||||
import noppes.npcs.controllers.PlayerDataController;
|
import noppes.npcs.controllers.PlayerDataController;
|
||||||
import noppes.npcs.controllers.data.Animation;
|
import noppes.npcs.controllers.data.Animation;
|
||||||
import noppes.npcs.controllers.data.PlayerData;
|
import noppes.npcs.controllers.data.PlayerData;
|
||||||
import noppes.npcs.controllers.data.PlayerFactionData;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -49,7 +46,7 @@ public class AnimationCommand extends CommandKamkeelBase {
|
|||||||
|
|
||||||
processSubCommand(sender, args[1], Arrays.copyOfRange(args, 2, args.length));
|
processSubCommand(sender, args[1], Arrays.copyOfRange(args, 2, args.length));
|
||||||
data.get(0).animationData.updateClient();
|
data.get(0).animationData.updateClient();
|
||||||
data.get(0).savePlayerDataOnFile();
|
data.get(0).save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubCommand(desc = "enable animation")
|
@SubCommand(desc = "enable animation")
|
||||||
+52
-20
@@ -1,4 +1,4 @@
|
|||||||
package kamkeel;
|
package kamkeel.command;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -39,9 +39,14 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
int tab = 0;
|
int tab = 0;
|
||||||
try{
|
try{
|
||||||
tab = Integer.parseInt(args[1]);
|
tab = Integer.parseInt(args[1]);
|
||||||
|
if(tab < 0 || tab > 15){
|
||||||
|
sendError(sender, "Tab must be within 1-15");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(NumberFormatException ex){
|
catch(NumberFormatException ex){
|
||||||
|
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = sender.getPlayerCoordinates().posX;
|
int x = sender.getPlayerCoordinates().posX;
|
||||||
@@ -58,6 +63,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
if(!npc.writeToNBTOptional(compound))
|
if(!npc.writeToNBTOptional(compound))
|
||||||
return;
|
return;
|
||||||
ServerCloneController.Instance.addClone(compound, name, tab);
|
ServerCloneController.Instance.addClone(compound, name, tab);
|
||||||
|
sendResult(sender, String.format("Added NPC \u00A7e%s\u00A77 to Tab \u00A7b%d\u00A77", name, tab));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,11 +77,17 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
sendMessage(sender, "--- Stored NPCs --- (server side)");
|
sendMessage(sender, "--- Stored NPCs --- (server side)");
|
||||||
int tab = 0;
|
int tab = 0;
|
||||||
try{
|
try{
|
||||||
tab = Integer.parseInt(args[0]);
|
tab = Integer.parseInt(args[1]);
|
||||||
|
if(tab < 0 || tab > 15){
|
||||||
|
sendError(sender, "Tab must be within 1-15");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(NumberFormatException ex){
|
catch(NumberFormatException ex){
|
||||||
|
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String name : ServerCloneController.Instance.getClones(tab)) {
|
for (String name : ServerCloneController.Instance.getClones(tab)) {
|
||||||
sendMessage(sender, name);
|
sendMessage(sender, name);
|
||||||
}
|
}
|
||||||
@@ -91,11 +103,17 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
String nametodel = args[0];
|
String nametodel = args[0];
|
||||||
int tab = 0;
|
int tab = 0;
|
||||||
try{
|
try{
|
||||||
tab = Integer.parseInt(args[1]);
|
tab = Integer.parseInt(args[1]);
|
||||||
|
if(tab < 0 || tab > 15){
|
||||||
|
sendError(sender, String.format("Tab must be within 1-15"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(NumberFormatException ex){
|
catch(NumberFormatException ex){
|
||||||
|
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean deleted = false;
|
boolean deleted = false;
|
||||||
for(String name : ServerCloneController.Instance.getClones(tab)){
|
for(String name : ServerCloneController.Instance.getClones(tab)){
|
||||||
if(nametodel.equalsIgnoreCase(name)){
|
if(nametodel.equalsIgnoreCase(name)){
|
||||||
@@ -105,7 +123,9 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ServerCloneController.Instance.removeClone(nametodel, tab)) {
|
if (!ServerCloneController.Instance.removeClone(nametodel, tab)) {
|
||||||
throw new CommandException(String.format("Npc '%s' wasn't found", nametodel));
|
sendError(sender, String.format("NPC '%s' was not found", nametodel));
|
||||||
|
} else {
|
||||||
|
sendResult(sender, String.format("Removed NPC \u00A7e%s\u00A77 from Tab \u00A7b%d\u00A77", nametodel, tab));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,14 +139,20 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
int tab = 0;
|
int tab = 0;
|
||||||
try{
|
try{
|
||||||
tab = Integer.parseInt(args[1]);
|
tab = Integer.parseInt(args[1]);
|
||||||
|
if(tab < 0 || tab > 15){
|
||||||
|
sendError(sender, String.format("Tab must be within 1-15"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(NumberFormatException ex){
|
catch(NumberFormatException ex){
|
||||||
|
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String newname=null;
|
String newname=null;
|
||||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
|
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
|
||||||
if(compound == null){
|
if(compound == null){
|
||||||
sendMessage(sender, "Unknown npc");
|
sendError(sender, "Unknown npc");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
World world = sender.getEntityWorld();
|
World world = sender.getEntityWorld();
|
||||||
@@ -142,14 +168,15 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
location = par[1];
|
location = par[1];
|
||||||
world = Utils.getWorld(par[0]);
|
world = Utils.getWorld(par[0]);
|
||||||
if (world == null){
|
if (world == null){
|
||||||
throw new CommandException(String.format("'%s' is an unknown world", par[0]));
|
sendError(sender, String.format("'%s' is an unknown world", par[0]));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location.contains(",")){
|
if (location.contains(",")){
|
||||||
par = location.split(",");
|
par = location.split(",");
|
||||||
if (par.length != 3){
|
if (par.length != 3){
|
||||||
sendMessage(sender, "Location need be x,y,z");
|
sendError(sender, "Location need be x,y,z");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
@@ -157,7 +184,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
posY = CommandBase.func_110665_a(sender, posY, par[1].trim(), 0, 0);
|
posY = CommandBase.func_110665_a(sender, posY, par[1].trim(), 0, 0);
|
||||||
posZ = CommandBase.func_110666_a(sender, posZ, par[2]);
|
posZ = CommandBase.func_110666_a(sender, posZ, par[2]);
|
||||||
} catch(NumberFormatException ex){
|
} catch(NumberFormatException ex){
|
||||||
sendMessage(sender, "Location should be in numbers");
|
sendError(sender, "Location should be in numbers");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args.length > 3){
|
if (args.length > 3){
|
||||||
@@ -169,7 +196,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given
|
if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given
|
||||||
sendMessage(sender, "Location needed");
|
sendError(sender, "Location needed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,9 +221,14 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
int tab = 0;
|
int tab = 0;
|
||||||
try{
|
try{
|
||||||
tab = Integer.parseInt(args[1]);
|
tab = Integer.parseInt(args[1]);
|
||||||
|
if(tab < 0 || tab > 15){
|
||||||
|
sendError(sender, String.format("Tab must be within 1-15"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(NumberFormatException ex){
|
catch(NumberFormatException ex){
|
||||||
|
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int width, height;
|
int width, height;
|
||||||
@@ -205,7 +237,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
height = Integer.parseInt(args[3]);
|
height = Integer.parseInt(args[3]);
|
||||||
}
|
}
|
||||||
catch(NumberFormatException ex){
|
catch(NumberFormatException ex){
|
||||||
sendMessage(sender, "length or width was not a number");
|
sendError(sender, "length or width was not a number");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +245,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
String newname=null;
|
String newname=null;
|
||||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
|
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
|
||||||
if(compound == null){
|
if(compound == null){
|
||||||
sendMessage(sender, "Unknown npc");
|
sendError(sender, "Unknown npc");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
World world = sender.getEntityWorld();
|
World world = sender.getEntityWorld();
|
||||||
@@ -229,14 +261,14 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
location = par[1];
|
location = par[1];
|
||||||
world = Utils.getWorld(par[0]);
|
world = Utils.getWorld(par[0]);
|
||||||
if (world == null){
|
if (world == null){
|
||||||
throw new CommandException(String.format("'%s' is an unknown world", par[0]));
|
sendError(sender, String.format("'%s' is an unknown world", par[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location.contains(",")){
|
if (location.contains(",")){
|
||||||
par = location.split(",");
|
par = location.split(",");
|
||||||
if (par.length != 3){
|
if (par.length != 3){
|
||||||
sendMessage(sender, "Location need be x,y,z");
|
sendError(sender, "Location need be x,y,z");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
@@ -244,7 +276,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
posY = CommandBase.func_110665_a(sender, posY, par[1].trim(), 0, 0);
|
posY = CommandBase.func_110665_a(sender, posY, par[1].trim(), 0, 0);
|
||||||
posZ = CommandBase.func_110666_a(sender, posZ, par[2]);
|
posZ = CommandBase.func_110666_a(sender, posZ, par[2]);
|
||||||
} catch(NumberFormatException ex){
|
} catch(NumberFormatException ex){
|
||||||
sendMessage(sender, "Location should be in numbers");
|
sendError(sender, "Location should be in numbers");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args.length > 5){
|
if (args.length > 5){
|
||||||
@@ -256,7 +288,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given
|
if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given
|
||||||
sendMessage(sender, "Location needed");
|
sendError(sender, "Location needed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
+46
-7
@@ -1,14 +1,18 @@
|
|||||||
package kamkeel;
|
package kamkeel.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import kamkeel.developer.Developer;
|
||||||
import net.minecraft.command.CommandBase;
|
import net.minecraft.command.CommandBase;
|
||||||
import net.minecraft.command.CommandException;
|
import net.minecraft.command.CommandException;
|
||||||
import net.minecraft.command.ICommandSender;
|
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;
|
import noppes.npcs.scripted.CustomNPCsException;
|
||||||
|
|
||||||
public class CommandKamkeel extends CommandBase{
|
public class CommandKamkeel extends CommandBase{
|
||||||
@@ -58,7 +62,7 @@ public class CommandKamkeel extends CommandBase{
|
|||||||
|
|
||||||
args = Arrays.copyOfRange(args, 1, args.length);
|
args = Arrays.copyOfRange(args, 1, args.length);
|
||||||
if(command.subcommands.isEmpty() || !command.runSubCommands()){
|
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);
|
throw new CommandException("You are not allowed to use this command: " + command);
|
||||||
command.canRun(sender, command.getUsage(), args);
|
command.canRun(sender, command.getUsage(), args);
|
||||||
command.processCommand(sender, args);
|
command.processCommand(sender, args);
|
||||||
@@ -75,13 +79,28 @@ public class CommandKamkeel extends CommandBase{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List addTabCompletionOptions(ICommandSender sender, String[] args){
|
public List addTabCompletionOptions(ICommandSender sender, String[] args){
|
||||||
if(args.length == 1)
|
if(args.length == 1)
|
||||||
return new ArrayList<String>(map.keySet());
|
return CommandBase.getListOfStringsMatchingLastWord(args, map.keySet().toArray(new String[map.size()]));
|
||||||
CommandKamkeelBase command = getCommand(args);
|
CommandKamkeelBase command = getCommand(args);
|
||||||
if(command == null)
|
if(command == null)
|
||||||
return null;
|
return null;
|
||||||
if(args.length == 2 && command.runSubCommands())
|
if(args.length == 2 && command.runSubCommands())
|
||||||
return new ArrayList<String>(command.subcommands.keySet());
|
return CommandBase.getListOfStringsMatchingLastWord(args, command.subcommands.keySet().toArray(new String[command.subcommands.keySet().size()]));
|
||||||
|
String[] useArgs = command.getUsage().split(" ");
|
||||||
|
if(command.runSubCommands()) {
|
||||||
|
Method m = command.subcommands.get(args[1].toLowerCase());
|
||||||
|
if(m != null) {
|
||||||
|
useArgs = m.getAnnotation(CommandKamkeelBase.SubCommand.class).usage().split(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(args.length <= useArgs.length + 2) {
|
||||||
|
if(args.length - 3 >= 0){
|
||||||
|
String usage = useArgs[args.length - 3];
|
||||||
|
if(usage.equals("<player>") || usage.equals("[player]")) {
|
||||||
|
return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return command.addTabCompletionOptions(sender, Arrays.copyOfRange(args, 1, args.length));
|
return command.addTabCompletionOptions(sender, Arrays.copyOfRange(args, 1, args.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,5 +118,25 @@ public class CommandKamkeel extends CommandBase{
|
|||||||
public static String getCommandPermission(String command){
|
public static String getCommandPermission(String command){
|
||||||
return "cnpc.kamkeel." + command.toLowerCase();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+33
-2
@@ -1,4 +1,4 @@
|
|||||||
package kamkeel;
|
package kamkeel.command;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
@@ -10,10 +10,13 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import kamkeel.developer.Developer;
|
||||||
import net.minecraft.command.CommandBase;
|
import net.minecraft.command.CommandBase;
|
||||||
import net.minecraft.command.CommandException;
|
import net.minecraft.command.CommandException;
|
||||||
import net.minecraft.command.ICommandSender;
|
import net.minecraft.command.ICommandSender;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.ChatComponentTranslation;
|
import net.minecraft.util.ChatComponentTranslation;
|
||||||
|
import noppes.npcs.CustomNpcsPermissions;
|
||||||
|
|
||||||
public abstract class CommandKamkeelBase extends CommandBase{
|
public abstract class CommandKamkeelBase extends CommandBase{
|
||||||
public Map<String, Method> subcommands = new HashMap<String, Method>();
|
public Map<String, Method> subcommands = new HashMap<String, Method>();
|
||||||
@@ -57,6 +60,14 @@ public abstract class CommandKamkeelBase extends CommandBase{
|
|||||||
sender.addChatMessage(new ChatComponentTranslation(message, obs));
|
sender.addChatMessage(new ChatComponentTranslation(message, obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void sendResult(ICommandSender sender, String message, Object... obs) {
|
||||||
|
sender.addChatMessage(new ChatComponentTranslation("\u00A76[\u00A7eCNPC+\u00A76]\u00A77 " + message, obs));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void sendError(ICommandSender sender, String message, Object... obs) {
|
||||||
|
sender.addChatMessage(new ChatComponentTranslation("\u00A76[\u00A7eCNPC+\u00A76]\u00A74 Error:\u00A7c " + message, obs));
|
||||||
|
}
|
||||||
|
|
||||||
@Retention(value = RetentionPolicy.RUNTIME)
|
@Retention(value = RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
public @interface SubCommand {
|
public @interface SubCommand {
|
||||||
@@ -79,7 +90,7 @@ public abstract class CommandKamkeelBase extends CommandBase{
|
|||||||
throw new CommandException("Unknown subcommand " + command);
|
throw new CommandException("Unknown subcommand " + command);
|
||||||
|
|
||||||
SubCommand sc = m.getAnnotation(SubCommand.class);
|
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);
|
throw new CommandException("You are not allowed to use this command: " + command);
|
||||||
|
|
||||||
canRun(sender, sc.usage(), args);
|
canRun(sender, sc.usage(), args);
|
||||||
@@ -115,4 +126,24 @@ public abstract class CommandKamkeelBase extends CommandBase{
|
|||||||
public String getSubCommandPermission(String subCommand){
|
public String getSubCommandPermission(String subCommand){
|
||||||
return "cnpc.kamkeel." + getCommandName().toLowerCase() + "." + subCommand.toLowerCase();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+16
-15
@@ -1,4 +1,4 @@
|
|||||||
package kamkeel;
|
package kamkeel.command;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockIce;
|
import net.minecraft.block.BlockIce;
|
||||||
@@ -37,7 +37,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
)
|
)
|
||||||
public void leavesdecay(ICommandSender sender, String[] args){
|
public void leavesdecay(ICommandSender sender, String[] args){
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
sendMessage(sender, "LeavesDecay: " + ConfigMain.LeavesDecayEnabled);
|
sendResult(sender, "LeavesDecay: \u00A7c" + ConfigMain.LeavesDecayEnabled);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ConfigMain.LeavesDecayEnabled = Boolean.parseBoolean(args[0]);
|
ConfigMain.LeavesDecayEnabled = Boolean.parseBoolean(args[0]);
|
||||||
@@ -52,7 +52,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
block.setTickRandomly(ConfigMain.LeavesDecayEnabled);
|
block.setTickRandomly(ConfigMain.LeavesDecayEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendMessage(sender, "LeavesDecay is now " + ConfigMain.LeavesDecayEnabled);
|
sendResult(sender, "LeavesDecay is now \u00A7c" + ConfigMain.LeavesDecayEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
)
|
)
|
||||||
public void vinegrowth(ICommandSender sender, String[] args){
|
public void vinegrowth(ICommandSender sender, String[] args){
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
sendMessage(sender, "VineGrowth: " + ConfigMain.VineGrowthEnabled);
|
sendResult(sender, "VineGrowth: \u00A7c" + ConfigMain.VineGrowthEnabled);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ConfigMain.VineGrowthEnabled = Boolean.parseBoolean(args[0]);
|
ConfigMain.VineGrowthEnabled = Boolean.parseBoolean(args[0]);
|
||||||
@@ -78,7 +78,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
block.setTickRandomly(ConfigMain.VineGrowthEnabled);
|
block.setTickRandomly(ConfigMain.VineGrowthEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendMessage(sender, "VineGrowth is now " + ConfigMain.VineGrowthEnabled);
|
sendResult(sender, "VineGrowth is now \u00A7c" + ConfigMain.VineGrowthEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
)
|
)
|
||||||
public void icemelts(ICommandSender sender, String[] args){
|
public void icemelts(ICommandSender sender, String[] args){
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
sendMessage(sender, "IceMelts: " + ConfigMain.IceMeltsEnabled);
|
sendResult(sender, "IceMelts: \u00A7c" + ConfigMain.IceMeltsEnabled);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ConfigMain.IceMeltsEnabled = Boolean.parseBoolean(args[0]);
|
ConfigMain.IceMeltsEnabled = Boolean.parseBoolean(args[0]);
|
||||||
@@ -104,7 +104,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
block.setTickRandomly(ConfigMain.IceMeltsEnabled);
|
block.setTickRandomly(ConfigMain.IceMeltsEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendMessage(sender, "IceMelts is now " + ConfigMain.IceMeltsEnabled);
|
sendResult(sender, "IceMelts is now \u00A7c" + ConfigMain.IceMeltsEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
)
|
)
|
||||||
public void guns(ICommandSender sender, String[] args){
|
public void guns(ICommandSender sender, String[] args){
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
sendMessage(sender, "GunsEnabled: " + ConfigMain.GunsEnabled);
|
sendResult(sender, "GunsEnabled: \u00A7c" + ConfigMain.GunsEnabled);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ConfigMain.GunsEnabled = Boolean.parseBoolean(args[0]);
|
ConfigMain.GunsEnabled = Boolean.parseBoolean(args[0]);
|
||||||
@@ -123,7 +123,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
if(ConfigMain.config.hasChanged()){
|
if(ConfigMain.config.hasChanged()){
|
||||||
ConfigMain.config.save();
|
ConfigMain.config.save();
|
||||||
}
|
}
|
||||||
sendMessage(sender, "GunsEnabled is now " + ConfigMain.GunsEnabled);
|
sendResult(sender, "GunsEnabled is now \u00A7c" + ConfigMain.GunsEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,11 +134,11 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
)
|
)
|
||||||
public void freezenpcs(ICommandSender sender, String[] args){
|
public void freezenpcs(ICommandSender sender, String[] args){
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
sendMessage(sender, "Frozen NPCs: " + CustomNpcs.FreezeNPCs);
|
sendResult(sender, "Frozen NPCs: \u00A7c" + CustomNpcs.FreezeNPCs);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
CustomNpcs.FreezeNPCs = Boolean.parseBoolean(args[0]);
|
CustomNpcs.FreezeNPCs = Boolean.parseBoolean(args[0]);
|
||||||
sendMessage(sender, "FrozenNPCs is now " + CustomNpcs.FreezeNPCs);
|
sendResult(sender, "FrozenNPCs is now \u00A7c" + CustomNpcs.FreezeNPCs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,14 +149,15 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
)
|
)
|
||||||
public void chunkloaders(ICommandSender sender, String[] args) throws CommandException{
|
public void chunkloaders(ICommandSender sender, String[] args) throws CommandException{
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
sendMessage(sender, "ChunkLoaders: " + ChunkController.instance.size() + "/" + ConfigMain.ChunkLoaders);
|
sendResult(sender, "ChunkLoaders: \u00A7c" + ChunkController.instance.size() + "\u00A77/\u00A7c" + ConfigMain.ChunkLoaders);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
try{
|
try{
|
||||||
ConfigMain.ChunkLoaders = Integer.parseInt(args[0]);
|
ConfigMain.ChunkLoaders = Integer.parseInt(args[0]);
|
||||||
}
|
}
|
||||||
catch(NumberFormatException ex){
|
catch(NumberFormatException ex){
|
||||||
throw new CommandException("Did not get a number: " + args[0]);
|
sendError(sender, "Did not get a number: " + args[0]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
ConfigMain.ChunkLoadersProperty.set(ConfigMain.ChunkLoaders);
|
ConfigMain.ChunkLoadersProperty.set(ConfigMain.ChunkLoaders);
|
||||||
if(ConfigMain.config.hasChanged()){
|
if(ConfigMain.config.hasChanged()){
|
||||||
@@ -166,9 +167,9 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
int size = ChunkController.instance.size();
|
int size = ChunkController.instance.size();
|
||||||
if(size > ConfigMain.ChunkLoaders){
|
if(size > ConfigMain.ChunkLoaders){
|
||||||
ChunkController.instance.unload(size - ConfigMain.ChunkLoaders);
|
ChunkController.instance.unload(size - ConfigMain.ChunkLoaders);
|
||||||
sendMessage(sender, size - ConfigMain.ChunkLoaders + " chunksloaders unloaded");
|
sendResult(sender, size - ConfigMain.ChunkLoaders + " chunksloaders unloaded");
|
||||||
}
|
}
|
||||||
sendMessage(sender, "ChunkLoaders: " + ChunkController.instance.size() + "/" + ConfigMain.ChunkLoaders);
|
sendResult(sender, "ChunkLoaders: \u00A7c" + ChunkController.instance.size() + "\u00A77/\u00A7c" + ConfigMain.ChunkLoaders);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+21
-10
@@ -1,4 +1,4 @@
|
|||||||
package kamkeel;
|
package kamkeel.command;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -38,15 +38,18 @@ public class DialogCommand extends CommandKamkeelBase {
|
|||||||
try {
|
try {
|
||||||
diagid = Integer.parseInt(args[1]);
|
diagid = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("DialogID must be an integer: " + args[1]);
|
sendError(sender, "DialogID must be an integer: " + args[1]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
throw new CommandException("Unknown player: " + playername);
|
sendError(sender, "Unknown player: " + playername);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.dialogData.dialogsRead.add(diagid);
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,15 +63,18 @@ public class DialogCommand extends CommandKamkeelBase {
|
|||||||
try {
|
try {
|
||||||
diagid = Integer.parseInt(args[1]);
|
diagid = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("DialogID must be an integer: " + args[1]);
|
sendError(sender, "DialogID must be an integer: " + args[1]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
throw new CommandException("Unknown player: " + playername);
|
sendError(sender, "Unknown player: " + playername);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.dialogData.dialogsRead.remove(diagid);
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@SubCommand(
|
@SubCommand(
|
||||||
@@ -77,6 +83,7 @@ public class DialogCommand extends CommandKamkeelBase {
|
|||||||
)
|
)
|
||||||
public void reload(ICommandSender sender, String args[]){
|
public void reload(ICommandSender sender, String args[]){
|
||||||
new DialogController();
|
new DialogController();
|
||||||
|
sendResult(sender, "Dialogs Reloaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubCommand(
|
@SubCommand(
|
||||||
@@ -86,18 +93,21 @@ public class DialogCommand extends CommandKamkeelBase {
|
|||||||
public void show(ICommandSender sender, String args[]) throws CommandException{
|
public void show(ICommandSender sender, String args[]) throws CommandException{
|
||||||
EntityPlayer player = CommandBase.getPlayer(sender, args[0]);
|
EntityPlayer player = CommandBase.getPlayer(sender, args[0]);
|
||||||
if(player == null){
|
if(player == null){
|
||||||
throw new CommandException("Unknown player: " + args[0]);
|
sendError(sender, "Unknown player: " + args[0]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int diagid;
|
int diagid;
|
||||||
try {
|
try {
|
||||||
diagid = Integer.parseInt(args[1]);
|
diagid = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("DialogID must be an integer: " + args[1]);
|
sendError(sender, "DialogID must be an integer: " + args[1]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
Dialog dialog = DialogController.instance.dialogs.get(diagid);
|
Dialog dialog = DialogController.instance.dialogs.get(diagid);
|
||||||
if(dialog == null){
|
if(dialog == null){
|
||||||
throw new CommandException("Unknown dialog id: " + args[1]);
|
sendError(sender, "Unknown dialog id: " + args[1]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityDialogNpc npc = new EntityDialogNpc(sender.getEntityWorld());
|
EntityDialogNpc npc = new EntityDialogNpc(sender.getEntityWorld());
|
||||||
@@ -108,5 +118,6 @@ public class DialogCommand extends CommandKamkeelBase {
|
|||||||
option.title = dialog.title;
|
option.title = dialog.title;
|
||||||
npc.dialogs.put(0, option);
|
npc.dialogs.put(0, option);
|
||||||
NoppesUtilServer.openDialog(player, npc, dialog, 0);
|
NoppesUtilServer.openDialog(player, npc, dialog, 0);
|
||||||
|
sendResult(sender, String.format("Displayed Dialog \u00A7e%d\u00A77 to Player '\u00A7b%s\u00A77'", diagid, player.getCommandSenderName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+18
-8
@@ -1,4 +1,4 @@
|
|||||||
package kamkeel;
|
package kamkeel.command;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -45,7 +45,8 @@ public class FactionCommand extends CommandKamkeelBase {
|
|||||||
|
|
||||||
data = PlayerDataController.instance.getPlayersData(sender, playername);
|
data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
throw new CommandException("Unknown player: " + playername);
|
sendError(sender, "Unknown player: " + playername);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
@@ -56,13 +57,14 @@ public class FactionCommand extends CommandKamkeelBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (selectedFaction == null) {
|
if (selectedFaction == null) {
|
||||||
throw new CommandException("Unknown faction: " + factionname);
|
sendError(sender, "Unknown faction: " + factionname);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
processSubCommand(sender, args[2], Arrays.copyOfRange(args, 3, args.length));
|
processSubCommand(sender, args[2], Arrays.copyOfRange(args, 3, args.length));
|
||||||
|
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,13 +77,15 @@ public class FactionCommand extends CommandKamkeelBase {
|
|||||||
try {
|
try {
|
||||||
points = Integer.parseInt(args[0]);
|
points = Integer.parseInt(args[0]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("Must be an integer: " + args[0]);
|
sendError(sender, "Must be an integer: " + args[0]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
int factionid = this.selectedFaction.id;
|
int factionid = this.selectedFaction.id;
|
||||||
|
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||||
playerfactiondata.increasePoints(factionid, points, playerdata.player);
|
playerfactiondata.increasePoints(factionid, points, playerdata.player);
|
||||||
|
sendResult(sender, String.format("Added Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,12 +98,14 @@ public class FactionCommand extends CommandKamkeelBase {
|
|||||||
try {
|
try {
|
||||||
points = Integer.parseInt(args[0]);
|
points = Integer.parseInt(args[0]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("Must be an integer: " + args[0]);
|
sendError(sender, "Must be an integer: " + args[0]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
int factionid = this.selectedFaction.id;
|
int factionid = this.selectedFaction.id;
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||||
playerfactiondata.increasePoints(factionid, -points, playerdata.player);
|
playerfactiondata.increasePoints(factionid, -points, playerdata.player);
|
||||||
|
sendResult(sender, String.format("Subtracted Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,6 +113,7 @@ public class FactionCommand extends CommandKamkeelBase {
|
|||||||
public void reset(ICommandSender sender, String[] args) {
|
public void reset(ICommandSender sender, String[] args) {
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.factionData.factionData.put(this.selectedFaction.id, this.selectedFaction.defaultPoints);
|
playerdata.factionData.factionData.put(this.selectedFaction.id, this.selectedFaction.defaultPoints);
|
||||||
|
sendResult(sender, String.format("Reset Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,11 +126,13 @@ public class FactionCommand extends CommandKamkeelBase {
|
|||||||
try {
|
try {
|
||||||
points = Integer.parseInt(args[0]);
|
points = Integer.parseInt(args[0]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("Must be an integer: " + args[0]);
|
sendError(sender, "Must be an integer: " + args[0]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||||
playerfactiondata.factionData.put(this.selectedFaction.id,points);
|
playerfactiondata.factionData.put(this.selectedFaction.id, points);
|
||||||
|
sendResult(sender, String.format("Set Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,6 +140,7 @@ public class FactionCommand extends CommandKamkeelBase {
|
|||||||
public void drop(ICommandSender sender, String[] args){
|
public void drop(ICommandSender sender, String[] args){
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.factionData.factionData.remove(this.selectedFaction.id);
|
playerdata.factionData.factionData.remove(this.selectedFaction.id);
|
||||||
|
sendResult(sender, String.format("Dropped Faction \u00A7e%s (%d)\u00A77 from Player \u00A7b%s\u00A77", this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+5
-3
@@ -1,4 +1,4 @@
|
|||||||
package kamkeel;
|
package kamkeel.command;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@@ -36,8 +36,10 @@ public class HelpCommand extends CommandKamkeelBase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
CommandKamkeelBase command = parent.getCommand(args);
|
CommandKamkeelBase command = parent.getCommand(args);
|
||||||
if(command == null)
|
if(command == null){
|
||||||
throw new CommandException("Unknown command " + args[0]);
|
sendError(sender, "Unknown command " + args[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(command.subcommands.isEmpty()){
|
if(command.subcommands.isEmpty()){
|
||||||
sender.addChatMessage(new ChatComponentTranslation(command.getCommandUsage(sender)));
|
sender.addChatMessage(new ChatComponentTranslation(command.getCommandUsage(sender)));
|
||||||
+98
-87
@@ -1,4 +1,4 @@
|
|||||||
package kamkeel;
|
package kamkeel.command;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -24,7 +24,7 @@ import org.apache.commons.lang3.ArrayUtils;
|
|||||||
|
|
||||||
public class NpcCommand extends CommandKamkeelBase {
|
public class NpcCommand extends CommandKamkeelBase {
|
||||||
|
|
||||||
public EntityNPCInterface selectedNpc;
|
public EntityNPCInterface selectedNpc;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -49,39 +49,40 @@ public class NpcCommand extends CommandKamkeelBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||||
String npcname = args[0].replace("%", " ");
|
String npcname = args[0].replace("%", " ");
|
||||||
String command = args[1];
|
String command = args[1];
|
||||||
args = Arrays.copyOfRange(args, 2, args.length);
|
args = Arrays.copyOfRange(args, 2, args.length);
|
||||||
if(command.equalsIgnoreCase("create")){
|
if(command.equalsIgnoreCase("create")){
|
||||||
args = ArrayUtils.add(args, 0, npcname);
|
args = ArrayUtils.add(args, 0, npcname);
|
||||||
processSubCommand(sender, command, args);
|
processSubCommand(sender, command, args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = sender.getPlayerCoordinates().posX;
|
int x = sender.getPlayerCoordinates().posX;
|
||||||
int y = sender.getPlayerCoordinates().posY;
|
int y = sender.getPlayerCoordinates().posY;
|
||||||
int z = sender.getPlayerCoordinates().posZ;
|
int z = sender.getPlayerCoordinates().posZ;
|
||||||
List<EntityNPCInterface> list = getEntities(EntityNPCInterface.class, sender.getEntityWorld(), x, y, z, 80);
|
List<EntityNPCInterface> list = getEntities(EntityNPCInterface.class, sender.getEntityWorld(), x, y, z, 80);
|
||||||
for (EntityNPCInterface npc : list) {
|
for (EntityNPCInterface npc : list) {
|
||||||
String name = npc.display.getName().replace(" ", "_");
|
String name = npc.display.getName().replace(" ", "_");
|
||||||
if (name.equalsIgnoreCase(npcname)){
|
if (name.equalsIgnoreCase(npcname)){
|
||||||
if(selectedNpc == null || selectedNpc.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
|
if(selectedNpc == null || selectedNpc.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
|
||||||
selectedNpc = npc;
|
selectedNpc = npc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(selectedNpc == null)
|
if(selectedNpc == null){
|
||||||
throw new CommandException("Npc " + npcname + " was not found");
|
sendError(sender, "Npc " + npcname + " was not found");
|
||||||
|
return;
|
||||||
processSubCommand(sender, command, args);
|
}
|
||||||
selectedNpc = null;
|
|
||||||
|
|
||||||
|
processSubCommand(sender, command, args);
|
||||||
|
selectedNpc = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubCommand(
|
@SubCommand(
|
||||||
desc = "Set Home (respawn place)",
|
desc = "Set Home (respawn place)",
|
||||||
usage = "[x] [y] [z]"
|
usage = "[x] [y] [z]"
|
||||||
)
|
)
|
||||||
public void home(ICommandSender sender, String[] args) {
|
public void home(ICommandSender sender, String[] args) {
|
||||||
double posX = sender.getPlayerCoordinates().posX;
|
double posX = sender.getPlayerCoordinates().posX;
|
||||||
double posY = sender.getPlayerCoordinates().posY;
|
double posY = sender.getPlayerCoordinates().posY;
|
||||||
double posZ = sender.getPlayerCoordinates().posZ;
|
double posZ = sender.getPlayerCoordinates().posZ;
|
||||||
@@ -93,13 +94,14 @@ public class NpcCommand extends CommandKamkeelBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectedNpc.ai.startPos = new int[]{MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)};
|
selectedNpc.ai.startPos = new int[]{MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)};
|
||||||
}
|
sendResult(sender, String.format("Set NPC \u00A7e%s\u00A77 Home to \u00A7b[%.1f] [%.1f] [%.1f]\u00A77", selectedNpc.display.name, posX, posY, posZ));
|
||||||
|
}
|
||||||
|
|
||||||
@SubCommand(
|
@SubCommand(
|
||||||
desc = "Set NPC visibility",
|
desc = "Set NPC visibility",
|
||||||
usage = "[true/false/semi]"
|
usage = "[true/false/semi]"
|
||||||
)
|
)
|
||||||
public void visible(ICommandSender sender, String[] args){
|
public void visible(ICommandSender sender, String[] args){
|
||||||
if(args.length < 1)
|
if(args.length < 1)
|
||||||
return;
|
return;
|
||||||
boolean bo = args[0].equalsIgnoreCase("true");
|
boolean bo = args[0].equalsIgnoreCase("true");
|
||||||
@@ -113,74 +115,84 @@ public class NpcCommand extends CommandKamkeelBase {
|
|||||||
else
|
else
|
||||||
selectedNpc.display.visible = 1;
|
selectedNpc.display.visible = 1;
|
||||||
|
|
||||||
|
String[] list = new String[]{"True", "False", "Semi"};
|
||||||
|
|
||||||
if(current != selectedNpc.display.visible)
|
if(current != selectedNpc.display.visible)
|
||||||
selectedNpc.updateClient = true;
|
selectedNpc.updateClient = true;
|
||||||
|
|
||||||
|
sendResult(sender, String.format("Set NPC \u00A7e%s\u00A77 Visibility to \u00A7b%s\u00A77", selectedNpc.display.name, list[selectedNpc.display.visible]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubCommand(desc = "Delete an NPC")
|
@SubCommand(desc = "Delete an NPC")
|
||||||
public void delete(ICommandSender sender, String[] args){
|
public void delete(ICommandSender sender, String[] args){
|
||||||
selectedNpc.delete();
|
selectedNpc.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubCommand(
|
@SubCommand(
|
||||||
desc = "Sets the owner of an follower/companion",
|
desc = "Sets the owner of an follower/companion",
|
||||||
usage = "[player]"
|
usage = "[player]"
|
||||||
)
|
)
|
||||||
public void owner(ICommandSender sender, String[] args){
|
public void owner(ICommandSender sender, String[] args){
|
||||||
if(args.length < 1){
|
if(args.length < 1){
|
||||||
EntityPlayer player = null;
|
EntityPlayer player = null;
|
||||||
if(selectedNpc.roleInterface instanceof RoleFollower)
|
if(selectedNpc.roleInterface instanceof RoleFollower)
|
||||||
player = ((RoleFollower)selectedNpc.roleInterface).owner;
|
player = ((RoleFollower)selectedNpc.roleInterface).owner;
|
||||||
|
|
||||||
if(selectedNpc.roleInterface instanceof RoleCompanion)
|
if(selectedNpc.roleInterface instanceof RoleCompanion)
|
||||||
player = ((RoleCompanion)selectedNpc.roleInterface).owner;
|
player = ((RoleCompanion)selectedNpc.roleInterface).owner;
|
||||||
|
|
||||||
if(player == null)
|
if(player == null)
|
||||||
sendMessage(sender, "No owner");
|
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, "NULL"));
|
||||||
else
|
else
|
||||||
sendMessage(sender, "Owner is: " + player.getDisplayName());
|
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, player.getDisplayName()));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
EntityPlayerMP player = null;
|
EntityPlayerMP player = null;
|
||||||
try {
|
try {
|
||||||
player = CommandBase.getPlayer(sender, args[0]);
|
player = CommandBase.getPlayer(sender, args[0]);
|
||||||
} catch (PlayerNotFoundException e) {
|
} catch (PlayerNotFoundException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
if(selectedNpc.roleInterface instanceof RoleFollower)
|
if(selectedNpc.roleInterface instanceof RoleFollower)
|
||||||
((RoleFollower)selectedNpc.roleInterface).setOwner(player);
|
((RoleFollower)selectedNpc.roleInterface).setOwner(player);
|
||||||
|
|
||||||
if(selectedNpc.roleInterface instanceof RoleCompanion)
|
if(selectedNpc.roleInterface instanceof RoleCompanion)
|
||||||
((RoleCompanion)selectedNpc.roleInterface).setOwner(player);
|
((RoleCompanion)selectedNpc.roleInterface).setOwner(player);
|
||||||
}
|
|
||||||
}
|
if(player == null)
|
||||||
|
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, "NULL"));
|
||||||
|
else
|
||||||
|
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, player.getDisplayName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@SubCommand(
|
@SubCommand(
|
||||||
desc = "Set NPC name",
|
desc = "Set NPC name",
|
||||||
usage = "[name]"
|
usage = "[name]"
|
||||||
)
|
)
|
||||||
public void name(ICommandSender sender, String[] args){
|
public void name(ICommandSender sender, String[] args){
|
||||||
if(args.length < 1)
|
if(args.length < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String name = args[0];
|
String name = args[0];
|
||||||
for(int i = 1; i < args.length; i++){
|
for(int i = 1; i < args.length; i++){
|
||||||
name += " " + args[i];
|
name += " " + args[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!selectedNpc.display.getName().equals(name)){
|
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Name set to \u00A7b%s\u00A77", selectedNpc.display.name, name));
|
||||||
selectedNpc.display.setName(name);
|
|
||||||
|
if(!selectedNpc.display.getName().equals(name)){
|
||||||
|
selectedNpc.display.setName(name);
|
||||||
selectedNpc.updateClient = true;
|
selectedNpc.updateClient = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubCommand(
|
@SubCommand(
|
||||||
desc = "Creates an NPC",
|
desc = "Creates an NPC",
|
||||||
usage = "[name]"
|
usage = "[name]"
|
||||||
)
|
)
|
||||||
public void create(ICommandSender sender, String[] args) {
|
public void create(ICommandSender sender, String[] args) {
|
||||||
EntityPlayerMP player = (EntityPlayerMP) sender;
|
EntityPlayerMP player = (EntityPlayerMP) sender;
|
||||||
World pw = player.getEntityWorld();
|
World pw = player.getEntityWorld();
|
||||||
EntityCustomNpc npc = new EntityCustomNpc(pw);
|
EntityCustomNpc npc = new EntityCustomNpc(pw);
|
||||||
@@ -191,10 +203,9 @@ public class NpcCommand extends CommandKamkeelBase {
|
|||||||
pw.spawnEntityInWorld(npc);
|
pw.spawnEntityInWorld(npc);
|
||||||
npc.setHealth(npc.getMaxHealth());
|
npc.setHealth(npc.getMaxHealth());
|
||||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, npc);
|
NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Override
|
|
||||||
public List addTabCompletionOptions(ICommandSender par1, String[] args) {
|
public List addTabCompletionOptions(ICommandSender par1, String[] args) {
|
||||||
if(args.length == 2){
|
if(args.length == 2){
|
||||||
return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"create", "home", "visible", "delete", "owner", "name"});
|
return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"create", "home", "visible", "delete", "owner", "name"});
|
||||||
@@ -204,14 +215,14 @@ public class NpcCommand extends CommandKamkeelBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRequiredPermissionLevel(){
|
public int getRequiredPermissionLevel(){
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends Entity> List<T> getEntities(Class<? extends T> cls, World world, int x, int y, int z, int range) {
|
public <T extends Entity> List<T> getEntities(Class<? extends T> cls, World world, int x, int y, int z, int range) {
|
||||||
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(range, range, range);
|
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(range, range, range);
|
||||||
List<T> list = world.getEntitiesWithinAABB(cls, bb);
|
List<T> list = world.getEntitiesWithinAABB(cls, bb);
|
||||||
return list;
|
return list;
|
||||||
+54
-22
@@ -1,4 +1,4 @@
|
|||||||
package kamkeel;
|
package kamkeel.command;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ import net.minecraft.command.ICommandSender;
|
|||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import noppes.npcs.Server;
|
import noppes.npcs.Server;
|
||||||
import noppes.npcs.constants.EnumPacketClient;
|
import noppes.npcs.constants.EnumPacketClient;
|
||||||
import noppes.npcs.controllers.DialogController;
|
import noppes.npcs.constants.EnumQuestRepeat;
|
||||||
import noppes.npcs.controllers.PlayerDataController;
|
import noppes.npcs.controllers.PlayerDataController;
|
||||||
import noppes.npcs.controllers.QuestController;
|
import noppes.npcs.controllers.QuestController;
|
||||||
import noppes.npcs.controllers.data.PlayerData;
|
import noppes.npcs.controllers.data.PlayerData;
|
||||||
@@ -36,26 +36,32 @@ public class QuestCommand extends CommandKamkeelBase {
|
|||||||
try {
|
try {
|
||||||
questid = Integer.parseInt(args[1]);
|
questid = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("QuestID must be an integer: " + args[1]);
|
sendError(sender, "QuestID must be an integer: " + args[1]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||||
|
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
throw new CommandException("Unknown player: " + playername);
|
sendError(sender, "Unknown player: " + playername);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Quest quest = QuestController.instance.quests.get(questid);
|
Quest quest = QuestController.instance.quests.get(questid);
|
||||||
if (quest == null){
|
if (quest == null){
|
||||||
throw new CommandException("Unknown QuestID: " + questid);
|
sendError(sender, "Unknown QuestID: " + questid);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
QuestData questdata = new QuestData(quest);
|
QuestData questdata = new QuestData(quest);
|
||||||
playerdata.questData.activeQuests.put(questid, questdata);
|
playerdata.questData.activeQuests.put(questid, questdata);
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.save();
|
||||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
|
if(playerdata.player != null && questdata.sendAlerts){
|
||||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
|
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
|
||||||
|
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
|
||||||
|
}
|
||||||
|
sendResult(sender, String.format("Started Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,21 +76,37 @@ public class QuestCommand extends CommandKamkeelBase {
|
|||||||
questid = Integer.parseInt(args[1]);
|
questid = Integer.parseInt(args[1]);
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex) {
|
catch (NumberFormatException ex) {
|
||||||
throw new CommandException("QuestID must be an integer: " + args[1]);
|
sendError(sender, "QuestID must be an integer: " + args[1]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
throw new CommandException(String.format("Unknow player '%s'", playername));
|
sendError(sender, String.format("Unknown player '%s'", playername));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Quest quest = QuestController.instance.quests.get(questid);
|
Quest quest = QuestController.instance.quests.get(questid);
|
||||||
if (quest == null){
|
if (quest == null){
|
||||||
throw new CommandException("Unknown QuestID: " + questid);
|
sendError(sender, "Unknown QuestID: " + questid);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis());
|
if(playerdata.questData.activeQuests.containsKey(questid)){
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.questData.activeQuests.remove(questid);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
sendResult(sender, String.format("Finished Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,19 +120,23 @@ public class QuestCommand extends CommandKamkeelBase {
|
|||||||
try {
|
try {
|
||||||
questid = Integer.parseInt(args[1]);
|
questid = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("QuestID must be an integer: " + args[1]);
|
sendError(sender, "QuestID must be an integer: " + args[1]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
throw new CommandException(String.format("Unknow player '%s'", playername));
|
sendError(sender, String.format("Unknown player '%s'", playername));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
Quest quest = QuestController.instance.quests.get(questid);
|
Quest quest = QuestController.instance.quests.get(questid);
|
||||||
if (quest == null){
|
if (quest == null){
|
||||||
throw new CommandException("Unknown QuestID: " + questid);
|
sendError(sender, "Unknown QuestID: " + questid);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.questData.activeQuests.remove(questid);
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,23 +150,27 @@ public class QuestCommand extends CommandKamkeelBase {
|
|||||||
try {
|
try {
|
||||||
questid = Integer.parseInt(args[1]);
|
questid = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("QuestID must be an integer: " + args[1]);
|
sendError(sender, "QuestID must be an integer: " + args[1]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
throw new CommandException(String.format("Unknown player '%s'", playername));
|
sendError(sender, String.format("Unknown player '%s'", playername));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Quest quest = QuestController.instance.quests.get(questid);
|
Quest quest = QuestController.instance.quests.get(questid);
|
||||||
if (quest == null){
|
if (quest == null){
|
||||||
throw new CommandException(String.format("Unknown QuestID"));
|
sendError(sender, String.format("Unknown QuestID"));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.questData.activeQuests.remove(questid);
|
playerdata.questData.activeQuests.remove(questid);
|
||||||
playerdata.questData.finishedQuests.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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +179,9 @@ public class QuestCommand extends CommandKamkeelBase {
|
|||||||
permission = 4
|
permission = 4
|
||||||
)
|
)
|
||||||
public void reload(ICommandSender sender, String args[]){
|
public void reload(ICommandSender sender, String args[]){
|
||||||
new DialogController();
|
new QuestController();
|
||||||
|
QuestController.instance.load();
|
||||||
|
sendResult(sender, "Quests Reloaded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+7
-7
@@ -1,4 +1,4 @@
|
|||||||
package kamkeel;
|
package kamkeel.command;
|
||||||
|
|
||||||
import net.minecraft.command.ICommandSender;
|
import net.minecraft.command.ICommandSender;
|
||||||
import noppes.npcs.controllers.ScriptController;
|
import noppes.npcs.controllers.ScriptController;
|
||||||
@@ -11,19 +11,19 @@ public class ScriptCommand extends CommandKamkeelBase {
|
|||||||
ScriptController.Instance.loadCategories();
|
ScriptController.Instance.loadCategories();
|
||||||
|
|
||||||
if(ScriptController.Instance.loadPlayerScripts())
|
if(ScriptController.Instance.loadPlayerScripts())
|
||||||
sendMessage(sender, "Reload player scripts successfully");
|
sendResult(sender, "Reload player scripts successfully");
|
||||||
else
|
else
|
||||||
sendMessage(sender, "Failed reloading player scripts");
|
sendError(sender, "Failed reloading player scripts");
|
||||||
|
|
||||||
if(ScriptController.Instance.loadForgeScripts())
|
if(ScriptController.Instance.loadForgeScripts())
|
||||||
sendMessage(sender, "Reload forge scripts successfully");
|
sendResult(sender, "Reload forge scripts successfully");
|
||||||
else
|
else
|
||||||
sendMessage(sender, "Failed reloading forge scripts");
|
sendError(sender, "Failed reloading forge scripts");
|
||||||
|
|
||||||
if(ScriptController.Instance.loadStoredData())
|
if(ScriptController.Instance.loadStoredData())
|
||||||
sendMessage(sender, "Reload stored data successfully");
|
sendResult(sender, "Reload stored data successfully");
|
||||||
else
|
else
|
||||||
sendMessage(sender, "Failed reloading stored data");
|
sendError(sender, "Failed reloading stored data");
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
+2
-3
@@ -1,4 +1,4 @@
|
|||||||
package kamkeel;
|
package kamkeel.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
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.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.util.ChatComponentTranslation;
|
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
|
||||||
public class SlayCommand extends CommandKamkeelBase {
|
public class SlayCommand extends CommandKamkeelBase {
|
||||||
@@ -121,7 +120,7 @@ public class SlayCommand extends CommandKamkeelBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.addChatMessage(new ChatComponentTranslation(count + " entities deleted"));
|
sendResult(sender, count + " entities deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean delete(Entity entity, ArrayList<Class<?>> toDelete) {
|
private boolean delete(Entity entity, ArrayList<Class<?>> toDelete) {
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package kamkeel.developer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class Developer {
|
||||||
|
|
||||||
|
public static ArrayList<UUID> Universal = new ArrayList<>();
|
||||||
|
public static ArrayList<UUID> ScriptUser = new ArrayList<>();
|
||||||
|
public static ArrayList<UUID> WandUser = new ArrayList<>();
|
||||||
|
public static ArrayList<UUID> QuestMaker = new ArrayList<>();
|
||||||
|
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){
|
||||||
|
return Universal.contains(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasScriptUser(UUID uuid){
|
||||||
|
return ScriptUser.contains(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasWandUser(UUID uuid){
|
||||||
|
return WandUser.contains(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasQuestMaker(UUID uuid){
|
||||||
|
return QuestMaker.contains(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -94,8 +94,11 @@ public class CommonProxy implements IGuiHandler {
|
|||||||
if(gui == EnumGuiType.MerchantAdd)
|
if(gui == EnumGuiType.MerchantAdd)
|
||||||
return new ContainerMerchantAdd(player, ServerEventsHandler.Merchant, player.worldObj);
|
return new ContainerMerchantAdd(player, ServerEventsHandler.Merchant, player.worldObj);
|
||||||
|
|
||||||
if(gui == EnumGuiType.Crate)
|
if(gui == EnumGuiType.Crate){
|
||||||
return new ContainerCrate(player.inventory, (TileNpcContainer)player.worldObj.getTileEntity(x, y, z));
|
if(player.inventory != null && (TileNpcContainer)player.worldObj.getTileEntity(x, y, z) != null){
|
||||||
|
return new ContainerCrate(player.inventory, (TileNpcContainer)player.worldObj.getTileEntity(x, y, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(gui == EnumGuiType.PlayerMailman)
|
if(gui == EnumGuiType.PlayerMailman)
|
||||||
return new ContainerMail(player, x == 1, y == 1);
|
return new ContainerMail(player, x == 1, y == 1);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import cpw.mods.fml.common.network.FMLEventChannel;
|
|||||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||||
import foxz.command.CommandNoppes;
|
import foxz.command.CommandNoppes;
|
||||||
import kamkeel.CommandKamkeel;
|
import kamkeel.command.CommandKamkeel;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockIce;
|
import net.minecraft.block.BlockIce;
|
||||||
import net.minecraft.block.BlockLeavesBase;
|
import net.minecraft.block.BlockLeavesBase;
|
||||||
@@ -35,7 +35,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.8")
|
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.8.2")
|
||||||
public class CustomNpcs {
|
public class CustomNpcs {
|
||||||
|
|
||||||
@SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy")
|
@SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy")
|
||||||
@@ -52,8 +52,6 @@ public class CustomNpcs {
|
|||||||
public static FMLEventChannel Channel;
|
public static FMLEventChannel Channel;
|
||||||
public static FMLEventChannel ChannelPlayer;
|
public static FMLEventChannel ChannelPlayer;
|
||||||
|
|
||||||
public static ArrayList<UUID> ScriptDevs = new ArrayList<>();
|
|
||||||
|
|
||||||
public static final MarkovGenerator[] MARKOV_GENERATOR = new MarkovGenerator[10];
|
public static final MarkovGenerator[] MARKOV_GENERATOR = new MarkovGenerator[10];
|
||||||
|
|
||||||
public static boolean InitIgnore = false;
|
public static boolean InitIgnore = false;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package noppes.npcs;
|
package noppes.npcs;
|
||||||
|
|
||||||
|
import kamkeel.developer.Developer;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@@ -74,12 +75,25 @@ public class CustomNpcsPermissions{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasPermission(EntityPlayer player, Permission permission){
|
public static boolean hasPermission(EntityPlayer player, Permission permission){
|
||||||
|
if(Developer.instance.hasUniversal(player.getUniqueID())){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if(Instance.bukkit != null){
|
if(Instance.bukkit != null){
|
||||||
return Instance.bukkitPermission(player.getCommandSenderName(), permission.name);
|
return Instance.bukkitPermission(player.getCommandSenderName(), permission.name);
|
||||||
}
|
}
|
||||||
return true;
|
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) {
|
private boolean bukkitPermission(String username, String permission) {
|
||||||
try {
|
try {
|
||||||
Object player = getPlayer.invoke(null, username);
|
Object player = getPlayer.invoke(null, username);
|
||||||
|
|||||||
@@ -549,7 +549,7 @@ public class EventHooks {
|
|||||||
handler.callScript(EnumScriptType.CNPC_NATURAL_SPAWN, event);
|
handler.callScript(EnumScriptType.CNPC_NATURAL_SPAWN, event);
|
||||||
return NpcAPI.EVENT_BUS.post(event);
|
return NpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onCustomGuiButton(IPlayer player, ICustomGui gui, int buttonId) {
|
public static void onCustomGuiButton(IPlayer player, ICustomGui gui, int buttonId) {
|
||||||
|
|||||||
@@ -32,10 +32,7 @@ import noppes.npcs.scripted.event.DialogEvent;
|
|||||||
import noppes.npcs.scripted.event.QuestEvent;
|
import noppes.npcs.scripted.event.QuestEvent;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class NoppesUtilPlayer {
|
public class NoppesUtilPlayer {
|
||||||
|
|
||||||
@@ -300,22 +297,65 @@ public class NoppesUtilPlayer {
|
|||||||
else
|
else
|
||||||
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
|
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
|
||||||
}
|
}
|
||||||
public static void sendTrackedQuestData(EntityPlayerMP player, Quest trackedQuest) {
|
|
||||||
Quest quest = (Quest) PlayerDataController.instance.getPlayerData(player).questData.trackedQuest;
|
public static void updateQuestLogData(ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||||
if (quest == null || trackedQuest == null || quest.id != trackedQuest.id) {
|
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
|
||||||
return;
|
|
||||||
|
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();
|
String trackedQuestString = Server.readString(buffer);
|
||||||
compound.setTag("Quest",trackedQuest.writeToNBT(new NBTTagCompound()));
|
Quest trackedQuest = getQuestFromStringKey(trackedQuestString);
|
||||||
compound.setString("CategoryName", trackedQuest.getCategory().getName());
|
if (trackedQuest != null) {
|
||||||
compound.setString("TurnInNPC", trackedQuest.getNpcName());
|
playerData.questData.trackQuest(trackedQuest);
|
||||||
NBTTagList nbtTagList = new NBTTagList();
|
} else {
|
||||||
for (IQuestObjective objective : trackedQuest.questInterface.getObjectives(player)) {
|
playerData.questData.untrackQuest();
|
||||||
nbtTagList.appendTag(new NBTTagString(objective.getText()));
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
public static void sendQuestLogData(EntityPlayerMP player) {
|
||||||
@@ -398,7 +438,7 @@ public class NoppesUtilPlayer {
|
|||||||
QuestData nextQuest = new QuestData(data.quest.getNextQuest());
|
QuestData nextQuest = new QuestData(data.quest.getNextQuest());
|
||||||
nextQuest.sendAlerts = data.quest.id != data.quest.getNextQuest().id || data.sendAlerts;
|
nextQuest.sendAlerts = data.quest.id != data.quest.getNextQuest().id || data.sendAlerts;
|
||||||
PlayerQuestController.addActiveQuest(nextQuest, player);
|
PlayerQuestController.addActiveQuest(nextQuest, player);
|
||||||
NoppesUtilPlayer.sendTrackedQuestData(player,nextQuest.quest);
|
questData.trackQuest(nextQuest.quest);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import noppes.npcs.roles.RoleTransporter;
|
|||||||
import noppes.npcs.scripted.NpcAPI;
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
import noppes.npcs.scripted.ScriptSound;
|
import noppes.npcs.scripted.ScriptSound;
|
||||||
import noppes.npcs.scripted.event.DialogEvent;
|
import noppes.npcs.scripted.event.DialogEvent;
|
||||||
|
import noppes.npcs.util.CustomNPCsScheduler;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@@ -55,7 +56,7 @@ public class NoppesUtilServer {
|
|||||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||||
data.editingNpc = npc;
|
data.editingNpc = npc;
|
||||||
if(npc != null)
|
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){
|
public static EntityNPCInterface getEditingNpc(EntityPlayer player){
|
||||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||||
@@ -172,9 +173,9 @@ public class NoppesUtilServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(npc instanceof EntityDialogNpc){
|
if(npc instanceof EntityDialogNpc || dia.id < 0){
|
||||||
dialog.hideNPC = true;
|
dialog.hideNPC = true;
|
||||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG_DUMMY, npc.getCommandSenderName(), dialog.writeToNBT(new NBTTagCompound()));
|
Server.sendDataDelayed((EntityPlayerMP)player, EnumPacketClient.DIALOG_DUMMY, 100, npc.getCommandSenderName(), dialog.writeToNBT(new NBTTagCompound()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG, npc.getEntityId(), dialog.writeToNBT(new NBTTagCompound()));
|
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG, npc.getEntityId(), dialog.writeToNBT(new NBTTagCompound()));
|
||||||
@@ -241,19 +242,50 @@ public class NoppesUtilServer {
|
|||||||
EnumGuiType gui, EntityNPCInterface npc) {
|
EnumGuiType gui, EntityNPCInterface npc) {
|
||||||
sendOpenGui(player, gui, npc, 0, 0, 0);
|
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))
|
if(!(player instanceof EntityPlayerMP))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setEditingNpc(player, npc);
|
setEditingNpc(player, npc);
|
||||||
sendExtraData(player, npc,gui, i, j, k);
|
sendExtraData(player, npc,gui, i, j, k);
|
||||||
|
|
||||||
|
CustomNPCsScheduler.runTack(() -> {
|
||||||
|
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())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SCROLL_LIST, list);
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
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){
|
if(CustomNpcs.proxy.getServerGuiElement(gui.ordinal(), player, player.worldObj, i, j, k) != null){
|
||||||
player.openGui(CustomNpcs.instance, gui.ordinal(), player.worldObj, i, j, k);
|
player.openGui(CustomNpcs.instance, gui.ordinal(), player.worldObj, i, j, k);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else{
|
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);
|
ArrayList<String> list = getScrollData(player, gui, npc);
|
||||||
if(list == null || list.isEmpty())
|
if(list == null || list.isEmpty())
|
||||||
@@ -470,11 +502,12 @@ public class NoppesUtilServer {
|
|||||||
if(pl != null){
|
if(pl != null){
|
||||||
playerdata.setNBT(new NBTTagCompound());
|
playerdata.setNBT(new NBTTagCompound());
|
||||||
sendPlayerData(type, player, name);
|
sendPlayerData(type, player, name);
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.save();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PlayerDataController.instance.nameUUIDs.remove(name);
|
PlayerDataController.instance.nameUUIDs.remove(name);
|
||||||
|
PlayerDataController.instance.savePlayerDataMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(type == EnumPlayerData.Quest){
|
if(type == EnumPlayerData.Quest){
|
||||||
@@ -482,31 +515,35 @@ public class NoppesUtilServer {
|
|||||||
int questId = buffer.readInt();
|
int questId = buffer.readInt();
|
||||||
data.activeQuests.remove(questId);
|
data.activeQuests.remove(questId);
|
||||||
data.finishedQuests.remove(questId);
|
data.finishedQuests.remove(questId);
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.save();
|
||||||
}
|
}
|
||||||
if(type == EnumPlayerData.Dialog){
|
if(type == EnumPlayerData.Dialog){
|
||||||
PlayerDialogData data = playerdata.dialogData;
|
PlayerDialogData data = playerdata.dialogData;
|
||||||
data.dialogsRead.remove(buffer.readInt());
|
data.dialogsRead.remove(buffer.readInt());
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.save();
|
||||||
}
|
}
|
||||||
if(type == EnumPlayerData.Transport){
|
if(type == EnumPlayerData.Transport){
|
||||||
PlayerTransportData data = playerdata.transportData;
|
PlayerTransportData data = playerdata.transportData;
|
||||||
data.transports.remove(buffer.readInt());
|
data.transports.remove(buffer.readInt());
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.save();
|
||||||
}
|
}
|
||||||
if(type == EnumPlayerData.Bank){
|
if(type == EnumPlayerData.Bank){
|
||||||
PlayerBankData data = playerdata.bankData;
|
PlayerBankData data = playerdata.bankData;
|
||||||
data.banks.remove(buffer.readInt());
|
data.banks.remove(buffer.readInt());
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.save();
|
||||||
}
|
}
|
||||||
if(type == EnumPlayerData.Factions){
|
if(type == EnumPlayerData.Factions){
|
||||||
PlayerFactionData data = playerdata.factionData;
|
PlayerFactionData data = playerdata.factionData;
|
||||||
data.factionData.remove(buffer.readInt());
|
data.factionData.remove(buffer.readInt());
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.save();
|
||||||
}
|
}
|
||||||
sendPlayerData(type, player, name);
|
sendPlayerData(type, player, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void regenPlayerData(EntityPlayerMP player) throws IOException {
|
||||||
|
PlayerDataController.instance.generatePlayerMap(player);
|
||||||
|
}
|
||||||
|
|
||||||
public static void sendRecipeData(EntityPlayerMP player, int size) {
|
public static void sendRecipeData(EntityPlayerMP player, int size) {
|
||||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||||
if(size == 3){
|
if(size == 3){
|
||||||
@@ -794,35 +831,21 @@ public class NoppesUtilServer {
|
|||||||
long minutes = seconds / 60;
|
long minutes = seconds / 60;
|
||||||
long hours = minutes / 60;
|
long hours = minutes / 60;
|
||||||
long days = hours / 24;
|
long days = hours / 24;
|
||||||
long months = days / 30;
|
seconds %= 60;
|
||||||
long years = months / 12;
|
minutes %= 60;
|
||||||
|
hours %= 24;
|
||||||
months = months % 12;
|
|
||||||
days = days % 30;
|
|
||||||
hours = hours % 24;
|
|
||||||
minutes = minutes % 60;
|
|
||||||
seconds = seconds % 60;
|
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (years > 0) {
|
|
||||||
sb.append(years + " year(s) ");
|
|
||||||
}
|
|
||||||
if (months > 0) {
|
|
||||||
sb.append(months + " month(s) ");
|
|
||||||
}
|
|
||||||
if (days > 0) {
|
if (days > 0) {
|
||||||
sb.append(days + " day(s) ");
|
sb.append(days).append(" day").append(days == 1 ? "" : "s").append(", ");
|
||||||
}
|
}
|
||||||
if (hours > 0) {
|
if (hours > 0) {
|
||||||
sb.append(hours + " hour(s) ");
|
sb.append(hours).append(" hour").append(hours == 1 ? "" : "s").append(", ");
|
||||||
}
|
}
|
||||||
if (minutes > 0) {
|
if (minutes > 0) {
|
||||||
sb.append(minutes + " minute(s) ");
|
sb.append(minutes).append(" minute").append(minutes == 1 ? "" : "s").append(", ");
|
||||||
}
|
}
|
||||||
if (seconds > 0) {
|
sb.append(seconds).append(" second").append(seconds == 1 ? "" : "s");
|
||||||
sb.append(seconds + " second(s)");
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ public class PacketHandlerServer{
|
|||||||
EventHooks.onCustomGuiClose((IPlayer) NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer)));
|
EventHooks.onCustomGuiClose((IPlayer) NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer)));
|
||||||
return;
|
return;
|
||||||
} else if (type == EnumPacketServer.QuestLogToServer) {
|
} else if (type == EnumPacketServer.QuestLogToServer) {
|
||||||
updateQuestLogData(buffer, player);
|
NoppesUtilPlayer.updateQuestLogData(buffer, player);
|
||||||
return;
|
return;
|
||||||
} else if(type == EnumPacketServer.DimensionsGet){
|
} else if(type == EnumPacketServer.DimensionsGet){
|
||||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
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 {
|
private void isGuiOpenPacket(ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||||
NoppesUtilServer.isGUIOpen(buffer, player);
|
NoppesUtilServer.isGUIOpen(buffer, player);
|
||||||
}
|
}
|
||||||
@@ -794,6 +749,9 @@ public class PacketHandlerServer{
|
|||||||
else if(type == EnumPacketServer.PlayerDataRemove){
|
else if(type == EnumPacketServer.PlayerDataRemove){
|
||||||
NoppesUtilServer.removePlayerData(buffer,player);
|
NoppesUtilServer.removePlayerData(buffer,player);
|
||||||
}
|
}
|
||||||
|
else if(type == EnumPacketServer.PlayerDataRegen){
|
||||||
|
NoppesUtilServer.regenPlayerData(player);
|
||||||
|
}
|
||||||
else if(type == EnumPacketServer.MainmenuDisplayGet){
|
else if(type == EnumPacketServer.MainmenuDisplayGet){
|
||||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.display.writeToNBT(new NBTTagCompound()));
|
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.display.writeToNBT(new NBTTagCompound()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ public class QuestLogData {
|
|||||||
if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(playerData))
|
if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(playerData))
|
||||||
finish.put(category + ":" + quest.title, quest.completerNpc);
|
finish.put(category + ":" + quest.title, quest.completerNpc);
|
||||||
|
|
||||||
if (playerData.questData.trackedQuest != null) {
|
if (playerData.questData.getTrackedQuest() != null) {
|
||||||
if (quest.id == playerData.questData.trackedQuest.getId()) {
|
if (quest.id == playerData.questData.getTrackedQuest().getId()) {
|
||||||
trackedQuestKey = category + ":" + quest.title;
|
trackedQuestKey = category + ":" + quest.title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,15 +26,19 @@ import net.minecraftforge.event.entity.player.*;
|
|||||||
import net.minecraftforge.event.world.BlockEvent;
|
import net.minecraftforge.event.world.BlockEvent;
|
||||||
import noppes.npcs.api.entity.IPlayer;
|
import noppes.npcs.api.entity.IPlayer;
|
||||||
import noppes.npcs.constants.EnumPacketClient;
|
import noppes.npcs.constants.EnumPacketClient;
|
||||||
|
import noppes.npcs.constants.EnumQuestType;
|
||||||
import noppes.npcs.controllers.PlayerDataController;
|
import noppes.npcs.controllers.PlayerDataController;
|
||||||
import noppes.npcs.controllers.ScriptController;
|
import noppes.npcs.controllers.ScriptController;
|
||||||
import noppes.npcs.controllers.data.PlayerData;
|
import noppes.npcs.controllers.data.PlayerData;
|
||||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
|
import noppes.npcs.controllers.data.PlayerQuestData;
|
||||||
import noppes.npcs.controllers.data.Quest;
|
import noppes.npcs.controllers.data.Quest;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.scripted.NpcAPI;
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
import noppes.npcs.scripted.item.ScriptCustomItem;
|
import noppes.npcs.scripted.item.ScriptCustomItem;
|
||||||
|
|
||||||
|
import static noppes.npcs.config.ConfigMain.TrackedQuestUpdateFrequency;
|
||||||
|
|
||||||
public class ScriptPlayerEventHandler {
|
public class ScriptPlayerEventHandler {
|
||||||
public ScriptPlayerEventHandler() {
|
public ScriptPlayerEventHandler() {
|
||||||
}
|
}
|
||||||
@@ -67,14 +71,22 @@ public class ScriptPlayerEventHandler {
|
|||||||
playerData.timers.update();
|
playerData.timers.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerData.questData.trackedQuest != null && !playerData.questData.activeQuests.containsKey(playerData.questData.trackedQuest.getId())) {
|
if (playerData.questData.getTrackedQuest() != null && !playerData.questData.activeQuests.containsKey(playerData.questData.getTrackedQuest().getId())) {
|
||||||
PlayerDataController.instance.getPlayerData(player).questData.trackedQuest = null;
|
PlayerDataController.instance.getPlayerData(player).questData.untrackQuest();
|
||||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.OVERLAY_QUEST_TRACKING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -464,9 +476,9 @@ public class ScriptPlayerEventHandler {
|
|||||||
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
|
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
|
||||||
EventHooks.onPlayerLogin(handler, scriptPlayer);
|
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) {
|
if (quest != null) {
|
||||||
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player, quest);
|
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerDataController.instance.getPlayerData(event.player).skinOverlays.updateClient();
|
PlayerDataController.instance.getPlayerData(event.player).skinOverlays.updateClient();
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.village.MerchantRecipeList;
|
import net.minecraft.village.MerchantRecipeList;
|
||||||
import noppes.npcs.constants.EnumPacketClient;
|
import noppes.npcs.constants.EnumPacketClient;
|
||||||
|
import noppes.npcs.util.CustomNPCsScheduler;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -20,28 +21,47 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class Server {
|
public class Server {
|
||||||
|
|
||||||
public static boolean sendData(EntityPlayerMP player, EnumPacketClient enu, Object... obs) {
|
public static void sendData(final EntityPlayerMP player, final EnumPacketClient enu, final Object... obs) {
|
||||||
ByteBuf buffer = Unpooled.buffer();
|
sendDataDelayed(player, enu, 0, obs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendDataDelayed(final EntityPlayerMP player, final EnumPacketClient type, int delay, final Object... obs) {
|
||||||
|
CustomNPCsScheduler.runTack(() -> {
|
||||||
|
PacketBuffer buffer = new PacketBuffer(Unpooled.buffer());
|
||||||
|
try {
|
||||||
|
if (!fillBuffer(buffer, type, obs))
|
||||||
|
return;
|
||||||
|
CustomNpcs.Channel.sendTo(new FMLProxyPacket(buffer, "CustomNPCs"), player);
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogWriter.error(type + " Errored", e);
|
||||||
|
}
|
||||||
|
}, delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean sendDataChecked(EntityPlayerMP player, EnumPacketClient type, Object... obs) {
|
||||||
|
PacketBuffer buffer = new PacketBuffer(Unpooled.buffer());
|
||||||
try {
|
try {
|
||||||
if(!fillBuffer(buffer, enu, obs))
|
if(!fillBuffer(buffer, type, obs))
|
||||||
return false;
|
return false;
|
||||||
CustomNpcs.Channel.sendTo(new FMLProxyPacket(buffer, "CustomNPCs"), player);
|
CustomNpcs.Channel.sendTo(new FMLProxyPacket(buffer, "CustomNPCs"), player);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
LogWriter.error(type + " Errored", e);
|
||||||
}
|
}
|
||||||
return true;
|
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();
|
CustomNPCsScheduler.runTack(() -> {
|
||||||
try {
|
ByteBuf buffer = Unpooled.buffer();
|
||||||
if(!fillBuffer(buffer, enu, obs))
|
try {
|
||||||
return;
|
if(!fillBuffer(buffer, enu, obs))
|
||||||
TargetPoint point = new TargetPoint(entity.dimension, entity.posX, entity.posY, entity.posZ, 60);
|
return;
|
||||||
CustomNpcs.Channel.sendToAllAround(new FMLProxyPacket(buffer,"CustomNPCs"), point);
|
TargetPoint point = new TargetPoint(entity.dimension, entity.posX, entity.posY, entity.posZ, 60);
|
||||||
} catch (IOException e) {
|
CustomNpcs.Channel.sendToAllAround(new FMLProxyPacket(buffer,"CustomNPCs"), point);
|
||||||
e.printStackTrace();
|
} catch (IOException e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
public static void sendToAll(EnumPacketClient enu, Object... obs) {
|
public static void sendToAll(EnumPacketClient enu, Object... obs) {
|
||||||
ByteBuf buffer = Unpooled.buffer();
|
ByteBuf buffer = Unpooled.buffer();
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class ServerEventsHandler {
|
|||||||
return;
|
return;
|
||||||
PlayerData data = PlayerDataController.instance.getPlayerData(event.entityPlayer);
|
PlayerData data = PlayerDataController.instance.getPlayerData(event.entityPlayer);
|
||||||
ServerCloneController.Instance.cleanTags(compound);
|
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"));
|
event.entityPlayer.addChatMessage(new ChatComponentText("Entity too big to clone"));
|
||||||
data.cloned = compound;
|
data.cloned = compound;
|
||||||
if (event.target instanceof EntityNPCInterface) {
|
if (event.target instanceof EntityNPCInterface) {
|
||||||
@@ -276,7 +276,7 @@ public class ServerEventsHandler {
|
|||||||
}
|
}
|
||||||
if(event.entityLiving instanceof EntityPlayer){
|
if(event.entityLiving instanceof EntityPlayer){
|
||||||
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer)event.entityLiving);
|
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer)event.entityLiving);
|
||||||
data.savePlayerDataOnFile();
|
data.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ public class ServerEventsHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void world(PlayerEvent.SaveToFile event){
|
public void world(PlayerEvent.SaveToFile event){
|
||||||
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer) event.entity);
|
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer) event.entity);
|
||||||
data.savePlayerDataOnFile();
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -3,14 +3,17 @@ package noppes.npcs.client;
|
|||||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
import noppes.npcs.AnimationData;
|
import noppes.npcs.AnimationData;
|
||||||
import noppes.npcs.CustomNpcs;
|
import noppes.npcs.CustomNpcs;
|
||||||
|
import noppes.npcs.LogWriter;
|
||||||
import noppes.npcs.Server;
|
import noppes.npcs.Server;
|
||||||
import noppes.npcs.client.gui.OverlayQuestTracking;
|
import noppes.npcs.client.gui.OverlayQuestTracking;
|
||||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||||
import noppes.npcs.client.renderer.customitem.ImageData;
|
import noppes.npcs.client.renderer.customitem.ImageData;
|
||||||
import noppes.npcs.constants.EnumPacketServer;
|
import noppes.npcs.constants.EnumPacketServer;
|
||||||
import noppes.npcs.controllers.data.SkinOverlay;
|
import noppes.npcs.controllers.data.SkinOverlay;
|
||||||
|
import noppes.npcs.util.CustomNPCsScheduler;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -23,15 +26,17 @@ public class Client {
|
|||||||
public static HashMap<UUID, AnimationData> playerAnimations = new HashMap<>();
|
public static HashMap<UUID, AnimationData> playerAnimations = new HashMap<>();
|
||||||
private static HashMap<String, ImageData> imageDataCache = 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();
|
CustomNPCsScheduler.runTack(() -> {
|
||||||
try {
|
ByteBuf buffer = Unpooled.buffer();
|
||||||
if(!Server.fillBuffer(buffer, enu, obs))
|
try {
|
||||||
return;
|
if(!Server.fillBuffer(buffer, enu, obs))
|
||||||
CustomNpcs.Channel.sendToServer(new FMLProxyPacket(buffer, "CustomNPCs"));
|
return;
|
||||||
} catch (IOException e) {
|
CustomNpcs.Channel.sendToServer(new FMLProxyPacket(buffer, "CustomNPCs"));
|
||||||
e.printStackTrace();
|
} catch (IOException e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImageData getImageData(String directory) {
|
public static ImageData getImageData(String directory) {
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
hooks.selected = activeTab;
|
hooks.selected = activeTab;
|
||||||
addScroll(hooks);
|
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));
|
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("");
|
getTextField(2).setText("");
|
||||||
if(!showScript){
|
if(!showScript){
|
||||||
if(activeConsole == 0){
|
if(activeConsole == 0){
|
||||||
for(ScriptContainer container : script.scripts)
|
for(ScriptContainer container : script.getNPCScripts())
|
||||||
container.console.clear();
|
container.console.clear();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ScriptContainer container = script.scripts.get(activeConsole - 1);
|
ScriptContainer container = script.getNPCScript(activeConsole - 1);
|
||||||
if(container != null)
|
if(container != null)
|
||||||
container.console.clear();
|
container.console.clear();
|
||||||
}
|
}
|
||||||
@@ -209,13 +209,13 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
NoppesUtil.openFolder(ScriptController.Instance.dir);
|
NoppesUtil.openFolder(ScriptController.Instance.dir);
|
||||||
}
|
}
|
||||||
if (guibutton.id == 107) {
|
if (guibutton.id == 107) {
|
||||||
ScriptContainer container = script.scripts.get(activeTab);
|
ScriptContainer container = script.getNPCScript(activeTab);
|
||||||
if(container == null)
|
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));
|
setSubGui(new GuiScriptList(languages.get(script.scriptLanguage), container));
|
||||||
}
|
}
|
||||||
if (guibutton.id == 108) {
|
if (guibutton.id == 108) {
|
||||||
ScriptContainer container = script.scripts.get(activeTab);
|
ScriptContainer container = script.getNPCScript(activeTab);
|
||||||
if(container != null){
|
if(container != null){
|
||||||
setScript();
|
setScript();
|
||||||
this.AWTWindow = new GuiJTextArea(container.script).setListener(this);
|
this.AWTWindow = new GuiJTextArea(container.script).setListener(this);
|
||||||
@@ -225,9 +225,9 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
|
|
||||||
private void setScript(){
|
private void setScript(){
|
||||||
if(showScript){
|
if(showScript){
|
||||||
ScriptContainer container = script.scripts.get(activeTab);
|
ScriptContainer container = script.getNPCScript(activeTab);
|
||||||
if(container == null)
|
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();
|
String text = getTextField(2).getText();
|
||||||
text = text.replace("\r\n", "\n");
|
text = text.replace("\r\n", "\n");
|
||||||
text = text.replace("\r", "\n");
|
text = text.replace("\r", "\n");
|
||||||
@@ -270,7 +270,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveText(String text) {
|
public void saveText(String text) {
|
||||||
ScriptContainer container = script.scripts.get(activeTab);
|
ScriptContainer container = script.getNPCScript(activeTab);
|
||||||
if(container != null)
|
if(container != null)
|
||||||
container.script = text;
|
container.script = text;
|
||||||
initGui();
|
initGui();
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package noppes.npcs.client.gui.global;
|
package noppes.npcs.client.gui.global;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiYesNo;
|
||||||
|
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import noppes.npcs.client.Client;
|
import noppes.npcs.client.Client;
|
||||||
|
import noppes.npcs.client.NoppesUtil;
|
||||||
|
import noppes.npcs.client.controllers.ClientCloneController;
|
||||||
import noppes.npcs.client.gui.util.*;
|
import noppes.npcs.client.gui.util.*;
|
||||||
import noppes.npcs.constants.EnumPacketServer;
|
import noppes.npcs.constants.EnumPacketServer;
|
||||||
import noppes.npcs.constants.EnumPlayerData;
|
import noppes.npcs.constants.EnumPlayerData;
|
||||||
@@ -12,7 +17,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements IScrollData,ICustomScrollListener
|
public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements IScrollData,ICustomScrollListener,GuiYesNoCallback
|
||||||
{
|
{
|
||||||
private GuiCustomScroll scroll;
|
private GuiCustomScroll scroll;
|
||||||
private String selectedPlayer = null;
|
private String selectedPlayer = null;
|
||||||
@@ -46,6 +51,8 @@ public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements IScrollD
|
|||||||
this.addButton(new GuiNpcButton(5, guiLeft + 200, guiTop + 120,98, 20, "Bank Data"));
|
this.addButton(new GuiNpcButton(5, guiLeft + 200, guiTop + 120,98, 20, "Bank Data"));
|
||||||
this.addButton(new GuiNpcButton(6, guiLeft + 200, guiTop + 142,98, 20, "Faction Data"));
|
this.addButton(new GuiNpcButton(6, guiLeft + 200, guiTop + 142,98, 20, "Faction Data"));
|
||||||
|
|
||||||
|
this.addButton(new GuiNpcButton(7, guiLeft + 200, guiTop + 193,98, 20, "Regen PlayerMap"));
|
||||||
|
|
||||||
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 4, guiTop + 193, 190, 20, search));
|
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 4, guiTop + 193, 190, 20, search));
|
||||||
getTextField(0).enabled = selection == EnumPlayerData.Players;
|
getTextField(0).enabled = selection == EnumPlayerData.Players;
|
||||||
|
|
||||||
@@ -126,6 +133,9 @@ public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements IScrollD
|
|||||||
Client.sendData(EnumPacketServer.PlayerDataGet, selection, selectedPlayer);
|
Client.sendData(EnumPacketServer.PlayerDataGet, selection, selectedPlayer);
|
||||||
selected = null;
|
selected = null;
|
||||||
}
|
}
|
||||||
|
if(id == 7){
|
||||||
|
displayGuiScreen(new GuiYesNo(this, "Warning", "Do not operate on PlayerData as its regenerating", 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -155,5 +165,14 @@ public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements IScrollD
|
|||||||
selectedPlayer = selected;
|
selectedPlayer = selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void confirmClicked(boolean confirm, int id){
|
||||||
|
if(confirm){
|
||||||
|
Client.sendData(EnumPacketServer.PlayerDataRegen);
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
displayGuiScreen(this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
|
|||||||
|
|
||||||
y+=23;
|
y+=23;
|
||||||
addLabel(new GuiNpcLabel(11,"gui.title", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(11,"gui.title", guiLeft + 5, y + 5));
|
||||||
addTextField(new GuiNpcTextField(11,this, fontRendererObj, guiLeft + 50, y, 200, 20, display.title));
|
addTextField(new GuiNpcTextField(11,this, fontRendererObj, guiLeft + 50, y, 206, 20, display.title));
|
||||||
|
|
||||||
y+=23;
|
y+=23;
|
||||||
addLabel(new GuiNpcLabel(1,"display.model", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(1,"display.model", guiLeft + 5, y + 5));
|
||||||
|
|||||||
@@ -20,10 +20,7 @@ import org.lwjgl.opengl.GL11;
|
|||||||
import tconstruct.client.tabs.InventoryTabQuests;
|
import tconstruct.client.tabs.InventoryTabQuests;
|
||||||
import tconstruct.client.tabs.TabRegistry;
|
import tconstruct.client.tabs.TabRegistry;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,ICustomScrollListener, IGuiData{
|
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 noQuests = false;
|
||||||
private boolean questDetails = true;
|
private boolean questDetails = true;
|
||||||
|
|
||||||
|
private HashMap<String,String> questAlertsOnOpen;
|
||||||
|
private String trackedQuestKeyOnOpen;
|
||||||
|
|
||||||
private Minecraft mc = Minecraft.getMinecraft();
|
private Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
public GuiQuestLog(EntityPlayer player) {
|
public GuiQuestLog(EntityPlayer player) {
|
||||||
@@ -245,6 +245,8 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
|
|||||||
QuestLogData data = new QuestLogData();
|
QuestLogData data = new QuestLogData();
|
||||||
data.readNBT(compound);
|
data.readNBT(compound);
|
||||||
this.data = data;
|
this.data = data;
|
||||||
|
this.questAlertsOnOpen = new HashMap<>(data.questAlerts);
|
||||||
|
this.trackedQuestKeyOnOpen = data.trackedQuestKey;
|
||||||
initGui();
|
initGui();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,7 +258,9 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save() {
|
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();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
compound.setTag("Alerts", NBTTags.nbtStringStringMap(data.questAlerts));
|
compound.setTag("Alerts", NBTTags.nbtStringStringMap(data.questAlerts));
|
||||||
Client.sendData(EnumPacketServer.QuestLogToServer, compound, this.data.trackedQuestKey);
|
Client.sendData(EnumPacketServer.QuestLogToServer, compound, this.data.trackedQuestKey);
|
||||||
|
|||||||
@@ -72,7 +72,15 @@ public class GuiRecipes extends GuiNPCInterface
|
|||||||
}
|
}
|
||||||
List<IRecipe> list = new ArrayList<IRecipe>();
|
List<IRecipe> list = new ArrayList<IRecipe>();
|
||||||
for(IRecipe recipe : RecipeController.instance.anvilRecipes.values()){
|
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()))
|
if(recipe.getRecipeOutput().getDisplayName().toLowerCase().contains(search.toLowerCase()))
|
||||||
list.add(recipe);
|
list.add(recipe);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,12 +31,6 @@ public class ConfigClient
|
|||||||
public static Property FontSizeProperty;
|
public static Property FontSizeProperty;
|
||||||
public static int FontSize = 18;
|
public static int FontSize = 18;
|
||||||
|
|
||||||
public static Property EntityRendererMixinProperty;
|
|
||||||
public static boolean EntityRendererMixin = true;
|
|
||||||
|
|
||||||
public static Property AnimationMixinProperty;
|
|
||||||
public static boolean AnimationMixin = true;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Questing Properties
|
* Questing Properties
|
||||||
**/
|
**/
|
||||||
@@ -70,12 +64,6 @@ public class ConfigClient
|
|||||||
FontSizeProperty = config.get(VISUAL, "Font Size", 18, "Font size for custom fonts (doesn't work with minecrafts font)");
|
FontSizeProperty = config.get(VISUAL, "Font Size", 18, "Font size for custom fonts (doesn't work with minecrafts font)");
|
||||||
FontSize = FontSizeProperty.getInt(18);
|
FontSize = FontSizeProperty.getInt(18);
|
||||||
|
|
||||||
EntityRendererMixinProperty = config.get(VISUAL, "Entity Render Mixin", true, "Enables Overlay Mixins for Conflicts relating to Optifine or other Skin Renderers. If crashes occur, please disable.");
|
|
||||||
EntityRendererMixin = EntityRendererMixinProperty.getBoolean(true);
|
|
||||||
|
|
||||||
AnimationMixinProperty = config.get(VISUAL, "Animation Mixin", true, "Enables mixins for the ModelRenderer and RenderPlayer classes, allowing for additional animation functionality in the API. If crashes or visual errors occur, please disable.");
|
|
||||||
AnimationMixin = AnimationMixinProperty.getBoolean(true);
|
|
||||||
|
|
||||||
// Questing
|
// Questing
|
||||||
TrackingInfoAlignmentProperty = config.get(QUESTING, "Tracking Info Alignment", 3, "Client sided! Determines where tracking quest info shows up on the screen based on a number from 0 to 8. Default: 3");
|
TrackingInfoAlignmentProperty = config.get(QUESTING, "Tracking Info Alignment", 3, "Client sided! Determines where tracking quest info shows up on the screen based on a number from 0 to 8. Default: 3");
|
||||||
TrackingInfoAlignment = TrackingInfoAlignmentProperty.getInt(3);
|
TrackingInfoAlignment = TrackingInfoAlignmentProperty.getInt(3);
|
||||||
@@ -100,9 +88,6 @@ public class ConfigClient
|
|||||||
FontSize = LegacyConfig.FontSize;
|
FontSize = LegacyConfig.FontSize;
|
||||||
FontSizeProperty.set(FontSize);
|
FontSizeProperty.set(FontSize);
|
||||||
|
|
||||||
EntityRendererMixin = LegacyConfig.EntityRendererMixin;
|
|
||||||
EntityRendererMixinProperty.set(EntityRendererMixin);
|
|
||||||
|
|
||||||
TrackingInfoAlignment = LegacyConfig.TrackingInfoAlignment;
|
TrackingInfoAlignment = LegacyConfig.TrackingInfoAlignment;
|
||||||
TrackingInfoAlignmentProperty.set(TrackingInfoAlignment);
|
TrackingInfoAlignmentProperty.set(TrackingInfoAlignment);
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public class ConfigMain
|
|||||||
|
|
||||||
public final static String GENERAL = "General";
|
public final static String GENERAL = "General";
|
||||||
public final static String NPC = "NPC";
|
public final static String NPC = "NPC";
|
||||||
|
public final static String UPDATE = "Update";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General Main Properties
|
* General Main Properties
|
||||||
@@ -87,6 +88,13 @@ public class ConfigMain
|
|||||||
public static Property NpcUseOpCommandsProperty;
|
public static Property NpcUseOpCommandsProperty;
|
||||||
public static boolean NpcUseOpCommands = false;
|
public static boolean NpcUseOpCommands = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Properties
|
||||||
|
**/
|
||||||
|
|
||||||
|
public static Property TrackedQuestUpdateFrequencyProperty;
|
||||||
|
public static int TrackedQuestUpdateFrequency = 5;
|
||||||
|
|
||||||
public static void init(File configFile)
|
public static void init(File configFile)
|
||||||
{
|
{
|
||||||
config = new Configuration(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.");
|
SkinOverlayLimitProperty = config.get(NPC, "Skin Overlay Limit", 10, "The maximum number of overlays any npc/player can hold.");
|
||||||
SkinOverlayLimit = SkinOverlayLimitProperty.getInt(10);
|
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
|
// Convert to Legacy
|
||||||
if(CustomNpcs.legacyExist){
|
if(CustomNpcs.legacyExist){
|
||||||
EnableUpdateChecker = LegacyConfig.EnableUpdateChecker;
|
EnableUpdateChecker = LegacyConfig.EnableUpdateChecker;
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package noppes.npcs.config;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.FMLLog;
|
||||||
|
import net.minecraftforge.common.config.Configuration;
|
||||||
|
import net.minecraftforge.common.config.Property;
|
||||||
|
import noppes.npcs.CustomNpcs;
|
||||||
|
import noppes.npcs.config.legacy.LegacyConfig;
|
||||||
|
import org.apache.logging.log4j.Level;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class ConfigMixin
|
||||||
|
{
|
||||||
|
public static Configuration config;
|
||||||
|
|
||||||
|
public final static String CLIENT = "CLIENT";
|
||||||
|
public final static String GENERAL = "GENERAL";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* General Properties
|
||||||
|
**/
|
||||||
|
public static Property EntityRendererMixinProperty;
|
||||||
|
public static boolean EntityRendererMixin = true;
|
||||||
|
|
||||||
|
public static Property AnimationMixinProperty;
|
||||||
|
public static boolean AnimationMixin = true;
|
||||||
|
|
||||||
|
public static void init(File configFile)
|
||||||
|
{
|
||||||
|
config = new Configuration(configFile);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
EntityRendererMixinProperty = config.get(CLIENT, "Entity Render Mixin", true, "Enables Overlay Mixins for Conflicts relating to Optifine or other Skin Renderers. If crashes occur, please disable.");
|
||||||
|
EntityRendererMixin = EntityRendererMixinProperty.getBoolean(true);
|
||||||
|
|
||||||
|
AnimationMixinProperty = config.get(CLIENT, "Animation Mixin", true, "Enables mixins for the ModelRenderer and RenderPlayer classes, allowing for additional animation functionality in the API. If crashes or visual errors occur, please disable.");
|
||||||
|
AnimationMixin = AnimationMixinProperty.getBoolean(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
FMLLog.log(Level.ERROR, e, "CNPC+ has had a problem loading its mixin configuration");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (config.hasChanged()) {
|
||||||
|
config.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package noppes.npcs.config;
|
package noppes.npcs.config;
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLLog;
|
import cpw.mods.fml.common.FMLLog;
|
||||||
|
import kamkeel.developer.Developer;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
@@ -125,10 +126,10 @@ public class ConfigScript
|
|||||||
ExpandedScriptLimit = 0;
|
ExpandedScriptLimit = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CustomNpcs.ScriptDevs.clear();
|
Developer.ScriptUser.clear();
|
||||||
String[] uuidStrings = ScriptDevIDs.split(",");
|
String[] uuidStrings = ScriptDevIDs.split(",");
|
||||||
for (String s : uuidStrings) {
|
for (String s : uuidStrings) {
|
||||||
CustomNpcs.ScriptDevs.add(UUID.fromString(s));
|
Developer.ScriptUser.add(UUID.fromString(s));
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
|
|
||||||
@@ -147,7 +148,7 @@ public class ConfigScript
|
|||||||
|
|
||||||
public static boolean isScriptDev(EntityPlayer player) {
|
public static boolean isScriptDev(EntityPlayer player) {
|
||||||
if(ScriptOpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile()) ||
|
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;
|
return true;
|
||||||
} else return ScriptDevIDs.isEmpty();
|
} else return ScriptDevIDs.isEmpty();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public enum EnumPacketServer {
|
|||||||
LinkedGetAll, LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED),
|
LinkedGetAll, LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED),
|
||||||
ScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), ScriptDataGet(true),
|
ScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), ScriptDataGet(true),
|
||||||
EventScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), EventScriptDataGet(true),
|
EventScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), EventScriptDataGet(true),
|
||||||
PlayerDataRemove(CustomNpcsPermissions.GLOBAL_PLAYERDATA),
|
PlayerDataRemove(CustomNpcsPermissions.GLOBAL_PLAYERDATA), PlayerDataRegen(CustomNpcsPermissions.GLOBAL_PLAYERDATA),
|
||||||
BankSave(CustomNpcsPermissions.GLOBAL_BANK), BanksGet, BankGet,
|
BankSave(CustomNpcsPermissions.GLOBAL_BANK), BanksGet, BankGet,
|
||||||
BankRemove(CustomNpcsPermissions.GLOBAL_BANK),
|
BankRemove(CustomNpcsPermissions.GLOBAL_BANK),
|
||||||
DialogCategorySave(CustomNpcsPermissions.GLOBAL_DIALOG), DialogCategoriesGet, DialogsGetFromDialog,
|
DialogCategorySave(CustomNpcsPermissions.GLOBAL_DIALOG), DialogCategoriesGet, DialogsGetFromDialog,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import noppes.npcs.api.gui.IItemSlot;
|
|||||||
import noppes.npcs.client.gui.custom.components.CustomGuiSlot;
|
import noppes.npcs.client.gui.custom.components.CustomGuiSlot;
|
||||||
import noppes.npcs.scripted.NpcAPI;
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
import noppes.npcs.scripted.gui.ScriptGui;
|
import noppes.npcs.scripted.gui.ScriptGui;
|
||||||
|
import noppes.npcs.util.CustomNPCsScheduler;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
@@ -134,8 +135,7 @@ public class ContainerCustomGui extends Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EntityPlayerMP p = (EntityPlayerMP) player;
|
EntityPlayerMP p = (EntityPlayerMP) player;
|
||||||
p.sendContainerToPlayer(this);
|
CustomNPCsScheduler.runTack(() -> {p.sendContainerToPlayer(this);}, 10);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,10 @@ public class ContainerNPCBankInterface extends ContainerNpcInterface
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized void setCurrency(ItemStack item){
|
||||||
|
currency.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i)
|
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ public class CustomGuiController {
|
|||||||
EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player.getMCEntity();
|
EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player.getMCEntity();
|
||||||
entityPlayerMP.openGui(CustomNpcs.instance, EnumGuiType.CustomGui.ordinal(), player.getWorld().getMCWorld(), gui.getSlots().size(), 0, 0);
|
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());
|
((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) {
|
public static boolean updateGui(IPlayer player, ScriptGui gui) {
|
||||||
if (((EntityPlayerMP)player.getMCEntity()).openContainer instanceof ContainerCustomGui) {
|
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;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@@ -40,11 +40,11 @@ public class CustomGuiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void openOverlay(IPlayer player, ScriptOverlay gui) {
|
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) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,50 +6,196 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.nbt.CompressedStreamTools;
|
import net.minecraft.nbt.CompressedStreamTools;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
import net.minecraft.util.IChatComponent;
|
||||||
import noppes.npcs.CustomNpcs;
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.LogWriter;
|
import noppes.npcs.LogWriter;
|
||||||
import noppes.npcs.controllers.data.Bank;
|
import noppes.npcs.controllers.data.*;
|
||||||
import noppes.npcs.controllers.data.PlayerBankData;
|
import noppes.npcs.util.CustomNPCsScheduler;
|
||||||
import noppes.npcs.controllers.data.PlayerData;
|
|
||||||
import noppes.npcs.controllers.data.PlayerMail;
|
|
||||||
import noppes.npcs.util.NBTJsonUtil;
|
import noppes.npcs.util.NBTJsonUtil;
|
||||||
|
import org.lwjgl.Sys;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileInputStream;
|
import java.util.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
public class PlayerDataController {
|
public class PlayerDataController {
|
||||||
public static PlayerDataController instance;
|
public static PlayerDataController instance;
|
||||||
public Map<String, String> nameUUIDs;
|
public HashMap<String, String> nameUUIDs;
|
||||||
|
|
||||||
public PlayerDataController(){
|
public PlayerDataController(){
|
||||||
instance = this;
|
instance = this;
|
||||||
File dir = getSaveDir();
|
File dir = getSaveDir();
|
||||||
if(dir != null){
|
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
LogWriter.info("Loading PlayerData...");
|
||||||
if(dir.listFiles() != null){
|
// If no PlayerData MAP - Load PlayerData to create PlayerData Map
|
||||||
for(File file : dir.listFiles()){
|
if(!getPlayerDataMap()){
|
||||||
if(file.isDirectory() || !file.getName().endsWith(".json"))
|
LogWriter.info("Generating PlayerData map file...");
|
||||||
continue;
|
File[] files = dir.listFiles(); // Get an array of all files in the directory
|
||||||
try {
|
HashMap<String, String> map = new HashMap<String, String>();
|
||||||
NBTTagCompound compound = NBTJsonUtil.LoadFile(file);
|
if(files != null){
|
||||||
if(compound.hasKey("PlayerName")){
|
int length = files.length;
|
||||||
map.put(compound.getString("PlayerName"), file.getName().substring(0, file.getName().length() - 5));
|
if(length != 0){
|
||||||
|
if(length > 100){
|
||||||
|
LogWriter.info("Found " + length + " PlayerData files... This may take a few minutes");
|
||||||
|
}
|
||||||
|
int tenPercent = (int) ((double) length * 0.1);
|
||||||
|
int progress = 0;
|
||||||
|
// Load the files in parallel using a stream
|
||||||
|
for(int i = 0; i < length; i++){
|
||||||
|
File file = files[i];
|
||||||
|
if(file.isDirectory() || !file.getName().endsWith(".json"))
|
||||||
|
continue;
|
||||||
|
try {
|
||||||
|
NBTTagCompound compound = NBTJsonUtil.LoadFile(file);
|
||||||
|
if(compound.hasKey("PlayerName")){
|
||||||
|
map.put(compound.getString("PlayerName"), file.getName().substring(0, file.getName().length() - 5));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogWriter.error("Error loading: " + file.getAbsolutePath(), e);
|
||||||
|
}
|
||||||
|
if(tenPercent != 0 ){
|
||||||
|
if(progress != 100){
|
||||||
|
if (i % tenPercent == 0) {
|
||||||
|
progress += 10;
|
||||||
|
LogWriter.info("Creating PlayerMap: Progress: " + progress + "%");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
LogWriter.error("Error loading: " + file.getAbsolutePath(), e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nameUUIDs = map;
|
|
||||||
}
|
}
|
||||||
|
nameUUIDs = map;
|
||||||
|
savePlayerDataMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogWriter.info("Done loading PlayerData");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void generatePlayerMap(EntityPlayerMP sender){
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
executor.execute(() -> {
|
||||||
|
if(sender != null){
|
||||||
|
LogWriter.info("PlayerMap regeneration queued by " + sender.getCommandSenderName());
|
||||||
|
sender.addChatMessage(new ChatComponentText("You have initiated PlayerMap regeneration"));
|
||||||
|
}
|
||||||
|
nameUUIDs.clear();
|
||||||
|
|
||||||
|
File dir = getSaveDir();
|
||||||
|
LogWriter.info("Generating PlayerData map file...");
|
||||||
|
File[] files = dir.listFiles(); // Get an array of all files in the directory
|
||||||
|
HashMap<String, String> map = new HashMap<String, String>();
|
||||||
|
if(files != null){
|
||||||
|
int length = files.length;
|
||||||
|
if(length != 0){
|
||||||
|
if(length > 100){
|
||||||
|
LogWriter.info("Found " + length + " PlayerData files... This may take a few minutes");
|
||||||
|
}
|
||||||
|
int tenPercent = (int) ((double) length * 0.1);
|
||||||
|
int progress = 0;
|
||||||
|
// Load the files in parallel using a stream
|
||||||
|
for(int i = 0; i < length; i++){
|
||||||
|
File file = files[i];
|
||||||
|
if(file.isDirectory() || !file.getName().endsWith(".json"))
|
||||||
|
continue;
|
||||||
|
try {
|
||||||
|
NBTTagCompound compound = NBTJsonUtil.LoadFile(file);
|
||||||
|
if(compound.hasKey("PlayerName")){
|
||||||
|
map.put(compound.getString("PlayerName"), file.getName().substring(0, file.getName().length() - 5));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogWriter.error("Error loading: " + file.getAbsolutePath(), e);
|
||||||
|
}
|
||||||
|
if(tenPercent != 0 ){
|
||||||
|
if(progress != 100){
|
||||||
|
if (i % tenPercent == 0) {
|
||||||
|
progress += 10;
|
||||||
|
LogWriter.info("Creating PlayerMap: Progress: " + progress + "%");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nameUUIDs = map;
|
||||||
|
savePlayerDataMap();
|
||||||
|
|
||||||
|
if(sender != null){
|
||||||
|
sender.addChatMessage(new ChatComponentText("PlayerMap regeneration complete"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
executor.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getPlayerDataMap(){
|
||||||
|
try {
|
||||||
|
File file = new File(getSaveDir(), "___playermap.dat");
|
||||||
|
if(file.exists()){
|
||||||
|
loadPlayerDataMap(file);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadPlayerDataMap(File file) throws IOException {
|
||||||
|
DataInputStream var1 = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(file))));
|
||||||
|
loadPlayerDatasMap(var1);
|
||||||
|
var1.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void loadPlayerDatasMap(DataInputStream stream) throws IOException{
|
||||||
|
NBTTagCompound nbttagcompound = CompressedStreamTools.read(stream);
|
||||||
|
readNBT(nbttagcompound);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void savePlayerDataMap(){
|
||||||
|
CustomNPCsScheduler.runTack(() -> {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public File getSaveDir(){
|
public File getSaveDir(){
|
||||||
try{
|
try{
|
||||||
File file = new File(CustomNpcs.getWorldSaveDirectory(),"playerdata");
|
File file = new File(CustomNpcs.getWorldSaveDirectory(),"playerdata");
|
||||||
@@ -113,26 +259,6 @@ public class PlayerDataController {
|
|||||||
return new NBTTagCompound();
|
return new NBTTagCompound();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Executor executor = Executors.newSingleThreadExecutor();
|
|
||||||
public void savePlayerData(PlayerData data){
|
|
||||||
NBTTagCompound compound = data.getNBT();
|
|
||||||
executor.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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerBankData getBankData(EntityPlayer player, int bankId) {
|
public PlayerBankData getBankData(EntityPlayer player, int bankId) {
|
||||||
Bank bank = BankController.getInstance().getBank(bankId);
|
Bank bank = BankController.getInstance().getBank(bankId);
|
||||||
PlayerBankData data = getPlayerData(player).bankData;
|
PlayerBankData data = getPlayerData(player).bankData;
|
||||||
@@ -174,7 +300,7 @@ public class PlayerDataController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
data = PlayerData.get(player);
|
data = PlayerDataController.instance.getPlayerData(player);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -185,7 +311,7 @@ public class PlayerDataController {
|
|||||||
EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username);
|
EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username);
|
||||||
PlayerData data = getDataFromUsername(username);
|
PlayerData data = getDataFromUsername(username);
|
||||||
data.mailData.playermail.add(mail.copy());
|
data.mailData.playermail.add(mail.copy());
|
||||||
savePlayerData(data);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PlayerData> getPlayersData(ICommandSender sender, String username){
|
public List<PlayerData> getPlayersData(ICommandSender sender, String username){
|
||||||
@@ -205,7 +331,39 @@ public class PlayerDataController {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void putPlayerMap(String playerName, String uuid) {
|
||||||
|
nameUUIDs.put(playerName, uuid);
|
||||||
|
savePlayerDataMap();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasMail(EntityPlayer player) {
|
public boolean hasMail(EntityPlayer player) {
|
||||||
return getPlayerData(player).mailData.hasMail();
|
return getPlayerData(player).mailData.hasMail();
|
||||||
}
|
}
|
||||||
|
public void readNBT(NBTTagCompound compound){
|
||||||
|
this.nameUUIDs = new HashMap<String, String>();
|
||||||
|
NBTTagList list = compound.getTagList("PlayerDataMap", 10);
|
||||||
|
if(list != null){
|
||||||
|
for(int i = 0; i < list.tagCount(); i++)
|
||||||
|
{
|
||||||
|
NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
|
||||||
|
String playerName = nbttagcompound.getString("Name");
|
||||||
|
String uuid = nbttagcompound.getString("UUID");
|
||||||
|
nameUUIDs.put(playerName, uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public NBTTagCompound writeNBT(){
|
||||||
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
|
NBTTagList playerList = new NBTTagList();
|
||||||
|
for(String key: nameUUIDs.keySet()){
|
||||||
|
NBTTagCompound playerCompound = new NBTTagCompound();
|
||||||
|
playerCompound.setString("Name", key);
|
||||||
|
playerCompound.setString("UUID", nameUUIDs.get(key));
|
||||||
|
playerList.appendTag(playerCompound);
|
||||||
|
|
||||||
|
}
|
||||||
|
nbt.setTag("PlayerDataMap", playerList);
|
||||||
|
return nbt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -60,17 +60,24 @@ public class PlayerQuestController {
|
|||||||
public static void setQuestFinished(Quest quest, EntityPlayer player){
|
public static void setQuestFinished(Quest quest, EntityPlayer player){
|
||||||
PlayerData playerdata = PlayerDataController.instance.getPlayerData(player);
|
PlayerData playerdata = PlayerDataController.instance.getPlayerData(player);
|
||||||
PlayerQuestData data = playerdata.questData;
|
PlayerQuestData data = playerdata.questData;
|
||||||
|
QuestData questData = data.activeQuests.get(quest.id);
|
||||||
data.activeQuests.remove(quest.id);
|
data.activeQuests.remove(quest.id);
|
||||||
if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY)
|
if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY)
|
||||||
data.finishedQuests.put(quest.id, System.currentTimeMillis());
|
data.finishedQuests.put(quest.id, System.currentTimeMillis());
|
||||||
else
|
else
|
||||||
data.finishedQuests.put(quest.id,player.worldObj.getTotalWorldTime());
|
data.finishedQuests.put(quest.id,player.worldObj.getTotalWorldTime());
|
||||||
|
|
||||||
if(quest.repeat != EnumQuestRepeat.NONE && quest.type == EnumQuestType.Dialog){
|
if(quest.repeat != EnumQuestRepeat.NONE && quest.type == EnumQuestType.Dialog){
|
||||||
QuestDialog questdialog = (QuestDialog) quest.questInterface;
|
QuestDialog questdialog = (QuestDialog) quest.questInterface;
|
||||||
for(int dialog : questdialog.dialogs.values()){
|
for(int dialog : questdialog.dialogs.values()){
|
||||||
playerdata.dialogData.dialogsRead.remove(dialog);
|
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){
|
public static boolean canQuestBeAccepted(Quest quest, EntityPlayer player){
|
||||||
if(quest == null)
|
if(quest == null)
|
||||||
|
|||||||
@@ -254,8 +254,6 @@ public class ServerCloneController implements ICloneHandler {
|
|||||||
nbttagcompound.removeTag("MovingPathNew");
|
nbttagcompound.removeTag("MovingPathNew");
|
||||||
nbttagcompound.removeTag("Pos");
|
nbttagcompound.removeTag("Pos");
|
||||||
nbttagcompound.removeTag("Riding");
|
nbttagcompound.removeTag("Riding");
|
||||||
nbttagcompound.removeTag("UUIDMost");
|
|
||||||
nbttagcompound.removeTag("UUIDLeast");
|
|
||||||
|
|
||||||
if(!nbttagcompound.hasKey("ModRev"))
|
if(!nbttagcompound.hasKey("ModRev"))
|
||||||
nbttagcompound.setInteger("ModRev", 1);
|
nbttagcompound.setInteger("ModRev", 1);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import noppes.npcs.constants.EnumPacketClient;
|
|||||||
import noppes.npcs.containers.ContainerNPCBankInterface;
|
import noppes.npcs.containers.ContainerNPCBankInterface;
|
||||||
import noppes.npcs.controllers.BankController;
|
import noppes.npcs.controllers.BankController;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
import noppes.npcs.util.CustomNPCsScheduler;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@@ -74,10 +75,8 @@ public class BankData {
|
|||||||
return bank.canBeUpgraded(slot) && upgradedSlots.get(slot);
|
return bank.canBeUpgraded(slot) && upgradedSlots.get(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openBankGui(EntityPlayer player, EntityNPCInterface npc, int bankId, int slot) {
|
public void openBankGui(final EntityPlayer player, EntityNPCInterface npc, int bankId, int slot) {
|
||||||
Bank bank = BankController.getInstance().banks.get(bankId);
|
final Bank bank = BankController.getInstance().getBank(bankId);
|
||||||
if(bank == null)
|
|
||||||
bank = BankController.getInstance().banks.values().iterator().next();
|
|
||||||
|
|
||||||
if(bank.getMaxSlots() <= slot)
|
if(bank.getMaxSlots() <= slot)
|
||||||
return;
|
return;
|
||||||
@@ -100,17 +99,19 @@ public class BankData {
|
|||||||
else{
|
else{
|
||||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankSmall, npc, slot, bank.id, 0);
|
NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankSmall, npc, slot, bank.id, 0);
|
||||||
}
|
}
|
||||||
|
final ItemStack item = currency;
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
CustomNPCsScheduler.runTack(() -> {
|
||||||
compound.setInteger("MaxSlots", bank.getMaxSlots());
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
compound.setInteger("UnlockedSlots", unlockedSlots);
|
compound.setInteger("MaxSlots", bank.getMaxSlots());
|
||||||
if(currency != null){
|
compound.setInteger("UnlockedSlots", unlockedSlots);
|
||||||
compound.setTag("Currency", NoppesUtilServer.writeItem(currency, new NBTTagCompound()));
|
if (item != null) {
|
||||||
ContainerNPCBankInterface container = getContainer(player);
|
compound.setTag("Currency", NoppesUtilServer.writeItem(item, new NBTTagCompound()));
|
||||||
container.currency.item = currency;
|
ContainerNPCBankInterface container = getContainer(player);
|
||||||
}
|
if (container != null)
|
||||||
|
container.setCurrency(item);
|
||||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.GUI_DATA,compound);
|
}
|
||||||
|
Server.sendDataChecked((EntityPlayerMP) player, EnumPacketClient.GUI_DATA, compound);
|
||||||
|
}, 300);
|
||||||
}
|
}
|
||||||
private ContainerNPCBankInterface getContainer(EntityPlayer player){
|
private ContainerNPCBankInterface getContainer(EntityPlayer player){
|
||||||
Container con = player.openContainer;
|
Container con = player.openContainer;
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ import javax.script.ScriptEngine;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class DataScript implements IScriptHandler {
|
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 EntityType entities = new EntityType();
|
||||||
private final static JobType jobs = new JobType();
|
private final static JobType jobs = new JobType();
|
||||||
private final static RoleType roles = new RoleType();
|
private final static RoleType roles = new RoleType();
|
||||||
@@ -49,7 +49,7 @@ public class DataScript implements IScriptHandler {
|
|||||||
|
|
||||||
public DataScript(EntityNPCInterface npc) {
|
public DataScript(EntityNPCInterface npc) {
|
||||||
for (int i = 0; i < 15; i++) {
|
for (int i = 0; i < 15; i++) {
|
||||||
scripts.add(new ScriptContainer(this));
|
this.setNPCScript(i, new ScriptContainer(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.npc = npc;
|
this.npc = npc;
|
||||||
@@ -94,30 +94,30 @@ public class DataScript implements IScriptHandler {
|
|||||||
return compound;
|
return compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ScriptContainer> readScript(NBTTagList list){
|
private HashMap<EnumScriptType,ScriptContainer> readScript(NBTTagList list){
|
||||||
List<ScriptContainer> scripts = new ArrayList<>();
|
HashMap<EnumScriptType,ScriptContainer> scripts = new HashMap<>();
|
||||||
for (int i = 0; i < 15; i++) {
|
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++){
|
for(int i = 0; i < list.tagCount(); i++){
|
||||||
NBTTagCompound compoundd = list.getCompoundTagAt(i);
|
NBTTagCompound compoundd = list.getCompoundTagAt(i);
|
||||||
ScriptContainer script = new ScriptContainer(this);
|
ScriptContainer script = new ScriptContainer(this);
|
||||||
script.readFromNBT(compoundd);
|
script.readFromNBT(compoundd);
|
||||||
if(script.hasCode() || npc.isRemote())
|
if (script.hasCode() || npc.isRemote()) {
|
||||||
scripts.set(compoundd.getInteger("Type"), script);
|
scripts.put(EnumScriptType.values()[compoundd.getInteger("Type")], script);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return scripts;
|
return scripts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private NBTTagList writeScript(List<ScriptContainer> scripts){
|
private NBTTagList writeScript(HashMap<EnumScriptType,ScriptContainer> scripts){
|
||||||
NBTTagList list = new NBTTagList();
|
NBTTagList list = new NBTTagList();
|
||||||
for(int type = 0; type < scripts.size(); type++){
|
for (Map.Entry<EnumScriptType,ScriptContainer> entry : scripts.entrySet()) {
|
||||||
NBTTagCompound compoundd = new NBTTagCompound();
|
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||||
compoundd.setInteger("Type", type);
|
tagCompound.setInteger("Type", entry.getKey().ordinal());
|
||||||
ScriptContainer script = scripts.get(type);
|
entry.getValue().writeToNBT(tagCompound);
|
||||||
script.writeToNBT(compoundd);
|
list.appendTag(tagCompound);
|
||||||
list.appendTag(compoundd);
|
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ public class DataScript implements IScriptHandler {
|
|||||||
script.run(type, event);
|
script.run(type, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptContainer script = scripts.get(type.ordinal());
|
ScriptContainer script = scripts.get(type);
|
||||||
if(script == null || script.errored || !script.hasCode())
|
if(script == null || script.errored || !script.hasCode())
|
||||||
return false;
|
return false;
|
||||||
script.setEngine(scriptLanguage);
|
script.setEngine(scriptLanguage);
|
||||||
@@ -198,18 +198,11 @@ public class DataScript implements IScriptHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Map<Long, String> getOldConsoleText() {
|
public Map<Long, String> getOldConsoleText() {
|
||||||
Map<Long, String> map = new TreeMap();
|
Map<Long, String> map = new TreeMap<>();
|
||||||
int tab = 0;
|
|
||||||
Iterator var3 = this.scripts.iterator();
|
|
||||||
|
|
||||||
while(var3.hasNext()) {
|
for (Map.Entry<EnumScriptType,ScriptContainer> entry : scripts.entrySet()) {
|
||||||
ScriptContainer script = (ScriptContainer)var3.next();
|
for (Map.Entry<Long,String> consoleEntry : entry.getValue().console.entrySet()) {
|
||||||
++tab;
|
map.put(consoleEntry.getKey(), " tab " + entry.getKey().ordinal() + ":\n" + consoleEntry.getValue());
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +254,7 @@ public class DataScript implements IScriptHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setScripts(List<ScriptContainer> list) {
|
public void setScripts(List<ScriptContainer> list) {
|
||||||
this.scripts = list;
|
this.eventScripts = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ScriptContainer> getScripts() {
|
public List<ScriptContainer> getScripts() {
|
||||||
@@ -279,4 +272,23 @@ public class DataScript implements IScriptHandler {
|
|||||||
dummyWorld = new ScriptWorld((WorldServer) world);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -19,6 +19,7 @@ import noppes.npcs.entity.data.DataSkinOverlays;
|
|||||||
import noppes.npcs.entity.data.DataTimers;
|
import noppes.npcs.entity.data.DataTimers;
|
||||||
import noppes.npcs.roles.RoleCompanion;
|
import noppes.npcs.roles.RoleCompanion;
|
||||||
import noppes.npcs.scripted.NpcAPI;
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
|
import noppes.npcs.util.CustomNPCsScheduler;
|
||||||
import noppes.npcs.util.NBTJsonUtil;
|
import noppes.npcs.util.NBTJsonUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -55,10 +56,6 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
|||||||
//Do Nothing
|
//Do Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
public void savePlayerDataOnFile() {
|
|
||||||
PlayerDataController.instance.savePlayerData(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadNBTData(NBTTagCompound compound) {
|
public void loadNBTData(NBTTagCompound compound) {
|
||||||
//Do Nothing
|
//Do Nothing
|
||||||
@@ -142,7 +139,7 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
|||||||
|
|
||||||
public void setGUIOpen(boolean bool) {
|
public void setGUIOpen(boolean bool) {
|
||||||
isGUIOpen = bool;
|
isGUIOpen = bool;
|
||||||
savePlayerDataOnFile();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getGUIOpen() {
|
public boolean getGUIOpen() {
|
||||||
@@ -161,7 +158,7 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
|||||||
activeCompanion = npc;
|
activeCompanion = npc;
|
||||||
if(npc != null)
|
if(npc != null)
|
||||||
((RoleCompanion)npc.roleInterface).companionID = companionID;
|
((RoleCompanion)npc.roleInterface).companionID = companionID;
|
||||||
savePlayerDataOnFile();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateCompanion(World world) {
|
public void updateCompanion(World world) {
|
||||||
@@ -302,7 +299,25 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
|||||||
return mailData;
|
return mailData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public synchronized void save() {
|
||||||
PlayerDataController.instance.savePlayerData(this);
|
final NBTTagCompound compound = getNBT();
|
||||||
|
final String filename = uuid + ".json";
|
||||||
|
|
||||||
|
CustomNPCsScheduler.runTack(() -> {
|
||||||
|
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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ import noppes.npcs.api.handler.IPlayerQuestData;
|
|||||||
import noppes.npcs.api.handler.data.IQuest;
|
import noppes.npcs.api.handler.data.IQuest;
|
||||||
import noppes.npcs.constants.EnumPacketClient;
|
import noppes.npcs.constants.EnumPacketClient;
|
||||||
import noppes.npcs.constants.EnumQuestCompletion;
|
import noppes.npcs.constants.EnumQuestCompletion;
|
||||||
|
import noppes.npcs.constants.EnumQuestRepeat;
|
||||||
import noppes.npcs.constants.EnumQuestType;
|
import noppes.npcs.constants.EnumQuestType;
|
||||||
import noppes.npcs.controllers.PlayerDataController;
|
import noppes.npcs.controllers.PlayerDataController;
|
||||||
import noppes.npcs.controllers.QuestController;
|
import noppes.npcs.controllers.QuestController;
|
||||||
@@ -24,7 +25,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class PlayerQuestData implements IPlayerQuestData {
|
public class PlayerQuestData implements IPlayerQuestData {
|
||||||
private final PlayerData parent;
|
private final PlayerData parent;
|
||||||
public IQuest trackedQuest = null;
|
private IQuest trackedQuest = null;
|
||||||
|
|
||||||
public HashMap<Integer,QuestData> activeQuests = new HashMap<Integer,QuestData>();
|
public HashMap<Integer,QuestData> activeQuests = new HashMap<Integer,QuestData>();
|
||||||
public HashMap<Integer,Long> finishedQuests = new HashMap<Integer,Long>();
|
public HashMap<Integer,Long> finishedQuests = new HashMap<Integer,Long>();
|
||||||
@@ -120,8 +121,6 @@ public class PlayerQuestData implements IPlayerQuestData {
|
|||||||
if(data.quest.type != type && type != null)
|
if(data.quest.type != type && type != null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) player,data.quest);
|
|
||||||
|
|
||||||
QuestInterface inter = data.quest.questInterface;
|
QuestInterface inter = data.quest.questInterface;
|
||||||
if(inter.isCompleted(playerData)){
|
if(inter.isCompleted(playerData)){
|
||||||
if((!data.isCompleted && data.quest.completion == EnumQuestCompletion.Npc) || data.quest.instantComplete(player,data)){
|
if((!data.isCompleted && data.quest.completion == EnumQuestCompletion.Npc) || data.quest.instantComplete(player,data)){
|
||||||
@@ -138,14 +137,32 @@ public class PlayerQuestData implements IPlayerQuestData {
|
|||||||
} else {
|
} else {
|
||||||
data.isCompleted = false;
|
data.isCompleted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.trackedQuest != null && data.quest.getId() == this.trackedQuest.getId()) {
|
||||||
|
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QuestItem.pickedUp = null;
|
QuestItem.pickedUp = null;
|
||||||
return bo;
|
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() {
|
public IQuest getTrackedQuest() {
|
||||||
return trackedQuest;
|
return this.trackedQuest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startQuest(int id) {
|
public void startQuest(int id) {
|
||||||
@@ -164,7 +181,11 @@ public class PlayerQuestData implements IPlayerQuestData {
|
|||||||
Quest quest = QuestController.instance.quests.get(id);
|
Quest quest = QuestController.instance.quests.get(id);
|
||||||
if (quest == null)
|
if (quest == null)
|
||||||
return;
|
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) {
|
public void stopQuest(int id) {
|
||||||
|
|||||||
@@ -148,11 +148,11 @@ public class Quest implements ICompatibilty, IQuest {
|
|||||||
|
|
||||||
switch (repeat) {
|
switch (repeat) {
|
||||||
case MCDAILY:
|
case MCDAILY:
|
||||||
return Math.max(0, questTime + 24000 - player.worldObj.getTotalWorldTime());
|
return Math.max(0, (questTime + 24000 - player.worldObj.getTotalWorldTime()) * 50);
|
||||||
case MCWEEKLY:
|
case MCWEEKLY:
|
||||||
return Math.max(0, questTime + 168000 - player.worldObj.getTotalWorldTime());
|
return Math.max(0, (questTime + 168000 - player.worldObj.getTotalWorldTime()) * 50);
|
||||||
case RLDAILY:
|
case RLDAILY:
|
||||||
return Math.max(0, questTime + 86400000 - System.currentTimeMillis());
|
return Math.max(0, questTime + 86400000 - System.currentTimeMillis());
|
||||||
case RLWEEKLY:
|
case RLWEEKLY:
|
||||||
return Math.max(0, questTime + 604800000 - System.currentTimeMillis());
|
return Math.max(0, questTime + 604800000 - System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import noppes.npcs.NoppesUtilServer;
|
|||||||
import noppes.npcs.config.ConfigMain;
|
import noppes.npcs.config.ConfigMain;
|
||||||
import noppes.npcs.constants.EnumGuiType;
|
import noppes.npcs.constants.EnumGuiType;
|
||||||
import noppes.npcs.entity.EntityCustomNpc;
|
import noppes.npcs.entity.EntityCustomNpc;
|
||||||
|
import noppes.npcs.util.CustomNPCsScheduler;
|
||||||
|
|
||||||
public class ItemNpcWand extends Item{
|
public class ItemNpcWand extends Item{
|
||||||
|
|
||||||
@@ -35,14 +36,14 @@ public class ItemNpcWand extends Item{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
if(par3World.isRemote)
|
||||||
return true;
|
return true;
|
||||||
if(ConfigMain.OpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile())){
|
if(ConfigMain.OpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile())){
|
||||||
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
|
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);
|
EntityCustomNpc npc = new EntityCustomNpc(par3World);
|
||||||
npc.ai.startPos = new int[]{par4,par5,par6};
|
npc.ai.startPos = new int[]{par4,par5,par6};
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ public class ItemNpcWand extends Item{
|
|||||||
par3World.spawnEntityInWorld(npc);
|
par3World.spawnEntityInWorld(npc);
|
||||||
npc.setHealth(npc.getMaxHealth());
|
npc.setHealth(npc.getMaxHealth());
|
||||||
|
|
||||||
NoppesUtilServer.sendOpenGui(player,EnumGuiType.MainMenuDisplay,npc);
|
NoppesUtilServer.sendOpenGuiNoDelay(player, EnumGuiType.MainMenuDisplay,npc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
|
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package noppes.npcs.mixin;
|
package noppes.npcs.mixin;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||||
import noppes.npcs.config.ConfigClient;
|
import noppes.npcs.config.ConfigClient;
|
||||||
|
import noppes.npcs.config.ConfigMixin;
|
||||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||||
|
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -32,13 +36,23 @@ public class CustomNPCsMixinPlugin implements IMixinConfigPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getMixins() {
|
public List<String> getMixins() {
|
||||||
|
|
||||||
|
// Load Mixin Config
|
||||||
|
String configPath = "config" + File.separator + "CustomNpcPlus" + File.separator;
|
||||||
|
ConfigMixin.init(new File(configPath + "mixin.cfg"));
|
||||||
|
boolean client = FMLLaunchHandler.side().isClient();
|
||||||
|
|
||||||
List<String> mixins = new ArrayList<>();
|
List<String> mixins = new ArrayList<>();
|
||||||
if (ConfigClient.EntityRendererMixin){
|
|
||||||
mixins.add("MixinEntityRenderer");
|
// Client Only Mixins
|
||||||
}
|
if(client){
|
||||||
if (ConfigClient.AnimationMixin) {
|
if (ConfigMixin.EntityRendererMixin){
|
||||||
mixins.add("MixinModelRenderer");
|
mixins.add("MixinEntityRenderer");
|
||||||
mixins.add("MixinRenderPlayer");
|
}
|
||||||
|
if (ConfigMixin.AnimationMixin) {
|
||||||
|
mixins.add("MixinModelRenderer");
|
||||||
|
mixins.add("MixinRenderPlayer");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return mixins;
|
return mixins;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package noppes.npcs.mixin;
|
package noppes.npcs.mixin;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.Mod;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.client.model.ModelBase;
|
||||||
import net.minecraft.client.model.ModelBiped;
|
import net.minecraft.client.model.ModelBiped;
|
||||||
import net.minecraft.client.model.ModelRenderer;
|
import net.minecraft.client.model.ModelRenderer;
|
||||||
import noppes.npcs.AnimationData;
|
import noppes.npcs.AnimationData;
|
||||||
@@ -38,6 +40,8 @@ public abstract class MixinModelRenderer {
|
|||||||
@Shadow public List childModels;
|
@Shadow public List childModels;
|
||||||
@Shadow abstract void compileDisplayList(float p_78788_1_);
|
@Shadow abstract void compileDisplayList(float p_78788_1_);
|
||||||
|
|
||||||
|
@Shadow public ModelBase baseModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Someone
|
* @author Someone
|
||||||
* @reason Because we need it
|
* @reason Because we need it
|
||||||
@@ -108,7 +112,7 @@ public abstract class MixinModelRenderer {
|
|||||||
}
|
}
|
||||||
if (ClientEventHandler.renderingPlayer != null && Client.playerAnimations.containsKey(ClientEventHandler.renderingPlayer.getUniqueID())) {
|
if (ClientEventHandler.renderingPlayer != null && Client.playerAnimations.containsKey(ClientEventHandler.renderingPlayer.getUniqueID())) {
|
||||||
animData = Client.playerAnimations.get(ClientEventHandler.renderingPlayer.getUniqueID());
|
animData = Client.playerAnimations.get(ClientEventHandler.renderingPlayer.getUniqueID());
|
||||||
EnumAnimationPart mainPartType = this.getPlayerPartType((ModelRenderer) (Object) this);
|
EnumAnimationPart mainPartType = null;
|
||||||
EnumAnimationPart pivotEqualPart = null;
|
EnumAnimationPart pivotEqualPart = null;
|
||||||
if (mainPartType == null) {
|
if (mainPartType == null) {
|
||||||
pivotEqualPart = this.pivotEqualPart((ModelRenderer) (Object) this);
|
pivotEqualPart = this.pivotEqualPart((ModelRenderer) (Object) this);
|
||||||
@@ -157,7 +161,9 @@ public abstract class MixinModelRenderer {
|
|||||||
{
|
{
|
||||||
for (i = 0; i < this.childModels.size(); ++i)
|
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)
|
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)
|
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();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,30 +283,32 @@ public abstract class MixinModelRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public EnumAnimationPart pivotEqualPart(ModelRenderer renderer) {
|
public EnumAnimationPart pivotEqualPart(ModelRenderer renderer) {
|
||||||
ModelRenderer head = ((ModelBiped) renderer.baseModel).bipedHead;
|
if(renderer.baseModel instanceof ModelBiped){
|
||||||
ModelRenderer body = ((ModelBiped) renderer.baseModel).bipedBody;
|
ModelRenderer head = ((ModelBiped) renderer.baseModel).bipedHead;
|
||||||
ModelRenderer larm = ((ModelBiped) renderer.baseModel).bipedLeftArm;
|
ModelRenderer body = ((ModelBiped) renderer.baseModel).bipedBody;
|
||||||
ModelRenderer rarm = ((ModelBiped) renderer.baseModel).bipedRightArm;
|
ModelRenderer larm = ((ModelBiped) renderer.baseModel).bipedLeftArm;
|
||||||
ModelRenderer lleg = ((ModelBiped) renderer.baseModel).bipedLeftLeg;
|
ModelRenderer rarm = ((ModelBiped) renderer.baseModel).bipedRightArm;
|
||||||
ModelRenderer rleg = ((ModelBiped) renderer.baseModel).bipedRightLeg;
|
ModelRenderer lleg = ((ModelBiped) renderer.baseModel).bipedLeftLeg;
|
||||||
|
ModelRenderer rleg = ((ModelBiped) renderer.baseModel).bipedRightLeg;
|
||||||
|
|
||||||
if (pivotsEqual(renderer,head)) {
|
if (pivotsEqual(renderer,head)) {
|
||||||
return EnumAnimationPart.HEAD;
|
return EnumAnimationPart.HEAD;
|
||||||
}
|
}
|
||||||
if (pivotsEqual(renderer,body)) {
|
if (pivotsEqual(renderer,body)) {
|
||||||
return EnumAnimationPart.BODY;
|
return EnumAnimationPart.BODY;
|
||||||
}
|
}
|
||||||
if (pivotsEqual(renderer,rarm)) {
|
if (pivotsEqual(renderer,rarm)) {
|
||||||
return EnumAnimationPart.RIGHT_ARM;
|
return EnumAnimationPart.RIGHT_ARM;
|
||||||
}
|
}
|
||||||
if (pivotsEqual(renderer,larm)) {
|
if (pivotsEqual(renderer,larm)) {
|
||||||
return EnumAnimationPart.LEFT_ARM;
|
return EnumAnimationPart.LEFT_ARM;
|
||||||
}
|
}
|
||||||
if (pivotsEqual(renderer,rleg)) {
|
if (pivotsEqual(renderer,rleg)) {
|
||||||
return EnumAnimationPart.RIGHT_LEG;
|
return EnumAnimationPart.RIGHT_LEG;
|
||||||
}
|
}
|
||||||
if (pivotsEqual(renderer,lleg)) {
|
if (pivotsEqual(renderer,lleg)) {
|
||||||
return EnumAnimationPart.LEFT_LEG;
|
return EnumAnimationPart.LEFT_LEG;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -99,13 +99,13 @@ public class QuestDialog extends QuestInterface implements IQuestDialog {
|
|||||||
if (progress == 0 && completed) {
|
if (progress == 0 && completed) {
|
||||||
data.dialogData.dialogsRead.remove(this.dialog.id);
|
data.dialogData.dialogsRead.remove(this.dialog.id);
|
||||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]);
|
data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]);
|
||||||
data.savePlayerDataOnFile();
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (progress == 1 && !completed) {
|
if (progress == 1 && !completed) {
|
||||||
data.dialogData.dialogsRead.add(this.dialog.id);
|
data.dialogData.dialogsRead.add(this.dialog.id);
|
||||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]);
|
data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]);
|
||||||
data.savePlayerDataOnFile();
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import noppes.npcs.constants.EnumPacketClient;
|
|||||||
import noppes.npcs.controllers.PlayerDataController;
|
import noppes.npcs.controllers.PlayerDataController;
|
||||||
import noppes.npcs.controllers.QuestController;
|
import noppes.npcs.controllers.QuestController;
|
||||||
import noppes.npcs.controllers.data.PlayerData;
|
import noppes.npcs.controllers.data.PlayerData;
|
||||||
|
import noppes.npcs.controllers.data.PlayerQuestData;
|
||||||
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
@@ -19,9 +20,11 @@ public abstract class QuestInterface implements IQuestInterface {
|
|||||||
public abstract void readEntityFromNBT(NBTTagCompound compound);
|
public abstract void readEntityFromNBT(NBTTagCompound compound);
|
||||||
public abstract boolean isCompleted(PlayerData player);
|
public abstract boolean isCompleted(PlayerData player);
|
||||||
public void handleComplete(EntityPlayer player) {
|
public void handleComplete(EntityPlayer player) {
|
||||||
if (QuestController.instance.get(questId).equals(PlayerDataController.instance.getPlayerData(player).questData.trackedQuest)) {
|
PlayerQuestData questData = PlayerDataController.instance.getPlayerData(player).questData;
|
||||||
PlayerDataController.instance.getPlayerData(player).questData.trackedQuest = null;
|
if(questData != null && questData.getTrackedQuest() != null){
|
||||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.OVERLAY_QUEST_TRACKING);
|
if (this.questId == PlayerDataController.instance.getPlayerData(player).questData.getTrackedQuest().getId()) {
|
||||||
|
PlayerDataController.instance.getPlayerData(player).questData.untrackQuest();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public abstract Vector<String> getQuestLogStatus(EntityPlayer player);
|
public abstract Vector<String> getQuestLogStatus(EntityPlayer player);
|
||||||
|
|||||||
@@ -131,18 +131,16 @@ public class QuestItem extends QuestInterface implements IQuestItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IQuestObjective[] getObjectives(EntityPlayer player) {
|
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);
|
List<ItemStack> questItems = NoppesUtilPlayer.countStacks(this.items, this.ignoreDamage, this.ignoreNBT);
|
||||||
Iterator var4 = questItems.iterator();
|
|
||||||
|
|
||||||
while(var4.hasNext()) {
|
for (ItemStack stack : questItems) {
|
||||||
ItemStack stack = (ItemStack)var4.next();
|
|
||||||
if (stack.stackSize > 0) {
|
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){
|
public void setLeaveItems(boolean leaveItems){
|
||||||
@@ -180,8 +178,13 @@ public class QuestItem extends QuestInterface implements IQuestItem {
|
|||||||
public int getProgress() {
|
public int getProgress() {
|
||||||
int count = 0;
|
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) {
|
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)) {
|
if (!NoppesUtilServer.IsItemStackNull(item) && NoppesUtilPlayer.compareItems(this.questItem, item, this.parent.ignoreDamage, this.parent.ignoreNBT)) {
|
||||||
count += item.stackSize;
|
count += item.stackSize;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ public class QuestKill extends QuestInterface implements IQuestKill {
|
|||||||
this.parent.setKilled(questdata, killed);
|
this.parent.setKilled(questdata, killed);
|
||||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]);
|
data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]);
|
||||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[4]);
|
data.questData.checkQuestCompletion(data, EnumQuestType.values()[4]);
|
||||||
data.savePlayerDataOnFile();
|
data.save();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new CustomNPCsException("Progress has to be between 0 and " + this.amount, new Object[0]);
|
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)) {
|
if ((!completed || progress != 1) && (completed || progress != 0)) {
|
||||||
questData.extraData.setBoolean(this.nbtName, progress == 1);
|
questData.extraData.setBoolean(this.nbtName, progress == 1);
|
||||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[3]);
|
data.questData.checkQuestCompletion(data, EnumQuestType.values()[3]);
|
||||||
data.savePlayerDataOnFile();
|
data.save();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]);
|
throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import noppes.npcs.api.item.IItemStack;
|
|||||||
import noppes.npcs.api.overlay.ICustomOverlay;
|
import noppes.npcs.api.overlay.ICustomOverlay;
|
||||||
import noppes.npcs.config.ConfigScript;
|
import noppes.npcs.config.ConfigScript;
|
||||||
import noppes.npcs.constants.EnumPacketClient;
|
import noppes.npcs.constants.EnumPacketClient;
|
||||||
|
import noppes.npcs.constants.EnumQuestRepeat;
|
||||||
import noppes.npcs.constants.EnumQuestType;
|
import noppes.npcs.constants.EnumQuestType;
|
||||||
import noppes.npcs.containers.ContainerCustomGui;
|
import noppes.npcs.containers.ContainerCustomGui;
|
||||||
import noppes.npcs.controllers.*;
|
import noppes.npcs.controllers.*;
|
||||||
@@ -270,7 +271,11 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
|||||||
if (quest == null)
|
if (quest == null)
|
||||||
return;
|
return;
|
||||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package noppes.npcs.util;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public class CustomNPCsScheduler {
|
||||||
|
private final static ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
||||||
|
|
||||||
|
public static void runTack(Runnable task, int delay){
|
||||||
|
executor.schedule(task, delay, TimeUnit.MILLISECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void runTack(Runnable task){
|
||||||
|
executor.schedule(task, 0, TimeUnit.MILLISECONDS);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import net.minecraft.init.Blocks;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import noppes.npcs.CustomItems;
|
import noppes.npcs.CustomItems;
|
||||||
import noppes.npcs.client.gui.player.GuiFaction;
|
import noppes.npcs.client.gui.player.GuiFaction;
|
||||||
|
import noppes.npcs.util.CustomNPCsScheduler;
|
||||||
|
|
||||||
public class InventoryTabFactions extends AbstractTab {
|
public class InventoryTabFactions extends AbstractTab {
|
||||||
public InventoryTabFactions() {
|
public InventoryTabFactions() {
|
||||||
@@ -15,19 +16,10 @@ public class InventoryTabFactions extends AbstractTab {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTabClicked() {
|
public void onTabClicked() {
|
||||||
Thread t = new Thread(){
|
CustomNPCsScheduler.runTack(() -> {
|
||||||
@Override
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
public void run(){
|
mc.displayGuiScreen(new GuiFaction());
|
||||||
try {
|
}, 100);
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
mc.displayGuiScreen(new GuiFaction());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
t.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import net.minecraft.init.Items;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.play.client.C0DPacketCloseWindow;
|
import net.minecraft.network.play.client.C0DPacketCloseWindow;
|
||||||
import noppes.npcs.CustomItems;
|
import noppes.npcs.CustomItems;
|
||||||
|
import noppes.npcs.client.gui.player.GuiFaction;
|
||||||
import noppes.npcs.client.gui.player.GuiQuestLog;
|
import noppes.npcs.client.gui.player.GuiQuestLog;
|
||||||
|
import noppes.npcs.util.CustomNPCsScheduler;
|
||||||
|
|
||||||
public class InventoryTabQuests extends AbstractTab {
|
public class InventoryTabQuests extends AbstractTab {
|
||||||
public InventoryTabQuests() {
|
public InventoryTabQuests() {
|
||||||
@@ -17,19 +19,10 @@ public class InventoryTabQuests extends AbstractTab {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTabClicked() {
|
public void onTabClicked() {
|
||||||
Thread t = new Thread(){
|
CustomNPCsScheduler.runTack(() -> {
|
||||||
@Override
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
public void run(){
|
mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer));
|
||||||
try {
|
}, 100);
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
t.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in new issue
Block a user