mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-24 15:14:26 +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
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
TL;DR
|
||||
> You CAN
|
||||
-- Fork and modify the code.
|
||||
-- Submit Pull Requests to this repository.
|
||||
-- Copy portions of this code for use in other projects.
|
||||
-- Write your own code that uses this code as a dependency. (addon mods!)
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
> You CANNOT
|
||||
-- Redistribute this in its entirety as source or compiled code.
|
||||
-- Create or distribute code which contains 50% or more Functionally Equivalent Statements* from this repository.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
> You MUST
|
||||
-- Maintain a visible repository of your code which is inspired by, derived from, or copied from this code. Basically, if you use it, pay it forward. You keep rights to your OWN code, but you still must make your source visible.
|
||||
|
||||
General Clauses
|
||||
Clauses that apply in general to any of the uses that follow.
|
||||
- Personal Permission Clause
|
||||
I will only give personal permission if I, KAMKEEL, am directly asked. If personal permission is given this does not imply endorsement.
|
||||
- Waive Clause
|
||||
All restrictive clauses in this license can be ignored with personal permission. Read the above clause.
|
||||
- Extensive Clause
|
||||
This license applies to CustomNPC+, the CustomNPC+ website, the legacy CustomNPC+ website and all other code, assets or binaries found on this website or the github repository unless otherwise indicated.
|
||||
- Informal Clause
|
||||
This license will not hold up in court. I have no intention of suing anyone for breaking it, the worst that can happen to you if you do is that I'll get annoyed and ask you to rectify your mistake. If you use a public distribution platform (such as CurseForge) it's also possible your project will get taken down. Breaking the license also makes you a jerk, and you don't want to be a jerk, do you?
|
||||
|
||||
If you want to Distribute CustomNPC+
|
||||
"Distribution" refers to making available binaries, assets, or source of the mod available from the original sources as part of your modpack or otherwise.
|
||||
- Attribution Clause
|
||||
You must give appropriate credit to KAMKEEL as the creator of CustomNPC+ or the parts of it you're using. Noppes can also be credit as the original Mod Author. If you do any alterations the fact that you do so should also be indicated. A link back is optional but it would be cool if you would do so.
|
||||
- Redistribution Clause
|
||||
You may not redistribute the enitirity of the source code provided, unless heavy modifications are made to it as a whole. More than 50% of the code cannot be redistributed unless direct permission is provided from either KAMKEEL or Noppes.
|
||||
- Non-Monetary Clause
|
||||
You may not charge for access to the distribution itself or gain money through it, this includes any type of inline advertisement, such as url shorteners (adf.ly or otherwise) or ads in your service slowing the download down. This includes restricting any amount of access behind a paywall. Charging for ingame goods such as mod items or cosmetic features on a server does not count as distribution and falls purely under the Mojang Terms of Service.
|
||||
|
||||
If you want to Feature CustomNPC+
|
||||
"Featuring" refers to using CustomNPC+ in an environment where you do not distribute binaries, assets, or source. An example would be a YouTube Let's Play.
|
||||
- Thief Clause
|
||||
You must not claim that you made CustomNPC+. Giving appropriate credit to KAMKEEL as the creator of CustomNPC+ makes you cooler, but you don't have to do it if you don't want to.
|
||||
|
||||
If you want to Use CustomNPC+ Code or Assets
|
||||
Usage of code or assets falls under the Extensive Clause.
|
||||
- External Clause
|
||||
Certain parts of the codebase are indicated to be licensed under alternative licenses. You must obey those licenses.
|
||||
- Attribution Clause
|
||||
You must give appropriate credit to KAMKEEL as the creator of CustomNPC+ or the parts of it you're using. Noppes can also be credit as the original Mod Author. If you do any alterations the fact that you do so should also be indicated. A link back is optional but it would be cool if you would do so.
|
||||
- Copyleft Clause
|
||||
Your project must be open source (have its source visible and allow for redistribution and modification) and include a clause similar to this one in its license.
|
||||
- API Clause
|
||||
Any of the other clauses under this section do not apply to any CustomNPC+ API code (the subdirectory src/api or https://github.com/KAMKEEL/CustomNPC-Plus-API). However, if CustomNPC+ API code is used, it must be included verbatim as it was obtained.
|
||||
+7
-4
@@ -34,7 +34,7 @@ configurations {
|
||||
|
||||
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
|
||||
archivesBaseName = "CustomNPC-Plus"
|
||||
|
||||
@@ -89,8 +89,6 @@ processResources
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {main { output.resourcesDir = output.classesDir }}
|
||||
|
||||
jar {
|
||||
from sourceSets.api.output
|
||||
|
||||
@@ -113,7 +111,7 @@ def refMapForYourConfig = 'customnpcs.refmap.json'
|
||||
def relativePathToMixinAP = 'tools/mixin-0.8-SNAPSHOT.jar'
|
||||
|
||||
if(!embedMixin){
|
||||
version += "+nomixin"
|
||||
version += "-nomixin"
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -202,3 +200,8 @@ sourceSets {
|
||||
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){
|
||||
playerdata.dialogData.dialogsRead.add(diagid);
|
||||
playerdata.savePlayerDataOnFile();
|
||||
playerdata.save();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public class CmdDialog extends ChMcLogger {
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.dialogData.dialogsRead.remove(diagid);
|
||||
playerdata.savePlayerDataOnFile();
|
||||
playerdata.save();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -41,173 +41,170 @@ import foxz.commandhelper.permissions.PlayerOnly;
|
||||
)
|
||||
public class CmdNoppes extends ChMcLogger {
|
||||
|
||||
public CmdFaction cmdfaction = new CmdFaction(ctorParm);
|
||||
public CmdNpc cmdnpc= new CmdNpc(ctorParm);
|
||||
public static Map<String,Class<?>> SlayMap = new LinkedHashMap<String,Class<?>>();
|
||||
|
||||
public CmdNoppes(Object sender) {
|
||||
super(sender);
|
||||
|
||||
SlayMap.clear();
|
||||
|
||||
SlayMap.put("all",EntityLivingBase.class);
|
||||
SlayMap.put("mobs",EntityMob.class);
|
||||
public CmdFaction cmdfaction = new CmdFaction(ctorParm);
|
||||
public CmdNpc cmdnpc = new CmdNpc(ctorParm);
|
||||
public static Map<String, Class<?>> SlayMap = new LinkedHashMap<String, Class<?>>();
|
||||
|
||||
public CmdNoppes(Object sender) {
|
||||
super(sender);
|
||||
|
||||
SlayMap.clear();
|
||||
|
||||
SlayMap.put("all", EntityLivingBase.class);
|
||||
SlayMap.put("mobs", EntityMob.class);
|
||||
SlayMap.put("animals", EntityAnimal.class);
|
||||
SlayMap.put("items", EntityItem.class);
|
||||
SlayMap.put("xporbs", EntityXPOrb.class);
|
||||
SlayMap.put("npcs", EntityNPCInterface.class);
|
||||
|
||||
HashMap<String,Class<?>> list = new HashMap<String,Class<?>>(EntityList.stringToClassMapping);
|
||||
for(String name : list.keySet()){
|
||||
|
||||
HashMap<String, Class<?>> list = new HashMap<String, Class<?>>(EntityList.stringToClassMapping);
|
||||
for (String name : list.keySet()) {
|
||||
Class<?> cls = list.get(name);
|
||||
if(EntityNPCInterface.class.isAssignableFrom(cls))
|
||||
if (EntityNPCInterface.class.isAssignableFrom(cls))
|
||||
continue;
|
||||
if(!EntityLivingBase.class.isAssignableFrom(cls))
|
||||
if (!EntityLivingBase.class.isAssignableFrom(cls))
|
||||
continue;
|
||||
SlayMap.put(name.toLowerCase(), list.get(name));
|
||||
}
|
||||
|
||||
SlayMap.remove("monster");
|
||||
SlayMap.remove("mob");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
name = "faction",
|
||||
desc = "Faction operations",
|
||||
usage = "<player> <faction> <command>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean faction(String[] args) {
|
||||
String playername = args[0];
|
||||
String factionname = args[1];
|
||||
|
||||
cmdfaction.data = getPlayersData(playername);
|
||||
if (cmdfaction.data.isEmpty()) {
|
||||
sendmessage(String.format("Unknow player '%s'", playername));
|
||||
return false;
|
||||
}
|
||||
try{
|
||||
cmdfaction.selectedFaction = FactionController.getInstance().get(Integer.parseInt(factionname));
|
||||
}
|
||||
catch(NumberFormatException e){
|
||||
cmdfaction.selectedFaction = FactionController.getInstance().getFactionFromName(factionname); // get faction data
|
||||
}
|
||||
if (cmdfaction.selectedFaction == null) {
|
||||
sendmessage(String.format("Unknow facion '%s", factionname));
|
||||
return false;
|
||||
}
|
||||
args = Arrays.copyOfRange(args, 2, args.length);
|
||||
cmdfaction.processCommand(this.pcParam, args);
|
||||
|
||||
for(PlayerData playerdata : cmdfaction.data){
|
||||
playerdata.savePlayerDataOnFile();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="NPC manipulations",
|
||||
usage="<npc> <command>",
|
||||
permissions={OpOnly.class,ParamCheck.class}
|
||||
)
|
||||
public boolean npc(String[] args){
|
||||
String npcname=args[0].replace("%", " ");
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
if(args[0].equalsIgnoreCase("create")){
|
||||
cmdnpc.processCommand(this.pcParam, new String[]{args[0], npcname});
|
||||
return true;
|
||||
}
|
||||
int x = pcParam.getPlayerCoordinates().posX;
|
||||
int y = pcParam.getPlayerCoordinates().posY;
|
||||
int z = pcParam.getPlayerCoordinates().posZ;
|
||||
List<EntityNPCInterface> list = getNearbeEntityFromPlayer(EntityNPCInterface.class, pcParam.getEntityWorld(), x, y, z, 80);
|
||||
EntityNPCInterface closest = null;
|
||||
for (EntityNPCInterface npc : list) {
|
||||
String name = npc.display.name.replace(" ", "_");
|
||||
if (name.equalsIgnoreCase(npcname)){
|
||||
if(closest == null || closest.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
|
||||
closest = npc;
|
||||
}
|
||||
}
|
||||
if(closest != null){
|
||||
cmdnpc.selectedNpc=closest;
|
||||
cmdnpc.processCommand(this.pcParam, args);
|
||||
cmdnpc.selectedNpc = null;
|
||||
}
|
||||
else
|
||||
sendmessage(String.format("NPC '%s' was not found",npcname));
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
name = "slay",
|
||||
desc = "Kills given entity within range. Also has all, mobs, animal options. Can have multiple types",
|
||||
usage = "<type>.. [range]",
|
||||
permissions = {PlayerOnly.class, OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean slay(String[] args) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) pcParam;
|
||||
@SubCommand(
|
||||
name = "faction",
|
||||
desc = "Faction operations",
|
||||
usage = "<player> <faction> <command>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean faction(String[] args) {
|
||||
String playername = args[0];
|
||||
String factionname = args[1];
|
||||
|
||||
cmdfaction.data = getPlayersData(playername);
|
||||
if (cmdfaction.data.isEmpty()) {
|
||||
sendmessage(String.format("Unknow player '%s'", playername));
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
cmdfaction.selectedFaction = FactionController.getInstance().get(Integer.parseInt(factionname));
|
||||
} catch (NumberFormatException e) {
|
||||
cmdfaction.selectedFaction = FactionController.getInstance().getFactionFromName(factionname); // get faction data
|
||||
}
|
||||
if (cmdfaction.selectedFaction == null) {
|
||||
sendmessage(String.format("Unknow facion '%s", factionname));
|
||||
return false;
|
||||
}
|
||||
args = Arrays.copyOfRange(args, 2, args.length);
|
||||
cmdfaction.processCommand(this.pcParam, args);
|
||||
|
||||
for (PlayerData playerdata : cmdfaction.data) {
|
||||
playerdata.save();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "NPC manipulations",
|
||||
usage = "<npc> <command>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public boolean npc(String[] args) {
|
||||
String npcname = args[0].replace("%", " ");
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
if (args[0].equalsIgnoreCase("create")) {
|
||||
cmdnpc.processCommand(this.pcParam, new String[]{args[0], npcname});
|
||||
return true;
|
||||
}
|
||||
int x = pcParam.getPlayerCoordinates().posX;
|
||||
int y = pcParam.getPlayerCoordinates().posY;
|
||||
int z = pcParam.getPlayerCoordinates().posZ;
|
||||
List<EntityNPCInterface> list = getNearbeEntityFromPlayer(EntityNPCInterface.class, pcParam.getEntityWorld(), x, y, z, 80);
|
||||
EntityNPCInterface closest = null;
|
||||
for (EntityNPCInterface npc : list) {
|
||||
String name = npc.display.name.replace(" ", "_");
|
||||
if (name.equalsIgnoreCase(npcname)) {
|
||||
if (closest == null || closest.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
|
||||
closest = npc;
|
||||
}
|
||||
}
|
||||
if (closest != null) {
|
||||
cmdnpc.selectedNpc = closest;
|
||||
cmdnpc.processCommand(this.pcParam, args);
|
||||
cmdnpc.selectedNpc = null;
|
||||
} else
|
||||
sendmessage(String.format("NPC '%s' was not found", npcname));
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
name = "slay",
|
||||
desc = "Kills given entity within range. Also has all, mobs, animal options. Can have multiple types",
|
||||
usage = "<type>.. [range]",
|
||||
permissions = {PlayerOnly.class, OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean slay(String[] args) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) pcParam;
|
||||
ArrayList<Class<?>> toDelete = new ArrayList<Class<?>>();
|
||||
boolean deleteNPCs = false;
|
||||
for(String delete : args){
|
||||
for (String delete : args) {
|
||||
delete = delete.toLowerCase();
|
||||
Class<?> cls = SlayMap.get(delete);
|
||||
if(cls != null)
|
||||
if (cls != null)
|
||||
toDelete.add(cls);
|
||||
if(delete.equals("mobs")){
|
||||
if (delete.equals("mobs")) {
|
||||
toDelete.add(EntityGhast.class);
|
||||
toDelete.add(EntityDragon.class);
|
||||
}
|
||||
if(delete.equals("npcs"))
|
||||
if (delete.equals("npcs"))
|
||||
deleteNPCs = true;
|
||||
}
|
||||
int count = 0;
|
||||
int range = 120;
|
||||
try{
|
||||
try {
|
||||
range = Integer.parseInt(args[args.length - 1]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
|
||||
}
|
||||
AxisAlignedBB box = player.boundingBox.expand(range, range, range);
|
||||
List<Entity> list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, box);
|
||||
|
||||
for(Entity entity : list){
|
||||
if(entity instanceof EntityPlayer)
|
||||
|
||||
for (Entity entity : list) {
|
||||
if (entity instanceof EntityPlayer)
|
||||
continue;
|
||||
if(entity instanceof EntityTameable && ((EntityTameable)entity).isTamed())
|
||||
if (entity instanceof EntityTameable && ((EntityTameable) entity).isTamed())
|
||||
continue;
|
||||
if(entity instanceof EntityNPCInterface && !deleteNPCs)
|
||||
if (entity instanceof EntityNPCInterface && !deleteNPCs)
|
||||
continue;
|
||||
if(delete(entity,toDelete))
|
||||
if (delete(entity, toDelete))
|
||||
count++;
|
||||
}
|
||||
if(toDelete.contains(EntityXPOrb.class)){
|
||||
if (toDelete.contains(EntityXPOrb.class)) {
|
||||
list = player.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, box);
|
||||
for(Entity entity : list){
|
||||
for (Entity entity : list) {
|
||||
entity.isDead = true;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if(toDelete.contains(EntityItem.class)){
|
||||
if (toDelete.contains(EntityItem.class)) {
|
||||
list = player.worldObj.getEntitiesWithinAABB(EntityItem.class, box);
|
||||
for(Entity entity : list){
|
||||
for (Entity entity : list) {
|
||||
entity.isDead = true;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
player.addChatMessage(new ChatComponentTranslation(count + " entities deleted"));
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean delete(Entity entity, ArrayList<Class<?>> toDelete) {
|
||||
for(Class<?> delete : toDelete){
|
||||
if(delete == EntityAnimal.class && (entity instanceof EntityHorse)){
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean delete(Entity entity, ArrayList<Class<?>> toDelete) {
|
||||
for (Class<?> delete : toDelete) {
|
||||
if (delete == EntityAnimal.class && (entity instanceof EntityHorse)) {
|
||||
continue;
|
||||
}
|
||||
if(delete.isAssignableFrom(entity.getClass())){
|
||||
if (delete.isAssignableFrom(entity.getClass())) {
|
||||
entity.isDead = true;
|
||||
return true;
|
||||
}
|
||||
@@ -215,53 +212,17 @@ public class CmdNoppes extends ChMcLogger {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public List addTabCompletion(ICommandSender par1, String[] args) {
|
||||
if(args[0].equalsIgnoreCase("slay")){
|
||||
if (args[0].equalsIgnoreCase("slay")) {
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, SlayMap.keySet().toArray(new String[SlayMap.size()]));
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("npc") && args.length == 3){
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("npc") && args.length == 3) {
|
||||
return cmdnpc.addTabCompletion(par1, Arrays.copyOfRange(args, 1, args.length));
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("faction") && args.length == 4){
|
||||
if (args[0].equalsIgnoreCase("faction") && args.length == 4) {
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"add", "subtract", "set", "reset", "drop", "create"});
|
||||
}
|
||||
return super.addTabCompletion(par1, args);
|
||||
}
|
||||
//<editor-fold desc="--- FoxZ fork (keep it pls)">
|
||||
// @SubCommand(
|
||||
// desc = "Save AltPlayerInv",
|
||||
// usage = "{player} {inv}",
|
||||
// permissions={OpOnly.class}
|
||||
// )
|
||||
// public boolean sapi(String[] args) {
|
||||
// EntityPlayer p = getOnlinePlayer(args[0]);
|
||||
// sendmessage(String.format("noppes.sapi:%s %s", args[0], args[1]));
|
||||
// if (p == null) {
|
||||
// sendmessage("noppes.sapi:unkow " + args[0]);
|
||||
// return false;
|
||||
// }
|
||||
// savePlayerAltInv(p, args[1]);
|
||||
// sendmessage("noppes.sapi:saved");
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @SubCommand(
|
||||
// desc = "Load AltPlayerInv",
|
||||
// usage = "{player} {inv}",
|
||||
// permissions={OpOnly.class}
|
||||
// )
|
||||
// public boolean lapi(String[] args) {
|
||||
// EntityPlayer p = getOnlinePlayer(args[0]);
|
||||
// sendmessage(String.format("noppes.lapi:%s %s", args[0], args[1]));
|
||||
// if (p == null) {
|
||||
// sendmessage("noppes.sapi:unknow " + args[0]);
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// loadPlayerAltInv(p, args[1]);
|
||||
// sendmessage("noppes.lapi:loaded");
|
||||
// return true;
|
||||
// }
|
||||
//</editor-fold>
|
||||
}
|
||||
return super.addTabCompletion(par1, args);
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class CmdQuest extends ChMcLogger{
|
||||
continue;
|
||||
QuestData questdata = new QuestData(quest);
|
||||
playerdata.questData.activeQuests.put(questid, questdata);
|
||||
playerdata.savePlayerDataOnFile();
|
||||
playerdata.save();
|
||||
if(playerdata.player != null){
|
||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
|
||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
|
||||
@@ -93,7 +93,7 @@ public class CmdQuest extends ChMcLogger{
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis());
|
||||
playerdata.savePlayerDataOnFile();
|
||||
playerdata.save();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ public class CmdQuest extends ChMcLogger{
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.savePlayerDataOnFile();
|
||||
playerdata.save();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -156,7 +156,7 @@ public class CmdQuest extends ChMcLogger{
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.questData.finishedQuests.remove(questid);
|
||||
playerdata.savePlayerDataOnFile();
|
||||
playerdata.save();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+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.ICommandSender;
|
||||
import net.minecraft.entity.monster.EntityEnderman;
|
||||
import noppes.npcs.controllers.AnimationController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.controllers.data.PlayerFactionData;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -49,7 +46,7 @@ public class AnimationCommand extends CommandKamkeelBase {
|
||||
|
||||
processSubCommand(sender, args[1], Arrays.copyOfRange(args, 2, args.length));
|
||||
data.get(0).animationData.updateClient();
|
||||
data.get(0).savePlayerDataOnFile();
|
||||
data.get(0).save();
|
||||
}
|
||||
|
||||
@SubCommand(desc = "enable animation")
|
||||
+52
-20
@@ -1,4 +1,4 @@
|
||||
package kamkeel;
|
||||
package kamkeel.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -39,9 +39,14 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
int tab = 0;
|
||||
try{
|
||||
tab = Integer.parseInt(args[1]);
|
||||
if(tab < 0 || tab > 15){
|
||||
sendError(sender, "Tab must be within 1-15");
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
|
||||
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||
return;
|
||||
}
|
||||
|
||||
int x = sender.getPlayerCoordinates().posX;
|
||||
@@ -58,6 +63,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
if(!npc.writeToNBTOptional(compound))
|
||||
return;
|
||||
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)");
|
||||
int tab = 0;
|
||||
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){
|
||||
|
||||
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||
return;
|
||||
}
|
||||
|
||||
for (String name : ServerCloneController.Instance.getClones(tab)) {
|
||||
sendMessage(sender, name);
|
||||
}
|
||||
@@ -91,11 +103,17 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
String nametodel = args[0];
|
||||
int tab = 0;
|
||||
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){
|
||||
|
||||
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||
return;
|
||||
}
|
||||
|
||||
boolean deleted = false;
|
||||
for(String name : ServerCloneController.Instance.getClones(tab)){
|
||||
if(nametodel.equalsIgnoreCase(name)){
|
||||
@@ -105,7 +123,9 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
}
|
||||
}
|
||||
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;
|
||||
try{
|
||||
tab = Integer.parseInt(args[1]);
|
||||
if(tab < 0 || tab > 15){
|
||||
sendError(sender, String.format("Tab must be within 1-15"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
|
||||
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||
return;
|
||||
}
|
||||
|
||||
String newname=null;
|
||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
|
||||
if(compound == null){
|
||||
sendMessage(sender, "Unknown npc");
|
||||
sendError(sender, "Unknown npc");
|
||||
return;
|
||||
}
|
||||
World world = sender.getEntityWorld();
|
||||
@@ -142,14 +168,15 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
location = par[1];
|
||||
world = Utils.getWorld(par[0]);
|
||||
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(",")){
|
||||
par = location.split(",");
|
||||
if (par.length != 3){
|
||||
sendMessage(sender, "Location need be x,y,z");
|
||||
sendError(sender, "Location need be x,y,z");
|
||||
return;
|
||||
}
|
||||
try{
|
||||
@@ -157,7 +184,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
posY = CommandBase.func_110665_a(sender, posY, par[1].trim(), 0, 0);
|
||||
posZ = CommandBase.func_110666_a(sender, posZ, par[2]);
|
||||
} catch(NumberFormatException ex){
|
||||
sendMessage(sender, "Location should be in numbers");
|
||||
sendError(sender, "Location should be in numbers");
|
||||
return;
|
||||
}
|
||||
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
|
||||
sendMessage(sender, "Location needed");
|
||||
sendError(sender, "Location needed");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -194,9 +221,14 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
int tab = 0;
|
||||
try{
|
||||
tab = Integer.parseInt(args[1]);
|
||||
if(tab < 0 || tab > 15){
|
||||
sendError(sender, String.format("Tab must be within 1-15"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
|
||||
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||
return;
|
||||
}
|
||||
|
||||
int width, height;
|
||||
@@ -205,7 +237,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
height = Integer.parseInt(args[3]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
sendMessage(sender, "length or width was not a number");
|
||||
sendError(sender, "length or width was not a number");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -213,7 +245,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
String newname=null;
|
||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
|
||||
if(compound == null){
|
||||
sendMessage(sender, "Unknown npc");
|
||||
sendError(sender, "Unknown npc");
|
||||
return;
|
||||
}
|
||||
World world = sender.getEntityWorld();
|
||||
@@ -229,14 +261,14 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
location = par[1];
|
||||
world = Utils.getWorld(par[0]);
|
||||
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(",")){
|
||||
par = location.split(",");
|
||||
if (par.length != 3){
|
||||
sendMessage(sender, "Location need be x,y,z");
|
||||
sendError(sender, "Location need be x,y,z");
|
||||
return;
|
||||
}
|
||||
try{
|
||||
@@ -244,7 +276,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
posY = CommandBase.func_110665_a(sender, posY, par[1].trim(), 0, 0);
|
||||
posZ = CommandBase.func_110666_a(sender, posZ, par[2]);
|
||||
} catch(NumberFormatException ex){
|
||||
sendMessage(sender, "Location should be in numbers");
|
||||
sendError(sender, "Location should be in numbers");
|
||||
return;
|
||||
}
|
||||
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
|
||||
sendMessage(sender, "Location needed");
|
||||
sendError(sender, "Location needed");
|
||||
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.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kamkeel.developer.Developer;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
|
||||
public class CommandKamkeel extends CommandBase{
|
||||
@@ -58,7 +62,7 @@ public class CommandKamkeel extends CommandBase{
|
||||
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
if(command.subcommands.isEmpty() || !command.runSubCommands()){
|
||||
if(!sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getCommandPermission(command.getCommandName())))
|
||||
if(!canSendCommand(sender, command))
|
||||
throw new CommandException("You are not allowed to use this command: " + command);
|
||||
command.canRun(sender, command.getUsage(), args);
|
||||
command.processCommand(sender, args);
|
||||
@@ -75,13 +79,28 @@ public class CommandKamkeel extends CommandBase{
|
||||
|
||||
@Override
|
||||
public List addTabCompletionOptions(ICommandSender sender, String[] args){
|
||||
if(args.length == 1)
|
||||
return new ArrayList<String>(map.keySet());
|
||||
if(args.length == 1)
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, map.keySet().toArray(new String[map.size()]));
|
||||
CommandKamkeelBase command = getCommand(args);
|
||||
if(command == null)
|
||||
return null;
|
||||
if(args.length == 2 && command.runSubCommands())
|
||||
return new ArrayList<String>(command.subcommands.keySet());
|
||||
if(args.length == 2 && command.runSubCommands())
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -99,5 +118,25 @@ public class CommandKamkeel extends CommandBase{
|
||||
public static String getCommandPermission(String command){
|
||||
return "cnpc.kamkeel." + command.toLowerCase();
|
||||
}
|
||||
|
||||
public static String getUniversalPermission(){
|
||||
return "cnpc.kamkeel.*";
|
||||
}
|
||||
|
||||
public static boolean canSendCommand(ICommandSender sender, CommandKamkeelBase command){
|
||||
if(sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getUniversalPermission())){
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getCommandPermission(command.getCommandName()))){
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender instanceof EntityPlayer){
|
||||
return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getCommandPermission(command.getCommandName()));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+33
-2
@@ -1,4 +1,4 @@
|
||||
package kamkeel;
|
||||
package kamkeel.command;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -10,10 +10,13 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kamkeel.developer.Developer;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
|
||||
public abstract class CommandKamkeelBase extends CommandBase{
|
||||
public Map<String, Method> subcommands = new HashMap<String, Method>();
|
||||
@@ -57,6 +60,14 @@ public abstract class CommandKamkeelBase extends CommandBase{
|
||||
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)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface SubCommand {
|
||||
@@ -79,7 +90,7 @@ public abstract class CommandKamkeelBase extends CommandBase{
|
||||
throw new CommandException("Unknown subcommand " + command);
|
||||
|
||||
SubCommand sc = m.getAnnotation(SubCommand.class);
|
||||
if(!sender.canCommandSenderUseCommand(sc.permission(), getSubCommandPermission(command)))
|
||||
if(!canSendCommand(sender, sc, command))
|
||||
throw new CommandException("You are not allowed to use this command: " + command);
|
||||
|
||||
canRun(sender, sc.usage(), args);
|
||||
@@ -115,4 +126,24 @@ public abstract class CommandKamkeelBase extends CommandBase{
|
||||
public String getSubCommandPermission(String subCommand){
|
||||
return "cnpc.kamkeel." + getCommandName().toLowerCase() + "." + subCommand.toLowerCase();
|
||||
}
|
||||
|
||||
public String getSubUniversalPermission(){
|
||||
return "cnpc.kamkeel." + getCommandName().toLowerCase() + "*";
|
||||
}
|
||||
|
||||
public boolean canSendCommand(ICommandSender sender, SubCommand command, String subCommand){
|
||||
if(sender.canCommandSenderUseCommand(command.permission(), getSubUniversalPermission())){
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender.canCommandSenderUseCommand(command.permission(), getSubCommandPermission(subCommand))){
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender instanceof EntityPlayer){
|
||||
return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getSubCommandPermission(subCommand));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+16
-15
@@ -1,4 +1,4 @@
|
||||
package kamkeel;
|
||||
package kamkeel.command;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockIce;
|
||||
@@ -37,7 +37,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
||||
)
|
||||
public void leavesdecay(ICommandSender sender, String[] args){
|
||||
if(args.length == 0){
|
||||
sendMessage(sender, "LeavesDecay: " + ConfigMain.LeavesDecayEnabled);
|
||||
sendResult(sender, "LeavesDecay: \u00A7c" + ConfigMain.LeavesDecayEnabled);
|
||||
}
|
||||
else{
|
||||
ConfigMain.LeavesDecayEnabled = Boolean.parseBoolean(args[0]);
|
||||
@@ -52,7 +52,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
||||
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){
|
||||
if(args.length == 0){
|
||||
sendMessage(sender, "VineGrowth: " + ConfigMain.VineGrowthEnabled);
|
||||
sendResult(sender, "VineGrowth: \u00A7c" + ConfigMain.VineGrowthEnabled);
|
||||
}
|
||||
else{
|
||||
ConfigMain.VineGrowthEnabled = Boolean.parseBoolean(args[0]);
|
||||
@@ -78,7 +78,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
||||
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){
|
||||
if(args.length == 0){
|
||||
sendMessage(sender, "IceMelts: " + ConfigMain.IceMeltsEnabled);
|
||||
sendResult(sender, "IceMelts: \u00A7c" + ConfigMain.IceMeltsEnabled);
|
||||
}
|
||||
else{
|
||||
ConfigMain.IceMeltsEnabled = Boolean.parseBoolean(args[0]);
|
||||
@@ -104,7 +104,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
||||
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){
|
||||
if(args.length == 0){
|
||||
sendMessage(sender, "GunsEnabled: " + ConfigMain.GunsEnabled);
|
||||
sendResult(sender, "GunsEnabled: \u00A7c" + ConfigMain.GunsEnabled);
|
||||
}
|
||||
else{
|
||||
ConfigMain.GunsEnabled = Boolean.parseBoolean(args[0]);
|
||||
@@ -123,7 +123,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
||||
if(ConfigMain.config.hasChanged()){
|
||||
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){
|
||||
if(args.length == 0){
|
||||
sendMessage(sender, "Frozen NPCs: " + CustomNpcs.FreezeNPCs);
|
||||
sendResult(sender, "Frozen NPCs: \u00A7c" + CustomNpcs.FreezeNPCs);
|
||||
}
|
||||
else{
|
||||
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{
|
||||
if(args.length == 0){
|
||||
sendMessage(sender, "ChunkLoaders: " + ChunkController.instance.size() + "/" + ConfigMain.ChunkLoaders);
|
||||
sendResult(sender, "ChunkLoaders: \u00A7c" + ChunkController.instance.size() + "\u00A77/\u00A7c" + ConfigMain.ChunkLoaders);
|
||||
}
|
||||
else{
|
||||
try{
|
||||
ConfigMain.ChunkLoaders = Integer.parseInt(args[0]);
|
||||
}
|
||||
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);
|
||||
if(ConfigMain.config.hasChanged()){
|
||||
@@ -166,9 +167,9 @@ public class ConfigCommand extends CommandKamkeelBase {
|
||||
int size = ChunkController.instance.size();
|
||||
if(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;
|
||||
|
||||
@@ -38,15 +38,18 @@ public class DialogCommand extends CommandKamkeelBase {
|
||||
try {
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
} 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);
|
||||
if (data.isEmpty()) {
|
||||
throw new CommandException("Unknown player: " + playername);
|
||||
sendError(sender, "Unknown player: " + playername);
|
||||
return;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.dialogData.dialogsRead.add(diagid);
|
||||
playerdata.savePlayerDataOnFile();
|
||||
playerdata.save();
|
||||
sendResult(sender, String.format("Forced Read for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,15 +63,18 @@ public class DialogCommand extends CommandKamkeelBase {
|
||||
try {
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
} 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);
|
||||
if (data.isEmpty()) {
|
||||
throw new CommandException("Unknown player: " + playername);
|
||||
sendError(sender, "Unknown player: " + playername);
|
||||
return;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.dialogData.dialogsRead.remove(diagid);
|
||||
playerdata.savePlayerDataOnFile();
|
||||
playerdata.save();
|
||||
sendResult(sender, String.format("Forced Unread for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername));
|
||||
}
|
||||
}
|
||||
@SubCommand(
|
||||
@@ -77,6 +83,7 @@ public class DialogCommand extends CommandKamkeelBase {
|
||||
)
|
||||
public void reload(ICommandSender sender, String args[]){
|
||||
new DialogController();
|
||||
sendResult(sender, "Dialogs Reloaded");
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
@@ -86,18 +93,21 @@ public class DialogCommand extends CommandKamkeelBase {
|
||||
public void show(ICommandSender sender, String args[]) throws CommandException{
|
||||
EntityPlayer player = CommandBase.getPlayer(sender, args[0]);
|
||||
if(player == null){
|
||||
throw new CommandException("Unknown player: " + args[0]);
|
||||
sendError(sender, "Unknown player: " + args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
int diagid;
|
||||
try {
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
} 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);
|
||||
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());
|
||||
@@ -108,5 +118,6 @@ public class DialogCommand extends CommandKamkeelBase {
|
||||
option.title = dialog.title;
|
||||
npc.dialogs.put(0, option);
|
||||
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.List;
|
||||
@@ -45,7 +45,8 @@ public class FactionCommand extends CommandKamkeelBase {
|
||||
|
||||
data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
throw new CommandException("Unknown player: " + playername);
|
||||
sendError(sender, "Unknown player: " + playername);
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
@@ -56,13 +57,14 @@ public class FactionCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.savePlayerDataOnFile();
|
||||
playerdata.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,13 +77,15 @@ public class FactionCommand extends CommandKamkeelBase {
|
||||
try {
|
||||
points = Integer.parseInt(args[0]);
|
||||
} 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;
|
||||
|
||||
for(PlayerData playerdata : data){
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
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 {
|
||||
points = Integer.parseInt(args[0]);
|
||||
} 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;
|
||||
for(PlayerData playerdata : data){
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
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) {
|
||||
for(PlayerData playerdata : data){
|
||||
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 {
|
||||
points = Integer.parseInt(args[0]);
|
||||
} 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){
|
||||
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){
|
||||
for(PlayerData playerdata : data){
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -1,4 +1,4 @@
|
||||
package kamkeel;
|
||||
package kamkeel.command;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map.Entry;
|
||||
@@ -36,9 +36,11 @@ public class HelpCommand extends CommandKamkeelBase{
|
||||
}
|
||||
|
||||
CommandKamkeelBase command = parent.getCommand(args);
|
||||
if(command == null)
|
||||
throw new CommandException("Unknown command " + args[0]);
|
||||
|
||||
if(command == null){
|
||||
sendError(sender, "Unknown command " + args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(command.subcommands.isEmpty()){
|
||||
sender.addChatMessage(new ChatComponentTranslation(command.getCommandUsage(sender)));
|
||||
return;
|
||||
+114
-103
@@ -1,4 +1,4 @@
|
||||
package kamkeel;
|
||||
package kamkeel.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -23,8 +23,8 @@ import noppes.npcs.roles.RoleFollower;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
public class NpcCommand extends CommandKamkeelBase {
|
||||
|
||||
public EntityNPCInterface selectedNpc;
|
||||
|
||||
public EntityNPCInterface selectedNpc;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -49,39 +49,40 @@ public class NpcCommand extends CommandKamkeelBase {
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
String npcname = args[0].replace("%", " ");
|
||||
String command = args[1];
|
||||
String npcname = args[0].replace("%", " ");
|
||||
String command = args[1];
|
||||
args = Arrays.copyOfRange(args, 2, args.length);
|
||||
if(command.equalsIgnoreCase("create")){
|
||||
args = ArrayUtils.add(args, 0, npcname);
|
||||
processSubCommand(sender, command, args);
|
||||
return;
|
||||
}
|
||||
processSubCommand(sender, command, args);
|
||||
return;
|
||||
}
|
||||
|
||||
int x = sender.getPlayerCoordinates().posX;
|
||||
int y = sender.getPlayerCoordinates().posY;
|
||||
int z = sender.getPlayerCoordinates().posZ;
|
||||
List<EntityNPCInterface> list = getEntities(EntityNPCInterface.class, sender.getEntityWorld(), x, y, z, 80);
|
||||
for (EntityNPCInterface npc : list) {
|
||||
String name = npc.display.getName().replace(" ", "_");
|
||||
if (name.equalsIgnoreCase(npcname)){
|
||||
if(selectedNpc == null || selectedNpc.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
|
||||
selectedNpc = npc;
|
||||
}
|
||||
}
|
||||
if(selectedNpc == null)
|
||||
throw new CommandException("Npc " + npcname + " was not found");
|
||||
|
||||
processSubCommand(sender, command, args);
|
||||
selectedNpc = null;
|
||||
|
||||
for (EntityNPCInterface npc : list) {
|
||||
String name = npc.display.getName().replace(" ", "_");
|
||||
if (name.equalsIgnoreCase(npcname)){
|
||||
if(selectedNpc == null || selectedNpc.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
|
||||
selectedNpc = npc;
|
||||
}
|
||||
}
|
||||
if(selectedNpc == null){
|
||||
sendError(sender, "Npc " + npcname + " was not found");
|
||||
return;
|
||||
}
|
||||
|
||||
processSubCommand(sender, command, args);
|
||||
selectedNpc = null;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Set Home (respawn place)",
|
||||
usage = "[x] [y] [z]"
|
||||
)
|
||||
public void home(ICommandSender sender, String[] args) {
|
||||
|
||||
@SubCommand(
|
||||
desc = "Set Home (respawn place)",
|
||||
usage = "[x] [y] [z]"
|
||||
)
|
||||
public void home(ICommandSender sender, String[] args) {
|
||||
double posX = sender.getPlayerCoordinates().posX;
|
||||
double posY = sender.getPlayerCoordinates().posY;
|
||||
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)};
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Set NPC visibility",
|
||||
usage = "[true/false/semi]"
|
||||
)
|
||||
public void visible(ICommandSender sender, String[] args){
|
||||
sendResult(sender, String.format("Set NPC \u00A7e%s\u00A77 Home to \u00A7b[%.1f] [%.1f] [%.1f]\u00A77", selectedNpc.display.name, posX, posY, posZ));
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Set NPC visibility",
|
||||
usage = "[true/false/semi]"
|
||||
)
|
||||
public void visible(ICommandSender sender, String[] args){
|
||||
if(args.length < 1)
|
||||
return;
|
||||
boolean bo = args[0].equalsIgnoreCase("true");
|
||||
@@ -113,74 +115,84 @@ public class NpcCommand extends CommandKamkeelBase {
|
||||
else
|
||||
selectedNpc.display.visible = 1;
|
||||
|
||||
String[] list = new String[]{"True", "False", "Semi"};
|
||||
|
||||
if(current != selectedNpc.display.visible)
|
||||
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")
|
||||
public void delete(ICommandSender sender, String[] args){
|
||||
selectedNpc.delete();
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Sets the owner of an follower/companion",
|
||||
usage = "[player]"
|
||||
)
|
||||
public void owner(ICommandSender sender, String[] args){
|
||||
if(args.length < 1){
|
||||
EntityPlayer player = null;
|
||||
if(selectedNpc.roleInterface instanceof RoleFollower)
|
||||
player = ((RoleFollower)selectedNpc.roleInterface).owner;
|
||||
|
||||
if(selectedNpc.roleInterface instanceof RoleCompanion)
|
||||
player = ((RoleCompanion)selectedNpc.roleInterface).owner;
|
||||
|
||||
if(player == null)
|
||||
sendMessage(sender, "No owner");
|
||||
else
|
||||
sendMessage(sender, "Owner is: " + player.getDisplayName());
|
||||
}
|
||||
else{
|
||||
EntityPlayerMP player = null;
|
||||
|
||||
@SubCommand(desc = "Delete an NPC")
|
||||
public void delete(ICommandSender sender, String[] args){
|
||||
selectedNpc.delete();
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Sets the owner of an follower/companion",
|
||||
usage = "[player]"
|
||||
)
|
||||
public void owner(ICommandSender sender, String[] args){
|
||||
if(args.length < 1){
|
||||
EntityPlayer player = null;
|
||||
if(selectedNpc.roleInterface instanceof RoleFollower)
|
||||
player = ((RoleFollower)selectedNpc.roleInterface).owner;
|
||||
|
||||
if(selectedNpc.roleInterface instanceof RoleCompanion)
|
||||
player = ((RoleCompanion)selectedNpc.roleInterface).owner;
|
||||
|
||||
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()));
|
||||
}
|
||||
else{
|
||||
EntityPlayerMP player = null;
|
||||
try {
|
||||
player = CommandBase.getPlayer(sender, args[0]);
|
||||
} catch (PlayerNotFoundException e) {
|
||||
|
||||
}
|
||||
if(selectedNpc.roleInterface instanceof RoleFollower)
|
||||
((RoleFollower)selectedNpc.roleInterface).setOwner(player);
|
||||
|
||||
if(selectedNpc.roleInterface instanceof RoleCompanion)
|
||||
((RoleCompanion)selectedNpc.roleInterface).setOwner(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc = "Set NPC name",
|
||||
usage = "[name]"
|
||||
)
|
||||
public void name(ICommandSender sender, String[] args){
|
||||
if(args.length < 1)
|
||||
return;
|
||||
|
||||
String name = args[0];
|
||||
for(int i = 1; i < args.length; i++){
|
||||
name += " " + args[i];
|
||||
}
|
||||
|
||||
if(!selectedNpc.display.getName().equals(name)){
|
||||
selectedNpc.display.setName(name);
|
||||
}
|
||||
if(selectedNpc.roleInterface instanceof RoleFollower)
|
||||
((RoleFollower)selectedNpc.roleInterface).setOwner(player);
|
||||
|
||||
if(selectedNpc.roleInterface instanceof RoleCompanion)
|
||||
((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(
|
||||
desc = "Set NPC name",
|
||||
usage = "[name]"
|
||||
)
|
||||
public void name(ICommandSender sender, String[] args){
|
||||
if(args.length < 1)
|
||||
return;
|
||||
|
||||
String name = args[0];
|
||||
for(int i = 1; i < args.length; i++){
|
||||
name += " " + args[i];
|
||||
}
|
||||
|
||||
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Name set to \u00A7b%s\u00A77", selectedNpc.display.name, name));
|
||||
|
||||
if(!selectedNpc.display.getName().equals(name)){
|
||||
selectedNpc.display.setName(name);
|
||||
selectedNpc.updateClient = true;
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Creates an NPC",
|
||||
usage = "[name]"
|
||||
)
|
||||
public void create(ICommandSender sender, String[] args) {
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Creates an NPC",
|
||||
usage = "[name]"
|
||||
)
|
||||
public void create(ICommandSender sender, String[] args) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) sender;
|
||||
World pw = player.getEntityWorld();
|
||||
EntityCustomNpc npc = new EntityCustomNpc(pw);
|
||||
@@ -191,10 +203,9 @@ public class NpcCommand extends CommandKamkeelBase {
|
||||
pw.spawnEntityInWorld(npc);
|
||||
npc.setHealth(npc.getMaxHealth());
|
||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, npc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
}
|
||||
|
||||
@Override
|
||||
public List addTabCompletionOptions(ICommandSender par1, String[] args) {
|
||||
if(args.length == 2){
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"create", "home", "visible", "delete", "owner", "name"});
|
||||
@@ -204,14 +215,14 @@ public class NpcCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel(){
|
||||
return 4;
|
||||
}
|
||||
@Override
|
||||
public int getRequiredPermissionLevel(){
|
||||
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);
|
||||
List<T> list = world.getEntitiesWithinAABB(cls, bb);
|
||||
return list;
|
||||
+55
-23
@@ -1,4 +1,4 @@
|
||||
package kamkeel;
|
||||
package kamkeel.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.constants.EnumQuestRepeat;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
@@ -36,26 +36,32 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
try {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
} 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);
|
||||
|
||||
if (data.isEmpty()) {
|
||||
throw new CommandException("Unknown player: " + playername);
|
||||
sendError(sender, "Unknown player: " + playername);
|
||||
return;
|
||||
}
|
||||
|
||||
Quest quest = QuestController.instance.quests.get(questid);
|
||||
if (quest == null){
|
||||
throw new CommandException("Unknown QuestID: " + questid);
|
||||
sendError(sender, "Unknown QuestID: " + questid);
|
||||
return;
|
||||
}
|
||||
|
||||
for(PlayerData playerdata : data){
|
||||
QuestData questdata = new QuestData(quest);
|
||||
playerdata.questData.activeQuests.put(questid, questdata);
|
||||
playerdata.savePlayerDataOnFile();
|
||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
|
||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
|
||||
playerdata.save();
|
||||
if(playerdata.player != null && questdata.sendAlerts){
|
||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
|
||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
|
||||
}
|
||||
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]);
|
||||
}
|
||||
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);
|
||||
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);
|
||||
if (quest == null){
|
||||
throw new CommandException("Unknown QuestID: " + questid);
|
||||
sendError(sender, "Unknown QuestID: " + questid);
|
||||
return;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis());
|
||||
playerdata.savePlayerDataOnFile();
|
||||
for(PlayerData playerdata : data){
|
||||
if(playerdata.questData.activeQuests.containsKey(questid)){
|
||||
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 {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
} 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);
|
||||
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);
|
||||
if (quest == null){
|
||||
throw new CommandException("Unknown QuestID: " + questid);
|
||||
sendError(sender, "Unknown QuestID: " + questid);
|
||||
return;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.savePlayerDataOnFile();
|
||||
playerdata.save();
|
||||
sendResult(sender, String.format("Stopped Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,23 +150,27 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
try {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
} 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);
|
||||
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);
|
||||
if (quest == null){
|
||||
throw new CommandException(String.format("Unknown QuestID"));
|
||||
sendError(sender, String.format("Unknown QuestID"));
|
||||
return;
|
||||
}
|
||||
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.questData.finishedQuests.remove(questid);
|
||||
playerdata.savePlayerDataOnFile();
|
||||
playerdata.save();
|
||||
sendResult(sender, String.format("Removed Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +179,9 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
permission = 4
|
||||
)
|
||||
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 noppes.npcs.controllers.ScriptController;
|
||||
@@ -11,19 +11,19 @@ public class ScriptCommand extends CommandKamkeelBase {
|
||||
ScriptController.Instance.loadCategories();
|
||||
|
||||
if(ScriptController.Instance.loadPlayerScripts())
|
||||
sendMessage(sender, "Reload player scripts successfully");
|
||||
sendResult(sender, "Reload player scripts successfully");
|
||||
else
|
||||
sendMessage(sender, "Failed reloading player scripts");
|
||||
sendError(sender, "Failed reloading player scripts");
|
||||
|
||||
if(ScriptController.Instance.loadForgeScripts())
|
||||
sendMessage(sender, "Reload forge scripts successfully");
|
||||
sendResult(sender, "Reload forge scripts successfully");
|
||||
else
|
||||
sendMessage(sender, "Failed reloading forge scripts");
|
||||
sendError(sender, "Failed reloading forge scripts");
|
||||
|
||||
if(ScriptController.Instance.loadStoredData())
|
||||
sendMessage(sender, "Reload stored data successfully");
|
||||
sendResult(sender, "Reload stored data successfully");
|
||||
else
|
||||
sendMessage(sender, "Failed reloading stored data");
|
||||
sendError(sender, "Failed reloading stored data");
|
||||
return true;
|
||||
|
||||
}
|
||||
+2
-3
@@ -1,4 +1,4 @@
|
||||
package kamkeel;
|
||||
package kamkeel.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -23,7 +23,6 @@ import net.minecraft.entity.passive.EntityTameable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class SlayCommand extends CommandKamkeelBase {
|
||||
@@ -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) {
|
||||
@@ -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)
|
||||
return new ContainerMerchantAdd(player, ServerEventsHandler.Merchant, player.worldObj);
|
||||
|
||||
if(gui == EnumGuiType.Crate)
|
||||
return new ContainerCrate(player.inventory, (TileNpcContainer)player.worldObj.getTileEntity(x, y, z));
|
||||
if(gui == EnumGuiType.Crate){
|
||||
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)
|
||||
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.registry.EntityRegistry;
|
||||
import foxz.command.CommandNoppes;
|
||||
import kamkeel.CommandKamkeel;
|
||||
import kamkeel.command.CommandKamkeel;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockIce;
|
||||
import net.minecraft.block.BlockLeavesBase;
|
||||
@@ -35,7 +35,7 @@ import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.8")
|
||||
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.8.2")
|
||||
public class CustomNpcs {
|
||||
|
||||
@SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy")
|
||||
@@ -52,8 +52,6 @@ public class CustomNpcs {
|
||||
public static FMLEventChannel Channel;
|
||||
public static FMLEventChannel ChannelPlayer;
|
||||
|
||||
public static ArrayList<UUID> ScriptDevs = new ArrayList<>();
|
||||
|
||||
public static final MarkovGenerator[] MARKOV_GENERATOR = new MarkovGenerator[10];
|
||||
|
||||
public static boolean InitIgnore = false;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import kamkeel.developer.Developer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -74,12 +75,25 @@ public class CustomNpcsPermissions{
|
||||
}
|
||||
|
||||
public static boolean hasPermission(EntityPlayer player, Permission permission){
|
||||
if(Developer.instance.hasUniversal(player.getUniqueID())){
|
||||
return true;
|
||||
}
|
||||
if(Instance.bukkit != null){
|
||||
return Instance.bukkitPermission(player.getCommandSenderName(), permission.name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean hasCustomPermission(EntityPlayer player, String permission){
|
||||
if(Developer.instance.hasUniversal(player.getUniqueID())){
|
||||
return true;
|
||||
}
|
||||
if(Instance.bukkit != null){
|
||||
return Instance.bukkitPermission(player.getCommandSenderName(), permission);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean bukkitPermission(String username, String permission) {
|
||||
try {
|
||||
Object player = getPlayer.invoke(null, username);
|
||||
|
||||
@@ -549,7 +549,7 @@ public class EventHooks {
|
||||
handler.callScript(EnumScriptType.CNPC_NATURAL_SPAWN, event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
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 java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class NoppesUtilPlayer {
|
||||
|
||||
@@ -300,22 +297,65 @@ public class NoppesUtilPlayer {
|
||||
else
|
||||
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
|
||||
}
|
||||
public static void sendTrackedQuestData(EntityPlayerMP player, Quest trackedQuest) {
|
||||
Quest quest = (Quest) PlayerDataController.instance.getPlayerData(player).questData.trackedQuest;
|
||||
if (quest == null || trackedQuest == null || quest.id != trackedQuest.id) {
|
||||
return;
|
||||
|
||||
public static void updateQuestLogData(ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
|
||||
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
HashMap<String,String> questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10));
|
||||
for (Map.Entry<String,String> entry : questAlerts.entrySet()) {
|
||||
Quest quest = getQuestFromStringKey(entry.getKey());
|
||||
if (quest != null) {
|
||||
playerData.questData.activeQuests.get(quest.id).sendAlerts = Boolean.parseBoolean(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("Quest",trackedQuest.writeToNBT(new NBTTagCompound()));
|
||||
compound.setString("CategoryName", trackedQuest.getCategory().getName());
|
||||
compound.setString("TurnInNPC", trackedQuest.getNpcName());
|
||||
NBTTagList nbtTagList = new NBTTagList();
|
||||
for (IQuestObjective objective : trackedQuest.questInterface.getObjectives(player)) {
|
||||
nbtTagList.appendTag(new NBTTagString(objective.getText()));
|
||||
String trackedQuestString = Server.readString(buffer);
|
||||
Quest trackedQuest = getQuestFromStringKey(trackedQuestString);
|
||||
if (trackedQuest != null) {
|
||||
playerData.questData.trackQuest(trackedQuest);
|
||||
} else {
|
||||
playerData.questData.untrackQuest();
|
||||
}
|
||||
}
|
||||
|
||||
private static Quest getQuestFromStringKey(String string) {
|
||||
if (string != null && string.contains(":")) {
|
||||
String[] splitString = string.split(":");
|
||||
if(splitString.length < 2){
|
||||
return null;
|
||||
}
|
||||
String categoryName = splitString[0];
|
||||
String questName = splitString[1];
|
||||
|
||||
for (QuestCategory category : QuestController.instance.categories.values()) {
|
||||
if (category.title.equals(categoryName)) {
|
||||
for (Quest quest : category.quests.values()) {
|
||||
if (quest.title.equals(questName)) {
|
||||
return quest;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void sendTrackedQuestData(EntityPlayerMP player) {
|
||||
Quest trackedQuest = (Quest) PlayerDataController.instance.getPlayerData(player).questData.getTrackedQuest();
|
||||
if(trackedQuest != null){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("Quest",trackedQuest.writeToNBT(new NBTTagCompound()));
|
||||
compound.setString("CategoryName", trackedQuest.getCategory().getName());
|
||||
compound.setString("TurnInNPC", trackedQuest.getNpcName());
|
||||
NBTTagList nbtTagList = new NBTTagList();
|
||||
for (IQuestObjective objective : trackedQuest.questInterface.getObjectives(player)) {
|
||||
nbtTagList.appendTag(new NBTTagString(objective.getText()));
|
||||
}
|
||||
compound.setTag("ObjectiveList",nbtTagList);
|
||||
|
||||
Server.sendData(player, EnumPacketClient.OVERLAY_QUEST_TRACKING, compound);
|
||||
}
|
||||
compound.setTag("ObjectiveList",nbtTagList);
|
||||
Server.sendData(player, EnumPacketClient.OVERLAY_QUEST_TRACKING, compound);
|
||||
}
|
||||
|
||||
public static void sendQuestLogData(EntityPlayerMP player) {
|
||||
@@ -398,7 +438,7 @@ public class NoppesUtilPlayer {
|
||||
QuestData nextQuest = new QuestData(data.quest.getNextQuest());
|
||||
nextQuest.sendAlerts = data.quest.id != data.quest.getNextQuest().id || data.sendAlerts;
|
||||
PlayerQuestController.addActiveQuest(nextQuest, player);
|
||||
NoppesUtilPlayer.sendTrackedQuestData(player,nextQuest.quest);
|
||||
questData.trackQuest(nextQuest.quest);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -39,6 +39,7 @@ import noppes.npcs.roles.RoleTransporter;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptSound;
|
||||
import noppes.npcs.scripted.event.DialogEvent;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@@ -55,7 +56,7 @@ public class NoppesUtilServer {
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
data.editingNpc = npc;
|
||||
if(npc != null)
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.EDIT_NPC, npc.getEntityId());
|
||||
Server.sendDataChecked((EntityPlayerMP)player, EnumPacketClient.EDIT_NPC, npc.getEntityId());
|
||||
}
|
||||
public static EntityNPCInterface getEditingNpc(EntityPlayer player){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
@@ -172,9 +173,9 @@ public class NoppesUtilServer {
|
||||
}
|
||||
}
|
||||
|
||||
if(npc instanceof EntityDialogNpc){
|
||||
if(npc instanceof EntityDialogNpc || dia.id < 0){
|
||||
dialog.hideNPC = true;
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG_DUMMY, npc.getCommandSenderName(), dialog.writeToNBT(new NBTTagCompound()));
|
||||
Server.sendDataDelayed((EntityPlayerMP)player, EnumPacketClient.DIALOG_DUMMY, 100, npc.getCommandSenderName(), dialog.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG, npc.getEntityId(), dialog.writeToNBT(new NBTTagCompound()));
|
||||
@@ -241,19 +242,50 @@ public class NoppesUtilServer {
|
||||
EnumGuiType gui, EntityNPCInterface npc) {
|
||||
sendOpenGui(player, gui, npc, 0, 0, 0);
|
||||
}
|
||||
public static void sendOpenGui(EntityPlayer player,
|
||||
EnumGuiType gui, EntityNPCInterface npc, int i, int j, int k) {
|
||||
|
||||
public static void sendOpenGuiNoDelay(EntityPlayer player,
|
||||
EnumGuiType gui, EntityNPCInterface npc) {
|
||||
sendOpenGuiNoDelay(player, gui, npc, 0, 0, 0);
|
||||
}
|
||||
|
||||
public static void sendOpenGui(final EntityPlayer player,
|
||||
final EnumGuiType gui, final EntityNPCInterface npc, final int i, final int j, final int k) {
|
||||
if(!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
setEditingNpc(player, npc);
|
||||
sendExtraData(player, npc,gui, i, j, k);
|
||||
|
||||
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){
|
||||
player.openGui(CustomNpcs.instance, gui.ordinal(), player.worldObj, i, j, k);
|
||||
return;
|
||||
}
|
||||
else{
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.GUI, gui.ordinal(), i, j, k);
|
||||
Server.sendDataChecked((EntityPlayerMP)player, EnumPacketClient.GUI, gui.ordinal(), i, j, k);
|
||||
}
|
||||
ArrayList<String> list = getScrollData(player, gui, npc);
|
||||
if(list == null || list.isEmpty())
|
||||
@@ -470,11 +502,12 @@ public class NoppesUtilServer {
|
||||
if(pl != null){
|
||||
playerdata.setNBT(new NBTTagCompound());
|
||||
sendPlayerData(type, player, name);
|
||||
playerdata.savePlayerDataOnFile();
|
||||
playerdata.save();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
PlayerDataController.instance.nameUUIDs.remove(name);
|
||||
PlayerDataController.instance.savePlayerDataMap();
|
||||
}
|
||||
}
|
||||
if(type == EnumPlayerData.Quest){
|
||||
@@ -482,30 +515,34 @@ public class NoppesUtilServer {
|
||||
int questId = buffer.readInt();
|
||||
data.activeQuests.remove(questId);
|
||||
data.finishedQuests.remove(questId);
|
||||
playerdata.savePlayerDataOnFile();
|
||||
playerdata.save();
|
||||
}
|
||||
if(type == EnumPlayerData.Dialog){
|
||||
PlayerDialogData data = playerdata.dialogData;
|
||||
data.dialogsRead.remove(buffer.readInt());
|
||||
playerdata.savePlayerDataOnFile();
|
||||
playerdata.save();
|
||||
}
|
||||
if(type == EnumPlayerData.Transport){
|
||||
PlayerTransportData data = playerdata.transportData;
|
||||
data.transports.remove(buffer.readInt());
|
||||
playerdata.savePlayerDataOnFile();
|
||||
playerdata.save();
|
||||
}
|
||||
if(type == EnumPlayerData.Bank){
|
||||
PlayerBankData data = playerdata.bankData;
|
||||
data.banks.remove(buffer.readInt());
|
||||
playerdata.savePlayerDataOnFile();
|
||||
playerdata.save();
|
||||
}
|
||||
if(type == EnumPlayerData.Factions){
|
||||
PlayerFactionData data = playerdata.factionData;
|
||||
data.factionData.remove(buffer.readInt());
|
||||
playerdata.savePlayerDataOnFile();
|
||||
playerdata.save();
|
||||
}
|
||||
sendPlayerData(type, player, name);
|
||||
}
|
||||
|
||||
public static void regenPlayerData(EntityPlayerMP player) throws IOException {
|
||||
PlayerDataController.instance.generatePlayerMap(player);
|
||||
}
|
||||
|
||||
public static void sendRecipeData(EntityPlayerMP player, int size) {
|
||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||
@@ -794,35 +831,21 @@ public class NoppesUtilServer {
|
||||
long minutes = seconds / 60;
|
||||
long hours = minutes / 60;
|
||||
long days = hours / 24;
|
||||
long months = days / 30;
|
||||
long years = months / 12;
|
||||
|
||||
months = months % 12;
|
||||
days = days % 30;
|
||||
hours = hours % 24;
|
||||
minutes = minutes % 60;
|
||||
seconds = seconds % 60;
|
||||
seconds %= 60;
|
||||
minutes %= 60;
|
||||
hours %= 24;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (years > 0) {
|
||||
sb.append(years + " year(s) ");
|
||||
}
|
||||
if (months > 0) {
|
||||
sb.append(months + " month(s) ");
|
||||
}
|
||||
if (days > 0) {
|
||||
sb.append(days + " day(s) ");
|
||||
sb.append(days).append(" day").append(days == 1 ? "" : "s").append(", ");
|
||||
}
|
||||
if (hours > 0) {
|
||||
sb.append(hours + " hour(s) ");
|
||||
sb.append(hours).append(" hour").append(hours == 1 ? "" : "s").append(", ");
|
||||
}
|
||||
if (minutes > 0) {
|
||||
sb.append(minutes + " minute(s) ");
|
||||
sb.append(minutes).append(" minute").append(minutes == 1 ? "" : "s").append(", ");
|
||||
}
|
||||
if (seconds > 0) {
|
||||
sb.append(seconds + " second(s)");
|
||||
}
|
||||
|
||||
sb.append(seconds).append(" second").append(seconds == 1 ? "" : "s");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class PacketHandlerServer{
|
||||
EventHooks.onCustomGuiClose((IPlayer) NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer)));
|
||||
return;
|
||||
} else if (type == EnumPacketServer.QuestLogToServer) {
|
||||
updateQuestLogData(buffer, player);
|
||||
NoppesUtilPlayer.updateQuestLogData(buffer, player);
|
||||
return;
|
||||
} else if(type == EnumPacketServer.DimensionsGet){
|
||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||
@@ -157,51 +157,6 @@ public class PacketHandlerServer{
|
||||
}
|
||||
}
|
||||
|
||||
private Quest getQuestFromString(String string) {
|
||||
if (string != null && string.contains(":")) {
|
||||
String[] splitString = string.split(":");
|
||||
if(splitString.length < 2){
|
||||
return null;
|
||||
}
|
||||
String categoryName = splitString[0];
|
||||
String questName = splitString[1];
|
||||
|
||||
for (QuestCategory category : QuestController.instance.categories.values()) {
|
||||
if (category.title.equals(categoryName)) {
|
||||
for (Quest quest : category.quests.values()) {
|
||||
if (quest.title.equals(questName)) {
|
||||
return quest;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void updateQuestLogData(ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
|
||||
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
HashMap<String,String> questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10));
|
||||
for (Map.Entry<String,String> entry : questAlerts.entrySet()) {
|
||||
Quest quest = this.getQuestFromString(entry.getKey());
|
||||
if (quest != null) {
|
||||
playerData.questData.activeQuests.get(quest.id).sendAlerts = Boolean.parseBoolean(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
String trackedQuestString = Server.readString(buffer);
|
||||
Quest trackedQuest = this.getQuestFromString(trackedQuestString);
|
||||
if (trackedQuest != null) {
|
||||
playerData.questData.trackedQuest = trackedQuest;
|
||||
NoppesUtilPlayer.sendTrackedQuestData(player, trackedQuest);
|
||||
}
|
||||
|
||||
playerData.questData.trackedQuest = null;
|
||||
Server.sendData(player, EnumPacketClient.OVERLAY_QUEST_TRACKING);
|
||||
}
|
||||
|
||||
private void isGuiOpenPacket(ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
NoppesUtilServer.isGUIOpen(buffer, player);
|
||||
}
|
||||
@@ -794,6 +749,9 @@ public class PacketHandlerServer{
|
||||
else if(type == EnumPacketServer.PlayerDataRemove){
|
||||
NoppesUtilServer.removePlayerData(buffer,player);
|
||||
}
|
||||
else if(type == EnumPacketServer.PlayerDataRegen){
|
||||
NoppesUtilServer.regenPlayerData(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuDisplayGet){
|
||||
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))
|
||||
finish.put(category + ":" + quest.title, quest.completerNpc);
|
||||
|
||||
if (playerData.questData.trackedQuest != null) {
|
||||
if (quest.id == playerData.questData.trackedQuest.getId()) {
|
||||
if (playerData.questData.getTrackedQuest() != null) {
|
||||
if (quest.id == playerData.questData.getTrackedQuest().getId()) {
|
||||
trackedQuestKey = category + ":" + quest.title;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,15 +26,19 @@ import net.minecraftforge.event.entity.player.*;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||
import noppes.npcs.controllers.data.PlayerQuestData;
|
||||
import noppes.npcs.controllers.data.Quest;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.item.ScriptCustomItem;
|
||||
|
||||
import static noppes.npcs.config.ConfigMain.TrackedQuestUpdateFrequency;
|
||||
|
||||
public class ScriptPlayerEventHandler {
|
||||
public ScriptPlayerEventHandler() {
|
||||
}
|
||||
@@ -67,14 +71,22 @@ public class ScriptPlayerEventHandler {
|
||||
playerData.timers.update();
|
||||
}
|
||||
|
||||
if (playerData.questData.trackedQuest != null && !playerData.questData.activeQuests.containsKey(playerData.questData.trackedQuest.getId())) {
|
||||
PlayerDataController.instance.getPlayerData(player).questData.trackedQuest = null;
|
||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.OVERLAY_QUEST_TRACKING);
|
||||
if (playerData.questData.getTrackedQuest() != null && !playerData.questData.activeQuests.containsKey(playerData.questData.getTrackedQuest().getId())) {
|
||||
PlayerDataController.instance.getPlayerData(player).questData.untrackQuest();
|
||||
}
|
||||
|
||||
if (player.ticksExisted%20 == 0 && !PlayerDataController.instance.getPlayerData(player).skinOverlays.overlayList.isEmpty()) {
|
||||
if (player.ticksExisted % 20 == 0 && !PlayerDataController.instance.getPlayerData(player).skinOverlays.overlayList.isEmpty()) {
|
||||
PlayerDataController.instance.getPlayerData(player).skinOverlays.updateClient();
|
||||
}
|
||||
|
||||
if (player.ticksExisted % (TrackedQuestUpdateFrequency * 20) == 0) {
|
||||
PlayerQuestData questData = playerData.questData;
|
||||
if(questData != null){
|
||||
if (questData.getTrackedQuest() != null && ((Quest) questData.getTrackedQuest()).type == EnumQuestType.Item) {
|
||||
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -464,9 +476,9 @@ public class ScriptPlayerEventHandler {
|
||||
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
|
||||
EventHooks.onPlayerLogin(handler, scriptPlayer);
|
||||
|
||||
Quest quest = (Quest) PlayerDataController.instance.getPlayerData(event.player).questData.trackedQuest;
|
||||
Quest quest = (Quest) PlayerDataController.instance.getPlayerData(event.player).questData.getTrackedQuest();
|
||||
if (quest != null) {
|
||||
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player, quest);
|
||||
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player);
|
||||
}
|
||||
|
||||
PlayerDataController.instance.getPlayerData(event.player).skinOverlays.updateClient();
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -20,28 +21,47 @@ import java.util.Map;
|
||||
|
||||
public class Server {
|
||||
|
||||
public static boolean sendData(EntityPlayerMP player, EnumPacketClient enu, Object... obs) {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
public static void sendData(final EntityPlayerMP player, final EnumPacketClient enu, final Object... obs) {
|
||||
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 {
|
||||
if(!fillBuffer(buffer, enu, obs))
|
||||
if(!fillBuffer(buffer, type, obs))
|
||||
return false;
|
||||
CustomNpcs.Channel.sendTo(new FMLProxyPacket(buffer, "CustomNPCs"), player);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LogWriter.error(type + " Errored", e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void sendAssociatedData(Entity entity, EnumPacketClient enu, Object... obs) {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
try {
|
||||
if(!fillBuffer(buffer, enu, obs))
|
||||
return;
|
||||
TargetPoint point = new TargetPoint(entity.dimension, entity.posX, entity.posY, entity.posZ, 60);
|
||||
CustomNpcs.Channel.sendToAllAround(new FMLProxyPacket(buffer,"CustomNPCs"), point);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
public static void sendAssociatedData(final Entity entity, final EnumPacketClient enu, final Object... obs) {
|
||||
CustomNPCsScheduler.runTack(() -> {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
try {
|
||||
if(!fillBuffer(buffer, enu, obs))
|
||||
return;
|
||||
TargetPoint point = new TargetPoint(entity.dimension, entity.posX, entity.posY, entity.posZ, 60);
|
||||
CustomNpcs.Channel.sendToAllAround(new FMLProxyPacket(buffer,"CustomNPCs"), point);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
public static void sendToAll(EnumPacketClient enu, Object... obs) {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
|
||||
@@ -92,7 +92,7 @@ public class ServerEventsHandler {
|
||||
return;
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(event.entityPlayer);
|
||||
ServerCloneController.Instance.cleanTags(compound);
|
||||
if(!Server.sendData((EntityPlayerMP)event.entityPlayer, EnumPacketClient.CLONE, compound))
|
||||
if(!Server.sendDataChecked((EntityPlayerMP)event.entityPlayer, EnumPacketClient.CLONE, compound))
|
||||
event.entityPlayer.addChatMessage(new ChatComponentText("Entity too big to clone"));
|
||||
data.cloned = compound;
|
||||
if (event.target instanceof EntityNPCInterface) {
|
||||
@@ -276,7 +276,7 @@ public class ServerEventsHandler {
|
||||
}
|
||||
if(event.entityLiving instanceof EntityPlayer){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer)event.entityLiving);
|
||||
data.savePlayerDataOnFile();
|
||||
data.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ public class ServerEventsHandler {
|
||||
@SubscribeEvent
|
||||
public void world(PlayerEvent.SaveToFile event){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer) event.entity);
|
||||
data.savePlayerDataOnFile();
|
||||
data.save();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -3,14 +3,17 @@ package noppes.npcs.client;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import noppes.npcs.AnimationData;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.client.gui.OverlayQuestTracking;
|
||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||
import noppes.npcs.client.renderer.customitem.ImageData;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.data.SkinOverlay;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
@@ -23,15 +26,17 @@ public class Client {
|
||||
public static HashMap<UUID, AnimationData> playerAnimations = new HashMap<>();
|
||||
private static HashMap<String, ImageData> imageDataCache = new HashMap<>();
|
||||
|
||||
public static void sendData(EnumPacketServer enu, Object... obs) {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
try {
|
||||
if(!Server.fillBuffer(buffer, enu, obs))
|
||||
return;
|
||||
CustomNpcs.Channel.sendToServer(new FMLProxyPacket(buffer, "CustomNPCs"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
public static void sendData(final EnumPacketServer enu, final Object... obs) {
|
||||
CustomNPCsScheduler.runTack(() -> {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
try {
|
||||
if(!Server.fillBuffer(buffer, enu, obs))
|
||||
return;
|
||||
CustomNpcs.Channel.sendToServer(new FMLProxyPacket(buffer, "CustomNPCs"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static ImageData getImageData(String directory) {
|
||||
|
||||
@@ -78,7 +78,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
||||
hooks.selected = activeTab;
|
||||
addScroll(hooks);
|
||||
|
||||
ScriptContainer container = script.scripts.get(activeTab);
|
||||
ScriptContainer container = script.getNPCScript(activeTab);
|
||||
|
||||
addTextField(new GuiNpcTextArea(2, this, guiLeft + 74, guiTop + 4, 239, 208, container == null?"":container.script));
|
||||
|
||||
@@ -185,11 +185,11 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
||||
getTextField(2).setText("");
|
||||
if(!showScript){
|
||||
if(activeConsole == 0){
|
||||
for(ScriptContainer container : script.scripts)
|
||||
for(ScriptContainer container : script.getNPCScripts())
|
||||
container.console.clear();
|
||||
}
|
||||
else{
|
||||
ScriptContainer container = script.scripts.get(activeConsole - 1);
|
||||
ScriptContainer container = script.getNPCScript(activeConsole - 1);
|
||||
if(container != null)
|
||||
container.console.clear();
|
||||
}
|
||||
@@ -209,13 +209,13 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
||||
NoppesUtil.openFolder(ScriptController.Instance.dir);
|
||||
}
|
||||
if (guibutton.id == 107) {
|
||||
ScriptContainer container = script.scripts.get(activeTab);
|
||||
ScriptContainer container = script.getNPCScript(activeTab);
|
||||
if(container == null)
|
||||
script.scripts.set(activeTab, container = new ScriptContainer(this.script));
|
||||
script.setNPCScript(activeTab, container = new ScriptContainer(this.script));
|
||||
setSubGui(new GuiScriptList(languages.get(script.scriptLanguage), container));
|
||||
}
|
||||
if (guibutton.id == 108) {
|
||||
ScriptContainer container = script.scripts.get(activeTab);
|
||||
ScriptContainer container = script.getNPCScript(activeTab);
|
||||
if(container != null){
|
||||
setScript();
|
||||
this.AWTWindow = new GuiJTextArea(container.script).setListener(this);
|
||||
@@ -225,9 +225,9 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
||||
|
||||
private void setScript(){
|
||||
if(showScript){
|
||||
ScriptContainer container = script.scripts.get(activeTab);
|
||||
ScriptContainer container = script.getNPCScript(activeTab);
|
||||
if(container == null)
|
||||
script.scripts.set(activeTab, container = new ScriptContainer(this.script));
|
||||
script.setNPCScript(activeTab, container = new ScriptContainer(this.script));
|
||||
String text = getTextField(2).getText();
|
||||
text = text.replace("\r\n", "\n");
|
||||
text = text.replace("\r", "\n");
|
||||
@@ -270,7 +270,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
||||
|
||||
@Override
|
||||
public void saveText(String text) {
|
||||
ScriptContainer container = script.scripts.get(activeTab);
|
||||
ScriptContainer container = script.getNPCScript(activeTab);
|
||||
if(container != null)
|
||||
container.script = text;
|
||||
initGui();
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
package noppes.npcs.client.gui.global;
|
||||
|
||||
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.NoppesUtil;
|
||||
import noppes.npcs.client.controllers.ClientCloneController;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.constants.EnumPlayerData;
|
||||
@@ -12,7 +17,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
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 String selectedPlayer = null;
|
||||
@@ -45,7 +50,9 @@ public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements IScrollD
|
||||
this.addButton(new GuiNpcButton(4, guiLeft + 200, guiTop + 98,98, 20, "Transport 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(7, guiLeft + 200, guiTop + 193,98, 20, "Regen PlayerMap"));
|
||||
|
||||
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 4, guiTop + 193, 190, 20, search));
|
||||
getTextField(0).enabled = selection == EnumPlayerData.Players;
|
||||
|
||||
@@ -126,6 +133,9 @@ public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements IScrollD
|
||||
Client.sendData(EnumPacketServer.PlayerDataGet, selection, selectedPlayer);
|
||||
selected = null;
|
||||
}
|
||||
if(id == 7){
|
||||
displayGuiScreen(new GuiYesNo(this, "Warning", "Do not operate on PlayerData as its regenerating", 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -155,5 +165,14 @@ public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements IScrollD
|
||||
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;
|
||||
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;
|
||||
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.TabRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,ICustomScrollListener, IGuiData{
|
||||
|
||||
@@ -36,6 +33,9 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
|
||||
private boolean noQuests = false;
|
||||
private boolean questDetails = true;
|
||||
|
||||
private HashMap<String,String> questAlertsOnOpen;
|
||||
private String trackedQuestKeyOnOpen;
|
||||
|
||||
private Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public GuiQuestLog(EntityPlayer player) {
|
||||
@@ -245,6 +245,8 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
|
||||
QuestLogData data = new QuestLogData();
|
||||
data.readNBT(compound);
|
||||
this.data = data;
|
||||
this.questAlertsOnOpen = new HashMap<>(data.questAlerts);
|
||||
this.trackedQuestKeyOnOpen = data.trackedQuestKey;
|
||||
initGui();
|
||||
}
|
||||
|
||||
@@ -256,7 +258,9 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
if (this.data != null) {
|
||||
if (this.data != null &&
|
||||
(!Objects.equals(this.questAlertsOnOpen, data.questAlerts) ||
|
||||
!Objects.equals(this.trackedQuestKeyOnOpen, data.trackedQuestKey))) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("Alerts", NBTTags.nbtStringStringMap(data.questAlerts));
|
||||
Client.sendData(EnumPacketServer.QuestLogToServer, compound, this.data.trackedQuestKey);
|
||||
|
||||
@@ -72,7 +72,15 @@ public class GuiRecipes extends GuiNPCInterface
|
||||
}
|
||||
List<IRecipe> list = new ArrayList<IRecipe>();
|
||||
for(IRecipe recipe : RecipeController.instance.anvilRecipes.values()){
|
||||
// System.out.println(recipe.getRecipeOutput().getDisplayName());
|
||||
if(recipe.getRecipeOutput() == null)
|
||||
continue;
|
||||
|
||||
if(recipe.getRecipeOutput().getDisplayName() == null)
|
||||
continue;
|
||||
|
||||
if(recipe.getRecipeOutput().getDisplayName().trim().equals(""))
|
||||
continue;
|
||||
|
||||
if(recipe.getRecipeOutput().getDisplayName().toLowerCase().contains(search.toLowerCase()))
|
||||
list.add(recipe);
|
||||
}
|
||||
|
||||
@@ -31,12 +31,6 @@ public class ConfigClient
|
||||
public static Property FontSizeProperty;
|
||||
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
|
||||
**/
|
||||
@@ -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)");
|
||||
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
|
||||
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);
|
||||
@@ -100,9 +88,6 @@ public class ConfigClient
|
||||
FontSize = LegacyConfig.FontSize;
|
||||
FontSizeProperty.set(FontSize);
|
||||
|
||||
EntityRendererMixin = LegacyConfig.EntityRendererMixin;
|
||||
EntityRendererMixinProperty.set(EntityRendererMixin);
|
||||
|
||||
TrackingInfoAlignment = LegacyConfig.TrackingInfoAlignment;
|
||||
TrackingInfoAlignmentProperty.set(TrackingInfoAlignment);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ public class ConfigMain
|
||||
|
||||
public final static String GENERAL = "General";
|
||||
public final static String NPC = "NPC";
|
||||
public final static String UPDATE = "Update";
|
||||
|
||||
/**
|
||||
* General Main Properties
|
||||
@@ -87,6 +88,13 @@ public class ConfigMain
|
||||
public static Property NpcUseOpCommandsProperty;
|
||||
public static boolean NpcUseOpCommands = false;
|
||||
|
||||
/**
|
||||
* Update Properties
|
||||
**/
|
||||
|
||||
public static Property TrackedQuestUpdateFrequencyProperty;
|
||||
public static int TrackedQuestUpdateFrequency = 5;
|
||||
|
||||
public static void init(File configFile)
|
||||
{
|
||||
config = new Configuration(configFile);
|
||||
@@ -161,6 +169,10 @@ public class ConfigMain
|
||||
SkinOverlayLimitProperty = config.get(NPC, "Skin Overlay Limit", 10, "The maximum number of overlays any npc/player can hold.");
|
||||
SkinOverlayLimit = SkinOverlayLimitProperty.getInt(10);
|
||||
|
||||
// Update
|
||||
TrackedQuestUpdateFrequencyProperty = config.get(UPDATE, "Tracked Quest Update Frequency", 5, "How often in seconds to update a players tracked quest. [Only applies to Item Quest currently]");
|
||||
TrackedQuestUpdateFrequency = TrackedQuestUpdateFrequencyProperty.getInt(5);
|
||||
|
||||
// Convert to Legacy
|
||||
if(CustomNpcs.legacyExist){
|
||||
EnableUpdateChecker = LegacyConfig.EnableUpdateChecker;
|
||||
|
||||
@@ -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;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import kamkeel.developer.Developer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
@@ -125,10 +126,10 @@ public class ConfigScript
|
||||
ExpandedScriptLimit = 0;
|
||||
|
||||
try {
|
||||
CustomNpcs.ScriptDevs.clear();
|
||||
Developer.ScriptUser.clear();
|
||||
String[] uuidStrings = ScriptDevIDs.split(",");
|
||||
for (String s : uuidStrings) {
|
||||
CustomNpcs.ScriptDevs.add(UUID.fromString(s));
|
||||
Developer.ScriptUser.add(UUID.fromString(s));
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
@@ -147,7 +148,7 @@ public class ConfigScript
|
||||
|
||||
public static boolean isScriptDev(EntityPlayer player) {
|
||||
if(ScriptOpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile()) ||
|
||||
CustomNpcs.ScriptDevs.contains(player.getUniqueID())){
|
||||
Developer.ScriptUser.contains(player.getUniqueID()) || Developer.Universal.contains(player.getUniqueID())){
|
||||
return true;
|
||||
} else return ScriptDevIDs.isEmpty();
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public enum EnumPacketServer {
|
||||
LinkedGetAll, LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED),
|
||||
ScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), ScriptDataGet(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,
|
||||
BankRemove(CustomNpcsPermissions.GLOBAL_BANK),
|
||||
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.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.gui.ScriptGui;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
@@ -134,8 +135,7 @@ public class ContainerCustomGui extends Container {
|
||||
}
|
||||
|
||||
EntityPlayerMP p = (EntityPlayerMP) player;
|
||||
p.sendContainerToPlayer(this);
|
||||
|
||||
CustomNPCsScheduler.runTack(() -> {p.sendContainerToPlayer(this);}, 10);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,10 @@ public class ContainerNPCBankInterface extends ContainerNpcInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
public synchronized void setCurrency(ItemStack item){
|
||||
currency.item = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i)
|
||||
{
|
||||
|
||||
@@ -27,12 +27,12 @@ public class CustomGuiController {
|
||||
EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player.getMCEntity();
|
||||
entityPlayerMP.openGui(CustomNpcs.instance, EnumGuiType.CustomGui.ordinal(), player.getWorld().getMCWorld(), gui.getSlots().size(), 0, 0);
|
||||
((ContainerCustomGui)((EntityPlayerMP)player.getMCEntity()).openContainer).setGui(gui, (EntityPlayer)player.getMCEntity());
|
||||
Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()});
|
||||
Server.sendDataChecked((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()});
|
||||
}
|
||||
|
||||
public static boolean updateGui(IPlayer player, ScriptGui gui) {
|
||||
if (((EntityPlayerMP)player.getMCEntity()).openContainer instanceof ContainerCustomGui) {
|
||||
Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()});
|
||||
Server.sendDataChecked((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()});
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -40,11 +40,11 @@ public class CustomGuiController {
|
||||
}
|
||||
|
||||
public static void openOverlay(IPlayer player, ScriptOverlay gui) {
|
||||
Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.SCRIPT_OVERLAY_DATA, new Object[]{gui.toNBT()});
|
||||
Server.sendDataChecked((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.SCRIPT_OVERLAY_DATA, new Object[]{gui.toNBT()});
|
||||
}
|
||||
|
||||
public static boolean updateOverlay(IPlayer player, ScriptOverlay gui) {
|
||||
Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.SCRIPT_OVERLAY_DATA, new Object[]{gui.toNBT()});
|
||||
Server.sendDataChecked((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.SCRIPT_OVERLAY_DATA, new Object[]{gui.toNBT()});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,50 +6,196 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.controllers.data.Bank;
|
||||
import noppes.npcs.controllers.data.PlayerBankData;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.controllers.data.PlayerMail;
|
||||
import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
public class PlayerDataController {
|
||||
public static PlayerDataController instance;
|
||||
public Map<String, String> nameUUIDs;
|
||||
public HashMap<String, String> nameUUIDs;
|
||||
|
||||
public PlayerDataController(){
|
||||
instance = this;
|
||||
File dir = getSaveDir();
|
||||
if(dir != null){
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
if(dir.listFiles() != null){
|
||||
for(File file : dir.listFiles()){
|
||||
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));
|
||||
|
||||
LogWriter.info("Loading PlayerData...");
|
||||
// If no PlayerData MAP - Load PlayerData to create PlayerData Map
|
||||
if(!getPlayerDataMap()){
|
||||
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 + "%");
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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(){
|
||||
try{
|
||||
File file = new File(CustomNpcs.getWorldSaveDirectory(),"playerdata");
|
||||
@@ -113,26 +259,6 @@ public class PlayerDataController {
|
||||
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) {
|
||||
Bank bank = BankController.getInstance().getBank(bankId);
|
||||
PlayerBankData data = getPlayerData(player).bankData;
|
||||
@@ -174,7 +300,7 @@ public class PlayerDataController {
|
||||
}
|
||||
}
|
||||
else
|
||||
data = PlayerData.get(player);
|
||||
data = PlayerDataController.instance.getPlayerData(player);
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -185,7 +311,7 @@ public class PlayerDataController {
|
||||
EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username);
|
||||
PlayerData data = getDataFromUsername(username);
|
||||
data.mailData.playermail.add(mail.copy());
|
||||
savePlayerData(data);
|
||||
data.save();
|
||||
}
|
||||
|
||||
public List<PlayerData> getPlayersData(ICommandSender sender, String username){
|
||||
@@ -205,7 +331,39 @@ public class PlayerDataController {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void putPlayerMap(String playerName, String uuid) {
|
||||
nameUUIDs.put(playerName, uuid);
|
||||
savePlayerDataMap();
|
||||
}
|
||||
|
||||
public boolean hasMail(EntityPlayer player) {
|
||||
return getPlayerData(player).mailData.hasMail();
|
||||
}
|
||||
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){
|
||||
PlayerData playerdata = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerQuestData data = playerdata.questData;
|
||||
QuestData questData = data.activeQuests.get(quest.id);
|
||||
data.activeQuests.remove(quest.id);
|
||||
if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY)
|
||||
data.finishedQuests.put(quest.id, System.currentTimeMillis());
|
||||
else
|
||||
data.finishedQuests.put(quest.id,player.worldObj.getTotalWorldTime());
|
||||
|
||||
if(quest.repeat != EnumQuestRepeat.NONE && quest.type == EnumQuestType.Dialog){
|
||||
QuestDialog questdialog = (QuestDialog) quest.questInterface;
|
||||
for(int dialog : questdialog.dialogs.values()){
|
||||
playerdata.dialogData.dialogsRead.remove(dialog);
|
||||
}
|
||||
}
|
||||
if (questData.sendAlerts) {
|
||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.MESSAGE, "quest.completed", questData.quest.title);
|
||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.CHAT, "quest.completed", ": ", questData.quest.title);
|
||||
}
|
||||
|
||||
}
|
||||
public static boolean canQuestBeAccepted(Quest quest, EntityPlayer player){
|
||||
if(quest == null)
|
||||
|
||||
@@ -254,8 +254,6 @@ public class ServerCloneController implements ICloneHandler {
|
||||
nbttagcompound.removeTag("MovingPathNew");
|
||||
nbttagcompound.removeTag("Pos");
|
||||
nbttagcompound.removeTag("Riding");
|
||||
nbttagcompound.removeTag("UUIDMost");
|
||||
nbttagcompound.removeTag("UUIDLeast");
|
||||
|
||||
if(!nbttagcompound.hasKey("ModRev"))
|
||||
nbttagcompound.setInteger("ModRev", 1);
|
||||
|
||||
@@ -15,6 +15,7 @@ import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.containers.ContainerNPCBankInterface;
|
||||
import noppes.npcs.controllers.BankController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -74,10 +75,8 @@ public class BankData {
|
||||
return bank.canBeUpgraded(slot) && upgradedSlots.get(slot);
|
||||
}
|
||||
|
||||
public void openBankGui(EntityPlayer player, EntityNPCInterface npc, int bankId, int slot) {
|
||||
Bank bank = BankController.getInstance().banks.get(bankId);
|
||||
if(bank == null)
|
||||
bank = BankController.getInstance().banks.values().iterator().next();
|
||||
public void openBankGui(final EntityPlayer player, EntityNPCInterface npc, int bankId, int slot) {
|
||||
final Bank bank = BankController.getInstance().getBank(bankId);
|
||||
|
||||
if(bank.getMaxSlots() <= slot)
|
||||
return;
|
||||
@@ -100,17 +99,19 @@ public class BankData {
|
||||
else{
|
||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankSmall, npc, slot, bank.id, 0);
|
||||
}
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("MaxSlots", bank.getMaxSlots());
|
||||
compound.setInteger("UnlockedSlots", unlockedSlots);
|
||||
if(currency != null){
|
||||
compound.setTag("Currency", NoppesUtilServer.writeItem(currency, new NBTTagCompound()));
|
||||
ContainerNPCBankInterface container = getContainer(player);
|
||||
container.currency.item = currency;
|
||||
}
|
||||
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.GUI_DATA,compound);
|
||||
final ItemStack item = currency;
|
||||
CustomNPCsScheduler.runTack(() -> {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("MaxSlots", bank.getMaxSlots());
|
||||
compound.setInteger("UnlockedSlots", unlockedSlots);
|
||||
if (item != null) {
|
||||
compound.setTag("Currency", NoppesUtilServer.writeItem(item, new NBTTagCompound()));
|
||||
ContainerNPCBankInterface container = getContainer(player);
|
||||
if (container != null)
|
||||
container.setCurrency(item);
|
||||
}
|
||||
Server.sendDataChecked((EntityPlayerMP) player, EnumPacketClient.GUI_DATA, compound);
|
||||
}, 300);
|
||||
}
|
||||
private ContainerNPCBankInterface getContainer(EntityPlayer player){
|
||||
Container con = player.openContainer;
|
||||
|
||||
@@ -30,9 +30,9 @@ import javax.script.ScriptEngine;
|
||||
import java.util.*;
|
||||
|
||||
public class DataScript implements IScriptHandler {
|
||||
public List<ScriptContainer> eventScripts = new ArrayList();
|
||||
public List<ScriptContainer> eventScripts = new ArrayList<>();
|
||||
|
||||
public List<ScriptContainer> scripts = new ArrayList();
|
||||
private HashMap<EnumScriptType,ScriptContainer> scripts = new HashMap<>();
|
||||
private final static EntityType entities = new EntityType();
|
||||
private final static JobType jobs = new JobType();
|
||||
private final static RoleType roles = new RoleType();
|
||||
@@ -49,7 +49,7 @@ public class DataScript implements IScriptHandler {
|
||||
|
||||
public DataScript(EntityNPCInterface npc) {
|
||||
for (int i = 0; i < 15; i++) {
|
||||
scripts.add(new ScriptContainer(this));
|
||||
this.setNPCScript(i, new ScriptContainer(this));
|
||||
}
|
||||
|
||||
this.npc = npc;
|
||||
@@ -94,30 +94,30 @@ public class DataScript implements IScriptHandler {
|
||||
return compound;
|
||||
}
|
||||
|
||||
private List<ScriptContainer> readScript(NBTTagList list){
|
||||
List<ScriptContainer> scripts = new ArrayList<>();
|
||||
private HashMap<EnumScriptType,ScriptContainer> readScript(NBTTagList list){
|
||||
HashMap<EnumScriptType,ScriptContainer> scripts = new HashMap<>();
|
||||
for (int i = 0; i < 15; i++) {
|
||||
scripts.add(new ScriptContainer(this));
|
||||
scripts.put(EnumScriptType.values()[i], new ScriptContainer(this));
|
||||
}
|
||||
|
||||
for(int i = 0; i < list.tagCount(); i++){
|
||||
NBTTagCompound compoundd = list.getCompoundTagAt(i);
|
||||
ScriptContainer script = new ScriptContainer(this);
|
||||
script.readFromNBT(compoundd);
|
||||
if(script.hasCode() || npc.isRemote())
|
||||
scripts.set(compoundd.getInteger("Type"), script);
|
||||
if (script.hasCode() || npc.isRemote()) {
|
||||
scripts.put(EnumScriptType.values()[compoundd.getInteger("Type")], script);
|
||||
}
|
||||
}
|
||||
return scripts;
|
||||
}
|
||||
|
||||
private NBTTagList writeScript(List<ScriptContainer> scripts){
|
||||
private NBTTagList writeScript(HashMap<EnumScriptType,ScriptContainer> scripts){
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(int type = 0; type < scripts.size(); type++){
|
||||
NBTTagCompound compoundd = new NBTTagCompound();
|
||||
compoundd.setInteger("Type", type);
|
||||
ScriptContainer script = scripts.get(type);
|
||||
script.writeToNBT(compoundd);
|
||||
list.appendTag(compoundd);
|
||||
for (Map.Entry<EnumScriptType,ScriptContainer> entry : scripts.entrySet()) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setInteger("Type", entry.getKey().ordinal());
|
||||
entry.getValue().writeToNBT(tagCompound);
|
||||
list.appendTag(tagCompound);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class DataScript implements IScriptHandler {
|
||||
script.run(type, event);
|
||||
}
|
||||
|
||||
ScriptContainer script = scripts.get(type.ordinal());
|
||||
ScriptContainer script = scripts.get(type);
|
||||
if(script == null || script.errored || !script.hasCode())
|
||||
return false;
|
||||
script.setEngine(scriptLanguage);
|
||||
@@ -198,18 +198,11 @@ public class DataScript implements IScriptHandler {
|
||||
}
|
||||
|
||||
public Map<Long, String> getOldConsoleText() {
|
||||
Map<Long, String> map = new TreeMap();
|
||||
int tab = 0;
|
||||
Iterator var3 = this.scripts.iterator();
|
||||
Map<Long, String> map = new TreeMap<>();
|
||||
|
||||
while(var3.hasNext()) {
|
||||
ScriptContainer script = (ScriptContainer)var3.next();
|
||||
++tab;
|
||||
Iterator var5 = script.console.entrySet().iterator();
|
||||
|
||||
while(var5.hasNext()) {
|
||||
Map.Entry<Long, String> entry = (Map.Entry)var5.next();
|
||||
map.put(entry.getKey(), " tab " + tab + ":\n" + (String)entry.getValue());
|
||||
for (Map.Entry<EnumScriptType,ScriptContainer> entry : scripts.entrySet()) {
|
||||
for (Map.Entry<Long,String> consoleEntry : entry.getValue().console.entrySet()) {
|
||||
map.put(consoleEntry.getKey(), " tab " + entry.getKey().ordinal() + ":\n" + consoleEntry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +254,7 @@ public class DataScript implements IScriptHandler {
|
||||
}
|
||||
|
||||
public void setScripts(List<ScriptContainer> list) {
|
||||
this.scripts = list;
|
||||
this.eventScripts = list;
|
||||
}
|
||||
|
||||
public List<ScriptContainer> getScripts() {
|
||||
@@ -279,4 +272,23 @@ public class DataScript implements IScriptHandler {
|
||||
dummyWorld = new ScriptWorld((WorldServer) world);
|
||||
}
|
||||
|
||||
public ScriptContainer getNPCScript(EnumScriptType scriptType) {
|
||||
return this.scripts.get(scriptType);
|
||||
}
|
||||
|
||||
public ScriptContainer getNPCScript(int ordinal) {
|
||||
return this.getNPCScript(EnumScriptType.values()[ordinal]);
|
||||
}
|
||||
|
||||
public void setNPCScript(EnumScriptType scriptType, ScriptContainer container) {
|
||||
this.scripts.put(scriptType, container);
|
||||
}
|
||||
|
||||
public void setNPCScript(int ordinal, ScriptContainer container) {
|
||||
this.setNPCScript(EnumScriptType.values()[ordinal], container);
|
||||
}
|
||||
|
||||
public Collection<ScriptContainer> getNPCScripts() {
|
||||
return this.scripts.values();
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import noppes.npcs.entity.data.DataSkinOverlays;
|
||||
import noppes.npcs.entity.data.DataTimers;
|
||||
import noppes.npcs.roles.RoleCompanion;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
import java.io.File;
|
||||
@@ -55,10 +56,6 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
//Do Nothing
|
||||
}
|
||||
|
||||
public void savePlayerDataOnFile() {
|
||||
PlayerDataController.instance.savePlayerData(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadNBTData(NBTTagCompound compound) {
|
||||
//Do Nothing
|
||||
@@ -142,7 +139,7 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
|
||||
public void setGUIOpen(boolean bool) {
|
||||
isGUIOpen = bool;
|
||||
savePlayerDataOnFile();
|
||||
save();
|
||||
}
|
||||
|
||||
public boolean getGUIOpen() {
|
||||
@@ -161,7 +158,7 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
activeCompanion = npc;
|
||||
if(npc != null)
|
||||
((RoleCompanion)npc.roleInterface).companionID = companionID;
|
||||
savePlayerDataOnFile();
|
||||
save();
|
||||
}
|
||||
|
||||
public void updateCompanion(World world) {
|
||||
@@ -302,7 +299,25 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
return mailData;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
PlayerDataController.instance.savePlayerData(this);
|
||||
public synchronized void save() {
|
||||
final NBTTagCompound compound = getNBT();
|
||||
final String filename = uuid + ".json";
|
||||
|
||||
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.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumQuestCompletion;
|
||||
import noppes.npcs.constants.EnumQuestRepeat;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
@@ -24,7 +25,7 @@ import java.util.List;
|
||||
|
||||
public class PlayerQuestData implements IPlayerQuestData {
|
||||
private final PlayerData parent;
|
||||
public IQuest trackedQuest = null;
|
||||
private IQuest trackedQuest = null;
|
||||
|
||||
public HashMap<Integer,QuestData> activeQuests = new HashMap<Integer,QuestData>();
|
||||
public HashMap<Integer,Long> finishedQuests = new HashMap<Integer,Long>();
|
||||
@@ -120,8 +121,6 @@ public class PlayerQuestData implements IPlayerQuestData {
|
||||
if(data.quest.type != type && type != null)
|
||||
continue;
|
||||
|
||||
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) player,data.quest);
|
||||
|
||||
QuestInterface inter = data.quest.questInterface;
|
||||
if(inter.isCompleted(playerData)){
|
||||
if((!data.isCompleted && data.quest.completion == EnumQuestCompletion.Npc) || data.quest.instantComplete(player,data)){
|
||||
@@ -138,14 +137,32 @@ public class PlayerQuestData implements IPlayerQuestData {
|
||||
} else {
|
||||
data.isCompleted = false;
|
||||
}
|
||||
|
||||
if (this.trackedQuest != null && data.quest.getId() == this.trackedQuest.getId()) {
|
||||
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
QuestItem.pickedUp = null;
|
||||
return bo;
|
||||
|
||||
}
|
||||
|
||||
public void trackQuest(IQuest quest) {
|
||||
if (this.trackedQuest == null || quest.getId() != this.trackedQuest.getId()) {
|
||||
this.trackedQuest = quest;
|
||||
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) this.parent.player);
|
||||
}
|
||||
}
|
||||
|
||||
public void untrackQuest() {
|
||||
if (this.trackedQuest != null) {
|
||||
this.trackedQuest = null;
|
||||
Server.sendData((EntityPlayerMP) this.parent.player, EnumPacketClient.OVERLAY_QUEST_TRACKING);
|
||||
}
|
||||
}
|
||||
|
||||
public IQuest getTrackedQuest() {
|
||||
return trackedQuest;
|
||||
return this.trackedQuest;
|
||||
}
|
||||
|
||||
public void startQuest(int id) {
|
||||
@@ -164,7 +181,11 @@ public class PlayerQuestData implements IPlayerQuestData {
|
||||
Quest quest = QuestController.instance.quests.get(id);
|
||||
if (quest == null)
|
||||
return;
|
||||
finishedQuests.put(id, System.currentTimeMillis());
|
||||
|
||||
if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY)
|
||||
finishedQuests.put(quest.id, System.currentTimeMillis());
|
||||
else
|
||||
finishedQuests.put(quest.id, parent.player.worldObj.getTotalWorldTime());
|
||||
}
|
||||
|
||||
public void stopQuest(int id) {
|
||||
|
||||
@@ -148,11 +148,11 @@ public class Quest implements ICompatibilty, IQuest {
|
||||
|
||||
switch (repeat) {
|
||||
case MCDAILY:
|
||||
return Math.max(0, questTime + 24000 - player.worldObj.getTotalWorldTime());
|
||||
return Math.max(0, (questTime + 24000 - player.worldObj.getTotalWorldTime()) * 50);
|
||||
case MCWEEKLY:
|
||||
return Math.max(0, questTime + 168000 - player.worldObj.getTotalWorldTime());
|
||||
return Math.max(0, (questTime + 168000 - player.worldObj.getTotalWorldTime()) * 50);
|
||||
case RLDAILY:
|
||||
return Math.max(0, questTime + 86400000 - System.currentTimeMillis());
|
||||
return Math.max(0, questTime + 86400000 - System.currentTimeMillis());
|
||||
case RLWEEKLY:
|
||||
return Math.max(0, questTime + 604800000 - System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
|
||||
public class ItemNpcWand extends Item{
|
||||
|
||||
@@ -35,14 +36,14 @@ public class ItemNpcWand extends Item{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
public boolean onItemUse(ItemStack par1ItemStack, final EntityPlayer player, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
if(par3World.isRemote)
|
||||
return true;
|
||||
if(ConfigMain.OpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile())){
|
||||
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
|
||||
}
|
||||
else if(CustomNpcsPermissions.Instance.hasPermission(player, CustomNpcsPermissions.NPC_CREATE)){
|
||||
else if(CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.NPC_CREATE)){
|
||||
EntityCustomNpc npc = new EntityCustomNpc(par3World);
|
||||
npc.ai.startPos = new int[]{par4,par5,par6};
|
||||
|
||||
@@ -50,8 +51,8 @@ public class ItemNpcWand extends Item{
|
||||
|
||||
par3World.spawnEntityInWorld(npc);
|
||||
npc.setHealth(npc.getMaxHealth());
|
||||
|
||||
NoppesUtilServer.sendOpenGui(player,EnumGuiType.MainMenuDisplay,npc);
|
||||
|
||||
NoppesUtilServer.sendOpenGuiNoDelay(player, EnumGuiType.MainMenuDisplay,npc);
|
||||
}
|
||||
else
|
||||
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package noppes.npcs.mixin;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
import noppes.npcs.config.ConfigClient;
|
||||
import noppes.npcs.config.ConfigMixin;
|
||||
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.IMixinInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -32,13 +36,23 @@ public class CustomNPCsMixinPlugin implements IMixinConfigPlugin {
|
||||
|
||||
@Override
|
||||
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<>();
|
||||
if (ConfigClient.EntityRendererMixin){
|
||||
mixins.add("MixinEntityRenderer");
|
||||
}
|
||||
if (ConfigClient.AnimationMixin) {
|
||||
mixins.add("MixinModelRenderer");
|
||||
mixins.add("MixinRenderPlayer");
|
||||
|
||||
// Client Only Mixins
|
||||
if(client){
|
||||
if (ConfigMixin.EntityRendererMixin){
|
||||
mixins.add("MixinEntityRenderer");
|
||||
}
|
||||
if (ConfigMixin.AnimationMixin) {
|
||||
mixins.add("MixinModelRenderer");
|
||||
mixins.add("MixinRenderPlayer");
|
||||
}
|
||||
}
|
||||
return mixins;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package noppes.npcs.mixin;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import noppes.npcs.AnimationData;
|
||||
@@ -38,6 +40,8 @@ public abstract class MixinModelRenderer {
|
||||
@Shadow public List childModels;
|
||||
@Shadow abstract void compileDisplayList(float p_78788_1_);
|
||||
|
||||
@Shadow public ModelBase baseModel;
|
||||
|
||||
/**
|
||||
* @author Someone
|
||||
* @reason Because we need it
|
||||
@@ -108,7 +112,7 @@ public abstract class MixinModelRenderer {
|
||||
}
|
||||
if (ClientEventHandler.renderingPlayer != null && Client.playerAnimations.containsKey(ClientEventHandler.renderingPlayer.getUniqueID())) {
|
||||
animData = Client.playerAnimations.get(ClientEventHandler.renderingPlayer.getUniqueID());
|
||||
EnumAnimationPart mainPartType = this.getPlayerPartType((ModelRenderer) (Object) this);
|
||||
EnumAnimationPart mainPartType = null;
|
||||
EnumAnimationPart pivotEqualPart = null;
|
||||
if (mainPartType == null) {
|
||||
pivotEqualPart = this.pivotEqualPart((ModelRenderer) (Object) this);
|
||||
@@ -157,7 +161,9 @@ public abstract class MixinModelRenderer {
|
||||
{
|
||||
for (i = 0; i < this.childModels.size(); ++i)
|
||||
{
|
||||
((ModelRenderer)this.childModels.get(i)).render(p_78785_1_);
|
||||
if(this.childModels.get(i) instanceof ModelRenderer){
|
||||
((ModelRenderer)this.childModels.get(i)).render(p_78785_1_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -170,7 +176,9 @@ public abstract class MixinModelRenderer {
|
||||
{
|
||||
for (i = 0; i < this.childModels.size(); ++i)
|
||||
{
|
||||
((ModelRenderer)this.childModels.get(i)).render(p_78785_1_);
|
||||
if(this.childModels.get(i) instanceof ModelRenderer){
|
||||
((ModelRenderer)this.childModels.get(i)).render(p_78785_1_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,10 +211,11 @@ public abstract class MixinModelRenderer {
|
||||
{
|
||||
for (i = 0; i < this.childModels.size(); ++i)
|
||||
{
|
||||
((ModelRenderer)this.childModels.get(i)).render(p_78785_1_);
|
||||
if(this.childModels.get(i) instanceof ModelRenderer){
|
||||
((ModelRenderer)this.childModels.get(i)).render(p_78785_1_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -274,30 +283,32 @@ public abstract class MixinModelRenderer {
|
||||
}
|
||||
|
||||
public EnumAnimationPart pivotEqualPart(ModelRenderer renderer) {
|
||||
ModelRenderer head = ((ModelBiped) renderer.baseModel).bipedHead;
|
||||
ModelRenderer body = ((ModelBiped) renderer.baseModel).bipedBody;
|
||||
ModelRenderer larm = ((ModelBiped) renderer.baseModel).bipedLeftArm;
|
||||
ModelRenderer rarm = ((ModelBiped) renderer.baseModel).bipedRightArm;
|
||||
ModelRenderer lleg = ((ModelBiped) renderer.baseModel).bipedLeftLeg;
|
||||
ModelRenderer rleg = ((ModelBiped) renderer.baseModel).bipedRightLeg;
|
||||
if(renderer.baseModel instanceof ModelBiped){
|
||||
ModelRenderer head = ((ModelBiped) renderer.baseModel).bipedHead;
|
||||
ModelRenderer body = ((ModelBiped) renderer.baseModel).bipedBody;
|
||||
ModelRenderer larm = ((ModelBiped) renderer.baseModel).bipedLeftArm;
|
||||
ModelRenderer rarm = ((ModelBiped) renderer.baseModel).bipedRightArm;
|
||||
ModelRenderer lleg = ((ModelBiped) renderer.baseModel).bipedLeftLeg;
|
||||
ModelRenderer rleg = ((ModelBiped) renderer.baseModel).bipedRightLeg;
|
||||
|
||||
if (pivotsEqual(renderer,head)) {
|
||||
return EnumAnimationPart.HEAD;
|
||||
}
|
||||
if (pivotsEqual(renderer,body)) {
|
||||
return EnumAnimationPart.BODY;
|
||||
}
|
||||
if (pivotsEqual(renderer,rarm)) {
|
||||
return EnumAnimationPart.RIGHT_ARM;
|
||||
}
|
||||
if (pivotsEqual(renderer,larm)) {
|
||||
return EnumAnimationPart.LEFT_ARM;
|
||||
}
|
||||
if (pivotsEqual(renderer,rleg)) {
|
||||
return EnumAnimationPart.RIGHT_LEG;
|
||||
}
|
||||
if (pivotsEqual(renderer,lleg)) {
|
||||
return EnumAnimationPart.LEFT_LEG;
|
||||
if (pivotsEqual(renderer,head)) {
|
||||
return EnumAnimationPart.HEAD;
|
||||
}
|
||||
if (pivotsEqual(renderer,body)) {
|
||||
return EnumAnimationPart.BODY;
|
||||
}
|
||||
if (pivotsEqual(renderer,rarm)) {
|
||||
return EnumAnimationPart.RIGHT_ARM;
|
||||
}
|
||||
if (pivotsEqual(renderer,larm)) {
|
||||
return EnumAnimationPart.LEFT_ARM;
|
||||
}
|
||||
if (pivotsEqual(renderer,rleg)) {
|
||||
return EnumAnimationPart.RIGHT_LEG;
|
||||
}
|
||||
if (pivotsEqual(renderer,lleg)) {
|
||||
return EnumAnimationPart.LEFT_LEG;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -99,13 +99,13 @@ public class QuestDialog extends QuestInterface implements IQuestDialog {
|
||||
if (progress == 0 && completed) {
|
||||
data.dialogData.dialogsRead.remove(this.dialog.id);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]);
|
||||
data.savePlayerDataOnFile();
|
||||
data.save();
|
||||
}
|
||||
|
||||
if (progress == 1 && !completed) {
|
||||
data.dialogData.dialogsRead.add(this.dialog.id);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]);
|
||||
data.savePlayerDataOnFile();
|
||||
data.save();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
@@ -10,6 +10,7 @@ import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.controllers.data.PlayerQuestData;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
@@ -19,9 +20,11 @@ public abstract class QuestInterface implements IQuestInterface {
|
||||
public abstract void readEntityFromNBT(NBTTagCompound compound);
|
||||
public abstract boolean isCompleted(PlayerData player);
|
||||
public void handleComplete(EntityPlayer player) {
|
||||
if (QuestController.instance.get(questId).equals(PlayerDataController.instance.getPlayerData(player).questData.trackedQuest)) {
|
||||
PlayerDataController.instance.getPlayerData(player).questData.trackedQuest = null;
|
||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.OVERLAY_QUEST_TRACKING);
|
||||
PlayerQuestData questData = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
if(questData != null && questData.getTrackedQuest() != null){
|
||||
if (this.questId == PlayerDataController.instance.getPlayerData(player).questData.getTrackedQuest().getId()) {
|
||||
PlayerDataController.instance.getPlayerData(player).questData.untrackQuest();
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract Vector<String> getQuestLogStatus(EntityPlayer player);
|
||||
|
||||
@@ -131,18 +131,16 @@ public class QuestItem extends QuestInterface implements IQuestItem {
|
||||
}
|
||||
|
||||
public IQuestObjective[] getObjectives(EntityPlayer player) {
|
||||
List<IQuestObjective> list = new ArrayList();
|
||||
List<IQuestObjective> list = new ArrayList<>();
|
||||
List<ItemStack> questItems = NoppesUtilPlayer.countStacks(this.items, this.ignoreDamage, this.ignoreNBT);
|
||||
Iterator var4 = questItems.iterator();
|
||||
|
||||
while(var4.hasNext()) {
|
||||
ItemStack stack = (ItemStack)var4.next();
|
||||
for (ItemStack stack : questItems) {
|
||||
if (stack.stackSize > 0) {
|
||||
list.add(new noppes.npcs.quests.QuestItem.QuestItemObjective(this, player, stack));
|
||||
list.add(new QuestItemObjective(this, player, stack));
|
||||
}
|
||||
}
|
||||
|
||||
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
|
||||
return list.toArray(new IQuestObjective[0]);
|
||||
}
|
||||
|
||||
public void setLeaveItems(boolean leaveItems){
|
||||
@@ -180,8 +178,13 @@ public class QuestItem extends QuestInterface implements IQuestItem {
|
||||
public int getProgress() {
|
||||
int count = 0;
|
||||
|
||||
ItemStack item = QuestItem.pickedUp;
|
||||
if (!NoppesUtilServer.IsItemStackNull(item) && NoppesUtilPlayer.compareItems(this.questItem, item, this.parent.ignoreDamage, this.parent.ignoreNBT)) {
|
||||
count += item.stackSize;
|
||||
}
|
||||
|
||||
for(int i = 0; i < this.player.inventory.getSizeInventory(); ++i) {
|
||||
ItemStack item = this.player.inventory.getStackInSlot(i);
|
||||
item = this.player.inventory.getStackInSlot(i);
|
||||
if (!NoppesUtilServer.IsItemStackNull(item) && NoppesUtilPlayer.compareItems(this.questItem, item, this.parent.ignoreDamage, this.parent.ignoreNBT)) {
|
||||
count += item.stackSize;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public class QuestKill extends QuestInterface implements IQuestKill {
|
||||
this.parent.setKilled(questdata, killed);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[4]);
|
||||
data.savePlayerDataOnFile();
|
||||
data.save();
|
||||
}
|
||||
} else {
|
||||
throw new CustomNPCsException("Progress has to be between 0 and " + this.amount, new Object[0]);
|
||||
|
||||
@@ -166,7 +166,7 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
|
||||
if ((!completed || progress != 1) && (completed || progress != 0)) {
|
||||
questData.extraData.setBoolean(this.nbtName, progress == 1);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[3]);
|
||||
data.savePlayerDataOnFile();
|
||||
data.save();
|
||||
}
|
||||
} else {
|
||||
throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]);
|
||||
|
||||
@@ -27,6 +27,7 @@ import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.api.overlay.ICustomOverlay;
|
||||
import noppes.npcs.config.ConfigScript;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumQuestRepeat;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.containers.ContainerCustomGui;
|
||||
import noppes.npcs.controllers.*;
|
||||
@@ -270,7 +271,11 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
if (quest == null)
|
||||
return;
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
data.questData.finishedQuests.put(id, System.currentTimeMillis());
|
||||
|
||||
if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY)
|
||||
data.questData.finishedQuests.put(quest.id, System.currentTimeMillis());
|
||||
else
|
||||
data.questData.finishedQuests.put(quest.id, player.worldObj.getTotalWorldTime());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 noppes.npcs.CustomItems;
|
||||
import noppes.npcs.client.gui.player.GuiFaction;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
|
||||
public class InventoryTabFactions extends AbstractTab {
|
||||
public InventoryTabFactions() {
|
||||
@@ -15,19 +16,10 @@ public class InventoryTabFactions extends AbstractTab {
|
||||
|
||||
@Override
|
||||
public void onTabClicked() {
|
||||
Thread t = new Thread(){
|
||||
@Override
|
||||
public void run(){
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.displayGuiScreen(new GuiFaction());
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
CustomNPCsScheduler.runTack(() -> {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.displayGuiScreen(new GuiFaction());
|
||||
}, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,9 @@ import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.play.client.C0DPacketCloseWindow;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.client.gui.player.GuiFaction;
|
||||
import noppes.npcs.client.gui.player.GuiQuestLog;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
|
||||
public class InventoryTabQuests extends AbstractTab {
|
||||
public InventoryTabQuests() {
|
||||
@@ -17,19 +19,10 @@ public class InventoryTabQuests extends AbstractTab {
|
||||
|
||||
@Override
|
||||
public void onTabClicked() {
|
||||
Thread t = new Thread(){
|
||||
@Override
|
||||
public void run(){
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer));
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
CustomNPCsScheduler.runTack(() -> {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer));
|
||||
}, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user