Exemplo n.º 1
0
  static UniqueIdentifier getUniqueName(Item item) {
    if (item == null) return null;
    String name = getMain().iItemRegistry.getNameForObject(item);
    UniqueIdentifier ui = new UniqueIdentifier(name);
    if (customItemStacks.contains(ui.modId, ui.name)) {
      return null;
    }

    return ui;
  }
Exemplo n.º 2
0
 @Override
 public void store(Measure measure) {
   // Emulate duplicate measure check
   String componentKey = measure.inputComponent().key();
   String metricKey = measure.metric().key();
   if (measuresByComponentAndMetric.contains(componentKey, metricKey)) {
     throw new SonarException("Can not add the same measure twice");
   }
   measuresByComponentAndMetric.row(componentKey).put(metricKey, measure);
 }
Exemplo n.º 3
0
 @Override
 public void store(DefaultCoverage defaultCoverage) {
   String fileKey = defaultCoverage.inputFile().key();
   // Emulate duplicate storage check
   if (coverageByComponentAndType.contains(fileKey, defaultCoverage.type())) {
     throw new UnsupportedOperationException(
         "Trying to save coverage twice for the same file is not supported: "
             + defaultCoverage.inputFile().relativePath());
   }
   coverageByComponentAndType.row(fileKey).put(defaultCoverage.type(), defaultCoverage);
 }
Exemplo n.º 4
0
  private void send(Player player, MessageNode node, String message) {
    switch (messages.getCat(node)) {
      case NOTIFICATION:
        if (player == null) {
          plugin.getLogger().warning("Could not send the following message: " + message);
        } else {
          // FEATURE: don't spam messages
          PlayerData playerData =
              plugin.getModuleForClass(DataStoreModule.class).getPlayerData(player.getName());
          long now = Calendar.getInstance().getTimeInMillis();

          if (!node.equals(playerData.lastMessageSent)
              || now - playerData.lastMessageTimestamp > 30000) {
            if (popupsAreEnabled(MsgCategory.NOTIFICATION))
              sendPopup(player, MsgCategory.NOTIFICATION, message);
            else player.sendMessage(message);
            playerData.lastMessageSent = node;
            playerData.lastMessageTimestamp = now;
          }
        }
        break;
      case TUTORIAL:
        Validate.notNull(player);
        if (persistModule.getCountFor(node, player.getName()) < messages.getMsgCount(node)) {
          long now = Calendar.getInstance().getTimeInMillis();

          if (!timeouts.contains(player.getName(), node)
              || now - timeouts.get(player.getName(), node) > 120000) // only if contains
          {
            timeouts.put(player.getName(), node, now);
            String msgText = messages.getString(node);
            if (manager != null) sendPopup(player, MsgCategory.TUTORIAL, msgText);
            else
              player.sendMessage(
                  ChatColor.DARK_RED + plugin.getTag() + ChatColor.WHITE + " " + msgText);
            persistModule.increment(node, player.getName());
          }
        } else timeouts.remove(player, message);
        break;
      case BROADCAST:
        plugin.getServer().broadcastMessage(message);
        break;
      default:
        throw new UnsupportedOperationException(messages.getCat(node) + " not implemented");
    }
  }
Exemplo n.º 5
0
    private boolean checkCorrectness() {
      Deque<DocStructure> structuresToCheck = new LinkedList<>();
      structuresToCheck.add(root);
      while (!structuresToCheck.isEmpty()) {
        DocStructure docStructure = structuresToCheck.removeLast();
        boolean contained = subDocuments.contains(docStructure.getType(), docStructure.getIndex());

        if (!contained) {
          throw new IllegalStateException(
              "The structure references the subdocument "
                  + docStructure.getType()
                  + " with index "
                  + docStructure.getIndex()
                  + ", which is not "
                  + "contained in the subdocuments table");
        }
      }
      return true;
    }
 public boolean containsAssociation(Vertex v1, Vertex v2) {
   return graph.contains(v1, v2) || graph.contains(v2, v1);
 }