mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-24 21:04:27 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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
+2
-2
@@ -34,7 +34,7 @@ configurations {
|
|||||||
|
|
||||||
apply plugin: 'forge'
|
apply plugin: 'forge'
|
||||||
|
|
||||||
version = "1.8"
|
version = "1.8.1"
|
||||||
group= "com.kamkeel.customnpc-plus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
group= "com.kamkeel.customnpc-plus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = "CustomNPC-Plus"
|
archivesBaseName = "CustomNPC-Plus"
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ def refMapForYourConfig = 'customnpcs.refmap.json'
|
|||||||
def relativePathToMixinAP = 'tools/mixin-0.8-SNAPSHOT.jar'
|
def relativePathToMixinAP = 'tools/mixin-0.8-SNAPSHOT.jar'
|
||||||
|
|
||||||
if(!embedMixin){
|
if(!embedMixin){
|
||||||
version += "+nomixin"
|
version += "-nomixin"
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|||||||
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.
@@ -39,9 +39,14 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
int tab = 0;
|
int tab = 0;
|
||||||
try{
|
try{
|
||||||
tab = Integer.parseInt(args[1]);
|
tab = Integer.parseInt(args[1]);
|
||||||
|
if(tab < 0 || tab > 15){
|
||||||
|
sendError(sender, "Tab must be within 1-15");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(NumberFormatException ex){
|
catch(NumberFormatException ex){
|
||||||
|
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = sender.getPlayerCoordinates().posX;
|
int x = sender.getPlayerCoordinates().posX;
|
||||||
@@ -58,6 +63,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
if(!npc.writeToNBTOptional(compound))
|
if(!npc.writeToNBTOptional(compound))
|
||||||
return;
|
return;
|
||||||
ServerCloneController.Instance.addClone(compound, name, tab);
|
ServerCloneController.Instance.addClone(compound, name, tab);
|
||||||
|
sendResult(sender, String.format("Added NPC \u00A7e%s\u00A77 to Tab \u00A7b%d\u00A77", name, tab));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,11 +77,17 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
sendMessage(sender, "--- Stored NPCs --- (server side)");
|
sendMessage(sender, "--- Stored NPCs --- (server side)");
|
||||||
int tab = 0;
|
int tab = 0;
|
||||||
try{
|
try{
|
||||||
tab = Integer.parseInt(args[0]);
|
tab = Integer.parseInt(args[1]);
|
||||||
|
if(tab < 0 || tab > 15){
|
||||||
|
sendError(sender, "Tab must be within 1-15");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(NumberFormatException ex){
|
catch(NumberFormatException ex){
|
||||||
|
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String name : ServerCloneController.Instance.getClones(tab)) {
|
for (String name : ServerCloneController.Instance.getClones(tab)) {
|
||||||
sendMessage(sender, name);
|
sendMessage(sender, name);
|
||||||
}
|
}
|
||||||
@@ -91,11 +103,17 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
String nametodel = args[0];
|
String nametodel = args[0];
|
||||||
int tab = 0;
|
int tab = 0;
|
||||||
try{
|
try{
|
||||||
tab = Integer.parseInt(args[1]);
|
tab = Integer.parseInt(args[1]);
|
||||||
|
if(tab < 0 || tab > 15){
|
||||||
|
sendError(sender, String.format("Tab must be within 1-15"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(NumberFormatException ex){
|
catch(NumberFormatException ex){
|
||||||
|
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean deleted = false;
|
boolean deleted = false;
|
||||||
for(String name : ServerCloneController.Instance.getClones(tab)){
|
for(String name : ServerCloneController.Instance.getClones(tab)){
|
||||||
if(nametodel.equalsIgnoreCase(name)){
|
if(nametodel.equalsIgnoreCase(name)){
|
||||||
@@ -105,7 +123,9 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ServerCloneController.Instance.removeClone(nametodel, tab)) {
|
if (!ServerCloneController.Instance.removeClone(nametodel, tab)) {
|
||||||
throw new CommandException(String.format("Npc '%s' wasn't found", nametodel));
|
sendError(sender, String.format("NPC '%s' was not found", nametodel));
|
||||||
|
} else {
|
||||||
|
sendResult(sender, String.format("Removed NPC \u00A7e%s\u00A77 from Tab \u00A7b%d\u00A77", nametodel, tab));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,14 +139,20 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
int tab = 0;
|
int tab = 0;
|
||||||
try{
|
try{
|
||||||
tab = Integer.parseInt(args[1]);
|
tab = Integer.parseInt(args[1]);
|
||||||
|
if(tab < 0 || tab > 15){
|
||||||
|
sendError(sender, String.format("Tab must be within 1-15"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(NumberFormatException ex){
|
catch(NumberFormatException ex){
|
||||||
|
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String newname=null;
|
String newname=null;
|
||||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
|
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
|
||||||
if(compound == null){
|
if(compound == null){
|
||||||
sendMessage(sender, "Unknown npc");
|
sendError(sender, "Unknown npc");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
World world = sender.getEntityWorld();
|
World world = sender.getEntityWorld();
|
||||||
@@ -142,14 +168,15 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
location = par[1];
|
location = par[1];
|
||||||
world = Utils.getWorld(par[0]);
|
world = Utils.getWorld(par[0]);
|
||||||
if (world == null){
|
if (world == null){
|
||||||
throw new CommandException(String.format("'%s' is an unknown world", par[0]));
|
sendError(sender, String.format("'%s' is an unknown world", par[0]));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location.contains(",")){
|
if (location.contains(",")){
|
||||||
par = location.split(",");
|
par = location.split(",");
|
||||||
if (par.length != 3){
|
if (par.length != 3){
|
||||||
sendMessage(sender, "Location need be x,y,z");
|
sendError(sender, "Location need be x,y,z");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
@@ -157,7 +184,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
posY = CommandBase.func_110665_a(sender, posY, par[1].trim(), 0, 0);
|
posY = CommandBase.func_110665_a(sender, posY, par[1].trim(), 0, 0);
|
||||||
posZ = CommandBase.func_110666_a(sender, posZ, par[2]);
|
posZ = CommandBase.func_110666_a(sender, posZ, par[2]);
|
||||||
} catch(NumberFormatException ex){
|
} catch(NumberFormatException ex){
|
||||||
sendMessage(sender, "Location should be in numbers");
|
sendError(sender, "Location should be in numbers");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args.length > 3){
|
if (args.length > 3){
|
||||||
@@ -169,7 +196,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given
|
if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given
|
||||||
sendMessage(sender, "Location needed");
|
sendError(sender, "Location needed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,9 +221,14 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
int tab = 0;
|
int tab = 0;
|
||||||
try{
|
try{
|
||||||
tab = Integer.parseInt(args[1]);
|
tab = Integer.parseInt(args[1]);
|
||||||
|
if(tab < 0 || tab > 15){
|
||||||
|
sendError(sender, String.format("Tab must be within 1-15"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(NumberFormatException ex){
|
catch(NumberFormatException ex){
|
||||||
|
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int width, height;
|
int width, height;
|
||||||
@@ -205,7 +237,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
height = Integer.parseInt(args[3]);
|
height = Integer.parseInt(args[3]);
|
||||||
}
|
}
|
||||||
catch(NumberFormatException ex){
|
catch(NumberFormatException ex){
|
||||||
sendMessage(sender, "length or width was not a number");
|
sendError(sender, "length or width was not a number");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +245,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
String newname=null;
|
String newname=null;
|
||||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
|
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
|
||||||
if(compound == null){
|
if(compound == null){
|
||||||
sendMessage(sender, "Unknown npc");
|
sendError(sender, "Unknown npc");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
World world = sender.getEntityWorld();
|
World world = sender.getEntityWorld();
|
||||||
@@ -229,14 +261,14 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
location = par[1];
|
location = par[1];
|
||||||
world = Utils.getWorld(par[0]);
|
world = Utils.getWorld(par[0]);
|
||||||
if (world == null){
|
if (world == null){
|
||||||
throw new CommandException(String.format("'%s' is an unknown world", par[0]));
|
sendError(sender, String.format("'%s' is an unknown world", par[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location.contains(",")){
|
if (location.contains(",")){
|
||||||
par = location.split(",");
|
par = location.split(",");
|
||||||
if (par.length != 3){
|
if (par.length != 3){
|
||||||
sendMessage(sender, "Location need be x,y,z");
|
sendError(sender, "Location need be x,y,z");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
@@ -244,7 +276,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
posY = CommandBase.func_110665_a(sender, posY, par[1].trim(), 0, 0);
|
posY = CommandBase.func_110665_a(sender, posY, par[1].trim(), 0, 0);
|
||||||
posZ = CommandBase.func_110666_a(sender, posZ, par[2]);
|
posZ = CommandBase.func_110666_a(sender, posZ, par[2]);
|
||||||
} catch(NumberFormatException ex){
|
} catch(NumberFormatException ex){
|
||||||
sendMessage(sender, "Location should be in numbers");
|
sendError(sender, "Location should be in numbers");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args.length > 5){
|
if (args.length > 5){
|
||||||
@@ -256,7 +288,7 @@ public class CloneCommand extends CommandKamkeelBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given
|
if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given
|
||||||
sendMessage(sender, "Location needed");
|
sendError(sender, "Location needed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
package kamkeel;
|
package kamkeel;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.command.CommandBase;
|
import net.minecraft.command.CommandBase;
|
||||||
import net.minecraft.command.CommandException;
|
import net.minecraft.command.CommandException;
|
||||||
import net.minecraft.command.ICommandSender;
|
import net.minecraft.command.ICommandSender;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
import noppes.npcs.scripted.CustomNPCsException;
|
import noppes.npcs.scripted.CustomNPCsException;
|
||||||
|
|
||||||
public class CommandKamkeel extends CommandBase{
|
public class CommandKamkeel extends CommandBase{
|
||||||
@@ -75,13 +78,28 @@ public class CommandKamkeel extends CommandBase{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List addTabCompletionOptions(ICommandSender sender, String[] args){
|
public List addTabCompletionOptions(ICommandSender sender, String[] args){
|
||||||
if(args.length == 1)
|
if(args.length == 1)
|
||||||
return new ArrayList<String>(map.keySet());
|
return CommandBase.getListOfStringsMatchingLastWord(args, map.keySet().toArray(new String[map.size()]));
|
||||||
CommandKamkeelBase command = getCommand(args);
|
CommandKamkeelBase command = getCommand(args);
|
||||||
if(command == null)
|
if(command == null)
|
||||||
return null;
|
return null;
|
||||||
if(args.length == 2 && command.runSubCommands())
|
if(args.length == 2 && command.runSubCommands())
|
||||||
return new ArrayList<String>(command.subcommands.keySet());
|
return CommandBase.getListOfStringsMatchingLastWord(args, command.subcommands.keySet().toArray(new String[command.subcommands.keySet().size()]));
|
||||||
|
String[] useArgs = command.getUsage().split(" ");
|
||||||
|
if(command.runSubCommands()) {
|
||||||
|
Method m = command.subcommands.get(args[1].toLowerCase());
|
||||||
|
if(m != null) {
|
||||||
|
useArgs = m.getAnnotation(CommandKamkeelBase.SubCommand.class).usage().split(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(args.length <= useArgs.length + 2) {
|
||||||
|
if(args.length - 3 >= 0){
|
||||||
|
String usage = useArgs[args.length - 3];
|
||||||
|
if(usage.equals("<player>") || usage.equals("[player]")) {
|
||||||
|
return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return command.addTabCompletionOptions(sender, Arrays.copyOfRange(args, 1, args.length));
|
return command.addTabCompletionOptions(sender, Arrays.copyOfRange(args, 1, args.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,14 @@ public abstract class CommandKamkeelBase extends CommandBase{
|
|||||||
sender.addChatMessage(new ChatComponentTranslation(message, obs));
|
sender.addChatMessage(new ChatComponentTranslation(message, obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void sendResult(ICommandSender sender, String message, Object... obs) {
|
||||||
|
sender.addChatMessage(new ChatComponentTranslation("\u00A76[\u00A7eCNPC+\u00A76]\u00A77 " + message, obs));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void sendError(ICommandSender sender, String message, Object... obs) {
|
||||||
|
sender.addChatMessage(new ChatComponentTranslation("\u00A76[\u00A7eCNPC+\u00A76]\u00A74 Error:\u00A7c " + message, obs));
|
||||||
|
}
|
||||||
|
|
||||||
@Retention(value = RetentionPolicy.RUNTIME)
|
@Retention(value = RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
public @interface SubCommand {
|
public @interface SubCommand {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
)
|
)
|
||||||
public void leavesdecay(ICommandSender sender, String[] args){
|
public void leavesdecay(ICommandSender sender, String[] args){
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
sendMessage(sender, "LeavesDecay: " + ConfigMain.LeavesDecayEnabled);
|
sendResult(sender, "LeavesDecay: \u00A7c" + ConfigMain.LeavesDecayEnabled);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ConfigMain.LeavesDecayEnabled = Boolean.parseBoolean(args[0]);
|
ConfigMain.LeavesDecayEnabled = Boolean.parseBoolean(args[0]);
|
||||||
@@ -52,7 +52,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
block.setTickRandomly(ConfigMain.LeavesDecayEnabled);
|
block.setTickRandomly(ConfigMain.LeavesDecayEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendMessage(sender, "LeavesDecay is now " + ConfigMain.LeavesDecayEnabled);
|
sendResult(sender, "LeavesDecay is now \u00A7c" + ConfigMain.LeavesDecayEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
)
|
)
|
||||||
public void vinegrowth(ICommandSender sender, String[] args){
|
public void vinegrowth(ICommandSender sender, String[] args){
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
sendMessage(sender, "VineGrowth: " + ConfigMain.VineGrowthEnabled);
|
sendResult(sender, "VineGrowth: \u00A7c" + ConfigMain.VineGrowthEnabled);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ConfigMain.VineGrowthEnabled = Boolean.parseBoolean(args[0]);
|
ConfigMain.VineGrowthEnabled = Boolean.parseBoolean(args[0]);
|
||||||
@@ -78,7 +78,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
block.setTickRandomly(ConfigMain.VineGrowthEnabled);
|
block.setTickRandomly(ConfigMain.VineGrowthEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendMessage(sender, "VineGrowth is now " + ConfigMain.VineGrowthEnabled);
|
sendResult(sender, "VineGrowth is now \u00A7c" + ConfigMain.VineGrowthEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
)
|
)
|
||||||
public void icemelts(ICommandSender sender, String[] args){
|
public void icemelts(ICommandSender sender, String[] args){
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
sendMessage(sender, "IceMelts: " + ConfigMain.IceMeltsEnabled);
|
sendResult(sender, "IceMelts: \u00A7c" + ConfigMain.IceMeltsEnabled);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ConfigMain.IceMeltsEnabled = Boolean.parseBoolean(args[0]);
|
ConfigMain.IceMeltsEnabled = Boolean.parseBoolean(args[0]);
|
||||||
@@ -104,7 +104,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
block.setTickRandomly(ConfigMain.IceMeltsEnabled);
|
block.setTickRandomly(ConfigMain.IceMeltsEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendMessage(sender, "IceMelts is now " + ConfigMain.IceMeltsEnabled);
|
sendResult(sender, "IceMelts is now \u00A7c" + ConfigMain.IceMeltsEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
)
|
)
|
||||||
public void guns(ICommandSender sender, String[] args){
|
public void guns(ICommandSender sender, String[] args){
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
sendMessage(sender, "GunsEnabled: " + ConfigMain.GunsEnabled);
|
sendResult(sender, "GunsEnabled: \u00A7c" + ConfigMain.GunsEnabled);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ConfigMain.GunsEnabled = Boolean.parseBoolean(args[0]);
|
ConfigMain.GunsEnabled = Boolean.parseBoolean(args[0]);
|
||||||
@@ -123,7 +123,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
if(ConfigMain.config.hasChanged()){
|
if(ConfigMain.config.hasChanged()){
|
||||||
ConfigMain.config.save();
|
ConfigMain.config.save();
|
||||||
}
|
}
|
||||||
sendMessage(sender, "GunsEnabled is now " + ConfigMain.GunsEnabled);
|
sendResult(sender, "GunsEnabled is now \u00A7c" + ConfigMain.GunsEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,11 +134,11 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
)
|
)
|
||||||
public void freezenpcs(ICommandSender sender, String[] args){
|
public void freezenpcs(ICommandSender sender, String[] args){
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
sendMessage(sender, "Frozen NPCs: " + CustomNpcs.FreezeNPCs);
|
sendResult(sender, "Frozen NPCs: \u00A7c" + CustomNpcs.FreezeNPCs);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
CustomNpcs.FreezeNPCs = Boolean.parseBoolean(args[0]);
|
CustomNpcs.FreezeNPCs = Boolean.parseBoolean(args[0]);
|
||||||
sendMessage(sender, "FrozenNPCs is now " + CustomNpcs.FreezeNPCs);
|
sendResult(sender, "FrozenNPCs is now \u00A7c" + CustomNpcs.FreezeNPCs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,14 +149,15 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
)
|
)
|
||||||
public void chunkloaders(ICommandSender sender, String[] args) throws CommandException{
|
public void chunkloaders(ICommandSender sender, String[] args) throws CommandException{
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
sendMessage(sender, "ChunkLoaders: " + ChunkController.instance.size() + "/" + ConfigMain.ChunkLoaders);
|
sendResult(sender, "ChunkLoaders: \u00A7c" + ChunkController.instance.size() + "\u00A77/\u00A7c" + ConfigMain.ChunkLoaders);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
try{
|
try{
|
||||||
ConfigMain.ChunkLoaders = Integer.parseInt(args[0]);
|
ConfigMain.ChunkLoaders = Integer.parseInt(args[0]);
|
||||||
}
|
}
|
||||||
catch(NumberFormatException ex){
|
catch(NumberFormatException ex){
|
||||||
throw new CommandException("Did not get a number: " + args[0]);
|
sendError(sender, "Did not get a number: " + args[0]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
ConfigMain.ChunkLoadersProperty.set(ConfigMain.ChunkLoaders);
|
ConfigMain.ChunkLoadersProperty.set(ConfigMain.ChunkLoaders);
|
||||||
if(ConfigMain.config.hasChanged()){
|
if(ConfigMain.config.hasChanged()){
|
||||||
@@ -166,9 +167,9 @@ public class ConfigCommand extends CommandKamkeelBase {
|
|||||||
int size = ChunkController.instance.size();
|
int size = ChunkController.instance.size();
|
||||||
if(size > ConfigMain.ChunkLoaders){
|
if(size > ConfigMain.ChunkLoaders){
|
||||||
ChunkController.instance.unload(size - ConfigMain.ChunkLoaders);
|
ChunkController.instance.unload(size - ConfigMain.ChunkLoaders);
|
||||||
sendMessage(sender, size - ConfigMain.ChunkLoaders + " chunksloaders unloaded");
|
sendResult(sender, size - ConfigMain.ChunkLoaders + " chunksloaders unloaded");
|
||||||
}
|
}
|
||||||
sendMessage(sender, "ChunkLoaders: " + ChunkController.instance.size() + "/" + ConfigMain.ChunkLoaders);
|
sendResult(sender, "ChunkLoaders: \u00A7c" + ChunkController.instance.size() + "\u00A77/\u00A7c" + ConfigMain.ChunkLoaders);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,15 +38,18 @@ public class DialogCommand extends CommandKamkeelBase {
|
|||||||
try {
|
try {
|
||||||
diagid = Integer.parseInt(args[1]);
|
diagid = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("DialogID must be an integer: " + args[1]);
|
sendError(sender, "DialogID must be an integer: " + args[1]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
throw new CommandException("Unknown player: " + playername);
|
sendError(sender, "Unknown player: " + playername);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.dialogData.dialogsRead.add(diagid);
|
playerdata.dialogData.dialogsRead.add(diagid);
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.savePlayerDataOnFile();
|
||||||
|
sendResult(sender, String.format("Forced Read for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,15 +63,18 @@ public class DialogCommand extends CommandKamkeelBase {
|
|||||||
try {
|
try {
|
||||||
diagid = Integer.parseInt(args[1]);
|
diagid = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("DialogID must be an integer: " + args[1]);
|
sendError(sender, "DialogID must be an integer: " + args[1]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
throw new CommandException("Unknown player: " + playername);
|
sendError(sender, "Unknown player: " + playername);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.dialogData.dialogsRead.remove(diagid);
|
playerdata.dialogData.dialogsRead.remove(diagid);
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.savePlayerDataOnFile();
|
||||||
|
sendResult(sender, String.format("Forced Unread for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@SubCommand(
|
@SubCommand(
|
||||||
@@ -77,6 +83,7 @@ public class DialogCommand extends CommandKamkeelBase {
|
|||||||
)
|
)
|
||||||
public void reload(ICommandSender sender, String args[]){
|
public void reload(ICommandSender sender, String args[]){
|
||||||
new DialogController();
|
new DialogController();
|
||||||
|
sendResult(sender, "Dialogs Reloaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubCommand(
|
@SubCommand(
|
||||||
@@ -86,18 +93,21 @@ public class DialogCommand extends CommandKamkeelBase {
|
|||||||
public void show(ICommandSender sender, String args[]) throws CommandException{
|
public void show(ICommandSender sender, String args[]) throws CommandException{
|
||||||
EntityPlayer player = CommandBase.getPlayer(sender, args[0]);
|
EntityPlayer player = CommandBase.getPlayer(sender, args[0]);
|
||||||
if(player == null){
|
if(player == null){
|
||||||
throw new CommandException("Unknown player: " + args[0]);
|
sendError(sender, "Unknown player: " + args[0]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int diagid;
|
int diagid;
|
||||||
try {
|
try {
|
||||||
diagid = Integer.parseInt(args[1]);
|
diagid = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("DialogID must be an integer: " + args[1]);
|
sendError(sender, "DialogID must be an integer: " + args[1]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
Dialog dialog = DialogController.instance.dialogs.get(diagid);
|
Dialog dialog = DialogController.instance.dialogs.get(diagid);
|
||||||
if(dialog == null){
|
if(dialog == null){
|
||||||
throw new CommandException("Unknown dialog id: " + args[1]);
|
sendError(sender, "Unknown dialog id: " + args[1]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityDialogNpc npc = new EntityDialogNpc(sender.getEntityWorld());
|
EntityDialogNpc npc = new EntityDialogNpc(sender.getEntityWorld());
|
||||||
@@ -108,5 +118,6 @@ public class DialogCommand extends CommandKamkeelBase {
|
|||||||
option.title = dialog.title;
|
option.title = dialog.title;
|
||||||
npc.dialogs.put(0, option);
|
npc.dialogs.put(0, option);
|
||||||
NoppesUtilServer.openDialog(player, npc, dialog, 0);
|
NoppesUtilServer.openDialog(player, npc, dialog, 0);
|
||||||
|
sendResult(sender, String.format("Displayed Dialog \u00A7e%d\u00A77 to Player '\u00A7b%s\u00A77'", diagid, player.getCommandSenderName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,8 @@ public class FactionCommand extends CommandKamkeelBase {
|
|||||||
|
|
||||||
data = PlayerDataController.instance.getPlayersData(sender, playername);
|
data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
throw new CommandException("Unknown player: " + playername);
|
sendError(sender, "Unknown player: " + playername);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
@@ -56,7 +57,8 @@ public class FactionCommand extends CommandKamkeelBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (selectedFaction == null) {
|
if (selectedFaction == null) {
|
||||||
throw new CommandException("Unknown faction: " + factionname);
|
sendError(sender, "Unknown faction: " + factionname);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
processSubCommand(sender, args[2], Arrays.copyOfRange(args, 3, args.length));
|
processSubCommand(sender, args[2], Arrays.copyOfRange(args, 3, args.length));
|
||||||
@@ -75,13 +77,15 @@ public class FactionCommand extends CommandKamkeelBase {
|
|||||||
try {
|
try {
|
||||||
points = Integer.parseInt(args[0]);
|
points = Integer.parseInt(args[0]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("Must be an integer: " + args[0]);
|
sendError(sender, "Must be an integer: " + args[0]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
int factionid = this.selectedFaction.id;
|
int factionid = this.selectedFaction.id;
|
||||||
|
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||||
playerfactiondata.increasePoints(factionid, points, playerdata.player);
|
playerfactiondata.increasePoints(factionid, points, playerdata.player);
|
||||||
|
sendResult(sender, String.format("Added Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,12 +98,14 @@ public class FactionCommand extends CommandKamkeelBase {
|
|||||||
try {
|
try {
|
||||||
points = Integer.parseInt(args[0]);
|
points = Integer.parseInt(args[0]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("Must be an integer: " + args[0]);
|
sendError(sender, "Must be an integer: " + args[0]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
int factionid = this.selectedFaction.id;
|
int factionid = this.selectedFaction.id;
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||||
playerfactiondata.increasePoints(factionid, -points, playerdata.player);
|
playerfactiondata.increasePoints(factionid, -points, playerdata.player);
|
||||||
|
sendResult(sender, String.format("Subtracted Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,6 +113,7 @@ public class FactionCommand extends CommandKamkeelBase {
|
|||||||
public void reset(ICommandSender sender, String[] args) {
|
public void reset(ICommandSender sender, String[] args) {
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.factionData.factionData.put(this.selectedFaction.id, this.selectedFaction.defaultPoints);
|
playerdata.factionData.factionData.put(this.selectedFaction.id, this.selectedFaction.defaultPoints);
|
||||||
|
sendResult(sender, String.format("Reset Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,11 +126,13 @@ public class FactionCommand extends CommandKamkeelBase {
|
|||||||
try {
|
try {
|
||||||
points = Integer.parseInt(args[0]);
|
points = Integer.parseInt(args[0]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("Must be an integer: " + args[0]);
|
sendError(sender, "Must be an integer: " + args[0]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||||
playerfactiondata.factionData.put(this.selectedFaction.id,points);
|
playerfactiondata.factionData.put(this.selectedFaction.id, points);
|
||||||
|
sendResult(sender, String.format("Set Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,6 +140,7 @@ public class FactionCommand extends CommandKamkeelBase {
|
|||||||
public void drop(ICommandSender sender, String[] args){
|
public void drop(ICommandSender sender, String[] args){
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.factionData.factionData.remove(this.selectedFaction.id);
|
playerdata.factionData.factionData.remove(this.selectedFaction.id);
|
||||||
|
sendResult(sender, String.format("Dropped Faction \u00A7e%s (%d)\u00A77 from Player \u00A7b%s\u00A77", this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,10 @@ public class HelpCommand extends CommandKamkeelBase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
CommandKamkeelBase command = parent.getCommand(args);
|
CommandKamkeelBase command = parent.getCommand(args);
|
||||||
if(command == null)
|
if(command == null){
|
||||||
throw new CommandException("Unknown command " + args[0]);
|
sendError(sender, "Unknown command " + args[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(command.subcommands.isEmpty()){
|
if(command.subcommands.isEmpty()){
|
||||||
sender.addChatMessage(new ChatComponentTranslation(command.getCommandUsage(sender)));
|
sender.addChatMessage(new ChatComponentTranslation(command.getCommandUsage(sender)));
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import org.apache.commons.lang3.ArrayUtils;
|
|||||||
|
|
||||||
public class NpcCommand extends CommandKamkeelBase {
|
public class NpcCommand extends CommandKamkeelBase {
|
||||||
|
|
||||||
public EntityNPCInterface selectedNpc;
|
public EntityNPCInterface selectedNpc;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -49,39 +49,40 @@ public class NpcCommand extends CommandKamkeelBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||||
String npcname = args[0].replace("%", " ");
|
String npcname = args[0].replace("%", " ");
|
||||||
String command = args[1];
|
String command = args[1];
|
||||||
args = Arrays.copyOfRange(args, 2, args.length);
|
args = Arrays.copyOfRange(args, 2, args.length);
|
||||||
if(command.equalsIgnoreCase("create")){
|
if(command.equalsIgnoreCase("create")){
|
||||||
args = ArrayUtils.add(args, 0, npcname);
|
args = ArrayUtils.add(args, 0, npcname);
|
||||||
processSubCommand(sender, command, args);
|
processSubCommand(sender, command, args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = sender.getPlayerCoordinates().posX;
|
int x = sender.getPlayerCoordinates().posX;
|
||||||
int y = sender.getPlayerCoordinates().posY;
|
int y = sender.getPlayerCoordinates().posY;
|
||||||
int z = sender.getPlayerCoordinates().posZ;
|
int z = sender.getPlayerCoordinates().posZ;
|
||||||
List<EntityNPCInterface> list = getEntities(EntityNPCInterface.class, sender.getEntityWorld(), x, y, z, 80);
|
List<EntityNPCInterface> list = getEntities(EntityNPCInterface.class, sender.getEntityWorld(), x, y, z, 80);
|
||||||
for (EntityNPCInterface npc : list) {
|
for (EntityNPCInterface npc : list) {
|
||||||
String name = npc.display.getName().replace(" ", "_");
|
String name = npc.display.getName().replace(" ", "_");
|
||||||
if (name.equalsIgnoreCase(npcname)){
|
if (name.equalsIgnoreCase(npcname)){
|
||||||
if(selectedNpc == null || selectedNpc.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
|
if(selectedNpc == null || selectedNpc.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
|
||||||
selectedNpc = npc;
|
selectedNpc = npc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(selectedNpc == null)
|
if(selectedNpc == null){
|
||||||
throw new CommandException("Npc " + npcname + " was not found");
|
sendError(sender, "Npc " + npcname + " was not found");
|
||||||
|
return;
|
||||||
processSubCommand(sender, command, args);
|
}
|
||||||
selectedNpc = null;
|
|
||||||
|
|
||||||
|
processSubCommand(sender, command, args);
|
||||||
|
selectedNpc = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubCommand(
|
@SubCommand(
|
||||||
desc = "Set Home (respawn place)",
|
desc = "Set Home (respawn place)",
|
||||||
usage = "[x] [y] [z]"
|
usage = "[x] [y] [z]"
|
||||||
)
|
)
|
||||||
public void home(ICommandSender sender, String[] args) {
|
public void home(ICommandSender sender, String[] args) {
|
||||||
double posX = sender.getPlayerCoordinates().posX;
|
double posX = sender.getPlayerCoordinates().posX;
|
||||||
double posY = sender.getPlayerCoordinates().posY;
|
double posY = sender.getPlayerCoordinates().posY;
|
||||||
double posZ = sender.getPlayerCoordinates().posZ;
|
double posZ = sender.getPlayerCoordinates().posZ;
|
||||||
@@ -93,13 +94,14 @@ public class NpcCommand extends CommandKamkeelBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectedNpc.ai.startPos = new int[]{MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)};
|
selectedNpc.ai.startPos = new int[]{MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)};
|
||||||
}
|
sendResult(sender, String.format("Set NPC \u00A7e%s\u00A77 Home to \u00A7b[%.1f] [%.1f] [%.1f]\u00A77", selectedNpc.display.name, posX, posY, posZ));
|
||||||
|
}
|
||||||
|
|
||||||
@SubCommand(
|
@SubCommand(
|
||||||
desc = "Set NPC visibility",
|
desc = "Set NPC visibility",
|
||||||
usage = "[true/false/semi]"
|
usage = "[true/false/semi]"
|
||||||
)
|
)
|
||||||
public void visible(ICommandSender sender, String[] args){
|
public void visible(ICommandSender sender, String[] args){
|
||||||
if(args.length < 1)
|
if(args.length < 1)
|
||||||
return;
|
return;
|
||||||
boolean bo = args[0].equalsIgnoreCase("true");
|
boolean bo = args[0].equalsIgnoreCase("true");
|
||||||
@@ -113,74 +115,84 @@ public class NpcCommand extends CommandKamkeelBase {
|
|||||||
else
|
else
|
||||||
selectedNpc.display.visible = 1;
|
selectedNpc.display.visible = 1;
|
||||||
|
|
||||||
|
String[] list = new String[]{"True", "False", "Semi"};
|
||||||
|
|
||||||
if(current != selectedNpc.display.visible)
|
if(current != selectedNpc.display.visible)
|
||||||
selectedNpc.updateClient = true;
|
selectedNpc.updateClient = true;
|
||||||
|
|
||||||
|
sendResult(sender, String.format("Set NPC \u00A7e%s\u00A77 Visibility to \u00A7b%s\u00A77", selectedNpc.display.name, list[selectedNpc.display.visible]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubCommand(desc = "Delete an NPC")
|
@SubCommand(desc = "Delete an NPC")
|
||||||
public void delete(ICommandSender sender, String[] args){
|
public void delete(ICommandSender sender, String[] args){
|
||||||
selectedNpc.delete();
|
selectedNpc.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubCommand(
|
@SubCommand(
|
||||||
desc = "Sets the owner of an follower/companion",
|
desc = "Sets the owner of an follower/companion",
|
||||||
usage = "[player]"
|
usage = "[player]"
|
||||||
)
|
)
|
||||||
public void owner(ICommandSender sender, String[] args){
|
public void owner(ICommandSender sender, String[] args){
|
||||||
if(args.length < 1){
|
if(args.length < 1){
|
||||||
EntityPlayer player = null;
|
EntityPlayer player = null;
|
||||||
if(selectedNpc.roleInterface instanceof RoleFollower)
|
if(selectedNpc.roleInterface instanceof RoleFollower)
|
||||||
player = ((RoleFollower)selectedNpc.roleInterface).owner;
|
player = ((RoleFollower)selectedNpc.roleInterface).owner;
|
||||||
|
|
||||||
if(selectedNpc.roleInterface instanceof RoleCompanion)
|
if(selectedNpc.roleInterface instanceof RoleCompanion)
|
||||||
player = ((RoleCompanion)selectedNpc.roleInterface).owner;
|
player = ((RoleCompanion)selectedNpc.roleInterface).owner;
|
||||||
|
|
||||||
if(player == null)
|
if(player == null)
|
||||||
sendMessage(sender, "No owner");
|
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, "NULL"));
|
||||||
else
|
else
|
||||||
sendMessage(sender, "Owner is: " + player.getDisplayName());
|
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, player.getDisplayName()));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
EntityPlayerMP player = null;
|
EntityPlayerMP player = null;
|
||||||
try {
|
try {
|
||||||
player = CommandBase.getPlayer(sender, args[0]);
|
player = CommandBase.getPlayer(sender, args[0]);
|
||||||
} catch (PlayerNotFoundException e) {
|
} catch (PlayerNotFoundException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
if(selectedNpc.roleInterface instanceof RoleFollower)
|
if(selectedNpc.roleInterface instanceof RoleFollower)
|
||||||
((RoleFollower)selectedNpc.roleInterface).setOwner(player);
|
((RoleFollower)selectedNpc.roleInterface).setOwner(player);
|
||||||
|
|
||||||
if(selectedNpc.roleInterface instanceof RoleCompanion)
|
if(selectedNpc.roleInterface instanceof RoleCompanion)
|
||||||
((RoleCompanion)selectedNpc.roleInterface).setOwner(player);
|
((RoleCompanion)selectedNpc.roleInterface).setOwner(player);
|
||||||
}
|
|
||||||
}
|
if(player == null)
|
||||||
|
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, "NULL"));
|
||||||
|
else
|
||||||
|
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, player.getDisplayName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@SubCommand(
|
@SubCommand(
|
||||||
desc = "Set NPC name",
|
desc = "Set NPC name",
|
||||||
usage = "[name]"
|
usage = "[name]"
|
||||||
)
|
)
|
||||||
public void name(ICommandSender sender, String[] args){
|
public void name(ICommandSender sender, String[] args){
|
||||||
if(args.length < 1)
|
if(args.length < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String name = args[0];
|
String name = args[0];
|
||||||
for(int i = 1; i < args.length; i++){
|
for(int i = 1; i < args.length; i++){
|
||||||
name += " " + args[i];
|
name += " " + args[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!selectedNpc.display.getName().equals(name)){
|
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Name set to \u00A7b%s\u00A77", selectedNpc.display.name, name));
|
||||||
selectedNpc.display.setName(name);
|
|
||||||
|
if(!selectedNpc.display.getName().equals(name)){
|
||||||
|
selectedNpc.display.setName(name);
|
||||||
selectedNpc.updateClient = true;
|
selectedNpc.updateClient = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubCommand(
|
@SubCommand(
|
||||||
desc = "Creates an NPC",
|
desc = "Creates an NPC",
|
||||||
usage = "[name]"
|
usage = "[name]"
|
||||||
)
|
)
|
||||||
public void create(ICommandSender sender, String[] args) {
|
public void create(ICommandSender sender, String[] args) {
|
||||||
EntityPlayerMP player = (EntityPlayerMP) sender;
|
EntityPlayerMP player = (EntityPlayerMP) sender;
|
||||||
World pw = player.getEntityWorld();
|
World pw = player.getEntityWorld();
|
||||||
EntityCustomNpc npc = new EntityCustomNpc(pw);
|
EntityCustomNpc npc = new EntityCustomNpc(pw);
|
||||||
@@ -191,10 +203,9 @@ public class NpcCommand extends CommandKamkeelBase {
|
|||||||
pw.spawnEntityInWorld(npc);
|
pw.spawnEntityInWorld(npc);
|
||||||
npc.setHealth(npc.getMaxHealth());
|
npc.setHealth(npc.getMaxHealth());
|
||||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, npc);
|
NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Override
|
|
||||||
public List addTabCompletionOptions(ICommandSender par1, String[] args) {
|
public List addTabCompletionOptions(ICommandSender par1, String[] args) {
|
||||||
if(args.length == 2){
|
if(args.length == 2){
|
||||||
return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"create", "home", "visible", "delete", "owner", "name"});
|
return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"create", "home", "visible", "delete", "owner", "name"});
|
||||||
@@ -204,14 +215,14 @@ public class NpcCommand extends CommandKamkeelBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRequiredPermissionLevel(){
|
public int getRequiredPermissionLevel(){
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends Entity> List<T> getEntities(Class<? extends T> cls, World world, int x, int y, int z, int range) {
|
public <T extends Entity> List<T> getEntities(Class<? extends T> cls, World world, int x, int y, int z, int range) {
|
||||||
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(range, range, range);
|
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(range, range, range);
|
||||||
List<T> list = world.getEntitiesWithinAABB(cls, bb);
|
List<T> list = world.getEntitiesWithinAABB(cls, bb);
|
||||||
return list;
|
return list;
|
||||||
|
|||||||
@@ -36,26 +36,32 @@ public class QuestCommand extends CommandKamkeelBase {
|
|||||||
try {
|
try {
|
||||||
questid = Integer.parseInt(args[1]);
|
questid = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("QuestID must be an integer: " + args[1]);
|
sendError(sender, "QuestID must be an integer: " + args[1]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||||
|
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
throw new CommandException("Unknown player: " + playername);
|
sendError(sender, "Unknown player: " + playername);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Quest quest = QuestController.instance.quests.get(questid);
|
Quest quest = QuestController.instance.quests.get(questid);
|
||||||
if (quest == null){
|
if (quest == null){
|
||||||
throw new CommandException("Unknown QuestID: " + questid);
|
sendError(sender, "Unknown QuestID: " + questid);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
QuestData questdata = new QuestData(quest);
|
QuestData questdata = new QuestData(quest);
|
||||||
playerdata.questData.activeQuests.put(questid, questdata);
|
playerdata.questData.activeQuests.put(questid, questdata);
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.savePlayerDataOnFile();
|
||||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
|
if(playerdata.player != null){
|
||||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
|
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
|
||||||
|
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
|
||||||
|
}
|
||||||
|
sendResult(sender, String.format("Started Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,21 +76,33 @@ public class QuestCommand extends CommandKamkeelBase {
|
|||||||
questid = Integer.parseInt(args[1]);
|
questid = Integer.parseInt(args[1]);
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex) {
|
catch (NumberFormatException ex) {
|
||||||
throw new CommandException("QuestID must be an integer: " + args[1]);
|
sendError(sender, "QuestID must be an integer: " + args[1]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
throw new CommandException(String.format("Unknow player '%s'", playername));
|
sendError(sender, String.format("Unknown player '%s'", playername));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Quest quest = QuestController.instance.quests.get(questid);
|
Quest quest = QuestController.instance.quests.get(questid);
|
||||||
if (quest == null){
|
if (quest == null){
|
||||||
throw new CommandException("Unknown QuestID: " + questid);
|
sendError(sender, "Unknown QuestID: " + questid);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
|
if(playerdata.questData.activeQuests.containsKey(questid)){
|
||||||
|
playerdata.questData.activeQuests.remove(questid);
|
||||||
|
}
|
||||||
|
|
||||||
playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis());
|
playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis());
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.savePlayerDataOnFile();
|
||||||
|
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 +116,23 @@ public class QuestCommand extends CommandKamkeelBase {
|
|||||||
try {
|
try {
|
||||||
questid = Integer.parseInt(args[1]);
|
questid = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("QuestID must be an integer: " + args[1]);
|
sendError(sender, "QuestID must be an integer: " + args[1]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
throw new CommandException(String.format("Unknow player '%s'", playername));
|
sendError(sender, String.format("Unknown player '%s'", playername));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
Quest quest = QuestController.instance.quests.get(questid);
|
Quest quest = QuestController.instance.quests.get(questid);
|
||||||
if (quest == null){
|
if (quest == null){
|
||||||
throw new CommandException("Unknown QuestID: " + questid);
|
sendError(sender, "Unknown QuestID: " + questid);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.questData.activeQuests.remove(questid);
|
playerdata.questData.activeQuests.remove(questid);
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.savePlayerDataOnFile();
|
||||||
|
sendResult(sender, String.format("Stopped Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,23 +146,27 @@ public class QuestCommand extends CommandKamkeelBase {
|
|||||||
try {
|
try {
|
||||||
questid = Integer.parseInt(args[1]);
|
questid = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new CommandException("QuestID must be an integer: " + args[1]);
|
sendError(sender, "QuestID must be an integer: " + args[1]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
throw new CommandException(String.format("Unknown player '%s'", playername));
|
sendError(sender, String.format("Unknown player '%s'", playername));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Quest quest = QuestController.instance.quests.get(questid);
|
Quest quest = QuestController.instance.quests.get(questid);
|
||||||
if (quest == null){
|
if (quest == null){
|
||||||
throw new CommandException(String.format("Unknown QuestID"));
|
sendError(sender, String.format("Unknown QuestID"));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
playerdata.questData.activeQuests.remove(questid);
|
playerdata.questData.activeQuests.remove(questid);
|
||||||
playerdata.questData.finishedQuests.remove(questid);
|
playerdata.questData.finishedQuests.remove(questid);
|
||||||
playerdata.savePlayerDataOnFile();
|
playerdata.savePlayerDataOnFile();
|
||||||
|
sendResult(sender, String.format("Removed Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +175,9 @@ public class QuestCommand extends CommandKamkeelBase {
|
|||||||
permission = 4
|
permission = 4
|
||||||
)
|
)
|
||||||
public void reload(ICommandSender sender, String args[]){
|
public void reload(ICommandSender sender, String args[]){
|
||||||
new DialogController();
|
new QuestController();
|
||||||
|
QuestController.instance.load();
|
||||||
|
sendResult(sender, "Quests Reloaded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11,19 +11,19 @@ public class ScriptCommand extends CommandKamkeelBase {
|
|||||||
ScriptController.Instance.loadCategories();
|
ScriptController.Instance.loadCategories();
|
||||||
|
|
||||||
if(ScriptController.Instance.loadPlayerScripts())
|
if(ScriptController.Instance.loadPlayerScripts())
|
||||||
sendMessage(sender, "Reload player scripts successfully");
|
sendResult(sender, "Reload player scripts successfully");
|
||||||
else
|
else
|
||||||
sendMessage(sender, "Failed reloading player scripts");
|
sendError(sender, "Failed reloading player scripts");
|
||||||
|
|
||||||
if(ScriptController.Instance.loadForgeScripts())
|
if(ScriptController.Instance.loadForgeScripts())
|
||||||
sendMessage(sender, "Reload forge scripts successfully");
|
sendResult(sender, "Reload forge scripts successfully");
|
||||||
else
|
else
|
||||||
sendMessage(sender, "Failed reloading forge scripts");
|
sendError(sender, "Failed reloading forge scripts");
|
||||||
|
|
||||||
if(ScriptController.Instance.loadStoredData())
|
if(ScriptController.Instance.loadStoredData())
|
||||||
sendMessage(sender, "Reload stored data successfully");
|
sendResult(sender, "Reload stored data successfully");
|
||||||
else
|
else
|
||||||
sendMessage(sender, "Failed reloading stored data");
|
sendError(sender, "Failed reloading stored data");
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public class SlayCommand extends CommandKamkeelBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.addChatMessage(new ChatComponentTranslation(count + " entities deleted"));
|
sendResult(sender, count + " entities deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean delete(Entity entity, ArrayList<Class<?>> toDelete) {
|
private boolean delete(Entity entity, ArrayList<Class<?>> toDelete) {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.8")
|
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.8.1")
|
||||||
public class CustomNpcs {
|
public class CustomNpcs {
|
||||||
|
|
||||||
@SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy")
|
@SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy")
|
||||||
|
|||||||
@@ -549,7 +549,7 @@ public class EventHooks {
|
|||||||
handler.callScript(EnumScriptType.CNPC_NATURAL_SPAWN, event);
|
handler.callScript(EnumScriptType.CNPC_NATURAL_SPAWN, event);
|
||||||
return NpcAPI.EVENT_BUS.post(event);
|
return NpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onCustomGuiButton(IPlayer player, ICustomGui gui, int buttonId) {
|
public static void onCustomGuiButton(IPlayer player, ICustomGui gui, int buttonId) {
|
||||||
|
|||||||
@@ -475,6 +475,7 @@ public class NoppesUtilServer {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PlayerDataController.instance.nameUUIDs.remove(name);
|
PlayerDataController.instance.nameUUIDs.remove(name);
|
||||||
|
PlayerDataController.instance.savePlayerDataMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(type == EnumPlayerData.Quest){
|
if(type == EnumPlayerData.Quest){
|
||||||
@@ -507,6 +508,10 @@ public class NoppesUtilServer {
|
|||||||
sendPlayerData(type, player, name);
|
sendPlayerData(type, player, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void regenPlayerData(EntityPlayerMP player) throws IOException {
|
||||||
|
PlayerDataController.instance.generatePlayerMap(player);
|
||||||
|
}
|
||||||
|
|
||||||
public static void sendRecipeData(EntityPlayerMP player, int size) {
|
public static void sendRecipeData(EntityPlayerMP player, int size) {
|
||||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||||
if(size == 3){
|
if(size == 3){
|
||||||
|
|||||||
@@ -794,6 +794,9 @@ public class PacketHandlerServer{
|
|||||||
else if(type == EnumPacketServer.PlayerDataRemove){
|
else if(type == EnumPacketServer.PlayerDataRemove){
|
||||||
NoppesUtilServer.removePlayerData(buffer,player);
|
NoppesUtilServer.removePlayerData(buffer,player);
|
||||||
}
|
}
|
||||||
|
else if(type == EnumPacketServer.PlayerDataRegen){
|
||||||
|
NoppesUtilServer.regenPlayerData(player);
|
||||||
|
}
|
||||||
else if(type == EnumPacketServer.MainmenuDisplayGet){
|
else if(type == EnumPacketServer.MainmenuDisplayGet){
|
||||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.display.writeToNBT(new NBTTagCompound()));
|
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.display.writeToNBT(new NBTTagCompound()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package noppes.npcs.client.gui.global;
|
package noppes.npcs.client.gui.global;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiYesNo;
|
||||||
|
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import noppes.npcs.client.Client;
|
import noppes.npcs.client.Client;
|
||||||
|
import noppes.npcs.client.NoppesUtil;
|
||||||
|
import noppes.npcs.client.controllers.ClientCloneController;
|
||||||
import noppes.npcs.client.gui.util.*;
|
import noppes.npcs.client.gui.util.*;
|
||||||
import noppes.npcs.constants.EnumPacketServer;
|
import noppes.npcs.constants.EnumPacketServer;
|
||||||
import noppes.npcs.constants.EnumPlayerData;
|
import noppes.npcs.constants.EnumPlayerData;
|
||||||
@@ -12,7 +17,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements IScrollData,ICustomScrollListener
|
public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements IScrollData,ICustomScrollListener,GuiYesNoCallback
|
||||||
{
|
{
|
||||||
private GuiCustomScroll scroll;
|
private GuiCustomScroll scroll;
|
||||||
private String selectedPlayer = null;
|
private String selectedPlayer = null;
|
||||||
@@ -46,6 +51,8 @@ public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements IScrollD
|
|||||||
this.addButton(new GuiNpcButton(5, guiLeft + 200, guiTop + 120,98, 20, "Bank Data"));
|
this.addButton(new GuiNpcButton(5, guiLeft + 200, guiTop + 120,98, 20, "Bank Data"));
|
||||||
this.addButton(new GuiNpcButton(6, guiLeft + 200, guiTop + 142,98, 20, "Faction Data"));
|
this.addButton(new GuiNpcButton(6, guiLeft + 200, guiTop + 142,98, 20, "Faction Data"));
|
||||||
|
|
||||||
|
this.addButton(new GuiNpcButton(7, guiLeft + 200, guiTop + 193,98, 20, "Regen PlayerMap"));
|
||||||
|
|
||||||
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 4, guiTop + 193, 190, 20, search));
|
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 4, guiTop + 193, 190, 20, search));
|
||||||
getTextField(0).enabled = selection == EnumPlayerData.Players;
|
getTextField(0).enabled = selection == EnumPlayerData.Players;
|
||||||
|
|
||||||
@@ -126,6 +133,9 @@ public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements IScrollD
|
|||||||
Client.sendData(EnumPacketServer.PlayerDataGet, selection, selectedPlayer);
|
Client.sendData(EnumPacketServer.PlayerDataGet, selection, selectedPlayer);
|
||||||
selected = null;
|
selected = null;
|
||||||
}
|
}
|
||||||
|
if(id == 7){
|
||||||
|
displayGuiScreen(new GuiYesNo(this, "Warning", "Do not operate on PlayerData as its regenerating", 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -155,5 +165,14 @@ public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements IScrollD
|
|||||||
selectedPlayer = selected;
|
selectedPlayer = selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void confirmClicked(boolean confirm, int id){
|
||||||
|
if(confirm){
|
||||||
|
Client.sendData(EnumPacketServer.PlayerDataRegen);
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
displayGuiScreen(this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
|
|||||||
|
|
||||||
y+=23;
|
y+=23;
|
||||||
addLabel(new GuiNpcLabel(11,"gui.title", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(11,"gui.title", guiLeft + 5, y + 5));
|
||||||
addTextField(new GuiNpcTextField(11,this, fontRendererObj, guiLeft + 50, y, 200, 20, display.title));
|
addTextField(new GuiNpcTextField(11,this, fontRendererObj, guiLeft + 50, y, 206, 20, display.title));
|
||||||
|
|
||||||
y+=23;
|
y+=23;
|
||||||
addLabel(new GuiNpcLabel(1,"display.model", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(1,"display.model", guiLeft + 5, y + 5));
|
||||||
|
|||||||
@@ -31,12 +31,6 @@ public class ConfigClient
|
|||||||
public static Property FontSizeProperty;
|
public static Property FontSizeProperty;
|
||||||
public static int FontSize = 18;
|
public static int FontSize = 18;
|
||||||
|
|
||||||
public static Property EntityRendererMixinProperty;
|
|
||||||
public static boolean EntityRendererMixin = true;
|
|
||||||
|
|
||||||
public static Property AnimationMixinProperty;
|
|
||||||
public static boolean AnimationMixin = true;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Questing Properties
|
* Questing Properties
|
||||||
**/
|
**/
|
||||||
@@ -70,12 +64,6 @@ public class ConfigClient
|
|||||||
FontSizeProperty = config.get(VISUAL, "Font Size", 18, "Font size for custom fonts (doesn't work with minecrafts font)");
|
FontSizeProperty = config.get(VISUAL, "Font Size", 18, "Font size for custom fonts (doesn't work with minecrafts font)");
|
||||||
FontSize = FontSizeProperty.getInt(18);
|
FontSize = FontSizeProperty.getInt(18);
|
||||||
|
|
||||||
EntityRendererMixinProperty = config.get(VISUAL, "Entity Render Mixin", true, "Enables Overlay Mixins for Conflicts relating to Optifine or other Skin Renderers. If crashes occur, please disable.");
|
|
||||||
EntityRendererMixin = EntityRendererMixinProperty.getBoolean(true);
|
|
||||||
|
|
||||||
AnimationMixinProperty = config.get(VISUAL, "Animation Mixin", true, "Enables mixins for the ModelRenderer and RenderPlayer classes, allowing for additional animation functionality in the API. If crashes or visual errors occur, please disable.");
|
|
||||||
AnimationMixin = AnimationMixinProperty.getBoolean(true);
|
|
||||||
|
|
||||||
// Questing
|
// Questing
|
||||||
TrackingInfoAlignmentProperty = config.get(QUESTING, "Tracking Info Alignment", 3, "Client sided! Determines where tracking quest info shows up on the screen based on a number from 0 to 8. Default: 3");
|
TrackingInfoAlignmentProperty = config.get(QUESTING, "Tracking Info Alignment", 3, "Client sided! Determines where tracking quest info shows up on the screen based on a number from 0 to 8. Default: 3");
|
||||||
TrackingInfoAlignment = TrackingInfoAlignmentProperty.getInt(3);
|
TrackingInfoAlignment = TrackingInfoAlignmentProperty.getInt(3);
|
||||||
@@ -100,9 +88,6 @@ public class ConfigClient
|
|||||||
FontSize = LegacyConfig.FontSize;
|
FontSize = LegacyConfig.FontSize;
|
||||||
FontSizeProperty.set(FontSize);
|
FontSizeProperty.set(FontSize);
|
||||||
|
|
||||||
EntityRendererMixin = LegacyConfig.EntityRendererMixin;
|
|
||||||
EntityRendererMixinProperty.set(EntityRendererMixin);
|
|
||||||
|
|
||||||
TrackingInfoAlignment = LegacyConfig.TrackingInfoAlignment;
|
TrackingInfoAlignment = LegacyConfig.TrackingInfoAlignment;
|
||||||
TrackingInfoAlignmentProperty.set(TrackingInfoAlignment);
|
TrackingInfoAlignmentProperty.set(TrackingInfoAlignment);
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -53,7 +53,7 @@ public enum EnumPacketServer {
|
|||||||
LinkedGetAll, LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED),
|
LinkedGetAll, LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED),
|
||||||
ScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), ScriptDataGet(true),
|
ScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), ScriptDataGet(true),
|
||||||
EventScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), EventScriptDataGet(true),
|
EventScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), EventScriptDataGet(true),
|
||||||
PlayerDataRemove(CustomNpcsPermissions.GLOBAL_PLAYERDATA),
|
PlayerDataRemove(CustomNpcsPermissions.GLOBAL_PLAYERDATA), PlayerDataRegen(CustomNpcsPermissions.GLOBAL_PLAYERDATA),
|
||||||
BankSave(CustomNpcsPermissions.GLOBAL_BANK), BanksGet, BankGet,
|
BankSave(CustomNpcsPermissions.GLOBAL_BANK), BanksGet, BankGet,
|
||||||
BankRemove(CustomNpcsPermissions.GLOBAL_BANK),
|
BankRemove(CustomNpcsPermissions.GLOBAL_BANK),
|
||||||
DialogCategorySave(CustomNpcsPermissions.GLOBAL_DIALOG), DialogCategoriesGet, DialogsGetFromDialog,
|
DialogCategorySave(CustomNpcsPermissions.GLOBAL_DIALOG), DialogCategoriesGet, DialogsGetFromDialog,
|
||||||
|
|||||||
@@ -6,50 +6,189 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.nbt.CompressedStreamTools;
|
import net.minecraft.nbt.CompressedStreamTools;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
import net.minecraft.util.IChatComponent;
|
||||||
import noppes.npcs.CustomNpcs;
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.LogWriter;
|
import noppes.npcs.LogWriter;
|
||||||
import noppes.npcs.controllers.data.Bank;
|
import noppes.npcs.controllers.data.*;
|
||||||
import noppes.npcs.controllers.data.PlayerBankData;
|
|
||||||
import noppes.npcs.controllers.data.PlayerData;
|
|
||||||
import noppes.npcs.controllers.data.PlayerMail;
|
|
||||||
import noppes.npcs.util.NBTJsonUtil;
|
import noppes.npcs.util.NBTJsonUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileInputStream;
|
import java.util.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
public class PlayerDataController {
|
public class PlayerDataController {
|
||||||
public static PlayerDataController instance;
|
public static PlayerDataController instance;
|
||||||
public Map<String, String> nameUUIDs;
|
public HashMap<String, String> nameUUIDs;
|
||||||
|
private static final Executor playerDataThread = Executors.newSingleThreadExecutor();
|
||||||
|
|
||||||
public PlayerDataController(){
|
public PlayerDataController(){
|
||||||
instance = this;
|
instance = this;
|
||||||
File dir = getSaveDir();
|
File dir = getSaveDir();
|
||||||
if(dir != null){
|
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
LogWriter.info("Loading PlayerData...");
|
||||||
if(dir.listFiles() != null){
|
// If no PlayerData MAP - Load PlayerData to create PlayerData Map
|
||||||
for(File file : dir.listFiles()){
|
if(!getPlayerDataMap()){
|
||||||
if(file.isDirectory() || !file.getName().endsWith(".json"))
|
LogWriter.info("Generating PlayerData map file...");
|
||||||
continue;
|
File[] files = dir.listFiles(); // Get an array of all files in the directory
|
||||||
try {
|
HashMap<String, String> map = new HashMap<String, String>();
|
||||||
NBTTagCompound compound = NBTJsonUtil.LoadFile(file);
|
if(files != null){
|
||||||
if(compound.hasKey("PlayerName")){
|
int length = files.length;
|
||||||
map.put(compound.getString("PlayerName"), file.getName().substring(0, file.getName().length() - 5));
|
if(length != 0){
|
||||||
|
if(length > 100){
|
||||||
|
LogWriter.info("Found " + length + " PlayerData files... This may take a few minutes");
|
||||||
|
}
|
||||||
|
int tenPercent = (int) ((double) length * 0.1);
|
||||||
|
int progress = 0;
|
||||||
|
// Load the files in parallel using a stream
|
||||||
|
for(int i = 0; i < length; i++){
|
||||||
|
File file = files[i];
|
||||||
|
if(file.isDirectory() || !file.getName().endsWith(".json"))
|
||||||
|
continue;
|
||||||
|
try {
|
||||||
|
NBTTagCompound compound = NBTJsonUtil.LoadFile(file);
|
||||||
|
if(compound.hasKey("PlayerName")){
|
||||||
|
map.put(compound.getString("PlayerName"), file.getName().substring(0, file.getName().length() - 5));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogWriter.error("Error loading: " + file.getAbsolutePath(), e);
|
||||||
|
}
|
||||||
|
if(tenPercent != 0 ){
|
||||||
|
if(progress != 100){
|
||||||
|
if (i % tenPercent == 0) {
|
||||||
|
progress += 10;
|
||||||
|
LogWriter.info("Creating PlayerMap: Progress: " + progress + "%");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
LogWriter.error("Error loading: " + file.getAbsolutePath(), e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nameUUIDs = map;
|
|
||||||
}
|
}
|
||||||
|
nameUUIDs = map;
|
||||||
|
savePlayerDataMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
LogWriter.info("Done loading PlayerData");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generatePlayerMap(EntityPlayerMP sender){
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
executor.execute(() -> {
|
||||||
|
if(sender != null){
|
||||||
|
LogWriter.info("PlayerMap regeneration queued by " + sender.getCommandSenderName());
|
||||||
|
sender.addChatMessage(new ChatComponentText("You have initiated PlayerMap regeneration"));
|
||||||
|
}
|
||||||
|
nameUUIDs.clear();
|
||||||
|
|
||||||
|
File dir = getSaveDir();
|
||||||
|
LogWriter.info("Generating PlayerData map file...");
|
||||||
|
File[] files = dir.listFiles(); // Get an array of all files in the directory
|
||||||
|
HashMap<String, String> map = new HashMap<String, String>();
|
||||||
|
if(files != null){
|
||||||
|
int length = files.length;
|
||||||
|
if(length != 0){
|
||||||
|
if(length > 100){
|
||||||
|
LogWriter.info("Found " + length + " PlayerData files... This may take a few minutes");
|
||||||
|
}
|
||||||
|
int tenPercent = (int) ((double) length * 0.1);
|
||||||
|
int progress = 0;
|
||||||
|
// Load the files in parallel using a stream
|
||||||
|
for(int i = 0; i < length; i++){
|
||||||
|
File file = files[i];
|
||||||
|
if(file.isDirectory() || !file.getName().endsWith(".json"))
|
||||||
|
continue;
|
||||||
|
try {
|
||||||
|
NBTTagCompound compound = NBTJsonUtil.LoadFile(file);
|
||||||
|
if(compound.hasKey("PlayerName")){
|
||||||
|
map.put(compound.getString("PlayerName"), file.getName().substring(0, file.getName().length() - 5));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogWriter.error("Error loading: " + file.getAbsolutePath(), e);
|
||||||
|
}
|
||||||
|
if(tenPercent != 0 ){
|
||||||
|
if(progress != 100){
|
||||||
|
if (i % tenPercent == 0) {
|
||||||
|
progress += 10;
|
||||||
|
LogWriter.info("Creating PlayerMap: Progress: " + progress + "%");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nameUUIDs = map;
|
||||||
|
savePlayerDataMap();
|
||||||
|
|
||||||
|
if(sender != null){
|
||||||
|
sender.addChatMessage(new ChatComponentText("PlayerMap regeneration complete"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
executor.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getPlayerDataMap(){
|
||||||
|
try {
|
||||||
|
File file = new File(getSaveDir(), "___playermap.dat");
|
||||||
|
if(file.exists()){
|
||||||
|
loadPlayerDataMap(file);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
File file = new File(getSaveDir(), "___playermap.dat_old");
|
||||||
|
if(file.exists()){
|
||||||
|
loadPlayerDataMap(file);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
}
|
||||||
|
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(){
|
||||||
|
try {
|
||||||
|
File saveDir = getSaveDir();
|
||||||
|
File file = new File(saveDir, "___playermap.dat_new");
|
||||||
|
File file1 = new File(saveDir, "___playermap.dat_old");
|
||||||
|
File file2 = new File(saveDir, "___playermap.dat");
|
||||||
|
CompressedStreamTools.writeCompressed(writeNBT(), new FileOutputStream(file));
|
||||||
|
if(file1.exists())
|
||||||
|
{
|
||||||
|
file1.delete();
|
||||||
|
}
|
||||||
|
file2.renameTo(file1);
|
||||||
|
if(file2.exists())
|
||||||
|
{
|
||||||
|
file2.delete();
|
||||||
|
}
|
||||||
|
file.renameTo(file2);
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogWriter.except(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getSaveDir(){
|
public File getSaveDir(){
|
||||||
try{
|
try{
|
||||||
File file = new File(CustomNpcs.getWorldSaveDirectory(),"playerdata");
|
File file = new File(CustomNpcs.getWorldSaveDirectory(),"playerdata");
|
||||||
@@ -113,10 +252,9 @@ public class PlayerDataController {
|
|||||||
return new NBTTagCompound();
|
return new NBTTagCompound();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Executor executor = Executors.newSingleThreadExecutor();
|
|
||||||
public void savePlayerData(PlayerData data){
|
public void savePlayerData(PlayerData data){
|
||||||
NBTTagCompound compound = data.getNBT();
|
NBTTagCompound compound = data.getNBT();
|
||||||
executor.execute(() -> {
|
playerDataThread.execute(() -> {
|
||||||
String filename = data.uuid + ".json";
|
String filename = data.uuid + ".json";
|
||||||
try {
|
try {
|
||||||
File saveDir = getSaveDir();
|
File saveDir = getSaveDir();
|
||||||
@@ -130,6 +268,9 @@ public class PlayerDataController {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogWriter.except(e);
|
LogWriter.except(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nameUUIDs.put(data.playername, data.uuid);
|
||||||
|
savePlayerDataMap();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +315,7 @@ public class PlayerDataController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
data = PlayerData.get(player);
|
data = PlayerDataController.instance.getPlayerData(player);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -208,4 +349,31 @@ public class PlayerDataController {
|
|||||||
public boolean hasMail(EntityPlayer player) {
|
public boolean hasMail(EntityPlayer player) {
|
||||||
return getPlayerData(player).mailData.hasMail();
|
return getPlayerData(player).mailData.hasMail();
|
||||||
}
|
}
|
||||||
|
public void readNBT(NBTTagCompound compound){
|
||||||
|
this.nameUUIDs = new HashMap<String, String>();
|
||||||
|
NBTTagList list = compound.getTagList("PlayerDataMap", 10);
|
||||||
|
if(list != null){
|
||||||
|
for(int i = 0; i < list.tagCount(); i++)
|
||||||
|
{
|
||||||
|
NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
|
||||||
|
String playerName = nbttagcompound.getString("Name");
|
||||||
|
String uuid = nbttagcompound.getString("UUID");
|
||||||
|
nameUUIDs.put(playerName, uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public NBTTagCompound writeNBT(){
|
||||||
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
|
NBTTagList playerList = new NBTTagList();
|
||||||
|
for(String key: nameUUIDs.keySet()){
|
||||||
|
NBTTagCompound playerCompound = new NBTTagCompound();
|
||||||
|
playerCompound.setString("Name", key);
|
||||||
|
playerCompound.setString("UUID", nameUUIDs.get(key));
|
||||||
|
playerList.appendTag(playerCompound);
|
||||||
|
|
||||||
|
}
|
||||||
|
nbt.setTag("PlayerDataMap", playerList);
|
||||||
|
return nbt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,14 @@
|
|||||||
package noppes.npcs.mixin;
|
package noppes.npcs.mixin;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||||
import noppes.npcs.config.ConfigClient;
|
import noppes.npcs.config.ConfigClient;
|
||||||
|
import noppes.npcs.config.ConfigMixin;
|
||||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||||
|
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -32,13 +36,23 @@ public class CustomNPCsMixinPlugin implements IMixinConfigPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getMixins() {
|
public List<String> getMixins() {
|
||||||
|
|
||||||
|
// Load Mixin Config
|
||||||
|
String configPath = "config" + File.separator + "CustomNpcPlus" + File.separator;
|
||||||
|
ConfigMixin.init(new File(configPath + "mixin.cfg"));
|
||||||
|
boolean client = FMLLaunchHandler.side().isClient();
|
||||||
|
|
||||||
List<String> mixins = new ArrayList<>();
|
List<String> mixins = new ArrayList<>();
|
||||||
if (ConfigClient.EntityRendererMixin){
|
|
||||||
mixins.add("MixinEntityRenderer");
|
// Client Only Mixins
|
||||||
}
|
if(client){
|
||||||
if (ConfigClient.AnimationMixin) {
|
if (ConfigMixin.EntityRendererMixin){
|
||||||
mixins.add("MixinModelRenderer");
|
mixins.add("MixinEntityRenderer");
|
||||||
mixins.add("MixinRenderPlayer");
|
}
|
||||||
|
if (ConfigMixin.AnimationMixin) {
|
||||||
|
mixins.add("MixinModelRenderer");
|
||||||
|
mixins.add("MixinRenderPlayer");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return mixins;
|
return mixins;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user