Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
Conflicts:
	pom.xml
  • Loading branch information
mung3r committed Jul 14, 2016
2 parents 16cd409 + a55eca8 commit b7436e7
Show file tree
Hide file tree
Showing 47 changed files with 252 additions and 265 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: java
jdk: [ oraclejdk7 ]
sudo: false
jdk: [ oraclejdk8 ]
sudo: false
29 changes: 11 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>se.crafted.chrisb</groupId>
<artifactId>ecoCreature</artifactId>
<name>ecoCreature</name>
<version>0.3.0-SNAPSHOT</version>
<version>0.3.2-SNAPSHOT</version>
<description>Player vs. Monster/Enemy Rewards</description>
<url>http://dev.bukkit.org/server-mods/ecocreature/</url>
<inceptionYear>2011</inceptionYear>
Expand All @@ -16,7 +16,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bukkit.version>1.8.7-R0.1-SNAPSHOT</bukkit.version>
<bukkit.version>1.9.4-R0.1-SNAPSHOT</bukkit.version>
<vault.version>1.5</vault.version>
<currentYear>2015</currentYear>
</properties>
Expand Down Expand Up @@ -146,9 +146,9 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.mcstats</groupId>
<groupId>org.mcstats.bukkit</groupId>
<artifactId>metrics</artifactId>
<version>R6</version>
<version>R7</version>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
Expand All @@ -157,15 +157,9 @@
</exclusions>
</dependency>
<dependency>
<groupId>nl.arfie.bukkit.attributes</groupId>
<artifactId>AttributesAPI</artifactId>
<version>1.2</version>
<exclusions>
<exclusion>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</exclusion>
</exclusions>
<groupId>minecraft.spigot.community.michel_0.api</groupId>
<artifactId>ItemAttribAPI</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.herocraftonline.heroes</groupId>
Expand Down Expand Up @@ -260,8 +254,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -309,8 +303,8 @@
<shadedPattern>se.crafted.chrisb.mcstats</shadedPattern>
</relocation>
<relocation>
<pattern>nl.arfie.bukkit.attributes</pattern>
<shadedPattern>se.crafted.chrisb.arfie.bukkit.attributes</shadedPattern>
<pattern>minecraft.spigot.community.michel_0.api</pattern>
<shadedPattern>se.crafted.chrisb.michel_0.api.attributes</shadedPattern>
</relocation>
</relocations>
</configuration>
Expand Down Expand Up @@ -346,7 +340,6 @@
</includes>
<excludes>
<exclude>src/main/java/**/CommandHandler.java</exclude>
<exclude>src/main/java/**/mcstats/Metrics.java</exclude>
</excludes>
</configuration>
<phase>clean</phase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;

import se.crafted.chrisb.ecoCreature.commons.DependencyUtils;
import se.crafted.chrisb.ecoCreature.commons.PluginUtils;
import se.crafted.chrisb.ecoCreature.commons.LoggerUtil;
import se.crafted.chrisb.ecoCreature.drops.categories.AbstractDropCategory;
import se.crafted.chrisb.ecoCreature.drops.categories.CustomDropCategory;
Expand Down Expand Up @@ -182,7 +182,7 @@ private static Collection<PlayerGain> loadGainMultipliers(ConfigurationSection c
gainMultipliers.addAll(RegionGain.parseConfig(config.getConfigurationSection("Gain.WorldGuard")));
gainMultipliers.addAll(RegiosGain.parseConfig(config.getConfigurationSection("Gain.Regios")));
gainMultipliers.addAll(ResidenceGain.parseConfig(config.getConfigurationSection("Gain.Residence")));
if (DependencyUtils.hasFactions()) {
if (PluginUtils.hasFactions()) {
gainMultipliers.addAll(FactionsGain.parseConfig(config.getConfigurationSection("Gain.Factions")));
}
gainMultipliers.addAll(TownyGain.parseConfig(config.getConfigurationSection("Gain.Towny")));
Expand Down Expand Up @@ -268,17 +268,18 @@ private FileConfiguration getConfig(File file) throws IOException, InvalidConfig
private void createConfig(File file) throws IOException
{
boolean success = file.getParentFile().mkdir() && file.createNewFile();

try (InputStream inputStream = plugin.getResource(file.getName()); FileOutputStream outputStream = new FileOutputStream(file)) {
byte[] buffer = new byte[BUFFER_SIZE];
int length;
while ((length = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, length);
}
} catch (IOException e) {
}
catch (IOException e) {
LoggerUtil.getInstance().warning("Could not read config file.");
}

LoggerUtil.getInstance().info("Created config file: " + file.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import se.crafted.chrisb.ecoCreature.commons.DependencyUtils;
import se.crafted.chrisb.ecoCreature.commons.PluginUtils;

public class CommandHandler
{
Expand Down Expand Up @@ -114,8 +114,8 @@ public boolean hasPermission(CommandSender sender, String permString)
}

Player player = (Player) sender;
if (DependencyUtils.hasPermission()) {
return DependencyUtils.getPermission().has(player, permString);
if (PluginUtils.hasPermission()) {
return PluginUtils.getPermission().has(player, permString);
}
return player.hasPermission(permString);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,15 @@ public static boolean isNotSuicide(PlayerDeathEvent event)
{
boolean isNotSuicide = true;

if (event != null && event.getEntity().getLastDamageCause() != null) {
if (event != null && event.getEntity().getLastDamageCause() != null && event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {

if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {

Entity damager = ((EntityDamageByEntityEvent) event.getEntity().getLastDamageCause()).getDamager();
Entity damager = ((EntityDamageByEntityEvent) event.getEntity().getLastDamageCause()).getDamager();

if (damager instanceof Projectile) {
Projectile projectile = (Projectile) damager;
if (projectile.getShooter() instanceof Player) {
Player shooter = (Player) projectile.getShooter();
isNotSuicide = !event.getEntity().getUniqueId().equals(shooter.getUniqueId());
}
if (damager instanceof Projectile) {
Projectile projectile = (Projectile) damager;
if (projectile.getShooter() instanceof Player) {
Player shooter = (Player) projectile.getShooter();
isNotSuicide = !event.getEntity().getUniqueId().equals(shooter.getUniqueId());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

import java.lang.reflect.Field;

import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_9_R2.NBTTagCompound;

import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;

public final class ItemUtils
Expand Down Expand Up @@ -60,7 +60,7 @@ private static NBTTagCompound getTag(ItemStack item)
try {
Field field = CraftItemStack.class.getDeclaredField("handle");
field.setAccessible(true);
return ((net.minecraft.server.v1_8_R3.ItemStack) field.get(item)).getTag();
return ((net.minecraft.server.v1_9_R2.ItemStack) field.get(item)).getTag();
}
catch (Exception ignored) {
}
Expand All @@ -72,11 +72,11 @@ private static ItemStack setTag(ItemStack item, NBTTagCompound tag)
{
CraftItemStack cItem = item instanceof CraftItemStack ? (CraftItemStack) item : CraftItemStack.asCraftCopy(item);

net.minecraft.server.v1_8_R3.ItemStack nmsItem = null;
net.minecraft.server.v1_9_R2.ItemStack nmsItem = null;
try {
Field field = CraftItemStack.class.getDeclaredField("handle");
field.setAccessible(true);
nmsItem = (net.minecraft.server.v1_8_R3.ItemStack) field.get(item);
nmsItem = (net.minecraft.server.v1_9_R2.ItemStack) field.get(item);
}
catch (Exception ignored) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import com.palmergames.bukkit.towny.Towny;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;

public final class DependencyUtils
public final class PluginUtils
{
private static Plugin vaultPlugin;
private static Plugin deathTpPlusPlugin;
Expand All @@ -55,7 +55,7 @@ public final class DependencyUtils
private static Permission permission;
private static Economy economy;

private DependencyUtils()
private PluginUtils()
{
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/se/crafted/chrisb/ecoCreature/drops/CoinDrop.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.bukkit.Location;
import org.bukkit.entity.Player;

import se.crafted.chrisb.ecoCreature.commons.DependencyUtils;
import se.crafted.chrisb.ecoCreature.commons.PluginUtils;
import se.crafted.chrisb.ecoCreature.commons.LoggerUtil;
import se.crafted.chrisb.ecoCreature.messages.Message;
import se.crafted.chrisb.ecoCreature.messages.MessageHandler;
Expand Down Expand Up @@ -116,7 +116,7 @@ public void setCoin(double coin)
@Override
public boolean deliver(Player player)
{
if (!DependencyUtils.hasEconomy() || player == null) {
if (!PluginUtils.hasEconomy() || player == null) {
return false;
}

Expand All @@ -130,7 +130,7 @@ public boolean deliver(Player player)
success = true;

Message message = memberId.equals(player.getUniqueId()) ? getMessage() : getPartyMessage();
addParameter(MessageToken.PLAYER, Bukkit.getOfflinePlayer(memberId).getName()).addParameter(MessageToken.AMOUNT, DependencyUtils.getEconomy().format(Math.abs(amount)));
addParameter(MessageToken.PLAYER, Bukkit.getOfflinePlayer(memberId).getName()).addParameter(MessageToken.AMOUNT, PluginUtils.getEconomy().format(Math.abs(amount)));

MessageHandler handler = new MessageHandler(message, getParameters());
handler.send(memberId);
Expand Down Expand Up @@ -183,15 +183,15 @@ public static double round(double unrounded, int precision)

private void registerAmount(UUID memberId, double amount)
{
if (!DependencyUtils.hasEconomy()) {
if (!PluginUtils.hasEconomy()) {
return;
}

if (amount > 0.0) {
DependencyUtils.getEconomy().depositPlayer(Bukkit.getOfflinePlayer(memberId), amount);
PluginUtils.getEconomy().depositPlayer(Bukkit.getOfflinePlayer(memberId), amount);
}
else if (amount < 0.0) {
DependencyUtils.getEconomy().withdrawPlayer(Bukkit.getOfflinePlayer(memberId), Math.abs(amount));
PluginUtils.getEconomy().withdrawPlayer(Bukkit.getOfflinePlayer(memberId), Math.abs(amount));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ protected static Collection<AbstractDropSource> parseSets(String rewardSection,
NumberRange range = parseRange(setName);
double percentage = parsePercentage(setName);

for (AbstractDropSource dropSource : DropSourceFactory.createSetSources(name, rewardSets)) {
for (AbstractDropSource dropSource : DropSourceFactory.createSetSources(name, config)) {
dropSource.setHuntingRules(huntingRules);
dropSource.setRange(range);
dropSource.setPercentage(percentage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.bukkit.entity.Player;
import org.bukkit.event.Event;

import se.crafted.chrisb.ecoCreature.commons.DependencyUtils;
import se.crafted.chrisb.ecoCreature.commons.PluginUtils;
import se.crafted.chrisb.ecoCreature.drops.sources.AbstractDropSource;
import se.crafted.chrisb.ecoCreature.drops.sources.DropSourceFactory;
import se.crafted.chrisb.ecoCreature.drops.categories.types.HeroesDropType;
Expand All @@ -45,7 +45,7 @@ public HeroesDropCategory(Map<HeroesDropType, Collection<AbstractDropSource>> dr
@Override
protected boolean isValidEvent(Event event)
{
return DependencyUtils.hasHeroes() && event instanceof HeroChangeLevelEvent;
return PluginUtils.hasHeroes() && event instanceof HeroChangeLevelEvent;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.bukkit.entity.Player;
import org.bukkit.event.Event;

import se.crafted.chrisb.ecoCreature.commons.DependencyUtils;
import se.crafted.chrisb.ecoCreature.commons.PluginUtils;
import se.crafted.chrisb.ecoCreature.drops.sources.AbstractDropSource;
import se.crafted.chrisb.ecoCreature.drops.sources.DropSourceFactory;
import se.crafted.chrisb.ecoCreature.drops.categories.types.McMMODropType;
Expand All @@ -45,7 +45,7 @@ public McMMODropCategory(Map<McMMODropType, Collection<AbstractDropSource>> drop
@Override
protected boolean isValidEvent(Event event)
{
return DependencyUtils.hasMcMMO() && event instanceof McMMOPlayerLevelUpEvent;
return PluginUtils.hasMcMMO() && event instanceof McMMOPlayerLevelUpEvent;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.simiancage.DeathTpPlus.events.DeathStreakEvent;
import org.simiancage.DeathTpPlus.events.KillStreakEvent;

import se.crafted.chrisb.ecoCreature.commons.DependencyUtils;
import se.crafted.chrisb.ecoCreature.commons.PluginUtils;
import se.crafted.chrisb.ecoCreature.drops.sources.AbstractDropSource;
import se.crafted.chrisb.ecoCreature.drops.sources.DropSourceFactory;
import se.crafted.chrisb.ecoCreature.drops.categories.types.StreakDropType;
Expand All @@ -45,7 +45,7 @@ public StreakDropCategory(Map<StreakDropType, Collection<AbstractDropSource>> dr
@Override
protected boolean isValidEvent(Event event)
{
return DependencyUtils.hasDeathTpPlus() && (event instanceof DeathStreakEvent || event instanceof KillStreakEvent);
return PluginUtils.hasDeathTpPlus() && (event instanceof DeathStreakEvent || event instanceof KillStreakEvent);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
*/
package se.crafted.chrisb.ecoCreature.drops.chances;

import java.util.Map;
import java.util.Random;

import org.apache.commons.lang.math.NumberRange;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.MemoryConfiguration;

public abstract class AbstractChance implements Chance
{
Expand Down Expand Up @@ -114,4 +117,15 @@ else if (range.getMinimumDouble() > range.getMaximumDouble()) {

return amount;
}


@SuppressWarnings("unchecked")
public static ConfigurationSection createMemoryConfig(Object obj)
{
MemoryConfiguration config = new MemoryConfiguration();
if (obj instanceof Map) {
config.addDefaults((Map<String, Object>) obj);
}
return config;
}
}
Loading

0 comments on commit b7436e7

Please sign in to comment.