MFF

    Minecraft Forge France
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Forge Events
      • Automatique
      • Foncé
      • Clair
    • S'inscrire
    • Se connecter

    EntityExtendedProperty modifiable quand joueur déconnecté

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    46 Messages 5 Publieurs 6.0k Vues 1 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • Benjamin LoisonB Hors-ligne
      Benjamin Loison
      dernière édition par

      Je n’ai pas compris ta question Robin, voici mon code actuel :

      SaveHandler saveHandler = (SaveHandler)DimensionManager.getWorld(0).getSaveHandler();
      File players = new File(saveHandler.getWorldDirectory(), "playerdata");
      GameProfile game = MinecraftServer.getServer().func_152358_ax().func_152655_a(list[0]);
      if(game == null)
      return;
      File playerData = new File(players, game.getId().toString() + ".dat");
      if(playerData.exists() && playerData.isFile())
      {
      try
      {
      NBTTagCompound tag = CompressedStreamTools.readCompressed(new FileInputStream(playerData));
      tag.getCompoundTag(EEPRestrained.EXT_PROP_NAME).setBoolean("adjoint", true);
      CompressedStreamTools.write(tag, playerData);
      }
      catch(Exception e)
      {}
      }
      

      Et voici ma classe EEPRestrained :

      package fr.altiscraft.benjaminloison.entity;
      
      import java.io.File;
      import java.io.FileWriter;
      import java.util.List;
      import java.util.Scanner;
      
      import org.apache.commons.lang3.StringUtils;
      
      import fr.altiscraft.benjaminloison.api.Nombre;
      import fr.altiscraft.benjaminloison.api.SlashOS;
      import fr.altiscraft.benjaminloison.common.ModAltisCraft;
      import fr.altiscraft.benjaminloison.packets.PacketMessage;
      import fr.altiscraft.benjaminloison.packets.PacketRestrainClientServer;
      import fr.altiscraft.benjaminloison.packets.PacketRestrainServer;
      import fr.altiscraft.benjaminloison.proxy.CommonProxy;
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.entity.player.EntityPlayerMP;
      import net.minecraft.init.Items;
      import net.minecraft.item.ItemStack;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.server.MinecraftServer;
      import net.minecraft.util.ChatComponentText;
      import net.minecraft.util.EnumChatFormatting;
      import net.minecraft.world.World;
      import net.minecraftforge.common.IExtendedEntityProperties;
      
      public class EEPRestrained implements IExtendedEntityProperties
      {
      public final static String EXT_PROP_NAME = "EEPRestrained";
      private EntityPlayer player;
      public long cash, money;
      public boolean escorte, menotte, spawned, vip, vipp, rebelle, staff, gendarme, adjoint, brigadier, sergent, adjudant, aspirant, major, lieutenant, capitaine, commandant, colonel, general, bac, transaltis, samu, garagiste, antv, velo, conduire, camion, bateau, arme, pilote, diamant, archeologie, sirene;
      public String gang, gangInviting;
      public String[] raisonInterpol = new String[50];
      public int[] montantInterpol = new int[50];
      
      public EEPRestrained(EntityPlayer player)
      {
      this.player = player;
      escorte = false;
      menotte = false;
      cash = 0;
      money = 0;
      spawned = false;
      vip = false;
      vipp = false;
      rebelle = false;
      staff = false;
      gendarme = false;
      adjoint = false;
      brigadier = false;
      sergent = false;
      adjudant = false;
      aspirant = false;
      major = false;
      lieutenant = false;
      capitaine = false;
      commandant = false;
      colonel = false;
      general = false;
      bac = false;
      transaltis = false;
      samu = false;
      garagiste = false;
      antv = false;
      velo = false;
      conduire = false;
      camion = false;
      bateau = false;
      arme = false;
      pilote = false;
      diamant = false;
      archeologie = false;
      sirene = false;
      gang = "";
      gangInviting = "";
      for(int i = 0; i < raisonInterpol.length; i++)
      {
      raisonInterpol* = "";
      }
      for(int i = 0; i < montantInterpol.length; i++)
      {
      montantInterpol* = 0;
      }
      }
      
      public static final void register(EntityPlayer player)
      {
      player.registerExtendedProperties(EEPRestrained.EXT_PROP_NAME, new EEPRestrained(player));
      }
      
      public static final EEPRestrained get(EntityPlayer player)
      {
      return (EEPRestrained)player.getExtendedProperties(EXT_PROP_NAME);
      }
      
      @Override
      public void saveNBTData(NBTTagCompound compound)
      {
      NBTTagCompound properties = new NBTTagCompound();
      properties.setBoolean("Escorte", escorte);
      properties.setBoolean("Menotte", menotte);
      properties.setLong("Cash", cash);
      properties.setLong("Money", money);
      properties.setBoolean("vip", vip);
      properties.setBoolean("vipp", vipp);
      properties.setBoolean("rebelle", rebelle);
      properties.setBoolean("staff", staff);
      properties.setBoolean("gendarme", gendarme);
      properties.setBoolean("adjoint", adjoint);
      properties.setBoolean("brigadier", brigadier);
      properties.setBoolean("sergent", sergent);
      properties.setBoolean("adjudant", adjudant);
      properties.setBoolean("major", major);
      properties.setBoolean("aspirant", aspirant);
      properties.setBoolean("lieutenant", lieutenant);
      properties.setBoolean("capitaine", capitaine);
      properties.setBoolean("commandant", commandant);
      properties.setBoolean("colonel", colonel);
      properties.setBoolean("general", general);
      properties.setBoolean("bac", bac);
      properties.setBoolean("transaltis", transaltis);
      properties.setBoolean("samu", samu);
      properties.setBoolean("garagiste", garagiste);
      properties.setBoolean("antv", antv);
      properties.setBoolean("velo", velo);
      properties.setBoolean("conduire", conduire);
      properties.setBoolean("camion", camion);
      properties.setBoolean("bateau", bateau);
      properties.setBoolean("arme", arme);
      properties.setBoolean("pilote", pilote);
      properties.setBoolean("diamant", diamant);
      properties.setBoolean("archeologie", archeologie);
      properties.setBoolean("sirene", sirene);
      properties.setString("gang", gang);
      properties.setString("gangInviting", gangInviting);
      for(int i = 0; i < raisonInterpol.length; i++)
      {
      properties.setString("raisonInterpol" + i, raisonInterpol*);
      }
      for(int i = 0; i < montantInterpol.length; i++)
      {
      properties.setInteger("montantInterpol" + i, montantInterpol*);
      }
      compound.setTag(EXT_PROP_NAME, properties);
      }
      
      public void saveNBTDataMoney(NBTTagCompound compound)
      {
      NBTTagCompound properties = new NBTTagCompound();
      properties.setLong("Money", money);
      properties.setBoolean("vip", vip);
      properties.setBoolean("vipp", vipp);
      properties.setBoolean("rebelle", rebelle);
      properties.setBoolean("staff", staff);
      properties.setBoolean("gendarme", gendarme);
      properties.setBoolean("adjoint", adjoint);
      properties.setBoolean("brigadier", brigadier);
      properties.setBoolean("sergent", sergent);
      properties.setBoolean("adjudant", adjudant);
      properties.setBoolean("aspirant", aspirant);
      properties.setBoolean("major", major);
      properties.setBoolean("lieutenant", lieutenant);
      properties.setBoolean("capitaine", capitaine);
      properties.setBoolean("commandant", commandant);
      properties.setBoolean("colonel", colonel);
      properties.setBoolean("general", general);
      properties.setBoolean("bac", bac);
      properties.setBoolean("transaltis", transaltis);
      properties.setBoolean("samu", samu);
      properties.setBoolean("garagiste", garagiste);
      properties.setBoolean("antv", antv);
      properties.setBoolean("velo", velo);
      properties.setBoolean("conduire", conduire);
      properties.setBoolean("camion", camion);
      properties.setBoolean("bateau", bateau);
      properties.setBoolean("arme", arme);
      properties.setBoolean("pilote", pilote);
      properties.setBoolean("diamant", diamant);
      properties.setBoolean("archeologie", archeologie);
      properties.setBoolean("sirene", sirene);
      properties.setString("gang", gang);
      properties.setString("gangInviting", gangInviting);
      compound.setTag(EXT_PROP_NAME, properties);
      }
      
      @Override
      public void loadNBTData(NBTTagCompound compound)
      {
      NBTTagCompound properties = (NBTTagCompound)compound.getTag(EXT_PROP_NAME);
      escorte = properties.getBoolean("Escorte");
      menotte = properties.getBoolean("Menotte");
      cash = properties.getLong("Cash");
      money = properties.getLong("Money");
      vip = properties.getBoolean("vip");
      vipp = properties.getBoolean("vipp");
      rebelle = properties.getBoolean("rebelle");
      staff = properties.getBoolean("staff");
      gendarme = properties.getBoolean("gendarme");
      adjoint = properties.getBoolean("adjoint");
      brigadier = properties.getBoolean("brigadier");
      sergent = properties.getBoolean("sergent");
      adjudant = properties.getBoolean("adjudant");
      major = properties.getBoolean("major");
      aspirant = properties.getBoolean("aspirant");
      lieutenant = properties.getBoolean("lieutenant");
      capitaine = properties.getBoolean("capitaine");
      commandant = properties.getBoolean("commandant");
      colonel = properties.getBoolean("colonel");
      general = properties.getBoolean("general");
      bac = properties.getBoolean("bac");
      transaltis = properties.getBoolean("transaltis");
      samu = properties.getBoolean("samu");
      garagiste = properties.getBoolean("garagiste");
      antv = properties.getBoolean("antv");
      velo = properties.getBoolean("velo");
      conduire = properties.getBoolean("conduire");
      camion = properties.getBoolean("camion");
      bateau = properties.getBoolean("bateau");
      arme = properties.getBoolean("arme");
      pilote = properties.getBoolean("pilote");
      diamant = properties.getBoolean("diamant");
      archeologie = properties.getBoolean("archeologie");
      sirene = properties.getBoolean("sirene");
      gang = properties.getString("gang");
      gangInviting = properties.getString("gangInviting");
      for(int i = 0; i < raisonInterpol.length; i++)
      {
      raisonInterpol* = properties.getString("raisonInterpol" + i);
      }
      for(int i = 0; i < montantInterpol.length; i++)
      {
      montantInterpol* = properties.getInteger("montantInterpol" + i);
      }
      }
      
      @Override
      public void init(Entity e, World w)
      {}
      
      public final void sync()
      {
      if(player.worldObj.isRemote)
      {
      ModAltisCraft.instance.network.sendToServer(new PacketRestrainServer(escorte, menotte, cash, money, spawned, vip, vipp, rebelle, staff, gendarme, adjoint, brigadier, sergent, adjudant, major, aspirant, lieutenant, capitaine, commandant, colonel, general, bac, transaltis, samu, garagiste, antv, velo, conduire, camion, bateau, arme, pilote, diamant, archeologie, sirene, gang, gangInviting, raisonInterpol, montantInterpol));
      }
      else
      {
      ModAltisCraft.instance.network.sendTo(new PacketRestrainClientServer(escorte, menotte, cash, money, spawned, vip, vipp, rebelle, staff, gendarme, adjoint, brigadier, sergent, adjudant, major, aspirant, lieutenant, capitaine, commandant, colonel, general, bac, transaltis, samu, garagiste, antv, velo, conduire, camion, bateau, arme, pilote, diamant, archeologie, sirene, gang, gangInviting, raisonInterpol, montantInterpol), (EntityPlayerMP)player);
      }
      }
      
      private static String getSaveKey(EntityPlayer player)
      {
      return player.getDisplayName() + ":" + EXT_PROP_NAME;
      }
      
      public static void saveProxyData(EntityPlayer player)
      {
      NBTTagCompound savedData = new NBTTagCompound();
      EEPRestrained.get(player).saveNBTData(savedData);
      CommonProxy.storeEntityData(getSaveKey(player), savedData);
      }
      
      public static void loadProxyData(EntityPlayer player)
      {
      EEPRestrained playerData = EEPRestrained.get(player);
      NBTTagCompound savedData = CommonProxy.getEntityData(getSaveKey(player));
      if(savedData != null)
      {
      playerData.loadNBTData(savedData);
      }
      playerData.sync();
      }
      
      public void creditCash(ItemStack item, int prix)
      {
      if(player.inventory.hasItem(ModAltisCraft.CarteBancaire))
      {
      if(cash + money >= prix)
      {
      setMoney(getMoney() - (prix - cash));
      setCash(0);
      boolean isEmpty = false;
      for(int i = 0; i <= player.inventory.getSizeInventory() - 5; i++)
      {
      if(player.inventory.mainInventory* == item || player.inventory.mainInventory* == null)
      {
      isEmpty = true;
      break;
      }
      }
      if(isEmpty)
      {
      player.inventory.addItemStackToInventory(item);
      ModAltisCraft.instance.network.sendTo(new PacketMessage(EnumChatFormatting.GREEN + "Item achete !", false), (EntityPlayerMP)player);
      }
      else
      {
      ModAltisCraft.instance.network.sendTo(new PacketMessage(EnumChatFormatting.RED + "Vous n'avez pas de place !", true), (EntityPlayerMP)player);
      }
      }
      else
      {
      ModAltisCraft.instance.network.sendTo(new PacketMessage(EnumChatFormatting.RED + "Pas assez d'argent au total !", true), (EntityPlayerMP)player);
      sync();
      }
      }
      else
      {
      ModAltisCraft.instance.network.sendTo(new PacketMessage(EnumChatFormatting.RED + "Pas assez d'argent !", true), (EntityPlayerMP)player);
      sync();
      }
      }
      
      public String recherchesraisonall()
      {
      String recherchesraisonall = "";
      for(int i = 0; i < raisonInterpol.length; i++)
      {
      if(i == 0)
      {
      recherchesraisonall = recherchesraisonall + raisonInterpol*;
      }
      else
      {
      recherchesraisonall = recherchesraisonall + " " + raisonInterpol*;
      }
      }
      return recherchesraisonall;
      }
      
      public int nombre()
      {
      int number = 0;
      for(int i = 0; i < montantInterpol.length; i++)
      {
      if(montantInterpol* != 0)
      {
      number += montantInterpol*;
      }
      }
      sync();
      return number;
      }
      
      public void resetInterpol()
      {
      for(int i = 0; i < raisonInterpol.length; i++)
      {
      raisonInterpol* = "";
      montantInterpol* = 0;
      }
      sync();
      }
      
      private boolean mis = false;
      
      public void addInterpol(String raison, int montant)
      {
      if(!gendarme)
      {
      mis = false;
      for(int i = 0; i < raisonInterpol.length && !mis; i++)
      {
      if(raisonInterpol*.equals("") && raisonInterpol* != null && !mis)
      {
      raisonInterpol* = raison;
      montantInterpol* = montant;
      mis = true;
      }
      }
      sync();
      }
      }
      
      public void vip(boolean vip2)
      {
      vip = vip2;
      sync();
      }
      
      public boolean getvip()
      {
      return vip;
      }
      
      public void vipp(boolean vipp2)
      {
      vipp = vipp2;
      sync();
      }
      
      public boolean getvipp()
      {
      return vipp;
      }
      
      public void sirene(boolean sirene)
      {
      this.sirene = sirene;
      }
      
      public void rebelle(boolean rebelle2)
      {
      rebelle = rebelle2;
      sync();
      }
      
      public boolean getrebelle()
      {
      return rebelle;
      }
      
      public void staff(boolean staff2)
      {
      staff = staff2;
      sync();
      }
      
      public boolean getstaff()
      {
      return staff;
      }
      
      public void gendarme(boolean gendarme2)
      {
      gendarme = gendarme2;
      sync();
      }
      
      public boolean getgendarme()
      {
      return gendarme;
      }
      
      public void gang(String gang2)
      {
      gang = gang2;
      sync();
      }
      
      public String getgang()
      {
      return gang;
      }
      
      public void adjoint(boolean adjoint2)
      {
      adjoint = adjoint2;
      sync();
      }
      
      public boolean getadjoint()
      {
      return adjoint;
      }
      
      public void brigadier(boolean brigadier2)
      {
      brigadier = brigadier2;
      sync();
      }
      
      public boolean getbrigadier()
      {
      return brigadier;
      }
      
      public void sergent(boolean sergent2)
      {
      sergent = sergent2;
      sync();
      }
      
      public boolean getsergent()
      {
      return sergent;
      }
      
      public void adjudant(boolean adjudant2)
      {
      adjudant = adjudant2;
      sync();
      }
      
      public boolean getadjudant()
      {
      return adjudant;
      }
      
      public void major(boolean major2)
      {
      major = major2;
      sync();
      }
      
      public boolean getmajor()
      {
      return major;
      }
      
      public void aspirant(boolean aspirant2)
      {
      aspirant = aspirant2;
      sync();
      }
      
      public boolean getaspirant()
      {
      return aspirant;
      }
      
      public void lieutenant(boolean lieutenant2)
      {
      lieutenant = lieutenant2;
      sync();
      }
      
      public boolean getlieutenant()
      {
      return lieutenant;
      }
      
      public void escorte(boolean escorte2)
      {
      escorte = escorte2;
      sync();
      }
      
      public boolean getescorte()
      {
      return escorte;
      }
      
      public void capitaine(boolean capitaine2)
      {
      capitaine = capitaine2;
      sync();
      }
      
      public boolean getcapitaine()
      {
      return capitaine;
      }
      
      public void commandant(boolean commandant2)
      {
      commandant = commandant2;
      sync();
      }
      
      public boolean getcommandant()
      {
      return commandant;
      }
      
      public void colonel(boolean colonel2)
      {
      colonel = colonel2;
      sync();
      }
      
      public boolean getcolonel()
      {
      return colonel;
      }
      
      public void general(boolean general2)
      {
      general = general2;
      sync();
      }
      
      public boolean getgeneral()
      {
      return general;
      }
      
      public void bac(boolean bac2)
      {
      bac = bac2;
      sync();
      }
      
      public boolean getbac()
      {
      return bac;
      }
      
      public void transaltis(boolean transaltis2)
      {
      transaltis = transaltis2;
      sync();
      }
      
      public boolean gettransaltis()
      {
      return transaltis;
      }
      
      public void samu(boolean samu2)
      {
      samu = samu2;
      sync();
      }
      
      public boolean getsamu()
      {
      return samu;
      }
      
      public void garagiste(boolean garagiste2)
      {
      garagiste = garagiste2;
      sync();
      }
      
      public boolean getgaragiste()
      {
      return garagiste;
      }
      
      public void antv(boolean antv2)
      {
      antv = antv2;
      sync();
      }
      
      public boolean getantv()
      {
      return antv;
      }
      
      public void velo(boolean velo2)
      {
      velo = velo2;
      sync();
      }
      
      public boolean getvelo()
      {
      return velo;
      }
      
      public void conduire(boolean conduire2)
      {
      conduire = conduire2;
      sync();
      }
      
      public boolean getconduire()
      {
      return conduire;
      }
      
      public void bateau(boolean bateau2)
      {
      bateau = bateau2;
      sync();
      }
      
      public boolean getbateau()
      {
      return bateau;
      }
      
      public void camion(boolean camion2)
      {
      camion = camion2;
      sync();
      }
      
      public boolean getcamion()
      {
      return camion;
      }
      
      public void arme(boolean arme2)
      {
      arme = arme2;
      sync();
      }
      
      public boolean getarme()
      {
      return arme;
      }
      
      public void pilote(boolean pilote2)
      {
      pilote = pilote2;
      sync();
      }
      
      public boolean getpilote()
      {
      return pilote;
      }
      
      public void diamant(boolean diamant2)
      {
      diamant = diamant2;
      sync();
      }
      
      public boolean getdiamant()
      {
      return diamant;
      }
      
      public void archeologie(boolean archeologie2)
      {
      archeologie = archeologie2;
      sync();
      }
      
      public boolean getarcheologie()
      {
      return archeologie;
      }
      
      public void gangInviting(String gangInviting2)
      {
      gangInviting = gangInviting2;
      sync();
      }
      
      public String getGangInviting()
      {
      return gangInviting;
      }
      
      public void menotte(boolean menotte2)
      {
      menotte = menotte2;
      sync();
      }
      
      public boolean isRestrained()
      {
      return menotte;
      }
      
      public void pay()
      {
      sync();
      }
      
      public void addCash(long amount)
      {
      boolean sufficient = amount <= getMoney();
      if(sufficient)
      {
      cash += amount;
      money -= amount;
      sync();
      }
      }
      
      public boolean sufficient(long amount)
      {
      boolean sufficient = amount <= getCash();
      if(sufficient)
      {
      return true;
      }
      else
      {
      return false;
      }
      }
      
      public boolean sufficientm(long amount)
      {
      boolean sufficient = amount <= getMoney();
      if(sufficient)
      {
      return true;
      }
      else
      {
      return false;
      }
      }
      
      public String buyCashTest(long amount, ItemStack item)
      {
      boolean sufficient = amount <= getCash();
      if(sufficient)
      {
      if(item != null)
      {
      boolean isEmpty = false;
      for(int i = 0; i <= player.inventory.getSizeInventory() - 5; i++)
      {
      if(player.inventory.mainInventory* == item || player.inventory.mainInventory* == null)
      {
      isEmpty = true;
      break;
      }
      }
      if(isEmpty)
      {
      return "mod.boughtitem";
      }
      else
      {
      return "mod.notenoughspace";
      }
      }
      }
      else
      {
      return "mod.notenoughmoney";
      }
      return null;
      }
      
      public void buyMoneyGang(int amount, ItemStack item, EntityPlayerMP sender)
      {
      if(item != null)
      {
      boolean isEmpty = false;
      for(int i = 0; i <= player.inventory.getSizeInventory() - 5; i++)
      {
      if(player.inventory.mainInventory* == item || player.inventory.mainInventory* == null)
      {
      isEmpty = true;
      break;
      }
      }
      if(isEmpty)
      {
      delMoneyGang(amount);
      player.inventory.addItemStackToInventory(item);
      ModAltisCraft.instance.network.sendTo(new PacketMessage("Item achete !", false, amount), sender);
      List <entityplayermp>players = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
      for(EntityPlayerMP joueur : players)
      {
      EEPRestrained props = EEPRestrained.get(joueur);
      if(props.gang.equals(gang) && !joueur.getDisplayName().equals(sender.getDisplayName()))
      {
      player.addChatMessage(new ChatComponentText(player.getDisplayName() + " a achete " + item.getDisplayName() + " a " + Nombre.main(amount) + " euros !"));
      }
      }
      }
      else
      {
      ModAltisCraft.instance.network.sendTo(new PacketMessage("Pas assez de place !", true, amount), sender);
      }
      }
      }
      
      public void buyCash(long amount, ItemStack item)
      {
      boolean sufficient = amount <= getCash();
      if(sufficient)
      {
      if(item != null)
      {
      boolean isEmpty = false;
      for(int i = 0; i <= player.inventory.getSizeInventory() - 5; i++)
      {
      if(player.inventory.mainInventory* == item || player.inventory.mainInventory* == null)
      {
      isEmpty = true;
      break;
      }
      }
      if(isEmpty)
      {
      delCash2(amount);
      player.inventory.addItemStackToInventory(item);
      }
      }
      }
      }
      
      public void buyPermis(long amount, String permis)
      {
      boolean sufficient = amount <= getCash();
      EEPRestrained props = EEPRestrained.get(player);
      if(sufficient)
      {
      ModAltisCraft.instance.network.sendTo(new PacketMessage("mod.bought", false, Math.round(amount)), (EntityPlayerMP)player);
      if(permis.contains("velo"))
      {
      props.velo(true);
      }
      else if(permis.contains("conduire"))
      {
      props.conduire(true);
      }
      else if(permis.contains("camion"))
      {
      props.camion(true);
      }
      else if(permis.contains("bateau"))
      {
      props.bateau(true);
      }
      else if(permis.contains("pilote"))
      {
      props.pilote(true);
      }
      else if(permis.contains("arme"))
      {
      props.arme(true);
      }
      else if(permis.contains("diamant"))
      {
      props.diamant(true);
      }
      else if(permis.contains("archeologie"))
      {
      props.archeologie(true);
      }
      else if(permis.contains("rebelle"))
      {
      props.rebelle(true);
      }
      props.delCash2(amount);
      }
      else
      {
      ModAltisCraft.instance.network.sendTo(new PacketMessage("mod.notenoughmoney ", true), (EntityPlayerMP)player);
      }
      }
      
      public void buyColorant(long amount, int color)
      {
      if(amount <= getCash())
      {
      ModAltisCraft.instance.network.sendTo(new PacketMessage("mod.bought", false, Math.round(amount)), (EntityPlayerMP)player);
      player.inventory.addItemStackToInventory(new ItemStack(Items.dye, 1, color));
      EEPRestrained.get(player).delCash2(amount);
      }
      else
      {
      ModAltisCraft.instance.network.sendTo(new PacketMessage("mod.notenoughmoney ", true), (EntityPlayerMP)player);
      }
      }
      
      public void addCashRaw(long amount)
      {
      cash += amount;
      sync();
      }
      
      public void delCash(long amount)
      {
      boolean sufficient = amount <= getCash();
      if(sufficient)
      {
      cash -= amount;
      money += amount;
      sync();
      }
      }
      
      public void delCash2(long amount)
      {
      if(amount <= getCash())
      {
      cash -= amount;
      sync();
      }
      }
      
      public void delMoney(long amount)
      {
      if(amount <= getMoney())
      {
      money -= amount;
      sync();
      }
      }
      
      public void delMoneyGang(int amount)
      {
      File fichiergang = new File(path + SlashOS.main() + "mods" + SlashOS.main() + "AltisCraft.fr" + SlashOS.main() + "Gang" + SlashOS.main() + gang + ".txt");
      File gangtemp = new File(path + SlashOS.main() + "mods" + SlashOS.main() + "AltisCraft.fr" + SlashOS.main() + "Gang" + SlashOS.main() + gang + ".temp");
      try
      {
      Scanner sc = new Scanner(fichiergang);
      Scanner sct = new Scanner(fichiergang);
      FileWriter fw = new FileWriter(gangtemp);
      fw.write(sc.nextLine());
      sc.nextLine();
      sct.nextLine();
      sct.nextLine();
      if(sct.hasNextLine())
      {
      sct.nextLine();
      }
      fw.write("\n" + (getMoneyGang() - amount));
      while(sc.hasNextLine())
      {
      if(sct.hasNextLine())
      {
      fw.write(sc.nextLine() + "\n");
      }
      else
      {
      fw.write(sc.nextLine());
      }
      sct.nextLine();
      }
      fw.close();
      sc.close();
      sct.close();
      fichiergang.delete();
      gangtemp.renameTo(fichiergang);
      }
      catch(Exception e)
      {}
      }
      
      String path = new File("").getAbsolutePath();
      
      public int getMoneyGang()
      {
      int amount = -1;
      try
      {
      Scanner sc = new Scanner(new File(path + SlashOS.main() + "mods" + SlashOS.main() + "AltisCraft.fr" + SlashOS.main() + "Gang" + SlashOS.main() + gang + ".txt"));
      if(sc.hasNextLine())
      {
      sc.nextLine();
      }
      if(sc.hasNextLine())
      {
      String scan = sc.nextLine();
      if(StringUtils.isNumeric(scan))
      {
      amount = Integer.parseInt(scan);
      }
      }
      sc.close();
      }
      catch(Exception e)
      {}
      return amount;
      }
      
      public long getCash()
      {
      return cash;
      }
      
      public void addMoney(long amount)
      {
      money += amount;
      sync();
      }
      
      public void setMoney(long amount)
      {
      money = amount;
      sync();
      }
      
      public void setCash(long amount)
      {
      cash = amount;
      sync();
      }
      
      public long getMoney()
      {
      return money;
      }
      }
      ```</entityplayermp>

      >! Développeur de Altis-Life (Arma III) sur Minecraft !
      >! Site web     : https://lemnoslife.com

      1 réponse Dernière réponse Répondre Citer 0
      • robin4002R Hors-ligne
        robin4002 Moddeurs confirmés Rédacteurs Administrateurs
        dernière édition par

        Dans ta fonction loadNBTData
        Tu as :
        NBTTagCompound properties = (NBTTagCompound)compound.getTag(EXT_PROP_NAME);
        puis :
        adjoint = properties.getBoolean(“adjoint”);
        ça correspond bien, donc je ne vois pas pourquoi ça ne fonctionne pas 😕

        Après avoir écrit relis le fichier pour vérifier que la modification s’est bien effectué. Il y a peut être un problème avec
        CompressedStreamTools.write(tag, playerData);

        1 réponse Dernière réponse Répondre Citer 0
        • Benjamin LoisonB Hors-ligne
          Benjamin Loison
          dernière édition par

          Les tests sont fait sur serveur :

          Lorsque j’éxécute le code quand je suis connecté, ça ne marche pas (normal, ça modifier la donnée dans le .dat mais à la déconnexion ça corrige le .dat avec les données que j’avais à la déconnexion en cache).
          Lorsque j’éxécute le code quand je suis déconnecté (bon pseudo), ça ne marche pas (il y a modification du fichier mais à la déconnexion, ça rétablit les données que j’avais à la déconnexion en cache). Même avec relancement du serveur (cache vidé), les données que j’avais à la déconnexion (en cache) sont rétablies 😕

          Et pas de soucis au niveau de réinitilisation possible, avec un autre code similaire quand je suis connecté et que je met Adjoint pas de soucis, je relance le serveur, je le suis toujours.

          >! Développeur de Altis-Life (Arma III) sur Minecraft !
          >! Site web     : https://lemnoslife.com

          1 réponse Dernière réponse Répondre Citer 0
          • robin4002R Hors-ligne
            robin4002 Moddeurs confirmés Rédacteurs Administrateurs
            dernière édition par

            @‘Benjamin Loison’:

            Lorsque j’éxécute le code quand je suis déconnecté (bon pseudo), ça ne marche pas (il y a modification du fichier mais à la déconnexion, ça rétablit les données que j’avais à la déconnexion en cache). Même avec relancement du serveur (cache vidé), les données que j’avais à la déconnexion (en cache) sont rétablies 😕

            ?!?
            Comment tu peux te déconnecté si tu n’es pas connecté ?

            1 réponse Dernière réponse Répondre Citer 0
            • Benjamin LoisonB Hors-ligne
              Benjamin Loison
              dernière édition par

              Lorsque j’éxécute le code quand je suis déconnecté (bon pseudo), ça ne marche pas (il y a modification du fichier mais à la connexion*, ça rétablit les données que j’avais à la déconnexion en cache). Même avec relancement du serveur (cache vidé), les données que j’avais à la déconnexion (en cache) sont rétablies 😕

              Erreur de ma part désolé x)

              >! Développeur de Altis-Life (Arma III) sur Minecraft !
              >! Site web     : https://lemnoslife.com

              1 réponse Dernière réponse Répondre Citer 0
              • robin4002R Hors-ligne
                robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                dernière édition par

                Tu as vérifier avec NBTexplorer les valeurs du .dat ?

                1 réponse Dernière réponse Répondre Citer 0
                • Benjamin LoisonB Hors-ligne
                  Benjamin Loison
                  dernière édition par

                  “(il y a modification du fichier mais à la connexion*, ça rétablit les données que j’avais à la déconnexion en cache). Même avec relancement du serveur (cache vidé), les données que j’avais à la déconnexion (en cache) sont rétablies” comme dit, lorsque j’éxécute le code pendant que je suis déconnecté, la valeur passe bien sur true, mais lorsque je me connecte même après un relancement, la donnée est remise sur false

                  >! Développeur de Altis-Life (Arma III) sur Minecraft !
                  >! Site web     : https://lemnoslife.com

                  1 réponse Dernière réponse Répondre Citer 0
                  • robin4002R Hors-ligne
                    robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                    dernière édition par

                    C’est étrange car normalement il ne devrait pas garder la valeur.
                    Enfin je ne vois pas où il peut la garder. La seule possibilité c’est en ram. Mais comme tu as le même problème même si tu reboot ce n’est pas ça.
                    Tu es sûr que tu n’as pas autre chose qui réinitialiser la valeur ?

                    1 réponse Dernière réponse Répondre Citer 0
                    • Benjamin LoisonB Hors-ligne
                      Benjamin Loison
                      dernière édition par

                      J’ai remarqué que après il y avait des problèmes de flux quand je laissais NBTExplorer lancé (normal, Minecraft essaie de modifier le fichier et NBTExplorer analyse déjà le fichier) alors j’ai bien fais attention de ne pas faire d’action (arrêter serveur…) lorsque NBTExplorer était ouvert mais rien à faire :X donc bon c’est extrêmement étrange, je ne pense pas qu’il y a besoin de tester en relancer le pc pour bien reset la ram mais bon :') J’ai l’impression que je vais presque bientôt devoir testé x)

                      >! Développeur de Altis-Life (Arma III) sur Minecraft !
                      >! Site web     : https://lemnoslife.com

                      1 réponse Dernière réponse Répondre Citer 0
                      • robin4002R Hors-ligne
                        robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                        dernière édition par

                        Tu as fait les tests en local sous Windows ?
                        Ton serveur de prod tourne sous Linux ? Si oui faudrait tester sur lui, car Linux a un comportement différent avec les fichiers (possibilité de modifier un truc même si quelque chose l’utilise, ce qui n’est pas le cas sous Windows).

                        1 réponse Dernière réponse Répondre Citer 0
                        • Benjamin LoisonB Hors-ligne
                          Benjamin Loison
                          dernière édition par

                          Oui sous Windows… Je vais essayer de faire ça et je te dis 😉

                          >! Développeur de Altis-Life (Arma III) sur Minecraft !
                          >! Site web     : https://lemnoslife.com

                          1 réponse Dernière réponse Répondre Citer 0
                          • Benjamin LoisonB Hors-ligne
                            Benjamin Loison
                            dernière édition par

                            Alors quand j’éxécute le code quand je suis déconnecté,
                            En locale ça modifie bien la booléenne et passe sur true
                            Sur Serveur Linux ça ne modifie pas la booléenne

                            Ps: lorsque j’éxécute deux fois le code quand déconnecté, ça ne me marque pas si la valeur est sur true ou false avec les system.out.print

                            >! Développeur de Altis-Life (Arma III) sur Minecraft !
                            >! Site web     : https://lemnoslife.com

                            1 réponse Dernière réponse Répondre Citer 0
                            • robin4002R Hors-ligne
                              robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                              dernière édition par

                              Print un peu de tout pour déboguer le code (le chemin du fichier, s’il existe, ce que le tab nbt contient, etc …).

                              1 réponse Dernière réponse Répondre Citer 0
                              • Benjamin LoisonB Hors-ligne
                                Benjamin Loison
                                dernière édition par

                                J’ai préféré abandonné ce projet, préférant utilisé NBT Explorer à partir des UUID, sinon j’essaye côté plugin de get une booléenne gendarme dans un coumpound EEPRestrained:

                                J’éxécute ça côté plugin:

                                EntityPlayer entity = ((CraftPlayer)p).getHandle();
                                NBTTagCompound nbt = new NBTTagCompound();
                                entity.b(nbt);
                                p.sendMessage(nbt + "!");
                                p.sendMessage(nbt.getCompound("EEPRestrained") + "!");
                                p.sendMessage(nbt.get("EEPRestrained") + "!");
                                p.sendMessage(nbt.getCompound("ForgeData") + "!");
                                p.sendMessage(nbt.get("ForgeData") + "!");
                                

                                Et j’obtiens ça:

                                [19:52:13] [Client thread/INFO]: [CHAT] {Spawns:[],bukkit:{newLevel:0,newExp:0,newTotalExp:0,firstPlayed:1464975640464L,lastKnownName:“Benjamin_Loison”,keepLevel:0b,expToDrop:0,lastPlayed:1466445126921L,},SleepTimer:0s,Health:20s,foodSaturationLevel:5.0f,Attributes:[0:{Base:20.0d,Name:“generic.maxHealth”,},1:{Base:0.0d,Name:“generic.knockbackResistance”,},2:{Base:0.10000000149011612d,Name:“generic.movementSpeed”,},3:{Base:1.0d,Name:“generic.attackDamage”,},],AbsorptionAmount:0.0f,XpLevel:0,abilities:{invulnerable:1b,mayfly:1b,instabuild:1b,walkSpeed:0.1f,mayBuild:1b,flying:1b,flySpeed:0.05f,},Score:0,Sleeping:0b,DeathTime:0s,XpP:0.0f,EnderItems:[],HealF:20.0f,XpTotal:0,foodLevel:20,foodExhaustionLevel:2.7223997f,HurtTime:0s,SelectedItemSlot:1,playerGameType:1,AttackTime:0s,Inventory:[0:{Slot:0b,id:323s,Count:1b,Damage:0s,},1:{Slot:1b,id:334s,Count:1b,Damage:0s,},2:{Slot:2b,id:89s,Count:1b,Damage:0s,},3:{Slot:3b,id:13s,Count:1b,Damage:0s,},4:{Slot:4b,id:271s,Count:1b,Damage:0s,},5:{Slot:5b,id:271s,Count:1b,Damage:0s,},6:{Slot:6b,id:217s,Count:1b,Damage:0s,},7:{Slot:7b,id:1s,Count:1b,Damage:0s,},8:{Slot:8b,id:225s,Count:1b,Damage:0s,},],foodTickTimer:0,}!
                                [19:52:13] [Client thread/INFO]: [CHAT] {}!
                                [19:52:13] [Client thread/INFO]: [CHAT] null!
                                [19:52:13] [Client thread/INFO]: [CHAT] {}!
                                [19:52:13] [Client thread/INFO]: [CHAT] null!

                                Voici le rendu sur NBT Explorer de mes Tags (pièce jointe).

                                Une idée de pourquoi bukkit arrive à être lu contrairement à mon coumpound ? 😕

                                Merci d’avance,

                                (Considérant que c’est autant du modding que du pluging, je poste sur ce forum qui peut m’apporter de l’aide)

                                >! Développeur de Altis-Life (Arma III) sur Minecraft !
                                >! Site web     : https://lemnoslife.com

                                1 réponse Dernière réponse Répondre Citer 0
                                • robin4002R Hors-ligne
                                  robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                  dernière édition par

                                  Peut-être que l’api de bukkit limite volontairement aux données de bukkit ?
                                  Je ne suis pas sûr, je n’ai jamais fait de plugin.

                                  1 réponse Dernière réponse Répondre Citer 0
                                  • Benjamin LoisonB Hors-ligne
                                    Benjamin Loison
                                    dernière édition par

                                    Ca reste dérangeant, c’est toi qui m’avais dis qu’il fallait faire comme ça pour get côté serveur plugin les ExtendedEntityProperties 😕 D’autres idées de comment get ces informations ?

                                    >! Développeur de Altis-Life (Arma III) sur Minecraft !
                                    >! Site web     : https://lemnoslife.com

                                    1 réponse Dernière réponse Répondre Citer 0
                                    • DeletedD Hors-ligne
                                      Deleted
                                      dernière édition par

                                      Je n’ai pas compris, tu souhaites récupérer le tag lié à la soif dans ton plugin pour gérer différentes autres choses, c’est bien ça ?? Sinon ce que tu peux faire, c’est t’intéresser de + près à comment bukkit gère les NBT de MC et voir si il serait possible de rajouter ton propre système pour justement autoriser ceux de forge à être lui, puisque comment ton message le montre, ce n’est pas le cas.
                                      Sinon essaie de recoder le plugin dans ton mod forge, pour ne plus avoir ce problème.

                                      1 réponse Dernière réponse Répondre Citer 0
                                      • robin4002R Hors-ligne
                                        robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                        dernière édition par

                                        Nope 😕

                                        1 réponse Dernière réponse Répondre Citer 0
                                        • Benjamin LoisonB Hors-ligne
                                          Benjamin Loison
                                          dernière édition par

                                          Vous ne connaissez pas sinon une libraries qui permet “d’ouvrir” les .dat pour en extraire les nbt … ça doit bien exister…

                                          >! Développeur de Altis-Life (Arma III) sur Minecraft !
                                          >! Site web     : https://lemnoslife.com

                                          1 réponse Dernière réponse Répondre Citer 0
                                          • SCAREXS Hors-ligne
                                            SCAREX
                                            dernière édition par

                                            Si tu cherches à récupérer des informations relatives à un joueur : le contenu se trouve dans les tags nbt du joueur, auquel tu devrais avoir accès normalement

                                            Site web contenant mes scripts : http://SCAREXgaming.github.io

                                            Pas de demandes de support par MP ni par skype SVP.
                                            Je n'accepte sur skype que l…

                                            1 réponse Dernière réponse Répondre Citer 0
                                            • 1
                                            • 2
                                            • 3
                                            • 2 / 3
                                            • Premier message
                                              Dernier message
                                            Design by Woryk
                                            ContactMentions Légales

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB