mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-13 03:07:34 +00:00
Merge branch 'dev'
This commit is contained in:
commit
809b1f269c
23 files changed
+603
-234
No files matched your search
+2
-2
@@ -34,7 +34,7 @@ configurations {
|
||||
|
||||
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
|
||||
archivesBaseName = "CustomNPC-Plus"
|
||||
|
||||
@@ -113,7 +113,7 @@ def refMapForYourConfig = 'customnpcs.refmap.json'
|
||||
def relativePathToMixinAP = 'tools/mixin-0.8-SNAPSHOT.jar'
|
||||
|
||||
if(!embedMixin){
|
||||
version += "+nomixin"
|
||||
version += "-nomixin"
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package kamkeel;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
|
||||
public class CommandKamkeel extends CommandBase{
|
||||
@@ -75,13 +78,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));
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
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();
|
||||
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()));
|
||||
}
|
||||
}
|
||||
@@ -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,7 +57,8 @@ 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));
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
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);
|
||||
}
|
||||
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]);
|
||||
}
|
||||
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){
|
||||
for(PlayerData playerdata : data){
|
||||
if(playerdata.questData.activeQuests.containsKey(questid)){
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
}
|
||||
|
||||
playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis());
|
||||
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 {
|
||||
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();
|
||||
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 {
|
||||
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();
|
||||
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
|
||||
)
|
||||
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();
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 = "CustomNpcs", version = "1.8.1")
|
||||
public class CustomNpcs {
|
||||
|
||||
@SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy")
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -475,6 +475,7 @@ public class NoppesUtilServer {
|
||||
}
|
||||
else {
|
||||
PlayerDataController.instance.nameUUIDs.remove(name);
|
||||
PlayerDataController.instance.savePlayerDataMap();
|
||||
}
|
||||
}
|
||||
if(type == EnumPlayerData.Quest){
|
||||
@@ -506,6 +507,10 @@ public class NoppesUtilServer {
|
||||
}
|
||||
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,6 +794,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()));
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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),
|
||||
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,
|
||||
|
||||
@@ -6,50 +6,189 @@ 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.NBTJsonUtil;
|
||||
|
||||
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;
|
||||
private static final Executor playerDataThread = Executors.newSingleThreadExecutor();
|
||||
|
||||
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) {
|
||||
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(){
|
||||
try{
|
||||
File file = new File(CustomNpcs.getWorldSaveDirectory(),"playerdata");
|
||||
@@ -113,10 +252,9 @@ public class PlayerDataController {
|
||||
return new NBTTagCompound();
|
||||
}
|
||||
|
||||
private static Executor executor = Executors.newSingleThreadExecutor();
|
||||
public void savePlayerData(PlayerData data){
|
||||
NBTTagCompound compound = data.getNBT();
|
||||
executor.execute(() -> {
|
||||
playerDataThread.execute(() -> {
|
||||
String filename = data.uuid + ".json";
|
||||
try {
|
||||
File saveDir = getSaveDir();
|
||||
@@ -130,6 +268,9 @@ public class PlayerDataController {
|
||||
} catch (Exception e) {
|
||||
LogWriter.except(e);
|
||||
}
|
||||
|
||||
nameUUIDs.put(data.playername, data.uuid);
|
||||
savePlayerDataMap();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -174,7 +315,7 @@ public class PlayerDataController {
|
||||
}
|
||||
}
|
||||
else
|
||||
data = PlayerData.get(player);
|
||||
data = PlayerDataController.instance.getPlayerData(player);
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -208,4 +349,31 @@ public class PlayerDataController {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user