Skip to content

Commit

Permalink
1.8 update
Browse files Browse the repository at this point in the history
Guava update no longer has Nullable, closeQuietly is now only for input
streams. Also, target 1.8 in general
  • Loading branch information
mcmonkey4eva committed Nov 29, 2014
1 parent 3528e04 commit a2163f9
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 32 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -3,4 +3,6 @@
.classpath
.project
CitizensAPI.jar
*.lnk
*.lnk
.idea/
*.iml
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -4,12 +4,12 @@

<groupId>net.citizensnpcs</groupId>
<artifactId>citizensapi</artifactId>
<version>2.0.13-SNAPSHOT</version>
<version>2.0.14-SNAPSHOT</version>
<name>CitizensAPI</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bukkit.version>1.7.8-R0.1-SNAPSHOT</bukkit.version>
<bukkit.version>1.8-R0.1-SNAPSHOT</bukkit.version>
<powermock.version>1.4.12</powermock.version>
<build.number>Unknown</build.number>
</properties>
Expand Down
@@ -1,7 +1,5 @@
package net.citizensnpcs.api.ai.event;

import javax.annotation.Nullable;

public interface NavigatorCallback {
void onCompletion(@Nullable CancelReason cancelReason);
void onCompletion(CancelReason cancelReason);
}
4 changes: 1 addition & 3 deletions src/main/java/net/citizensnpcs/api/ai/goals/MoveToGoal.java
@@ -1,7 +1,5 @@
package net.citizensnpcs.api.ai.goals;

import javax.annotation.Nullable;

import net.citizensnpcs.api.ai.event.CancelReason;
import net.citizensnpcs.api.ai.event.NavigatorCallback;
import net.citizensnpcs.api.ai.tree.BehaviorGoalAdapter;
Expand Down Expand Up @@ -43,7 +41,7 @@ public boolean shouldExecute() {
npc.getNavigator().setTarget(target);
npc.getNavigator().getLocalParameters().addSingleUseCallback(new NavigatorCallback() {
@Override
public void onCompletion(@Nullable CancelReason cancelReason) {
public void onCompletion(CancelReason cancelReason) {
finished = true;
reason = cancelReason;
}
Expand Down
Expand Up @@ -4,8 +4,6 @@
import java.util.EnumSet;
import java.util.Set;

import javax.annotation.Nullable;

import net.citizensnpcs.api.ai.event.CancelReason;
import net.citizensnpcs.api.ai.event.NavigatorCallback;
import net.citizensnpcs.api.ai.tree.BehaviorGoalAdapter;
Expand Down Expand Up @@ -63,7 +61,7 @@ public boolean shouldExecute() {
npc.getNavigator().setTarget(target, aggressive);
npc.getNavigator().getLocalParameters().addSingleUseCallback(new NavigatorCallback() {
@Override
public void onCompletion(@Nullable CancelReason cancelReason) {
public void onCompletion(CancelReason cancelReason) {
reason = cancelReason;
finished = true;
}
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/net/citizensnpcs/api/ai/tree/Selector.java
Expand Up @@ -5,8 +5,6 @@
import java.util.List;
import java.util.Random;

import javax.annotation.Nullable;

import com.google.common.base.Function;

/**
Expand Down Expand Up @@ -112,7 +110,7 @@ public Builder retryChildren() {
* Sets whether to retry child {@link Behavior}s when they return
* {@link BehaviorStatus#FAILURE}.
*
* @param retry
* @param b
* Whether to retry children
*/
public Builder retryChildren(boolean b) {
Expand Down Expand Up @@ -145,7 +143,7 @@ public static Builder selecting(Collection<Behavior> behaviors) {
private static final Random RANDOM = new Random();
private static final Function<List<Behavior>, Behavior> RANDOM_SELECTION = new Function<List<Behavior>, Behavior>() {
@Override
public Behavior apply(@Nullable List<Behavior> behaviors) {
public Behavior apply(List<Behavior> behaviors) {
return behaviors.get(RANDOM.nextInt(behaviors.size()));
}
};
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/net/citizensnpcs/api/ai/tree/Selectors.java
Expand Up @@ -6,8 +6,6 @@
import java.util.Comparator;
import java.util.List;

import javax.annotation.Nullable;

import com.google.common.base.Function;
import com.google.common.base.Preconditions;

Expand All @@ -23,7 +21,7 @@ private PrioritySelection(Comparator<Behavior> comparator) {
}

@Override
public Behavior apply(@Nullable List<Behavior> input) {
public Behavior apply(List<Behavior> input) {
Collections.sort(input, comparator);
return input.get(input.size() - 1);
}
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/net/citizensnpcs/api/npc/AbstractNPC.java
Expand Up @@ -5,8 +5,6 @@
import java.util.Set;
import java.util.UUID;

import javax.annotation.Nullable;

import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.ai.GoalController;
import net.citizensnpcs.api.ai.SimpleGoalController;
Expand Down Expand Up @@ -287,7 +285,7 @@ public void load(final DataKey root) {
Set<DataKey> keys = Sets.newHashSet(root.getRelative("traits").getSubKeys());
Iterables.addAll(keys, Iterables.transform(Splitter.on(',').split(traitNames), new Function<String, DataKey>() {
@Override
public DataKey apply(@Nullable String input) {
public DataKey apply(String input) {
return root.getRelative("traits." + input);
}
}));
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/net/citizensnpcs/api/util/MemoryDataKey.java
Expand Up @@ -4,8 +4,6 @@
import java.util.Map;
import java.util.Set;

import javax.annotation.Nullable;

import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.MemoryConfiguration;

Expand Down Expand Up @@ -100,7 +98,7 @@ public Iterable<DataKey> getSubKeys() {
Set<String> keys = head.getKeys(false);
return Iterables.transform(keys, new Function<String, DataKey>() {
@Override
public DataKey apply(@Nullable String input) {
public DataKey apply(String input) {
return new MemoryDataKey(root, getKeyFor(input));
}
});
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/net/citizensnpcs/api/util/NBTStorage.java
Expand Up @@ -91,7 +91,14 @@ public boolean load() {
ex.printStackTrace();
return false;
} finally {
Closeables.closeQuietly(stream);
try {
if (stream != null) {
stream.close();
}
}
catch (Exception e) {
e.getCause(); // Do nothing
}
}
return true;
}
Expand All @@ -114,7 +121,14 @@ public void save() {
} catch (IOException ex) {
ex.printStackTrace();
} finally {
Closeables.closeQuietly(stream);
try {
if (stream != null) {
stream.close();
}
}
catch (Exception e) {
e.getCause(); // Do nothing
}
}
}

Expand Down
18 changes: 16 additions & 2 deletions src/main/java/net/citizensnpcs/api/util/Translator.java
Expand Up @@ -204,7 +204,14 @@ private static void addTranslation(TranslationProvider from, File to) {
} catch (IOException e) {
e.printStackTrace();
} finally {
Closeables.closeQuietly(out);
try {
if (out != null) {
out.close();
}
}
catch (Exception e) {
e.getCause(); // Do nothing
}
}
}

Expand Down Expand Up @@ -291,7 +298,14 @@ private static void populateDefaults(File bundleFile) {
} catch (Exception e) {
e.printStackTrace();
} finally {
Closeables.closeQuietly(stream);
try {
if (stream != null) {
stream.close();
}
}
catch (Exception e) {
e.getCause(); // Do nothing
}
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/test/java/net/citizensnpcs/api/ai/BehaviorTreeTest.java
Expand Up @@ -5,8 +5,6 @@

import java.util.List;

import javax.annotation.Nullable;

import net.citizensnpcs.api.ai.tree.Behavior;
import net.citizensnpcs.api.ai.tree.BehaviorGoalAdapter;
import net.citizensnpcs.api.ai.tree.BehaviorStatus;
Expand All @@ -31,7 +29,7 @@ public void failureSelector() {
int idx;

@Override
public Behavior apply(@Nullable List<Behavior> input) {
public Behavior apply(List<Behavior> input) {
Behavior b = input.get(idx++);
if (idx >= input.size())
idx = 0;
Expand Down

0 comments on commit a2163f9

Please sign in to comment.