mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 18:45:29 +01:00
Remove possible NPE from trait plotting
This commit is contained in:
parent
8054667482
commit
dd53b5eefa
@ -130,7 +130,7 @@ public class Metrics {
|
||||
|
||||
/**
|
||||
* Add a Graph object to BukkitMetrics that represents data for the plugin that should be sent to the backend
|
||||
*
|
||||
*
|
||||
* @param graph
|
||||
* The name of the graph
|
||||
*/
|
||||
@ -145,7 +145,7 @@ public class Metrics {
|
||||
/**
|
||||
* Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics
|
||||
* website. Plotters can be added to the graph object returned.
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* The name of the graph
|
||||
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
|
||||
@ -167,7 +167,7 @@ public class Metrics {
|
||||
|
||||
/**
|
||||
* Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task.
|
||||
*
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public void disable() throws IOException {
|
||||
@ -191,7 +191,7 @@ public class Metrics {
|
||||
|
||||
/**
|
||||
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
|
||||
*
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public void enable() throws IOException {
|
||||
@ -214,7 +214,7 @@ public class Metrics {
|
||||
|
||||
/**
|
||||
* Gets the File object of the config file that should be used to store data such as the GUID and opt-out status
|
||||
*
|
||||
*
|
||||
* @return the File object for the config file
|
||||
*/
|
||||
public File getConfigFile() {
|
||||
@ -232,7 +232,7 @@ public class Metrics {
|
||||
|
||||
/**
|
||||
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
|
||||
*
|
||||
*
|
||||
* @return true if mineshafter is installed on the server
|
||||
*/
|
||||
private boolean isMineshafterPresent() {
|
||||
@ -246,7 +246,7 @@ public class Metrics {
|
||||
|
||||
/**
|
||||
* Has the server owner denied plugin metrics?
|
||||
*
|
||||
*
|
||||
* @return true if metrics should be opted out of it
|
||||
*/
|
||||
public boolean isOptOut() {
|
||||
@ -439,7 +439,7 @@ public class Metrics {
|
||||
* Start measuring statistics. This will immediately create an async repeating task as the plugin and send the
|
||||
* initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200
|
||||
* ticks.
|
||||
*
|
||||
*
|
||||
* @return True if statistics measuring is running, otherwise false.
|
||||
*/
|
||||
public boolean start() {
|
||||
@ -522,7 +522,7 @@ public class Metrics {
|
||||
|
||||
/**
|
||||
* Add a plotter to the graph, which will be used to plot entries
|
||||
*
|
||||
*
|
||||
* @param plotter
|
||||
* the plotter to add to the graph
|
||||
*/
|
||||
@ -542,7 +542,7 @@ public class Metrics {
|
||||
|
||||
/**
|
||||
* Gets the graph's name
|
||||
*
|
||||
*
|
||||
* @return the Graph's name
|
||||
*/
|
||||
public String getName() {
|
||||
@ -551,7 +551,7 @@ public class Metrics {
|
||||
|
||||
/**
|
||||
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph
|
||||
*
|
||||
*
|
||||
* @return an unmodifiable {@link java.util.Set} of the plotter objects
|
||||
*/
|
||||
public Set<Plotter> getPlotters() {
|
||||
@ -571,7 +571,7 @@ public class Metrics {
|
||||
|
||||
/**
|
||||
* Remove a plotter from the graph
|
||||
*
|
||||
*
|
||||
* @param plotter
|
||||
* the plotter to remove from the graph
|
||||
*/
|
||||
@ -599,7 +599,7 @@ public class Metrics {
|
||||
|
||||
/**
|
||||
* Construct a plotter with a specific plot name
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* the name of the plotter to use, which will show up on the website
|
||||
*/
|
||||
@ -619,7 +619,7 @@ public class Metrics {
|
||||
|
||||
/**
|
||||
* Get the column name for the plotted point
|
||||
*
|
||||
*
|
||||
* @return the plotted point's column name
|
||||
*/
|
||||
public String getColumnName() {
|
||||
@ -630,7 +630,7 @@ public class Metrics {
|
||||
* Get the current value for the plotted point. Since this function defers to an external function it may or may
|
||||
* not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called
|
||||
* from any thread so care should be taken when accessing resources that need to be synchronized.
|
||||
*
|
||||
*
|
||||
* @return the current value for the point to be plotted.
|
||||
*/
|
||||
public abstract int getValue();
|
||||
@ -649,7 +649,7 @@ public class Metrics {
|
||||
|
||||
/**
|
||||
* Appends a json encoded key/value pair to the given string builder.
|
||||
*
|
||||
*
|
||||
* @param json
|
||||
* @param key
|
||||
* @param value
|
||||
@ -684,7 +684,7 @@ public class Metrics {
|
||||
|
||||
/**
|
||||
* Escape a string to create a valid JSON string
|
||||
*
|
||||
*
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
@ -730,7 +730,7 @@ public class Metrics {
|
||||
|
||||
/**
|
||||
* GZip compress a string of bytes
|
||||
*
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
@ -756,7 +756,7 @@ public class Metrics {
|
||||
|
||||
/**
|
||||
* Encode text as UTF-8
|
||||
*
|
||||
*
|
||||
* @param text
|
||||
* the text to encode
|
||||
* @return the encoded text, as UTF-8
|
||||
|
@ -101,7 +101,7 @@ public class CitizensTraitFactory implements TraitFactory {
|
||||
|
||||
public void addPlotters(Graph graph) {
|
||||
for (Map.Entry<String, TraitInfo> entry : registered.entrySet()) {
|
||||
if (INTERNAL_TRAITS.contains(entry.getKey()))
|
||||
if (INTERNAL_TRAITS.contains(entry.getKey()) || entry.getKey() == null)
|
||||
continue;
|
||||
final Class<? extends Trait> traitClass = entry.getValue().getTraitClass();
|
||||
graph.addPlotter(new Metrics.Plotter(entry.getKey()) {
|
||||
@ -109,8 +109,9 @@ public class CitizensTraitFactory implements TraitFactory {
|
||||
public int getValue() {
|
||||
int numberUsingTrait = 0;
|
||||
for (NPC npc : CitizensAPI.getNPCRegistry()) {
|
||||
if (npc.hasTrait(traitClass))
|
||||
if (npc.hasTrait(traitClass)) {
|
||||
++numberUsingTrait;
|
||||
}
|
||||
}
|
||||
return numberUsingTrait;
|
||||
}
|
||||
|
@ -89,6 +89,9 @@ public class Skin {
|
||||
setNPCTexture(entity, localData);
|
||||
|
||||
// check if NPC prefers to use cached skin over the latest skin.
|
||||
if (entity.getNPC().data().has("player-skin-use-latest")) {
|
||||
entity.getNPC().data().remove("player-skin-use-latest");
|
||||
}
|
||||
if (!entity.getNPC().data().get(NPC.PLAYER_SKIN_USE_LATEST, Setting.NPC_SKIN_USE_LATEST.asBoolean())) {
|
||||
// cache preferred
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user