Skip to content

Commit

Permalink
Merge branch 'rewrite'
Browse files Browse the repository at this point in the history
  • Loading branch information
KAMKEEL committed Mar 18, 2024
2 parents d83a977 + e0af08c commit 736b9bc
Show file tree
Hide file tree
Showing 74 changed files with 1,706 additions and 1,617 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ buildscript {

apply plugin: 'forge'

version = "3.2"
version = "4.0"
group= "kamkeel.mpmplus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "MorePlayerModels-Plus"

Expand Down
100 changes: 61 additions & 39 deletions src/main/java/kamkeel/MorePlayerModelsPermissions.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.entity.player.EntityPlayer;
import noppes.mpm.MorePlayerModels;
import noppes.mpm.config.ConfigMain;
import noppes.mpm.config.ConfigPerm;
import org.apache.logging.log4j.LogManager;

import java.lang.reflect.InvocationTargetException;
Expand All @@ -13,30 +14,58 @@


public class MorePlayerModelsPermissions {
public static final Permission CONFIG_SKIN = new Permission("mpm.config.skin");
public static final Permission CONFIG_SOUND = new Permission("mpm.config.sound");
public static final Permission CONFIG_ENTITY = new Permission("mpm.config.entity");
public static final Permission CONFIG_SCALE = new Permission("mpm.config.scale");
public static final Permission CONFIG_HIDE = new Permission("mpm.config.hide");
public static final Permission CONFIG_SAVE = new Permission("mpm.config.save");
public static final Permission CONFIG_LOAD = new Permission("mpm.config.load");
// Config Permissions
public static final Permission CONFIG_SKIN = new Permission("mpm.config.skin", ConfigPerm.CONFIG_SKIN);
public static final Permission CONFIG_SOUND = new Permission("mpm.config.sound", ConfigPerm.CONFIG_SOUND);
public static final Permission CONFIG_ENTITY = new Permission("mpm.config.entity", ConfigPerm.CONFIG_ENTITY);
public static final Permission CONFIG_SCALE = new Permission("mpm.config.scale", ConfigPerm.CONFIG_SCALE);
public static final Permission CONFIG_HIDE = new Permission("mpm.config.hide", ConfigPerm.CONFIG_HIDE);
public static final Permission CONFIG_PRESET = new Permission("mpm.config.preset", ConfigPerm.CONFIG_PRESET);

public static final Permission PARTS = new Permission("mpm.parts");
public static final Permission PARTS_BEARD = new Permission("mpm.parts.beard");
public static final Permission PARTS_BREAST = new Permission("mpm.parts.breast");
public static final Permission PARTS_CAPE = new Permission("mpm.parts.cape");
public static final Permission PARTS_CLAWS = new Permission("mpm.parts.claws");
public static final Permission PARTS_EARS = new Permission("mpm.parts.ears");
public static final Permission PARTS_FIN = new Permission("mpm.parts.fin");
public static final Permission PARTS_HAIR = new Permission("mpm.parts.hair");
public static final Permission PARTS_HORNS = new Permission("mpm.parts.horns");
public static final Permission PARTS_LEGS = new Permission("mpm.parts.legs");
public static final Permission PARTS_MOHAWK = new Permission("mpm.parts.mohawk");
public static final Permission PARTS_PARTICLES = new Permission("mpm.parts.particles");
public static final Permission PARTS_SKIRT = new Permission("mpm.parts.skirt");
public static final Permission PARTS_SNOUT = new Permission("mpm.parts.snout");
public static final Permission PARTS_TAIL = new Permission("mpm.parts.tail");
public static final Permission PARTS_WINGS = new Permission("mpm.parts.wings");
// Part Permissions
public static final Permission PARTS = new Permission("mpm.parts", ConfigPerm.PARTS);
public static final Permission PARTS_BEARD = new Permission("mpm.parts.beard", ConfigPerm.PARTS_BEARD);
public static final Permission PARTS_BREAST = new Permission("mpm.parts.breast", ConfigPerm.PARTS_BREAST);
public static final Permission PARTS_CAPE = new Permission("mpm.parts.cape", ConfigPerm.PARTS_CAPE);
public static final Permission PARTS_CLAWS = new Permission("mpm.parts.claws", ConfigPerm.PARTS_CLAWS);
public static final Permission PARTS_EARS = new Permission("mpm.parts.ears", ConfigPerm.PARTS_EARS);
public static final Permission PARTS_FIN = new Permission("mpm.parts.fin", ConfigPerm.PARTS_FIN);
public static final Permission PARTS_HAIR = new Permission("mpm.parts.hair", ConfigPerm.PARTS_HAIR);
public static final Permission PARTS_HORNS = new Permission("mpm.parts.horns", ConfigPerm.PARTS_HORNS);
public static final Permission PARTS_LEGS = new Permission("mpm.parts.legs", ConfigPerm.PARTS_LEGS);
public static final Permission PARTS_MOHAWK = new Permission("mpm.parts.mohawk", ConfigPerm.PARTS_MOHAWK);
public static final Permission PARTS_PARTICLES = new Permission("mpm.parts.particles", ConfigPerm.PARTS_PARTICLES);
public static final Permission PARTS_SKIRT = new Permission("mpm.parts.skirt", ConfigPerm.PARTS_SKIRT);
public static final Permission PARTS_SNOUT = new Permission("mpm.parts.snout", ConfigPerm.PARTS_SNOUT);
public static final Permission PARTS_TAIL = new Permission("mpm.parts.tail", ConfigPerm.PARTS_TAIL);
public static final Permission PARTS_WINGS = new Permission("mpm.parts.wings", ConfigPerm.PARTS_WINGS);

// Emote Permissions
public static final Permission EMOTE = new Permission("mpm.emote", ConfigPerm.EMOTE);
public static final Permission ANGRY = new Permission("mpm.emote.angry", ConfigPerm.ANGRY);
public static final Permission BOW = new Permission("mpm.emote.bow", ConfigPerm.BOW);
public static final Permission CRAWL = new Permission("mpm.emote.crawl", ConfigPerm.CRAWL);
public static final Permission DANCE = new Permission("mpm.emote.dance", ConfigPerm.DANCE);
public static final Permission DEATH = new Permission("mpm.emote.death", ConfigPerm.DEATH);
public static final Permission HUG = new Permission("mpm.emote.hug", ConfigPerm.HUG);
public static final Permission LOVE = new Permission("mpm.emote.love", ConfigPerm.LOVE);
public static final Permission NO = new Permission("mpm.emote.no", ConfigPerm.NO);
public static final Permission YES = new Permission("mpm.emote.yes", ConfigPerm.YES);
public static final Permission POINT = new Permission("mpm.emote.point", ConfigPerm.POINT);
public static final Permission SING = new Permission("mpm.emote.sing", ConfigPerm.SING);
public static final Permission SIT = new Permission("mpm.emote.sit", ConfigPerm.SIT);
public static final Permission SLEEP = new Permission("mpm.emote.sleep", ConfigPerm.SLEEP);
public static final Permission WAG = new Permission("mpm.emote.wag", ConfigPerm.WAG);
public static final Permission WAVE = new Permission("mpm.emote.wave", ConfigPerm.WAVE);

// Admin Permissions
public static final Permission SETCLOAK = new Permission("mpm.admin.cloak", ConfigPerm.SETCLOAK);
public static final Permission SETMODEL = new Permission("mpm.admin.model", ConfigPerm.SETMODEL);
public static final Permission SETNAME = new Permission("mpm.admin.name", ConfigPerm.SETNAME);
public static final Permission SETURL = new Permission("mpm.admin.url", ConfigPerm.SETURL);
public static final Permission SIZE = new Permission("mpm.admin.size", ConfigPerm.SIZE);
public static final Permission SCALE = new Permission("mpm.admin.scale", ConfigPerm.SCALE);
public static final Permission RELOAD = new Permission("mpm.admin.reload", ConfigPerm.RELOAD);

public static MorePlayerModelsPermissions Instance;
private Class<?> bukkit;
Expand Down Expand Up @@ -69,26 +98,15 @@ public static boolean hasPermission(EntityPlayer player, Permission permission){
}
if(player != null){
if(permission != null){
if(Instance.bukkit != null){
return Instance.bukkitPermission(player.getCommandSenderName(), permission.name);
if(permission.isAllowed()){
return true;
}
}
}
return true;
}

public static boolean hasPermission(EntityPlayer player, String permission){
if(!ConfigMain.EnablePermissions){
return true;
}
if(player != null){
if(permission != null){
if(Instance.bukkit != null){
return Instance.bukkitPermission(player.getCommandSenderName(), permission);
return Instance.bukkitPermission(player.getCommandSenderName(), permission.name);
}
}
}
return true;
return false;
}

private boolean bukkitPermission(String username, String permission) {
Expand All @@ -108,14 +126,18 @@ private boolean bukkitPermission(String username, String permission) {
public static class Permission{
public static final List<Permission> permissionNode = new ArrayList<Permission>();
public static final List<String> permissions = new ArrayList<String>();
public boolean allowed;
public String name;
public Permission(String name){
public Permission(String name, boolean defaultBool){
this.name = name;
this.allowed = defaultBool;
if(!permissions.contains(name)){
permissions.add(name);
permissionNode.add(this);
}
}

public boolean isAllowed(){ return allowed; }
}

public static boolean enabled() {
Expand Down
68 changes: 36 additions & 32 deletions src/main/java/kamkeel/command/CommandMPM.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import noppes.mpm.ModelData;
import noppes.mpm.PlayerDataController;
import noppes.mpm.Server;
import noppes.mpm.commands.MpmCommandInterface;
import noppes.mpm.constants.EnumAnimation;
import noppes.mpm.constants.EnumPackets;
import noppes.mpm.constants.EnumPacketClient;
import noppes.mpm.controllers.ModelDataController;

import java.lang.reflect.Modifier;
import java.util.*;
Expand Down Expand Up @@ -69,26 +69,30 @@ public void processCommand(ICommandSender icommandsender, String[] args) throws
if(player == null)
throw new PlayerNotFoundException("commands.generic.player.notFound", icommandsender);

ModelData data = PlayerDataController.instance.getPlayerData(player);

if(type.equals("url")){
url(player, args, data);
}
else if(type.equals("scale")){
scale(player, args, data);
}
else if(type.equals("name")){
name(player, args, data);
}
else if(type.equals("entity")){
entity(player, args, data);
}
else if(type.equals("animation")){
animation(player, args, data);
}
else if(type.equals("sendmodel")){
sendmodel(player, args, data);
}
ModelData data = ModelData.getData(player);
if(data == null)
return;

switch (type) {
case "url":
url(player, args, data);
break;
case "scale":
scale(player, args, data);
break;
case "name":
name(player, args, data);
break;
case "entity":
entity(player, args, data);
break;
case "animation":
animation(player, args, data);
break;
case "sendmodel":
sendmodel(player, args, data);
break;
}
}

private void animation(EntityPlayer player, String[] args, ModelData data) throws WrongUsageException {
Expand All @@ -113,7 +117,7 @@ private void animation(EntityPlayer player, String[] args, ModelData data) throw
animation = EnumAnimation.NONE;
}

Server.sendAssociatedData(player, EnumPackets.ANIMATION, player.getCommandSenderName(), animation);
Server.sendAssociatedData(player, EnumPacketClient.PLAY_ANIMATION, player.getCommandSenderName(), animation);
data.setAnimation(animation.ordinal());
}

Expand All @@ -137,7 +141,7 @@ private void entity(EntityPlayer player, String[] args, ModelData data) throws W
}
}

Server.sendAssociatedData(player, EnumPackets.SEND_PLAYER_DATA, player.getCommandSenderName(), data.writeToNBT());
Server.sendAssociatedData(player, EnumPacketClient.SEND_PLAYER_DATA, player.getCommandSenderName(), data.getNBT());
}

private void name(EntityPlayer player, String[] args, ModelData data) throws WrongUsageException {
Expand All @@ -160,7 +164,7 @@ private void name(EntityPlayer player, String[] args, ModelData data) throws Wro
if(data.displayName.equalsIgnoreCase("clear"))
data.displayName = "";
player.refreshDisplayName();
Server.sendAssociatedData(player, EnumPackets.SEND_PLAYER_DATA, player.getCommandSenderName(), data.writeToNBT());
Server.sendAssociatedData(player, EnumPacketClient.SEND_PLAYER_DATA, player.getCommandSenderName(), data.getNBT());
}

private void url(EntityPlayer player, String[] args, ModelData data) throws WrongUsageException{
Expand All @@ -173,7 +177,7 @@ private void url(EntityPlayer player, String[] args, ModelData data) throws Wron
if(url.equalsIgnoreCase("clear"))
url = "";
data.url = url;
Server.sendAssociatedData(player, EnumPackets.SEND_PLAYER_DATA, player.getCommandSenderName(), data.writeToNBT());
Server.sendAssociatedData(player, EnumPacketClient.SEND_PLAYER_DATA, player.getCommandSenderName(), data.getNBT());
}

private void sendmodel(EntityPlayer fromPlayer, String[] args, ModelData fromData) throws WrongUsageException{
Expand All @@ -196,16 +200,16 @@ private void sendmodel(EntityPlayer fromPlayer, String[] args, ModelData fromDat
throw new WrongUsageException("/mpm sendmodel [@from_player] <@to_player> (to go back to default /mpm sendmodel [@p] clear)");
}
else
toData = PlayerDataController.instance.getPlayerData(toPlayer);
toData = ModelData.getData(toPlayer);

if(toData == null){
return;
}

NBTTagCompound compound = fromData.writeToNBT();
toData.readFromNBT(compound);
NBTTagCompound compound = fromData.getNBT();
toData.setNBT(compound);
toData.save();
Server.sendAssociatedData(toPlayer, EnumPackets.SEND_PLAYER_DATA, toPlayer.getCommandSenderName(), compound);
Server.sendAssociatedData(toPlayer, EnumPacketClient.SEND_PLAYER_DATA, toPlayer.getCommandSenderName(), compound);
}

private void scale(EntityPlayer player, String[] args, ModelData data) throws WrongUsageException{
Expand All @@ -216,7 +220,7 @@ private void scale(EntityPlayer player, String[] args, ModelData data) throws Wr
data.body.setScale(scale.scaleX, scale.scaleY, scale.scaleZ);
data.arms.setScale(scale.scaleX, scale.scaleY, scale.scaleZ);
data.legs.setScale(scale.scaleX, scale.scaleY, scale.scaleZ);
Server.sendAssociatedData(player, EnumPackets.SEND_PLAYER_DATA, player.getCommandSenderName(), data.writeToNBT());
Server.sendAssociatedData(player, EnumPacketClient.SEND_PLAYER_DATA, player.getCommandSenderName(), data.getNBT());
}
else if(args.length == 4){
Scale scale = Scale.Parse(args[0]);
Expand All @@ -229,7 +233,7 @@ else if(args.length == 4){

scale = Scale.Parse(args[3]);
data.legs.setScale(scale.scaleX, scale.scaleY, scale.scaleZ);
Server.sendAssociatedData(player, EnumPackets.SEND_PLAYER_DATA, player.getCommandSenderName(), data.writeToNBT());
Server.sendAssociatedData(player, EnumPacketClient.SEND_PLAYER_DATA, player.getCommandSenderName(), data.getNBT());
}
else{
throw new WrongUsageException("/mpm scale [@p] [head x,y,z] [body x,y,z] [arms x,y,z] [legs x,y,z]. Examples: /mpm scale @p 1, /mpm scale @p 1 1 1 1, /mpm scale 1,1,1 1,1,1 1,1,1 1,1,1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,13 @@ public static ModelBase getMainModel(RendererLivingEntity renderer){
public static void setMainModel(RenderPlayer renderer, ModelMPM modelBipedMain) {
renderer.mainModel = modelBipedMain;
}

public static String getTexture(RendererLivingEntity render, Entity entity){
ResourceLocation location = render.getEntityTexture(entity);
return location.toString();
}

public static ResourceLocation getResource(AbstractClientPlayer player, RendererLivingEntity render, Entity entity){
if(render != null){
try{
return render.getEntityTexture(entity);
}
catch(Exception ex){

}
catch(Exception ex){}
}
return player.getLocationSkin();
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/noppes/mpm/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public Object getClientGuiElement(int ID, EntityPlayer player, World world,
int x, int y, int z){
return null;
}

public ModelData getClientPlayerData(EntityPlayer player) {
return null;
}

public void load(){
MorePlayerModels.Channel.register(new PacketHandlerServer());
Expand Down
Loading

0 comments on commit 736b9bc

Please sign in to comment.