mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-28 03:15:42 +00:00
Remove all Legacy Ability Content, cleanup API.
- Add Script Tab to Abilities - Add Custom Ability - Add Icon Support for Abilities / Default Icon Support - Remove Icon Tab and throw it into Effects with allowed Override - Removed Deprecated API Sources
This commit is contained in:
1 parent
936dc7f0cc
commit
675c4ef4f9
50 files changed
+1488
-938
No files matched your search
@@ -226,6 +226,8 @@ import kamkeel.npcs.network.packets.request.role.RoleCompanionUpdatePacket;
|
||||
import kamkeel.npcs.network.packets.request.role.RoleGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.role.RoleSavePacket;
|
||||
import kamkeel.npcs.network.packets.request.script.BlockScriptPacket;
|
||||
import kamkeel.npcs.network.packets.request.script.AbilityScriptPacket;
|
||||
import kamkeel.npcs.network.packets.request.script.ChainedAbilityScriptPacket;
|
||||
import kamkeel.npcs.network.packets.request.script.EffectScriptPacket;
|
||||
import kamkeel.npcs.network.packets.request.script.EventScriptPacket;
|
||||
import kamkeel.npcs.network.packets.request.script.ForgeScriptPacket;
|
||||
@@ -316,6 +318,8 @@ public class PacketHandler {
|
||||
REQUEST_PACKET.registerPacket(new ScriptInfoPacket());
|
||||
REQUEST_PACKET.registerPacket(new ScriptFilesPacket());
|
||||
REQUEST_PACKET.registerPacket(new EffectScriptPacket());
|
||||
REQUEST_PACKET.registerPacket(new AbilityScriptPacket());
|
||||
REQUEST_PACKET.registerPacket(new ChainedAbilityScriptPacket());
|
||||
|
||||
// Cloner Packets
|
||||
REQUEST_PACKET.registerPacket(new CloneListPacket());
|
||||
|
||||
@@ -214,4 +214,6 @@ public enum EnumRequestPacket {
|
||||
|
||||
RecipeScript,
|
||||
ManageAuctionAction,
|
||||
AbilityScript,
|
||||
ChainedAbilityScript,
|
||||
}
|
||||
+1
-1
@@ -62,7 +62,7 @@ public final class BuiltInAbilityGetPacket extends AbstractPacket {
|
||||
String name = ByteBufUtils.readString(in);
|
||||
Ability ability = AbilityController.Instance.getAbilityByDisplayName(name);
|
||||
if (ability != null) {
|
||||
NBTTagCompound compound = ability.writeNBT();
|
||||
NBTTagCompound compound = ability.writeNBT(false);
|
||||
compound.setBoolean("BuiltIn", true);
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
|
||||
}
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ public final class ChainedAbilityGetPacket extends AbstractPacket {
|
||||
String chainName = ByteBufUtils.readString(in);
|
||||
ChainedAbility chain = AbilityController.Instance.getChainedAbility(chainName);
|
||||
if (chain != null) {
|
||||
NBTTagCompound compound = chain.writeNBT();
|
||||
NBTTagCompound compound = chain.writeNBT(false);
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public final class ChainedAbilitySavePacket extends AbstractPacket {
|
||||
if (chain.getName() != null && !chain.getName().isEmpty()) {
|
||||
AbilityController.Instance.saveChainedAbility(chain);
|
||||
NoppesUtilServer.sendChainedAbilitiesData((EntityPlayerMP) player);
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP) player, chain.writeNBT());
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP) player, chain.writeNBT(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -61,7 +61,7 @@ public final class CustomAbilityGetPacket extends AbstractPacket {
|
||||
String abilityName = ByteBufUtils.readString(in);
|
||||
Ability ability = AbilityController.Instance.getCustomAbility(abilityName);
|
||||
if (ability != null) {
|
||||
NBTTagCompound compound = ability.writeNBT();
|
||||
NBTTagCompound compound = ability.writeNBT(false);
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ public final class CustomAbilitySavePacket extends AbstractPacket {
|
||||
if (ability != null) {
|
||||
AbilityController.Instance.saveCustomAbility(ability);
|
||||
NoppesUtilServer.sendCustomAbilitiesData((EntityPlayerMP) player);
|
||||
NBTTagCompound responseNbt = ability.writeNBT();
|
||||
NBTTagCompound responseNbt = ability.writeNBT(false);
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP) player, responseNbt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package kamkeel.npcs.network.packets.request.script;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.controllers.AbilityController;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.PacketUtil;
|
||||
import kamkeel.npcs.network.enums.EnumRequestPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.config.ConfigDebug;
|
||||
import noppes.npcs.config.ConfigScript;
|
||||
import noppes.npcs.controllers.data.AbilityScript;
|
||||
import noppes.npcs.controllers.data.IScriptHandler;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class AbilityScriptPacket extends AbstractPacket {
|
||||
public static String packetName = "Request|AbilityScript";
|
||||
|
||||
private Action type;
|
||||
private String abilityId;
|
||||
private int page;
|
||||
private int maxSize;
|
||||
private NBTTagCompound compound;
|
||||
|
||||
public AbilityScriptPacket() {
|
||||
}
|
||||
|
||||
public AbilityScriptPacket(Action type, String abilityId, int page, int maxSize, NBTTagCompound compound) {
|
||||
this.type = type;
|
||||
this.abilityId = abilityId;
|
||||
this.page = page;
|
||||
this.maxSize = maxSize;
|
||||
this.compound = compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumRequestPacket.AbilityScript;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.REQUEST_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomNpcsPermissions.Permission getPermission() {
|
||||
return CustomNpcsPermissions.SCRIPT_PLAYER;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
out.writeInt(type.ordinal());
|
||||
ByteBufUtils.writeUTF8String(out, abilityId);
|
||||
|
||||
if (type == Action.SAVE) {
|
||||
out.writeInt(this.page);
|
||||
out.writeInt(this.maxSize);
|
||||
ByteBufUtils.writeNBT(out, this.compound);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
if (!ConfigScript.canScript(player, CustomNpcsPermissions.SCRIPT))
|
||||
return;
|
||||
|
||||
Action requestedAction = Action.values()[in.readInt()];
|
||||
String id = ByteBufUtils.readUTF8String(in);
|
||||
|
||||
Ability ability = AbilityController.Instance.resolveAbility(id);
|
||||
if (ability == null)
|
||||
return;
|
||||
|
||||
AbilityScript data = ability.getOrCreateScriptHandler();
|
||||
if (requestedAction == Action.GET) {
|
||||
PacketUtil.getScripts((IScriptHandler) data, (EntityPlayerMP) player);
|
||||
} else {
|
||||
data.saveScript(in);
|
||||
// Persist to disk
|
||||
AbilityController.Instance.saveCustomAbility(ability);
|
||||
if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
|
||||
LogWriter.script(String.format("[%s] (Player) %s SAVED ABILITY SCRIPT %s [%s]",
|
||||
"ABILITY SCRIPTS", player.getCommandSenderName(), ability.getName(), ability.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Save(String abilityId, int id, int maxSize, NBTTagCompound compound) {
|
||||
PacketClient.sendClient(new AbilityScriptPacket(Action.SAVE, abilityId, id, maxSize, compound));
|
||||
}
|
||||
|
||||
public static void Get(String abilityId) {
|
||||
PacketClient.sendClient(new AbilityScriptPacket(Action.GET, abilityId, -1, -1, new NBTTagCompound()));
|
||||
}
|
||||
|
||||
private enum Action {
|
||||
GET,
|
||||
SAVE
|
||||
}
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
package kamkeel.npcs.network.packets.request.script;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.controllers.AbilityController;
|
||||
import kamkeel.npcs.controllers.data.ability.data.ChainedAbility;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.PacketUtil;
|
||||
import kamkeel.npcs.network.enums.EnumRequestPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.config.ConfigDebug;
|
||||
import noppes.npcs.config.ConfigScript;
|
||||
import noppes.npcs.controllers.data.ChainedAbilityScript;
|
||||
import noppes.npcs.controllers.data.IScriptHandler;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class ChainedAbilityScriptPacket extends AbstractPacket {
|
||||
public static String packetName = "Request|ChainedAbilityScript";
|
||||
|
||||
private Action type;
|
||||
private String chainId;
|
||||
private int page;
|
||||
private int maxSize;
|
||||
private NBTTagCompound compound;
|
||||
|
||||
public ChainedAbilityScriptPacket() {
|
||||
}
|
||||
|
||||
public ChainedAbilityScriptPacket(Action type, String chainId, int page, int maxSize, NBTTagCompound compound) {
|
||||
this.type = type;
|
||||
this.chainId = chainId;
|
||||
this.page = page;
|
||||
this.maxSize = maxSize;
|
||||
this.compound = compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumRequestPacket.ChainedAbilityScript;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.REQUEST_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomNpcsPermissions.Permission getPermission() {
|
||||
return CustomNpcsPermissions.SCRIPT_PLAYER;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
out.writeInt(type.ordinal());
|
||||
ByteBufUtils.writeUTF8String(out, chainId);
|
||||
|
||||
if (type == Action.SAVE) {
|
||||
out.writeInt(this.page);
|
||||
out.writeInt(this.maxSize);
|
||||
ByteBufUtils.writeNBT(out, this.compound);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
if (!ConfigScript.canScript(player, CustomNpcsPermissions.SCRIPT))
|
||||
return;
|
||||
|
||||
Action requestedAction = Action.values()[in.readInt()];
|
||||
String id = ByteBufUtils.readUTF8String(in);
|
||||
|
||||
ChainedAbility chain = AbilityController.Instance.resolveChainedAbility(id);
|
||||
if (chain == null)
|
||||
return;
|
||||
|
||||
ChainedAbilityScript data = chain.getOrCreateScriptHandler();
|
||||
if (requestedAction == Action.GET) {
|
||||
PacketUtil.getScripts((IScriptHandler) data, (EntityPlayerMP) player);
|
||||
} else {
|
||||
data.saveScript(in);
|
||||
// Persist to disk
|
||||
AbilityController.Instance.saveChainedAbility(chain);
|
||||
if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
|
||||
LogWriter.script(String.format("[%s] (Player) %s SAVED CHAIN SCRIPT %s [%s]",
|
||||
"CHAIN SCRIPTS", player.getCommandSenderName(), chain.getName(), chain.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Save(String chainId, int id, int maxSize, NBTTagCompound compound) {
|
||||
PacketClient.sendClient(new ChainedAbilityScriptPacket(Action.SAVE, chainId, id, maxSize, compound));
|
||||
}
|
||||
|
||||
public static void Get(String chainId) {
|
||||
PacketClient.sendClient(new ChainedAbilityScriptPacket(Action.GET, chainId, -1, -1, new NBTTagCompound()));
|
||||
}
|
||||
|
||||
private enum Action {
|
||||
GET,
|
||||
SAVE
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user