Exemple #1
0
 public static void addAspect(
     UUID playerUUID, ScanResult scan, double chanceToIncrease, double increaseMult) {
   if (TEC.onlinePlayers.contains(playerUUID))
     TEC.addAspect(TEC.getPlayerOnline(playerUUID), scan, chanceToIncrease, increaseMult);
   else {
     if (!TEC.aspectBuffer.containsKey(playerUUID))
       TEC.aspectBuffer.put(playerUUID, new ArrayList<Pair<ScanResult, Pair<Double, Double>>>());
     TEC.aspectBuffer
         .get(playerUUID)
         .add(
             new Pair<ScanResult, Pair<Double, Double>>(
                 scan, new Pair<Double, Double>(chanceToIncrease, increaseMult)));
   }
 }
Exemple #2
0
    @Override
    public void readFromNBT(NBTTagCompound tagCom) {
      TEC.idToUsername.clear();
      NBTTagList idUsernameTag = tagCom.getTagList("idUsernames", 10);
      for (int i = 0; i < idUsernameTag.tagCount(); i++) {
        NBTTagCompound tag = idUsernameTag.getCompoundTagAt(i);
        TEC.idToUsername.put(
            UUID.fromString(tagCom.getString("UUID")), tagCom.getString("playerName"));
      }

      TEC.aspectBuffer.clear();
      NBTTagList bufferTag = tagCom.getTagList("bufferTag", 10);
      for (int i = 0; i < bufferTag.tagCount(); i++) {
        NBTTagCompound idedBuffer = bufferTag.getCompoundTagAt(i);
        UUID playerID = UUID.fromString(idedBuffer.getString("playerID"));
        NBTTagList playersBuffer = idedBuffer.getTagList("buffer", 10);
        for (int j = 0; j < playersBuffer.tagCount(); j++) {
          NBTTagCompound bufferEntry = playersBuffer.getCompoundTagAt(j);

          NBTTagCompound scanTag = bufferEntry.getCompoundTag("scan");
          ScanResult scan =
              new ScanResult(
                  scanTag.getByte("type"),
                  scanTag.getInteger("id"),
                  scanTag.getInteger("meta"),
                  EntityList.createEntityFromNBT(
                      scanTag.getCompoundTag("entityTag"), DimensionManager.getWorld(0)),
                  scanTag.getString("phenomena"));

          TEC.addAspect(
              playerID, scan, bufferEntry.getDouble("chance"), bufferEntry.getDouble("percent"));
        }
      }
    }
Exemple #3
0
 @SubscribeEvent
 public void login(PlayerEvent.PlayerLoggedInEvent event) {
   UUID id = event.player.getGameProfile().getId();
   TEC.idToUsername.put(id, event.player.getCommandSenderName());
   TEC.onlinePlayers.add(id);
   if (TEC.aspectBuffer.containsKey(id)) {
     List<Pair<ScanResult, Pair<Double, Double>>> pendingScans = TEC.aspectBuffer.get(id);
     for (Pair<ScanResult, Pair<Double, Double>> scan : pendingScans) {
       TEC.addAspect(
           event.player, scan.getKey(), scan.getValue().getKey(), scan.getValue().getValue());
     }
     TEC.aspectBuffer.remove(id);
   }
 }